@puzzmo/cli 1.0.71 → 1.0.73
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/lib/agents/claude.d.ts +2 -2
- package/lib/agents/claude.js +67 -16
- package/lib/agents/claude.js.map +1 -1
- package/lib/agents/codex.js +12 -1
- package/lib/agents/codex.js.map +1 -1
- package/lib/agents/copilot.js +10 -1
- package/lib/agents/copilot.js.map +1 -1
- package/lib/agents/gemini.js +9 -1
- package/lib/agents/gemini.js.map +1 -1
- package/lib/agents/index.d.ts +1 -1
- package/lib/agents/stream-json-cli.d.ts +5 -4
- package/lib/agents/stream-json-cli.js +29 -4
- package/lib/agents/stream-json-cli.js.map +1 -1
- package/lib/agents/types.d.ts +15 -0
- package/lib/commands/game/create.js +46 -18
- package/lib/commands/game/create.js.map +1 -1
- package/lib/commands/game/seedImport.d.ts +13 -0
- package/lib/commands/game/seedImport.js +25 -0
- package/lib/commands/game/seedImport.js.map +1 -0
- package/lib/commands/upload.js +8 -19
- package/lib/commands/upload.js.map +1 -1
- package/lib/download/page-downloader.js +20 -7
- package/lib/download/page-downloader.js.map +1 -1
- package/lib/skills/context.d.ts +6 -0
- package/lib/skills/context.js +74 -0
- package/lib/skills/context.js.map +1 -0
- package/lib/skills/mcp-client.d.ts +5 -0
- package/lib/skills/mcp-client.js +21 -0
- package/lib/skills/mcp-client.js.map +1 -1
- package/lib/skills/registry.d.ts +24 -3
- package/lib/skills/registry.js +47 -11
- package/lib/skills/registry.js.map +1 -1
- package/lib/skills/runner.d.ts +3 -6
- package/lib/skills/runner.js +45 -94
- package/lib/skills/runner.js.map +1 -1
- package/lib/skills/step.d.ts +25 -0
- package/lib/skills/step.js +29 -0
- package/lib/skills/step.js.map +1 -0
- package/lib/tui/pipeline.d.ts +3 -1
- package/lib/tui/pipeline.js +195 -75
- package/lib/tui/pipeline.js.map +1 -1
- package/lib/util/collapseRepeats.d.ts +20 -0
- package/lib/util/collapseRepeats.js +80 -0
- package/lib/util/collapseRepeats.js.map +1 -0
- package/lib/util/duration.d.ts +7 -0
- package/lib/util/duration.js +25 -0
- package/lib/util/duration.js.map +1 -0
- package/lib/util/exec.d.ts +15 -3
- package/lib/util/exec.js +37 -7
- package/lib/util/exec.js.map +1 -1
- package/lib/util/mascot.d.ts +18 -0
- package/lib/util/mascot.js +42 -0
- package/lib/util/mascot.js.map +1 -0
- package/package.json +3 -2
- package/scripts/demo-tui.mjs +108 -0
- package/src/agents/__fixtures__/README.md +1 -0
- package/src/agents/__fixtures__/claude-bash.jsonl +114 -0
- package/src/agents/claude.ts +64 -16
- package/src/agents/codex.ts +12 -1
- package/src/agents/copilot.ts +10 -1
- package/src/agents/gemini.ts +9 -1
- package/src/agents/index.ts +1 -1
- package/src/agents/parse-line.test.ts +40 -6
- package/src/agents/stream-json-cli.ts +32 -8
- package/src/agents/types.ts +16 -0
- package/src/commands/game/create.ts +47 -18
- package/src/commands/game/seedImport.ts +30 -0
- package/src/commands/upload.ts +7 -21
- package/src/download/page-downloader.ts +22 -7
- package/src/skills/context.ts +75 -0
- package/src/skills/mcp-client.ts +24 -0
- package/src/skills/registry.ts +66 -11
- package/src/skills/runner.ts +52 -103
- package/src/skills/step.ts +47 -0
- package/src/tui/pipeline.ts +200 -72
- package/src/util/collapseRepeats.test.ts +78 -0
- package/src/util/collapseRepeats.ts +77 -0
- package/src/util/duration.test.ts +37 -0
- package/src/util/duration.ts +25 -0
- package/src/util/exec.ts +40 -7
- package/src/util/mascot.ts +55 -0
- package/templates/minesweeper/README.md +3 -1
- package/templates/minesweeper/package.json +3 -1
package/lib/skills/runner.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { type SkillDefinition } from "./registry.js";
|
|
2
|
-
|
|
3
|
-
export declare const runSkillsPipeline: (agent: string, gameDir: string, repoContext: string) => Promise<void>;
|
|
4
|
-
/** Runs the skills pipeline with a split-pane TUI */
|
|
5
|
-
export declare const runSkillsPipelineTUI: (agent: string, gameDir: string, repoContext: string) => Promise<void>;
|
|
2
|
+
import { type PipelineContext } from "./step.js";
|
|
6
3
|
/** Runs a chosen subset of skills (the optional add-ons after the prompt flow); warns but never exits on failure */
|
|
7
|
-
export declare const runSelectedSkills: (
|
|
4
|
+
export declare const runSelectedSkills: (ctx: PipelineContext, skills: SkillDefinition[]) => Promise<void>;
|
|
8
5
|
/**
|
|
9
6
|
* Outcome of a build loop. `logPath` points at the persisted run transcript.
|
|
10
7
|
* On failure `reason` is a human-readable summary and `buildError` holds captured build output.
|
|
@@ -19,4 +16,4 @@ export type BuildLoopResult = {
|
|
|
19
16
|
logPath: string;
|
|
20
17
|
};
|
|
21
18
|
/** Runs a single agent invocation, verifies the build, and commits. Used by one-shot prompt-driven flows. */
|
|
22
|
-
export declare const runAgentWithBuildLoop: (
|
|
19
|
+
export declare const runAgentWithBuildLoop: (ctx: PipelineContext, prompt: string, label: string) => Promise<BuildLoopResult>;
|
package/lib/skills/runner.js
CHANGED
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { getAgent } from "../agents/index.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { runPipelineTUI } from "../tui/pipeline.js";
|
|
8
|
-
const agentTimeoutMs = 300000; // 5 minute timeout per agent invocation
|
|
9
|
-
/** Fetches step instructions from the MCP server and wraps them as an agent prompt */
|
|
10
|
-
const buildPrompt = async (stepName, gameDir, repoContext) => {
|
|
11
|
-
const instructions = await fetchSkillPrompt(stepName, gameDir);
|
|
12
|
-
return `Follow these instructions. The game source is in the current directory.\n\n${repoContext}\n\n${instructions}`;
|
|
13
|
-
};
|
|
4
|
+
import { verifyBuild } from "../util/exec.js";
|
|
5
|
+
import { formatDuration } from "../util/duration.js";
|
|
6
|
+
import { agentIdleTimeoutMs, buildStepPrompt, commitStep, resetSession } from "./step.js";
|
|
14
7
|
/**
|
|
15
8
|
* Invokes an LLM agent with a prompt, streaming its text and tool activity to the console.
|
|
16
9
|
* When `transcript` is provided, an ANSI-stripped copy of everything printed is appended to it.
|
|
17
10
|
*/
|
|
18
|
-
const invokeAgent = async (agentName, prompt, cwd, transcript) => {
|
|
11
|
+
const invokeAgent = async (agentName, prompt, cwd, session, transcript) => {
|
|
19
12
|
const agent = getAgent(agentName);
|
|
20
13
|
if (!agent) {
|
|
21
14
|
const line = ` Unknown agent: ${agentName}`;
|
|
@@ -23,6 +16,7 @@ const invokeAgent = async (agentName, prompt, cwd, transcript) => {
|
|
|
23
16
|
transcript?.push(line);
|
|
24
17
|
return false;
|
|
25
18
|
}
|
|
19
|
+
const started = Date.now();
|
|
26
20
|
let resultOk = null;
|
|
27
21
|
let sawError = false;
|
|
28
22
|
let midLine = false;
|
|
@@ -49,7 +43,7 @@ const invokeAgent = async (agentName, prompt, cwd, transcript) => {
|
|
|
49
43
|
record(line);
|
|
50
44
|
};
|
|
51
45
|
try {
|
|
52
|
-
for await (const event of agent.run({ prompt, cwd,
|
|
46
|
+
for await (const event of agent.run({ prompt, cwd, session, idleTimeoutMs: agentIdleTimeoutMs })) {
|
|
53
47
|
if (event.type === "text") {
|
|
54
48
|
process.stdout.write(dim(event.text));
|
|
55
49
|
midLine = !event.text.endsWith("\n");
|
|
@@ -68,8 +62,8 @@ const invokeAgent = async (agentName, prompt, cwd, transcript) => {
|
|
|
68
62
|
}
|
|
69
63
|
else if (event.type === "result") {
|
|
70
64
|
resultOk = event.ok;
|
|
71
|
-
const cost = event.costUSD != null ?
|
|
72
|
-
printLine((event.ok ? green : red)(` Agent finished${cost}`));
|
|
65
|
+
const cost = event.costUSD != null ? `, $${event.costUSD.toFixed(4)}` : "";
|
|
66
|
+
printLine((event.ok ? green : red)(` Agent finished in ${formatDuration(Date.now() - started)}${cost}`));
|
|
73
67
|
}
|
|
74
68
|
else if (event.type === "error") {
|
|
75
69
|
sawError = true;
|
|
@@ -83,88 +77,48 @@ const invokeAgent = async (agentName, prompt, cwd, transcript) => {
|
|
|
83
77
|
}
|
|
84
78
|
endLine();
|
|
85
79
|
flushBuf();
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const total = skillsPipeline.length;
|
|
91
|
-
for (let i = 0; i < total; i++) {
|
|
92
|
-
const skill = skillsPipeline[i];
|
|
93
|
-
const step = i + 1;
|
|
94
|
-
console.log(`[${step}/${total}] Running step: ${skill.name}`);
|
|
95
|
-
const prompt = await buildPrompt(skill.name, gameDir, repoContext);
|
|
96
|
-
let success = await invokeAgent(agent, prompt, gameDir);
|
|
97
|
-
if (!success) {
|
|
98
|
-
console.log(` Agent failed, retrying...`);
|
|
99
|
-
success = await invokeAgent(agent, prompt, gameDir);
|
|
100
|
-
if (!success) {
|
|
101
|
-
console.error(` Step ${skill.name} failed after retry. Stopping pipeline.`);
|
|
102
|
-
process.exit(1);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
// Verify build
|
|
106
|
-
const buildResult = verifyBuild(gameDir);
|
|
107
|
-
if (!buildResult.success) {
|
|
108
|
-
console.log(` Build failed after ${skill.name}, asking agent to fix...`);
|
|
109
|
-
const fixPrompt = `The vite build failed after the "${skill.name}" step. Fix the build errors:\n\n${buildResult.error}`;
|
|
110
|
-
await invokeAgent(agent, fixPrompt, gameDir);
|
|
111
|
-
const retryBuild = verifyBuild(gameDir);
|
|
112
|
-
if (!retryBuild.success) {
|
|
113
|
-
console.error(` Build still failing after fix attempt. Stopping.`);
|
|
114
|
-
process.exit(1);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
// Commit
|
|
118
|
-
try {
|
|
119
|
-
runCommand("git add -A", { cwd: gameDir });
|
|
120
|
-
gitCommit(`step: ${skill.name}`, { cwd: gameDir });
|
|
121
|
-
console.log(` Committed.`);
|
|
122
|
-
}
|
|
123
|
-
catch {
|
|
124
|
-
console.log(` No changes to commit.`);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
console.log(`\nAll skills completed!`);
|
|
128
|
-
};
|
|
129
|
-
/** Runs the skills pipeline with a split-pane TUI */
|
|
130
|
-
export const runSkillsPipelineTUI = async (agent, gameDir, repoContext) => {
|
|
131
|
-
await runPipelineTUI(agent, gameDir, repoContext);
|
|
80
|
+
const ok = resultOk ?? !sawError;
|
|
81
|
+
if (ok && session)
|
|
82
|
+
session.started = true;
|
|
83
|
+
return ok;
|
|
132
84
|
};
|
|
133
85
|
/** Runs a chosen subset of skills (the optional add-ons after the prompt flow); warns but never exits on failure */
|
|
134
|
-
export const runSelectedSkills = async (
|
|
86
|
+
export const runSelectedSkills = async (ctx, skills) => {
|
|
135
87
|
const total = skills.length;
|
|
88
|
+
const startedAll = Date.now();
|
|
136
89
|
for (let i = 0; i < total; i++) {
|
|
137
90
|
const skill = skills[i];
|
|
91
|
+
const startedStep = Date.now();
|
|
138
92
|
console.log(`[${i + 1}/${total}] Running step: ${skill.name}`);
|
|
139
|
-
const
|
|
140
|
-
|
|
93
|
+
const step = { name: skill.name, skills: [skill.name], preamble: "Follow these instructions." };
|
|
94
|
+
const prompt = await buildStepPrompt(step, ctx);
|
|
95
|
+
let success = await invokeAgent(ctx.agent, prompt, ctx.gameDir, ctx.session);
|
|
141
96
|
if (!success) {
|
|
142
97
|
console.log(` Agent failed, retrying...`);
|
|
143
|
-
|
|
98
|
+
resetSession(ctx.session);
|
|
99
|
+
success = await invokeAgent(ctx.agent, prompt, ctx.gameDir, ctx.session);
|
|
144
100
|
}
|
|
145
101
|
if (!success) {
|
|
146
102
|
console.error(` Step ${skill.name} did not complete cleanly, skipping.`);
|
|
147
103
|
continue;
|
|
148
104
|
}
|
|
149
105
|
// Verify build; ask the agent to fix but keep going regardless
|
|
150
|
-
const buildResult = verifyBuild(gameDir);
|
|
106
|
+
const buildResult = await verifyBuild(ctx.gameDir, ctx.buildCmd);
|
|
151
107
|
if (!buildResult.success) {
|
|
152
108
|
console.log(` Build failed after ${skill.name}, asking agent to fix...`);
|
|
153
|
-
const fixPrompt = `The
|
|
154
|
-
await invokeAgent(agent, fixPrompt, gameDir);
|
|
155
|
-
}
|
|
156
|
-
try {
|
|
157
|
-
runCommand("git add -A", { cwd: gameDir });
|
|
158
|
-
gitCommit(`step: ${skill.name}`, { cwd: gameDir });
|
|
159
|
-
console.log(` Committed.`);
|
|
160
|
-
}
|
|
161
|
-
catch {
|
|
162
|
-
console.log(` No changes to commit.`);
|
|
109
|
+
const fixPrompt = `The build (${ctx.buildCmd}) failed after the "${skill.name}" step. Fix the build errors:\n\n${buildResult.error}`;
|
|
110
|
+
await invokeAgent(ctx.agent, fixPrompt, ctx.gameDir, ctx.session);
|
|
163
111
|
}
|
|
112
|
+
const committed = await commitStep(ctx.gameDir, skill.name);
|
|
113
|
+
console.log(committed ? " Committed." : " No changes to commit.");
|
|
114
|
+
console.log(` ${skill.name} took ${formatDuration(Date.now() - startedStep)}`);
|
|
164
115
|
}
|
|
116
|
+
if (total > 0)
|
|
117
|
+
console.log(`Optional skills finished in ${formatDuration(Date.now() - startedAll)}`);
|
|
165
118
|
};
|
|
166
119
|
/** Runs a single agent invocation, verifies the build, and commits. Used by one-shot prompt-driven flows. */
|
|
167
|
-
export const runAgentWithBuildLoop = async (
|
|
120
|
+
export const runAgentWithBuildLoop = async (ctx, prompt, label) => {
|
|
121
|
+
const started = Date.now();
|
|
168
122
|
const transcript = [];
|
|
169
123
|
// Print to the console and record the same line to the run transcript.
|
|
170
124
|
const say = (line) => {
|
|
@@ -172,39 +126,36 @@ export const runAgentWithBuildLoop = async (agent, prompt, gameDir, label) => {
|
|
|
172
126
|
transcript.push(stripAnsi(line));
|
|
173
127
|
};
|
|
174
128
|
say(`Running agent: ${label}`);
|
|
175
|
-
let success = await invokeAgent(agent, prompt, gameDir, transcript);
|
|
129
|
+
let success = await invokeAgent(ctx.agent, prompt, ctx.gameDir, ctx.session, transcript);
|
|
176
130
|
if (!success) {
|
|
177
131
|
say(` Agent failed, retrying...`);
|
|
178
|
-
|
|
132
|
+
resetSession(ctx.session);
|
|
133
|
+
success = await invokeAgent(ctx.agent, prompt, ctx.gameDir, ctx.session, transcript);
|
|
179
134
|
if (!success) {
|
|
180
135
|
say(` Agent failed after retry. Stopping.`);
|
|
181
|
-
const logPath = writeRunLog(gameDir, label, transcript);
|
|
136
|
+
const logPath = writeRunLog(ctx.gameDir, label, transcript);
|
|
182
137
|
return { ok: false, reason: "the agent did not finish successfully after two attempts", logPath };
|
|
183
138
|
}
|
|
184
139
|
}
|
|
185
|
-
const
|
|
140
|
+
const buildStarted = Date.now();
|
|
141
|
+
const buildResult = await verifyBuild(ctx.gameDir, ctx.buildCmd);
|
|
142
|
+
say(dim(` Build took ${formatDuration(Date.now() - buildStarted)}`));
|
|
186
143
|
if (!buildResult.success) {
|
|
187
144
|
say(` Build failed, asking agent to fix...`);
|
|
188
145
|
recordBuildError(say, buildResult.error);
|
|
189
|
-
const fixPrompt = `The
|
|
190
|
-
await invokeAgent(agent, fixPrompt, gameDir, transcript);
|
|
191
|
-
const retry = verifyBuild(gameDir);
|
|
146
|
+
const fixPrompt = `The build (${ctx.buildCmd}) failed after the "${label}" step. Fix the build errors:\n\n${buildResult.error}`;
|
|
147
|
+
await invokeAgent(ctx.agent, fixPrompt, ctx.gameDir, ctx.session, transcript);
|
|
148
|
+
const retry = await verifyBuild(ctx.gameDir, ctx.buildCmd);
|
|
192
149
|
if (!retry.success) {
|
|
193
150
|
say(` Build still failing after fix attempt.`);
|
|
194
151
|
recordBuildError(say, retry.error);
|
|
195
|
-
const logPath = writeRunLog(gameDir, label, transcript);
|
|
196
|
-
return { ok: false, reason: "the
|
|
152
|
+
const logPath = writeRunLog(ctx.gameDir, label, transcript);
|
|
153
|
+
return { ok: false, reason: "the build is still failing after the agent's fix attempt", buildError: retry.error, logPath };
|
|
197
154
|
}
|
|
198
155
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
say(` Committed.`);
|
|
203
|
-
}
|
|
204
|
-
catch {
|
|
205
|
-
say(` No changes to commit.`);
|
|
206
|
-
}
|
|
207
|
-
return { ok: true, logPath: writeRunLog(gameDir, label, transcript) };
|
|
156
|
+
say((await commitStep(ctx.gameDir, label)) ? " Committed." : " No changes to commit.");
|
|
157
|
+
say(` ${label} finished in ${formatDuration(Date.now() - started)}`);
|
|
158
|
+
return { ok: true, logPath: writeRunLog(ctx.gameDir, label, transcript) };
|
|
208
159
|
};
|
|
209
160
|
/** Emits captured build output via `say`, trimmed to the trailing lines that usually hold the actual error */
|
|
210
161
|
const recordBuildError = (say, error) => {
|
package/lib/skills/runner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/skills/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/skills/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAAE,QAAQ,EAAqB,MAAM,oBAAoB,CAAA;AAEhE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,UAAU,EAAE,YAAY,EAAwB,MAAM,WAAW,CAAA;AAE/G;;;GAGG;AACH,MAAM,WAAW,GAAG,KAAK,EACvB,SAAiB,EACjB,MAAc,EACd,GAAW,EACX,OAAsB,EACtB,UAAqB,EACH,EAAE;IACpB,MAAM,KAAK,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAA;IACjC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,GAAG,oBAAoB,SAAS,EAAE,CAAA;QAC5C,OAAO,CA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,IAAI,IAAI,KAAK;QAAE,GAAG,CAAC,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,CAAA;AACnD,CAAC,CAAA;AAED,mHAAmH;AACnH,MAAM,WAAW,GAAG,CAAC,OAAe,EAAE,KAAa,EAAE,KAAe,EAAU,EAAE;IAC9E,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,CAAA;IACrD,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IAC1C,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,KAAK,MAAM,CAAC,CAAA;IAClD,EAAE,CAAC,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAA;IAClD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAED,4CAA4C;AAC5C,MAAM,MAAM,GAAG,wBAAwB,CAAA;AACvC,2EAA2E;AAC3E,MAAM,SAAS,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;AAEtD,uCAAuC;AACvC,MAAM,GAAG,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,UAAU,CAAC,SAAS,CAAA;AAC/C,yCAAyC;AACzC,MAAM,KAAK,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,WAAW,CAAC,SAAS,CAAA;AAClD,uCAAuC;AACvC,MAAM,GAAG,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,WAAW,CAAC,SAAS,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { AgentSession } from "../agents/index.js";
|
|
2
|
+
import type { PipelineStep } from "./registry.js";
|
|
3
|
+
/** Stop an agent that has produced no output at all for this long — a wedged run, not a thinking one */
|
|
4
|
+
export declare const agentIdleTimeoutMs = 120000;
|
|
5
|
+
/** Everything a step needs to run: which agent, where, how to build, and the conversation to continue */
|
|
6
|
+
export type PipelineContext = {
|
|
7
|
+
agent: string;
|
|
8
|
+
gameDir: string;
|
|
9
|
+
repoContext: string;
|
|
10
|
+
/** Command that builds the game, resolved from the detected package manager */
|
|
11
|
+
buildCmd: string;
|
|
12
|
+
/** Shared across steps so the agent keeps its picture of the project between them */
|
|
13
|
+
session: AgentSession;
|
|
14
|
+
};
|
|
15
|
+
/** A fresh conversation. Steps share one of these; a retry rotates to a new one. */
|
|
16
|
+
export declare const newSession: () => AgentSession;
|
|
17
|
+
/** Points the context at a new conversation, so the next run starts cold */
|
|
18
|
+
export declare const resetSession: (session: AgentSession) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Assembles a step's prompt: local instructions, the state of the project, then the skill
|
|
21
|
+
* docs from the MCP server. Several skills in one step become one agent invocation.
|
|
22
|
+
*/
|
|
23
|
+
export declare const buildStepPrompt: (step: PipelineStep, ctx: PipelineContext) => Promise<string>;
|
|
24
|
+
/** Stages and commits whatever the step changed. False when there was nothing to commit. */
|
|
25
|
+
export declare const commitStep: (gameDir: string, label: string) => Promise<boolean>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { runCapture } from "../util/exec.js";
|
|
3
|
+
import { fetchSkillPrompt } from "./mcp-client.js";
|
|
4
|
+
import { describeProject } from "./context.js";
|
|
5
|
+
/** Stop an agent that has produced no output at all for this long — a wedged run, not a thinking one */
|
|
6
|
+
export const agentIdleTimeoutMs = 120000;
|
|
7
|
+
/** A fresh conversation. Steps share one of these; a retry rotates to a new one. */
|
|
8
|
+
export const newSession = () => ({ id: randomUUID(), started: false });
|
|
9
|
+
/** Points the context at a new conversation, so the next run starts cold */
|
|
10
|
+
export const resetSession = (session) => {
|
|
11
|
+
session.id = randomUUID();
|
|
12
|
+
session.started = false;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Assembles a step's prompt: local instructions, the state of the project, then the skill
|
|
16
|
+
* docs from the MCP server. Several skills in one step become one agent invocation.
|
|
17
|
+
*/
|
|
18
|
+
export const buildStepPrompt = async (step, ctx) => {
|
|
19
|
+
const docs = await Promise.all(step.skills.map((name) => fetchSkillPrompt(name, ctx.gameDir)));
|
|
20
|
+
const parts = [step.preamble, ctx.repoContext, describeProject(ctx.gameDir), ...docs];
|
|
21
|
+
return parts.filter(Boolean).join("\n\n---\n\n");
|
|
22
|
+
};
|
|
23
|
+
/** Stages and commits whatever the step changed. False when there was nothing to commit. */
|
|
24
|
+
export const commitStep = async (gameDir, label) => {
|
|
25
|
+
await runCapture("git add -A", { cwd: gameDir });
|
|
26
|
+
const result = await runCapture(`git commit -m "step: ${label}"`, { cwd: gameDir });
|
|
27
|
+
return result.success;
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=step.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step.js","sourceRoot":"","sources":["../../src/skills/step.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAIxC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE9C,wGAAwG;AACxG,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAA;AAaxC,oFAAoF;AACpF,MAAM,CAAC,MAAM,UAAU,GAAG,GAAiB,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAA;AAEpF,4EAA4E;AAC5E,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAqB,EAAE,EAAE;IACpD,OAAO,CAAC,EAAE,GAAG,UAAU,EAAE,CAAA;IACzB,OAAO,CAAC,OAAO,GAAG,KAAK,CAAA;AACzB,CAAC,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAAE,IAAkB,EAAE,GAAoB,EAAmB,EAAE;IACjG,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;IAC9F,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,WAAW,EAAE,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC,CAAA;IACrF,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;AAClD,CAAC,CAAA;AAED,4FAA4F;AAC5F,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,EAAE,OAAe,EAAE,KAAa,EAAoB,EAAE;IACnF,MAAM,UAAU,CAAC,YAAY,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAA;IAChD,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,wBAAwB,KAAK,GAAG,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAA;IACnF,OAAO,MAAM,CAAC,OAAO,CAAA;AACvB,CAAC,CAAA"}
|
package/lib/tui/pipeline.d.ts
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import type { PipelineStep } from "../skills/registry.js";
|
|
2
|
+
import { type PipelineContext } from "../skills/step.js";
|
|
3
|
+
export declare const runPipelineTUI: (ctx: PipelineContext, steps: PipelineStep[]) => Promise<void>;
|