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
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.machineStates = machineStates;
|
|
4
|
+
exports.iterationStartState = iterationStartState;
|
|
5
|
+
exports.workflowExitStates = workflowExitStates;
|
|
6
|
+
const state_machine_1 = require("../memory/state-machine");
|
|
7
|
+
const bindings_1 = require("../workflow/bindings");
|
|
8
|
+
const schema_1 = require("../workflow/schema");
|
|
9
|
+
/** The machine of `type`, or `null` when `memory.yaml` does not register it (that is a separate diagnostic). */
|
|
10
|
+
function machineOf(memoryYaml, type) {
|
|
11
|
+
return Object.prototype.hasOwnProperty.call(memoryYaml.types, type) ? (0, state_machine_1.resolveStateMachine)(memoryYaml, type) : null;
|
|
12
|
+
}
|
|
13
|
+
/** Every state an element of a type can be in: its `sequence`, its reject and return targets, and `deprecated`. */
|
|
14
|
+
function machineStates(machine) {
|
|
15
|
+
const states = new Set(machine.sequence);
|
|
16
|
+
for (const gate of Object.values(machine.gates ?? {}))
|
|
17
|
+
states.add(gate.reject);
|
|
18
|
+
for (const target of Object.values(machine.returns ?? {}))
|
|
19
|
+
states.add(target);
|
|
20
|
+
states.add(state_machine_1.DEPRECATED_STATE);
|
|
21
|
+
return states;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The state an element enters a workflow run under `iterate_over` in (`spec-017` §4.4): the
|
|
25
|
+
* lowest-`sequence` value of the governing `where.status`, otherwise the type's first state. `null`
|
|
26
|
+
* when `memory.yaml` does not register `type`.
|
|
27
|
+
*/
|
|
28
|
+
function iterationStartState(memoryYaml, type, where) {
|
|
29
|
+
const machine = machineOf(memoryYaml, type);
|
|
30
|
+
if (!machine)
|
|
31
|
+
return null;
|
|
32
|
+
const raw = where?.['status'];
|
|
33
|
+
const statuses = (Array.isArray(raw) ? raw : raw === undefined ? [] : [raw]).map(String);
|
|
34
|
+
const positions = statuses.map((status) => machine.sequence.indexOf(status)).filter((index) => index !== -1);
|
|
35
|
+
return machine.sequence[positions.length > 0 ? Math.min(...positions) : 0]; // a sequence is never empty (spec-001)
|
|
36
|
+
}
|
|
37
|
+
/** The first state of `type`, or `null` for an unregistered type. */
|
|
38
|
+
function firstState(memoryYaml, type) {
|
|
39
|
+
return machineOf(memoryYaml, type)?.sequence[0] ?? null;
|
|
40
|
+
}
|
|
41
|
+
/** An untyped Memory verb token's transition, or `null` for any other token. */
|
|
42
|
+
const UNTYPED_VERBS = {
|
|
43
|
+
'memory.submit': 'submit',
|
|
44
|
+
'memory.approve': 'approve',
|
|
45
|
+
'memory.reject': 'reject',
|
|
46
|
+
'memory.deprecate': 'deprecate',
|
|
47
|
+
};
|
|
48
|
+
/** The `s` of `….set_state(s)`, unquoted, or `null`. */
|
|
49
|
+
function setStateArgument(token) {
|
|
50
|
+
const match = /\(\s*["']?([^"'()\s]+)["']?\s*\)/.exec(token);
|
|
51
|
+
return match ? match[1] : null;
|
|
52
|
+
}
|
|
53
|
+
/** A selection's types and statuses, each a list (`spec-003` § "Selections"). */
|
|
54
|
+
function asList(value) {
|
|
55
|
+
if (value === undefined)
|
|
56
|
+
return [];
|
|
57
|
+
return (Array.isArray(value) ? value : [value]).map(String);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The exit states of every phase of `workflow` (`spec-017` §4.4), in declared order.
|
|
61
|
+
*
|
|
62
|
+
* A plain `include:` phase runs the included workflow on the same element (§4.5) — found by name in
|
|
63
|
+
* `workflows` — and leaves the element in the state the included workflow's last phase leaves it in.
|
|
64
|
+
* An `iterate_over` phase runs its sub on other elements: the bound element's state is unchanged.
|
|
65
|
+
*
|
|
66
|
+
* @param workflow - The workflow whose phases are computed.
|
|
67
|
+
* @param memoryYaml - The `memory.yaml` the machines come from.
|
|
68
|
+
* @param start - The bound element's type and state at the first phase.
|
|
69
|
+
* @param workflows - The registry, by name, a plain `include:` is resolved in (default: none).
|
|
70
|
+
*/
|
|
71
|
+
function workflowExitStates(workflow, memoryYaml, start, workflows = new Map()) {
|
|
72
|
+
return compute(workflow, memoryYaml, start, workflows, new Set([workflow.name]));
|
|
73
|
+
}
|
|
74
|
+
function compute(workflow, memoryYaml, start, workflows, visiting) {
|
|
75
|
+
const creating = start.instance && start.boundType === null && workflow.element === undefined && (0, schema_1.workflowFacts)(workflow).startable
|
|
76
|
+
? workflow.phases.findIndex((phase) => (phase.actions ?? []).some((action) => (0, bindings_1.tokenName)(action) === 'memory.add'))
|
|
77
|
+
: -1;
|
|
78
|
+
let bound = start.boundType === null ? null : { type: start.boundType, action: -1, state: start.state };
|
|
79
|
+
// The elements created by earlier phases of this pass, the targets of a typed `<T>.set_state`.
|
|
80
|
+
const earlier = [];
|
|
81
|
+
const out = [];
|
|
82
|
+
workflow.phases.forEach((phase, p) => {
|
|
83
|
+
const entry = bound?.state ?? null;
|
|
84
|
+
const held = [];
|
|
85
|
+
const created = [];
|
|
86
|
+
const run = new Set();
|
|
87
|
+
let undetermined = null;
|
|
88
|
+
const hold = (type, gate, reject) => {
|
|
89
|
+
if (!held.some((h) => h.type === type && h.gate === gate))
|
|
90
|
+
held.push({ type, gate, reject });
|
|
91
|
+
};
|
|
92
|
+
/** Apply one transition to `target`, recording the first refusal and the gates it holds. */
|
|
93
|
+
const apply = (target, action, op) => {
|
|
94
|
+
const machine = machineOf(memoryYaml, target.type);
|
|
95
|
+
if (!machine)
|
|
96
|
+
return; // an unregistered type is E_WORKFLOW_ELEMENT_TYPE_UNKNOWN's, not this
|
|
97
|
+
const from = target.state;
|
|
98
|
+
const refuse = (reason) => {
|
|
99
|
+
undetermined ??= { action, type: target.type, from, reason };
|
|
100
|
+
target.state = null;
|
|
101
|
+
};
|
|
102
|
+
if (typeof op === 'object') {
|
|
103
|
+
const to = op.setState;
|
|
104
|
+
if (!machineStates(machine).has(to))
|
|
105
|
+
return refuse(`'${to}' is not a state of ${target.type}`);
|
|
106
|
+
if (from !== null) {
|
|
107
|
+
const fromIndex = machine.sequence.indexOf(from);
|
|
108
|
+
const toIndex = machine.sequence.indexOf(to);
|
|
109
|
+
if (fromIndex !== -1 && toIndex !== -1 && toIndex <= fromIndex) {
|
|
110
|
+
return refuse(`'${to}' does not lie after '${from}' in ${target.type}'s sequence`);
|
|
111
|
+
}
|
|
112
|
+
const gate = machine.gates?.[from];
|
|
113
|
+
if (gate && fromIndex !== -1 && machine.sequence[fromIndex + 1] === to)
|
|
114
|
+
hold(target.type, from, gate.reject);
|
|
115
|
+
}
|
|
116
|
+
target.state = to;
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (from === null) {
|
|
120
|
+
if (op === 'deprecate')
|
|
121
|
+
target.state = state_machine_1.DEPRECATED_STATE;
|
|
122
|
+
else
|
|
123
|
+
refuse('the state it starts from is undetermined');
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
let to;
|
|
127
|
+
try {
|
|
128
|
+
to = (0, state_machine_1.resolveTransitionTarget)(machine, from, op);
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
// `resolveTransitionTarget` refuses only with an `E_INVALID_TRANSITION` ValidationError.
|
|
132
|
+
return refuse(error.issues[0].message);
|
|
133
|
+
}
|
|
134
|
+
const leftGate = machine.gates?.[from];
|
|
135
|
+
if ((op === 'approve' || op === 'reject') && leftGate)
|
|
136
|
+
hold(target.type, from, leftGate.reject);
|
|
137
|
+
const enteredGate = machine.gates?.[to];
|
|
138
|
+
if (op === 'submit' && enteredGate)
|
|
139
|
+
hold(target.type, to, enteredGate.reject);
|
|
140
|
+
target.state = to;
|
|
141
|
+
};
|
|
142
|
+
if (phase.include !== undefined) {
|
|
143
|
+
const sub = workflows.get(phase.include);
|
|
144
|
+
if (phase.iterate_over === undefined && sub && !visiting.has(sub.name)) {
|
|
145
|
+
const subType = sub.element ?? bound?.type ?? null;
|
|
146
|
+
const sameElement = bound !== null && subType === bound.type;
|
|
147
|
+
const subStates = compute(sub, memoryYaml, { boundType: subType, state: sameElement ? bound.state : subType === null ? null : firstState(memoryYaml, subType), instance: false }, workflows, new Set([...visiting, sub.name]));
|
|
148
|
+
const last = subStates[subStates.length - 1];
|
|
149
|
+
if (sameElement && last)
|
|
150
|
+
bound.state = last.exit;
|
|
151
|
+
}
|
|
152
|
+
out.push({ phase: phase.name, boundType: bound?.type ?? null, entry, exit: bound?.state ?? null, undetermined: null, created: [], run: [], held: [], actionStates: [] });
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const selection = phase.where !== undefined && phase.iterate_over === undefined;
|
|
156
|
+
let latest = null;
|
|
157
|
+
let actsOnSelection = false;
|
|
158
|
+
// `<T>.set_state(s)` on the selection (§4.2 last fallback): the `(T, s)` pairs, in action order.
|
|
159
|
+
const selectionSets = [];
|
|
160
|
+
const actionStates = [];
|
|
161
|
+
(phase.actions ?? []).forEach((action, a) => {
|
|
162
|
+
actionStates.push(bound?.state ?? null);
|
|
163
|
+
const name = (0, bindings_1.tokenName)(action);
|
|
164
|
+
if (name === 'memory.add') {
|
|
165
|
+
const type = (0, bindings_1.memoryAddType)(action);
|
|
166
|
+
if (type === null)
|
|
167
|
+
return;
|
|
168
|
+
const element = { type, action: a, state: firstState(memoryYaml, type) };
|
|
169
|
+
created.push(element);
|
|
170
|
+
latest = element;
|
|
171
|
+
if (p === creating && bound === null)
|
|
172
|
+
bound = element;
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
const verb = UNTYPED_VERBS[name];
|
|
176
|
+
const untypedSet = name === 'element.set_state';
|
|
177
|
+
if (verb !== undefined || untypedSet) {
|
|
178
|
+
const op = untypedSet ? { setState: setStateArgument(action) ?? '' } : verb;
|
|
179
|
+
if (latest)
|
|
180
|
+
apply(latest, a, op);
|
|
181
|
+
else if (selection)
|
|
182
|
+
actsOnSelection = true;
|
|
183
|
+
else if (bound)
|
|
184
|
+
apply(bound, a, op);
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
const typed = /^([a-z][a-z0-9-]*)\.set_state$/.exec(name);
|
|
188
|
+
if (typed) {
|
|
189
|
+
const type = typed[1];
|
|
190
|
+
const op = { setState: setStateArgument(action) ?? '' };
|
|
191
|
+
if (bound && bound.type === type) {
|
|
192
|
+
apply(bound, a, op);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
const earlierOfType = earlier.filter((candidate) => candidate.type === type);
|
|
196
|
+
for (const element of earlierOfType) {
|
|
197
|
+
apply(element, a, op);
|
|
198
|
+
run.add(element);
|
|
199
|
+
}
|
|
200
|
+
if (earlierOfType.length === 0 && selection && asList(phase.where['type']).includes(type)) {
|
|
201
|
+
selectionSets.push({ type, to: op.setState });
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
if (selection && actsOnSelection) {
|
|
206
|
+
const statuses = asList(phase.where['status']);
|
|
207
|
+
for (const type of asList(phase.where['type'])) {
|
|
208
|
+
const machine = machineOf(memoryYaml, type);
|
|
209
|
+
if (!machine)
|
|
210
|
+
continue;
|
|
211
|
+
for (const status of statuses) {
|
|
212
|
+
const gate = machine.gates?.[status];
|
|
213
|
+
if (gate)
|
|
214
|
+
hold(type, status, gate.reject);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
for (const { type, to } of selectionSets) {
|
|
219
|
+
const machine = machineOf(memoryYaml, type);
|
|
220
|
+
if (!machine)
|
|
221
|
+
continue;
|
|
222
|
+
for (const status of asList(phase.where['status'])) {
|
|
223
|
+
const gate = machine.gates?.[status];
|
|
224
|
+
if (gate && machine.sequence[machine.sequence.indexOf(status) + 1] === to)
|
|
225
|
+
hold(type, status, gate.reject);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
earlier.push(...created.filter((element) => element !== bound));
|
|
229
|
+
out.push({
|
|
230
|
+
phase: phase.name,
|
|
231
|
+
boundType: bound?.type ?? null,
|
|
232
|
+
entry,
|
|
233
|
+
exit: bound?.state ?? null,
|
|
234
|
+
undetermined,
|
|
235
|
+
created: created.map((element) => ({ type: element.type, action: element.action, state: element.state })),
|
|
236
|
+
run: [...run].map((element) => ({ type: element.type, action: element.action, state: element.state })),
|
|
237
|
+
held,
|
|
238
|
+
actionStates,
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
return out;
|
|
242
|
+
}
|
|
243
|
+
//# sourceMappingURL=workflow-exit-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-exit-state.js","sourceRoot":"","sources":["../../src/core/workflow-exit-state.ts"],"names":[],"mappings":";;AA6HA,sCAMC;AAOD,kDAOC;AAuCD,gDAOC;AA7JD,2DAA4H;AAG5H,mDAAgE;AAChE,+CAAkE;AAiFlE,gHAAgH;AAChH,SAAS,SAAS,CAAC,UAAsB,EAAE,IAAY;IACrD,OAAO,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAA,mCAAmB,EAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACrH,CAAC;AAED,mHAAmH;AACnH,SAAgB,aAAa,CAAC,OAAqB;IACjD,MAAM,MAAM,GAAG,IAAI,GAAG,CAAS,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjD,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC;QAAE,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC/E,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;QAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC9E,MAAM,CAAC,GAAG,CAAC,gCAAgB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G,CAAC,IAAI,CAAC;YACP,KAAK,EAAE,KAAK,CAAC,IAAI;YACjB,SAAS,EAAE,KAAK,EAAE,IAAI,IAAI,IAAI;YAC9B,KAAK;YACL,IAAI,EAAE,KAAK,EAAE,KAAK,IAAI,IAAI;YAC1B,YAAY;YACZ,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;YACzG,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;YACtG,IAAI;YACJ,YAAY;SACb,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type Baseline, type DeducedStep, type Instance } from '../workflow/deduce';
|
|
2
|
+
import { type CoreResult } from './types';
|
|
3
|
+
import { type Step } from './workflow-next';
|
|
4
|
+
/** The refusal when no `<ref>` is given and no instance is open (as `workflow end`'s, `spec-017` §10). */
|
|
5
|
+
export declare const NO_ACTIVE_WORKFLOW_TO_FINALIZE = "no active workflow to finalize";
|
|
6
|
+
/** `workflow finalize`'s payload (`spec-017` §8 `FinalizeResult`). */
|
|
7
|
+
export interface FinalizeResult {
|
|
8
|
+
/** The commit the finalize gated on — `HEAD` before its record. */
|
|
9
|
+
readonly baseline: Baseline;
|
|
10
|
+
readonly instance: Instance;
|
|
11
|
+
/** The step the record completes, as `workflow next` reported it at the baseline. */
|
|
12
|
+
readonly finalized: Step;
|
|
13
|
+
/** The instance's next step after the record, deduced at the new `HEAD`; `null` when it has none. */
|
|
14
|
+
readonly next: Step | null;
|
|
15
|
+
/** The record's commit sha. */
|
|
16
|
+
readonly commit: string;
|
|
17
|
+
}
|
|
18
|
+
/** What the caller asked for: `<ref>`, `--step`, and the raw `--reason` (as `optionalReason` reads it). */
|
|
19
|
+
export interface FinalizeRequest {
|
|
20
|
+
readonly ref?: string;
|
|
21
|
+
readonly step?: string;
|
|
22
|
+
readonly options?: Readonly<Record<string, string>>;
|
|
23
|
+
}
|
|
24
|
+
/** The phase-record trailers of `step` (`spec-003` § "Evidence"), in the order the spec lists them. */
|
|
25
|
+
export declare function phaseRecordTrailers(step: Pick<DeducedStep, 'workflow' | 'phase' | 'instance' | 'scope'>): string[];
|
|
26
|
+
/**
|
|
27
|
+
* `workflow finalize` at `HEAD` (`spec-017` §7.9). See the module comment for the record and the order of
|
|
28
|
+
* the refusals.
|
|
29
|
+
*
|
|
30
|
+
* @throws `UsageError` (exit 2) for an unrecordable `--reason`, or a missing one on an `approval:` phase.
|
|
31
|
+
* @throws `DiagnosticsError` (`VALIDATION`) when the registry at `HEAD` has a `spec-003` error;
|
|
32
|
+
* `StorageError` when git cannot answer; `CommitFailure` when git refuses the commit.
|
|
33
|
+
*/
|
|
34
|
+
export declare function workflowFinalizeAtHead(root: string, request: FinalizeRequest): CoreResult<FinalizeResult>;
|
|
35
|
+
/** `workflow finalize`'s `--format console` rendering (`spec-017` §8). Pure. */
|
|
36
|
+
export declare function renderFinalizeConsole(result: FinalizeResult): string;
|
|
37
|
+
//# sourceMappingURL=workflow-finalize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-finalize.d.ts","sourceRoot":"","sources":["../../src/core/workflow-finalize.ts"],"names":[],"mappings":"AAoCA,OAAO,EAA2C,KAAK,QAAQ,EAAE,KAAK,WAAW,EAAE,KAAK,QAAQ,EAAiB,MAAM,oBAAoB,CAAC;AAK5I,OAAO,EAAmB,KAAK,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 0;
|
|
4
|
+
exports.phaseRecordTrailers = phaseRecordTrailers;
|
|
5
|
+
exports.workflowFinalizeAtHead = workflowFinalizeAtHead;
|
|
6
|
+
exports.renderFinalizeConsole = renderFinalizeConsole;
|
|
7
|
+
/**
|
|
8
|
+
* `wingfoil workflow finalize [<ref>] [--step <key>] [--reason <text>]` (task-226; `spec-017` §7.9, §4.3
|
|
9
|
+
* `record`, §5.1, §5.4, §8 `FinalizeResult`, §10, §11; ruling R11; `dl-104` D1 (b)–(c); REQ-SEC-01,
|
|
10
|
+
* REQ-SEC-03, P1.7).
|
|
11
|
+
*
|
|
12
|
+
* Records a phase's completion where the phase has no Memory or file evidence to deduce it from: a
|
|
13
|
+
* checkpoint, an `awaits` (§5.4), a `created` step that created nothing, and an approval no element carries
|
|
14
|
+
* (§5.1). The record is **one commit with no file change** (`commitEmpty`, `src/storage/commit.ts`):
|
|
15
|
+
*
|
|
16
|
+
* ```
|
|
17
|
+
* workflow: finalize <instance-id> <key>
|
|
18
|
+
*
|
|
19
|
+
* Approver: <name> <<email>> (approver) ← an `approval:` phase only
|
|
20
|
+
* Reason: <the dl-067 block> ← when `--reason` is given
|
|
21
|
+
*
|
|
22
|
+
* WingFoil-Phase: <workflow>.<phase> completed
|
|
23
|
+
* WingFoil-Instance: <instance-id>
|
|
24
|
+
* WingFoil-Element: <type>:<id> ← or WingFoil-Item: <collection>#<key>; none when unscoped
|
|
25
|
+
* WingFoil-Version: <semver> (<sha>)
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* The subject is outside the `wf(<type>)` grammar (`spec-003` verb table), so `memory history` never reads it
|
|
29
|
+
* as a Memory operation; the trailers are the phase record of `spec-003` § "Evidence", which the deduction
|
|
30
|
+
* reads with git's `%(trailers)` — from the **final** paragraph only, which is why they share it with the
|
|
31
|
+
* build signature (`CommitOptions.trailers`).
|
|
32
|
+
*
|
|
33
|
+
* **Baseline: `HEAD`, gating** (`spec-017` §1.1, §11): the deduction that names the frontier, and
|
|
34
|
+
* `dna.yaml` for approval authority, are read at `HEAD`; nothing is read from the working tree except the
|
|
35
|
+
* index, whose staged changes refuse the commit (`requireCleanIndex`, `dl-106`).
|
|
36
|
+
*
|
|
37
|
+
* **Refusal order**, every one before the commit: an unrecordable `--reason` (exit 2, before any read) →
|
|
38
|
+
* the git identity (REQ-SEC-01) → the instance → the step on the frontier → its evidence → on an
|
|
39
|
+
* `approval:` phase, a missing `--reason` (exit 2) and approver authority (REQ-SEC-03, the identity read
|
|
40
|
+
* once, `bug-149`) → a dirty index.
|
|
41
|
+
*/
|
|
42
|
+
const storage_1 = require("../storage");
|
|
43
|
+
const deduce_1 = require("../workflow/deduce");
|
|
44
|
+
const approval_authority_1 = require("./approval-authority");
|
|
45
|
+
const git_identity_1 = require("./git-identity");
|
|
46
|
+
const require_reason_1 = require("./require-reason");
|
|
47
|
+
const types_1 = require("./types");
|
|
48
|
+
const workflow_deduction_1 = require("./workflow-deduction");
|
|
49
|
+
const workflow_next_1 = require("./workflow-next");
|
|
50
|
+
const write_guard_1 = require("./write-guard");
|
|
51
|
+
/** The refusal when no `<ref>` is given and no instance is open (as `workflow end`'s, `spec-017` §10). */
|
|
52
|
+
exports.NO_ACTIVE_WORKFLOW_TO_FINALIZE = 'no active workflow to finalize';
|
|
53
|
+
/** `<type>:<id>` or `<collection>#<key>`, as the record's trailer and the step key write a scope. */
|
|
54
|
+
function scopeTrailer(scope) {
|
|
55
|
+
return 'item' in scope ? `WingFoil-Item: ${scope.item.collection}#${scope.item.key}` : `WingFoil-Element: ${scope.element.type}:${scope.element.id}`;
|
|
56
|
+
}
|
|
57
|
+
/** The phase-record trailers of `step` (`spec-003` § "Evidence"), in the order the spec lists them. */
|
|
58
|
+
function phaseRecordTrailers(step) {
|
|
59
|
+
return [`WingFoil-Phase: ${step.workflow}.${step.phase} completed`, `WingFoil-Instance: ${step.instance}`, ...(step.scope === null ? [] : [scopeTrailer(step.scope)])];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The Memory type named in the authority refusal (`user not authorized to approve type '<type>'`): the
|
|
63
|
+
* step's scope element's type, else the instance's bound element's, else `plan` — the instance itself.
|
|
64
|
+
*/
|
|
65
|
+
function authorityType(step, instance) {
|
|
66
|
+
if (step.scope !== null && 'element' in step.scope)
|
|
67
|
+
return step.scope.element.type;
|
|
68
|
+
return instance.element?.type ?? 'plan';
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Why `step` cannot be finalized: its phase completes from other evidence (`spec-017` §7.9, `dl-104` D1
|
|
72
|
+
* rationale). Names the missing kinds other than `record`, or — when none is missing — the kinds the phase
|
|
73
|
+
* declares other than `record`.
|
|
74
|
+
*/
|
|
75
|
+
function evidenceRefusal(step) {
|
|
76
|
+
const missing = step.evidence.missing.filter((kind) => kind !== 'record');
|
|
77
|
+
const kinds = missing.length > 0 ? missing : step.evidence.kinds.filter((kind) => kind !== 'record');
|
|
78
|
+
return (0, types_1.coreErr)({
|
|
79
|
+
code: 'CONFLICT',
|
|
80
|
+
message: `phase '${step.workflow}.${step.phase}' completes from its evidence: ${kinds.join(', ')}`,
|
|
81
|
+
details: { step: step.key, kinds: [...step.evidence.kinds], missing: [...step.evidence.missing] },
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* `workflow finalize` at `HEAD` (`spec-017` §7.9). See the module comment for the record and the order of
|
|
86
|
+
* the refusals.
|
|
87
|
+
*
|
|
88
|
+
* @throws `UsageError` (exit 2) for an unrecordable `--reason`, or a missing one on an `approval:` phase.
|
|
89
|
+
* @throws `DiagnosticsError` (`VALIDATION`) when the registry at `HEAD` has a `spec-003` error;
|
|
90
|
+
* `StorageError` when git cannot answer; `CommitFailure` when git refuses the commit.
|
|
91
|
+
*/
|
|
92
|
+
function workflowFinalizeAtHead(root, request) {
|
|
93
|
+
const given = (0, require_reason_1.optionalReason)(request.options);
|
|
94
|
+
const identity = (0, git_identity_1.requireGitIdentity)(root);
|
|
95
|
+
if (!identity.ok)
|
|
96
|
+
return identity;
|
|
97
|
+
const snapshot = (0, workflow_deduction_1.readDeductionSnapshotAtHead)(root);
|
|
98
|
+
const deduction = (0, deduce_1.deduceWorkflowState)(snapshot);
|
|
99
|
+
const selected = (0, deduce_1.resolveInstanceRef)(deduction, request.ref);
|
|
100
|
+
if (selected === null) {
|
|
101
|
+
if (request.ref !== undefined)
|
|
102
|
+
return (0, workflow_next_1.unresolvedRef)({ workflows: snapshot.workflows, plans: (0, workflow_deduction_1.instancePlanIds)(snapshot.documents) }, request.ref);
|
|
103
|
+
return (0, types_1.coreErr)({ code: 'NOT_FOUND', message: exports.NO_ACTIVE_WORKFLOW_TO_FINALIZE });
|
|
104
|
+
}
|
|
105
|
+
const { instance, frontier } = selected;
|
|
106
|
+
if (frontier.length === 0)
|
|
107
|
+
return (0, types_1.coreErr)({ code: 'CONFLICT', message: (0, workflow_next_1.emptyFrontierMessage)(selected), details: { instance: instance.id } });
|
|
108
|
+
const step = request.step === undefined ? frontier[0] : frontier.find((candidate) => candidate.key === request.step);
|
|
109
|
+
if (step === undefined) {
|
|
110
|
+
return (0, types_1.coreErr)({
|
|
111
|
+
code: 'CONFLICT',
|
|
112
|
+
message: `step '${request.step}' is not on the frontier of ${instance.id}`,
|
|
113
|
+
details: { frontier: frontier.map((candidate) => candidate.key) },
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
if (!step.evidence.finalizable)
|
|
117
|
+
return evidenceRefusal(step);
|
|
118
|
+
// A frontier step's workflow and phase are loaded (deduction puts only loaded phases on a frontier).
|
|
119
|
+
const phase = snapshot.workflows.find((workflow) => workflow.name === step.workflow).phases.find((candidate) => candidate.name === step.phase);
|
|
120
|
+
const body = [];
|
|
121
|
+
if (phase.approval !== undefined) {
|
|
122
|
+
const reason = (0, require_reason_1.requireReason)(request.options);
|
|
123
|
+
const authorized = (0, approval_authority_1.requireApprovalAuthority)(root, authorityType(step, instance), identity.value);
|
|
124
|
+
if (!authorized.ok)
|
|
125
|
+
return authorized;
|
|
126
|
+
body.push(`Approver: ${identity.value.name} <${identity.value.email}> (${approval_authority_1.APPROVER_ROLE})`, `Reason: ${reason}`);
|
|
127
|
+
}
|
|
128
|
+
else if (given !== undefined) {
|
|
129
|
+
body.push(`Reason: ${given}`);
|
|
130
|
+
}
|
|
131
|
+
const subject = `workflow: finalize ${instance.id} ${step.key}`;
|
|
132
|
+
const clean = (0, write_guard_1.requireCleanIndex)(root, subject);
|
|
133
|
+
if (!clean.ok)
|
|
134
|
+
return clean;
|
|
135
|
+
const finalized = (0, workflow_next_1.buildStep)(step, (0, workflow_next_1.readNextInputs)(root, snapshot, deduction));
|
|
136
|
+
const message = body.length === 0 ? subject : `${subject}\n\n${body.join('\n')}`;
|
|
137
|
+
const sha = (0, storage_1.commitEmpty)(root, message, { author: identity.value, trailers: phaseRecordTrailers(step) });
|
|
138
|
+
const after = (0, workflow_deduction_1.readDeductionSnapshotAtHead)(root);
|
|
139
|
+
const deducedAfter = (0, deduce_1.deduceWorkflowState)(after);
|
|
140
|
+
const nextStep = deducedAfter.instances.find((entry) => entry.instance.id === instance.id)?.frontier[0];
|
|
141
|
+
const next = nextStep === undefined ? null : (0, workflow_next_1.buildStep)(nextStep, (0, workflow_next_1.readNextInputs)(root, after, deducedAfter));
|
|
142
|
+
return (0, types_1.coreOk)({ baseline: deduction.baseline, instance, finalized, next, commit: sha }, { sha, message });
|
|
143
|
+
}
|
|
144
|
+
/** `workflow finalize`'s `--format console` rendering (`spec-017` §8). Pure. */
|
|
145
|
+
function renderFinalizeConsole(result) {
|
|
146
|
+
const lines = [`workflow: ${result.instance.workflow} (${result.instance.id})`, `finalized: ${result.finalized.key} (${result.commit})`];
|
|
147
|
+
if (result.next === null)
|
|
148
|
+
lines.push('no next step');
|
|
149
|
+
else
|
|
150
|
+
lines.push(...(0, workflow_next_1.stepLines)(result.next, 'next step'));
|
|
151
|
+
return `${lines.join('\n')}\n`;
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=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,CAAC;AAC5G,CAAC;AAED,gFAAgF;AAChF,SAAgB,qBAAqB,CAAC,MAAsB;IAC1D,MAAM,KAAK,GAAG,CAAC,aAAa,MAAM,CAAC,QAAQ,CAAC,QAAQ,KAAK,MAAM,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,cAAc,MAAM,CAAC,SAAS,CAAC,GAAG,KAAK,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IACzI,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI;QAAE,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;;QAChD,KAAK,CAAC,IAAI,CAAC,GAAG,IAAA,yBAAS,EAAC,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC;IACxD,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `wingfoil workflow list [--all]` and `wingfoil workflow show <ref>` (task-204; `spec-017` §7.5, §7.6, §8,
|
|
3
|
+
* §10; BDD P4.6, P4.7).
|
|
4
|
+
*
|
|
5
|
+
* **Baseline: `HEAD`, declared** (`spec-017` §1.1, approver ruling R15; `spec-006` §6 item 6; `spec-008`
|
|
6
|
+
* §11). Both commands answer from one snapshot of the repository as committed at `HEAD` —
|
|
7
|
+
* `readDeductionSnapshotAtHead` — and from the deduction computed on it (`deduceWorkflowState`), the one
|
|
8
|
+
* `workflow next` / `status` answer from, so a workflow "executable now" here is one a frontier step there
|
|
9
|
+
* enters. The working tree only explains: a deduction input that differs from `HEAD` is the warning
|
|
10
|
+
* `W_UNCOMMITTED_INPUTS` (§1.2), never the answer. `show`'s further reads — `workflows/bindings.yaml`,
|
|
11
|
+
* `roles.yaml` and the directive files — are made at the snapshot's commit, so one answer has one baseline.
|
|
12
|
+
*
|
|
13
|
+
* Both payloads carry the `baseline` and the deduction's ordered `diagnostics` (§1.3). A `spec-003` error
|
|
14
|
+
* refuses both: the snapshot reader throws `DiagnosticsError`, which the read-only operations map to
|
|
15
|
+
* `VALIDATION` with every diagnostic in `details` (exit `1`, §10).
|
|
16
|
+
*
|
|
17
|
+
* The MCP Resources `wingfoil://workflows` and `wingfoil://workflows/{name}` are not these operations: they
|
|
18
|
+
* keep their payload and their working-tree baseline in v0.3 (§9, `src/mcp/workflow-resource.ts`).
|
|
19
|
+
*/
|
|
20
|
+
import type { RolesYaml } from '../directives/schema';
|
|
21
|
+
import type { MemoryYaml } from '../memory/schema';
|
|
22
|
+
import type { Diagnostic } from '../validation';
|
|
23
|
+
import { type BindingsYaml, type TokenBinding } from '../workflow/bindings';
|
|
24
|
+
import { type Baseline, type Deduction, type EvidenceKind } from '../workflow/deduce';
|
|
25
|
+
import { type Cadence, type PhaseMode, type Workflow } from '../workflow/schema';
|
|
26
|
+
import { type DirectiveFile } from './loaders';
|
|
27
|
+
import { type CoreResult } from './types';
|
|
28
|
+
/** `ListResult.message` when `HEAD` holds no manifest (BDD P4.6 sc. 4; `spec-003` Layer 1). */
|
|
29
|
+
export declare const NO_WORKFLOWS_DEFINED = "no workflows defined";
|
|
30
|
+
/** The refusal of a `<ref>` that names no workflow (`spec-017` §10, BDD P4.7 sc. 3). */
|
|
31
|
+
export declare const unknownWorkflowMessage: (name: string) => string;
|
|
32
|
+
/** One entry of `workflow list` (`spec-017` §8 `ListResult`). */
|
|
33
|
+
export interface ListEntry {
|
|
34
|
+
readonly name: string;
|
|
35
|
+
readonly startable: boolean;
|
|
36
|
+
readonly includable: boolean;
|
|
37
|
+
readonly description: string | null;
|
|
38
|
+
/** Startable, or the sub a phase on an open instance's frontier includes (§7.5). */
|
|
39
|
+
readonly executableNow: boolean;
|
|
40
|
+
}
|
|
41
|
+
/** `workflow list`'s payload (`spec-017` §8). */
|
|
42
|
+
export interface ListResult {
|
|
43
|
+
readonly baseline: Baseline;
|
|
44
|
+
readonly workflows: readonly ListEntry[];
|
|
45
|
+
/** `no workflows defined` when `HEAD` holds no manifest; absent otherwise. */
|
|
46
|
+
readonly message?: string;
|
|
47
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
48
|
+
}
|
|
49
|
+
/** An action or check token with its binding (`spec-017` §6.1); a check is never evaluated in v0.3. */
|
|
50
|
+
export interface TokenView {
|
|
51
|
+
readonly token: string;
|
|
52
|
+
readonly binding: TokenBinding;
|
|
53
|
+
}
|
|
54
|
+
/** A check token: listed with its binding, `evaluated: false` (`spec-017` §6.1, P4.12 is v1.0). */
|
|
55
|
+
export interface CheckTokenView extends TokenView {
|
|
56
|
+
readonly evaluated: false;
|
|
57
|
+
}
|
|
58
|
+
/** One phase of a resolved declaration (`spec-017` §7.6). */
|
|
59
|
+
export interface PhaseView {
|
|
60
|
+
readonly name: string;
|
|
61
|
+
readonly description: string | null;
|
|
62
|
+
readonly role: string | null;
|
|
63
|
+
readonly optional: boolean;
|
|
64
|
+
/** The role's directives, role-bound and global, ascending by id (`spec-012` §5); empty without a role. */
|
|
65
|
+
readonly directives: readonly {
|
|
66
|
+
readonly id: string;
|
|
67
|
+
readonly title: string;
|
|
68
|
+
}[];
|
|
69
|
+
/** That resolution's warnings (`resolveRoleDirectives`), or why none was made. */
|
|
70
|
+
readonly directiveWarnings: readonly string[];
|
|
71
|
+
readonly actions: readonly TokenView[];
|
|
72
|
+
readonly checks: {
|
|
73
|
+
readonly pre: readonly CheckTokenView[];
|
|
74
|
+
readonly post: readonly CheckTokenView[];
|
|
75
|
+
};
|
|
76
|
+
/** Each entry with its owner type (`null`: no element, or an implicit owner) and whether it is evidence (§4.3). */
|
|
77
|
+
readonly produces: readonly {
|
|
78
|
+
readonly pattern: string;
|
|
79
|
+
readonly owner: string | null;
|
|
80
|
+
readonly evidence: boolean;
|
|
81
|
+
}[];
|
|
82
|
+
readonly approval: {
|
|
83
|
+
readonly byRole: string;
|
|
84
|
+
} | {
|
|
85
|
+
readonly byPerson: string;
|
|
86
|
+
} | null;
|
|
87
|
+
readonly awaits: {
|
|
88
|
+
readonly party: string;
|
|
89
|
+
readonly evidence: CheckTokenView;
|
|
90
|
+
} | null;
|
|
91
|
+
readonly fallback: {
|
|
92
|
+
readonly step: string;
|
|
93
|
+
readonly setState: string | null;
|
|
94
|
+
} | null;
|
|
95
|
+
/** `iterate_over` and its filter (§4.6). */
|
|
96
|
+
readonly iterate: {
|
|
97
|
+
readonly over: string;
|
|
98
|
+
readonly where: Readonly<Record<string, unknown>> | null;
|
|
99
|
+
} | null;
|
|
100
|
+
/** A `where` without `iterate_over` (`spec-003` § "Selections"). */
|
|
101
|
+
readonly selection: {
|
|
102
|
+
readonly where: Readonly<Record<string, unknown>>;
|
|
103
|
+
} | null;
|
|
104
|
+
/** The declared mode, `fresh` when absent (`spec-003` § "Execution independence"). */
|
|
105
|
+
readonly mode: PhaseMode;
|
|
106
|
+
readonly allowedModes: readonly PhaseMode[];
|
|
107
|
+
readonly distinctFrom: readonly string[];
|
|
108
|
+
readonly cadence: Cadence;
|
|
109
|
+
/** The evidence kinds the phase declares (§4.3), in the deduction's order. */
|
|
110
|
+
readonly evidence: readonly EvidenceKind[];
|
|
111
|
+
readonly include: string | null;
|
|
112
|
+
/** The included workflow, resolved the same way, nested under this phase (P4.7 sc. 2). */
|
|
113
|
+
readonly sub: WorkflowView | null;
|
|
114
|
+
}
|
|
115
|
+
/** A workflow's declaration resolved (`spec-017` §7.6). */
|
|
116
|
+
export interface WorkflowView {
|
|
117
|
+
readonly name: string;
|
|
118
|
+
/** Repository-relative (`.wingfoil/workflows/custom/<name>.yaml`). */
|
|
119
|
+
readonly file: string;
|
|
120
|
+
readonly startable: boolean;
|
|
121
|
+
readonly includable: boolean;
|
|
122
|
+
readonly description: string | null;
|
|
123
|
+
readonly element: string | null;
|
|
124
|
+
readonly phases: readonly PhaseView[];
|
|
125
|
+
}
|
|
126
|
+
/** `workflow show`'s payload: the resolved declaration with the baseline and the diagnostics (`spec-017` §8). */
|
|
127
|
+
export interface ShowResult {
|
|
128
|
+
readonly baseline: Baseline;
|
|
129
|
+
readonly workflow: WorkflowView;
|
|
130
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* `workflow list`'s answer from one deduction (`spec-017` §7.5): without `all`, the startable workflows and
|
|
134
|
+
* every includable one a frontier enters; with it, every loaded workflow. Pure.
|
|
135
|
+
*/
|
|
136
|
+
export declare function listWorkflows(workflows: readonly Workflow[], deduction: Deduction, all: boolean): ListResult;
|
|
137
|
+
/**
|
|
138
|
+
* `workflow list [--all]` at `HEAD` (`spec-017` §7.5).
|
|
139
|
+
*
|
|
140
|
+
* @throws `DiagnosticsError` (`VALIDATION`) when the registry at `HEAD` has a `spec-003` error;
|
|
141
|
+
* `StorageError` when git cannot answer.
|
|
142
|
+
*/
|
|
143
|
+
export declare function workflowListAtHead(root: string, all: boolean): ListResult;
|
|
144
|
+
/** What resolving one declaration reads, all at the snapshot's commit. */
|
|
145
|
+
export interface ShowInputs {
|
|
146
|
+
readonly workflows: readonly Workflow[];
|
|
147
|
+
/** Each workflow's file, repository-relative, parallel to `workflows`. */
|
|
148
|
+
readonly workflowFiles: readonly string[];
|
|
149
|
+
readonly memoryYaml: MemoryYaml | null;
|
|
150
|
+
readonly bindings: BindingsYaml | null;
|
|
151
|
+
readonly rolesYaml: RolesYaml | null;
|
|
152
|
+
readonly directiveFiles: readonly DirectiveFile[];
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* The evidence kinds `phase` declares (`spec-017` §4.3), by the rules the deduction's leaf step applies
|
|
156
|
+
* (`src/workflow/deduce.ts`), in its order: a plain `include` is `include` alone (§4.5); otherwise
|
|
157
|
+
* `include` for an `iterate_over`, `state` (`declaresState`, shared), `created`, `produces` (string
|
|
158
|
+
* entries with an explicit owner), `selection`, `awaits`, then `record` for an `awaits`, a phase with
|
|
159
|
+
* no kind but `created`, or an `approval:` whose phase holds no gate (`holdsGate: false`, §5.1, task-225).
|
|
160
|
+
*/
|
|
161
|
+
export declare function declaredEvidenceKinds(workflow: Workflow, p: number, boundType: string | null, holdsGate: boolean): EvidenceKind[];
|
|
162
|
+
/**
|
|
163
|
+
* `workflow show <ref>`'s answer (`spec-017` §7.6, §10): `ref` names a loaded workflow, or an open instance
|
|
164
|
+
* standing for its workflow; anything else is `NOT_FOUND` `unknown workflow: <ref>`. Pure.
|
|
165
|
+
*/
|
|
166
|
+
export declare function showWorkflow(inputs: ShowInputs, deduction: Deduction, ref: string): CoreResult<ShowResult>;
|
|
167
|
+
/**
|
|
168
|
+
* `workflow show <ref>` at `HEAD` (`spec-017` §7.6): the deduction snapshot (which carries `bindings.yaml`),
|
|
169
|
+
* then `roles.yaml` and the directive files at the snapshot's commit.
|
|
170
|
+
*
|
|
171
|
+
* @throws `DiagnosticsError` (`VALIDATION`) when the registry at `HEAD` has a `spec-003` error; a
|
|
172
|
+
* `ValidationError` for an invalid `roles.yaml` or directive file at `HEAD`; `StorageError` when git
|
|
173
|
+
* cannot answer.
|
|
174
|
+
*/
|
|
175
|
+
export declare function workflowShowAtHead(root: string, ref: string): CoreResult<ShowResult>;
|
|
176
|
+
//# sourceMappingURL=workflow-list-show.d.ts.map
|