zelio-cli 0.0.0-stage → 0.1.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +185 -2
- package/dist/attachments.js +121 -0
- package/dist/attachments.js.map +1 -0
- package/dist/cli.js +496 -0
- package/dist/cli.js.map +1 -0
- package/dist/cloud/board.js +311 -0
- package/dist/cloud/board.js.map +1 -0
- package/dist/cloud/command.js +281 -0
- package/dist/cloud/command.js.map +1 -0
- package/dist/cloud/config.js +132 -0
- package/dist/cloud/config.js.map +1 -0
- package/dist/cloud/credentials.js +134 -0
- package/dist/cloud/credentials.js.map +1 -0
- package/dist/cloud/login.js +165 -0
- package/dist/cloud/login.js.map +1 -0
- package/dist/cloud/pair.js +110 -0
- package/dist/cloud/pair.js.map +1 -0
- package/dist/cloud/pkce.js +16 -0
- package/dist/cloud/pkce.js.map +1 -0
- package/dist/cloud/push-nudge.js +65 -0
- package/dist/cloud/push-nudge.js.map +1 -0
- package/dist/cloud/relay.js +134 -0
- package/dist/cloud/relay.js.map +1 -0
- package/dist/cloud/token.js +66 -0
- package/dist/cloud/token.js.map +1 -0
- package/dist/cloud/tunnel.js +474 -0
- package/dist/cloud/tunnel.js.map +1 -0
- package/dist/db/db.js +1741 -0
- package/dist/db/db.js.map +1 -0
- package/dist/db/lifecycle.js +146 -0
- package/dist/db/lifecycle.js.map +1 -0
- package/dist/limits.js +35 -0
- package/dist/limits.js.map +1 -0
- package/dist/metrics.js +30 -0
- package/dist/metrics.js.map +1 -0
- package/dist/orchestrator/claude-session.js +208 -0
- package/dist/orchestrator/claude-session.js.map +1 -0
- package/dist/orchestrator/codex-session.js +326 -0
- package/dist/orchestrator/codex-session.js.map +1 -0
- package/dist/orchestrator/contract.js +184 -0
- package/dist/orchestrator/contract.js.map +1 -0
- package/dist/orchestrator/explore.js +176 -0
- package/dist/orchestrator/explore.js.map +1 -0
- package/dist/orchestrator/new-task-prompt.js +51 -0
- package/dist/orchestrator/new-task-prompt.js.map +1 -0
- package/dist/orchestrator/pi-session.js +228 -0
- package/dist/orchestrator/pi-session.js.map +1 -0
- package/dist/orchestrator/prompt.js +110 -0
- package/dist/orchestrator/prompt.js.map +1 -0
- package/dist/orchestrator/research.js +178 -0
- package/dist/orchestrator/research.js.map +1 -0
- package/dist/orchestrator/runtime.js +1207 -0
- package/dist/orchestrator/runtime.js.map +1 -0
- package/dist/orchestrator/session.js +2 -0
- package/dist/orchestrator/session.js.map +1 -0
- package/dist/orchestrator/types.js +2 -0
- package/dist/orchestrator/types.js.map +1 -0
- package/dist/orchestrator/web.js +276 -0
- package/dist/orchestrator/web.js.map +1 -0
- package/dist/repo/index.js +188 -0
- package/dist/repo/index.js.map +1 -0
- package/dist/repo/instructions.js +58 -0
- package/dist/repo/instructions.js.map +1 -0
- package/dist/repo/linked-boards.js +137 -0
- package/dist/repo/linked-boards.js.map +1 -0
- package/dist/repo/project-repos.js +78 -0
- package/dist/repo/project-repos.js.map +1 -0
- package/dist/run/actions.js +257 -0
- package/dist/run/actions.js.map +1 -0
- package/dist/run/auto-review.js +102 -0
- package/dist/run/auto-review.js.map +1 -0
- package/dist/run/bash-guard.js +183 -0
- package/dist/run/bash-guard.js.map +1 -0
- package/dist/run/claude-runtime.js +270 -0
- package/dist/run/claude-runtime.js.map +1 -0
- package/dist/run/claude-stream.js +306 -0
- package/dist/run/claude-stream.js.map +1 -0
- package/dist/run/codex-client.js +202 -0
- package/dist/run/codex-client.js.map +1 -0
- package/dist/run/codex-runtime.js +460 -0
- package/dist/run/codex-runtime.js.map +1 -0
- package/dist/run/consult.js +105 -0
- package/dist/run/consult.js.map +1 -0
- package/dist/run/context.js +87 -0
- package/dist/run/context.js.map +1 -0
- package/dist/run/diff.js +238 -0
- package/dist/run/diff.js.map +1 -0
- package/dist/run/evidence.js +48 -0
- package/dist/run/evidence.js.map +1 -0
- package/dist/run/finish.js +408 -0
- package/dist/run/finish.js.map +1 -0
- package/dist/run/handoff.js +51 -0
- package/dist/run/handoff.js.map +1 -0
- package/dist/run/harness-runtime.js +31 -0
- package/dist/run/harness-runtime.js.map +1 -0
- package/dist/run/harnesses.js +273 -0
- package/dist/run/harnesses.js.map +1 -0
- package/dist/run/issue.js +79 -0
- package/dist/run/issue.js.map +1 -0
- package/dist/run/keep-awake.js +58 -0
- package/dist/run/keep-awake.js.map +1 -0
- package/dist/run/lead.js +159 -0
- package/dist/run/lead.js.map +1 -0
- package/dist/run/manager.js +2546 -0
- package/dist/run/manager.js.map +1 -0
- package/dist/run/mentions.js +35 -0
- package/dist/run/mentions.js.map +1 -0
- package/dist/run/merge-watch.js +425 -0
- package/dist/run/merge-watch.js.map +1 -0
- package/dist/run/models.js +88 -0
- package/dist/run/models.js.map +1 -0
- package/dist/run/phases.js +23 -0
- package/dist/run/phases.js.map +1 -0
- package/dist/run/pi-rpc.js +439 -0
- package/dist/run/pi-rpc.js.map +1 -0
- package/dist/run/piped-check.js +56 -0
- package/dist/run/piped-check.js.map +1 -0
- package/dist/run/pr-checks.js +67 -0
- package/dist/run/pr-checks.js.map +1 -0
- package/dist/run/pr-merge.js +121 -0
- package/dist/run/pr-merge.js.map +1 -0
- package/dist/run/profiles.js +43 -0
- package/dist/run/profiles.js.map +1 -0
- package/dist/run/prompt.js +388 -0
- package/dist/run/prompt.js.map +1 -0
- package/dist/run/pull-request.js +23 -0
- package/dist/run/pull-request.js.map +1 -0
- package/dist/run/red-check.js +130 -0
- package/dist/run/red-check.js.map +1 -0
- package/dist/run/result-tool.js +93 -0
- package/dist/run/result-tool.js.map +1 -0
- package/dist/run/result.js +113 -0
- package/dist/run/result.js.map +1 -0
- package/dist/run/retro.js +346 -0
- package/dist/run/retro.js.map +1 -0
- package/dist/run/settings.js +27 -0
- package/dist/run/settings.js.map +1 -0
- package/dist/run/skills.js +146 -0
- package/dist/run/skills.js.map +1 -0
- package/dist/run/tests-first.js +146 -0
- package/dist/run/tests-first.js.map +1 -0
- package/dist/run/thinking.js +41 -0
- package/dist/run/thinking.js.map +1 -0
- package/dist/run/types.js +2 -0
- package/dist/run/types.js.map +1 -0
- package/dist/run/watchdog.js +259 -0
- package/dist/run/watchdog.js.map +1 -0
- package/dist/run/workflow.js +277 -0
- package/dist/run/workflow.js.map +1 -0
- package/dist/run/worktree.js +354 -0
- package/dist/run/worktree.js.map +1 -0
- package/dist/server/app.js +2946 -0
- package/dist/server/app.js.map +1 -0
- package/dist/server/auth.js +93 -0
- package/dist/server/auth.js.map +1 -0
- package/dist/server/demo.js +96 -0
- package/dist/server/demo.js.map +1 -0
- package/dist/server/idempotency.js +104 -0
- package/dist/server/idempotency.js.map +1 -0
- package/dist/server/port.js +36 -0
- package/dist/server/port.js.map +1 -0
- package/dist/server/principal.js +93 -0
- package/dist/server/principal.js.map +1 -0
- package/dist/server/repo-picker.js +18 -0
- package/dist/server/repo-picker.js.map +1 -0
- package/dist/server/terminal.js +285 -0
- package/dist/server/terminal.js.map +1 -0
- package/dist/setup/components.js +98 -0
- package/dist/setup/components.js.map +1 -0
- package/dist/setup/config.js +102 -0
- package/dist/setup/config.js.map +1 -0
- package/dist/setup/ink-ui.js +189 -0
- package/dist/setup/ink-ui.js.map +1 -0
- package/dist/setup/onboarding.js +167 -0
- package/dist/setup/onboarding.js.map +1 -0
- package/dist/setup/run.js +70 -0
- package/dist/setup/run.js.map +1 -0
- package/dist/skills.js +151 -0
- package/dist/skills.js.map +1 -0
- package/dist/ticket-cli.js +157 -0
- package/dist/ticket-cli.js.map +1 -0
- package/dist/version.js +13 -0
- package/dist/version.js.map +1 -0
- package/dist/voice/index.js +69 -0
- package/dist/voice/index.js.map +1 -0
- package/dist/voice/moonshine.js +247 -0
- package/dist/voice/moonshine.js.map +1 -0
- package/dist/voice/wav.js +54 -0
- package/dist/voice/wav.js.map +1 -0
- package/dist/voice/whisper.js +491 -0
- package/dist/voice/whisper.js.map +1 -0
- package/dist/web/assets/index-CCQMrUIF.js +255 -0
- package/dist/web/assets/index-lzGSgTRQ.css +1 -0
- package/dist/web/icons/apple-touch-icon.png +0 -0
- package/dist/web/icons/icon-192.png +0 -0
- package/dist/web/icons/icon-512.png +0 -0
- package/dist/web/icons/maskable-512.png +0 -0
- package/dist/web/index.html +21 -0
- package/dist/web/manifest.webmanifest +30 -0
- package/dist/web/sw.js +185 -0
- package/package.json +96 -4
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A read-only scout the planner can send into the repo.
|
|
3
|
+
*
|
|
4
|
+
* The planner's own turn is bounded, and its context is the card it has to
|
|
5
|
+
* write. A question like "where does a ticket transition write status, and what
|
|
6
|
+
* test covers it" needs six to ten reads that should not land in the planner's
|
|
7
|
+
* transcript one result at a time. This spawns a second pi with only
|
|
8
|
+
* read/grep/find/ls, gets a cited answer back, and keeps the planner's context
|
|
9
|
+
* for synthesis.
|
|
10
|
+
*
|
|
11
|
+
* The scout cannot write, cannot run a shell, and has no extension: it is the
|
|
12
|
+
* same read-only contract as the planner, one level down. Its output is treated
|
|
13
|
+
* as untrusted prose like a fetched page; the planner still has to cite it.
|
|
14
|
+
*/
|
|
15
|
+
import { spawn } from "node:child_process";
|
|
16
|
+
import { thinkingArgs } from "../run/thinking.js";
|
|
17
|
+
/** Enough to trace a path and its test; small enough that the wait stays bounded. */
|
|
18
|
+
export const SCOUT_TOOL_BUDGET = 12;
|
|
19
|
+
/** The outer planning turn is 240s; a scout that eats half of it is too slow. */
|
|
20
|
+
export const SCOUT_TIMEOUT_MS = 90_000;
|
|
21
|
+
/** More than this is a document, not an answer to one question. */
|
|
22
|
+
export const SCOUT_MAX_ANSWER_CHARS = 8_000;
|
|
23
|
+
export const SCOUT_PROMPT = `You are a read-only repository scout for Zelio's planner. You answer one question about this repo with evidence, then stop.
|
|
24
|
+
|
|
25
|
+
Rules:
|
|
26
|
+
- Read the repo. You cannot write, run a shell, or change anything.
|
|
27
|
+
- Find the entry point, the store, and the test that would judge it. Cite every claim as path:line.
|
|
28
|
+
- Answer in at most 300 words: the answer first, then an "Evidence:" list, one path:line per line with why it matters.
|
|
29
|
+
- If you cannot find it, say what you searched and where you looked. Never guess, never propose a card, never write code.`;
|
|
30
|
+
/**
|
|
31
|
+
* One question in, one cited answer out.
|
|
32
|
+
*
|
|
33
|
+
* The scout is steered at its tool limit and stopped a few calls later, the
|
|
34
|
+
* same protocol the planner uses: a ceiling that only exists in the prompt is a
|
|
35
|
+
* request, and a scout that ignores it must not become an unbounded process.
|
|
36
|
+
*/
|
|
37
|
+
export async function scoutRepo(options) {
|
|
38
|
+
const question = options.question.trim();
|
|
39
|
+
if (!question)
|
|
40
|
+
throw new Error("explore needs a question to answer");
|
|
41
|
+
if (options.signal?.aborted)
|
|
42
|
+
throw new Error("explore was cancelled");
|
|
43
|
+
const paths = (options.paths ?? [])
|
|
44
|
+
.filter((path) => typeof path === "string" && path.trim().length > 0)
|
|
45
|
+
.map((path) => path.trim())
|
|
46
|
+
.slice(0, 12);
|
|
47
|
+
const command = options.command ?? process.env.ZELIO_HARNESS ?? "pi";
|
|
48
|
+
const timeoutMs = options.timeoutMs ?? SCOUT_TIMEOUT_MS;
|
|
49
|
+
const maxToolCalls = options.maxToolCalls ?? SCOUT_TOOL_BUDGET;
|
|
50
|
+
const prompt = [
|
|
51
|
+
"Question:",
|
|
52
|
+
question,
|
|
53
|
+
...(paths.length > 0 ? ["", "Start here:", ...paths.map((path) => `- ${path}`)] : []),
|
|
54
|
+
"",
|
|
55
|
+
"Answer with findings and cited paths. No card, no code, no plan.",
|
|
56
|
+
].join("\n");
|
|
57
|
+
return new Promise((resolve, reject) => {
|
|
58
|
+
const child = spawn(command, [
|
|
59
|
+
"--mode",
|
|
60
|
+
"rpc",
|
|
61
|
+
"--no-session",
|
|
62
|
+
"--no-mcp",
|
|
63
|
+
"--no-extensions",
|
|
64
|
+
"--no-skills",
|
|
65
|
+
"--no-prompt-templates",
|
|
66
|
+
"--no-context-files",
|
|
67
|
+
"--tools",
|
|
68
|
+
"read,grep,find,ls",
|
|
69
|
+
"--system-prompt",
|
|
70
|
+
SCOUT_PROMPT,
|
|
71
|
+
...thinkingArgs("low"),
|
|
72
|
+
], { cwd: options.cwd ?? process.cwd(), stdio: ["pipe", "pipe", "pipe"] });
|
|
73
|
+
let text = "";
|
|
74
|
+
let stderr = "";
|
|
75
|
+
let calls = 0;
|
|
76
|
+
let steered = false;
|
|
77
|
+
let stopped = false;
|
|
78
|
+
let timedOut = false;
|
|
79
|
+
let finished = false;
|
|
80
|
+
const finish = (settle) => {
|
|
81
|
+
if (finished)
|
|
82
|
+
return;
|
|
83
|
+
finished = true;
|
|
84
|
+
clearTimeout(timer);
|
|
85
|
+
options.signal?.removeEventListener("abort", abort);
|
|
86
|
+
settle();
|
|
87
|
+
};
|
|
88
|
+
const send = (record) => {
|
|
89
|
+
if (child.killed)
|
|
90
|
+
return;
|
|
91
|
+
try {
|
|
92
|
+
child.stdin.write(`${JSON.stringify(record)}\n`);
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
// `close`/`error` already decides the outcome.
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
const abort = () => {
|
|
99
|
+
finish(() => reject(new Error("explore was cancelled")));
|
|
100
|
+
child.kill("SIGKILL");
|
|
101
|
+
};
|
|
102
|
+
const timer = setTimeout(() => {
|
|
103
|
+
timedOut = true;
|
|
104
|
+
child.kill("SIGKILL");
|
|
105
|
+
}, timeoutMs);
|
|
106
|
+
options.signal?.addEventListener("abort", abort, { once: true });
|
|
107
|
+
child.stdin.on("error", () => { });
|
|
108
|
+
child.on("error", (error) => {
|
|
109
|
+
finish(() => reject(new Error(`${command}: ${error.message}`)));
|
|
110
|
+
});
|
|
111
|
+
child.stderr.setEncoding("utf8");
|
|
112
|
+
child.stderr.on("data", (chunk) => {
|
|
113
|
+
stderr = (stderr + chunk).slice(-2000);
|
|
114
|
+
});
|
|
115
|
+
// Split on LF only, like the planner's parser: U+2028 inside JSON is legal
|
|
116
|
+
// and `readline` would cut a message in half.
|
|
117
|
+
let buffer = "";
|
|
118
|
+
child.stdout.setEncoding("utf8");
|
|
119
|
+
child.stdout.on("data", (chunk) => {
|
|
120
|
+
buffer += chunk;
|
|
121
|
+
let newline;
|
|
122
|
+
while ((newline = buffer.indexOf("\n")) !== -1) {
|
|
123
|
+
const line = buffer.slice(0, newline).replace(/\r$/, "");
|
|
124
|
+
buffer = buffer.slice(newline + 1);
|
|
125
|
+
if (!line.trim())
|
|
126
|
+
continue;
|
|
127
|
+
let record;
|
|
128
|
+
try {
|
|
129
|
+
record = JSON.parse(line);
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
if (record.type === "message_update" &&
|
|
135
|
+
record.assistantMessageEvent?.type === "text_delta") {
|
|
136
|
+
text += record.assistantMessageEvent.delta ?? "";
|
|
137
|
+
}
|
|
138
|
+
if (record.type === "tool_execution_start") {
|
|
139
|
+
calls += 1;
|
|
140
|
+
if (calls >= maxToolCalls && !steered) {
|
|
141
|
+
steered = true;
|
|
142
|
+
send({
|
|
143
|
+
id: "scout-budget",
|
|
144
|
+
type: "steer",
|
|
145
|
+
message: `You have used ${calls} tool calls. Answer now from what you read, with cited paths.`,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
else if (calls > maxToolCalls + 3 && !stopped) {
|
|
149
|
+
stopped = true;
|
|
150
|
+
send({ id: "scout-stop", type: "abort" });
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
// No wrap-up turn: the scout is research, not the card. When it
|
|
154
|
+
// settles, whatever it wrote is the answer.
|
|
155
|
+
if (record.type === "agent_settled")
|
|
156
|
+
child.stdin.end();
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
child.on("close", (code) => {
|
|
160
|
+
const answer = text.trim();
|
|
161
|
+
if (timedOut) {
|
|
162
|
+
return finish(() => reject(new Error(`explore timed out after ${timeoutMs}ms`)));
|
|
163
|
+
}
|
|
164
|
+
if (!answer) {
|
|
165
|
+
const tail = stderr.trim().slice(-500);
|
|
166
|
+
return finish(() => reject(new Error(`${command} exited ${code}: ${tail || "the scout wrote no answer"}`)));
|
|
167
|
+
}
|
|
168
|
+
const clipped = answer.length > SCOUT_MAX_ANSWER_CHARS
|
|
169
|
+
? `${answer.slice(0, SCOUT_MAX_ANSWER_CHARS)}\n… (${answer.length - SCOUT_MAX_ANSWER_CHARS} more characters)`
|
|
170
|
+
: answer;
|
|
171
|
+
finish(() => resolve(clipped));
|
|
172
|
+
});
|
|
173
|
+
send({ id: "explore-1", type: "prompt", message: prompt });
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=explore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"explore.js","sourceRoot":"","sources":["../../src/orchestrator/explore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,qFAAqF;AACrF,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAEpC,iFAAiF;AACjF,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAEvC,mEAAmE;AACnE,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,CAAC;AAE5C,MAAM,CAAC,MAAM,YAAY,GAAG;;;;;;0HAM8F,CAAC;AAmB3H;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,OAAqB;IACnD,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;IACzC,IAAI,CAAC,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;IACrE,IAAI,OAAO,CAAC,MAAM,EAAE,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAEtE,MAAM,KAAK,GAAG,CAAC,OAAO,CAA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AC;YAC3B,IAAI,QAAQ,EAAE,CAAC;gBACb,OAAO,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,2BAA2B,SAAS,IAAI,CAAC,CAAC,CAAC,CAAC;YACnF,CAAC;YACD,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC;gBACvC,OAAO,MAAM,CAAC,GAAG,EAAE,CACjB,MAAM,CAAC,IAAI,KAAK,CAAC,GAAG,OAAO,WAAW,IAAI,KAAK,IAAI,IAAI,2BAA2B,EAAE,CAAC,CAAC,CACvF,CAAC;YACJ,CAAC;YACD,MAAM,OAAO,GACX,MAAM,CAAC,MAAM,GAAG,sBAAsB;gBACpC,CAAC,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,sBAAsB,CAAC,QAAQ,MAAM,CAAC,MAAM,GAAG,sBAAsB,mBAAmB;gBAC7G,CAAC,CAAC,MAAM,CAAC;YACb,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,EAAE,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { OUTPUT_CONTRACT, PLANNING_METHOD, TICKET_RULES } from "./contract.js";
|
|
2
|
+
/**
|
|
3
|
+
* The new-task dialog's planner, and its own thing.
|
|
4
|
+
*
|
|
5
|
+
* The panel's prompt is a chat's doctrine: when to draft, how a draft changes
|
|
6
|
+
* across turns, what to do when the subject moves. None of that is this job.
|
|
7
|
+
* Here the person described a task in one box and is looking at the result, so
|
|
8
|
+
* the work is: read the repo, write the card, ask only what would change it.
|
|
9
|
+
*
|
|
10
|
+
* It is a separate unit on purpose, not a mode of the other one. If this door
|
|
11
|
+
* turns out to be the whole product — a person types what they want and gets a
|
|
12
|
+
* ticket, without ever opening the panel — then this file keeps growing and the
|
|
13
|
+
* orchestrator's prompt becomes the optional one. Two doctrines sharing a
|
|
14
|
+
* contract can do that; one prompt with a mode flag cannot.
|
|
15
|
+
*/
|
|
16
|
+
export const NEW_TASK_PROMPT = `You are the planner behind Zelio's new-task dialog, a local kanban board for supervising coding agents.
|
|
17
|
+
|
|
18
|
+
A person described a piece of work in one box. You are not having a conversation with them. Your job is to turn that description into the smallest number of draft tickets that would do the work, asking only the questions whose answers would change what gets built. The card comes back to them in the same dialog, with every field editable, and they confirm it or throw it away.
|
|
19
|
+
|
|
20
|
+
You are read-only. You never change files, never run builds, never implement. If the description asks for the work to be done, you write the card for it.
|
|
21
|
+
|
|
22
|
+
## This turn
|
|
23
|
+
|
|
24
|
+
- **The description and answers are the brief.** Use the scouts' findings as your reading. Read only to fill a missing fact or replace a failed finding. If no findings exist, read the repo before drafting.
|
|
25
|
+
- **One card is the normal answer.** Two only when the pieces can run at the same time in separate worktrees without touching the same files. Five is the ceiling. Sequential work is one card; a card whose criteria cannot pass on its own is a slice, not a ticket.
|
|
26
|
+
- **Ask at most three questions**, and only where reading the repo cannot answer. Each option carries its cost. If both answers lead to the same card, the question is a tax — delete it.
|
|
27
|
+
- **The board is not a suggestion box.** \`<board>\` lists work that already exists. A card that repeats a ticket there is worse than no card; if the description overlaps one, say so in \`reply\` and write the card as the change on top of it.
|
|
28
|
+
- **\`reply\` is one or two sentences** about the choice you made and the sharpest thing you are unsure of. Do not tell the person where to find the card: it is in front of them.
|
|
29
|
+
|
|
30
|
+
## What "checkable" means here
|
|
31
|
+
|
|
32
|
+
The person is about to let an agent run this without further reading. So the acceptance criteria are the thing you must not invent: derive each one from their words or from something you read, and put every guess in \`assumed\` where they will see it before confirming. A card with an honest flag is a card they can trust; a card with confident prose is one they have to re-read the repo to check.
|
|
33
|
+
|
|
34
|
+
When findings are supplied, they are the reading the method below describes: cite them for the entry point, the relevant tests and the reuse pattern, and open a file only for a failed finding or a missing fact.
|
|
35
|
+
|
|
36
|
+
${PLANNING_METHOD}
|
|
37
|
+
|
|
38
|
+
${TICKET_RULES}
|
|
39
|
+
|
|
40
|
+
${OUTPUT_CONTRACT}`;
|
|
41
|
+
/**
|
|
42
|
+
* The dialog's first pass. It decides what happens next: a card now for a
|
|
43
|
+
* small change, questions only the person can answer, or the reading the
|
|
44
|
+
* draft will need. It is short on purpose; the draft pass is the expensive one.
|
|
45
|
+
*/
|
|
46
|
+
export const NEW_TASK_INTAKE_PROMPT = `You are the first pass of Zelio's new-task dialog. From the person's description and the repository index only, ask at most three questions that only the person can answer and whose answers change what gets built. Otherwise ask nothing. Do not read files, write cards, or list research: scouts are already reading and a later pass writes the cards.
|
|
47
|
+
|
|
48
|
+
Return a JSON block with reply, questions and cards. Cards must be [].
|
|
49
|
+
|
|
50
|
+
${OUTPUT_CONTRACT}`;
|
|
51
|
+
//# sourceMappingURL=new-task-prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-task-prompt.js","sourceRoot":"","sources":["../../src/orchestrator/new-task-prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE/E;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;;;;;;;;;;;;;;;;;;;;EAoB7B,eAAe;;EAEf,YAAY;;EAEZ,eAAe,EAAE,CAAC;AAEpB;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;;;;EAIpC,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { toolResultText } from "../run/actions.js";
|
|
3
|
+
import { thinkingArgs } from "../run/thinking.js";
|
|
4
|
+
const TOOLS = "read,grep,find,ls,web_search,web_fetch,explore";
|
|
5
|
+
const EXTENSION = new URL("./web.js", import.meta.url);
|
|
6
|
+
const KILL_GRACE_MS = 2_000;
|
|
7
|
+
const clip = (value, max) => {
|
|
8
|
+
const text = value.replace(/\s+/g, " ").trim();
|
|
9
|
+
return text.length > max ? text.slice(0, max - 1) + "…" : text;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* The label for one planner tool call. pi emits the tool name and arguments, so
|
|
13
|
+
* the panel says what is happening instead of guessing at a phase.
|
|
14
|
+
*/
|
|
15
|
+
export function toolLabel(tool, args) {
|
|
16
|
+
const fields = (args ?? {});
|
|
17
|
+
const text = (key) => typeof fields[key] === "string" ? fields[key] : "";
|
|
18
|
+
switch (tool) {
|
|
19
|
+
case "read": {
|
|
20
|
+
const path = text("path") || text("file_path");
|
|
21
|
+
return path ? "Reading " + clip(path, 46) : "Reading a file";
|
|
22
|
+
}
|
|
23
|
+
case "grep": {
|
|
24
|
+
const pattern = text("pattern") || text("query");
|
|
25
|
+
return pattern ? "Searching the repo for “" + clip(pattern, 32) + "”" : "Searching the repo";
|
|
26
|
+
}
|
|
27
|
+
case "find": {
|
|
28
|
+
const pattern = text("pattern");
|
|
29
|
+
return pattern ? "Finding files matching “" + clip(pattern, 32) + "”" : "Finding files";
|
|
30
|
+
}
|
|
31
|
+
case "ls": {
|
|
32
|
+
const path = text("path");
|
|
33
|
+
return path ? "Listing " + clip(path, 46) : "Listing the repo";
|
|
34
|
+
}
|
|
35
|
+
case "web_search": {
|
|
36
|
+
const query = text("query") || text("q");
|
|
37
|
+
return query ? "Searching the web for “" + clip(query, 32) + "”" : "Searching the web";
|
|
38
|
+
}
|
|
39
|
+
case "web_fetch": {
|
|
40
|
+
const url = text("url");
|
|
41
|
+
if (!url)
|
|
42
|
+
return "Fetching a page";
|
|
43
|
+
try {
|
|
44
|
+
return "Fetching " + clip(new URL(url).host, 40);
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return "Fetching " + clip(url, 40);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
default:
|
|
51
|
+
return clip(tool, 40);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* pi over RPC for one planning turn. It owns the process and the wire format;
|
|
56
|
+
* the budget loop owns what to do with the events.
|
|
57
|
+
*/
|
|
58
|
+
export class PiPlannerSession {
|
|
59
|
+
child;
|
|
60
|
+
queue = [];
|
|
61
|
+
wake;
|
|
62
|
+
finished = false;
|
|
63
|
+
wasAborted = false;
|
|
64
|
+
stderr = "";
|
|
65
|
+
killTimer;
|
|
66
|
+
events;
|
|
67
|
+
constructor(options) {
|
|
68
|
+
this.child = spawn(options.command, [
|
|
69
|
+
"--mode",
|
|
70
|
+
"rpc",
|
|
71
|
+
"--no-session",
|
|
72
|
+
"--no-mcp",
|
|
73
|
+
"--no-extensions",
|
|
74
|
+
"--no-skills",
|
|
75
|
+
"--no-prompt-templates",
|
|
76
|
+
"--no-context-files",
|
|
77
|
+
...(options.noTools ? ["--no-tools"] : ["--extension", EXTENSION.href, "--tools", TOOLS]),
|
|
78
|
+
"--system-prompt",
|
|
79
|
+
options.systemPrompt,
|
|
80
|
+
...(options.model?.trim() ? ["--model", options.model.trim()] : []),
|
|
81
|
+
...thinkingArgs(options.thinking),
|
|
82
|
+
], { cwd: options.cwd, stdio: ["pipe", "pipe", "pipe"] });
|
|
83
|
+
this.events = this.iterate();
|
|
84
|
+
this.child.stdin.on("error", () => { });
|
|
85
|
+
this.child.stderr.setEncoding("utf8");
|
|
86
|
+
this.child.stderr.on("data", (chunk) => {
|
|
87
|
+
this.stderr = (this.stderr + chunk).slice(-4000);
|
|
88
|
+
});
|
|
89
|
+
let buffer = "";
|
|
90
|
+
this.child.stdout.setEncoding("utf8");
|
|
91
|
+
this.child.stdout.on("data", (chunk) => {
|
|
92
|
+
buffer += chunk;
|
|
93
|
+
let newline;
|
|
94
|
+
while ((newline = buffer.indexOf("\n")) !== -1) {
|
|
95
|
+
const line = buffer.slice(0, newline).replace(/\r$/, "");
|
|
96
|
+
buffer = buffer.slice(newline + 1);
|
|
97
|
+
if (!line.trim())
|
|
98
|
+
continue;
|
|
99
|
+
let record;
|
|
100
|
+
try {
|
|
101
|
+
record = JSON.parse(line);
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
this.read(record);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
this.child.on("error", (error) => {
|
|
110
|
+
this.finish({
|
|
111
|
+
type: "exit",
|
|
112
|
+
code: null,
|
|
113
|
+
stderr: options.command + ": " + error.message,
|
|
114
|
+
timedOut: false,
|
|
115
|
+
spawnError: true,
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
this.child.on("exit", (code) => {
|
|
119
|
+
clearTimeout(this.killTimer);
|
|
120
|
+
this.finish({ type: "exit", code, stderr: this.stderr.trim(), timedOut: false });
|
|
121
|
+
});
|
|
122
|
+
this.child.stdin.write(JSON.stringify({
|
|
123
|
+
id: options.id,
|
|
124
|
+
type: "prompt",
|
|
125
|
+
message: options.prompt,
|
|
126
|
+
...(options.images && options.images.length > 0 ? { images: options.images } : {}),
|
|
127
|
+
}) + "\n");
|
|
128
|
+
}
|
|
129
|
+
read(record) {
|
|
130
|
+
if (record.type === "message_update" && record.assistantMessageEvent?.type === "text_delta") {
|
|
131
|
+
this.push({ type: "text", text: record.assistantMessageEvent.delta ?? "" });
|
|
132
|
+
}
|
|
133
|
+
if (record.type === "tool_execution_start" && record.toolName) {
|
|
134
|
+
this.push({
|
|
135
|
+
type: "tool_start",
|
|
136
|
+
tool: record.toolName,
|
|
137
|
+
args: record.args,
|
|
138
|
+
label: toolLabel(record.toolName, record.args),
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
if (record.type === "tool_execution_end" && record.toolName) {
|
|
142
|
+
if (record.isError) {
|
|
143
|
+
const output = toolResultText(record.result);
|
|
144
|
+
if (output) {
|
|
145
|
+
this.push({ type: "tool_output", tool: record.toolName, text: output });
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
this.push({
|
|
149
|
+
type: "tool_end",
|
|
150
|
+
tool: record.toolName,
|
|
151
|
+
isError: Boolean(record.isError),
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
if (record.type === "agent_settled")
|
|
155
|
+
this.push({ type: "settled" });
|
|
156
|
+
}
|
|
157
|
+
push(event) {
|
|
158
|
+
this.queue.push(event);
|
|
159
|
+
const wake = this.wake;
|
|
160
|
+
this.wake = undefined;
|
|
161
|
+
wake?.();
|
|
162
|
+
}
|
|
163
|
+
finish(event) {
|
|
164
|
+
if (this.finished)
|
|
165
|
+
return;
|
|
166
|
+
this.finished = true;
|
|
167
|
+
clearTimeout(this.killTimer);
|
|
168
|
+
this.push(event);
|
|
169
|
+
}
|
|
170
|
+
async *iterate() {
|
|
171
|
+
for (;;) {
|
|
172
|
+
if (this.queue.length === 0) {
|
|
173
|
+
if (this.finished)
|
|
174
|
+
return;
|
|
175
|
+
// oxlint-disable-next-line no-await-in-loop
|
|
176
|
+
await new Promise((resolve) => {
|
|
177
|
+
this.wake = resolve;
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
const event = this.queue.shift();
|
|
181
|
+
if (!event)
|
|
182
|
+
continue;
|
|
183
|
+
yield event;
|
|
184
|
+
if (event.type === "exit")
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
send(record) {
|
|
189
|
+
if (this.finished)
|
|
190
|
+
return;
|
|
191
|
+
try {
|
|
192
|
+
this.child.stdin.write(JSON.stringify(record) + "\n");
|
|
193
|
+
}
|
|
194
|
+
catch {
|
|
195
|
+
// The process is gone; its exit event is the answer.
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
steer(text) {
|
|
199
|
+
this.send({ id: "budget-steer", type: "steer", message: text });
|
|
200
|
+
}
|
|
201
|
+
interrupt() {
|
|
202
|
+
this.send({ id: "budget-stop", type: "abort" });
|
|
203
|
+
}
|
|
204
|
+
prompt(text) {
|
|
205
|
+
this.send({ id: "budget-wrapup", type: "prompt", message: text });
|
|
206
|
+
}
|
|
207
|
+
close() {
|
|
208
|
+
if (this.finished)
|
|
209
|
+
return;
|
|
210
|
+
try {
|
|
211
|
+
this.child.stdin.end();
|
|
212
|
+
}
|
|
213
|
+
catch {
|
|
214
|
+
// Already gone.
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
abort() {
|
|
218
|
+
if (this.finished || this.wasAborted)
|
|
219
|
+
return;
|
|
220
|
+
this.wasAborted = true;
|
|
221
|
+
this.child.kill("SIGTERM");
|
|
222
|
+
this.killTimer = setTimeout(() => this.child.kill("SIGKILL"), KILL_GRACE_MS);
|
|
223
|
+
}
|
|
224
|
+
get aborted() {
|
|
225
|
+
return this.wasAborted;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
//# sourceMappingURL=pi-session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pi-session.js","sourceRoot":"","sources":["../../src/orchestrator/pi-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAuC,MAAM,oBAAoB,CAAC;AAEhF,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIlD,MAAM,KAAK,GAAG,gDAAgD,CAAC;AAC/D,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,UAAU,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;AACvD,MAAM,aAAa,GAAG,KAAK,CAAC;AAE5B,MAAM,IAAI,GAAG,CAAC,KAAa,EAAE,GAAW,EAAU,EAAE;IAClD,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IAC/C,OAAO,IAAI,CA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AC,QAAQ,IAAI,IAAI,CAAC,UAAU;YAAE,OAAO;QAC7C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC,CAAC;IAC/E,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;CACF"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The orchestrator's system prompt. This is the product: everything else in
|
|
3
|
+
* M2 is plumbing around it.
|
|
4
|
+
*
|
|
5
|
+
* The rules are the ones argued for in docs/PLAN.md — read-only on the repo,
|
|
6
|
+
* acceptance criteria derived from the user's words and repo evidence rather
|
|
7
|
+
* than from the agent's taste, a rationale on every card, and questions
|
|
8
|
+
* instead of confident invention.
|
|
9
|
+
*
|
|
10
|
+
* This is the chat's doctrine. The planning method, card rules and output block
|
|
11
|
+
* come from `contract.ts`, because the new-task dialog emits the same JSON under
|
|
12
|
+
* its own prompt; see `new-task-prompt.ts`.
|
|
13
|
+
*/
|
|
14
|
+
import { OUTPUT_CONTRACT, PLANNING_METHOD, TICKET_RULES } from "./contract.js";
|
|
15
|
+
export const ORCHESTRATOR_PROMPT = `You are the planner inside Zelio, a local kanban board for supervising coding agents. You help a person decide what to build, then turn work they have agreed to into draft tickets other agents will execute.
|
|
16
|
+
|
|
17
|
+
You are read-only. You never change files, never run builds, never implement. If asked to implement, you write a ticket instead.
|
|
18
|
+
|
|
19
|
+
## When to draft
|
|
20
|
+
|
|
21
|
+
Conversation is the default. Most turns are you helping the person decide what the work is; that is not a failed turn because no card came out of it.
|
|
22
|
+
|
|
23
|
+
Do not create or change a draft until the person signals they want the work turned into one. A signal is explicit — "create a ticket", "add it to the drafts", "make a card", "write that up" — or a clear acceptance of a concrete shape you proposed: "yes", "do that", "sounds right", "let's do it". Exploring, asking questions, thinking out loud, and "maybe" are not signals.
|
|
24
|
+
|
|
25
|
+
If the discussion has settled but they have not asked for a draft, say so in one sentence and ask whether to put it in the drafts. Do not create it just to be helpful.
|
|
26
|
+
|
|
27
|
+
When no draft exists, return \`cards: []\` on discussion turns. When a draft already exists and the person refines it, keep those cards current — they have already opted into the draft.
|
|
28
|
+
|
|
29
|
+
When you do add or change drafts, say so plainly in \`reply\`: "Added it to your drafts." These are drafts, not tickets; a ticket only exists after the person confirms it. Do not name the surface the drafts live on: it differs by the door the person came through, and the card is either in front of them or one click away.
|
|
30
|
+
|
|
31
|
+
## Asking
|
|
32
|
+
|
|
33
|
+
A question is a decision with a price on each answer. That is the whole shape of one.
|
|
34
|
+
|
|
35
|
+
- **Ask only what the repo cannot tell you.** If the code already answers it, say so in \`reply\` as a fact and do not ask. Put the path and line in \`evidence\`.
|
|
36
|
+
- **Never more than three questions.** Three is a conversation; four is a form.
|
|
37
|
+
- **Every option carries its consequence.** Not "add a migration" but "Add a migration — touches \`db.ts\`, +40 lines, needs a backfill test". The server deletes an option with no cost, so a costless option is a question you did not really ask.
|
|
38
|
+
- **Two to four options.** One option is an announcement, five is a menu.
|
|
39
|
+
- **A recommendation says where it came from.** \`derived: true\` means repo evidence produced the options, and \`evidence\` carries the path. A recommendation out of your own taste is \`derived: false\`, and the board labels it "my guess". Never dress taste as evidence.
|
|
40
|
+
- **If both answers lead to the same card, delete the question.** A question that cannot change the diff is a tax on the person's attention.
|
|
41
|
+
- **A question never blocks a draft you could already write.** Asking and drafting in the same turn is right when the cards are honest without the answer.
|
|
42
|
+
|
|
43
|
+
## Splitting
|
|
44
|
+
|
|
45
|
+
Default to one card. Split only for genuinely independent work or an explicit dependency; do not fragment one coherent outcome into file-edit chores. Separate parallel work only when the pieces can be worked on **at the same time by two agents without touching the same files and without making each other wrong**.
|
|
46
|
+
|
|
47
|
+
If a goal is split, preserve the complete user outcome across the cards and state dependencies plus who owns cross-card integration and final end-to-end verification. Individual green cards do not prove the full user flow.
|
|
48
|
+
|
|
49
|
+
So, before writing a second card, check all four:
|
|
50
|
+
|
|
51
|
+
1. **File overlap.** If two cards' \`likely_files\` intersect, they are one card. Two agents editing the same file is a conflict, not a plan.
|
|
52
|
+
2. **Order dependence.** If card B only makes sense after card A, B is not a card — it is the rest of A. Sequential work is one ticket.
|
|
53
|
+
3. **Verifiable alone.** If a card's acceptance criteria cannot pass with its siblings reverted, it is a slice, not a ticket.
|
|
54
|
+
4. **Check count.** Keep acceptance at four checks maximum. Split only for genuinely independent behaviours or a real dependency; preserve one coherent outcome when the work belongs together and name integration ownership across cards.
|
|
55
|
+
|
|
56
|
+
One or two cards is the normal answer, even for a change that touches five files. Five is the ceiling for genuinely independent work, never a target. Never pad a plan — a board of artificial slices spends the person's attention, which is the scarcest thing here.
|
|
57
|
+
|
|
58
|
+
Prefer the smallest version that tests the riskiest assumption.
|
|
59
|
+
|
|
60
|
+
## Refining a draft
|
|
61
|
+
|
|
62
|
+
When cards already exist they arrive in \`<draft-plan>\`. You are editing them, not writing them again.
|
|
63
|
+
|
|
64
|
+
- Keep a card's \`id\` when you change it. A card you leave out of the block is removed, so restate every card you still want.
|
|
65
|
+
- Do not restate, reword or re-guess a field the last message did not touch. Numbers, sizes and file lists the person already saw are theirs; if you think one is wrong, say so in \`reply\` and flag it in \`assumed\` — do not silently change it.
|
|
66
|
+
- A new constraint applies to every card it affects, not only the obvious one.
|
|
67
|
+
- Only invent a card without an id when the work is genuinely new.
|
|
68
|
+
- **A card the person accepted is finished being a card.** It is now a ticket in \`<board>\`, and it must not come back: not as a card, not reworded, not split off a corner of itself. If they ask for more work on it, that is a new card whose goal says what changes on top of that ticket.
|
|
69
|
+
- A new subject does not require dropping the cards on the table. Keep them unless they are now wrong or the person asked for something else instead.
|
|
70
|
+
|
|
71
|
+
## Outside this repo
|
|
72
|
+
|
|
73
|
+
You read this repo, and you can look things up: \`web_search\` finds GitHub repositories and Wikipedia, \`web_fetch\` reads a public page or raw file. You have no other checkout and no login, so a private page is not available to you.
|
|
74
|
+
|
|
75
|
+
When the person points at another product — "how does X do it", "look at their extension" — read it before you plan from it. Search for the repository, fetch the file that matters, and quote the path or URL you actually read. A card that borrows an idea says where the idea came from.
|
|
76
|
+
|
|
77
|
+
Two things you must never do here: pretend to have read something you did not, and copy a design without checking it against this repo. "They do X" is evidence; "we should do X because they do" is not a reason on its own.
|
|
78
|
+
|
|
79
|
+
If what you need is behind a login or not on the open web, say so in one sentence and make the ticket ask the person for the file — do not fill the gap with a guess.
|
|
80
|
+
|
|
81
|
+
## Fresh or empty repo
|
|
82
|
+
|
|
83
|
+
No code to read means no evidence, so do not pretend otherwise: propose 2-3 options with real tradeoffs rather than one confident recommendation, and make the first ticket a decision (write the choice into \`docs/DECISIONS.md\`) instead of a diff.
|
|
84
|
+
|
|
85
|
+
${PLANNING_METHOD}
|
|
86
|
+
|
|
87
|
+
${TICKET_RULES}
|
|
88
|
+
|
|
89
|
+
${OUTPUT_CONTRACT}`;
|
|
90
|
+
/**
|
|
91
|
+
* The handoff summariser. It is a separate pass, with its own system prompt,
|
|
92
|
+
* because compression is a different job from planning: the planner needs the
|
|
93
|
+
* decisions and constraints, not another draft. It gets the read-only toolset
|
|
94
|
+
* so it can check a path if the transcript mentions one, but it must not change
|
|
95
|
+
* anything.
|
|
96
|
+
*/
|
|
97
|
+
export const SUMMARY_PROMPT = `You are writing a handoff summary for the planner inside Zelio. The conversation you are given is at its message limit, so a new chat will continue the work and will not have the old transcript in front of it.
|
|
98
|
+
|
|
99
|
+
Compress the conversation into what the next planner must know. Be specific and factual, and keep the person's own words where they named a constraint. Cover:
|
|
100
|
+
|
|
101
|
+
- the goal: what the person is actually trying to get built
|
|
102
|
+
- every constraint or decision they stated, including things they explicitly ruled out
|
|
103
|
+
- work that was rejected, dropped, or replaced, and why
|
|
104
|
+
- open questions, unresolved assumptions, and anything the planner was unsure about
|
|
105
|
+
- the state of the draft plan or accepted tickets, if they matter to what comes next
|
|
106
|
+
|
|
107
|
+
Do not invent anything. Do not turn the summary into a new plan or a list of new questions. Do not include greetings or preamble. Use short paragraphs or bullets under those headings, under 500 words. Output only the summary text.
|
|
108
|
+
|
|
109
|
+
You are read-only: never edit, write, run commands, or change the repository.`;
|
|
110
|
+
//# sourceMappingURL=prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../src/orchestrator/prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC/E,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsEjC,eAAe;;EAEf,YAAY;;EAEZ,eAAe,EAAE,CAAC;AAEpB;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;;;;;;;;;;;;8EAYgD,CAAC"}
|