@sema-agent/core 7.70.0 → 7.71.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +740 -0
- package/dist/agents/agent-transcript-tool.js +43 -19
- package/dist/agents/inherited-tool-pool.d.ts +5 -1
- package/dist/agents/inherited-tool-pool.js +6 -0
- package/dist/agents/retain-ledger.js +2 -0
- package/dist/agents/send-message-tool.d.ts +12 -1
- package/dist/agents/send-message-tool.js +47 -9
- package/dist/agents/subagent.js +31 -10
- package/dist/agents/tool-filter.js +1 -2
- package/dist/agents/verify.js +13 -2
- package/dist/agents/yield-adoption.js +11 -1
- package/dist/brain/claude-model-id.d.ts +11 -0
- package/dist/brain/claude-model-id.js +3 -1
- package/dist/config/catalog.js +10 -1
- package/dist/config/defaults.d.ts +3 -0
- package/dist/config/defaults.js +1 -0
- package/dist/core/allow-entry.js +1 -2
- package/dist/core/ask-origin.d.ts +55 -21
- package/dist/core/ask-origin.js +19 -11
- package/dist/core/ask-question.d.ts +4 -7
- package/dist/core/ask-question.js +2 -4
- package/dist/core/ask-unresolvable-notice.d.ts +17 -3
- package/dist/core/ask-unresolvable-notice.js +18 -4
- package/dist/core/attachment-source.d.ts +1 -1
- package/dist/core/attachment-source.js +2 -0
- package/dist/core/auto-compaction.d.ts +14 -4
- package/dist/core/auto-compaction.js +3 -2
- package/dist/core/auto-strip.js +2 -0
- package/dist/core/caller-text.d.ts +2 -33
- package/dist/core/caller-text.js +2 -23
- package/dist/core/caller-tool-name.js +1 -2
- package/dist/core/canonical-json.d.ts +9 -0
- package/dist/core/canonical-json.js +6 -0
- package/dist/core/checkpoint-features.d.ts +43 -80
- package/dist/core/checkpoint-features.js +10 -20
- package/dist/core/checkpoint-generation.d.ts +89 -19
- package/dist/core/checkpoint-generation.js +89 -14
- package/dist/core/checkpoint-queries.d.ts +95 -15
- package/dist/core/checkpoint-queries.js +108 -7
- package/dist/core/checkpoint-rekey.d.ts +2 -1
- package/dist/core/checkpoint-rekey.js +2 -2
- package/dist/core/checkpoint-requirements.d.ts +21 -7
- package/dist/core/checkpoint-requirements.js +2 -5
- package/dist/core/checkpoint-row-verdict.d.ts +3 -4
- package/dist/core/checkpoint-row-verdict.js +20 -41
- package/dist/core/checkpoint-store.d.ts +69 -41
- package/dist/core/checkpoint-store.js +28 -14
- package/dist/core/command-sandbox.d.ts +5 -3
- package/dist/core/command-sandbox.js +17 -9
- package/dist/core/config-refusal-codes.d.ts +1 -1
- package/dist/core/config-refusal-codes.js +1 -0
- package/dist/core/declaration-words.d.ts +2 -1
- package/dist/core/declaration-words.js +13 -2
- package/dist/core/effective-path-target.d.ts +23 -0
- package/dist/core/effective-path-target.js +15 -1
- package/dist/core/engine-attestation.d.ts +5 -1
- package/dist/core/engine-attestation.js +1 -0
- package/dist/core/engine-capabilities.d.ts +14 -9
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +62 -32
- package/dist/core/engine-version.js +1 -1
- package/dist/core/entries-not-applied.d.ts +1 -1
- package/dist/core/entries-not-applied.js +1 -0
- package/dist/core/file-history-store.d.ts +95 -11
- package/dist/core/file-history-store.js +117 -19
- package/dist/core/gate-fold.js +13 -7
- package/dist/core/gate-lanes.js +9 -9
- package/dist/core/governance-codes.d.ts +56 -7
- package/dist/core/governance-codes.js +105 -7
- package/dist/core/grant-holder.d.ts +53 -0
- package/dist/core/grant-holder.js +80 -0
- package/dist/core/hooks.d.ts +7 -3
- package/dist/core/hooks.js +2 -2
- package/dist/core/locked-config.d.ts +7 -1
- package/dist/core/locked-config.js +9 -2
- package/dist/core/mcp-call-meta.d.ts +52 -7
- package/dist/core/mcp-call-meta.js +21 -2
- package/dist/core/mcp-host-read.d.ts +1 -1
- package/dist/core/mcp-server-spec.d.ts +18 -0
- package/dist/core/mcp-server-spec.js +1 -0
- package/dist/core/mcp.js +2 -2
- package/dist/core/member-outcome.d.ts +22 -1
- package/dist/core/member-outcome.js +18 -6
- package/dist/core/memory-engine/delegation-settlement.js +5 -5
- package/dist/core/memory-engine/engine.js +19 -19
- package/dist/core/memory-engine/file-backend.d.ts +7 -2
- package/dist/core/memory-engine/file-backend.js +14 -12
- package/dist/core/memory-engine/frontmatter.js +1 -1
- package/dist/core/memory-engine/index.d.ts +1 -0
- package/dist/core/memory-engine/index.js +1 -0
- package/dist/core/memory-engine/layout.d.ts +34 -9
- package/dist/core/memory-engine/layout.js +36 -19
- package/dist/core/memory-engine/memory-deployment.js +8 -8
- package/dist/core/memory-engine/mount-failed-notice.d.ts +8 -5
- package/dist/core/memory-engine/mount-failed-notice.js +5 -2
- package/dist/core/mode-policy.d.ts +5 -0
- package/dist/core/mode-policy.js +6 -0
- package/dist/core/mods/host.d.ts +2 -1
- package/dist/core/mods/host.js +7 -6
- package/dist/core/mods/kernel/index.d.ts +1 -1
- package/dist/core/mods/kernel/index.js +1 -1
- package/dist/core/mods/kernel/registration.d.ts +5 -2
- package/dist/core/mods/kernel/registration.js +19 -3
- package/dist/core/mods/package.d.ts +12 -1
- package/dist/core/mods/package.js +36 -9
- package/dist/core/mods/stations.d.ts +7 -1
- package/dist/core/mods/stations.js +17 -3
- package/dist/core/mods/teammate-stations.d.ts +4 -1
- package/dist/core/mods/teammate-stations.js +1 -1
- package/dist/core/native-signal.d.ts +13 -0
- package/dist/core/native-signal.js +18 -0
- package/dist/core/park-resumability.d.ts +16 -14
- package/dist/core/park-resumability.js +9 -4
- package/dist/core/path-rule-binding.js +1 -1
- package/dist/core/permission-rule-model.d.ts +11 -5
- package/dist/core/permission-rule-model.js +5 -3
- package/dist/core/permission-rule-org.js +1 -1
- package/dist/core/permission-rule-provider.d.ts +5 -1
- package/dist/core/permission-rule-provider.js +6 -1
- package/dist/core/permission-rule-session.d.ts +35 -5
- package/dist/core/permission-rule-session.js +32 -1
- package/dist/core/permission-rule-store.d.ts +5 -1
- package/dist/core/permission-rule-store.js +28 -5
- package/dist/core/permission-rules.d.ts +2 -2
- package/dist/core/permission-rules.js +2 -3
- package/dist/core/principal-name.d.ts +12 -0
- package/dist/core/principal-name.js +6 -2
- package/dist/core/read-root-grant-screen.d.ts +7 -6
- package/dist/core/read-root-grant-screen.js +7 -8
- package/dist/core/remote-env.d.ts +42 -8
- package/dist/core/resume-config-judge.js +1 -1
- package/dist/core/resume-startup-cause.d.ts +19 -4
- package/dist/core/resume-startup-cause.js +25 -6
- package/dist/core/rewind-conversation.d.ts +4 -0
- package/dist/core/rewrite-rejudge.d.ts +9 -1
- package/dist/core/rewrite-rejudge.js +11 -1
- package/dist/core/rule-offer-read.js +3 -2
- package/dist/core/runner/assemble-result.d.ts +21 -11
- package/dist/core/runner/assemble-result.js +24 -4
- package/dist/core/runner/boundary-reminders.d.ts +104 -0
- package/dist/core/runner/boundary-reminders.js +108 -0
- package/dist/core/runner/branch-writeback.d.ts +21 -7
- package/dist/core/runner/branch-writeback.js +44 -6
- package/dist/core/runner/command-sandbox-frame.js +2 -1
- package/dist/core/runner/compact-session.js +11 -4
- package/dist/core/runner/constraint-layers.d.ts +24 -5
- package/dist/core/runner/constraint-layers.js +21 -2
- package/dist/core/runner/continuation-gate.js +3 -1
- package/dist/core/runner/contracts.d.ts +83 -13
- package/dist/core/runner/cross-boundary-lane.js +2 -1
- package/dist/core/runner/delegation-owner.d.ts +246 -45
- package/dist/core/runner/delegation-owner.js +237 -63
- package/dist/core/runner/expire-settle.d.ts +17 -0
- package/dist/core/runner/expire-settle.js +8 -2
- package/dist/core/runner/file-history-request.d.ts +4 -3
- package/dist/core/runner/file-history-request.js +4 -1
- package/dist/core/runner/file-history-restore.d.ts +11 -3
- package/dist/core/runner/file-history-restore.js +11 -3
- package/dist/core/runner/gate-exit.d.ts +22 -1
- package/dist/core/runner/gate-exit.js +12 -14
- package/dist/core/runner/nested-memory-content.js +1 -1
- package/dist/core/runner/nested-memory-lane.d.ts +10 -2
- package/dist/core/runner/nested-memory-lane.js +29 -8
- package/dist/core/runner/own-model-money-door.d.ts +13 -0
- package/dist/core/runner/own-model-money-door.js +17 -0
- package/dist/core/runner/park-commit.d.ts +4 -2
- package/dist/core/runner/park-commit.js +2 -1
- package/dist/core/runner/permission-rule-lanes.d.ts +4 -0
- package/dist/core/runner/permission-rule-lanes.js +7 -0
- package/dist/core/runner/person-path-rows.js +1 -1
- package/dist/core/runner/placement-fence.d.ts +8 -2
- package/dist/core/runner/placement-fence.js +8 -3
- package/dist/core/runner/policy-throw.d.ts +3 -2
- package/dist/core/runner/policy-throw.js +2 -2
- package/dist/core/runner/prepare-acquire-reconcile.d.ts +23 -14
- package/dist/core/runner/prepare-acquire-reconcile.js +33 -15
- package/dist/core/runner/prepare-artifact.d.ts +14 -1
- package/dist/core/runner/prepare-artifact.js +7 -2
- package/dist/core/runner/prepare-ask-lane.d.ts +8 -0
- package/dist/core/runner/prepare-ask-lane.js +14 -5
- package/dist/core/runner/prepare-boundary-parks.js +5 -4
- package/dist/core/runner/prepare-config-doors.d.ts +9 -4
- package/dist/core/runner/prepare-config-doors.js +25 -8
- package/dist/core/runner/prepare-defer-classify.d.ts +8 -4
- package/dist/core/runner/prepare-defer-classify.js +6 -6
- package/dist/core/runner/prepare-execution-env.d.ts +4 -1
- package/dist/core/runner/prepare-execution-env.js +8 -3
- package/dist/core/runner/prepare-file-history.d.ts +26 -0
- package/dist/core/runner/prepare-file-history.js +15 -1
- package/dist/core/runner/prepare-inherited-gate.d.ts +8 -3
- package/dist/core/runner/prepare-inherited-gate.js +9 -2
- package/dist/core/runner/prepare-leg-adoption.d.ts +2 -2
- package/dist/core/runner/prepare-park-ask.js +8 -5
- package/dist/core/runner/prepare-policy-chain.d.ts +5 -0
- package/dist/core/runner/prepare-policy-chain.js +18 -7
- package/dist/core/runner/prepare-prompt-assembly.d.ts +3 -0
- package/dist/core/runner/prepare-prompt-assembly.js +4 -3
- package/dist/core/runner/prepare-suspend-saga.d.ts +4 -1
- package/dist/core/runner/prepare-suspend-saga.js +19 -5
- package/dist/core/runner/prepare-task.d.ts +2 -5
- package/dist/core/runner/prepare-task.js +71 -26
- package/dist/core/runner/prepare-turn-wiring.js +7 -5
- package/dist/core/runner/prepare-workspace-restore.js +59 -28
- package/dist/core/runner/read-root-grant.d.ts +1 -0
- package/dist/core/runner/read-root-grant.js +1 -2
- package/dist/core/runner/resume-admission.d.ts +3 -0
- package/dist/core/runner/resume-admission.js +6 -4
- package/dist/core/runner/resume-apply.js +7 -5
- package/dist/core/runner/resume-claim.d.ts +2 -2
- package/dist/core/runner/resume-claim.js +4 -4
- package/dist/core/runner/resume-policy-outcome.d.ts +1 -1
- package/dist/core/runner/resume-policy-outcome.js +6 -4
- package/dist/core/runner/resume-preflight.d.ts +3 -0
- package/dist/core/runner/resume-preflight.js +10 -3
- package/dist/core/runner/rewind-conversation.js +11 -4
- package/dist/core/runner/rewind-files.js +29 -14
- package/dist/core/runner/rewind-outcome.d.ts +27 -0
- package/dist/core/runner/rewind-outcome.js +14 -0
- package/dist/core/runner/run-attachment-seats.js +2 -1
- package/dist/core/runner/run-clock-and-content.js +2 -0
- package/dist/core/runner/run-identity-wiring.js +2 -0
- package/dist/core/runner/run-leg.js +11 -1
- package/dist/core/runner/run-notification-lane.d.ts +3 -0
- package/dist/core/runner/run-notification-lane.js +2 -2
- package/dist/core/runner/run-settle-and-teardown.d.ts +4 -2
- package/dist/core/runner/run-settle-and-teardown.js +52 -40
- package/dist/core/runner/run-stop-and-final-verify.d.ts +4 -0
- package/dist/core/runner/run-stop-and-final-verify.js +5 -4
- package/dist/core/runner/run-terminal-adoption.d.ts +1 -1
- package/dist/core/runner/run-terminal-adoption.js +3 -3
- package/dist/core/runner/run-turn-boundary.js +7 -0
- package/dist/core/runner/runtask.d.ts +7 -4
- package/dist/core/runner/runtask.js +18 -9
- package/dist/core/runner/session-call-grant-station.d.ts +64 -0
- package/dist/core/runner/session-call-grant-station.js +119 -0
- package/dist/core/runner/session-file-state-replay.js +2 -2
- package/dist/core/runner/session-prompt-seats.d.ts +95 -0
- package/dist/core/runner/session-prompt-seats.js +62 -0
- package/dist/core/runner/session-rule-policy.js +1 -1
- package/dist/core/runner/session-write-ledger.d.ts +8 -0
- package/dist/core/runner/session-write-ledger.js +16 -0
- package/dist/core/runner/side-call-account.js +5 -1
- package/dist/core/runner/stop-tail-notice.d.ts +7 -0
- package/dist/core/runner/stop-tail-notice.js +23 -8
- package/dist/core/runner/stream-reap.js +4 -2
- package/dist/core/runner/stream-settle-backstop.d.ts +1 -1
- package/dist/core/runner/stream-settle-backstop.js +17 -18
- package/dist/core/runner/terminal-account.js +17 -8
- package/dist/core/runner/terminal-projection.d.ts +3 -2
- package/dist/core/runner/terminal-projection.js +1 -1
- package/dist/core/runner/tool-turn-repair-seat.d.ts +2 -2
- package/dist/core/runner/tool-turn-repair-seat.js +12 -7
- package/dist/core/runner/turn-attachments.d.ts +22 -1
- package/dist/core/runner/turn-attachments.js +20 -3
- package/dist/core/runner-deps.d.ts +6 -2
- package/dist/core/secret-env.d.ts +26 -6
- package/dist/core/secret-env.js +6 -6
- package/dist/core/session-call-grant-screen.d.ts +58 -0
- package/dist/core/session-call-grant-screen.js +18 -0
- package/dist/core/session-call-grant.d.ts +93 -0
- package/dist/core/session-call-grant.js +524 -0
- package/dist/core/session-checkout.d.ts +3 -0
- package/dist/core/session-checkout.js +8 -3
- package/dist/core/session-policy-store.d.ts +14 -0
- package/dist/core/session-policy-store.js +16 -2
- package/dist/core/session-store.d.ts +18 -1
- package/dist/core/session-store.js +20 -4
- package/dist/core/session.d.ts +36 -4
- package/dist/core/shared-artifact-reads.d.ts +93 -0
- package/dist/core/shared-artifact-reads.js +94 -0
- package/dist/core/skill-grant.js +1 -1
- package/dist/core/skills-directory.d.ts +9 -45
- package/dist/core/skills-directory.js +9 -722
- package/dist/core/spend-account.js +3 -0
- package/dist/core/store-contracts/checkpoint-store-contract.d.ts +22 -4
- package/dist/core/store-contracts/checkpoint-store-contract.js +363 -29
- package/dist/core/store-contracts/file-history-store-contract.d.ts +11 -3
- package/dist/core/store-contracts/file-history-store-contract.js +62 -2
- package/dist/core/store-contracts/grant-fixture.d.ts +52 -0
- package/dist/core/store-contracts/grant-fixture.js +84 -0
- package/dist/core/store-contracts/session-repo-contract.js +18 -0
- package/dist/core/store-contracts/session-store-contract.d.ts +15 -1
- package/dist/core/store-contracts/session-store-contract.js +211 -2
- package/dist/core/store-contracts/workflow-journal-store-contract.js +47 -8
- package/dist/core/suspend-lane-reasons.d.ts +13 -0
- package/dist/core/suspend-lane-reasons.js +5 -0
- package/dist/core/synthetic-read-verdict.d.ts +5 -3
- package/dist/core/synthetic-read-verdict.js +1 -1
- package/dist/core/task-limits.d.ts +15 -0
- package/dist/core/task-notification.d.ts +33 -7
- package/dist/core/task-notification.js +34 -9
- package/dist/core/task-registry-agent.d.ts +1 -1
- package/dist/core/task-registry-agent.js +18 -7
- package/dist/core/task-registry-shared.d.ts +29 -4
- package/dist/core/task-registry-shared.js +7 -0
- package/dist/core/task-registry.d.ts +21 -1
- package/dist/core/task-registry.js +36 -9
- package/dist/core/task-result.d.ts +55 -1
- package/dist/core/task-spec.d.ts +17 -3
- package/dist/core/terminal-cause.d.ts +68 -5
- package/dist/core/tool-catalog-entries.js +1 -1
- package/dist/core/tool-check-reading.js +2 -1
- package/dist/core/tool-errors.js +1 -0
- package/dist/core/tool-list-grammar.d.ts +0 -47
- package/dist/core/tool-list-grammar.js +1 -75
- package/dist/core/tool-model-gate.d.ts +7 -11
- package/dist/core/tool-model-gate.js +5 -8
- package/dist/core/tool-name-aliases.js +2 -3
- package/dist/core/tool-name-readings.d.ts +4 -0
- package/dist/core/tool-name-readings.js +1 -0
- package/dist/core/tool-policy.d.ts +46 -4
- package/dist/core/tool-policy.js +47 -18
- package/dist/core/tool-result-store.d.ts +0 -24
- package/dist/core/tool-result-store.js +1 -36
- package/dist/core/tool-spec.d.ts +8 -4
- package/dist/core/untrusted-egress.js +2 -2
- package/dist/core/untrusted-text.d.ts +8 -0
- package/dist/core/untrusted-text.js +14 -0
- package/dist/core/user-attachment.d.ts +16 -1
- package/dist/core/user-attachment.js +42 -18
- package/dist/core/wiring-manifest.d.ts +4 -9
- package/dist/core/wiring-manifest.js +1 -1
- package/dist/core/workflow-journal-store.d.ts +55 -8
- package/dist/core/workflow-journal-store.js +34 -10
- package/dist/core/workflow-run-store-contract.js +56 -1
- package/dist/core/workflow-run-store.d.ts +43 -19
- package/dist/core/workflow-run-store.js +17 -2
- package/dist/engine/execution-env/node-execution-env.d.ts +3 -0
- package/dist/engine/execution-env/node-execution-env.js +4 -0
- package/dist/engine/harness/agent-harness.d.ts +10 -5
- package/dist/engine/harness/agent-harness.js +12 -4
- package/dist/engine/harness/types.d.ts +18 -0
- package/dist/engine/llm/tool-turns.d.ts +1 -1
- package/dist/engine/llm/types.d.ts +5 -4
- package/dist/engine/session/memory-repo.d.ts +15 -3
- package/dist/engine/session/memory-repo.js +21 -3
- package/dist/engine/session/memory-storage.d.ts +5 -0
- package/dist/engine/session/memory-storage.js +8 -3
- package/dist/engine/session/repo-utils.d.ts +9 -0
- package/dist/engine/session/repo-utils.js +14 -0
- package/dist/engine/session/storage-base.d.ts +20 -7
- package/dist/engine/session/storage-base.js +13 -1
- package/dist/index.d.ts +39 -21
- package/dist/index.js +32 -17
- package/dist/internal/harness.d.ts +1 -1
- package/dist/internal/harness.js +1 -1
- package/dist/orchestration/run-workflow-tool.d.ts +13 -1
- package/dist/orchestration/run-workflow-tool.js +101 -32
- package/dist/orchestration/workflow-park-adoption.d.ts +309 -92
- package/dist/orchestration/workflow-park-adoption.js +588 -323
- package/dist/orchestration/workflow-tree-id.d.ts +66 -0
- package/dist/orchestration/workflow-tree-id.js +66 -0
- package/dist/orchestration/workflow-types.d.ts +90 -11
- package/dist/orchestration/workflow-types.js +10 -1
- package/dist/orchestration/workflow.d.ts +30 -4
- package/dist/orchestration/workflow.js +424 -114
- package/dist/prompt-assembly/catalog/constitution.js +5 -1
- package/dist/prompt-assembly/catalog/core-behavior.d.ts +3 -4
- package/dist/prompt-assembly/catalog/core-behavior.js +61 -22
- package/dist/prompt-assembly/catalog/environment.js +2 -2
- package/dist/prompt-assembly/catalog/events.d.ts +16 -0
- package/dist/prompt-assembly/catalog/events.js +2 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/core-behavior.js +72 -44
- package/dist/prompt-assembly/catalog/locales/zh-Hans/environment.js +2 -2
- package/dist/prompt-assembly/catalog/locales/zh-Hans/events.js +2 -0
- package/dist/prompt-assembly/catalog/schema.d.ts +5 -1
- package/dist/prompt-assembly/catalog/schema.js +2 -0
- package/dist/prompt-assembly/catalog/sections.js +3 -14
- package/dist/prompt-assembly/event-registry.js +2 -0
- package/dist/prompt-assembly/select.js +1 -0
- package/dist/prompt-assembly/tool-catalog.d.ts +10 -7
- package/dist/prompt-assembly/tool-catalog.js +21 -7
- package/dist/prompt-assembly/types.d.ts +3 -0
- package/dist/prompts/default.d.ts +4 -1
- package/dist/prompts/default.js +6 -0
- package/dist/stores/file/checkpoint-store.d.ts +11 -10
- package/dist/stores/file/checkpoint-store.js +36 -10
- package/dist/stores/file/file-history-store.d.ts +6 -0
- package/dist/stores/file/file-history-store.js +21 -4
- package/dist/stores/file/fs-atomic.d.ts +1 -1
- package/dist/stores/file/index.d.ts +14 -4
- package/dist/stores/file/index.js +21 -5
- package/dist/stores/file/process-anchor.d.ts +9 -1
- package/dist/stores/file/session-policy-store.js +2 -17
- package/dist/stores/file/session-store.d.ts +27 -0
- package/dist/stores/file/session-store.js +81 -9
- package/dist/stores/file/workflow-journal-store.d.ts +14 -4
- package/dist/stores/file/workflow-journal-store.js +32 -24
- package/dist/stores/file/workflow-run-store.d.ts +15 -4
- package/dist/stores/file/workflow-run-store.js +76 -0
- package/dist/tools/artifact/artifact-tool.d.ts +10 -3
- package/dist/tools/artifact/artifact-tool.js +16 -1
- package/dist/tools/fs/bash-program-position.d.ts +10 -4
- package/dist/tools/fs/bash-program-position.js +11 -8
- package/dist/tools/fs/bash-readonly-classifier.d.ts +3 -1
- package/dist/tools/fs/bash-readonly-classifier.js +9 -2
- package/dist/tools/fs/find-actions.d.ts +30 -16
- package/dist/tools/fs/find-actions.js +272 -19
- package/dist/tools/fs/fs-bash.js +8 -5
- package/dist/tools/fs/fs-shared.d.ts +0 -29
- package/dist/tools/fs/fs-shared.js +0 -5
- package/dist/tools/fs/fs-write.js +2 -1
- package/dist/tools/fs/read-deny.d.ts +6 -1
- package/dist/tools/fs/read-deny.js +6 -1
- package/dist/tools/fs/read-floor.d.ts +6 -0
- package/dist/tools/fs/read-floor.js +5 -1
- package/dist/tools/fs/removal-actions.d.ts +43 -0
- package/dist/tools/fs/removal-actions.js +25 -0
- package/dist/tools/fs/removal-targets.d.ts +2 -21
- package/dist/tools/fs/removal-targets.js +2 -3
- package/dist/tools/fs/safety.d.ts +37 -1
- package/dist/tools/fs/safety.js +52 -0
- package/dist/tools/fs/shell-climb.d.ts +46 -0
- package/dist/tools/fs/shell-climb.js +79 -0
- package/dist/tools/fs/shell-read-check.js +47 -19
- package/dist/tools/fs/shell-read-establish.js +36 -22
- package/dist/tools/fs/shell-read-judge.d.ts +10 -2
- package/dist/tools/fs/shell-read-judge.js +4 -4
- package/dist/tools/fs/shell-read-plan.d.ts +3 -0
- package/dist/tools/fs/shell-read-plan.js +1 -1
- package/dist/tools/fs/shell-read-workdir.js +3 -2
- package/dist/tools/fs/shell-read-write-targets.d.ts +4 -3
- package/dist/tools/fs/shell-read-write-targets.js +3 -0
- package/package.json +2 -2
- package/test/export-surface.snapshot.json +173 -15
- package/wire-changes/core-stores-sql@7.71.0.json +40 -0
- package/wire-changes/core-stores-sql@7.71.1.json +40 -0
- package/wire-changes/core@7.71.0.json +5827 -0
- package/wire-changes/core@7.71.1.json +118 -0
- package/wire-changes/mods-kernel@7.71.0.json +52 -0
- package/wire-changes/mods-kernel@7.71.1.json +40 -0
- package/wire-changes/primitives@7.71.0.json +473 -0
- package/wire-changes/primitives@7.71.1.json +40 -0
- package/wire-changes/wiki-gate@7.71.0.json +40 -0
- package/wire-changes/wiki-gate@7.71.1.json +40 -0
- package/dist/core/frontmatter-fence.d.ts +0 -10
- package/dist/core/frontmatter-fence.js +0 -6
- package/dist/core/permission-rule-syntax.d.ts +0 -46
- package/dist/core/permission-rule-syntax.js +0 -52
|
@@ -1,687 +1,13 @@
|
|
|
1
1
|
import { readFileSync, readdirSync, statSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import {
|
|
3
|
+
import { readSkillFile } from "@sema-agent/primitives";
|
|
4
4
|
import { physicalPathOf } from "./physical-path.js";
|
|
5
5
|
import { isPhysicallyWithin } from "../tools/fs/path-containment.js";
|
|
6
6
|
import { assertNoRetiredKeys } from "./retired-keys.js";
|
|
7
|
-
import { ruleSpellingOf } from "./permission-rule-syntax.js";
|
|
8
|
-
import { EntryCutter, isBlank, notARule, SEQUENCE_NOT_A_NAME } from "./tool-list-grammar.js";
|
|
9
|
-
import { callerText } from "./caller-text.js";
|
|
10
7
|
import { thrownText } from "./thrown-value.js";
|
|
11
8
|
const SKILL_FILE = "SKILL.md";
|
|
12
9
|
const RESOURCE_DIRS = ["assets", "references", "scripts"];
|
|
13
|
-
const NAME_MAX_CHARS = 64;
|
|
14
|
-
const NAME_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
15
|
-
const DESCRIPTION_MAX_CHARS = 1024;
|
|
16
10
|
const DEFAULT_MAX_ATTACHMENT_BYTES = 256 * 1024;
|
|
17
|
-
const ALLOWED_TOOLS_KEY = "allowed-tools";
|
|
18
|
-
const DISALLOWED_TOOLS_KEY = "disallowed-tools";
|
|
19
|
-
const DISALLOWED_TOOLS_ALIAS = "disallowedTools";
|
|
20
|
-
const TOOL_LIST_KEYS = new Set([ALLOWED_TOOLS_KEY, DISALLOWED_TOOLS_KEY, DISALLOWED_TOOLS_ALIAS]);
|
|
21
|
-
const UNREAD_CONTINUATION = "it is followed by indented lines the frontmatter reader does not read";
|
|
22
|
-
const TEXT_AFTER_END = "text follows its closing quote or its closing `]` on the same line";
|
|
23
|
-
const SEQUENCE_NOT_AN_ENTRY = "its `- name` entries are not indented alike";
|
|
24
|
-
const VALUE_IS_A_MAPPING = "its value is a mapping or holds one (`key: value` or `{…}`), not a list of names";
|
|
25
|
-
const VALUE_NOT_A_STRING = "its value is a number or a boolean, not a list of names";
|
|
26
|
-
const YAML_ALIAS = 'it holds a YAML alias (an unquoted `*<name>`), which the reader does not resolve — quote a value or entry that is meant as a tool-name pattern ("*Edit")';
|
|
27
|
-
const YAML_ALIAS_START = /^\*[^\s,[\]{}]/;
|
|
28
|
-
const QUOTE_NOT_CLOSED = "a quote in it does not close";
|
|
29
|
-
const flowNotClosed = (opener) => `its \`${opener}\` does not close within its lines`;
|
|
30
|
-
const strayLine = (line) => `a flush-left line that is no key follows it (line ${line})`;
|
|
31
|
-
const NOT_A_KEY_LINE = "a flush-left frontmatter line is a key — letters, digits, `_` and `-`, or one quoted scalar — then `:` and a blank or nothing; a comment starts with `#`";
|
|
32
|
-
const KEY_REPEATED = "the key is written more than once";
|
|
33
|
-
const keyInsideValue = (inner) => `an indented line under its value is a mapping key, ${callerText(inner)} — YAML reads no key there (under a value that is not a mapping, or indented less than the nested block it follows)`;
|
|
34
|
-
const toolListOutOfPlace = (inner) => `it holds the tool-list key \`${inner}\` — a tool list is read only as a key of the frontmatter, written flush left; anywhere else its list would be lost`;
|
|
35
|
-
function leadingBlanks(text) {
|
|
36
|
-
let n = 0;
|
|
37
|
-
while (n < text.length && isBlank(text.charAt(n)))
|
|
38
|
-
n++;
|
|
39
|
-
return n;
|
|
40
|
-
}
|
|
41
|
-
const trimLeadingBlanks = (text) => text.slice(leadingBlanks(text));
|
|
42
|
-
function trimTrailingBlanks(text) {
|
|
43
|
-
let to = text.length;
|
|
44
|
-
while (to > 0 && isBlank(text.charAt(to - 1)))
|
|
45
|
-
to--;
|
|
46
|
-
return text.slice(0, to);
|
|
47
|
-
}
|
|
48
|
-
const trimBlanks = (text) => trimLeadingBlanks(trimTrailingBlanks(text));
|
|
49
|
-
function isSkippable(line) {
|
|
50
|
-
const body = trimLeadingBlanks(line);
|
|
51
|
-
return body === "" || body.startsWith("#");
|
|
52
|
-
}
|
|
53
|
-
function keyTokenOf(line) {
|
|
54
|
-
const quote = line.charAt(0);
|
|
55
|
-
const close = quote === '"' || quote === "'" ? closingQuote(line, 0) : -1;
|
|
56
|
-
const key = close > 0 ? decodeQuoted(line.slice(1, close), quote) : /^[A-Za-z][A-Za-z0-9_-]*/.exec(line)?.[0];
|
|
57
|
-
if (key === undefined)
|
|
58
|
-
return undefined;
|
|
59
|
-
return { key, after: trimLeadingBlanks(line.slice(close > 0 ? close + 1 : key.length)) };
|
|
60
|
-
}
|
|
61
|
-
function keyLineOf(line) {
|
|
62
|
-
const token = keyTokenOf(line);
|
|
63
|
-
return token !== undefined && token.after.startsWith(":") ? { key: token.key, rest: token.after.slice(1) } : undefined;
|
|
64
|
-
}
|
|
65
|
-
function yamlKeyLineOf(text) {
|
|
66
|
-
const line = keyLineOf(text);
|
|
67
|
-
return line !== undefined && (line.rest === "" || isBlank(line.rest.charAt(0))) ? line : undefined;
|
|
68
|
-
}
|
|
69
|
-
const yamlKeyOf = (text) => yamlKeyLineOf(text)?.key;
|
|
70
|
-
const isDashEntry = (text) => text.charAt(0) === "-" && (text.length === 1 || isBlank(text.charAt(1)));
|
|
71
|
-
function nestedLineHead(line) {
|
|
72
|
-
let text = trimLeadingBlanks(line);
|
|
73
|
-
let explicit = false;
|
|
74
|
-
for (;;) {
|
|
75
|
-
const marker = text.charAt(0);
|
|
76
|
-
if (text.length < 2 || (marker !== "-" && marker !== "?") || !isBlank(text.charAt(1)))
|
|
77
|
-
break;
|
|
78
|
-
explicit ||= marker === "?";
|
|
79
|
-
text = trimLeadingBlanks(text.slice(1));
|
|
80
|
-
}
|
|
81
|
-
const token = keyTokenOf(text);
|
|
82
|
-
const keyLine = yamlKeyLineOf(text);
|
|
83
|
-
const key = keyLine?.key ?? (explicit && token !== undefined && (token.after === "" || token.after.startsWith("#")) ? token.key : undefined);
|
|
84
|
-
if (key !== undefined && TOOL_LIST_KEYS.has(key))
|
|
85
|
-
return { key };
|
|
86
|
-
const value = trimLeadingBlanks(keyLine !== undefined ? keyLine.rest : text);
|
|
87
|
-
return value.charAt(0) === "{" || value.charAt(0) === "[" ? { flow: value } : {};
|
|
88
|
-
}
|
|
89
|
-
function toolListKeyIn(line) {
|
|
90
|
-
const head = nestedLineHead(line);
|
|
91
|
-
return head.key ?? (head.flow !== undefined ? scanValue(head.flow, "value").flowKey : undefined);
|
|
92
|
-
}
|
|
93
|
-
function nestedFlowAt(lines, at, end, flow, holds) {
|
|
94
|
-
const floor = Math.max(holds - 1, 0);
|
|
95
|
-
for (let budget = flow.length + 1;; budget *= 2) {
|
|
96
|
-
const region = valueRegion(lines, at, end, flow, floor, budget, false);
|
|
97
|
-
const scan = scanValue(region.lines.join("\n"), "value");
|
|
98
|
-
if (scan.unterminated === undefined || !region.capped)
|
|
99
|
-
return { ...(scan.flowKey !== undefined ? { key: scan.flowKey } : {}), held: Math.max(1, scan.held) };
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
function toolListKeyAfter(trailing) {
|
|
103
|
-
for (let p = 0; p < trailing.length; p++) {
|
|
104
|
-
if (isBlank(trailing.charAt(p)) || (p > 0 && !isBlank(trailing.charAt(p - 1))))
|
|
105
|
-
continue;
|
|
106
|
-
const key = yamlKeyOf(trailing.slice(p));
|
|
107
|
-
if (key !== undefined && TOOL_LIST_KEYS.has(key))
|
|
108
|
-
return key;
|
|
109
|
-
}
|
|
110
|
-
return undefined;
|
|
111
|
-
}
|
|
112
|
-
const opensNestedBlock = (text) => isDashEntry(text) || (text.charAt(0) === "?" && (text.length === 1 || isBlank(text.charAt(1)))) || yamlKeyOf(text) !== undefined || scanValue(text, "value").mapping === true;
|
|
113
|
-
function parseSkillFile(text) {
|
|
114
|
-
const fields = new Map();
|
|
115
|
-
const lists = new Map();
|
|
116
|
-
const normalized = (text.charCodeAt(0) === 0xfeff ? text.slice(1) : text).replace(/\r\n/g, "\n");
|
|
117
|
-
const lines = normalized.split("\n");
|
|
118
|
-
const unread = [];
|
|
119
|
-
const refused = new Set();
|
|
120
|
-
const refuse = (key, why, list) => {
|
|
121
|
-
if (refused.has(key))
|
|
122
|
-
return;
|
|
123
|
-
refused.add(key);
|
|
124
|
-
unread.push({ key, why, list });
|
|
125
|
-
};
|
|
126
|
-
let strayRefused = false;
|
|
127
|
-
const keep = (key, value) => {
|
|
128
|
-
if (!fields.has(key))
|
|
129
|
-
fields.set(key, value);
|
|
130
|
-
};
|
|
131
|
-
if (!isFrontmatterFence(lineAt(lines, 0)))
|
|
132
|
-
return { fields, lists, body: normalized, hadFrontmatter: false, unclosed: false, unread };
|
|
133
|
-
let end = -1;
|
|
134
|
-
for (let i = 1; i < lines.length; i++) {
|
|
135
|
-
if (isFrontmatterFence(lineAt(lines, i))) {
|
|
136
|
-
end = i;
|
|
137
|
-
break;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
if (end === -1)
|
|
141
|
-
return { fields, lists, body: normalized, hadFrontmatter: false, unclosed: true, unread };
|
|
142
|
-
const front = [];
|
|
143
|
-
const fileLine = [];
|
|
144
|
-
for (let k = 0; k < end; k++) {
|
|
145
|
-
for (const piece of lineAt(lines, k).split("\r")) {
|
|
146
|
-
front.push(piece);
|
|
147
|
-
fileLine.push(k + 1);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
const frontEnd = front.length;
|
|
151
|
-
let i = 1;
|
|
152
|
-
let owner;
|
|
153
|
-
const listKeysSeen = new Set();
|
|
154
|
-
const valued = new Set();
|
|
155
|
-
let aliasSwallows;
|
|
156
|
-
const lost = (at, why) => {
|
|
157
|
-
refuse(at.key, why, at.list);
|
|
158
|
-
if (at.key === DISALLOWED_TOOLS_ALIAS)
|
|
159
|
-
aliasSwallows ??= why;
|
|
160
|
-
};
|
|
161
|
-
const listLostAfter = (at, trailing) => {
|
|
162
|
-
const inner = trailing !== undefined ? toolListKeyAfter(trailing) : undefined;
|
|
163
|
-
if (inner !== undefined)
|
|
164
|
-
lost(at, toolListOutOfPlace(inner));
|
|
165
|
-
};
|
|
166
|
-
while (i < frontEnd) {
|
|
167
|
-
const line = lineAt(front, i);
|
|
168
|
-
if (isSkippable(line)) {
|
|
169
|
-
i++;
|
|
170
|
-
continue;
|
|
171
|
-
}
|
|
172
|
-
if (owner !== undefined && (isBlank(line.charAt(0)) ? leadingBlanks(line) >= owner.holds : owner.holds === 0 && isDashEntry(line))) {
|
|
173
|
-
const head = nestedLineHead(line);
|
|
174
|
-
const flow = head.key === undefined && head.flow !== undefined ? nestedFlowAt(front, i, frontEnd, head.flow, owner.holds) : undefined;
|
|
175
|
-
const held = flow?.held ?? 1;
|
|
176
|
-
let inner = head.key ?? flow?.key;
|
|
177
|
-
for (let at = i + 1; inner === undefined && at < i + held; at++)
|
|
178
|
-
inner = toolListKeyIn(lineAt(front, at));
|
|
179
|
-
if (inner !== undefined)
|
|
180
|
-
lost(owner, toolListOutOfPlace(inner));
|
|
181
|
-
i += held;
|
|
182
|
-
continue;
|
|
183
|
-
}
|
|
184
|
-
if (isBlank(line.charAt(0))) {
|
|
185
|
-
if (owner !== undefined) {
|
|
186
|
-
const inner = yamlKeyOf(trimLeadingBlanks(line));
|
|
187
|
-
const list = inner === undefined ? toolListKeyIn(line) : undefined;
|
|
188
|
-
if (inner !== undefined)
|
|
189
|
-
lost(owner, keyInsideValue(inner));
|
|
190
|
-
else if (list !== undefined)
|
|
191
|
-
lost(owner, toolListOutOfPlace(list));
|
|
192
|
-
else if (owner.list)
|
|
193
|
-
refuse(owner.key, UNREAD_CONTINUATION, true);
|
|
194
|
-
}
|
|
195
|
-
i++;
|
|
196
|
-
continue;
|
|
197
|
-
}
|
|
198
|
-
const keyLine = yamlKeyLineOf(line);
|
|
199
|
-
if (keyLine === undefined) {
|
|
200
|
-
if (owner?.list === true)
|
|
201
|
-
lost(owner, strayLine(fileLine[i] ?? i + 1));
|
|
202
|
-
else if (!strayRefused) {
|
|
203
|
-
strayRefused = true;
|
|
204
|
-
unread.push({ line: fileLine[i] ?? i + 1, why: NOT_A_KEY_LINE });
|
|
205
|
-
}
|
|
206
|
-
owner = undefined;
|
|
207
|
-
i++;
|
|
208
|
-
continue;
|
|
209
|
-
}
|
|
210
|
-
const { key, rest } = keyLine;
|
|
211
|
-
const tail = trimBlanks(rest);
|
|
212
|
-
owner = { key, list: TOOL_LIST_KEYS.has(key), holds: Number.POSITIVE_INFINITY };
|
|
213
|
-
if (owner.list) {
|
|
214
|
-
if (listKeysSeen.has(key))
|
|
215
|
-
refuse(key, KEY_REPEATED, true);
|
|
216
|
-
listKeysSeen.add(key);
|
|
217
|
-
const read = readToolList(front, i, frontEnd, trimLeadingBlanks(rest));
|
|
218
|
-
i = read.next;
|
|
219
|
-
listLostAfter(owner, read.trailing);
|
|
220
|
-
if (key === DISALLOWED_TOOLS_ALIAS)
|
|
221
|
-
aliasSwallows ??= read.unterminated;
|
|
222
|
-
const unspelled = read.problem === undefined ? read.entries.findIndex((e) => ruleSpellingOf(e) === undefined) : -1;
|
|
223
|
-
const problem = read.problem ?? (unspelled >= 0 ? notARule(unspelled + 1) : undefined);
|
|
224
|
-
if (problem !== undefined || read.null !== true)
|
|
225
|
-
valued.add(key);
|
|
226
|
-
if (problem !== undefined)
|
|
227
|
-
refuse(key, problem, true);
|
|
228
|
-
else if (read.null !== true && !lists.has(key))
|
|
229
|
-
lists.set(key, read.entries);
|
|
230
|
-
continue;
|
|
231
|
-
}
|
|
232
|
-
const start = valueStartOf(front, i, frontEnd, trimLeadingBlanks(rest));
|
|
233
|
-
if (start === undefined || (start.at > i && opensNestedBlock(start.first))) {
|
|
234
|
-
owner.holds = start === undefined ? 0 : leadingBlanks(lineAt(front, start.at));
|
|
235
|
-
keep(key, tail);
|
|
236
|
-
i++;
|
|
237
|
-
continue;
|
|
238
|
-
}
|
|
239
|
-
const block = parseBlockScalarHeader(trimBlanks(start.first));
|
|
240
|
-
if (block !== undefined) {
|
|
241
|
-
const read = readBlockScalar(front, start.at + 1, frontEnd, block);
|
|
242
|
-
keep(key, start.at > i ? tail : read.value);
|
|
243
|
-
i = read.next;
|
|
244
|
-
continue;
|
|
245
|
-
}
|
|
246
|
-
const region = valueRegion(front, start.at, frontEnd, start.first, 0);
|
|
247
|
-
const scan = scanValue(region.lines.join("\n"), "value");
|
|
248
|
-
if (scan.unterminated !== undefined)
|
|
249
|
-
refuse(key, scan.unterminated, false);
|
|
250
|
-
listLostAfter(owner, scan.trailing);
|
|
251
|
-
if (scan.flowKey !== undefined)
|
|
252
|
-
lost(owner, toolListOutOfPlace(scan.flowKey));
|
|
253
|
-
const flowLines = region.lines.slice(0, scan.held).filter((l) => !isSkippable(l)).map(trimBlanks);
|
|
254
|
-
keep(key, start.at > i ? tail : (scan.quoted ?? (tail.startsWith("[") && flowLines.length > 1 ? flowLines.join(" ") : tail)));
|
|
255
|
-
i = start.at + scan.held;
|
|
256
|
-
}
|
|
257
|
-
if (valued.has(DISALLOWED_TOOLS_KEY) && listKeysSeen.has(DISALLOWED_TOOLS_ALIAS)) {
|
|
258
|
-
lists.delete(DISALLOWED_TOOLS_ALIAS);
|
|
259
|
-
const at = unread.findIndex((u) => "key" in u && u.key === DISALLOWED_TOOLS_ALIAS);
|
|
260
|
-
if (at >= 0)
|
|
261
|
-
unread.splice(at, 1);
|
|
262
|
-
if (aliasSwallows !== undefined)
|
|
263
|
-
unread.push({ key: DISALLOWED_TOOLS_ALIAS, why: aliasSwallows, list: false });
|
|
264
|
-
}
|
|
265
|
-
let body = lines.slice(end + 1).join("\n");
|
|
266
|
-
if (body.startsWith("\n"))
|
|
267
|
-
body = body.slice(1);
|
|
268
|
-
return { fields, lists, body, hadFrontmatter: true, unclosed: false, unread };
|
|
269
|
-
}
|
|
270
|
-
function lineAt(lines, index) {
|
|
271
|
-
return lines[index] ?? "";
|
|
272
|
-
}
|
|
273
|
-
function valueStartOf(lines, keyIdx, end, value) {
|
|
274
|
-
if (!isSkippable(value))
|
|
275
|
-
return { at: keyIdx, first: value };
|
|
276
|
-
let j = keyIdx + 1;
|
|
277
|
-
while (j < end && isSkippable(lineAt(lines, j)))
|
|
278
|
-
j++;
|
|
279
|
-
const line = lineAt(lines, j);
|
|
280
|
-
return j < end && isBlank(line.charAt(0)) ? { at: j, first: trimLeadingBlanks(line) } : undefined;
|
|
281
|
-
}
|
|
282
|
-
function readToolList(lines, keyIdx, end, value) {
|
|
283
|
-
const start = valueStartOf(lines, keyIdx, end, value);
|
|
284
|
-
if (start === undefined || (start.at > keyIdx && start.first.startsWith("-")))
|
|
285
|
-
return readBlockSequence(lines, keyIdx + 1, end);
|
|
286
|
-
return readValue(lines, start.at, end, start.first);
|
|
287
|
-
}
|
|
288
|
-
function readValue(lines, valueIdx, end, first) {
|
|
289
|
-
const header = parseBlockScalarHeader(trimBlanks(first));
|
|
290
|
-
if (header !== undefined) {
|
|
291
|
-
const read = readBlockScalar(lines, valueIdx + 1, end, header);
|
|
292
|
-
const cut = new EntryCutter();
|
|
293
|
-
for (const line of read.value.split("\n")) {
|
|
294
|
-
for (const ch of line)
|
|
295
|
-
cut.push(ch);
|
|
296
|
-
cut.endScalar();
|
|
297
|
-
}
|
|
298
|
-
return { entries: cut.entries, ...(cut.problem !== undefined ? { problem: cut.problem } : {}), next: read.next };
|
|
299
|
-
}
|
|
300
|
-
const region = valueRegion(lines, valueIdx, end, first, 0);
|
|
301
|
-
const { held, mapping: _mapping, quoted: _quoted, flowKey: _flowKey, ...scan } = scanValue(region.lines.join("\n"), "value");
|
|
302
|
-
void _mapping;
|
|
303
|
-
void _quoted;
|
|
304
|
-
void _flowKey;
|
|
305
|
-
return { ...scan, next: valueIdx + held };
|
|
306
|
-
}
|
|
307
|
-
function valueRegion(lines, from, end, first, floor, budget = Number.POSITIVE_INFINITY, flushLeftCloses = true) {
|
|
308
|
-
const taken = [first];
|
|
309
|
-
const flow = first.startsWith("[") || first.startsWith("{");
|
|
310
|
-
let size = first.length + 1;
|
|
311
|
-
let j = from + 1;
|
|
312
|
-
for (; j < end; j++) {
|
|
313
|
-
if (size >= budget)
|
|
314
|
-
return { lines: taken, next: j, capped: true };
|
|
315
|
-
const line = lineAt(lines, j);
|
|
316
|
-
const body = trimLeadingBlanks(line);
|
|
317
|
-
const closes = flow && (body.startsWith("]") || body.startsWith("}")) && (flushLeftCloses || body.length < line.length);
|
|
318
|
-
if (!isSkippable(line) && leadingBlanks(line) <= floor && !closes)
|
|
319
|
-
break;
|
|
320
|
-
taken.push(body);
|
|
321
|
-
size += body.length + 1;
|
|
322
|
-
}
|
|
323
|
-
return { lines: taken, next: j, capped: false };
|
|
324
|
-
}
|
|
325
|
-
function readBlockSequence(lines, start, end) {
|
|
326
|
-
const entries = [];
|
|
327
|
-
let indent;
|
|
328
|
-
let j = start;
|
|
329
|
-
while (j < end) {
|
|
330
|
-
const line = lineAt(lines, j);
|
|
331
|
-
if (isSkippable(line)) {
|
|
332
|
-
j++;
|
|
333
|
-
continue;
|
|
334
|
-
}
|
|
335
|
-
const dashAt = leadingBlanks(line);
|
|
336
|
-
if (!isDashEntry(line.slice(dashAt)))
|
|
337
|
-
break;
|
|
338
|
-
const dashIndent = line.slice(0, dashAt);
|
|
339
|
-
if (indent !== undefined && dashIndent !== indent)
|
|
340
|
-
return { entries, next: j, problem: SEQUENCE_NOT_AN_ENTRY };
|
|
341
|
-
indent = dashIndent;
|
|
342
|
-
const item = valueRegion(lines, j, end, trimLeadingBlanks(line.slice(dashAt + 1)), dashAt);
|
|
343
|
-
const scan = scanValue(item.lines.join("\n"), "item");
|
|
344
|
-
if (scan.problem !== undefined)
|
|
345
|
-
return { entries, next: j + scan.held, problem: scan.problem, ...(scan.unterminated !== undefined ? { unterminated: scan.unterminated } : {}), ...(scan.trailing !== undefined ? { trailing: scan.trailing } : {}) };
|
|
346
|
-
for (const entry of scan.entries)
|
|
347
|
-
entries.push(entry);
|
|
348
|
-
j += scan.held;
|
|
349
|
-
}
|
|
350
|
-
return { entries, next: j, ...(indent === undefined ? { null: true } : {}) };
|
|
351
|
-
}
|
|
352
|
-
const YAML_NULL = /^(?:null|Null|NULL|~)$/;
|
|
353
|
-
const YAML_BOOL_OR_NUMBER = /^(?:true|True|TRUE|false|False|FALSE|[-+]?[0-9]+|0o[0-7]+|0x[0-9a-fA-F]+|[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)(?:[eE][-+]?[0-9]+)?|[-+]?\.(?:inf|Inf|INF)|\.(?:nan|NaN|NAN))$/;
|
|
354
|
-
function scanValue(text, seat) {
|
|
355
|
-
const cut = new EntryCutter();
|
|
356
|
-
let state = "start";
|
|
357
|
-
const opened = [];
|
|
358
|
-
const closes = (ch) => opened.length > 0 && ch === (opened[opened.length - 1] === "{" ? "}" : "]");
|
|
359
|
-
let held = text.split("\n").length;
|
|
360
|
-
let mapping = false;
|
|
361
|
-
let inComment = false;
|
|
362
|
-
let crossedLine = false;
|
|
363
|
-
let plain = "";
|
|
364
|
-
let breaks = 0;
|
|
365
|
-
let itemFrom = 0;
|
|
366
|
-
let isNull = false;
|
|
367
|
-
let unterminated;
|
|
368
|
-
let quoted;
|
|
369
|
-
let trailing;
|
|
370
|
-
let flowKey;
|
|
371
|
-
let quotedItem;
|
|
372
|
-
const endPlain = () => {
|
|
373
|
-
const written = trimBlanks(plain);
|
|
374
|
-
plain = "";
|
|
375
|
-
breaks = 0;
|
|
376
|
-
if (YAML_ALIAS_START.test(written))
|
|
377
|
-
cut.fail(YAML_ALIAS);
|
|
378
|
-
else if (opened.length > 0 || seat === "item") {
|
|
379
|
-
if (YAML_NULL.test(written) || YAML_BOOL_OR_NUMBER.test(written))
|
|
380
|
-
cut.fail(SEQUENCE_NOT_A_NAME);
|
|
381
|
-
}
|
|
382
|
-
else if (YAML_NULL.test(written))
|
|
383
|
-
isNull = true;
|
|
384
|
-
else if (YAML_BOOL_OR_NUMBER.test(written))
|
|
385
|
-
cut.fail(VALUE_NOT_A_STRING);
|
|
386
|
-
cut.endScalar();
|
|
387
|
-
};
|
|
388
|
-
const mappingMarkAt = (at) => {
|
|
389
|
-
const next = text.charAt(at + 1);
|
|
390
|
-
return next === "" || next === "\n" || isBlank(next) || (opened.length > 0 && (next === "," || next === "]" || next === "}"));
|
|
391
|
-
};
|
|
392
|
-
const ended = (item) => {
|
|
393
|
-
quotedItem = undefined;
|
|
394
|
-
if (item && opened.length > 0 && cut.entries.length === itemFrom)
|
|
395
|
-
cut.fail(SEQUENCE_NOT_A_NAME);
|
|
396
|
-
state = opened.length > 0 ? "after" : "done";
|
|
397
|
-
crossedLine = false;
|
|
398
|
-
};
|
|
399
|
-
for (let k = 0; k < text.length; k++) {
|
|
400
|
-
const ch = text.charAt(k);
|
|
401
|
-
if (inComment && ch !== "\n")
|
|
402
|
-
continue;
|
|
403
|
-
inComment = false;
|
|
404
|
-
const comment = ch === "#" && (k === 0 || isBlank(text.charAt(k - 1)) || text.charAt(k - 1) === "\n");
|
|
405
|
-
if (state !== "plain") {
|
|
406
|
-
if (isBlank(ch))
|
|
407
|
-
continue;
|
|
408
|
-
if (ch === "\n" || comment) {
|
|
409
|
-
crossedLine ||= ch === "\n";
|
|
410
|
-
inComment = comment;
|
|
411
|
-
continue;
|
|
412
|
-
}
|
|
413
|
-
if (state === "done") {
|
|
414
|
-
if (crossedLine) {
|
|
415
|
-
held = linesBefore(text, k);
|
|
416
|
-
break;
|
|
417
|
-
}
|
|
418
|
-
cut.fail(TEXT_AFTER_END);
|
|
419
|
-
quoted = undefined;
|
|
420
|
-
trailing ??= text.slice(k, lineEndOf(text, k));
|
|
421
|
-
continue;
|
|
422
|
-
}
|
|
423
|
-
if (opened.length > 0 && (ch === "," || ch === "]" || ch === "}")) {
|
|
424
|
-
if (ch === ",")
|
|
425
|
-
state = "start";
|
|
426
|
-
else if (closes(ch)) {
|
|
427
|
-
opened.pop();
|
|
428
|
-
ended(false);
|
|
429
|
-
}
|
|
430
|
-
else
|
|
431
|
-
cut.fail(SEQUENCE_NOT_A_NAME);
|
|
432
|
-
continue;
|
|
433
|
-
}
|
|
434
|
-
if (state === "after" && ch === ":") {
|
|
435
|
-
cut.fail(VALUE_IS_A_MAPPING);
|
|
436
|
-
if (quotedItem !== undefined && TOOL_LIST_KEYS.has(quotedItem))
|
|
437
|
-
flowKey ??= quotedItem;
|
|
438
|
-
state = "start";
|
|
439
|
-
continue;
|
|
440
|
-
}
|
|
441
|
-
if (state === "after")
|
|
442
|
-
cut.fail(TEXT_AFTER_END);
|
|
443
|
-
const opens = state === "start";
|
|
444
|
-
itemFrom = cut.entries.length;
|
|
445
|
-
if (opens && (ch === '"' || ch === "'")) {
|
|
446
|
-
const close = closingQuote(text, k);
|
|
447
|
-
if (close < 0) {
|
|
448
|
-
cut.fail((unterminated = QUOTE_NOT_CLOSED));
|
|
449
|
-
break;
|
|
450
|
-
}
|
|
451
|
-
const decoded = decodeQuoted(text.slice(k + 1, close), ch);
|
|
452
|
-
if (opened.length === 0)
|
|
453
|
-
quoted = decoded;
|
|
454
|
-
for (const c of decoded)
|
|
455
|
-
cut.push(c);
|
|
456
|
-
cut.endScalar();
|
|
457
|
-
ended(true);
|
|
458
|
-
if (opened.length > 0)
|
|
459
|
-
quotedItem = decoded;
|
|
460
|
-
k = close;
|
|
461
|
-
continue;
|
|
462
|
-
}
|
|
463
|
-
if (opens && (ch === "[" || ch === "{") && (opened.length > 0 || seat === "value")) {
|
|
464
|
-
if (opened.length > 0)
|
|
465
|
-
cut.fail(SEQUENCE_NOT_A_NAME);
|
|
466
|
-
else if (ch === "{")
|
|
467
|
-
cut.fail(VALUE_IS_A_MAPPING);
|
|
468
|
-
opened.push(ch);
|
|
469
|
-
continue;
|
|
470
|
-
}
|
|
471
|
-
state = "plain";
|
|
472
|
-
}
|
|
473
|
-
if (ch === "\n") {
|
|
474
|
-
breaks++;
|
|
475
|
-
continue;
|
|
476
|
-
}
|
|
477
|
-
if (breaks > 0 && opened.length === 0 && yamlKeyOf(trimLeadingBlanks(text.slice(k, lineEndOf(text, k)))) !== undefined) {
|
|
478
|
-
endPlain();
|
|
479
|
-
ended(true);
|
|
480
|
-
held = linesBefore(text, k);
|
|
481
|
-
break;
|
|
482
|
-
}
|
|
483
|
-
if (comment) {
|
|
484
|
-
endPlain();
|
|
485
|
-
ended(true);
|
|
486
|
-
inComment = true;
|
|
487
|
-
continue;
|
|
488
|
-
}
|
|
489
|
-
if (opened.length > 0 && (ch === "," || closes(ch))) {
|
|
490
|
-
endPlain();
|
|
491
|
-
ended(true);
|
|
492
|
-
if (ch === ",")
|
|
493
|
-
state = "start";
|
|
494
|
-
else {
|
|
495
|
-
opened.pop();
|
|
496
|
-
ended(false);
|
|
497
|
-
}
|
|
498
|
-
continue;
|
|
499
|
-
}
|
|
500
|
-
if (opened.length > 0 && (ch === "[" || ch === "{" || ch === "]" || ch === "}")) {
|
|
501
|
-
cut.fail(SEQUENCE_NOT_A_NAME);
|
|
502
|
-
if (ch === "[" || ch === "{")
|
|
503
|
-
opened.push(ch);
|
|
504
|
-
}
|
|
505
|
-
if (ch === ":" && mappingMarkAt(k)) {
|
|
506
|
-
cut.fail(VALUE_IS_A_MAPPING);
|
|
507
|
-
if (opened.length === 0)
|
|
508
|
-
mapping = true;
|
|
509
|
-
else {
|
|
510
|
-
const written = trimBlanks(plain);
|
|
511
|
-
if (TOOL_LIST_KEYS.has(written))
|
|
512
|
-
flowKey ??= written;
|
|
513
|
-
endPlain();
|
|
514
|
-
state = "start";
|
|
515
|
-
continue;
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
if (breaks > 0) {
|
|
519
|
-
cut.fold(breaks);
|
|
520
|
-
plain += breaks === 1 ? " " : "\n".repeat(breaks - 1);
|
|
521
|
-
breaks = 0;
|
|
522
|
-
}
|
|
523
|
-
cut.push(ch);
|
|
524
|
-
plain += ch;
|
|
525
|
-
}
|
|
526
|
-
if (opened.length > 0) {
|
|
527
|
-
const why = flowNotClosed(opened[0] ?? "[");
|
|
528
|
-
cut.fail(why);
|
|
529
|
-
unterminated ??= why;
|
|
530
|
-
}
|
|
531
|
-
if (state === "plain")
|
|
532
|
-
endPlain();
|
|
533
|
-
if (seat === "item" && cut.entries.length === 0)
|
|
534
|
-
cut.fail(SEQUENCE_NOT_A_NAME);
|
|
535
|
-
return {
|
|
536
|
-
entries: isNull ? [] : cut.entries,
|
|
537
|
-
...(cut.problem !== undefined ? { problem: cut.problem } : {}),
|
|
538
|
-
...(unterminated !== undefined ? { unterminated } : {}),
|
|
539
|
-
...(isNull ? { null: true } : {}),
|
|
540
|
-
held,
|
|
541
|
-
...(mapping ? { mapping: true } : {}),
|
|
542
|
-
...(quoted !== undefined ? { quoted } : {}),
|
|
543
|
-
...(trailing !== undefined ? { trailing } : {}),
|
|
544
|
-
...(flowKey !== undefined ? { flowKey } : {}),
|
|
545
|
-
};
|
|
546
|
-
}
|
|
547
|
-
function linesBefore(text, at) {
|
|
548
|
-
let n = 0;
|
|
549
|
-
for (let k = text.indexOf("\n"); k >= 0 && k < at; k = text.indexOf("\n", k + 1))
|
|
550
|
-
n++;
|
|
551
|
-
return n;
|
|
552
|
-
}
|
|
553
|
-
function lineEndOf(text, at) {
|
|
554
|
-
const k = text.indexOf("\n", at);
|
|
555
|
-
return k < 0 ? text.length : k;
|
|
556
|
-
}
|
|
557
|
-
function closingQuote(text, open) {
|
|
558
|
-
const quote = text.charAt(open);
|
|
559
|
-
for (let k = open + 1; k < text.length; k++) {
|
|
560
|
-
const ch = text.charAt(k);
|
|
561
|
-
if (quote === '"' && ch === "\\")
|
|
562
|
-
k++;
|
|
563
|
-
else if (ch === quote) {
|
|
564
|
-
if (quote === "'" && text.charAt(k + 1) === "'")
|
|
565
|
-
k++;
|
|
566
|
-
else
|
|
567
|
-
return k;
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
return -1;
|
|
571
|
-
}
|
|
572
|
-
const DOUBLE_QUOTE_ESCAPES = new Map(Object.entries({ 0: 0, a: 7, b: 8, t: 9, "\t": 9, n: 10, v: 11, f: 12, r: 13, e: 0x1b, " ": 32, '"': 34, "/": 47, "\\": 92, N: 0x85, _: 0xa0, L: 0x2028, P: 0x2029 }).map(([letter, code]) => [letter, String.fromCharCode(code)]));
|
|
573
|
-
function decodeQuoted(inner, quote) {
|
|
574
|
-
let out = "";
|
|
575
|
-
let blanks = "";
|
|
576
|
-
let breaks = 0;
|
|
577
|
-
let joined = false;
|
|
578
|
-
const fold = () => (breaks === 0 ? blanks : joined ? "\n".repeat(breaks) : breaks === 1 ? " " : "\n".repeat(breaks - 1));
|
|
579
|
-
for (let k = 0; k < inner.length; k++) {
|
|
580
|
-
const ch = inner.charAt(k);
|
|
581
|
-
if (ch === "\n") {
|
|
582
|
-
blanks = "";
|
|
583
|
-
breaks++;
|
|
584
|
-
continue;
|
|
585
|
-
}
|
|
586
|
-
if (isBlank(ch)) {
|
|
587
|
-
if (breaks === 0 && !joined)
|
|
588
|
-
blanks += ch;
|
|
589
|
-
continue;
|
|
590
|
-
}
|
|
591
|
-
out += fold();
|
|
592
|
-
blanks = "";
|
|
593
|
-
breaks = 0;
|
|
594
|
-
joined = false;
|
|
595
|
-
if (quote === "'" || ch !== "\\") {
|
|
596
|
-
out += ch;
|
|
597
|
-
if (quote === "'" && ch === "'")
|
|
598
|
-
k++;
|
|
599
|
-
continue;
|
|
600
|
-
}
|
|
601
|
-
const escape = /^(?:x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8}|[\s\S])/.exec(inner.slice(k + 1, k + 10))?.[0] ?? "";
|
|
602
|
-
const code = escape.length > 1 ? Number.parseInt(escape.slice(1), 16) : -1;
|
|
603
|
-
if (code > 0x10ffff || (code >= 0xd800 && code <= 0xdfff)) {
|
|
604
|
-
out += `\\${escape.charAt(0)}`;
|
|
605
|
-
k += 1;
|
|
606
|
-
continue;
|
|
607
|
-
}
|
|
608
|
-
k += escape.length;
|
|
609
|
-
joined = escape === "\n";
|
|
610
|
-
if (joined)
|
|
611
|
-
continue;
|
|
612
|
-
out += code >= 0 ? String.fromCodePoint(code) : (DOUBLE_QUOTE_ESCAPES.get(escape) ?? `\\${escape}`);
|
|
613
|
-
}
|
|
614
|
-
return out + fold();
|
|
615
|
-
}
|
|
616
|
-
function parseBlockScalarHeader(value) {
|
|
617
|
-
const m = /^([|>])([0-9+-]*)([\s\S]*)$/.exec(value);
|
|
618
|
-
if (!m)
|
|
619
|
-
return undefined;
|
|
620
|
-
const [, style = "", rest = "", comment = ""] = m;
|
|
621
|
-
if (comment !== "" && !(isBlank(comment.charAt(0)) && trimLeadingBlanks(comment).startsWith("#")))
|
|
622
|
-
return undefined;
|
|
623
|
-
if (!/^(?:[1-9]?[+-]?|[+-][1-9]?)$/.test(rest))
|
|
624
|
-
return undefined;
|
|
625
|
-
const digit = /[1-9]/.exec(rest)?.[0];
|
|
626
|
-
return { style: style === "|" ? "literal" : "folded", ...(digit !== undefined ? { indent: Number(digit) } : {}) };
|
|
627
|
-
}
|
|
628
|
-
function readBlockScalar(lines, start, end, header) {
|
|
629
|
-
const indentOf = leadingBlanks;
|
|
630
|
-
let indent = header.indent;
|
|
631
|
-
if (indent === undefined) {
|
|
632
|
-
for (let j = start; j < end; j++) {
|
|
633
|
-
if (trimBlanks(lineAt(lines, j)) === "")
|
|
634
|
-
continue;
|
|
635
|
-
indent = indentOf(lineAt(lines, j));
|
|
636
|
-
break;
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
if (indent === undefined || indent === 0)
|
|
640
|
-
return { value: "", next: start };
|
|
641
|
-
const taken = [];
|
|
642
|
-
let j = start;
|
|
643
|
-
for (; j < end; j++) {
|
|
644
|
-
const line = lineAt(lines, j);
|
|
645
|
-
if (trimBlanks(line) === "") {
|
|
646
|
-
taken.push("");
|
|
647
|
-
continue;
|
|
648
|
-
}
|
|
649
|
-
if (indentOf(line) < indent)
|
|
650
|
-
break;
|
|
651
|
-
taken.push(line.slice(indent));
|
|
652
|
-
}
|
|
653
|
-
while (taken.length > 0 && taken[taken.length - 1] === "")
|
|
654
|
-
taken.pop();
|
|
655
|
-
if (header.style === "literal")
|
|
656
|
-
return { value: taken.join("\n"), next: j };
|
|
657
|
-
let folded = "";
|
|
658
|
-
let blanks = 0;
|
|
659
|
-
let started = false;
|
|
660
|
-
let prevMoreIndented = false;
|
|
661
|
-
for (const cur of taken) {
|
|
662
|
-
if (cur === "") {
|
|
663
|
-
blanks++;
|
|
664
|
-
continue;
|
|
665
|
-
}
|
|
666
|
-
const moreIndented = indentOf(cur) > 0;
|
|
667
|
-
if (!started) {
|
|
668
|
-
folded = cur;
|
|
669
|
-
started = true;
|
|
670
|
-
}
|
|
671
|
-
else if (blanks > 0) {
|
|
672
|
-
folded += "\n".repeat(blanks) + cur;
|
|
673
|
-
}
|
|
674
|
-
else if (moreIndented || prevMoreIndented) {
|
|
675
|
-
folded += `\n${cur}`;
|
|
676
|
-
}
|
|
677
|
-
else {
|
|
678
|
-
folded += ` ${cur}`;
|
|
679
|
-
}
|
|
680
|
-
blanks = 0;
|
|
681
|
-
prevMoreIndented = moreIndented;
|
|
682
|
-
}
|
|
683
|
-
return { value: folded, next: j };
|
|
684
|
-
}
|
|
685
11
|
function listRelativeFiles(base, dir, prefix, out, walk) {
|
|
686
12
|
let entries;
|
|
687
13
|
try {
|
|
@@ -857,59 +183,20 @@ export function createSkillsFromDirectory(dir, options = {}) {
|
|
|
857
183
|
warn({ code: "no_skill_file", skill: name, detail: `no ${SKILL_FILE} in this directory — skipped` });
|
|
858
184
|
continue;
|
|
859
185
|
}
|
|
860
|
-
const
|
|
861
|
-
if (
|
|
862
|
-
|
|
863
|
-
warn({ code: "no_frontmatter", skill: name, detail });
|
|
864
|
-
continue;
|
|
865
|
-
}
|
|
866
|
-
if (parsed.unread.length > 0) {
|
|
867
|
-
const lists = parsed.unread.some((u) => "list" in u && u.list);
|
|
868
|
-
const said = parsed.unread.map((u) => ("line" in u ? `${SKILL_FILE} line ${u.line} is no key line (${u.why})` : `\`${u.key}\` has a value the reader cannot read${u.list ? " as a list" : ""} (${u.why})`));
|
|
869
|
-
warn({
|
|
870
|
-
code: "no_frontmatter",
|
|
871
|
-
skill: name,
|
|
872
|
-
detail: `${said.join("; ")}${lists ? " — write each list as one value (`a b`, `a, b`, `[a, b]`), a block scalar, or `- name` lines under the key" : ""} — skipped${lists ? ", not installed with a missing or shorter list" : ""}`,
|
|
873
|
-
});
|
|
874
|
-
continue;
|
|
875
|
-
}
|
|
876
|
-
const declaredName = parsed.fields.get("name");
|
|
877
|
-
if (declaredName === undefined || declaredName === "") {
|
|
878
|
-
warn({ code: "missing_name", skill: name, detail: "frontmatter has no `name` (required) — skipped" });
|
|
879
|
-
continue;
|
|
880
|
-
}
|
|
881
|
-
if (declaredName.length > NAME_MAX_CHARS || !NAME_RE.test(declaredName)) {
|
|
882
|
-
warn({
|
|
883
|
-
code: "invalid_name",
|
|
884
|
-
skill: name,
|
|
885
|
-
detail: `\`name\` must be ≤${NAME_MAX_CHARS} chars of lowercase alphanumerics in hyphen-separated runs — skipped`,
|
|
886
|
-
});
|
|
887
|
-
continue;
|
|
888
|
-
}
|
|
889
|
-
if (declaredName !== name) {
|
|
890
|
-
warn({ code: "name_mismatch", skill: name, detail: `frontmatter \`name\` is "${declaredName}" but the directory is "${name}" — skipped` });
|
|
891
|
-
continue;
|
|
892
|
-
}
|
|
893
|
-
const description = parsed.fields.get("description");
|
|
894
|
-
if (description === undefined || description === "") {
|
|
895
|
-
warn({ code: "missing_description", skill: name, detail: "frontmatter has no `description` (required) — skipped" });
|
|
896
|
-
continue;
|
|
897
|
-
}
|
|
898
|
-
if (description.length > DESCRIPTION_MAX_CHARS) {
|
|
899
|
-
warn({ code: "description_too_long", skill: name, detail: `\`description\` is ${description.length} chars, over the ${DESCRIPTION_MAX_CHARS} cap — skipped` });
|
|
186
|
+
const reading = readSkillFile(text, { directoryName: name });
|
|
187
|
+
if (reading.kind !== "read") {
|
|
188
|
+
warn({ code: reading.reason, skill: name, detail: reading.detail });
|
|
900
189
|
continue;
|
|
901
190
|
}
|
|
902
|
-
const allowedTools = parsed.lists.get(ALLOWED_TOOLS_KEY) ?? [];
|
|
903
|
-
const disallowedTools = parsed.lists.get(DISALLOWED_TOOLS_KEY) ?? parsed.lists.get(DISALLOWED_TOOLS_ALIAS) ?? [];
|
|
904
191
|
const baseDir = skillPhysicalRoot(skillDir, name, warn);
|
|
905
192
|
const files = baseDir === undefined ? [] : readAttachments(skillDir, baseDir, name, budget, warn);
|
|
906
193
|
skills.push({
|
|
907
|
-
name:
|
|
908
|
-
description,
|
|
909
|
-
content:
|
|
194
|
+
name: reading.name,
|
|
195
|
+
description: reading.description,
|
|
196
|
+
content: reading.body,
|
|
910
197
|
...(baseDir !== undefined ? { baseDir } : {}),
|
|
911
|
-
...(allowedTools.length > 0 ? { allowedTools } : {}),
|
|
912
|
-
...(disallowedTools.length > 0 ? { disallowedTools } : {}),
|
|
198
|
+
...(reading.allowedTools.length > 0 ? { allowedTools: [...reading.allowedTools] } : {}),
|
|
199
|
+
...(reading.disallowedTools.length > 0 ? { disallowedTools: [...reading.disallowedTools] } : {}),
|
|
913
200
|
...(files.length > 0 ? { files } : {}),
|
|
914
201
|
});
|
|
915
202
|
}
|