@cjhyy/code-shell-core 0.5.0-rc.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/LICENSE +21 -0
- package/README.md +162 -0
- package/dist/agent/coordinator.d.ts +49 -0
- package/dist/agent/coordinator.js +77 -0
- package/dist/arena/arena.d.ts +43 -0
- package/dist/arena/arena.js +334 -0
- package/dist/arena/context/context-tools.d.ts +16 -0
- package/dist/arena/context/context-tools.js +231 -0
- package/dist/arena/detect-mode.d.ts +20 -0
- package/dist/arena/detect-mode.js +78 -0
- package/dist/arena/digest-builder.d.ts +25 -0
- package/dist/arena/digest-builder.js +120 -0
- package/dist/arena/index.d.ts +29 -0
- package/dist/arena/index.js +29 -0
- package/dist/arena/iterate/convergence.d.ts +25 -0
- package/dist/arena/iterate/convergence.js +103 -0
- package/dist/arena/iterate/formats/index.d.ts +22 -0
- package/dist/arena/iterate/formats/index.js +283 -0
- package/dist/arena/iterate/index.d.ts +11 -0
- package/dist/arena/iterate/index.js +9 -0
- package/dist/arena/iterate/iterative-arena.d.ts +23 -0
- package/dist/arena/iterate/iterative-arena.js +237 -0
- package/dist/arena/iterate/parse.d.ts +42 -0
- package/dist/arena/iterate/parse.js +123 -0
- package/dist/arena/iterate/phases/argue.d.ts +22 -0
- package/dist/arena/iterate/phases/argue.js +159 -0
- package/dist/arena/iterate/phases/revise.d.ts +16 -0
- package/dist/arena/iterate/phases/revise.js +62 -0
- package/dist/arena/iterate/phases/tournament.d.ts +34 -0
- package/dist/arena/iterate/phases/tournament.js +113 -0
- package/dist/arena/iterate/tools/web-tools.d.ts +13 -0
- package/dist/arena/iterate/tools/web-tools.js +54 -0
- package/dist/arena/iterate/types.d.ts +152 -0
- package/dist/arena/iterate/types.js +8 -0
- package/dist/arena/ledger.d.ts +47 -0
- package/dist/arena/ledger.js +151 -0
- package/dist/arena/lenses/architecture.d.ts +5 -0
- package/dist/arena/lenses/architecture.js +22 -0
- package/dist/arena/lenses/engineering.d.ts +5 -0
- package/dist/arena/lenses/engineering.js +22 -0
- package/dist/arena/lenses/general.d.ts +5 -0
- package/dist/arena/lenses/general.js +20 -0
- package/dist/arena/lenses/index.d.ts +16 -0
- package/dist/arena/lenses/index.js +47 -0
- package/dist/arena/lenses/product.d.ts +5 -0
- package/dist/arena/lenses/product.js +22 -0
- package/dist/arena/model-presets.d.ts +23 -0
- package/dist/arena/model-presets.js +44 -0
- package/dist/arena/phases/adjudication.d.ts +24 -0
- package/dist/arena/phases/adjudication.js +144 -0
- package/dist/arena/phases/build-consensus.d.ts +29 -0
- package/dist/arena/phases/build-consensus.js +86 -0
- package/dist/arena/phases/claim-registry.d.ts +26 -0
- package/dist/arena/phases/claim-registry.js +60 -0
- package/dist/arena/phases/cross-review.d.ts +45 -0
- package/dist/arena/phases/cross-review.js +224 -0
- package/dist/arena/phases/debate-rounds.d.ts +27 -0
- package/dist/arena/phases/debate-rounds.js +162 -0
- package/dist/arena/phases/participant-research.d.ts +38 -0
- package/dist/arena/phases/participant-research.js +317 -0
- package/dist/arena/phases/planning-detail-expansion.d.ts +38 -0
- package/dist/arena/phases/planning-detail-expansion.js +121 -0
- package/dist/arena/planner.d.ts +27 -0
- package/dist/arena/planner.js +312 -0
- package/dist/arena/providers/docs.d.ts +6 -0
- package/dist/arena/providers/docs.js +108 -0
- package/dist/arena/providers/git.d.ts +8 -0
- package/dist/arena/providers/git.js +174 -0
- package/dist/arena/providers/index.d.ts +32 -0
- package/dist/arena/providers/index.js +132 -0
- package/dist/arena/providers/none.d.ts +7 -0
- package/dist/arena/providers/none.js +11 -0
- package/dist/arena/providers/repo.d.ts +6 -0
- package/dist/arena/providers/repo.js +255 -0
- package/dist/arena/render/session.d.ts +17 -0
- package/dist/arena/render/session.js +190 -0
- package/dist/arena/render/terminal.d.ts +34 -0
- package/dist/arena/render/terminal.js +286 -0
- package/dist/arena/strategies/discussion.d.ts +25 -0
- package/dist/arena/strategies/discussion.js +143 -0
- package/dist/arena/strategies/index.d.ts +15 -0
- package/dist/arena/strategies/index.js +28 -0
- package/dist/arena/strategies/language-wrapper.d.ts +17 -0
- package/dist/arena/strategies/language-wrapper.js +102 -0
- package/dist/arena/strategies/lens-wrapper.d.ts +16 -0
- package/dist/arena/strategies/lens-wrapper.js +236 -0
- package/dist/arena/strategies/planning.d.ts +30 -0
- package/dist/arena/strategies/planning.js +225 -0
- package/dist/arena/strategies/review.d.ts +26 -0
- package/dist/arena/strategies/review.js +168 -0
- package/dist/arena/strategies/utils.d.ts +39 -0
- package/dist/arena/strategies/utils.js +647 -0
- package/dist/arena/tools/selector.d.ts +17 -0
- package/dist/arena/tools/selector.js +61 -0
- package/dist/arena/transitions.d.ts +48 -0
- package/dist/arena/transitions.js +92 -0
- package/dist/arena/types.d.ts +508 -0
- package/dist/arena/types.js +27 -0
- package/dist/cli/agent-server-stdio.d.ts +32 -0
- package/dist/cli/agent-server-stdio.js +116 -0
- package/dist/colorizer.d.ts +23 -0
- package/dist/colorizer.js +12 -0
- package/dist/context/compaction.d.ts +116 -0
- package/dist/context/compaction.js +534 -0
- package/dist/context/manager.d.ts +145 -0
- package/dist/context/manager.js +423 -0
- package/dist/context/token-counter.d.ts +27 -0
- package/dist/context/token-counter.js +91 -0
- package/dist/context/tool-result-storage.d.ts +96 -0
- package/dist/context/tool-result-storage.js +296 -0
- package/dist/cost-tracker.d.ts +64 -0
- package/dist/cost-tracker.js +314 -0
- package/dist/cron/scheduler.d.ts +34 -0
- package/dist/cron/scheduler.js +115 -0
- package/dist/data/deepseek-models.json +46 -0
- package/dist/data/gemini-models.json +67 -0
- package/dist/data/openai-models.json +175 -0
- package/dist/data/openrouter-models.d.ts +35 -0
- package/dist/data/openrouter-models.js +36 -0
- package/dist/data/openrouter-models.json +4626 -0
- package/dist/data/openrouter-sync.d.ts +16 -0
- package/dist/data/openrouter-sync.js +53 -0
- package/dist/data/static-catalogs.d.ts +25 -0
- package/dist/data/static-catalogs.js +26 -0
- package/dist/data/zai-models.json +56 -0
- package/dist/engine/cost-store.d.ts +22 -0
- package/dist/engine/cost-store.js +15 -0
- package/dist/engine/engine.d.ts +295 -0
- package/dist/engine/engine.js +1467 -0
- package/dist/engine/model-facade.d.ts +24 -0
- package/dist/engine/model-facade.js +194 -0
- package/dist/engine/parse-task.d.ts +59 -0
- package/dist/engine/parse-task.js +135 -0
- package/dist/engine/patch-orphaned-tools.d.ts +52 -0
- package/dist/engine/patch-orphaned-tools.js +95 -0
- package/dist/engine/query.d.ts +50 -0
- package/dist/engine/query.js +107 -0
- package/dist/engine/runtime.d.ts +50 -0
- package/dist/engine/runtime.js +59 -0
- package/dist/engine/streaming-tool-queue.d.ts +34 -0
- package/dist/engine/streaming-tool-queue.js +61 -0
- package/dist/engine/token-budget.d.ts +22 -0
- package/dist/engine/token-budget.js +40 -0
- package/dist/engine/tool-summary.d.ts +13 -0
- package/dist/engine/tool-summary.js +35 -0
- package/dist/engine/turn-loop.d.ts +122 -0
- package/dist/engine/turn-loop.js +602 -0
- package/dist/engine/turn-state.d.ts +20 -0
- package/dist/engine/turn-state.js +17 -0
- package/dist/exceptions.d.ts +61 -0
- package/dist/exceptions.js +116 -0
- package/dist/git/utils.d.ts +35 -0
- package/dist/git/utils.js +98 -0
- package/dist/git/worktree.d.ts +36 -0
- package/dist/git/worktree.js +139 -0
- package/dist/hooks/events.d.ts +114 -0
- package/dist/hooks/events.js +4 -0
- package/dist/hooks/inject.d.ts +19 -0
- package/dist/hooks/inject.js +29 -0
- package/dist/hooks/registry.d.ts +15 -0
- package/dist/hooks/registry.js +84 -0
- package/dist/hooks/shell-runner.d.ts +45 -0
- package/dist/hooks/shell-runner.js +173 -0
- package/dist/index.d.ts +117 -0
- package/dist/index.js +145 -0
- package/dist/llm/api-key-sanitize.d.ts +22 -0
- package/dist/llm/api-key-sanitize.js +81 -0
- package/dist/llm/capabilities/index.d.ts +20 -0
- package/dist/llm/capabilities/index.js +39 -0
- package/dist/llm/capabilities/rules.d.ts +26 -0
- package/dist/llm/capabilities/rules.js +215 -0
- package/dist/llm/capabilities/types.d.ts +114 -0
- package/dist/llm/capabilities/types.js +24 -0
- package/dist/llm/client-base.d.ts +29 -0
- package/dist/llm/client-base.js +137 -0
- package/dist/llm/client-factory.d.ts +10 -0
- package/dist/llm/client-factory.js +29 -0
- package/dist/llm/model-cache.d.ts +21 -0
- package/dist/llm/model-cache.js +46 -0
- package/dist/llm/model-fetcher.d.ts +29 -0
- package/dist/llm/model-fetcher.js +282 -0
- package/dist/llm/model-pool.d.ts +95 -0
- package/dist/llm/model-pool.js +246 -0
- package/dist/llm/provider-catalog.d.ts +32 -0
- package/dist/llm/provider-catalog.js +50 -0
- package/dist/llm/provider-kinds.d.ts +21 -0
- package/dist/llm/provider-kinds.js +132 -0
- package/dist/llm/providers/anthropic.d.ts +19 -0
- package/dist/llm/providers/anthropic.js +267 -0
- package/dist/llm/providers/openai.d.ts +64 -0
- package/dist/llm/providers/openai.js +606 -0
- package/dist/llm/retry.d.ts +12 -0
- package/dist/llm/retry.js +17 -0
- package/dist/llm/stream-watchdog.d.ts +42 -0
- package/dist/llm/stream-watchdog.js +70 -0
- package/dist/llm/token-counter.d.ts +17 -0
- package/dist/llm/token-counter.js +36 -0
- package/dist/llm/types.d.ts +37 -0
- package/dist/llm/types.js +4 -0
- package/dist/logging/logger.d.ts +109 -0
- package/dist/logging/logger.js +390 -0
- package/dist/logging/sanitize-messages.d.ts +42 -0
- package/dist/logging/sanitize-messages.js +150 -0
- package/dist/logging/session-recorder.d.ts +90 -0
- package/dist/logging/session-recorder.js +304 -0
- package/dist/lsp/client.d.ts +41 -0
- package/dist/lsp/client.js +166 -0
- package/dist/lsp/manager.d.ts +40 -0
- package/dist/lsp/manager.js +124 -0
- package/dist/lsp/servers.d.ts +16 -0
- package/dist/lsp/servers.js +60 -0
- package/dist/migrate-models.d.ts +45 -0
- package/dist/migrate-models.js +179 -0
- package/dist/onboarding.d.ts +189 -0
- package/dist/onboarding.js +625 -0
- package/dist/plugins/gitOps.d.ts +32 -0
- package/dist/plugins/gitOps.js +62 -0
- package/dist/plugins/installedPlugins.d.ts +15 -0
- package/dist/plugins/installedPlugins.js +56 -0
- package/dist/plugins/knownMarketplaces.d.ts +10 -0
- package/dist/plugins/knownMarketplaces.js +46 -0
- package/dist/plugins/loadPluginHooks.d.ts +52 -0
- package/dist/plugins/loadPluginHooks.js +162 -0
- package/dist/plugins/marketplaceManager.d.ts +49 -0
- package/dist/plugins/marketplaceManager.js +142 -0
- package/dist/plugins/parseMarketplaceInput.d.ts +16 -0
- package/dist/plugins/parseMarketplaceInput.js +73 -0
- package/dist/plugins/pluginCommandHook.d.ts +54 -0
- package/dist/plugins/pluginCommandHook.js +180 -0
- package/dist/plugins/pluginCommandsLoader.d.ts +25 -0
- package/dist/plugins/pluginCommandsLoader.js +114 -0
- package/dist/plugins/pluginInstaller.d.ts +36 -0
- package/dist/plugins/pluginInstaller.js +228 -0
- package/dist/plugins/schemas.d.ts +9 -0
- package/dist/plugins/schemas.js +136 -0
- package/dist/plugins/types.d.ts +75 -0
- package/dist/plugins/types.js +7 -0
- package/dist/plugins/varRewrite.d.ts +42 -0
- package/dist/plugins/varRewrite.js +129 -0
- package/dist/preset/index.d.ts +60 -0
- package/dist/preset/index.js +159 -0
- package/dist/product/define.d.ts +60 -0
- package/dist/product/define.js +123 -0
- package/dist/product/index.d.ts +5 -0
- package/dist/product/index.js +4 -0
- package/dist/product/types.d.ts +111 -0
- package/dist/product/types.js +21 -0
- package/dist/prompt/composer.d.ts +49 -0
- package/dist/prompt/composer.js +168 -0
- package/dist/prompt/instruction-scanner.d.ts +54 -0
- package/dist/prompt/instruction-scanner.js +187 -0
- package/dist/prompt/section-cache.d.ts +15 -0
- package/dist/prompt/section-cache.js +31 -0
- package/dist/prompt/section-loader.d.ts +26 -0
- package/dist/prompt/section-loader.js +53 -0
- package/dist/prompt/sections/base.md +35 -0
- package/dist/prompt/sections/coding.md +31 -0
- package/dist/prompt/sections/orchestration.md +16 -0
- package/dist/prompt/sections/tone.md +9 -0
- package/dist/protocol/chat-session-manager.d.ts +33 -0
- package/dist/protocol/chat-session-manager.js +65 -0
- package/dist/protocol/chat-session.d.ts +49 -0
- package/dist/protocol/chat-session.js +86 -0
- package/dist/protocol/client.d.ts +104 -0
- package/dist/protocol/client.js +260 -0
- package/dist/protocol/factories.d.ts +93 -0
- package/dist/protocol/factories.js +64 -0
- package/dist/protocol/helpers.d.ts +42 -0
- package/dist/protocol/helpers.js +55 -0
- package/dist/protocol/index.d.ts +4 -0
- package/dist/protocol/index.js +4 -0
- package/dist/protocol/server.d.ts +80 -0
- package/dist/protocol/server.js +855 -0
- package/dist/protocol/transport.d.ts +37 -0
- package/dist/protocol/transport.js +85 -0
- package/dist/protocol/types.d.ts +221 -0
- package/dist/protocol/types.js +61 -0
- package/dist/remote/bridge.d.ts +37 -0
- package/dist/remote/bridge.js +103 -0
- package/dist/run/ArtifactTracker.d.ts +38 -0
- package/dist/run/ArtifactTracker.js +132 -0
- package/dist/run/CheckpointWriter.d.ts +53 -0
- package/dist/run/CheckpointWriter.js +135 -0
- package/dist/run/EngineRunner.d.ts +72 -0
- package/dist/run/EngineRunner.js +119 -0
- package/dist/run/Evaluator.d.ts +56 -0
- package/dist/run/Evaluator.js +62 -0
- package/dist/run/FileRunStore.d.ts +39 -0
- package/dist/run/FileRunStore.js +176 -0
- package/dist/run/Heartbeat.d.ts +54 -0
- package/dist/run/Heartbeat.js +123 -0
- package/dist/run/RunApprovalBackend.d.ts +53 -0
- package/dist/run/RunApprovalBackend.js +85 -0
- package/dist/run/RunLock.d.ts +40 -0
- package/dist/run/RunLock.js +98 -0
- package/dist/run/RunManager.d.ts +82 -0
- package/dist/run/RunManager.js +587 -0
- package/dist/run/RunQueue.d.ts +27 -0
- package/dist/run/RunQueue.js +73 -0
- package/dist/run/RunStore.d.ts +25 -0
- package/dist/run/RunStore.js +9 -0
- package/dist/run/factory.d.ts +63 -0
- package/dist/run/factory.js +51 -0
- package/dist/run/index.d.ts +17 -0
- package/dist/run/index.js +23 -0
- package/dist/run/types.d.ts +136 -0
- package/dist/run/types.js +28 -0
- package/dist/runtime/safe-spawn.d.ts +118 -0
- package/dist/runtime/safe-spawn.js +268 -0
- package/dist/services/analytics.d.ts +29 -0
- package/dist/services/analytics.js +84 -0
- package/dist/services/auto-dream.d.ts +49 -0
- package/dist/services/auto-dream.js +124 -0
- package/dist/services/diagnostics.d.ts +41 -0
- package/dist/services/diagnostics.js +99 -0
- package/dist/services/extract-memories.d.ts +31 -0
- package/dist/services/extract-memories.js +71 -0
- package/dist/services/index.d.ts +11 -0
- package/dist/services/index.js +17 -0
- package/dist/services/memory-orchestrator.d.ts +60 -0
- package/dist/services/memory-orchestrator.js +133 -0
- package/dist/services/notifier.d.ts +25 -0
- package/dist/services/notifier.js +69 -0
- package/dist/services/oauth.d.ts +27 -0
- package/dist/services/oauth.js +153 -0
- package/dist/services/session-memory.d.ts +37 -0
- package/dist/services/session-memory.js +81 -0
- package/dist/session/file-history.d.ts +41 -0
- package/dist/session/file-history.js +115 -0
- package/dist/session/memory.d.ts +104 -0
- package/dist/session/memory.js +310 -0
- package/dist/session/session-manager.d.ts +41 -0
- package/dist/session/session-manager.js +261 -0
- package/dist/session/transcript.d.ts +39 -0
- package/dist/session/transcript.js +186 -0
- package/dist/settings/manager.d.ts +36 -0
- package/dist/settings/manager.js +187 -0
- package/dist/settings/schema.d.ts +1219 -0
- package/dist/settings/schema.js +246 -0
- package/dist/skills/frontmatter.d.ts +13 -0
- package/dist/skills/frontmatter.js +70 -0
- package/dist/skills/index.d.ts +7 -0
- package/dist/skills/index.js +6 -0
- package/dist/skills/scanner.d.ts +31 -0
- package/dist/skills/scanner.js +171 -0
- package/dist/state.d.ts +160 -0
- package/dist/state.js +267 -0
- package/dist/tool-system/builtin/agent-notifications.d.ts +84 -0
- package/dist/tool-system/builtin/agent-notifications.js +197 -0
- package/dist/tool-system/builtin/agent-registry.d.ts +67 -0
- package/dist/tool-system/builtin/agent-registry.js +126 -0
- package/dist/tool-system/builtin/agent-transcript-translator.d.ts +22 -0
- package/dist/tool-system/builtin/agent-transcript-translator.js +160 -0
- package/dist/tool-system/builtin/agent.d.ts +16 -0
- package/dist/tool-system/builtin/agent.js +364 -0
- package/dist/tool-system/builtin/apply-patch/applier.d.ts +26 -0
- package/dist/tool-system/builtin/apply-patch/applier.js +250 -0
- package/dist/tool-system/builtin/apply-patch/index.d.ts +20 -0
- package/dist/tool-system/builtin/apply-patch/index.js +101 -0
- package/dist/tool-system/builtin/apply-patch/parser.d.ts +17 -0
- package/dist/tool-system/builtin/apply-patch/parser.js +212 -0
- package/dist/tool-system/builtin/apply-patch/seek-sequence.d.ts +18 -0
- package/dist/tool-system/builtin/apply-patch/seek-sequence.js +123 -0
- package/dist/tool-system/builtin/apply-patch/types.d.ts +49 -0
- package/dist/tool-system/builtin/apply-patch/types.js +13 -0
- package/dist/tool-system/builtin/arena.d.ts +31 -0
- package/dist/tool-system/builtin/arena.js +416 -0
- package/dist/tool-system/builtin/ask-user.d.ts +20 -0
- package/dist/tool-system/builtin/ask-user.js +99 -0
- package/dist/tool-system/builtin/bash.d.ts +21 -0
- package/dist/tool-system/builtin/bash.js +149 -0
- package/dist/tool-system/builtin/brief.d.ts +6 -0
- package/dist/tool-system/builtin/brief.js +41 -0
- package/dist/tool-system/builtin/config.d.ts +6 -0
- package/dist/tool-system/builtin/config.js +67 -0
- package/dist/tool-system/builtin/cron.d.ts +10 -0
- package/dist/tool-system/builtin/cron.js +61 -0
- package/dist/tool-system/builtin/edit.d.ts +6 -0
- package/dist/tool-system/builtin/edit.js +100 -0
- package/dist/tool-system/builtin/file-cache.d.ts +11 -0
- package/dist/tool-system/builtin/file-cache.js +39 -0
- package/dist/tool-system/builtin/glob.d.ts +7 -0
- package/dist/tool-system/builtin/glob.js +76 -0
- package/dist/tool-system/builtin/grep.d.ts +7 -0
- package/dist/tool-system/builtin/grep.js +150 -0
- package/dist/tool-system/builtin/index.d.ts +20 -0
- package/dist/tool-system/builtin/index.js +449 -0
- package/dist/tool-system/builtin/lsp.d.ts +6 -0
- package/dist/tool-system/builtin/lsp.js +141 -0
- package/dist/tool-system/builtin/mcp-tools.d.ts +10 -0
- package/dist/tool-system/builtin/mcp-tools.js +102 -0
- package/dist/tool-system/builtin/memory.d.ts +26 -0
- package/dist/tool-system/builtin/memory.js +226 -0
- package/dist/tool-system/builtin/notebook-edit.d.ts +6 -0
- package/dist/tool-system/builtin/notebook-edit.js +124 -0
- package/dist/tool-system/builtin/plan.d.ts +15 -0
- package/dist/tool-system/builtin/plan.js +55 -0
- package/dist/tool-system/builtin/powershell.d.ts +11 -0
- package/dist/tool-system/builtin/powershell.js +64 -0
- package/dist/tool-system/builtin/read.d.ts +6 -0
- package/dist/tool-system/builtin/read.js +70 -0
- package/dist/tool-system/builtin/remote-trigger.d.ts +6 -0
- package/dist/tool-system/builtin/remote-trigger.js +54 -0
- package/dist/tool-system/builtin/repl.d.ts +11 -0
- package/dist/tool-system/builtin/repl.js +82 -0
- package/dist/tool-system/builtin/send-message.d.ts +6 -0
- package/dist/tool-system/builtin/send-message.js +47 -0
- package/dist/tool-system/builtin/skill-prompt.d.ts +20 -0
- package/dist/tool-system/builtin/skill-prompt.js +52 -0
- package/dist/tool-system/builtin/skill.d.ts +9 -0
- package/dist/tool-system/builtin/skill.js +55 -0
- package/dist/tool-system/builtin/sleep.d.ts +6 -0
- package/dist/tool-system/builtin/sleep.js +33 -0
- package/dist/tool-system/builtin/task.d.ts +48 -0
- package/dist/tool-system/builtin/task.js +139 -0
- package/dist/tool-system/builtin/tool-search.d.ts +11 -0
- package/dist/tool-system/builtin/tool-search.js +90 -0
- package/dist/tool-system/builtin/web-fetch.d.ts +10 -0
- package/dist/tool-system/builtin/web-fetch.js +328 -0
- package/dist/tool-system/builtin/web-search.d.ts +25 -0
- package/dist/tool-system/builtin/web-search.js +174 -0
- package/dist/tool-system/builtin/worktree.d.ts +10 -0
- package/dist/tool-system/builtin/worktree.js +95 -0
- package/dist/tool-system/builtin/write.d.ts +6 -0
- package/dist/tool-system/builtin/write.js +36 -0
- package/dist/tool-system/context.d.ts +165 -0
- package/dist/tool-system/context.js +18 -0
- package/dist/tool-system/executor.d.ts +49 -0
- package/dist/tool-system/executor.js +495 -0
- package/dist/tool-system/investigation-guard.d.ts +46 -0
- package/dist/tool-system/investigation-guard.js +155 -0
- package/dist/tool-system/mcp-manager.d.ts +67 -0
- package/dist/tool-system/mcp-manager.js +249 -0
- package/dist/tool-system/permission.d.ts +111 -0
- package/dist/tool-system/permission.js +774 -0
- package/dist/tool-system/registry.d.ts +32 -0
- package/dist/tool-system/registry.js +131 -0
- package/dist/tool-system/sandbox/bwrap.d.ts +13 -0
- package/dist/tool-system/sandbox/bwrap.js +63 -0
- package/dist/tool-system/sandbox/index.d.ts +78 -0
- package/dist/tool-system/sandbox/index.js +222 -0
- package/dist/tool-system/sandbox/off.d.ts +2 -0
- package/dist/tool-system/sandbox/off.js +8 -0
- package/dist/tool-system/sandbox/seatbelt.d.ts +18 -0
- package/dist/tool-system/sandbox/seatbelt.js +109 -0
- package/dist/tool-system/task-guard.d.ts +29 -0
- package/dist/tool-system/task-guard.js +70 -0
- package/dist/tool-system/validation.d.ts +5 -0
- package/dist/tool-system/validation.js +39 -0
- package/dist/types.d.ts +376 -0
- package/dist/types.js +4 -0
- package/dist/updater.d.ts +65 -0
- package/dist/updater.js +405 -0
- package/dist/utils/debug.d.ts +41 -0
- package/dist/utils/debug.js +110 -0
- package/dist/utils/earlyInput.d.ts +43 -0
- package/dist/utils/earlyInput.js +166 -0
- package/dist/utils/env.d.ts +24 -0
- package/dist/utils/env.js +104 -0
- package/dist/utils/envUtils.d.ts +51 -0
- package/dist/utils/envUtils.js +135 -0
- package/dist/utils/execFileNoThrow.d.ts +39 -0
- package/dist/utils/execFileNoThrow.js +74 -0
- package/dist/utils/format.d.ts +44 -0
- package/dist/utils/format.js +236 -0
- package/dist/utils/intl.d.ts +22 -0
- package/dist/utils/intl.js +83 -0
- package/dist/utils/lockfile.d.ts +15 -0
- package/dist/utils/lockfile.js +30 -0
- package/dist/utils/memoize.d.ts +19 -0
- package/dist/utils/memoize.js +14 -0
- package/dist/utils/semver.d.ts +6 -0
- package/dist/utils/semver.js +13 -0
- package/dist/utils/sliceAnsi.d.ts +12 -0
- package/dist/utils/sliceAnsi.js +62 -0
- package/dist/utils/systemTheme.d.ts +40 -0
- package/dist/utils/systemTheme.js +108 -0
- package/dist/utils/task-sanitizer.d.ts +6 -0
- package/dist/utils/task-sanitizer.js +24 -0
- package/dist/utils/theme.d.ts +93 -0
- package/dist/utils/theme.js +544 -0
- package/dist/utils/toolDisplay.d.ts +31 -0
- package/dist/utils/toolDisplay.js +188 -0
- package/package.json +72 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in agent presets.
|
|
3
|
+
*
|
|
4
|
+
* Presets keep the core engine domain-agnostic while letting callers choose
|
|
5
|
+
* a default prompt, default tools, and safe permission shortcuts.
|
|
6
|
+
*
|
|
7
|
+
* System prompts are assembled from reusable markdown sections in
|
|
8
|
+
* src/prompt/sections/*.md — each preset declares which sections to include.
|
|
9
|
+
*/
|
|
10
|
+
import { loadSections } from "../prompt/section-loader.js";
|
|
11
|
+
export const AGENT_PRESET_NAMES = ["general", "terminal-coding"];
|
|
12
|
+
// ─── Tool sets ───────────────────────────────────────────────────
|
|
13
|
+
const GENERAL_BUILTIN_TOOLS = [
|
|
14
|
+
"Read",
|
|
15
|
+
"Write",
|
|
16
|
+
"Edit",
|
|
17
|
+
"ApplyPatch",
|
|
18
|
+
"Glob",
|
|
19
|
+
"Grep",
|
|
20
|
+
"Bash",
|
|
21
|
+
"WebSearch",
|
|
22
|
+
"WebFetch",
|
|
23
|
+
"AskUserQuestion",
|
|
24
|
+
"Agent",
|
|
25
|
+
// AgentStatus removed: background agents now write to ~/.code-shell/agents/
|
|
26
|
+
// <id>.txt — the parent agent can Read/Bash tail that file for live progress.
|
|
27
|
+
// The implementation is still in the registry for SDK consumers if needed.
|
|
28
|
+
"AgentCancel",
|
|
29
|
+
"EnterPlanMode",
|
|
30
|
+
"ExitPlanMode",
|
|
31
|
+
"ToolSearch",
|
|
32
|
+
"TodoWrite",
|
|
33
|
+
"Sleep",
|
|
34
|
+
"Config",
|
|
35
|
+
"CronCreate",
|
|
36
|
+
"CronDelete",
|
|
37
|
+
"CronList",
|
|
38
|
+
"Skill",
|
|
39
|
+
"MCPTool",
|
|
40
|
+
"ListMcpResources",
|
|
41
|
+
"ReadMcpResource",
|
|
42
|
+
"RemoteTrigger",
|
|
43
|
+
"REPL",
|
|
44
|
+
"PowerShell",
|
|
45
|
+
];
|
|
46
|
+
const TERMINAL_CODING_EXTRA_TOOLS = [
|
|
47
|
+
"EnterWorktree",
|
|
48
|
+
"ExitWorktree",
|
|
49
|
+
"NotebookEdit",
|
|
50
|
+
"LSP",
|
|
51
|
+
"Brief",
|
|
52
|
+
"Arena",
|
|
53
|
+
];
|
|
54
|
+
// ─── Permission rules ────────────────────────────────────────────
|
|
55
|
+
const GENERAL_PERMISSION_RULES = [
|
|
56
|
+
{ tool: "Read", decision: "allow" },
|
|
57
|
+
{ tool: "Glob", decision: "allow" },
|
|
58
|
+
{ tool: "Grep", decision: "allow" },
|
|
59
|
+
{ tool: "WebSearch", decision: "allow" },
|
|
60
|
+
{ tool: "WebFetch", decision: "allow" },
|
|
61
|
+
{ tool: "AskUserQuestion", decision: "allow" },
|
|
62
|
+
{ tool: "Agent", decision: "allow" },
|
|
63
|
+
{ tool: "AgentStatus", decision: "allow" },
|
|
64
|
+
{ tool: "AgentCancel", decision: "allow" },
|
|
65
|
+
{ tool: "EnterPlanMode", decision: "allow" },
|
|
66
|
+
{ tool: "ExitPlanMode", decision: "allow" },
|
|
67
|
+
{ tool: "ToolSearch", decision: "allow" },
|
|
68
|
+
{ tool: "TodoWrite", decision: "allow" },
|
|
69
|
+
{ tool: "Sleep", decision: "allow" },
|
|
70
|
+
{ tool: "CronList", decision: "allow" },
|
|
71
|
+
{ tool: "Skill", decision: "allow" },
|
|
72
|
+
{ tool: "ListMcpResources", decision: "allow" },
|
|
73
|
+
{ tool: "ReadMcpResource", decision: "allow" },
|
|
74
|
+
];
|
|
75
|
+
// ─── Preset definitions ──────────────────────────────────────────
|
|
76
|
+
export const BUILTIN_AGENT_PRESETS = {
|
|
77
|
+
general: {
|
|
78
|
+
name: "general",
|
|
79
|
+
label: "General Orchestrator",
|
|
80
|
+
description: "Domain-agnostic orchestration for research, operations, automation, and long-running tasks.",
|
|
81
|
+
promptSections: ["base", "orchestration", "tone"],
|
|
82
|
+
injectGitStatus: false,
|
|
83
|
+
builtinTools: [...GENERAL_BUILTIN_TOOLS],
|
|
84
|
+
defaultPermissionRules: GENERAL_PERMISSION_RULES,
|
|
85
|
+
},
|
|
86
|
+
"terminal-coding": {
|
|
87
|
+
name: "terminal-coding",
|
|
88
|
+
label: "Terminal Coding Assistant",
|
|
89
|
+
description: "General orchestration plus coding-focused guidance and code-navigation tools.",
|
|
90
|
+
promptSections: ["base", "orchestration", "coding", "tone"],
|
|
91
|
+
injectGitStatus: true,
|
|
92
|
+
builtinTools: [...GENERAL_BUILTIN_TOOLS, ...TERMINAL_CODING_EXTRA_TOOLS],
|
|
93
|
+
defaultPermissionRules: [
|
|
94
|
+
...GENERAL_PERMISSION_RULES,
|
|
95
|
+
{ tool: "LSP", decision: "allow" },
|
|
96
|
+
{ tool: "Brief", decision: "allow" },
|
|
97
|
+
],
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
export const DEFAULT_AGENT_PRESET = "general";
|
|
101
|
+
export const DEFAULT_CLI_PRESET = "terminal-coding";
|
|
102
|
+
/** Registry of custom presets registered by external consumers. */
|
|
103
|
+
const _customPresets = new Map();
|
|
104
|
+
/**
|
|
105
|
+
* Register a custom agent preset.
|
|
106
|
+
*
|
|
107
|
+
* External repos can call this to add their own presets:
|
|
108
|
+
* ```ts
|
|
109
|
+
* import { registerPreset } from "code-shell";
|
|
110
|
+
*
|
|
111
|
+
* registerPreset({
|
|
112
|
+
* name: "data-pipeline" as AgentPresetName,
|
|
113
|
+
* label: "Data Pipeline Orchestrator",
|
|
114
|
+
* description: "Manages ETL workflows and data quality checks.",
|
|
115
|
+
* promptSections: ["base", "orchestration"],
|
|
116
|
+
* injectGitStatus: false,
|
|
117
|
+
* builtinTools: ["Read", "Write", "Bash", "Glob", "Grep", "Agent"],
|
|
118
|
+
* defaultPermissionRules: [{ tool: "Read", decision: "allow" }],
|
|
119
|
+
* });
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
export function registerPreset(preset) {
|
|
123
|
+
_customPresets.set(preset.name, preset);
|
|
124
|
+
}
|
|
125
|
+
/** List all available preset names (built-in + custom). */
|
|
126
|
+
export function listPresetNames() {
|
|
127
|
+
return [...AGENT_PRESET_NAMES, ..._customPresets.keys()];
|
|
128
|
+
}
|
|
129
|
+
export function resolveAgentPreset(name) {
|
|
130
|
+
if (!name)
|
|
131
|
+
return BUILTIN_AGENT_PRESETS[DEFAULT_AGENT_PRESET];
|
|
132
|
+
// Check built-in first
|
|
133
|
+
const builtin = BUILTIN_AGENT_PRESETS[name];
|
|
134
|
+
if (builtin)
|
|
135
|
+
return builtin;
|
|
136
|
+
// Check custom presets
|
|
137
|
+
const custom = _customPresets.get(name);
|
|
138
|
+
if (custom)
|
|
139
|
+
return custom;
|
|
140
|
+
const allowed = listPresetNames().join(", ");
|
|
141
|
+
throw new Error(`Unknown agent preset "${name}". Available presets: ${allowed}`);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Build the full system prompt for a preset by loading and joining its sections.
|
|
145
|
+
*/
|
|
146
|
+
export function buildPresetSystemPrompt(preset) {
|
|
147
|
+
return loadSections(preset.promptSections);
|
|
148
|
+
}
|
|
149
|
+
export function resolveBuiltinToolNames(options) {
|
|
150
|
+
const preset = resolveAgentPreset(options?.preset);
|
|
151
|
+
const names = new Set(preset.builtinTools);
|
|
152
|
+
for (const name of options?.enabledBuiltinTools ?? []) {
|
|
153
|
+
names.add(name);
|
|
154
|
+
}
|
|
155
|
+
for (const name of options?.disabledBuiltinTools ?? []) {
|
|
156
|
+
names.delete(name);
|
|
157
|
+
}
|
|
158
|
+
return [...names];
|
|
159
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* defineProduct — assemble a domain-specific agent product from preset + adapter + contract.
|
|
3
|
+
*
|
|
4
|
+
* This is the primary entry point for external repos. One call produces a
|
|
5
|
+
* ready-to-use RunManager that embodies the product's behavior.
|
|
6
|
+
*
|
|
7
|
+
* Example (in an external repo):
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { defineProduct } from "code-shell";
|
|
10
|
+
*
|
|
11
|
+
* const { manager, preset } = defineProduct({
|
|
12
|
+
* preset: {
|
|
13
|
+
* name: "security-audit",
|
|
14
|
+
* label: "Security Audit Agent",
|
|
15
|
+
* description: "Scans repos for OWASP top 10 vulnerabilities.",
|
|
16
|
+
* sections: ["base", "orchestration"],
|
|
17
|
+
* appendPrompt: "You are a security expert. Focus on...",
|
|
18
|
+
* },
|
|
19
|
+
* adapter: {
|
|
20
|
+
* tools: [myCustomScanTool],
|
|
21
|
+
* enableTools: ["Read", "Glob", "Grep", "Bash"],
|
|
22
|
+
* permissionRules: [{ tool: "Bash", decision: "ask" }],
|
|
23
|
+
* },
|
|
24
|
+
* contract: {
|
|
25
|
+
* evaluator: new SecurityEvaluator(),
|
|
26
|
+
* defaultTags: ["security"],
|
|
27
|
+
* maxTurns: 50,
|
|
28
|
+
* },
|
|
29
|
+
* }, {
|
|
30
|
+
* llm: { provider: "openai", model: "...", apiKey: "..." },
|
|
31
|
+
* });
|
|
32
|
+
*
|
|
33
|
+
* await manager.submit({ objective: "Audit auth module for SQL injection" });
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
import type { LLMConfig, PermissionMode } from "../types.js";
|
|
37
|
+
import type { AgentPreset } from "../preset/index.js";
|
|
38
|
+
import { RunManager } from "../run/RunManager.js";
|
|
39
|
+
import type { ProductDefinition, CustomTool } from "./types.js";
|
|
40
|
+
export interface ProductRuntimeOptions {
|
|
41
|
+
/** LLM configuration (required). */
|
|
42
|
+
llm: LLMConfig;
|
|
43
|
+
/** Permission mode. Default: "acceptEdits" */
|
|
44
|
+
permissionMode?: PermissionMode;
|
|
45
|
+
/** Working directory. Default: process.cwd() */
|
|
46
|
+
cwd?: string;
|
|
47
|
+
/** Storage directory for runs. Default: ~/.code-shell/runs */
|
|
48
|
+
runsDir?: string;
|
|
49
|
+
/** Storage directory for sessions. */
|
|
50
|
+
sessionStorageDir?: string;
|
|
51
|
+
}
|
|
52
|
+
export interface ProductInstance {
|
|
53
|
+
/** The configured RunManager, ready for submit/resume/cancel. */
|
|
54
|
+
manager: RunManager;
|
|
55
|
+
/** The registered preset (can be used to create Engine directly). */
|
|
56
|
+
preset: AgentPreset;
|
|
57
|
+
/** Custom tools registered by the adapter (for reference). */
|
|
58
|
+
customTools: CustomTool[];
|
|
59
|
+
}
|
|
60
|
+
export declare function defineProduct(definition: ProductDefinition, runtime: ProductRuntimeOptions): ProductInstance;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* defineProduct — assemble a domain-specific agent product from preset + adapter + contract.
|
|
3
|
+
*
|
|
4
|
+
* This is the primary entry point for external repos. One call produces a
|
|
5
|
+
* ready-to-use RunManager that embodies the product's behavior.
|
|
6
|
+
*
|
|
7
|
+
* Example (in an external repo):
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { defineProduct } from "code-shell";
|
|
10
|
+
*
|
|
11
|
+
* const { manager, preset } = defineProduct({
|
|
12
|
+
* preset: {
|
|
13
|
+
* name: "security-audit",
|
|
14
|
+
* label: "Security Audit Agent",
|
|
15
|
+
* description: "Scans repos for OWASP top 10 vulnerabilities.",
|
|
16
|
+
* sections: ["base", "orchestration"],
|
|
17
|
+
* appendPrompt: "You are a security expert. Focus on...",
|
|
18
|
+
* },
|
|
19
|
+
* adapter: {
|
|
20
|
+
* tools: [myCustomScanTool],
|
|
21
|
+
* enableTools: ["Read", "Glob", "Grep", "Bash"],
|
|
22
|
+
* permissionRules: [{ tool: "Bash", decision: "ask" }],
|
|
23
|
+
* },
|
|
24
|
+
* contract: {
|
|
25
|
+
* evaluator: new SecurityEvaluator(),
|
|
26
|
+
* defaultTags: ["security"],
|
|
27
|
+
* maxTurns: 50,
|
|
28
|
+
* },
|
|
29
|
+
* }, {
|
|
30
|
+
* llm: { provider: "openai", model: "...", apiKey: "..." },
|
|
31
|
+
* });
|
|
32
|
+
*
|
|
33
|
+
* await manager.submit({ objective: "Audit auth module for SQL injection" });
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
import { registerPreset } from "../preset/index.js";
|
|
37
|
+
import { CompositeEvaluator, NoopEvaluator } from "../run/Evaluator.js";
|
|
38
|
+
import { RunManager } from "../run/RunManager.js";
|
|
39
|
+
import { FileRunStore } from "../run/FileRunStore.js";
|
|
40
|
+
import { join } from "node:path";
|
|
41
|
+
import { homedir } from "node:os";
|
|
42
|
+
// ─── Main function ─────────────────────────────────────��─────────
|
|
43
|
+
export function defineProduct(definition, runtime) {
|
|
44
|
+
const { preset: presetDef, adapter, contract } = definition;
|
|
45
|
+
// ── 1. Build and register preset ──────────────────────────────
|
|
46
|
+
const presetName = presetDef.name;
|
|
47
|
+
// Determine builtin tools: start from a base set, apply adapter overrides
|
|
48
|
+
const baseTools = [
|
|
49
|
+
"Read", "Write", "Edit", "Glob", "Grep", "Bash",
|
|
50
|
+
"AskUserQuestion", "Agent", "ToolSearch",
|
|
51
|
+
"TodoWrite",
|
|
52
|
+
];
|
|
53
|
+
const enabledSet = new Set([...baseTools, ...(adapter?.enableTools ?? [])]);
|
|
54
|
+
for (const t of adapter?.disableTools ?? []) {
|
|
55
|
+
enabledSet.delete(t);
|
|
56
|
+
}
|
|
57
|
+
// Combine permission rules
|
|
58
|
+
const permissionRules = [
|
|
59
|
+
// Default safe rules
|
|
60
|
+
{ tool: "Read", decision: "allow" },
|
|
61
|
+
{ tool: "Glob", decision: "allow" },
|
|
62
|
+
{ tool: "Grep", decision: "allow" },
|
|
63
|
+
{ tool: "AskUserQuestion", decision: "allow" },
|
|
64
|
+
{ tool: "ToolSearch", decision: "allow" },
|
|
65
|
+
{ tool: "TodoWrite", decision: "allow" },
|
|
66
|
+
// Product-specific rules (higher priority)
|
|
67
|
+
...(adapter?.permissionRules ?? []),
|
|
68
|
+
];
|
|
69
|
+
const agentPreset = {
|
|
70
|
+
name: presetName,
|
|
71
|
+
label: presetDef.label,
|
|
72
|
+
description: presetDef.description,
|
|
73
|
+
promptSections: presetDef.sections ?? ["base", "orchestration"],
|
|
74
|
+
injectGitStatus: presetDef.injectGitStatus ?? false,
|
|
75
|
+
builtinTools: [...enabledSet],
|
|
76
|
+
defaultPermissionRules: permissionRules,
|
|
77
|
+
};
|
|
78
|
+
registerPreset(agentPreset);
|
|
79
|
+
// ── 2. Build evaluator from contract ──────────────────────────
|
|
80
|
+
let evaluator;
|
|
81
|
+
if (!contract?.evaluator) {
|
|
82
|
+
evaluator = new NoopEvaluator();
|
|
83
|
+
}
|
|
84
|
+
else if (Array.isArray(contract.evaluator)) {
|
|
85
|
+
evaluator = new CompositeEvaluator(contract.evaluator);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
evaluator = contract.evaluator;
|
|
89
|
+
}
|
|
90
|
+
// ── 3. Collect custom tools ────────────────────────────────────
|
|
91
|
+
const customTools = adapter?.tools ?? [];
|
|
92
|
+
// Convert product CustomTool[] to EngineRunner's CustomToolEntry[]
|
|
93
|
+
const customToolEntries = customTools.map((ct) => ({
|
|
94
|
+
definition: ct.definition,
|
|
95
|
+
execute: ct.execute,
|
|
96
|
+
}));
|
|
97
|
+
// ── 4. Build RunManager ───────────────────────────────────────
|
|
98
|
+
const runsDir = runtime.runsDir ?? join(homedir(), ".code-shell", "runs");
|
|
99
|
+
const store = new FileRunStore(runsDir);
|
|
100
|
+
const manager = new RunManager({
|
|
101
|
+
store,
|
|
102
|
+
executor: {
|
|
103
|
+
llm: runtime.llm,
|
|
104
|
+
maxTurns: contract?.maxTurns ?? 30,
|
|
105
|
+
maxContextTokens: contract?.maxContextTokens ?? 200_000,
|
|
106
|
+
permissionMode: runtime.permissionMode ?? "acceptEdits",
|
|
107
|
+
sessionStorageDir: runtime.sessionStorageDir,
|
|
108
|
+
mcpServers: adapter?.mcpServers,
|
|
109
|
+
enabledBuiltinTools: [...enabledSet],
|
|
110
|
+
disabledBuiltinTools: adapter?.disableTools,
|
|
111
|
+
customSystemPrompt: presetDef.customPrompt,
|
|
112
|
+
appendSystemPrompt: presetDef.appendPrompt,
|
|
113
|
+
hooks: adapter?.hooks,
|
|
114
|
+
customTools: customToolEntries.length > 0 ? customToolEntries : undefined,
|
|
115
|
+
},
|
|
116
|
+
concurrency: contract?.concurrency ?? 1,
|
|
117
|
+
runsDir,
|
|
118
|
+
evaluator,
|
|
119
|
+
defaultTags: contract?.defaultTags,
|
|
120
|
+
defaultMetadata: contract?.defaultMetadata,
|
|
121
|
+
});
|
|
122
|
+
return { manager, preset: agentPreset, customTools };
|
|
123
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Product module — build domain-specific agents on CodeShell.
|
|
3
|
+
*/
|
|
4
|
+
export type { ProductDefinition, ProductPreset, ProductAdapter, ProductContract, CustomTool, } from "./types.js";
|
|
5
|
+
export { defineProduct, type ProductRuntimeOptions, type ProductInstance, } from "./define.js";
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Product Adapter — the contract for turning CodeShell into a domain-specific agent.
|
|
3
|
+
*
|
|
4
|
+
* A "product" is a concrete agent application built on top of CodeShell.
|
|
5
|
+
* Examples:
|
|
6
|
+
* - Code reviewer agent
|
|
7
|
+
* - Data pipeline orchestrator
|
|
8
|
+
* - DevOps deployment agent
|
|
9
|
+
* - Documentation writer
|
|
10
|
+
* - Security audit agent
|
|
11
|
+
*
|
|
12
|
+
* To build a product, an external repo provides:
|
|
13
|
+
*
|
|
14
|
+
* 1. **Preset** (brain) — system prompt, tool set, permission rules
|
|
15
|
+
* 2. **Adapter** (hands) — custom tools, MCP servers, domain-specific IO
|
|
16
|
+
* 3. **Contract** (quality) — evaluator, completion criteria, artifact specs
|
|
17
|
+
*
|
|
18
|
+
* These three layers compose into a ProductDefinition that CodeShell's
|
|
19
|
+
* `defineProduct()` function turns into a fully configured RunManager.
|
|
20
|
+
*/
|
|
21
|
+
import type { PermissionRule, MCPServerConfig } from "../types.js";
|
|
22
|
+
import type { Evaluator } from "../run/Evaluator.js";
|
|
23
|
+
import type { RegisteredTool } from "../types.js";
|
|
24
|
+
import type { EngineHookConfig } from "../engine/engine.js";
|
|
25
|
+
export interface ProductPreset {
|
|
26
|
+
/** Unique name for this product's preset. */
|
|
27
|
+
name: string;
|
|
28
|
+
/** Human-readable label. */
|
|
29
|
+
label: string;
|
|
30
|
+
/** One-line description. */
|
|
31
|
+
description: string;
|
|
32
|
+
/**
|
|
33
|
+
* System prompt for the agent. Two options:
|
|
34
|
+
* - `sections`: reuse CodeShell's built-in markdown sections (e.g. ["base", "orchestration"])
|
|
35
|
+
* - `customPrompt`: provide a full custom system prompt string
|
|
36
|
+
* If both are provided, customPrompt takes precedence.
|
|
37
|
+
*/
|
|
38
|
+
sections?: string[];
|
|
39
|
+
customPrompt?: string;
|
|
40
|
+
/** Additional text appended after the main system prompt. */
|
|
41
|
+
appendPrompt?: string;
|
|
42
|
+
/** Whether to inject git status into system context. Default: false */
|
|
43
|
+
injectGitStatus?: boolean;
|
|
44
|
+
}
|
|
45
|
+
export interface CustomTool {
|
|
46
|
+
/** Tool definition (name, description, inputSchema). */
|
|
47
|
+
definition: RegisteredTool;
|
|
48
|
+
/** Tool executor function. */
|
|
49
|
+
execute: (args: Record<string, unknown>) => Promise<string>;
|
|
50
|
+
}
|
|
51
|
+
export interface ProductAdapter {
|
|
52
|
+
/**
|
|
53
|
+
* Custom tools specific to this product domain.
|
|
54
|
+
* These are registered in addition to the preset's builtin tools.
|
|
55
|
+
*/
|
|
56
|
+
tools?: CustomTool[];
|
|
57
|
+
/**
|
|
58
|
+
* MCP servers to connect (external tool providers).
|
|
59
|
+
*/
|
|
60
|
+
mcpServers?: Record<string, MCPServerConfig>;
|
|
61
|
+
/**
|
|
62
|
+
* Builtin tools to explicitly enable (add to preset defaults).
|
|
63
|
+
*/
|
|
64
|
+
enableTools?: string[];
|
|
65
|
+
/**
|
|
66
|
+
* Builtin tools to explicitly disable (remove from preset defaults).
|
|
67
|
+
*/
|
|
68
|
+
disableTools?: string[];
|
|
69
|
+
/**
|
|
70
|
+
* Permission rules specific to this product.
|
|
71
|
+
* Applied on top of the preset's default rules.
|
|
72
|
+
*/
|
|
73
|
+
permissionRules?: PermissionRule[];
|
|
74
|
+
/**
|
|
75
|
+
* Hooks to register for this product.
|
|
76
|
+
* Key: hook event name, Value: handler function.
|
|
77
|
+
*/
|
|
78
|
+
hooks?: EngineHookConfig[];
|
|
79
|
+
}
|
|
80
|
+
export interface ProductContract {
|
|
81
|
+
/**
|
|
82
|
+
* Evaluator(s) to run on completion.
|
|
83
|
+
* Can be a single Evaluator or an array (composed automatically).
|
|
84
|
+
*/
|
|
85
|
+
evaluator?: Evaluator | Evaluator[];
|
|
86
|
+
/**
|
|
87
|
+
* Default tags applied to every run submitted through this product.
|
|
88
|
+
*/
|
|
89
|
+
defaultTags?: string[];
|
|
90
|
+
/**
|
|
91
|
+
* Default metadata attached to every run.
|
|
92
|
+
*/
|
|
93
|
+
defaultMetadata?: Record<string, unknown>;
|
|
94
|
+
/**
|
|
95
|
+
* Maximum turns per run. Overrides the default 30.
|
|
96
|
+
*/
|
|
97
|
+
maxTurns?: number;
|
|
98
|
+
/**
|
|
99
|
+
* Maximum context tokens. Overrides the default 200_000.
|
|
100
|
+
*/
|
|
101
|
+
maxContextTokens?: number;
|
|
102
|
+
/**
|
|
103
|
+
* Queue concurrency. Default: 1.
|
|
104
|
+
*/
|
|
105
|
+
concurrency?: number;
|
|
106
|
+
}
|
|
107
|
+
export interface ProductDefinition {
|
|
108
|
+
preset: ProductPreset;
|
|
109
|
+
adapter?: ProductAdapter;
|
|
110
|
+
contract?: ProductContract;
|
|
111
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Product Adapter — the contract for turning CodeShell into a domain-specific agent.
|
|
3
|
+
*
|
|
4
|
+
* A "product" is a concrete agent application built on top of CodeShell.
|
|
5
|
+
* Examples:
|
|
6
|
+
* - Code reviewer agent
|
|
7
|
+
* - Data pipeline orchestrator
|
|
8
|
+
* - DevOps deployment agent
|
|
9
|
+
* - Documentation writer
|
|
10
|
+
* - Security audit agent
|
|
11
|
+
*
|
|
12
|
+
* To build a product, an external repo provides:
|
|
13
|
+
*
|
|
14
|
+
* 1. **Preset** (brain) — system prompt, tool set, permission rules
|
|
15
|
+
* 2. **Adapter** (hands) — custom tools, MCP servers, domain-specific IO
|
|
16
|
+
* 3. **Contract** (quality) — evaluator, completion criteria, artifact specs
|
|
17
|
+
*
|
|
18
|
+
* These three layers compose into a ProductDefinition that CodeShell's
|
|
19
|
+
* `defineProduct()` function turns into a fully configured RunManager.
|
|
20
|
+
*/
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompt composer — assembles system prompt from sections.
|
|
3
|
+
*
|
|
4
|
+
* Following Claude Code's dual-chain architecture:
|
|
5
|
+
* system chain → API request "system" field
|
|
6
|
+
* messages chain → API request "messages" field (userContext prepended)
|
|
7
|
+
*/
|
|
8
|
+
import type { ToolDefinition, Message } from "../types.js";
|
|
9
|
+
import { type ScanOptions } from "./instruction-scanner.js";
|
|
10
|
+
import { type AgentPreset } from "../preset/index.js";
|
|
11
|
+
export interface ComposerOptions {
|
|
12
|
+
cwd: string;
|
|
13
|
+
model: string;
|
|
14
|
+
instructionOptions?: ScanOptions;
|
|
15
|
+
/** Resolved preset — used to load section-based prompt. */
|
|
16
|
+
preset?: AgentPreset;
|
|
17
|
+
customSystemPrompt?: string;
|
|
18
|
+
appendSystemPrompt?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Skill names (full names including any "<plugin>:" prefix) the user
|
|
21
|
+
* has disabled in settings. Filtered out of the LLM's skills listing
|
|
22
|
+
* so the prompt matches what the skill builtin tool will actually
|
|
23
|
+
* dispatch — see scanSkills(opts.disabledSkills) and skillTool.
|
|
24
|
+
*/
|
|
25
|
+
disabledSkills?: string[];
|
|
26
|
+
}
|
|
27
|
+
export declare class PromptComposer {
|
|
28
|
+
private readonly options;
|
|
29
|
+
private sectionCache;
|
|
30
|
+
private cachedInstructions;
|
|
31
|
+
constructor(options: ComposerOptions);
|
|
32
|
+
/**
|
|
33
|
+
* Build the system prompt from sections.
|
|
34
|
+
*/
|
|
35
|
+
buildSystemPrompt(tools: ToolDefinition[]): Promise<string>;
|
|
36
|
+
/**
|
|
37
|
+
* Build the userContext prefix message (CLAUDE.md content as <system-reminder>).
|
|
38
|
+
*/
|
|
39
|
+
buildUserContextMessage(): Message | null;
|
|
40
|
+
/**
|
|
41
|
+
* Build the systemContext (gitStatus etc.) to append to system prompt.
|
|
42
|
+
* Only injects git status if the resolved preset opts in.
|
|
43
|
+
*/
|
|
44
|
+
buildSystemContext(): Promise<string>;
|
|
45
|
+
invalidateCache(sectionName?: string): void;
|
|
46
|
+
private getSections;
|
|
47
|
+
private getInstructions;
|
|
48
|
+
private getMemoryContext;
|
|
49
|
+
}
|