@psimona/darkf 0.7.1 → 0.9.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.
Files changed (35) hide show
  1. package/docs/concepts/failure-modes.md +18 -5
  2. package/docs/concepts/handoff.md +8 -4
  3. package/docs/concepts/node-types.md +45 -21
  4. package/docs/guides/pick-an-agent-runner.md +143 -4
  5. package/docs/guides/plan-with-a-task-queue.md +18 -2
  6. package/docs/guides/run-detached-and-monitor.md +4 -3
  7. package/docs/guides/write-your-first-workflow.md +24 -5
  8. package/docs/reference/cli-commands.md +24 -6
  9. package/docs/reference/core-types.md +41 -6
  10. package/docs/start-here/quickstart.md +22 -2
  11. package/package.json +1 -1
  12. package/skills/darkf-usage/SKILL.md +17 -0
  13. package/skills/darkf-writing-workflows/SKILL.md +25 -18
  14. package/src/cli/detached.test.ts +92 -2
  15. package/src/cli/doctor.test.ts +224 -9
  16. package/src/cli/index.ts +83 -12
  17. package/src/cli/tarball.test.ts +8 -2
  18. package/src/core/graph.test.ts +266 -20
  19. package/src/core/graph.ts +61 -3
  20. package/src/core/types.ts +21 -0
  21. package/src/engine/run.test.ts +581 -17
  22. package/src/engine/run.ts +50 -7
  23. package/src/kit/agents/claude-code.test.ts +38 -2
  24. package/src/kit/agents/claude-code.ts +24 -3
  25. package/src/kit/agents/opencode.test.ts +89 -12
  26. package/src/kit/agents/opencode.ts +103 -8
  27. package/src/kit/status.test.ts +24 -0
  28. package/src/kit/status.ts +25 -8
  29. package/src/test/ok-output.ts +11 -0
  30. package/workflows/dev-loop/output-types.ts +43 -0
  31. package/workflows/dev-loop/scripts/begin.ts +2 -2
  32. package/workflows/dev-loop/scripts/finish.ts +2 -36
  33. package/workflows/dev-loop/workflow.ts +18 -4
  34. package/workflows/series-ordering/output-types.ts +9 -0
  35. package/workflows/series-ordering/workflow.ts +4 -0
@@ -1,11 +1,11 @@
1
1
  import type { DispatchInfo } from "@psimona/darkf/src/core/index.ts";
2
2
 
3
- // Ported from blueprint's build-backend create_branch: cut feature/<slug>
3
+ // Ported from a sibling project's build-backend create_branch: cut feature/<slug>
4
4
  // from the current tree. Uncommitted work (the feature under construction)
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 = "opencode-overlay-tiles";
8
+ const FEATURE = "mandatory-agent-output-types";
9
9
 
10
10
  function sh(cwd: string, ...args: string[]): [string, number] {
11
11
  const proc = Bun.spawnSync(args, { cwd, stdout: "pipe", stderr: "pipe" });
@@ -1,32 +1,16 @@
1
1
  import type { DispatchInfo, NodeResult } from "@psimona/darkf/src/core/index.ts";
2
2
 
3
- // Ported from blueprint's build-backend finish_branch (node 4): commit the
3
+ // Ported from a sibling project's build-backend finish_branch (node 4): commit the
4
4
  // loop's work on the feature branch, squash-merge onto master as one commit
5
5
  // (subject from the prd H1), delete the branch. The run ends with the work
6
6
  // merged; no supervisor merge.
7
7
  //
8
8
  // Safety rails:
9
9
  // - only runs on feature/<slug>;
10
- // - refuses when the dirty tree touches paths outside the loop's known
11
- // surface (the anti-sweep rail — a blind `git add -A` once wiped a
12
- // repo's .darkf state in the registry-lifecycle incident);
13
10
  // - refuses unless master is an ancestor of the branch (master must not
14
11
  // have moved mid-run — the only case where the squash could conflict);
15
12
  // - rolls back (reset --hard + checkout back) on any git failure.
16
- const FEATURE = "opencode-overlay-tiles";
17
- const ALLOWED = [
18
- "docs/",
19
- "darkf/src/",
20
- "darkf/skills/",
21
- "darkf/docs/",
22
- "darkf/package.json",
23
- "bun.lock",
24
- "darkf-opencode-plugin/",
25
- "ROADMAP.md",
26
- "README.md",
27
- "site/",
28
- "darkf/workflows/",
29
- ];
13
+ const FEATURE = "mandatory-agent-output-types";
30
14
 
31
15
  function sh(cwd: string, ...args: string[]): [string, number] {
32
16
  const proc = Bun.spawnSync(args, { cwd, stdout: "pipe", stderr: "pipe" });
@@ -52,24 +36,6 @@ export default function finishBranch(_handoff: NodeResult, info: DispatchInfo):
52
36
  };
53
37
  }
54
38
 
55
- const [status, statusRc] = sh(rootDir, "git", "status", "--porcelain");
56
- if (statusRc !== 0) {
57
- return { event: "merge_failed", output: { failure: "git status failed" } };
58
- }
59
- const dirty = status
60
- .split("\n")
61
- .map((l) => l.slice(3).trim())
62
- .filter(Boolean);
63
- const foreign = dirty.filter((p) => !ALLOWED.some((prefix) => p.startsWith(prefix)));
64
- if (foreign.length > 0) {
65
- return {
66
- event: "merge_failed",
67
- output: {
68
- failure: `dirty paths outside the loop's surface — human decision:\n${foreign.join("\n")}`,
69
- },
70
- };
71
- }
72
-
73
39
  const title = prdTitle(rootDir) ?? FEATURE;
74
40
  const subject = `feat: ${title} (${FEATURE})`;
75
41
  const add = sh(rootDir, "git", "add", "-A");
@@ -1,5 +1,13 @@
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
+ import {
4
+ documentOutput,
5
+ feedbackOutput,
6
+ fixOutput,
7
+ implementOutput,
8
+ planOutput,
9
+ reviewOutput,
10
+ } from "./output-types.ts";
3
11
 
4
12
  // dev-loop — begin → PlanPhase{plan → validate} → (dispatch →
5
13
  // Task{implement → test → [fix → test]* → review → mark done})* →
@@ -7,8 +15,8 @@ import { opencodeRunner } from "@psimona/darkf/src/kit/agents/opencode.ts";
7
15
  //
8
16
  // The darkf-on-darkf pilot, expanded after its first real run built the CLI
9
17
  // self-update feature (docs/specs/_built/self-update/). Shape ported from
10
- // blueprint's build-backend: Begin cuts the feature branch, Finish
11
- // squash-merges onto master with blueprint's rails, Feedback writes the run
18
+ // a sibling project's build-backend: Begin cuts the feature branch, Finish
19
+ // squash-merges onto master with a sibling project's rails, Feedback writes the run
12
20
  // retrospective under darkf/feedback/.
13
21
  //
14
22
  // Run from the target repo root with the released engine from the npm
@@ -98,8 +106,8 @@ import { opencodeRunner } from "@psimona/darkf/src/kit/agents/opencode.ts";
98
106
  export const agentRunner = opencodeRunner;
99
107
 
100
108
  const MODEL = "zai-coding-plan/glm-5.3-flash";
101
- const RUN_DATE = "2026-11-19";
102
- const FEATURE = "opencode-overlay-tiles";
109
+ const RUN_DATE = "2026-12-03";
110
+ const FEATURE = "mandatory-agent-output-types";
103
111
 
104
112
  export const workflow: WorkflowDef = {
105
113
  initial: "Begin",
@@ -119,6 +127,7 @@ export const workflow: WorkflowDef = {
119
127
  states: {
120
128
  Plan: {
121
129
  type: "agent",
130
+ outputType: planOutput,
122
131
  agent: { model: MODEL },
123
132
  retries: 1,
124
133
  prompt: `You are planning the ${FEATURE} run. Do not write or modify any code.
@@ -161,6 +170,7 @@ Finish with event "planned". If the contract is missing, contradictory, or too v
161
170
  states: {
162
171
  Implement: {
163
172
  type: "agent",
173
+ outputType: implementOutput,
164
174
  agent: { model: MODEL },
165
175
  retries: 1,
166
176
  prompt: `Implement exactly the one task you were handed for the ${FEATURE} feature — see "Input from the previous step" below for its id, title, and which requirements it satisfies. Nothing else.
@@ -182,6 +192,7 @@ Finish with event "implemented". If the task cannot be implemented as specified,
182
192
  },
183
193
  Fix: {
184
194
  type: "agent",
195
+ outputType: fixOutput,
185
196
  agent: { model: MODEL },
186
197
  retries: 1,
187
198
  prompt: `You are repairing the ${FEATURE} implementation after a failed gate.
@@ -193,6 +204,7 @@ Finish with event "fixed". If the failure exposes a spec defect you cannot resol
193
204
  },
194
205
  Review: {
195
206
  type: "agent",
207
+ outputType: reviewOutput,
196
208
  agent: { model: MODEL },
197
209
  retries: 1,
198
210
  prompt: `You are an independent reviewer. Do not modify any files.
@@ -218,6 +230,7 @@ Finish with event "approved" or event "changes_requested".`,
218
230
  },
219
231
  Document: {
220
232
  type: "agent",
233
+ outputType: documentOutput,
221
234
  agent: { model: MODEL },
222
235
  retries: 1,
223
236
  prompt: `You are updating user-facing documentation for the ${FEATURE} feature, after every task in its plan was implemented and independently reviewed. Do not modify code or tests.
@@ -245,6 +258,7 @@ If nothing user-facing changed and no doc drifted, finish with event "skipped" a
245
258
  },
246
259
  Feedback: {
247
260
  type: "agent",
261
+ outputType: feedbackOutput,
248
262
  agent: { model: MODEL },
249
263
  retries: 1,
250
264
  prompt: `Write the run retrospective for the ${FEATURE} dev-loop run, in the style of a post-run feedback note.
@@ -0,0 +1,9 @@
1
+ import { zodOutputType } from "@psimona/darkf/src/kit/validation/zod.ts";
2
+ import { z } from "zod";
3
+
4
+ // Verify runs Gradle against the working tree; nothing reads the handoff
5
+ // output. The declarations stay permissive — the rule guarantees a
6
+ // declaration, not a good one
7
+ // (docs/specs/mandatory-agent-output-types/, NG-1).
8
+ export const implementOutput = zodOutputType(z.unknown());
9
+ export const reviewOutput = zodOutputType(z.unknown());
@@ -9,6 +9,7 @@
9
9
  // darkf start <this dir> "<bug id>"
10
10
  import { type AgentRunner, DONE, type WorkflowDef } from "@psimona/darkf/src/core/index.ts";
11
11
  import { claudeCodeRunner } from "@psimona/darkf/src/kit/agents/claude-code.ts";
12
+ import { implementOutput, reviewOutput } from "./output-types.ts";
12
13
 
13
14
  export const agentRunner: AgentRunner = claudeCodeRunner;
14
15
 
@@ -52,6 +53,7 @@ Write your result per the handoff instructions: event "done" if it matches the s
52
53
 
53
54
  export const workflow: WorkflowDef = {
54
55
  initial: "Fix",
56
+ agent: { model: "claude-sonnet-5-5" },
55
57
  states: {
56
58
  Fix: {
57
59
  initial: "Implement",
@@ -59,6 +61,7 @@ export const workflow: WorkflowDef = {
59
61
  states: {
60
62
  Implement: {
61
63
  type: "agent",
64
+ outputType: implementOutput,
62
65
  retries: 1,
63
66
  prompt: IMPLEMENT_PROMPT,
64
67
  on: { implemented: "Verify", blocked: DONE, disputed: DONE },
@@ -72,6 +75,7 @@ export const workflow: WorkflowDef = {
72
75
  },
73
76
  Review: {
74
77
  type: "agent",
78
+ outputType: reviewOutput,
75
79
  retries: 1,
76
80
  prompt: REVIEW_PROMPT,
77
81
  on: { done: DONE, changes_requested: "Implement" },