astrocode-workflow 0.1.12 → 0.1.17
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/registry.d.ts +1 -1
- package/dist/index.js +8 -3
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.js +2 -2
- package/dist/tools/stage.js +3 -2
- package/dist/tools/workflow.d.ts +2 -0
- package/dist/tools/workflow.js +12 -4
- package/dist/workflow/directives.js +7 -3
- package/package.json +2 -2
- package/src/agents/registry.ts +1 -1
- package/src/index.ts +10 -3
- package/src/tools/index.ts +5 -3
- package/src/tools/stage.ts +3 -2
- package/src/tools/workflow.ts +14 -5
- package/src/workflow/directives.ts +7 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AgentConfig } from "@opencode-ai/sdk";
|
|
2
2
|
import type { AstrocodeConfig } from "../config/schema";
|
|
3
3
|
export declare function createAstroAgents(opts: {
|
|
4
|
-
systemDefaultModel
|
|
4
|
+
systemDefaultModel?: string;
|
|
5
5
|
pluginConfig: AstrocodeConfig;
|
|
6
6
|
}): Record<string, AgentConfig>;
|
package/dist/index.js
CHANGED
|
@@ -6,11 +6,14 @@ import { createAstroTools } from "./tools";
|
|
|
6
6
|
import { createContinuationEnforcer } from "./hooks/continuation-enforcer";
|
|
7
7
|
import { createToolOutputTruncatorHook } from "./hooks/tool-output-truncator";
|
|
8
8
|
import { createToastManager } from "./ui/toasts";
|
|
9
|
+
import { createAstroAgents } from "./agents/registry";
|
|
9
10
|
console.log("Astrocode plugin loading...");
|
|
10
11
|
const Astrocode = async (ctx) => {
|
|
11
12
|
const repoRoot = ctx.directory;
|
|
12
13
|
// Always load config first - this provides defaults even in limited mode
|
|
13
14
|
let pluginConfig = loadAstrocodeConfig(repoRoot);
|
|
15
|
+
// Create agents for registration
|
|
16
|
+
const agents = createAstroAgents({ pluginConfig });
|
|
14
17
|
// Always ensure .astro directories exist, even in limited mode
|
|
15
18
|
const paths = getAstroPaths(repoRoot, pluginConfig.db.path);
|
|
16
19
|
ensureAstroDirs(paths);
|
|
@@ -26,7 +29,7 @@ const Astrocode = async (ctx) => {
|
|
|
26
29
|
ensureSchema(db, { allowAutoMigrate: pluginConfig.db.allow_auto_migrate, failOnDowngrade: pluginConfig.db.fail_on_downgrade });
|
|
27
30
|
// Database initialized successfully
|
|
28
31
|
configHandler = createConfigHandler({ pluginConfig });
|
|
29
|
-
tools = createAstroTools({ ctx, config: pluginConfig, db });
|
|
32
|
+
tools = createAstroTools({ ctx, config: pluginConfig, db, agents });
|
|
30
33
|
continuation = createContinuationEnforcer({ ctx, config: pluginConfig, db });
|
|
31
34
|
truncatorHook = createToolOutputTruncatorHook({ ctx, config: pluginConfig, db });
|
|
32
35
|
toasts = createToastManager({ ctx, throttleMs: pluginConfig.ui.toasts.throttle_ms });
|
|
@@ -41,17 +44,19 @@ const Astrocode = async (ctx) => {
|
|
|
41
44
|
// Create limited functionality
|
|
42
45
|
db = null;
|
|
43
46
|
configHandler = createConfigHandler({ pluginConfig });
|
|
44
|
-
tools = createAstroTools({ ctx, config: pluginConfig, db });
|
|
47
|
+
tools = createAstroTools({ ctx, config: pluginConfig, db, agents });
|
|
45
48
|
continuation = null;
|
|
46
49
|
truncatorHook = null;
|
|
47
50
|
toasts = null;
|
|
48
51
|
}
|
|
49
52
|
return {
|
|
50
53
|
name: "Astrocode",
|
|
54
|
+
// Register agents
|
|
55
|
+
agents,
|
|
51
56
|
// Merge agents + slash commands into system config
|
|
52
57
|
config: configHandler,
|
|
53
58
|
// Register tools
|
|
54
|
-
tool:
|
|
59
|
+
tool: createAstroTools({ ctx, config: pluginConfig, db, agents }),
|
|
55
60
|
// Limit created subagents from spawning more subagents (OMO-style).
|
|
56
61
|
"tool.execute.before": async (input, output) => {
|
|
57
62
|
if (!pluginConfig.permissions.enforce_task_tool_restrictions)
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { ToolDefinition } from "@opencode-ai/plugin/tool";
|
|
2
2
|
import type { AstrocodeConfig } from "../config/schema";
|
|
3
3
|
import type { SqliteDb } from "../state/db";
|
|
4
|
+
import { AgentConfig } from "@opencode-ai/sdk";
|
|
4
5
|
export declare function createAstroTools(opts: {
|
|
5
6
|
ctx: any;
|
|
6
7
|
config: AstrocodeConfig;
|
|
7
8
|
db: SqliteDb;
|
|
9
|
+
agents?: Record<string, AgentConfig>;
|
|
8
10
|
}): Record<string, ToolDefinition>;
|
package/dist/tools/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { createAstroArtifactPutTool, createAstroArtifactListTool, createAstroArt
|
|
|
9
9
|
import { createAstroInjectPutTool, createAstroInjectListTool, createAstroInjectSearchTool, createAstroInjectGetTool } from "./injects";
|
|
10
10
|
import { createAstroRepairTool } from "./repair";
|
|
11
11
|
export function createAstroTools(opts) {
|
|
12
|
-
const { ctx, config, db } = opts;
|
|
12
|
+
const { ctx, config, db, agents } = opts;
|
|
13
13
|
const hasDatabase = !!db;
|
|
14
14
|
const tools = {};
|
|
15
15
|
// Always available tools
|
|
@@ -27,7 +27,7 @@ export function createAstroTools(opts) {
|
|
|
27
27
|
tools.astro_spec_set = createAstroSpecSetTool({ ctx, config, db });
|
|
28
28
|
tools.astro_run_get = createAstroRunGetTool({ ctx, config, db });
|
|
29
29
|
tools.astro_run_abort = createAstroRunAbortTool({ ctx, config, db });
|
|
30
|
-
tools.astro_workflow_proceed = createAstroWorkflowProceedTool({ ctx, config, db });
|
|
30
|
+
tools.astro_workflow_proceed = createAstroWorkflowProceedTool({ ctx, config, db, agents });
|
|
31
31
|
tools.astro_stage_start = createAstroStageStartTool({ ctx, config, db });
|
|
32
32
|
tools.astro_stage_complete = createAstroStageCompleteTool({ ctx, config, db });
|
|
33
33
|
tools.astro_stage_fail = createAstroStageFailTool({ ctx, config, db });
|
package/dist/tools/stage.js
CHANGED
|
@@ -219,8 +219,9 @@ export function createAstroStageCompleteTool(opts) {
|
|
|
219
219
|
const specPath = path.join(repoRoot, ".astro", "spec.md");
|
|
220
220
|
if (fs.existsSync(specPath) && fs.statSync(specPath).size > 100) {
|
|
221
221
|
// Skip spec
|
|
222
|
-
|
|
223
|
-
|
|
222
|
+
const specIndex = pipeline.indexOf("spec");
|
|
223
|
+
db.prepare("INSERT INTO stage_runs (stage_run_id, run_id, stage_key, stage_index, status, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?)")
|
|
224
|
+
.run(newId("stage"), rid, "spec", specIndex, "skipped", now, now);
|
|
224
225
|
next = "implement";
|
|
225
226
|
}
|
|
226
227
|
}
|
package/dist/tools/workflow.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { type ToolDefinition } from "@opencode-ai/plugin/tool";
|
|
2
2
|
import type { AstrocodeConfig } from "../config/schema";
|
|
3
3
|
import type { SqliteDb } from "../state/db";
|
|
4
|
+
import { AgentConfig } from "@opencode-ai/sdk";
|
|
4
5
|
export declare function createAstroWorkflowProceedTool(opts: {
|
|
5
6
|
ctx: any;
|
|
6
7
|
config: AstrocodeConfig;
|
|
7
8
|
db: SqliteDb;
|
|
9
|
+
agents?: Record<string, AgentConfig>;
|
|
8
10
|
}): ToolDefinition;
|
package/dist/tools/workflow.js
CHANGED
|
@@ -83,7 +83,7 @@ function buildDelegationPrompt(opts) {
|
|
|
83
83
|
].join("\n").trim();
|
|
84
84
|
}
|
|
85
85
|
export function createAstroWorkflowProceedTool(opts) {
|
|
86
|
-
const { ctx, config, db } = opts;
|
|
86
|
+
const { ctx, config, db, agents } = opts;
|
|
87
87
|
const toasts = createToastManager({ ctx, throttleMs: config.ui.toasts.throttle_ms });
|
|
88
88
|
return tool({
|
|
89
89
|
description: "Deterministic harness: advances the DB-driven pipeline by one step (or loops bounded). Stops when LLM work is required (delegation/await).",
|
|
@@ -134,15 +134,23 @@ export function createAstroWorkflowProceedTool(opts) {
|
|
|
134
134
|
console.log(`[Astrocode] Available agents:`, Object.keys(config.agent || {}));
|
|
135
135
|
// Validate agent availability with fallback chain
|
|
136
136
|
const systemConfig = config;
|
|
137
|
-
|
|
137
|
+
// Check both the system config agent map (if present) OR the local agents map passed to the tool
|
|
138
|
+
const agentExists = (name) => {
|
|
139
|
+
if (agents && agents[name])
|
|
140
|
+
return true;
|
|
141
|
+
if (systemConfig.agent && systemConfig.agent[name])
|
|
142
|
+
return true;
|
|
143
|
+
return false;
|
|
144
|
+
};
|
|
145
|
+
if (!agentExists(agentName)) {
|
|
138
146
|
console.warn(`[Astrocode] Agent ${agentName} not found in config. Falling back to General.`);
|
|
139
147
|
console.warn(`[Astrocode] Agent check: config.agent exists: ${!!systemConfig.agent}, agentName in config: ${systemConfig.agent ? agentName in systemConfig.agent : 'N/A'}`);
|
|
140
148
|
agentName = "General";
|
|
141
149
|
// Second fallback to orchestrator if General also unavailable
|
|
142
|
-
if (!
|
|
150
|
+
if (!agentExists(agentName)) {
|
|
143
151
|
console.warn(`[Astrocode] General agent also unavailable. Falling back to orchestrator.`);
|
|
144
152
|
agentName = config.agents?.orchestrator_name || "Astro";
|
|
145
|
-
if (!
|
|
153
|
+
if (!agentExists(agentName)) {
|
|
146
154
|
throw new Error(`Critical: No agents available for delegation. Primary: ${resolveAgentName(next.stage_key, config)}, General, Orchestrator: ${agentName}`);
|
|
147
155
|
}
|
|
148
156
|
}
|
|
@@ -85,11 +85,15 @@ export function buildStageDirective(opts) {
|
|
|
85
85
|
`Output contract (strict):`,
|
|
86
86
|
`1) Baton markdown (short, structured)`,
|
|
87
87
|
`2) ASTRO JSON between markers:`,
|
|
88
|
-
` ${"```"}`,
|
|
89
88
|
` ${"<!-- ASTRO_JSON_BEGIN -->"}`,
|
|
90
|
-
` {
|
|
89
|
+
` {`,
|
|
90
|
+
` "schema_version": 1,`,
|
|
91
|
+
` "stage_key": "${stage_key}",`,
|
|
92
|
+
` "status": "ok",`,
|
|
93
|
+
` "summary": "Brief summary of work done",`,
|
|
94
|
+
` ...`,
|
|
95
|
+
` }`,
|
|
91
96
|
` ${"<!-- ASTRO_JSON_END -->"}`,
|
|
92
|
-
` ${"```"}`,
|
|
93
97
|
``,
|
|
94
98
|
`ASTRO JSON requirements:`,
|
|
95
99
|
`- stage_key must be "${stage_key}"`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astrocode-workflow",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
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.1.
|
|
21
|
+
"astrocode-workflow": "^0.1.16",
|
|
22
22
|
"jsonc-parser": "^3.2.0",
|
|
23
23
|
"zod": "4.1.8"
|
|
24
24
|
},
|
package/src/agents/registry.ts
CHANGED
|
@@ -116,7 +116,7 @@ function stageVerifyPermissions(): PermissionMap {
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
export function createAstroAgents(opts: {
|
|
119
|
-
systemDefaultModel
|
|
119
|
+
systemDefaultModel?: string;
|
|
120
120
|
pluginConfig: AstrocodeConfig;
|
|
121
121
|
}): Record<string, AgentConfig> {
|
|
122
122
|
const { systemDefaultModel, pluginConfig } = opts;
|
package/src/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { createAstroTools } from "./tools";
|
|
|
7
7
|
import { createContinuationEnforcer } from "./hooks/continuation-enforcer";
|
|
8
8
|
import { createToolOutputTruncatorHook } from "./hooks/tool-output-truncator";
|
|
9
9
|
import { createToastManager } from "./ui/toasts";
|
|
10
|
+
import { createAstroAgents } from "./agents/registry";
|
|
10
11
|
import { info, warn } from "./shared/log";
|
|
11
12
|
|
|
12
13
|
console.log("Astrocode plugin loading...");
|
|
@@ -17,6 +18,9 @@ const Astrocode: Plugin = async (ctx) => {
|
|
|
17
18
|
// Always load config first - this provides defaults even in limited mode
|
|
18
19
|
let pluginConfig = loadAstrocodeConfig(repoRoot);
|
|
19
20
|
|
|
21
|
+
// Create agents for registration
|
|
22
|
+
const agents = createAstroAgents({ pluginConfig });
|
|
23
|
+
|
|
20
24
|
// Always ensure .astro directories exist, even in limited mode
|
|
21
25
|
const paths = getAstroPaths(repoRoot, pluginConfig.db.path);
|
|
22
26
|
ensureAstroDirs(paths);
|
|
@@ -36,7 +40,7 @@ const Astrocode: Plugin = async (ctx) => {
|
|
|
36
40
|
|
|
37
41
|
// Database initialized successfully
|
|
38
42
|
configHandler = createConfigHandler({ pluginConfig });
|
|
39
|
-
tools = createAstroTools({ ctx, config: pluginConfig, db });
|
|
43
|
+
tools = createAstroTools({ ctx, config: pluginConfig, db, agents });
|
|
40
44
|
continuation = createContinuationEnforcer({ ctx, config: pluginConfig, db });
|
|
41
45
|
truncatorHook = createToolOutputTruncatorHook({ ctx, config: pluginConfig, db });
|
|
42
46
|
toasts = createToastManager({ ctx, throttleMs: pluginConfig.ui.toasts.throttle_ms });
|
|
@@ -53,7 +57,7 @@ const Astrocode: Plugin = async (ctx) => {
|
|
|
53
57
|
// Create limited functionality
|
|
54
58
|
db = null;
|
|
55
59
|
configHandler = createConfigHandler({ pluginConfig });
|
|
56
|
-
tools = createAstroTools({ ctx, config: pluginConfig, db });
|
|
60
|
+
tools = createAstroTools({ ctx, config: pluginConfig, db, agents });
|
|
57
61
|
continuation = null;
|
|
58
62
|
truncatorHook = null;
|
|
59
63
|
toasts = null;
|
|
@@ -62,11 +66,14 @@ const Astrocode: Plugin = async (ctx) => {
|
|
|
62
66
|
return {
|
|
63
67
|
name: "Astrocode",
|
|
64
68
|
|
|
69
|
+
// Register agents
|
|
70
|
+
agents,
|
|
71
|
+
|
|
65
72
|
// Merge agents + slash commands into system config
|
|
66
73
|
config: configHandler,
|
|
67
74
|
|
|
68
75
|
// Register tools
|
|
69
|
-
tool:
|
|
76
|
+
tool: createAstroTools({ ctx, config: pluginConfig, db, agents }),
|
|
70
77
|
|
|
71
78
|
// Limit created subagents from spawning more subagents (OMO-style).
|
|
72
79
|
"tool.execute.before": async (input: any, output: any) => {
|
package/src/tools/index.ts
CHANGED
|
@@ -13,8 +13,10 @@ import { createAstroArtifactPutTool, createAstroArtifactListTool, createAstroArt
|
|
|
13
13
|
import { createAstroInjectPutTool, createAstroInjectListTool, createAstroInjectSearchTool, createAstroInjectGetTool } from "./injects";
|
|
14
14
|
import { createAstroRepairTool } from "./repair";
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
import { AgentConfig } from "@opencode-ai/sdk";
|
|
17
|
+
|
|
18
|
+
export function createAstroTools(opts: { ctx: any; config: AstrocodeConfig; db: SqliteDb; agents?: Record<string, AgentConfig> }): Record<string, ToolDefinition> {
|
|
19
|
+
const { ctx, config, db, agents } = opts;
|
|
18
20
|
const hasDatabase = !!db;
|
|
19
21
|
|
|
20
22
|
const tools: Record<string, ToolDefinition> = {};
|
|
@@ -36,7 +38,7 @@ export function createAstroTools(opts: { ctx: any; config: AstrocodeConfig; db:
|
|
|
36
38
|
tools.astro_spec_set = createAstroSpecSetTool({ ctx, config, db });
|
|
37
39
|
tools.astro_run_get = createAstroRunGetTool({ ctx, config, db });
|
|
38
40
|
tools.astro_run_abort = createAstroRunAbortTool({ ctx, config, db });
|
|
39
|
-
tools.astro_workflow_proceed = createAstroWorkflowProceedTool({ ctx, config, db });
|
|
41
|
+
tools.astro_workflow_proceed = createAstroWorkflowProceedTool({ ctx, config, db, agents });
|
|
40
42
|
tools.astro_stage_start = createAstroStageStartTool({ ctx, config, db });
|
|
41
43
|
tools.astro_stage_complete = createAstroStageCompleteTool({ ctx, config, db });
|
|
42
44
|
tools.astro_stage_fail = createAstroStageFailTool({ ctx, config, db });
|
package/src/tools/stage.ts
CHANGED
|
@@ -300,8 +300,9 @@ export function createAstroStageCompleteTool(opts: { ctx: any; config: Astrocode
|
|
|
300
300
|
const specPath = path.join(repoRoot, ".astro", "spec.md");
|
|
301
301
|
if (fs.existsSync(specPath) && fs.statSync(specPath).size > 100) {
|
|
302
302
|
// Skip spec
|
|
303
|
-
|
|
304
|
-
|
|
303
|
+
const specIndex = pipeline.indexOf("spec");
|
|
304
|
+
db.prepare("INSERT INTO stage_runs (stage_run_id, run_id, stage_key, stage_index, status, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?)")
|
|
305
|
+
.run(newId("stage"), rid, "spec", specIndex, "skipped", now, now);
|
|
305
306
|
next = "implement";
|
|
306
307
|
}
|
|
307
308
|
}
|
package/src/tools/workflow.ts
CHANGED
|
@@ -99,8 +99,10 @@ function buildDelegationPrompt(opts: {
|
|
|
99
99
|
].join("\n").trim();
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
import { AgentConfig } from "@opencode-ai/sdk";
|
|
103
|
+
|
|
104
|
+
export function createAstroWorkflowProceedTool(opts: { ctx: any; config: AstrocodeConfig; db: SqliteDb; agents?: Record<string, AgentConfig> }): ToolDefinition {
|
|
105
|
+
const { ctx, config, db, agents } = opts;
|
|
104
106
|
const toasts = createToastManager({ ctx, throttleMs: config.ui.toasts.throttle_ms });
|
|
105
107
|
|
|
106
108
|
return tool({
|
|
@@ -163,15 +165,22 @@ export function createAstroWorkflowProceedTool(opts: { ctx: any; config: Astroco
|
|
|
163
165
|
|
|
164
166
|
// Validate agent availability with fallback chain
|
|
165
167
|
const systemConfig = config as any;
|
|
166
|
-
|
|
168
|
+
// Check both the system config agent map (if present) OR the local agents map passed to the tool
|
|
169
|
+
const agentExists = (name: string) => {
|
|
170
|
+
if (agents && agents[name]) return true;
|
|
171
|
+
if (systemConfig.agent && systemConfig.agent[name]) return true;
|
|
172
|
+
return false;
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
if (!agentExists(agentName)) {
|
|
167
176
|
console.warn(`[Astrocode] Agent ${agentName} not found in config. Falling back to General.`);
|
|
168
177
|
console.warn(`[Astrocode] Agent check: config.agent exists: ${!!systemConfig.agent}, agentName in config: ${systemConfig.agent ? agentName in systemConfig.agent : 'N/A'}`);
|
|
169
178
|
agentName = "General";
|
|
170
179
|
// Second fallback to orchestrator if General also unavailable
|
|
171
|
-
if (!
|
|
180
|
+
if (!agentExists(agentName)) {
|
|
172
181
|
console.warn(`[Astrocode] General agent also unavailable. Falling back to orchestrator.`);
|
|
173
182
|
agentName = config.agents?.orchestrator_name || "Astro";
|
|
174
|
-
if (!
|
|
183
|
+
if (!agentExists(agentName)) {
|
|
175
184
|
throw new Error(`Critical: No agents available for delegation. Primary: ${resolveAgentName(next.stage_key, config)}, General, Orchestrator: ${agentName}`);
|
|
176
185
|
}
|
|
177
186
|
}
|
|
@@ -140,11 +140,15 @@ export function buildStageDirective(opts: {
|
|
|
140
140
|
`Output contract (strict):`,
|
|
141
141
|
`1) Baton markdown (short, structured)`,
|
|
142
142
|
`2) ASTRO JSON between markers:`,
|
|
143
|
-
` ${"```"}`,
|
|
144
143
|
` ${"<!-- ASTRO_JSON_BEGIN -->"}`,
|
|
145
|
-
` {
|
|
144
|
+
` {`,
|
|
145
|
+
` "schema_version": 1,`,
|
|
146
|
+
` "stage_key": "${stage_key}",`,
|
|
147
|
+
` "status": "ok",`,
|
|
148
|
+
` "summary": "Brief summary of work done",`,
|
|
149
|
+
` ...`,
|
|
150
|
+
` }`,
|
|
146
151
|
` ${"<!-- ASTRO_JSON_END -->"}`,
|
|
147
|
-
` ${"```"}`,
|
|
148
152
|
``,
|
|
149
153
|
`ASTRO JSON requirements:`,
|
|
150
154
|
`- stage_key must be "${stage_key}"`,
|