@alan-ai-hq/agent-manager 0.1.113 → 0.1.115
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +88 -0
- package/dist/__tests__/binding-switch-git.test.d.ts +2 -0
- package/dist/__tests__/binding-switch-git.test.d.ts.map +1 -0
- package/dist/__tests__/binding-switch-git.test.js +555 -0
- package/dist/__tests__/binding-switch-git.test.js.map +1 -0
- package/dist/__tests__/cli-ensure-install.test.d.ts +2 -0
- package/dist/__tests__/cli-ensure-install.test.d.ts.map +1 -0
- package/dist/__tests__/cli-ensure-install.test.js +177 -0
- package/dist/__tests__/cli-ensure-install.test.js.map +1 -0
- package/dist/__tests__/cli-executable.test.d.ts +2 -0
- package/dist/__tests__/cli-executable.test.d.ts.map +1 -0
- package/dist/__tests__/cli-executable.test.js +155 -0
- package/dist/__tests__/cli-executable.test.js.map +1 -0
- package/dist/__tests__/cli-executable.windows.test.d.ts +2 -0
- package/dist/__tests__/cli-executable.windows.test.d.ts.map +1 -0
- package/dist/__tests__/cli-executable.windows.test.js +123 -0
- package/dist/__tests__/cli-executable.windows.test.js.map +1 -0
- package/dist/__tests__/cli-help.test.d.ts +2 -0
- package/dist/__tests__/cli-help.test.d.ts.map +1 -0
- package/dist/__tests__/cli-help.test.js +47 -0
- package/dist/__tests__/cli-help.test.js.map +1 -0
- package/dist/__tests__/computer-readiness.test.d.ts +2 -0
- package/dist/__tests__/computer-readiness.test.d.ts.map +1 -0
- package/dist/__tests__/computer-readiness.test.js +63 -0
- package/dist/__tests__/computer-readiness.test.js.map +1 -0
- package/dist/__tests__/core-agent-provider-auth-env.test.d.ts +2 -0
- package/dist/__tests__/core-agent-provider-auth-env.test.d.ts.map +1 -0
- package/dist/__tests__/core-agent-provider-auth-env.test.js +93 -0
- package/dist/__tests__/core-agent-provider-auth-env.test.js.map +1 -0
- package/dist/__tests__/core-agent-workflow-context.test.d.ts +2 -0
- package/dist/__tests__/core-agent-workflow-context.test.d.ts.map +1 -0
- package/dist/__tests__/core-agent-workflow-context.test.js +139 -0
- package/dist/__tests__/core-agent-workflow-context.test.js.map +1 -0
- package/dist/__tests__/daemon-native-hooks.test.d.ts +2 -0
- package/dist/__tests__/daemon-native-hooks.test.d.ts.map +1 -0
- package/dist/__tests__/daemon-native-hooks.test.js +94 -0
- package/dist/__tests__/daemon-native-hooks.test.js.map +1 -0
- package/dist/__tests__/daemon-reconcile-ask.test.d.ts +2 -0
- package/dist/__tests__/daemon-reconcile-ask.test.d.ts.map +1 -0
- package/dist/__tests__/daemon-reconcile-ask.test.js +100 -0
- package/dist/__tests__/daemon-reconcile-ask.test.js.map +1 -0
- package/dist/__tests__/daemon-runner-status.test.d.ts +2 -0
- package/dist/__tests__/daemon-runner-status.test.d.ts.map +1 -0
- package/dist/__tests__/daemon-runner-status.test.js +102 -0
- package/dist/__tests__/daemon-runner-status.test.js.map +1 -0
- package/dist/__tests__/daemon-socket.integration.test.d.ts +2 -0
- package/dist/__tests__/daemon-socket.integration.test.d.ts.map +1 -0
- package/dist/__tests__/daemon-socket.integration.test.js +435 -0
- package/dist/__tests__/daemon-socket.integration.test.js.map +1 -0
- package/dist/__tests__/daemon.test.d.ts +2 -0
- package/dist/__tests__/daemon.test.d.ts.map +1 -0
- package/dist/__tests__/daemon.test.js +4884 -0
- package/dist/__tests__/daemon.test.js.map +1 -0
- package/dist/__tests__/ensure-shared-checkout-branch.test.d.ts +2 -0
- package/dist/__tests__/ensure-shared-checkout-branch.test.d.ts.map +1 -0
- package/dist/__tests__/ensure-shared-checkout-branch.test.js +129 -0
- package/dist/__tests__/ensure-shared-checkout-branch.test.js.map +1 -0
- package/dist/__tests__/event-journal-stress.test.d.ts +2 -0
- package/dist/__tests__/event-journal-stress.test.d.ts.map +1 -0
- package/dist/__tests__/event-journal-stress.test.js +124 -0
- package/dist/__tests__/event-journal-stress.test.js.map +1 -0
- package/dist/__tests__/event-journal.test.d.ts +2 -0
- package/dist/__tests__/event-journal.test.d.ts.map +1 -0
- package/dist/__tests__/event-journal.test.js +264 -0
- package/dist/__tests__/event-journal.test.js.map +1 -0
- package/dist/__tests__/event-outbox-persist-failure.test.d.ts +2 -0
- package/dist/__tests__/event-outbox-persist-failure.test.d.ts.map +1 -0
- package/dist/__tests__/event-outbox-persist-failure.test.js +143 -0
- package/dist/__tests__/event-outbox-persist-failure.test.js.map +1 -0
- package/dist/__tests__/event-outbox.test.d.ts +2 -0
- package/dist/__tests__/event-outbox.test.d.ts.map +1 -0
- package/dist/__tests__/event-outbox.test.js +602 -0
- package/dist/__tests__/event-outbox.test.js.map +1 -0
- package/dist/__tests__/execution-activity-tracker.test.d.ts +2 -0
- package/dist/__tests__/execution-activity-tracker.test.d.ts.map +1 -0
- package/dist/__tests__/execution-activity-tracker.test.js +64 -0
- package/dist/__tests__/execution-activity-tracker.test.js.map +1 -0
- package/dist/__tests__/execution-lease-client.test.d.ts +2 -0
- package/dist/__tests__/execution-lease-client.test.d.ts.map +1 -0
- package/dist/__tests__/execution-lease-client.test.js +274 -0
- package/dist/__tests__/execution-lease-client.test.js.map +1 -0
- package/dist/__tests__/fake-provider-cli.test.d.ts +2 -0
- package/dist/__tests__/fake-provider-cli.test.d.ts.map +1 -0
- package/dist/__tests__/fake-provider-cli.test.js +46 -0
- package/dist/__tests__/fake-provider-cli.test.js.map +1 -0
- package/dist/__tests__/generated-images.test.d.ts +2 -0
- package/dist/__tests__/generated-images.test.d.ts.map +1 -0
- package/dist/__tests__/generated-images.test.js +132 -0
- package/dist/__tests__/generated-images.test.js.map +1 -0
- package/dist/__tests__/helpers/sandbox-outbox.d.ts +3 -0
- package/dist/__tests__/helpers/sandbox-outbox.d.ts.map +1 -0
- package/dist/__tests__/helpers/sandbox-outbox.js +23 -0
- package/dist/__tests__/helpers/sandbox-outbox.js.map +1 -0
- package/dist/__tests__/install-command.test.d.ts +2 -0
- package/dist/__tests__/install-command.test.d.ts.map +1 -0
- package/dist/__tests__/install-command.test.js +185 -0
- package/dist/__tests__/install-command.test.js.map +1 -0
- package/dist/__tests__/integration-cli.test.d.ts +2 -0
- package/dist/__tests__/integration-cli.test.d.ts.map +1 -0
- package/dist/__tests__/integration-cli.test.js +150 -0
- package/dist/__tests__/integration-cli.test.js.map +1 -0
- package/dist/__tests__/lifecycle-contracts.test.d.ts +2 -0
- package/dist/__tests__/lifecycle-contracts.test.d.ts.map +1 -0
- package/dist/__tests__/lifecycle-contracts.test.js +66 -0
- package/dist/__tests__/lifecycle-contracts.test.js.map +1 -0
- package/dist/__tests__/lifecycle-logger.test.d.ts +2 -0
- package/dist/__tests__/lifecycle-logger.test.d.ts.map +1 -0
- package/dist/__tests__/lifecycle-logger.test.js +49 -0
- package/dist/__tests__/lifecycle-logger.test.js.map +1 -0
- package/dist/__tests__/local-daemon-lifecycle.test.d.ts +2 -0
- package/dist/__tests__/local-daemon-lifecycle.test.d.ts.map +1 -0
- package/dist/__tests__/local-daemon-lifecycle.test.js +594 -0
- package/dist/__tests__/local-daemon-lifecycle.test.js.map +1 -0
- package/dist/__tests__/local-git-status.test.d.ts +2 -0
- package/dist/__tests__/local-git-status.test.d.ts.map +1 -0
- package/dist/__tests__/local-git-status.test.js +31 -0
- package/dist/__tests__/local-git-status.test.js.map +1 -0
- package/dist/__tests__/mcp-config-adapters-files.test.d.ts +2 -0
- package/dist/__tests__/mcp-config-adapters-files.test.d.ts.map +1 -0
- package/dist/__tests__/mcp-config-adapters-files.test.js +486 -0
- package/dist/__tests__/mcp-config-adapters-files.test.js.map +1 -0
- package/dist/__tests__/mcp-config-adapters.test.d.ts +2 -0
- package/dist/__tests__/mcp-config-adapters.test.d.ts.map +1 -0
- package/dist/__tests__/mcp-config-adapters.test.js +492 -0
- package/dist/__tests__/mcp-config-adapters.test.js.map +1 -0
- package/dist/__tests__/mcp-sync.test.d.ts +2 -0
- package/dist/__tests__/mcp-sync.test.d.ts.map +1 -0
- package/dist/__tests__/mcp-sync.test.js +21 -0
- package/dist/__tests__/mcp-sync.test.js.map +1 -0
- package/dist/__tests__/model-scan-runner.test.d.ts +2 -0
- package/dist/__tests__/model-scan-runner.test.d.ts.map +1 -0
- package/dist/__tests__/model-scan-runner.test.js +80 -0
- package/dist/__tests__/model-scan-runner.test.js.map +1 -0
- package/dist/__tests__/native-hook-command.test.d.ts +2 -0
- package/dist/__tests__/native-hook-command.test.d.ts.map +1 -0
- package/dist/__tests__/native-hook-command.test.js +386 -0
- package/dist/__tests__/native-hook-command.test.js.map +1 -0
- package/dist/__tests__/native-hook-config.test.d.ts +2 -0
- package/dist/__tests__/native-hook-config.test.d.ts.map +1 -0
- package/dist/__tests__/native-hook-config.test.js +374 -0
- package/dist/__tests__/native-hook-config.test.js.map +1 -0
- package/dist/__tests__/native-hook-drain.test.d.ts +2 -0
- package/dist/__tests__/native-hook-drain.test.d.ts.map +1 -0
- package/dist/__tests__/native-hook-drain.test.js +197 -0
- package/dist/__tests__/native-hook-drain.test.js.map +1 -0
- package/dist/__tests__/native-hook-inbox.test.d.ts +2 -0
- package/dist/__tests__/native-hook-inbox.test.d.ts.map +1 -0
- package/dist/__tests__/native-hook-inbox.test.js +139 -0
- package/dist/__tests__/native-hook-inbox.test.js.map +1 -0
- package/dist/__tests__/native-session.test.d.ts +2 -0
- package/dist/__tests__/native-session.test.d.ts.map +1 -0
- package/dist/__tests__/native-session.test.js +41 -0
- package/dist/__tests__/native-session.test.js.map +1 -0
- package/dist/__tests__/native-stream-outbox.test.d.ts +2 -0
- package/dist/__tests__/native-stream-outbox.test.d.ts.map +1 -0
- package/dist/__tests__/native-stream-outbox.test.js +231 -0
- package/dist/__tests__/native-stream-outbox.test.js.map +1 -0
- package/dist/__tests__/native-stream-platform.test.d.ts +2 -0
- package/dist/__tests__/native-stream-platform.test.d.ts.map +1 -0
- package/dist/__tests__/native-stream-platform.test.js +20 -0
- package/dist/__tests__/native-stream-platform.test.js.map +1 -0
- package/dist/__tests__/native-transcript-cursor.test.d.ts +2 -0
- package/dist/__tests__/native-transcript-cursor.test.d.ts.map +1 -0
- package/dist/__tests__/native-transcript-cursor.test.js +60 -0
- package/dist/__tests__/native-transcript-cursor.test.js.map +1 -0
- package/dist/__tests__/native-transcript-stream.test.d.ts +2 -0
- package/dist/__tests__/native-transcript-stream.test.d.ts.map +1 -0
- package/dist/__tests__/native-transcript-stream.test.js +378 -0
- package/dist/__tests__/native-transcript-stream.test.js.map +1 -0
- package/dist/__tests__/network-diagnostics.test.d.ts +2 -0
- package/dist/__tests__/network-diagnostics.test.d.ts.map +1 -0
- package/dist/__tests__/network-diagnostics.test.js +26 -0
- package/dist/__tests__/network-diagnostics.test.js.map +1 -0
- package/dist/__tests__/observable-map.test.d.ts +2 -0
- package/dist/__tests__/observable-map.test.d.ts.map +1 -0
- package/dist/__tests__/observable-map.test.js +54 -0
- package/dist/__tests__/observable-map.test.js.map +1 -0
- package/dist/__tests__/outbox-baseline.bench.test.d.ts +2 -0
- package/dist/__tests__/outbox-baseline.bench.test.d.ts.map +1 -0
- package/dist/__tests__/outbox-baseline.bench.test.js +108 -0
- package/dist/__tests__/outbox-baseline.bench.test.js.map +1 -0
- package/dist/__tests__/provider-auth-preflight.test.d.ts +2 -0
- package/dist/__tests__/provider-auth-preflight.test.d.ts.map +1 -0
- package/dist/__tests__/provider-auth-preflight.test.js +123 -0
- package/dist/__tests__/provider-auth-preflight.test.js.map +1 -0
- package/dist/__tests__/provider-model-discovery.test.d.ts +2 -0
- package/dist/__tests__/provider-model-discovery.test.d.ts.map +1 -0
- package/dist/__tests__/provider-model-discovery.test.js +1071 -0
- package/dist/__tests__/provider-model-discovery.test.js.map +1 -0
- package/dist/__tests__/resource-diagnostics.test.d.ts +2 -0
- package/dist/__tests__/resource-diagnostics.test.d.ts.map +1 -0
- package/dist/__tests__/resource-diagnostics.test.js +138 -0
- package/dist/__tests__/resource-diagnostics.test.js.map +1 -0
- package/dist/__tests__/resume-fallback-env.test.d.ts +2 -0
- package/dist/__tests__/resume-fallback-env.test.d.ts.map +1 -0
- package/dist/__tests__/resume-fallback-env.test.js +28 -0
- package/dist/__tests__/resume-fallback-env.test.js.map +1 -0
- package/dist/__tests__/run-journal.test.d.ts +2 -0
- package/dist/__tests__/run-journal.test.d.ts.map +1 -0
- package/dist/__tests__/run-journal.test.js +121 -0
- package/dist/__tests__/run-journal.test.js.map +1 -0
- package/dist/__tests__/run-start-gate.test.d.ts +2 -0
- package/dist/__tests__/run-start-gate.test.d.ts.map +1 -0
- package/dist/__tests__/run-start-gate.test.js +18 -0
- package/dist/__tests__/run-start-gate.test.js.map +1 -0
- package/dist/__tests__/runtime-capabilities-sync.test.d.ts +2 -0
- package/dist/__tests__/runtime-capabilities-sync.test.d.ts.map +1 -0
- package/dist/__tests__/runtime-capabilities-sync.test.js +66 -0
- package/dist/__tests__/runtime-capabilities-sync.test.js.map +1 -0
- package/dist/__tests__/runtime-config.test.d.ts +2 -0
- package/dist/__tests__/runtime-config.test.d.ts.map +1 -0
- package/dist/__tests__/runtime-config.test.js +137 -0
- package/dist/__tests__/runtime-config.test.js.map +1 -0
- package/dist/__tests__/runtime-presenter-heartbeat.test.d.ts +2 -0
- package/dist/__tests__/runtime-presenter-heartbeat.test.d.ts.map +1 -0
- package/dist/__tests__/runtime-presenter-heartbeat.test.js +253 -0
- package/dist/__tests__/runtime-presenter-heartbeat.test.js.map +1 -0
- package/dist/__tests__/runtime-registration.test.d.ts +2 -0
- package/dist/__tests__/runtime-registration.test.d.ts.map +1 -0
- package/dist/__tests__/runtime-registration.test.js +109 -0
- package/dist/__tests__/runtime-registration.test.js.map +1 -0
- package/dist/__tests__/sandbox-outbox-storage.test.d.ts +2 -0
- package/dist/__tests__/sandbox-outbox-storage.test.d.ts.map +1 -0
- package/dist/__tests__/sandbox-outbox-storage.test.js +81 -0
- package/dist/__tests__/sandbox-outbox-storage.test.js.map +1 -0
- package/dist/__tests__/sandbox-outbox.test.d.ts +2 -0
- package/dist/__tests__/sandbox-outbox.test.d.ts.map +1 -0
- package/dist/__tests__/sandbox-outbox.test.js +300 -0
- package/dist/__tests__/sandbox-outbox.test.js.map +1 -0
- package/dist/__tests__/sandbox-workflow-context.test.d.ts +2 -0
- package/dist/__tests__/sandbox-workflow-context.test.d.ts.map +1 -0
- package/dist/__tests__/sandbox-workflow-context.test.js +600 -0
- package/dist/__tests__/sandbox-workflow-context.test.js.map +1 -0
- package/dist/__tests__/service-manager-deadline.test.d.ts +2 -0
- package/dist/__tests__/service-manager-deadline.test.d.ts.map +1 -0
- package/dist/__tests__/service-manager-deadline.test.js +36 -0
- package/dist/__tests__/service-manager-deadline.test.js.map +1 -0
- package/dist/__tests__/service-manager.test.d.ts +2 -0
- package/dist/__tests__/service-manager.test.d.ts.map +1 -0
- package/dist/__tests__/service-manager.test.js +769 -0
- package/dist/__tests__/service-manager.test.js.map +1 -0
- package/dist/__tests__/service-stop-ownership.test.d.ts +2 -0
- package/dist/__tests__/service-stop-ownership.test.d.ts.map +1 -0
- package/dist/__tests__/service-stop-ownership.test.js +89 -0
- package/dist/__tests__/service-stop-ownership.test.js.map +1 -0
- package/dist/__tests__/skill-invocation.test.d.ts +2 -0
- package/dist/__tests__/skill-invocation.test.d.ts.map +1 -0
- package/dist/__tests__/skill-invocation.test.js +40 -0
- package/dist/__tests__/skill-invocation.test.js.map +1 -0
- package/dist/__tests__/sleep-inhibitor-real.test.d.ts +2 -0
- package/dist/__tests__/sleep-inhibitor-real.test.d.ts.map +1 -0
- package/dist/__tests__/sleep-inhibitor-real.test.js +68 -0
- package/dist/__tests__/sleep-inhibitor-real.test.js.map +1 -0
- package/dist/__tests__/sleep-inhibitor.test.d.ts +2 -0
- package/dist/__tests__/sleep-inhibitor.test.d.ts.map +1 -0
- package/dist/__tests__/sleep-inhibitor.test.js +236 -0
- package/dist/__tests__/sleep-inhibitor.test.js.map +1 -0
- package/dist/__tests__/status-local-workspace.test.d.ts +2 -0
- package/dist/__tests__/status-local-workspace.test.d.ts.map +1 -0
- package/dist/__tests__/status-local-workspace.test.js +121 -0
- package/dist/__tests__/status-local-workspace.test.js.map +1 -0
- package/dist/__tests__/suspension-detector.test.d.ts +2 -0
- package/dist/__tests__/suspension-detector.test.d.ts.map +1 -0
- package/dist/__tests__/suspension-detector.test.js +112 -0
- package/dist/__tests__/suspension-detector.test.js.map +1 -0
- package/dist/__tests__/web-presenter-parent-events.test.d.ts +2 -0
- package/dist/__tests__/web-presenter-parent-events.test.d.ts.map +1 -0
- package/dist/__tests__/web-presenter-parent-events.test.js +168 -0
- package/dist/__tests__/web-presenter-parent-events.test.js.map +1 -0
- package/dist/__tests__/workspace-probe-concurrency.test.d.ts +2 -0
- package/dist/__tests__/workspace-probe-concurrency.test.d.ts.map +1 -0
- package/dist/__tests__/workspace-probe-concurrency.test.js +54 -0
- package/dist/__tests__/workspace-probe-concurrency.test.js.map +1 -0
- package/dist/__tests__/workspace-relocation.test.d.ts +2 -0
- package/dist/__tests__/workspace-relocation.test.d.ts.map +1 -0
- package/dist/__tests__/workspace-relocation.test.js +66 -0
- package/dist/__tests__/workspace-relocation.test.js.map +1 -0
- package/dist/__tests__/workspace-rpc.test.d.ts +2 -0
- package/dist/__tests__/workspace-rpc.test.d.ts.map +1 -0
- package/dist/__tests__/workspace-rpc.test.js +90 -0
- package/dist/__tests__/workspace-rpc.test.js.map +1 -0
- package/dist/__tests__/workspace-run-lease.test.d.ts +2 -0
- package/dist/__tests__/workspace-run-lease.test.d.ts.map +1 -0
- package/dist/__tests__/workspace-run-lease.test.js +331 -0
- package/dist/__tests__/workspace-run-lease.test.js.map +1 -0
- package/dist/__tests__/ws-client-connection.test.d.ts +2 -0
- package/dist/__tests__/ws-client-connection.test.d.ts.map +1 -0
- package/dist/__tests__/ws-client-connection.test.js +295 -0
- package/dist/__tests__/ws-client-connection.test.js.map +1 -0
- package/dist/__tests__/ws-client-heartbeat-volatile.test.d.ts +2 -0
- package/dist/__tests__/ws-client-heartbeat-volatile.test.d.ts.map +1 -0
- package/dist/__tests__/ws-client-heartbeat-volatile.test.js +63 -0
- package/dist/__tests__/ws-client-heartbeat-volatile.test.js.map +1 -0
- package/dist/__tests__/ws-client-heartbeat.integration.test.d.ts +2 -0
- package/dist/__tests__/ws-client-heartbeat.integration.test.d.ts.map +1 -0
- package/dist/__tests__/ws-client-heartbeat.integration.test.js +236 -0
- package/dist/__tests__/ws-client-heartbeat.integration.test.js.map +1 -0
- package/dist/__tests__/ws-client-user-message-ack.integration.test.d.ts +2 -0
- package/dist/__tests__/ws-client-user-message-ack.integration.test.d.ts.map +1 -0
- package/dist/__tests__/ws-client-user-message-ack.integration.test.js +211 -0
- package/dist/__tests__/ws-client-user-message-ack.integration.test.js.map +1 -0
- package/dist/antigravity-api-key-config.d.ts +2 -0
- package/dist/antigravity-api-key-config.d.ts.map +1 -0
- package/dist/antigravity-api-key-config.js +79 -0
- package/dist/antigravity-api-key-config.js.map +1 -0
- package/dist/binding-switch-git.d.ts +26 -0
- package/dist/binding-switch-git.d.ts.map +1 -0
- package/dist/binding-switch-git.js +871 -0
- package/dist/binding-switch-git.js.map +1 -0
- package/dist/cli-ensure-install.d.ts +34 -0
- package/dist/cli-ensure-install.d.ts.map +1 -0
- package/dist/cli-ensure-install.js +154 -0
- package/dist/cli-ensure-install.js.map +1 -0
- package/dist/cli-executable.d.ts +44 -0
- package/dist/cli-executable.d.ts.map +1 -0
- package/dist/cli-executable.js +435 -0
- package/dist/cli-executable.js.map +1 -0
- package/dist/cli-help.d.ts +11 -0
- package/dist/cli-help.d.ts.map +1 -0
- package/dist/cli-help.js +65 -0
- package/dist/cli-help.js.map +1 -0
- package/dist/computer-readiness.d.ts +41 -0
- package/dist/computer-readiness.d.ts.map +1 -0
- package/dist/computer-readiness.js +191 -0
- package/dist/computer-readiness.js.map +1 -0
- package/dist/core-agent.d.ts +32 -0
- package/dist/core-agent.d.ts.map +1 -0
- package/dist/core-agent.js +331 -0
- package/dist/core-agent.js.map +1 -0
- package/dist/daemon-execute.d.ts +42 -0
- package/dist/daemon-execute.d.ts.map +1 -0
- package/dist/daemon-execute.js +666 -0
- package/dist/daemon-execute.js.map +1 -0
- package/dist/daemon-helpers.d.ts +150 -0
- package/dist/daemon-helpers.d.ts.map +1 -0
- package/dist/daemon-helpers.js +157 -0
- package/dist/daemon-helpers.js.map +1 -0
- package/dist/daemon-local-control.d.ts +208 -0
- package/dist/daemon-local-control.d.ts.map +1 -0
- package/dist/daemon-local-control.js +826 -0
- package/dist/daemon-local-control.js.map +1 -0
- package/dist/daemon-local-http.d.ts +57 -0
- package/dist/daemon-local-http.d.ts.map +1 -0
- package/dist/daemon-local-http.js +375 -0
- package/dist/daemon-local-http.js.map +1 -0
- package/dist/daemon-native-hooks.d.ts +17 -0
- package/dist/daemon-native-hooks.d.ts.map +1 -0
- package/dist/daemon-native-hooks.js +54 -0
- package/dist/daemon-native-hooks.js.map +1 -0
- package/dist/daemon-provider-scan.d.ts +33 -0
- package/dist/daemon-provider-scan.d.ts.map +1 -0
- package/dist/daemon-provider-scan.js +187 -0
- package/dist/daemon-provider-scan.js.map +1 -0
- package/dist/daemon-runner-status.d.ts +164 -0
- package/dist/daemon-runner-status.d.ts.map +1 -0
- package/dist/daemon-runner-status.js +424 -0
- package/dist/daemon-runner-status.js.map +1 -0
- package/dist/daemon-start.d.ts +5 -0
- package/dist/daemon-start.d.ts.map +1 -0
- package/dist/daemon-start.js +1313 -0
- package/dist/daemon-start.js.map +1 -0
- package/dist/daemon-workspace.d.ts +36 -0
- package/dist/daemon-workspace.d.ts.map +1 -0
- package/dist/daemon-workspace.js +154 -0
- package/dist/daemon-workspace.js.map +1 -0
- package/dist/daemon.d.ts +59 -0
- package/dist/daemon.d.ts.map +1 -0
- package/dist/daemon.js +681 -0
- package/dist/daemon.js.map +1 -0
- package/dist/event-journal-crypto.d.ts +14 -0
- package/dist/event-journal-crypto.d.ts.map +1 -0
- package/dist/event-journal-crypto.js +89 -0
- package/dist/event-journal-crypto.js.map +1 -0
- package/dist/event-journal-paths.d.ts +10 -0
- package/dist/event-journal-paths.d.ts.map +1 -0
- package/dist/event-journal-paths.js +29 -0
- package/dist/event-journal-paths.js.map +1 -0
- package/dist/event-journal-recovery.d.ts +83 -0
- package/dist/event-journal-recovery.d.ts.map +1 -0
- package/dist/event-journal-recovery.js +333 -0
- package/dist/event-journal-recovery.js.map +1 -0
- package/dist/event-journal-types.d.ts +54 -0
- package/dist/event-journal-types.d.ts.map +1 -0
- package/dist/event-journal-types.js +10 -0
- package/dist/event-journal-types.js.map +1 -0
- package/dist/event-journal-writer.d.ts +44 -0
- package/dist/event-journal-writer.d.ts.map +1 -0
- package/dist/event-journal-writer.js +182 -0
- package/dist/event-journal-writer.js.map +1 -0
- package/dist/event-outbox.d.ts +113 -0
- package/dist/event-outbox.d.ts.map +1 -0
- package/dist/event-outbox.js +707 -0
- package/dist/event-outbox.js.map +1 -0
- package/dist/execution-activity-tracker.d.ts +43 -0
- package/dist/execution-activity-tracker.d.ts.map +1 -0
- package/dist/execution-activity-tracker.js +116 -0
- package/dist/execution-activity-tracker.js.map +1 -0
- package/dist/execution-lease-client.d.ts +62 -0
- package/dist/execution-lease-client.d.ts.map +1 -0
- package/dist/execution-lease-client.js +271 -0
- package/dist/execution-lease-client.js.map +1 -0
- package/dist/fake-provider-cli.d.ts +13 -0
- package/dist/fake-provider-cli.d.ts.map +1 -0
- package/dist/fake-provider-cli.js +53 -0
- package/dist/fake-provider-cli.js.map +1 -0
- package/dist/generated-images.d.ts +2 -0
- package/dist/generated-images.d.ts.map +1 -0
- package/dist/generated-images.js +2 -0
- package/dist/generated-images.js.map +1 -0
- package/dist/index.cjs +47033 -45514
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +224 -0
- package/dist/index.js.map +1 -0
- package/dist/install-command.d.ts +2 -0
- package/dist/install-command.d.ts.map +1 -0
- package/dist/install-command.js +96 -0
- package/dist/install-command.js.map +1 -0
- package/dist/integration-cli.d.ts +14 -0
- package/dist/integration-cli.d.ts.map +1 -0
- package/dist/integration-cli.js +80 -0
- package/dist/integration-cli.js.map +1 -0
- package/dist/lifecycle-logger.d.ts +25 -0
- package/dist/lifecycle-logger.d.ts.map +1 -0
- package/dist/lifecycle-logger.js +73 -0
- package/dist/lifecycle-logger.js.map +1 -0
- package/dist/local-daemon-lifecycle.d.ts +112 -0
- package/dist/local-daemon-lifecycle.d.ts.map +1 -0
- package/dist/local-daemon-lifecycle.js +433 -0
- package/dist/local-daemon-lifecycle.js.map +1 -0
- package/dist/local-git-status.d.ts +14 -0
- package/dist/local-git-status.d.ts.map +1 -0
- package/dist/local-git-status.js +43 -0
- package/dist/local-git-status.js.map +1 -0
- package/dist/managed-mcp.d.ts +7 -0
- package/dist/managed-mcp.d.ts.map +1 -0
- package/dist/managed-mcp.js +16 -0
- package/dist/managed-mcp.js.map +1 -0
- package/dist/mcp-config-adapters.d.ts +57 -0
- package/dist/mcp-config-adapters.d.ts.map +1 -0
- package/dist/mcp-config-adapters.js +929 -0
- package/dist/mcp-config-adapters.js.map +1 -0
- package/dist/mcp-sync.d.ts +44 -0
- package/dist/mcp-sync.d.ts.map +1 -0
- package/dist/mcp-sync.js +68 -0
- package/dist/mcp-sync.js.map +1 -0
- package/dist/model-scan-runner.d.ts +15 -0
- package/dist/model-scan-runner.d.ts.map +1 -0
- package/dist/model-scan-runner.js +56 -0
- package/dist/model-scan-runner.js.map +1 -0
- package/dist/native-hook-command.d.ts +31 -0
- package/dist/native-hook-command.d.ts.map +1 -0
- package/dist/native-hook-command.js +289 -0
- package/dist/native-hook-command.js.map +1 -0
- package/dist/native-hook-config.d.ts +43 -0
- package/dist/native-hook-config.d.ts.map +1 -0
- package/dist/native-hook-config.js +601 -0
- package/dist/native-hook-config.js.map +1 -0
- package/dist/native-hook-drain.d.ts +34 -0
- package/dist/native-hook-drain.d.ts.map +1 -0
- package/dist/native-hook-drain.js +83 -0
- package/dist/native-hook-drain.js.map +1 -0
- package/dist/native-hook-inbox.d.ts +40 -0
- package/dist/native-hook-inbox.d.ts.map +1 -0
- package/dist/native-hook-inbox.js +217 -0
- package/dist/native-hook-inbox.js.map +1 -0
- package/dist/native-project-config.d.ts +11 -0
- package/dist/native-project-config.d.ts.map +1 -0
- package/dist/native-project-config.js +49 -0
- package/dist/native-project-config.js.map +1 -0
- package/dist/native-session.d.ts +20 -0
- package/dist/native-session.d.ts.map +1 -0
- package/dist/native-session.js +213 -0
- package/dist/native-session.js.map +1 -0
- package/dist/native-stream-journal.d.ts +22 -0
- package/dist/native-stream-journal.d.ts.map +1 -0
- package/dist/native-stream-journal.js +98 -0
- package/dist/native-stream-journal.js.map +1 -0
- package/dist/native-stream-outbox.d.ts +40 -0
- package/dist/native-stream-outbox.d.ts.map +1 -0
- package/dist/native-stream-outbox.js +358 -0
- package/dist/native-stream-outbox.js.map +1 -0
- package/dist/native-stream-platform.d.ts +4 -0
- package/dist/native-stream-platform.d.ts.map +1 -0
- package/dist/native-stream-platform.js +11 -0
- package/dist/native-stream-platform.js.map +1 -0
- package/dist/native-transcript-cursor.d.ts +33 -0
- package/dist/native-transcript-cursor.d.ts.map +1 -0
- package/dist/native-transcript-cursor.js +108 -0
- package/dist/native-transcript-cursor.js.map +1 -0
- package/dist/native-transcript-stream.d.ts +20 -0
- package/dist/native-transcript-stream.d.ts.map +1 -0
- package/dist/native-transcript-stream.js +438 -0
- package/dist/native-transcript-stream.js.map +1 -0
- package/dist/network-diagnostics.d.ts +8 -0
- package/dist/network-diagnostics.d.ts.map +1 -0
- package/dist/network-diagnostics.js +56 -0
- package/dist/network-diagnostics.js.map +1 -0
- package/dist/observable-map.d.ts +13 -0
- package/dist/observable-map.d.ts.map +1 -0
- package/dist/observable-map.js +30 -0
- package/dist/observable-map.js.map +1 -0
- package/dist/provider-auth-preflight.d.ts +19 -0
- package/dist/provider-auth-preflight.d.ts.map +1 -0
- package/dist/provider-auth-preflight.js +107 -0
- package/dist/provider-auth-preflight.js.map +1 -0
- package/dist/provider-model-discovery.d.ts +33 -0
- package/dist/provider-model-discovery.d.ts.map +1 -0
- package/dist/provider-model-discovery.js +731 -0
- package/dist/provider-model-discovery.js.map +1 -0
- package/dist/resource-diagnostics.d.ts +21 -0
- package/dist/resource-diagnostics.d.ts.map +1 -0
- package/dist/resource-diagnostics.js +161 -0
- package/dist/resource-diagnostics.js.map +1 -0
- package/dist/resume-fallback-env.d.ts +3 -0
- package/dist/resume-fallback-env.d.ts.map +1 -0
- package/dist/resume-fallback-env.js +14 -0
- package/dist/resume-fallback-env.js.map +1 -0
- package/dist/run-journal.d.ts +51 -0
- package/dist/run-journal.d.ts.map +1 -0
- package/dist/run-journal.js +193 -0
- package/dist/run-journal.js.map +1 -0
- package/dist/runtime-backends.d.ts +2 -0
- package/dist/runtime-backends.d.ts.map +1 -0
- package/dist/runtime-backends.js +2 -0
- package/dist/runtime-backends.js.map +1 -0
- package/dist/runtime-capabilities-sync.d.ts +40 -0
- package/dist/runtime-capabilities-sync.d.ts.map +1 -0
- package/dist/runtime-capabilities-sync.js +56 -0
- package/dist/runtime-capabilities-sync.js.map +1 -0
- package/dist/runtime-config.d.ts +26 -0
- package/dist/runtime-config.d.ts.map +1 -0
- package/dist/runtime-config.js +170 -0
- package/dist/runtime-config.js.map +1 -0
- package/dist/runtime-presenter.d.ts +81 -0
- package/dist/runtime-presenter.d.ts.map +1 -0
- package/dist/runtime-presenter.js +422 -0
- package/dist/runtime-presenter.js.map +1 -0
- package/dist/runtime-registration.d.ts +40 -0
- package/dist/runtime-registration.d.ts.map +1 -0
- package/dist/runtime-registration.js +143 -0
- package/dist/runtime-registration.js.map +1 -0
- package/dist/sandbox-outbox-storage.d.ts +13 -0
- package/dist/sandbox-outbox-storage.d.ts.map +1 -0
- package/dist/sandbox-outbox-storage.js +98 -0
- package/dist/sandbox-outbox-storage.js.map +1 -0
- package/dist/sandbox-outbox.d.ts +115 -0
- package/dist/sandbox-outbox.d.ts.map +1 -0
- package/dist/sandbox-outbox.js +213 -0
- package/dist/sandbox-outbox.js.map +1 -0
- package/dist/sandbox.d.ts +34 -0
- package/dist/sandbox.d.ts.map +1 -0
- package/dist/sandbox.js +469 -0
- package/dist/sandbox.js.map +1 -0
- package/dist/service-manager.d.ts +113 -0
- package/dist/service-manager.d.ts.map +1 -0
- package/dist/service-manager.js +1065 -0
- package/dist/service-manager.js.map +1 -0
- package/dist/skills/__tests__/local-skill-source.test.d.ts +2 -0
- package/dist/skills/__tests__/local-skill-source.test.d.ts.map +1 -0
- package/dist/skills/__tests__/local-skill-source.test.js +373 -0
- package/dist/skills/__tests__/local-skill-source.test.js.map +1 -0
- package/dist/skills/__tests__/managed-skill-store.test.d.ts +2 -0
- package/dist/skills/__tests__/managed-skill-store.test.d.ts.map +1 -0
- package/dist/skills/__tests__/managed-skill-store.test.js +114 -0
- package/dist/skills/__tests__/managed-skill-store.test.js.map +1 -0
- package/dist/skills/__tests__/runtime-skill-coordinator.test.d.ts +2 -0
- package/dist/skills/__tests__/runtime-skill-coordinator.test.d.ts.map +1 -0
- package/dist/skills/__tests__/runtime-skill-coordinator.test.js +251 -0
- package/dist/skills/__tests__/runtime-skill-coordinator.test.js.map +1 -0
- package/dist/skills/__tests__/runtime-skill-manager.test.d.ts +2 -0
- package/dist/skills/__tests__/runtime-skill-manager.test.d.ts.map +1 -0
- package/dist/skills/__tests__/runtime-skill-manager.test.js +664 -0
- package/dist/skills/__tests__/runtime-skill-manager.test.js.map +1 -0
- package/dist/skills/__tests__/skill-bundle.test.d.ts +2 -0
- package/dist/skills/__tests__/skill-bundle.test.d.ts.map +1 -0
- package/dist/skills/__tests__/skill-bundle.test.js +42 -0
- package/dist/skills/__tests__/skill-bundle.test.js.map +1 -0
- package/dist/skills/__tests__/skill-control-client.test.d.ts +2 -0
- package/dist/skills/__tests__/skill-control-client.test.d.ts.map +1 -0
- package/dist/skills/__tests__/skill-control-client.test.js +49 -0
- package/dist/skills/__tests__/skill-control-client.test.js.map +1 -0
- package/dist/skills/__tests__/skill-source-config.test.d.ts +2 -0
- package/dist/skills/__tests__/skill-source-config.test.d.ts.map +1 -0
- package/dist/skills/__tests__/skill-source-config.test.js +295 -0
- package/dist/skills/__tests__/skill-source-config.test.js.map +1 -0
- package/dist/skills/local-skill-source.d.ts +77 -0
- package/dist/skills/local-skill-source.d.ts.map +1 -0
- package/dist/skills/local-skill-source.js +660 -0
- package/dist/skills/local-skill-source.js.map +1 -0
- package/dist/skills/managed-skill-store.d.ts +44 -0
- package/dist/skills/managed-skill-store.d.ts.map +1 -0
- package/dist/skills/managed-skill-store.js +160 -0
- package/dist/skills/managed-skill-store.js.map +1 -0
- package/dist/skills/runtime-skill-coordinator.d.ts +35 -0
- package/dist/skills/runtime-skill-coordinator.d.ts.map +1 -0
- package/dist/skills/runtime-skill-coordinator.js +166 -0
- package/dist/skills/runtime-skill-coordinator.js.map +1 -0
- package/dist/skills/runtime-skill-manager.d.ts +89 -0
- package/dist/skills/runtime-skill-manager.d.ts.map +1 -0
- package/dist/skills/runtime-skill-manager.js +934 -0
- package/dist/skills/runtime-skill-manager.js.map +1 -0
- package/dist/skills/skill-bundle.d.ts +2 -0
- package/dist/skills/skill-bundle.d.ts.map +1 -0
- package/dist/skills/skill-bundle.js +2 -0
- package/dist/skills/skill-bundle.js.map +1 -0
- package/dist/skills/skill-cli.d.ts +2 -0
- package/dist/skills/skill-cli.d.ts.map +1 -0
- package/dist/skills/skill-cli.js +81 -0
- package/dist/skills/skill-cli.js.map +1 -0
- package/dist/skills/skill-control-client.d.ts +20 -0
- package/dist/skills/skill-control-client.d.ts.map +1 -0
- package/dist/skills/skill-control-client.js +56 -0
- package/dist/skills/skill-control-client.js.map +1 -0
- package/dist/skills/skill-invocation.d.ts +10 -0
- package/dist/skills/skill-invocation.d.ts.map +1 -0
- package/dist/skills/skill-invocation.js +24 -0
- package/dist/skills/skill-invocation.js.map +1 -0
- package/dist/sleep-inhibitor.d.ts +32 -0
- package/dist/sleep-inhibitor.d.ts.map +1 -0
- package/dist/sleep-inhibitor.js +297 -0
- package/dist/sleep-inhibitor.js.map +1 -0
- package/dist/suspension-detector.d.ts +24 -0
- package/dist/suspension-detector.d.ts.map +1 -0
- package/dist/suspension-detector.js +59 -0
- package/dist/suspension-detector.js.map +1 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -0
- package/dist/web-presenter.d.ts +52 -0
- package/dist/web-presenter.d.ts.map +1 -0
- package/dist/web-presenter.js +264 -0
- package/dist/web-presenter.js.map +1 -0
- package/dist/workspace-relocation.d.ts +22 -0
- package/dist/workspace-relocation.d.ts.map +1 -0
- package/dist/workspace-relocation.js +90 -0
- package/dist/workspace-relocation.js.map +1 -0
- package/dist/workspace-rpc.d.ts +2 -0
- package/dist/workspace-rpc.d.ts.map +1 -0
- package/dist/workspace-rpc.js +15 -0
- package/dist/workspace-rpc.js.map +1 -0
- package/dist/workspace-run-lease.d.ts +116 -0
- package/dist/workspace-run-lease.d.ts.map +1 -0
- package/dist/workspace-run-lease.js +320 -0
- package/dist/workspace-run-lease.js.map +1 -0
- package/dist/ws-client.d.ts +168 -0
- package/dist/ws-client.d.ts.map +1 -0
- package/dist/ws-client.js +440 -0
- package/dist/ws-client.js.map +1 -0
- package/package.json +4 -3
|
@@ -0,0 +1,660 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
2
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
3
|
+
import { access, lstat, mkdir, readdir, readFile, realpath, writeFile } from "node:fs/promises";
|
|
4
|
+
import path, { isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
5
|
+
import { inspectSkillPackage } from "@alan-ai/shared/node/skill-package";
|
|
6
|
+
import { providerKindsForUserDirectory, skillRepositorySourceDirectories, } from "@alan-ai/shared/skills";
|
|
7
|
+
import { parse as parseToml } from "smol-toml";
|
|
8
|
+
const DEFAULT_SKILL_CONFIG = `version = 1
|
|
9
|
+
|
|
10
|
+
[skills]
|
|
11
|
+
enabled = true
|
|
12
|
+
discover_repository_skills = true
|
|
13
|
+
ignore = ["**/.git/**", "**/node_modules/**"]
|
|
14
|
+
|
|
15
|
+
[[skills.sources]]
|
|
16
|
+
path = "~/.agents/skills"
|
|
17
|
+
label = "Agent Skills"
|
|
18
|
+
|
|
19
|
+
[[skills.sources]]
|
|
20
|
+
path = "~/.alan/skill-sources"
|
|
21
|
+
label = "Alan drafts"
|
|
22
|
+
|
|
23
|
+
[[skills.sources]]
|
|
24
|
+
path = "~/.claude/skills"
|
|
25
|
+
label = "Claude skills"
|
|
26
|
+
providers = ["claude_cli"]
|
|
27
|
+
|
|
28
|
+
[[skills.sources]]
|
|
29
|
+
path = "~/.cursor/skills"
|
|
30
|
+
label = "Cursor skills"
|
|
31
|
+
providers = ["cursor_agent_cli"]
|
|
32
|
+
|
|
33
|
+
[[skills.sources]]
|
|
34
|
+
path = "~/.codex/skills"
|
|
35
|
+
label = "Codex skills"
|
|
36
|
+
providers = ["codex_app_server"]
|
|
37
|
+
|
|
38
|
+
[[skills.sources]]
|
|
39
|
+
path = "~/.copilot/skills"
|
|
40
|
+
label = "Copilot skills"
|
|
41
|
+
providers = ["copilot_cli"]
|
|
42
|
+
|
|
43
|
+
[[skills.sources]]
|
|
44
|
+
path = "~/.config/opencode/skills"
|
|
45
|
+
label = "OpenCode skills"
|
|
46
|
+
providers = ["opencode_cli", "opencode_serve"]
|
|
47
|
+
`;
|
|
48
|
+
export class LocalSkillSource {
|
|
49
|
+
lastCompleteRevision = null;
|
|
50
|
+
locations = new Map();
|
|
51
|
+
inspectionCache = new Map();
|
|
52
|
+
async scan(input) {
|
|
53
|
+
const attemptId = randomUUID();
|
|
54
|
+
const diagnostics = [];
|
|
55
|
+
const candidates = [];
|
|
56
|
+
const visitedDirectories = new Set();
|
|
57
|
+
let incompleteRoot = false;
|
|
58
|
+
const resolvedRoots = resolveScanRoots(input.roots, input.enabledProviderKinds ?? []);
|
|
59
|
+
// The invariant is "inside a declared root", not "inside this one". Checking
|
|
60
|
+
// per-root rejected every symlink between two roots the user declared —
|
|
61
|
+
// which is how provider directories are laid out, so a whole root could
|
|
62
|
+
// resolve to nothing but rejections.
|
|
63
|
+
const declaredRoots = await canonicalDirectories(resolvedRoots.map((root) => root.directory));
|
|
64
|
+
for (const resolvedRoot of resolvedRoots) {
|
|
65
|
+
const rootResult = await this.scanRoot(resolvedRoot, visitedDirectories, input.ignoredPaths ?? [], input.mode, declaredRoots);
|
|
66
|
+
candidates.push(...rootResult.candidates);
|
|
67
|
+
diagnostics.push(...rootResult.diagnostics);
|
|
68
|
+
incompleteRoot ||= rootResult.incomplete;
|
|
69
|
+
}
|
|
70
|
+
if (incompleteRoot) {
|
|
71
|
+
return {
|
|
72
|
+
status: "partial",
|
|
73
|
+
attemptId,
|
|
74
|
+
retainedInventoryRevision: this.lastCompleteRevision,
|
|
75
|
+
diagnostics: diagnostics.slice(0, 100),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
candidates.sort((left, right) => left.order === right.order
|
|
79
|
+
? left.candidate.name.localeCompare(right.candidate.name)
|
|
80
|
+
: left.order.localeCompare(right.order));
|
|
81
|
+
const uniqueCandidates = deduplicateCandidatesByContent(candidates);
|
|
82
|
+
const visibleCandidates = uniqueCandidates.slice(0, 2_000);
|
|
83
|
+
if (uniqueCandidates.length > visibleCandidates.length) {
|
|
84
|
+
return {
|
|
85
|
+
status: "partial",
|
|
86
|
+
attemptId,
|
|
87
|
+
retainedInventoryRevision: this.lastCompleteRevision,
|
|
88
|
+
diagnostics: [
|
|
89
|
+
...diagnostics.slice(0, 99),
|
|
90
|
+
{
|
|
91
|
+
code: "SCAN_LIMIT_EXCEEDED",
|
|
92
|
+
message: "Skill scan found more than 2,000 candidates",
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
this.locations = new Map(visibleCandidates.map(({ candidate, absolutePath }) => [candidate.localKey, absolutePath]));
|
|
98
|
+
const inventory = visibleCandidates.map(({ candidate }) => candidate);
|
|
99
|
+
const inventoryRevision = hashInventory(inventory);
|
|
100
|
+
this.lastCompleteRevision = inventoryRevision;
|
|
101
|
+
return {
|
|
102
|
+
status: "complete",
|
|
103
|
+
attemptId,
|
|
104
|
+
inventoryRevision,
|
|
105
|
+
candidates: inventory,
|
|
106
|
+
diagnostics: diagnostics.slice(0, 100),
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
resolvePackage(localKey) {
|
|
110
|
+
return this.locations.get(localKey) ?? null;
|
|
111
|
+
}
|
|
112
|
+
async inspectPackage(absolutePath, expectedContentHash) {
|
|
113
|
+
const cached = this.inspectionCache.get(absolutePath)?.inspected;
|
|
114
|
+
if (cached?.contentHash === expectedContentHash)
|
|
115
|
+
return cached;
|
|
116
|
+
return inspectSkillPackage(absolutePath, { expectedName: null });
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* The root read as one package, or null when it does not hold a SKILL.md.
|
|
120
|
+
*
|
|
121
|
+
* `expectedName` is null here on purpose. A package inside a library must be
|
|
122
|
+
* named for its directory, but a root is whatever the person called the
|
|
123
|
+
* folder, so that rule would reject it with DIRECTORY_NAME_MISMATCH.
|
|
124
|
+
*/
|
|
125
|
+
async scanRootAsPackage(resolvedRoot, ignoredPaths, mode) {
|
|
126
|
+
const directory = resolvedRoot.directory;
|
|
127
|
+
if (!(await pathExists(join(directory, "SKILL.md"))))
|
|
128
|
+
return null;
|
|
129
|
+
const canonicalRoot = await realpath(directory).catch(() => directory);
|
|
130
|
+
const name = path.basename(canonicalRoot);
|
|
131
|
+
try {
|
|
132
|
+
const fingerprint = await fingerprintPackage(canonicalRoot);
|
|
133
|
+
const ignoreSignature = JSON.stringify(ignoredPaths);
|
|
134
|
+
const cached = this.inspectionCache.get(canonicalRoot);
|
|
135
|
+
const inspected = mode === "incremental" &&
|
|
136
|
+
cached?.fingerprint === fingerprint &&
|
|
137
|
+
cached.ignoreSignature === ignoreSignature
|
|
138
|
+
? cached.inspected
|
|
139
|
+
: await inspectSkillPackage(canonicalRoot, { ignoredPaths, expectedName: null });
|
|
140
|
+
this.inspectionCache.set(canonicalRoot, { fingerprint, ignoreSignature, inspected });
|
|
141
|
+
return {
|
|
142
|
+
candidates: [
|
|
143
|
+
{
|
|
144
|
+
absolutePath: canonicalRoot,
|
|
145
|
+
rootPath: canonicalRoot,
|
|
146
|
+
order: `${resolvedRoot.order}:${name}`,
|
|
147
|
+
candidate: {
|
|
148
|
+
localKey: createLocalKey(resolvedRoot.root, inspected.metadata.name),
|
|
149
|
+
name: inspected.metadata.name,
|
|
150
|
+
description: inspected.metadata.description,
|
|
151
|
+
contentHash: inspected.contentHash,
|
|
152
|
+
fileCount: inspected.fileCount,
|
|
153
|
+
totalBytes: inspected.totalBytes,
|
|
154
|
+
origin: candidateOrigin(resolvedRoot.root),
|
|
155
|
+
diagnostics: inspected.diagnostics,
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
],
|
|
159
|
+
diagnostics: [],
|
|
160
|
+
incomplete: false,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
return {
|
|
165
|
+
candidates: [],
|
|
166
|
+
diagnostics: [
|
|
167
|
+
{
|
|
168
|
+
code: "INVALID_SKILL",
|
|
169
|
+
message: error instanceof Error ? error.message : String(error),
|
|
170
|
+
rootLabel: resolvedRoot.root.label,
|
|
171
|
+
localKey: createLocalKey(resolvedRoot.root, name),
|
|
172
|
+
},
|
|
173
|
+
],
|
|
174
|
+
incomplete: false,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
async scanRoot(resolvedRoot, visitedDirectories, ignoredPaths, mode, declaredRoots) {
|
|
179
|
+
// A source can be a Skill rather than a directory of them. A root holding
|
|
180
|
+
// its own SKILL.md is the package, and its subdirectories are that
|
|
181
|
+
// package's files, so this returns instead of also walking children.
|
|
182
|
+
const rootPackage = await this.scanRootAsPackage(resolvedRoot, ignoredPaths, mode);
|
|
183
|
+
if (rootPackage)
|
|
184
|
+
return rootPackage;
|
|
185
|
+
let entries;
|
|
186
|
+
try {
|
|
187
|
+
entries = await readdir(resolvedRoot.directory, { withFileTypes: true });
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
if (isAbsentDirectory(error))
|
|
191
|
+
return { candidates: [], diagnostics: [], incomplete: false };
|
|
192
|
+
return {
|
|
193
|
+
candidates: [],
|
|
194
|
+
diagnostics: [
|
|
195
|
+
{
|
|
196
|
+
code: "SOURCE_UNREADABLE",
|
|
197
|
+
message: `Could not read ${resolvedRoot.root.label}`,
|
|
198
|
+
rootLabel: resolvedRoot.root.label,
|
|
199
|
+
},
|
|
200
|
+
],
|
|
201
|
+
incomplete: true,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
const candidates = [];
|
|
205
|
+
const diagnostics = [];
|
|
206
|
+
const canonicalRoot = await realpath(resolvedRoot.directory).catch(() => resolvedRoot.directory);
|
|
207
|
+
for (const entry of entries) {
|
|
208
|
+
if (!entry.isDirectory() && !entry.isSymbolicLink())
|
|
209
|
+
continue;
|
|
210
|
+
const candidatePath = join(resolvedRoot.directory, entry.name);
|
|
211
|
+
const canonicalPath = await realpath(candidatePath).catch(() => null);
|
|
212
|
+
if (!canonicalPath) {
|
|
213
|
+
diagnostics.push({
|
|
214
|
+
code: "SOURCE_UNREADABLE",
|
|
215
|
+
message: `Could not resolve Skill ${entry.name}`,
|
|
216
|
+
rootLabel: resolvedRoot.root.label,
|
|
217
|
+
});
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
// A symlink into another declared root is a duplicate, not an escape:
|
|
221
|
+
// nothing is read that some root was not already going to read, and the
|
|
222
|
+
// canonical-path check below collapses it. Only a target no declared root
|
|
223
|
+
// covers is a real escape.
|
|
224
|
+
const roots = declaredRoots.length > 0 ? declaredRoots : [canonicalRoot];
|
|
225
|
+
if (!roots.some((root) => isWithinDirectory(root, canonicalPath))) {
|
|
226
|
+
diagnostics.push({
|
|
227
|
+
code: "SOURCE_OUTSIDE_DECLARED_ROOT",
|
|
228
|
+
message: `Skill ${entry.name} resolves outside every declared Skill source`,
|
|
229
|
+
rootLabel: resolvedRoot.root.label,
|
|
230
|
+
});
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
if (!(await isDirectory(canonicalPath)))
|
|
234
|
+
continue;
|
|
235
|
+
if (visitedDirectories.has(canonicalPath))
|
|
236
|
+
continue;
|
|
237
|
+
visitedDirectories.add(canonicalPath);
|
|
238
|
+
if (await hasManagedMarker(canonicalPath))
|
|
239
|
+
continue;
|
|
240
|
+
try {
|
|
241
|
+
const fingerprint = await fingerprintPackage(canonicalPath);
|
|
242
|
+
const ignoreSignature = JSON.stringify(ignoredPaths);
|
|
243
|
+
const cached = this.inspectionCache.get(canonicalPath);
|
|
244
|
+
const inspected = mode === "incremental" &&
|
|
245
|
+
cached?.fingerprint === fingerprint &&
|
|
246
|
+
cached.ignoreSignature === ignoreSignature
|
|
247
|
+
? cached.inspected
|
|
248
|
+
: await inspectSkillPackage(canonicalPath, { ignoredPaths });
|
|
249
|
+
this.inspectionCache.set(canonicalPath, { fingerprint, ignoreSignature, inspected });
|
|
250
|
+
const localKey = createLocalKey(resolvedRoot.root, entry.name);
|
|
251
|
+
candidates.push({
|
|
252
|
+
absolutePath: canonicalPath,
|
|
253
|
+
rootPath: canonicalRoot,
|
|
254
|
+
order: `${resolvedRoot.order}:${entry.name}`,
|
|
255
|
+
candidate: {
|
|
256
|
+
localKey,
|
|
257
|
+
name: inspected.metadata.name,
|
|
258
|
+
description: inspected.metadata.description,
|
|
259
|
+
contentHash: inspected.contentHash,
|
|
260
|
+
fileCount: inspected.fileCount,
|
|
261
|
+
totalBytes: inspected.totalBytes,
|
|
262
|
+
origin: candidateOrigin(resolvedRoot.root),
|
|
263
|
+
diagnostics: inspected.diagnostics,
|
|
264
|
+
},
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
catch (error) {
|
|
268
|
+
diagnostics.push({
|
|
269
|
+
code: "INVALID_SKILL",
|
|
270
|
+
message: error instanceof Error ? error.message : String(error),
|
|
271
|
+
rootLabel: resolvedRoot.root.label,
|
|
272
|
+
localKey: createLocalKey(resolvedRoot.root, entry.name),
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return { candidates, diagnostics, incomplete: false };
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
async function fingerprintPackage(root) {
|
|
280
|
+
const hash = createHash("sha256").update("alan-skill-stat-fingerprint-v1\0");
|
|
281
|
+
await visit(root, "");
|
|
282
|
+
return `sha256:${hash.digest("hex")}`;
|
|
283
|
+
async function visit(directory, relativeDirectory) {
|
|
284
|
+
const entries = await readdir(directory, { withFileTypes: true });
|
|
285
|
+
entries.sort((left, right) => Buffer.compare(Buffer.from(left.name), Buffer.from(right.name)));
|
|
286
|
+
for (const entry of entries) {
|
|
287
|
+
const path = relativeDirectory ? `${relativeDirectory}/${entry.name}` : entry.name;
|
|
288
|
+
const absolutePath = join(directory, entry.name);
|
|
289
|
+
const metadata = await lstat(absolutePath);
|
|
290
|
+
hash
|
|
291
|
+
.update(path.normalize("NFC"))
|
|
292
|
+
.update("\0")
|
|
293
|
+
.update(entry.isDirectory() ? "d" : entry.isFile() ? "f" : entry.isSymbolicLink() ? "l" : "o")
|
|
294
|
+
.update("\0")
|
|
295
|
+
.update(String(metadata.size))
|
|
296
|
+
.update("\0")
|
|
297
|
+
.update(String(metadata.mtimeMs))
|
|
298
|
+
.update("\0")
|
|
299
|
+
.update(String(metadata.mode & 0o777))
|
|
300
|
+
.update("\0");
|
|
301
|
+
if (entry.isDirectory())
|
|
302
|
+
await visit(absolutePath, path);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
const CODEX_SOURCE_LABEL = "Codex skills";
|
|
307
|
+
const STALE_CODEX_LABEL = "Legacy Cursor-compatible skills";
|
|
308
|
+
const STALE_CODEX_PROVIDER = "cursor_agent_cli";
|
|
309
|
+
/**
|
|
310
|
+
* The V1 preview wrote `~/.codex/skills` as a Cursor source, so every existing
|
|
311
|
+
* install files its Codex Skills under Cursor and labels them as Cursor's.
|
|
312
|
+
*
|
|
313
|
+
* Corrected here rather than by rewriting the file: the TOML is the user's, and
|
|
314
|
+
* a load-time rewrite would reformat it and drop their comments to fix two
|
|
315
|
+
* values. Reading it correctly repairs every install on the next scan and
|
|
316
|
+
* leaves anyone who deliberately renamed the source alone, since this only
|
|
317
|
+
* fires on the exact pair the preview shipped.
|
|
318
|
+
*/
|
|
319
|
+
function staleCodexDeclaration(relativeDirectory, label, providerKinds) {
|
|
320
|
+
const normalized = relativeDirectory.replaceAll("\\", "/").replace(/^\.\//, "");
|
|
321
|
+
if (normalized !== ".codex/skills")
|
|
322
|
+
return false;
|
|
323
|
+
const ownedByCursor = providerKinds !== undefined &&
|
|
324
|
+
providerKinds.length === 1 &&
|
|
325
|
+
providerKinds[0] === STALE_CODEX_PROVIDER;
|
|
326
|
+
return ownedByCursor || label === STALE_CODEX_LABEL;
|
|
327
|
+
}
|
|
328
|
+
async function canonicalDirectories(directories) {
|
|
329
|
+
const canonical = await Promise.all(directories.map((directory) => realpath(directory).catch(() => directory)));
|
|
330
|
+
return [...new Set(canonical)];
|
|
331
|
+
}
|
|
332
|
+
function isWithinDirectory(parent, candidate) {
|
|
333
|
+
const path = relative(parent, candidate);
|
|
334
|
+
return path !== ".." && !path.startsWith(`..${sep}`) && !isAbsolute(path);
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Add a folder the person picked to their own Skill sources.
|
|
338
|
+
*
|
|
339
|
+
* Appended as text rather than written from a re-serialized config: the TOML is
|
|
340
|
+
* theirs, and round-tripping it through a parser would silently reformat it and
|
|
341
|
+
* drop their comments. Elsewhere this file goes out of its way not to rewrite
|
|
342
|
+
* that file at all; here the write is the thing the person asked for, and it is
|
|
343
|
+
* additive.
|
|
344
|
+
*
|
|
345
|
+
* A folder already covered by a source is reported rather than added twice,
|
|
346
|
+
* because a second root over the same directory only produces rows the scan
|
|
347
|
+
* then has to deduplicate.
|
|
348
|
+
*/
|
|
349
|
+
export async function addSkillSource(homeDirectory, input) {
|
|
350
|
+
const label = input.label.trim();
|
|
351
|
+
if (!label)
|
|
352
|
+
return { state: "invalid", diagnostic: "A source needs a label" };
|
|
353
|
+
const sourcePath = resolveSkillSourcePath(input.path, homeDirectory);
|
|
354
|
+
if (!(await isDirectory(sourcePath))) {
|
|
355
|
+
return { state: "invalid", diagnostic: `${sourcePath} is not a folder` };
|
|
356
|
+
}
|
|
357
|
+
const loaded = await loadSkillSourceConfig(homeDirectory);
|
|
358
|
+
if (loaded.state === "invalid") {
|
|
359
|
+
return { state: "invalid", diagnostic: loaded.diagnostic };
|
|
360
|
+
}
|
|
361
|
+
const canonical = await realpath(sourcePath).catch(() => sourcePath);
|
|
362
|
+
for (const source of loaded.config.sources) {
|
|
363
|
+
const existing = await realpath(source.path).catch(() => source.path);
|
|
364
|
+
if (existing === canonical) {
|
|
365
|
+
return { state: "already_present", label: source.label, config: loaded.config };
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
const configPath = join(homeDirectory, ".alan", "config.toml");
|
|
369
|
+
const current = await readFile(configPath, "utf8");
|
|
370
|
+
const block = [
|
|
371
|
+
"",
|
|
372
|
+
"[[skills.sources]]",
|
|
373
|
+
`path = ${tomlString(sourcePath)}`,
|
|
374
|
+
`label = ${tomlString(label)}`,
|
|
375
|
+
"",
|
|
376
|
+
].join("\n");
|
|
377
|
+
await writeFile(configPath, `${current.replace(/\n*$/, "\n")}${block}`, {
|
|
378
|
+
encoding: "utf8",
|
|
379
|
+
mode: 0o600,
|
|
380
|
+
});
|
|
381
|
+
const reloaded = await loadSkillSourceConfig(homeDirectory);
|
|
382
|
+
if (reloaded.state === "invalid") {
|
|
383
|
+
return { state: "invalid", diagnostic: reloaded.diagnostic };
|
|
384
|
+
}
|
|
385
|
+
return { state: "added", label, config: reloaded.config };
|
|
386
|
+
}
|
|
387
|
+
function tomlString(value) {
|
|
388
|
+
return JSON.stringify(value);
|
|
389
|
+
}
|
|
390
|
+
export async function loadSkillSourceConfig(homeDirectory) {
|
|
391
|
+
const configDirectory = join(homeDirectory, ".alan");
|
|
392
|
+
const configPath = join(configDirectory, "config.toml");
|
|
393
|
+
await mkdir(configDirectory, { recursive: true, mode: 0o700 });
|
|
394
|
+
let created = false;
|
|
395
|
+
try {
|
|
396
|
+
await writeFile(configPath, DEFAULT_SKILL_CONFIG, {
|
|
397
|
+
encoding: "utf8",
|
|
398
|
+
flag: "wx",
|
|
399
|
+
mode: 0o600,
|
|
400
|
+
});
|
|
401
|
+
created = true;
|
|
402
|
+
}
|
|
403
|
+
catch (error) {
|
|
404
|
+
if (!isAlreadyPresent(error))
|
|
405
|
+
throw error;
|
|
406
|
+
}
|
|
407
|
+
const content = await readFile(configPath, "utf8");
|
|
408
|
+
try {
|
|
409
|
+
return { state: "ready", config: parseSkillSourceConfig(content, homeDirectory), created };
|
|
410
|
+
}
|
|
411
|
+
catch (error) {
|
|
412
|
+
return {
|
|
413
|
+
state: "invalid",
|
|
414
|
+
config: parseSkillSourceConfig(DEFAULT_SKILL_CONFIG, homeDirectory),
|
|
415
|
+
created: false,
|
|
416
|
+
diagnostic: error instanceof Error ? error.message : String(error),
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
export async function resolveSkillScanInput(homeDirectory, declared) {
|
|
421
|
+
const loaded = await loadSkillSourceConfig(homeDirectory);
|
|
422
|
+
if (loaded.state === "invalid") {
|
|
423
|
+
throw Object.assign(new Error(`Invalid Skill source configuration: ${loaded.diagnostic}`), {
|
|
424
|
+
code: "SKILL_SOURCE_CONFIG_INVALID",
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
const { config } = loaded;
|
|
428
|
+
if (!config.enabled)
|
|
429
|
+
return { ...declared, roots: [], ignoredPaths: config.ignoredPaths };
|
|
430
|
+
const draftsPath = resolve(join(homeDirectory, ".alan", "skill-sources"));
|
|
431
|
+
const enabledProviders = new Set(declared.enabledProviderKinds ?? []);
|
|
432
|
+
const configured = [];
|
|
433
|
+
for (const source of config.sources) {
|
|
434
|
+
if (source.providerKinds !== undefined &&
|
|
435
|
+
!source.providerKinds.some((provider) => enabledProviders.has(provider))) {
|
|
436
|
+
continue;
|
|
437
|
+
}
|
|
438
|
+
configured.push(resolve(source.path) === draftsPath
|
|
439
|
+
? { kind: "drafts", path: source.path, label: "Alan drafts" }
|
|
440
|
+
: {
|
|
441
|
+
kind: "configured",
|
|
442
|
+
declarationId: source.declarationId,
|
|
443
|
+
path: source.path,
|
|
444
|
+
label: source.label,
|
|
445
|
+
precedence: source.precedence,
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
const repositories = config.discoverRepositorySkills
|
|
449
|
+
? declared.roots.filter((root) => root.kind === "repository")
|
|
450
|
+
: [];
|
|
451
|
+
return {
|
|
452
|
+
...declared,
|
|
453
|
+
roots: [...configured, ...repositories],
|
|
454
|
+
ignoredPaths: [...new Set([...config.ignoredPaths, ...(declared.ignoredPaths ?? [])])],
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
function parseSkillSourceConfig(content, homeDirectory) {
|
|
458
|
+
const parsed = parseToml(content);
|
|
459
|
+
if (!isRecord(parsed) || parsed.version !== 1 || !isRecord(parsed.skills)) {
|
|
460
|
+
throw new Error("~/.alan/config.toml must contain version = 1 and a [skills] table");
|
|
461
|
+
}
|
|
462
|
+
const skills = parsed.skills;
|
|
463
|
+
const enabled = optionalBoolean(skills.enabled, true, "skills.enabled");
|
|
464
|
+
const discoverRepositorySkills = optionalBoolean(skills.discover_repository_skills, true, "skills.discover_repository_skills");
|
|
465
|
+
const ignoredPaths = optionalStringArray(skills.ignore, "skills.ignore");
|
|
466
|
+
if (!Array.isArray(skills.sources)) {
|
|
467
|
+
throw new Error("~/.alan/config.toml must declare at least one [[skills.sources]] table");
|
|
468
|
+
}
|
|
469
|
+
const sources = skills.sources.map((value, index) => {
|
|
470
|
+
if (!isRecord(value) || typeof value.path !== "string" || typeof value.label !== "string") {
|
|
471
|
+
throw new Error(`skills.sources entry ${index + 1} must contain string path and label values`);
|
|
472
|
+
}
|
|
473
|
+
const sourcePath = resolveSkillSourcePath(value.path, homeDirectory);
|
|
474
|
+
const label = value.label.trim();
|
|
475
|
+
if (!label)
|
|
476
|
+
throw new Error(`skills.sources entry ${index + 1} has an empty label`);
|
|
477
|
+
const declarationId = value.id === undefined
|
|
478
|
+
? stableSourceDeclarationId(sourcePath)
|
|
479
|
+
: requiredSourceId(value.id, `skills.sources[${index}].id`);
|
|
480
|
+
const explicitProviders = optionalStringArray(value.providers, `skills.sources[${index}].providers`);
|
|
481
|
+
const relativeDirectory = path.relative(homeDirectory, sourcePath);
|
|
482
|
+
const inferredProviders = providerKindsForUserDirectory(relativeDirectory);
|
|
483
|
+
const declaredProviders = value.providers === undefined
|
|
484
|
+
? inferredProviders
|
|
485
|
+
: [...new Set(explicitProviders.map((provider) => provider.trim()).filter(Boolean))];
|
|
486
|
+
const stale = staleCodexDeclaration(relativeDirectory, label, declaredProviders);
|
|
487
|
+
return {
|
|
488
|
+
declarationId,
|
|
489
|
+
path: sourcePath,
|
|
490
|
+
label: stale ? CODEX_SOURCE_LABEL : label,
|
|
491
|
+
precedence: index,
|
|
492
|
+
providerKinds: stale ? inferredProviders : declaredProviders,
|
|
493
|
+
};
|
|
494
|
+
});
|
|
495
|
+
const duplicateId = sources.find((source, index) => sources.findIndex((candidate) => candidate.declarationId === source.declarationId) !== index);
|
|
496
|
+
if (duplicateId) {
|
|
497
|
+
throw new Error(`skills.sources contains duplicate source id ${duplicateId.declarationId}`);
|
|
498
|
+
}
|
|
499
|
+
return { enabled, discoverRepositorySkills, ignoredPaths, sources };
|
|
500
|
+
}
|
|
501
|
+
function stableSourceDeclarationId(sourcePath) {
|
|
502
|
+
const digest = createHash("sha256")
|
|
503
|
+
.update("alan-skill-source-v1\0")
|
|
504
|
+
.update(sourcePath.normalize("NFC"))
|
|
505
|
+
.digest("hex")
|
|
506
|
+
.slice(0, 24);
|
|
507
|
+
return `source-${digest}`;
|
|
508
|
+
}
|
|
509
|
+
function requiredSourceId(value, field) {
|
|
510
|
+
if (typeof value !== "string" || !/^[a-z0-9]+(?:[-_.][a-z0-9]+)*$/i.test(value)) {
|
|
511
|
+
throw new Error(`${field} must be a stable identifier containing letters, numbers, -, _, or .`);
|
|
512
|
+
}
|
|
513
|
+
return value;
|
|
514
|
+
}
|
|
515
|
+
export function resolveSkillSourcePath(sourcePath, homeDirectory, pathApi = path) {
|
|
516
|
+
const trimmed = sourcePath.trim();
|
|
517
|
+
if (trimmed === "~")
|
|
518
|
+
return pathApi.resolve(homeDirectory);
|
|
519
|
+
if (trimmed.startsWith("~/") || trimmed.startsWith("~\\")) {
|
|
520
|
+
const components = trimmed
|
|
521
|
+
.slice(2)
|
|
522
|
+
.split(/[\\/]+/)
|
|
523
|
+
.filter(Boolean);
|
|
524
|
+
return pathApi.resolve(pathApi.join(homeDirectory, ...components));
|
|
525
|
+
}
|
|
526
|
+
return pathApi.isAbsolute(trimmed)
|
|
527
|
+
? pathApi.resolve(trimmed)
|
|
528
|
+
: pathApi.resolve(homeDirectory, trimmed);
|
|
529
|
+
}
|
|
530
|
+
function optionalBoolean(value, fallback, field) {
|
|
531
|
+
if (value === undefined)
|
|
532
|
+
return fallback;
|
|
533
|
+
if (typeof value !== "boolean")
|
|
534
|
+
throw new Error(`${field} must be true or false`);
|
|
535
|
+
return value;
|
|
536
|
+
}
|
|
537
|
+
function optionalStringArray(value, field) {
|
|
538
|
+
if (value === undefined)
|
|
539
|
+
return [];
|
|
540
|
+
if (!Array.isArray(value) || value.some((item) => typeof item !== "string")) {
|
|
541
|
+
throw new Error(`${field} must be an array of strings`);
|
|
542
|
+
}
|
|
543
|
+
return value;
|
|
544
|
+
}
|
|
545
|
+
function resolveScanRoots(roots, enabledProviderKinds) {
|
|
546
|
+
const resolved = [];
|
|
547
|
+
for (const root of roots) {
|
|
548
|
+
if (root.kind === "repository") {
|
|
549
|
+
for (const [index, relativeDirectory] of skillRepositorySourceDirectories(enabledProviderKinds).entries()) {
|
|
550
|
+
resolved.push({
|
|
551
|
+
root,
|
|
552
|
+
directory: join(root.path, relativeDirectory),
|
|
553
|
+
order: `1:${root.repositoryId}:${String(index).padStart(2, "0")}`,
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
continue;
|
|
557
|
+
}
|
|
558
|
+
resolved.push({
|
|
559
|
+
root,
|
|
560
|
+
directory: root.path,
|
|
561
|
+
order: root.kind === "configured"
|
|
562
|
+
? `0:${String(root.precedence).padStart(8, "0")}:${root.declarationId}`
|
|
563
|
+
: "2:drafts",
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
return resolved.sort((left, right) => left.order.localeCompare(right.order));
|
|
567
|
+
}
|
|
568
|
+
function candidateOrigin(root) {
|
|
569
|
+
if (root.kind === "repository") {
|
|
570
|
+
return { kind: "repository", label: root.label, repositoryId: root.repositoryId };
|
|
571
|
+
}
|
|
572
|
+
return { kind: root.kind, label: root.label };
|
|
573
|
+
}
|
|
574
|
+
function createLocalKey(root, skillName) {
|
|
575
|
+
const rootIdentity = root.kind === "configured"
|
|
576
|
+
? `configured:${root.declarationId}`
|
|
577
|
+
: root.kind === "repository"
|
|
578
|
+
? `repository:${root.repositoryId}`
|
|
579
|
+
: "drafts";
|
|
580
|
+
const digest = createHash("sha256")
|
|
581
|
+
.update("alan-local-skill-v1\0")
|
|
582
|
+
.update(rootIdentity)
|
|
583
|
+
.update("\0")
|
|
584
|
+
.update(skillName.normalize("NFC"))
|
|
585
|
+
.digest("hex");
|
|
586
|
+
return `local:${digest}`;
|
|
587
|
+
}
|
|
588
|
+
function hashInventory(candidates) {
|
|
589
|
+
const hash = createHash("sha256");
|
|
590
|
+
hash.update("alan-skill-inventory-v1\0");
|
|
591
|
+
for (const candidate of candidates) {
|
|
592
|
+
hash.update(candidate.localKey);
|
|
593
|
+
hash.update("\0");
|
|
594
|
+
hash.update(candidate.contentHash);
|
|
595
|
+
hash.update("\0");
|
|
596
|
+
hash.update(candidate.name);
|
|
597
|
+
hash.update("\0");
|
|
598
|
+
}
|
|
599
|
+
return `sha256:${hash.digest("hex")}`;
|
|
600
|
+
}
|
|
601
|
+
/**
|
|
602
|
+
* One row per package, attributed to the most specific source that covers it.
|
|
603
|
+
*
|
|
604
|
+
* Sources nest: pointing Alan at one Skill inside a library leaves two roots
|
|
605
|
+
* over the same package. The deeper root is the more specific statement of
|
|
606
|
+
* where it lives, so it wins over whichever happened to be declared first.
|
|
607
|
+
*/
|
|
608
|
+
function deduplicateCandidatesByContent(candidates) {
|
|
609
|
+
const bestByContent = new Map();
|
|
610
|
+
for (const located of candidates) {
|
|
611
|
+
const existing = bestByContent.get(located.candidate.contentHash);
|
|
612
|
+
if (!existing || located.rootPath.length > existing.rootPath.length) {
|
|
613
|
+
bestByContent.set(located.candidate.contentHash, located);
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
const winners = new Set(bestByContent.values());
|
|
617
|
+
return candidates.filter((located) => winners.has(located));
|
|
618
|
+
}
|
|
619
|
+
async function pathExists(candidate) {
|
|
620
|
+
try {
|
|
621
|
+
await access(candidate);
|
|
622
|
+
return true;
|
|
623
|
+
}
|
|
624
|
+
catch {
|
|
625
|
+
return false;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
async function hasManagedMarker(directory) {
|
|
629
|
+
try {
|
|
630
|
+
await access(join(directory, ".alan-managed.json"));
|
|
631
|
+
return true;
|
|
632
|
+
}
|
|
633
|
+
catch {
|
|
634
|
+
return false;
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
async function isDirectory(path) {
|
|
638
|
+
try {
|
|
639
|
+
return (await lstat(path)).isDirectory();
|
|
640
|
+
}
|
|
641
|
+
catch {
|
|
642
|
+
return false;
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
function isAbsentDirectory(error) {
|
|
646
|
+
return (typeof error === "object" &&
|
|
647
|
+
error !== null &&
|
|
648
|
+
"code" in error &&
|
|
649
|
+
["ENOENT", "ENOTDIR"].includes(String(error.code)));
|
|
650
|
+
}
|
|
651
|
+
function isAlreadyPresent(error) {
|
|
652
|
+
return (typeof error === "object" &&
|
|
653
|
+
error !== null &&
|
|
654
|
+
"code" in error &&
|
|
655
|
+
error.code === "EEXIST");
|
|
656
|
+
}
|
|
657
|
+
function isRecord(value) {
|
|
658
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
659
|
+
}
|
|
660
|
+
//# sourceMappingURL=local-skill-source.js.map
|