wingfoil 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +83 -43
- package/dist/agent/discovery.d.ts +72 -0
- package/dist/agent/discovery.d.ts.map +1 -0
- package/dist/agent/discovery.js +210 -0
- package/dist/agent/discovery.js.map +1 -0
- package/dist/agent/execute.d.ts +206 -0
- package/dist/agent/execute.d.ts.map +1 -0
- package/dist/agent/execute.js +581 -0
- package/dist/agent/execute.js.map +1 -0
- package/dist/agent/index.d.ts +23 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +85 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/launch.d.ts +133 -0
- package/dist/agent/launch.d.ts.map +1 -0
- package/dist/agent/launch.js +380 -0
- package/dist/agent/launch.js.map +1 -0
- package/dist/agent/manifest.d.ts +30 -0
- package/dist/agent/manifest.d.ts.map +1 -0
- package/dist/agent/manifest.js +93 -0
- package/dist/agent/manifest.js.map +1 -0
- package/dist/agent/placeholders.d.ts +49 -0
- package/dist/agent/placeholders.d.ts.map +1 -0
- package/dist/agent/placeholders.js +177 -0
- package/dist/agent/placeholders.js.map +1 -0
- package/dist/agent/run-log.d.ts +254 -0
- package/dist/agent/run-log.d.ts.map +1 -0
- package/dist/agent/run-log.js +612 -0
- package/dist/agent/run-log.js.map +1 -0
- package/dist/agent/schema.d.ts +100 -0
- package/dist/agent/schema.d.ts.map +1 -0
- package/dist/agent/schema.js +89 -0
- package/dist/agent/schema.js.map +1 -0
- package/dist/agent/step.d.ts +41 -0
- package/dist/agent/step.d.ts.map +1 -0
- package/dist/agent/step.js +95 -0
- package/dist/agent/step.js.map +1 -0
- package/dist/build-info.json +4 -0
- package/dist/cli/error.d.ts +11 -2
- package/dist/cli/error.d.ts.map +1 -1
- package/dist/cli/error.js +27 -6
- package/dist/cli/error.js.map +1 -1
- package/dist/cli/exit.d.ts +33 -3
- package/dist/cli/exit.d.ts.map +1 -1
- package/dist/cli/exit.js +54 -3
- package/dist/cli/exit.js.map +1 -1
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +2 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/init-command.d.ts.map +1 -1
- package/dist/cli/init-command.js +4 -2
- package/dist/cli/init-command.js.map +1 -1
- package/dist/cli/mcp-command.d.ts +13 -4
- package/dist/cli/mcp-command.d.ts.map +1 -1
- package/dist/cli/mcp-command.js +25 -8
- package/dist/cli/mcp-command.js.map +1 -1
- package/dist/cli/output.d.ts +12 -4
- package/dist/cli/output.d.ts.map +1 -1
- package/dist/cli/output.js +15 -4
- package/dist/cli/output.js.map +1 -1
- package/dist/cli/program.d.ts +1 -1
- package/dist/cli/program.d.ts.map +1 -1
- package/dist/cli/program.js +162 -40
- package/dist/cli/program.js.map +1 -1
- package/dist/cli/registrar.d.ts +1 -1
- package/dist/cli/registrar.d.ts.map +1 -1
- package/dist/cli/registrar.js +67 -6
- package/dist/cli/registrar.js.map +1 -1
- package/dist/cli/suggest.d.ts +20 -0
- package/dist/cli/suggest.d.ts.map +1 -0
- package/dist/cli/suggest.js +49 -0
- package/dist/cli/suggest.js.map +1 -0
- package/dist/cli/warning.d.ts +26 -0
- package/dist/cli/warning.d.ts.map +1 -0
- package/dist/cli/warning.js +66 -0
- package/dist/cli/warning.js.map +1 -0
- package/dist/cli.js +11 -2
- package/dist/cli.js.map +1 -1
- package/dist/core/agent-execute.d.ts +44 -0
- package/dist/core/agent-execute.d.ts.map +1 -0
- package/dist/core/agent-execute.js +71 -0
- package/dist/core/agent-execute.js.map +1 -0
- package/dist/core/agent-list.d.ts +95 -0
- package/dist/core/agent-list.d.ts.map +1 -0
- package/dist/core/agent-list.js +207 -0
- package/dist/core/agent-list.js.map +1 -0
- package/dist/core/agent-show.d.ts +44 -0
- package/dist/core/agent-show.d.ts.map +1 -0
- package/dist/core/agent-show.js +188 -0
- package/dist/core/agent-show.js.map +1 -0
- package/dist/core/approval-authority.d.ts +17 -14
- package/dist/core/approval-authority.d.ts.map +1 -1
- package/dist/core/approval-authority.js +9 -9
- package/dist/core/approval-authority.js.map +1 -1
- package/dist/core/builtin-asset.d.ts +18 -15
- package/dist/core/builtin-asset.d.ts.map +1 -1
- package/dist/core/builtin-asset.js +17 -14
- package/dist/core/builtin-asset.js.map +1 -1
- package/dist/core/builtin-integrity.d.ts +12 -2
- package/dist/core/builtin-integrity.d.ts.map +1 -1
- package/dist/core/builtin-integrity.js +85 -9
- package/dist/core/builtin-integrity.js.map +1 -1
- package/dist/core/confinement.d.ts +3 -1
- package/dist/core/confinement.d.ts.map +1 -1
- package/dist/core/confinement.js +7 -4
- package/dist/core/confinement.js.map +1 -1
- package/dist/core/context.d.ts +150 -98
- package/dist/core/context.d.ts.map +1 -1
- package/dist/core/context.js +602 -66
- package/dist/core/context.js.map +1 -1
- package/dist/core/directive-assign.d.ts +33 -7
- package/dist/core/directive-assign.d.ts.map +1 -1
- package/dist/core/directive-assign.js +67 -27
- package/dist/core/directive-assign.js.map +1 -1
- package/dist/core/directive-scope.d.ts +36 -0
- package/dist/core/directive-scope.d.ts.map +1 -0
- package/dist/core/directive-scope.js +34 -0
- package/dist/core/directive-scope.js.map +1 -0
- package/dist/core/directives-list.d.ts +13 -3
- package/dist/core/directives-list.d.ts.map +1 -1
- package/dist/core/directives-list.js +18 -6
- package/dist/core/directives-list.js.map +1 -1
- package/dist/core/dry-run.d.ts +33 -0
- package/dist/core/dry-run.d.ts.map +1 -0
- package/dist/core/dry-run.js +45 -0
- package/dist/core/dry-run.js.map +1 -0
- package/dist/core/element-ref.d.ts +23 -0
- package/dist/core/element-ref.d.ts.map +1 -0
- package/dist/core/element-ref.js +24 -0
- package/dist/core/element-ref.js.map +1 -0
- package/dist/core/error-details.d.ts +20 -0
- package/dist/core/error-details.d.ts.map +1 -0
- package/dist/core/error-details.js +65 -0
- package/dist/core/error-details.js.map +1 -0
- package/dist/core/exit-code.d.ts.map +1 -1
- package/dist/core/exit-code.js +6 -7
- package/dist/core/exit-code.js.map +1 -1
- package/dist/core/git-identity.d.ts +46 -11
- package/dist/core/git-identity.d.ts.map +1 -1
- package/dist/core/git-identity.js +140 -27
- package/dist/core/git-identity.js.map +1 -1
- package/dist/core/index.d.ts +184 -10
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1045 -185
- package/dist/core/index.js.map +1 -1
- package/dist/core/init.d.ts +45 -5
- package/dist/core/init.d.ts.map +1 -1
- package/dist/core/init.js +134 -24
- package/dist/core/init.js.map +1 -1
- package/dist/core/loaders.d.ts +170 -14
- package/dist/core/loaders.d.ts.map +1 -1
- package/dist/core/loaders.js +570 -89
- package/dist/core/loaders.js.map +1 -1
- package/dist/core/memory-add-link.d.ts +28 -0
- package/dist/core/memory-add-link.d.ts.map +1 -0
- package/dist/core/memory-add-link.js +67 -0
- package/dist/core/memory-add-link.js.map +1 -0
- package/dist/core/memory-add-type.d.ts +25 -1
- package/dist/core/memory-add-type.d.ts.map +1 -1
- package/dist/core/memory-add-type.js +59 -1
- package/dist/core/memory-add-type.js.map +1 -1
- package/dist/core/memory-amend.d.ts +80 -0
- package/dist/core/memory-amend.d.ts.map +1 -0
- package/dist/core/memory-amend.js +160 -0
- package/dist/core/memory-amend.js.map +1 -0
- package/dist/core/memory-supersede.d.ts +28 -0
- package/dist/core/memory-supersede.d.ts.map +1 -0
- package/dist/core/memory-supersede.js +79 -0
- package/dist/core/memory-supersede.js.map +1 -0
- package/dist/core/memory-transition.d.ts +190 -30
- package/dist/core/memory-transition.d.ts.map +1 -1
- package/dist/core/memory-transition.js +480 -59
- package/dist/core/memory-transition.js.map +1 -1
- package/dist/core/registry.d.ts +82 -10
- package/dist/core/registry.d.ts.map +1 -1
- package/dist/core/registry.js +50 -0
- package/dist/core/registry.js.map +1 -1
- package/dist/core/relevance.d.ts +74 -12
- package/dist/core/relevance.d.ts.map +1 -1
- package/dist/core/relevance.js +45 -27
- package/dist/core/relevance.js.map +1 -1
- package/dist/core/require-reason.d.ts.map +1 -1
- package/dist/core/require-reason.js +6 -5
- package/dist/core/require-reason.js.map +1 -1
- package/dist/core/required-fields.d.ts +28 -0
- package/dist/core/required-fields.d.ts.map +1 -0
- package/dist/core/required-fields.js +60 -0
- package/dist/core/required-fields.js.map +1 -0
- package/dist/core/revision.d.ts +82 -0
- package/dist/core/revision.d.ts.map +1 -0
- package/dist/core/revision.js +144 -0
- package/dist/core/revision.js.map +1 -0
- package/dist/core/types.d.ts +28 -2
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js +12 -3
- package/dist/core/types.js.map +1 -1
- package/dist/core/workflow-core-checks.d.ts +34 -0
- package/dist/core/workflow-core-checks.d.ts.map +1 -0
- package/dist/core/workflow-core-checks.js +403 -0
- package/dist/core/workflow-core-checks.js.map +1 -0
- package/dist/core/workflow-create-remove.d.ts +65 -0
- package/dist/core/workflow-create-remove.d.ts.map +1 -0
- package/dist/core/workflow-create-remove.js +277 -0
- package/dist/core/workflow-create-remove.js.map +1 -0
- package/dist/core/workflow-deduction.d.ts +48 -0
- package/dist/core/workflow-deduction.d.ts.map +1 -0
- package/dist/core/workflow-deduction.js +523 -0
- package/dist/core/workflow-deduction.js.map +1 -0
- package/dist/core/workflow-diagnostics.d.ts +83 -0
- package/dist/core/workflow-diagnostics.d.ts.map +1 -0
- package/dist/core/workflow-diagnostics.js +375 -0
- package/dist/core/workflow-diagnostics.js.map +1 -0
- package/dist/core/workflow-exit-state.d.ts +125 -0
- package/dist/core/workflow-exit-state.d.ts.map +1 -0
- package/dist/core/workflow-exit-state.js +243 -0
- package/dist/core/workflow-exit-state.js.map +1 -0
- package/dist/core/workflow-finalize.d.ts +37 -0
- package/dist/core/workflow-finalize.d.ts.map +1 -0
- package/dist/core/workflow-finalize.js +153 -0
- package/dist/core/workflow-finalize.js.map +1 -0
- package/dist/core/workflow-list-show.d.ts +176 -0
- package/dist/core/workflow-list-show.d.ts.map +1 -0
- package/dist/core/workflow-list-show.js +268 -0
- package/dist/core/workflow-list-show.js.map +1 -0
- package/dist/core/workflow-next.d.ts +268 -0
- package/dist/core/workflow-next.d.ts.map +1 -0
- package/dist/core/workflow-next.js +503 -0
- package/dist/core/workflow-next.js.map +1 -0
- package/dist/core/workflow-registry.d.ts +52 -0
- package/dist/core/workflow-registry.d.ts.map +1 -0
- package/dist/core/workflow-registry.js +158 -0
- package/dist/core/workflow-registry.js.map +1 -0
- package/dist/core/workflow-start-end.d.ts +71 -0
- package/dist/core/workflow-start-end.d.ts.map +1 -0
- package/dist/core/workflow-start-end.js +298 -0
- package/dist/core/workflow-start-end.js.map +1 -0
- package/dist/core/workflow-status.d.ts +83 -0
- package/dist/core/workflow-status.d.ts.map +1 -0
- package/dist/core/workflow-status.js +125 -0
- package/dist/core/workflow-status.js.map +1 -0
- package/dist/core/write-guard.d.ts +51 -8
- package/dist/core/write-guard.d.ts.map +1 -1
- package/dist/core/write-guard.js +139 -9
- package/dist/core/write-guard.js.map +1 -1
- package/dist/directives/index.d.ts +3 -2
- package/dist/directives/index.d.ts.map +1 -1
- package/dist/directives/index.js +5 -3
- package/dist/directives/index.js.map +1 -1
- package/dist/directives/schema.d.ts +34 -29
- package/dist/directives/schema.d.ts.map +1 -1
- package/dist/directives/schema.js +35 -29
- package/dist/directives/schema.js.map +1 -1
- package/dist/directives/version.d.ts +28 -0
- package/dist/directives/version.d.ts.map +1 -0
- package/dist/directives/version.js +51 -0
- package/dist/directives/version.js.map +1 -0
- package/dist/dna/edit.d.ts +7 -6
- package/dist/dna/edit.d.ts.map +1 -1
- package/dist/dna/edit.js +96 -41
- package/dist/dna/edit.js.map +1 -1
- package/dist/dna/mutate.js +18 -3
- package/dist/dna/mutate.js.map +1 -1
- package/dist/dna/path.d.ts +2 -2
- package/dist/dna/roles.d.ts +1 -1
- package/dist/dna/schema.d.ts +61 -3
- package/dist/dna/schema.d.ts.map +1 -1
- package/dist/dna/schema.js +121 -6
- package/dist/dna/schema.js.map +1 -1
- package/dist/mcp/dna-resource.d.ts.map +1 -1
- package/dist/mcp/dna-resource.js +4 -4
- package/dist/mcp/dna-resource.js.map +1 -1
- package/dist/mcp/index.d.ts +8 -4
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +13 -2
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/memory-resource.d.ts.map +1 -1
- package/dist/mcp/memory-resource.js +30 -19
- package/dist/mcp/memory-resource.js.map +1 -1
- package/dist/mcp/prompt.d.ts +61 -24
- package/dist/mcp/prompt.d.ts.map +1 -1
- package/dist/mcp/prompt.js +176 -47
- package/dist/mcp/prompt.js.map +1 -1
- package/dist/mcp/read-only.d.ts +39 -0
- package/dist/mcp/read-only.d.ts.map +1 -1
- package/dist/mcp/read-only.js +61 -0
- package/dist/mcp/read-only.js.map +1 -1
- package/dist/mcp/registrar.d.ts +10 -0
- package/dist/mcp/registrar.d.ts.map +1 -1
- package/dist/mcp/registrar.js +48 -12
- package/dist/mcp/registrar.js.map +1 -1
- package/dist/mcp/server.d.ts +21 -14
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +41 -15
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/session-resource.d.ts +13 -0
- package/dist/mcp/session-resource.d.ts.map +1 -0
- package/dist/mcp/session-resource.js +65 -0
- package/dist/mcp/session-resource.js.map +1 -0
- package/dist/mcp/workflow-resource.d.ts +18 -0
- package/dist/mcp/workflow-resource.d.ts.map +1 -1
- package/dist/mcp/workflow-resource.js +37 -8
- package/dist/mcp/workflow-resource.js.map +1 -1
- package/dist/memory/add.d.ts +110 -24
- package/dist/memory/add.d.ts.map +1 -1
- package/dist/memory/add.js +251 -64
- package/dist/memory/add.js.map +1 -1
- package/dist/memory/audit.d.ts +152 -39
- package/dist/memory/audit.d.ts.map +1 -1
- package/dist/memory/audit.js +257 -103
- package/dist/memory/audit.js.map +1 -1
- package/dist/memory/commit-message.d.ts +60 -38
- package/dist/memory/commit-message.d.ts.map +1 -1
- package/dist/memory/commit-message.js +167 -21
- package/dist/memory/commit-message.js.map +1 -1
- package/dist/memory/entry.d.ts.map +1 -1
- package/dist/memory/entry.js +1 -2
- package/dist/memory/entry.js.map +1 -1
- package/dist/memory/frontmatter-edit.d.ts +16 -4
- package/dist/memory/frontmatter-edit.d.ts.map +1 -1
- package/dist/memory/frontmatter-edit.js +13 -1
- package/dist/memory/frontmatter-edit.js.map +1 -1
- package/dist/memory/git-log.d.ts +18 -6
- package/dist/memory/git-log.d.ts.map +1 -1
- package/dist/memory/git-log.js +40 -13
- package/dist/memory/git-log.js.map +1 -1
- package/dist/memory/history.d.ts +73 -12
- package/dist/memory/history.d.ts.map +1 -1
- package/dist/memory/history.js +128 -44
- package/dist/memory/history.js.map +1 -1
- package/dist/memory/index.d.ts +13 -11
- package/dist/memory/index.d.ts.map +1 -1
- package/dist/memory/index.js +34 -3
- package/dist/memory/index.js.map +1 -1
- package/dist/memory/query.d.ts +161 -19
- package/dist/memory/query.d.ts.map +1 -1
- package/dist/memory/query.js +435 -55
- package/dist/memory/query.js.map +1 -1
- package/dist/memory/schema.d.ts +52 -3
- package/dist/memory/schema.d.ts.map +1 -1
- package/dist/memory/schema.js +132 -8
- package/dist/memory/schema.js.map +1 -1
- package/dist/memory/state-machine.d.ts +65 -10
- package/dist/memory/state-machine.d.ts.map +1 -1
- package/dist/memory/state-machine.js +134 -46
- package/dist/memory/state-machine.js.map +1 -1
- package/dist/memory/submit.d.ts +52 -3
- package/dist/memory/submit.d.ts.map +1 -1
- package/dist/memory/submit.js +118 -11
- package/dist/memory/submit.js.map +1 -1
- package/dist/storage/build-stamp.d.ts +18 -0
- package/dist/storage/build-stamp.d.ts.map +1 -0
- package/dist/storage/build-stamp.js +68 -0
- package/dist/storage/build-stamp.js.map +1 -0
- package/dist/storage/builtin-adapters.d.ts +32 -0
- package/dist/storage/builtin-adapters.d.ts.map +1 -0
- package/dist/storage/builtin-adapters.js +100 -0
- package/dist/storage/builtin-adapters.js.map +1 -0
- package/dist/storage/builtin-directives.d.ts +0 -29
- package/dist/storage/builtin-directives.d.ts.map +1 -1
- package/dist/storage/builtin-directives.js +9 -4
- package/dist/storage/builtin-directives.js.map +1 -1
- package/dist/storage/commit.d.ts +310 -3
- package/dist/storage/commit.d.ts.map +1 -1
- package/dist/storage/commit.js +807 -33
- package/dist/storage/commit.js.map +1 -1
- package/dist/storage/document.d.ts +6 -0
- package/dist/storage/document.d.ts.map +1 -1
- package/dist/storage/document.js +10 -1
- package/dist/storage/document.js.map +1 -1
- package/dist/storage/dry-run.d.ts +65 -0
- package/dist/storage/dry-run.d.ts.map +1 -0
- package/dist/storage/dry-run.js +150 -0
- package/dist/storage/dry-run.js.map +1 -0
- package/dist/storage/errors.d.ts +26 -0
- package/dist/storage/errors.d.ts.map +1 -1
- package/dist/storage/errors.js +27 -1
- package/dist/storage/errors.js.map +1 -1
- package/dist/storage/frontmatter.d.ts +1 -1
- package/dist/storage/frontmatter.js +1 -1
- package/dist/storage/git-read.d.ts +64 -0
- package/dist/storage/git-read.d.ts.map +1 -0
- package/dist/storage/git-read.js +107 -0
- package/dist/storage/git-read.js.map +1 -0
- package/dist/storage/index.d.ts +13 -5
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +39 -2
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/layout.d.ts +2 -2
- package/dist/storage/layout.d.ts.map +1 -1
- package/dist/storage/layout.js +2 -7
- package/dist/storage/layout.js.map +1 -1
- package/dist/storage/memory-path.d.ts +18 -5
- package/dist/storage/memory-path.d.ts.map +1 -1
- package/dist/storage/memory-path.js +41 -5
- package/dist/storage/memory-path.js.map +1 -1
- package/dist/storage/snapshot.js +1 -1
- package/dist/storage/templates.d.ts +33 -6
- package/dist/storage/templates.d.ts.map +1 -1
- package/dist/storage/templates.js +170 -16
- package/dist/storage/templates.js.map +1 -1
- package/dist/validation/config-version.d.ts +19 -0
- package/dist/validation/config-version.d.ts.map +1 -0
- package/dist/validation/config-version.js +53 -0
- package/dist/validation/config-version.js.map +1 -0
- package/dist/validation/diagnostic.d.ts +40 -0
- package/dist/validation/diagnostic.d.ts.map +1 -0
- package/dist/validation/diagnostic.js +41 -0
- package/dist/validation/diagnostic.js.map +1 -0
- package/dist/validation/format.d.ts +74 -0
- package/dist/validation/format.d.ts.map +1 -0
- package/dist/validation/format.js +104 -0
- package/dist/validation/format.js.map +1 -0
- package/dist/validation/id.d.ts +14 -0
- package/dist/validation/id.d.ts.map +1 -1
- package/dist/validation/id.js +35 -11
- package/dist/validation/id.js.map +1 -1
- package/dist/validation/identity.d.ts +40 -0
- package/dist/validation/identity.d.ts.map +1 -0
- package/dist/validation/identity.js +78 -0
- package/dist/validation/identity.js.map +1 -0
- package/dist/validation/index.d.ts +9 -3
- package/dist/validation/index.d.ts.map +1 -1
- package/dist/validation/index.js +30 -1
- package/dist/validation/index.js.map +1 -1
- package/dist/validation/secret-scan.d.ts +3 -2
- package/dist/validation/secret-scan.d.ts.map +1 -1
- package/dist/validation/secret-scan.js +32 -11
- package/dist/validation/secret-scan.js.map +1 -1
- package/dist/validation/warning.d.ts +30 -16
- package/dist/validation/warning.d.ts.map +1 -1
- package/dist/validation/warning.js +74 -7
- package/dist/validation/warning.js.map +1 -1
- package/dist/workflow/bindings.d.ts +152 -0
- package/dist/workflow/bindings.d.ts.map +1 -0
- package/dist/workflow/bindings.js +249 -0
- package/dist/workflow/bindings.js.map +1 -0
- package/dist/workflow/create.d.ts +13 -0
- package/dist/workflow/create.d.ts.map +1 -0
- package/dist/workflow/create.js +41 -0
- package/dist/workflow/create.js.map +1 -0
- package/dist/workflow/deduce.d.ts +400 -0
- package/dist/workflow/deduce.d.ts.map +1 -0
- package/dist/workflow/deduce.js +1109 -0
- package/dist/workflow/deduce.js.map +1 -0
- package/dist/workflow/manifest-edit.d.ts +19 -0
- package/dist/workflow/manifest-edit.d.ts.map +1 -0
- package/dist/workflow/manifest-edit.js +124 -0
- package/dist/workflow/manifest-edit.js.map +1 -0
- package/dist/workflow/schema.d.ts +158 -19
- package/dist/workflow/schema.d.ts.map +1 -1
- package/dist/workflow/schema.js +163 -15
- package/dist/workflow/schema.js.map +1 -1
- package/package.json +18 -8
package/dist/mcp/prompt.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.roleSessionPromptName = roleSessionPromptName;
|
|
4
|
+
exports.promptRequestError = promptRequestError;
|
|
5
|
+
exports.buildSessionContext = buildSessionContext;
|
|
4
6
|
exports.registerRolePrompts = registerRolePrompts;
|
|
5
7
|
/**
|
|
6
8
|
* The role-scoped MCP **Prompts** channel — `{role}-session` prompts that embed the role's assigned
|
|
@@ -19,7 +21,7 @@ exports.registerRolePrompts = registerRolePrompts;
|
|
|
19
21
|
* files and returns text. There is no code path in this module that writes, and it registers no Tool —
|
|
20
22
|
* so Prompts cannot become the agent write path REQ-SEC-05 reserves for validated Tools
|
|
21
23
|
* (`test/mcp/role-prompts.test.ts` asserts both: files byte-for-byte unchanged after a round trip, and
|
|
22
|
-
*
|
|
24
|
+
* no Tools channel declared on a Prompts-only server).
|
|
23
25
|
*
|
|
24
26
|
* **Nothing is re-implemented here.** Role catalogue via `loadDnaYaml`, bindings via `loadRolesYaml`,
|
|
25
27
|
* directive files via `loadDirectives`, and the role → directive resolution itself via
|
|
@@ -33,7 +35,9 @@ exports.registerRolePrompts = registerRolePrompts;
|
|
|
33
35
|
const path_1 = require("path");
|
|
34
36
|
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
35
37
|
const core_1 = require("../core");
|
|
38
|
+
const error_details_1 = require("../core/error-details");
|
|
36
39
|
const storage_1 = require("../storage");
|
|
40
|
+
const read_only_1 = require("./read-only");
|
|
37
41
|
/** spec-004 §3.1's prompt-name suffix: one prompt per role, named `{role}-session`. Module-local —
|
|
38
42
|
* {@link roleSessionPromptName} is the only naming API this channel exposes. */
|
|
39
43
|
const ROLE_PROMPT_NAME_SUFFIX = '-session';
|
|
@@ -46,8 +50,9 @@ function roleSessionPromptName(role) {
|
|
|
46
50
|
return `${role}${ROLE_PROMPT_NAME_SUFFIX}`;
|
|
47
51
|
}
|
|
48
52
|
/**
|
|
49
|
-
* A `prompts/get
|
|
50
|
-
* (-32602, the code the MCP SDK
|
|
53
|
+
* A request refusal — of `prompts/get`, or of the session Resource's read (`./session-resource.ts`, task-236) —
|
|
54
|
+
* whose JSON-RPC error carries `message` **verbatim** with code `InvalidParams` (-32602, the code the MCP SDK
|
|
55
|
+
* itself uses for an unknown prompt name or resource).
|
|
51
56
|
*
|
|
52
57
|
* Deliberately a plain `Error` with a `code`, not the SDK's `McpError`: `McpError`'s constructor
|
|
53
58
|
* prefixes its own message with `MCP error <code>: `, and the SDK serializes `error.message` as-is, so a
|
|
@@ -56,6 +61,82 @@ function roleSessionPromptName(role) {
|
|
|
56
61
|
function promptRequestError(message) {
|
|
57
62
|
return Object.assign(new Error(message), { code: types_js_1.ErrorCode.InvalidParams });
|
|
58
63
|
}
|
|
64
|
+
/** {@link promptRequestError} carrying `details` as `error.data.details` when there are any (spec-004 §3.4). */
|
|
65
|
+
function promptRequestErrorWithDetails(message, details) {
|
|
66
|
+
const error = promptRequestError(message);
|
|
67
|
+
return details.length > 0 ? Object.assign(error, { data: { details } }) : error;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The two optional arguments of every `{role}-session` Prompt (task-195, `spec-016` §2.4, approver
|
|
71
|
+
* ruling R18, spec-004 §3.1): given together, they turn the Prompt into the carrier of the `spec-012` §7
|
|
72
|
+
* execution context for `(role, element, state)`; given neither, the Prompt is the role header and
|
|
73
|
+
* directive blocks it always was.
|
|
74
|
+
*/
|
|
75
|
+
const ROLE_PROMPT_ARGUMENTS = [
|
|
76
|
+
{
|
|
77
|
+
name: 'element',
|
|
78
|
+
description: "the Memory element to build the execution context for, as <type>:<id> (e.g. task:task-042-foo); given together with 'state'",
|
|
79
|
+
required: false,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: 'state',
|
|
83
|
+
description: "the commit the execution context is read at (a sha, as agent execute passes it); given together with 'element'",
|
|
84
|
+
required: false,
|
|
85
|
+
},
|
|
86
|
+
];
|
|
87
|
+
const ROLE_PROMPT_ARGUMENT_NAMES = ROLE_PROMPT_ARGUMENTS.map((argument) => argument.name);
|
|
88
|
+
/**
|
|
89
|
+
* The details of a context refusal that is a failed read: the issues `errorDetails` selects, then the
|
|
90
|
+
* `details.cause` of an absent pillar file (`assembleExecutionContext`), which no `issues` carries.
|
|
91
|
+
*/
|
|
92
|
+
function contextRefusalDetails(error) {
|
|
93
|
+
const cause = error.details?.cause;
|
|
94
|
+
return [...(0, error_details_1.errorDetails)(error), ...(typeof cause === 'string' ? [{ detail: cause }] : [])];
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The execution context for `role`, `element` and `state` (task-195, spec-004 §3.2): `assembleExecutionContext`'s
|
|
98
|
+
* §7 payload, as returned — never re-serialized, and never indexed by its body markers (`bug-265`). `state` is
|
|
99
|
+
* resolved once, here, and the builder reads everything at that sha, so neither a later commit nor an uncommitted
|
|
100
|
+
* edit changes the answer. ONE builder for both carriers: the `{role}-session` Prompt wraps it in `messages`
|
|
101
|
+
* ({@link buildContextPrompt}), the session Resource in `contents` (`./session-resource.ts`, task-236), so the two
|
|
102
|
+
* answer the same bytes for the same arguments.
|
|
103
|
+
*
|
|
104
|
+
* The diagnostics: the directive-resolution warnings (`spec-012` §5.1 order), then the builder's notes (§3 stage
|
|
105
|
+
* order), then the `W_MEMORY_UNREADABLE` lines of the files the scan left out (path order, task-171).
|
|
106
|
+
*
|
|
107
|
+
* Refusals (spec-004 §3.4): a `state` that is not a commit and an element the commit does not hold are request
|
|
108
|
+
* errors, `-32602` — the latter with the unreadable files as `error.data.details`, so a subject that does not parse
|
|
109
|
+
* is not reported as merely absent. Every other refusal is about the repository (an archived subject, one in a
|
|
110
|
+
* newer `format:`, a missing pillar file) and is a failed read, as a failed Resource read is: the core message with
|
|
111
|
+
* its details.
|
|
112
|
+
*/
|
|
113
|
+
function buildSessionContext(root, role, element, state) {
|
|
114
|
+
let sha;
|
|
115
|
+
try {
|
|
116
|
+
sha = (0, core_1.resolveRevision)(root, state);
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
if (error instanceof core_1.RevisionError)
|
|
120
|
+
throw promptRequestError(error.message);
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
const result = (0, core_1.assembleExecutionContext)(root, { role, element, stateRef: sha });
|
|
124
|
+
if (!result.ok) {
|
|
125
|
+
const { error } = result;
|
|
126
|
+
if (error.code === 'NOT_FOUND') {
|
|
127
|
+
const unreadable = error.details?.unreadable;
|
|
128
|
+
throw promptRequestErrorWithDetails(error.message, (0, read_only_1.warningDetails)(Array.isArray(unreadable) ? unreadable : []));
|
|
129
|
+
}
|
|
130
|
+
throw (0, read_only_1.readRefusalError)(error.message, contextRefusalDetails(error));
|
|
131
|
+
}
|
|
132
|
+
const { payload, context, notes } = result.value;
|
|
133
|
+
return { text: payload, warnings: [...context.warnings, ...notes, ...(result.warnings ?? [])] };
|
|
134
|
+
}
|
|
135
|
+
/** The `prompts/get` result for `role` with `element` and `state`: one `user` message, the {@link buildSessionContext} text. */
|
|
136
|
+
function buildContextPrompt(root, role, element, state) {
|
|
137
|
+
const { text, warnings } = buildSessionContext(root, role, element, state);
|
|
138
|
+
return (0, read_only_1.withWarnings)({ messages: [{ role: 'user', content: { type: 'text', text } }] }, warnings);
|
|
139
|
+
}
|
|
59
140
|
/**
|
|
60
141
|
* The P5.2.2 undefined-role refusal, verbatim from `p5-interaction/P5.2.2-mcp-prompts.feature`
|
|
61
142
|
* (Scenario "Error - requesting a prompt for an undefined role"): `no prompt for undefined role '<role>'`.
|
|
@@ -76,10 +157,48 @@ function undefinedRolePromptError(role) {
|
|
|
76
157
|
function readDirectiveBody(root, file) {
|
|
77
158
|
return (0, storage_1.splitFrontmatter)((0, storage_1.readDocument)((0, path_1.join)(root, storage_1.WINGFOIL_DIR, file.path))).body.trim();
|
|
78
159
|
}
|
|
160
|
+
/** An ATX heading line: up to three spaces of indent, one to six `#`, then a space, a tab or the end. */
|
|
161
|
+
const ATX_HEADING = /^( {0,3})(#{1,6})(?=[ \t]|$)/;
|
|
162
|
+
/** A code-fence line: up to three spaces of indent, then three or more backticks or tildes. */
|
|
163
|
+
const CODE_FENCE = /^ {0,3}(`{3,}|~{3,})/;
|
|
164
|
+
/** How many levels a directive body's headings are pushed down inside a prompt (`dl-039` headings 1). */
|
|
165
|
+
const EMBEDDED_HEADING_DEMOTION = 2;
|
|
166
|
+
/**
|
|
167
|
+
* Push every heading of a directive `body` down {@link EMBEDDED_HEADING_DEMOTION} levels, capped at H6
|
|
168
|
+
* (`dl-039` headings 1, spec-004 §3.2). A directive file opens with its own H1, so embedded verbatim
|
|
169
|
+
* under a `## Directive:` block it outranked the block holding it, and every directive after the first
|
|
170
|
+
* read, structurally, as a new top-level section beside `# Role:`. Demoted, the body's H1 becomes an H3
|
|
171
|
+
* under its H2 block, and the prompt's outline matches its nesting.
|
|
172
|
+
*
|
|
173
|
+
* Only ATX headings (`#` … `######`) are rewritten. A line inside a fenced code block (``` or ~~~,
|
|
174
|
+
* closed by a fence of the same character at least as long) is code, not outline, and is left as
|
|
175
|
+
* written — a `# comment` in a shell example stays one. Every other byte is unchanged.
|
|
176
|
+
*/
|
|
177
|
+
function demoteHeadings(body) {
|
|
178
|
+
let fence = null;
|
|
179
|
+
return body
|
|
180
|
+
.split('\n')
|
|
181
|
+
.map((line) => {
|
|
182
|
+
const fenceMatch = CODE_FENCE.exec(line);
|
|
183
|
+
if (fence !== null) {
|
|
184
|
+
const closing = fenceMatch?.[1];
|
|
185
|
+
if (closing !== undefined && closing[0] === fence[0] && closing.length >= fence.length && line.trim() === closing) {
|
|
186
|
+
fence = null;
|
|
187
|
+
}
|
|
188
|
+
return line;
|
|
189
|
+
}
|
|
190
|
+
if (fenceMatch) {
|
|
191
|
+
fence = fenceMatch[1];
|
|
192
|
+
return line;
|
|
193
|
+
}
|
|
194
|
+
return line.replace(ATX_HEADING, (_whole, indent, hashes) => `${indent}${'#'.repeat(Math.min(6, hashes.length + EMBEDDED_HEADING_DEMOTION))}`);
|
|
195
|
+
})
|
|
196
|
+
.join('\n');
|
|
197
|
+
}
|
|
79
198
|
/**
|
|
80
199
|
* Compose the prompt text for `role` from its already-resolved directives — spec-004 §3.2's shape: a
|
|
81
200
|
* `# Role: {role}` header followed by one `## Directive: {id}` block per directive, each carrying that
|
|
82
|
-
* directive's full body.
|
|
201
|
+
* directive's full body with its headings demoted two levels ({@link demoteHeadings}).
|
|
83
202
|
*
|
|
84
203
|
* The heading uses `frontmatter.id`, not `name`: spec-004 §3.2's own example headings read
|
|
85
204
|
* `## Directive: code-quality` / `security-secrets`, which are the `id` values of the real directive
|
|
@@ -87,13 +206,13 @@ function readDirectiveBody(root, file) {
|
|
|
87
206
|
* by id.
|
|
88
207
|
*
|
|
89
208
|
* Block order is `resolveRoleDirectives`' — deduplicated by id and sorted id-ascending per
|
|
90
|
-
* `spec-012-context-loader-relevance-filtering` §5 / REQ-SYS-07
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
209
|
+
* `spec-012-context-loader-relevance-filtering` §5 / REQ-SYS-07. spec-004 §3.2 states the resolution
|
|
210
|
+
* as a *set* (`roles.yaml[R].directives` ∪ `global`) and the order as id-ascending (`dl-039` ordering
|
|
211
|
+
* 1). The choice rests on reusing the one resolver, which keeps REQ-INT-02's "100%" and REQ-STATE-05's
|
|
212
|
+
* disjointness a single guarantee; an own-then-global grouping would be equally deterministic.
|
|
94
213
|
*/
|
|
95
214
|
function composeRolePromptText(role, directives) {
|
|
96
|
-
const blocks = directives.map(({ id, body }) => `## Directive: ${id}\n${body}`);
|
|
215
|
+
const blocks = directives.map(({ id, body }) => `## Directive: ${id}\n${demoteHeadings(body)}`);
|
|
97
216
|
return [`# Role: ${role}`, ...blocks].join('\n\n');
|
|
98
217
|
}
|
|
99
218
|
/**
|
|
@@ -110,55 +229,45 @@ function buildRolePrompt(root, role) {
|
|
|
110
229
|
const { directives } = (0, core_1.resolveRoleDirectives)((0, core_1.loadDirectives)(root), (0, core_1.loadRolesYaml)(root), role);
|
|
111
230
|
const text = composeRolePromptText(role, directives.map((file) => ({ id: file.frontmatter.id, body: readDirectiveBody(root, file) })));
|
|
112
231
|
// MCP's `PromptMessage.role` is the two-value enum `"user" | "assistant"` (the SDK's
|
|
113
|
-
// `PromptMessageSchema`)
|
|
114
|
-
//
|
|
115
|
-
//
|
|
232
|
+
// `PromptMessageSchema`); `user` is the only wire role that can deliver instructional content.
|
|
233
|
+
// spec-004 §3.2's example says so since `dl-039` (role 1) — it used to show an unrepresentable
|
|
234
|
+
// `role: "system"`.
|
|
116
235
|
return { messages: [{ role: 'user', content: { type: 'text', text } }] };
|
|
117
236
|
}
|
|
118
237
|
/**
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
* SDK returns to the client as that request's error — the same way `wingfoil://dna` reports it.
|
|
122
|
-
*/
|
|
123
|
-
function loadRoleNames(root) {
|
|
124
|
-
return (0, core_1.loadDnaYaml)(root).team.roles.map(({ name }) => name);
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Register the role-scoped Prompts channel: one `{role}-session` Prompt per role in `dna.yaml`'s
|
|
128
|
-
* `team.roles` catalogue (spec-004 §3.1), each embedding that role's directives (§3.2), and a refusal
|
|
129
|
-
* for a session prompt naming a role DNA does not declare (P5.2.2's undefined-role scenario).
|
|
130
|
-
*
|
|
131
|
-
* **Nothing is read here — every read happens per request** (task-058 second pass, rejection `ff13321`).
|
|
132
|
-
* spec-014 §2 requires `createMcpServer` to perform "no I/O at construction time beyond wiring
|
|
133
|
-
* handlers", so the DNA role catalogue is loaded inside the `prompts/list` / `prompts/get` handlers,
|
|
134
|
-
* next to the per-request directive resolution spec-004 §3.2 already mandated (REQ-INT-02's "a newly
|
|
135
|
-
* assigned directive appears on the next session start"). Two consequences, both deliberate:
|
|
238
|
+
* Register the role-scoped Prompts channel: one `{role}-session` Prompt per role in `options.roles`
|
|
239
|
+
* (spec-004 §3.1), each embedding that role's directives (§3.2), and the refusals of §3.4.
|
|
136
240
|
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
241
|
+
* **The role set is fixed; the directives are not** (`dl-049` (b), task-174). `options.roles` is the
|
|
242
|
+
* DNA role set `wingfoil mcp` read once, in its pre-flight, before the server started; it is copied
|
|
243
|
+
* here and never re-read, so `prompts/list` and the undefined-role check read nothing, and a role added
|
|
244
|
+
* to `dna.yaml` while the server runs is served after a restart. The Prompts capability is therefore
|
|
245
|
+
* declared without `listChanged`: the list cannot change during a session. What a Prompt *embeds* is
|
|
246
|
+
* still resolved per request — `roles.yaml` and the directive files are read on every `prompts/get`
|
|
247
|
+
* (spec-004 §3.2, REQ-INT-02's "a newly assigned directive appears on the next session start"). This
|
|
248
|
+
* function itself reads nothing, so `createMcpServer` keeps spec-014 §2's "no I/O at construction".
|
|
143
249
|
*
|
|
144
250
|
* **Why the low-level handlers, not `McpServer.registerPrompt`.** The high-level API answers an
|
|
145
251
|
* unregistered name with its own `Prompt <name> not found` before any WingFoil code runs, so the BDD's
|
|
146
|
-
* `no prompt for undefined role 'wizard'` cannot be expressed through it
|
|
147
|
-
*
|
|
148
|
-
* `
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
252
|
+
* `no prompt for undefined role 'wizard'` cannot be expressed through it. This function therefore owns
|
|
253
|
+
* `prompts/list` and `prompts/get` on `server.server` — the same pattern `./read-only.ts`'s
|
|
254
|
+
* `registerWriteRefusalHandler` uses — and a later `registerPrompt` on the same server fails loudly ("A
|
|
255
|
+
* request handler for prompts/list already exists") instead of being silently shadowed. spec-004 §3.4's
|
|
256
|
+
* two refusals, both `-32602`: a `{role}-session` name whose role is not in the set is `no prompt for
|
|
257
|
+
* undefined role '<role>'`; a name that is not `{role}-session`-shaped names no role and keeps the SDK's
|
|
258
|
+
* `Prompt <name> not found`. A read that fails while a Prompt is built carries the loader's details as
|
|
259
|
+
* `error.data.details`, as a failed Resource read does (`withRefusalDetails`, `bug-184`).
|
|
153
260
|
*
|
|
154
261
|
* Call before the server is connected (MCP capabilities cannot be registered after connecting).
|
|
155
262
|
*/
|
|
156
263
|
function registerRolePrompts(server, options) {
|
|
264
|
+
const roles = [...options.roles];
|
|
157
265
|
server.server.registerCapabilities({ prompts: {} });
|
|
158
266
|
server.server.setRequestHandler(types_js_1.ListPromptsRequestSchema, () => ({
|
|
159
|
-
prompts:
|
|
267
|
+
prompts: roles.map((role) => ({
|
|
160
268
|
name: roleSessionPromptName(role),
|
|
161
|
-
description: `session instructions for the '${role}' role, embedding its assigned directives (read-only)`,
|
|
269
|
+
description: `session instructions for the '${role}' role, embedding its assigned directives (read-only); with element and state, the execution context for that element at that commit`,
|
|
270
|
+
arguments: ROLE_PROMPT_ARGUMENTS.map((argument) => ({ ...argument })),
|
|
162
271
|
})),
|
|
163
272
|
}));
|
|
164
273
|
server.server.setRequestHandler(types_js_1.GetPromptRequestSchema, (request) => {
|
|
@@ -167,10 +276,30 @@ function registerRolePrompts(server, options) {
|
|
|
167
276
|
throw promptRequestError(`Prompt ${name} not found`);
|
|
168
277
|
}
|
|
169
278
|
const role = name.slice(0, -ROLE_PROMPT_NAME_SUFFIX.length);
|
|
170
|
-
|
|
171
|
-
if (!loadRoleNames(root).includes(role))
|
|
279
|
+
if (!roles.includes(role))
|
|
172
280
|
throw undefinedRolePromptError(role);
|
|
173
|
-
|
|
281
|
+
// task-195: the two optional arguments (spec-004 §3.1); an unknown name is refused rather than
|
|
282
|
+
// ignored, so a misspelt `State` never falls back to the argument-less Prompt. Sorted: the first
|
|
283
|
+
// unknown name reported does not depend on the client's key order (REQ-SYS-07).
|
|
284
|
+
const args = request.params.arguments ?? {};
|
|
285
|
+
const unknown = Object.keys(args).sort().find((key) => !ROLE_PROMPT_ARGUMENT_NAMES.includes(key));
|
|
286
|
+
if (unknown !== undefined) {
|
|
287
|
+
throw promptRequestError(`unknown prompt argument '${unknown}': '${name}' takes only 'element' and 'state'`);
|
|
288
|
+
}
|
|
289
|
+
// An empty string is an absent argument (spec-004 §3.1): a client that submits every declared
|
|
290
|
+
// field sends `""` for the ones its user left blank.
|
|
291
|
+
const element = args.element === '' ? undefined : args.element;
|
|
292
|
+
const state = args.state === '' ? undefined : args.state;
|
|
293
|
+
if (element === undefined && state === undefined) {
|
|
294
|
+
return (0, read_only_1.withRefusalDetails)(() => buildRolePrompt(options.resolveRoot(), role));
|
|
295
|
+
}
|
|
296
|
+
if (element === undefined || state === undefined) {
|
|
297
|
+
throw promptRequestError(`prompt arguments 'element' and 'state' go together: '${element === undefined ? 'element' : 'state'}' is missing`);
|
|
298
|
+
}
|
|
299
|
+
const ref = (0, core_1.parseElementRef)(element);
|
|
300
|
+
if (!ref.ok)
|
|
301
|
+
throw promptRequestError(ref.error.message);
|
|
302
|
+
return (0, read_only_1.withRefusalDetails)(() => buildContextPrompt(options.resolveRoot(), role, ref.value, state));
|
|
174
303
|
});
|
|
175
304
|
}
|
|
176
305
|
//# sourceMappingURL=prompt.js.map
|
package/dist/mcp/prompt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../src/mcp/prompt.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../src/mcp/prompt.ts"],"names":[],"mappings":";;AAyEA,sDAEC;AAWD,gDAEC;AAgED,kDAmBC;AAuJD,kDAyCC;AA3WD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,+BAA4B;AAG5B,iEAAiH;AAGjH,kCAQiB;AAEjB,yDAAuE;AACvE,wCAA0E;AAE1E,2CAAiG;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AI,CAAC,KAAK,CAAC;QACzD,IAAI,OAAO,KAAK,SAAS,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACjD,OAAO,IAAA,8BAAkB,EAAC,GAAG,EAAE,CAAC,eAAe,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC;QAChF,CAAC;QACD,IAAI,OAAO,KAAK,SAAS,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACjD,MAAM,kBAAkB,CACtB,wDAAwD,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,cAAc,CAClH,CAAC;QACJ,CAAC;QACD,MAAM,GAAG,GAAG,IAAA,sBAAe,EAAC,OAAO,CAAC,CAAC;QACrC,IAAI,CAAC,GAAG,CAAC,EAAE;YAAE,MAAM,kBAAkB,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACzD,OAAO,IAAA,8BAAkB,EAAC,GAAG,EAAE,CAAC,kBAAkB,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;IACrG,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/mcp/read-only.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { type ErrorDetail } from '../core/error-details';
|
|
3
|
+
import type { CoreResult } from '../core/types';
|
|
2
4
|
/** spec-004 §2.3's exact, verbatim write-refusal string. */
|
|
3
5
|
export declare const WRITE_REFUSAL_MESSAGE = "resources are read-only";
|
|
4
6
|
/**
|
|
@@ -16,6 +18,33 @@ export declare function refuseIfWriteIntent(meta: Record<string, unknown> | unde
|
|
|
16
18
|
/** spec-004 §2.2's "resource not found" shape — distinct wording from the write refusal above, per
|
|
17
19
|
* the BDD scenario (`P5.2.1-mcp-resources.feature`) `resource not found: {identifier}` format. */
|
|
18
20
|
export declare function resourceNotFoundError(identifier: string): Error;
|
|
21
|
+
/**
|
|
22
|
+
* A failed read's JSON-RPC error: `message` as its text and, when there are any, the refusal's
|
|
23
|
+
* operator-facing `details` as `error.data.details` (spec-004 §4.3 item 4; task-130, `dl-055` option 1).
|
|
24
|
+
* The SDK forwards an `Error`'s `data` as the JSON-RPC `error.data`. No details, no `data` — the shape
|
|
25
|
+
* a refusal always had. Shared by the core-derived Resources (`./registrar.ts`) and the bespoke ones.
|
|
26
|
+
*/
|
|
27
|
+
export declare function readRefusalError(message: string, details: readonly ErrorDetail[]): Error;
|
|
28
|
+
/**
|
|
29
|
+
* Run a Resource or Prompt read, and give a loader refusal it throws the same details the CLI prints
|
|
30
|
+
* (task-174, `bug-184`). The handlers registered here call the pillar loaders directly, not through a
|
|
31
|
+
* `CoreOperation`, so a refusal reached the client without the `error.data` `./registrar.ts` gives
|
|
32
|
+
* one. The thrown error is mapped once, by core's own `coreErrorOf`; one that carries details is
|
|
33
|
+
* re-thrown as {@link readRefusalError} with its message unchanged, and anything else — a refusal with
|
|
34
|
+
* no details, a write refusal, a "resource not found", a programmer bug — is re-thrown as it was.
|
|
35
|
+
*/
|
|
36
|
+
export declare function withRefusalDetails<T>(read: () => T | Promise<T>): Promise<T>;
|
|
37
|
+
/**
|
|
38
|
+
* `result` with the read's diagnostics as a top-level `warnings` array (task-195, `bug-231`,
|
|
39
|
+
* spec-004 §2.2 / §3.2): the read-only twin of a Tool's `structuredContent.warnings` (§4.3 item 5).
|
|
40
|
+
* MCP's result objects are loose (the SDK's `ResultSchema` is a `looseObject`), so the field reaches
|
|
41
|
+
* the client beside `contents` or `messages`. No warnings, no field — the shape a read always had.
|
|
42
|
+
*/
|
|
43
|
+
export declare function withWarnings<T extends object>(result: T, warnings: readonly string[]): T & {
|
|
44
|
+
warnings?: string[];
|
|
45
|
+
};
|
|
46
|
+
/** One `error.data.details` entry per diagnostic line (`{detail}`), as {@link readRefusalError} carries them. */
|
|
47
|
+
export declare function warningDetails(warnings: readonly string[]): ErrorDetail[];
|
|
19
48
|
/**
|
|
20
49
|
* The `ReadResourceResult` shape every JSON-bodied Resource in `memory-resource.ts` (collection
|
|
21
50
|
* listing), `dna-resource.ts`, and `workflow-resource.ts` returns — one `contents[]` entry,
|
|
@@ -31,6 +60,16 @@ export declare function jsonResourceResult(uri: URL, value: unknown): {
|
|
|
31
60
|
text: string;
|
|
32
61
|
}];
|
|
33
62
|
};
|
|
63
|
+
/**
|
|
64
|
+
* A core operation's result as a JSON-bodied Resource read (task-239): its value as {@link jsonResourceResult}'s
|
|
65
|
+
* `text` — the bytes the CLI's `--format json` prints, without the final newline — with its warnings beside
|
|
66
|
+
* `contents` ({@link withWarnings}); a `CoreResult.error` is thrown as the failed read
|
|
67
|
+
* {@link readRefusalError} builds, with the CLI's message and details (spec-004 §4.3 item 4). The registrar's
|
|
68
|
+
* derived Resources (`./registrar.ts`) shape theirs the same way.
|
|
69
|
+
*/
|
|
70
|
+
export declare function coreResultResource(uri: URL, result: CoreResult<unknown>): ReturnType<typeof jsonResourceResult> & {
|
|
71
|
+
warnings?: string[];
|
|
72
|
+
};
|
|
34
73
|
/**
|
|
35
74
|
* Install the `resources/write` refusal (see module doc, case 1). MCP's own protocol does not define
|
|
36
75
|
* `resources/write` at all — no client capability or built-in handler exists for it — so this method
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-only.d.ts","sourceRoot":"","sources":["../../src/mcp/read-only.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"read-only.d.ts","sourceRoot":"","sources":["../../src/mcp/read-only.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE,OAAO,EAAgB,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,KAAK,EAAE,UAAU,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,CAAC,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,GAAG;IAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAGzI;AAUD;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAInE"}
|
package/dist/mcp/read-only.js
CHANGED
|
@@ -3,7 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.WRITE_INTENT_META_KEY = exports.WRITE_REFUSAL_MESSAGE = void 0;
|
|
4
4
|
exports.refuseIfWriteIntent = refuseIfWriteIntent;
|
|
5
5
|
exports.resourceNotFoundError = resourceNotFoundError;
|
|
6
|
+
exports.readRefusalError = readRefusalError;
|
|
7
|
+
exports.withRefusalDetails = withRefusalDetails;
|
|
8
|
+
exports.withWarnings = withWarnings;
|
|
9
|
+
exports.warningDetails = warningDetails;
|
|
6
10
|
exports.jsonResourceResult = jsonResourceResult;
|
|
11
|
+
exports.coreResultResource = coreResultResource;
|
|
7
12
|
exports.registerWriteRefusalHandler = registerWriteRefusalHandler;
|
|
8
13
|
/**
|
|
9
14
|
* Shared conventions for every bespoke Resource this task registers (`memory-resource`,
|
|
@@ -29,6 +34,8 @@ exports.registerWriteRefusalHandler = registerWriteRefusalHandler;
|
|
|
29
34
|
* bespoke read handler before it does anything else.
|
|
30
35
|
*/
|
|
31
36
|
const zod_1 = require("zod");
|
|
37
|
+
const core_1 = require("../core");
|
|
38
|
+
const error_details_1 = require("../core/error-details");
|
|
32
39
|
/** spec-004 §2.3's exact, verbatim write-refusal string. */
|
|
33
40
|
exports.WRITE_REFUSAL_MESSAGE = 'resources are read-only';
|
|
34
41
|
/**
|
|
@@ -52,6 +59,48 @@ function refuseIfWriteIntent(meta) {
|
|
|
52
59
|
function resourceNotFoundError(identifier) {
|
|
53
60
|
return new Error(`resource not found: ${identifier}`);
|
|
54
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* A failed read's JSON-RPC error: `message` as its text and, when there are any, the refusal's
|
|
64
|
+
* operator-facing `details` as `error.data.details` (spec-004 §4.3 item 4; task-130, `dl-055` option 1).
|
|
65
|
+
* The SDK forwards an `Error`'s `data` as the JSON-RPC `error.data`. No details, no `data` — the shape
|
|
66
|
+
* a refusal always had. Shared by the core-derived Resources (`./registrar.ts`) and the bespoke ones.
|
|
67
|
+
*/
|
|
68
|
+
function readRefusalError(message, details) {
|
|
69
|
+
return details.length > 0 ? Object.assign(new Error(message), { data: { details } }) : new Error(message);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Run a Resource or Prompt read, and give a loader refusal it throws the same details the CLI prints
|
|
73
|
+
* (task-174, `bug-184`). The handlers registered here call the pillar loaders directly, not through a
|
|
74
|
+
* `CoreOperation`, so a refusal reached the client without the `error.data` `./registrar.ts` gives
|
|
75
|
+
* one. The thrown error is mapped once, by core's own `coreErrorOf`; one that carries details is
|
|
76
|
+
* re-thrown as {@link readRefusalError} with its message unchanged, and anything else — a refusal with
|
|
77
|
+
* no details, a write refusal, a "resource not found", a programmer bug — is re-thrown as it was.
|
|
78
|
+
*/
|
|
79
|
+
async function withRefusalDetails(read) {
|
|
80
|
+
try {
|
|
81
|
+
return await read();
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
const refusal = (0, core_1.coreErrorOf)(error);
|
|
85
|
+
const details = refusal === null ? [] : (0, error_details_1.errorDetails)(refusal);
|
|
86
|
+
if (refusal === null || details.length === 0)
|
|
87
|
+
throw error;
|
|
88
|
+
throw readRefusalError(refusal.message, details);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* `result` with the read's diagnostics as a top-level `warnings` array (task-195, `bug-231`,
|
|
93
|
+
* spec-004 §2.2 / §3.2): the read-only twin of a Tool's `structuredContent.warnings` (§4.3 item 5).
|
|
94
|
+
* MCP's result objects are loose (the SDK's `ResultSchema` is a `looseObject`), so the field reaches
|
|
95
|
+
* the client beside `contents` or `messages`. No warnings, no field — the shape a read always had.
|
|
96
|
+
*/
|
|
97
|
+
function withWarnings(result, warnings) {
|
|
98
|
+
return warnings.length > 0 ? { ...result, warnings: [...warnings] } : result;
|
|
99
|
+
}
|
|
100
|
+
/** One `error.data.details` entry per diagnostic line (`{detail}`), as {@link readRefusalError} carries them. */
|
|
101
|
+
function warningDetails(warnings) {
|
|
102
|
+
return warnings.map((detail) => ({ detail }));
|
|
103
|
+
}
|
|
55
104
|
/**
|
|
56
105
|
* The `ReadResourceResult` shape every JSON-bodied Resource in `memory-resource.ts` (collection
|
|
57
106
|
* listing), `dna-resource.ts`, and `workflow-resource.ts` returns — one `contents[]` entry,
|
|
@@ -71,6 +120,18 @@ function jsonResourceResult(uri, value) {
|
|
|
71
120
|
],
|
|
72
121
|
};
|
|
73
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* A core operation's result as a JSON-bodied Resource read (task-239): its value as {@link jsonResourceResult}'s
|
|
125
|
+
* `text` — the bytes the CLI's `--format json` prints, without the final newline — with its warnings beside
|
|
126
|
+
* `contents` ({@link withWarnings}); a `CoreResult.error` is thrown as the failed read
|
|
127
|
+
* {@link readRefusalError} builds, with the CLI's message and details (spec-004 §4.3 item 4). The registrar's
|
|
128
|
+
* derived Resources (`./registrar.ts`) shape theirs the same way.
|
|
129
|
+
*/
|
|
130
|
+
function coreResultResource(uri, result) {
|
|
131
|
+
if (!result.ok)
|
|
132
|
+
throw readRefusalError(result.error.message, (0, error_details_1.errorDetails)(result.error));
|
|
133
|
+
return withWarnings(jsonResourceResult(uri, result.value), result.warnings ?? []);
|
|
134
|
+
}
|
|
74
135
|
/** The raw JSON-RPC shape of an (unsupported) `resources/write` request — just enough to extract the
|
|
75
136
|
* method literal `setRequestHandler` needs; `params` is never inspected, since every call is refused
|
|
76
137
|
* unconditionally regardless of its payload. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-only.js","sourceRoot":"","sources":["../../src/mcp/read-only.ts"],"names":[],"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CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC;AACpF,CAAC;AAED;;gDAEgD;AAChD,MAAM,2BAA2B,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3C,MAAM,EAAE,OAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC;IACpC,MAAM,EAAE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE;CACrD,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,SAAgB,2BAA2B,CAAC,MAAiB;IAC3D,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,2BAA2B,EAAE,KAAK,IAAI,EAAE;QACtE,MAAM,IAAI,KAAK,CAAC,6BAAqB,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/mcp/registrar.d.ts
CHANGED
|
@@ -49,6 +49,16 @@ export declare function deriveMcpResourceUri(moduleName: string, verb: string):
|
|
|
49
49
|
* response (spec-004 §4.3's "rejected identically to the CLI path") or, for a Resource read (which
|
|
50
50
|
* has no `isError` flag in the MCP protocol), a thrown error surfaced as a protocol-level read
|
|
51
51
|
* failure (spec-004 §2.2's "resource not found"-style refusal, generalized to any read failure).
|
|
52
|
+
* Either way the error's operator-facing details (`../core/error-details.ts`) travel with it — as the
|
|
53
|
+
* read error's JSON-RPC `error.data.details`, or as the tool result's `structuredContent` (task-130).
|
|
54
|
+
* A successful Tool result carries the operation's `CoreResult.warnings`, when it has any, as
|
|
55
|
+
* `structuredContent: {value, warnings}` (task-169). A successful Resource read carries them as a
|
|
56
|
+
* top-level `warnings` array beside `contents` (task-195, `bug-231`: since task-171 a read-only scan does
|
|
57
|
+
* report the documents it left out). Note that the shipped
|
|
58
|
+
* `wingfoil mcp` server (`./server.ts`) does not call this function and registers no Tools (P5.2.3,
|
|
59
|
+
* v0.4), so the Tool warning field is reachable only where this registrar is used; when Tools ship,
|
|
60
|
+
* `directive.assign` and the four `dna` write Tools (task-193) also need `force` as a Tool input
|
|
61
|
+
* (`spec-004` §4.3).
|
|
52
62
|
*/
|
|
53
63
|
export declare function registerCoreModules(server: McpServer, modules: readonly CoreModule[], options: RegisterCoreModulesOptions): void;
|
|
54
64
|
//# sourceMappingURL=registrar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registrar.d.ts","sourceRoot":"","sources":["../../src/mcp/registrar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"registrar.d.ts","sourceRoot":"","sources":["../../src/mcp/registrar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAIzE,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAKlE,wIAAwI;AACxI,MAAM,WAAW,0BAA0B;IACzC,+GAA+G;IAC/G,QAAQ,CAAC,WAAW,EAAE,MAAM,MAAM,CAAC;IACnC,iHAAiH;IACjH,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC;CACrC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE1E;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE7E;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,SAAS,UAAU,EAAE,EAC9B,OAAO,EAAE,0BAA0B,GAClC,IAAI,CA0EN"}
|