@s_s/harmonia 1.2.0 → 1.4.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 +140 -392
- package/build/cli/setup.d.ts +4 -2
- package/build/cli/setup.js +44 -18
- package/build/cli/setup.js.map +1 -1
- package/build/core/action-registry.d.ts +36 -0
- package/build/core/action-registry.js +53 -0
- package/build/core/action-registry.js.map +1 -0
- package/build/core/artifacts.d.ts +66 -0
- package/build/core/artifacts.js +178 -0
- package/build/core/artifacts.js.map +1 -0
- package/build/core/dispatch.d.ts +18 -11
- package/build/core/dispatch.js +43 -33
- package/build/core/dispatch.js.map +1 -1
- package/build/core/issues.d.ts +37 -0
- package/build/core/issues.js +100 -0
- package/build/core/issues.js.map +1 -0
- package/build/core/overrides.d.ts +19 -26
- package/build/core/overrides.js +32 -98
- package/build/core/overrides.js.map +1 -1
- package/build/core/plugin.d.ts +86 -0
- package/build/core/plugin.js +332 -0
- package/build/core/plugin.js.map +1 -0
- package/build/core/registry.d.ts +36 -3
- package/build/core/registry.js +63 -5
- package/build/core/registry.js.map +1 -1
- package/build/core/reviews.d.ts +13 -13
- package/build/core/reviews.js +31 -32
- package/build/core/reviews.js.map +1 -1
- package/build/core/schema.d.ts +43 -15
- package/build/core/schema.js +124 -20
- package/build/core/schema.js.map +1 -1
- package/build/core/state.d.ts +29 -22
- package/build/core/state.js +49 -81
- package/build/core/state.js.map +1 -1
- package/build/core/steps.d.ts +15 -15
- package/build/core/steps.js +32 -33
- package/build/core/steps.js.map +1 -1
- package/build/core/tree-utils.d.ts +52 -0
- package/build/core/tree-utils.js +226 -0
- package/build/core/tree-utils.js.map +1 -0
- package/build/core/types.d.ts +417 -117
- package/build/core/types.js +15 -1
- package/build/core/types.js.map +1 -1
- package/build/core/workflow-engine.d.ts +68 -0
- package/build/core/workflow-engine.js +821 -0
- package/build/core/workflow-engine.js.map +1 -0
- package/build/core/workflow-validator.d.ts +22 -0
- package/build/core/workflow-validator.js +489 -0
- package/build/core/workflow-validator.js.map +1 -0
- package/build/index.js +28 -25
- package/build/index.js.map +1 -1
- package/build/setup/inject.d.ts +4 -4
- package/build/setup/inject.js +6 -6
- package/build/setup/inject.js.map +1 -1
- package/build/setup/templates.d.ts +9 -7
- package/build/setup/templates.js +68 -103
- package/build/setup/templates.js.map +1 -1
- package/build/tools/artifact-approve.d.ts +8 -0
- package/build/tools/artifact-approve.js +94 -0
- package/build/tools/artifact-approve.js.map +1 -0
- package/build/tools/artifact-schema.d.ts +12 -0
- package/build/tools/artifact-schema.js +148 -0
- package/build/tools/artifact-schema.js.map +1 -0
- package/build/tools/artifact-tools.d.ts +18 -0
- package/build/tools/artifact-tools.js +465 -0
- package/build/tools/artifact-tools.js.map +1 -0
- package/build/tools/{report-dispatch.d.ts → dispatch-report.d.ts} +7 -3
- package/build/tools/dispatch-report.js +261 -0
- package/build/tools/dispatch-report.js.map +1 -0
- package/build/tools/engine-helpers.d.ts +41 -0
- package/build/tools/engine-helpers.js +182 -0
- package/build/tools/engine-helpers.js.map +1 -0
- package/build/tools/get-project-status.d.ts +6 -4
- package/build/tools/get-project-status.js +308 -246
- package/build/tools/get-project-status.js.map +1 -1
- package/build/tools/get-role-prompt.d.ts +1 -1
- package/build/tools/get-role-prompt.js +7 -41
- package/build/tools/get-role-prompt.js.map +1 -1
- package/build/tools/issue-tools.d.ts +10 -0
- package/build/tools/issue-tools.js +169 -0
- package/build/tools/issue-tools.js.map +1 -0
- package/build/tools/iteration-start.d.ts +7 -4
- package/build/tools/iteration-start.js +51 -20
- package/build/tools/iteration-start.js.map +1 -1
- package/build/tools/loop-done.d.ts +11 -0
- package/build/tools/loop-done.js +109 -0
- package/build/tools/loop-done.js.map +1 -0
- package/build/tools/patch-start.d.ts +16 -0
- package/build/tools/patch-start.js +122 -0
- package/build/tools/patch-start.js.map +1 -0
- package/build/tools/project-init.d.ts +5 -5
- package/build/tools/project-init.js +47 -18
- package/build/tools/project-init.js.map +1 -1
- package/build/tools/role-dispatch.d.ts +55 -0
- package/build/tools/role-dispatch.js +508 -0
- package/build/tools/role-dispatch.js.map +1 -0
- package/build/tools/utils.d.ts +40 -0
- package/build/tools/utils.js +97 -0
- package/build/tools/utils.js.map +1 -0
- package/package.json +1 -1
- package/{build/hooks/claude-code.js → workflows/dev/hooks/claude.js} +34 -23
- package/{build → workflows/dev}/hooks/content.js +27 -18
- package/workflows/dev/hooks/index.js +52 -0
- package/{build → workflows/dev}/hooks/openclaw.js +31 -20
- package/{build → workflows/dev}/hooks/opencode.js +31 -20
- package/workflows/dev/roles/architect.md +68 -28
- package/workflows/dev/roles/coordinator.md +103 -0
- package/workflows/dev/roles/developer.md +5 -5
- package/workflows/dev/roles/tester.md +19 -19
- package/workflows/dev/schemas/api-contract.json +42 -0
- package/workflows/dev/schemas/api-design.json +30 -13
- package/workflows/dev/schemas/data-model.json +20 -7
- package/workflows/dev/schemas/prd.completeness-check.json +6 -5
- package/workflows/dev/schemas/prd.draft.json +13 -5
- package/workflows/dev/schemas/prd.final.json +34 -11
- package/workflows/dev/schemas/prd.json +29 -11
- package/workflows/dev/schemas/prd.requirements.json +6 -5
- package/workflows/dev/schemas/prototype.json +6 -2
- package/workflows/dev/schemas/task-breakdown.coarse.json +4 -3
- package/workflows/dev/schemas/task-breakdown.dependencies.json +5 -4
- package/workflows/dev/schemas/task-breakdown.detailed.json +8 -3
- package/workflows/dev/schemas/task-breakdown.final.json +8 -3
- package/workflows/dev/schemas/task-breakdown.json +8 -3
- package/workflows/dev/schemas/tech-design.analysis.json +6 -5
- package/workflows/dev/schemas/tech-design.draft.json +14 -5
- package/workflows/dev/schemas/tech-design.final.json +39 -13
- package/workflows/dev/schemas/tech-design.json +34 -13
- package/workflows/dev/schemas/tech-design.research.json +21 -0
- package/workflows/dev/schemas/test-plan.json +17 -7
- package/workflows/dev/schemas/test-report.json +26 -9
- package/workflows/dev/schemas/user-stories.json +7 -3
- package/workflows/dev/tools/index.js +23 -0
- package/workflows/dev/workflow.json +234 -101
- package/build/core/docs.d.ts +0 -32
- package/build/core/docs.js +0 -91
- package/build/core/docs.js.map +0 -1
- package/build/core/workflow.d.ts +0 -33
- package/build/core/workflow.js +0 -140
- package/build/core/workflow.js.map +0 -1
- package/build/hooks/claude-code.d.ts +0 -20
- package/build/hooks/claude-code.js.map +0 -1
- package/build/hooks/content.d.ts +0 -43
- package/build/hooks/content.js.map +0 -1
- package/build/hooks/install.d.ts +0 -40
- package/build/hooks/install.js +0 -63
- package/build/hooks/install.js.map +0 -1
- package/build/hooks/openclaw.d.ts +0 -24
- package/build/hooks/openclaw.js.map +0 -1
- package/build/hooks/opencode.d.ts +0 -29
- package/build/hooks/opencode.js.map +0 -1
- package/build/tools/approve-doc.d.ts +0 -6
- package/build/tools/approve-doc.js +0 -108
- package/build/tools/approve-doc.js.map +0 -1
- package/build/tools/dispatch-role.d.ts +0 -16
- package/build/tools/dispatch-role.js +0 -277
- package/build/tools/dispatch-role.js.map +0 -1
- package/build/tools/doc-tools.d.ts +0 -16
- package/build/tools/doc-tools.js +0 -389
- package/build/tools/doc-tools.js.map +0 -1
- package/build/tools/override-tools.d.ts +0 -6
- package/build/tools/override-tools.js +0 -129
- package/build/tools/override-tools.js.map +0 -1
- package/build/tools/report-dispatch.js +0 -194
- package/build/tools/report-dispatch.js.map +0 -1
- package/build/tools/set-scale.d.ts +0 -6
- package/build/tools/set-scale.js +0 -107
- package/build/tools/set-scale.js.map +0 -1
- package/build/tools/setup-project.d.ts +0 -8
- package/build/tools/setup-project.js +0 -116
- package/build/tools/setup-project.js.map +0 -1
- package/build/tools/update-phase.d.ts +0 -12
- package/build/tools/update-phase.js +0 -159
- package/build/tools/update-phase.js.map +0 -1
- package/workflows/dev/roles/pm.md +0 -99
- package/workflows/dev/schemas/deploy.json +0 -20
- package/workflows/dev/schemas/fsd.json +0 -25
- package/workflows/dev/schemas/project-plan.json +0 -20
- package/workflows/dev/schemas/retrospective.json +0 -20
- package/workflows/dev/schemas/risk-assessment.json +0 -15
- package/workflows/dev/schemas/tech-design.api-contract.json +0 -20
package/build/cli/setup.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* CLI command: harmonia setup
|
|
3
3
|
*
|
|
4
|
-
* Prompt injection
|
|
5
|
-
* No project registration, no state init
|
|
4
|
+
* Prompt injection only.
|
|
5
|
+
* No project registration, no state init, no hook installation.
|
|
6
|
+
* Coordinator does project registration at runtime via MCP tools (project_init),
|
|
7
|
+
* which also handles hook installation.
|
|
6
8
|
*
|
|
7
9
|
* Usage:
|
|
8
10
|
* harmonia setup [options]
|
|
@@ -10,10 +12,13 @@
|
|
|
10
12
|
* Options:
|
|
11
13
|
* --agent <type> Agent type: opencode | claude-code | codex | openclaw (default: auto-detect)
|
|
12
14
|
*/
|
|
13
|
-
import { resolve } from 'node:path';
|
|
15
|
+
import { resolve, join, dirname } from 'node:path';
|
|
16
|
+
import { fileURLToPath } from 'node:url';
|
|
17
|
+
import { cp, readdir, stat, mkdir } from 'node:fs/promises';
|
|
14
18
|
import { detectHostAgent, injectPrompt } from '../setup/inject.js';
|
|
15
|
-
import { installHooks } from '../hooks/install.js';
|
|
16
19
|
import { getGlobalDir } from '../core/registry.js';
|
|
20
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
21
|
+
const __dirname = dirname(__filename);
|
|
17
22
|
const VALID_AGENTS = ['opencode', 'claude-code', 'codex', 'openclaw'];
|
|
18
23
|
/** Parse CLI flags from argv (starting after 'setup'). */
|
|
19
24
|
export function parseSetupArgs(args) {
|
|
@@ -47,25 +52,46 @@ export async function runSetup(opts) {
|
|
|
47
52
|
const result = await injectPrompt(agentType);
|
|
48
53
|
const action = result.created ? 'Created' : result.replaced ? 'Updated' : 'Appended to';
|
|
49
54
|
console.log(` [done] ${action} ${result.filePath}`);
|
|
50
|
-
// 3.
|
|
55
|
+
// 3. Copy built-in workflows to user data directory (skip existing)
|
|
56
|
+
const builtinWorkflowsRoot = resolve(__dirname, '..', '..', 'workflows');
|
|
57
|
+
const targetWorkflowsDir = join(getGlobalDir(), '.workflows');
|
|
51
58
|
try {
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
59
|
+
const entries = await readdir(builtinWorkflowsRoot);
|
|
60
|
+
const workflowDirs = [];
|
|
61
|
+
for (const entry of entries) {
|
|
62
|
+
const entryPath = join(builtinWorkflowsRoot, entry);
|
|
63
|
+
const s = await stat(entryPath);
|
|
64
|
+
if (s.isDirectory())
|
|
65
|
+
workflowDirs.push(entry);
|
|
60
66
|
}
|
|
61
|
-
|
|
62
|
-
|
|
67
|
+
if (workflowDirs.length > 0) {
|
|
68
|
+
await mkdir(targetWorkflowsDir, { recursive: true });
|
|
69
|
+
let copied = 0;
|
|
70
|
+
let skipped = 0;
|
|
71
|
+
for (const dir of workflowDirs) {
|
|
72
|
+
const dest = join(targetWorkflowsDir, dir);
|
|
73
|
+
try {
|
|
74
|
+
await stat(dest);
|
|
75
|
+
// Already exists — skip
|
|
76
|
+
skipped++;
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
// Does not exist — copy
|
|
80
|
+
await cp(join(builtinWorkflowsRoot, dir), dest, { recursive: true });
|
|
81
|
+
copied++;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (copied > 0)
|
|
85
|
+
console.log(` [done] Copied ${copied} built-in workflow(s) to ${targetWorkflowsDir}`);
|
|
86
|
+
if (skipped > 0)
|
|
87
|
+
console.log(` [skip] ${skipped} workflow(s) already exist in ${targetWorkflowsDir}`);
|
|
63
88
|
}
|
|
64
89
|
}
|
|
65
|
-
catch
|
|
66
|
-
|
|
90
|
+
catch {
|
|
91
|
+
// Built-in workflows dir may not exist (e.g. development environment) — not fatal
|
|
92
|
+
console.log(` [warn] Could not read built-in workflows from ${builtinWorkflowsRoot}`);
|
|
67
93
|
}
|
|
68
94
|
// 4. Summary
|
|
69
|
-
console.log(`\n Ready. Run your agent and call
|
|
95
|
+
console.log(`\n Ready. Run your agent and call project_init() to register a project.\n`);
|
|
70
96
|
}
|
|
71
97
|
//# sourceMappingURL=setup.js.map
|
package/build/cli/setup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/cli/setup.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/cli/setup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAE5D,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC,MAAM,YAAY,GAAG,CAAC,UAAU,EAAE,aAAa,EAAE,OAAO,EAAE,UAAU,CAAU,CAAC;AAM/E,0DAA0D;AAC1D,MAAM,UAAU,cAAc,CAAC,IAAc;IACzC,MAAM,IAAI,GAAiB,EAAE,CAAC;IAE9B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACnC,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QAEzB,QAAQ,GAA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AA4B,kBAAkB,EAAE,CAAC,CAAC;YACvG,IAAI,OAAO,GAAG,CAAC;gBAAE,OAAO,CAAC,GAAG,CAAC,YAAY,OAAO,iCAAiC,kBAAkB,EAAE,CAAC,CAAC;QAC3G,CAAC;IACL,CAAC;IAAC,MAAM,CAAC;QACL,kFAAkF;QAClF,OAAO,CAAC,GAAG,CAAC,mDAAmD,oBAAoB,EAAE,CAAC,CAAC;IAC3F,CAAC;IAED,aAAa;IACb,OAAO,CAAC,GAAG,CAAC,4EAA4E,CAAC,CAAC;AAC9F,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Action registry — manages node hook action registration and execution.
|
|
3
|
+
*
|
|
4
|
+
* Actions are registered by workflow plugins (via tools/index.js) and executed
|
|
5
|
+
* synchronously by the Core during tool call processing (in beforeDispatch
|
|
6
|
+
* and afterComplete hooks).
|
|
7
|
+
*
|
|
8
|
+
* Actions cannot require agent behavior — only data operations and external
|
|
9
|
+
* API calls. They execute within the MCP server context.
|
|
10
|
+
*/
|
|
11
|
+
import type { ActionHandler, ActionContext, ActionResult } from './types.js';
|
|
12
|
+
export declare class ActionRegistry {
|
|
13
|
+
private actions;
|
|
14
|
+
/**
|
|
15
|
+
* Register an action handler.
|
|
16
|
+
* @throws If an action with the same name is already registered
|
|
17
|
+
*/
|
|
18
|
+
register(name: string, handler: ActionHandler): void;
|
|
19
|
+
/**
|
|
20
|
+
* Execute a registered action.
|
|
21
|
+
* @throws If the action is not registered
|
|
22
|
+
*/
|
|
23
|
+
execute(name: string, context: ActionContext): Promise<ActionResult>;
|
|
24
|
+
/**
|
|
25
|
+
* Check if an action is registered.
|
|
26
|
+
*/
|
|
27
|
+
has(name: string): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* List all registered action names.
|
|
30
|
+
*/
|
|
31
|
+
list(): string[];
|
|
32
|
+
/**
|
|
33
|
+
* Remove all registered actions. Useful for testing or plugin reload.
|
|
34
|
+
*/
|
|
35
|
+
clear(): void;
|
|
36
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Action registry — manages node hook action registration and execution.
|
|
3
|
+
*
|
|
4
|
+
* Actions are registered by workflow plugins (via tools/index.js) and executed
|
|
5
|
+
* synchronously by the Core during tool call processing (in beforeDispatch
|
|
6
|
+
* and afterComplete hooks).
|
|
7
|
+
*
|
|
8
|
+
* Actions cannot require agent behavior — only data operations and external
|
|
9
|
+
* API calls. They execute within the MCP server context.
|
|
10
|
+
*/
|
|
11
|
+
export class ActionRegistry {
|
|
12
|
+
actions = new Map();
|
|
13
|
+
/**
|
|
14
|
+
* Register an action handler.
|
|
15
|
+
* @throws If an action with the same name is already registered
|
|
16
|
+
*/
|
|
17
|
+
register(name, handler) {
|
|
18
|
+
if (this.actions.has(name)) {
|
|
19
|
+
throw new Error(`Action "${name}" is already registered`);
|
|
20
|
+
}
|
|
21
|
+
this.actions.set(name, handler);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Execute a registered action.
|
|
25
|
+
* @throws If the action is not registered
|
|
26
|
+
*/
|
|
27
|
+
async execute(name, context) {
|
|
28
|
+
const handler = this.actions.get(name);
|
|
29
|
+
if (!handler) {
|
|
30
|
+
throw new Error(`Action "${name}" is not registered. Available actions: ${this.list().join(', ') || 'none'}`);
|
|
31
|
+
}
|
|
32
|
+
return handler(context);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Check if an action is registered.
|
|
36
|
+
*/
|
|
37
|
+
has(name) {
|
|
38
|
+
return this.actions.has(name);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* List all registered action names.
|
|
42
|
+
*/
|
|
43
|
+
list() {
|
|
44
|
+
return Array.from(this.actions.keys());
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Remove all registered actions. Useful for testing or plugin reload.
|
|
48
|
+
*/
|
|
49
|
+
clear() {
|
|
50
|
+
this.actions.clear();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=action-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-registry.js","sourceRoot":"","sources":["../../src/core/action-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,MAAM,OAAO,cAAc;IACf,OAAO,GAAG,IAAI,GAAG,EAAyB,CAAC;IAEnD;;;OAGG;IACH,QAAQ,CAAC,IAAY,EAAE,OAAsB;QACzC,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,WAAW,IAAI,yBAAyB,CAAC,CAAC;QAC9D,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACpC,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,OAAO,CAAC,IAAY,EAAE,OAAsB;QAC9C,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACvC,IAAI,CAAC,OAAO,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CACX,WAAW,IAAI,2CAA2C,IAAI,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,MAAM,EAAE,CAC/F,CAAC;QACN,CAAC;QACD,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,IAAY;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;IAED;;OAEG;IACH,IAAI;QACA,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,KAAK;QACD,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;CACJ"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Artifact management — read/write files to resolved output directories.
|
|
3
|
+
*
|
|
4
|
+
* All path resolution goes through `ArtifactIOContext`:
|
|
5
|
+
* - Default: `<contextDir>/artifacts/`
|
|
6
|
+
* - Custom: resolved via `ArtifactDefinition.output` template
|
|
7
|
+
*
|
|
8
|
+
* Supports .md, .html, and .json files based on artifact format configuration.
|
|
9
|
+
* Also supports step artifact files for sequential mode (e.g. prd.requirements.json).
|
|
10
|
+
*/
|
|
11
|
+
import type { ArtifactDefinition } from './types.js';
|
|
12
|
+
/** Context needed for artifact I/O path resolution */
|
|
13
|
+
export interface ArtifactIOContext {
|
|
14
|
+
/** Absolute path to the context directory (iter-N/ or patch-N/) */
|
|
15
|
+
contextDir: string;
|
|
16
|
+
/** Absolute path to the project source directory */
|
|
17
|
+
projectDir: string;
|
|
18
|
+
/** Context label string, e.g. "iter-1" or "patch-2" */
|
|
19
|
+
contextLabel: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Resolve the output directory for an artifact based on its `output` template.
|
|
23
|
+
*
|
|
24
|
+
* Placeholder resolution:
|
|
25
|
+
* - `{global}` → `<contextDir>/artifacts/`
|
|
26
|
+
* - `{project}` → `<projectDir>/`
|
|
27
|
+
* - `{context}` → contextLabel (e.g. "iter-1")
|
|
28
|
+
*
|
|
29
|
+
* When `output` is undefined, returns `<contextDir>/artifacts/` (default behavior).
|
|
30
|
+
*/
|
|
31
|
+
export declare function resolveArtifactDir(output: string | undefined, ioCtx: ArtifactIOContext): string;
|
|
32
|
+
/**
|
|
33
|
+
* Write an artifact to the resolved output directory.
|
|
34
|
+
*/
|
|
35
|
+
export declare function writeArtifact(artifactId: string, content: string, ioCtx: ArtifactIOContext, artifactDef?: ArtifactDefinition): Promise<string>;
|
|
36
|
+
/**
|
|
37
|
+
* Read an artifact from the resolved output directory.
|
|
38
|
+
*
|
|
39
|
+
* When `artifactDef` is provided with a known format, tries that extension first
|
|
40
|
+
* before falling back to probing all extensions.
|
|
41
|
+
*/
|
|
42
|
+
export declare function readArtifact(artifactId: string, ioCtx: ArtifactIOContext, artifactDef?: ArtifactDefinition): Promise<string>;
|
|
43
|
+
/**
|
|
44
|
+
* List artifacts that exist on disk.
|
|
45
|
+
*
|
|
46
|
+
* Groups definitions by their resolved output directory and does one `readdir`
|
|
47
|
+
* per unique directory, then matches artifact IDs in memory.
|
|
48
|
+
*
|
|
49
|
+
* When `artifactDefinitions` is empty, falls back to scanning
|
|
50
|
+
* `<ioCtx.contextDir>/artifacts/`.
|
|
51
|
+
*/
|
|
52
|
+
export declare function listArtifacts(ioCtx: ArtifactIOContext, artifactDefinitions: Record<string, ArtifactDefinition>): Promise<string[]>;
|
|
53
|
+
/**
|
|
54
|
+
* Write a step artifact to the resolved output directory.
|
|
55
|
+
*
|
|
56
|
+
* Step artifacts follow the main artifact's `output` configuration.
|
|
57
|
+
*
|
|
58
|
+
* @param format - "json" or "md" (determines file extension)
|
|
59
|
+
* @returns The file path written
|
|
60
|
+
*/
|
|
61
|
+
export declare function writeStepArtifact(artifactId: string, stepId: string, content: string, format: 'json' | 'md', ioCtx: ArtifactIOContext, artifactDef?: ArtifactDefinition): Promise<string>;
|
|
62
|
+
/**
|
|
63
|
+
* Read a step artifact from the resolved output directory.
|
|
64
|
+
* Tries .json first, then .md.
|
|
65
|
+
*/
|
|
66
|
+
export declare function readStepArtifact(artifactId: string, stepId: string, ioCtx: ArtifactIOContext, artifactDef?: ArtifactDefinition): Promise<string>;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Artifact management — read/write files to resolved output directories.
|
|
3
|
+
*
|
|
4
|
+
* All path resolution goes through `ArtifactIOContext`:
|
|
5
|
+
* - Default: `<contextDir>/artifacts/`
|
|
6
|
+
* - Custom: resolved via `ArtifactDefinition.output` template
|
|
7
|
+
*
|
|
8
|
+
* Supports .md, .html, and .json files based on artifact format configuration.
|
|
9
|
+
* Also supports step artifact files for sequential mode (e.g. prd.requirements.json).
|
|
10
|
+
*/
|
|
11
|
+
import { mkdir, readFile, writeFile, readdir } from 'node:fs/promises';
|
|
12
|
+
import { join } from 'node:path';
|
|
13
|
+
function artifactsDir(contextDir) {
|
|
14
|
+
return join(contextDir, 'artifacts');
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Resolve the output directory for an artifact based on its `output` template.
|
|
18
|
+
*
|
|
19
|
+
* Placeholder resolution:
|
|
20
|
+
* - `{global}` → `<contextDir>/artifacts/`
|
|
21
|
+
* - `{project}` → `<projectDir>/`
|
|
22
|
+
* - `{context}` → contextLabel (e.g. "iter-1")
|
|
23
|
+
*
|
|
24
|
+
* When `output` is undefined, returns `<contextDir>/artifacts/` (default behavior).
|
|
25
|
+
*/
|
|
26
|
+
export function resolveArtifactDir(output, ioCtx) {
|
|
27
|
+
if (!output) {
|
|
28
|
+
return artifactsDir(ioCtx.contextDir);
|
|
29
|
+
}
|
|
30
|
+
const resolved = output
|
|
31
|
+
.replace(/\{global\}/g, artifactsDir(ioCtx.contextDir))
|
|
32
|
+
.replace(/\{project\}/g, ioCtx.projectDir)
|
|
33
|
+
.replace(/\{context\}/g, ioCtx.contextLabel);
|
|
34
|
+
return resolved;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Get file extension for an artifact based on its definition.
|
|
38
|
+
*/
|
|
39
|
+
function getArtifactExtension(artifactDef) {
|
|
40
|
+
switch (artifactDef?.format) {
|
|
41
|
+
case 'html':
|
|
42
|
+
return '.html';
|
|
43
|
+
case 'json':
|
|
44
|
+
return '.json';
|
|
45
|
+
default:
|
|
46
|
+
return '.md';
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Write an artifact to the resolved output directory.
|
|
51
|
+
*/
|
|
52
|
+
export async function writeArtifact(artifactId, content, ioCtx, artifactDef) {
|
|
53
|
+
const dir = resolveArtifactDir(artifactDef?.output, ioCtx);
|
|
54
|
+
await mkdir(dir, { recursive: true });
|
|
55
|
+
const ext = getArtifactExtension(artifactDef);
|
|
56
|
+
const filePath = join(dir, `${artifactId}${ext}`);
|
|
57
|
+
await writeFile(filePath, content, 'utf-8');
|
|
58
|
+
return filePath;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Read an artifact from the resolved output directory.
|
|
62
|
+
*
|
|
63
|
+
* When `artifactDef` is provided with a known format, tries that extension first
|
|
64
|
+
* before falling back to probing all extensions.
|
|
65
|
+
*/
|
|
66
|
+
export async function readArtifact(artifactId, ioCtx, artifactDef) {
|
|
67
|
+
const dir = resolveArtifactDir(artifactDef?.output, ioCtx);
|
|
68
|
+
// If we know the format, try it first for a fast path
|
|
69
|
+
if (artifactDef?.format) {
|
|
70
|
+
const knownExt = getArtifactExtension(artifactDef);
|
|
71
|
+
try {
|
|
72
|
+
return await readFile(join(dir, `${artifactId}${knownExt}`), 'utf-8');
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
// fall through to probe all extensions
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
for (const ext of ['.md', '.html', '.json']) {
|
|
79
|
+
try {
|
|
80
|
+
return await readFile(join(dir, `${artifactId}${ext}`), 'utf-8');
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
// try next extension
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
throw new Error(`Artifact "${artifactId}" not found`);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* List artifacts that exist on disk.
|
|
90
|
+
*
|
|
91
|
+
* Groups definitions by their resolved output directory and does one `readdir`
|
|
92
|
+
* per unique directory, then matches artifact IDs in memory.
|
|
93
|
+
*
|
|
94
|
+
* When `artifactDefinitions` is empty, falls back to scanning
|
|
95
|
+
* `<ioCtx.contextDir>/artifacts/`.
|
|
96
|
+
*/
|
|
97
|
+
export async function listArtifacts(ioCtx, artifactDefinitions) {
|
|
98
|
+
// Definition-based grouping
|
|
99
|
+
if (Object.keys(artifactDefinitions).length > 0) {
|
|
100
|
+
// Group artifact IDs by resolved directory
|
|
101
|
+
const dirToIds = new Map();
|
|
102
|
+
for (const [id, def] of Object.entries(artifactDefinitions)) {
|
|
103
|
+
const dir = resolveArtifactDir(def.output, ioCtx);
|
|
104
|
+
const existing = dirToIds.get(dir);
|
|
105
|
+
if (existing) {
|
|
106
|
+
existing.push(id);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
dirToIds.set(dir, [id]);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const found = [];
|
|
113
|
+
for (const [dir, ids] of dirToIds) {
|
|
114
|
+
let files;
|
|
115
|
+
try {
|
|
116
|
+
files = await readdir(dir);
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
continue; // directory doesn't exist yet
|
|
120
|
+
}
|
|
121
|
+
// Strip extensions from filenames for matching
|
|
122
|
+
const fileBaseNames = new Set(files
|
|
123
|
+
.filter((f) => f.endsWith('.md') || f.endsWith('.html') || f.endsWith('.json'))
|
|
124
|
+
.map((f) => f.replace(/\.(md|html|json)$/, '')));
|
|
125
|
+
for (const id of ids) {
|
|
126
|
+
if (fileBaseNames.has(id)) {
|
|
127
|
+
found.push(id);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return found;
|
|
132
|
+
}
|
|
133
|
+
// Fallback: scan default artifacts directory
|
|
134
|
+
const dir = artifactsDir(ioCtx.contextDir);
|
|
135
|
+
try {
|
|
136
|
+
const files = await readdir(dir);
|
|
137
|
+
return files
|
|
138
|
+
.filter((f) => f.endsWith('.md') || f.endsWith('.html') || f.endsWith('.json'))
|
|
139
|
+
.map((f) => f.replace(/\.(md|html|json)$/, ''));
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
return [];
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
// ─── Step Artifact I/O ───
|
|
146
|
+
/**
|
|
147
|
+
* Write a step artifact to the resolved output directory.
|
|
148
|
+
*
|
|
149
|
+
* Step artifacts follow the main artifact's `output` configuration.
|
|
150
|
+
*
|
|
151
|
+
* @param format - "json" or "md" (determines file extension)
|
|
152
|
+
* @returns The file path written
|
|
153
|
+
*/
|
|
154
|
+
export async function writeStepArtifact(artifactId, stepId, content, format, ioCtx, artifactDef) {
|
|
155
|
+
const dir = resolveArtifactDir(artifactDef?.output, ioCtx);
|
|
156
|
+
await mkdir(dir, { recursive: true });
|
|
157
|
+
const ext = format === 'json' ? '.json' : '.md';
|
|
158
|
+
const filePath = join(dir, `${artifactId}.${stepId}${ext}`);
|
|
159
|
+
await writeFile(filePath, content, 'utf-8');
|
|
160
|
+
return filePath;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Read a step artifact from the resolved output directory.
|
|
164
|
+
* Tries .json first, then .md.
|
|
165
|
+
*/
|
|
166
|
+
export async function readStepArtifact(artifactId, stepId, ioCtx, artifactDef) {
|
|
167
|
+
const dir = resolveArtifactDir(artifactDef?.output, ioCtx);
|
|
168
|
+
for (const ext of ['.json', '.md']) {
|
|
169
|
+
try {
|
|
170
|
+
return await readFile(join(dir, `${artifactId}.${stepId}${ext}`), 'utf-8');
|
|
171
|
+
}
|
|
172
|
+
catch {
|
|
173
|
+
// try next extension
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
throw new Error(`Step artifact "${artifactId}.${stepId}" not found`);
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=artifacts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifacts.js","sourceRoot":"","sources":["../../src/core/artifacts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAajC,SAAS,YAAY,CAAC,UAAkB;IACpC,OAAO,IAA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kB,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IAE3D,KAAK,MAAM,GAAG,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC;QACjC,IAAI,CAAC;YACD,OAAO,MAAM,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,UAAU,IAAI,MAAM,GAAG,GAAG,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;QAC/E,CAAC;QAAC,MAAM,CAAC;YACL,qBAAqB;QACzB,CAAC;IACL,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,kBAAkB,UAAU,IAAI,MAAM,aAAa,CAAC,CAAC;AACzE,CAAC"}
|
package/build/core/dispatch.d.ts
CHANGED
|
@@ -1,41 +1,43 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Dispatch & Session tracking — manages:
|
|
3
|
-
* <
|
|
4
|
-
* <
|
|
3
|
+
* <context_dir>/sessions.json
|
|
4
|
+
* <context_dir>/dispatches.json
|
|
5
|
+
*
|
|
6
|
+
* context_dir is typically iter-<n>/ or patch-<n>/ under the project data dir.
|
|
5
7
|
*
|
|
6
8
|
* Sessions represent agent instances (can be reused across dispatches).
|
|
7
9
|
* Dispatches represent individual task assignments to a role.
|
|
8
10
|
* Relationship: Session 1:N Dispatch (a persistent session can receive multiple dispatches).
|
|
9
11
|
*/
|
|
10
12
|
import type { AgentType, SessionRecord, SessionStatus, DispatchRecord, DispatchStatus } from './types.js';
|
|
11
|
-
export declare function readSessions(projectName: string, iteration: number): Promise<SessionRecord[]>;
|
|
12
|
-
export declare function createSession(projectName: string, iteration: number, role: string, agentType?: AgentType, label?: string): Promise<SessionRecord>;
|
|
13
|
+
export declare function readSessions(projectName: string, iteration: number, contextDir?: string): Promise<SessionRecord[]>;
|
|
14
|
+
export declare function createSession(projectName: string, iteration: number, role: string, agentType?: AgentType, label?: string, contextDir?: string): Promise<SessionRecord>;
|
|
13
15
|
export declare function updateSession(projectName: string, iteration: number, sessionId: string, updates: {
|
|
14
16
|
status?: SessionStatus;
|
|
15
17
|
agentSessionId?: string;
|
|
16
18
|
agentType?: AgentType;
|
|
17
19
|
label?: string;
|
|
18
|
-
}): Promise<SessionRecord>;
|
|
20
|
+
}, contextDir?: string): Promise<SessionRecord>;
|
|
19
21
|
/**
|
|
20
22
|
* Find an idle session for a given role (for session reuse).
|
|
21
23
|
* Returns the most recently active idle session, or null if none found.
|
|
22
24
|
*/
|
|
23
|
-
export declare function findIdleSession(projectName: string, iteration: number, role: string): Promise<SessionRecord | null>;
|
|
25
|
+
export declare function findIdleSession(projectName: string, iteration: number, role: string, contextDir?: string): Promise<SessionRecord | null>;
|
|
24
26
|
/**
|
|
25
27
|
* Find a session by its agent session ID (for correlating external sessions).
|
|
26
28
|
*/
|
|
27
|
-
export declare function findSessionByAgentId(projectName: string, iteration: number, role: string, agentSessionId: string): Promise<SessionRecord | null>;
|
|
28
|
-
export declare function readDispatches(projectName: string, iteration: number): Promise<DispatchRecord[]>;
|
|
29
|
-
export declare function createDispatch(projectName: string, iteration: number, role: string, taskBrief: string, expectedOutputs: string[], sessionId?: string): Promise<DispatchRecord>;
|
|
29
|
+
export declare function findSessionByAgentId(projectName: string, iteration: number, role: string, agentSessionId: string, contextDir?: string): Promise<SessionRecord | null>;
|
|
30
|
+
export declare function readDispatches(projectName: string, iteration: number, contextDir?: string): Promise<DispatchRecord[]>;
|
|
31
|
+
export declare function createDispatch(projectName: string, iteration: number, role: string, taskBrief: string, expectedOutputs: string[], sessionId?: string, contextDir?: string, nodeId?: string): Promise<DispatchRecord>;
|
|
30
32
|
export declare function updateDispatch(projectName: string, iteration: number, dispatchId: string, updates: {
|
|
31
33
|
status?: DispatchStatus;
|
|
32
34
|
sessionId?: string;
|
|
33
35
|
note?: string;
|
|
34
|
-
}): Promise<DispatchRecord>;
|
|
36
|
+
}, contextDir?: string): Promise<DispatchRecord>;
|
|
35
37
|
/**
|
|
36
38
|
* Get a single dispatch record by ID.
|
|
37
39
|
*/
|
|
38
|
-
export declare function getDispatch(projectName: string, iteration: number, dispatchId: string): Promise<DispatchRecord | null>;
|
|
40
|
+
export declare function getDispatch(projectName: string, iteration: number, dispatchId: string, contextDir?: string): Promise<DispatchRecord | null>;
|
|
39
41
|
/** Valid state transitions for dispatch status. */
|
|
40
42
|
export declare const DISPATCH_TRANSITIONS: Record<DispatchStatus, DispatchStatus[]>;
|
|
41
43
|
/**
|
|
@@ -46,3 +48,8 @@ export declare function isValidTransition(from: DispatchStatus, to: DispatchStat
|
|
|
46
48
|
* Check if a dispatch status is terminal (no further transitions allowed).
|
|
47
49
|
*/
|
|
48
50
|
export declare function isTerminalStatus(status: DispatchStatus): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Check if a role has any running dispatches (status: 'dispatched' or 'running').
|
|
53
|
+
* Used by parallel dispatch logic to decide whether to force a new session.
|
|
54
|
+
*/
|
|
55
|
+
export declare function hasRunningDispatch(projectName: string, iteration: number, role: string, contextDir?: string): Promise<boolean>;
|