astrocode-workflow 0.1.11 → 0.1.16
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 +5 -0
- package/dist/state/db.js +14 -0
- package/dist/tools/stage.js +3 -2
- package/dist/workflow/directives.js +7 -3
- package/package.json +1 -1
- package/src/agents/registry.ts +1 -1
- package/src/index.ts +7 -0
- package/src/state/db.ts +13 -0
- package/src/tools/stage.ts +3 -2
- 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);
|
|
@@ -48,6 +51,8 @@ const Astrocode = async (ctx) => {
|
|
|
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
|
package/dist/state/db.js
CHANGED
|
@@ -2,6 +2,7 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { SCHEMA_SQL, SCHEMA_VERSION } from "./schema";
|
|
4
4
|
import { nowISO } from "../shared/time";
|
|
5
|
+
import { info } from "../shared/log";
|
|
5
6
|
import { createDatabaseAdapter } from "./adapters";
|
|
6
7
|
/** Ensure directory exists for a file path. */
|
|
7
8
|
function ensureParentDir(filePath) {
|
|
@@ -55,6 +56,19 @@ export function ensureSchema(db, opts) {
|
|
|
55
56
|
}
|
|
56
57
|
try {
|
|
57
58
|
db.exec(SCHEMA_SQL);
|
|
59
|
+
// Migrations for existing databases
|
|
60
|
+
// Add created_at to stage_runs if missing (introduced in schema version 2)
|
|
61
|
+
try {
|
|
62
|
+
const columns = db.prepare("PRAGMA table_info(stage_runs)").all();
|
|
63
|
+
const hasCreatedAt = columns.some(col => col.name === 'created_at');
|
|
64
|
+
if (!hasCreatedAt) {
|
|
65
|
+
db.exec("ALTER TABLE stage_runs ADD COLUMN created_at TEXT NOT NULL DEFAULT ''");
|
|
66
|
+
info("[Astrocode] Added created_at column to stage_runs table");
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch (e) {
|
|
70
|
+
// Column might already exist or table doesn't exist, ignore
|
|
71
|
+
}
|
|
58
72
|
const row = db.prepare("SELECT schema_version FROM repo_state WHERE id = 1").get();
|
|
59
73
|
if (!row) {
|
|
60
74
|
const now = nowISO();
|
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
|
}
|
|
@@ -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
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);
|
|
@@ -62,6 +66,9 @@ 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
|
|
package/src/state/db.ts
CHANGED
|
@@ -68,6 +68,19 @@ export function ensureSchema(db: SqliteDb, opts?: { allowAutoMigrate?: boolean;
|
|
|
68
68
|
try {
|
|
69
69
|
db.exec(SCHEMA_SQL);
|
|
70
70
|
|
|
71
|
+
// Migrations for existing databases
|
|
72
|
+
// Add created_at to stage_runs if missing (introduced in schema version 2)
|
|
73
|
+
try {
|
|
74
|
+
const columns = db.prepare("PRAGMA table_info(stage_runs)").all() as { name: string }[];
|
|
75
|
+
const hasCreatedAt = columns.some(col => col.name === 'created_at');
|
|
76
|
+
if (!hasCreatedAt) {
|
|
77
|
+
db.exec("ALTER TABLE stage_runs ADD COLUMN created_at TEXT NOT NULL DEFAULT ''");
|
|
78
|
+
info("[Astrocode] Added created_at column to stage_runs table");
|
|
79
|
+
}
|
|
80
|
+
} catch (e) {
|
|
81
|
+
// Column might already exist or table doesn't exist, ignore
|
|
82
|
+
}
|
|
83
|
+
|
|
71
84
|
const row = db.prepare("SELECT schema_version FROM repo_state WHERE id = 1").get() as { schema_version?: number } | undefined;
|
|
72
85
|
|
|
73
86
|
if (!row) {
|
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
|
}
|
|
@@ -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}"`,
|