mocode-ai 1.9.0 → 1.9.1

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.
@@ -36,6 +36,11 @@ function statusMark(e, st, anchor) {
36
36
  const why = describeAnchorState(anchor);
37
37
  parts.push(`STALE-CODE${why ? ` (${why})` : ''}`);
38
38
  }
39
+ // R16.1:来源标记。只在**二手转述**时出现——内容逐字来自工具输出(网页/文件/命令),
40
+ // 模型没经用户确认就记了下来。给的是"引用前先核实"的提示,不是"这条是假的"。
41
+ // 默认路径(模型自己总结的事实)不加标记,保持零噪音。
42
+ if (e.origin === 'tool_output')
43
+ parts.push('UNVERIFIED-ORIGIN');
39
44
  return parts.length > 0 ? ` [${parts.join(' | ')}]` : '';
40
45
  }
41
46
  export const memorySearchTool = {
@@ -14,8 +14,10 @@ function parseAnchorInputs(raw) {
14
14
  const p = typeof a.path === 'string' ? a.path.trim() : '';
15
15
  if (!p)
16
16
  continue;
17
+ // R7.1:非法 kind 按 file 处理(与 memory_save 同口径),不因此丢整条锚点。
18
+ const k = a.kind === 'dir' || a.kind === 'url' ? a.kind : undefined;
17
19
  const s = typeof a.symbol === 'string' ? a.symbol.trim() : '';
18
- out.push({ path: p, ...(s ? { symbol: s } : {}) });
20
+ out.push({ ...(k ? { kind: k } : {}), path: p, ...(s ? { symbol: s } : {}) });
19
21
  }
20
22
  return out;
21
23
  }
@@ -44,11 +46,19 @@ export const memoryUpdateTool = {
44
46
  },
45
47
  anchors: {
46
48
  type: 'array',
47
- description: 'R2 code anchors — REPLACES the whole set (pass [] to clear). Only paths/symbols; the content hash is recomputed at write time. Use this when the memory is about a specific file/function and you want a later edit to surface it as stale instead of silently serving an outdated fact.',
49
+ description: 'Anchors — REPLACES the whole set (pass [] to clear). kind=file (default) for a file or symbol; dir for a directory (detects added/removed/renamed entries, not edits inside files); url for a web page (provenance only, never fetched so never verified). Pass paths/symbols only; hashes are recomputed at write time. Use this so a later change surfaces the memory as stale instead of silently serving an outdated fact.',
48
50
  items: {
49
51
  type: 'object',
50
52
  properties: {
51
- path: { type: 'string', description: 'Workspace-relative file path, e.g. "src/memory/store.ts"' },
53
+ kind: {
54
+ type: 'string',
55
+ enum: ['file', 'dir', 'url'],
56
+ description: 'Default "file". Use "dir" for a directory, "url" for a web page.',
57
+ },
58
+ path: {
59
+ type: 'string',
60
+ description: 'Workspace-relative file/directory path, or an http(s) URL when kind=url',
61
+ },
52
62
  symbol: {
53
63
  type: 'string',
54
64
  description: 'Optional function/class/const name; prefers a fragment over the whole file',
@@ -529,7 +529,12 @@ export async function promptWithSlashMenu(opts) {
529
529
  computeFiltered();
530
530
  redraw();
531
531
  }
532
- /** Ctrl+C:有内容(已打字 / 多行 / 粘贴块 / 菜单草稿 / 粘贴缓冲 / 粘贴中)则清空,再按一次(空)才退出(仿 fish)。 */
532
+ /**
533
+ * Ctrl+C 分级清空(仿 fish,逐级放弃当前输入,最后一级才退出):
534
+ * 1. 有文本/菜单/粘贴缓冲 → 只清文本(留快照供 Ctrl+Z 还原);
535
+ * 2. 文本已空但有待发图片 → 清附件(Ctrl+Y 刚截的图,避免误清故单独一级);
536
+ * 3. 都空 → 退出(SIGINT)。
537
+ */
533
538
  function onCtrlC() {
534
539
  const flat = segs.map((s) => s.text).join('');
535
540
  const hasContent = flat.length > 0 || menuOpen || pasteState.pasteParts.length > 0 || pasteState.pasting;
@@ -537,6 +542,11 @@ export async function promptWithSlashMenu(opts) {
537
542
  clearInput();
538
543
  return;
539
544
  }
545
+ if (opts.hasPendingAttachments?.()) {
546
+ opts.clearPendingAttachments?.();
547
+ redraw(); // 脚栏 chip 擦除(sync 已更新 layout state,这里触发重画)
548
+ return;
549
+ }
540
550
  cleanup();
541
551
  reject(new Error('SIGINT'));
542
552
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mocode-ai",
3
- "version": "1.9.0",
3
+ "version": "1.9.1",
4
4
  "description": "终端编码 agent:LLM + tool-call 循环 + 流式输出(含思考)+ 27 个工具,接任意 OpenAI 兼容后端。",
5
5
  "type": "module",
6
6
  "bin": {