strands-darwin 0.0.34 → 0.0.36

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 (273) hide show
  1. package/README.md +22 -3
  2. package/README.zh-CN.md +22 -3
  3. package/dist/patches/@strands-agents+sdk+1.16.0.patch +29 -15
  4. package/dist/patches/ink+7.1.1.patch +58 -0
  5. package/dist/src/agent/background-delegation.d.ts +3 -3
  6. package/dist/src/agent/background-delegation.js +2 -2
  7. package/dist/src/agent/background-delegation.js.map +1 -1
  8. package/dist/src/agent/context-breakdown.d.ts +2 -1
  9. package/dist/src/agent/context-breakdown.js +2 -1
  10. package/dist/src/agent/context-breakdown.js.map +1 -1
  11. package/dist/src/agent/instructions.d.ts +22 -3
  12. package/dist/src/agent/instructions.js +67 -34
  13. package/dist/src/agent/instructions.js.map +1 -1
  14. package/dist/src/agent/prompt-cache.js +15 -2
  15. package/dist/src/agent/prompt-cache.js.map +1 -1
  16. package/dist/src/agent/refusal.d.ts +44 -7
  17. package/dist/src/agent/refusal.js +54 -8
  18. package/dist/src/agent/refusal.js.map +1 -1
  19. package/dist/src/agent/rewind.d.ts +2 -0
  20. package/dist/src/agent/rewind.js +4 -1
  21. package/dist/src/agent/rewind.js.map +1 -1
  22. package/dist/src/agent/runtime.d.ts +86 -13
  23. package/dist/src/agent/runtime.js +250 -43
  24. package/dist/src/agent/runtime.js.map +1 -1
  25. package/dist/src/agent/session.d.ts +96 -4
  26. package/dist/src/agent/session.js +249 -9
  27. package/dist/src/agent/session.js.map +1 -1
  28. package/dist/src/agent/stream-idle.d.ts +16 -0
  29. package/dist/src/agent/stream-idle.js +127 -0
  30. package/dist/src/agent/stream-idle.js.map +1 -0
  31. package/dist/src/agent/stream-resumption.d.ts +5 -2
  32. package/dist/src/agent/stream-resumption.js +5 -2
  33. package/dist/src/agent/stream-resumption.js.map +1 -1
  34. package/dist/src/agent/system-prompt.d.ts +1 -1
  35. package/dist/src/agent/system-prompt.js +4 -1
  36. package/dist/src/agent/system-prompt.js.map +1 -1
  37. package/dist/src/agent/thinking.js +4 -2
  38. package/dist/src/agent/thinking.js.map +1 -1
  39. package/dist/src/agent/working-context.d.ts +21 -1
  40. package/dist/src/agent/working-context.js +28 -1
  41. package/dist/src/agent/working-context.js.map +1 -1
  42. package/dist/src/agent/workspace-trust.d.ts +112 -0
  43. package/dist/src/agent/workspace-trust.js +207 -0
  44. package/dist/src/agent/workspace-trust.js.map +1 -0
  45. package/dist/src/agentcore/auto-policy.d.ts +7 -0
  46. package/dist/src/agentcore/auto-policy.js +50 -0
  47. package/dist/src/agentcore/auto-policy.js.map +1 -0
  48. package/dist/src/agentcore/auto-state.d.ts +43 -0
  49. package/dist/src/agentcore/auto-state.js +73 -0
  50. package/dist/src/agentcore/auto-state.js.map +1 -0
  51. package/dist/src/agentcore/cli.d.ts +2 -0
  52. package/dist/src/agentcore/cli.js +38 -0
  53. package/dist/src/agentcore/cli.js.map +1 -0
  54. package/dist/src/agentcore/config.d.ts +48 -0
  55. package/dist/src/agentcore/config.js +44 -0
  56. package/dist/src/agentcore/config.js.map +1 -0
  57. package/dist/src/agentcore/controller.d.ts +105 -0
  58. package/dist/src/agentcore/controller.js +979 -0
  59. package/dist/src/agentcore/controller.js.map +1 -0
  60. package/dist/src/agentcore/projection.d.ts +2 -0
  61. package/dist/src/agentcore/projection.js +8 -0
  62. package/dist/src/agentcore/projection.js.map +1 -0
  63. package/dist/src/agentcore/records.d.ts +41 -0
  64. package/dist/src/agentcore/records.js +149 -0
  65. package/dist/src/agentcore/records.js.map +1 -0
  66. package/dist/src/agentcore/state.d.ts +16 -0
  67. package/dist/src/agentcore/state.js +149 -0
  68. package/dist/src/agentcore/state.js.map +1 -0
  69. package/dist/src/agentcore/tools.d.ts +3 -0
  70. package/dist/src/agentcore/tools.js +11 -0
  71. package/dist/src/agentcore/tools.js.map +1 -0
  72. package/dist/src/agentcore/transport.d.ts +37 -0
  73. package/dist/src/agentcore/transport.js +242 -0
  74. package/dist/src/agentcore/transport.js.map +1 -0
  75. package/dist/src/agentcore/upload-projection.d.ts +208 -0
  76. package/dist/src/agentcore/upload-projection.js +823 -0
  77. package/dist/src/agentcore/upload-projection.js.map +1 -0
  78. package/dist/src/agents/child-recipe.js +4 -1
  79. package/dist/src/agents/child-recipe.js.map +1 -1
  80. package/dist/src/agents/loader.d.ts +12 -0
  81. package/dist/src/agents/loader.js +15 -1
  82. package/dist/src/agents/loader.js.map +1 -1
  83. package/dist/src/agents/subagent-tool.js +6 -7
  84. package/dist/src/agents/subagent-tool.js.map +1 -1
  85. package/dist/src/agents/workflow-tool.js +4 -6
  86. package/dist/src/agents/workflow-tool.js.map +1 -1
  87. package/dist/src/cli-doctor.js +14 -5
  88. package/dist/src/cli-doctor.js.map +1 -1
  89. package/dist/src/cli-import.d.ts +1 -0
  90. package/dist/src/cli-import.js +26 -0
  91. package/dist/src/cli-import.js.map +1 -0
  92. package/dist/src/cli-main.js +60 -10
  93. package/dist/src/cli-main.js.map +1 -1
  94. package/dist/src/cli-permissions.d.ts +2 -0
  95. package/dist/src/cli-permissions.js +20 -0
  96. package/dist/src/cli-permissions.js.map +1 -0
  97. package/dist/src/cli-sessions.js +6 -2
  98. package/dist/src/cli-sessions.js.map +1 -1
  99. package/dist/src/cli-usage.d.ts +9 -1
  100. package/dist/src/cli-usage.js +13 -0
  101. package/dist/src/cli-usage.js.map +1 -1
  102. package/dist/src/cli.js +19 -2
  103. package/dist/src/cli.js.map +1 -1
  104. package/dist/src/commands/custom-commands.d.ts +1 -1
  105. package/dist/src/commands/custom-commands.js +20 -6
  106. package/dist/src/commands/custom-commands.js.map +1 -1
  107. package/dist/src/commands/init-command.d.ts +47 -0
  108. package/dist/src/commands/init-command.js +110 -0
  109. package/dist/src/commands/init-command.js.map +1 -0
  110. package/dist/src/commands/review-command.d.ts +10 -0
  111. package/dist/src/commands/review-command.js +28 -0
  112. package/dist/src/commands/review-command.js.map +1 -0
  113. package/dist/src/config-file.d.ts +9 -0
  114. package/dist/src/config-file.js +82 -0
  115. package/dist/src/config-file.js.map +1 -0
  116. package/dist/src/config.d.ts +100 -7
  117. package/dist/src/config.js +253 -46
  118. package/dist/src/config.js.map +1 -1
  119. package/dist/src/dev-repl.js +33 -2
  120. package/dist/src/dev-repl.js.map +1 -1
  121. package/dist/src/headless-protocol.d.ts +24 -1
  122. package/dist/src/headless-protocol.js +24 -5
  123. package/dist/src/headless-protocol.js.map +1 -1
  124. package/dist/src/headless-runner.d.ts +8 -0
  125. package/dist/src/headless-runner.js +42 -2
  126. package/dist/src/headless-runner.js.map +1 -1
  127. package/dist/src/headless.d.ts +11 -0
  128. package/dist/src/headless.js +33 -7
  129. package/dist/src/headless.js.map +1 -1
  130. package/dist/src/hooks/hook-process.js +7 -2
  131. package/dist/src/hooks/hook-process.js.map +1 -1
  132. package/dist/src/hooks/lifecycle-hooks.js +3 -1
  133. package/dist/src/hooks/lifecycle-hooks.js.map +1 -1
  134. package/dist/src/hooks/tool-hooks.js +3 -1
  135. package/dist/src/hooks/tool-hooks.js.map +1 -1
  136. package/dist/src/import-claude-files.d.ts +28 -0
  137. package/dist/src/import-claude-files.js +227 -0
  138. package/dist/src/import-claude-files.js.map +1 -0
  139. package/dist/src/import-claude-snippets.d.ts +2 -0
  140. package/dist/src/import-claude-snippets.js +105 -0
  141. package/dist/src/import-claude-snippets.js.map +1 -0
  142. package/dist/src/import-claude.d.ts +13 -0
  143. package/dist/src/import-claude.js +287 -0
  144. package/dist/src/import-claude.js.map +1 -0
  145. package/dist/src/mcp/registry.d.ts +57 -1
  146. package/dist/src/mcp/registry.js +78 -6
  147. package/dist/src/mcp/registry.js.map +1 -1
  148. package/dist/src/memory/command.d.ts +1 -1
  149. package/dist/src/memory/command.js +89 -4
  150. package/dist/src/memory/command.js.map +1 -1
  151. package/dist/src/memory/controller.d.ts +32 -0
  152. package/dist/src/memory/controller.js +39 -3
  153. package/dist/src/memory/controller.js.map +1 -1
  154. package/dist/src/memory/state.d.ts +6 -0
  155. package/dist/src/memory/state.js +6 -1
  156. package/dist/src/memory/state.js.map +1 -1
  157. package/dist/src/memory/store.d.ts +13 -0
  158. package/dist/src/memory/store.js +38 -2
  159. package/dist/src/memory/store.js.map +1 -1
  160. package/dist/src/memory/tools.d.ts +7 -0
  161. package/dist/src/memory/tools.js +12 -1
  162. package/dist/src/memory/tools.js.map +1 -1
  163. package/dist/src/paths.js +3 -0
  164. package/dist/src/paths.js.map +1 -1
  165. package/dist/src/permissions-test.d.ts +18 -0
  166. package/dist/src/permissions-test.js +207 -0
  167. package/dist/src/permissions-test.js.map +1 -0
  168. package/dist/src/pricing/model-prices.d.ts +11 -6
  169. package/dist/src/pricing/model-prices.js +37 -16
  170. package/dist/src/pricing/model-prices.js.map +1 -1
  171. package/dist/src/project-identity.d.ts +3 -0
  172. package/dist/src/project-identity.js +8 -0
  173. package/dist/src/project-identity.js.map +1 -0
  174. package/dist/src/project-overrides.d.ts +57 -0
  175. package/dist/src/project-overrides.js +79 -0
  176. package/dist/src/project-overrides.js.map +1 -0
  177. package/dist/src/skills/builtin/setup-agentcore-memory/SKILL.md +158 -0
  178. package/dist/src/skills/loader.d.ts +1 -1
  179. package/dist/src/skills/loader.js +4 -1
  180. package/dist/src/skills/loader.js.map +1 -1
  181. package/dist/src/tools/background-bash.d.ts +21 -3
  182. package/dist/src/tools/background-bash.js +44 -8
  183. package/dist/src/tools/background-bash.js.map +1 -1
  184. package/dist/src/tools/file-editor-serial.d.ts +14 -0
  185. package/dist/src/tools/file-editor-serial.js +15 -0
  186. package/dist/src/tools/file-editor-serial.js.map +1 -1
  187. package/dist/src/tools/shell-env.d.ts +101 -0
  188. package/dist/src/tools/shell-env.js +173 -0
  189. package/dist/src/tools/shell-env.js.map +1 -0
  190. package/dist/src/trajectory/reader.d.ts +1 -1
  191. package/dist/src/trajectory/reader.js +23 -3
  192. package/dist/src/trajectory/reader.js.map +1 -1
  193. package/dist/src/trajectory/replay.js +23 -0
  194. package/dist/src/trajectory/replay.js.map +1 -1
  195. package/dist/src/trajectory/resume-recap.d.ts +11 -1
  196. package/dist/src/trajectory/resume-recap.js +10 -1
  197. package/dist/src/trajectory/resume-recap.js.map +1 -1
  198. package/dist/src/trajectory/rewind-history.d.ts +8 -0
  199. package/dist/src/trajectory/rewind-history.js +81 -0
  200. package/dist/src/trajectory/rewind-history.js.map +1 -0
  201. package/dist/src/trajectory/writer.d.ts +44 -3
  202. package/dist/src/trajectory/writer.js +80 -14
  203. package/dist/src/trajectory/writer.js.map +1 -1
  204. package/dist/src/tui/App.d.ts +8 -1
  205. package/dist/src/tui/App.js +453 -75
  206. package/dist/src/tui/App.js.map +1 -1
  207. package/dist/src/tui/InputBox.d.ts +1 -1
  208. package/dist/src/tui/InputBox.js +1 -1
  209. package/dist/src/tui/MessageList.js +1 -1
  210. package/dist/src/tui/MessageList.js.map +1 -1
  211. package/dist/src/tui/PermissionPrompt.js +5 -3
  212. package/dist/src/tui/PermissionPrompt.js.map +1 -1
  213. package/dist/src/tui/QueuedMessages.js +14 -8
  214. package/dist/src/tui/QueuedMessages.js.map +1 -1
  215. package/dist/src/tui/ToolCallPanel.js +2 -2
  216. package/dist/src/tui/ToolCallPanel.js.map +1 -1
  217. package/dist/src/tui/WorkspaceTrustPrompt.d.ts +8 -0
  218. package/dist/src/tui/WorkspaceTrustPrompt.js +37 -0
  219. package/dist/src/tui/WorkspaceTrustPrompt.js.map +1 -0
  220. package/dist/src/tui/draft-stash.d.ts +25 -0
  221. package/dist/src/tui/draft-stash.js +49 -0
  222. package/dist/src/tui/draft-stash.js.map +1 -0
  223. package/dist/src/tui/frame-budget.d.ts +2 -2
  224. package/dist/src/tui/frame-budget.js +3 -3
  225. package/dist/src/tui/frame-budget.js.map +1 -1
  226. package/dist/src/tui/help-format.d.ts +2 -2
  227. package/dist/src/tui/help-format.js +3 -3
  228. package/dist/src/tui/help-format.js.map +1 -1
  229. package/dist/src/tui/instructions-format.d.ts +14 -0
  230. package/dist/src/tui/instructions-format.js +24 -0
  231. package/dist/src/tui/instructions-format.js.map +1 -0
  232. package/dist/src/tui/mcp-format.d.ts +9 -0
  233. package/dist/src/tui/mcp-format.js +5 -3
  234. package/dist/src/tui/mcp-format.js.map +1 -1
  235. package/dist/src/tui/permission-rule-preview.d.ts +23 -0
  236. package/dist/src/tui/permission-rule-preview.js +38 -0
  237. package/dist/src/tui/permission-rule-preview.js.map +1 -0
  238. package/dist/src/tui/prompt-editor.d.ts +12 -0
  239. package/dist/src/tui/prompt-editor.js +38 -28
  240. package/dist/src/tui/prompt-editor.js.map +1 -1
  241. package/dist/src/tui/prompt-history-search.js +3 -2
  242. package/dist/src/tui/prompt-history-search.js.map +1 -1
  243. package/dist/src/tui/prompt-queue.d.ts +4 -2
  244. package/dist/src/tui/prompt-queue.js +22 -5
  245. package/dist/src/tui/prompt-queue.js.map +1 -1
  246. package/dist/src/tui/rewind-search.js +4 -3
  247. package/dist/src/tui/rewind-search.js.map +1 -1
  248. package/dist/src/tui/search-preview.d.ts +2 -0
  249. package/dist/src/tui/search-preview.js +9 -0
  250. package/dist/src/tui/search-preview.js.map +1 -0
  251. package/dist/src/tui/shell-command.js +4 -1
  252. package/dist/src/tui/shell-command.js.map +1 -1
  253. package/dist/src/tui/spinner.d.ts +1 -0
  254. package/dist/src/tui/spinner.js +6 -0
  255. package/dist/src/tui/spinner.js.map +1 -0
  256. package/dist/src/tui/status-format.d.ts +24 -0
  257. package/dist/src/tui/status-format.js +62 -2
  258. package/dist/src/tui/status-format.js.map +1 -1
  259. package/dist/src/tui/subagent-format.js +6 -0
  260. package/dist/src/tui/subagent-format.js.map +1 -1
  261. package/dist/src/tui/tangent.d.ts +122 -0
  262. package/dist/src/tui/tangent.js +153 -0
  263. package/dist/src/tui/tangent.js.map +1 -0
  264. package/dist/src/tui/task-format.d.ts +5 -0
  265. package/dist/src/tui/task-format.js +15 -0
  266. package/dist/src/tui/task-format.js.map +1 -1
  267. package/dist/src/tui/trust-format.d.ts +31 -0
  268. package/dist/src/tui/trust-format.js +102 -0
  269. package/dist/src/tui/trust-format.js.map +1 -0
  270. package/dist/src/tui/turn-state.d.ts +13 -1
  271. package/dist/src/tui/turn-state.js +13 -0
  272. package/dist/src/tui/turn-state.js.map +1 -1
  273. package/package.json +4 -3
@@ -0,0 +1,287 @@
1
+ /** Offline, prompt-only setup migration. Never imports runtime, SDK or configuration loaders. */
2
+ import path from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ import matter from 'gray-matter';
5
+ import { MAX_INSTRUCTIONS_BYTES } from './agent/instructions.js';
6
+ import { extensionRoots, userDarwinDir, userProjectDir } from './paths.js';
7
+ import { IMPORT_LIMITS, ImportProblem, ImportReader, verifySnapshot, writeImport } from './import-claude-files.js';
8
+ import { manualSettings, manualMcp } from './import-claude-snippets.js';
9
+ function text(data) {
10
+ try {
11
+ return new TextDecoder('utf-8', { fatal: true }).decode(data);
12
+ }
13
+ catch {
14
+ throw new ImportProblem('invalid UTF-8; manual migration required');
15
+ }
16
+ }
17
+ function prompt(data, fallback, agent) {
18
+ const raw = text(data);
19
+ // gray-matter also supports executable JS engines. Only an exact YAML opener is accepted.
20
+ if (!/^---\r?\n/.test(raw))
21
+ throw new ImportProblem('requires YAML frontmatter with plain --- delimiters');
22
+ let parsed;
23
+ try {
24
+ parsed = matter(raw);
25
+ }
26
+ catch {
27
+ throw new ImportProblem('invalid YAML frontmatter');
28
+ }
29
+ const allowed = agent ? ['name', 'description', 'tools'] : ['name', 'description'];
30
+ if (Object.keys(parsed.data).some(key => !allowed.includes(key)))
31
+ throw new ImportProblem('unsupported frontmatter (hooks, model, tools, permissions or other semantics); migrate manually without dropping restrictions');
32
+ if (agent && 'tools' in parsed.data && (!Array.isArray(parsed.data['tools']) || parsed.data['tools'].length !== 0))
33
+ throw new ImportProblem('nonempty/invalid Claude tools have no safe Darwin mapping; restrictions NOT removed');
34
+ const name = parsed.data['name'] ?? (agent ? undefined : fallback);
35
+ const description = parsed.data['description'];
36
+ if (typeof name !== 'string' || !/^[A-Za-z0-9_-]{1,64}$/.test(name) || typeof description !== 'string' || !description.trim() || !parsed.content.trim())
37
+ throw new ImportProblem('requires valid name, description and nonempty body');
38
+ if (/!`|\$ARGUMENTS|\$\d|\$\{?CLAUDE/.test(parsed.content))
39
+ throw new ImportProblem('dynamic command/argument substitution is unsupported; manual migration required');
40
+ // JSON strings are YAML scalars; no unsupported source fields survive.
41
+ const header = `---\nname: ${JSON.stringify(name)}\ndescription: ${JSON.stringify(description.trim())}\n${agent && 'tools' in parsed.data ? 'tools: []\n' : ''}---\n`;
42
+ return { name: name.toLowerCase(), data: Buffer.from(header + parsed.content) };
43
+ }
44
+ const builtinDirectory = fileURLToPath(new URL('./skills/builtin', import.meta.url));
45
+ const marker = '<!-- darwin import claude-code:';
46
+ const safeReason = (e) => e instanceof ImportProblem ? e.message : 'unreadable or unsafe item; manual migration required';
47
+ function line(plan, source, target, result) {
48
+ plan.lines.push(`${JSON.stringify(source)} -> ${JSON.stringify(target)}: ${result}`);
49
+ }
50
+ function attempt(plan, source, target, action) {
51
+ try {
52
+ action();
53
+ }
54
+ catch (e) {
55
+ plan.incomplete = true;
56
+ line(plan, source, target, `MANUAL: ${safeReason(e)}`);
57
+ }
58
+ }
59
+ function resourceTree(reader, root, depth = 0) {
60
+ if (depth > IMPORT_LIMITS.depth)
61
+ throw new ImportProblem('resource depth cap (6) exceeded');
62
+ const files = new Map();
63
+ for (const name of reader.list(root)) {
64
+ // Do not even open hidden policy, credentials or session stores inside resources.
65
+ if (name.startsWith('.') || /^(?:credentials?|secrets?|sessions?|history)(?:\.|$)/i.test(name) || /\.(?:pem|key|p12)$/i.test(name))
66
+ throw new ImportProblem('hidden/sensitive resource omitted; whole skill requires manual migration');
67
+ const file = path.join(root, name);
68
+ if (reader.kind(file) === 'directory') {
69
+ for (const [child, data] of resourceTree(reader, file, depth + 1))
70
+ files.set(path.join(name, child), data);
71
+ }
72
+ else {
73
+ const data = reader.read(file);
74
+ if (data === undefined)
75
+ throw new ImportProblem('resource disappeared');
76
+ files.set(name, data);
77
+ }
78
+ if (files.size > 100)
79
+ throw new ImportProblem('skill resource file cap (100) exceeded');
80
+ }
81
+ return files;
82
+ }
83
+ function claimedNames(plan, projectRoot, agent) {
84
+ const claimed = new Map();
85
+ if (agent)
86
+ claimed.set('general', 'built-in general');
87
+ else
88
+ for (const name of plan.reader.list(builtinDirectory))
89
+ claimed.set(name.toLowerCase(), 'built-in skill');
90
+ for (const layer of extensionRoots(projectRoot)) {
91
+ const dir = path.join(layer.root, agent ? 'agents' : 'skills');
92
+ for (const name of plan.reader.list(dir)) {
93
+ // Reserve names even for unsupported existing content: import never shadows it.
94
+ const file = path.join(dir, name, ...(agent ? [] : ['SKILL.md']));
95
+ if (agent && !name.endsWith('.md'))
96
+ continue;
97
+ const raw = plan.reader.read(file);
98
+ if (!raw)
99
+ continue;
100
+ let key = agent ? name.slice(0, -3) : name;
101
+ // Existing loaders may accept fields this importer intentionally refuses.
102
+ // Still reserve their declared names; never reinterpret or modify them.
103
+ try {
104
+ const content = text(raw);
105
+ if (!/^---\r?\n/.test(content))
106
+ throw new ImportProblem('unsupported existing definition; cannot safely inventory names');
107
+ const value = matter(content).data['name'];
108
+ if (typeof value === 'string' && value.trim())
109
+ key = value.trim();
110
+ }
111
+ catch {
112
+ throw new ImportProblem('existing definition names cannot be safely inventoried; no imports in this category');
113
+ }
114
+ if (!claimed.has(key.toLowerCase()))
115
+ claimed.set(key.toLowerCase(), file);
116
+ }
117
+ }
118
+ return claimed;
119
+ }
120
+ function extensions(plan, source, destination, claimed, agent) {
121
+ const { reader } = plan;
122
+ for (const entry of reader.list(source)) {
123
+ const from = path.join(source, entry);
124
+ const target = path.join(destination, entry);
125
+ attempt(plan, from, target, () => {
126
+ if (entry.startsWith('.') || /^(?:credentials?|secrets?|sessions?|history)(?:\.|$)/i.test(entry))
127
+ throw new ImportProblem('hidden/sensitive entry omitted without reading');
128
+ if (agent && (!entry.endsWith('.md') || reader.kind(from) !== 'file'))
129
+ throw new ImportProblem('only direct Markdown agents supported; nested definitions omitted');
130
+ const sourceFile = agent ? from : path.join(from, 'SKILL.md');
131
+ const raw = reader.read(sourceFile);
132
+ if (!raw)
133
+ throw new ImportProblem('missing prompt file');
134
+ const parsed = prompt(raw, entry, agent);
135
+ const targetFile = agent ? target : path.join(target, 'SKILL.md');
136
+ const existing = claimed.get(parsed.name);
137
+ if (existing && existing !== targetFile)
138
+ throw new ImportProblem(`name collision/reservation at ${JSON.stringify(existing)}; no precedence override`);
139
+ const files = agent ? new Map([[entry, parsed.data]]) : resourceTree(reader, from);
140
+ if (!agent)
141
+ files.set('SKILL.md', parsed.data);
142
+ const pending = [];
143
+ let present = 0;
144
+ for (const [relative, data] of files) {
145
+ const dest = agent ? target : path.join(target, relative);
146
+ const before = reader.read(dest);
147
+ if (before) {
148
+ if (!before.equals(data))
149
+ throw new ImportProblem('destination collision; existing bytes retained');
150
+ present++;
151
+ }
152
+ else
153
+ pending.push({ source: agent ? from : path.join(from, relative), target: dest, data });
154
+ }
155
+ if (!agent && reader.list(target).length) {
156
+ const tree = resourceTree(reader, target);
157
+ if (present !== files.size || tree.size !== files.size)
158
+ throw new ImportProblem('existing skill directory differs; no merge/partial repair');
159
+ }
160
+ // Resources first: on an I/O failure, an incomplete new skill is not discoverable.
161
+ pending.sort((a, b) => Number(a.target.endsWith('/SKILL.md')) - Number(b.target.endsWith('/SKILL.md')));
162
+ plan.writes.push(...pending);
163
+ claimed.set(parsed.name, targetFile);
164
+ line(plan, from, target, pending.length ? `COPY ${pending.length} prompt/resource file(s)${agent && !/tools: \[\]/.test(parsed.data.toString()) ? '; unrestricted source agent inherits Darwin eligible tools' : ''}` : 'ALREADY PRESENT (identical)');
165
+ });
166
+ }
167
+ }
168
+ function instructions(plan, projectRoot) {
169
+ const target = path.join(projectRoot, 'AGENTS.md');
170
+ attempt(plan, projectRoot, target, () => {
171
+ const before = plan.reader.read(target);
172
+ let combined = before ?? Buffer.alloc(0);
173
+ const additions = [];
174
+ const proposed = [];
175
+ for (const relative of ['CLAUDE.md', '.claude/CLAUDE.md']) {
176
+ const source = path.join(projectRoot, relative);
177
+ const raw = plan.reader.read(source);
178
+ if (!raw)
179
+ continue;
180
+ const body = text(raw);
181
+ if (body.includes(marker))
182
+ throw new ImportProblem('source contains reserved import marker');
183
+ const start = `${marker}${relative} -->`;
184
+ const section = Buffer.from(`\n\n${start}\n## Imported from ${relative}\n\nLiteral prompt content; @ imports are not expanded.\n\n${body}\n<!-- end darwin import claude-code:${relative} -->\n`);
185
+ if (combined.includes(section)) {
186
+ line(plan, source, target, 'ALREADY PRESENT (identical section)');
187
+ continue;
188
+ }
189
+ if (combined.includes(start))
190
+ throw new ImportProblem('existing import section differs; review and merge manually');
191
+ if (body.trim() && combined.includes(raw)) {
192
+ line(plan, source, target, 'ALREADY PRESENT (literal body; no section added)');
193
+ continue;
194
+ }
195
+ combined = Buffer.concat([combined, section]);
196
+ if (combined.length > MAX_INSTRUCTIONS_BYTES)
197
+ throw new ImportProblem('AGENTS.md would exceed 32768-byte instruction cap; nothing appended');
198
+ additions.push(section);
199
+ proposed.push({ source, bytes: section.length });
200
+ }
201
+ for (const item of proposed)
202
+ line(plan, item.source, target, `APPEND marked section (${item.bytes} bytes)`);
203
+ if (additions.length)
204
+ plan.writes.push({ source: projectRoot, target, data: Buffer.concat(additions), ...(before === undefined ? {} : { before }) });
205
+ });
206
+ }
207
+ export function scanClaudeImport(projectRoot) {
208
+ const plan = { reader: new ImportReader(), writes: [], lines: [], incomplete: false };
209
+ plan.lines.push('Claude Code setup migration: read-only plan; --apply writes prompt content ONLY.', 'No model/network/hooks/tools/session startup. No history, chats, credentials, trust or executable configuration imported.', 'Bounds: 400 entries (+ one overflow probe); 262144 bytes/file; 4194304 bytes per scan pass; skill depth 6 and 100 files; 100 MCP entries / rules per array; output 32768 bytes.', 'Precedence unchanged: built-ins, project .darwin, project .agents, global .darwin, global .agents. Existing names are not shadowed.', 'CLAUDE.md fallback remains supported when AGENTS.md is absent. @ imports stay literal, never expanded.', 'Omitted without scanning: ~/.claude.json (mixed credentials/project state, including user MCP), sessions/history, plugins, commands, rules, managed/nested/additional-directory setup.', 'Linux descriptor-safe file access only; other hosts require manual migration. Do not edit setup concurrently with apply.');
210
+ const layers = extensionRoots(projectRoot).filter(layer => layer.kind === 'darwin');
211
+ for (const agent of [false, true]) {
212
+ attempt(plan, 'existing Darwin layers', agent ? 'agents' : 'skills', () => {
213
+ const claimed = claimedNames(plan, projectRoot, agent);
214
+ for (const layer of layers) {
215
+ const source = path.join(path.dirname(layer.root), '.claude', agent ? 'agents' : 'skills');
216
+ const target = path.join(layer.root, agent ? 'agents' : 'skills');
217
+ attempt(plan, source, target, () => extensions(plan, source, target, claimed, agent));
218
+ }
219
+ });
220
+ }
221
+ instructions(plan, projectRoot);
222
+ const globalClaude = path.join(path.dirname(userDarwinDir()), '.claude');
223
+ const globalInstructions = path.join(globalClaude, 'CLAUDE.md');
224
+ attempt(plan, globalInstructions, 'no global AGENTS.md loader', () => {
225
+ if (plan.reader.read(globalInstructions))
226
+ line(plan, globalInstructions, 'no equivalent global instruction layer', 'MANUAL: not copied into project scope');
227
+ });
228
+ for (const source of [path.join(globalClaude, 'settings.json'), path.join(projectRoot, '.claude/settings.json'), path.join(projectRoot, '.claude/settings.local.json')]) {
229
+ const target = path.join(userProjectDir(projectRoot), 'permission-rules.json');
230
+ attempt(plan, source, target, () => {
231
+ const data = plan.reader.read(source);
232
+ if (data)
233
+ for (const report of manualSettings(text(data)))
234
+ line(plan, source, target, report);
235
+ });
236
+ }
237
+ const mcpSource = path.join(projectRoot, '.mcp.json');
238
+ const mcpTarget = path.join(layers[0].root, 'mcp.json');
239
+ attempt(plan, mcpSource, mcpTarget, () => {
240
+ const data = plan.reader.read(mcpSource);
241
+ if (data)
242
+ for (const report of manualMcp(text(data)))
243
+ line(plan, mcpSource, mcpTarget, report);
244
+ });
245
+ plan.lines.push('Manual snippets are candidates, NOT a complete policy conversion. Merge only after reviewing omissions, restrictions and scope; never replace existing deny rules. Global permissions have no global Darwin rule store.', 'Hooks are never converted or printed as commands. MCP snippets do not convey approval; root .mcp.json fallback and workspace trust remain unchanged. No config or trust file is written.');
246
+ return plan;
247
+ }
248
+ export function formatImportPlan(plan) {
249
+ const tail = `\n${plan.writes.length} planned file write(s); ${plan.incomplete ? 'some items require manual migration' : 'scan complete within stated scope'}.\n`;
250
+ const lines = [];
251
+ // Reserve room for the apply result, including one absolute failure path.
252
+ let size = Buffer.byteLength(tail) + 8192;
253
+ for (const raw of plan.lines) {
254
+ const value = raw.replace(/[\u0000-\u0009\u000b-\u001f\u007f-\u009f\u202a-\u202e\u2066-\u2069]/g, ch => `\\u${ch.charCodeAt(0).toString(16).padStart(4, '0')}`);
255
+ const n = Buffer.byteLength(value) + 1;
256
+ if (size + n > IMPORT_LIMITS.outputBytes) {
257
+ plan.incomplete = true;
258
+ lines.push('OUTPUT CAP: remaining plan/snippets omitted; apply refused because the complete plan cannot be displayed.');
259
+ break;
260
+ }
261
+ lines.push(value);
262
+ size += n;
263
+ }
264
+ return lines.join('\n') + tail;
265
+ }
266
+ export function applyClaudeImport(plan) {
267
+ if (formatImportPlan(plan).includes('OUTPUT CAP:'))
268
+ return { text: 'Apply refused: output cap; no writes.\n', failed: true };
269
+ try {
270
+ verifySnapshot(plan.reader);
271
+ }
272
+ catch (e) {
273
+ return { text: `Apply refused before writes: ${safeReason(e)}.\n`, failed: true };
274
+ }
275
+ let completed = 0;
276
+ for (const item of plan.writes) {
277
+ try {
278
+ writeImport(item);
279
+ completed++;
280
+ }
281
+ catch (e) {
282
+ return { text: `Apply stopped at ${JSON.stringify(item.target)} after ${completed} completed file write(s): ${safeReason(e)}. Earlier writes and possibly partial current file/created directories remain; inspect before retry. No rollback or overwrite attempted.\n`, failed: true };
283
+ }
284
+ }
285
+ return { text: `Applied ${completed} prompt/resource file write(s). Manual items/snippets were NOT applied. Source files unchanged.\n`, failed: false };
286
+ }
287
+ //# sourceMappingURL=import-claude.js.map
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IAAI,CAAC,CAAC;YAAC,SAAS,EAAE,CAAC;QAAC,CAAC;QACvC,OAAO,CAAC,EAAE,CAAC;YACT,OAAO,EAAE,IAAI,EAAE,oBAAoB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,SAAS,6BAA6B,UAAU,CAAC,CAAC,CAAC,4IAA4I,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;QAC1R,CAAC;IACH,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,WAAW,SAAS,mGAAmG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;AAC1J,CAAC"}
@@ -83,6 +83,7 @@ export declare function mcpConfigCandidates(projectRoot: string): {
83
83
  */
84
84
  export declare function loadMcpClients(projectRoot: string, options?: {
85
85
  quietStdioStderr?: boolean;
86
+ projectLayer?: 'armed' | 'held';
86
87
  }): Promise<McpLoadResult>;
87
88
  /** The declarative half of {@link loadMcpClients}: which files were read, and what they declare. */
88
89
  export interface McpServerConfigs extends Omit<McpLoadResult, 'clients'> {
@@ -93,13 +94,52 @@ export interface McpServerConfigs extends Omit<McpLoadResult, 'clients'> {
93
94
  */
94
95
  servers: Record<string, McpServerConfig> | undefined;
95
96
  }
97
+ /**
98
+ * Whether the repository-supplied project layer (`.darwin/mcp.json` or the root
99
+ * `.mcp.json`) is read at all (SER-090). `held` leaves both files unread — not parsed,
100
+ * so a malformed one cannot fail startup either — and the user-owned global file is
101
+ * the whole answer; `configPaths`/`ignoredConfigPath` then name only what was read.
102
+ * Default `armed`: every caller before workspace trust.
103
+ */
104
+ export interface McpReadOptions {
105
+ projectLayer?: 'armed' | 'held';
106
+ }
96
107
  /**
97
108
  * Reads and merges the MCP config files without constructing a single client:
98
109
  * nothing is spawned and nothing connects. `darwin doctor` reports from this;
99
110
  * {@link loadMcpClients} builds on it. An unreadable or malformed file is the same
100
111
  * {@link ConfigError} startup raises.
101
112
  */
102
- export declare function readMcpServerConfigs(projectRoot: string): Promise<McpServerConfigs>;
113
+ export declare function readMcpServerConfigs(projectRoot: string, options?: McpReadOptions): Promise<McpServerConfigs>;
114
+ /** One repository-supplied server as the workspace-trust inventory lists it (SER-090). */
115
+ export interface ProjectMcpServerInventory {
116
+ name: string;
117
+ /** The file that declares it: `.darwin/mcp.json`, or the root `.mcp.json` when that is the one in effect. */
118
+ file: string;
119
+ /** stdio: the program and its arguments as written (no `${VAR}` interpolation); `env` is never listed. */
120
+ command?: string;
121
+ args?: readonly string[];
122
+ /** http/sse: the endpoint as written; `headers` are never listed. */
123
+ url?: string;
124
+ /** `"disabled": true` entries are listed as such — the file still names them, the loader would skip them. */
125
+ disabled?: boolean;
126
+ }
127
+ /**
128
+ * The project layer alone, exactly as {@link readMcpServerConfigs} would select it
129
+ * (`.darwin/mcp.json` over the root `.mcp.json`, one file only), without merging the
130
+ * global layer and without constructing a client. The declarative reader above is
131
+ * reused for the parse, so the inventory cannot disagree with what startup would
132
+ * spawn; a malformed file is returned as `problem` with the loader's own message
133
+ * rather than thrown, because the inventory exists to *show* the checkout, not to
134
+ * refuse it — the refusal (or the hold) is the caller's decision.
135
+ */
136
+ export declare function inventoryProjectMcpServers(projectRoot: string): Promise<{
137
+ servers: ProjectMcpServerInventory[];
138
+ problem?: {
139
+ file: string;
140
+ problem: string;
141
+ };
142
+ }>;
103
143
  /**
104
144
  * The MCP stdio transport inherits child stderr by default. In headless mode
105
145
  * that would let arbitrary server banners violate the bounded progress protocol.
@@ -122,6 +162,22 @@ export declare function loadServersQuietly(servers: Record<string, McpServerConf
122
162
  * and accepts the collision risk for their particular set of servers.
123
163
  */
124
164
  export declare function withDefaultPrefixes(servers: Record<string, McpServerConfig>): Record<string, McpServerConfig>;
165
+ /**
166
+ * Gives every stdio server's `env` the `DARWIN=1` marker (SER-094), never overriding
167
+ * an `env.DARWIN` the user wrote.
168
+ *
169
+ * The config `env` is the only path into a stdio server's environment: the SDK's
170
+ * `buildStdioConfig` hands `{ ...getDefaultEnvironment(), ...interpolateRecord(env) }`
171
+ * to `StdioClientTransport`, whose `spawn` uses `{ ...getDefaultEnvironment(),
172
+ * ...env }` — a fixed whitelist (`HOME`, `LOGNAME`, `PATH`, `SHELL`, `TERM`, `USER`
173
+ * on POSIX), not `process.env`. So a `DARWIN` exported in the user's shell never
174
+ * reached a server before and still does not; the marker written here does, and a
175
+ * config `env.DARWIN` wins over it. Only stdio entries are touched — detected as the
176
+ * SDK detects them (`transport`, else `command`); http/sse entries and non-object
177
+ * entries pass through byte-identical, and `env` values keep their `${VAR}`
178
+ * interpolation because the SDK still runs it on the merged record.
179
+ */
180
+ export declare function withStdioDarwinMarker(servers: Record<string, McpServerConfig>): Record<string, McpServerConfig>;
125
181
  /**
126
182
  * Disconnects every client, tolerating individual failures.
127
183
  *
@@ -13,15 +13,17 @@
13
13
  * - supports `disabled`, `prefix` and `toolFilters` per server
14
14
  *
15
15
  * So the things left for us are: treating a missing file as "no MCP", turning
16
- * per-server failures into warnings instead of a failed startup, and defaulting
16
+ * per-server failures into warnings instead of a failed startup, defaulting
17
17
  * each server's `prefix` to `<name>_` so tool names stay unique across servers
18
- * (see {@link withDefaultPrefixes}).
18
+ * (see {@link withDefaultPrefixes}), and giving every stdio server's `env` the
19
+ * `DARWIN=1` marker (see {@link withStdioDarwinMarker}).
19
20
  */
20
21
  import { access, readFile } from 'node:fs/promises';
21
22
  import path from 'node:path';
22
23
  import { McpClient } from '@strands-agents/sdk';
23
24
  import { ConfigError } from '../config.js';
24
25
  import { darwinDir, userDarwinDir } from '../paths.js';
26
+ import { withDarwinMarker } from '../tools/shell-env.js';
25
27
  /** Preferred location, alongside the rest of darwin's project state. */
26
28
  export const MCP_CONFIG_FILENAME = 'mcp.json';
27
29
  /**
@@ -83,10 +85,12 @@ export function mcpConfigCandidates(projectRoot) {
83
85
  * a typo behind missing tools.
84
86
  */
85
87
  export async function loadMcpClients(projectRoot, options = {}) {
86
- const { servers, ...sources } = await readMcpServerConfigs(projectRoot);
88
+ const { servers, ...sources } = await readMcpServerConfigs(projectRoot, {
89
+ ...(options.projectLayer === undefined ? {} : { projectLayer: options.projectLayer }),
90
+ });
87
91
  if (servers === undefined)
88
92
  return { clients: [], ...sources };
89
- const prefixed = withDefaultPrefixes(servers);
93
+ const prefixed = withStdioDarwinMarker(withDefaultPrefixes(servers));
90
94
  const clients = options.quietStdioStderr === true
91
95
  ? await loadServersQuietly(prefixed)
92
96
  : await McpClient.loadServers(prefixed, { continueOnError: true });
@@ -98,10 +102,13 @@ export async function loadMcpClients(projectRoot, options = {}) {
98
102
  * {@link loadMcpClients} builds on it. An unreadable or malformed file is the same
99
103
  * {@link ConfigError} startup raises.
100
104
  */
101
- export async function readMcpServerConfigs(projectRoot) {
105
+ export async function readMcpServerConfigs(projectRoot, options = {}) {
102
106
  const { global, preferred, fallback } = mcpConfigCandidates(projectRoot);
107
+ const held = options.projectLayer === 'held';
103
108
  const [hasGlobal, hasPreferred, hasFallback] = await Promise.all([
104
- exists(global), exists(preferred), exists(fallback),
109
+ exists(global),
110
+ held ? false : exists(preferred),
111
+ held ? false : exists(fallback),
105
112
  ]);
106
113
  const projectConfig = hasPreferred ? preferred : hasFallback ? fallback : undefined;
107
114
  const ignoredConfigPath = hasPreferred && hasFallback ? fallback : undefined;
@@ -133,6 +140,44 @@ export async function readMcpServerConfigs(projectRoot) {
133
140
  ignoredConfigPath,
134
141
  };
135
142
  }
143
+ /**
144
+ * The project layer alone, exactly as {@link readMcpServerConfigs} would select it
145
+ * (`.darwin/mcp.json` over the root `.mcp.json`, one file only), without merging the
146
+ * global layer and without constructing a client. The declarative reader above is
147
+ * reused for the parse, so the inventory cannot disagree with what startup would
148
+ * spawn; a malformed file is returned as `problem` with the loader's own message
149
+ * rather than thrown, because the inventory exists to *show* the checkout, not to
150
+ * refuse it — the refusal (or the hold) is the caller's decision.
151
+ */
152
+ export async function inventoryProjectMcpServers(projectRoot) {
153
+ const { preferred, fallback } = mcpConfigCandidates(projectRoot);
154
+ const [hasPreferred, hasFallback] = await Promise.all([exists(preferred), exists(fallback)]);
155
+ const file = hasPreferred ? preferred : hasFallback ? fallback : undefined;
156
+ if (file === undefined)
157
+ return { servers: [] };
158
+ let layer;
159
+ try {
160
+ layer = unwrapServers(JSON.parse(await readFile(file, 'utf8')));
161
+ }
162
+ catch (error) {
163
+ return { servers: [], problem: { file, problem: error instanceof Error ? error.message : String(error) } };
164
+ }
165
+ const servers = Object.entries(layer).map(([name, entry]) => {
166
+ const record = typeof entry === 'object' && entry !== null ? entry : {};
167
+ const command = record['command'];
168
+ const args = record['args'];
169
+ const url = record['url'];
170
+ return {
171
+ name,
172
+ file,
173
+ ...(typeof command === 'string' ? { command } : {}),
174
+ ...(Array.isArray(args) ? { args: args.map((value) => (typeof value === 'string' ? value : JSON.stringify(value))) } : {}),
175
+ ...(typeof url === 'string' ? { url } : {}),
176
+ ...(record['disabled'] === true ? { disabled: true } : {}),
177
+ };
178
+ });
179
+ return { servers };
180
+ }
136
181
  /**
137
182
  * The MCP stdio transport inherits child stderr by default. In headless mode
138
183
  * that would let arbitrary server banners violate the bounded progress protocol.
@@ -184,6 +229,33 @@ export function withDefaultPrefixes(servers) {
184
229
  : entry,
185
230
  ]));
186
231
  }
232
+ /**
233
+ * Gives every stdio server's `env` the `DARWIN=1` marker (SER-094), never overriding
234
+ * an `env.DARWIN` the user wrote.
235
+ *
236
+ * The config `env` is the only path into a stdio server's environment: the SDK's
237
+ * `buildStdioConfig` hands `{ ...getDefaultEnvironment(), ...interpolateRecord(env) }`
238
+ * to `StdioClientTransport`, whose `spawn` uses `{ ...getDefaultEnvironment(),
239
+ * ...env }` — a fixed whitelist (`HOME`, `LOGNAME`, `PATH`, `SHELL`, `TERM`, `USER`
240
+ * on POSIX), not `process.env`. So a `DARWIN` exported in the user's shell never
241
+ * reached a server before and still does not; the marker written here does, and a
242
+ * config `env.DARWIN` wins over it. Only stdio entries are touched — detected as the
243
+ * SDK detects them (`transport`, else `command`); http/sse entries and non-object
244
+ * entries pass through byte-identical, and `env` values keep their `${VAR}`
245
+ * interpolation because the SDK still runs it on the merged record.
246
+ */
247
+ export function withStdioDarwinMarker(servers) {
248
+ return Object.fromEntries(Object.entries(servers).map(([name, entry]) => [
249
+ name,
250
+ typeof entry === 'object' && entry !== null && isStdioEntry(entry)
251
+ ? { ...entry, env: withDarwinMarker(entry.env ?? {}) }
252
+ : entry,
253
+ ]));
254
+ }
255
+ /** Mirrors the SDK loader's transport detection: explicit `transport`, else `command` → stdio. */
256
+ function isStdioEntry(entry) {
257
+ return entry.transport === undefined ? typeof entry.command === 'string' && entry.command !== '' : entry.transport === 'stdio';
258
+ }
187
259
  /**
188
260
  * Disconnects every client, tolerating individual failures.
189
261
  *
@@ -1 +1 @@
1
- {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/mcp/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGhD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEvD,wEAAwE;AACxE,MAAM,CAAC,MAAM,mBAAmB,GAAG,UAAU,CAAC;AAE9C;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,WAAW,CAAC;AAmCpD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAA6B;IAC7D,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;QAC5B,MAAM,UAAU,GAAI,MAAwD,CAAC,oBAAoB,CAAC;QAClG,MAAM,SAAS,GACb,UAAU,YAAY,GAAG,IAAI,CAAC,GAAG,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,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,CAAC,CAAC,CAAC;IACvF,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAClG,IAAI,OAAO,CAAC,YAAY,KAAK,IAAI,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzD,MAAM,IAAI,cAAc,CAAC,QAAQ,EAAE,GAAG,QAAQ,CAAC,MAAM,qCAAqC,CAAC,CAAC;IAC9F,CAAC;AACH,CAAC;AAED,KAAK,UAAU,MAAM,CAAC,QAAgB;IACpC,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
@@ -2,7 +2,7 @@ import { type MemoryValidationOptions } from './validation.js';
2
2
  export declare const MEMORY_REPORT_MAX_LINES = 48;
3
3
  export declare const MEMORY_REPORT_MAX_LINE_CODE_POINTS = 180;
4
4
  export declare const MEMORY_REPORT_MAX_ENTRIES = 32;
5
- export declare const MEMORY_USAGE = "usage: /memory [list] \u00B7 /memory show <id|number> \u00B7 /memory forget <id|number|all> \u00B7 /memory remember <note>";
5
+ export declare const MEMORY_USAGE = "usage: /memory [list] \u00B7 /memory show <id|number> \u00B7 /memory edit <id|number> <fact> \u00B7 /memory forget <id|number|all> \u00B7 /memory remember <note>";
6
6
  export type MemoryCommandResult = {
7
7
  readonly changed: boolean;
8
8
  readonly text: string;