@cjhyy/code-shell-core 0.6.0-rc.8 → 0.7.0-beta.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.
Files changed (177) hide show
  1. package/THIRD_PARTY_NOTICES.md +206 -0
  2. package/dist/automation/scheduler.d.ts +13 -7
  3. package/dist/automation/scheduler.js +116 -37
  4. package/dist/capability-control/service.d.ts +2 -0
  5. package/dist/capability-control/service.js +4 -2
  6. package/dist/cc-orchestrator/agent-adapter.d.ts +2 -0
  7. package/dist/cc-orchestrator/agent-adapter.js +7 -1
  8. package/dist/cc-orchestrator/codex-session-history.js +1 -1
  9. package/dist/cc-orchestrator/cwd-normalize.d.ts +2 -0
  10. package/dist/cc-orchestrator/cwd-normalize.js +19 -0
  11. package/dist/cc-orchestrator/external-agent-bindings.d.ts +27 -0
  12. package/dist/cc-orchestrator/external-agent-bindings.js +150 -0
  13. package/dist/cc-orchestrator/external-agent-driver.d.ts +1 -0
  14. package/dist/cc-orchestrator/external-agent-driver.js +102 -51
  15. package/dist/cc-orchestrator/external-agent-session-store.d.ts +23 -0
  16. package/dist/cc-orchestrator/external-agent-session-store.js +146 -0
  17. package/dist/cc-orchestrator/session-history.js +2 -2
  18. package/dist/cli/agent-server-stdio.js +9 -2
  19. package/dist/context/compaction.d.ts +38 -1
  20. package/dist/context/compaction.js +138 -0
  21. package/dist/context/manager.d.ts +34 -2
  22. package/dist/context/manager.js +254 -58
  23. package/dist/context/token-counter.js +13 -0
  24. package/dist/credentials/access.d.ts +56 -0
  25. package/dist/credentials/access.js +183 -0
  26. package/dist/credentials/index.d.ts +1 -0
  27. package/dist/credentials/index.js +1 -0
  28. package/dist/credentials/inject-credential-tool.d.ts +3 -1
  29. package/dist/credentials/inject-credential-tool.js +30 -11
  30. package/dist/credentials/types.d.ts +2 -2
  31. package/dist/credentials/use-credential-tool.d.ts +9 -1
  32. package/dist/credentials/use-credential-tool.js +58 -45
  33. package/dist/engine/engine.d.ts +38 -12
  34. package/dist/engine/engine.js +477 -163
  35. package/dist/engine/image-policy.d.ts +6 -0
  36. package/dist/engine/image-policy.js +17 -6
  37. package/dist/engine/input-attachments.d.ts +13 -0
  38. package/dist/engine/input-attachments.js +255 -0
  39. package/dist/engine/model-facade.d.ts +5 -2
  40. package/dist/engine/model-facade.js +6 -16
  41. package/dist/engine/parse-task.d.ts +10 -0
  42. package/dist/engine/parse-task.js +5 -0
  43. package/dist/engine/query.js +2 -0
  44. package/dist/engine/session-usage.d.ts +12 -0
  45. package/dist/engine/session-usage.js +56 -0
  46. package/dist/engine/steer-queue.d.ts +2 -1
  47. package/dist/engine/steer-queue.js +2 -2
  48. package/dist/engine/streaming-tool-queue.d.ts +11 -7
  49. package/dist/engine/streaming-tool-queue.js +11 -7
  50. package/dist/engine/turn-loop.d.ts +34 -2
  51. package/dist/engine/turn-loop.js +269 -52
  52. package/dist/engine/types.d.ts +8 -0
  53. package/dist/git/worktree/crud.d.ts +69 -0
  54. package/dist/git/worktree/crud.js +206 -0
  55. package/dist/git/worktree/diff.d.ts +14 -0
  56. package/dist/git/worktree/diff.js +82 -0
  57. package/dist/git/worktree/git-exec.d.ts +7 -0
  58. package/dist/git/worktree/git-exec.js +51 -0
  59. package/dist/git/worktree/index.d.ts +5 -0
  60. package/dist/git/worktree/index.js +5 -0
  61. package/dist/git/worktree/query.d.ts +42 -0
  62. package/dist/git/worktree/query.js +121 -0
  63. package/dist/git/worktree/slug.d.ts +11 -0
  64. package/dist/git/worktree/slug.js +58 -0
  65. package/dist/git/worktree.d.ts +1 -84
  66. package/dist/git/worktree.js +5 -230
  67. package/dist/index.d.ts +31 -28
  68. package/dist/index.js +27 -25
  69. package/dist/logging/logger.js +6 -6
  70. package/dist/logging/sanitize-messages.d.ts +10 -2
  71. package/dist/logging/sanitize-messages.js +21 -6
  72. package/dist/plugins/installer/checkUpdate.d.ts +4 -1
  73. package/dist/plugins/installer/checkUpdate.js +4 -2
  74. package/dist/plugins/installer/install.js +2 -0
  75. package/dist/plugins/installer/installFromSource.js +9 -1
  76. package/dist/plugins/installer/parseSource.d.ts +4 -1
  77. package/dist/plugins/installer/parseSource.js +28 -10
  78. package/dist/plugins/installer/sourcePath.d.ts +9 -0
  79. package/dist/plugins/installer/sourcePath.js +50 -0
  80. package/dist/plugins/installer/update.d.ts +4 -1
  81. package/dist/plugins/installer/update.js +5 -3
  82. package/dist/plugins/parseMarketplaceInput.d.ts +4 -1
  83. package/dist/plugins/parseMarketplaceInput.js +4 -3
  84. package/dist/plugins/pluginInstaller.js +24 -22
  85. package/dist/preset/index.d.ts +1 -0
  86. package/dist/preset/index.js +16 -9
  87. package/dist/prompt/sections/base.md +1 -1
  88. package/dist/protocol/chat-session-manager.d.ts +2 -0
  89. package/dist/protocol/chat-session-manager.js +38 -2
  90. package/dist/protocol/chat-session.d.ts +5 -0
  91. package/dist/protocol/chat-session.js +2 -0
  92. package/dist/protocol/client.d.ts +13 -5
  93. package/dist/protocol/client.js +26 -3
  94. package/dist/protocol/server.d.ts +43 -12
  95. package/dist/protocol/server.js +326 -104
  96. package/dist/protocol/types.d.ts +51 -0
  97. package/dist/protocol/types.js +6 -0
  98. package/dist/run/FileRunStore.js +10 -1
  99. package/dist/run/Heartbeat.js +12 -0
  100. package/dist/run/RunApprovalBackend.d.ts +3 -0
  101. package/dist/run/RunApprovalBackend.js +41 -6
  102. package/dist/run/RunLock.js +2 -0
  103. package/dist/run/RunManager.d.ts +2 -0
  104. package/dist/run/RunManager.js +64 -24
  105. package/dist/run/ids.d.ts +2 -0
  106. package/dist/run/ids.js +23 -0
  107. package/dist/runtime/background-shell.d.ts +1 -0
  108. package/dist/runtime/background-shell.js +23 -13
  109. package/dist/runtime/safe-spawn.js +74 -11
  110. package/dist/runtime/spawn-common.js +10 -0
  111. package/dist/services/auto-dream.d.ts +15 -4
  112. package/dist/services/auto-dream.js +20 -20
  113. package/dist/services/dream-consolidation.d.ts +2 -3
  114. package/dist/services/dream-consolidation.js +65 -15
  115. package/dist/services/extract-memories.d.ts +14 -5
  116. package/dist/services/extract-memories.js +20 -3
  117. package/dist/services/global-dream-promotion.d.ts +23 -0
  118. package/dist/services/global-dream-promotion.js +112 -0
  119. package/dist/services/memory-orchestrator.js +347 -34
  120. package/dist/session/memory.d.ts +61 -18
  121. package/dist/session/memory.js +342 -79
  122. package/dist/session/session-manager.d.ts +35 -1
  123. package/dist/session/session-manager.js +197 -4
  124. package/dist/session/transcript.d.ts +5 -1
  125. package/dist/session/transcript.js +38 -5
  126. package/dist/settings/manager.d.ts +1 -0
  127. package/dist/settings/manager.js +87 -37
  128. package/dist/settings/schema-export.d.ts +2 -3
  129. package/dist/settings/schema-export.js +2 -3
  130. package/dist/settings/schema.d.ts +21 -0
  131. package/dist/settings/schema.js +12 -0
  132. package/dist/skills/scanner.d.ts +3 -2
  133. package/dist/skills/scanner.js +12 -9
  134. package/dist/tool-system/builtin/background-jobs.d.ts +10 -1
  135. package/dist/tool-system/builtin/background-jobs.js +12 -1
  136. package/dist/tool-system/builtin/background-work.d.ts +17 -18
  137. package/dist/tool-system/builtin/background-work.js +51 -5
  138. package/dist/tool-system/builtin/config.d.ts +2 -1
  139. package/dist/tool-system/builtin/config.js +16 -11
  140. package/dist/tool-system/builtin/drive-claude-code.d.ts +16 -2
  141. package/dist/tool-system/builtin/drive-claude-code.js +301 -47
  142. package/dist/tool-system/builtin/edit.js +5 -2
  143. package/dist/tool-system/builtin/generate-video.d.ts +1 -0
  144. package/dist/tool-system/builtin/generate-video.js +13 -4
  145. package/dist/tool-system/builtin/index.d.ts +8 -3
  146. package/dist/tool-system/builtin/index.js +37 -21
  147. package/dist/tool-system/builtin/lsp.d.ts +2 -1
  148. package/dist/tool-system/builtin/lsp.js +6 -3
  149. package/dist/tool-system/builtin/memory.js +40 -8
  150. package/dist/tool-system/builtin/notebook-edit.js +5 -2
  151. package/dist/tool-system/builtin/powershell.d.ts +5 -2
  152. package/dist/tool-system/builtin/powershell.js +11 -7
  153. package/dist/tool-system/builtin/read.js +118 -6
  154. package/dist/tool-system/builtin/view-image.d.ts +2 -2
  155. package/dist/tool-system/builtin/view-image.js +109 -19
  156. package/dist/tool-system/builtin/worktree.d.ts +4 -4
  157. package/dist/tool-system/builtin/worktree.js +297 -74
  158. package/dist/tool-system/builtin/write.js +5 -3
  159. package/dist/tool-system/context.d.ts +23 -1
  160. package/dist/tool-system/executor.d.ts +1 -5
  161. package/dist/tool-system/executor.js +94 -115
  162. package/dist/tool-system/mcp-manager.d.ts +18 -5
  163. package/dist/tool-system/mcp-manager.js +157 -74
  164. package/dist/tool-system/mcp-stdio-diagnostics.d.ts +9 -0
  165. package/dist/tool-system/mcp-stdio-diagnostics.js +93 -0
  166. package/dist/tool-system/path-policy.d.ts +2 -0
  167. package/dist/tool-system/path-policy.js +41 -12
  168. package/dist/tool-system/permission.d.ts +28 -7
  169. package/dist/tool-system/permission.js +130 -49
  170. package/dist/tool-system/registry.js +11 -4
  171. package/dist/tool-system/tool-result-redaction.d.ts +7 -0
  172. package/dist/tool-system/tool-result-redaction.js +48 -0
  173. package/dist/tool-system/workspace-bridge.d.ts +11 -0
  174. package/dist/tool-system/workspace-bridge.js +1 -0
  175. package/dist/types.d.ts +86 -5
  176. package/dist/utils/toolDisplay.js +1 -1
  177. package/package.json +4 -3
@@ -12,7 +12,11 @@
12
12
  * auto-extracted entries (extract-memories output). LLM may
13
13
  * only modify these through permission-gated tool calls.
14
14
  * - dream/ The dream pipeline's workspace. The LLM is free to add /
15
- * merge / delete entries here; user/ is read-only to dream.
15
+ * merge / delete entries here. The dream loop may ALSO maintain
16
+ * user/ entries whose origin is `auto` or `dream` (dedup/merge/
17
+ * improve), but origin:`manual` user entries — things the user
18
+ * explicitly asked to remember — are never touched by dream.
19
+ * See dream-consolidation.ts (the origin guard at ~:240).
16
20
  *
17
21
  * MEMORY.md is the index file (one per scope).
18
22
  *
@@ -29,15 +33,20 @@
29
33
  * panel. Keeps the global layer curated — nothing auto-lands global.
30
34
  */
31
35
  export type MemoryScope = "user" | "dream" | "pending";
36
+ export type MemoryOrigin = "auto" | "manual" | "dream";
32
37
  export interface MemoryEntry {
38
+ /** Stable identity. Legacy files without frontmatter id read as legacy:<scope>:<fileName>. */
39
+ id?: string;
33
40
  name: string;
34
41
  description: string;
35
42
  type: "user" | "feedback" | "project" | "reference";
36
43
  content: string;
37
44
  fileName: string;
38
45
  scope: MemoryScope;
46
+ /** Semantic last content update time from frontmatter. */
47
+ updatedAt?: string;
39
48
  /** File mtime in epoch ms — drives maxAge filtering (TODO 8.1). 0 if unknown. */
40
- updatedAt?: number;
49
+ mtimeMs?: number;
41
50
  /**
42
51
  * 固定/置顶 (feedback#18 方案 A): a pinned memory is exempt from maxAge
43
52
  * injection filtering and sorts first in the injected context. UI surfaces
@@ -49,15 +58,20 @@ export interface MemoryEntry {
49
58
  * "manual" (or absent — legacy files) = written by the user/UI. Lets the
50
59
  * UI distinguish curated memories from extractor noise.
51
60
  */
52
- origin?: "auto" | "manual";
61
+ origin?: MemoryOrigin;
53
62
  /**
54
- * Recall lifecycle (召回 TTL). `usageCount` increments each time MemoryRead
55
- * hits this entry; `lastUsed` is the ISO timestamp of that last hit; `created`
56
- * is set on first save and preserved across UPDATE. Drives recall-based TTL:
63
+ * Recall lifecycle (召回 TTL). `useCount` increments each time MemoryRead
64
+ * hits this entry; `lastUsedAt` is the ISO timestamp of that last hit;
65
+ * `createdAt` is set on first save and preserved across UPDATE. Drives recall-based TTL:
57
66
  * a `project`-type memory not read for N days is pruned. Stored in frontmatter
58
- * — no SQLite. Legacy files lacking these fields read back as
59
- * {usageCount:0, lastUsed/created mtime}, never hidden.
67
+ * — no SQLite. Legacy `usageCount/lastUsed/created` fields are still read and
68
+ * exposed through their old aliases for compatibility.
60
69
  */
70
+ useCount?: number;
71
+ updateCount?: number;
72
+ lastUsedAt?: string;
73
+ createdAt?: string;
74
+ /** Legacy compatibility aliases. New writes use useCount/lastUsedAt/createdAt. */
61
75
  usageCount?: number;
62
76
  lastUsed?: string;
63
77
  created?: string;
@@ -67,6 +81,15 @@ export interface MemoryEntry {
67
81
  * user store (not the current one). Absent → fall back to no-repo / global.
68
82
  */
69
83
  originProject?: string;
84
+ /** Global dream promotion metadata (P1). */
85
+ promotionKey?: string;
86
+ originProjects?: string[];
87
+ evidenceCount?: number;
88
+ firstSeenAt?: string;
89
+ lastSeenAt?: string;
90
+ promotionReason?: string;
91
+ promotionStatus?: "pending" | "rejected";
92
+ promotionSourceId?: string;
70
93
  }
71
94
  /**
72
95
  * Drop memories older than `maxAgeDays` (by file mtime) for context injection
@@ -75,6 +98,12 @@ export interface MemoryEntry {
75
98
  * just because we couldn't read its timestamp. Pure + testable.
76
99
  */
77
100
  export declare function filterByAge(entries: MemoryEntry[], maxAgeDays?: number, now?: number): MemoryEntry[];
101
+ export interface SaveMemoryOptions {
102
+ /** False for lifecycle-only writes such as recordRecall and pin/unpin. */
103
+ incrementUpdateCount?: boolean;
104
+ /** Force provenance regardless of model/tool args. Used by origin guards. */
105
+ forceOrigin?: MemoryOrigin;
106
+ }
78
107
  export interface MemoryManagerOptions {
79
108
  /** Project root path; when set, memories are scoped under projects/<hash>/memory. */
80
109
  projectDir?: string;
@@ -97,13 +126,18 @@ export declare class MemoryManager {
97
126
  getMemoryDir(): string;
98
127
  getScope(): MemoryScope;
99
128
  /**
100
- * Save a memory entry. Creates the file and updates the index.
129
+ * Save a memory entry. New entries get a stable id and `<id>.md`; entries
130
+ * carrying an existing id update that file even when name changes.
101
131
  */
102
- save(entry: Omit<MemoryEntry, "fileName" | "scope">): string;
132
+ save(entry: Omit<MemoryEntry, "fileName" | "scope">, opts?: SaveMemoryOptions): string;
103
133
  /**
104
134
  * Load all memory entries.
105
135
  */
106
136
  loadAll(): MemoryEntry[];
137
+ findById(id: string): MemoryEntry | undefined;
138
+ find(nameOrFileOrId: string): MemoryEntry | undefined;
139
+ isOwnedBy(entry: MemoryEntry | undefined, allowedOrigins: readonly MemoryOrigin[]): boolean;
140
+ deleteIfOwned(nameOrFileOrId: string, allowedOrigins: readonly MemoryOrigin[]): "deleted" | "not_found" | "protected";
107
141
  /**
108
142
  * Load a single memory file.
109
143
  */
@@ -136,13 +170,14 @@ export declare class MemoryManager {
136
170
  */
137
171
  pruneByRecall(ttlDays: number, now?: Date): string[];
138
172
  /**
139
- * Approve a pending memory: move it from the pending scope into the user scope
140
- * of the SAME memory root (pending only ever exists at the global root — the
141
- * approval only gates global writes). Must be called on a pending-scope
142
- * manager. Returns the new user filename, or null if not found / wrong scope.
173
+ * Approve a pending memory: move it from the pending scope into the global
174
+ * dream scope of the SAME memory root. Pending only ever exists at the global
175
+ * root; approval gates whether a suggested global dream becomes injected.
176
+ * Must be called on a pending-scope manager. Returns the new global dream
177
+ * filename, or null if not found / wrong scope.
143
178
  *
144
- * 审批门 (用户拍板): the only path that moves an auto-extracted memory into the
145
- * curated, injected global user store.
179
+ * 审批门 (用户拍板): the only path that moves a suggested global dream into the
180
+ * injected global dream store.
146
181
  */
147
182
  approvePending(nameOrFile: string): string | null;
148
183
  /**
@@ -150,7 +185,12 @@ export declare class MemoryManager {
150
185
  * user store (originProject)。无 originProject 时落全局 user(兜底,不丢)。
151
186
  */
152
187
  demotePending(nameOrFile: string): string | null;
153
- /** Shared move for approve(→global user)/demote(→origin-project user). */
188
+ /**
189
+ * Reject a pending global-dream suggestion. The project dream entry stays in
190
+ * place, but is marked so the same source is not suggested again.
191
+ */
192
+ rejectPending(nameOrFile: string): boolean;
193
+ /** Shared move for approve(→global dream)/demote(→origin-project user). */
154
194
  private movePending;
155
195
  /**
156
196
  * Promote a project-level user memory to the GLOBAL user store (用户手动点
@@ -214,5 +254,8 @@ export declare class MemoryManager {
214
254
  */
215
255
  private ensureIndexCache;
216
256
  private writeIndex;
217
- private slugify;
257
+ private generateId;
258
+ private availableFileNameForId;
259
+ private fileNameForId;
260
+ private parseSyntheticLegacyId;
218
261
  }