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,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pending Plan Manager
|
|
3
|
+
*
|
|
4
|
+
* Manages plans that are awaiting user approval before execution.
|
|
5
|
+
* Used in "plan mode" where write operations are intercepted and queued
|
|
6
|
+
* as proposed changes rather than being executed immediately.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const planManager = createPendingPlanManager();
|
|
11
|
+
*
|
|
12
|
+
* // In plan mode, intercept a write operation
|
|
13
|
+
* planManager.addProposedChange({
|
|
14
|
+
* tool: 'write_file',
|
|
15
|
+
* args: { path: 'src/main.ts', content: '...' },
|
|
16
|
+
* reason: 'Create entry point for the application',
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* // User approves the plan
|
|
20
|
+
* const changes = planManager.approve();
|
|
21
|
+
* for (const change of changes) {
|
|
22
|
+
* await executeTool(change.tool, change.args);
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* Status of a pending plan.
|
|
28
|
+
*/
|
|
29
|
+
export type PlanStatus = 'pending' | 'approved' | 'rejected' | 'partially_approved';
|
|
30
|
+
/**
|
|
31
|
+
* A proposed change that will be executed if the plan is approved.
|
|
32
|
+
*/
|
|
33
|
+
export interface ProposedChange {
|
|
34
|
+
/** Unique ID for this change */
|
|
35
|
+
id: string;
|
|
36
|
+
/** The tool that would be called */
|
|
37
|
+
tool: string;
|
|
38
|
+
/** Arguments for the tool call */
|
|
39
|
+
args: Record<string, unknown>;
|
|
40
|
+
/** LLM's explanation of why this change is needed */
|
|
41
|
+
reason: string;
|
|
42
|
+
/** Order in which this change should be executed */
|
|
43
|
+
order: number;
|
|
44
|
+
/** Timestamp when this change was proposed */
|
|
45
|
+
proposedAt: string;
|
|
46
|
+
/** Optional: The tool call ID from the LLM response */
|
|
47
|
+
toolCallId?: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A pending plan awaiting user approval.
|
|
51
|
+
*/
|
|
52
|
+
export interface PendingPlan {
|
|
53
|
+
/** Unique plan ID */
|
|
54
|
+
id: string;
|
|
55
|
+
/** The original task/prompt that led to this plan */
|
|
56
|
+
task: string;
|
|
57
|
+
/** When the plan was created */
|
|
58
|
+
createdAt: string;
|
|
59
|
+
/** When the plan was last updated */
|
|
60
|
+
updatedAt: string;
|
|
61
|
+
/** The proposed changes in execution order */
|
|
62
|
+
proposedChanges: ProposedChange[];
|
|
63
|
+
/** Summary of exploration done before proposing changes */
|
|
64
|
+
explorationSummary: string;
|
|
65
|
+
/** Current status of the plan */
|
|
66
|
+
status: PlanStatus;
|
|
67
|
+
/** Session ID this plan belongs to */
|
|
68
|
+
sessionId?: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Result of approving a plan.
|
|
72
|
+
*/
|
|
73
|
+
export interface PlanApprovalResult {
|
|
74
|
+
/** Changes to execute */
|
|
75
|
+
changes: ProposedChange[];
|
|
76
|
+
/** Number of changes skipped (if partial approval) */
|
|
77
|
+
skippedCount: number;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Event types emitted by the plan manager.
|
|
81
|
+
*/
|
|
82
|
+
export type PendingPlanEvent = {
|
|
83
|
+
type: 'plan.created';
|
|
84
|
+
plan: PendingPlan;
|
|
85
|
+
} | {
|
|
86
|
+
type: 'plan.change.added';
|
|
87
|
+
change: ProposedChange;
|
|
88
|
+
planId: string;
|
|
89
|
+
} | {
|
|
90
|
+
type: 'plan.approved';
|
|
91
|
+
planId: string;
|
|
92
|
+
changeCount: number;
|
|
93
|
+
} | {
|
|
94
|
+
type: 'plan.rejected';
|
|
95
|
+
planId: string;
|
|
96
|
+
} | {
|
|
97
|
+
type: 'plan.cleared';
|
|
98
|
+
planId: string;
|
|
99
|
+
};
|
|
100
|
+
export type PendingPlanEventListener = (event: PendingPlanEvent) => void;
|
|
101
|
+
/**
|
|
102
|
+
* Manages pending plans that await user approval.
|
|
103
|
+
*/
|
|
104
|
+
export declare class PendingPlanManager {
|
|
105
|
+
private currentPlan;
|
|
106
|
+
private changeCounter;
|
|
107
|
+
private eventListeners;
|
|
108
|
+
/**
|
|
109
|
+
* Start a new pending plan.
|
|
110
|
+
* Clears any existing plan.
|
|
111
|
+
*/
|
|
112
|
+
startPlan(task: string, sessionId?: string): PendingPlan;
|
|
113
|
+
/**
|
|
114
|
+
* Add a proposed change to the current plan.
|
|
115
|
+
* Returns the created change, or null if no plan is active.
|
|
116
|
+
*/
|
|
117
|
+
addProposedChange(tool: string, args: Record<string, unknown>, reason: string, toolCallId?: string): ProposedChange | null;
|
|
118
|
+
/**
|
|
119
|
+
* Set the exploration summary for the current plan.
|
|
120
|
+
*/
|
|
121
|
+
setExplorationSummary(summary: string): void;
|
|
122
|
+
/**
|
|
123
|
+
* Get the current pending plan.
|
|
124
|
+
*/
|
|
125
|
+
getPendingPlan(): PendingPlan | null;
|
|
126
|
+
/**
|
|
127
|
+
* Check if there's an active pending plan.
|
|
128
|
+
*/
|
|
129
|
+
hasPendingPlan(): boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Get the number of proposed changes.
|
|
132
|
+
*/
|
|
133
|
+
getChangeCount(): number;
|
|
134
|
+
/**
|
|
135
|
+
* Approve the pending plan.
|
|
136
|
+
* @param count - If provided, only approve the first N changes
|
|
137
|
+
* @returns The changes to execute
|
|
138
|
+
*/
|
|
139
|
+
approve(count?: number): PlanApprovalResult;
|
|
140
|
+
/**
|
|
141
|
+
* Reject the pending plan.
|
|
142
|
+
* Clears all proposed changes.
|
|
143
|
+
*/
|
|
144
|
+
reject(): void;
|
|
145
|
+
/**
|
|
146
|
+
* Clear the current plan without changing status.
|
|
147
|
+
*/
|
|
148
|
+
clear(): void;
|
|
149
|
+
/**
|
|
150
|
+
* Restore a plan from storage.
|
|
151
|
+
*/
|
|
152
|
+
restorePlan(plan: PendingPlan): void;
|
|
153
|
+
/**
|
|
154
|
+
* Format the pending plan for display.
|
|
155
|
+
*/
|
|
156
|
+
formatPlan(): string;
|
|
157
|
+
/**
|
|
158
|
+
* Subscribe to plan events.
|
|
159
|
+
*/
|
|
160
|
+
subscribe(listener: PendingPlanEventListener): () => void;
|
|
161
|
+
private emit;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Create a new pending plan manager.
|
|
165
|
+
*/
|
|
166
|
+
export declare function createPendingPlanManager(): PendingPlanManager;
|
|
167
|
+
/**
|
|
168
|
+
* Format a plan for compact display (e.g., in status bar).
|
|
169
|
+
*/
|
|
170
|
+
export declare function formatPlanStatus(plan: PendingPlan | null): string;
|
|
171
|
+
//# sourceMappingURL=pending-plan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pending-plan.d.ts","sourceRoot":"","sources":["../../../src/integrations/pending-plan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAMH;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,oBAAoB,CAAC;AAEpF;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,gCAAgC;IAChC,EAAE,EAAE,MAAM,CAAC;IAEX,oCAAoC;IACpC,IAAI,EAAE,MAAM,CAAC;IAEb,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OA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ending Plan Manager
|
|
3
|
+
*
|
|
4
|
+
* Manages plans that are awaiting user approval before execution.
|
|
5
|
+
* Used in "plan mode" where write operations are intercepted and queued
|
|
6
|
+
* as proposed changes rather than being executed immediately.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const planManager = createPendingPlanManager();
|
|
11
|
+
*
|
|
12
|
+
* // In plan mode, intercept a write operation
|
|
13
|
+
* planManager.addProposedChange({
|
|
14
|
+
* tool: 'write_file',
|
|
15
|
+
* args: { path: 'src/main.ts', content: '...' },
|
|
16
|
+
* reason: 'Create entry point for the application',
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* // User approves the plan
|
|
20
|
+
* const changes = planManager.approve();
|
|
21
|
+
* for (const change of changes) {
|
|
22
|
+
* await executeTool(change.tool, change.args);
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
// =============================================================================
|
|
27
|
+
// PENDING PLAN MANAGER
|
|
28
|
+
// =============================================================================
|
|
29
|
+
/**
|
|
30
|
+
* Manages pending plans that await user approval.
|
|
31
|
+
*/
|
|
32
|
+
export class PendingPlanManager {
|
|
33
|
+
currentPlan = null;
|
|
34
|
+
changeCounter = 0;
|
|
35
|
+
eventListeners = new Set();
|
|
36
|
+
/**
|
|
37
|
+
* Start a new pending plan.
|
|
38
|
+
* Clears any existing plan.
|
|
39
|
+
*/
|
|
40
|
+
startPlan(task, sessionId) {
|
|
41
|
+
const now = new Date().toISOString();
|
|
42
|
+
const plan = {
|
|
43
|
+
id: `plan-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
|
|
44
|
+
task,
|
|
45
|
+
createdAt: now,
|
|
46
|
+
updatedAt: now,
|
|
47
|
+
proposedChanges: [],
|
|
48
|
+
explorationSummary: '',
|
|
49
|
+
status: 'pending',
|
|
50
|
+
sessionId,
|
|
51
|
+
};
|
|
52
|
+
this.currentPlan = plan;
|
|
53
|
+
this.changeCounter = 0;
|
|
54
|
+
this.emit({ type: 'plan.created', plan });
|
|
55
|
+
return plan;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Add a proposed change to the current plan.
|
|
59
|
+
* Returns the created change, or null if no plan is active.
|
|
60
|
+
*/
|
|
61
|
+
addProposedChange(tool, args, reason, toolCallId) {
|
|
62
|
+
if (!this.currentPlan) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
const change = {
|
|
66
|
+
id: `change-${++this.changeCounter}`,
|
|
67
|
+
tool,
|
|
68
|
+
args,
|
|
69
|
+
reason,
|
|
70
|
+
order: this.currentPlan.proposedChanges.length + 1,
|
|
71
|
+
proposedAt: new Date().toISOString(),
|
|
72
|
+
toolCallId,
|
|
73
|
+
};
|
|
74
|
+
this.currentPlan.proposedChanges.push(change);
|
|
75
|
+
this.currentPlan.updatedAt = new Date().toISOString();
|
|
76
|
+
this.emit({ type: 'plan.change.added', change, planId: this.currentPlan.id });
|
|
77
|
+
return change;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Set the exploration summary for the current plan.
|
|
81
|
+
*/
|
|
82
|
+
setExplorationSummary(summary) {
|
|
83
|
+
if (this.currentPlan) {
|
|
84
|
+
this.currentPlan.explorationSummary = summary;
|
|
85
|
+
this.currentPlan.updatedAt = new Date().toISOString();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Get the current pending plan.
|
|
90
|
+
*/
|
|
91
|
+
getPendingPlan() {
|
|
92
|
+
return this.currentPlan;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Check if there's an active pending plan.
|
|
96
|
+
*/
|
|
97
|
+
hasPendingPlan() {
|
|
98
|
+
return this.currentPlan !== null && this.currentPlan.status === 'pending';
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Get the number of proposed changes.
|
|
102
|
+
*/
|
|
103
|
+
getChangeCount() {
|
|
104
|
+
return this.currentPlan?.proposedChanges.length ?? 0;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Approve the pending plan.
|
|
108
|
+
* @param count - If provided, only approve the first N changes
|
|
109
|
+
* @returns The changes to execute
|
|
110
|
+
*/
|
|
111
|
+
approve(count) {
|
|
112
|
+
if (!this.currentPlan) {
|
|
113
|
+
return { changes: [], skippedCount: 0 };
|
|
114
|
+
}
|
|
115
|
+
const allChanges = this.currentPlan.proposedChanges;
|
|
116
|
+
const approvedChanges = count !== undefined
|
|
117
|
+
? allChanges.slice(0, count)
|
|
118
|
+
: allChanges;
|
|
119
|
+
const skippedCount = allChanges.length - approvedChanges.length;
|
|
120
|
+
this.currentPlan.status = skippedCount > 0 ? 'partially_approved' : 'approved';
|
|
121
|
+
this.currentPlan.updatedAt = new Date().toISOString();
|
|
122
|
+
this.emit({
|
|
123
|
+
type: 'plan.approved',
|
|
124
|
+
planId: this.currentPlan.id,
|
|
125
|
+
changeCount: approvedChanges.length,
|
|
126
|
+
});
|
|
127
|
+
// Clear the plan after approval
|
|
128
|
+
const result = { changes: approvedChanges, skippedCount };
|
|
129
|
+
this.currentPlan = null;
|
|
130
|
+
return result;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Reject the pending plan.
|
|
134
|
+
* Clears all proposed changes.
|
|
135
|
+
*/
|
|
136
|
+
reject() {
|
|
137
|
+
if (!this.currentPlan) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
this.currentPlan.status = 'rejected';
|
|
141
|
+
this.currentPlan.updatedAt = new Date().toISOString();
|
|
142
|
+
this.emit({ type: 'plan.rejected', planId: this.currentPlan.id });
|
|
143
|
+
this.currentPlan = null;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Clear the current plan without changing status.
|
|
147
|
+
*/
|
|
148
|
+
clear() {
|
|
149
|
+
if (this.currentPlan) {
|
|
150
|
+
this.emit({ type: 'plan.cleared', planId: this.currentPlan.id });
|
|
151
|
+
this.currentPlan = null;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Restore a plan from storage.
|
|
156
|
+
*/
|
|
157
|
+
restorePlan(plan) {
|
|
158
|
+
this.currentPlan = plan;
|
|
159
|
+
this.changeCounter = plan.proposedChanges.length;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Format the pending plan for display.
|
|
163
|
+
*/
|
|
164
|
+
formatPlan() {
|
|
165
|
+
if (!this.currentPlan) {
|
|
166
|
+
return 'No pending plan.';
|
|
167
|
+
}
|
|
168
|
+
const lines = [
|
|
169
|
+
`Plan: "${this.currentPlan.task}"`,
|
|
170
|
+
`Status: ${this.currentPlan.status}`,
|
|
171
|
+
`Created: ${this.currentPlan.createdAt}`,
|
|
172
|
+
'',
|
|
173
|
+
];
|
|
174
|
+
if (this.currentPlan.explorationSummary) {
|
|
175
|
+
lines.push('Exploration Summary:');
|
|
176
|
+
lines.push(this.currentPlan.explorationSummary);
|
|
177
|
+
lines.push('');
|
|
178
|
+
}
|
|
179
|
+
if (this.currentPlan.proposedChanges.length === 0) {
|
|
180
|
+
lines.push('No proposed changes yet.');
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
lines.push(`Proposed Changes (${this.currentPlan.proposedChanges.length}):`);
|
|
184
|
+
lines.push('');
|
|
185
|
+
for (const change of this.currentPlan.proposedChanges) {
|
|
186
|
+
lines.push(`${change.order}. [${change.tool}]`);
|
|
187
|
+
// Format args nicely
|
|
188
|
+
if (change.tool === 'write_file' || change.tool === 'edit_file') {
|
|
189
|
+
const path = change.args.path || change.args.file_path;
|
|
190
|
+
lines.push(` File: ${path}`);
|
|
191
|
+
}
|
|
192
|
+
else if (change.tool === 'bash') {
|
|
193
|
+
const cmd = String(change.args.command || '').slice(0, 60);
|
|
194
|
+
lines.push(` Command: ${cmd}${cmd.length >= 60 ? '...' : ''}`);
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
lines.push(` Args: ${JSON.stringify(change.args).slice(0, 80)}...`);
|
|
198
|
+
}
|
|
199
|
+
lines.push(` Reason: ${change.reason}`);
|
|
200
|
+
lines.push('');
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
lines.push('Commands: /approve, /reject, /show-plan');
|
|
204
|
+
return lines.join('\n');
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Subscribe to plan events.
|
|
208
|
+
*/
|
|
209
|
+
subscribe(listener) {
|
|
210
|
+
this.eventListeners.add(listener);
|
|
211
|
+
return () => this.eventListeners.delete(listener);
|
|
212
|
+
}
|
|
213
|
+
// Internal
|
|
214
|
+
emit(event) {
|
|
215
|
+
for (const listener of this.eventListeners) {
|
|
216
|
+
try {
|
|
217
|
+
listener(event);
|
|
218
|
+
}
|
|
219
|
+
catch {
|
|
220
|
+
// Ignore listener errors
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
// =============================================================================
|
|
226
|
+
// FACTORY
|
|
227
|
+
// =============================================================================
|
|
228
|
+
/**
|
|
229
|
+
* Create a new pending plan manager.
|
|
230
|
+
*/
|
|
231
|
+
export function createPendingPlanManager() {
|
|
232
|
+
return new PendingPlanManager();
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Format a plan for compact display (e.g., in status bar).
|
|
236
|
+
*/
|
|
237
|
+
export function formatPlanStatus(plan) {
|
|
238
|
+
if (!plan) {
|
|
239
|
+
return '';
|
|
240
|
+
}
|
|
241
|
+
const count = plan.proposedChanges.length;
|
|
242
|
+
return `${count} change${count === 1 ? '' : 's'} pending`;
|
|
243
|
+
}
|
|
244
|
+
//# sourceMappingURL=pending-plan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pending-plan.js","sourceRoot":"","sources":["../../../src/integrations/pending-plan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAyFH,gFAAgF;AAChF,uBAAuB;AACvB,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AC;IACpD,CAAC;IAED,WAAW;IAEH,IAAI,CAAC,KAAuB;QAClC,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YAC3C,IAAI,CAAC;gBACH,QAAQ,CAAC,KAAK,CAAC,CAAC;YAClB,CAAC;YAAC,MAAM,CAAC;gBACP,yBAAyB;YAC3B,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAED,gFAAgF;AAChF,UAAU;AACV,gFAAgF;AAEhF;;GAEG;AACH,MAAM,UAAU,wBAAwB;IACtC,OAAO,IAAI,kBAAkB,EAAE,CAAC;AAClC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAwB;IACvD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC;IAC1C,OAAO,GAAG,KAAK,UAAU,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC;AAC5D,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Persistence Utilities
|
|
3
|
+
*
|
|
4
|
+
* Debug logging and checkpoint management for session persistence.
|
|
5
|
+
*/
|
|
6
|
+
import type { SQLiteStore, SessionStore } from './index.js';
|
|
7
|
+
export type AnySessionStore = SQLiteStore | SessionStore;
|
|
8
|
+
/**
|
|
9
|
+
* Debug logger for persistence operations.
|
|
10
|
+
* Enabled via --debug flag. Shows data flow at each layer boundary.
|
|
11
|
+
* In TUI mode, logs are buffered instead of printed to avoid interfering with Ink.
|
|
12
|
+
*/
|
|
13
|
+
export declare class PersistenceDebugger {
|
|
14
|
+
private enabled;
|
|
15
|
+
private tuiMode;
|
|
16
|
+
private buffer;
|
|
17
|
+
enable(): void;
|
|
18
|
+
enableTUIMode(): void;
|
|
19
|
+
isEnabled(): boolean;
|
|
20
|
+
getBuffer(): string[];
|
|
21
|
+
log(message: string, data?: unknown): void;
|
|
22
|
+
error(message: string, err: unknown): void;
|
|
23
|
+
storeType(store: AnySessionStore): string;
|
|
24
|
+
}
|
|
25
|
+
export declare const persistenceDebug: PersistenceDebugger;
|
|
26
|
+
/**
|
|
27
|
+
* Checkpoint data structure for full state restoration.
|
|
28
|
+
*/
|
|
29
|
+
export interface CheckpointData {
|
|
30
|
+
id: string;
|
|
31
|
+
label?: string;
|
|
32
|
+
messages: unknown[];
|
|
33
|
+
iteration: number;
|
|
34
|
+
metrics?: unknown;
|
|
35
|
+
plan?: unknown;
|
|
36
|
+
memoryContext?: string[];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Save checkpoint to session store (works with both SQLite and JSONL).
|
|
40
|
+
* Now includes plan and memoryContext for full state restoration.
|
|
41
|
+
*/
|
|
42
|
+
export declare function saveCheckpointToStore(store: AnySessionStore, checkpoint: CheckpointData): void;
|
|
43
|
+
/**
|
|
44
|
+
* Load session state (checkpoint or messages) for resuming.
|
|
45
|
+
* Returns checkpoint data if found, or null.
|
|
46
|
+
*/
|
|
47
|
+
export declare function loadSessionState(sessionStore: AnySessionStore, sessionId: string): Promise<CheckpointData | null>;
|
|
48
|
+
//# sourceMappingURL=persistence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"persistence.d.ts","sourceRoot":"","sources":["../../../src/integrations/persistence.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG5D,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,YAAY,CAAC;AAMzD;;;;GAIG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAgB;IAE9B,MAAM,IAAI,IAAI;IAKd,aAAa,IAAI,IAAI;IAIrB,SAAS,IAAI,OAAO;IAIpB,SAAS,IAAI,MAAM,EAAE;IAMrB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI;IAgB1C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,IAAI;IAuB1C,SAAS,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM;CAM1C;AAGD,eAAO,MAAM,gBAAgB,qBAA4B,CAAC;AAM1D;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,eAAe,EACtB,UAAU,EAAE,cAAc,GACzB,IAAI,CAgEN;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,YAAY,EAAE,eAAe,EAC7B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CA8ChC"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Persistence Utilities
|
|
3
|
+
*
|
|
4
|
+
* Debug logging and checkpoint management for session persistence.
|
|
5
|
+
*/
|
|
6
|
+
// =============================================================================
|
|
7
|
+
// DEBUG LOGGER FOR PERSISTENCE OPERATIONS
|
|
8
|
+
// =============================================================================
|
|
9
|
+
/**
|
|
10
|
+
* Debug logger for persistence operations.
|
|
11
|
+
* Enabled via --debug flag. Shows data flow at each layer boundary.
|
|
12
|
+
* In TUI mode, logs are buffered instead of printed to avoid interfering with Ink.
|
|
13
|
+
*/
|
|
14
|
+
export class PersistenceDebugger {
|
|
15
|
+
enabled = false;
|
|
16
|
+
tuiMode = false;
|
|
17
|
+
buffer = [];
|
|
18
|
+
enable() {
|
|
19
|
+
this.enabled = true;
|
|
20
|
+
this.log('Persistence debug mode ENABLED');
|
|
21
|
+
}
|
|
22
|
+
enableTUIMode() {
|
|
23
|
+
this.tuiMode = true;
|
|
24
|
+
}
|
|
25
|
+
isEnabled() {
|
|
26
|
+
return this.enabled;
|
|
27
|
+
}
|
|
28
|
+
getBuffer() {
|
|
29
|
+
const logs = [...this.buffer];
|
|
30
|
+
this.buffer = [];
|
|
31
|
+
return logs;
|
|
32
|
+
}
|
|
33
|
+
log(message, data) {
|
|
34
|
+
if (!this.enabled)
|
|
35
|
+
return;
|
|
36
|
+
const timestamp = new Date().toISOString().split('T')[1].slice(0, 12);
|
|
37
|
+
const logLine = `[${timestamp}] ${message}`;
|
|
38
|
+
const dataLine = data !== undefined ? ` -> ${JSON.stringify(data, null, 2).split('\n').join('\n ')}` : '';
|
|
39
|
+
if (this.tuiMode) {
|
|
40
|
+
// Buffer logs in TUI mode to avoid console interference
|
|
41
|
+
this.buffer.push(logLine);
|
|
42
|
+
if (dataLine)
|
|
43
|
+
this.buffer.push(dataLine);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
console.log(logLine);
|
|
47
|
+
if (dataLine)
|
|
48
|
+
console.log(dataLine);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
error(message, err) {
|
|
52
|
+
if (!this.enabled)
|
|
53
|
+
return;
|
|
54
|
+
const timestamp = new Date().toISOString().split('T')[1].slice(0, 12);
|
|
55
|
+
const errLine = `[${timestamp}] ERROR: ${message}`;
|
|
56
|
+
let details = '';
|
|
57
|
+
if (err instanceof Error) {
|
|
58
|
+
details = ` -> ${err.message}`;
|
|
59
|
+
if (err.stack) {
|
|
60
|
+
details += `\n -> Stack: ${err.stack.split('\n').slice(1, 3).join(' -> ')}`;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
details = ` -> ${String(err)}`;
|
|
65
|
+
}
|
|
66
|
+
if (this.tuiMode) {
|
|
67
|
+
this.buffer.push(errLine);
|
|
68
|
+
this.buffer.push(details);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
console.error(errLine);
|
|
72
|
+
console.error(details);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
storeType(store) {
|
|
76
|
+
if ('saveCheckpoint' in store && typeof store.saveCheckpoint === 'function') {
|
|
77
|
+
return 'SQLiteStore';
|
|
78
|
+
}
|
|
79
|
+
return 'JSONLStore';
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// Global debug instance - enabled via --debug flag
|
|
83
|
+
export const persistenceDebug = new PersistenceDebugger();
|
|
84
|
+
/**
|
|
85
|
+
* Save checkpoint to session store (works with both SQLite and JSONL).
|
|
86
|
+
* Now includes plan and memoryContext for full state restoration.
|
|
87
|
+
*/
|
|
88
|
+
export function saveCheckpointToStore(store, checkpoint) {
|
|
89
|
+
const storeType = persistenceDebug.storeType(store);
|
|
90
|
+
persistenceDebug.log(`saveCheckpointToStore called`, {
|
|
91
|
+
storeType,
|
|
92
|
+
checkpointId: checkpoint.id,
|
|
93
|
+
messageCount: checkpoint.messages?.length ?? 0,
|
|
94
|
+
hasLabel: !!checkpoint.label,
|
|
95
|
+
hasPlan: !!checkpoint.plan,
|
|
96
|
+
});
|
|
97
|
+
try {
|
|
98
|
+
if ('saveCheckpoint' in store && typeof store.saveCheckpoint === 'function') {
|
|
99
|
+
// SQLite store - check currentSessionId
|
|
100
|
+
const sqliteStore = store;
|
|
101
|
+
const currentSessionId = sqliteStore.getCurrentSessionId();
|
|
102
|
+
persistenceDebug.log(`SQLite saveCheckpoint`, {
|
|
103
|
+
currentSessionId,
|
|
104
|
+
hasCurrentSession: !!currentSessionId,
|
|
105
|
+
});
|
|
106
|
+
if (!currentSessionId) {
|
|
107
|
+
persistenceDebug.error('SQLite store has no currentSessionId!', new Error('No active session'));
|
|
108
|
+
}
|
|
109
|
+
const ckptId = store.saveCheckpoint({
|
|
110
|
+
id: checkpoint.id,
|
|
111
|
+
label: checkpoint.label,
|
|
112
|
+
messages: checkpoint.messages,
|
|
113
|
+
iteration: checkpoint.iteration,
|
|
114
|
+
metrics: checkpoint.metrics,
|
|
115
|
+
plan: checkpoint.plan,
|
|
116
|
+
memoryContext: checkpoint.memoryContext,
|
|
117
|
+
}, checkpoint.label || `auto-checkpoint-${checkpoint.id}`);
|
|
118
|
+
persistenceDebug.log(`SQLite checkpoint saved successfully`, { returnedId: ckptId });
|
|
119
|
+
}
|
|
120
|
+
else if ('appendEntry' in store && typeof store.appendEntry === 'function') {
|
|
121
|
+
// JSONL store - use appendEntry with checkpoint type
|
|
122
|
+
persistenceDebug.log(`JSONL appendEntry (checkpoint type)`);
|
|
123
|
+
store.appendEntry({
|
|
124
|
+
type: 'checkpoint',
|
|
125
|
+
data: {
|
|
126
|
+
id: checkpoint.id,
|
|
127
|
+
label: checkpoint.label,
|
|
128
|
+
messages: checkpoint.messages,
|
|
129
|
+
iteration: checkpoint.iteration,
|
|
130
|
+
metrics: checkpoint.metrics,
|
|
131
|
+
plan: checkpoint.plan,
|
|
132
|
+
memoryContext: checkpoint.memoryContext,
|
|
133
|
+
createdAt: new Date().toISOString(),
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
persistenceDebug.log(`JSONL checkpoint appended successfully`);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
persistenceDebug.error('No compatible save method found on store', { storeType });
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
catch (err) {
|
|
143
|
+
persistenceDebug.error(`Failed to save checkpoint`, err);
|
|
144
|
+
// Re-throw in debug mode so the error is visible
|
|
145
|
+
if (persistenceDebug.isEnabled()) {
|
|
146
|
+
throw err;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Load session state (checkpoint or messages) for resuming.
|
|
152
|
+
* Returns checkpoint data if found, or null.
|
|
153
|
+
*/
|
|
154
|
+
export async function loadSessionState(sessionStore, sessionId) {
|
|
155
|
+
persistenceDebug.log('Loading session state', { sessionId });
|
|
156
|
+
// Try SQLite's loadLatestCheckpoint first
|
|
157
|
+
if ('loadLatestCheckpoint' in sessionStore && typeof sessionStore.loadLatestCheckpoint === 'function') {
|
|
158
|
+
const sqliteCheckpoint = sessionStore.loadLatestCheckpoint(sessionId);
|
|
159
|
+
if (sqliteCheckpoint?.state) {
|
|
160
|
+
persistenceDebug.log('Loaded from SQLite checkpoint', {
|
|
161
|
+
messageCount: sqliteCheckpoint.state.messages?.length,
|
|
162
|
+
});
|
|
163
|
+
return sqliteCheckpoint.state;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
// Fall back to entries-based lookup (for JSONL or if SQLite checkpoint not found)
|
|
167
|
+
try {
|
|
168
|
+
const entriesResult = sessionStore.loadSession(sessionId);
|
|
169
|
+
const entries = Array.isArray(entriesResult) ? entriesResult : await entriesResult;
|
|
170
|
+
// Try to find a checkpoint entry
|
|
171
|
+
const checkpoint = [...entries].reverse().find(e => e.type === 'checkpoint');
|
|
172
|
+
if (checkpoint?.data) {
|
|
173
|
+
persistenceDebug.log('Loaded from entries checkpoint', {
|
|
174
|
+
messageCount: checkpoint.data.messages?.length,
|
|
175
|
+
});
|
|
176
|
+
return checkpoint.data;
|
|
177
|
+
}
|
|
178
|
+
// No checkpoint, try to load messages directly from entries
|
|
179
|
+
const messages = entries
|
|
180
|
+
.filter((e) => e.type === 'message')
|
|
181
|
+
.map((e) => e.data);
|
|
182
|
+
if (messages.length > 0) {
|
|
183
|
+
persistenceDebug.log('Loaded messages from entries', { count: messages.length });
|
|
184
|
+
return {
|
|
185
|
+
id: `loaded-${sessionId}`,
|
|
186
|
+
messages,
|
|
187
|
+
iteration: 0,
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
persistenceDebug.error('Failed to load session entries', error);
|
|
193
|
+
}
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
//# sourceMappingURL=persistence.js.map
|