@agentic-coding-framework/orchestrator-core 0.1.2 → 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/dist/cli.js CHANGED
@@ -8,6 +8,7 @@
8
8
  * start-story <project-root> <story-id> Begin a new User Story (micro-waterfall)
9
9
  * start-custom <project-root> <instruction> Begin a custom ad-hoc task
10
10
  * dispatch <project-root> Dispatch next step (prints prompt)
11
+ * peek <project-root> [FIX P1] Read-only dispatch preview
11
12
  * apply-handoff <project-root> Parse HANDOFF.md → update STATE
12
13
  * approve <project-root> [note] Approve review step
13
14
  * reject <project-root> <reason> [note] Reject review step
@@ -18,15 +19,18 @@ const path_1 = require("path");
18
19
  const child_process_1 = require("child_process");
19
20
  const state_1 = require("./state");
20
21
  const dispatch_1 = require("./dispatch");
22
+ const auto_1 = require("./auto");
21
23
  const [, , command, ...args] = process.argv;
22
24
  function usage() {
23
25
  console.error(`Usage: orchestrator <command> [args]
24
26
 
25
27
  Commands:
28
+ auto <project-root> <message...> Unified entry — classify message & route automatically
26
29
  init <project-root> <project-name> Initialize .ai/STATE.json
27
30
  start-story <project-root> <story-id> Begin a new User Story (micro-waterfall)
28
31
  start-custom <project-root> <instruction> Begin a custom ad-hoc task
29
32
  dispatch <project-root> Dispatch next step (prints prompt to stdout)
33
+ peek <project-root> [NEW] Read-only dispatch preview (no state mutation)
30
34
  apply-handoff <project-root> Parse HANDOFF.md → update STATE.json
31
35
  post-check <project-root> Run step's post_check command
32
36
  approve <project-root> [note] Approve review step
@@ -47,6 +51,53 @@ function resolveRoot(raw) {
47
51
  }
48
52
  try {
49
53
  switch (command) {
54
+ case "auto": {
55
+ const projectRoot = resolveRoot(args[0]);
56
+ const message = args.slice(1).join(" ");
57
+ if (!message) {
58
+ console.error("Error: <message> is required");
59
+ console.error('Example: orchestrator auto ./project "目前狀態如何"');
60
+ process.exit(1);
61
+ }
62
+ const result = (0, auto_1.auto)(projectRoot, message);
63
+ // JSON to stdout (machine-readable)
64
+ console.log(JSON.stringify(result, null, 2));
65
+ // Human-friendly summary to stderr
66
+ switch (result.action) {
67
+ case "query":
68
+ console.error(`[auto] Query: ${result.data.project} — step=${result.data.step}, status=${result.data.status}`);
69
+ break;
70
+ case "dispatched":
71
+ console.error(`[auto] Dispatched: step=${result.step}, attempt=${result.attempt}, fw_lv=${result.fw_lv}`);
72
+ break;
73
+ case "done":
74
+ console.error(`[auto] Done: ${result.summary}`);
75
+ break;
76
+ case "needs_human":
77
+ console.error(`[auto] Needs human: ${result.message}`);
78
+ break;
79
+ case "blocked":
80
+ console.error(`[auto] Blocked: ${result.reason}`);
81
+ break;
82
+ case "approved":
83
+ console.error(`[auto] Approved${result.note ? ` (note: ${result.note})` : ""}`);
84
+ break;
85
+ case "rejected":
86
+ console.error(`[auto] Rejected: ${result.reason}${result.note ? ` — ${result.note}` : ""}`);
87
+ break;
88
+ case "detected":
89
+ console.error(`[auto] Framework level: ${result.framework.level}`);
90
+ break;
91
+ case "listed":
92
+ console.error(`[auto] Found ${result.projects.length} project(s)`);
93
+ break;
94
+ case "error":
95
+ console.error(`[auto] Error: ${result.message}`);
96
+ process.exit(1);
97
+ break;
98
+ }
99
+ break;
100
+ }
50
101
  case "init": {
51
102
  const projectRoot = resolveRoot(args[0]);
52
103
  const projectName = args[1];
@@ -61,6 +112,11 @@ try {
61
112
  else {
62
113
  console.log(`STATE.json already exists (step: ${state.step}, status: ${state.status})`);
63
114
  }
115
+ // Always ensure CLAUDE.md exists (idempotent, won't overwrite)
116
+ const claudeCreated = (0, state_1.writeClaudeMd)(projectRoot, projectName);
117
+ if (claudeCreated) {
118
+ console.log(`Created CLAUDE.md (CC will auto-detect ACF on session start)`);
119
+ }
64
120
  break;
65
121
  }
66
122
  case "start-story": {
@@ -84,7 +140,10 @@ try {
84
140
  }
85
141
  const label = args[2] || undefined; // optional label
86
142
  const agentTeams = args[3] === "--agent-teams";
87
- const state = (0, dispatch_1.startCustom)(projectRoot, instruction, { label, agentTeams });
143
+ const state = (0, dispatch_1.startCustom)(projectRoot, instruction, {
144
+ label,
145
+ agentTeams,
146
+ });
88
147
  console.log(`Started custom task: "${instruction}"`);
89
148
  console.log(` label: ${state.story}, step: ${state.step}, task_type: ${state.task_type}`);
90
149
  break;
@@ -108,14 +167,46 @@ try {
108
167
  break;
109
168
  case "blocked":
110
169
  console.error(`[dispatch] BLOCKED: ${result.reason}`);
111
- process.exit(1);
170
+ // [FIX P1] Use exit(0) — blocked is an expected orchestrator state,
171
+ // not an error. exit(1) breaks dispatch-claude-code.sh (set -e).
172
+ process.exit(0);
112
173
  break;
113
174
  case "already_running":
114
175
  console.error(`[dispatch] Already running (${result.elapsed_min} min)`);
115
176
  break;
116
177
  case "timeout":
117
178
  console.error(`[dispatch] TIMEOUT at ${result.step} (${result.elapsed_min} min)`);
118
- process.exit(1);
179
+ // [FIX P1] Use exit(0) — timeout is an expected orchestrator state.
180
+ // exit(1) would abort dispatch-claude-code.sh before it can retry.
181
+ process.exit(0);
182
+ break;
183
+ }
184
+ break;
185
+ }
186
+ // [FIX P1] New command: read-only dispatch preview
187
+ case "peek": {
188
+ const projectRoot = resolveRoot(args[0]);
189
+ const result = (0, dispatch_1.peek)(projectRoot);
190
+ switch (result.type) {
191
+ case "dispatched":
192
+ console.log(result.prompt);
193
+ console.error(`[peek] Would dispatch: step=${result.step} attempt=${result.attempt}`);
194
+ break;
195
+ case "done":
196
+ console.error(`[peek] DONE: ${result.summary}`);
197
+ break;
198
+ case "needs_human":
199
+ console.error(`[peek] NEEDS HUMAN REVIEW`);
200
+ console.error(result.message);
201
+ break;
202
+ case "blocked":
203
+ console.error(`[peek] BLOCKED: ${result.reason}`);
204
+ break;
205
+ case "already_running":
206
+ console.error(`[peek] Already running (${result.elapsed_min} min)`);
207
+ break;
208
+ case "timeout":
209
+ console.error(`[peek] TIMEOUT at ${result.step} (${result.elapsed_min} min)`);
119
210
  break;
120
211
  }
121
212
  break;
@@ -172,7 +263,11 @@ try {
172
263
  const projectRoot = resolveRoot(args[0]);
173
264
  const result = (0, dispatch_1.detectFramework)(projectRoot);
174
265
  console.log(JSON.stringify(result, null, 2));
175
- const levelNames = ["Not adopted", "Partial adoption", "Full adoption"];
266
+ const levelNames = [
267
+ "Not adopted",
268
+ "Partial adoption",
269
+ "Full adoption",
270
+ ];
176
271
  console.error(`Framework adoption: Level ${result.level} — ${levelNames[result.level]}`);
177
272
  break;
178
273
  }
@@ -198,3 +293,4 @@ catch (err) {
198
293
  console.error(`Error: ${err.message}`);
199
294
  process.exit(1);
200
295
  }
296
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;AACA;;;;;;;;;;;;;GAaG;;AAEH,+BAA+B;AAC/B,iDAAyC;AACzC,mCAA8D;AAC9D,yCAYoB;AACpB,iCAA8B;AAE9B,MAAM,CAAC,EAAE,AAAD,EAAG,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;AAE5C,SAAS,KAAK;IACZ,OAAO,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;;CAiBf,CAAC,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,SAAS,WAAW,CAAC,GAAuB;IAC1C,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACnD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,IAAA,cAAO,EAAC,GAAG,CAAC,CAAC;AACtB,CAAC;AAED,IAAI,CAAC;IACH,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,MAAM,CAAC,CAAC,CAAC;YACZ,MAAM,WAAW,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YACzC,MAAM,OAAO,GAAG,IAAI,CAAC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,EAAE,CAAC;gBACZ,OAAO,CAAC,KAAK,CAAC,oBAAoB,OAAO,EAAE,CAAC,CAAC;YAC/C,CAAC;YACD,KAAK,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAAC,OAAO,GAAY,EAAE,CAAC;IACtB,OAAO,CAAC,KAAK,CAAC,UAAW,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;IAClD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
@@ -5,35 +5,37 @@
5
5
  * to drive the micro-waterfall pipeline. All decisions are deterministic —
6
6
  * zero LLM tokens.
7
7
  *
8
- * Main entry point: dispatch(projectRoot)
8
+ * Main entry points:
9
+ * dispatch(projectRoot) — dispatch next step (mutates STATE)
10
+ * peek(projectRoot) — [FIX P1] read-only dispatch preview (no mutation)
9
11
  */
10
- import { type State, type Step, type Status, type Reason } from "./state";
11
- import { type StepRule } from "./rules";
12
+ import { State } from "./state";
13
+ import { StepRule } from "./rules";
12
14
  export type DispatchResult = {
13
15
  type: "dispatched";
14
- step: Step;
16
+ step: string;
15
17
  attempt: number;
16
18
  prompt: string;
17
- fw_lv: 0 | 1 | 2;
19
+ fw_lv: number;
18
20
  } | {
19
- type: "blocked";
20
- step: Step;
21
- reason: string;
21
+ type: "done";
22
+ story: string;
23
+ summary: string;
22
24
  } | {
23
25
  type: "needs_human";
24
- step: Step;
26
+ step: string;
25
27
  message: string;
26
28
  } | {
27
- type: "done";
28
- story: string;
29
- summary: string;
29
+ type: "blocked";
30
+ step: string;
31
+ reason: string;
30
32
  } | {
31
33
  type: "already_running";
32
- step: Step;
34
+ step: string;
33
35
  elapsed_min: number;
34
36
  } | {
35
37
  type: "timeout";
36
- step: Step;
38
+ step: string;
37
39
  elapsed_min: number;
38
40
  };
39
41
  /**
@@ -47,30 +49,38 @@ export type DispatchResult = {
47
49
  * steps, etc.).
48
50
  */
49
51
  export declare function dispatch(projectRoot: string): DispatchResult;
52
+ /**
53
+ * [FIX P1] Read-only dispatch preview — returns the same DispatchResult
54
+ * as dispatch() but never writes to STATE.json.
55
+ *
56
+ * Use cases:
57
+ * - dispatch-claude-code.sh: check if dispatch would succeed before committing
58
+ * - Monitoring / debugging without state contamination
59
+ * - OpenClaw dry-run checks
60
+ */
61
+ export declare function peek(projectRoot: string): DispatchResult;
50
62
  /**
51
63
  * Build the dispatch prompt from the template.
52
64
  * Pure template filling — zero LLM reasoning.
53
65
  */
54
66
  export declare function buildPrompt(state: State, rule: StepRule): string;
55
- /** Parsed result from HANDOFF.md's YAML front matter */
56
- export interface HandoffResult {
67
+ export interface HandoffData {
57
68
  story: string | null;
58
69
  step: string | null;
59
70
  attempt: number | null;
60
- status: Status | null;
61
- reason: Reason | null;
71
+ status: string | null;
72
+ reason: string | null;
62
73
  files_changed: string[];
63
74
  tests_pass: number | null;
64
75
  tests_fail: number | null;
65
76
  tests_skip: number | null;
66
- /** The markdown body (everything after the second ---) */
67
77
  body: string;
68
78
  }
69
79
  /**
70
80
  * Parse HANDOFF.md — prioritize YAML front matter, fallback to grep.
71
81
  * Direct translation of Protocol's hook pseudocode.
72
82
  */
73
- export declare function parseHandoff(projectRoot: string): HandoffResult | null;
83
+ export declare function parseHandoff(projectRoot: string): HandoffData | null;
74
84
  /**
75
85
  * After executor exits, read HANDOFF.md and update STATE.json accordingly.
76
86
  * This is the TypeScript equivalent of the Protocol's post-execution hook.
@@ -93,7 +103,7 @@ export declare function approveReview(projectRoot: string, humanNote?: string):
93
103
  /**
94
104
  * Reject the review with a reason and optional note.
95
105
  */
96
- export declare function rejectReview(projectRoot: string, reason: Reason, humanNote?: string): void;
106
+ export declare function rejectReview(projectRoot: string, reason: string, humanNote?: string): void;
97
107
  /**
98
108
  * Begin a new User Story. Resets state to bdd step with attempt 1.
99
109
  * Auto-initializes STATE.json if the project hasn't adopted the framework yet.
@@ -102,33 +112,10 @@ export declare function startStory(projectRoot: string, storyId: string, options
102
112
  agentTeams?: boolean;
103
113
  }): State;
104
114
  /**
105
- * Get a human-friendly project status summary.
106
- * OpenClaw calls this when the user asks "how's the project?" or "open project X".
107
- *
108
- * Returns structured data that OpenClaw LLM can translate to natural language.
115
+ * Detect whether a project uses the Agentic Coding Framework.
116
+ * OpenClaw calls this when the user asks "is this project using the framework?"
109
117
  */
110
- export interface ProjectStatus {
111
- project: string;
112
- task_type: string;
113
- story: string | null;
114
- step: string;
115
- status: string;
116
- attempt: number;
117
- max_attempts: number;
118
- reason: string | null;
119
- tests: {
120
- pass: number;
121
- fail: number;
122
- skip: number;
123
- } | null;
124
- lint_pass: boolean | null;
125
- files_changed: string[];
126
- blocked_by: string[];
127
- human_note: string | null;
128
- memory_summary: string | null;
129
- has_framework: FrameworkDetection;
130
- }
131
- export interface FrameworkDetection {
118
+ export declare function detectFramework(projectRoot: string): {
132
119
  has_state: boolean;
133
120
  has_memory: boolean;
134
121
  has_context: boolean;
@@ -136,62 +123,25 @@ export interface FrameworkDetection {
136
123
  has_sdd: boolean;
137
124
  has_handoff: boolean;
138
125
  has_history: boolean;
139
- /** Adoption level: 0 = none, 1 = partial (some files), 2 = full (all core files) */
140
- level: 0 | 1 | 2;
141
- }
142
- /**
143
- * Detect whether a project uses the Agentic Coding Framework.
144
- * OpenClaw calls this when the user asks "is this project using the framework?"
145
- */
146
- export declare function detectFramework(projectRoot: string): FrameworkDetection;
126
+ level: number;
127
+ };
147
128
  /**
148
129
  * Get comprehensive project status for OpenClaw to summarize to the user.
149
- * Works for ANY project — with or without the Agentic Coding Framework.
150
- *
151
- * - Framework project (has STATE.json): returns full state + memory summary
152
- * - Non-framework project: returns framework detection + whatever files exist
153
130
  */
154
- export declare function queryProjectStatus(projectRoot: string): ProjectStatus;
155
- /** Project entry returned by listProjects */
156
- export interface ProjectEntry {
157
- /** Project name (from STATE.json, package.json, or directory name) */
158
- name: string;
159
- /** Directory name relative to workspace root */
160
- dir: string;
161
- /** Current step ("none" if not using framework) */
162
- step: string;
163
- /** Current status ("not_initialized" if not using framework) */
164
- status: string;
165
- /** Current story ID */
166
- story: string | null;
167
- /** Whether this project uses the Agentic Coding Framework */
168
- has_framework: boolean;
169
- }
131
+ export declare function queryProjectStatus(projectRoot: string): Record<string, unknown>;
170
132
  /**
171
- * Scan a workspace directory for all projects — both framework and non-framework.
172
- * OpenClaw calls this when the user asks "list my projects" or "switch project".
173
- *
174
- * A directory is considered a "project" if it contains any of:
175
- * - .ai/STATE.json (framework project)
176
- * - package.json (Node.js project)
177
- * - go.mod (Go project)
178
- * - Cargo.toml (Rust project)
179
- * - pyproject.toml or setup.py (Python project)
180
- * - .git/ (any git repo)
133
+ * Scan a workspace directory for all projects.
181
134
  */
182
- export declare function listProjects(workspaceRoot: string): ProjectEntry[];
135
+ export declare function listProjects(workspaceRoot: string): Record<string, unknown>[];
183
136
  /**
184
137
  * Begin a custom (ad-hoc) task. The orchestrator forwards the instruction
185
138
  * to Claude Code with full project context, without going through the
186
139
  * micro-waterfall pipeline.
187
140
  *
188
141
  * Pipeline: custom → update-memory → done
189
- * Auto-initializes STATE.json if the project hasn't adopted the framework yet.
190
- *
191
- * Use cases: refactoring, code review, bug fix, DevOps, documentation,
192
- * testing, migration, performance optimization, security, cleanup, etc.
193
142
  */
194
143
  export declare function startCustom(projectRoot: string, instruction: string, options?: {
195
144
  label?: string;
196
145
  agentTeams?: boolean;
197
146
  }): State;
147
+ //# sourceMappingURL=dispatch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../src/dispatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,EAOL,KAAK,EACN,MAAM,SAAS,CAAC;AACjB,OAAO,EAIL,QAAQ,EACT,MAAM,SAAS,CAAC;AAIjB,MAAM,MAAM,cAAc,GACtB;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,M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