deeper-cli 1.0.1 → 1.0.3
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/index.js +49 -5
- package/dist/cli/index.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/chat-repl.ts +43 -5
package/package.json
CHANGED
package/src/cli/chat-repl.ts
CHANGED
|
@@ -87,7 +87,7 @@ export async function startRepl(opts: ReplOptions): Promise<void> {
|
|
|
87
87
|
|
|
88
88
|
if (tcs.length > 0) {
|
|
89
89
|
stag = 0;
|
|
90
|
-
lh.push({ role: 'assistant', content: fc || null, reasoning_content:
|
|
90
|
+
lh.push({ role: 'assistant', content: fc || null, reasoning_content: th || undefined, tool_calls: tcs.map(t => ({ id: t.id, name: t.name, arguments: { ...t.args } })) });
|
|
91
91
|
for (const tc of tcs) {
|
|
92
92
|
const tool = tools.find(t => t.name === tc.name);
|
|
93
93
|
if (!tool) { lh.push({ role: 'tool', content: `Error: unknown ${tc.name}`, tool_call_id: tc.id }); continue; }
|
|
@@ -103,7 +103,7 @@ export async function startRepl(opts: ReplOptions): Promise<void> {
|
|
|
103
103
|
trimHistory(lh, 20); continue;
|
|
104
104
|
}
|
|
105
105
|
// 无工具调用但有文本 → 完成
|
|
106
|
-
if (fc) { lh.push({ role: 'assistant', content: fc }); stag = 0; }
|
|
106
|
+
if (fc) { lh.push({ role: 'assistant', content: fc, reasoning_content: th || undefined }); stag = 0; }
|
|
107
107
|
else { stag++; if (stag >= 3) return `停滞: 连续${stag}轮无进展`; continue; }
|
|
108
108
|
const final = lh[lh.length-1]?.content || '完成';
|
|
109
109
|
return final.slice(0, 800);
|
|
@@ -239,6 +239,8 @@ export async function startRepl(opts: ReplOptions): Promise<void> {
|
|
|
239
239
|
O(G(' /tasks') + G(' 任务列表') + '\n');
|
|
240
240
|
O(G(' /rules') + G(' 规则管理') + '\n');
|
|
241
241
|
O(G(' /mcp') + G(' MCP服务器') + '\n');
|
|
242
|
+
O(G(' /plan') + G(' <任务> 先出方案') + '\n');
|
|
243
|
+
O(G(' /spec') + G(' <任务> 先出规格') + '\n');
|
|
242
244
|
O(G(' /status') + G(' 当前状态') + '\n');
|
|
243
245
|
O(G(' /model') + G(' 模型设置') + '\n');
|
|
244
246
|
O(G(' /config') + G(' 配置管理') + '\n');
|
|
@@ -302,7 +304,43 @@ export async function startRepl(opts: ReplOptions): Promise<void> {
|
|
|
302
304
|
}
|
|
303
305
|
if (cmd === '/help') {
|
|
304
306
|
O(c(' /help /clear /quit /save [name] /load|resume [name] /sessions\n'));
|
|
305
|
-
O(c(' /tools [cat] /stats /memory /tasks /model /config /cwd /export /init /mcp /rules\n
|
|
307
|
+
O(c(' /tools [cat] /stats /memory /tasks /model /config /cwd /export /init /mcp /rules\n'));
|
|
308
|
+
O(c(' /plan <任务> /spec <任务> /status\n\n'));
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
311
|
+
if (cmd === '/plan') {
|
|
312
|
+
if (!arg) { O(y(' 用法: /plan <任务描述>\n\n')); continue; }
|
|
313
|
+
O(b(c(' Plan Mode')) + G(` • ${arg.slice(0, 50)}`) + '\n\n');
|
|
314
|
+
history.push({ role: 'system', content: `[Plan Mode]
|
|
315
|
+
你必须遵循以下流程,严格按步骤执行:
|
|
316
|
+
1. 先输出一份详尽的实施方案(不要写代码)
|
|
317
|
+
2. 方案必须包含:需求分析、技术选型、架构设计、数据流、模块划分、实施步骤
|
|
318
|
+
3. 等待用户确认方案(输入 ok/继续/可以 等确认词)
|
|
319
|
+
4. 用户确认后,按方案逐步实施,每完成一步更新 todo
|
|
320
|
+
5. 完成后总结交付内容
|
|
321
|
+
|
|
322
|
+
当前任务:${arg}` });
|
|
323
|
+
history.push({ role: 'user', content: arg });
|
|
324
|
+
const pfdefs = toolsToDefs(tools);
|
|
325
|
+
await runLoop(opts, history, tools, pfdefs, confirm);
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
if (cmd === '/spec') {
|
|
329
|
+
if (!arg) { O(y(' 用法: /spec <任务描述>\n\n')); continue; }
|
|
330
|
+
O(b(c(' Spec Mode')) + G(` • ${arg.slice(0, 50)}`) + '\n\n');
|
|
331
|
+
history.push({ role: 'system', content: `[Spec Mode]
|
|
332
|
+
你必须遵循以下流程,严格按步骤执行:
|
|
333
|
+
1. 先输出一份完整的产品规格文档(不要写代码)
|
|
334
|
+
2. 规格文档必须包含:需求概述、功能清单、交互设计、数据结构、API设计、组件树、非功能性需求、测试策略、里程碑
|
|
335
|
+
3. 文档使用 Markdown 格式,标题用 # 层次清晰
|
|
336
|
+
4. 等待用户确认规格(输入 ok/继续/可以 等确认词)
|
|
337
|
+
5. 用户确认后,按规格逐步实施,每完成一步更新 todo
|
|
338
|
+
6. 完成后总结交付内容
|
|
339
|
+
|
|
340
|
+
当前任务:${arg}` });
|
|
341
|
+
history.push({ role: 'user', content: arg });
|
|
342
|
+
const sfdefs = toolsToDefs(tools);
|
|
343
|
+
await runLoop(opts, history, tools, sfdefs, confirm);
|
|
306
344
|
continue;
|
|
307
345
|
}
|
|
308
346
|
O(G(` 未知命令: ${cmd} (输入 /help 查看帮助)\n\n`));
|
|
@@ -435,7 +473,7 @@ async function runLoop(
|
|
|
435
473
|
stagnation = 0;
|
|
436
474
|
Oflush();
|
|
437
475
|
const compactFc = fc && fc.length > 500 ? fc.replace(/\n/g, ' ').slice(0, 300) + '…' : fc;
|
|
438
|
-
history.push({ role: 'assistant', content: compactFc || null, reasoning_content: undefined, tool_calls: tcs.map(t => ({ id: t.id, name: t.name, arguments: { ...t.args } })) });
|
|
476
|
+
history.push({ role: 'assistant', content: compactFc || null, reasoning_content: th || undefined, tool_calls: tcs.map(t => ({ id: t.id, name: t.name, arguments: { ...t.args } })) });
|
|
439
477
|
fc = ''; th = '';
|
|
440
478
|
let doneTools = 0;
|
|
441
479
|
|
|
@@ -468,7 +506,7 @@ async function runLoop(
|
|
|
468
506
|
trimHistory(history, MAX_HISTORY); continue;
|
|
469
507
|
}
|
|
470
508
|
|
|
471
|
-
if (fc) { history.push({ role: 'assistant', content: fc }); stagnation = 0; }
|
|
509
|
+
if (fc) { history.push({ role: 'assistant', content: fc, reasoning_content: th || undefined }); stagnation = 0; }
|
|
472
510
|
else { stagnation++; }
|
|
473
511
|
|
|
474
512
|
const ctxPct = ((totalCtx / CONTEXT_LIMIT) * 100).toFixed(1);
|