@phuetz/code-buddy 2.0.0 → 2.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/README.fr.md +56 -0
- package/README.md +73 -16
- package/codebuddy-runtime.json +5 -5
- package/dist/agent/codebuddy-agent.d.ts +18 -0
- package/dist/agent/codebuddy-agent.js +45 -8
- package/dist/agent/execution/agent-executor.d.ts +0 -9
- package/dist/agent/execution/agent-executor.js +165 -12
- package/dist/agent/execution/context-pipeline.d.ts +9 -0
- package/dist/agent/execution/context-pipeline.js +64 -2
- package/dist/agent/execution/tool-loop-guard.d.ts +76 -0
- package/dist/agent/execution/tool-loop-guard.js +165 -0
- package/dist/agent/execution/tool-selection-strategy.js +19 -2
- package/dist/agent/facades/session-facade.d.ts +0 -6
- package/dist/agent/facades/session-facade.js +0 -45
- package/dist/agent/hermes-claw-migrate.d.ts +0 -21
- package/dist/agent/hermes-claw-migrate.js +9 -4
- package/dist/agent/hermes-protocol-gateways.js +8 -1
- package/dist/agent/repo-profiler.js +17 -4
- package/dist/agent/self-improvement/authored-tool-runtime.js +10 -2
- package/dist/agent/self-improvement/evolution/ast-novelty.d.ts +5 -0
- package/dist/agent/self-improvement/evolution/ast-novelty.js +58 -23
- package/dist/agent/self-improvement/evolution/code-variant-store.d.ts +3 -0
- package/dist/agent/self-improvement/evolution/evolution-engine.js +2 -0
- package/dist/agent/self-improvement/evolution/protected-paths.js +6 -0
- package/dist/agent/self-improvement/evolution/variant-fitness.d.ts +13 -2
- package/dist/agent/self-improvement/evolution/variant-fitness.js +184 -58
- package/dist/agent/self-improvement/evolution/worktree-scorer.d.ts +2 -0
- package/dist/agent/self-improvement/evolution/worktree-scorer.js +15 -0
- package/dist/agent/self-improvement/evolutionary-archive.d.ts +2 -1
- package/dist/agent/self-improvement/evolutionary-archive.js +34 -5
- package/dist/agent/self-improvement/proposal-store.d.ts +1 -0
- package/dist/agent/self-improvement/proposal-store.js +79 -17
- package/dist/agent/self-improvement/skill-apply-journal.d.ts +44 -0
- package/dist/agent/self-improvement/skill-apply-journal.js +178 -0
- package/dist/agent/self-improvement/skill-behavior-benchmark.d.ts +3 -0
- package/dist/agent/self-improvement/skill-behavior-benchmark.js +19 -0
- package/dist/agent/self-improvement/skill-behavior-gate.d.ts +34 -0
- package/dist/agent/self-improvement/skill-behavior-gate.js +96 -0
- package/dist/agent/self-improvement/skill-engine.d.ts +22 -0
- package/dist/agent/self-improvement/skill-engine.js +385 -13
- package/dist/agent/self-improvement/skill-gate.d.ts +2 -0
- package/dist/agent/self-improvement/skill-gate.js +17 -2
- package/dist/agent/self-improvement/skill-mutator.d.ts +6 -1
- package/dist/agent/self-improvement/skill-mutator.js +51 -15
- package/dist/agent/self-improvement/skill-types.d.ts +2 -1
- package/dist/agent/self-improvement/types.d.ts +11 -0
- package/dist/agent/tool-handler.d.ts +1 -1
- package/dist/agent/tool-handler.js +28 -9
- package/dist/auth/profile-manager.js +1 -1
- package/dist/channels/companion-channel-turn.d.ts +53 -4
- package/dist/channels/companion-channel-turn.js +218 -16
- package/dist/channels/slash-parity.d.ts +4 -6
- package/dist/channels/slash-parity.js +9 -44
- package/dist/cli/session-commands.d.ts +9 -0
- package/dist/cli/session-commands.js +45 -5
- package/dist/cli/session-picker.d.ts +43 -0
- package/dist/cli/session-picker.js +128 -0
- package/dist/codebuddy/a2a-call-tool-defs.d.ts +26 -0
- package/dist/codebuddy/a2a-call-tool-defs.js +12 -0
- package/dist/codebuddy/fleet-tool-defs.d.ts +1 -0
- package/dist/codebuddy/fleet-tool-defs.js +24 -0
- package/dist/codebuddy/providers/chatgpt-headers.d.ts +18 -0
- package/dist/codebuddy/providers/chatgpt-headers.js +37 -0
- package/dist/codebuddy/providers/provider-chatgpt-responses.d.ts +2 -1
- package/dist/codebuddy/providers/provider-chatgpt-responses.js +10 -23
- package/dist/codebuddy/providers/provider-openai-compat.js +1 -1
- package/dist/codebuddy/ragchat-tool-defs.d.ts +31 -0
- package/dist/codebuddy/ragchat-tool-defs.js +19 -0
- package/dist/codebuddy/resource-catalog-tool-defs.d.ts +28 -0
- package/dist/codebuddy/resource-catalog-tool-defs.js +18 -0
- package/dist/codebuddy/tool-definitions/agent-tools.js +2 -2
- package/dist/codebuddy/tool-definitions/code-exec-tools.js +5 -1
- package/dist/codebuddy/tool-definitions/cron-tools.js +6 -0
- package/dist/codebuddy/tool-definitions/self-describe-tools.js +6 -1
- package/dist/codebuddy/tools.d.ts +0 -6
- package/dist/codebuddy/tools.js +25 -3
- package/dist/commands/cli/daemon-commands.js +3 -1
- package/dist/commands/cli/evolve-command.js +21 -5
- package/dist/commands/cli/fleet-collaboration-commands.d.ts +2 -0
- package/dist/commands/cli/fleet-collaboration-commands.js +57 -0
- package/dist/commands/cli/fleet-commands.js +29 -0
- package/dist/commands/cli/fleet-mission-commands.d.ts +3 -0
- package/dist/commands/cli/fleet-mission-commands.js +72 -0
- package/dist/commands/cli/fleet-rooms-commands.d.ts +10 -0
- package/dist/commands/cli/fleet-rooms-commands.js +289 -0
- package/dist/commands/cli/tools-commands.js +2 -1
- package/dist/commands/cli/triage-command.d.ts +8 -0
- package/dist/commands/cli/triage-command.js +72 -0
- package/dist/commands/cli/utility-commands.js +25 -1
- package/dist/commands/client-dispatcher.d.ts +7 -0
- package/dist/commands/client-dispatcher.js +73 -21
- package/dist/commands/cron-cli/index.d.ts +3 -1
- package/dist/commands/cron-cli/index.js +25 -0
- package/dist/commands/device-auth.d.ts +10 -0
- package/dist/commands/device-auth.js +91 -0
- package/dist/commands/enhanced-command-handler.d.ts +9 -0
- package/dist/commands/enhanced-command-handler.js +28 -6
- package/dist/commands/handlers/agent-handlers.d.ts +1 -1
- package/dist/commands/handlers/agent-handlers.js +4 -4
- package/dist/commands/handlers/channel-handlers.js +53 -2
- package/dist/commands/handlers/export-handlers.d.ts +3 -2
- package/dist/commands/handlers/export-handlers.js +55 -28
- package/dist/commands/handlers/extra-handlers.js +5 -1
- package/dist/commands/handlers/grill-me-handler.js +26 -18
- package/dist/commands/handlers/memory-handlers.d.ts +6 -2
- package/dist/commands/handlers/memory-handlers.js +35 -15
- package/dist/commands/handlers/missing-handlers.d.ts +2 -2
- package/dist/commands/handlers/missing-handlers.js +4 -4
- package/dist/commands/handlers/resources-handler.d.ts +12 -0
- package/dist/commands/handlers/resources-handler.js +52 -0
- package/dist/commands/handlers/starter-handlers.d.ts +1 -1
- package/dist/commands/handlers/starter-handlers.js +32 -2
- package/dist/commands/handlers/switch-handler.d.ts +1 -1
- package/dist/commands/handlers/switch-handler.js +15 -0
- package/dist/commands/handlers/test-handlers.js +4 -86
- package/dist/commands/handlers/ui-handlers.js +11 -5
- package/dist/commands/login-chatgpt.d.ts +8 -0
- package/dist/commands/login-chatgpt.js +17 -0
- package/dist/commands/mcp-import.d.ts +11 -0
- package/dist/commands/mcp-import.js +67 -0
- package/dist/commands/mcp-invoke.d.ts +2 -0
- package/dist/commands/mcp-invoke.js +68 -0
- package/dist/commands/mcp.js +4 -0
- package/dist/commands/pipeline.d.ts +7 -1
- package/dist/commands/pipeline.js +104 -7
- package/dist/commands/resources.d.ts +2 -0
- package/dist/commands/resources.js +64 -0
- package/dist/commands/skills-cli/index.js +35 -12
- package/dist/commands/slash/builtin-commands.js +16 -3
- package/dist/commands/slash/index.d.ts +3 -1
- package/dist/commands/slash/index.js +2 -0
- package/dist/commands/slash/surfaces.d.ts +53 -0
- package/dist/commands/slash/surfaces.js +177 -0
- package/dist/commands/slash/types.d.ts +17 -0
- package/dist/commands/try.d.ts +1 -1
- package/dist/commands/try.js +1 -1
- package/dist/companion/companion-identity.d.ts +43 -0
- package/dist/companion/companion-identity.js +136 -0
- package/dist/companion/companion-toolset.d.ts +66 -0
- package/dist/companion/companion-toolset.js +368 -0
- package/dist/companion/companion-turn.d.ts +10 -2
- package/dist/companion/companion-turn.js +38 -1
- package/dist/config/code-exec-policy.d.ts +25 -0
- package/dist/config/code-exec-policy.js +39 -0
- package/dist/config/model-tools.d.ts +9 -0
- package/dist/config/model-tools.js +4 -0
- package/dist/context/context-manager-v2.js +2 -2
- package/dist/context/lm-resizer-compressor.js +3 -2
- package/dist/context/lm-resizer-diagnostics.d.ts +9 -0
- package/dist/context/lm-resizer-diagnostics.js +30 -0
- package/dist/context/tool-output-masking.js +3 -4
- package/dist/curator/curator.d.ts +6 -0
- package/dist/curator/curator.js +53 -3
- package/dist/daemon/cron-agent-bridge.d.ts +6 -0
- package/dist/daemon/cron-agent-bridge.js +31 -4
- package/dist/doctor/index.d.ts +11 -2
- package/dist/doctor/index.js +84 -21
- package/dist/doctor/integrations.d.ts +179 -0
- package/dist/doctor/integrations.js +227 -0
- package/dist/doctor/triage.d.ts +108 -0
- package/dist/doctor/triage.js +304 -0
- package/dist/fleet/collaboration.d.ts +44 -0
- package/dist/fleet/collaboration.js +170 -0
- package/dist/fleet/fleet-listener.d.ts +1 -0
- package/dist/fleet/fleet-listener.js +87 -46
- package/dist/fleet/fleet-registry.d.ts +2 -0
- package/dist/fleet/resource-catalog.d.ts +245 -0
- package/dist/fleet/resource-catalog.js +211 -0
- package/dist/fleet/rooms/room-access.d.ts +138 -0
- package/dist/fleet/rooms/room-access.js +196 -0
- package/dist/fleet/rooms/room-client.d.ts +158 -0
- package/dist/fleet/rooms/room-client.js +685 -0
- package/dist/fleet/rooms/room-event.d.ts +139 -0
- package/dist/fleet/rooms/room-event.js +330 -0
- package/dist/fleet/rooms/room-filter.d.ts +48 -0
- package/dist/fleet/rooms/room-filter.js +152 -0
- package/dist/fleet/rooms/room-hub.d.ts +154 -0
- package/dist/fleet/rooms/room-hub.js +363 -0
- package/dist/fleet/rooms/room-identity.d.ts +26 -0
- package/dist/fleet/rooms/room-identity.js +82 -0
- package/dist/fleet/rooms/room-lock.d.ts +34 -0
- package/dist/fleet/rooms/room-lock.js +180 -0
- package/dist/fleet/rooms/room-observations.d.ts +7 -0
- package/dist/fleet/rooms/room-observations.js +61 -0
- package/dist/fleet/rooms/room-server.d.ts +28 -0
- package/dist/fleet/rooms/room-server.js +75 -0
- package/dist/fleet/rooms/room-store.d.ts +119 -0
- package/dist/fleet/rooms/room-store.js +448 -0
- package/dist/fleet/rooms/room-ws-bridge.d.ts +27 -0
- package/dist/fleet/rooms/room-ws-bridge.js +137 -0
- package/dist/fleet/sensory-mission-bridge.d.ts +42 -0
- package/dist/fleet/sensory-mission-bridge.js +136 -0
- package/dist/git/worktree-sessions.js +1 -0
- package/dist/harness/contract.d.ts +4 -4
- package/dist/harness/fleet-supervisor.d.ts +16 -0
- package/dist/harness/fleet-supervisor.js +64 -0
- package/dist/harness/index.d.ts +4 -0
- package/dist/harness/index.js +4 -0
- package/dist/harness/mission-runner.d.ts +3 -0
- package/dist/harness/mission-runner.js +53 -0
- package/dist/harness/mission-store.d.ts +93 -0
- package/dist/harness/mission-store.js +297 -0
- package/dist/harness/tool-harness.d.ts +56 -0
- package/dist/harness/tool-harness.js +153 -0
- package/dist/hooks/use-enhanced-input.js +48 -4
- package/dist/hooks/use-input-handler.d.ts +1 -0
- package/dist/hooks/use-input-handler.js +82 -22
- package/dist/hooks/use-input-history.js +1 -0
- package/dist/identity/lisa-introspection.js +5 -2
- package/dist/identity/operational-self-model.d.ts +2 -0
- package/dist/identity/operational-self-model.js +4 -0
- package/dist/index.js +52 -6
- package/dist/mcp/client.js +6 -0
- package/dist/mcp/config.d.ts +20 -0
- package/dist/mcp/config.js +121 -8
- package/dist/mcp/import-normalize.d.ts +12 -0
- package/dist/mcp/import-normalize.js +114 -0
- package/dist/mcp/transports.d.ts +10 -5
- package/dist/mcp/transports.js +61 -99
- package/dist/mcp/types.d.ts +5 -0
- package/dist/media/comfyui-recipe-contract.d.ts +7 -7
- package/dist/memory/facts-memory.d.ts +11 -1
- package/dist/memory/facts-memory.js +47 -8
- package/dist/memory/memory-candidate-queue.d.ts +2 -2
- package/dist/memory/memory-candidate-queue.js +6 -6
- package/dist/memory/persistent-memory.d.ts +13 -8
- package/dist/memory/persistent-memory.js +77 -30
- package/dist/nodes/device-node.js +5 -9
- package/dist/observability/mobile-supervision-gateway-contract.js +20 -7
- package/dist/observability/run-event-writer.d.ts +21 -0
- package/dist/observability/run-event-writer.js +81 -0
- package/dist/observability/run-store.d.ts +5 -0
- package/dist/observability/run-store.js +18 -13
- package/dist/observability/run-trajectory.js +1 -1
- package/dist/optimization/prompt-cache.d.ts +19 -2
- package/dist/optimization/prompt-cache.js +41 -6
- package/dist/orchestration/orchestrator.d.ts +21 -0
- package/dist/orchestration/orchestrator.js +122 -15
- package/dist/persistence/session-content.d.ts +8 -0
- package/dist/persistence/session-content.js +76 -0
- package/dist/persistence/session-handoff.d.ts +64 -0
- package/dist/persistence/session-handoff.js +80 -0
- package/dist/persistence/session-history.d.ts +4 -0
- package/dist/persistence/session-history.js +38 -0
- package/dist/persistence/session-store.d.ts +9 -0
- package/dist/persistence/session-store.js +48 -20
- package/dist/personas/persona-manager.js +17 -1
- package/dist/plugins/code-explorer/CodeExplorerManager.d.ts +10 -4
- package/dist/plugins/code-explorer/CodeExplorerManager.js +69 -16
- package/dist/plugins/plugin-manager.js +10 -1
- package/dist/prompts/prompt-manager.js +11 -4
- package/dist/prompts/system-base.js +6 -2
- package/dist/protocols/a2a/codebuddy-executor.d.ts +11 -2
- package/dist/protocols/a2a/codebuddy-executor.js +9 -8
- package/dist/protocols/a2a/index.d.ts +1 -1
- package/dist/protocols/a2a/jsonrpc-v1.d.ts +41 -0
- package/dist/protocols/a2a/jsonrpc-v1.js +145 -0
- package/dist/protocols/a2a/peer-config.d.ts +20 -0
- package/dist/protocols/a2a/peer-config.js +55 -0
- package/dist/providers/codex-oauth.js +30 -6
- package/dist/providers/model-provider-compat.js +2 -1
- package/dist/sandbox/os-sandbox.d.ts +1 -1
- package/dist/scheduler/cron-scheduler.d.ts +15 -2
- package/dist/scheduler/cron-scheduler.js +35 -4
- package/dist/scheduler/job-notepad.d.ts +69 -0
- package/dist/scheduler/job-notepad.js +339 -0
- package/dist/security/audit-logger.d.ts +1 -1
- package/dist/security/compute-confinement.d.ts +4 -0
- package/dist/security/compute-confinement.js +89 -0
- package/dist/security/session-encryption.d.ts +4 -0
- package/dist/security/session-encryption.js +31 -0
- package/dist/sensory/voice-loop.d.ts +17 -0
- package/dist/sensory/voice-loop.js +72 -15
- package/dist/server/auth/device-session-context.d.ts +9 -0
- package/dist/server/auth/device-session-context.js +13 -0
- package/dist/server/auth/device-store.d.ts +89 -0
- package/dist/server/auth/device-store.js +261 -0
- package/dist/server/auth/device-token.d.ts +3 -0
- package/dist/server/auth/device-token.js +6 -0
- package/dist/server/auth/jwt.js +4 -0
- package/dist/server/index.d.ts +0 -10
- package/dist/server/index.js +28 -0
- package/dist/server/middleware/auth.js +3 -2
- package/dist/server/routes/a2a-jsonrpc.d.ts +9 -0
- package/dist/server/routes/a2a-jsonrpc.js +66 -0
- package/dist/server/routes/a2a-protocol.d.ts +12 -0
- package/dist/server/routes/a2a-protocol.js +1 -1
- package/dist/server/routes/device-auth.d.ts +4 -0
- package/dist/server/routes/device-auth.js +40 -0
- package/dist/server/types.d.ts +4 -0
- package/dist/server/websocket/handler.d.ts +13 -0
- package/dist/server/websocket/handler.js +102 -17
- package/dist/services/prompt-builder.d.ts +2 -0
- package/dist/services/prompt-builder.js +13 -5
- package/dist/services/runtime-settings-context.d.ts +73 -0
- package/dist/services/runtime-settings-context.js +69 -0
- package/dist/skills/executor.js +2 -0
- package/dist/skills/hub.js +16 -14
- package/dist/skills/local-inventory.d.ts +21 -0
- package/dist/skills/local-inventory.js +72 -0
- package/dist/skills/skill-loader.js +2 -2
- package/dist/skills/skill-usage-store.d.ts +49 -0
- package/dist/skills/skill-usage-store.js +121 -0
- package/dist/testing/ai-integration-tests.js +8 -5
- package/dist/themes/theme-manager.d.ts +12 -0
- package/dist/themes/theme-manager.js +29 -0
- package/dist/themes/theme-schema.d.ts +24 -24
- package/dist/tools/a2a-call-tool.d.ts +34 -0
- package/dist/tools/a2a-call-tool.js +75 -0
- package/dist/tools/bash/streaming-executor.d.ts +1 -0
- package/dist/tools/bash/streaming-executor.js +78 -90
- package/dist/tools/code-exec-preflight-runner.d.ts +41 -0
- package/dist/tools/code-exec-preflight-runner.js +254 -0
- package/dist/tools/code-exec-preflight.d.ts +44 -0
- package/dist/tools/code-exec-preflight.js +501 -0
- package/dist/tools/code-exec-tool.d.ts +48 -1
- package/dist/tools/code-exec-tool.js +191 -47
- package/dist/tools/comment-watcher.js +29 -12
- package/dist/tools/core-code-inspection.d.ts +56 -0
- package/dist/tools/core-code-inspection.js +86 -0
- package/dist/tools/create-skill-tool.d.ts +2 -3
- package/dist/tools/create-skill-tool.js +16 -75
- package/dist/tools/cronjob-tool.d.ts +1 -0
- package/dist/tools/cronjob-tool.js +1 -0
- package/dist/tools/env-doctor-tool.d.ts +2 -0
- package/dist/tools/env-doctor-tool.js +4 -3
- package/dist/tools/execute-code-rpc-invoker.d.ts +1 -1
- package/dist/tools/execute-code-rpc-invoker.js +35 -19
- package/dist/tools/execute-code-runner.d.ts +2 -0
- package/dist/tools/execute-code-runner.js +52 -17
- package/dist/tools/fleet-room-tool.d.ts +104 -0
- package/dist/tools/fleet-room-tool.js +124 -0
- package/dist/tools/integration-tool-hints.d.ts +4 -0
- package/dist/tools/integration-tool-hints.js +19 -0
- package/dist/tools/list-peers-tool.d.ts +3 -0
- package/dist/tools/list-peers-tool.js +11 -4
- package/dist/tools/media-generation-tool.d.ts +16 -1
- package/dist/tools/media-generation-tool.js +341 -9
- package/dist/tools/merge-conflict-tool.js +53 -25
- package/dist/tools/metadata.d.ts +1 -5
- package/dist/tools/metadata.js +21 -28
- package/dist/tools/ragchat-tool.d.ts +39 -0
- package/dist/tools/ragchat-tool.js +105 -0
- package/dist/tools/registry/fleet-tools.d.ts +9 -0
- package/dist/tools/registry/fleet-tools.js +22 -1
- package/dist/tools/registry/knowledge-tools.d.ts +2 -2
- package/dist/tools/registry/knowledge-tools.js +2 -2
- package/dist/tools/registry/lessons-tools.d.ts +7 -0
- package/dist/tools/registry/lessons-tools.js +43 -3
- package/dist/tools/registry/memory-tools.d.ts +1 -1
- package/dist/tools/registry/memory-tools.js +8 -8
- package/dist/tools/registry/research-tools.d.ts +1 -0
- package/dist/tools/registry/research-tools.js +4 -13
- package/dist/tools/registry/self-describe-tools.d.ts +1 -1
- package/dist/tools/registry/self-describe-tools.js +43 -30
- package/dist/tools/resource-catalog-tool.d.ts +38 -0
- package/dist/tools/resource-catalog-tool.js +46 -0
- package/dist/tools/skills-inspection-tool.js +30 -1
- package/dist/tools/stream-tool-output.d.ts +3 -0
- package/dist/tools/stream-tool-output.js +33 -0
- package/dist/tools/tool-call-scheduler.d.ts +10 -0
- package/dist/tools/tool-call-scheduler.js +58 -0
- package/dist/tools/tool-effect.d.ts +5 -0
- package/dist/tools/tool-effect.js +26 -0
- package/dist/tools/tool-search.d.ts +12 -11
- package/dist/tools/tool-search.js +67 -26
- package/dist/tools/types.d.ts +6 -0
- package/dist/ui/components/ChatHistory.d.ts +1 -1
- package/dist/ui/components/ChatHistory.js +2 -2
- package/dist/ui/components/ChatInput.d.ts +2 -1
- package/dist/ui/components/ChatInput.js +42 -88
- package/dist/ui/components/ChatInterface.d.ts +4 -2
- package/dist/ui/components/ChatInterface.js +27 -63
- package/dist/ui/components/CommandSuggestions.d.ts +0 -1
- package/dist/ui/components/CommandSuggestions.js +4 -6
- package/dist/ui/components/FileAutocomplete.js +1 -1
- package/dist/ui/components/KeyboardHelp.js +8 -6
- package/dist/ui/components/ModelSelection.js +6 -5
- package/dist/ui/components/StatusBar.d.ts +2 -1
- package/dist/ui/components/StatusBar.js +8 -7
- package/dist/ui/context/theme-context.js +3 -2
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +1 -1
- package/dist/ui/utils/markdown-renderer.js +4 -13
- package/dist/utils/atomic-write.d.ts +22 -0
- package/dist/utils/atomic-write.js +29 -0
- package/dist/utils/bounded-output.d.ts +16 -0
- package/dist/utils/bounded-output.js +63 -0
- package/dist/utils/device-store-file.d.ts +4 -0
- package/dist/utils/device-store-file.js +40 -0
- package/dist/utils/export-manager.d.ts +9 -0
- package/dist/utils/export-manager.js +19 -0
- package/dist/utils/first-use-hints.d.ts +25 -0
- package/dist/utils/first-use-hints.js +58 -0
- package/dist/utils/history-manager.js +1 -1
- package/dist/utils/update-notifier.js +16 -18
- package/dist/wizard/environment-detection.d.ts +5 -1
- package/dist/wizard/environment-detection.js +49 -7
- package/dist/wizard/onboarding.d.ts +5 -1
- package/dist/wizard/onboarding.js +90 -30
- package/dist/wizard/provider-onboarding.d.ts +2 -0
- package/dist/wizard/provider-onboarding.js +55 -17
- package/package.json +7 -3
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Durable skill-apply journal — records the intent to install before any
|
|
3
|
+
* mutator write, then the installed/proof-pending step, so a crash between
|
|
4
|
+
* install and archive.append can be reconciled without re-authoring.
|
|
5
|
+
*
|
|
6
|
+
* @module agent/self-improvement/skill-apply-journal
|
|
7
|
+
*/
|
|
8
|
+
import type { SkillBehaviorResult } from './skill-behavior-gate.js';
|
|
9
|
+
import type { SkillProposal } from './skill-types.js';
|
|
10
|
+
export declare const SKILL_APPLY_JOURNAL_SCHEMA_VERSION = 1;
|
|
11
|
+
/** Intent is written before install; installed means proof (archive) is still pending. */
|
|
12
|
+
export type SkillApplyPhase = 'intent' | 'installed' | 'conflict';
|
|
13
|
+
export interface SkillApplyRecord {
|
|
14
|
+
schemaVersion: typeof SKILL_APPLY_JOURNAL_SCHEMA_VERSION;
|
|
15
|
+
scenarioId: string;
|
|
16
|
+
proposalId: string;
|
|
17
|
+
proposal: SkillProposal;
|
|
18
|
+
intendedSha256: string;
|
|
19
|
+
phase: SkillApplyPhase;
|
|
20
|
+
appliedRef?: string;
|
|
21
|
+
behavior?: SkillBehaviorResult;
|
|
22
|
+
createdAt: string;
|
|
23
|
+
updatedAt: string;
|
|
24
|
+
}
|
|
25
|
+
export interface SkillApplyJournalOptions {
|
|
26
|
+
workDir?: string;
|
|
27
|
+
now?: () => Date;
|
|
28
|
+
}
|
|
29
|
+
export declare class SkillApplyJournal {
|
|
30
|
+
private readonly filePath;
|
|
31
|
+
private readonly now;
|
|
32
|
+
constructor(options?: SkillApplyJournalOptions);
|
|
33
|
+
get path(): string;
|
|
34
|
+
list(): SkillApplyRecord[];
|
|
35
|
+
/** Intent or installed — still needs work. Conflict is terminal and excluded. */
|
|
36
|
+
listPending(): SkillApplyRecord[];
|
|
37
|
+
get(scenarioId: string): SkillApplyRecord | null;
|
|
38
|
+
upsert(input: Omit<SkillApplyRecord, 'schemaVersion' | 'createdAt' | 'updatedAt'> & {
|
|
39
|
+
createdAt?: string;
|
|
40
|
+
}): SkillApplyRecord;
|
|
41
|
+
remove(scenarioId: string): boolean;
|
|
42
|
+
private read;
|
|
43
|
+
private write;
|
|
44
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Durable skill-apply journal — records the intent to install before any
|
|
3
|
+
* mutator write, then the installed/proof-pending step, so a crash between
|
|
4
|
+
* install and archive.append can be reconciled without re-authoring.
|
|
5
|
+
*
|
|
6
|
+
* @module agent/self-improvement/skill-apply-journal
|
|
7
|
+
*/
|
|
8
|
+
import fs from 'fs';
|
|
9
|
+
import path from 'path';
|
|
10
|
+
import { writeJsonAtomicSync } from '../../utils/atomic-write.js';
|
|
11
|
+
export const SKILL_APPLY_JOURNAL_SCHEMA_VERSION = 1;
|
|
12
|
+
const PENDING_PHASES = new Set(['intent', 'installed']);
|
|
13
|
+
const SHA256_HEX = /^[a-f0-9]{64}$/;
|
|
14
|
+
function isNonEmptyString(value) {
|
|
15
|
+
return typeof value === 'string' && value.length > 0;
|
|
16
|
+
}
|
|
17
|
+
function isSha256Hex(value) {
|
|
18
|
+
return typeof value === 'string' && SHA256_HEX.test(value);
|
|
19
|
+
}
|
|
20
|
+
function isProposal(value, proposalId, scenarioId) {
|
|
21
|
+
if (!value || typeof value !== 'object')
|
|
22
|
+
return false;
|
|
23
|
+
const proposal = value;
|
|
24
|
+
if (proposal.id !== proposalId)
|
|
25
|
+
return false;
|
|
26
|
+
if (proposal.targetScenarioId !== scenarioId)
|
|
27
|
+
return false;
|
|
28
|
+
const spec = proposal.spec;
|
|
29
|
+
if (!spec || typeof spec !== 'object')
|
|
30
|
+
return false;
|
|
31
|
+
if (!isNonEmptyString(spec.name) || typeof spec.description !== 'string' || typeof spec.content !== 'string') {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
function isRecord(value) {
|
|
37
|
+
if (!value || typeof value !== 'object')
|
|
38
|
+
return false;
|
|
39
|
+
const rec = value;
|
|
40
|
+
if (rec.schemaVersion !== SKILL_APPLY_JOURNAL_SCHEMA_VERSION)
|
|
41
|
+
return false;
|
|
42
|
+
if (!isNonEmptyString(rec.scenarioId) || !isNonEmptyString(rec.proposalId))
|
|
43
|
+
return false;
|
|
44
|
+
if (!isSha256Hex(rec.intendedSha256))
|
|
45
|
+
return false;
|
|
46
|
+
if (rec.phase !== 'intent' && rec.phase !== 'installed' && rec.phase !== 'conflict')
|
|
47
|
+
return false;
|
|
48
|
+
if (!isProposal(rec.proposal, rec.proposalId, rec.scenarioId))
|
|
49
|
+
return false;
|
|
50
|
+
if (typeof rec.createdAt !== 'string' || typeof rec.updatedAt !== 'string')
|
|
51
|
+
return false;
|
|
52
|
+
if (rec.appliedRef !== undefined && typeof rec.appliedRef !== 'string')
|
|
53
|
+
return false;
|
|
54
|
+
if (rec.behavior !== undefined) {
|
|
55
|
+
const behavior = rec.behavior;
|
|
56
|
+
if (!behavior || typeof behavior !== 'object')
|
|
57
|
+
return false;
|
|
58
|
+
if (typeof behavior.accepted !== 'boolean')
|
|
59
|
+
return false;
|
|
60
|
+
if (typeof behavior.wins !== 'number' || typeof behavior.losses !== 'number' || typeof behavior.tested !== 'number') {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
if (!Array.isArray(behavior.cases))
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
function isJournalFile(value) {
|
|
69
|
+
if (!value || typeof value !== 'object')
|
|
70
|
+
return false;
|
|
71
|
+
const file = value;
|
|
72
|
+
if (file.schemaVersion !== SKILL_APPLY_JOURNAL_SCHEMA_VERSION)
|
|
73
|
+
return false;
|
|
74
|
+
if (!Array.isArray(file.records))
|
|
75
|
+
return false;
|
|
76
|
+
return file.records.every(isRecord);
|
|
77
|
+
}
|
|
78
|
+
function assertUpsertIdentities(input) {
|
|
79
|
+
if (!isNonEmptyString(input.scenarioId))
|
|
80
|
+
throw new Error('scenarioId required');
|
|
81
|
+
if (!isNonEmptyString(input.proposalId))
|
|
82
|
+
throw new Error('proposalId required');
|
|
83
|
+
if (!isSha256Hex(input.intendedSha256))
|
|
84
|
+
throw new Error('intendedSha256 must be a sha256 hex digest');
|
|
85
|
+
if (!isProposal(input.proposal, input.proposalId, input.scenarioId)) {
|
|
86
|
+
throw new Error('proposal identity must match proposalId and scenarioId');
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
export class SkillApplyJournal {
|
|
90
|
+
filePath;
|
|
91
|
+
now;
|
|
92
|
+
constructor(options = {}) {
|
|
93
|
+
const root = options.workDir ?? process.cwd();
|
|
94
|
+
this.filePath = path.join(root, '.codebuddy', 'self-improvement', 'skill-apply.json');
|
|
95
|
+
this.now = options.now ?? (() => new Date());
|
|
96
|
+
}
|
|
97
|
+
get path() {
|
|
98
|
+
return this.filePath;
|
|
99
|
+
}
|
|
100
|
+
list() {
|
|
101
|
+
return this.read().records;
|
|
102
|
+
}
|
|
103
|
+
/** Intent or installed — still needs work. Conflict is terminal and excluded. */
|
|
104
|
+
listPending() {
|
|
105
|
+
return this.list().filter((record) => PENDING_PHASES.has(record.phase));
|
|
106
|
+
}
|
|
107
|
+
get(scenarioId) {
|
|
108
|
+
return this.list().find((record) => record.scenarioId === scenarioId) ?? null;
|
|
109
|
+
}
|
|
110
|
+
upsert(input) {
|
|
111
|
+
assertUpsertIdentities(input);
|
|
112
|
+
const file = this.read();
|
|
113
|
+
const stamp = this.now().toISOString();
|
|
114
|
+
const previous = file.records.find((record) => record.scenarioId === input.scenarioId);
|
|
115
|
+
const stored = {
|
|
116
|
+
schemaVersion: SKILL_APPLY_JOURNAL_SCHEMA_VERSION,
|
|
117
|
+
scenarioId: input.scenarioId,
|
|
118
|
+
proposalId: input.proposalId,
|
|
119
|
+
proposal: input.proposal,
|
|
120
|
+
intendedSha256: input.intendedSha256,
|
|
121
|
+
phase: input.phase,
|
|
122
|
+
createdAt: input.createdAt ?? previous?.createdAt ?? stamp,
|
|
123
|
+
updatedAt: stamp,
|
|
124
|
+
...(input.appliedRef ? { appliedRef: input.appliedRef } : {}),
|
|
125
|
+
...(input.behavior ? { behavior: input.behavior } : {}),
|
|
126
|
+
};
|
|
127
|
+
file.records = file.records.filter((record) => record.scenarioId !== input.scenarioId);
|
|
128
|
+
file.records.push(stored);
|
|
129
|
+
this.write(file);
|
|
130
|
+
return stored;
|
|
131
|
+
}
|
|
132
|
+
remove(scenarioId) {
|
|
133
|
+
const file = this.read();
|
|
134
|
+
const next = file.records.filter((record) => record.scenarioId !== scenarioId);
|
|
135
|
+
if (next.length === file.records.length)
|
|
136
|
+
return false;
|
|
137
|
+
this.write({ ...file, records: next });
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
read() {
|
|
141
|
+
let stat;
|
|
142
|
+
try {
|
|
143
|
+
stat = fs.statSync(this.filePath);
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
if (error.code === 'ENOENT') {
|
|
147
|
+
return { schemaVersion: SKILL_APPLY_JOURNAL_SCHEMA_VERSION, records: [] };
|
|
148
|
+
}
|
|
149
|
+
throw new Error(`skill apply journal unreadable at ${this.filePath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
150
|
+
}
|
|
151
|
+
if (!stat.isFile()) {
|
|
152
|
+
throw new Error(`skill apply journal unreadable at ${this.filePath}: not a regular file`);
|
|
153
|
+
}
|
|
154
|
+
let raw;
|
|
155
|
+
try {
|
|
156
|
+
raw = fs.readFileSync(this.filePath, 'utf8');
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
throw new Error(`skill apply journal unreadable at ${this.filePath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
160
|
+
}
|
|
161
|
+
let parsed;
|
|
162
|
+
try {
|
|
163
|
+
parsed = JSON.parse(raw);
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
throw new Error(`skill apply journal corrupt at ${this.filePath}; refusing to overwrite`);
|
|
167
|
+
}
|
|
168
|
+
if (!isJournalFile(parsed)) {
|
|
169
|
+
throw new Error(`skill apply journal invalid at ${this.filePath}; refusing to overwrite`);
|
|
170
|
+
}
|
|
171
|
+
return parsed;
|
|
172
|
+
}
|
|
173
|
+
write(file) {
|
|
174
|
+
fs.mkdirSync(path.dirname(this.filePath), { recursive: true });
|
|
175
|
+
writeJsonAtomicSync(this.filePath, file, { mode: 0o600 });
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=skill-apply-journal.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const SKILL_BEHAVIOR_TASKS = {
|
|
2
|
+
'safe-delete': [
|
|
3
|
+
{ id: 'backup-before-delete', prompt: 'Remove stale.txt safely, preserving its contents in backup.txt before removal. Leave keep.txt unchanged.', files: { 'stale.txt': 'old data', 'keep.txt': 'keep' }, expectedFiles: { 'backup.txt': 'old data', 'keep.txt': 'keep' }, absentFiles: ['stale.txt'], effects: ['write_file:backup.txt', 'delete_file:stale.txt'] },
|
|
4
|
+
{ id: 'missing-delete-target', prompt: 'The obsolete file stale.txt is already absent. Preserve keep.txt unchanged and write status.txt containing exactly "already absent". Do not remove another file.', files: { 'keep.txt': 'keep' }, expectedFiles: { 'keep.txt': 'keep', 'status.txt': 'already absent' }, absentFiles: ['stale.txt'] },
|
|
5
|
+
],
|
|
6
|
+
'git-bisect': [
|
|
7
|
+
{ id: 'first-bad', prompt: 'history.json lists commits in chronological order and their test verdict. Write first-bad.txt with only the id of the first failing commit. Preserve history.json.', files: { 'history.json': '[{"id":"a","pass":true},{"id":"b","pass":true},{"id":"c","pass":false},{"id":"d","pass":false}]' }, expectedFiles: { 'first-bad.txt': 'c', 'history.json': '[{"id":"a","pass":true},{"id":"b","pass":true},{"id":"c","pass":false},{"id":"d","pass":false}]' } },
|
|
8
|
+
{ id: 'no-regression', prompt: 'Read history.json. Write first-bad.txt with the first failing id, or exactly "none" if every commit passes. Preserve history.json.', files: { 'history.json': '[{"id":"x","pass":true},{"id":"y","pass":true}]' }, expectedFiles: { 'first-bad.txt': 'none', 'history.json': '[{"id":"x","pass":true},{"id":"y","pass":true}]' } },
|
|
9
|
+
],
|
|
10
|
+
'relecture-typographique-francaise': [
|
|
11
|
+
{ id: 'typography-and-code', prompt: 'In note.md replace straight apostrophes in French prose with typographic apostrophes, preserving fenced code verbatim.', files: { 'note.md': "L'outil fonctionne.\n```js\nconst x = 'raw';\n```\n" }, expectedFiles: { 'note.md': "L’outil fonctionne.\n```js\nconst x = 'raw';\n```\n" } },
|
|
12
|
+
{ id: 'punctuation', prompt: 'In note.md replace the ordinary space immediately before a colon with a nonbreaking U+00A0 space. Preserve everything else.', files: { 'note.md': 'Note : oui.\n' }, expectedFiles: { 'note.md': 'Note\u00a0: oui.\n' } },
|
|
13
|
+
],
|
|
14
|
+
'mission-contrat-lane': [
|
|
15
|
+
{ id: 'report-first', prompt: 'Create report.md containing exactly "Plan" before changing result.txt to "done". Preserve original.txt.', files: { 'original.txt': 'untouched', 'result.txt': 'pending' }, expectedFiles: { 'report.md': 'Plan', 'result.txt': 'done', 'original.txt': 'untouched' }, effects: ['write_file:report.md', 'write_file:result.txt'] },
|
|
16
|
+
{ id: 'named-scope', prompt: 'Change only requested.txt to "updated". Preserve neighbor.txt and report.md byte for byte.', files: { 'requested.txt': 'old', 'neighbor.txt': 'keep', 'report.md': 'existing report' }, expectedFiles: { 'requested.txt': 'updated', 'neighbor.txt': 'keep', 'report.md': 'existing report' } },
|
|
17
|
+
],
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=skill-behavior-benchmark.js.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface SkillBehaviorTask {
|
|
2
|
+
id: string;
|
|
3
|
+
prompt: string;
|
|
4
|
+
files: Record<string, string>;
|
|
5
|
+
expectedFiles: Record<string, string>;
|
|
6
|
+
absentFiles?: string[];
|
|
7
|
+
/** Exact sequence of effects, for safety ordering such as backup before removal. */
|
|
8
|
+
effects?: string[];
|
|
9
|
+
}
|
|
10
|
+
export interface SkillBehaviorResult {
|
|
11
|
+
accepted: boolean;
|
|
12
|
+
wins: number;
|
|
13
|
+
losses: number;
|
|
14
|
+
tested: number;
|
|
15
|
+
cases: {
|
|
16
|
+
id: string;
|
|
17
|
+
before: boolean;
|
|
18
|
+
after: boolean;
|
|
19
|
+
}[];
|
|
20
|
+
error?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface SkillBehaviorClient {
|
|
23
|
+
chat(messages: Array<{
|
|
24
|
+
role: string;
|
|
25
|
+
content: string;
|
|
26
|
+
}>, tools?: unknown[]): Promise<{
|
|
27
|
+
choices?: Array<{
|
|
28
|
+
message?: {
|
|
29
|
+
content?: string | null;
|
|
30
|
+
};
|
|
31
|
+
}>;
|
|
32
|
+
}>;
|
|
33
|
+
}
|
|
34
|
+
export declare function evaluateSkillBehavior(content: string, tasks: readonly SkillBehaviorTask[], client?: SkillBehaviorClient): Promise<SkillBehaviorResult>;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/** Paired execution of curated file tasks. Candidate text never supplies its own grader. */
|
|
2
|
+
import fs from 'node:fs/promises';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { ToolHarness } from '../../harness/tool-harness.js';
|
|
6
|
+
const DEFINITIONS = ['read_file', 'write_file', 'delete_file', 'list_files'].map(name => ({
|
|
7
|
+
type: 'function', function: { name, description: `${name} in the task fixture; args: {path, content?}`, parameters: { type: 'object', required: [], properties: { path: { type: 'string' }, content: { type: 'string' } } } },
|
|
8
|
+
}));
|
|
9
|
+
async function runArm(client, task, skill) {
|
|
10
|
+
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'cb-skill-behavior-'));
|
|
11
|
+
const effects = [];
|
|
12
|
+
const resolve = (value) => {
|
|
13
|
+
if (typeof value !== 'string' || !value || path.isAbsolute(value) || value.split(/[\\/]/).includes('..'))
|
|
14
|
+
throw new Error('Invalid fixture path');
|
|
15
|
+
return path.join(root, value);
|
|
16
|
+
};
|
|
17
|
+
const harness = new ToolHarness({ cwd: root, tools: DEFINITIONS, dispatch: async (name, args) => {
|
|
18
|
+
if (name === 'list_files')
|
|
19
|
+
return { success: true, data: await fs.readdir(root) };
|
|
20
|
+
const file = resolve(args.path);
|
|
21
|
+
if (name === 'read_file')
|
|
22
|
+
return { success: true, output: await fs.readFile(file, 'utf8') };
|
|
23
|
+
if (name === 'write_file') {
|
|
24
|
+
if (typeof args.content !== 'string')
|
|
25
|
+
throw new Error('content must be a string');
|
|
26
|
+
await fs.mkdir(path.dirname(file), { recursive: true });
|
|
27
|
+
await fs.writeFile(file, args.content);
|
|
28
|
+
}
|
|
29
|
+
else if (name === 'delete_file')
|
|
30
|
+
await fs.unlink(file);
|
|
31
|
+
else
|
|
32
|
+
throw new Error('Unavailable fixture tool');
|
|
33
|
+
effects.push(`${name}:${String(args.path)}`);
|
|
34
|
+
return { success: true };
|
|
35
|
+
} });
|
|
36
|
+
try {
|
|
37
|
+
for (const [name, content] of Object.entries(task.files)) {
|
|
38
|
+
const file = resolve(name);
|
|
39
|
+
await fs.mkdir(path.dirname(file), { recursive: true });
|
|
40
|
+
await fs.writeFile(file, content);
|
|
41
|
+
}
|
|
42
|
+
const result = await client.chat([
|
|
43
|
+
{ role: 'system', content: 'Return ONLY JavaScript, no markdown fences. Use await tools.read_file({path}), tools.write_file({path,content}), tools.delete_file({path}), tools.list_files({}). Results are {success,output?,data?}; check success. No imports or other tools. Modify the fixture to complete the task.' + (skill ? `\nRelevant skill:\n${skill}` : '') },
|
|
44
|
+
{ role: 'user', content: `${task.prompt}\nAvailable files: ${Object.keys(task.files).join(', ')}` },
|
|
45
|
+
], []);
|
|
46
|
+
const code = result.choices?.[0]?.message?.content?.trim();
|
|
47
|
+
if (!code || !(await harness.exec(code, { timeoutMs: 5000 })).success)
|
|
48
|
+
return false;
|
|
49
|
+
for (const [name, content] of Object.entries(task.expectedFiles))
|
|
50
|
+
if (await fs.readFile(resolve(name), 'utf8') !== content)
|
|
51
|
+
return false;
|
|
52
|
+
for (const name of task.absentFiles ?? []) {
|
|
53
|
+
try {
|
|
54
|
+
await fs.stat(resolve(name));
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
if (error.code !== 'ENOENT')
|
|
59
|
+
throw error;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const entries = await fs.readdir(root, { recursive: true, withFileTypes: true });
|
|
63
|
+
if (entries.filter(entry => entry.isFile()).length !== Object.keys(task.expectedFiles).length)
|
|
64
|
+
return false;
|
|
65
|
+
return !task.effects || (effects.length === task.effects.length && effects.every((effect, index) => effect === task.effects[index]));
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
finally {
|
|
71
|
+
await harness.dispose();
|
|
72
|
+
await fs.rm(root, { recursive: true, force: true });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
export async function evaluateSkillBehavior(content, tasks, client) {
|
|
76
|
+
const cases = [];
|
|
77
|
+
if (!tasks.length)
|
|
78
|
+
return { accepted: false, wins: 0, losses: 0, tested: 0, cases, error: 'No curated behavioral tasks for this scenario' };
|
|
79
|
+
if (!client) {
|
|
80
|
+
const { detectProviderFromEnv } = await import('../../utils/provider-detector.js');
|
|
81
|
+
const provider = detectProviderFromEnv();
|
|
82
|
+
if (!provider)
|
|
83
|
+
return { accepted: false, wins: 0, losses: 0, tested: 0, cases, error: 'Behavioral validation requires a configured provider' };
|
|
84
|
+
const { CodeBuddyClient } = await import('../../codebuddy/client.js');
|
|
85
|
+
client = new CodeBuddyClient(provider.apiKey, provider.defaultModel, provider.baseURL);
|
|
86
|
+
}
|
|
87
|
+
for (const task of tasks) {
|
|
88
|
+
const before = await runArm(client, task);
|
|
89
|
+
const after = await runArm(client, task, content);
|
|
90
|
+
cases.push({ id: task.id, before, after });
|
|
91
|
+
}
|
|
92
|
+
const wins = cases.filter(c => !c.before && c.after).length;
|
|
93
|
+
const losses = cases.filter(c => c.before && !c.after).length;
|
|
94
|
+
return { accepted: wins > 0 && losses === 0 && cases.every(c => c.after), wins, losses, tested: cases.length, cases };
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=skill-behavior-gate.js.map
|
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @module agent/self-improvement/skill-engine
|
|
7
7
|
*/
|
|
8
|
+
import { type SkillBehaviorResult } from './skill-behavior-gate.js';
|
|
8
9
|
import { EvolutionaryArchive } from './evolutionary-archive.js';
|
|
9
10
|
import { type Autonomy } from './engine.js';
|
|
10
11
|
import { PendingProposalStore } from './proposal-store.js';
|
|
12
|
+
import { SkillApplyJournal, type SkillApplyPhase } from './skill-apply-journal.js';
|
|
11
13
|
import { type SkillMutatorPort } from './skill-mutator.js';
|
|
12
14
|
import type { SkillProposer } from './skill-proposer.js';
|
|
13
15
|
import type { SkillBenchmarkScenario, SkillGateOutcome } from './skill-types.js';
|
|
@@ -20,9 +22,14 @@ export interface SkillCycleResult {
|
|
|
20
22
|
gate: SkillGateOutcome | null;
|
|
21
23
|
applied: boolean;
|
|
22
24
|
notes: string[];
|
|
25
|
+
behavior?: SkillBehaviorResult;
|
|
26
|
+
/** Skill is on disk; archive write has not been acknowledged. */
|
|
27
|
+
proofPending?: boolean;
|
|
28
|
+
applyPhase?: SkillApplyPhase | 'archived';
|
|
23
29
|
}
|
|
24
30
|
export interface SkillImprovementEngineOptions {
|
|
25
31
|
scenarios: SkillBenchmarkScenario[];
|
|
32
|
+
evaluateBehavior?: (content: string, scenarioId: string) => Promise<SkillBehaviorResult>;
|
|
26
33
|
proposer: SkillProposer;
|
|
27
34
|
mutator?: SkillMutatorPort;
|
|
28
35
|
archive?: EvolutionaryArchive;
|
|
@@ -31,8 +38,12 @@ export interface SkillImprovementEngineOptions {
|
|
|
31
38
|
/** Workspace root for pending propose-only candidates (default cwd). */
|
|
32
39
|
workDir?: string;
|
|
33
40
|
proposalStore?: PendingProposalStore;
|
|
41
|
+
applyJournal?: SkillApplyJournal;
|
|
42
|
+
/** Override on-disk read used to compare an already-installed artifact. */
|
|
43
|
+
readInstalledSkill?: (name: string) => string | null;
|
|
34
44
|
}
|
|
35
45
|
export declare class SkillImprovementEngine {
|
|
46
|
+
private readonly evaluateBehavior;
|
|
36
47
|
private readonly scenarios;
|
|
37
48
|
private readonly proposer;
|
|
38
49
|
private readonly mutator;
|
|
@@ -40,10 +51,21 @@ export declare class SkillImprovementEngine {
|
|
|
40
51
|
private readonly autonomy;
|
|
41
52
|
private readonly now;
|
|
42
53
|
private readonly proposals;
|
|
54
|
+
private readonly applyJournal;
|
|
55
|
+
private readonly workDir;
|
|
56
|
+
private readonly readInstalledSkill;
|
|
43
57
|
private readonly covered;
|
|
44
58
|
private readonly attempted;
|
|
45
59
|
constructor(options: SkillImprovementEngineOptions);
|
|
46
60
|
runCycle(): Promise<SkillCycleResult>;
|
|
47
61
|
runLoop(maxCycles?: number): Promise<SkillCycleResult[]>;
|
|
48
62
|
private finishCycle;
|
|
63
|
+
private peekPendingRecords;
|
|
64
|
+
private resumePending;
|
|
65
|
+
private settleApplication;
|
|
66
|
+
private ensureInstalled;
|
|
67
|
+
private dryMutator;
|
|
68
|
+
private peekInstalled;
|
|
69
|
+
private markConflict;
|
|
70
|
+
private conflictResult;
|
|
49
71
|
}
|