@psimona/darkf 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/feedback/2026-10-31-task-list-json.md +26 -0
- package/package.json +1 -1
- package/src/core/index.ts +1 -0
- package/src/core/tasks.test.ts +146 -0
- package/src/core/tasks.ts +158 -0
- package/src/core/types.ts +34 -0
- package/src/kit/status.test.ts +51 -1
- package/src/kit/status.ts +42 -1
- package/workflows/dev-loop/scripts/begin.ts +1 -1
- package/workflows/dev-loop/scripts/finish.ts +10 -2
- package/workflows/dev-loop/workflow.ts +44 -21
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Run feedback — task-list-json
|
|
2
|
+
|
|
3
|
+
- **Date:** 2026-10-31
|
|
4
|
+
- **Engine/workflow:** darkf dev-loop
|
|
5
|
+
- **Run:** 7f95d772-b147-42d8-b40a-1e40b9ce51d5
|
|
6
|
+
- **Final outcome:** merged. Squashed `feature/task-list-json` to master as `feat: task-list-json (task-list-json)`; branch deleted. Confirmed in git log as `02a7aa2`.
|
|
7
|
+
- **Scopes:** TaskList support shipped end to end: `Task`/`TaskList` types in core, hand-written zero-dependency `parseTaskList`, `foldTaskList` in the kit, and a new tasks tab (absent/invalid/valid views, strict done/total, stall warning) in the opencode plugin overlay.
|
|
8
|
+
|
|
9
|
+
## What worked
|
|
10
|
+
|
|
11
|
+
- One pass through the loop: Implement → Check → Fix → Check → Review approved → merged. No retry loops.
|
|
12
|
+
- All gates green at merge: secret-scan, typecheck, lint, arch-check, darkf 179 tests, plugin 12 tests, coverage at ~96% lines.
|
|
13
|
+
- Implementation matched the spec field for field (`docs/specs/task-list-json/spec.md`); the reviewer verified types, decisions, and tests against it and approved with no change requests.
|
|
14
|
+
- `parseTaskList` narrowing is proven by tests: legacy `moscow` and task-side `requirements` are dropped, bad unions and non-object roots rejected with path-prefixed errors.
|
|
15
|
+
- The plugin reads `tasks.json` via the existing 1s poll plus an `fs.watch` with the same retry-until-exists pattern as the journal watcher; teardown cleans up both.
|
|
16
|
+
|
|
17
|
+
## Failures and root causes
|
|
18
|
+
|
|
19
|
+
1. First Check gate failed on a biome format error in `darkf/workflows/dev-loop/scripts/finish.ts:17` (the `ALLOWED` array needed multi-line formatting). Root cause: this feature's own retarget commit (a054445) edited the finish script and committed it unformatted. The Implement summary then mislabeled it as "pre-existing and outside allowed paths". Cost: one extra Fix → Check cycle, about 3 minutes per journal timestamps (fail at 1793474949114, pass at 1793475128840).
|
|
20
|
+
|
|
21
|
+
## Notes
|
|
22
|
+
|
|
23
|
+
- The dev-loop finish script (`darkf/workflows/dev-loop/scripts/finish.ts`) sits in the lint path. Any run that retargets it must format it before committing, or the Check gate will fail.
|
|
24
|
+
- When a failing file is outside the feature's allowed paths, check `git log`/`git blame` before calling it pre-existing. Here the implementing agent's claim was wrong and the fix step had to re-derive the cause.
|
|
25
|
+
- The spec's mention of item-loop.ts refers to the separate, not-yet-implemented item-loop-convention spec. No migration was required for this run. Future item-loop work will need it.
|
|
26
|
+
- No tasks.json was produced by this run itself; the feature only adds the consumer side. Exercise the producer path in a later run.
|
package/package.json
CHANGED
package/src/core/index.ts
CHANGED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { parseTaskList } from "./tasks.ts";
|
|
3
|
+
import type { TaskList } from "./types.ts";
|
|
4
|
+
|
|
5
|
+
const VALID: TaskList = {
|
|
6
|
+
id: "ips-csv-load",
|
|
7
|
+
spec: { prd: "docs/specs/x/prd.md", design: "docs/specs/x/design.md" },
|
|
8
|
+
requirements: [
|
|
9
|
+
{ id: "REQ-1", kind: "req", text: "load the csv", priority: "must" },
|
|
10
|
+
{ id: "NFR-2", kind: "nfr", text: "under 10s", priority: "should" },
|
|
11
|
+
],
|
|
12
|
+
tasks: [
|
|
13
|
+
{ id: "T-1", title: "wire the loader", status: "done", satisfies: ["REQ-1"], priority: "must" },
|
|
14
|
+
{ id: "T-2", title: "bench it", status: "in-progress", satisfies: ["NFR-2"] },
|
|
15
|
+
{ id: "T-3", title: "write it up", status: "pending" },
|
|
16
|
+
],
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
test("parseTaskList on a valid list returns it narrowed, unknown extra fields ignored", () => {
|
|
20
|
+
const parsed = parseTaskList({
|
|
21
|
+
...VALID,
|
|
22
|
+
tasks: [...VALID.tasks, { id: "T-9", title: "future", status: "failed", note: "extra" }],
|
|
23
|
+
});
|
|
24
|
+
expect(parsed).not.toHaveProperty("error");
|
|
25
|
+
expect(parsed).toEqual({
|
|
26
|
+
...VALID,
|
|
27
|
+
tasks: [...VALID.tasks, { id: "T-9", title: "future", status: "failed" }],
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test("parseTaskList accepts the minimal shape: only id and tasks, everything else optional", () => {
|
|
32
|
+
expect(parseTaskList({ id: "x", tasks: [] })).toEqual({ id: "x", tasks: [] });
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
describe("parseTaskList narrowing", () => {
|
|
36
|
+
test("non-object roots are rejected", () => {
|
|
37
|
+
expect(parseTaskList(null)).toHaveProperty("error");
|
|
38
|
+
expect(parseTaskList("nope")).toHaveProperty("error");
|
|
39
|
+
expect(parseTaskList([VALID])).toHaveProperty("error");
|
|
40
|
+
expect(parseTaskList(undefined)).toHaveProperty("error");
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test("missing or wrong-typed id", () => {
|
|
44
|
+
const { id: _id, ...noId } = VALID;
|
|
45
|
+
expect(parseTaskList(noId)).toHaveProperty("error");
|
|
46
|
+
expect(parseTaskList({ ...VALID, id: 7 })).toHaveProperty("error");
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test("wrong-typed spec fields", () => {
|
|
50
|
+
expect(parseTaskList({ ...VALID, spec: "docs" })).toHaveProperty("error");
|
|
51
|
+
expect(parseTaskList({ ...VALID, spec: { prd: 3 } })).toHaveProperty("error");
|
|
52
|
+
expect(parseTaskList({ ...VALID, spec: { design: [] } })).toHaveProperty("error");
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test("missing or wrong-typed fields on a task", () => {
|
|
56
|
+
const missingTitle = { id: "T-1", status: "pending" };
|
|
57
|
+
expect(parseTaskList({ id: "x", tasks: [missingTitle] })).toHaveProperty("error");
|
|
58
|
+
expect(
|
|
59
|
+
parseTaskList({ id: "x", tasks: [{ id: 1, title: "t", status: "pending" }] }),
|
|
60
|
+
).toHaveProperty("error");
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test("bad status union", () => {
|
|
64
|
+
const parsed = parseTaskList({
|
|
65
|
+
id: "x",
|
|
66
|
+
tasks: [{ id: "T-1", title: "t", status: "archived" }],
|
|
67
|
+
});
|
|
68
|
+
expect(parsed).toHaveProperty("error");
|
|
69
|
+
expect((parsed as { error: string }).error).toContain("tasks[0].status");
|
|
70
|
+
expect((parsed as { error: string }).error).toContain(
|
|
71
|
+
'"pending" | "in-progress" | "done" | "failed"',
|
|
72
|
+
);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test("bad priority union, on both tasks and requirements", () => {
|
|
76
|
+
const taskSide = parseTaskList({
|
|
77
|
+
id: "x",
|
|
78
|
+
tasks: [{ id: "T-1", title: "t", status: "pending", priority: "Must" }],
|
|
79
|
+
});
|
|
80
|
+
expect((taskSide as { error: string }).error).toContain("tasks[0].priority");
|
|
81
|
+
expect((taskSide as { error: string }).error).toContain(
|
|
82
|
+
'"must" | "should" | "could" | "won\'t"',
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
const requirementSide = parseTaskList({
|
|
86
|
+
id: "x",
|
|
87
|
+
requirements: [{ id: "REQ-1", kind: "req", text: "t", priority: "SHOULD" }],
|
|
88
|
+
tasks: [],
|
|
89
|
+
});
|
|
90
|
+
expect((requirementSide as { error: string }).error).toContain("requirements[0].priority");
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test("bad requirement kind union and wrong-typed requirement fields", () => {
|
|
94
|
+
const badKind = parseTaskList({
|
|
95
|
+
id: "x",
|
|
96
|
+
requirements: [{ id: "REQ-1", kind: "story", text: "t" }],
|
|
97
|
+
tasks: [],
|
|
98
|
+
});
|
|
99
|
+
expect((badKind as { error: string }).error).toContain("requirements[0].kind");
|
|
100
|
+
|
|
101
|
+
const noText = parseTaskList({
|
|
102
|
+
id: "x",
|
|
103
|
+
requirements: [{ id: "REQ-1", kind: "req" }],
|
|
104
|
+
tasks: [],
|
|
105
|
+
});
|
|
106
|
+
expect(noText).toHaveProperty("error");
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
test("satisfies must be an array of strings", () => {
|
|
110
|
+
const notArray = parseTaskList({
|
|
111
|
+
id: "x",
|
|
112
|
+
tasks: [{ id: "T-1", title: "t", status: "pending", satisfies: "REQ-1" }],
|
|
113
|
+
});
|
|
114
|
+
expect((notArray as { error: string }).error).toContain("tasks[0].satisfies");
|
|
115
|
+
|
|
116
|
+
const notStrings = parseTaskList({
|
|
117
|
+
id: "x",
|
|
118
|
+
tasks: [{ id: "T-1", title: "t", status: "pending", satisfies: ["REQ-1", 2] }],
|
|
119
|
+
});
|
|
120
|
+
expect((notStrings as { error: string }).error).toContain("tasks[0].satisfies[1]");
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
test("tasks not an array", () => {
|
|
124
|
+
const parsed = parseTaskList({ id: "x", tasks: "T-1,T-2" });
|
|
125
|
+
expect(parsed).toHaveProperty("error");
|
|
126
|
+
expect((parsed as { error: string }).error).toContain("tasks:");
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
test("requirements not an array", () => {
|
|
130
|
+
expect(parseTaskList({ id: "x", requirements: {}, tasks: [] })).toHaveProperty("error");
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
test("the legacy consumer shape has no tolerance: task-side requirements are not read", () => {
|
|
134
|
+
// Pre-migration consumer tasks carry `requirements` instead of `satisfies`
|
|
135
|
+
// — the validator narrows to the standard only; migration is the writer's
|
|
136
|
+
// one-shot job (Decisions: Consumer repo migrates to the standard).
|
|
137
|
+
const legacy = parseTaskList({
|
|
138
|
+
id: "x",
|
|
139
|
+
tasks: [{ id: "T-1", requirements: ["REQ-1"], title: "t", status: "pending" }],
|
|
140
|
+
});
|
|
141
|
+
expect(legacy).toEqual({
|
|
142
|
+
id: "x",
|
|
143
|
+
tasks: [{ id: "T-1", title: "t", status: "pending" }],
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
});
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import type { Task, TaskList, TaskPriority, TaskRequirement, TaskStatus } from "./types.ts";
|
|
2
|
+
|
|
3
|
+
// Hand-written narrowing of unknown JSON to a TaskList (docs/specs/task-list-json/spec.md,
|
|
4
|
+
// Decisions: Validation) — zero deps, no dual-schema tolerance: the legacy
|
|
5
|
+
// names (`moscow`, task-side `requirements`) are simply not read, and the
|
|
6
|
+
// result is either a TaskList or `{ error }`. The item-loop path and the
|
|
7
|
+
// OpenCode plugin share this one validator, so a malformed list can never
|
|
8
|
+
// crash a consumer.
|
|
9
|
+
//
|
|
10
|
+
// Unknown extra fields are ignored — the schema is narrowed to, not
|
|
11
|
+
// enforced as a closed record.
|
|
12
|
+
|
|
13
|
+
const TASK_STATUSES: readonly TaskStatus[] = ["pending", "in-progress", "done", "failed"];
|
|
14
|
+
const TASK_PRIORITIES: readonly TaskPriority[] = ["must", "should", "could", "won't"];
|
|
15
|
+
const REQUIREMENT_KINDS: readonly TaskRequirement["kind"][] = ["req", "nfr", "ng"];
|
|
16
|
+
|
|
17
|
+
function isObject(value: unknown): value is Record<string, unknown> {
|
|
18
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function describe(value: unknown): string {
|
|
22
|
+
if (value === null) return "null";
|
|
23
|
+
if (value === undefined) return "undefined";
|
|
24
|
+
if (Array.isArray(value)) return "an array";
|
|
25
|
+
return `a ${typeof value}`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// The failure half of every sub-parse below — never checked with `in` on the
|
|
29
|
+
// value itself, which throws on the string primitives the success half is.
|
|
30
|
+
function isError(x: unknown): x is { error: string } {
|
|
31
|
+
return typeof x === "object" && x !== null && "error" in x;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function oneOf(value: unknown, allowed: readonly string[], at: string): string | undefined {
|
|
35
|
+
if (typeof value === "string" && (allowed as readonly string[]).includes(value)) return undefined;
|
|
36
|
+
const quoted = allowed.map((a) => JSON.stringify(a)).join(" | ");
|
|
37
|
+
return `${at}: expected one of ${quoted}, got ${JSON.stringify(value) ?? describe(value)}`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function parsePriority(value: unknown, at: string): TaskPriority | { error: string } {
|
|
41
|
+
const err = oneOf(value, TASK_PRIORITIES, at);
|
|
42
|
+
return err === undefined ? (value as TaskPriority) : { error: err };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function parseStringArray(value: unknown, at: string): string[] | { error: string } {
|
|
46
|
+
if (!Array.isArray(value)) return { error: `${at}: expected an array, got ${describe(value)}` };
|
|
47
|
+
for (const [i, entry] of value.entries()) {
|
|
48
|
+
if (typeof entry !== "string") {
|
|
49
|
+
return { error: `${at}[${i}]: expected a string, got ${describe(entry)}` };
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return value;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function parseRequirement(value: unknown, index: number): TaskRequirement | { error: string } {
|
|
56
|
+
const at = `requirements[${index}]`;
|
|
57
|
+
if (!isObject(value)) return { error: `${at}: expected an object, got ${describe(value)}` };
|
|
58
|
+
if (typeof value.id !== "string") {
|
|
59
|
+
return { error: `${at}.id: expected a string, got ${describe(value.id)}` };
|
|
60
|
+
}
|
|
61
|
+
const kindErr = oneOf(value.kind, REQUIREMENT_KINDS, `${at}.kind`);
|
|
62
|
+
if (kindErr !== undefined) return { error: kindErr };
|
|
63
|
+
if (typeof value.text !== "string") {
|
|
64
|
+
return { error: `${at}.text: expected a string, got ${describe(value.text)}` };
|
|
65
|
+
}
|
|
66
|
+
const requirement: TaskRequirement = {
|
|
67
|
+
id: value.id,
|
|
68
|
+
kind: value.kind as TaskRequirement["kind"],
|
|
69
|
+
text: value.text,
|
|
70
|
+
};
|
|
71
|
+
if (value.priority !== undefined) {
|
|
72
|
+
const priority = parsePriority(value.priority, `${at}.priority`);
|
|
73
|
+
if (isError(priority)) return priority;
|
|
74
|
+
requirement.priority = priority;
|
|
75
|
+
}
|
|
76
|
+
return requirement;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function parseTask(value: unknown, index: number): Task | { error: string } {
|
|
80
|
+
const at = `tasks[${index}]`;
|
|
81
|
+
if (!isObject(value)) return { error: `${at}: expected an object, got ${describe(value)}` };
|
|
82
|
+
if (typeof value.id !== "string") {
|
|
83
|
+
return { error: `${at}.id: expected a string, got ${describe(value.id)}` };
|
|
84
|
+
}
|
|
85
|
+
if (typeof value.title !== "string") {
|
|
86
|
+
return { error: `${at}.title: expected a string, got ${describe(value.title)}` };
|
|
87
|
+
}
|
|
88
|
+
const statusErr = oneOf(value.status, TASK_STATUSES, `${at}.status`);
|
|
89
|
+
if (statusErr !== undefined) return { error: statusErr };
|
|
90
|
+
const task: Task = { id: value.id, title: value.title, status: value.status as TaskStatus };
|
|
91
|
+
if (value.satisfies !== undefined) {
|
|
92
|
+
const satisfies = parseStringArray(value.satisfies, `${at}.satisfies`);
|
|
93
|
+
if (isError(satisfies)) return satisfies;
|
|
94
|
+
task.satisfies = satisfies;
|
|
95
|
+
}
|
|
96
|
+
if (value.priority !== undefined) {
|
|
97
|
+
const priority = parsePriority(value.priority, `${at}.priority`);
|
|
98
|
+
if (isError(priority)) return priority;
|
|
99
|
+
task.priority = priority;
|
|
100
|
+
}
|
|
101
|
+
return task;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function parseTaskList(json: unknown): TaskList | { error: string } {
|
|
105
|
+
if (!isObject(json)) {
|
|
106
|
+
return { error: `task list: expected an object, got ${describe(json)}` };
|
|
107
|
+
}
|
|
108
|
+
if (typeof json.id !== "string") {
|
|
109
|
+
return { error: `id: expected a string, got ${describe(json.id)}` };
|
|
110
|
+
}
|
|
111
|
+
const list: TaskList = { id: json.id, tasks: [] };
|
|
112
|
+
|
|
113
|
+
if (json.spec !== undefined) {
|
|
114
|
+
if (!isObject(json.spec)) {
|
|
115
|
+
return { error: `spec: expected an object, got ${describe(json.spec)}` };
|
|
116
|
+
}
|
|
117
|
+
const spec: TaskList["spec"] = {};
|
|
118
|
+
if (json.spec.prd !== undefined) {
|
|
119
|
+
if (typeof json.spec.prd !== "string") {
|
|
120
|
+
return { error: `spec.prd: expected a string, got ${describe(json.spec.prd)}` };
|
|
121
|
+
}
|
|
122
|
+
spec.prd = json.spec.prd;
|
|
123
|
+
}
|
|
124
|
+
if (json.spec.design !== undefined) {
|
|
125
|
+
if (typeof json.spec.design !== "string") {
|
|
126
|
+
return { error: `spec.design: expected a string, got ${describe(json.spec.design)}` };
|
|
127
|
+
}
|
|
128
|
+
spec.design = json.spec.design;
|
|
129
|
+
}
|
|
130
|
+
list.spec = spec;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (json.requirements !== undefined) {
|
|
134
|
+
if (!Array.isArray(json.requirements)) {
|
|
135
|
+
return { error: `requirements: expected an array, got ${describe(json.requirements)}` };
|
|
136
|
+
}
|
|
137
|
+
const requirements: TaskRequirement[] = [];
|
|
138
|
+
for (const [i, entry] of json.requirements.entries()) {
|
|
139
|
+
const requirement = parseRequirement(entry, i);
|
|
140
|
+
if (isError(requirement)) return requirement;
|
|
141
|
+
requirements.push(requirement);
|
|
142
|
+
}
|
|
143
|
+
list.requirements = requirements;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (!Array.isArray(json.tasks)) {
|
|
147
|
+
return { error: `tasks: expected an array, got ${describe(json.tasks)}` };
|
|
148
|
+
}
|
|
149
|
+
const tasks: Task[] = [];
|
|
150
|
+
for (const [i, entry] of json.tasks.entries()) {
|
|
151
|
+
const task = parseTask(entry, i);
|
|
152
|
+
if (isError(task)) return task;
|
|
153
|
+
tasks.push(task);
|
|
154
|
+
}
|
|
155
|
+
list.tasks = tasks;
|
|
156
|
+
|
|
157
|
+
return list;
|
|
158
|
+
}
|
package/src/core/types.ts
CHANGED
|
@@ -277,3 +277,37 @@ export interface RunResult {
|
|
|
277
277
|
trace: StepTrace[];
|
|
278
278
|
node: NodeStatus;
|
|
279
279
|
}
|
|
280
|
+
|
|
281
|
+
// --- Task lists ---
|
|
282
|
+
//
|
|
283
|
+
// One shared vocabulary for plan/dispatch task lists (docs/specs/task-list-json/spec.md):
|
|
284
|
+
// workflows write it, `parseTaskList` narrows it, the OpenCode plugin renders it.
|
|
285
|
+
// Lowercase MoSCoW and `satisfies` are the locked names — the validator has no
|
|
286
|
+
// tolerance for the legacy shapes (`moscow`, task-side `requirements`).
|
|
287
|
+
|
|
288
|
+
export type TaskStatus = "pending" | "in-progress" | "done" | "failed";
|
|
289
|
+
export type TaskPriority = "must" | "should" | "could" | "won't";
|
|
290
|
+
|
|
291
|
+
export interface Task {
|
|
292
|
+
id: string;
|
|
293
|
+
title: string;
|
|
294
|
+
status: TaskStatus;
|
|
295
|
+
/** Requirement ids this task satisfies, when the list carries requirements. */
|
|
296
|
+
satisfies?: string[];
|
|
297
|
+
priority?: TaskPriority;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
export interface TaskRequirement {
|
|
301
|
+
id: string; // "REQ-1", "NFR-2", "NG-1"
|
|
302
|
+
kind: "req" | "nfr" | "ng";
|
|
303
|
+
text: string;
|
|
304
|
+
priority?: TaskPriority;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export interface TaskList {
|
|
308
|
+
id: string;
|
|
309
|
+
/** Paths to the spec documents the tasks implement, when present. */
|
|
310
|
+
spec?: { prd?: string; design?: string };
|
|
311
|
+
requirements?: TaskRequirement[];
|
|
312
|
+
tasks: Task[];
|
|
313
|
+
}
|
package/src/kit/status.test.ts
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
type CrashReason,
|
|
4
|
+
EXIT,
|
|
5
|
+
FAILED,
|
|
6
|
+
type NodeEvent,
|
|
7
|
+
type NodeResult,
|
|
8
|
+
type TaskList,
|
|
9
|
+
} from "../core/index.ts";
|
|
3
10
|
import {
|
|
4
11
|
agentStallWarning,
|
|
5
12
|
classifyTerminal,
|
|
6
13
|
foldJournal,
|
|
7
14
|
foldReport,
|
|
15
|
+
foldTaskList,
|
|
8
16
|
nudgeWarning,
|
|
9
17
|
stallWarning,
|
|
10
18
|
} from "./status.ts";
|
|
@@ -421,3 +429,45 @@ describe("foldReport", () => {
|
|
|
421
429
|
});
|
|
422
430
|
});
|
|
423
431
|
});
|
|
432
|
+
|
|
433
|
+
describe("foldTaskList", () => {
|
|
434
|
+
const LIST: TaskList = {
|
|
435
|
+
id: "x",
|
|
436
|
+
tasks: [
|
|
437
|
+
{ id: "T-1", title: "a", status: "done" },
|
|
438
|
+
{ id: "T-2", title: "b", status: "done" },
|
|
439
|
+
{ id: "T-3", title: "c", status: "in-progress" },
|
|
440
|
+
{ id: "T-4", title: "d", status: "pending" },
|
|
441
|
+
{ id: "T-5", title: "e", status: "failed" },
|
|
442
|
+
],
|
|
443
|
+
};
|
|
444
|
+
|
|
445
|
+
test("strict counts: done only; failed/pending/in-progress are all not-done", () => {
|
|
446
|
+
expect(foldTaskList(LIST).done).toBe(2);
|
|
447
|
+
expect(foldTaskList(LIST).total).toBe(5);
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
test("current is the file's in-progress task, null when nothing is in-progress", () => {
|
|
451
|
+
expect(foldTaskList(LIST).current?.id).toBe("T-3");
|
|
452
|
+
expect(
|
|
453
|
+
foldTaskList({ id: "x", tasks: [{ id: "T-1", title: "a", status: "pending" }] }).current,
|
|
454
|
+
).toBeNull();
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
test("no stall when exactly one (or zero) task is in-progress", () => {
|
|
458
|
+
expect(foldTaskList(LIST).stall).toBeNull();
|
|
459
|
+
expect(foldTaskList({ id: "x", tasks: [] }).stall).toBeNull();
|
|
460
|
+
});
|
|
461
|
+
|
|
462
|
+
test("stall when the list names more than one current task", () => {
|
|
463
|
+
const digest = foldTaskList({
|
|
464
|
+
id: "x",
|
|
465
|
+
tasks: [
|
|
466
|
+
{ id: "T-1", title: "a", status: "in-progress" },
|
|
467
|
+
{ id: "T-2", title: "b", status: "in-progress" },
|
|
468
|
+
],
|
|
469
|
+
});
|
|
470
|
+
expect(digest.stall).toContain("2 tasks in-progress");
|
|
471
|
+
expect(digest.current?.id).toBe("T-1");
|
|
472
|
+
});
|
|
473
|
+
});
|
package/src/kit/status.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type CrashReason,
|
|
3
|
+
DONE,
|
|
4
|
+
FAILED,
|
|
5
|
+
type NodeResult,
|
|
6
|
+
parseEventLog,
|
|
7
|
+
type Task,
|
|
8
|
+
type TaskList,
|
|
9
|
+
} from "../core/index.ts";
|
|
2
10
|
import { journalTerminal, type RegistryStatus } from "./registry.ts";
|
|
3
11
|
|
|
4
12
|
export interface JournalDigest {
|
|
@@ -107,6 +115,39 @@ export function foldJournal(journalText: string): JournalDigest {
|
|
|
107
115
|
return digest;
|
|
108
116
|
}
|
|
109
117
|
|
|
118
|
+
// --- task lists (docs/specs/task-list-json/spec.md) ---
|
|
119
|
+
|
|
120
|
+
export interface TaskListDigest {
|
|
121
|
+
/** Strict count: only `done` tasks — pending, in-progress, and failed all
|
|
122
|
+
* count as not-done, so the plugin's `nn/mm` tab title is honest. */
|
|
123
|
+
done: number;
|
|
124
|
+
total: number;
|
|
125
|
+
/** The task the file says the run is on — its `in-progress` status is
|
|
126
|
+
* authoritative (no journal join); `null` when nothing is in-progress. */
|
|
127
|
+
current: Task | null;
|
|
128
|
+
/** Non-null only when the list is incoherent about "where the run is":
|
|
129
|
+
* more than one task in-progress. A `TaskList` carries no timestamps, so
|
|
130
|
+
* a time-based stall isn't derivable here — staleness of the current row
|
|
131
|
+
* stays covered by the workflow view's own stall warning. */
|
|
132
|
+
stall: string | null;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Pure fold over a parsed TaskList for rendering: done/total counts, the
|
|
136
|
+
// current in-progress item, and stall state. Never throws — input is an
|
|
137
|
+
// already-narrowed TaskList (see `parseTaskList`).
|
|
138
|
+
export function foldTaskList(list: TaskList): TaskListDigest {
|
|
139
|
+
const inProgress = list.tasks.filter((t) => t.status === "in-progress");
|
|
140
|
+
return {
|
|
141
|
+
done: list.tasks.filter((t) => t.status === "done").length,
|
|
142
|
+
total: list.tasks.length,
|
|
143
|
+
current: inProgress[0] ?? null,
|
|
144
|
+
stall:
|
|
145
|
+
inProgress.length > 1
|
|
146
|
+
? `${inProgress.length} tasks in-progress — expected one; the list's current position is ambiguous`
|
|
147
|
+
: null,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
110
151
|
export type TerminalState =
|
|
111
152
|
| "succeeded"
|
|
112
153
|
| "failed"
|
|
@@ -5,7 +5,7 @@ import type { DispatchInfo } from "@psimona/darkf/src/core/index.ts";
|
|
|
5
5
|
// rides along on the branch — Finish commits it there before the squash.
|
|
6
6
|
// The slug is a workflow-file constant for the pilot; editing this file per
|
|
7
7
|
// feature is the contract until engine-side input plumbing exists.
|
|
8
|
-
const FEATURE = "
|
|
8
|
+
const FEATURE = "task-list-json";
|
|
9
9
|
|
|
10
10
|
function sh(...args: string[]): [string, number] {
|
|
11
11
|
const proc = Bun.spawnSync(args, { stdout: "pipe", stderr: "pipe" });
|
|
@@ -13,8 +13,16 @@ import type { DispatchInfo, NodeResult } from "@psimona/darkf/src/core/index.ts"
|
|
|
13
13
|
// - refuses unless master is an ancestor of the branch (master must not
|
|
14
14
|
// have moved mid-run — the only case where the squash could conflict);
|
|
15
15
|
// - rolls back (reset --hard + checkout back) on any git failure.
|
|
16
|
-
const FEATURE = "
|
|
17
|
-
const ALLOWED = [
|
|
16
|
+
const FEATURE = "task-list-json";
|
|
17
|
+
const ALLOWED = [
|
|
18
|
+
"docs/",
|
|
19
|
+
"darkf/src/",
|
|
20
|
+
"darkf-opencode-plugin/",
|
|
21
|
+
"ROADMAP.md",
|
|
22
|
+
"README.md",
|
|
23
|
+
"site/",
|
|
24
|
+
"darkf/workflows/",
|
|
25
|
+
];
|
|
18
26
|
|
|
19
27
|
function sh(...args: string[]): [string, number] {
|
|
20
28
|
const proc = Bun.spawnSync(args, { stdout: "pipe", stderr: "pipe" });
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { DONE, type WorkflowDef } from "@psimona/darkf/src/core/index.ts";
|
|
2
2
|
import { opencodeRunner } from "@psimona/darkf/src/kit/agents/opencode.ts";
|
|
3
3
|
|
|
4
|
-
// dev-loop — begin → implement → check → review → finish(squash) →
|
|
4
|
+
// dev-loop — begin → implement → check → review → document → finish(squash) →
|
|
5
|
+
// feedback.
|
|
5
6
|
//
|
|
6
7
|
// The darkf-on-darkf pilot, expanded after its first real run built the CLI
|
|
7
8
|
// self-update feature (docs/specs/self-update/). Shape ported from
|
|
@@ -24,7 +25,8 @@ import { opencodeRunner } from "@psimona/darkf/src/kit/agents/opencode.ts";
|
|
|
24
25
|
// Implement prompt). No other git automation: the human curates what the
|
|
25
26
|
// workflow leaves behind (spec archive, roadmap entry, feedback note).
|
|
26
27
|
//
|
|
27
|
-
// The implementer, fixer, and
|
|
28
|
+
// The implementer, fixer, reviewer, and documenter are separate dispatches.
|
|
29
|
+
// Their only
|
|
28
30
|
// shared channels are the repo itself (files, git diff, the spec docs) and
|
|
29
31
|
// the one-hop handoff — matching PHILOSOPHY.md: nothing rides along for
|
|
30
32
|
// free.
|
|
@@ -32,8 +34,8 @@ import { opencodeRunner } from "@psimona/darkf/src/kit/agents/opencode.ts";
|
|
|
32
34
|
export const agentRunner = opencodeRunner;
|
|
33
35
|
|
|
34
36
|
const MODEL = "zai-coding-plan/glm-5.3-flash";
|
|
35
|
-
const RUN_DATE = "2026-10-
|
|
36
|
-
const FEATURE = "
|
|
37
|
+
const RUN_DATE = "2026-10-31";
|
|
38
|
+
const FEATURE = "task-list-json";
|
|
37
39
|
|
|
38
40
|
export const workflow: WorkflowDef = {
|
|
39
41
|
initial: "Begin",
|
|
@@ -46,10 +48,11 @@ export const workflow: WorkflowDef = {
|
|
|
46
48
|
},
|
|
47
49
|
Loop: {
|
|
48
50
|
initial: "Implement",
|
|
49
|
-
// The normal path is one cycle (Implement → Check → Review →
|
|
50
|
-
// Each Fix → Check re-entry costs another.
|
|
51
|
-
// fix rounds
|
|
52
|
-
|
|
51
|
+
// The normal path is one cycle (Implement → Check → Review → Document
|
|
52
|
+
// → Finish). Each Fix → Check re-entry costs another. 8 leaves room
|
|
53
|
+
// for two fix rounds including the terminal Document dispatch before
|
|
54
|
+
// the engine calls the run stuck.
|
|
55
|
+
maxCycles: 8,
|
|
53
56
|
states: {
|
|
54
57
|
Implement: {
|
|
55
58
|
type: "agent",
|
|
@@ -57,16 +60,18 @@ export const workflow: WorkflowDef = {
|
|
|
57
60
|
retries: 1,
|
|
58
61
|
prompt: `Implement the ${FEATURE} feature in this repository.
|
|
59
62
|
|
|
60
|
-
First read docs/specs/${FEATURE}/
|
|
63
|
+
First read docs/specs/${FEATURE}/spec.md. It is the contract: its Design sketch and both Decisions sections are locked — implement exactly what they specify, nothing more.
|
|
61
64
|
|
|
62
|
-
Resume semantics: if the working tree already implements the spec, verify that instead of re-implementing — read the existing darkf/src/
|
|
65
|
+
Resume semantics: if the working tree already implements the spec, verify that instead of re-implementing — read the existing darkf/src/core/tasks.ts and darkf-opencode-plugin/src/digest.ts, confirm they match the spec, and finish "implemented" without rewriting.
|
|
63
66
|
|
|
64
67
|
Deliverables (when not already present):
|
|
65
|
-
-
|
|
66
|
-
-
|
|
67
|
-
-
|
|
68
|
+
- the TaskList type family in darkf/src/core/types.ts per the spec's Design sketch (TaskStatus, TaskPriority, Task, TaskRequirement, TaskList), re-exported from darkf/src/core/index.ts
|
|
69
|
+
- parseTaskList in darkf/src/core/tasks.ts: hand-written, zero-dependency, narrowing unknown JSON to TaskList | { error } (Decisions: Validation)
|
|
70
|
+
- foldTaskList alongside foldJournal in darkf/src/kit/status.ts: a pure function returning done/total counts, the current in-progress item, and stall state
|
|
71
|
+
- the plugin (darkf-opencode-plugin/src/): TaskListView in digest.ts; store.ts reads .darkf/run/<runId>/tasks.json on the existing poll with an fs.watch next to the journal watcher; overlay.tsx grows a tab bar — tab "workflow" (today's PlanGraph, unchanged, the default) and tab "tasks nn/mm" (strict done/total in the title, hidden while tasks.json is absent, "?" counter plus the inline parse error when invalid); task rows per the plugin Decisions (glyph + id + title, "!" before the title for must priority, the active row's dim "↳ REQ-…" satisfies line, ○ pending / ● in-progress accent bold / ✓ done dim / ✗ failed error); keys "1"/"2" and clicking a tab title switch tabs; the supervisor pane stays below, shared by both tabs
|
|
72
|
+
- tests: parseTaskList narrowing cases (valid list, missing/wrong-typed fields, bad status and priority unions, tasks not an array), foldTaskList counts/current/stall, and the TaskListView digest in darkf-opencode-plugin/src/digest.test.ts
|
|
68
73
|
|
|
69
|
-
Follow the existing code style of darkf/src/
|
|
74
|
+
Follow the existing code style of darkf/src/kit/status.ts and darkf-opencode-plugin/src/. Do not commit. Do not touch files outside darkf/src/, darkf-opencode-plugin/src/, and docs/specs/${FEATURE}/.
|
|
70
75
|
|
|
71
76
|
Finish with event "implemented". If the spec cannot be implemented as written, finish with event "blocked" and put the reason in the output. If a review demand contradicts the spec, finish with event "disputed" and ground the objection in the spec text.`,
|
|
72
77
|
on: { implemented: "Check", blocked: DONE, disputed: DONE },
|
|
@@ -83,7 +88,7 @@ Finish with event "implemented". If the spec cannot be implemented as written, f
|
|
|
83
88
|
retries: 1,
|
|
84
89
|
prompt: `You are repairing the ${FEATURE} implementation after a failed gate.
|
|
85
90
|
|
|
86
|
-
The handoff you received carries either the failing tail of "bun run check" or the reviewer's change list. Read docs/specs/${FEATURE}/
|
|
91
|
+
The handoff you received carries either the failing tail of "bun run check" or the reviewer's change list. Read docs/specs/${FEATURE}/spec.md for the contract. Fix the code minimally. Do not redesign. Do not commit. Do not touch files outside darkf/src/ and darkf-opencode-plugin/src/.
|
|
87
92
|
|
|
88
93
|
Finish with event "fixed". If the failure exposes a spec defect you cannot resolve in code, finish with event "blocked" and the reason. If the demand contradicts the spec, finish with event "disputed" and ground the objection in the spec text.`,
|
|
89
94
|
on: { fixed: "Check", blocked: DONE, disputed: DONE },
|
|
@@ -94,16 +99,34 @@ Finish with event "fixed". If the failure exposes a spec defect you cannot resol
|
|
|
94
99
|
retries: 1,
|
|
95
100
|
prompt: `You are an independent reviewer. Do not modify any files.
|
|
96
101
|
|
|
97
|
-
Verify the working tree against docs/specs/${FEATURE}/
|
|
102
|
+
Verify the working tree against docs/specs/${FEATURE}/spec.md:
|
|
98
103
|
- inspect git status --porcelain in addition to git diff — agent-authored new files are invisible to git diff alone
|
|
99
|
-
- check
|
|
100
|
-
- check
|
|
101
|
-
- you may run bun test darkf/src/
|
|
104
|
+
- check the types match the spec's Design sketch field for field, and that both Decisions sections are each reflected in code (parseTaskList zero-dep narrowing; tasks.json read from .darkf/run/<runId>/; satisfies + lowercase MoSCoW; row format, glyph mapping, strict done/total counter, hidden-when-absent tab, file-status active row)
|
|
105
|
+
- check the test suites cover the spec: parseTaskList narrowing, foldTaskList, and the TaskListView digest
|
|
106
|
+
- you may run "bun test darkf/src/core darkf/src/kit darkf-opencode-plugin/src" yourself
|
|
102
107
|
|
|
103
|
-
Approve only if the implementation fulfills the
|
|
108
|
+
Approve only if the implementation fulfills the spec. Otherwise list every required change concretely in the output.
|
|
104
109
|
|
|
105
110
|
Finish with event "approved" or event "changes_requested".`,
|
|
106
|
-
on: { approved: "
|
|
111
|
+
on: { approved: "Document", changes_requested: "Fix" },
|
|
112
|
+
},
|
|
113
|
+
Document: {
|
|
114
|
+
type: "agent",
|
|
115
|
+
agent: { model: MODEL },
|
|
116
|
+
retries: 1,
|
|
117
|
+
prompt: `You are updating user-facing documentation for the ${FEATURE} feature, after an independent review approved the implementation. Do not modify code or tests.
|
|
118
|
+
|
|
119
|
+
Read docs/specs/${FEATURE}/spec.md (or prd.md/design.md when present) for what the feature does, and run git diff master plus git status --porcelain to see what shipped.
|
|
120
|
+
|
|
121
|
+
Update only what the feature's user-facing surface touches:
|
|
122
|
+
- README.md — CLI flags/commands, plugin behavior, setup steps that changed
|
|
123
|
+
- docs-site pages under site/src/content/docs/ — the affected guide or reference page; add a short new guide only for a genuinely user-visible capability
|
|
124
|
+
- cross-references in docs/ that now point at moved or renamed paths
|
|
125
|
+
|
|
126
|
+
Do NOT touch: ROADMAP.md, darkf/feedback/, docs/specs/ (the spec archive move and roadmap entry are post-merge human curation), any file under darkf/src/ or darkf-opencode-plugin/.
|
|
127
|
+
|
|
128
|
+
If nothing user-facing changed, or the docs need no edit, finish with event "skipped" and put the one-line reason in the output. Otherwise make the edits and finish with event "documented". If the docs cannot be updated (for example the site is broken), finish with event "blocked" and the reason.`,
|
|
129
|
+
on: { documented: "Finish", skipped: "Finish", blocked: DONE },
|
|
107
130
|
},
|
|
108
131
|
},
|
|
109
132
|
},
|