astrocode-workflow 0.1.1 → 0.1.3

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.
@@ -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\nFollow the latest [SYSTEM DIRECTIVE: ASTROCODE \u2014 STAGE_*] you receive.\n\nOutput exactly:\n1) Baton markdown (short, structured)\n2) Valid ASTRO JSON between markers:\n<!-- ASTRO_JSON_BEGIN -->\n{...}\n<!-- ASTRO_JSON_END -->\n\nDo not narrate. If blocked, ask exactly ONE question and stop.\n";
2
+ export declare const BASE_STAGE_PROMPT = "You are an Astro stage subagent.\n\nFollow the latest [SYSTEM DIRECTIVE: ASTROCODE \u2014 STAGE_*] you receive.\n\nOutput exactly:\n1) Baton markdown (short, structured)\n2) Valid ASTRO JSON between markers with ALL required fields:\n<!-- ASTRO_JSON_BEGIN -->\n{\n \"stage_key\": \"CURRENT_STAGE\",\n \"status\": \"ok\",\n \"summary\": \"Brief summary of work done\",\n \"decisions\": [\"Decision 1\", \"Decision 2\"],\n \"next_actions\": [\"Action 1\", \"Action 2\"],\n \"files\": [{\"path\": \"file.js\", \"kind\": \"file\"}],\n \"evidence\": [{\"path\": \"test.js\", \"kind\": \"evidence\"}],\n \"tasks\": [{\"title\": \"Task\", \"complexity\": 3}],\n \"new_stories\": [{\"title\": \"Story\", \"body_md\": \"Desc\"}],\n \"questions\": [],\n \"metrics\": {\"lines\": 100}\n}\n<!-- ASTRO_JSON_END -->\n\nCRITICAL: Include stage_key, status, and summary in EVERY response. Use \"ok\" status unless blocked/failed.\n\nDo not narrate. If blocked, ask exactly ONE question and stop.\n";
@@ -21,10 +21,24 @@ Follow the latest [SYSTEM DIRECTIVE: ASTROCODE — STAGE_*] you receive.
21
21
 
22
22
  Output exactly:
23
23
  1) Baton markdown (short, structured)
24
- 2) Valid ASTRO JSON between markers:
24
+ 2) Valid ASTRO JSON between markers with ALL required fields:
25
25
  <!-- ASTRO_JSON_BEGIN -->
26
- {...}
26
+ {
27
+ "stage_key": "CURRENT_STAGE",
28
+ "status": "ok",
29
+ "summary": "Brief summary of work done",
30
+ "decisions": ["Decision 1", "Decision 2"],
31
+ "next_actions": ["Action 1", "Action 2"],
32
+ "files": [{"path": "file.js", "kind": "file"}],
33
+ "evidence": [{"path": "test.js", "kind": "evidence"}],
34
+ "tasks": [{"title": "Task", "complexity": 3}],
35
+ "new_stories": [{"title": "Story", "body_md": "Desc"}],
36
+ "questions": [],
37
+ "metrics": {"lines": 100}
38
+ }
27
39
  <!-- ASTRO_JSON_END -->
28
40
 
41
+ CRITICAL: Include stage_key, status, and summary in EVERY response. Use "ok" status unless blocked/failed.
42
+
29
43
  Do not narrate. If blocked, ask exactly ONE question and stop.
30
44
  `;
@@ -98,13 +98,13 @@ export function createAstroAgents(opts) {
98
98
  pluginConfig.agents = {
99
99
  orchestrator_name: "Astro",
100
100
  stage_agent_names: {
101
- frame: "AstroFrame",
102
- plan: "AstroPlan",
103
- spec: "AstroSpec",
104
- implement: "AstroImplement",
105
- review: "AstroReview",
106
- verify: "AstroVerify",
107
- close: "AstroClose"
101
+ frame: "Frame",
102
+ plan: "Plan",
103
+ spec: "Spec",
104
+ implement: "Implement",
105
+ review: "Review",
106
+ verify: "Verify",
107
+ close: "Close"
108
108
  },
109
109
  librarian_name: "Librarian",
110
110
  explore_name: "Explore",
@@ -129,13 +129,13 @@ const AgentsSchema = z.object({
129
129
  // Display names for the stage sub-agents.
130
130
  stage_agent_names: z
131
131
  .object({
132
- frame: z.string().default("Astro — Frame"),
133
- plan: z.string().default("Astro — Plan"),
134
- spec: z.string().default("Astro — Spec"),
135
- implement: z.string().default("Astro — Implement"),
136
- review: z.string().default("Astro — Review"),
137
- verify: z.string().default("Astro — Verify"),
138
- close: z.string().default("Astro — Close"),
132
+ frame: z.string().default("Frame"),
133
+ plan: z.string().default("Plan"),
134
+ spec: z.string().default("Spec"),
135
+ implement: z.string().default("Implement"),
136
+ review: z.string().default("Review"),
137
+ verify: z.string().default("Verify"),
138
+ close: z.string().default("Close"),
139
139
  })
140
140
  .partial()
141
141
  .default({}),
@@ -81,10 +81,10 @@ export function createAstroStageCompleteTool(opts) {
81
81
  }
82
82
  const parsed = parseStageOutputText(output_text);
83
83
  if (parsed.error || !parsed.astro_json) {
84
- return `❌ Stage completion failed: ${parsed.error ?? "ASTRO JSON missing"}. Please ensure output includes proper JSON markers.`;
84
+ return `❌ JSON Parse Error: ${parsed.error ?? "ASTRO JSON missing"}. Ensure output includes <!-- ASTRO_JSON_BEGIN -->{...}<!-- ASTRO_JSON_END --> markers with valid JSON.`;
85
85
  }
86
86
  if (parsed.astro_json.stage_key !== sk) {
87
- return `❌ Stage completion failed: ASTRO JSON stage_key mismatch (expected ${sk}, got ${parsed.astro_json.stage_key}).`;
87
+ return `❌ Stage Key Mismatch: ASTRO JSON has stage_key="${parsed.astro_json.stage_key}" but expected "${sk}". Update the JSON to match the current stage.`;
88
88
  }
89
89
  // Evidence requirement
90
90
  const evidenceRequired = (sk === "verify" && config.workflow.evidence_required.verify) ||
package/dist/ui/inject.js CHANGED
@@ -1,8 +1,10 @@
1
1
  let isInjecting = false;
2
+ let queuedInjection = null;
2
3
  export async function injectChatPrompt(opts) {
3
4
  const { ctx, sessionId, text } = opts;
4
- // Skip if already injecting (max 1 at a time, no queuing)
5
5
  if (isInjecting) {
6
+ // Replace any existing queued injection (keep only latest)
7
+ queuedInjection = opts;
6
8
  return;
7
9
  }
8
10
  isInjecting = true;
@@ -16,5 +18,12 @@ export async function injectChatPrompt(opts) {
16
18
  }
17
19
  finally {
18
20
  isInjecting = false;
21
+ // Process queued injection if any
22
+ if (queuedInjection) {
23
+ const next = queuedInjection;
24
+ queuedInjection = null;
25
+ // Schedule next injection asynchronously to prevent recursion
26
+ setImmediate(() => injectChatPrompt(next));
27
+ }
19
28
  }
20
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astrocode-workflow",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -18,7 +18,7 @@
18
18
  "dependencies": {
19
19
  "@opencode-ai/plugin": "^1.1.19",
20
20
  "@opencode-ai/sdk": "^1.1.19",
21
- "astrocode-workflow": "^0.0.5",
21
+ "astrocode-workflow": "^0.1.1",
22
22
  "jsonc-parser": "^3.2.0",
23
23
  "zod": "4.1.8"
24
24
  },
@@ -22,10 +22,24 @@ Follow the latest [SYSTEM DIRECTIVE: ASTROCODE — STAGE_*] you receive.
22
22
 
23
23
  Output exactly:
24
24
  1) Baton markdown (short, structured)
25
- 2) Valid ASTRO JSON between markers:
25
+ 2) Valid ASTRO JSON between markers with ALL required fields:
26
26
  <!-- ASTRO_JSON_BEGIN -->
27
- {...}
27
+ {
28
+ "stage_key": "CURRENT_STAGE",
29
+ "status": "ok",
30
+ "summary": "Brief summary of work done",
31
+ "decisions": ["Decision 1", "Decision 2"],
32
+ "next_actions": ["Action 1", "Action 2"],
33
+ "files": [{"path": "file.js", "kind": "file"}],
34
+ "evidence": [{"path": "test.js", "kind": "evidence"}],
35
+ "tasks": [{"title": "Task", "complexity": 3}],
36
+ "new_stories": [{"title": "Story", "body_md": "Desc"}],
37
+ "questions": [],
38
+ "metrics": {"lines": 100}
39
+ }
28
40
  <!-- ASTRO_JSON_END -->
29
41
 
42
+ CRITICAL: Include stage_key, status, and summary in EVERY response. Use "ok" status unless blocked/failed.
43
+
30
44
  Do not narrate. If blocked, ask exactly ONE question and stop.
31
45
  `;
@@ -126,13 +126,13 @@ export function createAstroAgents(opts: {
126
126
  pluginConfig.agents = {
127
127
  orchestrator_name: "Astro",
128
128
  stage_agent_names: {
129
- frame: "AstroFrame",
130
- plan: "AstroPlan",
131
- spec: "AstroSpec",
132
- implement: "AstroImplement",
133
- review: "AstroReview",
134
- verify: "AstroVerify",
135
- close: "AstroClose"
129
+ frame: "Frame",
130
+ plan: "Plan",
131
+ spec: "Spec",
132
+ implement: "Implement",
133
+ review: "Review",
134
+ verify: "Verify",
135
+ close: "Close"
136
136
  },
137
137
  librarian_name: "Librarian",
138
138
  explore_name: "Explore",
@@ -154,13 +154,13 @@ const AgentsSchema = z.object({
154
154
  // Display names for the stage sub-agents.
155
155
  stage_agent_names: z
156
156
  .object({
157
- frame: z.string().default("Astro — Frame"),
158
- plan: z.string().default("Astro — Plan"),
159
- spec: z.string().default("Astro — Spec"),
160
- implement: z.string().default("Astro — Implement"),
161
- review: z.string().default("Astro — Review"),
162
- verify: z.string().default("Astro — Verify"),
163
- close: z.string().default("Astro — Close"),
157
+ frame: z.string().default("Frame"),
158
+ plan: z.string().default("Plan"),
159
+ spec: z.string().default("Spec"),
160
+ implement: z.string().default("Implement"),
161
+ review: z.string().default("Review"),
162
+ verify: z.string().default("Verify"),
163
+ close: z.string().default("Close"),
164
164
  })
165
165
  .partial()
166
166
  .default({}),
@@ -94,11 +94,11 @@ export function createAstroStageCompleteTool(opts: { ctx: any; config: Astrocode
94
94
 
95
95
  const parsed = parseStageOutputText(output_text);
96
96
  if (parsed.error || !parsed.astro_json) {
97
- return `❌ Stage completion failed: ${parsed.error ?? "ASTRO JSON missing"}. Please ensure output includes proper JSON markers.`;
97
+ return `❌ JSON Parse Error: ${parsed.error ?? "ASTRO JSON missing"}. Ensure output includes <!-- ASTRO_JSON_BEGIN -->{...}<!-- ASTRO_JSON_END --> markers with valid JSON.`;
98
98
  }
99
99
 
100
100
  if (parsed.astro_json.stage_key !== sk) {
101
- return `❌ Stage completion failed: ASTRO JSON stage_key mismatch (expected ${sk}, got ${parsed.astro_json.stage_key}).`;
101
+ return `❌ Stage Key Mismatch: ASTRO JSON has stage_key="${parsed.astro_json.stage_key}" but expected "${sk}". Update the JSON to match the current stage.`;
102
102
  }
103
103
 
104
104
  // Evidence requirement
package/src/ui/inject.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  let isInjecting = false;
2
+ let queuedInjection: { ctx: any; sessionId: string; text: string } | null = null;
2
3
 
3
4
  export async function injectChatPrompt(opts: {
4
5
  ctx: any;
@@ -7,8 +8,9 @@ export async function injectChatPrompt(opts: {
7
8
  }) {
8
9
  const { ctx, sessionId, text } = opts;
9
10
 
10
- // Skip if already injecting (max 1 at a time, no queuing)
11
11
  if (isInjecting) {
12
+ // Replace any existing queued injection (keep only latest)
13
+ queuedInjection = opts;
12
14
  return;
13
15
  }
14
16
 
@@ -23,5 +25,12 @@ export async function injectChatPrompt(opts: {
23
25
  });
24
26
  } finally {
25
27
  isInjecting = false;
28
+ // Process queued injection if any
29
+ if (queuedInjection) {
30
+ const next = queuedInjection;
31
+ queuedInjection = null;
32
+ // Schedule next injection asynchronously to prevent recursion
33
+ setImmediate(() => injectChatPrompt(next));
34
+ }
26
35
  }
27
36
  }