mocode-ai 1.1.3 → 1.1.4

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.
@@ -178,8 +178,12 @@ export function buildBasePrompt(sessionId = getCurrentSessionId()) {
178
178
  const memorySection = buildMemoryPromptSection();
179
179
  const notepadSection = buildNotepadSection(sessionId);
180
180
  // 静态主体:稳定段落集中在前,让支持 prompt caching 的后端能命中前缀缓存(#12)。
181
+ // 约束:staticBody 的前缀段(尤其 ## Core behavior 第一行)必须是纯静态文本,
182
+ // 不得嵌入会话级可变函数调用(如 t()/config.model)。否则 /language、/model
183
+ // 切换会让最敏感的前缀变化,破坏自动前缀缓存命中。可变值统一放到
184
+ // ## Termination & Reporting 段末尾(仍在切片边界之前,子 agent 仍能拿到)。
181
185
  const staticBody = `## Core behavior
182
- You are mocode, a terminal coding agent. Complete programming tasks through a "think → call tool → observe result → think again" loop until solved. ${t('assistant.languageInstruction')}
186
+ You are mocode, a terminal coding agent. Complete programming tasks through a "think → call tool → observe result → think again" loop until solved.
183
187
 
184
188
  ## Modes
185
189
  - AUTO is the default: investigate and complete the task with the tools currently exposed.
@@ -213,26 +217,33 @@ ${buildCodegraphSection()}
213
217
  - Stop immediately when no more tools are needed; give conclusions directly.
214
218
  - **Do not stop prematurely during exploration**: if you started investigating but haven't gathered enough information to answer the user's question, keep calling tools. Only stop when you have sufficient evidence or hit a dead end.
215
219
  - **No flattery / no preamble in conclusions**: skip "Sure", "好的", "我已经完成了" and similar no-information prefixes — jump straight to substance.
216
- - Report honestly: say success when successful, say where you're stuck when failing, and mention anything skipped. Reference code in "path:line" format (e.g., src/index.ts:42). Keep it concise.`;
217
- // 动态段(置于末尾):memory 索引 + notepad 目录。仅当有内容才拼
218
- // "## Project context" 标题,避免空标题噪声(#13)。notepad 使用说明始终保留。
220
+ - Report honestly: say success when successful, say where you're stuck when failing, and mention anything skipped. Reference code in "path:line" format (e.g., src/index.ts:42). Keep it concise.
221
+ ${t('assistant.languageInstruction')}`;
222
+ // 动态段(置于末尾):memory 索引 + notepad 目录与使用说明。
223
+ // 按需注入(#13):仅当有内容才拼对应标题/说明,避免空标题与无文件时的模板噪声。
224
+ // - "## Project context" 仅当 memorySection/notepadSection 非空;
225
+ // - notepad 使用说明仅当 notes.md 文件存在(notepadSection 非空)—
226
+ // 无文件时连 marker 都不拼,既省 token 也让前缀缓存更稳。core 切片
227
+ // 回退到 MARKER_DYNAMIC_SECTION 或整段(见 buildMocodeCorePrompt)。
219
228
  const dynamicParts = [];
220
229
  const ctxContent = `${memorySection}${notepadSection}`.trimEnd();
221
230
  if (ctxContent) {
222
231
  dynamicParts.push(`## Project context (dynamic reference)\n${ctxContent}`);
223
232
  }
224
- dynamicParts.push(`## Session Notepad (\`.mocode/sessions/${sessionId ?? '<id>'}/notes.md\`)\n` +
225
- 'Use this compact, persistent working surface for tasks with at least three steps or context-loss risk; skip it for simple work.\n\n' +
226
- 'Keep at most one active plan:\n' +
227
- '```\n' +
228
- '## Plan: <title>\n' +
229
- 'Goal: <outcome>\n' +
230
- '### Steps\n' +
231
- '- [ ] 1. <verifiable step>\n' +
232
- '### Progress\n' +
233
- '- <completed phase and evidence>\n' +
234
- '```\n' +
235
- 'Update checkboxes and Progress after each completed phase. Before the final reply, reconcile the plan with actual work, then rename it to `## Done:` or remove it. Keep other notes concise and session-specific; use memory for stable cross-session facts.');
233
+ if (notepadSection) {
234
+ dynamicParts.push(`## Session Notepad (\`.mocode/sessions/${sessionId ?? '<id>'}/notes.md\`)\n` +
235
+ 'Use this compact, persistent working surface for tasks with at least three steps or context-loss risk; skip it for simple work.\n\n' +
236
+ 'Keep at most one active plan:\n' +
237
+ '```\n' +
238
+ '## Plan: <title>\n' +
239
+ 'Goal: <outcome>\n' +
240
+ '### Steps\n' +
241
+ '- [ ] 1. <verifiable step>\n' +
242
+ '### Progress\n' +
243
+ '- <completed phase and evidence>\n' +
244
+ '```\n' +
245
+ 'Update checkboxes and Progress after each completed phase. Before the final reply, reconcile the plan with actual work, then rename it to `## Done:` or remove it. Keep other notes concise and session-specific; use memory for stable cross-session facts.');
246
+ }
236
247
  return `${staticBody}\n\n${dynamicParts.join('\n\n')}`;
237
248
  }
238
249
  /** 静态主体结束 + 会话私有段起点标记,供 buildMocodeCorePrompt 稳健切片(#17)。 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mocode-ai",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "终端编码 agent:LLM + tool-call 循环 + 流式输出(含思考)+ 16 个工具,接任意 OpenAI 兼容后端。",
5
5
  "type": "module",
6
6
  "bin": {