Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions cli/src/commands/tasks.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,16 @@ export async function show(args, io) {
["not before", task.notBeforeAt],
["external status", task.externalStatus],
["instruction doc", task.instructionDocId],
]);
io.print("");
if (task.instructionDocId) {
io.print("Before executing this task, read its attached SOP:");
io.print(` dataops kb show ${task.instructionDocId}`);
} else {
io.print("No SOP attached to this task.");
}
io.print("");
fields(io, [
["source docs", task.sourceDocIds],
["instructions", task.instructionsUrl],
["materials", task.materials?.length ? task.materials.map((m) => (m.label ? `${m.label} ${m.url}` : m.url)).join(", ") : ""],
Expand Down
42 changes: 42 additions & 0 deletions cli/test/tasks-sop-hint.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import assert from "node:assert/strict";
import { afterEach, test } from "node:test";
import { captureIo, fakePortal, isolateConfig } from "./helpers.mjs";
isolateConfig();
const originalFetch = globalThis.fetch;
const { run } = await import("../src/cli.mjs");
afterEach(() => { globalThis.fetch = originalFetch; });

const task = { id: "t-1", description: "Synthetic upload task", status: "todo", version: 7,
instructionDocId: "sop.finance.upload-package", sourceDocIds: ["sop.finance.monthly"],
notesLog: [{ text: "Long historical context", createdAt: "2026-01-01" }] };

test("show prominently prompts the directly attached SOP, without fetching or writing", async () => {
const calls = fakePortal({ "GET /api/tasks/t-1": task });
const io = captureIo();
assert.equal(await run(["tasks", "show", "t-1"], io), 0);
const output = io.text();
assert.match(output, /Before executing this task, read its attached SOP:\n dataops kb show sop\.finance\.upload-package/);
assert.ok(output.indexOf("id:") < output.indexOf("Before executing"));
assert.ok(output.indexOf("Before executing") < output.indexOf("source docs:"));
assert.ok(output.indexOf("Before executing") < output.indexOf("notes log:"));
assert.doesNotMatch(output, /dataops kb show sop\.finance\.monthly/);
assert.match(output, /instruction doc:\s+sop\.finance\.upload-package/);
assert.deepEqual(calls.map(c => [c.method, c.route]), [["GET", "/api/tasks/t-1"]]);
});

test("show explicitly states no attached SOP instead of substituting source docs", async () => {
fakePortal({ "GET /api/tasks/t-1": { ...task, instructionDocId: null } });
const io = captureIo();
assert.equal(await run(["tasks", "show", "t-1"], io), 0);
assert.match(io.text(), /No SOP attached to this task\./);
assert.doesNotMatch(io.text(), /dataops kb show/);
});

test("JSON task fields remain unchanged and fetching stays read-only", async () => {
const calls = fakePortal({ "GET /api/tasks/t-1": task });
const io = captureIo();
assert.equal(await run(["tasks", "show", "t-1", "--json"], io), 0);
assert.deepEqual(io.json(), task);
assert.equal(calls.length, 1);
assert.equal(calls[0].method, "GET");
});