@raolin2025/claude-code-node 2.8.13 → 2.8.14
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raolin2025/claude-code-node",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.14",
|
|
4
4
|
"description": "Node.js AI Code Agent CLI - Zero dependencies, pure JavaScript, security hardened, multi-channel notifications, Telegram & QQ Bot remote programming, rich media upload, multi-account management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/core/index.js",
|
|
@@ -52,6 +52,13 @@ test('意图识别:写文档任务', () => {
|
|
|
52
52
|
assert.ok(r2 && r2.toolHint.includes('Write'))
|
|
53
53
|
})
|
|
54
54
|
|
|
55
|
+
test('意图识别:阅读文档是读取任务(不误判为写)', () => {
|
|
56
|
+
const r = detectIntent('阅读DEVELOPMENT_PLAN.md文档')
|
|
57
|
+
assert.ok(r, '应识别到意图')
|
|
58
|
+
assert.ok(r.toolHint.includes('Read'), '应提示用 Read')
|
|
59
|
+
assert.ok(!r.toolHint.includes('Write'), '读取任务不应提示 Write')
|
|
60
|
+
})
|
|
61
|
+
|
|
55
62
|
test('意图识别:找文件任务', () => {
|
|
56
63
|
const r = detectIntent('查找src目录下的文件')
|
|
57
64
|
assert.ok(r && r.toolHint.includes('Glob'))
|
package/src/core/query-engine.js
CHANGED
|
@@ -228,12 +228,25 @@ export class QueryEngine {
|
|
|
228
228
|
// 发送前硬校验:工具结果可能已使上下文超窗,确保 ≤ 窗口(摘要优先 + 滑动窗口裁剪兜底)
|
|
229
229
|
this._ensureFitWindow()
|
|
230
230
|
|
|
231
|
-
//
|
|
231
|
+
// 小模型模式:首轮若识别到明确意图,把引导【追加到首条 system 消息】。
|
|
232
|
+
// 注意:不能 push 一条新的 system 消息到中间——llama.cpp/Jinja 严格要求
|
|
233
|
+
// system 消息必须在对话开头,中间插 system 会报 "System message must be at the beginning" (500)。
|
|
232
234
|
if (smallModel && !intentGuided && this.state.messages.length > 0) {
|
|
233
235
|
const guidance = buildIntentGuidance(userMessage.content, { enable: true })
|
|
234
236
|
if (guidance) {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
+
// 找到第一条 system 消息,把引导拼接进去(保持 system 全在开头)
|
|
238
|
+
const sysIdx = this.state.messages.findIndex(m => m.role === 'system')
|
|
239
|
+
if (sysIdx !== -1) {
|
|
240
|
+
const sysMsg = this.state.messages[sysIdx]
|
|
241
|
+
this.state.messages[sysIdx] = {
|
|
242
|
+
...sysMsg,
|
|
243
|
+
content: (typeof sysMsg.content === 'string' ? sysMsg.content : '') + '\n\n' + guidance,
|
|
244
|
+
}
|
|
245
|
+
} else {
|
|
246
|
+
// 没有 system 消息 → 作为 user 引导插入(跟随在最新 user 之后作为新 user)
|
|
247
|
+
this.state.messages.push({ role: 'user', content: guidance })
|
|
248
|
+
}
|
|
249
|
+
if (this.config.verbose) console.error('[small-model] 已注入意图引导(并入首条 system):' + guidance.slice(0, 60) + '...')
|
|
237
250
|
}
|
|
238
251
|
intentGuided = true
|
|
239
252
|
}
|
package/src/core/small-model.js
CHANGED
|
@@ -118,6 +118,13 @@ export const RETRY_GUIDANCE = `[系统提示] 你刚才没有调用任何工具
|
|
|
118
118
|
// note: 给模型的动作说明
|
|
119
119
|
|
|
120
120
|
const INTENT_RULES = [
|
|
121
|
+
{
|
|
122
|
+
// 读/查看/阅读文档或文件 → 读取任务(优先于写规则,避免"阅读XX文档"被误判为写)
|
|
123
|
+
pattern: /(读|阅读|查看|打开|展示|显示|看看|浏览).*(文档|文件|内容|md|readme|代码|计划)/i,
|
|
124
|
+
plan: ['Read(读文件内容)'],
|
|
125
|
+
note: '这是读取任务,用 Read 读取目标文件内容并理解。',
|
|
126
|
+
toolHint: 'Read, Glob',
|
|
127
|
+
},
|
|
121
128
|
{
|
|
122
129
|
// 写文档/文件/计划/代码:覆盖"写/创建/生成/更新/保存/做好...文档/计划"等
|
|
123
130
|
pattern: /(写|创建|生成|更新|保存|做好|做一份|制定|起草|撰写|输出|整理|编写).*(文档|文件|计划|方案|说明|md|readme|代码|函数|模块|接口)/i,
|