teapot-coding-agent 0.29.29 → 0.29.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/agent.js +11 -0
- package/dist/agent/tools.js +52 -2
- package/dist/master.js +47 -16
- package/package.json +1 -1
- package/public/assets/index-BYYMQSQw.js +30 -0
- package/public/assets/index-BYYMQSQw.js.map +1 -0
- package/public/assets/{shiki-DM4FXbBS.js → shiki-BHXNwDA0.js} +2 -2
- package/public/assets/{shiki-DM4FXbBS.js.map → shiki-BHXNwDA0.js.map} +1 -1
- package/public/index.html +1 -1
- package/public/assets/index-CIno4glv.js +0 -30
- package/public/assets/index-CIno4glv.js.map +0 -1
package/dist/agent/agent.js
CHANGED
|
@@ -252,6 +252,17 @@ Most session state is not injected into prompts — fetch it with tools instead:
|
|
|
252
252
|
save_skill(name, description, content, files=[{name, content}]) so future
|
|
253
253
|
sessions can load_skill them — helper scripts go through files and are made
|
|
254
254
|
executable automatically.
|
|
255
|
+
- LEAD with the answer or the action: no preamble ("Great question", "Let me…",
|
|
256
|
+
"I'll now…") and no closing pleasantries ("Hope this helps", "let me know if…").
|
|
257
|
+
The operator reads the first line and the last line — make those two carry what
|
|
258
|
+
happened and what is next.
|
|
259
|
+
- For multi-step work, number the steps and keep ONE in progress at a time. When you
|
|
260
|
+
are partway through, say which step finished and which is next; do not re-narrate
|
|
261
|
+
the whole plan, and do not assume the operator remembers the previous turn.
|
|
262
|
+
- Report what now WORKS, concretely, rather than what you changed: "login works with
|
|
263
|
+
magic links — try /login" beats "I made some changes to the auth flow".
|
|
264
|
+
- State errors as cause and fix ("test fails at a.spec.ts:42: expected 200, got 401 —
|
|
265
|
+
missing auth header"), never as alarm ("uh oh", "there seems to be a problem").
|
|
255
266
|
- When you make meaningful progress, call report_progress. Its output is
|
|
256
267
|
shown to the operator directly (rendered as markdown in the progress
|
|
257
268
|
panel) — do NOT also repeat the same content as a chat message; end the
|
package/dist/agent/tools.js
CHANGED
|
@@ -1142,13 +1142,41 @@ export const TOOLS = [
|
|
|
1142
1142
|
let off = num(args.offset, 1);
|
|
1143
1143
|
off = off < 0 ? Math.max(0, lines.length + off) : Math.max(0, off - 1);
|
|
1144
1144
|
const lim = num(args.limit, 2000);
|
|
1145
|
+
// A LINE cap alone does not bound the output: a single 5MB minified line is one
|
|
1146
|
+
// "line", and 2000 lines of 2000 chars is 4MB. The three caps below each kill a
|
|
1147
|
+
// different shape of oversized file (#17 item 3):
|
|
1148
|
+
// lines → a 3000-line source file
|
|
1149
|
+
// bytes → a big log, whatever its line structure
|
|
1150
|
+
// per-line → minified.js / a one-line JSON blob
|
|
1145
1151
|
const pageLines = lines.slice(off, off + lim);
|
|
1146
|
-
|
|
1152
|
+
// PER-LINE cap first: clipping lines before joining means one giant line cannot
|
|
1153
|
+
// blow the byte budget on its own, and the marker names how much was cut.
|
|
1154
|
+
const cappedLines = pageLines.map((l) => l.length > MAX_READ_LINE_CHARS
|
|
1155
|
+
? l.slice(0, MAX_READ_LINE_CHARS) +
|
|
1156
|
+
` …[line clipped: ${l.length - MAX_READ_LINE_CHARS} more chars]`
|
|
1157
|
+
: l);
|
|
1158
|
+
const rendered = idMode === "hash" ? renderHashlines(cappedLines, off + 1) : renderGutter(cappedLines, off + 1);
|
|
1147
1159
|
// the phantom trailing line is dropped for the count too, or a file that
|
|
1148
1160
|
// ends in a newline always reports one line more than it has
|
|
1149
1161
|
const total = lines.length && lines[lines.length - 1] === "" ? lines.length - 1 : lines.length;
|
|
1150
1162
|
const more = off + lim < total ? `\n... (${total - off - lim} more lines)` : "";
|
|
1151
|
-
|
|
1163
|
+
const out = rendered + more;
|
|
1164
|
+
// BYTE cap last, with the remaining line count in the marker so the model knows
|
|
1165
|
+
// how to continue rather than assuming it saw everything.
|
|
1166
|
+
if (out.length > MAX_READ_BYTES) {
|
|
1167
|
+
const head = out.slice(0, MAX_READ_BYTES);
|
|
1168
|
+
const cutAt = head.lastIndexOf("\n");
|
|
1169
|
+
return {
|
|
1170
|
+
ok: true,
|
|
1171
|
+
result: (cutAt > 0 ? head.slice(0, cutAt) : head) +
|
|
1172
|
+
`\n... [output clipped at ${MAX_READ_BYTES} bytes of ${out.length}; ` +
|
|
1173
|
+
// `head` holds N rendered lines separated by N-1 newlines, and rendering
|
|
1174
|
+
// started at 1-indexed line `off + 1`, so the next unread line is
|
|
1175
|
+
// off + 1 + N. Counting newlines alone gives N-1 and would re-read one line.
|
|
1176
|
+
`continue with offset=${off + 1 + countLines(cutAt > 0 ? head.slice(0, cutAt) : head) + 1}]`,
|
|
1177
|
+
};
|
|
1178
|
+
}
|
|
1179
|
+
return { ok: true, result: out };
|
|
1152
1180
|
},
|
|
1153
1181
|
},
|
|
1154
1182
|
{
|
|
@@ -1915,6 +1943,28 @@ export const TOOLS = [
|
|
|
1915
1943
|
/** #16: how many files one read_file call may cover. Each costs context, so an
|
|
1916
1944
|
* unbounded array would just be a way to overflow the window in one shot. */
|
|
1917
1945
|
const MAX_MULTI_READ = 10;
|
|
1946
|
+
/**
|
|
1947
|
+
* The three read caps (#17 item 3). A line cap alone is not a bound: one 5MB minified
|
|
1948
|
+
* line is a single "line", and 2000 lines of 2000 chars is 4MB. Each cap kills a
|
|
1949
|
+
* different shape of oversized file:
|
|
1950
|
+
*
|
|
1951
|
+
* 2000 lines → a 3000-line source file (the `limit` default, unchanged)
|
|
1952
|
+
* 256 KB → a 5MB log, whatever its lines
|
|
1953
|
+
* 2000 chars → minified.js / a one-line JSON blob
|
|
1954
|
+
*
|
|
1955
|
+
* The byte cap is a SHARE of what a tool result can be, not the whole budget: the model
|
|
1956
|
+
* still needs room to reason about what it read.
|
|
1957
|
+
*/
|
|
1958
|
+
const MAX_READ_BYTES = 256 * 1024;
|
|
1959
|
+
const MAX_READ_LINE_CHARS = 2_000;
|
|
1960
|
+
/** how many lines a string contains — used to say where to resume a clipped read */
|
|
1961
|
+
function countLines(s) {
|
|
1962
|
+
let n = 0;
|
|
1963
|
+
for (let i = 0; i < s.length; i++)
|
|
1964
|
+
if (s.charCodeAt(i) === 10)
|
|
1965
|
+
n++;
|
|
1966
|
+
return n;
|
|
1967
|
+
}
|
|
1918
1968
|
/**
|
|
1919
1969
|
* Subsequence match: every character of `needle` appears in `hay`, in order,
|
|
1920
1970
|
* gaps allowed (#16 "fuzzy").
|
package/dist/master.js
CHANGED
|
@@ -1915,49 +1915,80 @@ When this task is done (or truly blocked), call finish() with a summary for @${p
|
|
|
1915
1915
|
* (the files survived, but nothing in the UI could reach them again).
|
|
1916
1916
|
*/
|
|
1917
1917
|
async archiveAgent(id) {
|
|
1918
|
-
const
|
|
1919
|
-
if (!
|
|
1918
|
+
const root = this.config.agents.find((a) => a.id === id);
|
|
1919
|
+
if (!root)
|
|
1920
1920
|
throw new Error(`no such agent: ${id}`);
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1921
|
+
// The whole SUBTREE goes with it. A sub-agent whose parent is archived can never
|
|
1922
|
+
// run again — its parent is what spawns and messages it — so leaving it un-archived
|
|
1923
|
+
// put orphans in the list that look usable and are not. The descendants are found
|
|
1924
|
+
// from the config (not the live map), so sub-agents that are already stopped or
|
|
1925
|
+
// suspended are included.
|
|
1926
|
+
const ids = [id, ...this.subtreeOf(id).map((s) => s.id)];
|
|
1927
|
+
const now = Date.now();
|
|
1928
|
+
for (const one of ids) {
|
|
1929
|
+
const live = this.agents.get(one);
|
|
1930
|
+
if (live) {
|
|
1931
|
+
this.agents.delete(one);
|
|
1932
|
+
await live.dispose();
|
|
1933
|
+
}
|
|
1934
|
+
const ac = this.config.agents.find((a) => a.id === one);
|
|
1935
|
+
if (!ac)
|
|
1936
|
+
continue;
|
|
1937
|
+
ac.archived = true;
|
|
1938
|
+
ac.archivedAt = now;
|
|
1925
1939
|
}
|
|
1926
|
-
ac.archived = true;
|
|
1927
|
-
ac.archivedAt = Date.now();
|
|
1928
1940
|
this.saveConfig();
|
|
1929
|
-
return { archived: true };
|
|
1941
|
+
return { archived: true, ids };
|
|
1930
1942
|
}
|
|
1931
|
-
/**
|
|
1943
|
+
/**
|
|
1944
|
+
* Bring an archived agent back. Its session pointer was never touched.
|
|
1945
|
+
*
|
|
1946
|
+
* Restores the SUBTREE too, because archiving took it: a parent restored without its
|
|
1947
|
+
* children would come back unable to reach the work it delegated, and the children
|
|
1948
|
+
* would sit invisibly in the archive with no way to know why.
|
|
1949
|
+
*/
|
|
1932
1950
|
async restoreAgent(id) {
|
|
1933
1951
|
const ac = this.config.agents.find((a) => a.id === id);
|
|
1934
1952
|
if (!ac)
|
|
1935
1953
|
throw new Error(`no such agent: ${id}`);
|
|
1936
|
-
|
|
1937
|
-
|
|
1954
|
+
const ids = [id, ...this.subtreeOf(id).map((s) => s.id)];
|
|
1955
|
+
for (const one of ids) {
|
|
1956
|
+
const e = this.config.agents.find((a) => a.id === one);
|
|
1957
|
+
if (!e)
|
|
1958
|
+
continue;
|
|
1959
|
+
delete e.archived;
|
|
1960
|
+
delete e.archivedAt;
|
|
1961
|
+
}
|
|
1938
1962
|
this.saveConfig();
|
|
1939
1963
|
// start it again unless it was never configured to run (it is in the list, so it
|
|
1940
1964
|
// was) — a restore is the operator asking for it back, so it comes back LIVE
|
|
1941
1965
|
try {
|
|
1942
1966
|
await this.addAgent(ac);
|
|
1943
|
-
return { restored: true, live: true };
|
|
1967
|
+
return { restored: true, live: true, ids };
|
|
1944
1968
|
}
|
|
1945
1969
|
catch (err) {
|
|
1946
1970
|
// the entry is restored either way; starting it can fail on a provider/auth
|
|
1947
1971
|
// problem, and reporting that is more useful than undoing the restore
|
|
1948
1972
|
console.error(`[teapot] restored "${id}" but could not start it: ${err.message}`);
|
|
1949
|
-
return { restored: true, live: false };
|
|
1973
|
+
return { restored: true, live: false, ids };
|
|
1950
1974
|
}
|
|
1951
1975
|
}
|
|
1952
1976
|
/** Archived entries, newest first — what the settings panel lists. */
|
|
1953
1977
|
archivedAgents() {
|
|
1954
|
-
|
|
1955
|
-
|
|
1978
|
+
const archived = this.config.agents.filter((a) => a.archived);
|
|
1979
|
+
const ids = new Set(archived.map((a) => a.id));
|
|
1980
|
+
return archived
|
|
1956
1981
|
.map((a) => ({
|
|
1957
1982
|
id: a.id,
|
|
1958
1983
|
workspace: a.workspace,
|
|
1959
1984
|
...(a.archivedAt !== undefined ? { archivedAt: a.archivedAt } : {}),
|
|
1960
1985
|
sessions: this.sessionsOf(a.id).length,
|
|
1986
|
+
// A sub-agent is listed under its parent rather than as an equal entry: the
|
|
1987
|
+
// operator archived ONE thing, and a flat list of every descendant makes it
|
|
1988
|
+
// look like they did several. Only an ARCHIVED parent counts — otherwise a
|
|
1989
|
+
// live parent would hide a genuinely standalone entry.
|
|
1990
|
+
...(a.parent && ids.has(a.parent) ? { parent: a.parent } : {}),
|
|
1991
|
+
subs: this.subtreeOf(a.id).filter((s) => ids.has(s.id)).length,
|
|
1961
1992
|
}))
|
|
1962
1993
|
.sort((a, b) => (b.archivedAt ?? 0) - (a.archivedAt ?? 0));
|
|
1963
1994
|
}
|