attocode 0.1.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/CHANGELOG.md +48 -0
- package/LICENSE +21 -0
- package/README.md +164 -0
- package/dist/src/adapters.d.ts +83 -0
- package/dist/src/adapters.d.ts.map +1 -0
- package/dist/src/adapters.js +221 -0
- package/dist/src/adapters.js.map +1 -0
- package/dist/src/agent-tools/index.d.ts +7 -0
- package/dist/src/agent-tools/index.d.ts.map +1 -0
- package/dist/src/agent-tools/index.js +8 -0
- package/dist/src/agent-tools/index.js.map +1 -0
- package/dist/src/agent-tools/lsp-file-tools.d.ts +33 -0
- package/dist/src/agent-tools/lsp-file-tools.d.ts.map +1 -0
- package/dist/src/agent-tools/lsp-file-tools.js +200 -0
- package/dist/src/agent-tools/lsp-file-tools.js.map +1 -0
- package/dist/src/agent.d.ts +667 -0
- package/dist/src/agent.d.ts.map +1 -0
- package/dist/src/agent.js +2824 -0
- package/dist/src/agent.js.map +1 -0
- package/dist/src/cli.d.ts +36 -0
- package/dist/src/cli.d.ts.map +1 -0
- package/dist/src/cli.js +176 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/commands/handler.d.ts +22 -0
- package/dist/src/commands/handler.d.ts.map +1 -0
- package/dist/src/commands/handler.js +1320 -0
- package/dist/src/commands/handler.js.map +1 -0
- package/dist/src/commands/init.d.ts +7 -0
- package/dist/src/commands/init.d.ts.map +1 -0
- package/dist/src/commands/init.js +153 -0
- package/dist/src/commands/init.js.map +1 -0
- package/dist/src/commands/types.d.ts +70 -0
- package/dist/src/commands/types.d.ts.map +1 -0
- package/dist/src/commands/types.js +8 -0
- package/dist/src/commands/types.js.map +1 -0
- package/dist/src/config.d.ts +22 -0
- package/dist/src/config.d.ts.map +1 -0
- package/dist/src/config.js +25 -0
- package/dist/src/config.js.map +1 -0
- package/dist/src/core/index.d.ts +32 -0
- package/dist/src/core/index.d.ts.map +1 -0
- package/dist/src/core/index.js +35 -0
- package/dist/src/core/index.js.map +1 -0
- package/dist/src/core/process-handlers.d.ts +43 -0
- package/dist/src/core/process-handlers.d.ts.map +1 -0
- package/dist/src/core/process-handlers.js +117 -0
- package/dist/src/core/process-handlers.js.map +1 -0
- package/dist/src/core/protocol/bridge.d.ts +117 -0
- package/dist/src/core/protocol/bridge.d.ts.map +1 -0
- package/dist/src/core/protocol/bridge.js +149 -0
- package/dist/src/core/protocol/bridge.js.map +1 -0
- package/dist/src/core/protocol/index.d.ts +8 -0
- package/dist/src/core/protocol/index.d.ts.map +1 -0
- package/dist/src/core/protocol/index.js +8 -0
- package/dist/src/core/protocol/index.js.map +1 -0
- package/dist/src/core/protocol/types.d.ts +539 -0
- package/dist/src/core/protocol/types.d.ts.map +1 -0
- package/dist/src/core/protocol/types.js +149 -0
- package/dist/src/core/protocol/types.js.map +1 -0
- package/dist/src/core/queues/atomic-counter.d.ts +36 -0
- package/dist/src/core/queues/atomic-counter.d.ts.map +1 -0
- package/dist/src/core/queues/atomic-counter.js +46 -0
- package/dist/src/core/queues/atomic-counter.js.map +1 -0
- package/dist/src/core/queues/event-queue.d.ts +126 -0
- package/dist/src/core/queues/event-queue.d.ts.map +1 -0
- package/dist/src/core/queues/event-queue.js +208 -0
- package/dist/src/core/queues/event-queue.js.map +1 -0
- package/dist/src/core/queues/index.d.ts +12 -0
- package/dist/src/core/queues/index.d.ts.map +1 -0
- package/dist/src/core/queues/index.js +15 -0
- package/dist/src/core/queues/index.js.map +1 -0
- package/dist/src/core/queues/submission-queue.d.ts +116 -0
- package/dist/src/core/queues/submission-queue.d.ts.map +1 -0
- package/dist/src/core/queues/submission-queue.js +236 -0
- package/dist/src/core/queues/submission-queue.js.map +1 -0
- package/dist/src/costs/index.d.ts +22 -0
- package/dist/src/costs/index.d.ts.map +1 -0
- package/dist/src/costs/index.js +22 -0
- package/dist/src/costs/index.js.map +1 -0
- package/dist/src/costs/model-registry.d.ts +80 -0
- package/dist/src/costs/model-registry.d.ts.map +1 -0
- package/dist/src/costs/model-registry.js +237 -0
- package/dist/src/costs/model-registry.js.map +1 -0
- package/dist/src/costs/types.d.ts +50 -0
- package/dist/src/costs/types.d.ts.map +1 -0
- package/dist/src/costs/types.js +2 -0
- package/dist/src/costs/types.js.map +1 -0
- package/dist/src/defaults.d.ts +114 -0
- package/dist/src/defaults.d.ts.map +1 -0
- package/dist/src/defaults.js +457 -0
- package/dist/src/defaults.js.map +1 -0
- package/dist/src/first-run.d.ts +35 -0
- package/dist/src/first-run.d.ts.map +1 -0
- package/dist/src/first-run.js +94 -0
- package/dist/src/first-run.js.map +1 -0
- package/dist/src/hello.d.ts +2 -0
- package/dist/src/hello.d.ts.map +1 -0
- package/dist/src/hello.js +4 -0
- package/dist/src/hello.js.map +1 -0
- package/dist/src/integrations/agent-registry.d.ts +160 -0
- package/dist/src/integrations/agent-registry.d.ts.map +1 -0
- package/dist/src/integrations/agent-registry.js +446 -0
- package/dist/src/integrations/agent-registry.js.map +1 -0
- package/dist/src/integrations/auto-compaction.d.ts +177 -0
- package/dist/src/integrations/auto-compaction.d.ts.map +1 -0
- package/dist/src/integrations/auto-compaction.js +428 -0
- package/dist/src/integrations/auto-compaction.js.map +1 -0
- package/dist/src/integrations/cancellation.d.ts +162 -0
- package/dist/src/integrations/cancellation.d.ts.map +1 -0
- package/dist/src/integrations/cancellation.js +339 -0
- package/dist/src/integrations/cancellation.js.map +1 -0
- package/dist/src/integrations/codebase-context.d.ts +319 -0
- package/dist/src/integrations/codebase-context.d.ts.map +1 -0
- package/dist/src/integrations/codebase-context.js +816 -0
- package/dist/src/integrations/codebase-context.js.map +1 -0
- package/dist/src/integrations/compaction.d.ts +192 -0
- package/dist/src/integrations/compaction.d.ts.map +1 -0
- package/dist/src/integrations/compaction.js +376 -0
- package/dist/src/integrations/compaction.js.map +1 -0
- package/dist/src/integrations/context-engineering.d.ts +246 -0
- package/dist/src/integrations/context-engineering.d.ts.map +1 -0
- package/dist/src/integrations/context-engineering.js +394 -0
- package/dist/src/integrations/context-engineering.js.map +1 -0
- package/dist/src/integrations/diff-utils.d.ts +105 -0
- package/dist/src/integrations/diff-utils.d.ts.map +1 -0
- package/dist/src/integrations/diff-utils.js +497 -0
- package/dist/src/integrations/diff-utils.js.map +1 -0
- package/dist/src/integrations/economics.d.ts +192 -0
- package/dist/src/integrations/economics.d.ts.map +1 -0
- package/dist/src/integrations/economics.js +431 -0
- package/dist/src/integrations/economics.js.map +1 -0
- package/dist/src/integrations/execution-policy.d.ts +189 -0
- package/dist/src/integrations/execution-policy.d.ts.map +1 -0
- package/dist/src/integrations/execution-policy.js +352 -0
- package/dist/src/integrations/execution-policy.js.map +1 -0
- package/dist/src/integrations/file-change-tracker.d.ts +161 -0
- package/dist/src/integrations/file-change-tracker.d.ts.map +1 -0
- package/dist/src/integrations/file-change-tracker.js +520 -0
- package/dist/src/integrations/file-change-tracker.js.map +1 -0
- package/dist/src/integrations/hierarchical-config.d.ts +212 -0
- package/dist/src/integrations/hierarchical-config.d.ts.map +1 -0
- package/dist/src/integrations/hierarchical-config.js +484 -0
- package/dist/src/integrations/hierarchical-config.js.map +1 -0
- package/dist/src/integrations/hooks.d.ts +114 -0
- package/dist/src/integrations/hooks.d.ts.map +1 -0
- package/dist/src/integrations/hooks.js +326 -0
- package/dist/src/integrations/hooks.js.map +1 -0
- package/dist/src/integrations/ignore.d.ts +143 -0
- package/dist/src/integrations/ignore.d.ts.map +1 -0
- package/dist/src/integrations/ignore.js +417 -0
- package/dist/src/integrations/ignore.js.map +1 -0
- package/dist/src/integrations/image-renderer.d.ts +119 -0
- package/dist/src/integrations/image-renderer.d.ts.map +1 -0
- package/dist/src/integrations/image-renderer.js +306 -0
- package/dist/src/integrations/image-renderer.js.map +1 -0
- package/dist/src/integrations/index.d.ts +42 -0
- package/dist/src/integrations/index.d.ts.map +1 -0
- package/dist/src/integrations/index.js +73 -0
- package/dist/src/integrations/index.js.map +1 -0
- package/dist/src/integrations/lsp.d.ts +196 -0
- package/dist/src/integrations/lsp.d.ts.map +1 -0
- package/dist/src/integrations/lsp.js +582 -0
- package/dist/src/integrations/lsp.js.map +1 -0
- package/dist/src/integrations/mcp-client.d.ts +270 -0
- package/dist/src/integrations/mcp-client.d.ts.map +1 -0
- package/dist/src/integrations/mcp-client.js +698 -0
- package/dist/src/integrations/mcp-client.js.map +1 -0
- package/dist/src/integrations/mcp-tool-search.d.ts +77 -0
- package/dist/src/integrations/mcp-tool-search.d.ts.map +1 -0
- package/dist/src/integrations/mcp-tool-search.js +220 -0
- package/dist/src/integrations/mcp-tool-search.js.map +1 -0
- package/dist/src/integrations/memory.d.ts +108 -0
- package/dist/src/integrations/memory.d.ts.map +1 -0
- package/dist/src/integrations/memory.js +288 -0
- package/dist/src/integrations/memory.js.map +1 -0
- package/dist/src/integrations/multi-agent.d.ts +150 -0
- package/dist/src/integrations/multi-agent.d.ts.map +1 -0
- package/dist/src/integrations/multi-agent.js +306 -0
- package/dist/src/integrations/multi-agent.js.map +1 -0
- package/dist/src/integrations/observability.d.ts +162 -0
- package/dist/src/integrations/observability.d.ts.map +1 -0
- package/dist/src/integrations/observability.js +406 -0
- package/dist/src/integrations/observability.js.map +1 -0
- package/dist/src/integrations/openrouter-pricing.d.ts +42 -0
- package/dist/src/integrations/openrouter-pricing.d.ts.map +1 -0
- package/dist/src/integrations/openrouter-pricing.js +124 -0
- package/dist/src/integrations/openrouter-pricing.js.map +1 -0
- package/dist/src/integrations/pending-plan.d.ts +171 -0
- package/dist/src/integrations/pending-plan.d.ts.map +1 -0
- package/dist/src/integrations/pending-plan.js +244 -0
- package/dist/src/integrations/pending-plan.js.map +1 -0
- package/dist/src/integrations/persistence.d.ts +48 -0
- package/dist/src/integrations/persistence.d.ts.map +1 -0
- package/dist/src/integrations/persistence.js +196 -0
- package/dist/src/integrations/persistence.js.map +1 -0
- package/dist/src/integrations/planning.d.ts +96 -0
- package/dist/src/integrations/planning.d.ts.map +1 -0
- package/dist/src/integrations/planning.js +338 -0
- package/dist/src/integrations/planning.js.map +1 -0
- package/dist/src/integrations/pty-shell.d.ts +169 -0
- package/dist/src/integrations/pty-shell.d.ts.map +1 -0
- package/dist/src/integrations/pty-shell.js +367 -0
- package/dist/src/integrations/pty-shell.js.map +1 -0
- package/dist/src/integrations/react.d.ts +139 -0
- package/dist/src/integrations/react.d.ts.map +1 -0
- package/dist/src/integrations/react.js +273 -0
- package/dist/src/integrations/react.js.map +1 -0
- package/dist/src/integrations/resources.d.ts +177 -0
- package/dist/src/integrations/resources.d.ts.map +1 -0
- package/dist/src/integrations/resources.js +311 -0
- package/dist/src/integrations/resources.js.map +1 -0
- package/dist/src/integrations/result-synthesizer.d.ts +389 -0
- package/dist/src/integrations/result-synthesizer.d.ts.map +1 -0
- package/dist/src/integrations/result-synthesizer.js +951 -0
- package/dist/src/integrations/result-synthesizer.js.map +1 -0
- package/dist/src/integrations/routing.d.ts +117 -0
- package/dist/src/integrations/routing.d.ts.map +1 -0
- package/dist/src/integrations/routing.js +347 -0
- package/dist/src/integrations/routing.js.map +1 -0
- package/dist/src/integrations/rules.d.ts +131 -0
- package/dist/src/integrations/rules.d.ts.map +1 -0
- package/dist/src/integrations/rules.js +284 -0
- package/dist/src/integrations/rules.js.map +1 -0
- package/dist/src/integrations/safety.d.ts +142 -0
- package/dist/src/integrations/safety.d.ts.map +1 -0
- package/dist/src/integrations/safety.js +342 -0
- package/dist/src/integrations/safety.js.map +1 -0
- package/dist/src/integrations/sandbox/basic.d.ts +74 -0
- package/dist/src/integrations/sandbox/basic.d.ts.map +1 -0
- package/dist/src/integrations/sandbox/basic.js +310 -0
- package/dist/src/integrations/sandbox/basic.js.map +1 -0
- package/dist/src/integrations/sandbox/docker.d.ts +94 -0
- package/dist/src/integrations/sandbox/docker.d.ts.map +1 -0
- package/dist/src/integrations/sandbox/docker.js +293 -0
- package/dist/src/integrations/sandbox/docker.js.map +1 -0
- package/dist/src/integrations/sandbox/index.d.ts +182 -0
- package/dist/src/integrations/sandbox/index.d.ts.map +1 -0
- package/dist/src/integrations/sandbox/index.js +382 -0
- package/dist/src/integrations/sandbox/index.js.map +1 -0
- package/dist/src/integrations/sandbox/landlock.d.ts +59 -0
- package/dist/src/integrations/sandbox/landlock.d.ts.map +1 -0
- package/dist/src/integrations/sandbox/landlock.js +326 -0
- package/dist/src/integrations/sandbox/landlock.js.map +1 -0
- package/dist/src/integrations/sandbox/seatbelt.d.ts +68 -0
- package/dist/src/integrations/sandbox/seatbelt.d.ts.map +1 -0
- package/dist/src/integrations/sandbox/seatbelt.js +298 -0
- package/dist/src/integrations/sandbox/seatbelt.js.map +1 -0
- package/dist/src/integrations/semantic-cache.d.ts +178 -0
- package/dist/src/integrations/semantic-cache.d.ts.map +1 -0
- package/dist/src/integrations/semantic-cache.js +372 -0
- package/dist/src/integrations/semantic-cache.js.map +1 -0
- package/dist/src/integrations/session-store.d.ts +183 -0
- package/dist/src/integrations/session-store.d.ts.map +1 -0
- package/dist/src/integrations/session-store.js +345 -0
- package/dist/src/integrations/session-store.js.map +1 -0
- package/dist/src/integrations/shared-blackboard.d.ts +403 -0
- package/dist/src/integrations/shared-blackboard.d.ts.map +1 -0
- package/dist/src/integrations/shared-blackboard.js +710 -0
- package/dist/src/integrations/shared-blackboard.js.map +1 -0
- package/dist/src/integrations/skills.d.ts +171 -0
- package/dist/src/integrations/skills.d.ts.map +1 -0
- package/dist/src/integrations/skills.js +403 -0
- package/dist/src/integrations/skills.js.map +1 -0
- package/dist/src/integrations/smart-decomposer.d.ts +322 -0
- package/dist/src/integrations/smart-decomposer.d.ts.map +1 -0
- package/dist/src/integrations/smart-decomposer.js +856 -0
- package/dist/src/integrations/smart-decomposer.js.map +1 -0
- package/dist/src/integrations/sourcegraph.d.ts +169 -0
- package/dist/src/integrations/sourcegraph.d.ts.map +1 -0
- package/dist/src/integrations/sourcegraph.js +379 -0
- package/dist/src/integrations/sourcegraph.js.map +1 -0
- package/dist/src/integrations/sqlite-store.d.ts +518 -0
- package/dist/src/integrations/sqlite-store.d.ts.map +1 -0
- package/dist/src/integrations/sqlite-store.js +1423 -0
- package/dist/src/integrations/sqlite-store.js.map +1 -0
- package/dist/src/integrations/streaming.d.ts +102 -0
- package/dist/src/integrations/streaming.d.ts.map +1 -0
- package/dist/src/integrations/streaming.js +362 -0
- package/dist/src/integrations/streaming.js.map +1 -0
- package/dist/src/integrations/thread-manager.d.ts +199 -0
- package/dist/src/integrations/thread-manager.d.ts.map +1 -0
- package/dist/src/integrations/thread-manager.js +357 -0
- package/dist/src/integrations/thread-manager.js.map +1 -0
- package/dist/src/main.d.ts +26 -0
- package/dist/src/main.d.ts.map +1 -0
- package/dist/src/main.js +170 -0
- package/dist/src/main.js.map +1 -0
- package/dist/src/modes/index.d.ts +10 -0
- package/dist/src/modes/index.d.ts.map +1 -0
- package/dist/src/modes/index.js +10 -0
- package/dist/src/modes/index.js.map +1 -0
- package/dist/src/modes/repl.d.ts +19 -0
- package/dist/src/modes/repl.d.ts.map +1 -0
- package/dist/src/modes/repl.js +393 -0
- package/dist/src/modes/repl.js.map +1 -0
- package/dist/src/modes/tui.d.ts +29 -0
- package/dist/src/modes/tui.d.ts.map +1 -0
- package/dist/src/modes/tui.js +272 -0
- package/dist/src/modes/tui.js.map +1 -0
- package/dist/src/modes.d.ts +179 -0
- package/dist/src/modes.d.ts.map +1 -0
- package/dist/src/modes.js +385 -0
- package/dist/src/modes.js.map +1 -0
- package/dist/src/observability/tracer.d.ts +111 -0
- package/dist/src/observability/tracer.d.ts.map +1 -0
- package/dist/src/observability/tracer.js +300 -0
- package/dist/src/observability/tracer.js.map +1 -0
- package/dist/src/observability/types.d.ts +271 -0
- package/dist/src/observability/types.d.ts.map +1 -0
- package/dist/src/observability/types.js +24 -0
- package/dist/src/observability/types.js.map +1 -0
- package/dist/src/paths.d.ts +101 -0
- package/dist/src/paths.d.ts.map +1 -0
- package/dist/src/paths.js +148 -0
- package/dist/src/paths.js.map +1 -0
- package/dist/src/persistence/index.d.ts +38 -0
- package/dist/src/persistence/index.d.ts.map +1 -0
- package/dist/src/persistence/index.js +48 -0
- package/dist/src/persistence/index.js.map +1 -0
- package/dist/src/persistence/migrator.d.ts +135 -0
- package/dist/src/persistence/migrator.d.ts.map +1 -0
- package/dist/src/persistence/migrator.js +303 -0
- package/dist/src/persistence/migrator.js.map +1 -0
- package/dist/src/persistence/schema.d.ts +101 -0
- package/dist/src/persistence/schema.d.ts.map +1 -0
- package/dist/src/persistence/schema.js +395 -0
- package/dist/src/persistence/schema.js.map +1 -0
- package/dist/src/providers/adapters/anthropic.d.ts +20 -0
- package/dist/src/providers/adapters/anthropic.d.ts.map +1 -0
- package/dist/src/providers/adapters/anthropic.js +124 -0
- package/dist/src/providers/adapters/anthropic.js.map +1 -0
- package/dist/src/providers/adapters/mock.d.ts +25 -0
- package/dist/src/providers/adapters/mock.d.ts.map +1 -0
- package/dist/src/providers/adapters/mock.js +133 -0
- package/dist/src/providers/adapters/mock.js.map +1 -0
- package/dist/src/providers/adapters/openai.d.ts +21 -0
- package/dist/src/providers/adapters/openai.d.ts.map +1 -0
- package/dist/src/providers/adapters/openai.js +126 -0
- package/dist/src/providers/adapters/openai.js.map +1 -0
- package/dist/src/providers/adapters/openrouter.d.ts +49 -0
- package/dist/src/providers/adapters/openrouter.d.ts.map +1 -0
- package/dist/src/providers/adapters/openrouter.js +363 -0
- package/dist/src/providers/adapters/openrouter.js.map +1 -0
- package/dist/src/providers/provider.d.ts +54 -0
- package/dist/src/providers/provider.d.ts.map +1 -0
- package/dist/src/providers/provider.js +111 -0
- package/dist/src/providers/provider.js.map +1 -0
- package/dist/src/providers/resilient-fetch.d.ts +99 -0
- package/dist/src/providers/resilient-fetch.d.ts.map +1 -0
- package/dist/src/providers/resilient-fetch.js +208 -0
- package/dist/src/providers/resilient-fetch.js.map +1 -0
- package/dist/src/providers/types.d.ts +227 -0
- package/dist/src/providers/types.d.ts.map +1 -0
- package/dist/src/providers/types.js +24 -0
- package/dist/src/providers/types.js.map +1 -0
- package/dist/src/session-picker.d.ts +28 -0
- package/dist/src/session-picker.d.ts.map +1 -0
- package/dist/src/session-picker.js +256 -0
- package/dist/src/session-picker.js.map +1 -0
- package/dist/src/test-sqlite.d.ts +2 -0
- package/dist/src/test-sqlite.d.ts.map +1 -0
- package/dist/src/test-sqlite.js +114 -0
- package/dist/src/test-sqlite.js.map +1 -0
- package/dist/src/tools/agent.d.ts +44 -0
- package/dist/src/tools/agent.d.ts.map +1 -0
- package/dist/src/tools/agent.js +110 -0
- package/dist/src/tools/agent.js.map +1 -0
- package/dist/src/tools/bash.d.ts +52 -0
- package/dist/src/tools/bash.d.ts.map +1 -0
- package/dist/src/tools/bash.js +141 -0
- package/dist/src/tools/bash.js.map +1 -0
- package/dist/src/tools/file.d.ts +47 -0
- package/dist/src/tools/file.d.ts.map +1 -0
- package/dist/src/tools/file.js +263 -0
- package/dist/src/tools/file.js.map +1 -0
- package/dist/src/tools/permission.d.ts +43 -0
- package/dist/src/tools/permission.d.ts.map +1 -0
- package/dist/src/tools/permission.js +216 -0
- package/dist/src/tools/permission.js.map +1 -0
- package/dist/src/tools/registry.d.ts +63 -0
- package/dist/src/tools/registry.d.ts.map +1 -0
- package/dist/src/tools/registry.js +250 -0
- package/dist/src/tools/registry.js.map +1 -0
- package/dist/src/tools/standard.d.ts +57 -0
- package/dist/src/tools/standard.d.ts.map +1 -0
- package/dist/src/tools/standard.js +113 -0
- package/dist/src/tools/standard.js.map +1 -0
- package/dist/src/tools/types.d.ts +146 -0
- package/dist/src/tools/types.d.ts.map +1 -0
- package/dist/src/tools/types.js +28 -0
- package/dist/src/tools/types.js.map +1 -0
- package/dist/src/tools/undo.d.ts +71 -0
- package/dist/src/tools/undo.d.ts.map +1 -0
- package/dist/src/tools/undo.js +123 -0
- package/dist/src/tools/undo.js.map +1 -0
- package/dist/src/tracing/cache-boundary-tracker.d.ts +189 -0
- package/dist/src/tracing/cache-boundary-tracker.d.ts.map +1 -0
- package/dist/src/tracing/cache-boundary-tracker.js +411 -0
- package/dist/src/tracing/cache-boundary-tracker.js.map +1 -0
- package/dist/src/tracing/trace-collector.d.ts +274 -0
- package/dist/src/tracing/trace-collector.d.ts.map +1 -0
- package/dist/src/tracing/trace-collector.js +727 -0
- package/dist/src/tracing/trace-collector.js.map +1 -0
- package/dist/src/tracing/types.d.ts +657 -0
- package/dist/src/tracing/types.d.ts.map +1 -0
- package/dist/src/tracing/types.js +39 -0
- package/dist/src/tracing/types.js.map +1 -0
- package/dist/src/tricks/failure-evidence.d.ts +268 -0
- package/dist/src/tricks/failure-evidence.d.ts.map +1 -0
- package/dist/src/tricks/failure-evidence.js +544 -0
- package/dist/src/tricks/failure-evidence.js.map +1 -0
- package/dist/src/tricks/json-utils.d.ts +77 -0
- package/dist/src/tricks/json-utils.d.ts.map +1 -0
- package/dist/src/tricks/json-utils.js +247 -0
- package/dist/src/tricks/json-utils.js.map +1 -0
- package/dist/src/tricks/kv-cache-context.d.ts +227 -0
- package/dist/src/tricks/kv-cache-context.d.ts.map +1 -0
- package/dist/src/tricks/kv-cache-context.js +377 -0
- package/dist/src/tricks/kv-cache-context.js.map +1 -0
- package/dist/src/tricks/recitation.d.ts +208 -0
- package/dist/src/tricks/recitation.d.ts.map +1 -0
- package/dist/src/tricks/recitation.js +374 -0
- package/dist/src/tricks/recitation.js.map +1 -0
- package/dist/src/tricks/reversible-compaction.d.ts +251 -0
- package/dist/src/tricks/reversible-compaction.d.ts.map +1 -0
- package/dist/src/tricks/reversible-compaction.js +555 -0
- package/dist/src/tricks/reversible-compaction.js.map +1 -0
- package/dist/src/tricks/serialization-diversity.d.ts +197 -0
- package/dist/src/tricks/serialization-diversity.d.ts.map +1 -0
- package/dist/src/tricks/serialization-diversity.js +460 -0
- package/dist/src/tricks/serialization-diversity.js.map +1 -0
- package/dist/src/tui/app.d.ts +42 -0
- package/dist/src/tui/app.d.ts.map +1 -0
- package/dist/src/tui/app.js +1076 -0
- package/dist/src/tui/app.js.map +1 -0
- package/dist/src/tui/components/ApprovalDialog.d.ts +28 -0
- package/dist/src/tui/components/ApprovalDialog.d.ts.map +1 -0
- package/dist/src/tui/components/ApprovalDialog.js +59 -0
- package/dist/src/tui/components/ApprovalDialog.js.map +1 -0
- package/dist/src/tui/components/InputArea.d.ts +35 -0
- package/dist/src/tui/components/InputArea.d.ts.map +1 -0
- package/dist/src/tui/components/InputArea.js +144 -0
- package/dist/src/tui/components/InputArea.js.map +1 -0
- package/dist/src/tui/components/MessageItem.d.ts +28 -0
- package/dist/src/tui/components/MessageItem.d.ts.map +1 -0
- package/dist/src/tui/components/MessageItem.js +27 -0
- package/dist/src/tui/components/MessageItem.js.map +1 -0
- package/dist/src/tui/components/ScrollableBox.d.ts +41 -0
- package/dist/src/tui/components/ScrollableBox.d.ts.map +1 -0
- package/dist/src/tui/components/ScrollableBox.js +101 -0
- package/dist/src/tui/components/ScrollableBox.js.map +1 -0
- package/dist/src/tui/components/ToolCallItem.d.ts +33 -0
- package/dist/src/tui/components/ToolCallItem.d.ts.map +1 -0
- package/dist/src/tui/components/ToolCallItem.js +91 -0
- package/dist/src/tui/components/ToolCallItem.js.map +1 -0
- package/dist/src/tui/components/index.d.ts +13 -0
- package/dist/src/tui/components/index.d.ts.map +1 -0
- package/dist/src/tui/components/index.js +15 -0
- package/dist/src/tui/components/index.js.map +1 -0
- package/dist/src/tui/event-display.d.ts +19 -0
- package/dist/src/tui/event-display.d.ts.map +1 -0
- package/dist/src/tui/event-display.js +178 -0
- package/dist/src/tui/event-display.js.map +1 -0
- package/dist/src/tui/index.d.ts +105 -0
- package/dist/src/tui/index.d.ts.map +1 -0
- package/dist/src/tui/index.js +214 -0
- package/dist/src/tui/index.js.map +1 -0
- package/dist/src/tui/input/CommandPalette.d.ts +55 -0
- package/dist/src/tui/input/CommandPalette.d.ts.map +1 -0
- package/dist/src/tui/input/CommandPalette.js +135 -0
- package/dist/src/tui/input/CommandPalette.js.map +1 -0
- package/dist/src/tui/input/index.d.ts +7 -0
- package/dist/src/tui/input/index.d.ts.map +1 -0
- package/dist/src/tui/input/index.js +7 -0
- package/dist/src/tui/input/index.js.map +1 -0
- package/dist/src/tui/theme/index.d.ts +45 -0
- package/dist/src/tui/theme/index.d.ts.map +1 -0
- package/dist/src/tui/theme/index.js +215 -0
- package/dist/src/tui/theme/index.js.map +1 -0
- package/dist/src/tui/types.d.ts +214 -0
- package/dist/src/tui/types.d.ts.map +1 -0
- package/dist/src/tui/types.js +27 -0
- package/dist/src/tui/types.js.map +1 -0
- package/dist/src/types.d.ts +905 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +9 -0
- package/dist/src/types.js.map +1 -0
- package/package.json +89 -0
|
@@ -0,0 +1,856 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Smart Task Decomposer Integration
|
|
3
|
+
*
|
|
4
|
+
* Uses LLM-assisted analysis for intelligent task decomposition.
|
|
5
|
+
* Replaces keyword-based decomposition with semantic understanding.
|
|
6
|
+
*
|
|
7
|
+
* Key features:
|
|
8
|
+
* - Semantic task analysis (understands intent, not just keywords)
|
|
9
|
+
* - Implicit dependency detection ("implement auth" needs "design schema")
|
|
10
|
+
* - Codebase-aware decomposition (considers existing structure)
|
|
11
|
+
* - Resource contention detection (identifies potential conflicts)
|
|
12
|
+
* - Dynamic strategy selection based on task characteristics
|
|
13
|
+
*/
|
|
14
|
+
// =============================================================================
|
|
15
|
+
// CONSTANTS
|
|
16
|
+
// =============================================================================
|
|
17
|
+
const DEFAULT_CONFIG = {
|
|
18
|
+
maxSubtasks: 10,
|
|
19
|
+
minComplexityToDecompose: 3,
|
|
20
|
+
useLLM: false,
|
|
21
|
+
llmProvider: undefined,
|
|
22
|
+
codebaseAware: true,
|
|
23
|
+
defaultStrategy: 'adaptive',
|
|
24
|
+
detectConflicts: true,
|
|
25
|
+
};
|
|
26
|
+
// Task type indicators for heuristic analysis
|
|
27
|
+
const TYPE_INDICATORS = {
|
|
28
|
+
research: ['find', 'search', 'discover', 'locate', 'identify', 'explore', 'investigate'],
|
|
29
|
+
analysis: ['analyze', 'understand', 'examine', 'review', 'study', 'evaluate'],
|
|
30
|
+
design: ['design', 'plan', 'architect', 'structure', 'outline', 'sketch'],
|
|
31
|
+
implement: ['implement', 'create', 'build', 'write', 'code', 'develop', 'add'],
|
|
32
|
+
test: ['test', 'verify', 'validate', 'check', 'ensure', 'assert'],
|
|
33
|
+
refactor: ['refactor', 'improve', 'optimize', 'clean', 'simplify', 'restructure'],
|
|
34
|
+
review: ['review', 'inspect', 'audit', 'check', 'examine'],
|
|
35
|
+
document: ['document', 'describe', 'explain', 'annotate', 'comment'],
|
|
36
|
+
integrate: ['integrate', 'connect', 'combine', 'merge', 'link'],
|
|
37
|
+
deploy: ['deploy', 'release', 'publish', 'ship', 'launch'],
|
|
38
|
+
merge: ['merge', 'combine', 'consolidate', 'aggregate', 'synthesize'],
|
|
39
|
+
};
|
|
40
|
+
// =============================================================================
|
|
41
|
+
// SMART DECOMPOSER
|
|
42
|
+
// =============================================================================
|
|
43
|
+
/**
|
|
44
|
+
* Intelligently decomposes tasks using semantic analysis.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const decomposer = createSmartDecomposer({
|
|
49
|
+
* useLLM: true,
|
|
50
|
+
* llmProvider: async (task, context) => {
|
|
51
|
+
* // Call your LLM here
|
|
52
|
+
* return { subtasks: [...], strategy: 'parallel', reasoning: '...' };
|
|
53
|
+
* },
|
|
54
|
+
* });
|
|
55
|
+
*
|
|
56
|
+
* const result = await decomposer.decompose(
|
|
57
|
+
* 'Implement user authentication with OAuth2 and session management',
|
|
58
|
+
* { repoMap }
|
|
59
|
+
* );
|
|
60
|
+
*
|
|
61
|
+
* console.log(`Decomposed into ${result.subtasks.length} subtasks`);
|
|
62
|
+
* console.log(`Strategy: ${result.strategy}`);
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export class SmartDecomposer {
|
|
66
|
+
config;
|
|
67
|
+
listeners = [];
|
|
68
|
+
taskCounter = 0;
|
|
69
|
+
constructor(config = {}) {
|
|
70
|
+
this.config = {
|
|
71
|
+
...DEFAULT_CONFIG,
|
|
72
|
+
...config,
|
|
73
|
+
llmProvider: config.llmProvider ?? DEFAULT_CONFIG.llmProvider,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
// ===========================================================================
|
|
77
|
+
// DECOMPOSITION
|
|
78
|
+
// ===========================================================================
|
|
79
|
+
/**
|
|
80
|
+
* Decompose a task into subtasks.
|
|
81
|
+
*/
|
|
82
|
+
async decompose(task, context = {}) {
|
|
83
|
+
this.emit({ type: 'decomposition.started', task });
|
|
84
|
+
let subtasks;
|
|
85
|
+
let strategy;
|
|
86
|
+
let llmAssisted = false;
|
|
87
|
+
// Try LLM-assisted decomposition first
|
|
88
|
+
if (this.config.useLLM && this.config.llmProvider) {
|
|
89
|
+
try {
|
|
90
|
+
this.emit({ type: 'llm.called', task });
|
|
91
|
+
const llmResult = await this.config.llmProvider(task, context);
|
|
92
|
+
subtasks = this.convertLLMResult(llmResult);
|
|
93
|
+
strategy = llmResult.strategy;
|
|
94
|
+
llmAssisted = true;
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
// Fall back to heuristic decomposition
|
|
98
|
+
const heuristicResult = this.decomposeHeuristic(task, context);
|
|
99
|
+
subtasks = heuristicResult.subtasks;
|
|
100
|
+
strategy = heuristicResult.strategy;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
// Use heuristic decomposition
|
|
105
|
+
const heuristicResult = this.decomposeHeuristic(task, context);
|
|
106
|
+
subtasks = heuristicResult.subtasks;
|
|
107
|
+
strategy = heuristicResult.strategy;
|
|
108
|
+
}
|
|
109
|
+
// Limit subtasks
|
|
110
|
+
if (subtasks.length > this.config.maxSubtasks) {
|
|
111
|
+
subtasks = subtasks.slice(0, this.config.maxSubtasks);
|
|
112
|
+
}
|
|
113
|
+
// Enhance with codebase awareness
|
|
114
|
+
if (this.config.codebaseAware && context.repoMap) {
|
|
115
|
+
subtasks = this.enhanceWithCodebaseContext(subtasks, context.repoMap);
|
|
116
|
+
}
|
|
117
|
+
// Build dependency graph
|
|
118
|
+
const dependencyGraph = this.buildDependencyGraph(subtasks);
|
|
119
|
+
// Check for cycles
|
|
120
|
+
if (dependencyGraph.cycles.length > 0) {
|
|
121
|
+
for (const cycle of dependencyGraph.cycles) {
|
|
122
|
+
this.emit({ type: 'cycle.detected', cycle });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
// Detect resource conflicts
|
|
126
|
+
let conflicts = [];
|
|
127
|
+
if (this.config.detectConflicts) {
|
|
128
|
+
conflicts = this.detectConflicts(subtasks);
|
|
129
|
+
for (const conflict of conflicts) {
|
|
130
|
+
this.emit({ type: 'conflict.detected', conflict });
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
// Calculate totals
|
|
134
|
+
const totalComplexity = subtasks.reduce((sum, t) => sum + t.complexity, 0);
|
|
135
|
+
const totalEstimatedTokens = subtasks.reduce((sum, t) => sum + (t.estimatedTokens ?? 1000), 0);
|
|
136
|
+
const result = {
|
|
137
|
+
originalTask: task,
|
|
138
|
+
subtasks,
|
|
139
|
+
dependencyGraph,
|
|
140
|
+
conflicts,
|
|
141
|
+
strategy,
|
|
142
|
+
totalComplexity,
|
|
143
|
+
totalEstimatedTokens,
|
|
144
|
+
metadata: {
|
|
145
|
+
decomposedAt: new Date(),
|
|
146
|
+
codebaseAware: this.config.codebaseAware && !!context.repoMap,
|
|
147
|
+
llmAssisted,
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
this.emit({ type: 'decomposition.completed', result });
|
|
151
|
+
return result;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Convert LLM result to SmartSubtask array.
|
|
155
|
+
*/
|
|
156
|
+
convertLLMResult(llmResult) {
|
|
157
|
+
const idMap = new Map();
|
|
158
|
+
// First pass: create IDs
|
|
159
|
+
return llmResult.subtasks.map((s, index) => {
|
|
160
|
+
const id = `task-${++this.taskCounter}`;
|
|
161
|
+
idMap.set(s.description, id);
|
|
162
|
+
idMap.set(String(index), id);
|
|
163
|
+
return {
|
|
164
|
+
id,
|
|
165
|
+
description: s.description,
|
|
166
|
+
status: 'pending',
|
|
167
|
+
dependencies: [], // Will be resolved in second pass
|
|
168
|
+
complexity: s.complexity,
|
|
169
|
+
type: s.type,
|
|
170
|
+
parallelizable: s.parallelizable,
|
|
171
|
+
relevantFiles: s.relevantFiles,
|
|
172
|
+
suggestedRole: s.suggestedRole,
|
|
173
|
+
};
|
|
174
|
+
}).map((subtask, index) => {
|
|
175
|
+
// Second pass: resolve dependencies
|
|
176
|
+
const original = llmResult.subtasks[index];
|
|
177
|
+
subtask.dependencies = original.dependencies
|
|
178
|
+
.map((dep) => idMap.get(dep) ?? dep)
|
|
179
|
+
.filter((dep) => dep !== subtask.id);
|
|
180
|
+
// Update status based on dependencies
|
|
181
|
+
subtask.status = subtask.dependencies.length > 0 ? 'blocked' : 'ready';
|
|
182
|
+
return subtask;
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Heuristic-based decomposition when LLM is not available.
|
|
187
|
+
*/
|
|
188
|
+
decomposeHeuristic(task, _context) {
|
|
189
|
+
const taskLower = task.toLowerCase();
|
|
190
|
+
// Determine task type
|
|
191
|
+
const primaryType = this.inferTaskType(taskLower);
|
|
192
|
+
// Determine strategy
|
|
193
|
+
const strategy = this.inferStrategy(taskLower, primaryType);
|
|
194
|
+
// Generate subtasks based on strategy
|
|
195
|
+
let subtasks;
|
|
196
|
+
switch (strategy) {
|
|
197
|
+
case 'sequential':
|
|
198
|
+
subtasks = this.generateSequentialSubtasks(task, primaryType);
|
|
199
|
+
break;
|
|
200
|
+
case 'parallel':
|
|
201
|
+
subtasks = this.generateParallelSubtasks(task, primaryType);
|
|
202
|
+
break;
|
|
203
|
+
case 'hierarchical':
|
|
204
|
+
subtasks = this.generateHierarchicalSubtasks(task, primaryType);
|
|
205
|
+
break;
|
|
206
|
+
case 'pipeline':
|
|
207
|
+
subtasks = this.generatePipelineSubtasks(task, primaryType);
|
|
208
|
+
break;
|
|
209
|
+
default:
|
|
210
|
+
subtasks = this.generateAdaptiveSubtasks(task, primaryType);
|
|
211
|
+
}
|
|
212
|
+
return { subtasks, strategy };
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Infer the primary task type from description.
|
|
216
|
+
*/
|
|
217
|
+
inferTaskType(taskLower) {
|
|
218
|
+
for (const [type, indicators] of Object.entries(TYPE_INDICATORS)) {
|
|
219
|
+
for (const indicator of indicators) {
|
|
220
|
+
if (taskLower.includes(indicator)) {
|
|
221
|
+
return type;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return 'implement'; // Default
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Infer decomposition strategy from task description.
|
|
229
|
+
*/
|
|
230
|
+
inferStrategy(taskLower, primaryType) {
|
|
231
|
+
// Sequential indicators
|
|
232
|
+
if (taskLower.includes('then') ||
|
|
233
|
+
taskLower.includes('after') ||
|
|
234
|
+
taskLower.includes('before') ||
|
|
235
|
+
taskLower.includes('first') ||
|
|
236
|
+
taskLower.includes('step by step')) {
|
|
237
|
+
return 'sequential';
|
|
238
|
+
}
|
|
239
|
+
// Parallel indicators
|
|
240
|
+
if (taskLower.includes('in parallel') ||
|
|
241
|
+
taskLower.includes('simultaneously') ||
|
|
242
|
+
taskLower.includes('at the same time') ||
|
|
243
|
+
(taskLower.includes('all') && taskLower.includes('files'))) {
|
|
244
|
+
return 'parallel';
|
|
245
|
+
}
|
|
246
|
+
// Pipeline indicators
|
|
247
|
+
if (taskLower.includes('process') ||
|
|
248
|
+
taskLower.includes('transform') ||
|
|
249
|
+
taskLower.includes('pipeline')) {
|
|
250
|
+
return 'pipeline';
|
|
251
|
+
}
|
|
252
|
+
// Hierarchical for complex tasks
|
|
253
|
+
if (taskLower.includes('complex') ||
|
|
254
|
+
taskLower.includes('comprehensive') ||
|
|
255
|
+
taskLower.includes('full') ||
|
|
256
|
+
taskLower.length > 200) {
|
|
257
|
+
return 'hierarchical';
|
|
258
|
+
}
|
|
259
|
+
// Type-based defaults
|
|
260
|
+
switch (primaryType) {
|
|
261
|
+
case 'research':
|
|
262
|
+
case 'analysis':
|
|
263
|
+
return 'parallel';
|
|
264
|
+
case 'implement':
|
|
265
|
+
case 'refactor':
|
|
266
|
+
return 'sequential';
|
|
267
|
+
default:
|
|
268
|
+
return 'adaptive';
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Generate sequential subtasks.
|
|
273
|
+
*/
|
|
274
|
+
generateSequentialSubtasks(task, type) {
|
|
275
|
+
const subtasks = [];
|
|
276
|
+
let prevId = null;
|
|
277
|
+
// Research phase
|
|
278
|
+
const researchId = `task-${++this.taskCounter}`;
|
|
279
|
+
subtasks.push({
|
|
280
|
+
id: researchId,
|
|
281
|
+
description: `Research and understand: ${task}`,
|
|
282
|
+
status: 'ready',
|
|
283
|
+
dependencies: [],
|
|
284
|
+
complexity: 2,
|
|
285
|
+
type: 'research',
|
|
286
|
+
parallelizable: false,
|
|
287
|
+
});
|
|
288
|
+
prevId = researchId;
|
|
289
|
+
// Main execution phase
|
|
290
|
+
const executeId = `task-${++this.taskCounter}`;
|
|
291
|
+
subtasks.push({
|
|
292
|
+
id: executeId,
|
|
293
|
+
description: `Execute: ${task}`,
|
|
294
|
+
status: 'blocked',
|
|
295
|
+
dependencies: [prevId],
|
|
296
|
+
complexity: 5,
|
|
297
|
+
type,
|
|
298
|
+
parallelizable: false,
|
|
299
|
+
});
|
|
300
|
+
prevId = executeId;
|
|
301
|
+
// Verification phase
|
|
302
|
+
const verifyId = `task-${++this.taskCounter}`;
|
|
303
|
+
subtasks.push({
|
|
304
|
+
id: verifyId,
|
|
305
|
+
description: `Verify and test: ${task}`,
|
|
306
|
+
status: 'blocked',
|
|
307
|
+
dependencies: [prevId],
|
|
308
|
+
complexity: 2,
|
|
309
|
+
type: 'test',
|
|
310
|
+
parallelizable: false,
|
|
311
|
+
});
|
|
312
|
+
return subtasks;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Generate parallel subtasks.
|
|
316
|
+
*/
|
|
317
|
+
generateParallelSubtasks(task, type) {
|
|
318
|
+
const subtasks = [];
|
|
319
|
+
// Split task into parts
|
|
320
|
+
const parts = this.splitIntoParts(task);
|
|
321
|
+
const partIds = [];
|
|
322
|
+
for (const part of parts) {
|
|
323
|
+
const id = `task-${++this.taskCounter}`;
|
|
324
|
+
partIds.push(id);
|
|
325
|
+
subtasks.push({
|
|
326
|
+
id,
|
|
327
|
+
description: part,
|
|
328
|
+
status: 'ready',
|
|
329
|
+
dependencies: [],
|
|
330
|
+
complexity: Math.ceil(5 / parts.length),
|
|
331
|
+
type,
|
|
332
|
+
parallelizable: true,
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
// Merge task
|
|
336
|
+
subtasks.push({
|
|
337
|
+
id: `task-${++this.taskCounter}`,
|
|
338
|
+
description: `Combine results: ${task}`,
|
|
339
|
+
status: 'blocked',
|
|
340
|
+
dependencies: partIds,
|
|
341
|
+
complexity: 2,
|
|
342
|
+
type: 'merge',
|
|
343
|
+
parallelizable: false,
|
|
344
|
+
});
|
|
345
|
+
return subtasks;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Generate hierarchical subtasks.
|
|
349
|
+
*/
|
|
350
|
+
generateHierarchicalSubtasks(task, _type) {
|
|
351
|
+
const subtasks = [];
|
|
352
|
+
let prevId = null;
|
|
353
|
+
const phases = [
|
|
354
|
+
{ name: 'Analysis', type: 'analysis', complexity: 2 },
|
|
355
|
+
{ name: 'Design', type: 'design', complexity: 3 },
|
|
356
|
+
{ name: 'Implementation', type: 'implement', complexity: 5 },
|
|
357
|
+
{ name: 'Testing', type: 'test', complexity: 2 },
|
|
358
|
+
{ name: 'Review', type: 'review', complexity: 2 },
|
|
359
|
+
];
|
|
360
|
+
for (const phase of phases) {
|
|
361
|
+
const id = `task-${++this.taskCounter}`;
|
|
362
|
+
subtasks.push({
|
|
363
|
+
id,
|
|
364
|
+
description: `${phase.name}: ${task}`,
|
|
365
|
+
status: prevId ? 'blocked' : 'ready',
|
|
366
|
+
dependencies: prevId ? [prevId] : [],
|
|
367
|
+
complexity: phase.complexity,
|
|
368
|
+
type: phase.type,
|
|
369
|
+
parallelizable: false,
|
|
370
|
+
});
|
|
371
|
+
prevId = id;
|
|
372
|
+
}
|
|
373
|
+
return subtasks;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Generate pipeline subtasks.
|
|
377
|
+
*/
|
|
378
|
+
generatePipelineSubtasks(task, type) {
|
|
379
|
+
const subtasks = [];
|
|
380
|
+
let prevId = null;
|
|
381
|
+
const stages = [
|
|
382
|
+
{ name: 'Input', desc: 'Gather inputs' },
|
|
383
|
+
{ name: 'Transform', desc: 'Process data' },
|
|
384
|
+
{ name: 'Validate', desc: 'Validate results' },
|
|
385
|
+
{ name: 'Output', desc: 'Generate output' },
|
|
386
|
+
];
|
|
387
|
+
for (const stage of stages) {
|
|
388
|
+
const id = `task-${++this.taskCounter}`;
|
|
389
|
+
subtasks.push({
|
|
390
|
+
id,
|
|
391
|
+
description: `${stage.name}: ${stage.desc} for ${task}`,
|
|
392
|
+
status: prevId ? 'blocked' : 'ready',
|
|
393
|
+
dependencies: prevId ? [prevId] : [],
|
|
394
|
+
complexity: 2,
|
|
395
|
+
type,
|
|
396
|
+
parallelizable: false,
|
|
397
|
+
});
|
|
398
|
+
prevId = id;
|
|
399
|
+
}
|
|
400
|
+
return subtasks;
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Generate adaptive subtasks (mix of strategies).
|
|
404
|
+
*/
|
|
405
|
+
generateAdaptiveSubtasks(task, type) {
|
|
406
|
+
const subtasks = [];
|
|
407
|
+
// Research (can be parallel)
|
|
408
|
+
const researchId = `task-${++this.taskCounter}`;
|
|
409
|
+
subtasks.push({
|
|
410
|
+
id: researchId,
|
|
411
|
+
description: `Research: ${task}`,
|
|
412
|
+
status: 'ready',
|
|
413
|
+
dependencies: [],
|
|
414
|
+
complexity: 2,
|
|
415
|
+
type: 'research',
|
|
416
|
+
parallelizable: true,
|
|
417
|
+
});
|
|
418
|
+
// Analysis (can be parallel with research)
|
|
419
|
+
const analysisId = `task-${++this.taskCounter}`;
|
|
420
|
+
subtasks.push({
|
|
421
|
+
id: analysisId,
|
|
422
|
+
description: `Analyze requirements: ${task}`,
|
|
423
|
+
status: 'ready',
|
|
424
|
+
dependencies: [],
|
|
425
|
+
complexity: 2,
|
|
426
|
+
type: 'analysis',
|
|
427
|
+
parallelizable: true,
|
|
428
|
+
});
|
|
429
|
+
// Implementation (depends on both)
|
|
430
|
+
const implId = `task-${++this.taskCounter}`;
|
|
431
|
+
subtasks.push({
|
|
432
|
+
id: implId,
|
|
433
|
+
description: `Implement: ${task}`,
|
|
434
|
+
status: 'blocked',
|
|
435
|
+
dependencies: [researchId, analysisId],
|
|
436
|
+
complexity: 5,
|
|
437
|
+
type,
|
|
438
|
+
parallelizable: false,
|
|
439
|
+
});
|
|
440
|
+
// Testing (depends on implementation)
|
|
441
|
+
subtasks.push({
|
|
442
|
+
id: `task-${++this.taskCounter}`,
|
|
443
|
+
description: `Test: ${task}`,
|
|
444
|
+
status: 'blocked',
|
|
445
|
+
dependencies: [implId],
|
|
446
|
+
complexity: 2,
|
|
447
|
+
type: 'test',
|
|
448
|
+
parallelizable: false,
|
|
449
|
+
});
|
|
450
|
+
return subtasks;
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Split task description into parts.
|
|
454
|
+
*/
|
|
455
|
+
splitIntoParts(task) {
|
|
456
|
+
// Try to find natural splits
|
|
457
|
+
const connectors = [' and ', ', ', '; ', ' also ', ' additionally '];
|
|
458
|
+
let parts = [task];
|
|
459
|
+
for (const connector of connectors) {
|
|
460
|
+
if (task.toLowerCase().includes(connector.toLowerCase())) {
|
|
461
|
+
parts = task.split(new RegExp(connector, 'i'));
|
|
462
|
+
break;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
// Clean up and filter
|
|
466
|
+
parts = parts
|
|
467
|
+
.map((p) => p.trim())
|
|
468
|
+
.filter((p) => p.length > 10);
|
|
469
|
+
// If no good splits, create generic parts
|
|
470
|
+
if (parts.length < 2) {
|
|
471
|
+
parts = [
|
|
472
|
+
`Part 1: ${task}`,
|
|
473
|
+
`Part 2: ${task}`,
|
|
474
|
+
];
|
|
475
|
+
}
|
|
476
|
+
return parts.slice(0, 5);
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* Enhance subtasks with codebase context.
|
|
480
|
+
*/
|
|
481
|
+
enhanceWithCodebaseContext(subtasks, repoMap) {
|
|
482
|
+
return subtasks.map((subtask) => {
|
|
483
|
+
// Find relevant files based on task description
|
|
484
|
+
const relevantFiles = this.findRelevantFiles(subtask.description, repoMap);
|
|
485
|
+
// Estimate tokens based on relevant files
|
|
486
|
+
const estimatedTokens = relevantFiles.reduce((sum, file) => {
|
|
487
|
+
const chunk = repoMap.chunks.get(file);
|
|
488
|
+
return sum + (chunk?.tokenCount ?? 500);
|
|
489
|
+
}, 1000); // Base tokens for the task itself
|
|
490
|
+
return {
|
|
491
|
+
...subtask,
|
|
492
|
+
relevantFiles: relevantFiles.slice(0, 5),
|
|
493
|
+
estimatedTokens,
|
|
494
|
+
};
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Find files relevant to a task description.
|
|
499
|
+
*/
|
|
500
|
+
findRelevantFiles(description, repoMap) {
|
|
501
|
+
const descLower = description.toLowerCase();
|
|
502
|
+
const words = descLower.split(/\s+/).filter((w) => w.length > 3);
|
|
503
|
+
const scored = [];
|
|
504
|
+
for (const [file, chunk] of repoMap.chunks) {
|
|
505
|
+
let score = 0;
|
|
506
|
+
// Check file path
|
|
507
|
+
const fileLower = file.toLowerCase();
|
|
508
|
+
for (const word of words) {
|
|
509
|
+
if (fileLower.includes(word)) {
|
|
510
|
+
score += 2;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
// Check symbols
|
|
514
|
+
for (const symbol of chunk.symbols) {
|
|
515
|
+
const symbolLower = symbol.toLowerCase();
|
|
516
|
+
for (const word of words) {
|
|
517
|
+
if (symbolLower.includes(word) || word.includes(symbolLower)) {
|
|
518
|
+
score += 1;
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
if (score > 0) {
|
|
523
|
+
scored.push({ file, score });
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
// Sort by score and return top files
|
|
527
|
+
scored.sort((a, b) => b.score - a.score);
|
|
528
|
+
return scored.slice(0, 10).map((s) => s.file);
|
|
529
|
+
}
|
|
530
|
+
// ===========================================================================
|
|
531
|
+
// DEPENDENCY GRAPH
|
|
532
|
+
// ===========================================================================
|
|
533
|
+
/**
|
|
534
|
+
* Build a dependency graph from subtasks.
|
|
535
|
+
*/
|
|
536
|
+
buildDependencyGraph(subtasks) {
|
|
537
|
+
const dependencies = new Map();
|
|
538
|
+
const dependents = new Map();
|
|
539
|
+
// Build maps
|
|
540
|
+
for (const subtask of subtasks) {
|
|
541
|
+
dependencies.set(subtask.id, subtask.dependencies);
|
|
542
|
+
for (const dep of subtask.dependencies) {
|
|
543
|
+
if (!dependents.has(dep)) {
|
|
544
|
+
dependents.set(dep, []);
|
|
545
|
+
}
|
|
546
|
+
dependents.get(dep).push(subtask.id);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
// Detect cycles
|
|
550
|
+
const cycles = this.detectCycles(subtasks, dependencies);
|
|
551
|
+
// Calculate execution order (topological sort)
|
|
552
|
+
const executionOrder = this.topologicalSort(subtasks, dependencies);
|
|
553
|
+
// Calculate parallel groups
|
|
554
|
+
const parallelGroups = this.calculateParallelGroups(subtasks, dependencies);
|
|
555
|
+
return {
|
|
556
|
+
dependencies,
|
|
557
|
+
dependents,
|
|
558
|
+
executionOrder,
|
|
559
|
+
parallelGroups,
|
|
560
|
+
cycles,
|
|
561
|
+
};
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* Detect cycles in dependency graph.
|
|
565
|
+
*/
|
|
566
|
+
detectCycles(subtasks, dependencies) {
|
|
567
|
+
const cycles = [];
|
|
568
|
+
const visited = new Set();
|
|
569
|
+
const inStack = new Set();
|
|
570
|
+
const dfs = (id, path) => {
|
|
571
|
+
if (inStack.has(id)) {
|
|
572
|
+
// Found cycle
|
|
573
|
+
const cycleStart = path.indexOf(id);
|
|
574
|
+
cycles.push(path.slice(cycleStart));
|
|
575
|
+
return;
|
|
576
|
+
}
|
|
577
|
+
if (visited.has(id))
|
|
578
|
+
return;
|
|
579
|
+
visited.add(id);
|
|
580
|
+
inStack.add(id);
|
|
581
|
+
const deps = dependencies.get(id) ?? [];
|
|
582
|
+
for (const dep of deps) {
|
|
583
|
+
dfs(dep, [...path, id]);
|
|
584
|
+
}
|
|
585
|
+
inStack.delete(id);
|
|
586
|
+
};
|
|
587
|
+
for (const subtask of subtasks) {
|
|
588
|
+
dfs(subtask.id, []);
|
|
589
|
+
}
|
|
590
|
+
return cycles;
|
|
591
|
+
}
|
|
592
|
+
/**
|
|
593
|
+
* Topological sort of tasks.
|
|
594
|
+
*/
|
|
595
|
+
topologicalSort(subtasks, dependencies) {
|
|
596
|
+
const result = [];
|
|
597
|
+
const visited = new Set();
|
|
598
|
+
const temp = new Set();
|
|
599
|
+
const visit = (id) => {
|
|
600
|
+
if (temp.has(id))
|
|
601
|
+
return false; // Cycle
|
|
602
|
+
if (visited.has(id))
|
|
603
|
+
return true;
|
|
604
|
+
temp.add(id);
|
|
605
|
+
const deps = dependencies.get(id) ?? [];
|
|
606
|
+
for (const dep of deps) {
|
|
607
|
+
if (!visit(dep))
|
|
608
|
+
return false;
|
|
609
|
+
}
|
|
610
|
+
temp.delete(id);
|
|
611
|
+
visited.add(id);
|
|
612
|
+
result.push(id);
|
|
613
|
+
return true;
|
|
614
|
+
};
|
|
615
|
+
for (const subtask of subtasks) {
|
|
616
|
+
visit(subtask.id);
|
|
617
|
+
}
|
|
618
|
+
return result;
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* Calculate groups of tasks that can run in parallel.
|
|
622
|
+
*/
|
|
623
|
+
calculateParallelGroups(subtasks, dependencies) {
|
|
624
|
+
const groups = [];
|
|
625
|
+
const completed = new Set();
|
|
626
|
+
const remaining = new Set(subtasks.map((s) => s.id));
|
|
627
|
+
while (remaining.size > 0) {
|
|
628
|
+
const group = [];
|
|
629
|
+
for (const id of remaining) {
|
|
630
|
+
const deps = dependencies.get(id) ?? [];
|
|
631
|
+
const allDepsCompleted = deps.every((dep) => completed.has(dep));
|
|
632
|
+
if (allDepsCompleted) {
|
|
633
|
+
const subtask = subtasks.find((s) => s.id === id);
|
|
634
|
+
if (subtask?.parallelizable || group.length === 0) {
|
|
635
|
+
group.push(id);
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
if (group.length === 0) {
|
|
640
|
+
// No progress - likely a cycle, break to avoid infinite loop
|
|
641
|
+
break;
|
|
642
|
+
}
|
|
643
|
+
groups.push(group);
|
|
644
|
+
for (const id of group) {
|
|
645
|
+
completed.add(id);
|
|
646
|
+
remaining.delete(id);
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
return groups;
|
|
650
|
+
}
|
|
651
|
+
// ===========================================================================
|
|
652
|
+
// CONFLICT DETECTION
|
|
653
|
+
// ===========================================================================
|
|
654
|
+
/**
|
|
655
|
+
* Detect resource conflicts between subtasks.
|
|
656
|
+
*/
|
|
657
|
+
detectConflicts(subtasks) {
|
|
658
|
+
const conflicts = [];
|
|
659
|
+
const writeResources = new Map(); // resource -> taskIds
|
|
660
|
+
const readResources = new Map();
|
|
661
|
+
// Collect resource usage
|
|
662
|
+
for (const subtask of subtasks) {
|
|
663
|
+
for (const resource of subtask.modifies ?? []) {
|
|
664
|
+
if (!writeResources.has(resource)) {
|
|
665
|
+
writeResources.set(resource, []);
|
|
666
|
+
}
|
|
667
|
+
writeResources.get(resource).push(subtask.id);
|
|
668
|
+
}
|
|
669
|
+
for (const resource of subtask.reads ?? []) {
|
|
670
|
+
if (!readResources.has(resource)) {
|
|
671
|
+
readResources.set(resource, []);
|
|
672
|
+
}
|
|
673
|
+
readResources.get(resource).push(subtask.id);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
// Check for write-write conflicts
|
|
677
|
+
for (const [resource, taskIds] of writeResources) {
|
|
678
|
+
if (taskIds.length > 1) {
|
|
679
|
+
// Check if tasks are in parallel groups
|
|
680
|
+
const parallelConflict = this.areInParallel(taskIds, subtasks);
|
|
681
|
+
if (parallelConflict) {
|
|
682
|
+
conflicts.push({
|
|
683
|
+
resource,
|
|
684
|
+
taskIds,
|
|
685
|
+
type: 'write-write',
|
|
686
|
+
severity: 'error',
|
|
687
|
+
suggestion: `Tasks ${taskIds.join(', ')} both write to ${resource}. ` +
|
|
688
|
+
`Consider making them sequential or coordinating through the blackboard.`,
|
|
689
|
+
});
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
// Check for read-write conflicts
|
|
694
|
+
for (const [resource, writeTaskIds] of writeResources) {
|
|
695
|
+
const readTaskIds = readResources.get(resource) ?? [];
|
|
696
|
+
for (const writeId of writeTaskIds) {
|
|
697
|
+
for (const readId of readTaskIds) {
|
|
698
|
+
if (writeId !== readId && this.areInParallel([writeId, readId], subtasks)) {
|
|
699
|
+
conflicts.push({
|
|
700
|
+
resource,
|
|
701
|
+
taskIds: [writeId, readId],
|
|
702
|
+
type: 'read-write',
|
|
703
|
+
severity: 'warning',
|
|
704
|
+
suggestion: `Task ${writeId} writes to ${resource} while ${readId} reads it. ` +
|
|
705
|
+
`Consider adding a dependency to ensure correct ordering.`,
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
return conflicts;
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* Check if tasks can run in parallel (no dependencies between them).
|
|
715
|
+
*/
|
|
716
|
+
areInParallel(taskIds, subtasks) {
|
|
717
|
+
const taskMap = new Map(subtasks.map((s) => [s.id, s]));
|
|
718
|
+
for (let i = 0; i < taskIds.length; i++) {
|
|
719
|
+
for (let j = i + 1; j < taskIds.length; j++) {
|
|
720
|
+
const task1 = taskMap.get(taskIds[i]);
|
|
721
|
+
const task2 = taskMap.get(taskIds[j]);
|
|
722
|
+
if (task1 && task2) {
|
|
723
|
+
// Check if either depends on the other
|
|
724
|
+
if (!task1.dependencies.includes(task2.id) &&
|
|
725
|
+
!task2.dependencies.includes(task1.id)) {
|
|
726
|
+
return true; // Can run in parallel
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
return false;
|
|
732
|
+
}
|
|
733
|
+
// ===========================================================================
|
|
734
|
+
// UTILITIES
|
|
735
|
+
// ===========================================================================
|
|
736
|
+
/**
|
|
737
|
+
* Subscribe to events.
|
|
738
|
+
*/
|
|
739
|
+
on(listener) {
|
|
740
|
+
this.listeners.push(listener);
|
|
741
|
+
return () => {
|
|
742
|
+
const idx = this.listeners.indexOf(listener);
|
|
743
|
+
if (idx >= 0)
|
|
744
|
+
this.listeners.splice(idx, 1);
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
emit(event) {
|
|
748
|
+
for (const listener of this.listeners) {
|
|
749
|
+
try {
|
|
750
|
+
listener(event);
|
|
751
|
+
}
|
|
752
|
+
catch {
|
|
753
|
+
// Ignore listener errors
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
// =============================================================================
|
|
759
|
+
// FACTORY FUNCTIONS
|
|
760
|
+
// =============================================================================
|
|
761
|
+
/**
|
|
762
|
+
* Create a smart decomposer.
|
|
763
|
+
*
|
|
764
|
+
* @example
|
|
765
|
+
* ```typescript
|
|
766
|
+
* // Simple heuristic decomposition
|
|
767
|
+
* const decomposer = createSmartDecomposer();
|
|
768
|
+
*
|
|
769
|
+
* // LLM-assisted decomposition
|
|
770
|
+
* const decomposer = createSmartDecomposer({
|
|
771
|
+
* useLLM: true,
|
|
772
|
+
* llmProvider: async (task, context) => {
|
|
773
|
+
* const response = await llm.complete({
|
|
774
|
+
* prompt: `Decompose this task: ${task}`,
|
|
775
|
+
* // ...
|
|
776
|
+
* });
|
|
777
|
+
* return parseDecomposition(response);
|
|
778
|
+
* },
|
|
779
|
+
* });
|
|
780
|
+
*
|
|
781
|
+
* const result = await decomposer.decompose('Build a REST API for user management');
|
|
782
|
+
* ```
|
|
783
|
+
*/
|
|
784
|
+
export function createSmartDecomposer(config = {}) {
|
|
785
|
+
return new SmartDecomposer(config);
|
|
786
|
+
}
|
|
787
|
+
/**
|
|
788
|
+
* Create an LLM prompt for task decomposition.
|
|
789
|
+
*/
|
|
790
|
+
export function createDecompositionPrompt(task, context) {
|
|
791
|
+
const parts = [
|
|
792
|
+
'You are a task decomposition expert. Break down the following task into subtasks.',
|
|
793
|
+
'',
|
|
794
|
+
`Task: ${task}`,
|
|
795
|
+
'',
|
|
796
|
+
];
|
|
797
|
+
if (context.repoMap) {
|
|
798
|
+
parts.push('Codebase context:');
|
|
799
|
+
parts.push(`- ${context.repoMap.chunks.size} files`);
|
|
800
|
+
parts.push(`- Entry points: ${context.repoMap.entryPoints.slice(0, 3).join(', ')}`);
|
|
801
|
+
parts.push('');
|
|
802
|
+
}
|
|
803
|
+
if (context.hints && context.hints.length > 0) {
|
|
804
|
+
parts.push('Hints:');
|
|
805
|
+
for (const hint of context.hints) {
|
|
806
|
+
parts.push(`- ${hint}`);
|
|
807
|
+
}
|
|
808
|
+
parts.push('');
|
|
809
|
+
}
|
|
810
|
+
parts.push('For each subtask, provide:');
|
|
811
|
+
parts.push('1. Description');
|
|
812
|
+
parts.push('2. Type (research, analysis, design, implement, test, refactor, review, document, integrate, deploy, merge)');
|
|
813
|
+
parts.push('3. Complexity (1-10)');
|
|
814
|
+
parts.push('4. Dependencies (which other subtasks must complete first)');
|
|
815
|
+
parts.push('5. Whether it can run in parallel with other tasks');
|
|
816
|
+
parts.push('');
|
|
817
|
+
parts.push('Also suggest an overall strategy: sequential, parallel, hierarchical, adaptive, or pipeline.');
|
|
818
|
+
parts.push('');
|
|
819
|
+
parts.push('Respond in JSON format.');
|
|
820
|
+
return parts.join('\n');
|
|
821
|
+
}
|
|
822
|
+
/**
|
|
823
|
+
* Parse LLM response into decomposition result.
|
|
824
|
+
*/
|
|
825
|
+
export function parseDecompositionResponse(response) {
|
|
826
|
+
try {
|
|
827
|
+
// Try to extract JSON from the response
|
|
828
|
+
const jsonMatch = response.match(/\{[\s\S]*\}/);
|
|
829
|
+
if (!jsonMatch) {
|
|
830
|
+
throw new Error('No JSON found in response');
|
|
831
|
+
}
|
|
832
|
+
const parsed = JSON.parse(jsonMatch[0]);
|
|
833
|
+
return {
|
|
834
|
+
subtasks: (parsed.subtasks || []).map((s) => ({
|
|
835
|
+
description: s.description || '',
|
|
836
|
+
type: s.type || 'implement',
|
|
837
|
+
complexity: s.complexity || 3,
|
|
838
|
+
dependencies: s.dependencies || [],
|
|
839
|
+
parallelizable: s.parallelizable ?? true,
|
|
840
|
+
relevantFiles: s.relevantFiles,
|
|
841
|
+
suggestedRole: s.suggestedRole,
|
|
842
|
+
})),
|
|
843
|
+
strategy: parsed.strategy || 'adaptive',
|
|
844
|
+
reasoning: parsed.reasoning || '',
|
|
845
|
+
};
|
|
846
|
+
}
|
|
847
|
+
catch {
|
|
848
|
+
// Return default if parsing fails
|
|
849
|
+
return {
|
|
850
|
+
subtasks: [],
|
|
851
|
+
strategy: 'adaptive',
|
|
852
|
+
reasoning: 'Failed to parse LLM response',
|
|
853
|
+
};
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
//# sourceMappingURL=smart-decomposer.js.map
|