one-code-extension 0.4.1 → 0.6.0
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/README.md +16 -5
- package/agents/general-purpose.md +2 -2
- package/docs/guide/README.md +2 -1
- package/docs/guide/bring-your-claude-code-setup.md +60 -9
- package/docs/guide/configuration.md +48 -14
- package/docs/guide/differences-from-claude-code.md +40 -28
- package/docs/guide/doctor.md +20 -13
- package/docs/guide/hooks.md +18 -3
- package/docs/guide/installation.md +26 -4
- package/docs/guide/permissions-modes-and-auto-mode.md +225 -49
- package/docs/guide/providers-and-models.md +137 -54
- package/docs/guide/reference.md +27 -15
- package/docs/guide/sessions-and-context.md +69 -16
- package/docs/guide/skills-plugins-and-mcp.md +57 -20
- package/docs/guide/subagents-and-workflows.md +95 -29
- package/docs/guide/tasks-and-background-work.md +101 -26
- package/docs/guide/terminal-interface.md +24 -12
- package/docs/guide/tools.md +46 -5
- package/docs/guide/troubleshooting.md +13 -9
- package/docs/guide/windows.md +58 -31
- package/extensions/artifacts/gallery.ts +227 -0
- package/extensions/artifacts/index.ts +288 -0
- package/extensions/artifacts/store.ts +570 -0
- package/extensions/artifacts/viewer.ts +199 -0
- package/extensions/ask-user/description.ts +67 -0
- package/extensions/ask-user/dialogs.ts +80 -0
- package/extensions/ask-user/index.ts +37 -33
- package/extensions/ask-user/questions.ts +32 -7
- package/extensions/ask-user/widget.ts +45 -25
- package/extensions/auto-mode/actions.ts +6 -0
- package/extensions/auto-mode/cache.ts +88 -0
- package/extensions/auto-mode/classifier-prompt.ts +5 -4
- package/extensions/auto-mode/classifier.ts +290 -65
- package/extensions/auto-mode/config.ts +72 -20
- package/extensions/auto-mode/decision-log.ts +2 -0
- package/extensions/auto-mode/defaults.ts +1 -1
- package/extensions/auto-mode/denials.ts +124 -0
- package/extensions/auto-mode/git-checkout-programs.ts +187 -0
- package/extensions/auto-mode/git-status-meta.ts +159 -0
- package/extensions/auto-mode/history.ts +189 -0
- package/extensions/auto-mode/instructions.ts +58 -52
- package/extensions/auto-mode/model-select.ts +159 -134
- package/extensions/auto-mode/paths.ts +57 -5
- package/extensions/auto-mode/pause.ts +57 -2
- package/extensions/auto-mode/prompt.ts +37 -21
- package/extensions/auto-mode/read-only-options.ts +724 -0
- package/extensions/auto-mode/resolved-paths-meta.ts +133 -0
- package/extensions/auto-mode/rules.ts +18 -1
- package/extensions/auto-mode/safety-floor.ts +361 -18
- package/extensions/auto-mode/setup-run.ts +20 -14
- package/extensions/auto-mode/shell-analysis.ts +764 -490
- package/extensions/auto-mode/shell-parse.ts +885 -0
- package/extensions/auto-mode/system-note.ts +33 -0
- package/extensions/auto-mode/transcript.ts +80 -51
- package/extensions/background/cron.ts +642 -0
- package/extensions/background/index.ts +614 -248
- package/extensions/background/loop-fire.ts +173 -0
- package/extensions/background/loop-preamble.ts +59 -0
- package/extensions/background/loop-skill.ts +163 -0
- package/extensions/background/monitor-batch.ts +53 -0
- package/extensions/background/noop-fold.ts +128 -0
- package/extensions/background/switch-guard.ts +56 -0
- package/extensions/background/wakeup.ts +178 -55
- package/extensions/bash/background.ts +53 -17
- package/extensions/bash/child.ts +7 -0
- package/extensions/bash/description.ts +188 -0
- package/extensions/bash/guards.ts +15 -67
- package/extensions/bash/index.ts +66 -35
- package/extensions/branding/compaction-keep.ts +63 -0
- package/extensions/branding/declined.ts +22 -0
- package/extensions/branding/index.ts +133 -9
- package/extensions/branding/prompt-editor.ts +53 -6
- package/extensions/branding/queued-edit.ts +31 -0
- package/extensions/branding/replaced-builtins.ts +68 -0
- package/extensions/branding/startup.ts +33 -71
- package/extensions/btw/index.ts +250 -78
- package/extensions/btw/panel.ts +228 -100
- package/extensions/btw/prompt.ts +41 -4
- package/extensions/cache-marks/index.ts +42 -0
- package/extensions/claude-compat/index.ts +7 -11
- package/extensions/claude-context/index.ts +436 -63
- package/extensions/compaction/cut.ts +157 -0
- package/extensions/compaction/index.ts +219 -75
- package/extensions/compaction/kept-thinking.ts +62 -0
- package/extensions/compaction/prompt.ts +15 -12
- package/extensions/context-budget/budget.ts +16 -2
- package/extensions/context-budget/index.ts +35 -15
- package/extensions/context-management/index.ts +36 -28
- package/extensions/doctor/build.ts +59 -8
- package/extensions/doctor/builtins.ts +84 -0
- package/extensions/doctor/cli.ts +7 -1
- package/extensions/doctor/compat.ts +88 -23
- package/extensions/doctor/dependencies.ts +41 -5
- package/extensions/doctor/fix-prompt.ts +9 -2
- package/extensions/doctor/index.ts +102 -58
- package/extensions/doctor/models.ts +102 -63
- package/extensions/doctor/presets.ts +42 -27
- package/extensions/doctor/report.ts +19 -2
- package/extensions/doctor/viewer.ts +49 -27
- package/extensions/effort/index.ts +141 -25
- package/extensions/effort/settings.ts +21 -0
- package/extensions/effort/slider.ts +24 -20
- package/extensions/exit/index.ts +32 -1
- package/extensions/file-tracker/index.ts +420 -42
- package/extensions/file-tracker/replay.ts +137 -24
- package/extensions/file-tracker/restore.ts +66 -0
- package/extensions/file-tracker/results.ts +66 -0
- package/extensions/file-tracker/shell-reads.ts +211 -0
- package/extensions/file-tracker/tracker.ts +45 -15
- package/extensions/footer/footer-line.ts +45 -24
- package/extensions/footer/index.ts +47 -2
- package/extensions/footer/pr.ts +34 -5
- package/extensions/hooks/compaction.ts +7 -0
- package/extensions/hooks/executor.ts +32 -30
- package/extensions/hooks/index.ts +209 -58
- package/extensions/hooks/matcher.ts +3 -0
- package/extensions/hooks/prompt-context.ts +59 -0
- package/extensions/hooks/protocol.ts +41 -3
- package/extensions/hooks/settings.ts +50 -19
- package/extensions/hooks/subagent-bridge.ts +2 -0
- package/extensions/hooks/trust.ts +26 -12
- package/extensions/idle-compact/index.ts +119 -0
- package/extensions/idle-compact/policy.ts +143 -0
- package/extensions/init/index.ts +11 -10
- package/extensions/init/prompt.ts +25 -32
- package/extensions/interrupted/index.ts +13 -1
- package/extensions/kept-thinking/index.ts +27 -0
- package/extensions/ledger/index.ts +46 -0
- package/extensions/ledger/wire.ts +154 -0
- package/extensions/lib/agent-cron.ts +146 -0
- package/extensions/lib/agent-loader.ts +18 -3
- package/extensions/lib/agent-view.ts +85 -0
- package/extensions/lib/anthropic-auth.ts +98 -0
- package/extensions/lib/anthropic-payload.ts +82 -1
- package/extensions/lib/anthropic-server-call.ts +230 -0
- package/extensions/lib/anthropic-server-tools.ts +485 -0
- package/extensions/lib/app-launch.mjs +94 -0
- package/extensions/lib/argument-hints.ts +190 -0
- package/extensions/lib/atomic-write.ts +6 -2
- package/extensions/lib/auto-memory.ts +75 -0
- package/extensions/lib/bash-parser.ts +84 -0
- package/extensions/lib/btw-fork.ts +93 -0
- package/extensions/lib/child-extensions.ts +52 -0
- package/extensions/lib/child-writes.ts +45 -0
- package/extensions/lib/claude-context.ts +515 -100
- package/extensions/lib/claude-external-includes.ts +68 -0
- package/extensions/lib/claude-id.ts +22 -0
- package/extensions/lib/claude-rules.ts +323 -0
- package/extensions/lib/claude-settings.ts +76 -4
- package/extensions/lib/compaction-boundary.ts +36 -0
- package/extensions/lib/compaction-keep.mjs +83 -0
- package/extensions/lib/config-mode.ts +112 -0
- package/extensions/lib/consent-dialogs.ts +63 -0
- package/extensions/lib/consent-preview.ts +5 -1
- package/extensions/lib/consent-stores.ts +48 -0
- package/extensions/lib/context-facts.ts +97 -0
- package/extensions/lib/covered-messages.ts +23 -0
- package/extensions/lib/deferred.ts +359 -25
- package/extensions/lib/dock-rows.ts +60 -0
- package/extensions/lib/empty-tool-result.ts +27 -0
- package/extensions/lib/environment-block.ts +76 -0
- package/extensions/lib/fetch-timeout.ts +24 -6
- package/extensions/{system-prompt → lib}/git-status.ts +51 -13
- package/extensions/lib/git.ts +75 -13
- package/extensions/lib/grammars/LICENSE-tree-sitter-bash +21 -0
- package/extensions/lib/grammars/README.md +2 -0
- package/extensions/lib/grammars/tree-sitter-bash.wasm +0 -0
- package/extensions/lib/guide-docs.ts +45 -0
- package/extensions/lib/headless-output.ts +46 -0
- package/extensions/lib/hook-gate.ts +7 -7
- package/extensions/lib/interrupt.ts +20 -4
- package/extensions/lib/key-input.ts +455 -0
- package/extensions/lib/keys.ts +14 -1
- package/extensions/lib/ledger/fold-memo.ts +49 -0
- package/extensions/lib/ledger/fold.ts +265 -0
- package/extensions/lib/ledger/layout.ts +72 -0
- package/extensions/lib/ledger/plan.ts +102 -0
- package/extensions/lib/ledger/records.ts +276 -0
- package/extensions/lib/ledger/state.ts +47 -0
- package/extensions/lib/ledger/validate.ts +141 -0
- package/extensions/lib/ledger/wire.ts +632 -0
- package/extensions/lib/local-command.ts +71 -19
- package/extensions/lib/mcp-overrides.ts +1 -1
- package/extensions/lib/mcp-share.ts +46 -0
- package/extensions/lib/memory-content.ts +146 -0
- package/extensions/lib/memory-index.ts +18 -0
- package/extensions/lib/memory.ts +134 -123
- package/extensions/lib/model-catalog/huggingface.json +178 -0
- package/extensions/lib/model-catalog/models-dev.json +18533 -0
- package/extensions/lib/model-catalog/openrouter.json +5050 -0
- package/extensions/lib/model-catalog-data.ts +513 -0
- package/extensions/lib/model-catalog.ts +462 -0
- package/extensions/lib/model-choice-warnings.ts +137 -0
- package/extensions/lib/model-pairings.ts +152 -0
- package/extensions/{auto-mode → lib}/model-picker.ts +26 -43
- package/extensions/lib/model-policy.ts +112 -15
- package/extensions/lib/model-tier.ts +283 -355
- package/extensions/lib/model-unusable.ts +1 -1
- package/extensions/lib/newer-model.ts +100 -0
- package/extensions/lib/notices.ts +87 -0
- package/extensions/lib/notifications.ts +357 -73
- package/extensions/lib/one-code-settings.ts +74 -8
- package/extensions/lib/open-browser.ts +63 -0
- package/extensions/lib/openrouter-generation.ts +94 -0
- package/extensions/lib/operation-deadline.ts +30 -0
- package/extensions/lib/original-command.ts +4 -4
- package/extensions/lib/package-version.ts +1 -1
- package/extensions/lib/panel-focus.ts +134 -0
- package/extensions/lib/paths.ts +17 -2
- package/extensions/lib/permission-gate.ts +72 -6
- package/extensions/lib/persisted-output.ts +60 -8
- package/extensions/lib/pi-ai-estimate.ts +19 -3
- package/extensions/lib/pi-version.ts +38 -2
- package/extensions/lib/plan-mode-channels.ts +42 -5
- package/extensions/lib/plugins.ts +26 -17
- package/extensions/lib/powershell-parse-script.ts +208 -0
- package/extensions/lib/powershell-parser.ts +344 -0
- package/extensions/lib/previous-mark.ts +101 -0
- package/extensions/lib/process-state.ts +48 -0
- package/extensions/lib/process-tree.ts +132 -8
- package/extensions/lib/prompt-options.ts +82 -0
- package/extensions/lib/queued-delivery.ts +44 -0
- package/extensions/lib/reminders.ts +370 -358
- package/extensions/lib/replaced-builtins.mjs +199 -0
- package/extensions/lib/replay-call.ts +70 -0
- package/extensions/lib/request-replay.ts +547 -0
- package/extensions/lib/scratchpad.ts +81 -14
- package/extensions/lib/send-now-channel.ts +7 -0
- package/extensions/lib/session-model-tier.ts +51 -0
- package/extensions/lib/session-work.ts +64 -0
- package/extensions/lib/settings-channels.ts +4 -4
- package/extensions/lib/shell-exit-semantics.ts +170 -0
- package/extensions/lib/shell-quote.ts +11 -0
- package/extensions/lib/shell-result.ts +70 -0
- package/extensions/lib/shell-spawn.ts +70 -6
- package/extensions/lib/shell-tool.ts +75 -25
- package/extensions/lib/side-call-cache.ts +124 -0
- package/extensions/lib/side-call-run.ts +96 -0
- package/extensions/lib/side-call-usage.ts +38 -0
- package/extensions/lib/side-call.ts +24 -1
- package/extensions/lib/single-flight.ts +18 -0
- package/extensions/lib/skill-body.ts +42 -0
- package/extensions/lib/skill-scan.ts +63 -24
- package/extensions/lib/spill-file.ts +140 -0
- package/extensions/lib/subagent-handback.ts +112 -0
- package/extensions/lib/system-role.ts +156 -0
- package/extensions/lib/terminal-text.ts +114 -0
- package/extensions/lib/text-width.ts +47 -16
- package/extensions/lib/timer-ops.ts +20 -0
- package/extensions/lib/tool-additions.ts +129 -0
- package/extensions/lib/tool-call-corruption.ts +134 -0
- package/extensions/lib/tool-path.ts +66 -0
- package/extensions/lib/tool-variants.ts +69 -0
- package/extensions/lib/tui-render.ts +255 -27
- package/extensions/lib/turn-budget-layout.ts +159 -0
- package/extensions/lib/update-check.mjs +15 -2
- package/extensions/lib/usage-bus.ts +1 -1
- package/extensions/lib/user-denial.ts +38 -0
- package/extensions/lib/workspace-channel.ts +16 -0
- package/extensions/lib/worktree-channel.ts +31 -3
- package/extensions/lib/worktree-isolation.ts +40 -10
- package/extensions/lsp/client.ts +8 -9
- package/extensions/lsp/index.ts +76 -12
- package/extensions/lsp/keep-alive.ts +1 -1
- package/extensions/lsp/trust.ts +119 -0
- package/extensions/lsp/watcher.ts +1 -1
- package/extensions/mcp/announce.ts +90 -43
- package/extensions/mcp/client.ts +161 -48
- package/extensions/mcp/config.ts +132 -8
- package/extensions/mcp/discovery.ts +19 -0
- package/extensions/mcp/index.ts +220 -121
- package/extensions/mcp/oauth/browser.ts +38 -17
- package/extensions/mcp/oauth/flow.ts +25 -17
- package/extensions/mcp/oauth/provider.ts +14 -8
- package/extensions/mcp/oauth/store.ts +34 -16
- package/extensions/mcp/panel/keys.ts +12 -11
- package/extensions/mcp/panel/render.ts +9 -6
- package/extensions/mcp/schema.ts +104 -5
- package/extensions/mcp/trust.ts +164 -73
- package/extensions/memory/entries.ts +23 -14
- package/extensions/memory/index.ts +134 -28
- package/extensions/memory/open-external.ts +33 -18
- package/extensions/memory/panel.ts +135 -26
- package/extensions/model-default/index.ts +86 -19
- package/extensions/newer-model/index.ts +31 -0
- package/extensions/notebook/description.ts +18 -0
- package/extensions/notebook/index.ts +6 -5
- package/extensions/notebook/notebook.ts +1 -1
- package/extensions/permissions/index.ts +1426 -398
- package/extensions/permissions/matcher.ts +425 -74
- package/extensions/permissions/modes.ts +11 -4
- package/extensions/permissions/panel/host.ts +130 -0
- package/extensions/permissions/panel/keys.ts +48 -0
- package/extensions/permissions/panel/render.ts +450 -0
- package/extensions/permissions/panel/state.ts +550 -0
- package/extensions/permissions/powershell-cmdlets.ts +198 -0
- package/extensions/permissions/powershell-paths.ts +197 -0
- package/extensions/permissions/powershell-rules.ts +207 -280
- package/extensions/permissions/powershell-tree.ts +557 -0
- package/extensions/permissions/project-trust.ts +27 -11
- package/extensions/permissions/protected-paths.ts +14 -2
- package/extensions/permissions/session-grant.ts +6 -0
- package/extensions/permissions/settings.ts +166 -31
- package/extensions/permissions/subagent-gate.ts +25 -0
- package/extensions/permissions/workspace.ts +78 -0
- package/extensions/plan-mode/index.ts +276 -92
- package/extensions/plan-mode/reminder.ts +89 -21
- package/extensions/plan-mode/run-state.ts +26 -0
- package/extensions/plan-mode/texts.ts +177 -0
- package/extensions/plan-mode/viewer.ts +92 -27
- package/extensions/plugins/counts.ts +3 -3
- package/extensions/plugins/index.ts +64 -46
- package/extensions/plugins/install/install.ts +16 -0
- package/extensions/plugins/marketplace/sync.ts +9 -3
- package/extensions/plugins/marketplace/types.ts +3 -1
- package/extensions/plugins/panel/keys.ts +21 -24
- package/extensions/plugins/panel/render.ts +12 -6
- package/extensions/plugins/shell-expand.ts +107 -0
- package/extensions/plugins/template.ts +32 -15
- package/extensions/powershell/child.ts +7 -0
- package/extensions/powershell/description.ts +38 -6
- package/extensions/powershell/guards.ts +1 -1
- package/extensions/powershell/index.ts +14 -7
- package/extensions/recap/index.ts +73 -71
- package/extensions/recap/prompt.ts +2 -2
- package/extensions/recap/scheduler.ts +3 -5
- package/extensions/search-tools/grep-merge.ts +39 -0
- package/extensions/search-tools/index.ts +0 -0
- package/extensions/send-now/chord.ts +62 -0
- package/extensions/send-now/index.ts +133 -0
- package/extensions/session-title/index.ts +3 -0
- package/extensions/session-title/title.ts +4 -1
- package/extensions/skill/announce.ts +30 -0
- package/extensions/skill/code-review.ts +97 -0
- package/extensions/skill/index.ts +469 -132
- package/extensions/skill/invoke.ts +118 -75
- package/extensions/skill/listing.ts +133 -9
- package/extensions/skill/panel/keys.ts +15 -16
- package/extensions/skill/panel/render.ts +5 -2
- package/extensions/skill/panel/state.ts +12 -1
- package/extensions/subagents/agent-args.ts +39 -0
- package/extensions/subagents/agent-description.ts +132 -0
- package/extensions/subagents/agents.ts +146 -31
- package/extensions/subagents/default-model.ts +2 -3
- package/extensions/subagents/delegation-steer.ts +4 -4
- package/extensions/subagents/fork-cache.ts +82 -0
- package/extensions/subagents/guide-agent.ts +189 -0
- package/extensions/subagents/hand-back-review.ts +3 -0
- package/extensions/subagents/index.ts +1594 -852
- package/extensions/subagents/live-runs.ts +26 -6
- package/extensions/subagents/model-select.ts +38 -25
- package/extensions/subagents/outcome.ts +5 -2
- package/extensions/subagents/panel-keys.ts +73 -31
- package/extensions/subagents/panel-render.ts +120 -96
- package/extensions/subagents/panel-widget.ts +60 -89
- package/extensions/subagents/parent-mode.ts +50 -0
- package/extensions/subagents/pending-claim.ts +18 -1
- package/extensions/subagents/runner.ts +135 -80
- package/extensions/subagents/runs.ts +44 -5
- package/extensions/subagents/send-to-main-tool.ts +1 -1
- package/extensions/subagents/session-turns.ts +32 -8
- package/extensions/subagents/shell-panel.ts +36 -178
- package/extensions/subagents/tasks-dialog.ts +170 -0
- package/extensions/subagents/viewport-mirror.ts +95 -0
- package/extensions/subagents/worktree.ts +57 -13
- package/extensions/system-prompt/environment.ts +19 -19
- package/extensions/system-prompt/idle-turn.ts +65 -0
- package/extensions/system-prompt/index.ts +165 -47
- package/extensions/system-prompt/template.ts +34 -51
- package/extensions/system-prompt/tiers/common.ts +23 -64
- package/extensions/system-prompt/tiers/frontier.ts +32 -11
- package/extensions/system-prompt/tiers/low.ts +67 -45
- package/extensions/system-prompt/tiers/mid.ts +96 -38
- package/extensions/system-reminder/index.ts +204 -70
- package/extensions/tasks/descriptions.ts +190 -0
- package/extensions/tasks/index.ts +120 -41
- package/extensions/tasks/store.ts +83 -16
- package/extensions/tool-call-corruption/child.ts +7 -0
- package/extensions/tool-call-corruption/index.ts +237 -0
- package/extensions/tool-search/index.ts +366 -144
- package/extensions/tool-style/index.ts +68 -10
- package/extensions/tool-style/write-description.ts +40 -0
- package/extensions/tool-style/write-render.ts +237 -0
- package/extensions/turn-duration/index.ts +7 -3
- package/extensions/turn-duration/line.ts +47 -4
- package/extensions/web/backends.ts +6 -9
- package/extensions/web/description.ts +50 -0
- package/extensions/web/index.ts +118 -53
- package/extensions/web/native-call.ts +15 -0
- package/extensions/web/native-results.ts +41 -0
- package/extensions/web-fetch/description.ts +42 -0
- package/extensions/web-fetch/extract.ts +53 -6
- package/extensions/web-fetch/index.ts +125 -76
- package/extensions/web-fetch/page-content.ts +19 -0
- package/extensions/web-fetch/response.ts +49 -0
- package/extensions/web-fetch/summarize.ts +9 -10
- package/extensions/workflow/agent-session.ts +108 -18
- package/extensions/workflow/args.ts +24 -0
- package/extensions/workflow/description.ts +67 -0
- package/extensions/workflow/globals.ts +17 -3
- package/extensions/workflow/index.ts +157 -162
- package/extensions/workflow/records.ts +1 -0
- package/extensions/workflow/run-manager.ts +33 -6
- package/extensions/workflow/saved-workflows.ts +3 -2
- package/extensions/workflow/types.ts +22 -1
- package/extensions/workflow/viewer.ts +54 -24
- package/extensions/workflow/widget.ts +20 -0
- package/extensions/worktree/descriptions.ts +91 -0
- package/extensions/worktree/guards.ts +316 -54
- package/extensions/worktree/index.ts +162 -44
- package/extensions/worktree/powershell-guards.ts +167 -0
- package/extensions/worktree/rewrite.ts +14 -16
- package/package.json +21 -7
- package/skills/artifact-design/SKILL.md +85 -0
- package/skills/code-review/SKILL.md +20 -20
- package/skills/code-review/cells/arguments-and-flags.md +19 -0
- package/skills/code-review/cells/high-3x5-recall-verify.md +137 -0
- package/skills/code-review/cells/high-8-inline.md +122 -0
- package/skills/code-review/cells/low-1-pass-max4.md +27 -0
- package/skills/code-review/cells/low-1-pass-min-files-4.md +28 -0
- package/skills/code-review/cells/max-5x5-verify-sweep.md +162 -0
- package/skills/code-review/cells/medium-3x5-verify.md +132 -0
- package/skills/code-review/cells/minimal-prompt.md +32 -0
- package/skills/code-review/cells/xhigh-10-inline-sweep.md +149 -0
- package/skills/code-review/cells/xhigh-5x5-verify-sweep.md +162 -0
- package/skills/fewer-permission-prompts/SKILL.md +1 -1
- package/skills/loop/SKILL.md +11 -0
- package/skills/security-review/SKILL.md +2 -5
- package/skills/simplify/SKILL.md +7 -5
- package/skills/workflow-authoring/SKILL.md +143 -0
- package/themes/onecode-light.json +1 -1
- package/themes/onecode.json +1 -1
- package/types/app.d.ts +58 -0
- package/types/community-packages.d.ts +26 -1
- package/extensions/auto-mode/recoverability.ts +0 -229
- package/extensions/lib/capability-index.ts +0 -466
- package/extensions/lib/model-facts.generated.json +0 -2675
- package/extensions/lib/model-facts.ts +0 -162
- package/extensions/tool-search/announce.ts +0 -42
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* of the next user message, after the reminder stack and before the user's own
|
|
8
8
|
* text —
|
|
9
9
|
*
|
|
10
|
-
* <local-command-caveat>
|
|
10
|
+
* <local-command-caveat>The command below was run directly in …</local-command-caveat>\n
|
|
11
11
|
* <command-name>/model</command-name>\n
|
|
12
12
|
* <command-message>model</command-message>\n
|
|
13
13
|
* <command-args></command-args>\n
|
|
@@ -16,19 +16,25 @@
|
|
|
16
16
|
* (twelve-space indent on the second and third command lines, verbatim from
|
|
17
17
|
* CC's `formatCommandInputTags`; stdout XML-escaped like CC's `escapeXml`, `&
|
|
18
18
|
* < >` only). `/clear` carries an EMPTY stdout block and opens the new
|
|
19
|
-
* conversation. The caveat tells the model
|
|
19
|
+
* conversation. The caveat tells the model the command was the user's, not a
|
|
20
|
+
* request to it, kept as context.
|
|
20
21
|
*
|
|
21
22
|
* One Code emits these through the reminder queue's `user-prepend` placement
|
|
22
23
|
* (`lib/reminders.ts`): pi dispatches an extension command BEFORE its `input`
|
|
23
24
|
* event fires and handles its own built-ins (`/model`, `/name`, …) before
|
|
24
25
|
* either, so there is no single interception point — every One Code local
|
|
25
26
|
* command is registered through `registerLocalCommand`, which announces before
|
|
26
|
-
* the handler runs,
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
27
|
+
* the handler runs (or, with `reportsResult`, after it, carrying the handler's
|
|
28
|
+
* returned text as the stdout, as CC's `onDone(result)` does), and `/model` is
|
|
29
|
+
* announced from the `model_select` event by the extension that persists the
|
|
30
|
+
* choice. pi built-ins we cannot see
|
|
31
|
+
* (`/compact`, `/settings`, …) stay silent. The blocks are persisted when
|
|
32
|
+
* announced, as pending entries the next prompt's request carries and records
|
|
33
|
+
* (lib/reminders.ts `user-prepend`), so a `/reload` or a resume before that
|
|
34
|
+
* prompt keeps them, as CC's transcript does.
|
|
30
35
|
*/
|
|
31
36
|
|
|
37
|
+
import { announceArgumentHint, type HintEmitter, withoutExactMatch } from "./argument-hints.ts";
|
|
32
38
|
import { REMINDER_CHANNEL, type ReminderPayload } from "./reminders.ts";
|
|
33
39
|
|
|
34
40
|
/** The slice of pi's ExtensionAPI the announcer needs (its event bus). */
|
|
@@ -43,8 +49,9 @@ export interface ReminderEmitter {
|
|
|
43
49
|
*/
|
|
44
50
|
export const LOCAL_COMMAND_TAG_PREFIXES = ["<local-command-caveat>", "<command-name>", "<command-message>", "<local-command-stdout>"] as const;
|
|
45
51
|
|
|
52
|
+
/** Claude Code 2.1.288's caveat, naming the harness the command ran in. */
|
|
46
53
|
export const LOCAL_COMMAND_CAVEAT =
|
|
47
|
-
"<local-command-caveat>
|
|
54
|
+
"<local-command-caveat>The command below was run directly in One Code, not sent to you as a request, and its output goes straight to the user. It's recorded here as context for later messages.</local-command-caveat>\n";
|
|
48
55
|
|
|
49
56
|
/** CC's `escapeXml` (utils/xml.ts): `& < >` only. */
|
|
50
57
|
export function escapeXml(s: string): string {
|
|
@@ -58,6 +65,12 @@ export interface LocalCommand {
|
|
|
58
65
|
args?: string;
|
|
59
66
|
/** The command's printed result; "" (the default) is what `/clear` shows. */
|
|
60
67
|
stdout?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Keys the breadcrumb's pending entries (`<key>:caveat`, `<key>:command`,
|
|
70
|
+
* `<key>:stdout`), so a later announcement under the same key replaces an
|
|
71
|
+
* undelivered one instead of joining it.
|
|
72
|
+
*/
|
|
73
|
+
key?: string;
|
|
61
74
|
}
|
|
62
75
|
|
|
63
76
|
/** CC's `formatCommandInputTags` — the command breadcrumb, indentation included. */
|
|
@@ -70,43 +83,82 @@ export function commandStdoutBlock(stdout = ""): string {
|
|
|
70
83
|
return `<local-command-stdout>${escapeXml(stdout)}</local-command-stdout>\n`;
|
|
71
84
|
}
|
|
72
85
|
|
|
86
|
+
/** The pending-entry key suffix of each block, in `localCommandBlocks` order. */
|
|
87
|
+
const BLOCK_KEYS = ["caveat", "command", "stdout"] as const;
|
|
88
|
+
|
|
73
89
|
/** The three bare text blocks a local command leaves for the model, in CC's order. */
|
|
74
90
|
export function localCommandBlocks(command: LocalCommand): string[] {
|
|
75
91
|
return [LOCAL_COMMAND_CAVEAT, commandInputBlock(command.name, (command.args ?? "").trim()), commandStdoutBlock(command.stdout ?? "")];
|
|
76
92
|
}
|
|
77
93
|
|
|
78
94
|
/**
|
|
79
|
-
* Tell the model a local command ran. Call it from the command's handler
|
|
80
|
-
*
|
|
81
|
-
* so the breadcrumb opens the new
|
|
95
|
+
* Tell the model a local command ran. Call it from the command's handler; a
|
|
96
|
+
* command that replaces the session (`/clear`) announces from the new
|
|
97
|
+
* session's `session_start` instead, so the breadcrumb opens the new
|
|
98
|
+
* conversation exactly as in CC.
|
|
82
99
|
*/
|
|
83
100
|
export function announceLocalCommand(pi: ReminderEmitter, command: LocalCommand): void {
|
|
84
101
|
localCommandBlocks(command).forEach((text, index) => {
|
|
85
102
|
// The caveat heads a RUN of commands: a second command before the next
|
|
86
103
|
// prompt joins the first caveat instead of repeating it.
|
|
87
|
-
const payload: ReminderPayload = {
|
|
104
|
+
const payload: ReminderPayload = {
|
|
105
|
+
text,
|
|
106
|
+
placement: "user-prepend",
|
|
107
|
+
raw: true,
|
|
108
|
+
...(index === 0 ? { once: true } : {}),
|
|
109
|
+
...(command.key ? { key: `${command.key}:${BLOCK_KEYS[index]}` } : {}),
|
|
110
|
+
};
|
|
88
111
|
pi.events.emit(REMINDER_CHANNEL, payload);
|
|
89
112
|
});
|
|
90
113
|
}
|
|
91
114
|
|
|
92
115
|
type CommandOptions = { handler: (args: string, ctx: any) => Promise<void> | void } & Record<string, unknown>;
|
|
93
116
|
|
|
117
|
+
/**
|
|
118
|
+
* What a local command passes: pi's options, plus `reportsResult` when its
|
|
119
|
+
* handler returns the stdout (a returned string is never silently dropped).
|
|
120
|
+
*/
|
|
121
|
+
type LocalCommandOptions<O extends CommandOptions> = Omit<O, "handler"> & { argumentHint?: string } & (
|
|
122
|
+
| { reportsResult: true; handler: (args: string, ctx: Parameters<O["handler"]>[1]) => Promise<string | void> | string | void }
|
|
123
|
+
| { reportsResult?: false; handler: (args: string, ctx: Parameters<O["handler"]>[1]) => Promise<void> | void }
|
|
124
|
+
);
|
|
125
|
+
|
|
94
126
|
/**
|
|
95
127
|
* `pi.registerCommand` for a One Code local command: the breadcrumb is
|
|
96
|
-
* announced before the handler runs, so no command can forget it.
|
|
128
|
+
* announced before the handler runs, so no command can forget it. With
|
|
129
|
+
* `reportsResult`, it is announced once the handler settles instead, its
|
|
130
|
+
* stdout the string the handler returned (CC's `onDone(result)`; "" for none
|
|
131
|
+
* or a throw). Only a command that never starts a turn of its own may opt in:
|
|
132
|
+
* a breadcrumb queued after `sendUserMessage` would miss that message. `/clear`
|
|
97
133
|
* is the one exception — it announces from the NEW session's `session_start`
|
|
98
|
-
* (see clear/index.ts) and registers plainly.
|
|
134
|
+
* (see clear/index.ts) and registers plainly. `argumentHint` is the prompt's
|
|
135
|
+
* dim placeholder for the command's argument (lib/argument-hints.ts). Its
|
|
136
|
+
* completions leave out an exact match, so a fully typed argument runs on the
|
|
137
|
+
* first Enter (`withoutExactMatch`).
|
|
99
138
|
*/
|
|
100
139
|
export function registerLocalCommand<O extends CommandOptions>(
|
|
101
|
-
pi: ReminderEmitter & { registerCommand(name: string, options: O): void },
|
|
140
|
+
pi: ReminderEmitter & HintEmitter & { registerCommand(name: string, options: O): void },
|
|
102
141
|
name: string,
|
|
103
|
-
options: O
|
|
142
|
+
options: LocalCommandOptions<O>,
|
|
104
143
|
): void {
|
|
144
|
+
const { argumentHint, reportsResult, ...rest } = options;
|
|
145
|
+
if (argumentHint) announceArgumentHint(pi, name, argumentHint);
|
|
146
|
+
const complete = (rest as { getArgumentCompletions?: Parameters<typeof withoutExactMatch>[0] }).getArgumentCompletions;
|
|
105
147
|
pi.registerCommand(name, {
|
|
106
|
-
...
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
148
|
+
...(rest as unknown as O),
|
|
149
|
+
...(complete ? { getArgumentCompletions: withoutExactMatch(complete) } : {}),
|
|
150
|
+
handler: async (args: string, ctx: Parameters<O["handler"]>[1]) => {
|
|
151
|
+
if (!reportsResult) {
|
|
152
|
+
announceLocalCommand(pi, { name, args });
|
|
153
|
+
await options.handler(args, ctx);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
let stdout = "";
|
|
157
|
+
try {
|
|
158
|
+
stdout = (await options.handler(args, ctx)) ?? "";
|
|
159
|
+
} finally {
|
|
160
|
+
announceLocalCommand(pi, { name, args, stdout });
|
|
161
|
+
}
|
|
110
162
|
},
|
|
111
163
|
});
|
|
112
164
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* The /mcp panel's Disable/Enable action persists across sessions here rather
|
|
5
5
|
* than by mutating the user's `~/.claude.json` or a plugin's `.mcp.json`: those
|
|
6
6
|
* are Claude Code's / a plugin's config, which One Code only ever reads (the
|
|
7
|
-
* "own state, borrowed config" rule — docs/decisions/memory-state.md). A
|
|
7
|
+
* "own state, borrowed config" rule — working-docs/decisions/memory-state.md). A
|
|
8
8
|
* disabled server is still discovered and listed; the mcp extension just skips
|
|
9
9
|
* connecting it, and the panel offers Enable to bring it back.
|
|
10
10
|
*
|
|
@@ -23,3 +23,49 @@ export interface McpToolsPayload {
|
|
|
23
23
|
*/
|
|
24
24
|
settled?: boolean;
|
|
25
25
|
}
|
|
26
|
+
|
|
27
|
+
/** How long a child spawned while MCP is still connecting waits for the settled set. */
|
|
28
|
+
export const MCP_SETTLE_CAP_MS = 10_000;
|
|
29
|
+
|
|
30
|
+
/** The events slice `watchMcpTools` needs. */
|
|
31
|
+
export interface McpToolsEvents {
|
|
32
|
+
on(channel: string, handler: (data: unknown) => void): unknown;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Track the parent's live MCP tool definitions for in-process children (the
|
|
37
|
+
* subagent runner and the workflow runner). Subscribe at extension load; the
|
|
38
|
+
* getter resolves to the current set. The parent's MCP connect runs in the
|
|
39
|
+
* background, so a child spawned in the first seconds of a session waits for
|
|
40
|
+
* the settled publish, capped so a hung server cannot stall spawns, instead of
|
|
41
|
+
* baking in a still-connecting (possibly empty) snapshot. Empty when no MCP
|
|
42
|
+
* servers are configured.
|
|
43
|
+
*/
|
|
44
|
+
export function watchMcpTools(events: McpToolsEvents, settleCapMs = MCP_SETTLE_CAP_MS): () => Promise<ToolDefinition[]> {
|
|
45
|
+
let tools: ToolDefinition[] = [];
|
|
46
|
+
let settled = false;
|
|
47
|
+
let resolveSettled: (() => void) | undefined;
|
|
48
|
+
const settledPromise = new Promise<void>((resolve) => {
|
|
49
|
+
resolveSettled = resolve;
|
|
50
|
+
});
|
|
51
|
+
events.on(MCP_TOOLS_CHANNEL, (data) => {
|
|
52
|
+
const payload = data as McpToolsPayload | undefined;
|
|
53
|
+
tools = payload?.tools ?? [];
|
|
54
|
+
if (payload?.settled) {
|
|
55
|
+
settled = true;
|
|
56
|
+
resolveSettled?.();
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return async () => {
|
|
60
|
+
if (!settled) {
|
|
61
|
+
await Promise.race([
|
|
62
|
+
settledPromise,
|
|
63
|
+
new Promise<void>((resolve) => {
|
|
64
|
+
const timer = setTimeout(resolve, settleCapMs);
|
|
65
|
+
timer.unref?.();
|
|
66
|
+
}),
|
|
67
|
+
]);
|
|
68
|
+
}
|
|
69
|
+
return tools;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MEMORY.md and memory-file content: Claude Code's index load limits and
|
|
3
|
+
* truncation, and the frontmatter stamp written into memory files. Kept apart
|
|
4
|
+
* from `memory.ts`, whose path helpers most extensions import, so only the
|
|
5
|
+
* memory and doctor extensions load the YAML and instruction parsers.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { isMap, isScalar, parseDocument, visit } from "yaml";
|
|
9
|
+
import { parseRule } from "./claude-rules.ts";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Claude Code loads only the first 200 lines or 25,000 characters of
|
|
13
|
+
* MEMORY.md, whichever comes first, and tells the model what it cut (see
|
|
14
|
+
* `truncateIndex`). Mirror that so an overgrown index behaves identically
|
|
15
|
+
* here. The limits are measured against what actually loads: YAML frontmatter
|
|
16
|
+
* and block-level HTML comments are stripped first, and surrounding
|
|
17
|
+
* whitespace does not count. Claude Code measures string length, not UTF-8
|
|
18
|
+
* bytes.
|
|
19
|
+
*/
|
|
20
|
+
export const INDEX_MAX_LINES = 200;
|
|
21
|
+
export const INDEX_MAX_CHARS = 25_000;
|
|
22
|
+
|
|
23
|
+
/** The index uses Claude Code's instruction parser before applying its load limits. */
|
|
24
|
+
export function loadableIndexContent(content: string): string {
|
|
25
|
+
return parseRule(content).content;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Line and character counts of the index as the limits measure it. */
|
|
29
|
+
function indexSize(loadable: string): { trimmed: string; lines: number; chars: number } {
|
|
30
|
+
const trimmed = loadable.trim();
|
|
31
|
+
return { trimmed, lines: trimmed.split("\n").length, chars: trimmed.length };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The index as it loads. Within the limits it is the loadable content as is.
|
|
36
|
+
* Past either limit it is cut the way Claude Code cuts it: to the first 200
|
|
37
|
+
* lines, then back to the last line break within 25,000 characters, followed
|
|
38
|
+
* by Claude Code's warning line naming what was cut, so the model knows the
|
|
39
|
+
* index goes on. The result ends in a newline, so the next section of the
|
|
40
|
+
* context block starts on a line of its own.
|
|
41
|
+
*/
|
|
42
|
+
export function truncateIndex(content: string): string {
|
|
43
|
+
const loadable = loadableIndexContent(content);
|
|
44
|
+
const { trimmed, lines, chars } = indexSize(loadable);
|
|
45
|
+
const overLines = lines > INDEX_MAX_LINES;
|
|
46
|
+
const overChars = chars > INDEX_MAX_CHARS;
|
|
47
|
+
if (!overLines && !overChars) return loadable;
|
|
48
|
+
|
|
49
|
+
let kept = overLines ? trimmed.split("\n").slice(0, INDEX_MAX_LINES).join("\n") : trimmed;
|
|
50
|
+
if (kept.length > INDEX_MAX_CHARS) {
|
|
51
|
+
const lastBreak = kept.lastIndexOf("\n", INDEX_MAX_CHARS);
|
|
52
|
+
kept = kept.slice(0, lastBreak > 0 ? lastBreak : INDEX_MAX_CHARS);
|
|
53
|
+
}
|
|
54
|
+
const keptLines = trimmed[kept.length] === "\n" ? kept.split("\n").length : 0;
|
|
55
|
+
const nextStart = kept.length + 1;
|
|
56
|
+
const nextEnd = trimmed.indexOf("\n", nextStart);
|
|
57
|
+
const nextLine = trimmed.slice(nextStart, nextEnd < 0 ? undefined : nextEnd).trim();
|
|
58
|
+
const cut =
|
|
59
|
+
keptLines === 0
|
|
60
|
+
? `everything after the first ${kept.length} characters of line 1 was cut off`
|
|
61
|
+
: `${lines - keptLines} of ${lines} lines were cut off, starting at line ${keptLines + 1}${nextLine ? ` ("${shortenLine(nextLine, 80)}")` : ""}`;
|
|
62
|
+
const size =
|
|
63
|
+
overChars && !overLines
|
|
64
|
+
? `${formatSize(chars)} (limit: ${formatSize(INDEX_MAX_CHARS)}) \u2014 index entries are too long`
|
|
65
|
+
: overLines && !overChars
|
|
66
|
+
? `${lines} lines (limit: ${INDEX_MAX_LINES})`
|
|
67
|
+
: `${lines} lines and ${formatSize(chars)}`;
|
|
68
|
+
return `${kept}\n\n> WARNING: MEMORY.md is ${size}. Only part of it was loaded: ${cut}. Keep index entries to one line under ~200 chars; move detail into topic files.\n`;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** A size the way Claude Code prints it: `N bytes`, else `N.NKB`/`MB` with a trailing `.0` dropped. */
|
|
72
|
+
function formatSize(n: number): string {
|
|
73
|
+
const units = ["KB", "MB", "GB"];
|
|
74
|
+
let value = n / 1024;
|
|
75
|
+
if (value < 1) return `${n} bytes`;
|
|
76
|
+
let unit = 0;
|
|
77
|
+
while (value >= 1024 && unit < units.length - 1) {
|
|
78
|
+
value /= 1024;
|
|
79
|
+
unit++;
|
|
80
|
+
}
|
|
81
|
+
return `${value.toFixed(1).replace(/\.0$/, "")}${units[unit]}`;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Claude Code's quote of the first cut line: at most `max` characters, cut at a word when that keeps over half. */
|
|
85
|
+
function shortenLine(text: string, max: number): string {
|
|
86
|
+
if (text.length <= max) return text;
|
|
87
|
+
const head = [...text].slice(0, max - 1).join("");
|
|
88
|
+
const lastSpace = head.search(/\s\S*$/);
|
|
89
|
+
const atWord = lastSpace === -1 ? "" : head.slice(0, lastSpace).trimEnd();
|
|
90
|
+
return `${atWord.length > max / 2 ? atWord : head.trimEnd()}\u2026`;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Where the index stands against its load limits, checked after each write so
|
|
95
|
+
* the model hears about an overgrown index while it can still fix it (Claude
|
|
96
|
+
* Code behaves the same: near-limit reminder, over-limit error — the write
|
|
97
|
+
* itself always succeeds).
|
|
98
|
+
*/
|
|
99
|
+
export function indexLimitStatus(content: string): "ok" | "near" | "over" {
|
|
100
|
+
const { lines, chars } = indexSize(loadableIndexContent(content));
|
|
101
|
+
if (lines > INDEX_MAX_LINES || chars > INDEX_MAX_CHARS) return "over";
|
|
102
|
+
if (lines >= INDEX_MAX_LINES * 0.9 || chars >= INDEX_MAX_CHARS * 0.9) return "near";
|
|
103
|
+
return "ok";
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export const INDEX_NEAR_LIMIT_REMINDER = `MEMORY.md is approaching its load limit (only the first ${INDEX_MAX_LINES} lines or 25KB are loaded each session). Shorten it now: keep one line per entry, move detail into topic files in the memory directory, and merge or drop stale entries.`;
|
|
107
|
+
|
|
108
|
+
export const INDEX_OVER_LIMIT_ERROR = `MEMORY.md is over its load limit (${INDEX_MAX_LINES} lines / 25KB): everything past the limit is dropped the next time it is loaded. The write succeeded, but rewrite the index now — one line per entry, move detail into topic files, merge or drop stale entries.`;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Stamp safe YAML memory headers, retaining the originating session on updates.
|
|
112
|
+
* Claude Code's ue/Mt preserve originSessionId; Dn declines unsafe rewrites.
|
|
113
|
+
* Keep comments, flow mappings, BOM/CRLF and the body; leave malformed headers,
|
|
114
|
+
* aliases and non-mapping metadata untouched rather than losing user content.
|
|
115
|
+
*/
|
|
116
|
+
export function stampFrontmatter(content: string, sessionId: string, modifiedIso: string): string {
|
|
117
|
+
if (/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F]/.test(content)) return content;
|
|
118
|
+
const match = content.match(/^(\uFEFF?---[ \t]*\r?\n)([\s\S]*?)(\r?\n---[ \t]*(?:\r?\n|$))/);
|
|
119
|
+
if (!match) return content;
|
|
120
|
+
|
|
121
|
+
// Claude Code checks its permissive parser against strict delimiters before
|
|
122
|
+
// rewriting: a quoted value containing "---" can make the header ambiguous.
|
|
123
|
+
const parsedBoundary = content.replace(/^\uFEFF/, "").match(/^---\s*\n([\s\S]*?)---\s*\n?/);
|
|
124
|
+
if (parsedBoundary?.[1].trim() !== match[2].trim()) return content;
|
|
125
|
+
|
|
126
|
+
const document = parseDocument(match[2]);
|
|
127
|
+
if (document.errors.length || document.warnings.length || !isMap(document.contents)) return content;
|
|
128
|
+
let hasAlias = false;
|
|
129
|
+
visit(document, { Alias: () => { hasAlias = true; } });
|
|
130
|
+
if (hasAlias) return content;
|
|
131
|
+
|
|
132
|
+
if (document.get("metadata") == null) document.set("metadata", document.createNode({}));
|
|
133
|
+
const metadata = document.get("metadata", true);
|
|
134
|
+
if (!isMap(metadata)) return content;
|
|
135
|
+
|
|
136
|
+
metadata.set("node_type", "memory");
|
|
137
|
+
const nodeIndex = metadata.items.findIndex((pair) => isScalar(pair.key) && pair.key.value === "node_type");
|
|
138
|
+
metadata.items.unshift(...metadata.items.splice(nodeIndex, 1));
|
|
139
|
+
const origin = metadata.get("originSessionId");
|
|
140
|
+
if (typeof origin !== "string" || !origin) metadata.set("originSessionId", sessionId);
|
|
141
|
+
metadata.set("modified", modifiedIso);
|
|
142
|
+
|
|
143
|
+
let yaml = document.toString().replace(/\n$/, "");
|
|
144
|
+
if (match[1].endsWith("\r\n")) yaml = yaml.replaceAll("\n", "\r\n");
|
|
145
|
+
return match[1] + yaml + match[3] + content.slice(match[0].length);
|
|
146
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Read the startup/compaction memory index without loading excluded or non-text files. */
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { isClaudeLocation, readFileIfPresent } from "./claude-context.ts";
|
|
5
|
+
import { autoMemoryEnabled } from "./auto-memory.ts";
|
|
6
|
+
import { claudeSourcesOn } from "./config-mode.ts";
|
|
7
|
+
import { projectMemoryDir } from "./memory.ts";
|
|
8
|
+
import { truncateIndex } from "./memory-content.ts";
|
|
9
|
+
import { claudeUserDir } from "./paths.ts";
|
|
10
|
+
|
|
11
|
+
export function readMemoryIndex(cwd: string, home: string = os.homedir()): { path: string; content: string } | null {
|
|
12
|
+
if (!autoMemoryEnabled(cwd)) return null;
|
|
13
|
+
const path = join(projectMemoryDir(cwd, home), "MEMORY.md");
|
|
14
|
+
if (!claudeSourcesOn() && isClaudeLocation(path, claudeUserDir(home))) return null;
|
|
15
|
+
const raw = readFileIfPresent(path);
|
|
16
|
+
if (!raw?.trim() || raw.includes("\0")) return null;
|
|
17
|
+
return { path, content: truncateIndex(raw) };
|
|
18
|
+
}
|