hyacinth-ai 0.9.6
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 +205 -0
- package/commands.json +25 -0
- package/dist/agents/builtins.d.ts +8 -0
- package/dist/agents/builtins.js +50 -0
- package/dist/agents/config-loader.d.ts +15 -0
- package/dist/agents/config-loader.js +75 -0
- package/dist/agents/delegate-tool.d.ts +109 -0
- package/dist/agents/delegate-tool.js +407 -0
- package/dist/agents/index.d.ts +5 -0
- package/dist/agents/index.js +5 -0
- package/dist/agents/registry.d.ts +2 -0
- package/dist/agents/registry.js +2 -0
- package/dist/bypass/agents/companion/index.d.ts +57 -0
- package/dist/bypass/agents/companion/index.js +487 -0
- package/dist/bypass/agents/orchestrator/index.d.ts +17 -0
- package/dist/bypass/agents/orchestrator/index.js +414 -0
- package/dist/bypass/agents/orchestrator.d.ts +16 -0
- package/dist/bypass/agents/orchestrator.js +377 -0
- package/dist/bypass/agents/world-engine/agent.d.ts +41 -0
- package/dist/bypass/agents/world-engine/agent.js +385 -0
- package/dist/bypass/agents/world-engine/index.d.ts +52 -0
- package/dist/bypass/agents/world-engine/index.js +198 -0
- package/dist/bypass/agents/world-engine/sim.d.ts +14 -0
- package/dist/bypass/agents/world-engine/sim.js +120 -0
- package/dist/bypass/agents/world-engine/store.d.ts +110 -0
- package/dist/bypass/agents/world-engine/store.js +519 -0
- package/dist/bypass/agents/world-engine/ticker.d.ts +37 -0
- package/dist/bypass/agents/world-engine/ticker.js +214 -0
- package/dist/bypass/agents/world-engine/tools.d.ts +6 -0
- package/dist/bypass/agents/world-engine/tools.js +380 -0
- package/dist/bypass/agents/world-engine/types.d.ts +202 -0
- package/dist/bypass/agents/world-engine/types.js +56 -0
- package/dist/bypass/agents/world-engine.d.ts +20 -0
- package/dist/bypass/agents/world-engine.js +63 -0
- package/dist/bypass/base.d.ts +48 -0
- package/dist/bypass/base.js +126 -0
- package/dist/bypass/index.d.ts +5 -0
- package/dist/bypass/index.js +6 -0
- package/dist/bypass/manager.d.ts +41 -0
- package/dist/bypass/manager.js +179 -0
- package/dist/bypass/types.d.ts +63 -0
- package/dist/bypass/types.js +14 -0
- package/dist/channels/auto-detect.d.ts +25 -0
- package/dist/channels/auto-detect.js +77 -0
- package/dist/channels/builtin/http-webhook.d.ts +25 -0
- package/dist/channels/builtin/http-webhook.js +287 -0
- package/dist/channels/builtin/tui-channel.d.ts +33 -0
- package/dist/channels/builtin/tui-channel.js +61 -0
- package/dist/channels/builtin/tui-ws-session.d.ts +16 -0
- package/dist/channels/builtin/tui-ws-session.js +90 -0
- package/dist/channels/builtin/webui-output-handler.d.ts +30 -0
- package/dist/channels/builtin/webui-output-handler.js +93 -0
- package/dist/channels/index.d.ts +5 -0
- package/dist/channels/index.js +3 -0
- package/dist/channels/interface.d.ts +148 -0
- package/dist/channels/interface.js +15 -0
- package/dist/channels/manager.d.ts +43 -0
- package/dist/channels/manager.js +156 -0
- package/dist/channels/message-queue.d.ts +36 -0
- package/dist/channels/message-queue.js +91 -0
- package/dist/channels/plugins/clawbot/clawbot-auth.d.ts +50 -0
- package/dist/channels/plugins/clawbot/clawbot-auth.js +235 -0
- package/dist/channels/plugins/clawbot/clawbot-channel.d.ts +76 -0
- package/dist/channels/plugins/clawbot/clawbot-channel.js +566 -0
- package/dist/channels/plugins/clawbot/clawbot-client.d.ts +180 -0
- package/dist/channels/plugins/clawbot/clawbot-client.js +312 -0
- package/dist/channels/plugins/clawbot/clawbot-config.d.ts +30 -0
- package/dist/channels/plugins/clawbot/clawbot-config.js +28 -0
- package/dist/channels/plugins/clawbot/clawbot-message-queue.d.ts +27 -0
- package/dist/channels/plugins/clawbot/clawbot-message-queue.js +114 -0
- package/dist/channels/plugins/clawbot/clawbot-session.d.ts +10 -0
- package/dist/channels/plugins/clawbot/clawbot-session.js +26 -0
- package/dist/channels/plugins/clawbot/index.d.ts +17 -0
- package/dist/channels/plugins/clawbot/index.js +58 -0
- package/dist/channels/plugins/feishu/feishu-channel.d.ts +57 -0
- package/dist/channels/plugins/feishu/feishu-channel.js +602 -0
- package/dist/channels/plugins/feishu/feishu-client.d.ts +23 -0
- package/dist/channels/plugins/feishu/feishu-client.js +86 -0
- package/dist/channels/plugins/feishu/feishu-config.d.ts +53 -0
- package/dist/channels/plugins/feishu/feishu-config.js +35 -0
- package/dist/channels/plugins/feishu/feishu-event.d.ts +102 -0
- package/dist/channels/plugins/feishu/feishu-event.js +257 -0
- package/dist/channels/plugins/feishu/feishu-log-suppressor.d.ts +7 -0
- package/dist/channels/plugins/feishu/feishu-log-suppressor.js +34 -0
- package/dist/channels/plugins/feishu/feishu-message-queue.d.ts +27 -0
- package/dist/channels/plugins/feishu/feishu-message-queue.js +112 -0
- package/dist/channels/plugins/feishu/feishu-send.d.ts +44 -0
- package/dist/channels/plugins/feishu/feishu-send.js +232 -0
- package/dist/channels/plugins/feishu/feishu-session.d.ts +44 -0
- package/dist/channels/plugins/feishu/feishu-session.js +84 -0
- package/dist/channels/plugins/feishu/feishu-streaming.d.ts +49 -0
- package/dist/channels/plugins/feishu/feishu-streaming.js +185 -0
- package/dist/channels/plugins/feishu/feishu-transport.d.ts +29 -0
- package/dist/channels/plugins/feishu/feishu-transport.js +99 -0
- package/dist/channels/plugins/feishu/index.d.ts +22 -0
- package/dist/channels/plugins/feishu/index.js +68 -0
- package/dist/cli/doctor.d.ts +20 -0
- package/dist/cli/doctor.js +317 -0
- package/dist/context/cache-strategy.d.ts +76 -0
- package/dist/context/cache-strategy.js +123 -0
- package/dist/context/composer.d.ts +77 -0
- package/dist/context/composer.js +318 -0
- package/dist/context/compressor.d.ts +218 -0
- package/dist/context/compressor.js +909 -0
- package/dist/context/index.d.ts +14 -0
- package/dist/context/index.js +8 -0
- package/dist/context/interface.d.ts +33 -0
- package/dist/context/interface.js +2 -0
- package/dist/context/manifest-defaults.d.ts +51 -0
- package/dist/context/manifest-defaults.js +133 -0
- package/dist/context/manifest-loader.d.ts +16 -0
- package/dist/context/manifest-loader.js +103 -0
- package/dist/context/manifest-types.d.ts +26 -0
- package/dist/context/manifest-types.js +2 -0
- package/dist/context/precision/analyzer.d.ts +31 -0
- package/dist/context/precision/analyzer.js +131 -0
- package/dist/context/precision/companion.d.ts +27 -0
- package/dist/context/precision/companion.js +144 -0
- package/dist/context/precision/default.d.ts +14 -0
- package/dist/context/precision/default.js +17 -0
- package/dist/context/precision/index.d.ts +9 -0
- package/dist/context/precision/index.js +7 -0
- package/dist/context/precision/keyword-pool.d.ts +27 -0
- package/dist/context/precision/keyword-pool.js +66 -0
- package/dist/context/precision/strategy.d.ts +18 -0
- package/dist/context/precision/strategy.js +51 -0
- package/dist/context/precision/summary-store.d.ts +18 -0
- package/dist/context/precision/summary-store.js +67 -0
- package/dist/context/precision/types.d.ts +23 -0
- package/dist/context/precision/types.js +2 -0
- package/dist/context/profiles.d.ts +45 -0
- package/dist/context/profiles.js +92 -0
- package/dist/context/prompt-builder.d.ts +76 -0
- package/dist/context/prompt-builder.js +133 -0
- package/dist/context/retriever.d.ts +44 -0
- package/dist/context/retriever.js +203 -0
- package/dist/context/router.d.ts +122 -0
- package/dist/context/router.js +291 -0
- package/dist/context/section-resolver.d.ts +38 -0
- package/dist/context/section-resolver.js +398 -0
- package/dist/context/tokenizer.d.ts +23 -0
- package/dist/context/tokenizer.js +78 -0
- package/dist/dependency/analyzer.d.ts +33 -0
- package/dist/dependency/analyzer.js +242 -0
- package/dist/dependency/data-flow-tracker.d.ts +12 -0
- package/dist/dependency/data-flow-tracker.js +97 -0
- package/dist/dependency/function-parser.d.ts +34 -0
- package/dist/dependency/function-parser.js +295 -0
- package/dist/dependency/index.d.ts +14 -0
- package/dist/dependency/index.js +20 -0
- package/dist/dependency/parser.d.ts +10 -0
- package/dist/dependency/parser.js +93 -0
- package/dist/dependency/types.d.ts +57 -0
- package/dist/dependency/types.js +2 -0
- package/dist/env/env-collector.d.ts +45 -0
- package/dist/env/env-collector.js +221 -0
- package/dist/env/index.d.ts +3 -0
- package/dist/env/index.js +2 -0
- package/dist/event-store.d.ts +27 -0
- package/dist/event-store.js +71 -0
- package/dist/evolution/git-manager.d.ts +46 -0
- package/dist/evolution/git-manager.js +276 -0
- package/dist/evolution/index.d.ts +3 -0
- package/dist/evolution/index.js +2 -0
- package/dist/flow/bootstrap-flow.d.ts +19 -0
- package/dist/flow/bootstrap-flow.js +72 -0
- package/dist/flow/flow-registry.d.ts +12 -0
- package/dist/flow/flow-registry.js +74 -0
- package/dist/flow/flow-tools.d.ts +8 -0
- package/dist/flow/flow-tools.js +106 -0
- package/dist/flow/index.d.ts +6 -0
- package/dist/flow/index.js +8 -0
- package/dist/flow/todo-flow.d.ts +25 -0
- package/dist/flow/todo-flow.js +107 -0
- package/dist/flow/types.d.ts +78 -0
- package/dist/flow/types.js +12 -0
- package/dist/flows/bootstrap.d.ts +18 -0
- package/dist/flows/bootstrap.js +119 -0
- package/dist/flows/index.d.ts +6 -0
- package/dist/flows/index.js +11 -0
- package/dist/flows/todo.d.ts +26 -0
- package/dist/flows/todo.js +174 -0
- package/dist/flows/tools.d.ts +8 -0
- package/dist/flows/tools.js +119 -0
- package/dist/flows/types.d.ts +27 -0
- package/dist/flows/types.js +10 -0
- package/dist/gateway/cli.d.ts +5 -0
- package/dist/gateway/cli.js +1027 -0
- package/dist/gateway/factory.d.ts +80 -0
- package/dist/gateway/factory.js +832 -0
- package/dist/gateway/guardian.d.ts +8 -0
- package/dist/gateway/guardian.js +30 -0
- package/dist/gateway/index.d.ts +3 -0
- package/dist/gateway/index.js +3 -0
- package/dist/gateway/server.d.ts +17 -0
- package/dist/gateway/server.js +96 -0
- package/dist/gateway/tui.d.ts +16 -0
- package/dist/gateway/tui.js +3273 -0
- package/dist/hot-reload/agent-watcher.d.ts +24 -0
- package/dist/hot-reload/agent-watcher.js +175 -0
- package/dist/hot-reload/bundle-watcher.d.ts +12 -0
- package/dist/hot-reload/bundle-watcher.js +35 -0
- package/dist/hot-reload/channel-watcher.d.ts +19 -0
- package/dist/hot-reload/channel-watcher.js +54 -0
- package/dist/hot-reload/command-watcher.d.ts +14 -0
- package/dist/hot-reload/command-watcher.js +54 -0
- package/dist/hot-reload/config-watcher.d.ts +20 -0
- package/dist/hot-reload/config-watcher.js +58 -0
- package/dist/hot-reload/index.d.ts +12 -0
- package/dist/hot-reload/index.js +12 -0
- package/dist/hot-reload/manager.d.ts +58 -0
- package/dist/hot-reload/manager.js +243 -0
- package/dist/hot-reload/manifest-watcher.d.ts +9 -0
- package/dist/hot-reload/manifest-watcher.js +42 -0
- package/dist/hot-reload/mcp-watcher.d.ts +18 -0
- package/dist/hot-reload/mcp-watcher.js +64 -0
- package/dist/hot-reload/model-catalog-watcher.d.ts +18 -0
- package/dist/hot-reload/model-catalog-watcher.js +62 -0
- package/dist/hot-reload/plugin-watcher.d.ts +20 -0
- package/dist/hot-reload/plugin-watcher.js +56 -0
- package/dist/hot-reload/prompt-watcher.d.ts +6 -0
- package/dist/hot-reload/prompt-watcher.js +38 -0
- package/dist/hot-reload/provider-watcher.d.ts +16 -0
- package/dist/hot-reload/provider-watcher.js +45 -0
- package/dist/hot-reload/skill-watcher.d.ts +19 -0
- package/dist/hot-reload/skill-watcher.js +82 -0
- package/dist/hot-reload/tool-watcher.d.ts +16 -0
- package/dist/hot-reload/tool-watcher.js +168 -0
- package/dist/hot-reload/workflow-watcher.d.ts +19 -0
- package/dist/hot-reload/workflow-watcher.js +84 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +6 -0
- package/dist/knowledge/fts5-retriever.d.ts +30 -0
- package/dist/knowledge/fts5-retriever.js +223 -0
- package/dist/knowledge/index.d.ts +11 -0
- package/dist/knowledge/index.js +14 -0
- package/dist/knowledge/indexer.d.ts +41 -0
- package/dist/knowledge/indexer.js +186 -0
- package/dist/knowledge/query-preprocessor.d.ts +13 -0
- package/dist/knowledge/query-preprocessor.js +63 -0
- package/dist/knowledge/retriever.d.ts +45 -0
- package/dist/knowledge/retriever.js +9 -0
- package/dist/knowledge/store.d.ts +27 -0
- package/dist/knowledge/store.js +61 -0
- package/dist/knowledge/structured-store.d.ts +78 -0
- package/dist/knowledge/structured-store.js +280 -0
- package/dist/knowledge/structured-tools.d.ts +12 -0
- package/dist/knowledge/structured-tools.js +151 -0
- package/dist/knowledge/tools.d.ts +20 -0
- package/dist/knowledge/tools.js +238 -0
- package/dist/knowledge/watcher.d.ts +28 -0
- package/dist/knowledge/watcher.js +113 -0
- package/dist/lifecycle/index.d.ts +12 -0
- package/dist/lifecycle/index.js +14 -0
- package/dist/lifecycle/interface.d.ts +94 -0
- package/dist/lifecycle/interface.js +2 -0
- package/dist/lifecycle/local-model.d.ts +62 -0
- package/dist/lifecycle/local-model.js +331 -0
- package/dist/lifecycle/manager.d.ts +70 -0
- package/dist/lifecycle/manager.js +374 -0
- package/dist/lifecycle/supervisor.d.ts +89 -0
- package/dist/lifecycle/supervisor.js +277 -0
- package/dist/lifecycle-integration-test.d.ts +2 -0
- package/dist/lifecycle-integration-test.js +72 -0
- package/dist/local-model/download-manager.d.ts +59 -0
- package/dist/local-model/download-manager.js +517 -0
- package/dist/local-model/index.d.ts +109 -0
- package/dist/local-model/index.js +233 -0
- package/dist/local-model/llamacpp-provider.d.ts +95 -0
- package/dist/local-model/llamacpp-provider.js +379 -0
- package/dist/local-model/model-bridge.d.ts +48 -0
- package/dist/local-model/model-bridge.js +256 -0
- package/dist/local-model/model-registry.d.ts +47 -0
- package/dist/local-model/model-registry.js +188 -0
- package/dist/local-model/types.d.ts +49 -0
- package/dist/local-model/types.js +2 -0
- package/dist/logging/index.d.ts +3 -0
- package/dist/logging/index.js +3 -0
- package/dist/logging/logger.d.ts +56 -0
- package/dist/logging/logger.js +94 -0
- package/dist/machine/flows/bootstrap.d.ts +18 -0
- package/dist/machine/flows/bootstrap.js +119 -0
- package/dist/machine/flows/index.d.ts +6 -0
- package/dist/machine/flows/index.js +11 -0
- package/dist/machine/flows/spec.d.ts +17 -0
- package/dist/machine/flows/spec.js +176 -0
- package/dist/machine/flows/todo.d.ts +26 -0
- package/dist/machine/flows/todo.js +175 -0
- package/dist/machine/flows/tools.d.ts +8 -0
- package/dist/machine/flows/tools.js +119 -0
- package/dist/machine/flows/types.d.ts +33 -0
- package/dist/machine/flows/types.js +10 -0
- package/dist/machine/index.d.ts +8 -0
- package/dist/machine/index.js +9 -0
- package/dist/machine/registry.d.ts +34 -0
- package/dist/machine/registry.js +98 -0
- package/dist/machine/runner.d.ts +41 -0
- package/dist/machine/runner.js +177 -0
- package/dist/machine/types.d.ts +121 -0
- package/dist/machine/types.js +9 -0
- package/dist/mcp/bridge.d.ts +33 -0
- package/dist/mcp/bridge.js +99 -0
- package/dist/mcp/client.d.ts +37 -0
- package/dist/mcp/client.js +161 -0
- package/dist/mcp/config.d.ts +15 -0
- package/dist/mcp/config.js +85 -0
- package/dist/mcp/index.d.ts +7 -0
- package/dist/mcp/index.js +7 -0
- package/dist/mcp/install-manager.d.ts +31 -0
- package/dist/mcp/install-manager.js +158 -0
- package/dist/mcp/lifecycle.d.ts +41 -0
- package/dist/mcp/lifecycle.js +175 -0
- package/dist/mcp/process-transport.d.ts +21 -0
- package/dist/mcp/process-transport.js +59 -0
- package/dist/mcp/side-effect.d.ts +5 -0
- package/dist/mcp/side-effect.js +21 -0
- package/dist/mcp/system.d.ts +95 -0
- package/dist/mcp/system.js +279 -0
- package/dist/memory/companion-session.d.ts +22 -0
- package/dist/memory/companion-session.js +77 -0
- package/dist/memory/compression-boundary.d.ts +20 -0
- package/dist/memory/compression-boundary.js +40 -0
- package/dist/memory/conversation.d.ts +34 -0
- package/dist/memory/conversation.js +107 -0
- package/dist/memory/events.d.ts +42 -0
- package/dist/memory/events.js +56 -0
- package/dist/memory/index.d.ts +7 -0
- package/dist/memory/index.js +6 -0
- package/dist/memory/memory-store.d.ts +11 -0
- package/dist/memory/memory-store.js +51 -0
- package/dist/memory/session-allowlist.d.ts +11 -0
- package/dist/memory/session-allowlist.js +50 -0
- package/dist/memory/session.d.ts +48 -0
- package/dist/memory/session.js +275 -0
- package/dist/memory/stats.d.ts +23 -0
- package/dist/memory/stats.js +59 -0
- package/dist/memory/summary.d.ts +7 -0
- package/dist/memory/summary.js +23 -0
- package/dist/multimodal/index.d.ts +66 -0
- package/dist/multimodal/index.js +210 -0
- package/dist/orchestrator/index.d.ts +5 -0
- package/dist/orchestrator/index.js +4 -0
- package/dist/orchestrator/loop.d.ts +331 -0
- package/dist/orchestrator/loop.js +2443 -0
- package/dist/orchestrator/plan-store.d.ts +81 -0
- package/dist/orchestrator/plan-store.js +167 -0
- package/dist/orchestrator/planner.d.ts +20 -0
- package/dist/orchestrator/planner.js +34 -0
- package/dist/parser/index.d.ts +2 -0
- package/dist/parser/index.js +2 -0
- package/dist/parser/router.d.ts +30 -0
- package/dist/parser/router.js +61 -0
- package/dist/plugins/api.d.ts +39 -0
- package/dist/plugins/api.js +85 -0
- package/dist/plugins/define.d.ts +27 -0
- package/dist/plugins/define.js +32 -0
- package/dist/plugins/index.d.ts +9 -0
- package/dist/plugins/index.js +5 -0
- package/dist/plugins/loader.d.ts +39 -0
- package/dist/plugins/loader.js +128 -0
- package/dist/plugins/manager.d.ts +61 -0
- package/dist/plugins/manager.js +257 -0
- package/dist/plugins/types.d.ts +82 -0
- package/dist/plugins/types.js +2 -0
- package/dist/prompts/agents/code-reviewer.md +16 -0
- package/dist/prompts/agents/security-auditor.md +17 -0
- package/dist/prompts/agents/test-writer.md +15 -0
- package/dist/prompts/attention/attention.md +12 -0
- package/dist/prompts/environment/environment.md +18 -0
- package/dist/prompts/environment/feishu.md +107 -0
- package/dist/prompts/flows/bootstrap-confirm.md +14 -0
- package/dist/prompts/flows/bootstrap-identity.md +11 -0
- package/dist/prompts/flows/bootstrap-soul.md +19 -0
- package/dist/prompts/flows/bootstrap-user.md +11 -0
- package/dist/prompts/flows/spec-checklist.md +27 -0
- package/dist/prompts/flows/spec-define.md +64 -0
- package/dist/prompts/flows/spec-executing-checklist.md +15 -0
- package/dist/prompts/flows/spec-executing-tasks.md +15 -0
- package/dist/prompts/flows/spec-spec.md +51 -0
- package/dist/prompts/flows/spec-tasks.md +32 -0
- package/dist/prompts/flows/todo-execution.md +7 -0
- package/dist/prompts/flows/todo-planning.md +18 -0
- package/dist/prompts/framework/architecture.md +131 -0
- package/dist/prompts/identity/identity.md +2 -0
- package/dist/prompts/loader.d.ts +24 -0
- package/dist/prompts/loader.js +102 -0
- package/dist/prompts/loader.ts +119 -0
- package/dist/prompts/orchestration/summary.md +14 -0
- package/dist/prompts/persona/BOOTSTRAP.md +5 -0
- package/dist/prompts/persona/IDENTITY.md +16 -0
- package/dist/prompts/persona/PartnerMemory.md +5 -0
- package/dist/prompts/persona/PartnerSoul.md +7 -0
- package/dist/prompts/persona/SOUL.md +30 -0
- package/dist/prompts/persona/USER.md +16 -0
- package/dist/prompts/precise/analyze.md +23 -0
- package/dist/prompts/precise/persona.md +18 -0
- package/dist/prompts/safety/coding-standards.md +5 -0
- package/dist/prompts/safety/safety.md +4 -0
- package/dist/prompts/skills/code-review.md +4 -0
- package/dist/prompts/skills/debug.md +7 -0
- package/dist/prompts/skills/framework-reference.md +131 -0
- package/dist/prompts/skills/refactor.md +6 -0
- package/dist/prompts/summary.md +22 -0
- package/dist/prompts/tools/framework-capabilities.md +241 -0
- package/dist/prompts/tools/tool-rules.md +15 -0
- package/dist/provider/anthropic.d.ts +62 -0
- package/dist/provider/anthropic.js +361 -0
- package/dist/provider/catalog.d.ts +58 -0
- package/dist/provider/catalog.js +97 -0
- package/dist/provider/compatible.d.ts +89 -0
- package/dist/provider/compatible.js +328 -0
- package/dist/provider/config.d.ts +23 -0
- package/dist/provider/config.js +158 -0
- package/dist/provider/deepseek.d.ts +25 -0
- package/dist/provider/deepseek.js +37 -0
- package/dist/provider/fallback.d.ts +51 -0
- package/dist/provider/fallback.js +113 -0
- package/dist/provider/gemini.d.ts +27 -0
- package/dist/provider/gemini.js +170 -0
- package/dist/provider/index.d.ts +36 -0
- package/dist/provider/index.js +42 -0
- package/dist/provider/interface.d.ts +62 -0
- package/dist/provider/interface.js +2 -0
- package/dist/provider/local-config.d.ts +37 -0
- package/dist/provider/local-config.js +146 -0
- package/dist/provider/local.d.ts +45 -0
- package/dist/provider/local.js +248 -0
- package/dist/provider/manager.d.ts +67 -0
- package/dist/provider/manager.js +355 -0
- package/dist/provider/mimo.d.ts +19 -0
- package/dist/provider/mimo.js +30 -0
- package/dist/provider/minimax.d.ts +22 -0
- package/dist/provider/minimax.js +33 -0
- package/dist/provider/model-catalog-loader.d.ts +42 -0
- package/dist/provider/model-catalog-loader.js +89 -0
- package/dist/provider/model-channel-registry.d.ts +130 -0
- package/dist/provider/model-channel-registry.js +488 -0
- package/dist/provider/model-router.d.ts +60 -0
- package/dist/provider/model-router.js +87 -0
- package/dist/provider/openai.d.ts +54 -0
- package/dist/provider/openai.js +274 -0
- package/dist/provider/qwen.d.ts +19 -0
- package/dist/provider/qwen.js +30 -0
- package/dist/provider/resilient.d.ts +46 -0
- package/dist/provider/resilient.js +181 -0
- package/dist/provider/retry.d.ts +16 -0
- package/dist/provider/retry.js +78 -0
- package/dist/provider/router.d.ts +68 -0
- package/dist/provider/router.js +145 -0
- package/dist/provider/tool-args-recovery.d.ts +36 -0
- package/dist/provider/tool-args-recovery.js +91 -0
- package/dist/provider/user-id.d.ts +13 -0
- package/dist/provider/user-id.js +53 -0
- package/dist/provider/zhipu.d.ts +19 -0
- package/dist/provider/zhipu.js +32 -0
- package/dist/registry/agent.registry.d.ts +57 -0
- package/dist/registry/agent.registry.js +224 -0
- package/dist/registry/base.d.ts +54 -0
- package/dist/registry/base.js +99 -0
- package/dist/registry/channel.registry.d.ts +53 -0
- package/dist/registry/channel.registry.js +87 -0
- package/dist/registry/index.d.ts +9 -0
- package/dist/registry/index.js +10 -0
- package/dist/registry/mcp.registry.d.ts +2 -0
- package/dist/registry/mcp.registry.js +2 -0
- package/dist/registry/plugin.registry.d.ts +33 -0
- package/dist/registry/plugin.registry.js +66 -0
- package/dist/registry/provider.registry.d.ts +51 -0
- package/dist/registry/provider.registry.js +104 -0
- package/dist/registry/skill.registry.d.ts +33 -0
- package/dist/registry/skill.registry.js +95 -0
- package/dist/registry/tool.registry.d.ts +68 -0
- package/dist/registry/tool.registry.js +185 -0
- package/dist/repair/loop-guard.d.ts +98 -0
- package/dist/repair/loop-guard.js +217 -0
- package/dist/repair/scavenge.d.ts +19 -0
- package/dist/repair/scavenge.js +81 -0
- package/dist/repair/storm.d.ts +7 -0
- package/dist/repair/storm.js +7 -0
- package/dist/rollback/index.d.ts +5 -0
- package/dist/rollback/index.js +4 -0
- package/dist/rollback/rollback-tool.d.ts +13 -0
- package/dist/rollback/rollback-tool.js +167 -0
- package/dist/rollback/turn-recorder.d.ts +37 -0
- package/dist/rollback/turn-recorder.js +183 -0
- package/dist/rollback/turn-store.d.ts +29 -0
- package/dist/rollback/turn-store.js +114 -0
- package/dist/rollback/types.d.ts +51 -0
- package/dist/rollback/types.js +9 -0
- package/dist/runtime/config-center.d.ts +92 -0
- package/dist/runtime/config-center.js +467 -0
- package/dist/runtime/config-schema.d.ts +201 -0
- package/dist/runtime/config-schema.js +2 -0
- package/dist/runtime/defaults.d.ts +3 -0
- package/dist/runtime/defaults.js +146 -0
- package/dist/schedule/cron.d.ts +24 -0
- package/dist/schedule/cron.js +145 -0
- package/dist/schedule/index.d.ts +6 -0
- package/dist/schedule/index.js +4 -0
- package/dist/schedule/persistence.d.ts +33 -0
- package/dist/schedule/persistence.js +106 -0
- package/dist/schedule/scheduler.d.ts +85 -0
- package/dist/schedule/scheduler.js +630 -0
- package/dist/schedule/types.d.ts +185 -0
- package/dist/schedule/types.js +2 -0
- package/dist/setup/config.d.ts +189 -0
- package/dist/setup/config.js +253 -0
- package/dist/setup/index.d.ts +3 -0
- package/dist/setup/index.js +3 -0
- package/dist/setup/model-defaults.d.ts +13 -0
- package/dist/setup/model-defaults.js +87 -0
- package/dist/setup/persona-bootstrap.d.ts +42 -0
- package/dist/setup/persona-bootstrap.js +379 -0
- package/dist/setup/wizard.d.ts +32 -0
- package/dist/setup/wizard.js +384 -0
- package/dist/skills/index.d.ts +4 -0
- package/dist/skills/index.js +4 -0
- package/dist/skills/loader.d.ts +12 -0
- package/dist/skills/loader.js +83 -0
- package/dist/skills/registry.d.ts +2 -0
- package/dist/skills/registry.js +2 -0
- package/dist/skills/skill-tool.d.ts +20 -0
- package/dist/skills/skill-tool.js +49 -0
- package/dist/tools/archive.d.ts +17 -0
- package/dist/tools/archive.js +131 -0
- package/dist/tools/ask-user.d.ts +9 -0
- package/dist/tools/ask-user.js +62 -0
- package/dist/tools/background-registry.d.ts +45 -0
- package/dist/tools/background-registry.js +164 -0
- package/dist/tools/bash.d.ts +56 -0
- package/dist/tools/bash.js +391 -0
- package/dist/tools/bundle-registry.d.ts +42 -0
- package/dist/tools/bundle-registry.js +239 -0
- package/dist/tools/bundle-tools.d.ts +11 -0
- package/dist/tools/bundle-tools.js +168 -0
- package/dist/tools/channel-info.d.ts +5 -0
- package/dist/tools/channel-info.js +38 -0
- package/dist/tools/compression.d.ts +7 -0
- package/dist/tools/compression.js +21 -0
- package/dist/tools/config.d.ts +23 -0
- package/dist/tools/config.js +255 -0
- package/dist/tools/db-query.d.ts +12 -0
- package/dist/tools/db-query.js +107 -0
- package/dist/tools/diagnostics.d.ts +30 -0
- package/dist/tools/diagnostics.js +111 -0
- package/dist/tools/diff-channel.d.ts +9 -0
- package/dist/tools/diff-channel.js +17 -0
- package/dist/tools/diff-files.d.ts +17 -0
- package/dist/tools/diff-files.js +88 -0
- package/dist/tools/disk-usage.d.ts +34 -0
- package/dist/tools/disk-usage.js +258 -0
- package/dist/tools/edit.d.ts +30 -0
- package/dist/tools/edit.js +235 -0
- package/dist/tools/executor.d.ts +32 -0
- package/dist/tools/executor.js +66 -0
- package/dist/tools/file-tracker.d.ts +20 -0
- package/dist/tools/file-tracker.js +44 -0
- package/dist/tools/filtered-registry.d.ts +29 -0
- package/dist/tools/filtered-registry.js +50 -0
- package/dist/tools/flow.d.ts +10 -0
- package/dist/tools/flow.js +180 -0
- package/dist/tools/git-tool.d.ts +24 -0
- package/dist/tools/git-tool.js +113 -0
- package/dist/tools/glob.d.ts +29 -0
- package/dist/tools/glob.js +152 -0
- package/dist/tools/grep.d.ts +14 -0
- package/dist/tools/grep.js +325 -0
- package/dist/tools/http-request.d.ts +14 -0
- package/dist/tools/http-request.js +126 -0
- package/dist/tools/index.d.ts +43 -0
- package/dist/tools/index.js +76 -0
- package/dist/tools/injection-filter.d.ts +6 -0
- package/dist/tools/injection-filter.js +71 -0
- package/dist/tools/insert.d.ts +13 -0
- package/dist/tools/insert.js +61 -0
- package/dist/tools/interface.d.ts +30 -0
- package/dist/tools/interface.js +2 -0
- package/dist/tools/json-edit.d.ts +15 -0
- package/dist/tools/json-edit.js +122 -0
- package/dist/tools/multi-edit.d.ts +9 -0
- package/dist/tools/multi-edit.js +146 -0
- package/dist/tools/path-sandbox.d.ts +14 -0
- package/dist/tools/path-sandbox.js +60 -0
- package/dist/tools/process-tools.d.ts +15 -0
- package/dist/tools/process-tools.js +95 -0
- package/dist/tools/python-bridge/bridge.d.ts +24 -0
- package/dist/tools/python-bridge/bridge.js +39 -0
- package/dist/tools/python-bridge/executor.d.ts +6 -0
- package/dist/tools/python-bridge/executor.js +69 -0
- package/dist/tools/python-bridge/index.d.ts +5 -0
- package/dist/tools/python-bridge/index.js +4 -0
- package/dist/tools/python-bridge/parser.d.ts +21 -0
- package/dist/tools/python-bridge/parser.js +258 -0
- package/dist/tools/read.d.ts +16 -0
- package/dist/tools/read.js +276 -0
- package/dist/tools/registry.d.ts +2 -0
- package/dist/tools/registry.js +2 -0
- package/dist/tools/restart.d.ts +10 -0
- package/dist/tools/restart.js +46 -0
- package/dist/tools/result-buffer.d.ts +66 -0
- package/dist/tools/result-buffer.js +146 -0
- package/dist/tools/runtime-control.d.ts +163 -0
- package/dist/tools/runtime-control.js +1780 -0
- package/dist/tools/symbol-references.d.ts +5 -0
- package/dist/tools/symbol-references.js +331 -0
- package/dist/tools/system-info.d.ts +3 -0
- package/dist/tools/system-info.js +55 -0
- package/dist/tools/write.d.ts +18 -0
- package/dist/tools/write.js +118 -0
- package/dist/tools/xref/index.d.ts +25 -0
- package/dist/tools/xref/index.js +25 -0
- package/dist/tools/xref/manager.d.ts +85 -0
- package/dist/tools/xref/manager.js +948 -0
- package/dist/tools/xref/parser.d.ts +34 -0
- package/dist/tools/xref/parser.js +64 -0
- package/dist/tools/xref/regex-parser.d.ts +26 -0
- package/dist/tools/xref/regex-parser.js +446 -0
- package/dist/tools/xref/schema.d.ts +104 -0
- package/dist/tools/xref/schema.js +68 -0
- package/dist/tools/xref/ts-parser.d.ts +20 -0
- package/dist/tools/xref/ts-parser.js +403 -0
- package/dist/tools/xref/xref-build.d.ts +20 -0
- package/dist/tools/xref/xref-build.js +128 -0
- package/dist/tools/xref/xref-graph.d.ts +24 -0
- package/dist/tools/xref/xref-graph.js +88 -0
- package/dist/tools/xref/xref-query.d.ts +30 -0
- package/dist/tools/xref/xref-query.js +123 -0
- package/dist/types.d.ts +217 -0
- package/dist/types.js +2 -0
- package/dist/ui/assistant-message.d.ts +7 -0
- package/dist/ui/assistant-message.js +18 -0
- package/dist/ui/chat-log.d.ts +52 -0
- package/dist/ui/chat-log.js +246 -0
- package/dist/ui/command-registry.d.ts +73 -0
- package/dist/ui/command-registry.js +838 -0
- package/dist/ui/diff-component.d.ts +14 -0
- package/dist/ui/diff-component.js +42 -0
- package/dist/ui/hyperlink-markdown.d.ts +10 -0
- package/dist/ui/hyperlink-markdown.js +21 -0
- package/dist/ui/markdown-message.d.ts +10 -0
- package/dist/ui/markdown-message.js +16 -0
- package/dist/ui/osc8-hyperlinks.d.ts +4 -0
- package/dist/ui/osc8-hyperlinks.js +142 -0
- package/dist/ui/pi-tui-editor.d.ts +35 -0
- package/dist/ui/pi-tui-editor.js +79 -0
- package/dist/ui/slash-commands.d.ts +16 -0
- package/dist/ui/slash-commands.js +29 -0
- package/dist/ui/slash-panel.d.ts +54 -0
- package/dist/ui/slash-panel.js +199 -0
- package/dist/ui/theme.d.ts +120 -0
- package/dist/ui/theme.js +154 -0
- package/dist/ui/tool-display.d.ts +13 -0
- package/dist/ui/tool-display.js +85 -0
- package/dist/ui/tool-execution.d.ts +22 -0
- package/dist/ui/tool-execution.js +87 -0
- package/dist/ui/tui-formatters.d.ts +2 -0
- package/dist/ui/tui-formatters.js +145 -0
- package/dist/ui/user-message.d.ts +5 -0
- package/dist/ui/user-message.js +11 -0
- package/dist/update/check.d.ts +8 -0
- package/dist/update/check.js +28 -0
- package/dist/update/config.d.ts +6 -0
- package/dist/update/config.js +18 -0
- package/dist/update/download.d.ts +3 -0
- package/dist/update/download.js +27 -0
- package/dist/update/index.d.ts +6 -0
- package/dist/update/index.js +5 -0
- package/dist/update/install.d.ts +3 -0
- package/dist/update/install.js +33 -0
- package/dist/update/types.d.ts +16 -0
- package/dist/update/types.js +2 -0
- package/dist/utils/diff.d.ts +9 -0
- package/dist/utils/diff.js +45 -0
- package/dist/utils/misc.d.ts +12 -0
- package/dist/utils/misc.js +34 -0
- package/dist/world-engine/agent.d.ts +41 -0
- package/dist/world-engine/agent.js +385 -0
- package/dist/world-engine/index.d.ts +45 -0
- package/dist/world-engine/index.js +160 -0
- package/dist/world-engine/sim.d.ts +14 -0
- package/dist/world-engine/sim.js +120 -0
- package/dist/world-engine/store.d.ts +110 -0
- package/dist/world-engine/store.js +519 -0
- package/dist/world-engine/ticker.d.ts +37 -0
- package/dist/world-engine/ticker.js +214 -0
- package/dist/world-engine/tools.d.ts +6 -0
- package/dist/world-engine/tools.js +380 -0
- package/dist/world-engine/types.d.ts +202 -0
- package/dist/world-engine/types.js +56 -0
- package/docs/api.md +180 -0
- package/docs/architecture.md +206 -0
- package/docs/diagnostics/2026-06-08-config-prompt-guidance.md +67 -0
- package/docs/superpowers/plans/2026-06-08-global-bootstrap-mode.md +89 -0
- package/docs/superpowers/specs/2026-06-08-global-bootstrap-mode-design.md +174 -0
- package/docs/user-guide.md +226 -0
- package/package.json +63 -0
- package/plugins/example-greeter/index.js +55 -0
- package/plugins/example-greeter/plugin.json +8 -0
- package/pnpm-workspace.yaml +5 -0
- package/provider_arch.md +179 -0
- package/start-webui.sh +27 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/webui-channel-design.md +789 -0
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
import { loadPrompt, renderPrompt } from '../prompts/loader.js';
|
|
2
|
+
import { loadProjectContext } from './prompt-builder.js';
|
|
3
|
+
import { Retriever } from './retriever.js';
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { getGlobalPersonaDir } from '../setup/persona-bootstrap.js';
|
|
7
|
+
/** 查找旁路Agent对指定 section 的注入 */
|
|
8
|
+
function findBypassInjection(sectionName, injections) {
|
|
9
|
+
if (!injections?.length)
|
|
10
|
+
return undefined;
|
|
11
|
+
return injections.find(ij => ij.section === sectionName);
|
|
12
|
+
}
|
|
13
|
+
export async function resolveSection(sec, ctx) {
|
|
14
|
+
// Router 的 beforeSection 钩子:在正常解析前介入
|
|
15
|
+
if (ctx.router.beforeSection) {
|
|
16
|
+
const preempted = await ctx.router.beforeSection(sec, ctx);
|
|
17
|
+
if (preempted !== undefined) {
|
|
18
|
+
return preempted || undefined; // null → undefined(跳过此 section)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
// 旁路Agent 注入:replace 模式时替换整个 section 内容
|
|
22
|
+
const bypassInj = findBypassInjection(sec.name, ctx.bypassInjections);
|
|
23
|
+
if (bypassInj?.mode === 'replace') {
|
|
24
|
+
return bypassInj.content;
|
|
25
|
+
}
|
|
26
|
+
// 正常解析
|
|
27
|
+
let resolved;
|
|
28
|
+
switch (sec.type) {
|
|
29
|
+
case 'static':
|
|
30
|
+
resolved = resolveStatic(sec, ctx);
|
|
31
|
+
break;
|
|
32
|
+
case 'template':
|
|
33
|
+
resolved = resolveTemplate(sec, ctx);
|
|
34
|
+
break;
|
|
35
|
+
case 'runtime':
|
|
36
|
+
resolved = await resolveRuntime(sec, ctx);
|
|
37
|
+
break;
|
|
38
|
+
case 'retrieval':
|
|
39
|
+
resolved = await resolveRetrieval(sec, ctx);
|
|
40
|
+
break;
|
|
41
|
+
case 'conditional':
|
|
42
|
+
resolved = resolveConditional(sec, ctx);
|
|
43
|
+
break;
|
|
44
|
+
default: resolved = undefined;
|
|
45
|
+
}
|
|
46
|
+
// 旁路Agent 注入:append 模式时追加到正常解析结果末尾
|
|
47
|
+
if (bypassInj?.mode === 'append' && bypassInj.content) {
|
|
48
|
+
resolved = resolved ? `${resolved}\n\n${bypassInj.content}` : bypassInj.content;
|
|
49
|
+
}
|
|
50
|
+
return resolved;
|
|
51
|
+
}
|
|
52
|
+
// --- Static ---
|
|
53
|
+
function resolveStatic(sec, ctx) {
|
|
54
|
+
const router = ctx?.router;
|
|
55
|
+
if (sec.name === 'persona_soul') {
|
|
56
|
+
// precise_mode 保持原有 activeConditions 逻辑
|
|
57
|
+
if (ctx?.activeConditions?.has('precise_mode'))
|
|
58
|
+
return undefined;
|
|
59
|
+
// Router 定义了替代 persona 来源 → 加载替代内容,跳过默认 SOUL
|
|
60
|
+
// 注:resolve 字段用于 runtime section(异步),static section 只用 source + append。
|
|
61
|
+
// 如需完全异步接管 persona,应使用 beforeSection 钩子。
|
|
62
|
+
const personaOverride = router?.sourceOverrides['persona_soul'];
|
|
63
|
+
if (personaOverride) {
|
|
64
|
+
try {
|
|
65
|
+
const effectiveSource = personaOverride.source ?? sec.source;
|
|
66
|
+
let content = loadPrompt(effectiveSource.replace(/^prompts\//, ''));
|
|
67
|
+
if (personaOverride.append) {
|
|
68
|
+
content = content + '\n\n' + personaOverride.append;
|
|
69
|
+
}
|
|
70
|
+
return content;
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return buildSoulSection() || undefined;
|
|
77
|
+
}
|
|
78
|
+
// Router 指定跳过的 section
|
|
79
|
+
if (router?.skipSections.includes(sec.name)) {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
return loadPrompt(sec.source.replace(/^prompts\//, ''));
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// --- Template ---
|
|
90
|
+
function resolveTemplate(sec, ctx) {
|
|
91
|
+
const vars = {};
|
|
92
|
+
if (sec.templateVars) {
|
|
93
|
+
for (const v of sec.templateVars) {
|
|
94
|
+
if (v === 'cwd')
|
|
95
|
+
vars.cwd = ctx.cwd;
|
|
96
|
+
if (v === 'toolNames') {
|
|
97
|
+
vars.toolNames = ctx.tools.map(t => t.name).join(', ') || '(无)';
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
try {
|
|
102
|
+
return renderPrompt(loadPrompt(sec.source.replace(/^prompts\//, '')), vars);
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// --- Runtime ---
|
|
109
|
+
//
|
|
110
|
+
// 运行时 Section 解析器。
|
|
111
|
+
//
|
|
112
|
+
// Zone 布局(详见 manifest-defaults.ts):
|
|
113
|
+
// Zone 1 (Anchor) — 身份/环境/注册表/记忆(稳定,享受前缀缓存)
|
|
114
|
+
// Zone 2 (Manifest) — 辅助索引区(默认关闭)
|
|
115
|
+
// Zone 3 (History) — 摘要/项目上下文/历史消息(持续增长,压缩器管理)
|
|
116
|
+
// Zone 4 (Context) — 知识库检索(可独立开关)
|
|
117
|
+
// Zone 5 (Live) — Flow 注入/时间戳/用户输入(每轮变化,不缓存)
|
|
118
|
+
//
|
|
119
|
+
// 通用回退规则:runtime:xxx → 查找 ctx.sources.get('xxx'),若存在则取其内容。
|
|
120
|
+
async function resolveRuntime(sec, ctx) {
|
|
121
|
+
const src = sec.source;
|
|
122
|
+
if (src === 'runtime:plan') {
|
|
123
|
+
return ctx.currentPlan ? `[Current Plan]\n${ctx.currentPlan}` : undefined;
|
|
124
|
+
}
|
|
125
|
+
if (src === 'runtime:impact') {
|
|
126
|
+
return ctx.impactInfo ? `[Dependency Impact Analysis]\n${ctx.impactInfo}` : undefined;
|
|
127
|
+
}
|
|
128
|
+
if (src === 'runtime:summary') {
|
|
129
|
+
return ctx.historySummary ? `[Context Summary]\n${ctx.historySummary}` : undefined;
|
|
130
|
+
}
|
|
131
|
+
if (src === 'runtime:timestamp') {
|
|
132
|
+
// 时间戳的条件注入由 Router.beforeSection 控制(如 CompanionRouter 的概率注入)。
|
|
133
|
+
// 此处无条件生成时间戳文本——如果 beforeSection 返回了 null,此代码不会执行。
|
|
134
|
+
// # currentDate 是系统元数据标记(非用户输入),模型训练数据中识别为背景信息
|
|
135
|
+
const [datePart, timePart] = ctx.timestamp.split(' ');
|
|
136
|
+
const dateSlash = datePart.replace(/-/g, '/');
|
|
137
|
+
return `# currentDate\nToday is ${dateSlash}, ${timePart}.`;
|
|
138
|
+
}
|
|
139
|
+
if (src === 'runtime:userInput') {
|
|
140
|
+
return ctx.userInput || undefined;
|
|
141
|
+
}
|
|
142
|
+
if (src === 'runtime:env') {
|
|
143
|
+
const envSource = ctx.sources?.get('env-info');
|
|
144
|
+
if (envSource?.getContent) {
|
|
145
|
+
const content = await envSource.getContent();
|
|
146
|
+
return content || undefined;
|
|
147
|
+
}
|
|
148
|
+
return undefined;
|
|
149
|
+
}
|
|
150
|
+
// Router(或 profile)指定跳过的 runtime source
|
|
151
|
+
const runtimeKey = src.startsWith('runtime:') ? src.slice('runtime:'.length) : '';
|
|
152
|
+
const skipSources = ctx.router?.skipRuntimeSources ?? ctx.profile.skipRuntimeSources;
|
|
153
|
+
if (skipSources.includes(runtimeKey)) {
|
|
154
|
+
return undefined;
|
|
155
|
+
}
|
|
156
|
+
if (src === 'runtime:skills' || src === 'runtime:agents' || src === 'runtime:mcp') {
|
|
157
|
+
const kind = src.replace('runtime:', '');
|
|
158
|
+
return buildSourcePartsFromCtx(kind, ctx);
|
|
159
|
+
}
|
|
160
|
+
// 会话临时 MCP:仅收集 cacheability === 'live' 的 mcp- 源,用于 Zone 5 热插拔展示
|
|
161
|
+
if (src === 'runtime:mcp_live') {
|
|
162
|
+
return buildLiveMcpIndex(ctx);
|
|
163
|
+
}
|
|
164
|
+
// 会话临时工具:hot-reload 热添加的工具不进 Zone 2 tool_rules,而在 Zone 5 session_tools 展示
|
|
165
|
+
if (src === 'runtime:tools_live') {
|
|
166
|
+
return resolveContextSourceContent('session-tools', ctx);
|
|
167
|
+
}
|
|
168
|
+
// MCP 状态变更通知:从 ContextSource 读取并消费,注入后自动清空
|
|
169
|
+
if (src === 'runtime:mcp_status') {
|
|
170
|
+
return resolveContextSourceContent('mcp-status', ctx);
|
|
171
|
+
}
|
|
172
|
+
// 工具包索引(Zone 2):所有 bundle 的名称 + 简介
|
|
173
|
+
if (src === 'runtime:tool_bundles') {
|
|
174
|
+
return resolveContextSourceContent('tool-bundles', ctx);
|
|
175
|
+
}
|
|
176
|
+
// 模式注入(Zone 5):plan/spec 激活时注入提示词
|
|
177
|
+
// ── Flow 注入在 Zone 5(flow_injection),由 ContextSource 驱动 ──
|
|
178
|
+
// runtime:history 由 composer.ts assembleZone() 专门处理(展开为 Message[])。
|
|
179
|
+
// 此处的 handler 仅作为防护:如果未来 manifest 将 history section 从 Zone 3 移走,
|
|
180
|
+
// 或 composer 的硬编码拦截被移除,此处显式返回 undefined 而非静默丢失。
|
|
181
|
+
// 架构说明见 §0.5 原则③:所有 runtime source 应在 section-resolver 中有显式路由。
|
|
182
|
+
if (src === 'runtime:history') {
|
|
183
|
+
return undefined;
|
|
184
|
+
}
|
|
185
|
+
// Router(或 profile)指定了替代 memory 来源 → 路由到对应 ContextSource
|
|
186
|
+
if (src === 'runtime:memory') {
|
|
187
|
+
const memoryOverride = ctx.router?.sourceOverrides['memory'];
|
|
188
|
+
const altSourceName = memoryOverride?.source ?? ctx.profile.memorySource;
|
|
189
|
+
if (altSourceName) {
|
|
190
|
+
const altSource = ctx.sources?.get(altSourceName);
|
|
191
|
+
if (altSource?.getContent) {
|
|
192
|
+
const content = await altSource.getContent();
|
|
193
|
+
return content || undefined;
|
|
194
|
+
}
|
|
195
|
+
return undefined;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
if (src.startsWith('runtime:')) {
|
|
199
|
+
const key = src.slice('runtime:'.length);
|
|
200
|
+
const source = ctx.sources?.get(key);
|
|
201
|
+
if (source?.getContent) {
|
|
202
|
+
const content = await source.getContent();
|
|
203
|
+
return content || undefined;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return undefined;
|
|
207
|
+
}
|
|
208
|
+
// --- Retrieval ---
|
|
209
|
+
async function resolveRetrieval(sec, ctx) {
|
|
210
|
+
const routerSkipSections = ctx.router?.skipSections ?? ctx.profile.skipSections;
|
|
211
|
+
if (routerSkipSections.includes(sec.name)) {
|
|
212
|
+
return undefined;
|
|
213
|
+
}
|
|
214
|
+
const src = sec.source;
|
|
215
|
+
if (src === 'runtime:projectContext') {
|
|
216
|
+
const projectCtx = await loadProjectContext(ctx.cwd);
|
|
217
|
+
if (projectCtx) {
|
|
218
|
+
return `[Project Context from ${projectCtx.source}]\n${projectCtx.content}`;
|
|
219
|
+
}
|
|
220
|
+
return undefined;
|
|
221
|
+
}
|
|
222
|
+
if (src === 'runtime:pool' || src === 'runtime:git') {
|
|
223
|
+
if (!ctx.fullHistory || ctx.fullHistory.length === 0)
|
|
224
|
+
return undefined;
|
|
225
|
+
const retriever = new Retriever();
|
|
226
|
+
const result = await retriever.retrieve({
|
|
227
|
+
pool: ctx.fullHistory,
|
|
228
|
+
excludeLast: 1,
|
|
229
|
+
excludeHashes: ctx.zone3Hashes,
|
|
230
|
+
userInput: ctx.userInput,
|
|
231
|
+
maxTokens: Math.floor(ctx.maxContextTokens * 0.50),
|
|
232
|
+
tokenCounter: ctx.tokenCounter,
|
|
233
|
+
gitManager: ctx.gitManager,
|
|
234
|
+
cwd: ctx.cwd,
|
|
235
|
+
});
|
|
236
|
+
if (src === 'runtime:pool' && result.messages.length > 0) {
|
|
237
|
+
const lines = ['[Context Pool Results]'];
|
|
238
|
+
for (const msg of result.messages) {
|
|
239
|
+
const text = extractTextContent(msg);
|
|
240
|
+
if (text)
|
|
241
|
+
lines.push(`[${msg.role}] ${text}`);
|
|
242
|
+
}
|
|
243
|
+
return lines.join('\n');
|
|
244
|
+
}
|
|
245
|
+
if (src === 'runtime:git' && result.gitContext && result.gitContext.length > 0) {
|
|
246
|
+
const lines = ['[Git Context]'];
|
|
247
|
+
for (const entry of result.gitContext) {
|
|
248
|
+
const filesStr = entry.files.length > 0
|
|
249
|
+
? ` (涉及: ${entry.files.slice(0, 5).join(', ')}${entry.files.length > 5 ? '...' : ''})`
|
|
250
|
+
: '';
|
|
251
|
+
lines.push(`${entry.hash} ${entry.message}${filesStr}`);
|
|
252
|
+
}
|
|
253
|
+
return lines.join('\n');
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return undefined;
|
|
257
|
+
}
|
|
258
|
+
// --- Conditional ---
|
|
259
|
+
function resolveConditional(sec, ctx) {
|
|
260
|
+
if (sec.condition === 'precise_mode') {
|
|
261
|
+
if (!ctx.activeConditions?.has('precise_mode'))
|
|
262
|
+
return undefined;
|
|
263
|
+
return resolveStatic(sec, ctx);
|
|
264
|
+
}
|
|
265
|
+
return undefined;
|
|
266
|
+
}
|
|
267
|
+
// --- Helpers ---
|
|
268
|
+
const PERSONA_SOUL_FILES = ['SOUL', 'IDENTITY', 'USER'];
|
|
269
|
+
export function buildSoulSection() {
|
|
270
|
+
const parts = [];
|
|
271
|
+
for (const name of PERSONA_SOUL_FILES) {
|
|
272
|
+
try {
|
|
273
|
+
const content = loadPersonaPrompt(name);
|
|
274
|
+
if (content)
|
|
275
|
+
parts.push(content);
|
|
276
|
+
}
|
|
277
|
+
catch {
|
|
278
|
+
// skip
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
return parts.length > 0 ? parts.join('\n\n---\n\n') : '';
|
|
282
|
+
}
|
|
283
|
+
function loadPersonaPrompt(name) {
|
|
284
|
+
const fileName = `${name}.md`;
|
|
285
|
+
const projectPath = path.join(process.cwd(), '.agent', 'prompts', 'persona', fileName);
|
|
286
|
+
if (fs.existsSync(projectPath)) {
|
|
287
|
+
return fs.readFileSync(projectPath, 'utf-8');
|
|
288
|
+
}
|
|
289
|
+
const globalPath = path.join(getGlobalPersonaDir(), fileName);
|
|
290
|
+
if (fs.existsSync(globalPath)) {
|
|
291
|
+
return fs.readFileSync(globalPath, 'utf-8');
|
|
292
|
+
}
|
|
293
|
+
return loadPrompt(`persona/${name}`);
|
|
294
|
+
}
|
|
295
|
+
function extractTextContent(message) {
|
|
296
|
+
const contents = Array.isArray(message.content)
|
|
297
|
+
? message.content
|
|
298
|
+
: [message.content];
|
|
299
|
+
// Collect text from all blocks — handles [image, text] and [text, image] messages
|
|
300
|
+
const textParts = contents
|
|
301
|
+
.filter((c) => c.type === 'text')
|
|
302
|
+
.map(c => c.text);
|
|
303
|
+
if (textParts.length > 0)
|
|
304
|
+
return textParts.join('\n');
|
|
305
|
+
// Single non-text block — return type marker
|
|
306
|
+
if (contents.length === 1) {
|
|
307
|
+
if (contents[0].type === 'image')
|
|
308
|
+
return `[Image: ${contents[0].source?.media_type ?? 'unknown'}]`;
|
|
309
|
+
if (contents[0].type === 'tool_use')
|
|
310
|
+
return `[ToolUse: ${contents[0].name}]`;
|
|
311
|
+
if (contents[0].type === 'tool_result')
|
|
312
|
+
return `[ToolResult: ${contents[0].tool_use_id}]`;
|
|
313
|
+
}
|
|
314
|
+
return null;
|
|
315
|
+
}
|
|
316
|
+
/** 从指定名称的 ContextSource 读取内容 */
|
|
317
|
+
function resolveContextSourceContent(sourceName, ctx) {
|
|
318
|
+
if (!ctx.sources)
|
|
319
|
+
return undefined;
|
|
320
|
+
const source = ctx.sources.get(sourceName);
|
|
321
|
+
if (!source?.getContent)
|
|
322
|
+
return undefined;
|
|
323
|
+
const content = source.getContent();
|
|
324
|
+
const text = typeof content === 'string' ? content : '';
|
|
325
|
+
return text || undefined;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* 收集所有 cacheability === 'live' 的 MCP 源,生成会话临时 MCP 索引。
|
|
329
|
+
* 用于 Zone 5 session_mcp section — 热插拔 MCP 不进 Zone 2,避免破坏前缀缓存。
|
|
330
|
+
* 下次启动时这些 MCP 会自动归位到 Zone 2(cacheability 变为 'manifest')。
|
|
331
|
+
*/
|
|
332
|
+
function buildLiveMcpIndex(ctx) {
|
|
333
|
+
if (!ctx.sources)
|
|
334
|
+
return undefined;
|
|
335
|
+
// 收集匹配的 live MCP 源,按 name 排序保证输出稳定
|
|
336
|
+
const matchedSources = [];
|
|
337
|
+
for (const [, source] of ctx.sources) {
|
|
338
|
+
if (source.cacheability !== 'live')
|
|
339
|
+
continue;
|
|
340
|
+
if (!source.name.startsWith('mcp-'))
|
|
341
|
+
continue;
|
|
342
|
+
matchedSources.push(source);
|
|
343
|
+
}
|
|
344
|
+
matchedSources.sort((a, b) => a.name.localeCompare(b.name));
|
|
345
|
+
if (matchedSources.length === 0)
|
|
346
|
+
return undefined;
|
|
347
|
+
const parts = matchedSources.map((source) => `- ${source.name}: ${source.description ?? '(no description)'}`);
|
|
348
|
+
return `会话临时 MCP — 本次对话可用\n${parts.join('\n')}`;
|
|
349
|
+
}
|
|
350
|
+
function buildSourcePartsFromCtx(kind, ctx) {
|
|
351
|
+
if (!ctx.sources)
|
|
352
|
+
return undefined;
|
|
353
|
+
const prefix = kind === 'mcp' ? 'mcp-' : `${kind}-`;
|
|
354
|
+
const parts = [];
|
|
355
|
+
// 收集匹配的 source,按 name 显式排序以保证输出稳定可预测。
|
|
356
|
+
// 这确保了即使 Map 插入顺序因热插拔 remove+re-add 而改变,Zone 2 文本字节布局也不变,最大化前缀缓存命中率。
|
|
357
|
+
const matchedSources = [];
|
|
358
|
+
for (const [, source] of ctx.sources) {
|
|
359
|
+
if (source.cacheability !== 'manifest')
|
|
360
|
+
continue;
|
|
361
|
+
if (kind !== 'mcp' && !source.name.startsWith(prefix))
|
|
362
|
+
continue;
|
|
363
|
+
if (kind === 'mcp' && !source.name.startsWith('mcp-'))
|
|
364
|
+
continue;
|
|
365
|
+
matchedSources.push(source);
|
|
366
|
+
}
|
|
367
|
+
matchedSources.sort((a, b) => a.name.localeCompare(b.name));
|
|
368
|
+
for (const source of matchedSources) {
|
|
369
|
+
switch (source.strategy) {
|
|
370
|
+
case 'always_inline':
|
|
371
|
+
parts.push(`- ${source.name}: ${source.description ?? '(no description)'}`);
|
|
372
|
+
break;
|
|
373
|
+
case 'index_only':
|
|
374
|
+
parts.push(`- ${source.name}: ${source.description ?? '(no description)'}`);
|
|
375
|
+
break;
|
|
376
|
+
case 'lazy_expand': {
|
|
377
|
+
const isSelected = kind === 'skill'
|
|
378
|
+
? ctx.selectedSkills?.includes(source.name.replace('skill-', ''))
|
|
379
|
+
: kind === 'agent'
|
|
380
|
+
? ctx.selectedAgents?.includes(source.name.replace('agent-', ''))
|
|
381
|
+
: false;
|
|
382
|
+
if (isSelected && source.getContent) {
|
|
383
|
+
const content = source.getContent();
|
|
384
|
+
const text = typeof content === 'string' ? content : '';
|
|
385
|
+
parts.push(`- ${source.name}: ${text}`);
|
|
386
|
+
}
|
|
387
|
+
else {
|
|
388
|
+
parts.push(`- ${source.name}: ${source.description ?? '(lazy: expand on use)'}`);
|
|
389
|
+
}
|
|
390
|
+
break;
|
|
391
|
+
}
|
|
392
|
+
case 'phase_bound':
|
|
393
|
+
break;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
return parts.length > 0 ? parts.join('\n') : undefined;
|
|
397
|
+
}
|
|
398
|
+
//# sourceMappingURL=section-resolver.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Message } from '../types.js';
|
|
2
|
+
export declare class TokenCounter {
|
|
3
|
+
#private;
|
|
4
|
+
/**
|
|
5
|
+
* Count tokens for a plain text string.
|
|
6
|
+
*/
|
|
7
|
+
countTokens(text: string): number;
|
|
8
|
+
/**
|
|
9
|
+
* Count tokens for a single Message object.
|
|
10
|
+
*
|
|
11
|
+
* Overhead model:
|
|
12
|
+
* - 4 tokens per message for role framing
|
|
13
|
+
* - TextContent: text tokens + 4
|
|
14
|
+
* - ToolUseContent: JSON.stringify(input) tokens + name tokens + 4
|
|
15
|
+
* - ToolResultContent: content tokens + 4
|
|
16
|
+
*/
|
|
17
|
+
countMessageTokens(message: Message): number;
|
|
18
|
+
/**
|
|
19
|
+
* Count tokens for an array of messages.
|
|
20
|
+
*/
|
|
21
|
+
countMessagesTokens(messages: Message[]): number;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=tokenizer.d.ts.map
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { encodingForModel } from 'js-tiktoken';
|
|
2
|
+
// --- Lazy singleton encoding ---
|
|
3
|
+
let _encoding = null;
|
|
4
|
+
function getEncoding() {
|
|
5
|
+
if (!_encoding) {
|
|
6
|
+
_encoding = encodingForModel('gpt-4');
|
|
7
|
+
}
|
|
8
|
+
return _encoding;
|
|
9
|
+
}
|
|
10
|
+
// --- TokenCounter ---
|
|
11
|
+
export class TokenCounter {
|
|
12
|
+
/**
|
|
13
|
+
* Count tokens for a plain text string.
|
|
14
|
+
*/
|
|
15
|
+
countTokens(text) {
|
|
16
|
+
return getEncoding().encode(text).length;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Count tokens for a single Message object.
|
|
20
|
+
*
|
|
21
|
+
* Overhead model:
|
|
22
|
+
* - 4 tokens per message for role framing
|
|
23
|
+
* - TextContent: text tokens + 4
|
|
24
|
+
* - ToolUseContent: JSON.stringify(input) tokens + name tokens + 4
|
|
25
|
+
* - ToolResultContent: content tokens + 4
|
|
26
|
+
*/
|
|
27
|
+
countMessageTokens(message) {
|
|
28
|
+
let tokens = 4; // role overhead per message
|
|
29
|
+
const contents = Array.isArray(message.content)
|
|
30
|
+
? message.content
|
|
31
|
+
: [message.content];
|
|
32
|
+
for (const part of contents) {
|
|
33
|
+
tokens += this.#countContentTokens(part);
|
|
34
|
+
}
|
|
35
|
+
return tokens;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Count tokens for an array of messages.
|
|
39
|
+
*/
|
|
40
|
+
countMessagesTokens(messages) {
|
|
41
|
+
return messages.reduce((sum, msg) => sum + this.countMessageTokens(msg), 0);
|
|
42
|
+
}
|
|
43
|
+
#countContentTokens(content) {
|
|
44
|
+
switch (content.type) {
|
|
45
|
+
case 'text': {
|
|
46
|
+
const tc = content;
|
|
47
|
+
return this.countTokens(tc.text) + 4;
|
|
48
|
+
}
|
|
49
|
+
case 'tool_use': {
|
|
50
|
+
const tuc = content;
|
|
51
|
+
const inputTokens = this.countTokens(JSON.stringify(tuc.input));
|
|
52
|
+
const nameTokens = this.countTokens(tuc.name);
|
|
53
|
+
return inputTokens + nameTokens + 4;
|
|
54
|
+
}
|
|
55
|
+
case 'thinking': {
|
|
56
|
+
const tc = content;
|
|
57
|
+
return this.countTokens(tc.thinking) + 4;
|
|
58
|
+
}
|
|
59
|
+
case 'tool_result': {
|
|
60
|
+
const trc = content;
|
|
61
|
+
return this.countTokens(trc.content) + 4;
|
|
62
|
+
}
|
|
63
|
+
case 'image': {
|
|
64
|
+
const img = content;
|
|
65
|
+
if (img.source.type === 'url')
|
|
66
|
+
return 1000; // 远程 URL,保守估算
|
|
67
|
+
// base64: decoded ≈ data.length * 0.75 bytes, ~1 token per 4 bytes
|
|
68
|
+
return Math.max(1, Math.ceil(img.source.data.length * 0.75 / 4)) + 4;
|
|
69
|
+
}
|
|
70
|
+
default: {
|
|
71
|
+
// Unknown content type — best-effort: stringify and count
|
|
72
|
+
const _exhaustive = content;
|
|
73
|
+
return this.countTokens(JSON.stringify(_exhaustive)) + 4;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=tokenizer.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { DependencyGraph, ImpactResult } from './types.js';
|
|
2
|
+
import type { GitManager } from '../evolution/git-manager.js';
|
|
3
|
+
export declare class DependencyAnalyzer {
|
|
4
|
+
private parser;
|
|
5
|
+
private graph;
|
|
6
|
+
private fileHashes;
|
|
7
|
+
private rootDir;
|
|
8
|
+
private projectKey;
|
|
9
|
+
private cachePath;
|
|
10
|
+
/** 分析项目,构建依赖图(优先加载缓存) */
|
|
11
|
+
analyze(rootDir: string): Promise<DependencyGraph>;
|
|
12
|
+
/** 全量构建依赖图 */
|
|
13
|
+
private fullBuild;
|
|
14
|
+
/** 增量更新:重新解析变更文件,更新依赖图 */
|
|
15
|
+
incrementalUpdate(changedFiles?: string[], gitManager?: GitManager): Promise<void>;
|
|
16
|
+
/** 构建正向和反向索引 */
|
|
17
|
+
private buildIndexes;
|
|
18
|
+
/** 查询影响面:修改 file 后,哪些文件会受影响 */
|
|
19
|
+
getImpact(file: string, symbol?: string): ImpactResult;
|
|
20
|
+
/** 获取依赖图(只读) */
|
|
21
|
+
getGraph(): Readonly<DependencyGraph> | null;
|
|
22
|
+
/** 获取 projectKey */
|
|
23
|
+
getProjectKey(): string;
|
|
24
|
+
/** 序列化 DependencyGraph 为可存储的 JSON 格式 */
|
|
25
|
+
private serialize;
|
|
26
|
+
/** 反序列化 JSON 为 DependencyGraph */
|
|
27
|
+
private deserialize;
|
|
28
|
+
/** 从磁盘加载缓存 */
|
|
29
|
+
private loadCache;
|
|
30
|
+
/** 保存缓存到磁盘 */
|
|
31
|
+
private saveCache;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=analyzer.d.ts.map
|