codemini-cli 0.5.10 → 0.5.11
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/OPERATIONS.md +242 -242
- package/README.md +588 -588
- package/codemini-web/dist/assets/{highlighted-body-OFNGDK62-7HL7yft8.js → highlighted-body-OFNGDK62-CANOG7Xg.js} +1 -1
- package/codemini-web/dist/assets/{index-BK75hMb2.js → index-B71xykPM.js} +108 -108
- package/codemini-web/dist/assets/index-Dkq1DdDX.css +2 -0
- package/codemini-web/dist/assets/mermaid-GHXKKRXX-Z_w7M93P.js +1 -0
- package/codemini-web/dist/index.html +23 -23
- package/codemini-web/lib/approval-manager.js +32 -32
- package/codemini-web/lib/runtime-bridge.js +17 -11
- package/codemini-web/server.js +534 -205
- package/deployment.md +212 -212
- package/package.json +1 -1
- package/skills/brainstorm/SKILL.md +77 -77
- package/skills/codemini.skills.json +40 -40
- package/skills/grill-me/SKILL.md +30 -30
- package/skills/superpowers-lite/SKILL.md +82 -82
- package/src/cli.js +74 -74
- package/src/commands/chat.js +210 -210
- package/src/commands/run.js +313 -313
- package/src/commands/skill.js +438 -304
- package/src/commands/web.js +57 -57
- package/src/core/agent-loop.js +980 -980
- package/src/core/ast.js +309 -307
- package/src/core/chat-runtime.js +6261 -6253
- package/src/core/command-evaluator.js +72 -72
- package/src/core/command-loader.js +311 -311
- package/src/core/command-policy.js +301 -301
- package/src/core/command-risk.js +156 -156
- package/src/core/config-store.js +289 -289
- package/src/core/constants.js +18 -1
- package/src/core/context-compact.js +365 -365
- package/src/core/default-system-prompt.js +114 -107
- package/src/core/dream-audit.js +105 -105
- package/src/core/dream-consolidate.js +229 -229
- package/src/core/dream-evaluator.js +185 -185
- package/src/core/fff-adapter.js +383 -383
- package/src/core/memory-store.js +543 -543
- package/src/core/project-index.js +737 -548
- package/src/core/project-instructions.js +98 -98
- package/src/core/provider/anthropic.js +514 -514
- package/src/core/provider/openai-compatible.js +501 -501
- package/src/core/reflect-skill.js +178 -178
- package/src/core/reply-language.js +40 -40
- package/src/core/session-store.js +474 -474
- package/src/core/shell-profile.js +237 -237
- package/src/core/shell.js +323 -323
- package/src/core/soul.js +69 -69
- package/src/core/system-prompt-composer.js +52 -52
- package/src/core/tool-args.js +199 -154
- package/src/core/tool-output.js +184 -184
- package/src/core/tool-result-store.js +206 -206
- package/src/core/tools.js +3024 -2893
- package/src/core/version.js +11 -11
- package/src/tui/chat-app.js +5171 -5171
- package/src/tui/tool-activity/presenters/misc.js +30 -30
- package/src/tui/tool-activity/presenters/system.js +20 -20
- package/templates/project-requirements/report-shell.html +582 -582
- package/codemini-web/dist/assets/index-BSdIdn3L.css +0 -2
- package/codemini-web/dist/assets/mermaid-GHXKKRXX-Dg9qh8mg.js +0 -1
|
@@ -1,237 +1,237 @@
|
|
|
1
|
-
const DEFAULT_SHELL = process.platform === 'win32' ? 'powershell' : 'bash';
|
|
2
|
-
|
|
3
|
-
function uniqueStrings(items = []) {
|
|
4
|
-
const out = [];
|
|
5
|
-
const seen = new Set();
|
|
6
|
-
for (const item of items) {
|
|
7
|
-
const value = String(item || '').trim();
|
|
8
|
-
if (!value || seen.has(value)) continue;
|
|
9
|
-
seen.add(value);
|
|
10
|
-
out.push(value);
|
|
11
|
-
}
|
|
12
|
-
return out;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const SHELL_PROFILES = {
|
|
16
|
-
powershell: {
|
|
17
|
-
shell: 'powershell',
|
|
18
|
-
label: 'PowerShell',
|
|
19
|
-
command_allowlist: [
|
|
20
|
-
'rg',
|
|
21
|
-
'git',
|
|
22
|
-
'node',
|
|
23
|
-
'npm',
|
|
24
|
-
'npx',
|
|
25
|
-
'python',
|
|
26
|
-
'python3',
|
|
27
|
-
'py',
|
|
28
|
-
'pip',
|
|
29
|
-
'pip3',
|
|
30
|
-
'get-childitem',
|
|
31
|
-
'get-content',
|
|
32
|
-
'get-location',
|
|
33
|
-
'get-command',
|
|
34
|
-
'get-help',
|
|
35
|
-
'get-item',
|
|
36
|
-
'get-process',
|
|
37
|
-
'select-string',
|
|
38
|
-
'select-object',
|
|
39
|
-
'where-object',
|
|
40
|
-
'foreach-object',
|
|
41
|
-
'measure-object',
|
|
42
|
-
'sort-object',
|
|
43
|
-
'compare-object',
|
|
44
|
-
'resolve-path',
|
|
45
|
-
'test-path',
|
|
46
|
-
'set-content',
|
|
47
|
-
'new-item',
|
|
48
|
-
'copy-item',
|
|
49
|
-
'move-item',
|
|
50
|
-
'pwd'
|
|
51
|
-
],
|
|
52
|
-
blocked_commands: [
|
|
53
|
-
'del',
|
|
54
|
-
'erase',
|
|
55
|
-
'rmdir',
|
|
56
|
-
'rd',
|
|
57
|
-
'format',
|
|
58
|
-
'diskpart',
|
|
59
|
-
'cipher',
|
|
60
|
-
'bcdedit',
|
|
61
|
-
'reg',
|
|
62
|
-
'takeown',
|
|
63
|
-
'icacls',
|
|
64
|
-
'remove-item'
|
|
65
|
-
],
|
|
66
|
-
blocked_path_patterns: [
|
|
67
|
-
'c:\\windows',
|
|
68
|
-
'c:\\program files',
|
|
69
|
-
'c:\\program files (x86)',
|
|
70
|
-
'c:\\users\\default',
|
|
71
|
-
'%systemroot%',
|
|
72
|
-
'$env:systemroot'
|
|
73
|
-
]
|
|
74
|
-
},
|
|
75
|
-
bash: {
|
|
76
|
-
shell: 'bash',
|
|
77
|
-
label: 'bash',
|
|
78
|
-
command_allowlist: [
|
|
79
|
-
'cd',
|
|
80
|
-
'rg',
|
|
81
|
-
'find',
|
|
82
|
-
'grep',
|
|
83
|
-
'git',
|
|
84
|
-
'node',
|
|
85
|
-
'npm',
|
|
86
|
-
'npx',
|
|
87
|
-
'python',
|
|
88
|
-
'python3',
|
|
89
|
-
'pip',
|
|
90
|
-
'pip3',
|
|
91
|
-
'ls',
|
|
92
|
-
'cat',
|
|
93
|
-
'sed',
|
|
94
|
-
'head',
|
|
95
|
-
'tail',
|
|
96
|
-
'wc',
|
|
97
|
-
'test',
|
|
98
|
-
'sort',
|
|
99
|
-
'uniq',
|
|
100
|
-
'cut',
|
|
101
|
-
'tr',
|
|
102
|
-
'xargs',
|
|
103
|
-
'basename',
|
|
104
|
-
'dirname',
|
|
105
|
-
'paste',
|
|
106
|
-
'echo',
|
|
107
|
-
'sleep',
|
|
108
|
-
'true',
|
|
109
|
-
'false',
|
|
110
|
-
'cp',
|
|
111
|
-
'mv',
|
|
112
|
-
'mkdir',
|
|
113
|
-
'pwd'
|
|
114
|
-
],
|
|
115
|
-
blocked_commands: ['rm', 'sudo', 'su', 'dd', 'mkfs', 'mount', 'umount', 'chmod', 'chown'],
|
|
116
|
-
blocked_path_patterns: ['/etc/', '/bin/', '/usr/', '/var/', '/sys/', '/proc/', '/system/', '/library/']
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
export function normalizeShellName(value) {
|
|
121
|
-
const raw = String(value || '').trim().toLowerCase();
|
|
122
|
-
if (raw === 'pwsh') return 'powershell';
|
|
123
|
-
if (raw === 'sh' || raw === 'zsh') return 'bash';
|
|
124
|
-
if (raw === 'cmd') return 'powershell';
|
|
125
|
-
if (raw === 'powershell' || raw === 'bash') return raw;
|
|
126
|
-
return DEFAULT_SHELL;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export function getShellProfile(value) {
|
|
130
|
-
return SHELL_PROFILES[normalizeShellName(value)];
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export function getEffectivePolicy(config) {
|
|
134
|
-
const profile = getShellProfile(config?.shell?.default);
|
|
135
|
-
const policy = config?.policy || {};
|
|
136
|
-
return {
|
|
137
|
-
...policy,
|
|
138
|
-
command_allowlist: uniqueStrings([
|
|
139
|
-
...(Array.isArray(profile.command_allowlist) ? profile.command_allowlist : []),
|
|
140
|
-
...(Array.isArray(policy.command_allowlist) ? policy.command_allowlist : [])
|
|
141
|
-
]),
|
|
142
|
-
blocked_commands: uniqueStrings([
|
|
143
|
-
...(Array.isArray(profile.blocked_commands) ? profile.blocked_commands : []),
|
|
144
|
-
...(Array.isArray(policy.blocked_commands) ? policy.blocked_commands : [])
|
|
145
|
-
]),
|
|
146
|
-
blocked_path_patterns: uniqueStrings([
|
|
147
|
-
...(Array.isArray(profile.blocked_path_patterns) ? profile.blocked_path_patterns : []),
|
|
148
|
-
...(Array.isArray(policy.blocked_path_patterns) ? policy.blocked_path_patterns : [])
|
|
149
|
-
])
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export function getShellSystemPrompt(value) {
|
|
154
|
-
const profile = getShellProfile(value);
|
|
155
|
-
return `You are Codemini CLI, an AI coding assistant running in a ${profile.label} shell environment.
|
|
156
|
-
|
|
157
|
-
# Using your tools
|
|
158
|
-
|
|
159
|
-
ALWAYS prefer dedicated tools over raw shell commands:
|
|
160
|
-
- The visible default tool list is intentionally small. If a needed capability is not currently listed, do not assume it is unavailable — call tool_search to load additional tools first
|
|
161
|
-
- Use query_project_index first for broad repository understanding. It combines project-map metadata with indexed file symbols so you can narrow candidates before reading source files
|
|
162
|
-
- Use read to inspect files — NEVER use cat, head, or tail via run. Use canonical shapes like {path:"src/app.ts"}, {path:"src/app.ts:10-40"}, or {path:"src/app.ts", start_line:10, end_line:40}
|
|
163
|
-
- Use grep to search file contents — NEVER use grep or rg via run
|
|
164
|
-
- Use list for directory-by-directory filesystem discovery. If you specifically need pattern-based file lookup like src/**/*.ts, load glob with tool_search instead of falling back to run
|
|
165
|
-
- Use edit to modify existing files — this is the DEFAULT path for code changes. Prefer {path:"src/app.ts", old_text:"foo", new_text:"bar"}
|
|
166
|
-
- Use write only for creating new files or complete rewrites (set full_file_rewrite=true for existing code files). Prefer {path:"notes.txt", content:"..."}
|
|
167
|
-
- Use update_todos to manage the session todo checklist for complex work. Provide the full current list each time and usually keep exactly one item in_progress
|
|
168
|
-
- Use read_plan and update_plan to recover or sync structured plan state when plan progress was interrupted (for example by transient gateway/model errors)
|
|
169
|
-
- Use run for shell commands. For long-running processes (dev servers, watchers), set run_in_background=true when you know you do not need the final result immediately. Long-running commands may also be backgrounded automatically
|
|
170
|
-
|
|
171
|
-
Use update_todos with these rules:
|
|
172
|
-
- MUST use it before major tool work when the task has 3 or more meaningful steps, multiple files or phases, explicit verification work, debugging with multiple hypotheses, or any non-trivial implementation likely to span several tool calls
|
|
173
|
-
- Do NOT use it for single-step trivial edits, one-off command execution, or purely informational/chat responses
|
|
174
|
-
- The input must be the full current checklist, not a partial patch
|
|
175
|
-
- Keep exactly one item in_progress while work is actively underway unless the user explicitly asks for parallel execution
|
|
176
|
-
- Mark items completed immediately after finishing them, and add newly discovered follow-up work as new checklist items
|
|
177
|
-
- If tests fail, verification is incomplete, or a blocker remains, do not mark the affected item completed
|
|
178
|
-
- Before giving a completion-style final answer for a complex task, update_todos so the checklist is either fully completed or clearly shows the remaining blocker
|
|
179
|
-
|
|
180
|
-
Some tools are loaded on demand through tool_search. Common examples:
|
|
181
|
-
- glob for pattern-based file lookup
|
|
182
|
-
- ast_query and read_ast_node for advanced AST-scoped reads and edits
|
|
183
|
-
- list_background_tasks, get_background_task, and stop_background_task for managing long-running background commands
|
|
184
|
-
- save_memory, list_memory, search_memory, and forget_memory for persistent memory operations
|
|
185
|
-
|
|
186
|
-
For structural code edits (functions, classes, methods), prefer AST-scoped reads before editing:
|
|
187
|
-
- Common one-shot workflow: read(path, query=..., capture_name=...) → edit with symbol or ast_target
|
|
188
|
-
- If you already have ast_target: read(ast_target=...) → edit with ast_target
|
|
189
|
-
- Advanced multi-step workflow: tool_search("ast_query") → ast_query → read_ast_node → edit with ast_target and kind=replace_block
|
|
190
|
-
Fall back to plain grep/read/edit only when AST is not appropriate.
|
|
191
|
-
|
|
192
|
-
For background commands: use run to launch. If you need management tools that are not currently visible, load list_background_tasks/get_background_task/stop_background_task with tool_search. Prefer reading the returned output_file with read instead of asking for a separate logs tool.
|
|
193
|
-
|
|
194
|
-
Common tool call patterns:
|
|
195
|
-
- Query the project index first: {query:"login auth flow", path:"src", max_results:5}
|
|
196
|
-
- Load a deferred tool when needed: {query:"glob"} or {query:"all"}
|
|
197
|
-
- Read a file: {path:"src/app.ts"} or {path:"src/app.ts", start_line:20, end_line:60}
|
|
198
|
-
- Read a specific range inline: {path:"src/app.ts:20-60"}
|
|
199
|
-
- Search text: {pattern:"loginUser", path:"src"} or {query:"loginUser", directory:"src"}
|
|
200
|
-
- List a directory first: {path:"src"}
|
|
201
|
-
- After loading glob, find files by pattern: {pattern:"src/**/*.ts"} or {query:"src/**/*.ts"}
|
|
202
|
-
- Edit exact text: {path:"src/app.ts", old_text:"foo", new_text:"bar"}
|
|
203
|
-
- Edit with shorthand: {path:"src/app.ts", old_text:"foo", content:"bar"}
|
|
204
|
-
- Write a new file: {path:"notes.txt", content:"..."} or {path:"src/page.tsx", content:"..."}
|
|
205
|
-
- When the environment provides a Working directory, prefer absolute path values rooted there instead of guessing prefixes
|
|
206
|
-
- If the user gives a relative path like src/app.ts, resolve it from the current Working directory rather than inventing ../ or sibling folders
|
|
207
|
-
|
|
208
|
-
# Doing tasks
|
|
209
|
-
|
|
210
|
-
- You are a terminal-first CLI coding agent, not a generic chat assistant
|
|
211
|
-
- The user shares your workspace with you; prefer inspecting the project yourself before asking them to paste files that should be discoverable
|
|
212
|
-
- Before substantial tool work, send a short progress update to the user about what you are about to inspect or do
|
|
213
|
-
- Do not jump straight into tools without a brief user-facing note when the task is actionable
|
|
214
|
-
- For tasks with 3 or more meaningful steps, proactively create and maintain a todo checklist with update_todos
|
|
215
|
-
- For complex tasks, create the todo checklist before the first major implementation or verification tool call
|
|
216
|
-
- If a command or tool is blocked or fails, inspect the error and retry with allowed commands or tools
|
|
217
|
-
- For AST-scoped edits, if edit rejects due to missing or stale ast_target, fix arguments and retry
|
|
218
|
-
- Do not claim filesystem access is impossible unless search/read tools also fail
|
|
219
|
-
- Do not add comments, docstrings, or type annotations to code you did not change
|
|
220
|
-
- Do not add features or refactor code beyond what was asked
|
|
221
|
-
|
|
222
|
-
# Plan mode
|
|
223
|
-
|
|
224
|
-
- In plan mode, explore and propose the next steps first
|
|
225
|
-
- In plan mode, do not start implementation until the user asks you to continue
|
|
226
|
-
- If requirements are still unclear, ask one focused question and stop
|
|
227
|
-
- If there are multiple reasonable approaches, give short options and a suggested direction, then stop for user confirmation
|
|
228
|
-
|
|
229
|
-
# Tone and style
|
|
230
|
-
|
|
231
|
-
- Keep answers compact and easy to scan
|
|
232
|
-
- Lead with the answer or next action, not scene-setting
|
|
233
|
-
- Do not restate the user's request unless a brief restatement prevents ambiguity
|
|
234
|
-
- When referencing code, use path:line_number format
|
|
235
|
-
- Keep technical wording, commands, paths, and error details exact
|
|
236
|
-
- Only use emojis if the user explicitly requests it`;
|
|
237
|
-
}
|
|
1
|
+
const DEFAULT_SHELL = process.platform === 'win32' ? 'powershell' : 'bash';
|
|
2
|
+
|
|
3
|
+
function uniqueStrings(items = []) {
|
|
4
|
+
const out = [];
|
|
5
|
+
const seen = new Set();
|
|
6
|
+
for (const item of items) {
|
|
7
|
+
const value = String(item || '').trim();
|
|
8
|
+
if (!value || seen.has(value)) continue;
|
|
9
|
+
seen.add(value);
|
|
10
|
+
out.push(value);
|
|
11
|
+
}
|
|
12
|
+
return out;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const SHELL_PROFILES = {
|
|
16
|
+
powershell: {
|
|
17
|
+
shell: 'powershell',
|
|
18
|
+
label: 'PowerShell',
|
|
19
|
+
command_allowlist: [
|
|
20
|
+
'rg',
|
|
21
|
+
'git',
|
|
22
|
+
'node',
|
|
23
|
+
'npm',
|
|
24
|
+
'npx',
|
|
25
|
+
'python',
|
|
26
|
+
'python3',
|
|
27
|
+
'py',
|
|
28
|
+
'pip',
|
|
29
|
+
'pip3',
|
|
30
|
+
'get-childitem',
|
|
31
|
+
'get-content',
|
|
32
|
+
'get-location',
|
|
33
|
+
'get-command',
|
|
34
|
+
'get-help',
|
|
35
|
+
'get-item',
|
|
36
|
+
'get-process',
|
|
37
|
+
'select-string',
|
|
38
|
+
'select-object',
|
|
39
|
+
'where-object',
|
|
40
|
+
'foreach-object',
|
|
41
|
+
'measure-object',
|
|
42
|
+
'sort-object',
|
|
43
|
+
'compare-object',
|
|
44
|
+
'resolve-path',
|
|
45
|
+
'test-path',
|
|
46
|
+
'set-content',
|
|
47
|
+
'new-item',
|
|
48
|
+
'copy-item',
|
|
49
|
+
'move-item',
|
|
50
|
+
'pwd'
|
|
51
|
+
],
|
|
52
|
+
blocked_commands: [
|
|
53
|
+
'del',
|
|
54
|
+
'erase',
|
|
55
|
+
'rmdir',
|
|
56
|
+
'rd',
|
|
57
|
+
'format',
|
|
58
|
+
'diskpart',
|
|
59
|
+
'cipher',
|
|
60
|
+
'bcdedit',
|
|
61
|
+
'reg',
|
|
62
|
+
'takeown',
|
|
63
|
+
'icacls',
|
|
64
|
+
'remove-item'
|
|
65
|
+
],
|
|
66
|
+
blocked_path_patterns: [
|
|
67
|
+
'c:\\windows',
|
|
68
|
+
'c:\\program files',
|
|
69
|
+
'c:\\program files (x86)',
|
|
70
|
+
'c:\\users\\default',
|
|
71
|
+
'%systemroot%',
|
|
72
|
+
'$env:systemroot'
|
|
73
|
+
]
|
|
74
|
+
},
|
|
75
|
+
bash: {
|
|
76
|
+
shell: 'bash',
|
|
77
|
+
label: 'bash',
|
|
78
|
+
command_allowlist: [
|
|
79
|
+
'cd',
|
|
80
|
+
'rg',
|
|
81
|
+
'find',
|
|
82
|
+
'grep',
|
|
83
|
+
'git',
|
|
84
|
+
'node',
|
|
85
|
+
'npm',
|
|
86
|
+
'npx',
|
|
87
|
+
'python',
|
|
88
|
+
'python3',
|
|
89
|
+
'pip',
|
|
90
|
+
'pip3',
|
|
91
|
+
'ls',
|
|
92
|
+
'cat',
|
|
93
|
+
'sed',
|
|
94
|
+
'head',
|
|
95
|
+
'tail',
|
|
96
|
+
'wc',
|
|
97
|
+
'test',
|
|
98
|
+
'sort',
|
|
99
|
+
'uniq',
|
|
100
|
+
'cut',
|
|
101
|
+
'tr',
|
|
102
|
+
'xargs',
|
|
103
|
+
'basename',
|
|
104
|
+
'dirname',
|
|
105
|
+
'paste',
|
|
106
|
+
'echo',
|
|
107
|
+
'sleep',
|
|
108
|
+
'true',
|
|
109
|
+
'false',
|
|
110
|
+
'cp',
|
|
111
|
+
'mv',
|
|
112
|
+
'mkdir',
|
|
113
|
+
'pwd'
|
|
114
|
+
],
|
|
115
|
+
blocked_commands: ['rm', 'sudo', 'su', 'dd', 'mkfs', 'mount', 'umount', 'chmod', 'chown'],
|
|
116
|
+
blocked_path_patterns: ['/etc/', '/bin/', '/usr/', '/var/', '/sys/', '/proc/', '/system/', '/library/']
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export function normalizeShellName(value) {
|
|
121
|
+
const raw = String(value || '').trim().toLowerCase();
|
|
122
|
+
if (raw === 'pwsh') return 'powershell';
|
|
123
|
+
if (raw === 'sh' || raw === 'zsh') return 'bash';
|
|
124
|
+
if (raw === 'cmd') return 'powershell';
|
|
125
|
+
if (raw === 'powershell' || raw === 'bash') return raw;
|
|
126
|
+
return DEFAULT_SHELL;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export function getShellProfile(value) {
|
|
130
|
+
return SHELL_PROFILES[normalizeShellName(value)];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export function getEffectivePolicy(config) {
|
|
134
|
+
const profile = getShellProfile(config?.shell?.default);
|
|
135
|
+
const policy = config?.policy || {};
|
|
136
|
+
return {
|
|
137
|
+
...policy,
|
|
138
|
+
command_allowlist: uniqueStrings([
|
|
139
|
+
...(Array.isArray(profile.command_allowlist) ? profile.command_allowlist : []),
|
|
140
|
+
...(Array.isArray(policy.command_allowlist) ? policy.command_allowlist : [])
|
|
141
|
+
]),
|
|
142
|
+
blocked_commands: uniqueStrings([
|
|
143
|
+
...(Array.isArray(profile.blocked_commands) ? profile.blocked_commands : []),
|
|
144
|
+
...(Array.isArray(policy.blocked_commands) ? policy.blocked_commands : [])
|
|
145
|
+
]),
|
|
146
|
+
blocked_path_patterns: uniqueStrings([
|
|
147
|
+
...(Array.isArray(profile.blocked_path_patterns) ? profile.blocked_path_patterns : []),
|
|
148
|
+
...(Array.isArray(policy.blocked_path_patterns) ? policy.blocked_path_patterns : [])
|
|
149
|
+
])
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export function getShellSystemPrompt(value) {
|
|
154
|
+
const profile = getShellProfile(value);
|
|
155
|
+
return `You are Codemini CLI, an AI coding assistant running in a ${profile.label} shell environment.
|
|
156
|
+
|
|
157
|
+
# Using your tools
|
|
158
|
+
|
|
159
|
+
ALWAYS prefer dedicated tools over raw shell commands:
|
|
160
|
+
- The visible default tool list is intentionally small. If a needed capability is not currently listed, do not assume it is unavailable — call tool_search to load additional tools first
|
|
161
|
+
- Use query_project_index first for broad repository understanding. It combines project-map metadata with indexed file symbols so you can narrow candidates before reading source files
|
|
162
|
+
- Use read to inspect files — NEVER use cat, head, or tail via run. Use canonical shapes like {path:"src/app.ts"}, {path:"src/app.ts:10-40"}, or {path:"src/app.ts", start_line:10, end_line:40}
|
|
163
|
+
- Use grep to search file contents — NEVER use grep or rg via run
|
|
164
|
+
- Use list for directory-by-directory filesystem discovery. If you specifically need pattern-based file lookup like src/**/*.ts, load glob with tool_search instead of falling back to run
|
|
165
|
+
- Use edit to modify existing files — this is the DEFAULT path for code changes. Prefer {path:"src/app.ts", old_text:"foo", new_text:"bar"}
|
|
166
|
+
- Use write only for creating new files or complete rewrites (set full_file_rewrite=true for existing code files). Prefer {path:"notes.txt", content:"..."}
|
|
167
|
+
- Use update_todos to manage the session todo checklist for complex work. Provide the full current list each time and usually keep exactly one item in_progress
|
|
168
|
+
- Use read_plan and update_plan to recover or sync structured plan state when plan progress was interrupted (for example by transient gateway/model errors)
|
|
169
|
+
- Use run for shell commands. For long-running processes (dev servers, watchers), set run_in_background=true when you know you do not need the final result immediately. Long-running commands may also be backgrounded automatically
|
|
170
|
+
|
|
171
|
+
Use update_todos with these rules:
|
|
172
|
+
- MUST use it before major tool work when the task has 3 or more meaningful steps, multiple files or phases, explicit verification work, debugging with multiple hypotheses, or any non-trivial implementation likely to span several tool calls
|
|
173
|
+
- Do NOT use it for single-step trivial edits, one-off command execution, or purely informational/chat responses
|
|
174
|
+
- The input must be the full current checklist, not a partial patch
|
|
175
|
+
- Keep exactly one item in_progress while work is actively underway unless the user explicitly asks for parallel execution
|
|
176
|
+
- Mark items completed immediately after finishing them, and add newly discovered follow-up work as new checklist items
|
|
177
|
+
- If tests fail, verification is incomplete, or a blocker remains, do not mark the affected item completed
|
|
178
|
+
- Before giving a completion-style final answer for a complex task, update_todos so the checklist is either fully completed or clearly shows the remaining blocker
|
|
179
|
+
|
|
180
|
+
Some tools are loaded on demand through tool_search. Common examples:
|
|
181
|
+
- glob for pattern-based file lookup
|
|
182
|
+
- ast_query and read_ast_node for advanced AST-scoped reads and edits
|
|
183
|
+
- list_background_tasks, get_background_task, and stop_background_task for managing long-running background commands
|
|
184
|
+
- save_memory, list_memory, search_memory, and forget_memory for persistent memory operations
|
|
185
|
+
|
|
186
|
+
For structural code edits (functions, classes, methods), prefer AST-scoped reads before editing:
|
|
187
|
+
- Common one-shot workflow: read(path, query=..., capture_name=...) → edit with symbol or ast_target
|
|
188
|
+
- If you already have ast_target: read(ast_target=...) → edit with ast_target
|
|
189
|
+
- Advanced multi-step workflow: tool_search("ast_query") → ast_query → read_ast_node → edit with ast_target and kind=replace_block
|
|
190
|
+
Fall back to plain grep/read/edit only when AST is not appropriate.
|
|
191
|
+
|
|
192
|
+
For background commands: use run to launch. If you need management tools that are not currently visible, load list_background_tasks/get_background_task/stop_background_task with tool_search. Prefer reading the returned output_file with read instead of asking for a separate logs tool.
|
|
193
|
+
|
|
194
|
+
Common tool call patterns:
|
|
195
|
+
- Query the project index first: {query:"login auth flow", path:"src", max_results:5}
|
|
196
|
+
- Load a deferred tool when needed: {query:"glob"} or {query:"all"}
|
|
197
|
+
- Read a file: {path:"src/app.ts"} or {path:"src/app.ts", start_line:20, end_line:60}
|
|
198
|
+
- Read a specific range inline: {path:"src/app.ts:20-60"}
|
|
199
|
+
- Search text: {pattern:"loginUser", path:"src"} or {query:"loginUser", directory:"src"}
|
|
200
|
+
- List a directory first: {path:"src"}
|
|
201
|
+
- After loading glob, find files by pattern: {pattern:"src/**/*.ts"} or {query:"src/**/*.ts"}
|
|
202
|
+
- Edit exact text: {path:"src/app.ts", old_text:"foo", new_text:"bar"}
|
|
203
|
+
- Edit with shorthand: {path:"src/app.ts", old_text:"foo", content:"bar"}
|
|
204
|
+
- Write a new file: {path:"notes.txt", content:"..."} or {path:"src/page.tsx", content:"..."}
|
|
205
|
+
- When the environment provides a Working directory, prefer absolute path values rooted there instead of guessing prefixes
|
|
206
|
+
- If the user gives a relative path like src/app.ts, resolve it from the current Working directory rather than inventing ../ or sibling folders
|
|
207
|
+
|
|
208
|
+
# Doing tasks
|
|
209
|
+
|
|
210
|
+
- You are a terminal-first CLI coding agent, not a generic chat assistant
|
|
211
|
+
- The user shares your workspace with you; prefer inspecting the project yourself before asking them to paste files that should be discoverable
|
|
212
|
+
- Before substantial tool work, send a short progress update to the user about what you are about to inspect or do
|
|
213
|
+
- Do not jump straight into tools without a brief user-facing note when the task is actionable
|
|
214
|
+
- For tasks with 3 or more meaningful steps, proactively create and maintain a todo checklist with update_todos
|
|
215
|
+
- For complex tasks, create the todo checklist before the first major implementation or verification tool call
|
|
216
|
+
- If a command or tool is blocked or fails, inspect the error and retry with allowed commands or tools
|
|
217
|
+
- For AST-scoped edits, if edit rejects due to missing or stale ast_target, fix arguments and retry
|
|
218
|
+
- Do not claim filesystem access is impossible unless search/read tools also fail
|
|
219
|
+
- Do not add comments, docstrings, or type annotations to code you did not change
|
|
220
|
+
- Do not add features or refactor code beyond what was asked
|
|
221
|
+
|
|
222
|
+
# Plan mode
|
|
223
|
+
|
|
224
|
+
- In plan mode, explore and propose the next steps first
|
|
225
|
+
- In plan mode, do not start implementation until the user asks you to continue
|
|
226
|
+
- If requirements are still unclear, ask one focused question and stop
|
|
227
|
+
- If there are multiple reasonable approaches, give short options and a suggested direction, then stop for user confirmation
|
|
228
|
+
|
|
229
|
+
# Tone and style
|
|
230
|
+
|
|
231
|
+
- Keep answers compact and easy to scan
|
|
232
|
+
- Lead with the answer or next action, not scene-setting
|
|
233
|
+
- Do not restate the user's request unless a brief restatement prevents ambiguity
|
|
234
|
+
- When referencing code, use path:line_number format
|
|
235
|
+
- Keep technical wording, commands, paths, and error details exact
|
|
236
|
+
- Only use emojis if the user explicitly requests it`;
|
|
237
|
+
}
|