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,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lesson 25: Rules System Integration
|
|
3
|
+
*
|
|
4
|
+
* Loads and applies rules from CLAUDE.md and other sources (from Lesson 12).
|
|
5
|
+
* Rules can modify the system prompt, add constraints, or provide context.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Rule source configuration.
|
|
9
|
+
*/
|
|
10
|
+
export interface RuleSource {
|
|
11
|
+
type: 'file' | 'inline';
|
|
12
|
+
path?: string;
|
|
13
|
+
content?: string;
|
|
14
|
+
priority?: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Rules configuration.
|
|
18
|
+
*/
|
|
19
|
+
export interface RulesConfig {
|
|
20
|
+
enabled?: boolean;
|
|
21
|
+
sources?: RuleSource[];
|
|
22
|
+
watch?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Loaded rule.
|
|
26
|
+
*/
|
|
27
|
+
export interface LoadedRule {
|
|
28
|
+
source: string;
|
|
29
|
+
content: string;
|
|
30
|
+
priority: number;
|
|
31
|
+
loadedAt: Date;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Rules manager events.
|
|
35
|
+
*/
|
|
36
|
+
export type RulesEvent = {
|
|
37
|
+
type: 'rules.loaded';
|
|
38
|
+
count: number;
|
|
39
|
+
sources: string[];
|
|
40
|
+
} | {
|
|
41
|
+
type: 'rules.reloaded';
|
|
42
|
+
source: string;
|
|
43
|
+
} | {
|
|
44
|
+
type: 'rules.error';
|
|
45
|
+
source: string;
|
|
46
|
+
error: string;
|
|
47
|
+
};
|
|
48
|
+
export type RulesEventListener = (event: RulesEvent) => void;
|
|
49
|
+
/**
|
|
50
|
+
* RulesManager loads and manages rules from various sources.
|
|
51
|
+
*/
|
|
52
|
+
export declare class RulesManager {
|
|
53
|
+
private config;
|
|
54
|
+
private rules;
|
|
55
|
+
private listeners;
|
|
56
|
+
private watchers;
|
|
57
|
+
private baseDir;
|
|
58
|
+
constructor(config?: Partial<RulesConfig>, baseDir?: string);
|
|
59
|
+
/**
|
|
60
|
+
* Load rules from configured sources.
|
|
61
|
+
*/
|
|
62
|
+
loadRules(): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Load a single rule source.
|
|
65
|
+
*/
|
|
66
|
+
private loadSource;
|
|
67
|
+
/**
|
|
68
|
+
* Setup file watchers for auto-reload.
|
|
69
|
+
*/
|
|
70
|
+
private setupWatchers;
|
|
71
|
+
/**
|
|
72
|
+
* Reload a specific source.
|
|
73
|
+
*/
|
|
74
|
+
private reloadSource;
|
|
75
|
+
/**
|
|
76
|
+
* Clean up watchers.
|
|
77
|
+
*/
|
|
78
|
+
private cleanupWatchers;
|
|
79
|
+
/**
|
|
80
|
+
* Get all rules as a combined string for system prompt.
|
|
81
|
+
*/
|
|
82
|
+
getRulesContent(): string;
|
|
83
|
+
/**
|
|
84
|
+
* Get rules as context strings for memory augmentation.
|
|
85
|
+
*/
|
|
86
|
+
getRulesContext(): string[];
|
|
87
|
+
/**
|
|
88
|
+
* Get loaded rules.
|
|
89
|
+
*/
|
|
90
|
+
getLoadedRules(): LoadedRule[];
|
|
91
|
+
/**
|
|
92
|
+
* Add a rule at runtime.
|
|
93
|
+
*/
|
|
94
|
+
addRule(content: string, priority?: number, source?: string): void;
|
|
95
|
+
/**
|
|
96
|
+
* Remove a rule by source.
|
|
97
|
+
*/
|
|
98
|
+
removeRule(source: string): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Subscribe to events.
|
|
101
|
+
*/
|
|
102
|
+
on(listener: RulesEventListener): () => void;
|
|
103
|
+
/**
|
|
104
|
+
* Emit an event.
|
|
105
|
+
*/
|
|
106
|
+
private emit;
|
|
107
|
+
/**
|
|
108
|
+
* Cleanup resources.
|
|
109
|
+
*/
|
|
110
|
+
cleanup(): void;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Create a rules manager and load rules.
|
|
114
|
+
*/
|
|
115
|
+
export declare function createRulesManager(config?: Partial<RulesConfig>, baseDir?: string): Promise<RulesManager>;
|
|
116
|
+
/**
|
|
117
|
+
* Default rule sources to check.
|
|
118
|
+
*/
|
|
119
|
+
export declare const DEFAULT_RULE_SOURCES: RuleSource[];
|
|
120
|
+
/**
|
|
121
|
+
* Parse rules from markdown content.
|
|
122
|
+
* Extracts sections and returns structured rules.
|
|
123
|
+
*/
|
|
124
|
+
export declare function parseRulesFromMarkdown(content: string): {
|
|
125
|
+
sections: Array<{
|
|
126
|
+
heading: string;
|
|
127
|
+
content: string;
|
|
128
|
+
}>;
|
|
129
|
+
raw: string;
|
|
130
|
+
};
|
|
131
|
+
//# sourceMappingURL=rules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../../src/integrations/rules.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,UAAU,EAA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E,MAAM,EAAE,QAAQ,GAAE,MAAU,EAAE,MAAM,GAAE,MAAkB,GAAG,IAAI;IAUhF;;OAEG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IASnC;;OAEG;IACH,EAAE,CAAC,QAAQ,EAAE,kBAAkB,GAAG,MAAM,IAAI;IAQ5C;;OAEG;IACH,OAAO,CAAC,IAAI;IAUZ;;OAEG;IACH,OAAO,IAAI,IAAI;CAKhB;AAMD;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,EAC7B,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,YAAY,CAAC,CAIvB;AAMD;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,UAAU,EAQ5C,CAAC;AAEF;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG;IACvD,QAAQ,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACtD,GAAG,EAAE,MAAM,CAAC;CACb,CAiCA"}
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lesson 25: Rules System Integration
|
|
3
|
+
*
|
|
4
|
+
* Loads and applies rules from CLAUDE.md and other sources (from Lesson 12).
|
|
5
|
+
* Rules can modify the system prompt, add constraints, or provide context.
|
|
6
|
+
*/
|
|
7
|
+
import { readFile } from 'node:fs/promises';
|
|
8
|
+
import { existsSync, watch } from 'node:fs';
|
|
9
|
+
import { resolve } from 'node:path';
|
|
10
|
+
// =============================================================================
|
|
11
|
+
// RULES MANAGER
|
|
12
|
+
// =============================================================================
|
|
13
|
+
/**
|
|
14
|
+
* RulesManager loads and manages rules from various sources.
|
|
15
|
+
*/
|
|
16
|
+
export class RulesManager {
|
|
17
|
+
config;
|
|
18
|
+
rules = [];
|
|
19
|
+
listeners = [];
|
|
20
|
+
watchers = [];
|
|
21
|
+
baseDir;
|
|
22
|
+
constructor(config = {}, baseDir) {
|
|
23
|
+
this.config = {
|
|
24
|
+
enabled: config.enabled ?? true,
|
|
25
|
+
sources: config.sources ?? [],
|
|
26
|
+
watch: config.watch ?? false,
|
|
27
|
+
};
|
|
28
|
+
this.baseDir = baseDir || process.cwd();
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Load rules from configured sources.
|
|
32
|
+
*/
|
|
33
|
+
async loadRules() {
|
|
34
|
+
if (!this.config.enabled)
|
|
35
|
+
return;
|
|
36
|
+
this.rules = [];
|
|
37
|
+
const loadedSources = [];
|
|
38
|
+
for (const source of this.config.sources || []) {
|
|
39
|
+
try {
|
|
40
|
+
const rule = await this.loadSource(source);
|
|
41
|
+
if (rule) {
|
|
42
|
+
this.rules.push(rule);
|
|
43
|
+
loadedSources.push(rule.source);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
const error = err instanceof Error ? err.message : String(err);
|
|
48
|
+
this.emit({ type: 'rules.error', source: source.path || 'inline', error });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// Sort by priority (higher first)
|
|
52
|
+
this.rules.sort((a, b) => b.priority - a.priority);
|
|
53
|
+
this.emit({ type: 'rules.loaded', count: this.rules.length, sources: loadedSources });
|
|
54
|
+
// Setup watchers if configured
|
|
55
|
+
if (this.config.watch) {
|
|
56
|
+
this.setupWatchers();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Load a single rule source.
|
|
61
|
+
*/
|
|
62
|
+
async loadSource(source) {
|
|
63
|
+
if (source.type === 'inline' && source.content) {
|
|
64
|
+
return {
|
|
65
|
+
source: 'inline',
|
|
66
|
+
content: source.content,
|
|
67
|
+
priority: source.priority ?? 0,
|
|
68
|
+
loadedAt: new Date(),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
if (source.type === 'file' && source.path) {
|
|
72
|
+
const resolvedPath = resolve(this.baseDir, source.path);
|
|
73
|
+
if (!existsSync(resolvedPath)) {
|
|
74
|
+
// File doesn't exist - not an error, just skip
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
const content = await readFile(resolvedPath, 'utf-8');
|
|
78
|
+
return {
|
|
79
|
+
source: resolvedPath,
|
|
80
|
+
content: content.trim(),
|
|
81
|
+
priority: source.priority ?? 0,
|
|
82
|
+
loadedAt: new Date(),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Setup file watchers for auto-reload.
|
|
89
|
+
*/
|
|
90
|
+
setupWatchers() {
|
|
91
|
+
// Clean up existing watchers
|
|
92
|
+
this.cleanupWatchers();
|
|
93
|
+
for (const source of this.config.sources || []) {
|
|
94
|
+
if (source.type === 'file' && source.path) {
|
|
95
|
+
const resolvedPath = resolve(this.baseDir, source.path);
|
|
96
|
+
if (existsSync(resolvedPath)) {
|
|
97
|
+
try {
|
|
98
|
+
const watcher = watch(resolvedPath, async (eventType) => {
|
|
99
|
+
if (eventType === 'change') {
|
|
100
|
+
await this.reloadSource(source);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
this.watchers.push(watcher);
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
// Ignore watch errors (e.g., file system doesn't support watching)
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Reload a specific source.
|
|
114
|
+
*/
|
|
115
|
+
async reloadSource(source) {
|
|
116
|
+
try {
|
|
117
|
+
const rule = await this.loadSource(source);
|
|
118
|
+
if (rule) {
|
|
119
|
+
// Find and replace existing rule from this source
|
|
120
|
+
const existingIndex = this.rules.findIndex(r => r.source === rule.source);
|
|
121
|
+
if (existingIndex >= 0) {
|
|
122
|
+
this.rules[existingIndex] = rule;
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
this.rules.push(rule);
|
|
126
|
+
this.rules.sort((a, b) => b.priority - a.priority);
|
|
127
|
+
}
|
|
128
|
+
this.emit({ type: 'rules.reloaded', source: rule.source });
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
catch (err) {
|
|
132
|
+
const error = err instanceof Error ? err.message : String(err);
|
|
133
|
+
this.emit({ type: 'rules.error', source: source.path || 'inline', error });
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Clean up watchers.
|
|
138
|
+
*/
|
|
139
|
+
cleanupWatchers() {
|
|
140
|
+
for (const watcher of this.watchers) {
|
|
141
|
+
watcher.close();
|
|
142
|
+
}
|
|
143
|
+
this.watchers = [];
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Get all rules as a combined string for system prompt.
|
|
147
|
+
*/
|
|
148
|
+
getRulesContent() {
|
|
149
|
+
if (this.rules.length === 0)
|
|
150
|
+
return '';
|
|
151
|
+
return this.rules
|
|
152
|
+
.map(r => `# Rules from ${r.source}\n\n${r.content}`)
|
|
153
|
+
.join('\n\n---\n\n');
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Get rules as context strings for memory augmentation.
|
|
157
|
+
*/
|
|
158
|
+
getRulesContext() {
|
|
159
|
+
return this.rules.map(r => r.content);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Get loaded rules.
|
|
163
|
+
*/
|
|
164
|
+
getLoadedRules() {
|
|
165
|
+
return [...this.rules];
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Add a rule at runtime.
|
|
169
|
+
*/
|
|
170
|
+
addRule(content, priority = 0, source = 'runtime') {
|
|
171
|
+
this.rules.push({
|
|
172
|
+
source,
|
|
173
|
+
content,
|
|
174
|
+
priority,
|
|
175
|
+
loadedAt: new Date(),
|
|
176
|
+
});
|
|
177
|
+
this.rules.sort((a, b) => b.priority - a.priority);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Remove a rule by source.
|
|
181
|
+
*/
|
|
182
|
+
removeRule(source) {
|
|
183
|
+
const index = this.rules.findIndex(r => r.source === source);
|
|
184
|
+
if (index >= 0) {
|
|
185
|
+
this.rules.splice(index, 1);
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Subscribe to events.
|
|
192
|
+
*/
|
|
193
|
+
on(listener) {
|
|
194
|
+
this.listeners.push(listener);
|
|
195
|
+
return () => {
|
|
196
|
+
const idx = this.listeners.indexOf(listener);
|
|
197
|
+
if (idx >= 0)
|
|
198
|
+
this.listeners.splice(idx, 1);
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Emit an event.
|
|
203
|
+
*/
|
|
204
|
+
emit(event) {
|
|
205
|
+
for (const listener of this.listeners) {
|
|
206
|
+
try {
|
|
207
|
+
listener(event);
|
|
208
|
+
}
|
|
209
|
+
catch {
|
|
210
|
+
// Ignore listener errors
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Cleanup resources.
|
|
216
|
+
*/
|
|
217
|
+
cleanup() {
|
|
218
|
+
this.cleanupWatchers();
|
|
219
|
+
this.listeners = [];
|
|
220
|
+
this.rules = [];
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
// =============================================================================
|
|
224
|
+
// FACTORY
|
|
225
|
+
// =============================================================================
|
|
226
|
+
/**
|
|
227
|
+
* Create a rules manager and load rules.
|
|
228
|
+
*/
|
|
229
|
+
export async function createRulesManager(config, baseDir) {
|
|
230
|
+
const manager = new RulesManager(config, baseDir);
|
|
231
|
+
await manager.loadRules();
|
|
232
|
+
return manager;
|
|
233
|
+
}
|
|
234
|
+
// =============================================================================
|
|
235
|
+
// DEFAULT SOURCES
|
|
236
|
+
// =============================================================================
|
|
237
|
+
/**
|
|
238
|
+
* Default rule sources to check.
|
|
239
|
+
*/
|
|
240
|
+
export const DEFAULT_RULE_SOURCES = [
|
|
241
|
+
// Project-level rules (highest priority)
|
|
242
|
+
{ type: 'file', path: '.agent/rules.md', priority: 10 },
|
|
243
|
+
// Global CLAUDE.md at project root
|
|
244
|
+
{ type: 'file', path: 'CLAUDE.md', priority: 5 },
|
|
245
|
+
// Alternative locations
|
|
246
|
+
{ type: 'file', path: '.agent/CLAUDE.md', priority: 5 },
|
|
247
|
+
{ type: 'file', path: 'docs/CLAUDE.md', priority: 3 },
|
|
248
|
+
];
|
|
249
|
+
/**
|
|
250
|
+
* Parse rules from markdown content.
|
|
251
|
+
* Extracts sections and returns structured rules.
|
|
252
|
+
*/
|
|
253
|
+
export function parseRulesFromMarkdown(content) {
|
|
254
|
+
const sections = [];
|
|
255
|
+
const lines = content.split('\n');
|
|
256
|
+
let currentHeading = '';
|
|
257
|
+
let currentContent = [];
|
|
258
|
+
for (const line of lines) {
|
|
259
|
+
const headingMatch = line.match(/^(#{1,3})\s+(.+)$/);
|
|
260
|
+
if (headingMatch) {
|
|
261
|
+
// Save previous section
|
|
262
|
+
if (currentHeading || currentContent.length > 0) {
|
|
263
|
+
sections.push({
|
|
264
|
+
heading: currentHeading,
|
|
265
|
+
content: currentContent.join('\n').trim(),
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
currentHeading = headingMatch[2];
|
|
269
|
+
currentContent = [];
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
currentContent.push(line);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
// Save last section
|
|
276
|
+
if (currentHeading || currentContent.length > 0) {
|
|
277
|
+
sections.push({
|
|
278
|
+
heading: currentHeading,
|
|
279
|
+
content: currentContent.join('\n').trim(),
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
return { sections, raw: content };
|
|
283
|
+
}
|
|
284
|
+
//# sourceMappingURL=rules.js.map
|
|
@@ -0,0 +1 @@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,CAAC;QAChD,QAAQ,CAAC,IAAI,CAAC;YACZ,OAAO,EAAE,cAAc;YACvB,OAAO,EAAE,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE;SAC1C,CAAC,CAAC;IACL,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lesson 23: Safety Integration
|
|
3
|
+
*
|
|
4
|
+
* Integrates sandboxing (Lesson 20) and human-in-the-loop (Lesson 21)
|
|
5
|
+
* into the production agent. Provides execution safety and approval workflows.
|
|
6
|
+
*/
|
|
7
|
+
import type { SandboxConfig, HumanInLoopConfig, ToolCall } from '../types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Manages sandboxed execution of tools.
|
|
10
|
+
*/
|
|
11
|
+
export declare class SandboxManager {
|
|
12
|
+
private config;
|
|
13
|
+
constructor(config: SandboxConfig);
|
|
14
|
+
/**
|
|
15
|
+
* Check if a command is allowed.
|
|
16
|
+
*/
|
|
17
|
+
isCommandAllowed(command: string): {
|
|
18
|
+
allowed: boolean;
|
|
19
|
+
reason?: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Check if a path is allowed.
|
|
23
|
+
* Resolves relative paths against cwd before comparison.
|
|
24
|
+
*/
|
|
25
|
+
isPathAllowed(path: string): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Get resource limits.
|
|
28
|
+
*/
|
|
29
|
+
getResourceLimits(): NonNullable<SandboxConfig['resourceLimits']>;
|
|
30
|
+
/**
|
|
31
|
+
* Wrap execution with resource limits.
|
|
32
|
+
*/
|
|
33
|
+
executeWithLimits<T>(fn: () => Promise<T>, timeout?: number): Promise<T>;
|
|
34
|
+
/**
|
|
35
|
+
* Validate tool call against sandbox rules.
|
|
36
|
+
*/
|
|
37
|
+
validateToolCall(toolCall: ToolCall): {
|
|
38
|
+
valid: boolean;
|
|
39
|
+
reason?: string;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Manages human approval workflows.
|
|
44
|
+
*/
|
|
45
|
+
export declare class HumanInLoopManager {
|
|
46
|
+
private config;
|
|
47
|
+
private auditLog;
|
|
48
|
+
private pendingApprovals;
|
|
49
|
+
constructor(config: HumanInLoopConfig);
|
|
50
|
+
/**
|
|
51
|
+
* Determine risk level of an action.
|
|
52
|
+
*/
|
|
53
|
+
assessRisk(toolCall: ToolCall): RiskLevel;
|
|
54
|
+
/**
|
|
55
|
+
* Check if action needs approval.
|
|
56
|
+
*/
|
|
57
|
+
needsApproval(toolCall: ToolCall): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Request approval for an action.
|
|
60
|
+
*/
|
|
61
|
+
requestApproval(toolCall: ToolCall, context: string): Promise<ApprovalResult>;
|
|
62
|
+
/**
|
|
63
|
+
* Console-based approval (for demos).
|
|
64
|
+
*/
|
|
65
|
+
private consoleApproval;
|
|
66
|
+
/**
|
|
67
|
+
* Execute with timeout.
|
|
68
|
+
*/
|
|
69
|
+
private executeWithTimeout;
|
|
70
|
+
/**
|
|
71
|
+
* Log an action to audit trail.
|
|
72
|
+
*/
|
|
73
|
+
private logAction;
|
|
74
|
+
/**
|
|
75
|
+
* Get audit log.
|
|
76
|
+
*/
|
|
77
|
+
getAuditLog(): AuditEntry[];
|
|
78
|
+
/**
|
|
79
|
+
* Get audit summary.
|
|
80
|
+
*/
|
|
81
|
+
getAuditSummary(): AuditSummary;
|
|
82
|
+
/**
|
|
83
|
+
* Clear audit log.
|
|
84
|
+
*/
|
|
85
|
+
clearAuditLog(): void;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Combined safety manager for the production agent.
|
|
89
|
+
*/
|
|
90
|
+
export declare class SafetyManager {
|
|
91
|
+
sandbox: SandboxManager | null;
|
|
92
|
+
humanInLoop: HumanInLoopManager | null;
|
|
93
|
+
constructor(sandboxConfig: SandboxConfig | false, hilConfig: HumanInLoopConfig | false);
|
|
94
|
+
/**
|
|
95
|
+
* Validate a tool call against all safety rules.
|
|
96
|
+
*/
|
|
97
|
+
validateAndApprove(toolCall: ToolCall, context: string): Promise<{
|
|
98
|
+
allowed: boolean;
|
|
99
|
+
reason?: string;
|
|
100
|
+
}>;
|
|
101
|
+
/**
|
|
102
|
+
* Execute a tool call with safety wrapping.
|
|
103
|
+
*/
|
|
104
|
+
executeWithSafety<T>(fn: () => Promise<T>, toolCall: ToolCall, context: string): Promise<T>;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Risk levels for safety assessment.
|
|
108
|
+
* Matches the risk property in ApprovalRequest from types.ts.
|
|
109
|
+
*/
|
|
110
|
+
type RiskLevel = 'low' | 'moderate' | 'high' | 'critical';
|
|
111
|
+
/**
|
|
112
|
+
* Result of an approval request.
|
|
113
|
+
* Extends ApprovalResponse with additional tracking info.
|
|
114
|
+
*/
|
|
115
|
+
interface ApprovalResult {
|
|
116
|
+
approved: boolean;
|
|
117
|
+
reason?: string;
|
|
118
|
+
modifiedArgs?: Record<string, unknown>;
|
|
119
|
+
/** Who approved the action (for audit trail) */
|
|
120
|
+
approver?: string;
|
|
121
|
+
}
|
|
122
|
+
interface AuditEntry {
|
|
123
|
+
timestamp: Date;
|
|
124
|
+
action: string;
|
|
125
|
+
args: unknown;
|
|
126
|
+
approved: boolean;
|
|
127
|
+
approver: string;
|
|
128
|
+
risk: RiskLevel;
|
|
129
|
+
}
|
|
130
|
+
interface AuditSummary {
|
|
131
|
+
total: number;
|
|
132
|
+
approved: number;
|
|
133
|
+
denied: number;
|
|
134
|
+
byRisk: {
|
|
135
|
+
low: number;
|
|
136
|
+
medium: number;
|
|
137
|
+
high: number;
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
export declare function createSafetyManager(sandboxConfig: SandboxConfig | false, hilConfig: HumanInLoopConfig | false): SafetyManager;
|
|
141
|
+
export {};
|
|
142
|
+
//# sour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