codemini-cli 0.1.12 → 0.1.13
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/package.json +1 -1
- package/src/core/agent-loop.js +17 -0
- package/src/core/chat-runtime.js +364 -44
- package/src/core/config-store.js +39 -3
- package/src/core/reply-language.js +25 -0
- package/src/core/shell-profile.js +1 -1
- package/src/core/soul.js +3 -1
- package/src/core/tools.js +884 -8
- package/src/tui/chat-app.js +89 -15
package/src/core/config-store.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { getConfigFilePath, getLegacyConfigDir } from './paths.js';
|
|
4
|
+
import { normalizeReplyLanguage } from './reply-language.js';
|
|
4
5
|
import { normalizeShellName } from './shell-profile.js';
|
|
5
6
|
|
|
6
7
|
function normalizeUiLanguage(value) {
|
|
@@ -32,7 +33,23 @@ const DEFAULT_CONFIG = {
|
|
|
32
33
|
},
|
|
33
34
|
execution: {
|
|
34
35
|
mode: 'auto',
|
|
35
|
-
always_allow_tools: [
|
|
36
|
+
always_allow_tools: [
|
|
37
|
+
'locate',
|
|
38
|
+
'open_target',
|
|
39
|
+
'edit_target',
|
|
40
|
+
'search_code',
|
|
41
|
+
'read_block',
|
|
42
|
+
'read_symbol_context',
|
|
43
|
+
'validate_edit',
|
|
44
|
+
'replace_block',
|
|
45
|
+
'replace_text',
|
|
46
|
+
'insert_before',
|
|
47
|
+
'insert_after',
|
|
48
|
+
'generate_diff',
|
|
49
|
+
'run_command',
|
|
50
|
+
'read_file',
|
|
51
|
+
'write_file'
|
|
52
|
+
],
|
|
36
53
|
max_steps: 16
|
|
37
54
|
},
|
|
38
55
|
sessions: {
|
|
@@ -44,7 +61,8 @@ const DEFAULT_CONFIG = {
|
|
|
44
61
|
timeout_ms: 120000
|
|
45
62
|
},
|
|
46
63
|
ui: {
|
|
47
|
-
language: 'zh'
|
|
64
|
+
language: 'zh',
|
|
65
|
+
reply_language: 'zh'
|
|
48
66
|
},
|
|
49
67
|
soul: {
|
|
50
68
|
preset: 'default',
|
|
@@ -110,10 +128,28 @@ function normalizePolicyLists(config) {
|
|
|
110
128
|
? next.execution.always_allow_tools
|
|
111
129
|
: [];
|
|
112
130
|
next.execution.always_allow_tools = uniqueStrings(
|
|
113
|
-
[
|
|
131
|
+
[
|
|
132
|
+
'locate',
|
|
133
|
+
'open_target',
|
|
134
|
+
'edit_target',
|
|
135
|
+
'search_code',
|
|
136
|
+
'read_block',
|
|
137
|
+
'read_symbol_context',
|
|
138
|
+
'validate_edit',
|
|
139
|
+
'replace_block',
|
|
140
|
+
'replace_text',
|
|
141
|
+
'insert_before',
|
|
142
|
+
'insert_after',
|
|
143
|
+
'generate_diff',
|
|
144
|
+
'run_command',
|
|
145
|
+
'read_file',
|
|
146
|
+
'write_file',
|
|
147
|
+
...rawTools
|
|
148
|
+
].filter((name) => String(name) !== 'list_files')
|
|
114
149
|
);
|
|
115
150
|
next.ui = next.ui || {};
|
|
116
151
|
next.ui.language = normalizeUiLanguage(next.ui.language);
|
|
152
|
+
next.ui.reply_language = normalizeReplyLanguage(next.ui.reply_language);
|
|
117
153
|
next.policy = next.policy || {};
|
|
118
154
|
next.policy.command_allowlist = uniqueStrings(
|
|
119
155
|
Array.isArray(next.policy.command_allowlist) ? next.policy.command_allowlist : []
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export function normalizeReplyLanguage(value) {
|
|
2
|
+
const raw = String(value || '').trim().toLowerCase();
|
|
3
|
+
if (!raw) return 'zh';
|
|
4
|
+
if (['en', 'en-us', 'en_us', 'english'].includes(raw)) return 'en';
|
|
5
|
+
if (['zh', 'zh-cn', 'zh_cn', 'cn', 'chinese', '中文', '简体中文'].includes(raw)) return 'zh';
|
|
6
|
+
return 'zh';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function buildSystemPromptWithReplyLanguage(baseSystemPrompt, config = {}) {
|
|
10
|
+
const replyLanguage = normalizeReplyLanguage(config?.ui?.reply_language);
|
|
11
|
+
const directive =
|
|
12
|
+
replyLanguage === 'en'
|
|
13
|
+
? [
|
|
14
|
+
'[Reply language]',
|
|
15
|
+
'Respond in English.',
|
|
16
|
+
'Write generated documentation, user-facing text, and code comments in English unless the user explicitly asks for a different language.'
|
|
17
|
+
].join('\n')
|
|
18
|
+
: [
|
|
19
|
+
'[Reply language]',
|
|
20
|
+
'Respond in Simplified Chinese.',
|
|
21
|
+
'Write generated documentation, user-facing text, and code comments in Simplified Chinese unless the user explicitly asks for a different language.'
|
|
22
|
+
].join('\n');
|
|
23
|
+
|
|
24
|
+
return `${String(baseSystemPrompt || '').trim()}\n\n${directive}`.trim();
|
|
25
|
+
}
|
|
@@ -118,5 +118,5 @@ export function getEffectivePolicy(config) {
|
|
|
118
118
|
|
|
119
119
|
export function getShellSystemPrompt(value) {
|
|
120
120
|
const profile = getShellProfile(value);
|
|
121
|
-
return `You are CodeMini CLI working in a ${profile.label} shell environment.
|
|
121
|
+
return `You are CodeMini CLI working in a ${profile.label} shell environment. Prefer the high-level structured workflow first: use locate to find candidates, open_target to inspect the smallest useful block and receive edit metadata, and edit_target to apply minimal edits. When you need lower-level control, use search_code, read_block, read_symbol_context, validate_edit, replace_block, replace_text, insert_before, insert_after, and generate_diff. Use run_command only when those structured tools are not enough. Use read_file only when structured reads are not enough. Use write_file only for full-file writes and always provide a concrete file path, not a directory. Avoid unnecessary tool calls.`;
|
|
122
122
|
}
|
package/src/core/soul.js
CHANGED
|
@@ -2,6 +2,7 @@ import fs from 'node:fs/promises';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
4
|
import { getBaseConfigDir } from './paths.js';
|
|
5
|
+
import { buildSystemPromptWithReplyLanguage } from './reply-language.js';
|
|
5
6
|
|
|
6
7
|
const MODULE_DIR = path.dirname(fileURLToPath(import.meta.url));
|
|
7
8
|
const BUNDLED_SOULS_DIR = path.resolve(MODULE_DIR, '..', '..', 'souls');
|
|
@@ -45,11 +46,12 @@ export async function loadSoulPrompt(config = {}) {
|
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
export async function buildSystemPromptWithSoul(baseSystemPrompt, config = {}) {
|
|
49
|
+
const promptWithReplyLanguage = buildSystemPromptWithReplyLanguage(baseSystemPrompt, config);
|
|
48
50
|
const soulPrompt = await loadSoulPrompt(config);
|
|
49
51
|
const guard = [
|
|
50
52
|
'[Soul guard]',
|
|
51
53
|
'Apply this soul to response tone only.',
|
|
52
54
|
'Response tone only: do not change plans, code, tests, file formats, or technical decisions.'
|
|
53
55
|
].join('\n');
|
|
54
|
-
return `${String(
|
|
56
|
+
return `${String(promptWithReplyLanguage || '').trim()}\n\n${guard}\n\n${soulPrompt}`.trim();
|
|
55
57
|
}
|