@psimona/darkf 0.0.0-stage → 0.3.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/README.md +28 -2
- package/bunfig.toml +13 -0
- package/examples/article-classifier/data/articles.ts +38 -0
- package/examples/article-classifier/scripts/next.ts +7 -0
- package/examples/article-classifier/scripts/queue.ts +33 -0
- package/examples/article-classifier/scripts/record.ts +9 -0
- package/examples/article-classifier/workflow.ts +44 -0
- package/examples/haiku-commit/scripts/check.ts +24 -0
- package/examples/haiku-commit/workflow.ts +28 -0
- package/examples/haiku-readme/scripts/test.ts +13 -0
- package/examples/haiku-readme/scripts/write.ts +10 -0
- package/examples/haiku-readme/workflow.ts +41 -0
- package/examples/task-queue/scripts/next.ts +20 -0
- package/examples/task-queue/scripts/record.ts +20 -0
- package/examples/task-queue/supervise.ts +57 -0
- package/examples/task-queue/workflow.ts +33 -0
- package/package.json +30 -4
- package/src/cli/detached.test.ts +557 -0
- package/src/cli/index.ts +1012 -0
- package/src/core/graph.test.ts +172 -0
- package/src/core/graph.ts +148 -0
- package/src/core/index.ts +4 -0
- package/src/core/journal.ts +21 -0
- package/src/core/mermaid.test.ts +34 -0
- package/src/core/mermaid.ts +95 -0
- package/src/core/types.ts +279 -0
- package/src/engine/eventLog.ts +17 -0
- package/src/engine/index.ts +2 -0
- package/src/engine/run.test.ts +1068 -0
- package/src/engine/run.ts +359 -0
- package/src/exports.ts +2 -0
- package/src/kit/agents/claude-code.test.ts +37 -0
- package/src/kit/agents/claude-code.ts +180 -0
- package/src/kit/agents/handoff.test.ts +128 -0
- package/src/kit/agents/handoff.ts +69 -0
- package/src/kit/agents/opencode.test.ts +136 -0
- package/src/kit/agents/opencode.ts +327 -0
- package/src/kit/registry.test.ts +386 -0
- package/src/kit/registry.ts +296 -0
- package/src/kit/status.test.ts +423 -0
- package/src/kit/status.ts +282 -0
- package/tsconfig.json +4 -0
- package/workflows/series-ordering/scripts/verify.ts +18 -0
- package/workflows/series-ordering/workflow.ts +79 -0
package/tsconfig.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Verify: run the blueprint Gradle check suite. green → Review, red → Implement.
|
|
2
|
+
// rootDir (the invocation cwd) IS the target repo — no path hardcoding.
|
|
3
|
+
import type { DispatchInfo, NodeResult } from "@psimona/darkf/src/core/index.ts";
|
|
4
|
+
|
|
5
|
+
export default function verify(_handoff: NodeResult, info: DispatchInfo): NodeResult {
|
|
6
|
+
const proc = Bun.spawnSync(["./gradlew", "check"], {
|
|
7
|
+
cwd: info.rootDir,
|
|
8
|
+
stdout: "pipe",
|
|
9
|
+
stderr: "pipe",
|
|
10
|
+
timeout: 1_200_000,
|
|
11
|
+
});
|
|
12
|
+
const tail = `${proc.stdout?.toString() ?? ""}\n${proc.stderr?.toString() ?? ""}`
|
|
13
|
+
.split("\n")
|
|
14
|
+
.slice(-120)
|
|
15
|
+
.join("\n");
|
|
16
|
+
if (proc.exitCode === 0) return { event: "green", output: { tail } };
|
|
17
|
+
return { event: "red", output: { exitCode: proc.exitCode, tail: tail.slice(-6000) } };
|
|
18
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// series-ordering — dogfood workflow: implement + verify + review the
|
|
2
|
+
// `marketdata-series-chronological-order` bug fix in the blueprint repo.
|
|
3
|
+
//
|
|
4
|
+
// Uses the built-in claude-code harness (handoff-file contract, session
|
|
5
|
+
// resume). rootDir — the agent's working directory and the run-artifact root —
|
|
6
|
+
// is the INVOCATION directory, so run from the repo you target:
|
|
7
|
+
// cd /path/to/blueprint
|
|
8
|
+
// darkf start <this dir> "marketdata-series-chronological-order"
|
|
9
|
+
import { type AgentRunner, DONE, type WorkflowDef } from "@psimona/darkf/src/core/index.ts";
|
|
10
|
+
import { claudeCodeRunner } from "@psimona/darkf/src/kit/agents/claude-code.ts";
|
|
11
|
+
|
|
12
|
+
export const agentRunner: AgentRunner = claudeCodeRunner;
|
|
13
|
+
|
|
14
|
+
const IMPLEMENT_PROMPT = `You are implementing an approved, fully specified bug fix in the Kotlin/JVM + Gradle repo at your working directory.
|
|
15
|
+
|
|
16
|
+
If the working tree already contains a partial implementation (a previous attempt), verify and complete it instead of starting over.
|
|
17
|
+
|
|
18
|
+
Read both spec files first (paths relative to the repo root):
|
|
19
|
+
- docs/specs/_implemented/marketdata-series-chronological-order/prd.md (REQ-1..REQ-5, CON-1..CON-3)
|
|
20
|
+
- docs/specs/_implemented/marketdata-series-chronological-order/design.md (exact changes, code sketches, test plan)
|
|
21
|
+
|
|
22
|
+
Implement exactly the design, nothing more:
|
|
23
|
+
1. MarketDataPort: add the ordering-contract KDoc (design has the wording).
|
|
24
|
+
2. PostgresMarketDataAdapter: ORDER BY asset_id, date, market, currency (quotes); ORDER BY asset_id, date, type (corporate actions).
|
|
25
|
+
3. MarketDataMapping: sort before groupBy — quotes compareBy(date, market, currency); corporate actions compareBy(date, type.wireName).
|
|
26
|
+
4. Extend existing test classes only (design Testing Strategy):
|
|
27
|
+
- MarketDataMappingTest: shuffled rows read back ascending; equal-date tiebreak cases (quotes and corporate actions).
|
|
28
|
+
- PostgresMarketDataAdapterTest: seed rows in reverse date order, read ascending, read twice identical (DatabaseIntegrationTestBase).
|
|
29
|
+
- ComputePipelineIntegrationTest: multi-date data via its FakeLoaders, pipeline run twice with differently-constructed but ascending list instances, identical nav/marketValue/twr. The test's inputs must both honor the port contract (ascending); do not import marketdata's adapter.outbound.database internals.
|
|
30
|
+
|
|
31
|
+
Then run ./gradlew check from the repo root; it must pass. If Docker (Testcontainers) is unavailable, run ./gradlew test instead and say so in your report.
|
|
32
|
+
|
|
33
|
+
Rules: touch only the files the design names; no new files; do NOT commit or stage anything; no code comments.
|
|
34
|
+
|
|
35
|
+
If a review demand contradicts the spec (prd.md/design.md) or would make a test unable to fail, do NOT silently comply — object. Write your result with event "disputed", the demand you reject, and your spec-grounded rationale in output.
|
|
36
|
+
|
|
37
|
+
Write your result per the handoff instructions: event "implemented" (done and check green), "blocked" (cannot proceed — reason in output), or "disputed" (review demand contradicts the spec — demand + rationale in output).`;
|
|
38
|
+
|
|
39
|
+
const REVIEW_PROMPT = `You are reviewing an implementation in the repo at your working directory.
|
|
40
|
+
|
|
41
|
+
Spec: docs/specs/_implemented/marketdata-series-chronological-order/prd.md and design.md.
|
|
42
|
+
|
|
43
|
+
Inspect EVERYTHING in the working tree: git diff for tracked files AND git status --porcelain for untracked files — an earlier review missed agent-authored extra files because git diff alone does not show them. Nothing beyond the six files the design names may exist as part of this change.
|
|
44
|
+
|
|
45
|
+
Check:
|
|
46
|
+
1. Every REQ-1..REQ-5 in prd.md is implemented and backed by a test that can actually fail if the production fix is reverted.
|
|
47
|
+
2. The diff matches the design change list exactly — no scope creep, no unrelated edits, no extra files.
|
|
48
|
+
3. Constraints hold: no REST wire-shape change (CON-1), no schema change (CON-2), no module-boundary violations (CON-3).
|
|
49
|
+
|
|
50
|
+
Write your result per the handoff instructions: event "done" if it matches the spec, or "changes_requested" with a numbered list of concrete fixes in output.`;
|
|
51
|
+
|
|
52
|
+
export const workflow: WorkflowDef = {
|
|
53
|
+
initial: "Fix",
|
|
54
|
+
states: {
|
|
55
|
+
Fix: {
|
|
56
|
+
initial: "Implement",
|
|
57
|
+
maxCycles: 8,
|
|
58
|
+
states: {
|
|
59
|
+
Implement: {
|
|
60
|
+
type: "agent",
|
|
61
|
+
retries: 1,
|
|
62
|
+
prompt: IMPLEMENT_PROMPT,
|
|
63
|
+
on: { implemented: "Verify", blocked: DONE, disputed: DONE },
|
|
64
|
+
},
|
|
65
|
+
Verify: {
|
|
66
|
+
type: "script",
|
|
67
|
+
file: "verify.ts",
|
|
68
|
+
on: { green: "Review", red: "Implement" },
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
Review: {
|
|
73
|
+
type: "agent",
|
|
74
|
+
retries: 1,
|
|
75
|
+
prompt: REVIEW_PROMPT,
|
|
76
|
+
on: { done: DONE, changes_requested: "Implement" },
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
};
|