@zhuk/spego 0.10.1 → 0.12.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/CHANGELOG.md +27 -0
- package/README.md +19 -48
- package/dist/artifacts/engine.d.ts +3 -7
- package/dist/artifacts/engine.js +39 -23
- package/dist/artifacts/engine.js.map +1 -1
- package/dist/artifacts/storage.d.ts +3 -2
- package/dist/artifacts/storage.js +42 -7
- package/dist/artifacts/storage.js.map +1 -1
- package/dist/artifacts/validation.js +1 -1
- package/dist/artifacts/validation.js.map +1 -1
- package/dist/cli/body-input.js +12 -2
- package/dist/cli/body-input.js.map +1 -1
- package/dist/cli/commands/artifact.js +53 -12
- package/dist/cli/commands/artifact.js.map +1 -1
- package/dist/cli/commands/meta.js +1 -1
- package/dist/cli/commands/meta.js.map +1 -1
- package/dist/cli/commands/skills.js +0 -2
- package/dist/cli/commands/skills.js.map +1 -1
- package/dist/cli/commands/view.js +29 -27
- package/dist/cli/commands/view.js.map +1 -1
- package/dist/cli/runtime.d.ts +2 -0
- package/dist/cli/runtime.js +2 -1
- package/dist/cli/runtime.js.map +1 -1
- package/dist/cli.js +0 -2
- package/dist/cli.js.map +1 -1
- package/dist/{commands → command-meta}/registry.js +0 -12
- package/dist/command-meta/registry.js.map +1 -0
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/generator/claude.d.ts +1 -0
- package/dist/generator/claude.js +17 -2
- package/dist/generator/claude.js.map +1 -1
- package/dist/generator/index.js +2 -0
- package/dist/generator/index.js.map +1 -1
- package/dist/generator/opencode.d.ts +5 -0
- package/dist/generator/opencode.js +207 -0
- package/dist/generator/opencode.js.map +1 -0
- package/dist/generator/write.d.ts +1 -0
- package/dist/generator/write.js +14 -0
- package/dist/generator/write.js.map +1 -1
- package/dist/index/indexer.js +37 -8
- package/dist/index/indexer.js.map +1 -1
- package/dist/index/revisions.d.ts +2 -2
- package/dist/index/revisions.js +18 -3
- package/dist/index/revisions.js.map +1 -1
- package/dist/workspace/config.d.ts +0 -69
- package/dist/workspace/config.js +4 -21
- package/dist/workspace/config.js.map +1 -1
- package/dist/workspace/init.js +16 -4
- package/dist/workspace/init.js.map +1 -1
- package/dist/workspace/paths.d.ts +12 -0
- package/dist/workspace/paths.js +69 -0
- package/dist/workspace/paths.js.map +1 -1
- package/package.json +3 -5
- package/dist/cli/commands/orchestrate.d.ts +0 -6
- package/dist/cli/commands/orchestrate.js +0 -51
- package/dist/cli/commands/orchestrate.js.map +0 -1
- package/dist/commands/registry.js.map +0 -1
- package/dist/index.d.ts +0 -33
- package/dist/index.js +0 -20
- package/dist/index.js.map +0 -1
- package/dist/orchestration/agents.d.ts +0 -15
- package/dist/orchestration/agents.js +0 -156
- package/dist/orchestration/agents.js.map +0 -1
- package/dist/orchestration/artifacts.d.ts +0 -8
- package/dist/orchestration/artifacts.js +0 -20
- package/dist/orchestration/artifacts.js.map +0 -1
- package/dist/orchestration/client.d.ts +0 -59
- package/dist/orchestration/client.js +0 -107
- package/dist/orchestration/client.js.map +0 -1
- package/dist/orchestration/config.d.ts +0 -14
- package/dist/orchestration/config.js +0 -45
- package/dist/orchestration/config.js.map +0 -1
- package/dist/orchestration/emit.d.ts +0 -7
- package/dist/orchestration/emit.js +0 -19
- package/dist/orchestration/emit.js.map +0 -1
- package/dist/orchestration/engine.d.ts +0 -23
- package/dist/orchestration/engine.js +0 -136
- package/dist/orchestration/engine.js.map +0 -1
- package/dist/orchestration/file-gate.d.ts +0 -19
- package/dist/orchestration/file-gate.js +0 -25
- package/dist/orchestration/file-gate.js.map +0 -1
- package/dist/orchestration/index.d.ts +0 -18
- package/dist/orchestration/index.js +0 -12
- package/dist/orchestration/index.js.map +0 -1
- package/dist/orchestration/manager.d.ts +0 -13
- package/dist/orchestration/manager.js +0 -26
- package/dist/orchestration/manager.js.map +0 -1
- package/dist/orchestration/prompts.d.ts +0 -10
- package/dist/orchestration/prompts.js +0 -71
- package/dist/orchestration/prompts.js.map +0 -1
- package/dist/orchestration/scheduler.d.ts +0 -18
- package/dist/orchestration/scheduler.js +0 -49
- package/dist/orchestration/scheduler.js.map +0 -1
- package/dist/orchestration/schema.d.ts +0 -12
- package/dist/orchestration/schema.js +0 -78
- package/dist/orchestration/schema.js.map +0 -1
- package/dist/orchestration/tiers.d.ts +0 -14
- package/dist/orchestration/tiers.js +0 -57
- package/dist/orchestration/tiers.js.map +0 -1
- package/dist/orchestration/types.d.ts +0 -74
- package/dist/orchestration/types.js +0 -8
- package/dist/orchestration/types.js.map +0 -1
- package/dist/orchestration/verifier.d.ts +0 -14
- package/dist/orchestration/verifier.js +0 -66
- package/dist/orchestration/verifier.js.map +0 -1
- package/dist/orchestration/worker.d.ts +0 -16
- package/dist/orchestration/worker.js +0 -80
- package/dist/orchestration/worker.js.map +0 -1
- /package/dist/{commands → command-meta}/registry.d.ts +0 -0
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Thin async client for the OpenCode REST API (`opencode serve`).
|
|
3
|
-
*
|
|
4
|
-
* Uses the Node global `fetch` and `AbortController` for per-request timeouts,
|
|
5
|
-
* with exponential backoff and jitter on 429/503. The {@link OpenCodeApi}
|
|
6
|
-
* interface is the seam used by the manager, worker, and verifier so the
|
|
7
|
-
* pipeline can be exercised in tests with a fake backend.
|
|
8
|
-
*/
|
|
9
|
-
import { SpegoError } from '../errors.js';
|
|
10
|
-
const RETRYABLE_STATUS = new Set([429, 503]);
|
|
11
|
-
/** Extract the concatenated text parts from a message response. */
|
|
12
|
-
export function extractText(response) {
|
|
13
|
-
const parts = response.parts ?? [];
|
|
14
|
-
return parts
|
|
15
|
-
.filter((p) => p.type === 'text' && typeof p.text === 'string')
|
|
16
|
-
.map((p) => p.text ?? '')
|
|
17
|
-
.join('\n')
|
|
18
|
-
.trim();
|
|
19
|
-
}
|
|
20
|
-
export class OpenCodeClient {
|
|
21
|
-
baseUrl;
|
|
22
|
-
authHeader;
|
|
23
|
-
timeoutMs;
|
|
24
|
-
maxRetries;
|
|
25
|
-
constructor(opts) {
|
|
26
|
-
this.baseUrl = opts.baseUrl.replace(/\/+$/, '');
|
|
27
|
-
this.timeoutMs = opts.timeoutMs ?? 300_000;
|
|
28
|
-
this.maxRetries = opts.maxRetries ?? 5;
|
|
29
|
-
if (opts.password) {
|
|
30
|
-
const raw = `${opts.username ?? 'opencode'}:${opts.password}`;
|
|
31
|
-
this.authHeader = `Basic ${Buffer.from(raw).toString('base64')}`;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
async health() {
|
|
35
|
-
return (await this.request('GET', '/global/health'));
|
|
36
|
-
}
|
|
37
|
-
async createSession(title) {
|
|
38
|
-
const body = title ? { title } : {};
|
|
39
|
-
return (await this.request('POST', '/session', body));
|
|
40
|
-
}
|
|
41
|
-
async sendMessage(sessionId, input) {
|
|
42
|
-
const body = { parts: [{ type: 'text', text: input.text }] };
|
|
43
|
-
if (input.model)
|
|
44
|
-
body.model = input.model;
|
|
45
|
-
if (input.agent)
|
|
46
|
-
body.agent = input.agent;
|
|
47
|
-
if (input.system)
|
|
48
|
-
body.system = input.system;
|
|
49
|
-
return (await this.request('POST', `/session/${sessionId}/message`, body));
|
|
50
|
-
}
|
|
51
|
-
async getSessionDiff(sessionId) {
|
|
52
|
-
const result = await this.request('GET', `/session/${sessionId}/diff`);
|
|
53
|
-
return Array.isArray(result) ? result : [];
|
|
54
|
-
}
|
|
55
|
-
async deleteSession(sessionId) {
|
|
56
|
-
await this.request('DELETE', `/session/${sessionId}`);
|
|
57
|
-
}
|
|
58
|
-
async request(method, path, body) {
|
|
59
|
-
let delay = 2000;
|
|
60
|
-
for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
|
|
61
|
-
const controller = new AbortController();
|
|
62
|
-
const timer = setTimeout(() => controller.abort(), this.timeoutMs);
|
|
63
|
-
try {
|
|
64
|
-
const headers = { 'content-type': 'application/json' };
|
|
65
|
-
if (this.authHeader)
|
|
66
|
-
headers.authorization = this.authHeader;
|
|
67
|
-
const res = await fetch(`${this.baseUrl}${path}`, {
|
|
68
|
-
method,
|
|
69
|
-
headers,
|
|
70
|
-
body: body === undefined ? undefined : JSON.stringify(body),
|
|
71
|
-
signal: controller.signal,
|
|
72
|
-
});
|
|
73
|
-
if (RETRYABLE_STATUS.has(res.status) && attempt < this.maxRetries) {
|
|
74
|
-
const retryAfter = Number(res.headers.get('retry-after')) || delay / 1000;
|
|
75
|
-
await sleep(Math.min(retryAfter * 1000 + Math.random() * 1000, 60_000));
|
|
76
|
-
delay = Math.min(delay * 2, 60_000);
|
|
77
|
-
continue;
|
|
78
|
-
}
|
|
79
|
-
if (!res.ok) {
|
|
80
|
-
throw new SpegoError('ORCHESTRATION_FAILED', `OpenCode API ${res.status} on ${method} ${path}`, {
|
|
81
|
-
status: res.status,
|
|
82
|
-
path,
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
const text = await res.text();
|
|
86
|
-
return text ? JSON.parse(text) : null;
|
|
87
|
-
}
|
|
88
|
-
catch (err) {
|
|
89
|
-
if (err instanceof SpegoError)
|
|
90
|
-
throw err;
|
|
91
|
-
if (attempt >= this.maxRetries) {
|
|
92
|
-
throw new SpegoError('ORCHESTRATION_BACKEND_UNREACHABLE', `OpenCode server unreachable at ${this.baseUrl}`, { serverUrl: this.baseUrl, cause: err.message });
|
|
93
|
-
}
|
|
94
|
-
await sleep(Math.min(delay + Math.random() * 1000, 60_000));
|
|
95
|
-
delay = Math.min(delay * 2, 60_000);
|
|
96
|
-
}
|
|
97
|
-
finally {
|
|
98
|
-
clearTimeout(timer);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
throw new SpegoError('ORCHESTRATION_FAILED', `Exhausted retries for ${method} ${path}`, { path });
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
function sleep(ms) {
|
|
105
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
106
|
-
}
|
|
107
|
-
//# sourceMappingURL=client.js.map
|
|
@@ -1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H,CAAC;QACD,MAAM,IAAI,UAAU,CAAC,sBAAsB,EAAE,yBAAyB,MAAM,IAAI,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;IACpG,CAAC;CACF;AAED,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Resolve orchestration runtime settings from workspace config plus
|
|
3
|
-
* environment-variable overrides.
|
|
4
|
-
*
|
|
5
|
-
* No fictional model identifier is committed as a default — model ids default
|
|
6
|
-
* to empty and MUST be supplied via `.spego/config.yaml` or the environment.
|
|
7
|
-
*/
|
|
8
|
-
import type { WorkspaceConfig } from '../workspace/config.js';
|
|
9
|
-
import type { OrchestrationRuntimeConfig } from './types.js';
|
|
10
|
-
type Env = Record<string, string | undefined>;
|
|
11
|
-
export declare function resolveOrchestrationConfig(config: WorkspaceConfig, env?: Env): OrchestrationRuntimeConfig;
|
|
12
|
-
/** Throw if a model required to run the pipeline is not configured. */
|
|
13
|
-
export declare function assertModelsConfigured(rc: OrchestrationRuntimeConfig): void;
|
|
14
|
-
export {};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Resolve orchestration runtime settings from workspace config plus
|
|
3
|
-
* environment-variable overrides.
|
|
4
|
-
*
|
|
5
|
-
* No fictional model identifier is committed as a default — model ids default
|
|
6
|
-
* to empty and MUST be supplied via `.spego/config.yaml` or the environment.
|
|
7
|
-
*/
|
|
8
|
-
import { SpegoError } from '../errors.js';
|
|
9
|
-
function pick(env, ...keys) {
|
|
10
|
-
for (const key of keys) {
|
|
11
|
-
const value = env[key];
|
|
12
|
-
if (value !== undefined && value !== '')
|
|
13
|
-
return value;
|
|
14
|
-
}
|
|
15
|
-
return undefined;
|
|
16
|
-
}
|
|
17
|
-
export function resolveOrchestrationConfig(config, env = process.env) {
|
|
18
|
-
const block = config.orchestration;
|
|
19
|
-
const maxParallelEnv = pick(env, 'SPEGO_ORCHESTRATION_MAX_PARALLEL');
|
|
20
|
-
const maxParallel = maxParallelEnv ? Number(maxParallelEnv) : block.maxParallel;
|
|
21
|
-
return {
|
|
22
|
-
serverUrl: pick(env, 'SPEGO_ORCHESTRATION_SERVER_URL', 'OPENCODE_BASE_URL') ?? block.serverUrl,
|
|
23
|
-
models: {
|
|
24
|
-
manager: pick(env, 'SPEGO_ORCHESTRATION_MODEL_MANAGER') ?? block.models.manager,
|
|
25
|
-
worker: pick(env, 'SPEGO_ORCHESTRATION_MODEL_WORKER') ?? block.models.worker,
|
|
26
|
-
verifier: pick(env, 'SPEGO_ORCHESTRATION_MODEL_VERIFIER') ?? block.models.verifier,
|
|
27
|
-
fallback: pick(env, 'SPEGO_ORCHESTRATION_MODEL_FALLBACK') ?? block.models.fallback,
|
|
28
|
-
},
|
|
29
|
-
maxParallel: Number.isFinite(maxParallel) && maxParallel > 0 ? Math.floor(maxParallel) : 1,
|
|
30
|
-
workDir: pick(env, 'SPEGO_ORCHESTRATION_WORK_DIR') ?? block.workDir,
|
|
31
|
-
username: pick(env, 'OPENCODE_SERVER_USERNAME'),
|
|
32
|
-
password: pick(env, 'OPENCODE_SERVER_PASSWORD'),
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
/** Throw if a model required to run the pipeline is not configured. */
|
|
36
|
-
export function assertModelsConfigured(rc) {
|
|
37
|
-
const missing = ['manager', 'worker', 'verifier'].filter((tier) => !rc.models[tier]);
|
|
38
|
-
if (missing.length > 0) {
|
|
39
|
-
throw new SpegoError('ORCHESTRATION_NOT_CONFIGURED', `Orchestration model(s) not configured: ${missing.join(', ')}`, {
|
|
40
|
-
missing,
|
|
41
|
-
hint: 'Set orchestration.models in .spego/config.yaml or SPEGO_ORCHESTRATION_MODEL_* env vars',
|
|
42
|
-
});
|
|
43
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CAAC,GAAG,EAAE,oCAAoC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,QAAQ;SACnF;QACD,WAAW,EAAE,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,WAAW,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1F,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE,8BAA8B,CAAC,IAAI,KAAK,CAAC,OAAO;QACnE,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE,0BAA0B,CAAC;QAC/C,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE,0BAA0B,CAAC;KAChD,CAAC;AACJ,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,sBAAsB,CAAC,EAA8B;IACnE,MAAM,OAAO,GAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,UAAU,CAAW,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IAChG,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,UAAU,CAClB,8BAA8B,EAC9B,0CAA0C,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAC9D;YACE,OAAO;YACP,IAAI,EAAE,wFAAwF;SAC/F,CACF,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Emit the OpenCode orchestration assets (agent prompts + the orchestrate
|
|
3
|
-
* command) under `.opencode/`. Reuses the generator's marker-aware writer so
|
|
4
|
-
* user-authored files are never clobbered and regeneration is deterministic.
|
|
5
|
-
*/
|
|
6
|
-
import type { GenerationReport } from '../generator/types.js';
|
|
7
|
-
export declare function emitOrchestrationAssets(projectRoot: string): Promise<GenerationReport>;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Emit the OpenCode orchestration assets (agent prompts + the orchestrate
|
|
3
|
-
* command) under `.opencode/`. Reuses the generator's marker-aware writer so
|
|
4
|
-
* user-authored files are never clobbered and regeneration is deterministic.
|
|
5
|
-
*/
|
|
6
|
-
import path from 'node:path';
|
|
7
|
-
import { writeGeneratedFile } from '../generator/write.js';
|
|
8
|
-
import { GENERATOR_VERSION } from '../generator/types.js';
|
|
9
|
-
import { ORCHESTRATION_AGENT_ASSETS } from './agents.js';
|
|
10
|
-
export async function emitOrchestrationAssets(projectRoot) {
|
|
11
|
-
const files = [];
|
|
12
|
-
for (const asset of ORCHESTRATION_AGENT_ASSETS) {
|
|
13
|
-
const absPath = path.join(projectRoot, asset.relPath);
|
|
14
|
-
const action = await writeGeneratedFile(absPath, asset.content);
|
|
15
|
-
files.push({ path: absPath, action });
|
|
16
|
-
}
|
|
17
|
-
return { target: 'opencode-orchestration', files, version: GENERATOR_VERSION };
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=emit.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"emit.js","sourceRoot":"","sources":["../../src/orchestration/emit.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAEzD,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,WAAmB;IAC/D,MAAM,KAAK,GAAoB,EAAE,CAAC;IAClC,KAAK,MAAM,KAAK,IAAI,0BAA0B,EAAE,CAAC;QAC/C,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QACtD,MAAM,MAAM,GAAG,MAAM,kBAAkB,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QAChE,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,wBAAwB,EAAE,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,CAAC;AACjF,CAAC"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Top-level orchestration entrypoint.
|
|
3
|
-
*
|
|
4
|
-
* Reads a named OpenSpec change read-only, then runs the manager → swarm →
|
|
5
|
-
* verifier pipeline through the OpenCode REST API and returns a structured
|
|
6
|
-
* outcome. OpenSpec lifecycle state (apply/verify/sync/archive) is never
|
|
7
|
-
* mutated; only the working tree may change as workers implement sub-tasks.
|
|
8
|
-
*/
|
|
9
|
-
import type { OpenCodeApi } from './client.js';
|
|
10
|
-
import type { ExecutionMode, OrchestrationOutcome } from './types.js';
|
|
11
|
-
export declare const AGENT_MANAGER = "ultramanager";
|
|
12
|
-
export declare const AGENT_WORKER = "ultraworker";
|
|
13
|
-
export declare const AGENT_VERIFIER = "ultraverifier";
|
|
14
|
-
export interface OrchestrateOptions {
|
|
15
|
-
projectRoot: string;
|
|
16
|
-
changeName: string;
|
|
17
|
-
mode?: ExecutionMode;
|
|
18
|
-
skipVerify?: boolean;
|
|
19
|
-
/** Inject a backend for testing; defaults to a real {@link OpenCodeClient}. */
|
|
20
|
-
client?: OpenCodeApi;
|
|
21
|
-
env?: Record<string, string | undefined>;
|
|
22
|
-
}
|
|
23
|
-
export declare function orchestrateChange(opts: OrchestrateOptions): Promise<OrchestrationOutcome>;
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Top-level orchestration entrypoint.
|
|
3
|
-
*
|
|
4
|
-
* Reads a named OpenSpec change read-only, then runs the manager → swarm →
|
|
5
|
-
* verifier pipeline through the OpenCode REST API and returns a structured
|
|
6
|
-
* outcome. OpenSpec lifecycle state (apply/verify/sync/archive) is never
|
|
7
|
-
* mutated; only the working tree may change as workers implement sub-tasks.
|
|
8
|
-
*/
|
|
9
|
-
import fs from 'node:fs/promises';
|
|
10
|
-
import path from 'node:path';
|
|
11
|
-
import { resolveWorkspacePaths } from '../workspace/paths.js';
|
|
12
|
-
import { readConfig } from '../workspace/config.js';
|
|
13
|
-
import { discoverChanges } from '../delivery/openspec-discover.js';
|
|
14
|
-
import { SpegoError } from '../errors.js';
|
|
15
|
-
import { OpenCodeClient } from './client.js';
|
|
16
|
-
import { resolveOrchestrationConfig, assertModelsConfigured } from './config.js';
|
|
17
|
-
import { ensureWorkDir, saveArtifact, appendLog } from './artifacts.js';
|
|
18
|
-
import { runManager } from './manager.js';
|
|
19
|
-
import { runWorker } from './worker.js';
|
|
20
|
-
import { runVerifier } from './verifier.js';
|
|
21
|
-
import { runSwarm } from './scheduler.js';
|
|
22
|
-
export const AGENT_MANAGER = 'ultramanager';
|
|
23
|
-
export const AGENT_WORKER = 'ultraworker';
|
|
24
|
-
export const AGENT_VERIFIER = 'ultraverifier';
|
|
25
|
-
async function readMaybe(filePath) {
|
|
26
|
-
try {
|
|
27
|
-
return await fs.readFile(filePath, 'utf8');
|
|
28
|
-
}
|
|
29
|
-
catch {
|
|
30
|
-
return '';
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
async function buildRequirement(projectRoot, relPath) {
|
|
34
|
-
const dir = path.join(projectRoot, relPath);
|
|
35
|
-
const proposal = await readMaybe(path.join(dir, 'proposal.md'));
|
|
36
|
-
const design = await readMaybe(path.join(dir, 'design.md'));
|
|
37
|
-
const tasks = await readMaybe(path.join(dir, 'tasks.md'));
|
|
38
|
-
let specSections = '';
|
|
39
|
-
try {
|
|
40
|
-
const specsDir = path.join(dir, 'specs');
|
|
41
|
-
const entries = await fs.readdir(specsDir, { recursive: true });
|
|
42
|
-
const mdFiles = entries.filter((e) => e.endsWith('.md')).sort();
|
|
43
|
-
if (mdFiles.length > 0) {
|
|
44
|
-
const parts = await Promise.all(mdFiles.map(async (f) => {
|
|
45
|
-
const content = await readMaybe(path.join(specsDir, f));
|
|
46
|
-
return content.trim()
|
|
47
|
-
? `### ${path.basename(f, '.md')}\n\n${content.trim()}`
|
|
48
|
-
: '';
|
|
49
|
-
}));
|
|
50
|
-
specSections = parts.filter(Boolean).join('\n\n');
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
catch {
|
|
54
|
-
// specs dir may not exist
|
|
55
|
-
}
|
|
56
|
-
return [
|
|
57
|
-
'# Change requirement',
|
|
58
|
-
proposal.trim(),
|
|
59
|
-
design.trim() ? `## Design\n\n${design.trim()}` : '',
|
|
60
|
-
specSections ? `## Specs\n\n${specSections}` : '',
|
|
61
|
-
tasks.trim() ? `## Planned tasks\n\n${tasks.trim()}` : '',
|
|
62
|
-
]
|
|
63
|
-
.filter(Boolean)
|
|
64
|
-
.join('\n\n');
|
|
65
|
-
}
|
|
66
|
-
export async function orchestrateChange(opts) {
|
|
67
|
-
const projectRoot = path.resolve(opts.projectRoot);
|
|
68
|
-
const wsPaths = resolveWorkspacePaths(projectRoot);
|
|
69
|
-
const config = await readConfig(wsPaths.configPath);
|
|
70
|
-
const rc = resolveOrchestrationConfig(config, opts.env);
|
|
71
|
-
const changes = await discoverChanges(projectRoot);
|
|
72
|
-
const change = changes.find((c) => c.name === opts.changeName && !c.archived);
|
|
73
|
-
if (!change) {
|
|
74
|
-
throw new SpegoError('CHANGE_NOT_FOUND', `OpenSpec change "${opts.changeName}" not found`, {
|
|
75
|
-
changeName: opts.changeName,
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
assertModelsConfigured(rc);
|
|
79
|
-
const requirement = await buildRequirement(projectRoot, change.relPath);
|
|
80
|
-
const workDirAbs = await ensureWorkDir(projectRoot, path.join(rc.workDir, change.name));
|
|
81
|
-
await saveArtifact(workDirAbs, 'requirement.md', requirement);
|
|
82
|
-
const client = opts.client ??
|
|
83
|
-
new OpenCodeClient({ baseUrl: rc.serverUrl, username: rc.username, password: rc.password });
|
|
84
|
-
await client.health();
|
|
85
|
-
const breakdown = await runManager(client, {
|
|
86
|
-
requirement,
|
|
87
|
-
model: rc.models.manager,
|
|
88
|
-
agentName: AGENT_MANAGER,
|
|
89
|
-
workDirAbs,
|
|
90
|
-
});
|
|
91
|
-
await appendLog(workDirAbs, `manager: ${breakdown.subtasks.length} sub-tasks (mode=${breakdown.executionMode})`);
|
|
92
|
-
const swarm = await runSwarm(breakdown, {
|
|
93
|
-
mode: opts.mode,
|
|
94
|
-
maxParallel: rc.maxParallel,
|
|
95
|
-
runTask: (task) => runWorker(client, task, breakdown, {
|
|
96
|
-
model: rc.models.worker,
|
|
97
|
-
agentName: AGENT_WORKER,
|
|
98
|
-
projectRoot,
|
|
99
|
-
workDirAbs,
|
|
100
|
-
}),
|
|
101
|
-
});
|
|
102
|
-
for (const warning of swarm.warnings)
|
|
103
|
-
await appendLog(workDirAbs, `warning: ${warning}`);
|
|
104
|
-
let verdict;
|
|
105
|
-
if (opts.skipVerify) {
|
|
106
|
-
verdict = {
|
|
107
|
-
passed: swarm.results.every((r) => r.success),
|
|
108
|
-
testOutput: '',
|
|
109
|
-
failingCriteria: [],
|
|
110
|
-
regressions: [],
|
|
111
|
-
notes: 'Verification skipped.',
|
|
112
|
-
skipped: true,
|
|
113
|
-
};
|
|
114
|
-
await saveArtifact(workDirAbs, 'verdict.json', verdict);
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
verdict = await runVerifier(client, breakdown, swarm.results, {
|
|
118
|
-
model: rc.models.verifier,
|
|
119
|
-
agentName: AGENT_VERIFIER,
|
|
120
|
-
workDirAbs,
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
const tasksSucceeded = swarm.results.filter((r) => r.success).length;
|
|
124
|
-
await appendLog(workDirAbs, `done: ${tasksSucceeded}/${swarm.results.length} succeeded; verdict=${verdict.passed ? 'PASS' : 'FAIL'}`);
|
|
125
|
-
return {
|
|
126
|
-
changeName: change.name,
|
|
127
|
-
goal: breakdown.goal,
|
|
128
|
-
executionMode: opts.mode ?? breakdown.executionMode,
|
|
129
|
-
tasksTotal: swarm.results.length,
|
|
130
|
-
tasksSucceeded,
|
|
131
|
-
results: swarm.results,
|
|
132
|
-
verdict,
|
|
133
|
-
warnings: swarm.warnings,
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
//# sourceMappingURL=engine.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../../src/orchestration/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,EAAE,0BAA0B,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG1C,MAAM,CAAC,MAAM,aAAa,GAAG,cAAc,CAAC;AAC5C,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAC;AAC1C,MAAM,CAAC,MAAM,cAAc,GAAG,eAAe,CAAC;AAY9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b,UAAU,EACV,SAAS,cAAc,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,uBAAuB,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,CACzG,CAAC;IAEF,OAAO;QACL,UAAU,EAAE,MAAM,CAAC,IAAI;QACvB,IAAI,EAAE,SAAS,CAAC,IAAI;QACpB,aAAa,EAAE,IAAI,CAAC,IAAI,IAAI,SAAS,CAAC,aAAa;QACnD,UAAU,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM;QAChC,cAAc;QACd,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,OAAO;QACP,QAAQ,EAAE,KAAK,CAAC,QAAQ;KACzB,CAAC;AACJ,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Per-task file gate.
|
|
3
|
-
*
|
|
4
|
-
* Each worker may persist edits only to the files listed in its sub-task
|
|
5
|
-
* allow-list. Anything outside the list is reverted and the sub-task is
|
|
6
|
-
* marked failed. Detection is pure (and unit-tested); reverting is delegated
|
|
7
|
-
* to an injected callback so the policy stays decoupled from git/fs IO.
|
|
8
|
-
*/
|
|
9
|
-
/** Return the changed paths that fall outside the allow-list. */
|
|
10
|
-
export declare function detectFileGateViolations(changedPaths: string[], allowed: string[]): string[];
|
|
11
|
-
export interface FileGateResult {
|
|
12
|
-
violations: string[];
|
|
13
|
-
}
|
|
14
|
-
/** Detect violations, revert each one through the supplied callback, and report them. */
|
|
15
|
-
export declare function enforceFileGate(opts: {
|
|
16
|
-
changedPaths: string[];
|
|
17
|
-
allowed: string[];
|
|
18
|
-
revert: (path: string) => Promise<void> | void;
|
|
19
|
-
}): Promise<FileGateResult>;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Per-task file gate.
|
|
3
|
-
*
|
|
4
|
-
* Each worker may persist edits only to the files listed in its sub-task
|
|
5
|
-
* allow-list. Anything outside the list is reverted and the sub-task is
|
|
6
|
-
* marked failed. Detection is pure (and unit-tested); reverting is delegated
|
|
7
|
-
* to an injected callback so the policy stays decoupled from git/fs IO.
|
|
8
|
-
*/
|
|
9
|
-
function normalizePath(p) {
|
|
10
|
-
return p.replace(/^\.\//, '').replace(/\\/g, '/').replace(/^\/+/, '');
|
|
11
|
-
}
|
|
12
|
-
/** Return the changed paths that fall outside the allow-list. */
|
|
13
|
-
export function detectFileGateViolations(changedPaths, allowed) {
|
|
14
|
-
const allow = new Set(allowed.map(normalizePath));
|
|
15
|
-
return changedPaths.filter((p) => !allow.has(normalizePath(p)));
|
|
16
|
-
}
|
|
17
|
-
/** Detect violations, revert each one through the supplied callback, and report them. */
|
|
18
|
-
export async function enforceFileGate(opts) {
|
|
19
|
-
const violations = detectFileGateViolations(opts.changedPaths, opts.allowed);
|
|
20
|
-
for (const violation of violations) {
|
|
21
|
-
await opts.revert(violation);
|
|
22
|
-
}
|
|
23
|
-
return { violations };
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=file-gate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-gate.js","sourceRoot":"","sources":["../../src/orchestration/file-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,SAAS,aAAa,CAAC,CAAS;IAC9B,OAAO,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AACxE,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,wBAAwB,CAAC,YAAsB,EAAE,OAAiB;IAChF,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC;IAClD,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClE,CAAC;AAMD,yFAAyF;AACzF,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,IAIrC;IACC,MAAM,UAAU,GAAG,wBAAwB,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IAC7E,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,EAAE,UAAU,EAAE,CAAC;AACxB,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Public surface for the ultracode multi-agent orchestration capability.
|
|
3
|
-
*/
|
|
4
|
-
export { orchestrateChange, AGENT_MANAGER, AGENT_WORKER, AGENT_VERIFIER } from './engine.js';
|
|
5
|
-
export type { OrchestrateOptions } from './engine.js';
|
|
6
|
-
export { OpenCodeClient, extractText } from './client.js';
|
|
7
|
-
export type { OpenCodeApi, OpenCodeClientOptions, SendMessageInput, OpenCodeMessageResponse } from './client.js';
|
|
8
|
-
export { resolveOrchestrationConfig, assertModelsConfigured } from './config.js';
|
|
9
|
-
export { parseBreakdown, stripJsonFences } from './schema.js';
|
|
10
|
-
export { buildDependencyTiers } from './tiers.js';
|
|
11
|
-
export type { DependencyTiers } from './tiers.js';
|
|
12
|
-
export { runSwarm } from './scheduler.js';
|
|
13
|
-
export type { SwarmOptions, SwarmOutcome } from './scheduler.js';
|
|
14
|
-
export { detectFileGateViolations, enforceFileGate } from './file-gate.js';
|
|
15
|
-
export type { FileGateResult } from './file-gate.js';
|
|
16
|
-
export { ORCHESTRATION_AGENT_ASSETS } from './agents.js';
|
|
17
|
-
export type { OrchestrationAsset } from './agents.js';
|
|
18
|
-
export type { ExecutionMode, SubTask, TaskBreakdown, SubtaskResult, Verdict, OrchestrationModels, OrchestrationRuntimeConfig, OrchestrationOutcome, } from './types.js';
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Public surface for the ultracode multi-agent orchestration capability.
|
|
3
|
-
*/
|
|
4
|
-
export { orchestrateChange, AGENT_MANAGER, AGENT_WORKER, AGENT_VERIFIER } from './engine.js';
|
|
5
|
-
export { OpenCodeClient, extractText } from './client.js';
|
|
6
|
-
export { resolveOrchestrationConfig, assertModelsConfigured } from './config.js';
|
|
7
|
-
export { parseBreakdown, stripJsonFences } from './schema.js';
|
|
8
|
-
export { buildDependencyTiers } from './tiers.js';
|
|
9
|
-
export { runSwarm } from './scheduler.js';
|
|
10
|
-
export { detectFileGateViolations, enforceFileGate } from './file-gate.js';
|
|
11
|
-
export { ORCHESTRATION_AGENT_ASSETS } from './agents.js';
|
|
12
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/orchestration/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7F,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1D,OAAO,EAAE,0BAA0B,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAElD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,wBAAwB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAE3E,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Manager step: send the requirement to the manager agent, validate the
|
|
3
|
-
* returned breakdown against the schema, persist it, and return the model.
|
|
4
|
-
*/
|
|
5
|
-
import type { OpenCodeApi } from './client.js';
|
|
6
|
-
import type { TaskBreakdown } from './types.js';
|
|
7
|
-
export interface ManagerOptions {
|
|
8
|
-
requirement: string;
|
|
9
|
-
model: string;
|
|
10
|
-
agentName: string;
|
|
11
|
-
workDirAbs: string;
|
|
12
|
-
}
|
|
13
|
-
export declare function runManager(api: OpenCodeApi, opts: ManagerOptions): Promise<TaskBreakdown>;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Manager step: send the requirement to the manager agent, validate the
|
|
3
|
-
* returned breakdown against the schema, persist it, and return the model.
|
|
4
|
-
*/
|
|
5
|
-
import { extractText } from './client.js';
|
|
6
|
-
import { parseBreakdown } from './schema.js';
|
|
7
|
-
import { MANAGER_SYSTEM_PROMPT } from './prompts.js';
|
|
8
|
-
import { saveArtifact } from './artifacts.js';
|
|
9
|
-
export async function runManager(api, opts) {
|
|
10
|
-
const session = await api.createSession('spego-orchestrate-manager');
|
|
11
|
-
try {
|
|
12
|
-
const response = await api.sendMessage(session.id, {
|
|
13
|
-
text: opts.requirement,
|
|
14
|
-
model: opts.model,
|
|
15
|
-
agent: opts.agentName,
|
|
16
|
-
system: MANAGER_SYSTEM_PROMPT,
|
|
17
|
-
});
|
|
18
|
-
const breakdown = parseBreakdown(extractText(response));
|
|
19
|
-
await saveArtifact(opts.workDirAbs, 'breakdown.json', breakdown);
|
|
20
|
-
return breakdown;
|
|
21
|
-
}
|
|
22
|
-
finally {
|
|
23
|
-
await api.deleteSession(session.id).catch(() => undefined);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=manager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"manager.js","sourceRoot":"","sources":["../../src/orchestration/manager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAU9C,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,GAAgB,EAAE,IAAoB;IACrE,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,aAAa,CAAC,2BAA2B,CAAC,CAAC;IACrE,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,EAAE;YACjD,IAAI,EAAE,IAAI,CAAC,WAAW;YACtB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,KAAK,EAAE,IAAI,CAAC,SAAS;YACrB,MAAM,EAAE,qBAAqB;SAC9B,CAAC,CAAC;QACH,MAAM,SAAS,GAAG,cAAc,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC;QACxD,MAAM,YAAY,CAAC,IAAI,CAAC,UAAU,EAAE,gBAAgB,EAAE,SAAS,CAAC,CAAC;QACjE,OAAO,SAAS,CAAC;IACnB,CAAC;YAAS,CAAC;QACT,MAAM,GAAG,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IAC7D,CAAC;AACH,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* System prompts for the orchestration agents, ported from the ultracode
|
|
3
|
-
* reference implementation. The manager emits a strict snake_case JSON
|
|
4
|
-
* contract; the worker reports a status marker; the verifier emits a verdict.
|
|
5
|
-
*/
|
|
6
|
-
import type { SubTask, TaskBreakdown } from './types.js';
|
|
7
|
-
export declare const MANAGER_SYSTEM_PROMPT = "You are UltraManager, a senior software architect responsible for decomposing a coding task into precise, parallelisable sub-tasks.\n\nOutput ONLY valid JSON matching this schema \u2014 no prose, no markdown fences:\n{\n \"goal\": \"<one sentence>\",\n \"context_summary\": \"<=200 words summarising relevant codebase context>\",\n \"execution_mode\": \"sequential\" | \"parallel\" | \"adaptive\",\n \"test_command\": \"<shell command to run the full test suite>\",\n \"language\": \"<primary language>\",\n \"subtasks\": [\n {\n \"id\": \"<snake_case unique id>\",\n \"title\": \"<=60 chars>\",\n \"description\": \"<clear implementation instructions>\",\n \"files\": [\"<relative paths the worker may modify>\"],\n \"acceptance_criteria\": [\"<verifiable criterion>\"],\n \"depends_on\": [\"<other subtask id>\"],\n \"priority\": 0\n }\n ]\n}\n\nRules:\n- Each subtask must be self-contained enough to be implemented in one agent session.\n- Minimise cross-task file overlap to allow safe parallel execution.\n- If tasks share files, list them as depends_on (sequential chain).\n- acceptance_criteria must be executable assertions, not vague goals.\n- Do NOT include any text outside the JSON object.";
|
|
8
|
-
export declare const VERIFIER_SYSTEM_PROMPT = "You are UltraVerifier, a QA agent responsible for final validation.\nYou will receive a JSON summary of all completed sub-tasks and their changed files.\nYour job:\n1. Run the full test suite using the provided test command.\n2. Check that every acceptance criterion is satisfied.\n3. Report any regressions or missing criteria.\n4. Output ONLY a structured JSON verdict (no prose, no fences):\n{\n \"passed\": true | false,\n \"test_output\": \"<truncated stdout>\",\n \"failing_criteria\": [\"<criterion text>\"],\n \"regressions\": [\"<regression description>\"],\n \"notes\": \"<optional free text>\"\n}";
|
|
9
|
-
export declare function renderWorkerPrompt(task: SubTask, breakdown: TaskBreakdown): string;
|
|
10
|
-
export declare function renderVerifierPrompt(payload: unknown): string;
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* System prompts for the orchestration agents, ported from the ultracode
|
|
3
|
-
* reference implementation. The manager emits a strict snake_case JSON
|
|
4
|
-
* contract; the worker reports a status marker; the verifier emits a verdict.
|
|
5
|
-
*/
|
|
6
|
-
export const MANAGER_SYSTEM_PROMPT = `You are UltraManager, a senior software architect responsible for decomposing a coding task into precise, parallelisable sub-tasks.
|
|
7
|
-
|
|
8
|
-
Output ONLY valid JSON matching this schema — no prose, no markdown fences:
|
|
9
|
-
{
|
|
10
|
-
"goal": "<one sentence>",
|
|
11
|
-
"context_summary": "<=200 words summarising relevant codebase context>",
|
|
12
|
-
"execution_mode": "sequential" | "parallel" | "adaptive",
|
|
13
|
-
"test_command": "<shell command to run the full test suite>",
|
|
14
|
-
"language": "<primary language>",
|
|
15
|
-
"subtasks": [
|
|
16
|
-
{
|
|
17
|
-
"id": "<snake_case unique id>",
|
|
18
|
-
"title": "<=60 chars>",
|
|
19
|
-
"description": "<clear implementation instructions>",
|
|
20
|
-
"files": ["<relative paths the worker may modify>"],
|
|
21
|
-
"acceptance_criteria": ["<verifiable criterion>"],
|
|
22
|
-
"depends_on": ["<other subtask id>"],
|
|
23
|
-
"priority": 0
|
|
24
|
-
}
|
|
25
|
-
]
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
Rules:
|
|
29
|
-
- Each subtask must be self-contained enough to be implemented in one agent session.
|
|
30
|
-
- Minimise cross-task file overlap to allow safe parallel execution.
|
|
31
|
-
- If tasks share files, list them as depends_on (sequential chain).
|
|
32
|
-
- acceptance_criteria must be executable assertions, not vague goals.
|
|
33
|
-
- Do NOT include any text outside the JSON object.`;
|
|
34
|
-
export const VERIFIER_SYSTEM_PROMPT = `You are UltraVerifier, a QA agent responsible for final validation.
|
|
35
|
-
You will receive a JSON summary of all completed sub-tasks and their changed files.
|
|
36
|
-
Your job:
|
|
37
|
-
1. Run the full test suite using the provided test command.
|
|
38
|
-
2. Check that every acceptance criterion is satisfied.
|
|
39
|
-
3. Report any regressions or missing criteria.
|
|
40
|
-
4. Output ONLY a structured JSON verdict (no prose, no fences):
|
|
41
|
-
{
|
|
42
|
-
"passed": true | false,
|
|
43
|
-
"test_output": "<truncated stdout>",
|
|
44
|
-
"failing_criteria": ["<criterion text>"],
|
|
45
|
-
"regressions": ["<regression description>"],
|
|
46
|
-
"notes": "<optional free text>"
|
|
47
|
-
}`;
|
|
48
|
-
export function renderWorkerPrompt(task, breakdown) {
|
|
49
|
-
return `You are UltraWorker, a focused implementation agent.
|
|
50
|
-
You will implement a single sub-task precisely.
|
|
51
|
-
|
|
52
|
-
Codebase context:
|
|
53
|
-
${breakdown.contextSummary}
|
|
54
|
-
|
|
55
|
-
Task spec (JSON):
|
|
56
|
-
${JSON.stringify(task, null, 2)}
|
|
57
|
-
|
|
58
|
-
Rules:
|
|
59
|
-
- Modify ONLY the files listed in the \`files\` array.
|
|
60
|
-
- After implementing, run the test command to verify your changes:
|
|
61
|
-
${breakdown.testCommand || '(no test command provided)'}
|
|
62
|
-
- If tests fail, fix them (max 3 attempts) before reporting done.
|
|
63
|
-
- End your final message with exactly:
|
|
64
|
-
ULTRAWORKER_STATUS: SUCCESS
|
|
65
|
-
or
|
|
66
|
-
ULTRAWORKER_STATUS: FAILED - <reason>`;
|
|
67
|
-
}
|
|
68
|
-
export function renderVerifierPrompt(payload) {
|
|
69
|
-
return `Here is the multi-agent execution summary. Run the test suite and emit your verdict JSON.\n\n${JSON.stringify(payload, null, 2)}`;
|
|
70
|
-
}
|
|
71
|
-
//# sourceMappingURL=prompts.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../src/orchestration/prompts.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;mDA2Bc,CAAC;AAEpD,MAAM,CAAC,MAAM,sBAAsB,GAAG;;;;;;;;;;;;;EAapC,CAAC;AAEH,MAAM,UAAU,kBAAkB,CAAC,IAAa,EAAE,SAAwB;IACxE,OAAO;;;;EAIP,SAAS,CAAC,cAAc;;;EAGxB,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;;;;;MAKzB,SAAS,CAAC,WAAW,IAAI,4BAA4B;;;;;0CAKjB,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,OAAgB;IACnD,OAAO,gGAAgG,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;AAC5I,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Swarm scheduler. Executes sub-tasks in `sequential`, `parallel`, or
|
|
3
|
-
* `adaptive` mode, honoring `dependsOn` edges and bounding concurrency.
|
|
4
|
-
*
|
|
5
|
-
* The actual per-task work is injected via `runTask`, keeping the scheduler
|
|
6
|
-
* free of any OpenCode/IO coupling and trivially unit-testable.
|
|
7
|
-
*/
|
|
8
|
-
import type { ExecutionMode, SubTask, SubtaskResult, TaskBreakdown } from './types.js';
|
|
9
|
-
export interface SwarmOptions {
|
|
10
|
-
mode?: ExecutionMode;
|
|
11
|
-
maxParallel: number;
|
|
12
|
-
runTask: (task: SubTask) => Promise<SubtaskResult>;
|
|
13
|
-
}
|
|
14
|
-
export interface SwarmOutcome {
|
|
15
|
-
results: SubtaskResult[];
|
|
16
|
-
warnings: string[];
|
|
17
|
-
}
|
|
18
|
-
export declare function runSwarm(breakdown: TaskBreakdown, opts: SwarmOptions): Promise<SwarmOutcome>;
|