longer-agent 0.1.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/LICENSE +21 -0
- package/README.md +227 -0
- package/README.zh-CN.md +227 -0
- package/agent_templates/executor/agent.yaml +22 -0
- package/agent_templates/executor/system_prompt.md +17 -0
- package/agent_templates/explorer/agent.yaml +13 -0
- package/agent_templates/explorer/system_prompt.md +19 -0
- package/agent_templates/main/agent.yaml +7 -0
- package/agent_templates/main/system_prompt.md +45 -0
- package/configExample.yaml +83 -0
- package/dist/agents/agent.d.ts +79 -0
- package/dist/agents/agent.d.ts.map +1 -0
- package/dist/agents/agent.js +156 -0
- package/dist/agents/agent.js.map +1 -0
- package/dist/agents/tool-loop.d.ts +140 -0
- package/dist/agents/tool-loop.d.ts.map +1 -0
- package/dist/agents/tool-loop.js +465 -0
- package/dist/agents/tool-loop.js.map +1 -0
- package/dist/ask.d.ts +81 -0
- package/dist/ask.d.ts.map +1 -0
- package/dist/ask.js +34 -0
- package/dist/ask.js.map +1 -0
- package/dist/auth/openai-oauth.d.ts +66 -0
- package/dist/auth/openai-oauth.d.ts.map +1 -0
- package/dist/auth/openai-oauth.js +640 -0
- package/dist/auth/openai-oauth.js.map +1 -0
- package/dist/cli.d.ts +14 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +254 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands.d.ts +118 -0
- package/dist/commands.d.ts.map +1 -0
- package/dist/commands.js +862 -0
- package/dist/commands.js.map +1 -0
- package/dist/config.d.ts +130 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +648 -0
- package/dist/config.js.map +1 -0
- package/dist/context-rendering.d.ts +69 -0
- package/dist/context-rendering.d.ts.map +1 -0
- package/dist/context-rendering.js +250 -0
- package/dist/context-rendering.js.map +1 -0
- package/dist/document-projection.d.ts +12 -0
- package/dist/document-projection.d.ts.map +1 -0
- package/dist/document-projection.js +75 -0
- package/dist/document-projection.js.map +1 -0
- package/dist/ephemeral-log.d.ts +15 -0
- package/dist/ephemeral-log.d.ts.map +1 -0
- package/dist/ephemeral-log.js +173 -0
- package/dist/ephemeral-log.js.map +1 -0
- package/dist/file-attach.d.ts +89 -0
- package/dist/file-attach.d.ts.map +1 -0
- package/dist/file-attach.js +571 -0
- package/dist/file-attach.js.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/dist/init-wizard.d.ts +13 -0
- package/dist/init-wizard.d.ts.map +1 -0
- package/dist/init-wizard.js +328 -0
- package/dist/init-wizard.js.map +1 -0
- package/dist/log-entry.d.ts +104 -0
- package/dist/log-entry.d.ts.map +1 -0
- package/dist/log-entry.js +292 -0
- package/dist/log-entry.js.map +1 -0
- package/dist/log-projection.d.ts +73 -0
- package/dist/log-projection.d.ts.map +1 -0
- package/dist/log-projection.js +651 -0
- package/dist/log-projection.js.map +1 -0
- package/dist/mcp-client.d.ts +55 -0
- package/dist/mcp-client.d.ts.map +1 -0
- package/dist/mcp-client.js +402 -0
- package/dist/mcp-client.js.map +1 -0
- package/dist/model-selection.d.ts +16 -0
- package/dist/model-selection.d.ts.map +1 -0
- package/dist/model-selection.js +181 -0
- package/dist/model-selection.js.map +1 -0
- package/dist/network-retry.d.ts +38 -0
- package/dist/network-retry.d.ts.map +1 -0
- package/dist/network-retry.js +140 -0
- package/dist/network-retry.js.map +1 -0
- package/dist/persistence.d.ts +104 -0
- package/dist/persistence.d.ts.map +1 -0
- package/dist/persistence.js +644 -0
- package/dist/persistence.js.map +1 -0
- package/dist/primitives/context.d.ts +29 -0
- package/dist/primitives/context.d.ts.map +1 -0
- package/dist/primitives/context.js +85 -0
- package/dist/primitives/context.js.map +1 -0
- package/dist/progress.d.ts +51 -0
- package/dist/progress.d.ts.map +1 -0
- package/dist/progress.js +229 -0
- package/dist/progress.js.map +1 -0
- package/dist/provider-presets.d.ts +34 -0
- package/dist/provider-presets.d.ts.map +1 -0
- package/dist/provider-presets.js +181 -0
- package/dist/provider-presets.js.map +1 -0
- package/dist/providers/anthropic.d.ts +32 -0
- package/dist/providers/anthropic.d.ts.map +1 -0
- package/dist/providers/anthropic.js +450 -0
- package/dist/providers/anthropic.js.map +1 -0
- package/dist/providers/base.d.ts +135 -0
- package/dist/providers/base.d.ts.map +1 -0
- package/dist/providers/base.js +104 -0
- package/dist/providers/base.js.map +1 -0
- package/dist/providers/glm.d.ts +18 -0
- package/dist/providers/glm.d.ts.map +1 -0
- package/dist/providers/glm.js +59 -0
- package/dist/providers/glm.js.map +1 -0
- package/dist/providers/kimi.d.ts +23 -0
- package/dist/providers/kimi.d.ts.map +1 -0
- package/dist/providers/kimi.js +89 -0
- package/dist/providers/kimi.js.map +1 -0
- package/dist/providers/minimax.d.ts +20 -0
- package/dist/providers/minimax.d.ts.map +1 -0
- package/dist/providers/minimax.js +192 -0
- package/dist/providers/minimax.js.map +1 -0
- package/dist/providers/openai-chat.d.ts +33 -0
- package/dist/providers/openai-chat.d.ts.map +1 -0
- package/dist/providers/openai-chat.js +543 -0
- package/dist/providers/openai-chat.js.map +1 -0
- package/dist/providers/openai-responses.d.ts +26 -0
- package/dist/providers/openai-responses.d.ts.map +1 -0
- package/dist/providers/openai-responses.js +443 -0
- package/dist/providers/openai-responses.js.map +1 -0
- package/dist/providers/openrouter.d.ts +24 -0
- package/dist/providers/openrouter.d.ts.map +1 -0
- package/dist/providers/openrouter.js +177 -0
- package/dist/providers/openrouter.js.map +1 -0
- package/dist/providers/registry.d.ts +7 -0
- package/dist/providers/registry.d.ts.map +1 -0
- package/dist/providers/registry.js +38 -0
- package/dist/providers/registry.js.map +1 -0
- package/dist/security/path.d.ts +51 -0
- package/dist/security/path.d.ts.map +1 -0
- package/dist/security/path.js +187 -0
- package/dist/security/path.js.map +1 -0
- package/dist/security/sensitive-files.d.ts +3 -0
- package/dist/security/sensitive-files.d.ts.map +1 -0
- package/dist/security/sensitive-files.js +41 -0
- package/dist/security/sensitive-files.js.map +1 -0
- package/dist/session.d.ts +446 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +4595 -0
- package/dist/session.js.map +1 -0
- package/dist/settings.d.ts +46 -0
- package/dist/settings.d.ts.map +1 -0
- package/dist/settings.js +134 -0
- package/dist/settings.js.map +1 -0
- package/dist/show-context.d.ts +35 -0
- package/dist/show-context.d.ts.map +1 -0
- package/dist/show-context.js +320 -0
- package/dist/show-context.js.map +1 -0
- package/dist/skills/loader.d.ts +49 -0
- package/dist/skills/loader.d.ts.map +1 -0
- package/dist/skills/loader.js +166 -0
- package/dist/skills/loader.js.map +1 -0
- package/dist/summarize-context.d.ts +29 -0
- package/dist/summarize-context.d.ts.map +1 -0
- package/dist/summarize-context.js +247 -0
- package/dist/summarize-context.js.map +1 -0
- package/dist/templates/loader.d.ts +104 -0
- package/dist/templates/loader.d.ts.map +1 -0
- package/dist/templates/loader.js +514 -0
- package/dist/templates/loader.js.map +1 -0
- package/dist/tools/basic.d.ts +29 -0
- package/dist/tools/basic.d.ts.map +1 -0
- package/dist/tools/basic.js +2079 -0
- package/dist/tools/basic.js.map +1 -0
- package/dist/tools/comm.d.ts +17 -0
- package/dist/tools/comm.d.ts.map +1 -0
- package/dist/tools/comm.js +192 -0
- package/dist/tools/comm.js.map +1 -0
- package/dist/tools/web-fetch.d.ts +11 -0
- package/dist/tools/web-fetch.d.ts.map +1 -0
- package/dist/tools/web-fetch.js +237 -0
- package/dist/tools/web-fetch.js.map +1 -0
- package/dist/tools/web-search.d.ts +24 -0
- package/dist/tools/web-search.d.ts.map +1 -0
- package/dist/tools/web-search.js +51 -0
- package/dist/tools/web-search.js.map +1 -0
- package/dist/tui/app.d.ts +35 -0
- package/dist/tui/app.d.ts.map +1 -0
- package/dist/tui/app.js +1042 -0
- package/dist/tui/app.js.map +1 -0
- package/dist/tui/checkbox-picker.d.ts +35 -0
- package/dist/tui/checkbox-picker.d.ts.map +1 -0
- package/dist/tui/checkbox-picker.js +85 -0
- package/dist/tui/checkbox-picker.js.map +1 -0
- package/dist/tui/command-picker.d.ts +31 -0
- package/dist/tui/command-picker.d.ts.map +1 -0
- package/dist/tui/command-picker.js +113 -0
- package/dist/tui/command-picker.js.map +1 -0
- package/dist/tui/components/ask-panel.d.ts +21 -0
- package/dist/tui/components/ask-panel.d.ts.map +1 -0
- package/dist/tui/components/ask-panel.js +81 -0
- package/dist/tui/components/ask-panel.js.map +1 -0
- package/dist/tui/components/conversation-panel.d.ts +68 -0
- package/dist/tui/components/conversation-panel.d.ts.map +1 -0
- package/dist/tui/components/conversation-panel.js +611 -0
- package/dist/tui/components/conversation-panel.js.map +1 -0
- package/dist/tui/components/input-panel.d.ts +27 -0
- package/dist/tui/components/input-panel.d.ts.map +1 -0
- package/dist/tui/components/input-panel.js +725 -0
- package/dist/tui/components/input-panel.js.map +1 -0
- package/dist/tui/components/logo-panel.d.ts +14 -0
- package/dist/tui/components/logo-panel.d.ts.map +1 -0
- package/dist/tui/components/logo-panel.js +37 -0
- package/dist/tui/components/logo-panel.js.map +1 -0
- package/dist/tui/components/plan-panel.d.ts +10 -0
- package/dist/tui/components/plan-panel.d.ts.map +1 -0
- package/dist/tui/components/plan-panel.js +8 -0
- package/dist/tui/components/plan-panel.js.map +1 -0
- package/dist/tui/components/status-bar.d.ts +24 -0
- package/dist/tui/components/status-bar.d.ts.map +1 -0
- package/dist/tui/components/status-bar.js +80 -0
- package/dist/tui/components/status-bar.js.map +1 -0
- package/dist/tui/input/editor-state.d.ts +22 -0
- package/dist/tui/input/editor-state.d.ts.map +1 -0
- package/dist/tui/input/editor-state.js +157 -0
- package/dist/tui/input/editor-state.js.map +1 -0
- package/dist/tui/input/keymap.d.ts +3 -0
- package/dist/tui/input/keymap.d.ts.map +1 -0
- package/dist/tui/input/keymap.js +72 -0
- package/dist/tui/input/keymap.js.map +1 -0
- package/dist/tui/input/paste-slots.d.ts +17 -0
- package/dist/tui/input/paste-slots.d.ts.map +1 -0
- package/dist/tui/input/paste-slots.js +46 -0
- package/dist/tui/input/paste-slots.js.map +1 -0
- package/dist/tui/input/paste.d.ts +15 -0
- package/dist/tui/input/paste.d.ts.map +1 -0
- package/dist/tui/input/paste.js +35 -0
- package/dist/tui/input/paste.js.map +1 -0
- package/dist/tui/input/protocol.d.ts +9 -0
- package/dist/tui/input/protocol.d.ts.map +1 -0
- package/dist/tui/input/protocol.js +387 -0
- package/dist/tui/input/protocol.js.map +1 -0
- package/dist/tui/input/sanitize.d.ts +6 -0
- package/dist/tui/input/sanitize.d.ts.map +1 -0
- package/dist/tui/input/sanitize.js +20 -0
- package/dist/tui/input/sanitize.js.map +1 -0
- package/dist/tui/input/types.d.ts +18 -0
- package/dist/tui/input/types.d.ts.map +1 -0
- package/dist/tui/input/types.js +2 -0
- package/dist/tui/input/types.js.map +1 -0
- package/dist/tui/launch.d.ts +23 -0
- package/dist/tui/launch.d.ts.map +1 -0
- package/dist/tui/launch.js +104 -0
- package/dist/tui/launch.js.map +1 -0
- package/dist/tui/theme.d.ts +20 -0
- package/dist/tui/theme.d.ts.map +1 -0
- package/dist/tui/theme.js +29 -0
- package/dist/tui/theme.js.map +1 -0
- package/dist/tui/types.d.ts +136 -0
- package/dist/tui/types.d.ts.map +1 -0
- package/dist/tui/types.js +9 -0
- package/dist/tui/types.js.map +1 -0
- package/package.json +76 -0
- package/prompts/sections/agents_md.md +23 -0
- package/prompts/sections/important_log.md +16 -0
- package/prompts/sections/system_mechanisms.md +18 -0
- package/prompts/tools/apply_patch.md +31 -0
- package/prompts/tools/ask.md +18 -0
- package/prompts/tools/bash.md +13 -0
- package/prompts/tools/bash_background.md +9 -0
- package/prompts/tools/bash_output.md +9 -0
- package/prompts/tools/check_status.md +3 -0
- package/prompts/tools/diff.md +5 -0
- package/prompts/tools/edit_file.md +11 -0
- package/prompts/tools/glob.md +7 -0
- package/prompts/tools/grep.md +20 -0
- package/prompts/tools/kill_agent.md +3 -0
- package/prompts/tools/kill_shell.md +5 -0
- package/prompts/tools/list_dir.md +5 -0
- package/prompts/tools/plan.md +252 -0
- package/prompts/tools/read_file.md +9 -0
- package/prompts/tools/show_context.md +12 -0
- package/prompts/tools/skill.md +7 -0
- package/prompts/tools/spawn_agent.md +195 -0
- package/prompts/tools/summarize_context.md +122 -0
- package/prompts/tools/test.md +5 -0
- package/prompts/tools/wait.md +17 -0
- package/prompts/tools/web_fetch.md +9 -0
- package/prompts/tools/web_search.md +5 -0
- package/prompts/tools/write_file.md +11 -0
- package/skills/.staging/.gitkeep +0 -0
- package/skills/explain-code/SKILL.md +15 -0
- package/skills/skill-manager/SKILL.md +83 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TUI launcher -- renders the Ink application.
|
|
3
|
+
*
|
|
4
|
+
* This is the entry point for the terminal UI. It sets up the
|
|
5
|
+
* progress bridge, wires session and store, and renders the
|
|
6
|
+
* React/Ink component tree.
|
|
7
|
+
*/
|
|
8
|
+
import React from "react";
|
|
9
|
+
import { render } from "ink";
|
|
10
|
+
import { App } from "./app.js";
|
|
11
|
+
import { ProgressReporter } from "../progress.js";
|
|
12
|
+
import { buildDefaultRegistry } from "../commands.js";
|
|
13
|
+
const KITTY_KEYBOARD_ENABLE = "\u001b[>1u";
|
|
14
|
+
const KITTY_KEYBOARD_DISABLE = "\u001b[<u";
|
|
15
|
+
const BRACKETED_PASTE_ENABLE = "\u001b[?2004h";
|
|
16
|
+
const BRACKETED_PASTE_DISABLE = "\u001b[?2004l";
|
|
17
|
+
const SET_TERMINAL_TITLE = "\u001b]0;LongerAgent\u0007";
|
|
18
|
+
function shouldEnableKittyKeyboard() {
|
|
19
|
+
if (process.env["LONGERAGENT_DISABLE_KITTY_KEYBOARD"] === "1")
|
|
20
|
+
return false;
|
|
21
|
+
return process.stdout.isTTY === true;
|
|
22
|
+
}
|
|
23
|
+
export async function launchTui(sessionOrOptions, commandRegistryArg, storeArg, optsArg) {
|
|
24
|
+
let session;
|
|
25
|
+
let commandRegistry;
|
|
26
|
+
let store;
|
|
27
|
+
let verbose = false;
|
|
28
|
+
if (typeof sessionOrOptions === "object" &&
|
|
29
|
+
"session" in sessionOrOptions &&
|
|
30
|
+
typeof sessionOrOptions.session?.turn === "function") {
|
|
31
|
+
// Options-object form
|
|
32
|
+
const lo = sessionOrOptions;
|
|
33
|
+
session = lo.session;
|
|
34
|
+
commandRegistry =
|
|
35
|
+
lo.commandRegistry ?? buildDefaultRegistry();
|
|
36
|
+
store = lo.sessionStore ?? null;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
// Positional form
|
|
40
|
+
session = sessionOrOptions;
|
|
41
|
+
commandRegistry = commandRegistryArg ?? buildDefaultRegistry();
|
|
42
|
+
store = storeArg ?? null;
|
|
43
|
+
verbose = optsArg?.verbose ?? false;
|
|
44
|
+
}
|
|
45
|
+
// Progress bridge: captures progress events and forwards to React
|
|
46
|
+
let progressCallback;
|
|
47
|
+
const tuiProgress = new ProgressReporter({
|
|
48
|
+
level: verbose ? "verbose" : "normal",
|
|
49
|
+
callback: (event) => {
|
|
50
|
+
if (progressCallback) {
|
|
51
|
+
progressCallback(event);
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
// Wire progress to session
|
|
56
|
+
session._progress = tuiProgress;
|
|
57
|
+
let ttyFeaturesEnabled = false;
|
|
58
|
+
if (process.stdout.isTTY === true) {
|
|
59
|
+
try {
|
|
60
|
+
process.stdout.write(SET_TERMINAL_TITLE);
|
|
61
|
+
process.stdout.write(BRACKETED_PASTE_ENABLE);
|
|
62
|
+
if (shouldEnableKittyKeyboard()) {
|
|
63
|
+
process.stdout.write(KITTY_KEYBOARD_ENABLE);
|
|
64
|
+
}
|
|
65
|
+
ttyFeaturesEnabled = true;
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
// ignore
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
const { waitUntilExit } = render(React.createElement(App, {
|
|
73
|
+
session,
|
|
74
|
+
commandRegistry,
|
|
75
|
+
store,
|
|
76
|
+
onProgressCallback: (cb) => {
|
|
77
|
+
progressCallback = cb;
|
|
78
|
+
},
|
|
79
|
+
}), { exitOnCtrlC: false });
|
|
80
|
+
await waitUntilExit();
|
|
81
|
+
}
|
|
82
|
+
finally {
|
|
83
|
+
if (ttyFeaturesEnabled) {
|
|
84
|
+
try {
|
|
85
|
+
if (shouldEnableKittyKeyboard()) {
|
|
86
|
+
process.stdout.write(KITTY_KEYBOARD_DISABLE);
|
|
87
|
+
}
|
|
88
|
+
process.stdout.write(BRACKETED_PASTE_DISABLE);
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
// ignore
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// Catch-all cleanup after TUI exits.
|
|
95
|
+
// Safe to call even if close() was already called by /quit or Ctrl+C.
|
|
96
|
+
try {
|
|
97
|
+
await session.close();
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
// ignore
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=launch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"launch.js","sourceRoot":"","sources":["../../src/tui/launch.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B,OAAO,EAAE,gBAAgB,EAAyB,MAAM,gBAAgB,CAAC;AAEzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEtD,MAAM,qBAAqB,GAAG,YAAY,CAAC;AAC3C,MAAM,sBAAsB,GAAG,WAAW,CAAC;AAC3C,MAAM,sBAAsB,GAAG,eAAe,CAAC;AAC/C,MAAM,uBAAuB,GAAG,eAAe,CAAC;AAChD,MA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CAAC;QAED,qCAAqC;QACrC,sEAAsE;QACtE,IAAI,CAAC;YACH,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;QACxB,CAAC;QAAC,MAAM,CAAC;YACP,SAAS;QACX,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centralized TUI theme.
|
|
3
|
+
*
|
|
4
|
+
* `theme.accent` is the primary brand color used for logo, prompts,
|
|
5
|
+
* headings, and highlights. Change it at runtime via `setAccent()`.
|
|
6
|
+
* Ink accepts: named colors, "bright" variants, or hex strings like "#7c3aed".
|
|
7
|
+
*/
|
|
8
|
+
export declare const DEFAULT_ACCENT = "#4b4bf0";
|
|
9
|
+
export declare const theme: {
|
|
10
|
+
/** Primary brand / accent color used for logo, prompts, headings, highlights. */
|
|
11
|
+
accent: string;
|
|
12
|
+
};
|
|
13
|
+
/** Update the accent color at runtime. */
|
|
14
|
+
export declare function setAccent(color: string): void;
|
|
15
|
+
/** Preset accent color options for the /theme picker (ordered by hue). */
|
|
16
|
+
export declare const ACCENT_PRESETS: ReadonlyArray<{
|
|
17
|
+
label: string;
|
|
18
|
+
value: string;
|
|
19
|
+
}>;
|
|
20
|
+
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/tui/theme.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,eAAO,MAAM,cAAc,YAAY,CAAC;AAExC,eAAO,MAAM,KAAK;IAChB,iFAAiF;;CAElF,CAAC;AAEF,0CAA0C;AAC1C,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAE7C;AAED,0EAA0E;AAC1E,eAAO,MAAM,cAAc,EAAE,aAAa,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAU1E,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centralized TUI theme.
|
|
3
|
+
*
|
|
4
|
+
* `theme.accent` is the primary brand color used for logo, prompts,
|
|
5
|
+
* headings, and highlights. Change it at runtime via `setAccent()`.
|
|
6
|
+
* Ink accepts: named colors, "bright" variants, or hex strings like "#7c3aed".
|
|
7
|
+
*/
|
|
8
|
+
export const DEFAULT_ACCENT = "#4b4bf0";
|
|
9
|
+
export const theme = {
|
|
10
|
+
/** Primary brand / accent color used for logo, prompts, headings, highlights. */
|
|
11
|
+
accent: DEFAULT_ACCENT,
|
|
12
|
+
};
|
|
13
|
+
/** Update the accent color at runtime. */
|
|
14
|
+
export function setAccent(color) {
|
|
15
|
+
theme.accent = color;
|
|
16
|
+
}
|
|
17
|
+
/** Preset accent color options for the /theme picker (ordered by hue). */
|
|
18
|
+
export const ACCENT_PRESETS = [
|
|
19
|
+
{ label: "Indigo", value: "#4b4bf0" },
|
|
20
|
+
{ label: "Lavender", value: "#7264B5" },
|
|
21
|
+
{ label: "Mauve", value: "#AF5A85" },
|
|
22
|
+
{ label: "Dusty Rose", value: "#C0596A" },
|
|
23
|
+
{ label: "Terracotta", value: "#C26647" },
|
|
24
|
+
{ label: "Gold", value: "#BE9C37" },
|
|
25
|
+
{ label: "Olive", value: "#759E4C" },
|
|
26
|
+
{ label: "Ocean", value: "#4396B2" },
|
|
27
|
+
{ label: "Deep Blue", value: "#1919E6" },
|
|
28
|
+
];
|
|
29
|
+
//# sourceMappingURL=theme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.js","sourceRoot":"","sources":["../../src/tui/theme.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,SAAS,CAAC;AAExC,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,iFAAiF;IACjF,MAAM,EAAE,cAAc;CACvB,CAAC;AAEF,0CAA0C;AAC1C,MAAM,UAAU,SAAS,CAAC,KAAa;IACrC,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC;AACvB,CAAC;AAED,0EAA0E;AAC1E,MAAM,CAAC,MAAM,cAAc,GAAoD;IAC7E,EAAE,KAAK,EAAE,QAAQ,EAAO,KAAK,EAAE,SAAS,EAAE;IAC1C,EAAE,KAAK,EAAE,UAAU,EAAK,KAAK,EAAE,SAAS,EAAE;IAC1C,EAAE,KAAK,EAAE,OAAO,EAAQ,KAAK,EAAE,SAAS,EAAE;IAC1C,EAAE,KAAK,EAAE,YAAY,EAAG,KAAK,EAAE,SAAS,EAAE;IAC1C,EAAE,KAAK,EAAE,YAAY,EAAG,KAAK,EAAE,SAAS,EAAE;IAC1C,EAAE,KAAK,EAAE,MAAM,EAAS,KAAK,EAAE,SAAS,EAAE;IAC1C,EAAE,KAAK,EAAE,OAAO,EAAQ,KAAK,EAAE,SAAS,EAAE;IAC1C,EAAE,KAAK,EAAE,OAAO,EAAQ,KAAK,EAAE,SAAS,EAAE;IAC1C,EAAE,KAAK,EAAE,WAAW,EAAI,KAAK,EAAE,SAAS,EAAE;CAC3C,CAAC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TUI-specific type definitions.
|
|
3
|
+
*
|
|
4
|
+
* Defines interfaces for Session, CommandRegistry, and other types
|
|
5
|
+
* that the TUI layer depends on. These act as the contract boundary
|
|
6
|
+
* between the TUI and the core runtime.
|
|
7
|
+
*/
|
|
8
|
+
import type { ProgressReporter } from "../progress.js";
|
|
9
|
+
import type { SessionStore, LogSessionMeta } from "../persistence.js";
|
|
10
|
+
import type { PendingAskUi, AgentQuestionDecision } from "../ask.js";
|
|
11
|
+
import type { LogEntry, LogIdAllocator } from "../log-entry.js";
|
|
12
|
+
import type { CommandRegistry as ActualCommandRegistry, CommandContext, SlashCommand as ActualSlashCommand, CommandOption as ActualCommandOption } from "../commands.js";
|
|
13
|
+
export type CommandRegistry = ActualCommandRegistry;
|
|
14
|
+
export type SlashCommand = ActualSlashCommand;
|
|
15
|
+
export type CommandOption = ActualCommandOption;
|
|
16
|
+
export type { CommandContext };
|
|
17
|
+
export interface Session {
|
|
18
|
+
turn(userInput: string, options?: {
|
|
19
|
+
signal?: AbortSignal;
|
|
20
|
+
}): Promise<string>;
|
|
21
|
+
close(): Promise<void>;
|
|
22
|
+
requestTurnInterrupt?(): {
|
|
23
|
+
accepted: boolean;
|
|
24
|
+
reason?: "compact_in_progress";
|
|
25
|
+
};
|
|
26
|
+
cancelCurrentTurn?(): void;
|
|
27
|
+
primaryAgent: {
|
|
28
|
+
name: string;
|
|
29
|
+
modelConfig?: {
|
|
30
|
+
name?: string;
|
|
31
|
+
provider?: string;
|
|
32
|
+
model?: string;
|
|
33
|
+
contextLength?: number;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
_progress?: ProgressReporter;
|
|
37
|
+
_turnCount: number;
|
|
38
|
+
_compactCount: number;
|
|
39
|
+
_createdAt?: string;
|
|
40
|
+
/** Input tokens from the most recent provider response. */
|
|
41
|
+
lastInputTokens: number;
|
|
42
|
+
/** Total tokens from the most recent provider response. */
|
|
43
|
+
lastTotalTokens: number;
|
|
44
|
+
/** Cache-read tokens from the most recent provider response. */
|
|
45
|
+
lastCacheReadTokens?: number;
|
|
46
|
+
/** Callback for incremental persistence — called at save-worthy checkpoints. */
|
|
47
|
+
onSaveRequest?: () => void;
|
|
48
|
+
setStore(store: SessionStore | null): void;
|
|
49
|
+
getPendingAsk(): PendingAskUi | null;
|
|
50
|
+
resolveAgentQuestionAsk?(askId: string, decision: AgentQuestionDecision): void;
|
|
51
|
+
resumePendingTurn?(options?: {
|
|
52
|
+
signal?: AbortSignal;
|
|
53
|
+
}): Promise<string>;
|
|
54
|
+
hasPendingTurnToResume?(): boolean;
|
|
55
|
+
runManualSummarize?(instruction?: string, options?: {
|
|
56
|
+
signal?: AbortSignal;
|
|
57
|
+
}): Promise<string>;
|
|
58
|
+
runManualCompact?(instruction?: string, options?: {
|
|
59
|
+
signal?: AbortSignal;
|
|
60
|
+
}): Promise<void>;
|
|
61
|
+
/** The config name for the current model (e.g., "my-claude"). */
|
|
62
|
+
currentModelConfigName?: string;
|
|
63
|
+
/** Switch to a different configured model by config name. */
|
|
64
|
+
switchModel?(modelConfigName: string): void;
|
|
65
|
+
/** Access to Config for model enumeration. */
|
|
66
|
+
config?: {
|
|
67
|
+
modelNames: string[];
|
|
68
|
+
getModel(name: string): {
|
|
69
|
+
provider: string;
|
|
70
|
+
model: string;
|
|
71
|
+
contextLength: number;
|
|
72
|
+
supportsThinking: boolean;
|
|
73
|
+
supportsMultimodal: boolean;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
_resetTransientState(): void;
|
|
77
|
+
_initConversation(): void;
|
|
78
|
+
/** Deliver a message to the agent (routes based on agent state). */
|
|
79
|
+
deliverMessage?(source: "user" | "system" | "sub-agent", content: string): void;
|
|
80
|
+
/** Read-only structured log snapshot. */
|
|
81
|
+
log?: readonly LogEntry[];
|
|
82
|
+
/** Subscribe to log changes. Returns unsubscribe function. */
|
|
83
|
+
subscribeLog?(listener: () => void): () => void;
|
|
84
|
+
/** Restore session from loaded log data. */
|
|
85
|
+
restoreFromLog?(meta: LogSessionMeta, entries: LogEntry[], idAllocator: LogIdAllocator): void;
|
|
86
|
+
/** Get log data for persistence (meta + entries). */
|
|
87
|
+
getLogForPersistence?(): {
|
|
88
|
+
meta: LogSessionMeta;
|
|
89
|
+
entries: readonly LogEntry[];
|
|
90
|
+
};
|
|
91
|
+
/** Reset session for /new. */
|
|
92
|
+
resetForNewSession?(newStore?: any): void;
|
|
93
|
+
/** Append a persisted status line to the log. */
|
|
94
|
+
appendStatusMessage?(text: string, statusType?: string): void;
|
|
95
|
+
/** Append a persisted error line to the log. */
|
|
96
|
+
appendErrorMessage?(text: string, errorType?: string): void;
|
|
97
|
+
/** Return all skills (enabled + disabled) for UI display. */
|
|
98
|
+
getAllSkillNames?(): {
|
|
99
|
+
name: string;
|
|
100
|
+
description: string;
|
|
101
|
+
enabled: boolean;
|
|
102
|
+
}[];
|
|
103
|
+
/** Enable or disable a skill by name. */
|
|
104
|
+
setSkillEnabled?(name: string, enabled: boolean): void;
|
|
105
|
+
/** Rescan disk and rebuild skill state. */
|
|
106
|
+
reloadSkills?(): {
|
|
107
|
+
added: string[];
|
|
108
|
+
removed: string[];
|
|
109
|
+
total: number;
|
|
110
|
+
};
|
|
111
|
+
/** Read-only access to loaded skills. */
|
|
112
|
+
skills?: ReadonlyMap<string, unknown>;
|
|
113
|
+
}
|
|
114
|
+
export type ConversationEntryKind = "user" | "assistant" | "interrupted_marker" | "progress" | "sub_agent_rollup" | "sub_agent_done" | "tool_call" | "tool_result" | "reasoning" | "status" | "error" | "compact_mark";
|
|
115
|
+
export interface ConversationEntry {
|
|
116
|
+
kind: ConversationEntryKind;
|
|
117
|
+
text: string;
|
|
118
|
+
/** Timestamp when this entry was created (Unix ms). Used for tool call timing. */
|
|
119
|
+
startedAt?: number;
|
|
120
|
+
/** Elapsed time in ms (set when the matching tool_result is found). */
|
|
121
|
+
elapsedMs?: number;
|
|
122
|
+
id?: string;
|
|
123
|
+
/** Whether this user message is queued for delivery (agent is working). */
|
|
124
|
+
queued?: boolean;
|
|
125
|
+
/** When true, TUI renders this entry in dim/gray style. */
|
|
126
|
+
dim?: boolean;
|
|
127
|
+
}
|
|
128
|
+
export interface LaunchOptions {
|
|
129
|
+
session: Session;
|
|
130
|
+
commandRegistry?: CommandRegistry;
|
|
131
|
+
sessionStore?: SessionStore | null;
|
|
132
|
+
config?: {
|
|
133
|
+
defaultModel?: string;
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/tui/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;A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AAI,CAAC;IACvD,2CAA2C;IAC3C,YAAY,CAAC,IAAI;QAAE,KAAK,EAAE,MAAM,EAAE,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IACvE,yCAAyC;IACzC,MAAM,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC;AAMD,MAAM,MAAM,qBAAqB,GAC7B,MAAM,GACN,WAAW,GACX,oBAAoB,GACpB,UAAU,GACV,kBAAkB,GAClB,gBAAgB,GAChB,WAAW,GACX,aAAa,GACb,WAAW,GACX,QAAQ,GACR,OAAO,GACP,cAAc,CAAC;AAEnB,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,qBAAqB,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,kFAAkF;IAClF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uEAAuE;IACvE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,2EAA2E;IAC3E,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,2DAA2D;IAC3D,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAMD,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,YAAY,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;IACnC,MAAM,CAAC,EAAE;QAAE,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACpC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TUI-specific type definitions.
|
|
3
|
+
*
|
|
4
|
+
* Defines interfaces for Session, CommandRegistry, and other types
|
|
5
|
+
* that the TUI layer depends on. These act as the contract boundary
|
|
6
|
+
* between the TUI and the core runtime.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/tui/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "longer-agent",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A terminal AI coding agent built for long sessions — three-layer context management, persistent memory, and parallel sub-agents",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "Felix Rui Gao",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/FelixRuiGao/LongerAgent.git"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/FelixRuiGao/LongerAgent",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/FelixRuiGao/LongerAgent/issues"
|
|
15
|
+
},
|
|
16
|
+
"main": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"bin": {
|
|
19
|
+
"longeragent": "./dist/cli.js"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist/",
|
|
23
|
+
"agent_templates/",
|
|
24
|
+
"prompts/",
|
|
25
|
+
"skills/",
|
|
26
|
+
"configExample.yaml",
|
|
27
|
+
"LICENSE",
|
|
28
|
+
"README.md"
|
|
29
|
+
],
|
|
30
|
+
"keywords": [
|
|
31
|
+
"ai",
|
|
32
|
+
"agent",
|
|
33
|
+
"cli",
|
|
34
|
+
"llm",
|
|
35
|
+
"coding-agent",
|
|
36
|
+
"multi-agent",
|
|
37
|
+
"context-management",
|
|
38
|
+
"summarization",
|
|
39
|
+
"terminal"
|
|
40
|
+
],
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "node -e \"const fs=require('fs');fs.rmSync('dist',{recursive:true,force:true});\" && tsc -p tsconfig.build.json",
|
|
43
|
+
"dev": "tsx src/cli.ts",
|
|
44
|
+
"test": "vitest run",
|
|
45
|
+
"test:watch": "vitest",
|
|
46
|
+
"typecheck": "tsc --noEmit",
|
|
47
|
+
"prepublishOnly": "pnpm build && pnpm test"
|
|
48
|
+
},
|
|
49
|
+
"engines": {
|
|
50
|
+
"node": ">=18.0.0"
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"@anthropic-ai/sdk": "^0.61.0",
|
|
54
|
+
"@inquirer/prompts": "^8.3.0",
|
|
55
|
+
"commander": "^12.0.0",
|
|
56
|
+
"gpt-tokenizer": "^3.4.0",
|
|
57
|
+
"ink": "^6.8.0",
|
|
58
|
+
"js-yaml": "^4.1.0",
|
|
59
|
+
"marked": "^15.0.0",
|
|
60
|
+
"marked-terminal": "^7.0.0",
|
|
61
|
+
"markitdown-ts": "^0.0.10",
|
|
62
|
+
"openai": "^4.90.0",
|
|
63
|
+
"react": "^19.2.4"
|
|
64
|
+
},
|
|
65
|
+
"devDependencies": {
|
|
66
|
+
"@types/js-yaml": "^4.0.9",
|
|
67
|
+
"@types/node": "^22.0.0",
|
|
68
|
+
"@types/react": "^19.2.14",
|
|
69
|
+
"tsx": "^4.19.0",
|
|
70
|
+
"typescript": "^5.7.0",
|
|
71
|
+
"vitest": "^3.0.0"
|
|
72
|
+
},
|
|
73
|
+
"optionalDependencies": {
|
|
74
|
+
"@modelcontextprotocol/sdk": "^1.12.0"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
## AGENTS.md — Persistent Memory
|
|
2
|
+
|
|
3
|
+
Two persistent memory files are automatically loaded and injected into your context on every turn:
|
|
4
|
+
|
|
5
|
+
1. **Global memory** (`~/AGENTS.md`) — user-level preferences, conventions, and knowledge that apply across all projects.
|
|
6
|
+
2. **Project memory** (`{PROJECT_ROOT}/AGENTS.md`) — project-specific architecture decisions, patterns, key file paths, and accumulated insights.
|
|
7
|
+
|
|
8
|
+
These files survive across sessions and context resets — they are always visible after the system prompt, similar to the important log.
|
|
9
|
+
|
|
10
|
+
**Reading:** You always see the latest content from both files. Use this context to inform your work.
|
|
11
|
+
|
|
12
|
+
**Writing:** Use `edit_file` or `write_file` to update these files when you discover stable, long-term knowledge worth persisting. The project AGENTS.md is the more common target.
|
|
13
|
+
|
|
14
|
+
**What belongs here:**
|
|
15
|
+
- Confirmed patterns and conventions (coding style, architecture decisions)
|
|
16
|
+
- Key file paths and project structure insights
|
|
17
|
+
- User preferences for workflow and communication
|
|
18
|
+
- Solutions to recurring problems
|
|
19
|
+
|
|
20
|
+
**What does NOT belong here:**
|
|
21
|
+
- Session-specific or in-progress work (use the important log instead)
|
|
22
|
+
- Transient debugging context
|
|
23
|
+
- Information that duplicates existing project docs
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
## Important Log
|
|
2
|
+
|
|
3
|
+
The primary agent's persistent engineering notebook at `{SESSION_ARTIFACTS}/important-log.md`. It survives context resets and compaction — always visible after the system prompt. Maintained by the primary agent; sub-agents can read it for background context.
|
|
4
|
+
|
|
5
|
+
This file is auto-created by the system. Use `edit_file` to update it.
|
|
6
|
+
|
|
7
|
+
**Only log information that is genuinely valuable long-term.** Keep entries concise. Examples of what belongs here:
|
|
8
|
+
|
|
9
|
+
- A viable approach discovered after extensive exploration and trial-and-error — the conclusion, not the journey
|
|
10
|
+
- The path to a reference file created during investigation (e.g., "code issues cataloged in `{SESSION_ARTIFACTS}/issues.md`") — rather than duplicating the content here
|
|
11
|
+
- Architecture insights or critical decisions that will inform future work
|
|
12
|
+
- Failed approaches and *why* they failed, to avoid repeating them
|
|
13
|
+
|
|
14
|
+
**Don't log:** verbose code (reference file paths instead), full exploration dumps (summarize them), routine progress, anything transient.
|
|
15
|
+
|
|
16
|
+
**Manage size actively.** When the file grows large, edit it to compress or remove entries from completed work.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# System Mechanisms
|
|
2
|
+
|
|
3
|
+
## Auto-Compact
|
|
4
|
+
|
|
5
|
+
When your context approaches the model's limit, the system triggers auto-compact:
|
|
6
|
+
|
|
7
|
+
1. You write a **continuation prompt** — a briefing summarizing the full conversation state.
|
|
8
|
+
2. Context is reset. System prompt, important log, master plan, and phase plan are re-injected.
|
|
9
|
+
3. Your briefing becomes the new starting context for a fresh instance.
|
|
10
|
+
|
|
11
|
+
**Proactive compression is better than forced compact.** Use `summarize_context` regularly. A forced compact is disruptive — it interrupts your workflow and compresses everything at once.
|
|
12
|
+
|
|
13
|
+
## Hint Compression
|
|
14
|
+
|
|
15
|
+
When context is filling (but below the compact threshold), you'll see:
|
|
16
|
+
`[SYSTEM: Context window is filling up...]`
|
|
17
|
+
|
|
18
|
+
This is a soft reminder to use `summarize_context`. Prioritize: completed subtasks, large consumed tool results, exploratory steps that led to conclusions.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
## `apply_patch`
|
|
2
|
+
|
|
3
|
+
`apply_patch(patch)`
|
|
4
|
+
|
|
5
|
+
Apply a structured multi-file patch. Use this for:
|
|
6
|
+
|
|
7
|
+
- Multiple edits in one file
|
|
8
|
+
- Coordinated edits across files
|
|
9
|
+
- Appending to large files in chunks
|
|
10
|
+
|
|
11
|
+
Recommended workflow for large file generation:
|
|
12
|
+
|
|
13
|
+
- Start the file with `write_file`
|
|
14
|
+
- Then use `apply_patch` to append additional sections in chunks
|
|
15
|
+
|
|
16
|
+
Patch syntax:
|
|
17
|
+
|
|
18
|
+
```text
|
|
19
|
+
*** Begin Patch
|
|
20
|
+
*** Update File: src/app.ts
|
|
21
|
+
@@
|
|
22
|
+
-old line
|
|
23
|
+
+new line
|
|
24
|
+
*** Append File: docs/guide.md
|
|
25
|
+
+## Next Section
|
|
26
|
+
+More text...
|
|
27
|
+
*** Add File: src/new.ts
|
|
28
|
+
+export const x = 1;
|
|
29
|
+
*** Delete File: src/old.ts
|
|
30
|
+
*** End Patch
|
|
31
|
+
```
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
## `ask`
|
|
2
|
+
|
|
3
|
+
Ask the user 1-4 structured questions, each with 1-4 concrete options. The system automatically adds two extra options to each question: **"Enter custom answer"** (user types free text) and **"Discuss further"** (user wants open discussion before deciding).
|
|
4
|
+
|
|
5
|
+
**Use `ask`** when you have concrete, limited alternatives — architecture patterns, implementation approaches, library choices.
|
|
6
|
+
|
|
7
|
+
> Three approaches to optimize queries: indexes, rewriting, caching. Use `ask`.
|
|
8
|
+
|
|
9
|
+
**Ask in text instead** when the problem is vague or exploratory.
|
|
10
|
+
|
|
11
|
+
> "The auth flow feels wrong somehow." Discuss in text first, use `ask` when concrete alternatives emerge.
|
|
12
|
+
|
|
13
|
+
**Don't ask** when you can find the answer yourself via tool calls.
|
|
14
|
+
|
|
15
|
+
**Understanding responses:**
|
|
16
|
+
- **Option selected** — proceed with that choice.
|
|
17
|
+
- **Custom input** — the user typed a free-text answer instead of picking an option. Treat it as their specific instruction.
|
|
18
|
+
- **Discuss further** — treat it as a normal answer meaning the user wants to continue the discussion before making a final commitment. Use any other answers normally. Briefly address the discussion points, then wait for the user's next message.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
## `bash`
|
|
2
|
+
|
|
3
|
+
`bash(command, timeout?, cwd?)`
|
|
4
|
+
|
|
5
|
+
Execute shell commands. Returns stdout, stderr, and exit code.
|
|
6
|
+
|
|
7
|
+
Use `bash` for: running builds, installing dependencies, git operations, short scripts, checking system state. For file reading, searching, and editing, prefer the dedicated tools — they have proper access controls and structured output.
|
|
8
|
+
|
|
9
|
+
**Before creating directories or files via bash**, verify the parent directory exists first.
|
|
10
|
+
|
|
11
|
+
**Timeouts:** Default 60s, max 600s. Long-running commands should specify a timeout.
|
|
12
|
+
|
|
13
|
+
**Output limit:** ~200KB per stream. Large outputs are truncated.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
## `bash_background`
|
|
2
|
+
|
|
3
|
+
`bash_background(command, cwd?, id?)`
|
|
4
|
+
|
|
5
|
+
Start a tracked background shell command. Use this for long-running processes like dev servers and watchers.
|
|
6
|
+
|
|
7
|
+
- Returns a shell ID and a stable log file path.
|
|
8
|
+
- Use `bash_output` to inspect logs later.
|
|
9
|
+
- Use `wait(shell="...", seconds=60)` if you want to wait for the process to exit.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
## `bash_output`
|
|
2
|
+
|
|
3
|
+
`bash_output(id, tail_lines?, max_chars?)`
|
|
4
|
+
|
|
5
|
+
Read output from a tracked background shell.
|
|
6
|
+
|
|
7
|
+
- Without `tail_lines`, returns unread output since the last `bash_output` call for that shell.
|
|
8
|
+
- With `tail_lines`, returns the recent tail without advancing the unread cursor.
|
|
9
|
+
- If output is truncated, prefer searching the full log file first and then reading the relevant region.
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
## `check_status`
|
|
2
|
+
|
|
3
|
+
Check for new messages (user messages, system notifications), sub-agent status, and tracked shell status. Non-blocking. Use to read messages when you see a `[Message Notification]` in a tool result. **For waiting, use `wait` instead** — it's more efficient and doesn't waste activations.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
## `edit_file`
|
|
2
|
+
|
|
3
|
+
`edit_file(path, old_str, new_str, expected_mtime_ms?)`
|
|
4
|
+
|
|
5
|
+
Apply a minimal patch by replacing a unique string. `old_str` must appear **exactly once** in the file — if it's not unique, provide more surrounding context to make it unique.
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
edit_file(path="{PROJECT_ROOT}/example.py", old_str="Hello", new_str="Hi")
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Supports `expected_mtime_ms` for concurrency safety. Prefer `edit_file` over `write_file` for modifications — it's smaller and safer.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
## `grep`
|
|
2
|
+
|
|
3
|
+
`grep(pattern, path?, output_mode?, glob?, type?, -A?, -B?, -C?, -i?, head_limit?)`
|
|
4
|
+
|
|
5
|
+
Search file contents using regex. Supports glob filtering, file type filtering, context lines, and multiple output modes.
|
|
6
|
+
|
|
7
|
+
Key parameters:
|
|
8
|
+
- `output_mode`: `"files_with_matches"` (default, paths only), `"content"` (matching lines), `"count"` (match counts).
|
|
9
|
+
- `glob`: Filter files by pattern (e.g. `"*.ts"`, `"*.{ts,tsx}"`).
|
|
10
|
+
- `type`: Filter by file type (e.g. `"js"`, `"py"`).
|
|
11
|
+
- `-A`, `-B`, `-C`: Context lines after/before/around each match (content mode only).
|
|
12
|
+
- `-i`: Case insensitive.
|
|
13
|
+
- `head_limit`: Limit number of results.
|
|
14
|
+
|
|
15
|
+
Recommended workflow for large files and logs:
|
|
16
|
+
|
|
17
|
+
- Start with `grep` to find the relevant area.
|
|
18
|
+
- Then use `read_file(start_line, end_line)` to inspect the matching region.
|
|
19
|
+
- Prefer this over reading a very large file from the top unless you genuinely need the overall structure.
|
|
20
|
+
- When output says "truncated", search the full log file or source file for specific keywords rather than re-requesting full content.
|