@prestyj/cli 4.3.164 → 4.3.201
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/cli.js +106 -27
- package/dist/cli.js.map +1 -1
- package/dist/core/agent-session.d.ts +50 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +175 -20
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/agents.d.ts +6 -1
- package/dist/core/agents.d.ts.map +1 -1
- package/dist/core/agents.js +112 -3
- package/dist/core/agents.js.map +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +20 -1
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/claude-code-version.d.ts +10 -0
- package/dist/core/claude-code-version.d.ts.map +1 -0
- package/dist/core/claude-code-version.js +106 -0
- package/dist/core/claude-code-version.js.map +1 -0
- package/dist/core/compaction/compactor.d.ts +13 -0
- package/dist/core/compaction/compactor.d.ts.map +1 -1
- package/dist/core/compaction/compactor.js +20 -1
- package/dist/core/compaction/compactor.js.map +1 -1
- package/dist/core/compaction/compactor.test.js +12 -1
- package/dist/core/compaction/compactor.test.js.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/model-registry.d.ts +30 -2
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +41 -26
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-registry.test.d.ts +2 -0
- package/dist/core/model-registry.test.d.ts.map +1 -0
- package/dist/core/model-registry.test.js +19 -0
- package/dist/core/model-registry.test.js.map +1 -0
- package/dist/core/oauth/anthropic.d.ts.map +1 -1
- package/dist/core/oauth/anthropic.js +64 -42
- package/dist/core/oauth/anthropic.js.map +1 -1
- package/dist/core/oauth/openai.js +1 -1
- package/dist/core/oauth/openai.js.map +1 -1
- package/dist/core/prompt-commands.d.ts.map +1 -1
- package/dist/core/prompt-commands.js +480 -100
- package/dist/core/prompt-commands.js.map +1 -1
- package/dist/core/prompt-commands.test.d.ts +2 -0
- package/dist/core/prompt-commands.test.d.ts.map +1 -0
- package/dist/core/prompt-commands.test.js +33 -0
- package/dist/core/prompt-commands.test.js.map +1 -0
- package/dist/core/repomap-context.d.ts +11 -0
- package/dist/core/repomap-context.d.ts.map +1 -0
- package/dist/core/repomap-context.js +68 -0
- package/dist/core/repomap-context.js.map +1 -0
- package/dist/core/repomap-context.test.d.ts +2 -0
- package/dist/core/repomap-context.test.d.ts.map +1 -0
- package/dist/core/repomap-context.test.js +47 -0
- package/dist/core/repomap-context.test.js.map +1 -0
- package/dist/core/repomap.d.ts +74 -0
- package/dist/core/repomap.d.ts.map +1 -0
- package/dist/core/repomap.js +897 -0
- package/dist/core/repomap.js.map +1 -0
- package/dist/core/repomap.test.d.ts +2 -0
- package/dist/core/repomap.test.d.ts.map +1 -0
- package/dist/core/repomap.test.js +444 -0
- package/dist/core/repomap.test.js.map +1 -0
- package/dist/core/session-compaction.d.ts +15 -0
- package/dist/core/session-compaction.d.ts.map +1 -0
- package/dist/core/session-compaction.js +31 -0
- package/dist/core/session-compaction.js.map +1 -0
- package/dist/core/session-compaction.test.d.ts +2 -0
- package/dist/core/session-compaction.test.d.ts.map +1 -0
- package/dist/core/session-compaction.test.js +70 -0
- package/dist/core/session-compaction.test.js.map +1 -0
- package/dist/core/settings-manager.d.ts +3 -5
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +6 -5
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/slash-commands.d.ts +2 -0
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +15 -14
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/style-packs/index.d.ts.map +1 -1
- package/dist/core/style-packs/index.js +8 -9
- package/dist/core/style-packs/index.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/interactive.d.ts.map +1 -1
- package/dist/interactive.js +12 -6
- package/dist/interactive.js.map +1 -1
- package/dist/modes/json-mode.d.ts +7 -0
- package/dist/modes/json-mode.d.ts.map +1 -1
- package/dist/modes/json-mode.js +9 -1
- package/dist/modes/json-mode.js.map +1 -1
- package/dist/system-prompt.d.ts.map +1 -1
- package/dist/system-prompt.js +105 -108
- package/dist/system-prompt.js.map +1 -1
- package/dist/system-prompt.test.d.ts +2 -0
- package/dist/system-prompt.test.d.ts.map +1 -0
- package/dist/system-prompt.test.js +107 -0
- package/dist/system-prompt.test.js.map +1 -0
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +1 -0
- package/dist/tools/bash.js.map +1 -1
- package/dist/tools/edit-diff.d.ts +66 -1
- package/dist/tools/edit-diff.d.ts.map +1 -1
- package/dist/tools/edit-diff.js +208 -10
- package/dist/tools/edit-diff.js.map +1 -1
- package/dist/tools/edit-diff.test.js +175 -15
- package/dist/tools/edit-diff.test.js.map +1 -1
- package/dist/tools/edit.d.ts +3 -1
- package/dist/tools/edit.d.ts.map +1 -1
- package/dist/tools/edit.js +190 -44
- package/dist/tools/edit.js.map +1 -1
- package/dist/tools/edit.test.js +392 -3
- package/dist/tools/edit.test.js.map +1 -1
- package/dist/tools/enter-plan.d.ts.map +1 -1
- package/dist/tools/enter-plan.js +1 -0
- package/dist/tools/enter-plan.js.map +1 -1
- package/dist/tools/exit-plan.d.ts.map +1 -1
- package/dist/tools/exit-plan.js +1 -0
- package/dist/tools/exit-plan.js.map +1 -1
- package/dist/tools/index.d.ts +13 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +4 -4
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/prompt-hints.d.ts.map +1 -1
- package/dist/tools/prompt-hints.js +6 -4
- package/dist/tools/prompt-hints.js.map +1 -1
- package/dist/tools/read.d.ts +1 -1
- package/dist/tools/read.d.ts.map +1 -1
- package/dist/tools/read.js +2 -1
- package/dist/tools/read.js.map +1 -1
- package/dist/tools/subagent.d.ts +1 -1
- package/dist/tools/subagent.d.ts.map +1 -1
- package/dist/tools/subagent.js +55 -2
- package/dist/tools/subagent.js.map +1 -1
- package/dist/tools/tasks.d.ts.map +1 -1
- package/dist/tools/tasks.js +1 -0
- package/dist/tools/tasks.js.map +1 -1
- package/dist/tools/web-fetch.d.ts +1 -0
- package/dist/tools/web-fetch.d.ts.map +1 -1
- package/dist/tools/web-fetch.js +96 -6
- package/dist/tools/web-fetch.js.map +1 -1
- package/dist/tools/web-fetch.test.d.ts +2 -0
- package/dist/tools/web-fetch.test.d.ts.map +1 -0
- package/dist/tools/web-fetch.test.js +90 -0
- package/dist/tools/web-fetch.test.js.map +1 -0
- package/dist/tools/web-search.d.ts +1 -0
- package/dist/tools/web-search.d.ts.map +1 -1
- package/dist/tools/web-search.js +167 -27
- package/dist/tools/web-search.js.map +1 -1
- package/dist/tools/web-search.test.d.ts +2 -0
- package/dist/tools/web-search.test.d.ts.map +1 -0
- package/dist/tools/web-search.test.js +119 -0
- package/dist/tools/web-search.test.js.map +1 -0
- package/dist/tools/write.d.ts +1 -1
- package/dist/tools/write.d.ts.map +1 -1
- package/dist/tools/write.js +3 -1
- package/dist/tools/write.js.map +1 -1
- package/dist/tools/write.test.js +23 -0
- package/dist/tools/write.test.js.map +1 -1
- package/dist/ui/App.d.ts +54 -5
- package/dist/ui/App.d.ts.map +1 -1
- package/dist/ui/App.js +533 -241
- package/dist/ui/App.js.map +1 -1
- package/dist/ui/activity-phrases.d.ts +2 -1
- package/dist/ui/activity-phrases.d.ts.map +1 -1
- package/dist/ui/activity-phrases.js +11 -1
- package/dist/ui/activity-phrases.js.map +1 -1
- package/dist/ui/components/ActivityIndicator.d.ts +15 -1
- package/dist/ui/components/ActivityIndicator.d.ts.map +1 -1
- package/dist/ui/components/ActivityIndicator.js +143 -44
- package/dist/ui/components/ActivityIndicator.js.map +1 -1
- package/dist/ui/components/ActivityIndicator.test.d.ts +2 -0
- package/dist/ui/components/ActivityIndicator.test.d.ts.map +1 -0
- package/dist/ui/components/ActivityIndicator.test.js +40 -0
- package/dist/ui/components/ActivityIndicator.test.js.map +1 -0
- package/dist/ui/components/AnimationContext.d.ts +8 -2
- package/dist/ui/components/AnimationContext.d.ts.map +1 -1
- package/dist/ui/components/AnimationContext.js +94 -16
- package/dist/ui/components/AnimationContext.js.map +1 -1
- package/dist/ui/components/AssistantMessage.js +1 -1
- package/dist/ui/components/AssistantMessage.js.map +1 -1
- package/dist/ui/components/CompactionNotice.d.ts +5 -1
- package/dist/ui/components/CompactionNotice.d.ts.map +1 -1
- package/dist/ui/components/CompactionNotice.js +4 -6
- package/dist/ui/components/CompactionNotice.js.map +1 -1
- package/dist/ui/components/Footer.d.ts +10 -2
- package/dist/ui/components/Footer.d.ts.map +1 -1
- package/dist/ui/components/Footer.js +45 -8
- package/dist/ui/components/Footer.js.map +1 -1
- package/dist/ui/components/InputArea.d.ts.map +1 -1
- package/dist/ui/components/InputArea.js +76 -28
- package/dist/ui/components/InputArea.js.map +1 -1
- package/dist/ui/components/ServerToolExecution.d.ts +1 -0
- package/dist/ui/components/ServerToolExecution.d.ts.map +1 -1
- package/dist/ui/components/ServerToolExecution.js +21 -2
- package/dist/ui/components/ServerToolExecution.js.map +1 -1
- package/dist/ui/components/Spinner.d.ts +3 -1
- package/dist/ui/components/Spinner.d.ts.map +1 -1
- package/dist/ui/components/Spinner.js +10 -4
- package/dist/ui/components/Spinner.js.map +1 -1
- package/dist/ui/components/StreamingArea.js +1 -1
- package/dist/ui/components/StreamingArea.js.map +1 -1
- package/dist/ui/components/SubAgentPanel.d.ts.map +1 -1
- package/dist/ui/components/SubAgentPanel.js +3 -4
- package/dist/ui/components/SubAgentPanel.js.map +1 -1
- package/dist/ui/components/ToolExecution.d.ts +2 -0
- package/dist/ui/components/ToolExecution.d.ts.map +1 -1
- package/dist/ui/components/ToolExecution.js +24 -5
- package/dist/ui/components/ToolExecution.js.map +1 -1
- package/dist/ui/components/ToolGroupExecution.d.ts.map +1 -1
- package/dist/ui/components/ToolGroupExecution.js +23 -2
- package/dist/ui/components/ToolGroupExecution.js.map +1 -1
- package/dist/ui/components/ToolUseLoader.d.ts +4 -2
- package/dist/ui/components/ToolUseLoader.d.ts.map +1 -1
- package/dist/ui/components/ToolUseLoader.js +3 -3
- package/dist/ui/components/ToolUseLoader.js.map +1 -1
- package/dist/ui/components/index.d.ts +1 -2
- package/dist/ui/components/index.d.ts.map +1 -1
- package/dist/ui/components/index.js +1 -2
- package/dist/ui/components/index.js.map +1 -1
- package/dist/ui/hooks/useAgentLoop.d.ts +4 -1
- package/dist/ui/hooks/useAgentLoop.d.ts.map +1 -1
- package/dist/ui/hooks/useAgentLoop.js +110 -13
- package/dist/ui/hooks/useAgentLoop.js.map +1 -1
- package/dist/ui/hooks/useBlink.d.ts.map +1 -1
- package/dist/ui/hooks/useBlink.js +3 -4
- package/dist/ui/hooks/useBlink.js.map +1 -1
- package/dist/ui/hooks/useTerminalSize.d.ts +12 -3
- package/dist/ui/hooks/useTerminalSize.d.ts.map +1 -1
- package/dist/ui/hooks/useTerminalSize.js +16 -1
- package/dist/ui/hooks/useTerminalSize.js.map +1 -1
- package/dist/ui/pixel.js +1 -1
- package/dist/ui/render.d.ts +44 -5
- package/dist/ui/render.d.ts.map +1 -1
- package/dist/ui/render.js +56 -8
- package/dist/ui/render.js.map +1 -1
- package/dist/utils/error-handler.d.ts.map +1 -1
- package/dist/utils/error-handler.js +2 -0
- package/dist/utils/error-handler.js.map +1 -1
- package/package.json +8 -5
- package/dist/ui/buddy/Buddy.d.ts +0 -15
- package/dist/ui/buddy/Buddy.d.ts.map +0 -1
- package/dist/ui/buddy/Buddy.js +0 -118
- package/dist/ui/buddy/Buddy.js.map +0 -1
- package/dist/ui/buddy/gacha.d.ts +0 -8
- package/dist/ui/buddy/gacha.d.ts.map +0 -1
- package/dist/ui/buddy/gacha.js +0 -94
- package/dist/ui/buddy/gacha.js.map +0 -1
- package/dist/ui/buddy/species.d.ts +0 -52
- package/dist/ui/buddy/species.d.ts.map +0 -1
- package/dist/ui/buddy/species.js +0 -257
- package/dist/ui/buddy/species.js.map +0 -1
- package/dist/ui/components/ThinkingIndicator.d.ts +0 -6
- package/dist/ui/components/ThinkingIndicator.d.ts.map +0 -1
- package/dist/ui/components/ThinkingIndicator.js +0 -145
- package/dist/ui/components/ThinkingIndicator.js.map +0 -1
package/dist/system-prompt.js
CHANGED
|
@@ -6,21 +6,14 @@ import { TOOL_PROMPT_HINTS, DEFAULT_TOOL_NAMES } from "./tools/prompt-hints.js";
|
|
|
6
6
|
import { renderStylePacksSection } from "./core/style-packs/index.js";
|
|
7
7
|
import { detectVerifyCommands, renderVerifySection } from "./core/verify-commands.js";
|
|
8
8
|
const CONTEXT_FILES = ["AGENTS.md", "CLAUDE.md", ".cursorrules", "CONVENTIONS.md"];
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* @param toolNames — if provided, the Tools section only lists these tools.
|
|
13
|
-
* Pass `tools.map(t => t.name)` from the session so the prompt reflects
|
|
14
|
-
* exactly what the model can call. Defaults to the full built-in set.
|
|
15
|
-
*/
|
|
16
|
-
export async function buildSystemPrompt(cwd, skills, planMode, approvedPlanPath, toolNames, activeLanguages) {
|
|
17
|
-
const sections = [];
|
|
18
|
-
// 1. Identity
|
|
19
|
-
sections.push(`You are EZ Coder by Nolan Grout — a coding agent that works directly in the user's codebase. ` +
|
|
9
|
+
const UNCACHED_MARKER = "<!-- uncached -->";
|
|
10
|
+
function renderIdentitySection() {
|
|
11
|
+
return (`You are EZ Coder by Nolan Grout — a coding agent that works directly in the user's codebase. ` +
|
|
20
12
|
`You explore, understand, change, and verify code — completing tasks end-to-end ` +
|
|
21
13
|
`rather than just suggesting edits.`);
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
}
|
|
15
|
+
function renderTalkSection() {
|
|
16
|
+
return (`## How to Talk\n\n` +
|
|
24
17
|
`**Between tool calls**: one short sentence max — what you're doing next. ` +
|
|
25
18
|
`No quoting tool output, no restating the problem, no thinking out loud. Think silently, then act.\n\n` +
|
|
26
19
|
`**Final replies**: 1–3 sentences, hard cap 5. No preamble, no recap, no "let me know if…". ` +
|
|
@@ -31,81 +24,72 @@ export async function buildSystemPrompt(cwd, skills, planMode, approvedPlanPath,
|
|
|
31
24
|
`Good: "Found it — forms.css global rule out-specifies mine. Fixing." [edit]\n\n` +
|
|
32
25
|
`**Exceptions**: ask before destructive actions, surface real tradeoffs, admit unverified claims. ` +
|
|
33
26
|
`Plan mode is exempt.`);
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
}
|
|
28
|
+
function renderWorkSection() {
|
|
29
|
+
return (`## How to Work\n\n` +
|
|
36
30
|
`- **Read before \`edit\`/\`write\`.** No edit/write without a prior read this session — missed reads waste the payload.\n` +
|
|
31
|
+
`- **Re-read after mutating tools.** Anything that rewrites files on disk (formatter, \`lint --fix\`, codemods, codegen, \`git checkout --\`) invalidates your cached view. Read the file again before the next \`edit\`/\`write\` — stale \`old_string\` matches fail, or worse, silently overwrite the mutation.\n` +
|
|
32
|
+
`- **Compute in bash, write with \`edit\`.** When a task needs computation (word counts, regex, padding, structural validation), use bash for the computation and the \`edit\` tool to apply the result. Shelling out to \`python -c '... f.write(...)'\` or \`sed -i\` loses read-tracking, partial-apply, indent forgiveness, and actionable error messages — and a mid-script crash leaves the file in unknown state.\n` +
|
|
37
33
|
`- **Match the neighbors.** Before any user-visible change: find the closest existing equivalent, reuse components/tokens, mirror tone. No sibling? Stop and ask. Generic-looking output is a regression.\n` +
|
|
38
34
|
`- **Edits stay small.** Plan multi-file work first. After: run tests/typecheck/lint, read errors, rebuild.\n` +
|
|
39
35
|
`- **Just do it.** Routine follow-up (build, migrate, seed, re-run) is yours — don't ask.\n` +
|
|
40
36
|
`- **Ask first for destructive actions**: deleting files, force-push, dropping data, killing processes, \`rm -rf\`, \`--hard\`, \`--force\`.\n` +
|
|
41
37
|
`- **Investigate unexpected state** (unfamiliar files, branches, locks) — may be the user's in-progress work.\n` +
|
|
42
|
-
`- **Precedence when rules conflict** (highest first): CLAUDE.md /
|
|
38
|
+
`- **Precedence when rules conflict** (highest first): AGENTS.md / CLAUDE.md / .cursorrules / CONVENTIONS.md → existing patterns in the edited file/module → Language Style Packs → defaults in this prompt.\n` +
|
|
43
39
|
`- **Verify after meaningful edits.** When a Verification section is present, run the relevant commands for the language(s) you touched. Fix failures before reporting completion.\n` +
|
|
44
40
|
`- **Untracked files → \`.gitignore\`**: artifacts, configs, secrets, logs, scratch, \`.env\`, caches.\n` +
|
|
45
41
|
`- **Never fake verification.** If you didn't run the check or it failed, say so. Don't invent results.`);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (approvedPlanPath
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
`- **
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
` 2. A known identifier/prop/hook — \`useVideoConfig\`, \`interpolate(\`, \`<Sequence\`, \`SubtitlePage\`\n` +
|
|
89
|
-
` 3. A unique config key — \`"defaultExport":\`, \`assetsInclude:\`\n` +
|
|
90
|
-
` Bad: \`karaoke word animation subtitle\` → zero hits, every time. Good: \`from "@remotion/captions"\` + \`peek: true\` → real files; then narrow with \`repo\` + \`path\` and read them.\n` +
|
|
91
|
-
` - **Filename + topic ≠ query.** \`Page.tsx tiktok\` won't match. Use \`path: "Page.tsx"\` + \`repo: "remotion-dev"\` + a literal token in \`query\`.\n` +
|
|
92
|
-
` - Filters: \`language: ["TypeScript"]\`, \`repo: "owner/name"\` (substring), \`path: "src/components/"\` (substring), \`matchCase\`, \`useRegexp\`.\n` +
|
|
93
|
-
` - Workflow: \`peek: true\` first → paths + match counts only (cheap triage). Then call again narrowed by \`repo\` + \`path\` for full snippets. Paginate with \`offset\`.\n` +
|
|
94
|
-
` - Defaults exclude tests, \`node_modules\`, vendored, build, and generated files — pass \`includeTests: true\` or \`includeVendored: true\` to widen.\n` +
|
|
95
|
-
` - Token budget: \`maxResults\` defaults to 10 (cap 200), \`contextLines\` defaults to 5 (range 0–20). Keep both small unless you need more.\n` +
|
|
96
|
-
` - RE2 regex only: no lookahead/lookbehind/backrefs; multi-line patterns need \`(?s)\` prefix.\n` +
|
|
97
|
-
`- Applies to everything — APIs, CLI flags, configs (vite.config.ts, package.json, Dockerfile, GH Actions), shell idioms, schema shapes, error wording, conventions. Not just "unfamiliar" code.`);
|
|
98
|
-
// 4. Code Quality
|
|
99
|
-
sections.push(`## Code Quality\n\n` +
|
|
42
|
+
}
|
|
43
|
+
function renderPlanModeSection() {
|
|
44
|
+
return (`## Plan Mode (ACTIVE)\n\n` +
|
|
45
|
+
`You are in PLAN MODE. Research and design an implementation plan before writing any code.\n\n` +
|
|
46
|
+
`### Workflow\n` +
|
|
47
|
+
`1. Explore: read, grep, find, ls to understand the codebase\n` +
|
|
48
|
+
`2. Research: \`web_search\` + \`web_fetch\` for docs; for real code, use Explore to discover candidate repos/files/anchors, then SearchCode to verify exact snippets (full usage below)\n` +
|
|
49
|
+
`3. Draft: write the plan to .ezcoder/plans/<name>.md\n` +
|
|
50
|
+
`4. Submit: call exit_plan with the plan path\n\n` +
|
|
51
|
+
`### Rules\n` +
|
|
52
|
+
`- bash, edit, write (except to .ezcoder/plans/), and subagent are restricted\n` +
|
|
53
|
+
`- Be specific: exact file paths, function names, line numbers\n` +
|
|
54
|
+
`- Note risks and verification criteria\n\n` +
|
|
55
|
+
`### Plan Format\n` +
|
|
56
|
+
`Plan can have any structure, but it MUST end with a section titled exactly \`## Steps\` ` +
|
|
57
|
+
`containing a single flat numbered list. This section is parsed by the progress widget — ` +
|
|
58
|
+
`the ONLY source of truth for step tracking. Do NOT put numbered lists elsewhere.`);
|
|
59
|
+
}
|
|
60
|
+
async function renderApprovedPlanSection(approvedPlanPath, planMode) {
|
|
61
|
+
if (!approvedPlanPath || planMode)
|
|
62
|
+
return null;
|
|
63
|
+
const planContent = await fs.readFile(approvedPlanPath, "utf-8").catch(() => null);
|
|
64
|
+
if (planContent === null)
|
|
65
|
+
return null;
|
|
66
|
+
if (!planContent.trim())
|
|
67
|
+
return null;
|
|
68
|
+
return (`## Approved Plan\n\n` +
|
|
69
|
+
`Follow this plan strictly. File: ${approvedPlanPath}\n\n` +
|
|
70
|
+
`<approved_plan>\n${planContent.trim()}\n</approved_plan>\n\n` +
|
|
71
|
+
`- Follow step order. Don't deviate without user confirmation.\n` +
|
|
72
|
+
`- After each step from \`## Steps\`, output \`[DONE:n]\` (e.g. \`[DONE:1]\`) to update the progress widget, then continue with step n+1 in the same turn.`);
|
|
73
|
+
}
|
|
74
|
+
function renderResearchSection() {
|
|
75
|
+
return (`## Research & Verification\n\n` +
|
|
76
|
+
`Do not assume current APIs, CLI flags, config schema, or error wording — verify.\n\n` +
|
|
77
|
+
`- **Docs first**: use \`web_search\` to find authoritative pages, then \`web_fetch\` to read them.\n` +
|
|
78
|
+
`- **Public code samples**: use \`mcp__kencode-search__exploreCodeSamples\` once early for examples/patterns/ideas/best practices or vague concepts. Treat it as anchor discovery: read its recommended options and copy 3–5 of its follow-up \`searchCode\` calls before inventing new queries.\n` +
|
|
79
|
+
`- **Exact code search**: use \`mcp__kencode-search__searchCode\` to verify snippets by literal text or RE2 regex only — NOT semantic search. Put code tokens in \`query\`; use \`path\` only for literal file-path substrings and \`repo\` only after a broad/peek search proves the anchor exists. Report Explore-only results as candidates, SearchCode results as verified code.\n` +
|
|
80
|
+
`- **Verify after edits**: run relevant checks, read failures, fix them, and never report unrun or failing checks as passing.`);
|
|
81
|
+
}
|
|
82
|
+
function renderCodeQualitySection() {
|
|
83
|
+
return (`## Code Quality\n\n` +
|
|
100
84
|
`- Descriptive names that reveal intent. Define types before implementation.\n` +
|
|
101
85
|
`- No dead code, no commented-out code. No stubs or placeholders unless asked.\n` +
|
|
102
86
|
`- Handle errors at I/O, user input, and external API boundaries.\n` +
|
|
103
87
|
`- Prefer existing dependencies. Don't refactor or reorganize unprompted.`);
|
|
104
|
-
|
|
88
|
+
}
|
|
89
|
+
function renderToolsSection(toolNames, planMode) {
|
|
105
90
|
const activeTools = toolNames ?? DEFAULT_TOOL_NAMES;
|
|
106
91
|
const toolLines = [];
|
|
107
92
|
for (const name of activeTools) {
|
|
108
|
-
// In plan mode, hide enter_plan (already entered); outside plan mode, hide exit_plan.
|
|
109
93
|
if (planMode && name === "enter_plan")
|
|
110
94
|
continue;
|
|
111
95
|
if (!planMode && name === "exit_plan")
|
|
@@ -114,10 +98,9 @@ export async function buildSystemPrompt(cwd, skills, planMode, approvedPlanPath,
|
|
|
114
98
|
if (hint)
|
|
115
99
|
toolLines.push(`- **${name}**: ${hint}`);
|
|
116
100
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
// 6. Project context — walk from cwd to root looking for context files
|
|
101
|
+
return toolLines.length > 0 ? `## Tools\n\n${toolLines.join("\n")}` : null;
|
|
102
|
+
}
|
|
103
|
+
async function collectProjectContext(cwd) {
|
|
121
104
|
const contextParts = [];
|
|
122
105
|
let dir = cwd;
|
|
123
106
|
const visited = new Set();
|
|
@@ -131,7 +114,7 @@ export async function buildSystemPrompt(cwd, skills, planMode, approvedPlanPath,
|
|
|
131
114
|
contextParts.push(`### ${relPath}\n\n${content.trim()}`);
|
|
132
115
|
}
|
|
133
116
|
catch {
|
|
134
|
-
// File doesn't exist, skip
|
|
117
|
+
// File doesn't exist, skip.
|
|
135
118
|
}
|
|
136
119
|
}
|
|
137
120
|
const parent = path.dirname(dir);
|
|
@@ -139,29 +122,56 @@ export async function buildSystemPrompt(cwd, skills, planMode, approvedPlanPath,
|
|
|
139
122
|
break;
|
|
140
123
|
dir = parent;
|
|
141
124
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
125
|
+
return contextParts;
|
|
126
|
+
}
|
|
127
|
+
function renderProjectContextSection(contextParts) {
|
|
128
|
+
if (contextParts.length === 0)
|
|
129
|
+
return null;
|
|
130
|
+
return (`## Project Context\n\n` +
|
|
131
|
+
`**Highest precedence** — AGENTS.md / CLAUDE.md override Language Style Packs and all default guidance. ` +
|
|
132
|
+
`When these files conflict with anything else in this prompt, follow the project file.\n\n` +
|
|
133
|
+
contextParts.join("\n\n"));
|
|
134
|
+
}
|
|
135
|
+
function renderEnvironmentSection(cwd) {
|
|
136
|
+
return `## Environment\n\n- Working directory: ${cwd}\n- Platform: ${process.platform}`;
|
|
137
|
+
}
|
|
138
|
+
function renderUncachedDateSuffix() {
|
|
139
|
+
const today = new Date();
|
|
140
|
+
const day = today.getDate();
|
|
141
|
+
const month = today.toLocaleString("en-US", { month: "long" });
|
|
142
|
+
const year = today.getFullYear();
|
|
143
|
+
return `${UNCACHED_MARKER}\nToday's date: ${day} ${month} ${year}`;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Build the system prompt dynamically based on cwd and context.
|
|
147
|
+
*
|
|
148
|
+
* @param toolNames — if provided, the Tools section only lists these tools.
|
|
149
|
+
* Pass `tools.map(t => t.name)` from the session so the prompt reflects
|
|
150
|
+
* exactly what the model can call. Defaults to the full built-in set.
|
|
151
|
+
*/
|
|
152
|
+
export async function buildSystemPrompt(cwd, skills, planMode, approvedPlanPath, toolNames, activeLanguages) {
|
|
153
|
+
const sections = [renderIdentitySection(), renderTalkSection(), renderWorkSection()];
|
|
154
|
+
if (planMode)
|
|
155
|
+
sections.push(renderPlanModeSection());
|
|
156
|
+
const approvedPlanSection = await renderApprovedPlanSection(approvedPlanPath, planMode);
|
|
157
|
+
if (approvedPlanSection)
|
|
158
|
+
sections.push(approvedPlanSection);
|
|
159
|
+
sections.push(renderResearchSection(), renderCodeQualitySection());
|
|
160
|
+
const toolsSection = renderToolsSection(toolNames, planMode);
|
|
161
|
+
if (toolsSection)
|
|
162
|
+
sections.push(toolsSection);
|
|
163
|
+
const projectContextSection = renderProjectContextSection(await collectProjectContext(cwd));
|
|
164
|
+
if (projectContextSection)
|
|
165
|
+
sections.push(projectContextSection);
|
|
151
166
|
if (activeLanguages && activeLanguages.size > 0) {
|
|
152
167
|
const stylePacks = renderStylePacksSection(activeLanguages, cwd);
|
|
153
168
|
if (stylePacks)
|
|
154
169
|
sections.push(stylePacks);
|
|
155
|
-
// 6c. Verification — detected commands for the active languages, so the
|
|
156
|
-
// agent can close the feedback loop after pack-influenced edits. Without
|
|
157
|
-
// this anchor, packs are advisory; with it, the model has concrete
|
|
158
|
-
// commands to run and verify against.
|
|
159
170
|
const verifyCmds = detectVerifyCommands(cwd, activeLanguages);
|
|
160
171
|
const verifySection = renderVerifySection(verifyCmds);
|
|
161
172
|
if (verifySection)
|
|
162
173
|
sections.push(verifySection);
|
|
163
174
|
}
|
|
164
|
-
// 7. Eyes — open improvement signals from past probe use (gated on .ezcoder/eyes/manifest.json)
|
|
165
175
|
if (isEyesActive(cwd)) {
|
|
166
176
|
const open = readJournal({ status: "open", order: "desc", limit: 10 }, cwd);
|
|
167
177
|
if (open.length > 0) {
|
|
@@ -171,30 +181,17 @@ export async function buildSystemPrompt(cwd, skills, planMode, approvedPlanPath,
|
|
|
171
181
|
return `- ${date} · *${e.kind}*${probeTag}: ${e.reason}`;
|
|
172
182
|
});
|
|
173
183
|
sections.push(`## Eyes — Open Improvement Signals\n\n` +
|
|
174
|
-
`These
|
|
175
|
-
`
|
|
176
|
-
`inadequate capability would force you to **guess, skip verification, or hand-wave**, ` +
|
|
177
|
-
`surface the tradeoff in conversation rather than working around it silently — give the ` +
|
|
178
|
-
`user the choice to fix the probe first.\n\n` +
|
|
184
|
+
`These unresolved signals from this project's perception probes (\`.ezcoder/eyes/\`) may bear on the work. ` +
|
|
185
|
+
`If a missing capability would force guessing or skipped verification, surface the tradeoff instead.\n\n` +
|
|
179
186
|
lines.join("\n"));
|
|
180
187
|
}
|
|
181
188
|
}
|
|
182
|
-
// 9. Skills
|
|
183
189
|
if (skills && skills.length > 0) {
|
|
184
190
|
const skillsSection = formatSkillsForPrompt(skills);
|
|
185
|
-
if (skillsSection)
|
|
191
|
+
if (skillsSection)
|
|
186
192
|
sections.push(skillsSection);
|
|
187
|
-
}
|
|
188
193
|
}
|
|
189
|
-
|
|
190
|
-
sections.push(`## Environment\n\n` + `- Working directory: ${cwd}\n` + `- Platform: ${process.platform}`);
|
|
191
|
-
// Dynamic section (uncached) — separated by marker so the transform layer
|
|
192
|
-
// can split the system prompt into cached + uncached blocks.
|
|
193
|
-
const today = new Date();
|
|
194
|
-
const day = today.getDate();
|
|
195
|
-
const month = today.toLocaleString("en-US", { month: "long" });
|
|
196
|
-
const year = today.getFullYear();
|
|
197
|
-
sections.push(`<!-- uncached -->\nToday's date: ${day} ${month} ${year}`);
|
|
194
|
+
sections.push(renderEnvironmentSection(cwd), renderUncachedDateSuffix());
|
|
198
195
|
return sections.join("\n\n");
|
|
199
196
|
}
|
|
200
197
|
//# sourceMappingURL=system-prompt.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../src/system-prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,W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@ -0,0 +1,107 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
5
|
+
import { buildSystemPrompt } from "./system-prompt.js";
|
|
6
|
+
const tempDirs = [];
|
|
7
|
+
async function makeProject(files = {}) {
|
|
8
|
+
const cwd = await fs.mkdtemp(path.join(os.tmpdir(), "ezcoder-system-prompt-"));
|
|
9
|
+
tempDirs.push(cwd);
|
|
10
|
+
for (const [relativePath, content] of Object.entries(files)) {
|
|
11
|
+
const filePath = path.join(cwd, relativePath);
|
|
12
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
13
|
+
await fs.writeFile(filePath, content, "utf-8");
|
|
14
|
+
}
|
|
15
|
+
return cwd;
|
|
16
|
+
}
|
|
17
|
+
function sectionIndex(prompt, heading) {
|
|
18
|
+
const index = prompt.indexOf(heading);
|
|
19
|
+
expect(index, `${heading} should exist`).toBeGreaterThanOrEqual(0);
|
|
20
|
+
return index;
|
|
21
|
+
}
|
|
22
|
+
function toolsSection(prompt) {
|
|
23
|
+
const start = sectionIndex(prompt, "## Tools");
|
|
24
|
+
const rest = prompt.slice(start);
|
|
25
|
+
const next = rest.indexOf("\n\n## ", "## Tools".length);
|
|
26
|
+
return next === -1 ? rest : rest.slice(0, next);
|
|
27
|
+
}
|
|
28
|
+
afterEach(async () => {
|
|
29
|
+
await Promise.all(tempDirs.splice(0).map((dir) => fs.rm(dir, { recursive: true, force: true })));
|
|
30
|
+
});
|
|
31
|
+
describe("buildSystemPrompt", () => {
|
|
32
|
+
it("renders deterministic section order and keeps only the volatile date after the marker", async () => {
|
|
33
|
+
const cwd = await makeProject({
|
|
34
|
+
"CLAUDE.md": "Project rules win.",
|
|
35
|
+
"package.json": JSON.stringify({ scripts: { check: "tsc --noEmit" } }),
|
|
36
|
+
"tsconfig.json": "{}",
|
|
37
|
+
});
|
|
38
|
+
const prompt = await buildSystemPrompt(cwd, [{ name: "find-skills", description: "Find skills.", content: "", source: "test" }], false, undefined, ["read", "edit", "web_search", "enter_plan", "exit_plan", "skill"], new Set(["typescript"]));
|
|
39
|
+
expect(prompt.startsWith("You are EZ Coder by Nolan Grout")).toBe(true);
|
|
40
|
+
expect(sectionIndex(prompt, "## How to Talk")).toBeLessThan(sectionIndex(prompt, "## How to Work"));
|
|
41
|
+
expect(sectionIndex(prompt, "## How to Work")).toBeLessThan(sectionIndex(prompt, "## Research & Verification"));
|
|
42
|
+
expect(sectionIndex(prompt, "## Research & Verification")).toBeLessThan(sectionIndex(prompt, "## Code Quality"));
|
|
43
|
+
expect(sectionIndex(prompt, "## Code Quality")).toBeLessThan(sectionIndex(prompt, "## Tools"));
|
|
44
|
+
expect(sectionIndex(prompt, "## Tools")).toBeLessThan(sectionIndex(prompt, "## Project Context"));
|
|
45
|
+
expect(sectionIndex(prompt, "## Project Context")).toBeLessThan(sectionIndex(prompt, "## Language Style Packs"));
|
|
46
|
+
expect(sectionIndex(prompt, "## Language Style Packs")).toBeLessThan(sectionIndex(prompt, "## Verification"));
|
|
47
|
+
expect(sectionIndex(prompt, "## Verification")).toBeLessThan(sectionIndex(prompt, "## Skills"));
|
|
48
|
+
expect(sectionIndex(prompt, "## Skills")).toBeLessThan(sectionIndex(prompt, "## Environment"));
|
|
49
|
+
const marker = "<!-- uncached -->";
|
|
50
|
+
expect(prompt.match(new RegExp(marker, "g"))).toHaveLength(1);
|
|
51
|
+
const afterMarker = prompt.slice(prompt.indexOf(marker) + marker.length).trim();
|
|
52
|
+
expect(afterMarker).toMatch(/^Today's date: \d{1,2} [A-Za-z]+ \d{4}$/);
|
|
53
|
+
});
|
|
54
|
+
it("lists exactly available known tools and hides unavailable plan transition tools", async () => {
|
|
55
|
+
const cwd = await makeProject();
|
|
56
|
+
const normalPrompt = await buildSystemPrompt(cwd, undefined, false, undefined, [
|
|
57
|
+
"read",
|
|
58
|
+
"web_search",
|
|
59
|
+
"exit_plan",
|
|
60
|
+
"not_a_tool",
|
|
61
|
+
]);
|
|
62
|
+
const normalTools = toolsSection(normalPrompt);
|
|
63
|
+
expect(normalTools).toContain("**read**");
|
|
64
|
+
expect(normalTools).toContain("**web_search**");
|
|
65
|
+
expect(normalTools).not.toContain("**exit_plan**");
|
|
66
|
+
expect(normalTools).not.toContain("not_a_tool");
|
|
67
|
+
expect(normalTools).not.toContain("**edit**");
|
|
68
|
+
const planPrompt = await buildSystemPrompt(cwd, undefined, true, undefined, [
|
|
69
|
+
"read",
|
|
70
|
+
"enter_plan",
|
|
71
|
+
"exit_plan",
|
|
72
|
+
]);
|
|
73
|
+
const planTools = toolsSection(planPrompt);
|
|
74
|
+
expect(planTools).toContain("**read**");
|
|
75
|
+
expect(planTools).toContain("**exit_plan**");
|
|
76
|
+
expect(planTools).not.toContain("**enter_plan**");
|
|
77
|
+
});
|
|
78
|
+
it("places project-context precedence next to project context before style packs", async () => {
|
|
79
|
+
const cwd = await makeProject({
|
|
80
|
+
"AGENTS.md": "Use tabs for this fixture.",
|
|
81
|
+
"tsconfig.json": "{}",
|
|
82
|
+
});
|
|
83
|
+
const prompt = await buildSystemPrompt(cwd, undefined, false, undefined, ["read"], new Set(["typescript"]));
|
|
84
|
+
const projectContextIndex = sectionIndex(prompt, "## Project Context");
|
|
85
|
+
const precedenceIndex = prompt.indexOf("**Highest precedence**", projectContextIndex);
|
|
86
|
+
expect(precedenceIndex).toBeGreaterThan(projectContextIndex);
|
|
87
|
+
expect(precedenceIndex).toBeLessThan(sectionIndex(prompt, "### AGENTS.md"));
|
|
88
|
+
expect(sectionIndex(prompt, "## Project Context")).toBeLessThan(sectionIndex(prompt, "## Language Style Packs"));
|
|
89
|
+
expect(prompt).toContain("AGENTS.md / CLAUDE.md override Language Style Packs");
|
|
90
|
+
});
|
|
91
|
+
it("keeps kencode guidance concise while separating exploration from exact search", async () => {
|
|
92
|
+
const cwd = await makeProject();
|
|
93
|
+
const prompt = await buildSystemPrompt(cwd, undefined, false, undefined, [
|
|
94
|
+
"mcp__kencode-search__exploreCodeSamples",
|
|
95
|
+
"mcp__kencode-search__searchCode",
|
|
96
|
+
]);
|
|
97
|
+
const tools = toolsSection(prompt);
|
|
98
|
+
expect(tools).toContain("discover candidate repos/files and literal anchors");
|
|
99
|
+
expect(tools).toContain("follow-up searchCode calls");
|
|
100
|
+
expect(tools).toContain("literal text or RE2 regex");
|
|
101
|
+
expect(tools).toContain("NOT semantic");
|
|
102
|
+
expect(tools).toContain("path` is a literal file-path substring");
|
|
103
|
+
expect(tools).not.toContain("zero hits, every time");
|
|
104
|
+
expect(tools.length).toBeLessThan(750);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
//# sourceMappingURL=system-prompt.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-prompt.test.js","sourceRoot":"","sources":["../src/system-prompt.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAGvD,MAAM,QAAQ,GAAa,EAAE,CAAC;AAE9B,KAAK,UAAU,WAAW,CAAC,QAAgC,EAAE;IAC3D,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,wBAAwB,CAAC,CAAC,CAAC;IAC/E,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACnB,KAAK,MAAM,CAAC,YAAY,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5D,MAAM,QAAQ,GAAG,IAAI,CAAC,IA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C;QAClE,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,uBAAuB,CAAC,CAAC;QACrD,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/tools/bash.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bash.d.ts","sourceRoot":"","sources":["../../src/tools/bash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAIjE,OAAO,EAAmB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAwDvE,QAAA,MAAM,UAAU;;;;iBAed,CAAC;AAEH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,MAAM,EACX,cAAc,EAAE,cAAc,EAC9B,GAAG,GAAE,cAAgC,EACrC,WAAW,CAAC,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,GACjC,SAAS,CAAC,OAAO,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"bash.d.ts","sourceRoot":"","sources":["../../src/tools/bash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAIjE,OAAO,EAAmB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAwDvE,QAAA,MAAM,UAAU;;;;iBAed,CAAC;AAEH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,MAAM,EACX,cAAc,EAAE,cAAc,EAC9B,GAAG,GAAE,cAAgC,EACrC,WAAW,CAAC,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,GACjC,SAAS,CAAC,OAAO,UAAU,CAAC,CAkH9B"}
|
package/dist/tools/bash.js
CHANGED
|
@@ -80,6 +80,7 @@ export function createBashTool(cwd, processManager, ops = localOperations, planM
|
|
|
80
80
|
"Set run_in_background=true for long-running processes (dev servers, watchers). " +
|
|
81
81
|
"Use task_output/task_stop to interact with background processes.",
|
|
82
82
|
parameters: BashParams,
|
|
83
|
+
executionMode: "sequential",
|
|
83
84
|
async execute({ command, timeout: timeoutMs, run_in_background }, context) {
|
|
84
85
|
if (planModeRef?.current) {
|
|
85
86
|
return "Error: bash is restricted in plan mode. Use read-only tools (read, grep, find, ls) to explore the codebase.";
|
package/dist/tools/bash.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bash.js","sourceRoot":"","sources":["../../src/tools/bash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAuB,MAAM,iBAAiB,CAAC;AAEvE,MAAM,eAAe,GAAG,OAAO,CAAC,CAAC,cAAc;AAC/C,MAAM,gBAAgB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,6CAA6C;AAExF,4GAA4G;AAC5G,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC;IAC5B,MAAM;IACN,MAAM;IACN,MAAM;IACN,SAAS;IACT,OAAO;IACP,MAAM;IACN,QAAQ;IACR,UAAU;IACV,QAAQ;IACR,iBAAiB;IACjB,eAAe;IACf,gBAAgB;IAChB,iBAAiB;IACjB,QAAQ;IACR,QAAQ;IACR,OAAO;IACP,UAAU;IACV,gBA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Aa,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;wBAC9E,MAAM,cAAc,GAAG,YAAY,CAAC,CAAC,CAAC,iBAAiB,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;wBAC3E,MAAM,GAAG,4BAA4B,MAAM,CAAC,SAAS,OAAO,MAAM,CAAC,UAAU,UAAU,cAAc,MAAM,MAAM,EAAE,CAAC;oBACtH,CAAC;oBAED,MAAM,QAAQ,GAAG,QAAQ;wBACvB,CAAC,CAAC,YAAY,gBAAgB,KAAK;wBACnC,CAAC,CAAC,MAAM;4BACN,CAAC,CAAC,QAAQ;4BACV,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC;oBAExB,OAAO,CAAC,cAAc,QAAQ,KAAK,MAAM,EAAE,CAAC,CAAC;gBAC/C,CAAC,CAAC,CAAC;gBAEH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;oBACxB,YAAY,CAAC,KAAK,CAAC,CAAC;oBACpB,OAAO,CAAC,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;oBACrD,OAAO,CAAC,kCAAkC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;gBAC3D,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,3 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Aider's `replace_part_with_missing_leading_whitespace` (~10k stars between
|
|
3
|
+
* aider/devon/codemcp/qwen-coder use this exact pattern). Models very often
|
|
4
|
+
* mess up leading whitespace — uniformly across both old_text and new_text.
|
|
5
|
+
* Strategy:
|
|
6
|
+
* 1. Outdent old/new uniformly by the smallest leading-whitespace count
|
|
7
|
+
* across all non-blank lines (handles "model included some but not all").
|
|
8
|
+
* 2. Scan the file for a window where every line matches when stripped AND
|
|
9
|
+
* the file's actual leading prefix is uniform across non-blank lines.
|
|
10
|
+
* 3. Re-apply that uniform file-prefix to every non-blank line of new_text
|
|
11
|
+
* before substituting.
|
|
12
|
+
*
|
|
13
|
+
* Returns the rewritten file content on success, null when no unique match.
|
|
14
|
+
*/
|
|
15
|
+
export declare function applyMissingLeadingWhitespace(working: string, old: string, next: string): string | null;
|
|
16
|
+
/**
|
|
17
|
+
* Aider-style `...` elision matching: when `old_text` contains lines that are
|
|
18
|
+
* just `...`, treat them as "skip whatever's here" placeholders. The model
|
|
19
|
+
* writes:
|
|
20
|
+
*
|
|
21
|
+
* old: function foo() {
|
|
22
|
+
* ...
|
|
23
|
+
* return bar;
|
|
24
|
+
* }
|
|
25
|
+
* new: function foo() {
|
|
26
|
+
* ...
|
|
27
|
+
* return baz;
|
|
28
|
+
* }
|
|
29
|
+
*
|
|
30
|
+
* We split both `old` and `next` on the `...` lines, then anchor the bookend
|
|
31
|
+
* pieces in `working` (greedy, in order). The elided middle from `working` is
|
|
32
|
+
* preserved verbatim and stitched in between the new bookends. Returns the
|
|
33
|
+
* rewritten buffer on success, null when:
|
|
34
|
+
* - `old` has no `...` lines (caller should try other strategies)
|
|
35
|
+
* - piece counts differ between `old` and `next` (ambiguous elision)
|
|
36
|
+
* - any piece is empty (means dots at start/end or adjacent — too risky)
|
|
37
|
+
* - any old piece doesn't appear in `working` after the previous one
|
|
38
|
+
*
|
|
39
|
+
* Greedy first-match-then-forward. We DO NOT support `replace_all` with
|
|
40
|
+
* elision — `...` is intrinsically a single edit.
|
|
41
|
+
*/
|
|
42
|
+
export declare function applyDotdotdots(working: string, old: string, next: string): string | null;
|
|
43
|
+
/**
|
|
44
|
+
* Models often add a spurious leading blank line to `old_text` (e.g. when
|
|
45
|
+
* copying a code block out of fenced markdown). Aider noticed this back at
|
|
46
|
+
* its issue #25. If the first line is blank, return the same text minus that
|
|
47
|
+
* line so the caller can retry the match. Returns null when no leading blank
|
|
48
|
+
* line exists, so callers can cheaply skip the retry.
|
|
49
|
+
*/
|
|
50
|
+
export declare function stripLeadingBlankLine(text: string): string | null;
|
|
1
51
|
/**
|
|
2
52
|
* Find text in content, trying exact match first then fuzzy.
|
|
3
53
|
*/
|
|
@@ -20,7 +70,22 @@ export declare function countOccurrences(content: string, oldText: string): numb
|
|
|
20
70
|
* expected location(s) — multiple results help disambiguate when several
|
|
21
71
|
* regions look similar (e.g. repeated function bodies).
|
|
22
72
|
*/
|
|
23
|
-
export
|
|
73
|
+
export interface ClosestSnippet {
|
|
74
|
+
snippet: string;
|
|
75
|
+
topLine: number;
|
|
76
|
+
}
|
|
77
|
+
export declare function findClosestSnippet(content: string, oldText: string, contextLines?: number, maxResults?: number): ClosestSnippet | null;
|
|
78
|
+
/**
|
|
79
|
+
* Locate every occurrence of `text` in `content` and return the 1-indexed line
|
|
80
|
+
* number plus a trimmed preview of that line. Tries exact first, then the same
|
|
81
|
+
* fuzzy normalization as `countOccurrences` so the line numbers match what the
|
|
82
|
+
* caller saw in `countOccurrences`. Capped at `max` so error messages stay
|
|
83
|
+
* compact when a token like `}` matches dozens of times.
|
|
84
|
+
*/
|
|
85
|
+
export declare function findOccurrenceLines(content: string, text: string, max?: number): {
|
|
86
|
+
line: number;
|
|
87
|
+
preview: string;
|
|
88
|
+
}[];
|
|
24
89
|
/**
|
|
25
90
|
* Generate a unified diff string.
|
|
26
91
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edit-diff.d.ts","sourceRoot":"","sources":["../../src/tools/edit-diff.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"edit-diff.d.ts","sourceRoot":"","sources":["../../src/tools/edit-diff.ts"],"names":[],"mappings":"AA8CA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,GACX,MAAM,GAAG,IAAI,CAgDf;AAED;;;;;;;;;;;;;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