@cjhyy/code-shell-core 0.5.0-rc.1 → 0.6.0-rc.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.
- package/README.md +13 -10
- package/dist/agent/agent-definition-registry.d.ts +21 -3
- package/dist/agent/agent-definition-registry.js +49 -18
- package/dist/agent/agent-definition.d.ts +32 -0
- package/dist/agent/agent-definition.js +49 -4
- package/dist/arena/arena.js +11 -12
- package/dist/arena/context/context-tools.js +47 -6
- package/dist/arena/context/within-root.d.ts +7 -0
- package/dist/arena/context/within-root.js +15 -0
- package/dist/arena/iterate/phases/argue.js +8 -2
- package/dist/arena/iterate/phases/revise.js +1 -1
- package/dist/arena/iterate/phases/tournament.js +3 -3
- package/dist/arena/ledger.js +9 -1
- package/dist/arena/phases/adjudication.js +1 -4
- package/dist/arena/phases/build-consensus.js +1 -4
- package/dist/arena/phases/cross-review.js +2 -8
- package/dist/arena/phases/debate-rounds.js +1 -4
- package/dist/arena/phases/participant-research.js +1 -4
- package/dist/arena/phases/planning-detail-expansion.js +8 -10
- package/dist/arena/planner.js +0 -1
- package/dist/arena/providers/docs.d.ts +1 -0
- package/dist/arena/providers/docs.js +5 -2
- package/dist/arena/providers/repo.d.ts +1 -0
- package/dist/arena/providers/repo.js +5 -2
- package/dist/arena/strategies/utils.d.ts +1 -4
- package/dist/arena/strategies/utils.js +7 -51
- package/dist/arena/transitions.d.ts +7 -2
- package/dist/arena/transitions.js +9 -4
- package/dist/arena/types.d.ts +8 -2
- package/dist/automation/cron-expr.d.ts +41 -0
- package/dist/automation/cron-expr.js +169 -0
- package/dist/automation/index.d.ts +41 -0
- package/dist/automation/index.js +39 -0
- package/dist/automation/runner.d.ts +84 -0
- package/dist/automation/runner.js +92 -0
- package/dist/automation/scheduler.d.ts +194 -0
- package/dist/automation/scheduler.js +623 -0
- package/dist/automation/store.d.ts +39 -0
- package/dist/automation/store.js +122 -0
- package/dist/automation/write-policy.d.ts +34 -0
- package/dist/automation/write-policy.js +113 -0
- package/dist/automation/write-run.d.ts +51 -0
- package/dist/automation/write-run.js +38 -0
- package/dist/capability-control/disabled-lists.d.ts +25 -0
- package/dist/capability-control/disabled-lists.js +57 -0
- package/dist/capability-control/index.d.ts +5 -0
- package/dist/capability-control/index.js +3 -0
- package/dist/capability-control/overlay.d.ts +64 -0
- package/dist/capability-control/overlay.js +116 -0
- package/dist/capability-control/project.d.ts +65 -0
- package/dist/capability-control/project.js +147 -0
- package/dist/capability-control/service.d.ts +70 -0
- package/dist/capability-control/service.js +147 -0
- package/dist/capability-control/types.d.ts +62 -0
- package/dist/capability-control/types.js +17 -0
- package/dist/cc-orchestrator/agent-adapter.d.ts +50 -0
- package/dist/cc-orchestrator/agent-adapter.js +133 -0
- package/dist/cc-orchestrator/cc-capability.d.ts +19 -0
- package/dist/cc-orchestrator/cc-capability.js +53 -0
- package/dist/cc-orchestrator/codex-session-discovery.d.ts +24 -0
- package/dist/cc-orchestrator/codex-session-discovery.js +191 -0
- package/dist/cc-orchestrator/codex-session-history.d.ts +25 -0
- package/dist/cc-orchestrator/codex-session-history.js +187 -0
- package/dist/cc-orchestrator/external-agent-changes.d.ts +19 -0
- package/dist/cc-orchestrator/external-agent-changes.js +214 -0
- package/dist/cc-orchestrator/external-agent-driver.d.ts +18 -0
- package/dist/cc-orchestrator/external-agent-driver.js +69 -0
- package/dist/cc-orchestrator/index.d.ts +8 -0
- package/dist/cc-orchestrator/index.js +8 -0
- package/dist/cc-orchestrator/relevance-judge.d.ts +15 -0
- package/dist/cc-orchestrator/relevance-judge.js +29 -0
- package/dist/cc-orchestrator/session-discovery.d.ts +46 -0
- package/dist/cc-orchestrator/session-discovery.js +125 -0
- package/dist/cc-orchestrator/session-history.d.ts +19 -0
- package/dist/cc-orchestrator/session-history.js +67 -0
- package/dist/cli/agent-server-stdio.d.ts +26 -1
- package/dist/cli/agent-server-stdio.js +221 -28
- package/dist/cli/agent-server-tcp.d.ts +20 -0
- package/dist/cli/agent-server-tcp.js +134 -0
- package/dist/cli/graceful-shutdown.d.ts +27 -0
- package/dist/cli/graceful-shutdown.js +30 -0
- package/dist/context/compaction.d.ts +56 -0
- package/dist/context/compaction.js +209 -15
- package/dist/context/manager.d.ts +0 -20
- package/dist/context/manager.js +25 -41
- package/dist/cost-tracker.js +5 -61
- package/dist/credentials/cipher.d.ts +49 -0
- package/dist/credentials/cipher.js +45 -0
- package/dist/credentials/cookie-jar.d.ts +24 -0
- package/dist/credentials/cookie-jar.js +40 -0
- package/dist/credentials/index.d.ts +7 -0
- package/dist/credentials/index.js +5 -0
- package/dist/credentials/inject-credential-tool.d.ts +20 -0
- package/dist/credentials/inject-credential-tool.js +130 -0
- package/dist/credentials/store.d.ts +72 -0
- package/dist/credentials/store.js +184 -0
- package/dist/credentials/types.d.ts +56 -0
- package/dist/credentials/use-credential-tool.d.ts +29 -0
- package/dist/credentials/use-credential-tool.js +205 -0
- package/dist/credentials/use-gate.d.ts +56 -0
- package/dist/credentials/use-gate.js +52 -0
- package/dist/cron/cron-runtime.d.ts +2 -0
- package/dist/cron/cron-runtime.js +2 -0
- package/dist/cron/cron-store.d.ts +2 -0
- package/dist/cron/cron-store.js +2 -0
- package/dist/cron/scheduler.d.ts +5 -32
- package/dist/cron/scheduler.js +5 -113
- package/dist/data/model-metadata.d.ts +77 -0
- package/dist/data/model-metadata.js +56 -0
- package/dist/data/model-metadata.json +216 -0
- package/dist/data/openrouter-models.d.ts +18 -7
- package/dist/data/openrouter-models.js +35 -8
- package/dist/data/openrouter-sync.js +1 -1
- package/dist/engine/aux-key.d.ts +10 -0
- package/dist/engine/aux-key.js +11 -0
- package/dist/engine/dynamic-tool-defs.d.ts +19 -0
- package/dist/engine/dynamic-tool-defs.js +36 -0
- package/dist/engine/engine.d.ts +431 -108
- package/dist/engine/engine.js +1630 -279
- package/dist/engine/friendly-error.d.ts +18 -0
- package/dist/engine/friendly-error.js +63 -0
- package/dist/engine/goal.d.ts +187 -0
- package/dist/engine/goal.js +196 -0
- package/dist/engine/image-compression.d.ts +81 -0
- package/dist/engine/image-compression.js +186 -0
- package/dist/engine/image-policy.d.ts +165 -0
- package/dist/engine/image-policy.js +189 -0
- package/dist/engine/model-connections-pool.d.ts +17 -0
- package/dist/engine/model-connections-pool.js +66 -0
- package/dist/engine/model-facade.d.ts +10 -0
- package/dist/engine/model-facade.js +25 -0
- package/dist/engine/patch-orphaned-tools.js +3 -0
- package/dist/engine/reactive-threshold.d.ts +13 -0
- package/dist/engine/reactive-threshold.js +17 -0
- package/dist/engine/resolve-llm-config.d.ts +16 -0
- package/dist/engine/resolve-llm-config.js +44 -0
- package/dist/engine/runtime.js +9 -1
- package/dist/engine/sandbox-cache-key.d.ts +10 -0
- package/dist/engine/sandbox-cache-key.js +9 -0
- package/dist/engine/sandbox-config.d.ts +31 -0
- package/dist/engine/sandbox-config.js +38 -0
- package/dist/engine/session-title.d.ts +13 -0
- package/dist/engine/session-title.js +34 -0
- package/dist/engine/session-usage.d.ts +19 -0
- package/dist/engine/session-usage.js +25 -0
- package/dist/engine/steer-queue.d.ts +32 -0
- package/dist/engine/steer-queue.js +26 -0
- package/dist/engine/streaming-tool-queue.d.ts +12 -0
- package/dist/engine/streaming-tool-queue.js +50 -10
- package/dist/engine/turn-loop.d.ts +94 -9
- package/dist/engine/turn-loop.js +775 -342
- package/dist/engine/types.d.ts +175 -0
- package/dist/engine/types.js +13 -0
- package/dist/external-agents/config.d.ts +2 -0
- package/dist/external-agents/config.js +15 -0
- package/dist/external-agents/types.d.ts +31 -0
- package/dist/external-agents/types.js +1 -0
- package/dist/git/parse-log.d.ts +13 -0
- package/dist/git/parse-log.js +21 -0
- package/dist/git/utils.d.ts +8 -6
- package/dist/git/utils.js +62 -26
- package/dist/git/worktree.d.ts +48 -0
- package/dist/git/worktree.js +111 -20
- package/dist/hooks/events.d.ts +23 -1
- package/dist/hooks/goal-stop-hook.d.ts +58 -0
- package/dist/hooks/goal-stop-hook.js +279 -0
- package/dist/hooks/hook-output.d.ts +33 -0
- package/dist/hooks/hook-output.js +79 -0
- package/dist/hooks/registry.d.ts +15 -0
- package/dist/hooks/registry.js +57 -1
- package/dist/hooks/shell-runner.d.ts +2 -0
- package/dist/hooks/shell-runner.js +48 -18
- package/dist/index.d.ts +79 -11
- package/dist/index.js +89 -6
- package/dist/llm/capabilities/param-specs.d.ts +14 -0
- package/dist/llm/capabilities/param-specs.js +62 -0
- package/dist/llm/capabilities/reasoning-control.d.ts +24 -0
- package/dist/llm/capabilities/reasoning-control.js +38 -0
- package/dist/llm/capabilities/rules.js +37 -3
- package/dist/llm/capabilities/types.d.ts +32 -2
- package/dist/llm/clamp-max-tokens.d.ts +11 -0
- package/dist/llm/clamp-max-tokens.js +17 -0
- package/dist/llm/client-base.d.ts +69 -5
- package/dist/llm/client-base.js +185 -25
- package/dist/llm/client-factory.d.ts +3 -3
- package/dist/llm/client-factory.js +2 -2
- package/dist/llm/model-cache.js +4 -2
- package/dist/llm/model-pool.d.ts +29 -11
- package/dist/llm/model-pool.js +36 -20
- package/dist/llm/provider-auth.d.ts +41 -0
- package/dist/llm/provider-auth.js +76 -0
- package/dist/llm/provider-catalog.d.ts +6 -2
- package/dist/llm/providers/anthropic.d.ts +32 -2
- package/dist/llm/providers/anthropic.js +207 -18
- package/dist/llm/providers/openai.d.ts +47 -2
- package/dist/llm/providers/openai.js +478 -71
- package/dist/llm/reasoning-setting.d.ts +51 -0
- package/dist/llm/reasoning-setting.js +40 -0
- package/dist/llm/stop-reason.d.ts +13 -0
- package/dist/llm/stop-reason.js +21 -0
- package/dist/llm/stream-watchdog.js +5 -1
- package/dist/llm/strip-vision.d.ts +32 -0
- package/dist/llm/strip-vision.js +94 -0
- package/dist/llm/token-counter.js +9 -2
- package/dist/llm/types.d.ts +9 -6
- package/dist/logging/logger.js +18 -4
- package/dist/logging/sanitize-messages.d.ts +10 -0
- package/dist/logging/sanitize-messages.js +112 -0
- package/dist/lsp/client.js +28 -8
- package/dist/lsp/manager.d.ts +1 -1
- package/dist/lsp/manager.js +42 -11
- package/dist/lsp/root-path.d.ts +9 -0
- package/dist/lsp/root-path.js +12 -0
- package/dist/model-catalog/builtin.d.ts +12 -0
- package/dist/model-catalog/builtin.js +407 -0
- package/dist/model-catalog/gen-connections.d.ts +20 -0
- package/dist/model-catalog/gen-connections.js +28 -0
- package/dist/model-catalog/index.d.ts +41 -0
- package/dist/model-catalog/index.js +90 -0
- package/dist/model-catalog/params.d.ts +20 -0
- package/dist/model-catalog/params.js +45 -0
- package/dist/model-catalog/resolve.d.ts +48 -0
- package/dist/model-catalog/resolve.js +33 -0
- package/dist/model-catalog/save-entry.d.ts +32 -0
- package/dist/model-catalog/save-entry.js +104 -0
- package/dist/model-catalog/types.d.ts +561 -0
- package/dist/model-catalog/types.js +93 -0
- package/dist/model-catalog/upsert.d.ts +9 -0
- package/dist/model-catalog/upsert.js +8 -0
- package/dist/onboarding.d.ts +12 -82
- package/dist/onboarding.js +75 -333
- package/dist/plugins/gitOps.d.ts +53 -0
- package/dist/plugins/gitOps.js +130 -5
- package/dist/plugins/installer/checkUpdate.d.ts +16 -0
- package/dist/plugins/installer/checkUpdate.js +32 -0
- package/dist/plugins/installer/codex/convertAgents.d.ts +7 -0
- package/dist/plugins/installer/codex/convertAgents.js +55 -0
- package/dist/plugins/installer/codex/convertCommands.d.ts +19 -0
- package/dist/plugins/installer/codex/convertCommands.js +46 -0
- package/dist/plugins/installer/codex/convertMcp.d.ts +11 -0
- package/dist/plugins/installer/codex/convertMcp.js +85 -0
- package/dist/plugins/installer/codex/convertSkills.d.ts +12 -0
- package/dist/plugins/installer/codex/convertSkills.js +33 -0
- package/dist/plugins/installer/detectFormat.d.ts +2 -0
- package/dist/plugins/installer/detectFormat.js +6 -0
- package/dist/plugins/installer/install.d.ts +7 -0
- package/dist/plugins/installer/install.js +123 -0
- package/dist/plugins/installer/installFromArchive.d.ts +43 -0
- package/dist/plugins/installer/installFromArchive.js +134 -0
- package/dist/plugins/installer/installFromSource.d.ts +13 -0
- package/dist/plugins/installer/installFromSource.js +51 -0
- package/dist/plugins/installer/list.d.ts +9 -0
- package/dist/plugins/installer/list.js +30 -0
- package/dist/plugins/installer/loadPluginAgents.d.ts +3 -0
- package/dist/plugins/installer/loadPluginAgents.js +27 -0
- package/dist/plugins/installer/loadPluginMcp.d.ts +14 -0
- package/dist/plugins/installer/loadPluginMcp.js +107 -0
- package/dist/plugins/installer/parseSource.d.ts +20 -0
- package/dist/plugins/installer/parseSource.js +74 -0
- package/dist/plugins/installer/paths.d.ts +5 -0
- package/dist/plugins/installer/paths.js +25 -0
- package/dist/plugins/installer/pruneDisabled.d.ts +24 -0
- package/dist/plugins/installer/pruneDisabled.js +73 -0
- package/dist/plugins/installer/types.d.ts +52 -0
- package/dist/plugins/installer/types.js +28 -0
- package/dist/plugins/installer/uninstall.d.ts +2 -0
- package/dist/plugins/installer/uninstall.js +18 -0
- package/dist/plugins/installer/unzip.d.ts +14 -0
- package/dist/plugins/installer/unzip.js +82 -0
- package/dist/plugins/installer/update.d.ts +28 -0
- package/dist/plugins/installer/update.js +97 -0
- package/dist/plugins/loadPluginHooks.d.ts +54 -1
- package/dist/plugins/loadPluginHooks.js +83 -1
- package/dist/plugins/marketplaceManager.d.ts +15 -1
- package/dist/plugins/marketplaceManager.js +58 -4
- package/dist/plugins/pluginCommandHook.js +34 -14
- package/dist/plugins/pluginContent.d.ts +30 -0
- package/dist/plugins/pluginContent.js +83 -0
- package/dist/plugins/pluginInstaller.d.ts +34 -0
- package/dist/plugins/pluginInstaller.js +168 -35
- package/dist/plugins/schemas.js +41 -6
- package/dist/plugins/types.d.ts +10 -0
- package/dist/preset/index.d.ts +7 -1
- package/dist/preset/index.js +112 -6
- package/dist/product/types.d.ts +1 -1
- package/dist/prompt/composer.d.ts +31 -0
- package/dist/prompt/composer.js +95 -25
- package/dist/prompt/instruction-scanner.js +5 -3
- package/dist/prompt/section-loader.js +1 -0
- package/dist/prompt/sections/base.md +1 -0
- package/dist/prompt/sections/browser.md +10 -0
- package/dist/prompt/sections/coding.md +4 -0
- package/dist/prompt/sections/orchestration.md +8 -0
- package/dist/protocol/chat-session-manager.d.ts +15 -2
- package/dist/protocol/chat-session-manager.js +46 -0
- package/dist/protocol/chat-session.d.ts +82 -0
- package/dist/protocol/chat-session.js +121 -1
- package/dist/protocol/client.d.ts +27 -0
- package/dist/protocol/client.js +38 -0
- package/dist/protocol/redact.d.ts +50 -0
- package/dist/protocol/redact.js +71 -0
- package/dist/protocol/server.d.ts +153 -2
- package/dist/protocol/server.js +807 -39
- package/dist/protocol/tcp-transport.d.ts +45 -0
- package/dist/protocol/tcp-transport.js +74 -0
- package/dist/protocol/transport.js +3 -2
- package/dist/protocol/types.d.ts +69 -0
- package/dist/protocol/types.js +22 -0
- package/dist/quota/credentials.d.ts +3 -0
- package/dist/quota/credentials.js +80 -0
- package/dist/quota/index.d.ts +36 -0
- package/dist/quota/index.js +155 -0
- package/dist/quota/types.d.ts +48 -0
- package/dist/quota/types.js +13 -0
- package/dist/remote/bridge.d.ts +11 -2
- package/dist/remote/bridge.js +61 -33
- package/dist/review/review-prompt.d.ts +28 -0
- package/dist/review/review-prompt.js +81 -0
- package/dist/run/ArtifactTracker.js +5 -4
- package/dist/run/EngineRunner.d.ts +27 -1
- package/dist/run/EngineRunner.js +46 -8
- package/dist/run/FileRunStore.js +40 -11
- package/dist/run/RunApprovalBackend.js +25 -5
- package/dist/run/RunLock.d.ts +28 -2
- package/dist/run/RunLock.js +49 -7
- package/dist/run/RunManager.d.ts +12 -0
- package/dist/run/RunManager.js +86 -3
- package/dist/run/RunQueue.d.ts +1 -0
- package/dist/run/RunQueue.js +8 -2
- package/dist/run/factory.d.ts +8 -1
- package/dist/run/factory.js +1 -0
- package/dist/run/index.d.ts +2 -2
- package/dist/run/index.js +1 -1
- package/dist/run/redirect-target.d.ts +7 -0
- package/dist/run/redirect-target.js +13 -0
- package/dist/run/types.js +1 -1
- package/dist/runtime/background-shell.d.ts +139 -0
- package/dist/runtime/background-shell.js +495 -0
- package/dist/runtime/output-clean.d.ts +24 -0
- package/dist/runtime/output-clean.js +41 -0
- package/dist/runtime/ring-file.d.ts +64 -0
- package/dist/runtime/ring-file.js +174 -0
- package/dist/runtime/safe-spawn.js +15 -34
- package/dist/runtime/spawn-common.d.ts +148 -0
- package/dist/runtime/spawn-common.js +303 -0
- package/dist/runtime/truncate-output.d.ts +22 -0
- package/dist/runtime/truncate-output.js +49 -0
- package/dist/runtime/utf8-cut.d.ts +11 -0
- package/dist/runtime/utf8-cut.js +23 -0
- package/dist/services/auto-dream.d.ts +4 -0
- package/dist/services/auto-dream.js +26 -26
- package/dist/services/browser-open.d.ts +13 -0
- package/dist/services/browser-open.js +16 -0
- package/dist/services/diagnostics.d.ts +1 -2
- package/dist/services/diagnostics.js +12 -7
- package/dist/services/dream-consolidation.d.ts +57 -0
- package/dist/services/dream-consolidation.js +151 -0
- package/dist/services/extract-memories.d.ts +14 -1
- package/dist/services/extract-memories.js +45 -6
- package/dist/services/memory-orchestrator.d.ts +21 -0
- package/dist/services/memory-orchestrator.js +125 -32
- package/dist/services/notifier.d.ts +8 -0
- package/dist/services/notifier.js +39 -25
- package/dist/services/oauth.js +5 -7
- package/dist/services/session-memory-sort.d.ts +8 -0
- package/dist/services/session-memory-sort.js +9 -0
- package/dist/services/session-memory.js +30 -19
- package/dist/session/file-history.d.ts +124 -1
- package/dist/session/file-history.js +232 -9
- package/dist/session/memory.d.ts +116 -2
- package/dist/session/memory.js +250 -28
- package/dist/session/session-manager.d.ts +63 -1
- package/dist/session/session-manager.js +186 -5
- package/dist/session/simple-diff.d.ts +23 -0
- package/dist/session/simple-diff.js +84 -0
- package/dist/session/transcript.d.ts +25 -1
- package/dist/session/transcript.js +35 -2
- package/dist/session/undo-target.d.ts +67 -0
- package/dist/session/undo-target.js +144 -0
- package/dist/settings/disk-defaults.d.ts +42 -0
- package/dist/settings/disk-defaults.js +33 -0
- package/dist/settings/feature-flags.d.ts +64 -0
- package/dist/settings/feature-flags.js +61 -0
- package/dist/settings/manager.d.ts +101 -1
- package/dist/settings/manager.js +345 -15
- package/dist/settings/migrate-config.d.ts +45 -0
- package/dist/settings/migrate-config.js +125 -0
- package/dist/settings/personalization.d.ts +19 -0
- package/dist/settings/personalization.js +7 -0
- package/dist/settings/schema-export.d.ts +25 -0
- package/dist/settings/schema-export.js +38 -0
- package/dist/settings/schema.d.ts +1827 -396
- package/dist/settings/schema.js +361 -81
- package/dist/skills/scanner.d.ts +9 -0
- package/dist/skills/scanner.js +30 -2
- package/dist/stt/resolve-transcribe.d.ts +31 -0
- package/dist/stt/resolve-transcribe.js +108 -0
- package/dist/stt/transcribe.d.ts +51 -0
- package/dist/stt/transcribe.js +65 -0
- package/dist/tool-system/browser-bridge.d.ts +226 -0
- package/dist/tool-system/browser-bridge.js +163 -0
- package/dist/tool-system/builtin/add-marketplace.d.ts +12 -0
- package/dist/tool-system/builtin/add-marketplace.js +76 -0
- package/dist/tool-system/builtin/agent-heartbeat.d.ts +49 -0
- package/dist/tool-system/builtin/agent-heartbeat.js +89 -0
- package/dist/tool-system/builtin/agent-notifications.d.ts +12 -3
- package/dist/tool-system/builtin/agent-notifications.js +9 -3
- package/dist/tool-system/builtin/agent-output-file.d.ts +38 -0
- package/dist/tool-system/builtin/agent-output-file.js +72 -0
- package/dist/tool-system/builtin/agent-registry.d.ts +23 -0
- package/dist/tool-system/builtin/agent-registry.js +16 -4
- package/dist/tool-system/builtin/agent.d.ts +50 -11
- package/dist/tool-system/builtin/agent.js +576 -73
- package/dist/tool-system/builtin/apply-patch/applier.js +66 -8
- package/dist/tool-system/builtin/apply-patch/backup-targets.d.ts +10 -0
- package/dist/tool-system/builtin/apply-patch/backup-targets.js +30 -0
- package/dist/tool-system/builtin/apply-patch/index.js +7 -3
- package/dist/tool-system/builtin/arena.js +6 -7
- package/dist/tool-system/builtin/background-jobs.d.ts +76 -0
- package/dist/tool-system/builtin/background-jobs.js +124 -0
- package/dist/tool-system/builtin/background-shell-tools.d.ts +20 -0
- package/dist/tool-system/builtin/background-shell-tools.js +108 -0
- package/dist/tool-system/builtin/background-work.d.ts +67 -0
- package/dist/tool-system/builtin/background-work.js +86 -0
- package/dist/tool-system/builtin/bash-output-style.d.ts +32 -0
- package/dist/tool-system/builtin/bash-output-style.js +40 -0
- package/dist/tool-system/builtin/bash.d.ts +5 -2
- package/dist/tool-system/builtin/bash.js +98 -62
- package/dist/tool-system/builtin/browser-tools.d.ts +33 -0
- package/dist/tool-system/builtin/browser-tools.js +312 -0
- package/dist/tool-system/builtin/cancel-goal.d.ts +31 -0
- package/dist/tool-system/builtin/cancel-goal.js +64 -0
- package/dist/tool-system/builtin/check-quota.d.ts +15 -0
- package/dist/tool-system/builtin/check-quota.js +34 -0
- package/dist/tool-system/builtin/complete-goal.d.ts +25 -0
- package/dist/tool-system/builtin/complete-goal.js +45 -0
- package/dist/tool-system/builtin/config.js +7 -0
- package/dist/tool-system/builtin/cron.d.ts +7 -0
- package/dist/tool-system/builtin/cron.js +105 -9
- package/dist/tool-system/builtin/drive-claude-code.d.ts +30 -0
- package/dist/tool-system/builtin/drive-claude-code.js +157 -0
- package/dist/tool-system/builtin/edit-model-catalog.d.ts +3 -0
- package/dist/tool-system/builtin/edit-model-catalog.js +94 -0
- package/dist/tool-system/builtin/edit.d.ts +2 -1
- package/dist/tool-system/builtin/edit.js +21 -12
- package/dist/tool-system/builtin/eol.d.ts +29 -0
- package/dist/tool-system/builtin/eol.js +37 -0
- package/dist/tool-system/builtin/file-cache.d.ts +6 -0
- package/dist/tool-system/builtin/file-cache.js +8 -0
- package/dist/tool-system/builtin/generate-image.d.ts +60 -0
- package/dist/tool-system/builtin/generate-image.js +374 -0
- package/dist/tool-system/builtin/generate-video.d.ts +55 -0
- package/dist/tool-system/builtin/generate-video.js +361 -0
- package/dist/tool-system/builtin/grep.js +6 -2
- package/dist/tool-system/builtin/image-providers.d.ts +86 -0
- package/dist/tool-system/builtin/image-providers.js +190 -0
- package/dist/tool-system/builtin/image-uploader.d.ts +33 -0
- package/dist/tool-system/builtin/image-uploader.js +74 -0
- package/dist/tool-system/builtin/index.d.ts +24 -1
- package/dist/tool-system/builtin/index.js +310 -25
- package/dist/tool-system/builtin/mcp-tools.js +23 -3
- package/dist/tool-system/builtin/memory.js +45 -7
- package/dist/tool-system/builtin/notebook-edit.d.ts +2 -1
- package/dist/tool-system/builtin/notebook-edit.js +1 -1
- package/dist/tool-system/builtin/powershell.js +4 -1
- package/dist/tool-system/builtin/read.d.ts +2 -1
- package/dist/tool-system/builtin/read.js +11 -3
- package/dist/tool-system/builtin/repl.js +4 -1
- package/dist/tool-system/builtin/skill.js +9 -0
- package/dist/tool-system/builtin/sleep.js +12 -5
- package/dist/tool-system/builtin/task.js +4 -1
- package/dist/tool-system/builtin/tool-search.js +25 -7
- package/dist/tool-system/builtin/update-automation-memory.d.ts +24 -0
- package/dist/tool-system/builtin/update-automation-memory.js +60 -0
- package/dist/tool-system/builtin/video-providers.d.ts +154 -0
- package/dist/tool-system/builtin/video-providers.js +235 -0
- package/dist/tool-system/builtin/view-image.d.ts +18 -0
- package/dist/tool-system/builtin/view-image.js +96 -0
- package/dist/tool-system/builtin/web-fetch.js +12 -2
- package/dist/tool-system/builtin/web-search.d.ts +4 -1
- package/dist/tool-system/builtin/web-search.js +57 -10
- package/dist/tool-system/builtin/worktree.d.ts +2 -1
- package/dist/tool-system/builtin/worktree.js +31 -4
- package/dist/tool-system/builtin/write.d.ts +2 -1
- package/dist/tool-system/builtin/write.js +1 -1
- package/dist/tool-system/context.d.ts +166 -6
- package/dist/tool-system/executor.d.ts +3 -2
- package/dist/tool-system/executor.js +197 -119
- package/dist/tool-system/investigation-guard.d.ts +4 -1
- package/dist/tool-system/investigation-guard.js +20 -4
- package/dist/tool-system/mcp-manager.d.ts +78 -16
- package/dist/tool-system/mcp-manager.js +357 -28
- package/dist/tool-system/path-policy.d.ts +99 -0
- package/dist/tool-system/path-policy.js +578 -0
- package/dist/tool-system/permission.d.ts +36 -1
- package/dist/tool-system/permission.js +322 -117
- package/dist/tool-system/plan-mode-allowlist.d.ts +32 -0
- package/dist/tool-system/plan-mode-allowlist.js +65 -0
- package/dist/tool-system/registry.d.ts +1 -0
- package/dist/tool-system/registry.js +26 -1
- package/dist/tool-system/sandbox/index.d.ts +8 -0
- package/dist/tool-system/sandbox/index.js +7 -2
- package/dist/tool-system/validate-tool-metadata.d.ts +36 -0
- package/dist/tool-system/validate-tool-metadata.js +63 -0
- package/dist/tool-system/validation.d.ts +10 -0
- package/dist/tool-system/validation.js +16 -3
- package/dist/types.d.ts +301 -15
- package/dist/updater.js +20 -9
- package/dist/utils/envUtils.d.ts +0 -9
- package/dist/utils/envUtils.js +3 -28
- package/dist/utils/exec.d.ts +40 -0
- package/dist/utils/exec.js +144 -0
- package/dist/utils/format.js +4 -2
- package/dist/utils/json.d.ts +12 -0
- package/dist/utils/json.js +92 -0
- package/dist/utils/lockfile.js +9 -2
- package/dist/utils/theme.d.ts +7 -1
- package/dist/utils/theme.js +5 -3
- package/dist/utils/toolDisplay.js +0 -1
- package/package.json +14 -7
- package/dist/agent/coordinator.d.ts +0 -49
- package/dist/agent/coordinator.js +0 -77
- package/dist/settings/manager.test.js +0 -73
- package/dist/tool-system/builtin/remote-trigger.d.ts +0 -6
- package/dist/tool-system/builtin/remote-trigger.js +0 -54
- package/dist/tool-system/builtin/send-message.d.ts +0 -6
- package/dist/tool-system/builtin/send-message.js +0 -47
- /package/dist/{settings/manager.test.d.ts → credentials/types.js} +0 -0
package/dist/plugins/gitOps.d.ts
CHANGED
|
@@ -21,10 +21,63 @@ export type GitResult = {
|
|
|
21
21
|
ok: false;
|
|
22
22
|
error: string;
|
|
23
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* On a fresh macOS without the Command Line Tools, `/usr/bin/git` is an `xcrun`
|
|
26
|
+
* stub that spawns fine (so `isGitAvailable()`'s findExecutable check is fooled)
|
|
27
|
+
* but exits non-zero with an xcrun error on stderr. Classify that as a
|
|
28
|
+
* missing-git condition so runGit returns GIT_NOT_FOUND and the host shows the
|
|
29
|
+
* friendly "install Git" guidance instead of leaking the raw xcrun error.
|
|
30
|
+
*/
|
|
31
|
+
export declare function isMissingDeveloperToolsStderr(stderr: string): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Force git to never prompt interactively. gitOps runs in headless contexts
|
|
34
|
+
* (the Electron main process, the agent worker) that have no TTY, so a
|
|
35
|
+
* private/auth-required clone or an unknown SSH host key would otherwise make
|
|
36
|
+
* git BLOCK on a credential/host-key prompt — the operation appears to hang
|
|
37
|
+
* until the safeSpawn timeout (or an off-screen askpass dialog). With these
|
|
38
|
+
* set, git fails fast with an auth error instead.
|
|
39
|
+
*
|
|
40
|
+
* - GIT_TERMINAL_PROMPT=0 — git's own username/password prompt becomes an error.
|
|
41
|
+
* - GIT_SSH_COMMAND BatchMode=yes — ssh never asks for a password/passphrase;
|
|
42
|
+
* accept-new auto-trusts a first-seen host key (instead of the y/n prompt)
|
|
43
|
+
* but still rejects a changed key. Not overridden if the caller already
|
|
44
|
+
* provides GIT_SSH_COMMAND (e.g. a custom identity file).
|
|
45
|
+
*/
|
|
46
|
+
export declare function nonInteractiveGitEnv(base: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
47
|
+
/**
|
|
48
|
+
* Clone a marketplace repo cheaply. These repos can bundle hundreds of plugins
|
|
49
|
+
* (thousands of files), but adding a marketplace only needs its manifest — the
|
|
50
|
+
* individual plugin trees are pulled on demand at install time
|
|
51
|
+
* ({@link gitSparseCheckoutAdd}). So we do a blobless, no-checkout clone and
|
|
52
|
+
* then sparse-check out only the manifest directories.
|
|
53
|
+
*
|
|
54
|
+
* `sparsePaths` defaults to the two manifest locations we support
|
|
55
|
+
* (.claude-plugin and .agents/plugins). On any failure of the sparse setup we
|
|
56
|
+
* fall back to checking out the full tree, so correctness never depends on
|
|
57
|
+
* sparse support being present.
|
|
58
|
+
*
|
|
59
|
+
* Pass `full: true` to skip sparse entirely and check out the whole tree. This
|
|
60
|
+
* is required when the caller reads arbitrary plugin content from the clone
|
|
61
|
+
* (installing a plugin or a plugin subdir), as opposed to a marketplace where
|
|
62
|
+
* only the manifest dirs are needed up front.
|
|
63
|
+
*/
|
|
24
64
|
export declare function gitClone(url: string, destDir: string, options?: {
|
|
25
65
|
ref?: string;
|
|
66
|
+
sparsePaths?: string[];
|
|
67
|
+
full?: boolean;
|
|
26
68
|
}): Promise<GitResult>;
|
|
69
|
+
/**
|
|
70
|
+
* Expand a sparse-checkout to include an additional path (a plugin subdir),
|
|
71
|
+
* materializing its blobs. Best-effort: if the repo isn't sparse this errors
|
|
72
|
+
* harmlessly and the caller proceeds (the files are already present).
|
|
73
|
+
*/
|
|
74
|
+
export declare function gitSparseCheckoutAdd(repoDir: string, relPath: string): Promise<GitResult>;
|
|
27
75
|
export declare function gitRevParseHead(repoDir: string): Promise<GitResult>;
|
|
76
|
+
/**
|
|
77
|
+
* Resolve a ref (default HEAD) on a remote git URL WITHOUT cloning — one
|
|
78
|
+
* cheap network round-trip. Returns the 40-char SHA on success.
|
|
79
|
+
*/
|
|
80
|
+
export declare function gitLsRemote(url: string, ref?: string): Promise<GitResult>;
|
|
28
81
|
export declare function gitFetchAndReset(repoDir: string, ref?: string): Promise<GitResult>;
|
|
29
82
|
/**
|
|
30
83
|
* Github source helper: convert "owner/repo" to an https clone URL.
|
package/dist/plugins/gitOps.js
CHANGED
|
@@ -15,10 +15,53 @@
|
|
|
15
15
|
* classification. See docs/architecture/17 for the trust framing.
|
|
16
16
|
*/
|
|
17
17
|
import { safeSpawn } from "../runtime/safe-spawn.js";
|
|
18
|
+
import { resolveGit, isGitAvailable } from "../utils/exec.js";
|
|
19
|
+
/**
|
|
20
|
+
* On a fresh macOS without the Command Line Tools, `/usr/bin/git` is an `xcrun`
|
|
21
|
+
* stub that spawns fine (so `isGitAvailable()`'s findExecutable check is fooled)
|
|
22
|
+
* but exits non-zero with an xcrun error on stderr. Classify that as a
|
|
23
|
+
* missing-git condition so runGit returns GIT_NOT_FOUND and the host shows the
|
|
24
|
+
* friendly "install Git" guidance instead of leaking the raw xcrun error.
|
|
25
|
+
*/
|
|
26
|
+
export function isMissingDeveloperToolsStderr(stderr) {
|
|
27
|
+
return /xcrun: error|not a developer tool|no developer tools/i.test(stderr);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Force git to never prompt interactively. gitOps runs in headless contexts
|
|
31
|
+
* (the Electron main process, the agent worker) that have no TTY, so a
|
|
32
|
+
* private/auth-required clone or an unknown SSH host key would otherwise make
|
|
33
|
+
* git BLOCK on a credential/host-key prompt — the operation appears to hang
|
|
34
|
+
* until the safeSpawn timeout (or an off-screen askpass dialog). With these
|
|
35
|
+
* set, git fails fast with an auth error instead.
|
|
36
|
+
*
|
|
37
|
+
* - GIT_TERMINAL_PROMPT=0 — git's own username/password prompt becomes an error.
|
|
38
|
+
* - GIT_SSH_COMMAND BatchMode=yes — ssh never asks for a password/passphrase;
|
|
39
|
+
* accept-new auto-trusts a first-seen host key (instead of the y/n prompt)
|
|
40
|
+
* but still rejects a changed key. Not overridden if the caller already
|
|
41
|
+
* provides GIT_SSH_COMMAND (e.g. a custom identity file).
|
|
42
|
+
*/
|
|
43
|
+
export function nonInteractiveGitEnv(base) {
|
|
44
|
+
return {
|
|
45
|
+
...base,
|
|
46
|
+
GIT_TERMINAL_PROMPT: "0",
|
|
47
|
+
GIT_SSH_COMMAND: base.GIT_SSH_COMMAND ?? "ssh -oBatchMode=yes -oStrictHostKeyChecking=accept-new",
|
|
48
|
+
};
|
|
49
|
+
}
|
|
18
50
|
async function runGit(args, cwd, timeoutMs = 60_000) {
|
|
19
|
-
|
|
51
|
+
// Up-front check: if git isn't installed/reachable at all, return a clear,
|
|
52
|
+
// actionable error instead of a raw "spawn git ENOENT". The desktop host
|
|
53
|
+
// turns GIT_NOT_FOUND into a friendly "install Git" prompt.
|
|
54
|
+
if (!isGitAvailable()) {
|
|
55
|
+
return {
|
|
56
|
+
ok: false,
|
|
57
|
+
error: "GIT_NOT_FOUND: git was not found. Install Git (https://git-scm.com/downloads) " +
|
|
58
|
+
"and restart, or set the `git.path` setting to your git binary.",
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
// Resolve git: user `git.path` override, else PATH×PATHEXT (.cmd/.exe on Win).
|
|
62
|
+
const r = await safeSpawn(resolveGit(), args, {
|
|
20
63
|
cwd: cwd ?? process.cwd(),
|
|
21
|
-
env: process.env,
|
|
64
|
+
env: nonInteractiveGitEnv(process.env),
|
|
22
65
|
timeoutMs,
|
|
23
66
|
});
|
|
24
67
|
if (r.spawnFailed) {
|
|
@@ -30,25 +73,107 @@ async function runGit(args, cwd, timeoutMs = 60_000) {
|
|
|
30
73
|
if (r.exitCode === 0) {
|
|
31
74
|
return { ok: true, stdout: r.stdout.trim() };
|
|
32
75
|
}
|
|
76
|
+
// mac CLT-missing stub: git spawned but exited non-zero with an xcrun error —
|
|
77
|
+
// treat as not-installed so the host shows install guidance (not a raw error).
|
|
78
|
+
if (isMissingDeveloperToolsStderr(r.stderr)) {
|
|
79
|
+
return {
|
|
80
|
+
ok: false,
|
|
81
|
+
error: "GIT_NOT_FOUND: git was not found (the macOS Command Line Tools are not installed). " +
|
|
82
|
+
"Run `xcode-select --install`, or install Git from https://git-scm.com/downloads, " +
|
|
83
|
+
"then restart — or set the `git.path` setting to your git binary.",
|
|
84
|
+
};
|
|
85
|
+
}
|
|
33
86
|
return {
|
|
34
87
|
ok: false,
|
|
35
88
|
error: `git ${args.join(" ")} exited ${r.exitCode}: ${r.stderr.trim() || "unknown error"}`,
|
|
36
89
|
};
|
|
37
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Clone a marketplace repo cheaply. These repos can bundle hundreds of plugins
|
|
93
|
+
* (thousands of files), but adding a marketplace only needs its manifest — the
|
|
94
|
+
* individual plugin trees are pulled on demand at install time
|
|
95
|
+
* ({@link gitSparseCheckoutAdd}). So we do a blobless, no-checkout clone and
|
|
96
|
+
* then sparse-check out only the manifest directories.
|
|
97
|
+
*
|
|
98
|
+
* `sparsePaths` defaults to the two manifest locations we support
|
|
99
|
+
* (.claude-plugin and .agents/plugins). On any failure of the sparse setup we
|
|
100
|
+
* fall back to checking out the full tree, so correctness never depends on
|
|
101
|
+
* sparse support being present.
|
|
102
|
+
*
|
|
103
|
+
* Pass `full: true` to skip sparse entirely and check out the whole tree. This
|
|
104
|
+
* is required when the caller reads arbitrary plugin content from the clone
|
|
105
|
+
* (installing a plugin or a plugin subdir), as opposed to a marketplace where
|
|
106
|
+
* only the manifest dirs are needed up front.
|
|
107
|
+
*/
|
|
38
108
|
export async function gitClone(url, destDir, options) {
|
|
39
|
-
const
|
|
109
|
+
const sparsePaths = options?.sparsePaths ?? [".claude-plugin", ".agents/plugins"];
|
|
110
|
+
const args = ["clone", "--depth", "1", "--filter=blob:none", "--no-checkout"];
|
|
40
111
|
if (options?.ref)
|
|
41
112
|
args.push("--branch", options.ref);
|
|
42
113
|
args.push("--", url, destDir);
|
|
43
|
-
|
|
114
|
+
const cloned = await runGit(args);
|
|
115
|
+
if (!cloned.ok)
|
|
116
|
+
return cloned;
|
|
117
|
+
// Full-tree clone: skip sparse setup and check out everything. Used by plugin
|
|
118
|
+
// content clones, which read files anywhere in the repo.
|
|
119
|
+
if (options?.full) {
|
|
120
|
+
const checkout = await runGit(["checkout"], destDir);
|
|
121
|
+
if (!checkout.ok)
|
|
122
|
+
return checkout;
|
|
123
|
+
return cloned;
|
|
124
|
+
}
|
|
125
|
+
// Restrict the working tree to the manifest dirs, then check out. Use
|
|
126
|
+
// non-cone mode so nested paths like ".agents/plugins" match exactly.
|
|
127
|
+
// `--` before the manifest-derived paths: a malicious manifest path shaped
|
|
128
|
+
// like `--stdin`/`--cone` would otherwise be parsed as a sparse-checkout flag
|
|
129
|
+
// (arg-injection). No RCE flag here as in ls-remote, but match the discipline.
|
|
130
|
+
const init = await runGit(["sparse-checkout", "set", "--no-cone", "--", ...sparsePaths], destDir);
|
|
131
|
+
if (!init.ok) {
|
|
132
|
+
// Sparse unsupported/failed — fall back to a normal full checkout so the
|
|
133
|
+
// manifest is still present.
|
|
134
|
+
return runGit(["checkout"], destDir);
|
|
135
|
+
}
|
|
136
|
+
const checkout = await runGit(["checkout"], destDir);
|
|
137
|
+
if (!checkout.ok)
|
|
138
|
+
return checkout;
|
|
139
|
+
return cloned;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Expand a sparse-checkout to include an additional path (a plugin subdir),
|
|
143
|
+
* materializing its blobs. Best-effort: if the repo isn't sparse this errors
|
|
144
|
+
* harmlessly and the caller proceeds (the files are already present).
|
|
145
|
+
*/
|
|
146
|
+
export async function gitSparseCheckoutAdd(repoDir, relPath) {
|
|
147
|
+
return runGit(["sparse-checkout", "add", "--", relPath], repoDir);
|
|
44
148
|
}
|
|
45
149
|
export async function gitRevParseHead(repoDir) {
|
|
46
150
|
return runGit(["rev-parse", "HEAD"], repoDir);
|
|
47
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* Resolve a ref (default HEAD) on a remote git URL WITHOUT cloning — one
|
|
154
|
+
* cheap network round-trip. Returns the 40-char SHA on success.
|
|
155
|
+
*/
|
|
156
|
+
export async function gitLsRemote(url, ref) {
|
|
157
|
+
// `git ls-remote <url> <ref>` prints "<sha>\t<refname>"; take the first sha.
|
|
158
|
+
// SECURITY: the `--` end-of-options separator is REQUIRED before a
|
|
159
|
+
// user-controlled `url`. Without it a marketplace/plugin URL shaped like
|
|
160
|
+
// `--upload-pack=<cmd>` is parsed as a git flag and git EXECUTES <cmd> (RCE).
|
|
161
|
+
// gitClone already does this (`-- url destDir`); ls-remote must match.
|
|
162
|
+
const r = await runGit(["ls-remote", "--", url, ref ?? "HEAD"]);
|
|
163
|
+
if (!r.ok)
|
|
164
|
+
return r;
|
|
165
|
+
const sha = r.stdout.split(/\s+/)[0] ?? "";
|
|
166
|
+
if (!/^[0-9a-f]{7,40}$/i.test(sha)) {
|
|
167
|
+
return { ok: false, error: `ls-remote: no sha for ${ref ?? "HEAD"} in: ${r.stdout.slice(0, 120)}` };
|
|
168
|
+
}
|
|
169
|
+
return { ok: true, stdout: sha };
|
|
170
|
+
}
|
|
48
171
|
export async function gitFetchAndReset(repoDir, ref) {
|
|
49
172
|
const fetchArgs = ["fetch", "--depth", "1", "origin"];
|
|
173
|
+
// `--` before a (possibly user/manifest-derived) ref so a flag-shaped ref
|
|
174
|
+
// can't be parsed as a git fetch option. Consistent with clone/ls-remote.
|
|
50
175
|
if (ref)
|
|
51
|
-
fetchArgs.push(ref);
|
|
176
|
+
fetchArgs.push("--", ref);
|
|
52
177
|
const fetch = await runGit(fetchArgs, repoDir);
|
|
53
178
|
if (!fetch.ok)
|
|
54
179
|
return fetch;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface UpdateCheck {
|
|
2
|
+
name: string;
|
|
3
|
+
updateAvailable: boolean;
|
|
4
|
+
currentCommit?: string;
|
|
5
|
+
latestCommit?: string;
|
|
6
|
+
reason?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Check whether a remote (git-sourced) plugin has a newer commit upstream,
|
|
10
|
+
* WITHOUT cloning. Compares the recorded install commit (meta.commit) against
|
|
11
|
+
* `git ls-remote`. Local-source plugins, older installs without a recorded
|
|
12
|
+
* commit, and ls-remote failures all resolve to `updateAvailable: false` with
|
|
13
|
+
* an explanatory `reason` rather than throwing — the only hard error is an
|
|
14
|
+
* unknown plugin name.
|
|
15
|
+
*/
|
|
16
|
+
export declare function checkPluginUpdate(name: string): Promise<UpdateCheck>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { gitLsRemote } from "../gitOps.js";
|
|
3
|
+
import { pluginMetaPath } from "./paths.js";
|
|
4
|
+
import { parseSource } from "./parseSource.js";
|
|
5
|
+
import { CSMeta, PluginInstallError } from "./types.js";
|
|
6
|
+
/**
|
|
7
|
+
* Check whether a remote (git-sourced) plugin has a newer commit upstream,
|
|
8
|
+
* WITHOUT cloning. Compares the recorded install commit (meta.commit) against
|
|
9
|
+
* `git ls-remote`. Local-source plugins, older installs without a recorded
|
|
10
|
+
* commit, and ls-remote failures all resolve to `updateAvailable: false` with
|
|
11
|
+
* an explanatory `reason` rather than throwing — the only hard error is an
|
|
12
|
+
* unknown plugin name.
|
|
13
|
+
*/
|
|
14
|
+
export async function checkPluginUpdate(name) {
|
|
15
|
+
const metaPath = pluginMetaPath(name);
|
|
16
|
+
if (!existsSync(metaPath))
|
|
17
|
+
throw new PluginInstallError(`no plugin named '${name}'`);
|
|
18
|
+
const meta = CSMeta.parse(JSON.parse(readFileSync(metaPath, "utf-8")));
|
|
19
|
+
const parsed = parseSource(meta.source);
|
|
20
|
+
if (parsed.kind !== "remote") {
|
|
21
|
+
return { name, updateAvailable: false, reason: "not a remote source" };
|
|
22
|
+
}
|
|
23
|
+
if (!meta.commit) {
|
|
24
|
+
return { name, updateAvailable: false, reason: "no recorded commit to compare" };
|
|
25
|
+
}
|
|
26
|
+
const latest = await gitLsRemote(parsed.url, parsed.ref);
|
|
27
|
+
if (!latest.ok) {
|
|
28
|
+
return { name, updateAvailable: false, currentCommit: meta.commit, reason: latest.error };
|
|
29
|
+
}
|
|
30
|
+
const updateAvailable = latest.stdout.toLowerCase() !== meta.commit.toLowerCase();
|
|
31
|
+
return { name, updateAvailable, currentCommit: meta.commit, latestCommit: latest.stdout };
|
|
32
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert one Codex agent TOML into a CC agent Markdown string.
|
|
3
|
+
* Real CC fields: name, description, model, body(=developer_instructions).
|
|
4
|
+
* Every other field is preserved with a `codex_` prefix (v1 inert; see spec §7.1).
|
|
5
|
+
* `mcp_servers` values are rewritten to `<plugin>:<server>` to match the MCP merge key.
|
|
6
|
+
*/
|
|
7
|
+
export declare function convertCodexAgentToml(toml: string, sourceName: string, pluginName: string): string;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { parse as parseToml } from "smol-toml";
|
|
2
|
+
import { stringify as stringifyYaml } from "yaml";
|
|
3
|
+
import { serializeAgentDefinition } from "../../../agent/agent-definition.js";
|
|
4
|
+
import { PluginInstallError } from "../types.js";
|
|
5
|
+
const MAPPED = new Set(["name", "description", "model", "developer_instructions"]);
|
|
6
|
+
/**
|
|
7
|
+
* Convert one Codex agent TOML into a CC agent Markdown string.
|
|
8
|
+
* Real CC fields: name, description, model, body(=developer_instructions).
|
|
9
|
+
* Every other field is preserved with a `codex_` prefix (v1 inert; see spec §7.1).
|
|
10
|
+
* `mcp_servers` values are rewritten to `<plugin>:<server>` to match the MCP merge key.
|
|
11
|
+
*/
|
|
12
|
+
export function convertCodexAgentToml(toml, sourceName, pluginName) {
|
|
13
|
+
let raw;
|
|
14
|
+
try {
|
|
15
|
+
raw = parseToml(toml);
|
|
16
|
+
}
|
|
17
|
+
catch (err) {
|
|
18
|
+
throw new PluginInstallError(`${sourceName}: invalid TOML — ${err.message}`);
|
|
19
|
+
}
|
|
20
|
+
if (typeof raw.name !== "string" || !raw.name.trim()) {
|
|
21
|
+
throw new PluginInstallError(`${sourceName}: missing required 'name'`);
|
|
22
|
+
}
|
|
23
|
+
if (typeof raw.description !== "string" || !raw.description.trim()) {
|
|
24
|
+
throw new PluginInstallError(`${sourceName}: missing required 'description'`);
|
|
25
|
+
}
|
|
26
|
+
const body = typeof raw.developer_instructions === "string" ? raw.developer_instructions.trim() : "";
|
|
27
|
+
const base = serializeAgentDefinition({
|
|
28
|
+
name: raw.name.trim(),
|
|
29
|
+
description: raw.description.trim(),
|
|
30
|
+
systemPrompt: body,
|
|
31
|
+
...(typeof raw.model === "string" && raw.model.trim() ? { model: raw.model.trim() } : {}),
|
|
32
|
+
});
|
|
33
|
+
// Collect codex_-prefixed extras.
|
|
34
|
+
const extras = {};
|
|
35
|
+
for (const [key, value] of Object.entries(raw)) {
|
|
36
|
+
if (MAPPED.has(key))
|
|
37
|
+
continue;
|
|
38
|
+
const outKey = `codex_${key}`;
|
|
39
|
+
if (key === "mcp_servers" && Array.isArray(value)) {
|
|
40
|
+
extras[outKey] = value.map((s) => (typeof s === "string" ? `${pluginName}:${s}` : s));
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
extras[outKey] = value;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (Object.keys(extras).length === 0)
|
|
47
|
+
return base;
|
|
48
|
+
// Splice the extra YAML lines into the existing frontmatter block.
|
|
49
|
+
const extraYaml = stringifyYaml(extras).trimEnd();
|
|
50
|
+
const match = /^---\n([\s\S]*?)\n---\n([\s\S]*)$/.exec(base);
|
|
51
|
+
if (!match)
|
|
52
|
+
throw new PluginInstallError(`${sourceName}: internal — serializer produced no frontmatter`);
|
|
53
|
+
const [, fm, rest] = match;
|
|
54
|
+
return `---\n${fm}\n${extraYaml}\n---\n${rest}`;
|
|
55
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map a Codex plugin's slash commands into CC's `commands/` layout.
|
|
3
|
+
*
|
|
4
|
+
* Codex `prompts/*.md` and CC `commands/*.md` are isomorphic: each is a
|
|
5
|
+
* markdown file (optional `description`/`argument-hint` frontmatter) whose
|
|
6
|
+
* basename becomes the command name, and codeshell's `pluginCommandsLoader`
|
|
7
|
+
* already scans `commands/*.md`. So the conversion is a flat copy of every
|
|
8
|
+
* `.md` from `prompts/` (and any explicit `commands/`) into `dest/commands/`.
|
|
9
|
+
*
|
|
10
|
+
* Placeholder syntax differs (Codex `$1`/`$FILE` vs CC `$ARGUMENTS`) but the
|
|
11
|
+
* body is copied verbatim — v1 inert, the same stance taken for `codex_`
|
|
12
|
+
* agent fields (see convertAgents.ts). Non-`.md` files are ignored, matching
|
|
13
|
+
* Codex's own behaviour. On a filename collision an explicit `commands/`
|
|
14
|
+
* entry wins over `prompts/` (the more specific source).
|
|
15
|
+
*
|
|
16
|
+
* Async fs throughout: this runs in the Electron main process during install;
|
|
17
|
+
* sync copies block the event loop and freeze the UI (see convertSkills.ts).
|
|
18
|
+
*/
|
|
19
|
+
export declare function copyCodexCommands(sourceDir: string, destDir: string): Promise<void>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { readdir, mkdir, copyFile } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
/**
|
|
5
|
+
* Map a Codex plugin's slash commands into CC's `commands/` layout.
|
|
6
|
+
*
|
|
7
|
+
* Codex `prompts/*.md` and CC `commands/*.md` are isomorphic: each is a
|
|
8
|
+
* markdown file (optional `description`/`argument-hint` frontmatter) whose
|
|
9
|
+
* basename becomes the command name, and codeshell's `pluginCommandsLoader`
|
|
10
|
+
* already scans `commands/*.md`. So the conversion is a flat copy of every
|
|
11
|
+
* `.md` from `prompts/` (and any explicit `commands/`) into `dest/commands/`.
|
|
12
|
+
*
|
|
13
|
+
* Placeholder syntax differs (Codex `$1`/`$FILE` vs CC `$ARGUMENTS`) but the
|
|
14
|
+
* body is copied verbatim — v1 inert, the same stance taken for `codex_`
|
|
15
|
+
* agent fields (see convertAgents.ts). Non-`.md` files are ignored, matching
|
|
16
|
+
* Codex's own behaviour. On a filename collision an explicit `commands/`
|
|
17
|
+
* entry wins over `prompts/` (the more specific source).
|
|
18
|
+
*
|
|
19
|
+
* Async fs throughout: this runs in the Electron main process during install;
|
|
20
|
+
* sync copies block the event loop and freeze the UI (see convertSkills.ts).
|
|
21
|
+
*/
|
|
22
|
+
export async function copyCodexCommands(sourceDir, destDir) {
|
|
23
|
+
// prompts/ first, then commands/ — later writes overwrite earlier, so an
|
|
24
|
+
// explicit commands/ entry wins the collision.
|
|
25
|
+
const written = await copyMdFiles(join(sourceDir, "prompts"), join(destDir, "commands"));
|
|
26
|
+
await copyMdFiles(join(sourceDir, "commands"), join(destDir, "commands"), written);
|
|
27
|
+
}
|
|
28
|
+
/** Flat-copy *.md from srcDir into destDir; returns the set of basenames written. */
|
|
29
|
+
async function copyMdFiles(srcDir, destDir, written = new Set()) {
|
|
30
|
+
if (!existsSync(srcDir))
|
|
31
|
+
return written;
|
|
32
|
+
let ensuredDest = false;
|
|
33
|
+
for (const dirent of await readdir(srcDir, { withFileTypes: true })) {
|
|
34
|
+
if (!dirent.isFile() && !dirent.isSymbolicLink())
|
|
35
|
+
continue;
|
|
36
|
+
if (!dirent.name.endsWith(".md"))
|
|
37
|
+
continue;
|
|
38
|
+
if (!ensuredDest) {
|
|
39
|
+
await mkdir(destDir, { recursive: true });
|
|
40
|
+
ensuredDest = true;
|
|
41
|
+
}
|
|
42
|
+
await copyFile(join(srcDir, dirent.name), join(destDir, dirent.name));
|
|
43
|
+
written.add(dirent.name);
|
|
44
|
+
}
|
|
45
|
+
return written;
|
|
46
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare function normalizeCodexMcpFields(cfg: Record<string, unknown>): Record<string, unknown>;
|
|
2
|
+
/**
|
|
3
|
+
* Resolve a Codex manifest's mcpServers declaration into a plain server map.
|
|
4
|
+
* Each server's env-secret fields are normalized from Codex's snake_case to
|
|
5
|
+
* our runtime camelCase (see normalizeCodexMcpFields).
|
|
6
|
+
* - object → normalized inline map
|
|
7
|
+
* - string → read that file relative to sourceDir; accept either a bare map
|
|
8
|
+
* or a `{ mcpServers: {...} }` wrapper, then normalize.
|
|
9
|
+
* - undefined → {}
|
|
10
|
+
*/
|
|
11
|
+
export declare function resolveCodexMcpServers(sourceDir: string, decl: string | Record<string, unknown> | undefined): Record<string, unknown>;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { isAbsolute, relative, resolve, sep } from "node:path";
|
|
3
|
+
import { PluginInstallError } from "../types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Codex `.mcp.json` writes env-secret fields in snake_case
|
|
6
|
+
* (`bearer_token_env_var`, `env_http_headers`, `env_vars`), but our runtime
|
|
7
|
+
* MCP manager reads camelCase (`bearerTokenEnvVar`, `envHeaders`, `envVars` —
|
|
8
|
+
* see buildStdioEnv / buildHttpHeaders in tool-system/mcp-manager.ts). Nothing
|
|
9
|
+
* between install and connect runs these through a zod schema (install spreads
|
|
10
|
+
* the object verbatim; loadPluginMcp casts raw JSON), so without this re-key an
|
|
11
|
+
* imported Codex plugin's secret references would silently never apply and the
|
|
12
|
+
* server would connect without its auth header / env. Re-key one server config
|
|
13
|
+
* object. An already-present camelCase key wins over its snake_case twin so we
|
|
14
|
+
* never clobber the canonical form. Non-object input passes through unchanged.
|
|
15
|
+
*/
|
|
16
|
+
const CODEX_FIELD_MAP = {
|
|
17
|
+
bearer_token_env_var: "bearerTokenEnvVar",
|
|
18
|
+
env_http_headers: "envHeaders",
|
|
19
|
+
env_vars: "envVars",
|
|
20
|
+
};
|
|
21
|
+
export function normalizeCodexMcpFields(cfg) {
|
|
22
|
+
if (!cfg || typeof cfg !== "object" || Array.isArray(cfg))
|
|
23
|
+
return cfg;
|
|
24
|
+
const out = {};
|
|
25
|
+
for (const [key, value] of Object.entries(cfg)) {
|
|
26
|
+
const mapped = CODEX_FIELD_MAP[key];
|
|
27
|
+
// Skip the snake_case form if its camelCase twin is already present.
|
|
28
|
+
if (mapped && mapped in cfg)
|
|
29
|
+
continue;
|
|
30
|
+
out[mapped ?? key] = value;
|
|
31
|
+
}
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
34
|
+
/** Apply normalizeCodexMcpFields to every server in a name → config map. */
|
|
35
|
+
function normalizeServerMap(servers) {
|
|
36
|
+
const out = {};
|
|
37
|
+
for (const [name, cfg] of Object.entries(servers)) {
|
|
38
|
+
out[name] = normalizeCodexMcpFields(cfg);
|
|
39
|
+
}
|
|
40
|
+
return out;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Resolve a Codex manifest's mcpServers declaration into a plain server map.
|
|
44
|
+
* Each server's env-secret fields are normalized from Codex's snake_case to
|
|
45
|
+
* our runtime camelCase (see normalizeCodexMcpFields).
|
|
46
|
+
* - object → normalized inline map
|
|
47
|
+
* - string → read that file relative to sourceDir; accept either a bare map
|
|
48
|
+
* or a `{ mcpServers: {...} }` wrapper, then normalize.
|
|
49
|
+
* - undefined → {}
|
|
50
|
+
*/
|
|
51
|
+
export function resolveCodexMcpServers(sourceDir, decl) {
|
|
52
|
+
if (decl === undefined)
|
|
53
|
+
return {};
|
|
54
|
+
if (typeof decl === "object")
|
|
55
|
+
return normalizeServerMap(decl);
|
|
56
|
+
// `decl` is an untrusted, unvalidated manifest field from a (possibly
|
|
57
|
+
// remote-cloned) plugin. Resolve it and assert it stays inside sourceDir so
|
|
58
|
+
// a value like "../../../../etc/secret.json" can't escape the plugin dir and
|
|
59
|
+
// read arbitrary files into the install's mcp-servers.json.
|
|
60
|
+
const base = resolve(sourceDir);
|
|
61
|
+
const path = resolve(base, decl);
|
|
62
|
+
const rel = relative(base, path);
|
|
63
|
+
if (rel === ".." || rel.startsWith(`..${sep}`) || isAbsolute(rel)) {
|
|
64
|
+
throw new PluginInstallError(`mcpServers ref escapes plugin dir: ${decl}`);
|
|
65
|
+
}
|
|
66
|
+
if (!existsSync(path)) {
|
|
67
|
+
throw new PluginInstallError(`mcpServers ref not found: ${decl}`);
|
|
68
|
+
}
|
|
69
|
+
let parsed;
|
|
70
|
+
try {
|
|
71
|
+
parsed = JSON.parse(readFileSync(path, "utf-8"));
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
throw new PluginInstallError(`invalid mcp json ${decl}: ${err instanceof Error ? err.message : String(err)}`);
|
|
75
|
+
}
|
|
76
|
+
// Only objects yield server maps. An array/number/string that happens to
|
|
77
|
+
// parse is not a valid mcp config — return an empty map rather than casting
|
|
78
|
+
// a non-object to Record.
|
|
79
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
|
|
80
|
+
return {};
|
|
81
|
+
if ("mcpServers" in parsed) {
|
|
82
|
+
return normalizeServerMap(parsed.mcpServers ?? {});
|
|
83
|
+
}
|
|
84
|
+
return normalizeServerMap(parsed);
|
|
85
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copy <sourceDir>/skills into <destDir>/skills verbatim (Codex & CC SKILL.md
|
|
3
|
+
* are isomorphic). Validates each SKILL.md has a frontmatter block first — a
|
|
4
|
+
* malformed skill fails the whole install (spec §10).
|
|
5
|
+
*
|
|
6
|
+
* Async fs throughout: this runs inside the Electron main process during
|
|
7
|
+
* install; a synchronous recursive copy (cpSync) blocks the event loop and
|
|
8
|
+
* freezes the UI. The sibling `cc` branch already awaits cp for this reason
|
|
9
|
+
* (see install.ts) — this mirrors the 178abc8 sync→async migration that
|
|
10
|
+
* originally missed this function.
|
|
11
|
+
*/
|
|
12
|
+
export declare function copyCodexSkills(sourceDir: string, destDir: string): Promise<void>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { readdir, readFile, cp } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { PluginInstallError } from "../types.js";
|
|
5
|
+
const FRONTMATTER = /^---\s*\n[\s\S]*?\n---/;
|
|
6
|
+
/**
|
|
7
|
+
* Copy <sourceDir>/skills into <destDir>/skills verbatim (Codex & CC SKILL.md
|
|
8
|
+
* are isomorphic). Validates each SKILL.md has a frontmatter block first — a
|
|
9
|
+
* malformed skill fails the whole install (spec §10).
|
|
10
|
+
*
|
|
11
|
+
* Async fs throughout: this runs inside the Electron main process during
|
|
12
|
+
* install; a synchronous recursive copy (cpSync) blocks the event loop and
|
|
13
|
+
* freezes the UI. The sibling `cc` branch already awaits cp for this reason
|
|
14
|
+
* (see install.ts) — this mirrors the 178abc8 sync→async migration that
|
|
15
|
+
* originally missed this function.
|
|
16
|
+
*/
|
|
17
|
+
export async function copyCodexSkills(sourceDir, destDir) {
|
|
18
|
+
const skillsSrc = join(sourceDir, "skills");
|
|
19
|
+
if (!existsSync(skillsSrc))
|
|
20
|
+
return;
|
|
21
|
+
for (const dirent of await readdir(skillsSrc, { withFileTypes: true })) {
|
|
22
|
+
if (!dirent.isDirectory())
|
|
23
|
+
continue;
|
|
24
|
+
const skillFile = join(skillsSrc, dirent.name, "SKILL.md");
|
|
25
|
+
if (!existsSync(skillFile))
|
|
26
|
+
continue;
|
|
27
|
+
const raw = (await readFile(skillFile, "utf-8")).trim();
|
|
28
|
+
if (!FRONTMATTER.test(raw)) {
|
|
29
|
+
throw new PluginInstallError(`skills/${dirent.name}/SKILL.md: missing frontmatter`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
await cp(skillsSrc, join(destDir, "skills"), { recursive: true });
|
|
33
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
/** Binary detection: a Codex plugin has `.codex-plugin/plugin.json`; everything else is CC. */
|
|
4
|
+
export function detectPluginFormat(sourceDir) {
|
|
5
|
+
return existsSync(join(sourceDir, ".codex-plugin", "plugin.json")) ? "codex" : "cc";
|
|
6
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Install a local plugin directory into ~/.code-shell/plugins/<name>/.
|
|
3
|
+
* Builds into a temp sibling dir, then renames into place — a conversion
|
|
4
|
+
* failure leaves nothing behind. `installedAt` is passed in (caller stamps the
|
|
5
|
+
* timestamp) to keep this function pure of the unavailable Date.now().
|
|
6
|
+
*/
|
|
7
|
+
export declare function installPluginFromPath(sourceDir: string, name: string, installedAt: string): Promise<string>;
|