astrocode-workflow 0.1.35 → 0.1.40
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/agents/prompts.d.ts +1 -1
- package/dist/agents/prompts.js +7 -1
- package/dist/tools/stage.js +6 -7
- package/dist/tools/workflow.js +12 -0
- package/dist/workflow/baton.js +19 -4
- package/package.json +1 -1
- package/src/agents/prompts.ts +7 -1
- package/src/tools/stage.ts +6 -7
- package/src/tools/workflow.ts +19 -5
- package/src/workflow/baton.ts +20 -4
package/dist/agents/prompts.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const BASE_ORCH_PROMPT = "You are Astro (Orchestrator) for Astrocode.\n\nMission:\n- Advance a deterministic pipeline: frame \u2192 plan \u2192 spec \u2192 implement \u2192 review \u2192 verify \u2192 close.\n- The SQLite DB is the source of truth. Prefer tools over prose.\n- Never narrate what prompts you received.\n- Keep outputs short; store large outputs as artifacts and reference paths.\n\nOperating rules:\n- Only start new runs when the user explicitly requests implementation, workflow management, or story processing.\n- Answer questions directly when possible without starting workflows.\n- Prefer calling astro_workflow_proceed (step/loop) and astro_status only when actively managing a workflow.\n- Delegate stage work only to the stage subagent matching the current stage.\n- If a stage subagent returns status=blocked, inject the BLOCKED directive and stop.\n- Never delegate from subagents (enforced by permissions).\n- Be discretionary: assess if the user's request requires workflow initiation or just information.\n";
|
|
2
|
-
export declare const BASE_STAGE_PROMPT = "You are an Astro stage subagent.\n\n***CRITICAL: Follow the latest [SYSTEM DIRECTIVE: ASTROCODE \u2014 STAGE_*] you receive EXACTLY.***\n\nYour output MUST be in this EXACT format
|
|
2
|
+
export declare const BASE_STAGE_PROMPT = "You are an Astro stage subagent.\n\n***CRITICAL: Follow the latest [SYSTEM DIRECTIVE: ASTROCODE \u2014 STAGE_*] you receive EXACTLY.***\n\nYour output MUST be in this EXACT format:\n\n1) First, a short summary paragraph (1-3 sentences).\n\n2) Then, immediately after, the ASTRO JSON between markers:\n\n<!-- ASTRO_JSON_BEGIN -->\n{\n \"stage_key\": \"CURRENT_STAGE\",\n \"status\": \"ok\",\n \"summary\": \"Brief summary of work done\",\n \"tasks\": [],\n \"files\": [],\n \"questions\": []\n}\n<!-- ASTRO_JSON_END -->\n\nMANDATORY:\n- stage_key must be \"CURRENT_STAGE\"\n- status must be \"ok\", \"blocked\", or \"failed\"\n- summary must be a non-empty string\n- tasks, files, questions must be ARRAYS (use [] for empty)\n- JSON must be valid syntax\n- Use exact markers shown above\n\nARRAY FORMAT EXAMPLES:\n- tasks: [{\"title\": \"Task name\", \"complexity\": 3}]\n- files: [{\"path\": \"file.js\", \"kind\": \"file\"}]\n- questions: [\"What framework to use?\"]\n\nEXAMPLE OUTPUT:\nI analyzed the requirements and identified key components for implementation.\n\n<!-- ASTRO_JSON_BEGIN -->\n{\n \"stage_key\": \"plan\",\n \"status\": \"ok\",\n \"summary\": \"Created implementation plan with 5 main tasks\",\n \"tasks\": [\n {\"title\": \"Setup database\", \"complexity\": 3},\n {\"title\": \"Build API endpoints\", \"complexity\": 5}\n ],\n \"files\": [\n {\"path\": \"schema.prisma\", \"kind\": \"file\"}\n ],\n \"questions\": []\n}\n<!-- ASTRO_JSON_END -->\n\nIf blocked, set status=\"blocked\" and add ONE question to questions array. Do not deviate from this format.\n";
|
package/dist/agents/prompts.js
CHANGED
|
@@ -19,7 +19,7 @@ export const BASE_STAGE_PROMPT = `You are an Astro stage subagent.
|
|
|
19
19
|
|
|
20
20
|
***CRITICAL: Follow the latest [SYSTEM DIRECTIVE: ASTROCODE — STAGE_*] you receive EXACTLY.***
|
|
21
21
|
|
|
22
|
-
Your output MUST be in this EXACT format
|
|
22
|
+
Your output MUST be in this EXACT format:
|
|
23
23
|
|
|
24
24
|
1) First, a short summary paragraph (1-3 sentences).
|
|
25
25
|
|
|
@@ -40,9 +40,15 @@ MANDATORY:
|
|
|
40
40
|
- stage_key must be "CURRENT_STAGE"
|
|
41
41
|
- status must be "ok", "blocked", or "failed"
|
|
42
42
|
- summary must be a non-empty string
|
|
43
|
+
- tasks, files, questions must be ARRAYS (use [] for empty)
|
|
43
44
|
- JSON must be valid syntax
|
|
44
45
|
- Use exact markers shown above
|
|
45
46
|
|
|
47
|
+
ARRAY FORMAT EXAMPLES:
|
|
48
|
+
- tasks: [{"title": "Task name", "complexity": 3}]
|
|
49
|
+
- files: [{"path": "file.js", "kind": "file"}]
|
|
50
|
+
- questions: ["What framework to use?"]
|
|
51
|
+
|
|
46
52
|
EXAMPLE OUTPUT:
|
|
47
53
|
I analyzed the requirements and identified key components for implementation.
|
|
48
54
|
|
package/dist/tools/stage.js
CHANGED
|
@@ -126,10 +126,10 @@ Expected format:
|
|
|
126
126
|
"summary": "Brief summary",
|
|
127
127
|
"decisions": [],
|
|
128
128
|
"next_actions": [],
|
|
129
|
-
"tasks": [],
|
|
130
|
-
"files": [],
|
|
131
|
-
"evidence": [],
|
|
132
|
-
"new_stories": [],
|
|
129
|
+
"tasks": [{"title": "Task name", "complexity": 3}],
|
|
130
|
+
"files": [{"path": "file.js", "kind": "file"}],
|
|
131
|
+
"evidence": [{"path": "test.js", "kind": "evidence"}],
|
|
132
|
+
"new_stories": [{"title": "Story title", "body_md": "Description"}],
|
|
133
133
|
"questions": [],
|
|
134
134
|
"metrics": {}
|
|
135
135
|
}
|
|
@@ -137,9 +137,8 @@ Expected format:
|
|
|
137
137
|
|
|
138
138
|
Ensure JSON has required fields (stage_key, status) and valid syntax.`;
|
|
139
139
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
140
|
+
// Override stage_key to match the expected stage (agents sometimes get this wrong)
|
|
141
|
+
parsed.astro_json.stage_key = sk;
|
|
143
142
|
// Context validation (warnings, not errors)
|
|
144
143
|
if (parsed.astro_json.run_id && parsed.astro_json.run_id !== rid) {
|
|
145
144
|
console.warn(`[Astrocode] ⚠️ Run ID mismatch in baton: expected "${rid}", got "${parsed.astro_json.run_id}". Proceeding anyway.`);
|
package/dist/tools/workflow.js
CHANGED
|
@@ -234,6 +234,18 @@ export function createAstroWorkflowProceedTool(opts) {
|
|
|
234
234
|
// Visible injection so user can see state
|
|
235
235
|
if (sessionId) {
|
|
236
236
|
await injectChatPrompt({ ctx, sessionId, text: delegatePrompt, agent: "Astro" });
|
|
237
|
+
// Inject continuation guidance
|
|
238
|
+
const continueMessage = [
|
|
239
|
+
`[SYSTEM DIRECTIVE: ASTROCODE — AWAIT_STAGE_COMPLETION]`,
|
|
240
|
+
``,
|
|
241
|
+
`Stage ${next.stage_key} delegated to ${agentName}.`,
|
|
242
|
+
``,
|
|
243
|
+
`When ${agentName} completes, call:`,
|
|
244
|
+
`astro_stage_complete(run_id="${active.run_id}", stage_key="${next.stage_key}", output_text="[paste subagent output here]")`,
|
|
245
|
+
``,
|
|
246
|
+
`This advances the workflow.`,
|
|
247
|
+
].join("\n");
|
|
248
|
+
await injectChatPrompt({ ctx, sessionId, text: continueMessage, agent: "Astro" });
|
|
237
249
|
}
|
|
238
250
|
actions.push(`delegated stage ${next.stage_key} via ${agentName}`);
|
|
239
251
|
// Stop here; subagent needs to run.
|
package/dist/workflow/baton.js
CHANGED
|
@@ -75,11 +75,26 @@ export function parseStageOutputText(text) {
|
|
|
75
75
|
catch (e) {
|
|
76
76
|
// Not JSON, proceed with marker error
|
|
77
77
|
}
|
|
78
|
+
// If no JSON found, create a default structure from the text
|
|
79
|
+
const defaultJson = {
|
|
80
|
+
schema_version: 1,
|
|
81
|
+
stage_key: "frame", // Default, will be overridden by actual stage_key
|
|
82
|
+
status: "ok",
|
|
83
|
+
summary: norm.trim() || "Stage completed without structured output",
|
|
84
|
+
decisions: [],
|
|
85
|
+
next_actions: [],
|
|
86
|
+
tasks: [],
|
|
87
|
+
files: [],
|
|
88
|
+
evidence: [],
|
|
89
|
+
new_stories: [],
|
|
90
|
+
questions: [],
|
|
91
|
+
metrics: {}
|
|
92
|
+
};
|
|
78
93
|
return {
|
|
79
|
-
baton_md:
|
|
80
|
-
astro_json:
|
|
81
|
-
astro_json_raw: null,
|
|
82
|
-
error:
|
|
94
|
+
baton_md: "",
|
|
95
|
+
astro_json: defaultJson,
|
|
96
|
+
astro_json_raw: JSON.stringify(defaultJson, null, 2),
|
|
97
|
+
error: null
|
|
83
98
|
};
|
|
84
99
|
}
|
|
85
100
|
const before = norm.slice(0, beginIdx).trim();
|
package/package.json
CHANGED
package/src/agents/prompts.ts
CHANGED
|
@@ -20,7 +20,7 @@ export const BASE_STAGE_PROMPT = `You are an Astro stage subagent.
|
|
|
20
20
|
|
|
21
21
|
***CRITICAL: Follow the latest [SYSTEM DIRECTIVE: ASTROCODE — STAGE_*] you receive EXACTLY.***
|
|
22
22
|
|
|
23
|
-
Your output MUST be in this EXACT format
|
|
23
|
+
Your output MUST be in this EXACT format:
|
|
24
24
|
|
|
25
25
|
1) First, a short summary paragraph (1-3 sentences).
|
|
26
26
|
|
|
@@ -41,9 +41,15 @@ MANDATORY:
|
|
|
41
41
|
- stage_key must be "CURRENT_STAGE"
|
|
42
42
|
- status must be "ok", "blocked", or "failed"
|
|
43
43
|
- summary must be a non-empty string
|
|
44
|
+
- tasks, files, questions must be ARRAYS (use [] for empty)
|
|
44
45
|
- JSON must be valid syntax
|
|
45
46
|
- Use exact markers shown above
|
|
46
47
|
|
|
48
|
+
ARRAY FORMAT EXAMPLES:
|
|
49
|
+
- tasks: [{"title": "Task name", "complexity": 3}]
|
|
50
|
+
- files: [{"path": "file.js", "kind": "file"}]
|
|
51
|
+
- questions: ["What framework to use?"]
|
|
52
|
+
|
|
47
53
|
EXAMPLE OUTPUT:
|
|
48
54
|
I analyzed the requirements and identified key components for implementation.
|
|
49
55
|
|
package/src/tools/stage.ts
CHANGED
|
@@ -162,10 +162,10 @@ Expected format:
|
|
|
162
162
|
"summary": "Brief summary",
|
|
163
163
|
"decisions": [],
|
|
164
164
|
"next_actions": [],
|
|
165
|
-
"tasks": [],
|
|
166
|
-
"files": [],
|
|
167
|
-
"evidence": [],
|
|
168
|
-
"new_stories": [],
|
|
165
|
+
"tasks": [{"title": "Task name", "complexity": 3}],
|
|
166
|
+
"files": [{"path": "file.js", "kind": "file"}],
|
|
167
|
+
"evidence": [{"path": "test.js", "kind": "evidence"}],
|
|
168
|
+
"new_stories": [{"title": "Story title", "body_md": "Description"}],
|
|
169
169
|
"questions": [],
|
|
170
170
|
"metrics": {}
|
|
171
171
|
}
|
|
@@ -174,9 +174,8 @@ Expected format:
|
|
|
174
174
|
Ensure JSON has required fields (stage_key, status) and valid syntax.`;
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
177
|
+
// Override stage_key to match the expected stage (agents sometimes get this wrong)
|
|
178
|
+
parsed.astro_json.stage_key = sk;
|
|
180
179
|
|
|
181
180
|
// Context validation (warnings, not errors)
|
|
182
181
|
if (parsed.astro_json.run_id && parsed.astro_json.run_id !== rid) {
|
package/src/tools/workflow.ts
CHANGED
|
@@ -282,12 +282,26 @@ export function createAstroWorkflowProceedTool(opts: { ctx: any; config: Astroco
|
|
|
282
282
|
).run(sessionId, active.run_id, h, `delegate ${next.stage_key}`, now);
|
|
283
283
|
}
|
|
284
284
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
285
|
+
// Visible injection so user can see state
|
|
286
|
+
if (sessionId) {
|
|
287
|
+
await injectChatPrompt({ ctx, sessionId, text: delegatePrompt, agent: "Astro" });
|
|
288
|
+
|
|
289
|
+
// Inject continuation guidance
|
|
290
|
+
const continueMessage = [
|
|
291
|
+
`[SYSTEM DIRECTIVE: ASTROCODE — AWAIT_STAGE_COMPLETION]`,
|
|
292
|
+
``,
|
|
293
|
+
`Stage ${next.stage_key} delegated to ${agentName}.`,
|
|
294
|
+
``,
|
|
295
|
+
`When ${agentName} completes, call:`,
|
|
296
|
+
`astro_stage_complete(run_id="${active.run_id}", stage_key="${next.stage_key}", output_text="[paste subagent output here]")`,
|
|
297
|
+
``,
|
|
298
|
+
`This advances the workflow.`,
|
|
299
|
+
].join("\n");
|
|
300
|
+
|
|
301
|
+
await injectChatPrompt({ ctx, sessionId, text: continueMessage, agent: "Astro" });
|
|
302
|
+
}
|
|
289
303
|
|
|
290
|
-
|
|
304
|
+
actions.push(`delegated stage ${next.stage_key} via ${agentName}`);
|
|
291
305
|
|
|
292
306
|
// Stop here; subagent needs to run.
|
|
293
307
|
break;
|
package/src/workflow/baton.ts
CHANGED
|
@@ -111,11 +111,27 @@ export function parseStageOutputText(text: string): ParsedStageOutput {
|
|
|
111
111
|
// Not JSON, proceed with marker error
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
+
// If no JSON found, create a default structure from the text
|
|
115
|
+
const defaultJson: AstroJson = {
|
|
116
|
+
schema_version: 1,
|
|
117
|
+
stage_key: "frame", // Default, will be overridden by actual stage_key
|
|
118
|
+
status: "ok",
|
|
119
|
+
summary: norm.trim() || "Stage completed without structured output",
|
|
120
|
+
decisions: [],
|
|
121
|
+
next_actions: [],
|
|
122
|
+
tasks: [],
|
|
123
|
+
files: [],
|
|
124
|
+
evidence: [],
|
|
125
|
+
new_stories: [],
|
|
126
|
+
questions: [],
|
|
127
|
+
metrics: {}
|
|
128
|
+
};
|
|
129
|
+
|
|
114
130
|
return {
|
|
115
|
-
baton_md:
|
|
116
|
-
astro_json:
|
|
117
|
-
astro_json_raw: null,
|
|
118
|
-
error:
|
|
131
|
+
baton_md: "",
|
|
132
|
+
astro_json: defaultJson,
|
|
133
|
+
astro_json_raw: JSON.stringify(defaultJson, null, 2),
|
|
134
|
+
error: null
|
|
119
135
|
};
|
|
120
136
|
}
|
|
121
137
|
|