wtf-p 0.8.0 → 0.8.2
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 +34 -19
- package/bin/lib/adapter-compiler.js +411 -78
- package/bin/lib/clio-registration.js +44 -17
- package/bin/uninstall.js +19 -4
- package/package.json +3 -3
- package/protocol/actions/advance.json +232 -0
- package/protocol/actions/checkpoint.json +10 -1
- package/protocol/actions/execute-outline.json +10 -2
- package/protocol/actions/export-latex.json +15 -2
- package/protocol/actions/plan-revision.json +22 -4
- package/protocol/actions/polish-prose.json +13 -3
- package/protocol/actions/research-gap.json +16 -3
- package/protocol/actions/verify-work.json +13 -4
- package/protocol/aliases.lock.json +1 -0
- package/protocol/catalog.json +4 -2
- package/protocol/project/README.md +39 -0
- package/protocol/project/schemas/interaction.schema.json +100 -0
- package/protocol/project/templates/interaction.json +16 -0
- package/protocol/roles/research-synthesizer.md +1 -1
- package/protocol/skills/wtfp-deliver-research/SKILL.md +1 -1
- package/protocol/skills/wtfp-deliver-research/references/actions.md +2 -2
- package/protocol/skills/wtfp-manage-project/SKILL.md +2 -1
- package/protocol/skills/wtfp-manage-project/references/actions.md +13 -1
- package/protocol/skills/wtfp-plan-section/SKILL.md +1 -1
- package/protocol/skills/wtfp-plan-section/references/actions.md +4 -3
- package/protocol/skills/wtfp-research-literature/SKILL.md +1 -1
- package/protocol/skills/wtfp-research-literature/references/actions.md +1 -1
- package/protocol/skills/wtfp-review-manuscript/SKILL.md +1 -1
- package/protocol/skills/wtfp-review-manuscript/references/actions.md +2 -1
- package/protocol/skills/wtfp-write-section/SKILL.md +1 -1
- package/protocol/skills/wtfp-write-section/references/actions.md +1 -1
- package/protocol/workflows/advance.md +38 -0
- package/protocol/workflows/checkpoint.md +2 -2
- package/protocol/workflows/discuss-section.md +1 -1
- package/protocol/workflows/execute-outline.md +2 -2
- package/protocol/workflows/export-latex.md +4 -4
- package/protocol/workflows/plan-revision.md +4 -3
- package/protocol/workflows/plan-section.md +3 -3
- package/protocol/workflows/polish-prose.md +3 -3
- package/protocol/workflows/research-gap.md +5 -5
- package/protocol/workflows/verify-work.md +5 -3
- package/protocol/workflows/write-section.md +4 -4
- package/vendors/antigravity/.wtfp-generated.json +195 -183
- package/vendors/antigravity/actions/advance.json +232 -0
- package/vendors/antigravity/actions/checkpoint.json +10 -1
- package/vendors/antigravity/actions/execute-outline.json +10 -2
- package/vendors/antigravity/actions/export-latex.json +15 -2
- package/vendors/antigravity/actions/plan-revision.json +22 -4
- package/vendors/antigravity/actions/polish-prose.json +13 -3
- package/vendors/antigravity/actions/research-gap.json +16 -3
- package/vendors/antigravity/actions/verify-work.json +13 -4
- package/vendors/antigravity/agents/wtfp-research-synthesizer.md +1 -1
- package/vendors/antigravity/aliases.lock.json +1 -0
- package/vendors/antigravity/catalog.json +4 -2
- package/vendors/antigravity/compatibility/action-availability.json +13 -1
- package/vendors/antigravity/plugin.json +2 -1
- package/vendors/antigravity/project/README.md +39 -0
- package/vendors/antigravity/project/schemas/interaction.schema.json +100 -0
- package/vendors/antigravity/project/templates/interaction.json +16 -0
- package/vendors/antigravity/roles/research-synthesizer.md +1 -1
- package/vendors/antigravity/rules/wtfp-project-state.md +43 -1
- package/vendors/antigravity/{commands/wtfp-add-todo.md → skills/wtfp-add-todo/SKILL.md} +2 -3
- package/vendors/antigravity/skills/wtfp-advance/SKILL.md +18 -0
- package/vendors/antigravity/{commands/wtfp-analyze-bib.md → skills/wtfp-analyze-bib/SKILL.md} +2 -1
- package/vendors/antigravity/{commands/wtfp-audit-milestone.md → skills/wtfp-audit-milestone/SKILL.md} +2 -1
- package/vendors/antigravity/{commands/wtfp-check-refs.md → skills/wtfp-check-refs/SKILL.md} +2 -1
- package/vendors/antigravity/{commands/wtfp-check-todos.md → skills/wtfp-check-todos/SKILL.md} +2 -1
- package/vendors/antigravity/{commands/wtfp-checkpoint.md → skills/wtfp-checkpoint/SKILL.md} +4 -17
- package/vendors/antigravity/{commands/wtfp-contribute.md → skills/wtfp-contribute/SKILL.md} +2 -1
- package/vendors/antigravity/{commands/wtfp-create-outline.md → skills/wtfp-create-outline/SKILL.md} +2 -9
- package/vendors/antigravity/{commands/wtfp-create-poster.md → skills/wtfp-create-poster/SKILL.md} +3 -7
- package/vendors/antigravity/{commands/wtfp-create-slides.md → skills/wtfp-create-slides/SKILL.md} +3 -7
- package/vendors/antigravity/skills/wtfp-deliver-research/SKILL.md +1 -1
- package/vendors/antigravity/skills/wtfp-deliver-research/references/actions.md +2 -2
- package/vendors/antigravity/{commands/wtfp-discuss-section.md → skills/wtfp-discuss-section/SKILL.md} +3 -6
- package/vendors/antigravity/{commands/wtfp-execute-outline.md → skills/wtfp-execute-outline/SKILL.md} +4 -13
- package/vendors/antigravity/{commands/wtfp-export-latex.md → skills/wtfp-export-latex/SKILL.md} +2 -1
- package/vendors/antigravity/{commands/wtfp-help.md → skills/wtfp-help/SKILL.md} +4 -3
- package/vendors/antigravity/{commands/wtfp-insert-section.md → skills/wtfp-insert-section/SKILL.md} +2 -1
- package/vendors/antigravity/{commands/wtfp-list-assumptions.md → skills/wtfp-list-assumptions/SKILL.md} +3 -11
- package/vendors/antigravity/skills/wtfp-manage-project/SKILL.md +2 -1
- package/vendors/antigravity/skills/wtfp-manage-project/references/actions.md +29 -1
- package/vendors/antigravity/{commands/wtfp-map-project.md → skills/wtfp-map-project/SKILL.md} +2 -1
- package/vendors/antigravity/{commands/wtfp-new-paper.md → skills/wtfp-new-paper/SKILL.md} +2 -1
- package/vendors/antigravity/{commands/wtfp-pause-writing.md → skills/wtfp-pause-writing/SKILL.md} +2 -7
- package/vendors/antigravity/{commands/wtfp-plan-milestone-gaps.md → skills/wtfp-plan-milestone-gaps/SKILL.md} +2 -7
- package/vendors/antigravity/{commands/wtfp-plan-revision.md → skills/wtfp-plan-revision/SKILL.md} +10 -10
- package/vendors/antigravity/skills/wtfp-plan-section/SKILL.md +1 -1
- package/vendors/antigravity/skills/wtfp-plan-section/references/actions.md +4 -3
- package/vendors/antigravity/{commands/wtfp-polish-prose.md → skills/wtfp-polish-prose/SKILL.md} +9 -10
- package/vendors/antigravity/{commands/wtfp-progress.md → skills/wtfp-progress/SKILL.md} +3 -23
- package/vendors/antigravity/{commands/wtfp-quick.md → skills/wtfp-quick/SKILL.md} +2 -5
- package/vendors/antigravity/{commands/wtfp-remove-section.md → skills/wtfp-remove-section/SKILL.md} +2 -1
- package/vendors/antigravity/{commands/wtfp-report-bug.md → skills/wtfp-report-bug/SKILL.md} +2 -1
- package/vendors/antigravity/{commands/wtfp-request-feature.md → skills/wtfp-request-feature/SKILL.md} +2 -1
- package/vendors/antigravity/{commands/wtfp-research-gap.md → skills/wtfp-research-gap/SKILL.md} +2 -1
- package/vendors/antigravity/skills/wtfp-research-literature/SKILL.md +1 -1
- package/vendors/antigravity/skills/wtfp-research-literature/references/actions.md +1 -1
- package/vendors/antigravity/{commands/wtfp-resume-writing.md → skills/wtfp-resume-writing/SKILL.md} +2 -13
- package/vendors/antigravity/skills/wtfp-review-manuscript/SKILL.md +1 -1
- package/vendors/antigravity/skills/wtfp-review-manuscript/references/actions.md +2 -1
- package/vendors/antigravity/{commands/wtfp-review-section.md → skills/wtfp-review-section/SKILL.md} +2 -9
- package/vendors/antigravity/{commands/wtfp-settings.md → skills/wtfp-settings/SKILL.md} +2 -1
- package/vendors/antigravity/{commands/wtfp-submit-milestone.md → skills/wtfp-submit-milestone/SKILL.md} +2 -13
- package/vendors/antigravity/{commands/wtfp-update.md → skills/wtfp-update/SKILL.md} +2 -1
- package/vendors/antigravity/{commands/wtfp-verify-work.md → skills/wtfp-verify-work/SKILL.md} +9 -6
- package/vendors/antigravity/skills/wtfp-write-section/SKILL.md +1 -1
- package/vendors/antigravity/skills/wtfp-write-section/references/actions.md +1 -1
- package/vendors/antigravity/tools/README.md +1 -1
- package/vendors/antigravity/workflows/advance.md +38 -0
- package/vendors/antigravity/workflows/checkpoint.md +2 -2
- package/vendors/antigravity/workflows/discuss-section.md +1 -1
- package/vendors/antigravity/workflows/execute-outline.md +2 -2
- package/vendors/antigravity/workflows/export-latex.md +4 -4
- package/vendors/antigravity/workflows/plan-revision.md +4 -3
- package/vendors/antigravity/workflows/plan-section.md +3 -3
- package/vendors/antigravity/workflows/polish-prose.md +3 -3
- package/vendors/antigravity/workflows/research-gap.md +5 -5
- package/vendors/antigravity/workflows/verify-work.md +5 -3
- package/vendors/antigravity/workflows/write-section.md +4 -4
- package/vendors/claude/.claude-plugin/marketplace.json +2 -2
- package/vendors/claude/.claude-plugin/plugin.json +1 -1
- package/vendors/claude/.wtfp-generated.json +135 -111
- package/vendors/claude/actions/advance.json +232 -0
- package/vendors/claude/actions/checkpoint.json +10 -1
- package/vendors/claude/actions/execute-outline.json +10 -2
- package/vendors/claude/actions/export-latex.json +15 -2
- package/vendors/claude/actions/plan-revision.json +22 -4
- package/vendors/claude/actions/polish-prose.json +13 -3
- package/vendors/claude/actions/research-gap.json +16 -3
- package/vendors/claude/actions/verify-work.json +13 -4
- package/vendors/claude/agents/wtfp-research-synthesizer.md +1 -1
- package/vendors/claude/ai.iowarp.clio/agents/wtfp-argument-verifier.md +7 -8
- package/vendors/claude/ai.iowarp.clio/agents/wtfp-citation-expert.md +5 -5
- package/vendors/claude/ai.iowarp.clio/agents/wtfp-citation-formatter.md +3 -3
- package/vendors/claude/ai.iowarp.clio/agents/wtfp-coherence-checker.md +9 -10
- package/vendors/claude/ai.iowarp.clio/agents/wtfp-outliner.md +3 -3
- package/vendors/claude/ai.iowarp.clio/agents/wtfp-plan-checker.md +7 -8
- package/vendors/claude/ai.iowarp.clio/agents/wtfp-prose-polisher.md +4 -4
- package/vendors/claude/ai.iowarp.clio/agents/wtfp-research-synthesizer.md +6 -6
- package/vendors/claude/ai.iowarp.clio/agents/wtfp-section-planner.md +3 -3
- package/vendors/claude/ai.iowarp.clio/agents/wtfp-section-reviewer.md +9 -10
- package/vendors/claude/ai.iowarp.clio/agents/wtfp-section-writer.md +3 -3
- package/vendors/claude/ai.iowarp.clio/fleets/wtfp-draft-review.md +1 -1
- package/vendors/claude/ai.iowarp.clio/fleets/wtfp-plan-section.md +1 -1
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/add-todo.md +8 -2
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/advance.md +15 -0
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/analyze-bib.md +26 -8
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/audit-milestone.md +12 -16
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/check-refs.md +26 -8
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/check-todos.md +11 -0
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/checkpoint.md +13 -16
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/create-outline.md +25 -10
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/create-poster.md +12 -6
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/create-slides.md +12 -6
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/discuss-section.md +12 -5
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/execute-outline.md +27 -14
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/export-latex.md +16 -12
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/help.md +4 -1
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/insert-section.md +11 -0
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/list-assumptions.md +7 -10
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/map-project.md +8 -0
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/new-paper.md +11 -0
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/pause-writing.md +8 -6
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/plan-milestone-gaps.md +11 -6
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/plan-revision.md +19 -9
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/plan-section.md +28 -17
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/polish-prose.md +32 -11
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/progress.md +10 -22
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/quick.md +25 -6
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/research-gap.md +37 -16
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/resume-writing.md +11 -12
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/review-section.md +22 -10
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/settings.md +11 -0
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/submit-milestone.md +11 -12
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/verify-work.md +18 -5
- package/vendors/claude/ai.iowarp.clio/prompts/wtfp/write-section.md +29 -16
- package/vendors/claude/aliases.lock.json +1 -0
- package/vendors/claude/catalog.json +4 -2
- package/vendors/claude/commands/add-todo.md +0 -2
- package/vendors/claude/commands/advance.md +16 -0
- package/vendors/claude/commands/analyze-bib.md +0 -6
- package/vendors/claude/commands/audit-milestone.md +0 -16
- package/vendors/claude/commands/check-refs.md +0 -6
- package/vendors/claude/commands/checkpoint.md +2 -16
- package/vendors/claude/commands/create-outline.md +0 -8
- package/vendors/claude/commands/create-poster.md +1 -6
- package/vendors/claude/commands/create-slides.md +1 -6
- package/vendors/claude/commands/discuss-section.md +1 -5
- package/vendors/claude/commands/execute-outline.md +2 -12
- package/vendors/claude/commands/export-latex.md +4 -12
- package/vendors/claude/commands/help.md +1 -1
- package/vendors/claude/commands/list-assumptions.md +1 -10
- package/vendors/claude/commands/pause-writing.md +0 -6
- package/vendors/claude/commands/plan-milestone-gaps.md +0 -6
- package/vendors/claude/commands/plan-revision.md +8 -9
- package/vendors/claude/commands/plan-section.md +3 -15
- package/vendors/claude/commands/polish-prose.md +7 -9
- package/vendors/claude/commands/progress.md +1 -22
- package/vendors/claude/commands/quick.md +0 -4
- package/vendors/claude/commands/research-gap.md +5 -13
- package/vendors/claude/commands/resume-writing.md +0 -12
- package/vendors/claude/commands/review-section.md +0 -8
- package/vendors/claude/commands/submit-milestone.md +0 -12
- package/vendors/claude/commands/verify-work.md +7 -5
- package/vendors/claude/commands/write-section.md +4 -14
- package/vendors/claude/compatibility/action-availability.json +10 -1
- package/vendors/claude/output-styles/wtfp-academic-writing.md +7 -7
- package/vendors/claude/plugin.json +15 -1
- package/vendors/claude/project/README.md +39 -0
- package/vendors/claude/project/schemas/interaction.schema.json +100 -0
- package/vendors/claude/project/templates/interaction.json +16 -0
- package/vendors/claude/roles/research-synthesizer.md +1 -1
- package/vendors/claude/skills/wtfp-deliver-research/SKILL.md +1 -1
- package/vendors/claude/skills/wtfp-deliver-research/references/actions.md +2 -2
- package/vendors/claude/skills/wtfp-manage-project/SKILL.md +2 -1
- package/vendors/claude/skills/wtfp-manage-project/references/actions.md +29 -1
- package/vendors/claude/skills/wtfp-plan-section/SKILL.md +1 -1
- package/vendors/claude/skills/wtfp-plan-section/references/actions.md +4 -3
- package/vendors/claude/skills/wtfp-research-literature/SKILL.md +1 -1
- package/vendors/claude/skills/wtfp-research-literature/references/actions.md +1 -1
- package/vendors/claude/skills/wtfp-review-manuscript/SKILL.md +1 -1
- package/vendors/claude/skills/wtfp-review-manuscript/references/actions.md +2 -1
- package/vendors/claude/skills/wtfp-write-section/SKILL.md +1 -1
- package/vendors/claude/skills/wtfp-write-section/references/actions.md +1 -1
- package/vendors/claude/tools/README.md +1 -1
- package/vendors/claude/workflows/advance.md +38 -0
- package/vendors/claude/workflows/checkpoint.md +2 -2
- package/vendors/claude/workflows/discuss-section.md +1 -1
- package/vendors/claude/workflows/execute-outline.md +2 -2
- package/vendors/claude/workflows/export-latex.md +4 -4
- package/vendors/claude/workflows/plan-revision.md +4 -3
- package/vendors/claude/workflows/plan-section.md +3 -3
- package/vendors/claude/workflows/polish-prose.md +3 -3
- package/vendors/claude/workflows/research-gap.md +5 -5
- package/vendors/claude/workflows/verify-work.md +5 -3
- package/vendors/claude/workflows/write-section.md +4 -4
- package/vendors/clio-extension/.wtfp-generated.json +73 -13
- package/vendors/clio-extension/actions/advance.json +232 -0
- package/vendors/clio-extension/actions/checkpoint.json +10 -1
- package/vendors/clio-extension/actions/execute-outline.json +10 -2
- package/vendors/clio-extension/actions/export-latex.json +15 -2
- package/vendors/clio-extension/actions/plan-revision.json +22 -4
- package/vendors/clio-extension/actions/polish-prose.json +13 -3
- package/vendors/clio-extension/actions/research-gap.json +16 -3
- package/vendors/clio-extension/actions/verify-work.json +13 -4
- package/vendors/clio-extension/clio-coder-extension.yaml +48 -10
- package/vendors/clio-extension/compatibility/action-availability.json +11 -5
- package/vendors/clio-extension/project/schemas/interaction.schema.json +100 -0
- package/vendors/clio-extension/project/templates/checkpoint.json +25 -0
- package/vendors/clio-extension/project/templates/config.json +31 -0
- package/vendors/clio-extension/project/templates/decisions.json +35 -0
- package/vendors/clio-extension/project/templates/evidence.json +18 -0
- package/vendors/clio-extension/project/templates/interaction.json +16 -0
- package/vendors/clio-extension/project/templates/manifest.json +30 -0
- package/vendors/clio-extension/project/templates/outline.json +38 -0
- package/vendors/clio-extension/project/templates/section.json +32 -0
- package/vendors/clio-extension/project/templates/source.json +20 -0
- package/vendors/clio-extension/project/templates/state.json +22 -0
- package/vendors/clio-extension/project/templates/validation.json +32 -0
- package/vendors/clio-extension/runtime/claim-coverage.cjs +332 -0
- package/vendors/clio-extension/runtime/desk-trust.cjs +112 -0
- package/vendors/clio-extension/runtime/extension.test.ts +2034 -65
- package/vendors/clio-extension/runtime/extension.ts +3032 -435
- package/vendors/clio-extension/runtime/write-guard.json +629 -18
- package/vendors/codex/plugins/wtfp/.codex-plugin/plugin.json +1 -1
- package/vendors/codex/plugins/wtfp/.wtfp-generated.json +55 -39
- package/vendors/codex/plugins/wtfp/actions/advance.json +232 -0
- package/vendors/codex/plugins/wtfp/actions/checkpoint.json +10 -1
- package/vendors/codex/plugins/wtfp/actions/execute-outline.json +10 -2
- package/vendors/codex/plugins/wtfp/actions/export-latex.json +15 -2
- package/vendors/codex/plugins/wtfp/actions/plan-revision.json +22 -4
- package/vendors/codex/plugins/wtfp/actions/polish-prose.json +13 -3
- package/vendors/codex/plugins/wtfp/actions/research-gap.json +16 -3
- package/vendors/codex/plugins/wtfp/actions/verify-work.json +13 -4
- package/vendors/codex/plugins/wtfp/agents/wtfp-research-synthesizer.toml +1 -1
- package/vendors/codex/plugins/wtfp/aliases.lock.json +1 -0
- package/vendors/codex/plugins/wtfp/catalog.json +4 -2
- package/vendors/codex/plugins/wtfp/compatibility/action-availability.json +13 -1
- package/vendors/codex/plugins/wtfp/plugin.json +1 -1
- package/vendors/codex/plugins/wtfp/project/README.md +39 -0
- package/vendors/codex/plugins/wtfp/project/schemas/interaction.schema.json +100 -0
- package/vendors/codex/plugins/wtfp/project/templates/interaction.json +16 -0
- package/vendors/codex/plugins/wtfp/roles/research-synthesizer.md +1 -1
- package/vendors/codex/plugins/wtfp/skills/wtfp-deliver-research/SKILL.md +1 -1
- package/vendors/codex/plugins/wtfp/skills/wtfp-deliver-research/references/actions.md +2 -2
- package/vendors/codex/plugins/wtfp/skills/wtfp-manage-project/SKILL.md +2 -1
- package/vendors/codex/plugins/wtfp/skills/wtfp-manage-project/references/actions.md +29 -1
- package/vendors/codex/plugins/wtfp/skills/wtfp-plan-section/SKILL.md +1 -1
- package/vendors/codex/plugins/wtfp/skills/wtfp-plan-section/references/actions.md +4 -3
- package/vendors/codex/plugins/wtfp/skills/wtfp-research-literature/SKILL.md +1 -1
- package/vendors/codex/plugins/wtfp/skills/wtfp-research-literature/references/actions.md +1 -1
- package/vendors/codex/plugins/wtfp/skills/wtfp-review-manuscript/SKILL.md +1 -1
- package/vendors/codex/plugins/wtfp/skills/wtfp-review-manuscript/references/actions.md +2 -1
- package/vendors/codex/plugins/wtfp/skills/wtfp-write-section/SKILL.md +1 -1
- package/vendors/codex/plugins/wtfp/skills/wtfp-write-section/references/actions.md +1 -1
- package/vendors/codex/plugins/wtfp/tools/README.md +1 -1
- package/vendors/codex/plugins/wtfp/workflows/advance.md +38 -0
- package/vendors/codex/plugins/wtfp/workflows/checkpoint.md +2 -2
- package/vendors/codex/plugins/wtfp/workflows/discuss-section.md +1 -1
- package/vendors/codex/plugins/wtfp/workflows/execute-outline.md +2 -2
- package/vendors/codex/plugins/wtfp/workflows/export-latex.md +4 -4
- package/vendors/codex/plugins/wtfp/workflows/plan-revision.md +4 -3
- package/vendors/codex/plugins/wtfp/workflows/plan-section.md +3 -3
- package/vendors/codex/plugins/wtfp/workflows/polish-prose.md +3 -3
- package/vendors/codex/plugins/wtfp/workflows/research-gap.md +5 -5
- package/vendors/codex/plugins/wtfp/workflows/verify-work.md +5 -3
- package/vendors/codex/plugins/wtfp/workflows/write-section.md +4 -4
- package/vendors/copilot/.wtfp-generated.json +74 -54
- package/vendors/copilot/marketplace.json +2 -2
- package/vendors/copilot/plugins/wtfp/.claude-plugin/plugin.json +1 -1
- package/vendors/copilot/plugins/wtfp/.wtfp-generated.json +79 -59
- package/vendors/copilot/plugins/wtfp/actions/advance.json +232 -0
- package/vendors/copilot/plugins/wtfp/actions/checkpoint.json +10 -1
- package/vendors/copilot/plugins/wtfp/actions/execute-outline.json +10 -2
- package/vendors/copilot/plugins/wtfp/actions/export-latex.json +15 -2
- package/vendors/copilot/plugins/wtfp/actions/plan-revision.json +22 -4
- package/vendors/copilot/plugins/wtfp/actions/polish-prose.json +13 -3
- package/vendors/copilot/plugins/wtfp/actions/research-gap.json +16 -3
- package/vendors/copilot/plugins/wtfp/actions/verify-work.json +13 -4
- package/vendors/copilot/plugins/wtfp/agents/wtfp-research-synthesizer.md +1 -1
- package/vendors/copilot/plugins/wtfp/aliases.lock.json +1 -0
- package/vendors/copilot/plugins/wtfp/catalog.json +4 -2
- package/vendors/copilot/plugins/wtfp/commands/wtfp-add-todo.md +0 -2
- package/vendors/copilot/plugins/wtfp/commands/wtfp-advance.md +17 -0
- package/vendors/copilot/plugins/wtfp/commands/wtfp-checkpoint.md +2 -16
- package/vendors/copilot/plugins/wtfp/commands/wtfp-create-outline.md +0 -8
- package/vendors/copilot/plugins/wtfp/commands/wtfp-create-poster.md +1 -6
- package/vendors/copilot/plugins/wtfp/commands/wtfp-create-slides.md +1 -6
- package/vendors/copilot/plugins/wtfp/commands/wtfp-discuss-section.md +1 -5
- package/vendors/copilot/plugins/wtfp/commands/wtfp-execute-outline.md +2 -12
- package/vendors/copilot/plugins/wtfp/commands/wtfp-help.md +1 -1
- package/vendors/copilot/plugins/wtfp/commands/wtfp-list-assumptions.md +1 -10
- package/vendors/copilot/plugins/wtfp/commands/wtfp-pause-writing.md +0 -6
- package/vendors/copilot/plugins/wtfp/commands/wtfp-plan-milestone-gaps.md +0 -6
- package/vendors/copilot/plugins/wtfp/commands/wtfp-plan-revision.md +8 -9
- package/vendors/copilot/plugins/wtfp/commands/wtfp-plan-section.md +3 -15
- package/vendors/copilot/plugins/wtfp/commands/wtfp-polish-prose.md +7 -9
- package/vendors/copilot/plugins/wtfp/commands/wtfp-progress.md +1 -22
- package/vendors/copilot/plugins/wtfp/commands/wtfp-quick.md +0 -4
- package/vendors/copilot/plugins/wtfp/commands/wtfp-resume-writing.md +0 -12
- package/vendors/copilot/plugins/wtfp/commands/wtfp-review-section.md +0 -8
- package/vendors/copilot/plugins/wtfp/commands/wtfp-submit-milestone.md +0 -12
- package/vendors/copilot/plugins/wtfp/commands/wtfp-verify-work.md +7 -5
- package/vendors/copilot/plugins/wtfp/commands/wtfp-write-section.md +4 -14
- package/vendors/copilot/plugins/wtfp/compatibility/action-availability.json +13 -1
- package/vendors/copilot/plugins/wtfp/project/README.md +39 -0
- package/vendors/copilot/plugins/wtfp/project/schemas/interaction.schema.json +100 -0
- package/vendors/copilot/plugins/wtfp/project/templates/interaction.json +16 -0
- package/vendors/copilot/plugins/wtfp/roles/research-synthesizer.md +1 -1
- package/vendors/copilot/plugins/wtfp/skills/wtfp-deliver-research/SKILL.md +1 -1
- package/vendors/copilot/plugins/wtfp/skills/wtfp-deliver-research/references/actions.md +2 -2
- package/vendors/copilot/plugins/wtfp/skills/wtfp-manage-project/SKILL.md +2 -1
- package/vendors/copilot/plugins/wtfp/skills/wtfp-manage-project/references/actions.md +29 -1
- package/vendors/copilot/plugins/wtfp/skills/wtfp-plan-section/SKILL.md +1 -1
- package/vendors/copilot/plugins/wtfp/skills/wtfp-plan-section/references/actions.md +4 -3
- package/vendors/copilot/plugins/wtfp/skills/wtfp-research-literature/SKILL.md +1 -1
- package/vendors/copilot/plugins/wtfp/skills/wtfp-research-literature/references/actions.md +1 -1
- package/vendors/copilot/plugins/wtfp/skills/wtfp-review-manuscript/SKILL.md +1 -1
- package/vendors/copilot/plugins/wtfp/skills/wtfp-review-manuscript/references/actions.md +2 -1
- package/vendors/copilot/plugins/wtfp/skills/wtfp-write-section/SKILL.md +1 -1
- package/vendors/copilot/plugins/wtfp/skills/wtfp-write-section/references/actions.md +1 -1
- package/vendors/copilot/plugins/wtfp/tools/README.md +1 -1
- package/vendors/copilot/plugins/wtfp/workflows/advance.md +38 -0
- package/vendors/copilot/plugins/wtfp/workflows/checkpoint.md +2 -2
- package/vendors/copilot/plugins/wtfp/workflows/discuss-section.md +1 -1
- package/vendors/copilot/plugins/wtfp/workflows/execute-outline.md +2 -2
- package/vendors/copilot/plugins/wtfp/workflows/export-latex.md +4 -4
- package/vendors/copilot/plugins/wtfp/workflows/plan-revision.md +4 -3
- package/vendors/copilot/plugins/wtfp/workflows/plan-section.md +3 -3
- package/vendors/copilot/plugins/wtfp/workflows/polish-prose.md +3 -3
- package/vendors/copilot/plugins/wtfp/workflows/research-gap.md +5 -5
- package/vendors/copilot/plugins/wtfp/workflows/verify-work.md +5 -3
- package/vendors/copilot/plugins/wtfp/workflows/write-section.md +4 -4
- package/vendors/copilot/project/.github/agents/wtfp-research-synthesizer.agent.md +1 -1
- package/vendors/copilot/project/.github/prompts/wtfp-add-todo.prompt.md +0 -2
- package/vendors/copilot/project/.github/prompts/wtfp-advance.prompt.md +18 -0
- package/vendors/copilot/project/.github/prompts/wtfp-help.prompt.md +1 -1
- package/vendors/copilot/project/.github/prompts/wtfp-list-assumptions.prompt.md +1 -10
- package/vendors/copilot/project/.github/prompts/wtfp-pause-writing.prompt.md +0 -6
- package/vendors/copilot/project/.github/skills/wtfp-deliver-research/SKILL.md +1 -1
- package/vendors/copilot/project/.github/skills/wtfp-deliver-research/references/actions.md +2 -2
- package/vendors/copilot/project/.github/skills/wtfp-manage-project/SKILL.md +2 -1
- package/vendors/copilot/project/.github/skills/wtfp-manage-project/references/actions.md +25 -1
- package/vendors/copilot/project/.github/skills/wtfp-plan-section/SKILL.md +1 -1
- package/vendors/copilot/project/.github/skills/wtfp-plan-section/references/actions.md +4 -3
- package/vendors/copilot/project/.github/skills/wtfp-research-literature/SKILL.md +1 -1
- package/vendors/copilot/project/.github/skills/wtfp-research-literature/references/actions.md +1 -1
- package/vendors/copilot/project/.github/skills/wtfp-review-manuscript/SKILL.md +1 -1
- package/vendors/copilot/project/.github/skills/wtfp-review-manuscript/references/actions.md +2 -1
- package/vendors/copilot/project/.github/skills/wtfp-write-section/SKILL.md +1 -1
- package/vendors/copilot/project/.github/skills/wtfp-write-section/references/actions.md +1 -1
- package/vendors/copilot/project/.github/wtfp/actions/advance.json +232 -0
- package/vendors/copilot/project/.github/wtfp/actions/checkpoint.json +10 -1
- package/vendors/copilot/project/.github/wtfp/actions/execute-outline.json +10 -2
- package/vendors/copilot/project/.github/wtfp/actions/export-latex.json +15 -2
- package/vendors/copilot/project/.github/wtfp/actions/plan-revision.json +22 -4
- package/vendors/copilot/project/.github/wtfp/actions/polish-prose.json +13 -3
- package/vendors/copilot/project/.github/wtfp/actions/research-gap.json +16 -3
- package/vendors/copilot/project/.github/wtfp/actions/verify-work.json +13 -4
- package/vendors/copilot/project/.github/wtfp/aliases.lock.json +1 -0
- package/vendors/copilot/project/.github/wtfp/catalog.json +4 -2
- package/vendors/copilot/project/.github/wtfp/compatibility/action-availability.json +14 -1
- package/vendors/copilot/project/.github/wtfp/project/README.md +39 -0
- package/vendors/copilot/project/.github/wtfp/project/schemas/interaction.schema.json +100 -0
- package/vendors/copilot/project/.github/wtfp/project/templates/interaction.json +16 -0
- package/vendors/copilot/project/.github/wtfp/roles/research-synthesizer.md +1 -1
- package/vendors/copilot/project/.github/wtfp/skills/wtfp-deliver-research/SKILL.md +1 -1
- package/vendors/copilot/project/.github/wtfp/skills/wtfp-deliver-research/references/actions.md +2 -2
- package/vendors/copilot/project/.github/wtfp/skills/wtfp-manage-project/SKILL.md +2 -1
- package/vendors/copilot/project/.github/wtfp/skills/wtfp-manage-project/references/actions.md +13 -1
- package/vendors/copilot/project/.github/wtfp/skills/wtfp-plan-section/SKILL.md +1 -1
- package/vendors/copilot/project/.github/wtfp/skills/wtfp-plan-section/references/actions.md +4 -3
- package/vendors/copilot/project/.github/wtfp/skills/wtfp-research-literature/SKILL.md +1 -1
- package/vendors/copilot/project/.github/wtfp/skills/wtfp-research-literature/references/actions.md +1 -1
- package/vendors/copilot/project/.github/wtfp/skills/wtfp-review-manuscript/SKILL.md +1 -1
- package/vendors/copilot/project/.github/wtfp/skills/wtfp-review-manuscript/references/actions.md +2 -1
- package/vendors/copilot/project/.github/wtfp/skills/wtfp-write-section/SKILL.md +1 -1
- package/vendors/copilot/project/.github/wtfp/skills/wtfp-write-section/references/actions.md +1 -1
- package/vendors/copilot/project/.github/wtfp/workflows/advance.md +38 -0
- package/vendors/copilot/project/.github/wtfp/workflows/checkpoint.md +2 -2
- package/vendors/copilot/project/.github/wtfp/workflows/discuss-section.md +1 -1
- package/vendors/copilot/project/.github/wtfp/workflows/execute-outline.md +2 -2
- package/vendors/copilot/project/.github/wtfp/workflows/export-latex.md +4 -4
- package/vendors/copilot/project/.github/wtfp/workflows/plan-revision.md +4 -3
- package/vendors/copilot/project/.github/wtfp/workflows/plan-section.md +3 -3
- package/vendors/copilot/project/.github/wtfp/workflows/polish-prose.md +3 -3
- package/vendors/copilot/project/.github/wtfp/workflows/research-gap.md +5 -5
- package/vendors/copilot/project/.github/wtfp/workflows/verify-work.md +5 -3
- package/vendors/copilot/project/.github/wtfp/workflows/write-section.md +4 -4
- package/vendors/copilot/project/README.md +1 -1
- package/vendors/gemini/.wtfp-generated.json +84 -64
- package/vendors/gemini/actions/advance.json +232 -0
- package/vendors/gemini/actions/checkpoint.json +10 -1
- package/vendors/gemini/actions/execute-outline.json +10 -2
- package/vendors/gemini/actions/export-latex.json +15 -2
- package/vendors/gemini/actions/plan-revision.json +22 -4
- package/vendors/gemini/actions/polish-prose.json +13 -3
- package/vendors/gemini/actions/research-gap.json +16 -3
- package/vendors/gemini/actions/verify-work.json +13 -4
- package/vendors/gemini/agents/wtfp-research-synthesizer.md +1 -1
- package/vendors/gemini/aliases.lock.json +1 -0
- package/vendors/gemini/catalog.json +4 -2
- package/vendors/gemini/commands/wtfp/add-todo.toml +54 -144
- package/vendors/gemini/commands/wtfp/advance.toml +14 -0
- package/vendors/gemini/commands/wtfp/check-todos.toml +54 -2
- package/vendors/gemini/commands/wtfp/checkpoint.toml +66 -738
- package/vendors/gemini/commands/wtfp/create-outline.toml +39 -431
- package/vendors/gemini/commands/wtfp/create-poster.toml +43 -299
- package/vendors/gemini/commands/wtfp/create-slides.toml +43 -299
- package/vendors/gemini/commands/wtfp/discuss-section.toml +45 -262
- package/vendors/gemini/commands/wtfp/execute-outline.toml +53 -486
- package/vendors/gemini/commands/wtfp/help.toml +44 -3
- package/vendors/gemini/commands/wtfp/insert-section.toml +44 -4
- package/vendors/gemini/commands/wtfp/list-assumptions.toml +45 -513
- package/vendors/gemini/commands/wtfp/map-project.toml +39 -0
- package/vendors/gemini/commands/wtfp/new-paper.toml +39 -0
- package/vendors/gemini/commands/wtfp/pause-writing.toml +54 -309
- package/vendors/gemini/commands/wtfp/plan-milestone-gaps.toml +42 -370
- package/vendors/gemini/commands/wtfp/plan-revision.toml +229 -277
- package/vendors/gemini/commands/wtfp/plan-section.toml +47 -629
- package/vendors/gemini/commands/wtfp/polish-prose.toml +217 -268
- package/vendors/gemini/commands/wtfp/progress.toml +55 -1143
- package/vendors/gemini/commands/wtfp/quick.toml +41 -220
- package/vendors/gemini/commands/wtfp/resume-writing.toml +54 -698
- package/vendors/gemini/commands/wtfp/review-section.toml +42 -411
- package/vendors/gemini/commands/wtfp/settings.toml +54 -2
- package/vendors/gemini/commands/wtfp/submit-milestone.toml +42 -620
- package/vendors/gemini/commands/wtfp/verify-work.toml +169 -57
- package/vendors/gemini/commands/wtfp/write-section.toml +45 -486
- package/vendors/gemini/compatibility/action-availability.json +13 -1
- package/vendors/gemini/gemini-extension.json +1 -1
- package/vendors/gemini/project/README.md +39 -0
- package/vendors/gemini/project/schemas/interaction.schema.json +100 -0
- package/vendors/gemini/project/templates/interaction.json +16 -0
- package/vendors/gemini/roles/research-synthesizer.md +1 -1
- package/vendors/gemini/skills/wtfp-deliver-research/SKILL.md +1 -1
- package/vendors/gemini/skills/wtfp-deliver-research/references/actions.md +2 -2
- package/vendors/gemini/skills/wtfp-manage-project/SKILL.md +2 -1
- package/vendors/gemini/skills/wtfp-manage-project/references/actions.md +29 -1
- package/vendors/gemini/skills/wtfp-plan-section/SKILL.md +1 -1
- package/vendors/gemini/skills/wtfp-plan-section/references/actions.md +4 -3
- package/vendors/gemini/skills/wtfp-research-literature/SKILL.md +1 -1
- package/vendors/gemini/skills/wtfp-research-literature/references/actions.md +1 -1
- package/vendors/gemini/skills/wtfp-review-manuscript/SKILL.md +1 -1
- package/vendors/gemini/skills/wtfp-review-manuscript/references/actions.md +2 -1
- package/vendors/gemini/skills/wtfp-write-section/SKILL.md +1 -1
- package/vendors/gemini/skills/wtfp-write-section/references/actions.md +1 -1
- package/vendors/gemini/tools/README.md +1 -1
- package/vendors/gemini/workflows/advance.md +38 -0
- package/vendors/gemini/workflows/checkpoint.md +2 -2
- package/vendors/gemini/workflows/discuss-section.md +1 -1
- package/vendors/gemini/workflows/execute-outline.md +2 -2
- package/vendors/gemini/workflows/export-latex.md +4 -4
- package/vendors/gemini/workflows/plan-revision.md +4 -3
- package/vendors/gemini/workflows/plan-section.md +3 -3
- package/vendors/gemini/workflows/polish-prose.md +3 -3
- package/vendors/gemini/workflows/research-gap.md +5 -5
- package/vendors/gemini/workflows/verify-work.md +5 -3
- package/vendors/gemini/workflows/write-section.md +4 -4
- package/vendors/opencode/.wtfp-generated.json +83 -63
- package/vendors/opencode/actions/advance.json +232 -0
- package/vendors/opencode/actions/checkpoint.json +10 -1
- package/vendors/opencode/actions/execute-outline.json +10 -2
- package/vendors/opencode/actions/export-latex.json +15 -2
- package/vendors/opencode/actions/plan-revision.json +22 -4
- package/vendors/opencode/actions/polish-prose.json +13 -3
- package/vendors/opencode/actions/research-gap.json +16 -3
- package/vendors/opencode/actions/verify-work.json +13 -4
- package/vendors/opencode/agents/wtfp/research-synthesizer.md +1 -1
- package/vendors/opencode/aliases.lock.json +1 -0
- package/vendors/opencode/catalog.json +4 -2
- package/vendors/opencode/commands/wtfp/add-todo.md +54 -144
- package/vendors/opencode/commands/wtfp/advance.md +16 -0
- package/vendors/opencode/commands/wtfp/check-todos.md +54 -2
- package/vendors/opencode/commands/wtfp/checkpoint.md +66 -738
- package/vendors/opencode/commands/wtfp/create-outline.md +39 -431
- package/vendors/opencode/commands/wtfp/create-poster.md +43 -299
- package/vendors/opencode/commands/wtfp/create-slides.md +43 -299
- package/vendors/opencode/commands/wtfp/discuss-section.md +45 -262
- package/vendors/opencode/commands/wtfp/execute-outline.md +53 -486
- package/vendors/opencode/commands/wtfp/help.md +44 -3
- package/vendors/opencode/commands/wtfp/insert-section.md +44 -4
- package/vendors/opencode/commands/wtfp/list-assumptions.md +45 -513
- package/vendors/opencode/commands/wtfp/map-project.md +39 -0
- package/vendors/opencode/commands/wtfp/new-paper.md +39 -0
- package/vendors/opencode/commands/wtfp/pause-writing.md +54 -309
- package/vendors/opencode/commands/wtfp/plan-milestone-gaps.md +42 -370
- package/vendors/opencode/commands/wtfp/plan-revision.md +229 -277
- package/vendors/opencode/commands/wtfp/plan-section.md +47 -629
- package/vendors/opencode/commands/wtfp/polish-prose.md +217 -268
- package/vendors/opencode/commands/wtfp/progress.md +55 -1143
- package/vendors/opencode/commands/wtfp/quick.md +41 -220
- package/vendors/opencode/commands/wtfp/resume-writing.md +54 -698
- package/vendors/opencode/commands/wtfp/review-section.md +42 -411
- package/vendors/opencode/commands/wtfp/settings.md +54 -2
- package/vendors/opencode/commands/wtfp/submit-milestone.md +42 -620
- package/vendors/opencode/commands/wtfp/verify-work.md +169 -57
- package/vendors/opencode/commands/wtfp/write-section.md +45 -486
- package/vendors/opencode/compatibility/action-availability.json +13 -1
- package/vendors/opencode/project/README.md +39 -0
- package/vendors/opencode/project/schemas/interaction.schema.json +100 -0
- package/vendors/opencode/project/templates/interaction.json +16 -0
- package/vendors/opencode/roles/research-synthesizer.md +1 -1
- package/vendors/opencode/skills/wtfp-deliver-research/SKILL.md +1 -1
- package/vendors/opencode/skills/wtfp-deliver-research/references/actions.md +2 -2
- package/vendors/opencode/skills/wtfp-manage-project/SKILL.md +2 -1
- package/vendors/opencode/skills/wtfp-manage-project/references/actions.md +29 -1
- package/vendors/opencode/skills/wtfp-plan-section/SKILL.md +1 -1
- package/vendors/opencode/skills/wtfp-plan-section/references/actions.md +4 -3
- package/vendors/opencode/skills/wtfp-research-literature/SKILL.md +1 -1
- package/vendors/opencode/skills/wtfp-research-literature/references/actions.md +1 -1
- package/vendors/opencode/skills/wtfp-review-manuscript/SKILL.md +1 -1
- package/vendors/opencode/skills/wtfp-review-manuscript/references/actions.md +2 -1
- package/vendors/opencode/skills/wtfp-write-section/SKILL.md +1 -1
- package/vendors/opencode/skills/wtfp-write-section/references/actions.md +1 -1
- package/vendors/opencode/tools/README.md +1 -1
- package/vendors/opencode/workflows/advance.md +38 -0
- package/vendors/opencode/workflows/checkpoint.md +2 -2
- package/vendors/opencode/workflows/discuss-section.md +1 -1
- package/vendors/opencode/workflows/execute-outline.md +2 -2
- package/vendors/opencode/workflows/export-latex.md +4 -4
- package/vendors/opencode/workflows/plan-revision.md +4 -3
- package/vendors/opencode/workflows/plan-section.md +3 -3
- package/vendors/opencode/workflows/polish-prose.md +3 -3
- package/vendors/opencode/workflows/research-gap.md +5 -5
- package/vendors/opencode/workflows/verify-work.md +5 -3
- package/vendors/opencode/workflows/write-section.md +4 -4
- package/vendors/plugin/.wtfp-generated.json +101 -81
- package/vendors/plugin/actions/advance.json +232 -0
- package/vendors/plugin/actions/checkpoint.json +10 -1
- package/vendors/plugin/actions/execute-outline.json +10 -2
- package/vendors/plugin/actions/export-latex.json +15 -2
- package/vendors/plugin/actions/plan-revision.json +22 -4
- package/vendors/plugin/actions/polish-prose.json +13 -3
- package/vendors/plugin/actions/research-gap.json +16 -3
- package/vendors/plugin/actions/verify-work.json +13 -4
- package/vendors/plugin/ai.iowarp.clio/agents/wtfp-argument-verifier.md +7 -8
- package/vendors/plugin/ai.iowarp.clio/agents/wtfp-citation-expert.md +5 -5
- package/vendors/plugin/ai.iowarp.clio/agents/wtfp-citation-formatter.md +3 -3
- package/vendors/plugin/ai.iowarp.clio/agents/wtfp-coherence-checker.md +9 -10
- package/vendors/plugin/ai.iowarp.clio/agents/wtfp-outliner.md +3 -3
- package/vendors/plugin/ai.iowarp.clio/agents/wtfp-plan-checker.md +7 -8
- package/vendors/plugin/ai.iowarp.clio/agents/wtfp-prose-polisher.md +4 -4
- package/vendors/plugin/ai.iowarp.clio/agents/wtfp-research-synthesizer.md +6 -6
- package/vendors/plugin/ai.iowarp.clio/agents/wtfp-section-planner.md +3 -3
- package/vendors/plugin/ai.iowarp.clio/agents/wtfp-section-reviewer.md +9 -10
- package/vendors/plugin/ai.iowarp.clio/agents/wtfp-section-writer.md +3 -3
- package/vendors/plugin/ai.iowarp.clio/playbooks/wtfp-draft-review.md +1 -1
- package/vendors/plugin/ai.iowarp.clio/playbooks/wtfp-plan-section.md +1 -1
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/add-todo.md +21 -4
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/advance.md +101 -0
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/analyze-bib.md +27 -8
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/audit-milestone.md +26 -5
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/check-refs.md +40 -7
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/check-todos.md +25 -5
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/checkpoint.md +27 -7
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/create-outline.md +26 -8
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/create-poster.md +27 -13
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/create-slides.md +27 -13
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/discuss-section.md +26 -6
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/execute-outline.md +42 -9
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/export-latex.md +35 -24
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/help.md +4 -1
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/insert-section.md +25 -5
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/list-assumptions.md +21 -17
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/map-project.md +21 -4
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/new-paper.md +25 -5
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/pause-writing.md +21 -4
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/plan-milestone-gaps.md +25 -5
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/plan-revision.md +33 -20
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/plan-section.md +42 -10
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/polish-prose.md +43 -10
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/progress.md +26 -30
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/quick.md +40 -7
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/research-gap.md +51 -13
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/resume-writing.md +25 -5
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/review-section.md +36 -7
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/settings.md +25 -5
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/submit-milestone.md +27 -5
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/verify-work.md +30 -8
- package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/write-section.md +44 -11
- package/vendors/plugin/aliases.lock.json +1 -0
- package/vendors/plugin/catalog.json +4 -2
- package/vendors/plugin/compatibility/action-availability.json +11 -5
- package/vendors/plugin/plugin.json +16 -2
- package/vendors/plugin/project/README.md +39 -0
- package/vendors/plugin/project/schemas/interaction.schema.json +100 -0
- package/vendors/plugin/project/templates/interaction.json +16 -0
- package/vendors/plugin/roles/research-synthesizer.md +1 -1
- package/vendors/plugin/skills/wtfp-deliver-research/SKILL.md +1 -1
- package/vendors/plugin/skills/wtfp-deliver-research/references/actions.md +2 -2
- package/vendors/plugin/skills/wtfp-manage-project/SKILL.md +2 -1
- package/vendors/plugin/skills/wtfp-manage-project/references/actions.md +13 -1
- package/vendors/plugin/skills/wtfp-plan-section/SKILL.md +1 -1
- package/vendors/plugin/skills/wtfp-plan-section/references/actions.md +4 -3
- package/vendors/plugin/skills/wtfp-research-literature/SKILL.md +1 -1
- package/vendors/plugin/skills/wtfp-research-literature/references/actions.md +1 -1
- package/vendors/plugin/skills/wtfp-review-manuscript/SKILL.md +1 -1
- package/vendors/plugin/skills/wtfp-review-manuscript/references/actions.md +2 -1
- package/vendors/plugin/skills/wtfp-write-section/SKILL.md +1 -1
- package/vendors/plugin/skills/wtfp-write-section/references/actions.md +1 -1
- package/vendors/plugin/tools/README.md +1 -1
- package/vendors/plugin/workflows/advance.md +38 -0
- package/vendors/plugin/workflows/checkpoint.md +2 -2
- package/vendors/plugin/workflows/discuss-section.md +1 -1
- package/vendors/plugin/workflows/execute-outline.md +2 -2
- package/vendors/plugin/workflows/export-latex.md +4 -4
- package/vendors/plugin/workflows/plan-revision.md +4 -3
- package/vendors/plugin/workflows/plan-section.md +3 -3
- package/vendors/plugin/workflows/polish-prose.md +3 -3
- package/vendors/plugin/workflows/research-gap.md +5 -5
- package/vendors/plugin/workflows/verify-work.md +5 -3
- package/vendors/plugin/workflows/write-section.md +4 -4
- package/vendors/antigravity/commands/wtfp-plan-section.md +0 -78
- package/vendors/antigravity/commands/wtfp-write-section.md +0 -77
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
// Generated by WTF-P adapter compiler v5 from clio/runtime/extension.test.ts; do not edit.
|
|
2
2
|
/**
|
|
3
3
|
* Package tests for the WTF-P desk, run by `clio-coder extensions test
|
|
4
|
-
* vendors/clio-extension`.
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* passes one.
|
|
4
|
+
* vendors/clio-extension`. Each case builds a small valid project in a
|
|
5
|
+
* task-owned TMPDIR and drives the desk the way Clio does: tool calls,
|
|
6
|
+
* interviews, hooks and observations. The kit serves no plugin unless a case
|
|
7
|
+
* passes one. Answers here are simulated interview events, not a human's:
|
|
8
|
+
* they test the desk's bookkeeping, never an author's judgment.
|
|
8
9
|
*/
|
|
9
10
|
import assert from "node:assert/strict";
|
|
10
|
-
import {
|
|
11
|
+
import { createHash, createHmac } from "node:crypto";
|
|
12
|
+
import { spawnSync } from "node:child_process";
|
|
13
|
+
import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, readlinkSync, realpathSync, rmSync, statSync, symlinkSync, utimesSync, writeFileSync } from "node:fs";
|
|
14
|
+
import os, { homedir } from "node:os";
|
|
11
15
|
import path from "node:path";
|
|
12
16
|
import { test } from "node:test";
|
|
13
17
|
import { fileURLToPath } from "node:url";
|
|
@@ -17,15 +21,22 @@ const ROOT = fileURLToPath(new URL("../", import.meta.url));
|
|
|
17
21
|
const PROJECT = "desk-test";
|
|
18
22
|
const AT = "2026-10-01T12:00:00Z";
|
|
19
23
|
const GATE = "checkpoint-framing";
|
|
24
|
+
const PLAN_GATE = "approve-initial";
|
|
25
|
+
const PLAN_URI = "project://sections/introduction/plans/initial";
|
|
26
|
+
const PLAN_FILE = ".planning/sections/introduction/plans/initial.md";
|
|
27
|
+
|
|
28
|
+
type Json = Record<string, unknown>;
|
|
29
|
+
type Host = Awaited<ReturnType<typeof createExtensionTestHost>>;
|
|
30
|
+
|
|
31
|
+
function put(workspace: string, relative: string, value: unknown): void {
|
|
32
|
+
mkdirSync(path.dirname(path.join(workspace, relative)), { recursive: true });
|
|
33
|
+
writeFileSync(path.join(workspace, relative), typeof value === "string" ? value : `${JSON.stringify(value, null, 2)}\n`);
|
|
34
|
+
}
|
|
20
35
|
|
|
21
36
|
function project(): string {
|
|
22
37
|
assert.ok(process.env.TMPDIR, "Tests need a task-owned TMPDIR.");
|
|
23
38
|
const workspace = mkdtempSync(path.join(process.env.TMPDIR, "wtfp-desk-test-"));
|
|
24
|
-
|
|
25
|
-
mkdirSync(path.dirname(path.join(workspace, relative)), { recursive: true });
|
|
26
|
-
writeFileSync(path.join(workspace, relative), typeof value === "string" ? value : `${JSON.stringify(value, null, 2)}\n`);
|
|
27
|
-
};
|
|
28
|
-
put(".planning/project.json", {
|
|
39
|
+
put(workspace, ".planning/project.json", {
|
|
29
40
|
schema: "wtfp.project.manifest/v1",
|
|
30
41
|
protocol_version: 1,
|
|
31
42
|
id: PROJECT,
|
|
@@ -43,12 +54,12 @@ function project(): string {
|
|
|
43
54
|
decisions: "project://decisions",
|
|
44
55
|
outline: "project://structure/outline",
|
|
45
56
|
materials: [],
|
|
46
|
-
manuscripts: [],
|
|
57
|
+
manuscripts: ["project://paper/introduction"],
|
|
47
58
|
deliverables: [],
|
|
48
59
|
archives: [],
|
|
49
60
|
},
|
|
50
61
|
});
|
|
51
|
-
put(".planning/config.json", {
|
|
62
|
+
put(workspace, ".planning/config.json", {
|
|
52
63
|
schema: "wtfp.project.config/v1",
|
|
53
64
|
project_id: PROJECT,
|
|
54
65
|
interaction_mode: "standard",
|
|
@@ -61,7 +72,7 @@ function project(): string {
|
|
|
61
72
|
safety: { destructive_requires_authorization: true, external_publish_requires_authorization: true, backup_before_major_edits: true },
|
|
62
73
|
parallelism: { enabled: false, max_workers: 1 },
|
|
63
74
|
});
|
|
64
|
-
put(".planning/state.json", {
|
|
75
|
+
put(workspace, ".planning/state.json", {
|
|
65
76
|
schema: "wtfp.project.state/v1",
|
|
66
77
|
project_id: PROJECT,
|
|
67
78
|
revision: 3,
|
|
@@ -69,11 +80,11 @@ function project(): string {
|
|
|
69
80
|
status: "active",
|
|
70
81
|
current_section_uri: "project://sections/introduction",
|
|
71
82
|
progress: { sections_total: 1, sections_complete: 0, word_target: 100, word_count: 0 },
|
|
72
|
-
active_checkpoint_uris: [`project://checkpoints/${GATE}`],
|
|
73
|
-
last_transition: { from: "planning", to: "writing", reason: "The plan is
|
|
83
|
+
active_checkpoint_uris: [`project://checkpoints/${GATE}`, `project://checkpoints/${PLAN_GATE}`],
|
|
84
|
+
last_transition: { from: "planning", to: "writing", reason: "The plan is linked.", at: AT },
|
|
74
85
|
updated_at: AT,
|
|
75
86
|
});
|
|
76
|
-
put(".planning/structure/outline.json", {
|
|
87
|
+
put(workspace, ".planning/structure/outline.json", {
|
|
77
88
|
schema: "wtfp.project.outline/v1",
|
|
78
89
|
project_id: PROJECT,
|
|
79
90
|
revision: 1,
|
|
@@ -94,7 +105,7 @@ function project(): string {
|
|
|
94
105
|
],
|
|
95
106
|
updated_at: AT,
|
|
96
107
|
});
|
|
97
|
-
put(".planning/sections/introduction/section.json", {
|
|
108
|
+
put(workspace, ".planning/sections/introduction/section.json", {
|
|
98
109
|
schema: "wtfp.project.section/v1",
|
|
99
110
|
id: "introduction",
|
|
100
111
|
project_id: PROJECT,
|
|
@@ -107,18 +118,13 @@ function project(): string {
|
|
|
107
118
|
wave: 1,
|
|
108
119
|
depends_on: [],
|
|
109
120
|
claims: [],
|
|
110
|
-
artifacts: {
|
|
111
|
-
|
|
112
|
-
research: "project://sections/introduction/research",
|
|
113
|
-
plans: ["project://sections/introduction/plans/initial"],
|
|
114
|
-
reviews: [],
|
|
115
|
-
manuscript: "project://paper/introduction",
|
|
116
|
-
},
|
|
117
|
-
checkpoint_uris: [`project://checkpoints/${GATE}`],
|
|
121
|
+
artifacts: { plans: [PLAN_URI], reviews: [], manuscript: "project://paper/introduction" },
|
|
122
|
+
checkpoint_uris: [`project://checkpoints/${GATE}`, `project://checkpoints/${PLAN_GATE}`],
|
|
118
123
|
validation_uris: [],
|
|
119
124
|
updated_at: AT,
|
|
120
125
|
});
|
|
121
|
-
put(
|
|
126
|
+
put(workspace, PLAN_FILE, "# Plan\n\n1. State the bottleneck.\n2. State the contribution.\n");
|
|
127
|
+
put(workspace, `.planning/checkpoints/${GATE}.json`, {
|
|
122
128
|
schema: "wtfp.project.checkpoint/v1",
|
|
123
129
|
id: GATE,
|
|
124
130
|
project_id: PROJECT,
|
|
@@ -134,25 +140,68 @@ function project(): string {
|
|
|
134
140
|
resume_action: "write-section",
|
|
135
141
|
created_at: AT,
|
|
136
142
|
});
|
|
143
|
+
put(workspace, `.planning/checkpoints/${PLAN_GATE}.json`, {
|
|
144
|
+
schema: "wtfp.project.checkpoint/v1",
|
|
145
|
+
id: PLAN_GATE,
|
|
146
|
+
project_id: PROJECT,
|
|
147
|
+
kind: "decision",
|
|
148
|
+
status: "pending",
|
|
149
|
+
blocking: true,
|
|
150
|
+
scope_uri: PLAN_URI,
|
|
151
|
+
request: "Approve the introduction plan?",
|
|
152
|
+
options: [
|
|
153
|
+
{ id: "approve", label: "Approve", implication: "The writer drafts from exactly this plan." },
|
|
154
|
+
{ id: "revise", label: "Revise", implication: "The plan is rewritten before drafting." },
|
|
155
|
+
],
|
|
156
|
+
resume_action: "write-section",
|
|
157
|
+
created_at: AT,
|
|
158
|
+
});
|
|
137
159
|
// Eleven body words: front matter, the heading, the citation key and the code block do not count.
|
|
138
160
|
put(
|
|
161
|
+
workspace,
|
|
139
162
|
"paper/introduction.md",
|
|
140
163
|
"---\ntitle: Introduction\n---\n# Introduction\n\nShared memory changes the cost of logging [@smith2024]. It's a well-known trade-off.\n\n```c\nint flush = 1;\n```\n",
|
|
141
164
|
);
|
|
165
|
+
// The desk test clock starts at the epoch; the existing draft is a day older than any approval a test gives.
|
|
166
|
+
utimesSync(path.join(workspace, "paper/introduction.md"), new Date(-86_400_000), new Date(-86_400_000));
|
|
142
167
|
return workspace;
|
|
143
168
|
}
|
|
144
169
|
|
|
145
|
-
type Json = Record<string, unknown>;
|
|
146
170
|
const read = (workspace: string, relative: string): Json => JSON.parse(readFileSync(path.join(workspace, relative), "utf8")) as Json;
|
|
171
|
+
const sha = (workspace: string, relative: string): string => createHash("sha256").update(readFileSync(path.join(workspace, relative))).digest("hex");
|
|
172
|
+
const interactions = (workspace: string): Json[] => {
|
|
173
|
+
const directory = path.join(workspace, ".planning/interactions");
|
|
174
|
+
return existsSync(directory) ? readdirSync(directory).sort().map((name) => read(workspace, `.planning/interactions/${name}`)) : [];
|
|
175
|
+
};
|
|
147
176
|
|
|
148
|
-
|
|
177
|
+
function tree(workspace: string, relative = "."): Record<string, string> {
|
|
178
|
+
const out: Record<string, string> = {};
|
|
179
|
+
for (const entry of readdirSync(path.join(workspace, relative), { withFileTypes: true })) {
|
|
180
|
+
const child = path.join(relative, entry.name);
|
|
181
|
+
if (entry.isDirectory()) Object.assign(out, tree(workspace, child));
|
|
182
|
+
else out[child] = sha(workspace, child);
|
|
183
|
+
}
|
|
184
|
+
return out;
|
|
185
|
+
}
|
|
149
186
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
187
|
+
const canonical = (value: unknown): string =>
|
|
188
|
+
Array.isArray(value)
|
|
189
|
+
? `[${value.map(canonical).join(",")}]`
|
|
190
|
+
: value !== null && typeof value === "object"
|
|
191
|
+
? `{${Object.keys(value).sort().map((name) => `${JSON.stringify(name)}:${canonical((value as Json)[name])}`).join(",")}}`
|
|
192
|
+
: JSON.stringify(value);
|
|
193
|
+
|
|
194
|
+
/** An interaction sealed the way the desk seals one, for tests that need a valid seal on a changed record. */
|
|
195
|
+
const resealed = (body: Json, key: Buffer): Json => ({
|
|
196
|
+
...body,
|
|
197
|
+
seal: { method: "hmac-sha256", key_id: createHash("sha256").update(key).digest("hex").slice(0, 16), mac: createHmac("sha256", key).update(canonical(body)).digest("hex") },
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
const SERVED = { id: "wtfp", prompts: ["wtfp:check-todos", "wtfp:plan-section", "wtfp:progress", "wtfp:write-section", "wtfp:research-gap"] };
|
|
201
|
+
|
|
202
|
+
async function withDesk(run: (host: Host, workspace: string) => Promise<void>, plugin: typeof SERVED | null = null): Promise<void> {
|
|
154
203
|
const workspace = project();
|
|
155
|
-
const host = await createExtensionTestHost(ROOT, { workspace, plugin });
|
|
204
|
+
const host = withClioFacts(await createExtensionTestHost(ROOT, { workspace, plugin }), workspace);
|
|
156
205
|
try {
|
|
157
206
|
await run(host, workspace);
|
|
158
207
|
} finally {
|
|
@@ -161,62 +210,1979 @@ async function withDesk(
|
|
|
161
210
|
}
|
|
162
211
|
}
|
|
163
212
|
|
|
164
|
-
|
|
213
|
+
async function ask(host: Host, checkpoint: string): Promise<string> {
|
|
214
|
+
const asked = await host.tool("gate", { checkpoint });
|
|
215
|
+
assert.equal(asked.interview?.id, "gate-one", asked.text);
|
|
216
|
+
return asked.interview?.step.key as string;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
async function answer(host: Host, checkpoint: string, choice: string): Promise<string> {
|
|
220
|
+
const key = await ask(host, checkpoint);
|
|
221
|
+
const done = await host.interview({ id: "gate-one", step: key, nav: "next", answers: { choice } });
|
|
222
|
+
return "done" in done ? done.text : `step ${done.step.key}`;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
const blocked = (result: { effects?: Array<{ kind: string }> }): string | null => {
|
|
226
|
+
const effect = result.effects?.find((entry) => entry.kind === "block_tool") as { reason?: string } | undefined;
|
|
227
|
+
return effect ? (effect.reason ?? "") : null;
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
const write = (host: Host, target: string) => host.hook({ point: "before_tool", tool: "write", turnId: "t1", args: { path: target } });
|
|
231
|
+
|
|
232
|
+
const rewriteOf = (result: { effects?: Array<{ kind: string }> }): Json | null =>
|
|
233
|
+
(result.effects?.find((effect) => effect.kind === "rewrite_tool_input") as { args?: Json } | undefined)?.args ?? null;
|
|
234
|
+
|
|
235
|
+
// --- the host's facts ------------------------------------------------------------
|
|
236
|
+
// Clio 0.6.3 sends a before_tool hook where a path-taking tool lands and, for
|
|
237
|
+
// dispatch, the plan admission parsed, and judges a rewritten call again. The
|
|
238
|
+
// desk judges only those, so the test host models them as Clio resolves them,
|
|
239
|
+
// with the test process's own access.
|
|
240
|
+
|
|
241
|
+
/** The WTF-P recipes Clio runs read-only: the reviewers, whose recipes are Clio's read-only class. */
|
|
242
|
+
const READ_ONLY_RECIPES = new Set(["wtfp-argument-verifier", "wtfp-coherence-checker", "wtfp-plan-checker", "wtfp-section-reviewer"]);
|
|
243
|
+
|
|
244
|
+
/** A path with its existing part resolved through links; the rest is kept as named. */
|
|
245
|
+
function physical(file: string): string {
|
|
246
|
+
let head = file;
|
|
247
|
+
const rest: string[] = [];
|
|
248
|
+
while (!existsSync(head) && path.dirname(head) !== head) {
|
|
249
|
+
rest.unshift(path.basename(head));
|
|
250
|
+
head = path.dirname(head);
|
|
251
|
+
}
|
|
252
|
+
return path.join(realpathSync(head), ...rest);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Where a write through `joined` lands, as Clio's canonicalizeRawPath walks it
|
|
257
|
+
* (src/core/path-canonical.ts): a link at any component, dangling or not, is
|
|
258
|
+
* read and the walk goes on from its target, a `..` after a link steps up from
|
|
259
|
+
* the link's target, and a missing component ends the walk. Null for a loop,
|
|
260
|
+
* more than 40 links, or a component that cannot be inspected.
|
|
261
|
+
*/
|
|
262
|
+
function clioWalk(joined: string): string | null {
|
|
263
|
+
const { root } = path.parse(joined);
|
|
264
|
+
const parts = joined.slice(root.length).split(path.sep).filter((part) => part !== "" && part !== ".");
|
|
265
|
+
const up = parts.indexOf("..");
|
|
266
|
+
const pending = up === -1 ? [] : parts.slice(up);
|
|
267
|
+
let cursor = path.resolve(path.join(root, ...(up === -1 ? parts : parts.slice(0, up))));
|
|
268
|
+
const real = (file: string): string | null => {
|
|
269
|
+
try {
|
|
270
|
+
return path.resolve(realpathSync(file));
|
|
271
|
+
} catch {
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
let current = real(cursor);
|
|
276
|
+
while (current === null) {
|
|
277
|
+
const parent = path.dirname(cursor);
|
|
278
|
+
if (parent === cursor) return null;
|
|
279
|
+
pending.unshift(path.basename(cursor));
|
|
280
|
+
cursor = parent;
|
|
281
|
+
current = real(cursor);
|
|
282
|
+
}
|
|
283
|
+
let hops = 0;
|
|
284
|
+
while (pending.length > 0) {
|
|
285
|
+
const part = pending.shift() as string;
|
|
286
|
+
if (part === "..") {
|
|
287
|
+
current = path.dirname(current);
|
|
288
|
+
continue;
|
|
289
|
+
}
|
|
290
|
+
const next = path.join(current, part);
|
|
291
|
+
let target: string;
|
|
292
|
+
try {
|
|
293
|
+
target = readlinkSync(next);
|
|
294
|
+
} catch (error) {
|
|
295
|
+
const code = (error as NodeJS.ErrnoException).code;
|
|
296
|
+
if (code === "EINVAL") {
|
|
297
|
+
current = next;
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
if (code === "ENOENT" || code === "ENOTDIR") {
|
|
301
|
+
if (!pending.includes("..")) return path.resolve(next, ...pending);
|
|
302
|
+
current = next;
|
|
303
|
+
continue;
|
|
304
|
+
}
|
|
305
|
+
return null;
|
|
306
|
+
}
|
|
307
|
+
hops += 1;
|
|
308
|
+
if (hops > 40) return null;
|
|
309
|
+
if (path.isAbsolute(target)) current = path.parse(target).root;
|
|
310
|
+
pending.unshift(...target.split(path.sep).filter(Boolean));
|
|
311
|
+
}
|
|
312
|
+
return current;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/** Where Clio lands a tool's path: `@` dropped, Unicode spaces plain, `~` expanded, then Clio's physical walk from the workspace it runs in. */
|
|
316
|
+
function clioTarget(raw: string, workspace: string): Json {
|
|
317
|
+
let spelled = (raw.startsWith("@") ? raw.slice(1) : raw).replace(/[\u00A0\u2000-\u200A\u202F\u205F\u3000]/gu, " ");
|
|
318
|
+
if (spelled === "~") spelled = homedir();
|
|
319
|
+
else if (spelled.startsWith("~/")) spelled = homedir() + spelled.slice(1);
|
|
320
|
+
const real = realpathSync(workspace);
|
|
321
|
+
// Clio runs in the workspace, so its own /proc/self/cwd is the workspace.
|
|
322
|
+
if (spelled === "/proc/self/cwd" || spelled.startsWith("/proc/self/cwd/")) spelled = real + spelled.slice("/proc/self/cwd".length);
|
|
323
|
+
const landed = clioWalk(path.isAbsolute(spelled) ? spelled : `${real}${path.sep}${spelled}`);
|
|
324
|
+
const at = landed ?? (path.isAbsolute(spelled) ? spelled : `${real}${path.sep}${spelled}`);
|
|
325
|
+
const relative = path.relative(real, at);
|
|
326
|
+
const inside = landed !== null && relative !== ".." && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative);
|
|
327
|
+
return { arg: "path", path: at, resolved: landed !== null, workspacePath: inside ? relative.split(path.sep).join("/") || "." : null };
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* A dispatch call as Clio's admission hands it to hooks (src/tools/dispatch-arguments.ts
|
|
332
|
+
* prepareDispatchArguments, src/tools/dispatch-admission.ts): `tasks` an array, a
|
|
333
|
+
* lone `task` moved into it, and either Clio's private resolved plan or the
|
|
334
|
+
* reason preparation failed. Clio refuses a `./` root and parallel writers
|
|
335
|
+
* without roots before any hook; these tests send no other failing shape.
|
|
336
|
+
*/
|
|
337
|
+
function clioPrepare(args: Json): Json {
|
|
338
|
+
const next: Json = { ...args };
|
|
339
|
+
if (typeof next.tasks === "string" && /^\s*[[{]/u.test(next.tasks)) {
|
|
340
|
+
try {
|
|
341
|
+
next.tasks = JSON.parse(next.tasks) as unknown;
|
|
342
|
+
} catch {
|
|
343
|
+
// Clio leaves the string and reports the shape itself.
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
if (next.tasks !== undefined && !Array.isArray(next.tasks)) next.tasks = [next.tasks];
|
|
347
|
+
if (next.tasks === undefined && typeof next.task === "string") {
|
|
348
|
+
const { task, ...rest } = next;
|
|
349
|
+
Object.assign(next, { ...rest, tasks: [{ task }] });
|
|
350
|
+
delete next.task;
|
|
351
|
+
}
|
|
352
|
+
if (args.list === true || args.apply_winner !== undefined || !Array.isArray(next.tasks)) return next;
|
|
353
|
+
const items = (next.tasks as unknown[]).map((task) => (typeof task === "string" ? { task } : (task as Json)));
|
|
354
|
+
const declared = items.map((item) => ((item.intent as Json | undefined)?.write_roots ?? (args.intent as Json | undefined)?.write_roots ?? []) as string[]);
|
|
355
|
+
const writers = items.filter((item, index) => !READ_ONLY_RECIPES.has(agentOf(item, args)) && declared[index] !== undefined);
|
|
356
|
+
const failure = declared.flat().some((root) => /^\.\/./u.test(root.trim()))
|
|
357
|
+
? "write_roots entries may not start with ./"
|
|
358
|
+
: writers.length > 1 && declared.some((roots, index) => !READ_ONLY_RECIPES.has(agentOf(items[index] as Json, args)) && roots.filter((root) => !/^\.\/?$/u.test(root.trim())).length === 0)
|
|
359
|
+
? "parallel writers need disjoint intent.write_roots"
|
|
360
|
+
: null;
|
|
361
|
+
return failure === null ? { ...next, __clio_resolved_dispatch_plan: { resolvedBy: "clio" } } : { ...next, __clio_dispatch_plan_preparation_error: failure };
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
function agentOf(item: Json, args: Json): string {
|
|
365
|
+
const named = typeof item.agent === "string" ? item.agent : typeof args.agent === "string" ? args.agent : "";
|
|
366
|
+
return named.trim() || "coder";
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/** The plan Clio's admission reports for prepared arguments: write roots trimmed, without `.`, deduplicated and sorted, with their physical boundaries. */
|
|
370
|
+
function clioPlan(prepared: Json, workspace: string): Json {
|
|
371
|
+
const real = realpathSync(workspace);
|
|
372
|
+
if (prepared.list === true) return { kind: "list" };
|
|
373
|
+
if (prepared.apply_winner !== undefined) return { kind: "apply-winner", branch: String((prepared.apply_winner as Json).branch ?? ""), cwd: real };
|
|
374
|
+
const items = ((prepared.tasks ?? []) as unknown[]).map((task) => (typeof task === "string" ? { task } : (task as Json)));
|
|
375
|
+
const shared = (prepared.intent as Json | undefined)?.write_roots;
|
|
376
|
+
return {
|
|
377
|
+
kind: "tasks",
|
|
378
|
+
mode: "single",
|
|
379
|
+
tasks: items.map((item) => {
|
|
380
|
+
const spelledCwd = typeof item.cwd === "string" ? item.cwd : typeof prepared.cwd === "string" ? prepared.cwd : ".";
|
|
381
|
+
const cwd = physical(path.resolve(real, spelledCwd.trim() || "."));
|
|
382
|
+
const agent = agentOf(item, prepared);
|
|
383
|
+
// Clio runs a read-only recipe's worker read-only, with no write roots (src/tools/dispatch.ts writerLanding).
|
|
384
|
+
const readOnly = READ_ONLY_RECIPES.has(agent);
|
|
385
|
+
const roots = readOnly ? [] : [...new Set((((item.intent as Json | undefined)?.write_roots ?? shared ?? []) as string[]).map((root) => root.trim()).filter((root) => !/^\.\/?$/u.test(root)))].sort();
|
|
386
|
+
return { role: "task", agent, cwd, writeRoots: roots, writeBoundaries: roots.map((root) => physical(path.resolve(cwd, root))), worktree: item.worktree === true, readOnly };
|
|
387
|
+
}),
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/** A before_tool event as Clio 0.6.3 sends it, unless the test sent its own facts. */
|
|
392
|
+
function withFacts(event: Json, workspace: string): Json {
|
|
393
|
+
// Clio sends the same landing at after_tool as at before_tool.
|
|
394
|
+
if ((event.point !== "before_tool" && event.point !== "after_tool") || "target" in event || "dispatch" in event) return event;
|
|
395
|
+
const args = (event.args ?? {}) as Json;
|
|
396
|
+
if (event.tool === "dispatch") {
|
|
397
|
+
const prepared = clioPrepare(args);
|
|
398
|
+
return typeof prepared.__clio_dispatch_plan_preparation_error === "string" ? { ...event, args: prepared } : { ...event, args: prepared, dispatch: clioPlan(prepared, workspace) };
|
|
399
|
+
}
|
|
400
|
+
const raw = args.path ?? args.file_path ?? args.filePath;
|
|
401
|
+
if (["write", "edit", "artifact"].includes(event.tool as string) && typeof raw === "string" && raw.trim().length > 0)
|
|
402
|
+
return { ...event, target: clioTarget(event.tool === "artifact" ? raw.trim() : raw, workspace) };
|
|
403
|
+
return event;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* The test host as Clio 0.6.3 runs the desk: each before_tool event carries
|
|
408
|
+
* Clio's facts; a dispatch Clio could not prepare is refused by Clio with its
|
|
409
|
+
* own reason when no hook refused it first; and a call the desk rewrites is
|
|
410
|
+
* admitted afresh, so a plan-scale one, which needs the operator's approval,
|
|
411
|
+
* is refused, and any other is judged again with the plan of what it starts.
|
|
412
|
+
* An event marked `bare` reaches the desk as Clio 0.6.2 sends it.
|
|
413
|
+
*/
|
|
414
|
+
function withClioFacts(host: Host, workspace: string): Host {
|
|
415
|
+
const hook = host.hook.bind(host);
|
|
416
|
+
const refuse = (reason: string) => ({ effects: [{ kind: "block_tool", reason }] });
|
|
417
|
+
const judged = async (event: Json, options?: Json) => {
|
|
418
|
+
if (event.bare === true) {
|
|
419
|
+
const { bare: _bare, ...sent } = event;
|
|
420
|
+
return hook(sent as never, options as never);
|
|
421
|
+
}
|
|
422
|
+
const sent = withFacts(event, workspace);
|
|
423
|
+
const first = await hook(sent as never, options as never);
|
|
424
|
+
if (event.point !== "before_tool" || event.tool !== "dispatch" || "dispatch" in event) return first;
|
|
425
|
+
const failure = (sent.args as Json).__clio_dispatch_plan_preparation_error;
|
|
426
|
+
if (typeof failure === "string") return blocked(first) === null ? refuse(`Clio: ${failure}`) : first;
|
|
427
|
+
const rewritten = rewriteOf(first);
|
|
428
|
+
if (rewritten === null || blocked(first) !== null) return first;
|
|
429
|
+
if ((((sent.dispatch as Json).tasks as unknown[]) ?? []).length > 1) return refuse("extension wtfp rewrote dispatch input into a call that would need operator approval");
|
|
430
|
+
const second = await hook(withFacts({ ...event, args: rewritten }, workspace) as never, options as never);
|
|
431
|
+
const refused = blocked(second);
|
|
432
|
+
return refused === null ? first : refuse(`extension wtfp rewrote dispatch input into a call that is blocked: ${refused}`);
|
|
433
|
+
};
|
|
434
|
+
return new Proxy(host, { get: (target, key) => (key === "hook" ? judged : Reflect.get(target, key)) }) as Host;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/** The write roots a confining rewrite hands its single worker, wherever the rewrite put them. */
|
|
438
|
+
const rootsOf = (rewrite: Json | null): unknown =>
|
|
439
|
+
((((rewrite?.tasks as Json[] | undefined)?.[0]?.intent ?? rewrite?.intent) as Json | undefined)?.write_roots);
|
|
440
|
+
|
|
441
|
+
// --- record writes -------------------------------------------------------------
|
|
442
|
+
|
|
443
|
+
test("record writes at the revision or digest the caller read and refuses stale, blind and invalid writes", () =>
|
|
165
444
|
withDesk(async (host, workspace) => {
|
|
166
445
|
const state = read(workspace, ".planning/state.json");
|
|
167
446
|
const written = await host.tool("record", { uri: "project://state", record: { ...state, phase: "reviewing" }, expect_revision: 3 });
|
|
168
447
|
assert.equal(written.isError, undefined, written.text);
|
|
169
|
-
assert.
|
|
170
|
-
assert.equal(read(workspace, ".planning/state.json").phase, "reviewing");
|
|
448
|
+
assert.equal((written.data as Json).revision, 4);
|
|
171
449
|
const stale = await host.tool("record", { uri: "project://state", record: { ...state, phase: "ready" }, expect_revision: 3 });
|
|
172
|
-
assert.equal(stale.isError, true);
|
|
173
450
|
assert.match(stale.text, /revision 4, not 3/);
|
|
174
|
-
const
|
|
175
|
-
assert.
|
|
451
|
+
const blind = await host.tool("record", { uri: "project://state", record: { ...state, phase: "ready" } });
|
|
452
|
+
assert.match(blind.text, /already exists; read it with extension_wtfp__read_record/);
|
|
453
|
+
const invalid = await host.tool("record", { uri: "project://state", record: { ...state, phase: "drafting" }, expect_revision: 4 });
|
|
176
454
|
assert.match(invalid.text, /would not validate/);
|
|
177
455
|
assert.deepEqual([read(workspace, ".planning/state.json").phase, read(workspace, ".planning/state.json").revision], ["reviewing", 4]);
|
|
456
|
+
|
|
457
|
+
// Two writers read the same section bytes; only the first lands (R1).
|
|
458
|
+
const section = read(workspace, ".planning/sections/introduction/section.json");
|
|
459
|
+
const seen = (await host.tool("read_record", { uri: "project://sections/introduction" })).data as Json;
|
|
460
|
+
assert.equal(seen.sha256, sha(workspace, ".planning/sections/introduction/section.json"));
|
|
461
|
+
const first = await host.tool("record", { uri: "project://sections/introduction", record: { ...section, goal: "First writer." }, expect_sha256: seen.sha256 });
|
|
462
|
+
assert.equal(first.isError, undefined, first.text);
|
|
463
|
+
const second = await host.tool("record", { uri: "project://sections/introduction", record: { ...section, goal: "Second writer." }, expect_sha256: seen.sha256 });
|
|
464
|
+
assert.match(second.text, /changed since it was read/);
|
|
465
|
+
assert.equal(read(workspace, ".planning/sections/introduction/section.json").goal, "First writer.");
|
|
466
|
+
|
|
467
|
+
const gone = await host.tool("record", { uri: "project://sources/never-made", record: {}, expect_sha256: "0".repeat(64) });
|
|
468
|
+
assert.match(gone.text, /holds wtfp.project.source\/v1|no longer exists/);
|
|
178
469
|
}));
|
|
179
470
|
|
|
180
|
-
test("
|
|
471
|
+
test("record refuses wrong type, id, project and unknown fields without touching the destination", () =>
|
|
181
472
|
withDesk(async (host, workspace) => {
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
473
|
+
const before = sha(workspace, ".planning/sections/introduction/section.json");
|
|
474
|
+
const section = read(workspace, ".planning/sections/introduction/section.json");
|
|
475
|
+
const expect_sha256 = before;
|
|
476
|
+
const cases: Array<[Json, RegExp]> = [
|
|
477
|
+
[{ ...section, schema: "wtfp.project.source/v1" }, /holds wtfp.project.section\/v1/],
|
|
478
|
+
[{ ...section, id: "methods" }, /whose id is introduction/],
|
|
479
|
+
[{ ...section, project_id: "another-project" }, /belongs to project another-project/],
|
|
480
|
+
[{ ...section, surprise: true }, /would not validate: .*unknown property surprise|surprise/],
|
|
481
|
+
// A model fixes what it is told; it is told the missing project_id and every schema error at once.
|
|
482
|
+
[(({ project_id: _omitted, ...rest }) => rest)(section), /needs project_id "desk-test"/],
|
|
483
|
+
[{ ...section, surprise: true, other: 1 }, /would not validate: .*surprise.*; .*other/],
|
|
484
|
+
];
|
|
485
|
+
for (const [record, pattern] of cases) {
|
|
486
|
+
const refused = await host.tool("record", { uri: "project://sections/introduction", record, expect_sha256 });
|
|
487
|
+
assert.equal(refused.isError, true);
|
|
488
|
+
assert.match(refused.text, pattern);
|
|
489
|
+
}
|
|
490
|
+
assert.equal(sha(workspace, ".planning/sections/introduction/section.json"), before);
|
|
491
|
+
// An authored artifact is not a record; the refusal names its file instead of leaving the model to search.
|
|
492
|
+
const artifact = await host.tool("read_record", { uri: "project://sections/introduction/context" });
|
|
493
|
+
assert.match(artifact.text, /authored artifact, not a JSON record; read or write \.planning\/sections\/introduction\/context\.md with the file tools/);
|
|
494
|
+
const plan = await host.tool("read_record", { uri: "project://sections/introduction/plans/initial" });
|
|
495
|
+
assert.match(plan.text, /\.planning\/sections\/introduction\/plans\/initial\.md/);
|
|
496
|
+
// A record that does not exist yet comes with its example, and so does a refused create (live: four calls, one field each).
|
|
497
|
+
const missing = await host.tool("read_record", { uri: "project://sections/methods" });
|
|
498
|
+
assert.match(missing.text, /does not exist yet[\s\S]*A section record looks like this example[\s\S]*"outline_uri"/);
|
|
499
|
+
const bare = await host.tool("record", { uri: "project://sections/methods", record: { schema: "wtfp.project.section/v1", id: "methods", project_id: PROJECT, title: "Methods" } });
|
|
500
|
+
assert.match(bare.text, /would not validate[\s\S]*A section record looks like this example[\s\S]*"word_target"/);
|
|
501
|
+
// A model has no clock: a validation created without executed_at gets the desk's time.
|
|
502
|
+
const unstamped = { schema: "wtfp.project.validation/v1", id: "introduction-stamped", project_id: PROJECT, subject_uri: "project://paper/introduction", validator_role: "section-reviewer", action_id: "review-section", status: "passed", checks: [{ id: "plan-criteria", status: "passed", summary: "Every plan criterion holds.", evidence: ["Stated."] }], issues: [], next_actions: [], effects_applied: [] };
|
|
503
|
+
const stamped = await host.tool("record", { uri: "project://validations/introduction-stamped", record: unstamped });
|
|
504
|
+
assert.equal(stamped.isError, undefined, stamped.text);
|
|
505
|
+
assert.match(String(read(workspace, ".planning/validations/introduction-stamped.json").executed_at), /^\d{4}-\d{2}-\d{2}T/);
|
|
506
|
+
// An invented time, live a few minutes in the future, is replaced too: it ordered a review after the answer it preceded.
|
|
507
|
+
await host.tool("record", { uri: "project://validations/introduction-invented", record: { ...unstamped, id: "introduction-invented", executed_at: "2099-01-01T00:00:00Z" } });
|
|
508
|
+
assert.ok(String(read(workspace, ".planning/validations/introduction-invented.json").executed_at) < "2099", "the desk's time replaces the model's");
|
|
509
|
+
assert.match((await host.tool("read_record", { uri: "project://checkpoints/never-made" })).text, /omit updated_at and created_at, which the desk sets/);
|
|
510
|
+
// Live, a long record closed early and left its last fields beside it; the desk names them.
|
|
511
|
+
const strayFields = await host.tool("record", { uri: "project://validations/stray", record: { schema: "wtfp.project.validation/v1", id: "stray", project_id: PROJECT, subject_uri: "project://paper/introduction", validator_role: "section-reviewer", action_id: "review-section", status: "passed", checks: [{ id: "c", status: "passed", summary: "Holds.", evidence: ["Stated."] }] }, issues: [], next_actions: [], effects_applied: [] });
|
|
512
|
+
assert.equal(strayFields.isError, undefined, strayFields.text);
|
|
513
|
+
assert.match(strayFields.text, /^issues, next_actions, effects_applied arrived beside record and were moved inside it/);
|
|
514
|
+
assert.deepEqual(read(workspace, ".planning/validations/stray.json").next_actions, []);
|
|
515
|
+
const notFields = await host.tool("record", { uri: "project://validations/stray-2", record: { schema: "wtfp.project.validation/v1" }, surprise: 1 });
|
|
516
|
+
assert.match(notFields.text, /surprise is not a record tool argument/);
|
|
517
|
+
const update = await host.tool("record", { uri: "project://sections/introduction", record: { ...section, surprise: true }, expect_sha256 });
|
|
518
|
+
assert.doesNotMatch(update.text, /looks like this example/, "an update is refused without the example");
|
|
519
|
+
const snake = await host.tool("read_record", { uri: "project://checkpoints/confirm_outline" });
|
|
520
|
+
assert.match(snake.text, /invalid id; record ids are lowercase .* such as confirm-outline/);
|
|
187
521
|
}));
|
|
188
522
|
|
|
189
|
-
test("
|
|
523
|
+
test("no record write or file write escapes through a symbolic link", () =>
|
|
190
524
|
withDesk(async (host, workspace) => {
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
525
|
+
const outside = mkdtempSync(path.join(process.env.TMPDIR as string, "wtfp-outside-"));
|
|
526
|
+
try {
|
|
527
|
+
symlinkSync(outside, path.join(workspace, ".planning/sections/escape"));
|
|
528
|
+
const section = { ...read(workspace, ".planning/sections/introduction/section.json"), id: "escape", title: "Escape" };
|
|
529
|
+
const refused = await host.tool("record", { uri: "project://sections/escape", record: section });
|
|
530
|
+
assert.match(refused.text, /symbolic link/);
|
|
531
|
+
assert.deepEqual(readdirSync(outside), []);
|
|
532
|
+
// A link that lands in paper/ is judged where it lands (W2).
|
|
533
|
+
symlinkSync(path.join(workspace, "paper"), path.join(workspace, "drafts"));
|
|
534
|
+
assert.match(blocked(await write(host, "drafts/introduction.md")) ?? "", /cannot be written yet/);
|
|
535
|
+
// Clio follows a dangling link to its target, here outside the project, and refuses the write if the link changes after the hook.
|
|
536
|
+
symlinkSync(path.join(outside, "missing"), path.join(workspace, "paper/dangling.md"));
|
|
537
|
+
assert.equal(blocked(await write(host, "paper/dangling.md")), null);
|
|
538
|
+
// A link Clio cannot resolve, such as a loop, is refused.
|
|
539
|
+
symlinkSync("loop", path.join(workspace, "paper/loop"));
|
|
540
|
+
assert.match(blocked(await write(host, "paper/loop/draft.md")) ?? "", /could not resolve/);
|
|
541
|
+
} finally {
|
|
542
|
+
rmSync(outside, { recursive: true, force: true });
|
|
543
|
+
}
|
|
544
|
+
}));
|
|
545
|
+
|
|
546
|
+
test("a readback that differs from what was written is reported against the file it names", () =>
|
|
547
|
+
withDesk(async (host, workspace) => {
|
|
548
|
+
const state = read(workspace, ".planning/state.json");
|
|
549
|
+
process.env.WTFP_DESK_TEST_FAULT = "tamper-after-rename";
|
|
550
|
+
try {
|
|
551
|
+
const result = await host.tool("record", { uri: "project://state", record: { ...state, phase: "reviewing" }, expect_revision: 3 });
|
|
552
|
+
assert.equal(result.isError, true);
|
|
553
|
+
assert.match(result.text, /readback of \.planning\/state\.json differs from what was written/);
|
|
554
|
+
assert.match(result.text, /^Committed, but/, "a write that landed is never reported as not written");
|
|
555
|
+
} finally {
|
|
556
|
+
delete process.env.WTFP_DESK_TEST_FAULT;
|
|
557
|
+
}
|
|
558
|
+
}));
|
|
559
|
+
|
|
560
|
+
// --- author gates --------------------------------------------------------------
|
|
561
|
+
|
|
562
|
+
test("a gate answer is recorded as a sealed interaction bound to what the author saw", () =>
|
|
563
|
+
withDesk(async (host, workspace) => {
|
|
564
|
+
const text = await answer(host, GATE, "workflow-first");
|
|
565
|
+
assert.match(text, /Recorded the author's answer: checkpoint-framing: Workflow first/);
|
|
197
566
|
const checkpoint = read(workspace, `.planning/checkpoints/${GATE}.json`);
|
|
198
567
|
assert.equal(checkpoint.status, "resolved");
|
|
199
568
|
assert.deepEqual(
|
|
200
569
|
[(checkpoint.resolution as Json).resolved_by, (checkpoint.resolution as Json).selected_option],
|
|
201
570
|
["author", "workflow-first"],
|
|
202
571
|
);
|
|
203
|
-
assert.deepEqual(read(workspace, ".planning/state.json").active_checkpoint_uris, []);
|
|
572
|
+
assert.deepEqual(read(workspace, ".planning/state.json").active_checkpoint_uris, [`project://checkpoints/${PLAN_GATE}`]);
|
|
573
|
+
const [interaction] = interactions(workspace);
|
|
574
|
+
assert.equal(interaction?.channel, "attested-interview");
|
|
575
|
+
assert.equal(interaction?.outcome, "selected");
|
|
576
|
+
assert.equal(interaction?.selected_option, "workflow-first");
|
|
577
|
+
assert.match(String((interaction?.seal as Json).mac), /^[a-f0-9]{64}$/);
|
|
578
|
+
const seen = (await host.tool("read_record", { uri: `project://checkpoints/${GATE}` })).data as Json;
|
|
579
|
+
assert.equal(seen.trust, "attested");
|
|
580
|
+
// The answer cannot be applied twice (G4).
|
|
581
|
+
const again = await host.tool("gate", { checkpoint: GATE });
|
|
582
|
+
assert.match(again.text, /already resolved by the author at this desk/);
|
|
583
|
+
}));
|
|
584
|
+
|
|
585
|
+
test("cancelling, headless asking and keeping a gate pending never resolve it (G2)", () =>
|
|
586
|
+
withDesk(async (host, workspace) => {
|
|
587
|
+
let key = await ask(host, GATE);
|
|
588
|
+
const cancelled = await host.interview({ id: "gate-one", step: key, nav: "cancel", answers: {}, reason: "operator" });
|
|
589
|
+
assert.match("done" in cancelled ? cancelled.text : "", /stays pending/);
|
|
590
|
+
key = await ask(host, GATE);
|
|
591
|
+
const headless = await host.interview({ id: "gate-one", step: key, nav: "cancel", answers: {}, reason: "headless" });
|
|
592
|
+
assert.match("done" in headless ? headless.text : "", /headless session; the gate stays pending and authorizes nothing/);
|
|
593
|
+
const kept = await answer(host, GATE, "__keep");
|
|
594
|
+
assert.match(kept, /kept checkpoint-framing pending/);
|
|
595
|
+
assert.equal(read(workspace, `.planning/checkpoints/${GATE}.json`).status, "pending");
|
|
596
|
+
assert.deepEqual(interactions(workspace).map((entry) => entry.outcome), ["kept-pending"]);
|
|
597
|
+
assert.ok(blocked(await write(host, "paper/introduction.md")));
|
|
598
|
+
}));
|
|
599
|
+
|
|
600
|
+
test("an answer that was not offered, replayed, or meant for another desk records nothing (G3, G4)", () =>
|
|
601
|
+
withDesk(async (host, workspace) => {
|
|
602
|
+
const key = await ask(host, GATE);
|
|
603
|
+
const offered = await host.interview({ id: "gate-one", step: key, nav: "next", answers: { choice: "__resolve" } });
|
|
604
|
+
assert.match("done" in offered ? offered.text : "", /not one of the options offered/);
|
|
605
|
+
const replay = await host.interview({ id: "gate-one", step: key, nav: "next", answers: { choice: "workflow-first" } });
|
|
606
|
+
assert.match("done" in replay ? replay.text : "", /matches no open question/);
|
|
607
|
+
const forged = await host.interview({ id: "gate-one", step: "gate.0123456789ab", nav: "next", answers: { choice: "workflow-first" } });
|
|
608
|
+
assert.match("done" in forged ? forged.text : "", /matches no open question/);
|
|
609
|
+
const other = project();
|
|
610
|
+
const elsewhere = withClioFacts(await createExtensionTestHost(ROOT, { workspace: other }), other);
|
|
611
|
+
try {
|
|
612
|
+
const foreign = await elsewhere.interview({ id: "gate-one", step: await ask(host, GATE), nav: "next", answers: { choice: "workflow-first" } });
|
|
613
|
+
assert.match("done" in foreign ? foreign.text : "", /matches no open question/);
|
|
614
|
+
assert.equal(read(other, `.planning/checkpoints/${GATE}.json`).status, "pending");
|
|
615
|
+
} finally {
|
|
616
|
+
await elsewhere.dispose();
|
|
617
|
+
rmSync(other, { recursive: true, force: true });
|
|
618
|
+
}
|
|
619
|
+
assert.equal(read(workspace, `.planning/checkpoints/${GATE}.json`).status, "pending");
|
|
620
|
+
assert.deepEqual(interactions(workspace), []);
|
|
621
|
+
}));
|
|
622
|
+
|
|
623
|
+
test("a question that changes while it is open sets the old answer aside and asks again (G3)", () =>
|
|
624
|
+
withDesk(async (host, workspace) => {
|
|
625
|
+
const key = await ask(host, PLAN_GATE);
|
|
626
|
+
writeFileSync(path.join(workspace, PLAN_FILE), "# Plan\n\n1. A different plan.\n");
|
|
627
|
+
const stale = await host.interview({ id: "gate-one", step: key, nav: "next", answers: { choice: "approve" } });
|
|
628
|
+
assert.ok(!("done" in stale), "a changed subject is asked again");
|
|
629
|
+
assert.equal(read(workspace, `.planning/checkpoints/${PLAN_GATE}.json`).status, "pending");
|
|
630
|
+
assert.deepEqual(interactions(workspace).map((entry) => entry.outcome), ["discarded-stale"]);
|
|
631
|
+
const checkpoint = read(workspace, `.planning/checkpoints/${PLAN_GATE}.json`);
|
|
632
|
+
const key2 = "step" in stale ? stale.step.key : "";
|
|
633
|
+
put(workspace, `.planning/checkpoints/${PLAN_GATE}.json`, { ...checkpoint, request: "Approve the rewritten plan?" });
|
|
634
|
+
const stale2 = await host.interview({ id: "gate-one", step: key2, nav: "next", answers: { choice: "approve" } });
|
|
635
|
+
assert.ok(!("done" in stale2));
|
|
636
|
+
assert.equal(read(workspace, `.planning/checkpoints/${PLAN_GATE}.json`).status, "pending");
|
|
637
|
+
}));
|
|
638
|
+
|
|
639
|
+
test("an agent cannot fabricate, unblock, rescope or expire an author gate through any write path it has (G1)", () =>
|
|
640
|
+
withDesk(async (host, workspace) => {
|
|
641
|
+
const checkpoint = read(workspace, `.planning/checkpoints/${GATE}.json`);
|
|
642
|
+
const expect_sha256 = sha(workspace, `.planning/checkpoints/${GATE}.json`);
|
|
643
|
+
const resolution = { resolved_by: "author", selected_option: "workflow-first", summary: "The author chose it.", resolved_at: AT };
|
|
644
|
+
const attempts: Array<[Json, RegExp]> = [
|
|
645
|
+
[{ ...checkpoint, status: "resolved", resolution }, /only the author's answer at the desk/],
|
|
646
|
+
[{ ...checkpoint, status: "resolved", resolution: { ...resolution, resolved_by: "policy" } }, /resolved only by the author/],
|
|
647
|
+
[{ ...checkpoint, blocking: false }, /cannot be made nonblocking/],
|
|
648
|
+
[{ ...checkpoint, scope_uri: "project://sections/elsewhere" }, /cannot change scope/],
|
|
649
|
+
[{ ...checkpoint, status: "expired" }, /cannot be expired by the agent/],
|
|
650
|
+
];
|
|
651
|
+
for (const [record, pattern] of attempts) {
|
|
652
|
+
const refused = await host.tool("record", { uri: `project://checkpoints/${GATE}`, record, expect_sha256 });
|
|
653
|
+
assert.match(refused.text, pattern);
|
|
654
|
+
}
|
|
655
|
+
const interaction = await host.tool("record", { uri: "project://interactions/fake", record: { schema: "wtfp.project.interaction/v1", id: "fake" } });
|
|
656
|
+
assert.match(interaction.text, /only the desk records an author's answer/);
|
|
657
|
+
const first = await write(host, `.planning/checkpoints/${GATE}.json`);
|
|
658
|
+
assert.match(blocked(first) ?? "", /portable record; write it with extension_wtfp__record/);
|
|
659
|
+
assert.ok(first.effects?.some((effect) => effect.kind === "protect_path"), "the desk asks the host to protect its answers from shell mutation");
|
|
660
|
+
assert.match(blocked(await write(host, ".planning/interactions/fake.json")) ?? "", /written only by the desk/);
|
|
661
|
+
const shell = await host.hook({ point: "before_tool", tool: "bash", turnId: "t1", args: { command: "python3 -c 'open(\".planning/interactions/x.json\",\"w\")'" } });
|
|
662
|
+
assert.match(blocked(shell) ?? "", /desk's own records/);
|
|
663
|
+
|
|
664
|
+
// A resolution written straight to disk is not the author's answer: it holds its scope and is offered for confirmation.
|
|
665
|
+
put(workspace, `.planning/checkpoints/${GATE}.json`, { ...checkpoint, status: "resolved", resolution });
|
|
666
|
+
const seen = (await host.tool("read_record", { uri: `project://checkpoints/${GATE}` })).data as Json;
|
|
667
|
+
assert.equal(seen.trust, "unattested");
|
|
668
|
+
await answer(host, PLAN_GATE, "approve");
|
|
669
|
+
assert.match(blocked(await write(host, "paper/introduction.md")) ?? "", /not observed by this desk and must be confirmed/);
|
|
670
|
+
const gates = await host.command("check-todos");
|
|
671
|
+
assert.match(gates.interview?.step.title ?? "", /Confirm a recorded answer/);
|
|
672
|
+
const confirmed = await host.interview({ id: "gate", step: gates.interview?.step.key as string, nav: "next", answers: { choice: "workflow-first" } });
|
|
673
|
+
assert.match("done" in confirmed ? confirmed.text : "", /Recorded: checkpoint-framing: Workflow first/);
|
|
674
|
+
assert.equal(blocked(await write(host, "paper/introduction.md")), null);
|
|
204
675
|
}));
|
|
205
676
|
|
|
206
|
-
test("
|
|
677
|
+
test("nonblocking policy resolutions and state snapshots are not author gates", () =>
|
|
678
|
+
withDesk(async (host, workspace) => {
|
|
679
|
+
const note = {
|
|
680
|
+
schema: "wtfp.project.checkpoint/v1",
|
|
681
|
+
id: "note-figure-style",
|
|
682
|
+
project_id: PROJECT,
|
|
683
|
+
kind: "human-action",
|
|
684
|
+
status: "pending",
|
|
685
|
+
blocking: false,
|
|
686
|
+
scope_uri: "project://sections/introduction",
|
|
687
|
+
request: "Pick a figure palette when convenient.",
|
|
688
|
+
options: [],
|
|
689
|
+
resume_action: "write-section",
|
|
690
|
+
created_at: AT,
|
|
691
|
+
};
|
|
692
|
+
const created = await host.tool("record", { uri: "project://checkpoints/note-figure-style", record: note });
|
|
693
|
+
assert.equal(created.isError, undefined, created.text);
|
|
694
|
+
const policy = { resolved_by: "policy", summary: "The configured default palette applies.", resolved_at: AT };
|
|
695
|
+
const resolved = await host.tool("record", {
|
|
696
|
+
uri: "project://checkpoints/note-figure-style",
|
|
697
|
+
record: { ...note, status: "resolved", resolution: policy },
|
|
698
|
+
expect_sha256: sha(workspace, ".planning/checkpoints/note-figure-style.json"),
|
|
699
|
+
});
|
|
700
|
+
assert.equal(resolved.isError, undefined, resolved.text);
|
|
701
|
+
assert.equal(((await host.tool("read_record", { uri: "project://checkpoints/note-figure-style" })).data as Json).trust, "policy");
|
|
702
|
+
const forged = await host.tool("record", {
|
|
703
|
+
uri: "project://checkpoints/blocking-by-policy",
|
|
704
|
+
record: { ...note, id: "blocking-by-policy", blocking: true, status: "resolved", resolution: policy },
|
|
705
|
+
});
|
|
706
|
+
assert.match(forged.text, /resolved only by the author/);
|
|
707
|
+
const snapshot = await host.tool("record", {
|
|
708
|
+
uri: "project://checkpoints/snapshot-before-revision",
|
|
709
|
+
record: {
|
|
710
|
+
...note,
|
|
711
|
+
id: "snapshot-before-revision",
|
|
712
|
+
kind: "state-snapshot",
|
|
713
|
+
status: "available",
|
|
714
|
+
request: "State before the revision.",
|
|
715
|
+
snapshot: { archive_uri: "project://archives/checkpoints/snapshot-before-revision", resources: [{ uri: "project://state", revision: 3, sha256: sha(workspace, ".planning/state.json") }] },
|
|
716
|
+
},
|
|
717
|
+
});
|
|
718
|
+
assert.equal(snapshot.isError, undefined, snapshot.text);
|
|
719
|
+
await answer(host, GATE, "protocol-first");
|
|
720
|
+
await answer(host, PLAN_GATE, "approve");
|
|
721
|
+
assert.equal(blocked(await write(host, "paper/introduction.md")), null, "neither the policy-resolved note nor the snapshot holds the section");
|
|
722
|
+
assert.match((await host.command("check-todos")).text, /No pending gates/);
|
|
723
|
+
}));
|
|
724
|
+
|
|
725
|
+
// --- approved plans and write boundaries ---------------------------------------------
|
|
726
|
+
|
|
727
|
+
test("the manuscript waits for an author-approved plan whose exact bytes were approved (W1)", () =>
|
|
728
|
+
withDesk(async (host, workspace) => {
|
|
729
|
+
await answer(host, GATE, "protocol-first");
|
|
730
|
+
assert.match(blocked(await write(host, "paper/introduction.md")) ?? "", /has not answered "Approve the introduction plan\?"/);
|
|
731
|
+
const declined = project();
|
|
732
|
+
const other = withClioFacts(await createExtensionTestHost(ROOT, { workspace: declined }), declined);
|
|
733
|
+
try {
|
|
734
|
+
await answer(other, GATE, "protocol-first");
|
|
735
|
+
await answer(other, PLAN_GATE, "revise");
|
|
736
|
+
assert.match(blocked(await write(other, "paper/introduction.md")) ?? "", /answered "revise" on approve-initial, not approve/);
|
|
737
|
+
} finally {
|
|
738
|
+
await other.dispose();
|
|
739
|
+
rmSync(declined, { recursive: true, force: true });
|
|
740
|
+
}
|
|
741
|
+
await answer(host, PLAN_GATE, "approve");
|
|
742
|
+
assert.equal(blocked(await write(host, "paper/introduction.md")), null);
|
|
743
|
+
const ready = await host.tool("readiness", { section: "introduction" });
|
|
744
|
+
assert.equal((ready.data as Json).ready, true, ready.text);
|
|
745
|
+
// A linked plan is immutable, and changing its bytes anyway voids the approval.
|
|
746
|
+
assert.match(blocked(await write(host, PLAN_FILE)) ?? "", /linked plans are immutable/);
|
|
747
|
+
writeFileSync(path.join(workspace, PLAN_FILE), "# Plan\n\n1. Something the author never saw.\n");
|
|
748
|
+
assert.match(blocked(await write(host, "paper/introduction.md")) ?? "", /plan changed after the author approved it/);
|
|
749
|
+
rmSync(path.join(workspace, PLAN_FILE));
|
|
750
|
+
assert.match(blocked(await write(host, "paper/introduction.md")) ?? "", /does not resolve to a plan file/);
|
|
751
|
+
// A status alone never stands in for a plan.
|
|
752
|
+
const section = read(workspace, ".planning/sections/introduction/section.json");
|
|
753
|
+
put(workspace, ".planning/sections/introduction/section.json", { ...section, artifacts: { plans: [], reviews: [], manuscript: "project://paper/introduction" } });
|
|
754
|
+
assert.match(blocked(await write(host, "paper/introduction.md")) ?? "", /no plan is linked/);
|
|
755
|
+
// Nested and variant manuscript paths are the same section's manuscript.
|
|
756
|
+
assert.ok(blocked(await write(host, "paper/introduction/results.md")));
|
|
757
|
+
assert.ok(blocked(await write(host, "paper/introduction.v2.md")));
|
|
758
|
+
assert.equal(blocked(await write(host, "paper/unrelated-notes.md")), null);
|
|
759
|
+
}));
|
|
760
|
+
|
|
761
|
+
test("literature-heavy sections wait for verified evidence behind their required claims", () =>
|
|
762
|
+
withDesk(async (host, workspace) => {
|
|
763
|
+
const outline = read(workspace, ".planning/structure/outline.json");
|
|
764
|
+
const [entry] = outline.sections as Json[];
|
|
765
|
+
put(workspace, ".planning/structure/outline.json", { ...outline, sections: [{ ...entry, research: { required: true, topics: ["logging"] } }] });
|
|
766
|
+
const section = read(workspace, ".planning/sections/introduction/section.json");
|
|
767
|
+
put(workspace, ".planning/sections/introduction/section.json", {
|
|
768
|
+
...section,
|
|
769
|
+
claims: [{ id: "claim-flush", statement: "Flushes dominate logging cost.", status: "planned", evidence_required: true, evidence_uris: [] }],
|
|
770
|
+
});
|
|
771
|
+
await answer(host, GATE, "protocol-first");
|
|
772
|
+
await answer(host, PLAN_GATE, "approve");
|
|
773
|
+
const ready = await host.tool("readiness", { section: "introduction" });
|
|
774
|
+
assert.equal((ready.data as Json).ready, false);
|
|
775
|
+
assert.match(ready.text, /1 required claim lacks verified evidence \(claim-flush\); run research-gap first/);
|
|
776
|
+
assert.match(blocked(await write(host, "paper/introduction.md")) ?? "", /research-gap/);
|
|
777
|
+
// Verified, full-text support makes it ready; a contradiction on record, an invalid record or a reused id takes that back.
|
|
778
|
+
put(workspace, ".planning/sources/source-flush.json", {
|
|
779
|
+
schema: "wtfp.project.source/v1", id: "source-flush", project_id: PROJECT, kind: "journal-article", title: "Flush Costs", creators: ["A. Author"], year: 2025,
|
|
780
|
+
identifiers: { doi: "10.1234/flush" }, citation_key: "author2025", status: "verified",
|
|
781
|
+
provenance: { discovered_via: "scholarly-index", inspection_depth: "full-text", verified_at: AT },
|
|
782
|
+
});
|
|
783
|
+
const support = {
|
|
784
|
+
schema: "wtfp.project.evidence/v1", id: "evidence-flush", project_id: PROJECT, source_uri: "project://sources/source-flush", claim_id: "claim-flush", relation: "supports",
|
|
785
|
+
statement: "Flushes dominate.", locator: { kind: "section", value: "3" }, interpretation: "Direct measurement.", confidence: "high", inspection_depth: "full-text", verified_at: AT,
|
|
786
|
+
};
|
|
787
|
+
put(workspace, ".planning/evidence/evidence-flush.json", support);
|
|
788
|
+
const linked = read(workspace, ".planning/sections/introduction/section.json");
|
|
789
|
+
put(workspace, ".planning/sections/introduction/section.json", { ...linked, claims: [{ ...(linked.claims as Json[])[0], evidence_uris: ["project://evidence/evidence-flush"] }] });
|
|
790
|
+
const readyNow = async () => ((await host.tool("readiness", { section: "introduction" })).data as Json).ready;
|
|
791
|
+
assert.equal(await readyNow(), true);
|
|
792
|
+
put(workspace, ".planning/evidence/evidence-against.json", { ...support, id: "evidence-against", relation: "contradicts" });
|
|
793
|
+
assert.equal(await readyNow(), false, "an unlinked contradiction contests the claim");
|
|
794
|
+
rmSync(path.join(workspace, ".planning/evidence/evidence-against.json"));
|
|
795
|
+
const { statement: _statement, ...statementless } = support;
|
|
796
|
+
put(workspace, ".planning/evidence/evidence-flush.json", statementless);
|
|
797
|
+
assert.equal(await readyNow(), false, "an evidence record that fails its schema supports nothing");
|
|
798
|
+
put(workspace, ".planning/evidence/evidence-flush.json", support);
|
|
799
|
+
// A second copy can only sit away from the protocol file, so it is the copy that is ignored, and reported.
|
|
800
|
+
put(workspace, ".planning/evidence/evidence-flush-copy.json", { ...support, relation: "contradicts" });
|
|
801
|
+
assert.equal(await readyNow(), true);
|
|
802
|
+
assert.match((await host.command("validate")).text, /record-ignored \.planning\/evidence\/evidence-flush-copy\.json/);
|
|
803
|
+
rmSync(path.join(workspace, ".planning/evidence/evidence-flush-copy.json"));
|
|
804
|
+
assert.equal(await readyNow(), true);
|
|
805
|
+
// project://evidence/evidence-flush resolves to one file; the same record anywhere else is not it.
|
|
806
|
+
writeFileSync(path.join(workspace, ".planning/evidence/renamed.json"), readFileSync(path.join(workspace, ".planning/evidence/evidence-flush.json")));
|
|
807
|
+
rmSync(path.join(workspace, ".planning/evidence/evidence-flush.json"));
|
|
808
|
+
assert.equal(await readyNow(), false, "evidence away from its protocol file supports nothing");
|
|
809
|
+
assert.match((await host.command("validate")).text, /record-ignored \.planning\/evidence\/renamed\.json/);
|
|
810
|
+
// A manuscript the desk will not follow cannot have its citations checked, and says so.
|
|
811
|
+
rmSync(path.join(workspace, "paper/introduction.md"));
|
|
812
|
+
symlinkSync(path.join(workspace, ".planning/project.json"), path.join(workspace, "paper/introduction.md"));
|
|
813
|
+
assert.match((await host.command("validate")).text, /manuscript-unread project:\/\/sections\/introduction/);
|
|
814
|
+
// A drafted section whose manuscript link names nothing under paper/ is reported too.
|
|
815
|
+
const linked2 = read(workspace, ".planning/sections/introduction/section.json");
|
|
816
|
+
put(workspace, ".planning/sections/introduction/section.json", { ...linked2, status: "writing", artifacts: { ...(linked2.artifacts as Json), manuscript: "project://materials/notes" } });
|
|
817
|
+
assert.match((await host.command("validate")).text, /manuscript-unread project:\/\/sections\/introduction: project:\/\/materials\/notes could not be checked/);
|
|
818
|
+
}, SERVED));
|
|
819
|
+
|
|
820
|
+
test("an author's note on a gate answer reaches the next step, and typed text asks again instead of answering", () =>
|
|
821
|
+
withDesk(async (host, workspace) => {
|
|
822
|
+
await answer(host, GATE, "protocol-first");
|
|
823
|
+
// Free text names no option: the same gate comes back with how to attach the text, and nothing is recorded.
|
|
824
|
+
const key = await ask(host, PLAN_GATE);
|
|
825
|
+
const typed = await host.interview({ id: "gate-one", step: key, nav: "next", answers: { choice: "Split the claim in two." }, other: { choice: true } } as never);
|
|
826
|
+
assert.ok(!("done" in typed), "the gate is asked again");
|
|
827
|
+
assert.match(JSON.stringify(typed.step.intro), /attach your text to it with \[n\] note/);
|
|
828
|
+
assert.equal((read(workspace, `.planning/checkpoints/${PLAN_GATE}.json`) as Json).status, "pending");
|
|
829
|
+
// An option with a note records both; the note is the author's own, inside the sealed answer's checkpoint.
|
|
830
|
+
const done = await host.interview({ id: "gate-one", step: typed.step.key, nav: "next", answers: { choice: "revise" }, notes: { choice: "Split the claim\nin two." } } as never);
|
|
831
|
+
assert.ok("done" in done, JSON.stringify(done));
|
|
832
|
+
const resolved = read(workspace, `.planning/checkpoints/${PLAN_GATE}.json`);
|
|
833
|
+
assert.equal((resolved.resolution as Json).selected_option, "revise");
|
|
834
|
+
assert.match(String((resolved.resolution as Json).summary), /The author's note: Split the claim in two\.$/);
|
|
835
|
+
const ready = await host.tool("readiness", { section: "introduction" });
|
|
836
|
+
assert.match(ready.text, /not approve, with this note for the next plan: Split the claim in two\./);
|
|
837
|
+
}, SERVED));
|
|
838
|
+
|
|
839
|
+
test("a complete draft goes to submit-milestone on a fresh audit with no errors, and back to audit after any later write", () =>
|
|
840
|
+
withDesk(async (host, workspace) => {
|
|
841
|
+
await answer(host, GATE, "protocol-first");
|
|
842
|
+
await answer(host, PLAN_GATE, "approve");
|
|
843
|
+
put(workspace, ".planning/sections/introduction/section.json", { ...read(workspace, ".planning/sections/introduction/section.json"), status: "complete" });
|
|
844
|
+
const nextOf = async () => (((await host.tool("status", {})).data as Json).next as Json).action;
|
|
845
|
+
assert.equal(await nextOf(), "audit-milestone");
|
|
846
|
+
const audit = { schema: "wtfp.project.validation/v1", id: "milestone-audit-01", project_id: PROJECT, subject_uri: "project://state", validator_role: "coherence-checker", action_id: "audit-milestone", status: "issues-found", checks: [{ id: "readiness", status: "passed", summary: "Every section is complete.", evidence: ["Stated."] }], issues: [{ severity: "warning", summary: "One source is metadata-only." }], next_actions: [], effects_applied: [], executed_at: AT };
|
|
847
|
+
put(workspace, ".planning/validations/milestone-audit-01.json", audit);
|
|
848
|
+
assert.equal(await nextOf(), "submit-milestone", "warnings alone do not hold delivery");
|
|
849
|
+
put(workspace, ".planning/validations/milestone-audit-01.json", { ...audit, issues: [{ severity: "error", summary: "A citation does not resolve." }] });
|
|
850
|
+
assert.equal(await nextOf(), "plan-milestone-gaps");
|
|
851
|
+
put(workspace, ".planning/validations/milestone-audit-01.json", audit);
|
|
852
|
+
// A passed submission delivers the draft; an audit after it keeps it delivered.
|
|
853
|
+
put(workspace, ".planning/validations/milestone-01.json", { ...audit, id: "milestone-01", action_id: "submit-milestone", status: "passed", issues: [] });
|
|
854
|
+
put(workspace, ".planning/validations/milestone-audit-02.json", { ...audit, id: "milestone-audit-02" });
|
|
855
|
+
assert.equal(await nextOf(), null, "delivered");
|
|
856
|
+
assert.match(String(((((await host.tool("status", {})).data as Json).next as Json).reason)), /^Delivered/);
|
|
857
|
+
const later = Date.now() / 1000 + 60;
|
|
858
|
+
utimesSync(path.join(workspace, "paper/introduction.md"), later, later);
|
|
859
|
+
assert.equal(await nextOf(), "audit-milestone", "an audit of an earlier draft does not stand for this one");
|
|
860
|
+
}, SERVED));
|
|
861
|
+
|
|
862
|
+
test("submit-milestone archives the whole project once, by digest, and nothing else may", () =>
|
|
863
|
+
withDesk(async (host, workspace) => {
|
|
864
|
+
const refused = await host.tool("archive", { archive: "draft-01" });
|
|
865
|
+
assert.match(refused.text, /nothing armed does not declare archiving project:\/\/archives\/draft-01/);
|
|
866
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:submit-milestone" });
|
|
867
|
+
const made = await host.tool("archive", { archive: "draft-01" });
|
|
868
|
+
assert.equal(made.isError, undefined, made.text);
|
|
869
|
+
const manifest = read(workspace, ".planning/archives/draft-01/manifest.json");
|
|
870
|
+
const files = manifest.files as Array<{ path: string; sha256: string }>;
|
|
871
|
+
assert.ok(files.some((file) => file.path === ".planning/project.json") && files.some((file) => file.path === "paper/introduction.md"));
|
|
872
|
+
for (const file of files) assert.equal(sha(workspace, `.planning/archives/draft-01/${file.path}`), file.sha256, file.path);
|
|
873
|
+
assert.match((await host.tool("archive", { archive: "draft-01" })).text, /already exists, and an archive is immutable/);
|
|
874
|
+
const again = await host.tool("archive", { archive: "draft-02" });
|
|
875
|
+
assert.ok(!(read(workspace, ".planning/archives/draft-02/manifest.json").files as Array<{ path: string }>).some((file) => file.path.startsWith(".planning/archives/")), again.text);
|
|
876
|
+
}, { id: "wtfp", prompts: [...SERVED.prompts, "wtfp:submit-milestone"] }));
|
|
877
|
+
|
|
878
|
+
test("the author's approval links the plan it approves, in the same commit", () =>
|
|
879
|
+
withDesk(async (host, workspace) => {
|
|
880
|
+
const section = read(workspace, ".planning/sections/introduction/section.json");
|
|
881
|
+
put(workspace, ".planning/sections/introduction/section.json", { ...section, status: "not-started", artifacts: { ...(section.artifacts as Json), plans: [] } });
|
|
882
|
+
await answer(host, GATE, "protocol-first");
|
|
883
|
+
assert.match(await answer(host, PLAN_GATE, "approve"), /The desk linked project:\/\/sections\/introduction\/plans\/initial in project:\/\/sections\/introduction with this answer; do not link it again\. The desk wrote project:\/\/checkpoints\/approve-initial, project:\/\/state, project:\/\/sections\/introduction; read any of them again before writing it/);
|
|
884
|
+
const linked = read(workspace, ".planning/sections/introduction/section.json");
|
|
885
|
+
assert.deepEqual((linked.artifacts as Json).plans, [PLAN_URI]);
|
|
886
|
+
assert.equal(linked.status, "planned");
|
|
887
|
+
assert.equal(((await host.tool("readiness", { section: "introduction" })).data as Json).ready, true);
|
|
888
|
+
}, SERVED));
|
|
889
|
+
|
|
890
|
+
test("a family URI reads every record of that family in one call, and names what it leaves out", () =>
|
|
891
|
+
withDesk(async (host, workspace) => {
|
|
892
|
+
const source = (id: string, title: string) => ({
|
|
893
|
+
schema: "wtfp.project.source/v1", id, project_id: PROJECT, kind: "journal-article", title, creators: ["A. Author"], year: 2025,
|
|
894
|
+
identifiers: { doi: `10.1234/${id}` }, citation_key: id.replace(/-/gu, ""), status: "verified",
|
|
895
|
+
provenance: { discovered_via: "scholarly-index", inspection_depth: "full-text", verified_at: AT },
|
|
896
|
+
});
|
|
897
|
+
const empty = await host.tool("read_record", { uri: "project://sources" });
|
|
898
|
+
assert.match(empty.text, /project:\/\/sources holds no records yet/);
|
|
899
|
+
put(workspace, ".planning/sources/source-a.json", source("source-a", "A"));
|
|
900
|
+
put(workspace, ".planning/sources/source-b.json", source("source-b", "B"));
|
|
901
|
+
const both = await host.tool("read_record", { uri: "project://sources/*" });
|
|
902
|
+
assert.match(both.text, /holds 2 records; 2 returned in full/);
|
|
903
|
+
const records = (both.data as Json).records as Json[];
|
|
904
|
+
assert.deepEqual(records.map((entry) => (entry.record as Json).id), ["source-a", "source-b"]);
|
|
905
|
+
assert.equal(records[0]?.sha256, (await host.tool("read_record", { uri: "project://sources/source-a" }) as { data: Json }).data.sha256);
|
|
906
|
+
// A family past the read's budget returns what fits and names the rest.
|
|
907
|
+
put(workspace, ".planning/sources/source-c.json", source("source-c", "C".repeat(60 * 1024)));
|
|
908
|
+
const capped = await host.tool("read_record", { uri: "project://sources" });
|
|
909
|
+
assert.deepEqual((capped.data as Json).omitted, ["source-c"]);
|
|
910
|
+
assert.match(capped.text, /1 more not returned, to keep this read small; read the next page with project:\/\/sources\?after=source-b/);
|
|
911
|
+
const next = await host.tool("read_record", { uri: "project://sources?after=source-b" });
|
|
912
|
+
assert.deepEqual(((next.data as Json).records as Json[]).map((entry) => (entry.record as Json).id), ["source-c"]);
|
|
913
|
+
// Sections are a family too, read from each section's own directory.
|
|
914
|
+
const sections = await host.tool("read_record", { uri: "project://sections" });
|
|
915
|
+
assert.deepEqual(((sections.data as Json).records as Json[]).map((entry) => entry.uri), ["project://sections/introduction"]);
|
|
916
|
+
}, SERVED));
|
|
917
|
+
|
|
918
|
+
test("a literature-heavy section that records no claim needing evidence is not covered", () =>
|
|
919
|
+
withDesk(async (host, workspace) => {
|
|
920
|
+
const outline = read(workspace, ".planning/structure/outline.json");
|
|
921
|
+
const [entry] = outline.sections as Json[];
|
|
922
|
+
put(workspace, ".planning/structure/outline.json", { ...outline, sections: [{ ...entry, research: { required: true, topics: ["logging"] } }] });
|
|
923
|
+
await answer(host, GATE, "protocol-first");
|
|
924
|
+
await answer(host, PLAN_GATE, "approve");
|
|
925
|
+
const ready = await host.tool("readiness", { section: "introduction" });
|
|
926
|
+
assert.equal((ready.data as Json).ready, false, "no claims means nothing shows the sources cover it");
|
|
927
|
+
assert.match(ready.text, /records no claim that needs evidence.*run research-gap first/);
|
|
928
|
+
assert.match(blocked(await write(host, "paper/introduction.md")) ?? "", /research-gap/);
|
|
929
|
+
// A rejected claim, or one that needs no evidence, covers nothing either.
|
|
930
|
+
const section = read(workspace, ".planning/sections/introduction/section.json");
|
|
931
|
+
const claim = { id: "claim-flush", statement: "Flushes dominate logging cost.", status: "rejected", evidence_required: true, evidence_uris: [] };
|
|
932
|
+
put(workspace, ".planning/sections/introduction/section.json", { ...section, claims: [claim, { ...claim, id: "claim-scope", status: "planned", evidence_required: false }] });
|
|
933
|
+
assert.equal(((await host.tool("readiness", { section: "introduction" })).data as Json).ready, false);
|
|
934
|
+
// Turning research off is the author's way to draft without it.
|
|
935
|
+
put(workspace, ".planning/structure/outline.json", { ...outline, sections: [{ ...entry, research: { required: false, topics: [] } }] });
|
|
936
|
+
assert.equal(((await host.tool("readiness", { section: "introduction" })).data as Json).ready, true);
|
|
937
|
+
}, SERVED));
|
|
938
|
+
|
|
939
|
+
test("a section file counts only for the section whose id names its directory", () =>
|
|
940
|
+
withDesk(async (host, workspace) => {
|
|
941
|
+
const outline = read(workspace, ".planning/structure/outline.json");
|
|
942
|
+
const [entry] = outline.sections as Json[];
|
|
943
|
+
put(workspace, ".planning/structure/outline.json", { ...outline, sections: [{ ...entry, research: { required: true, topics: ["logging"] } }] });
|
|
944
|
+
const section = read(workspace, ".planning/sections/introduction/section.json");
|
|
945
|
+
const claims = [{ id: "claim-flush", statement: "Flushes dominate logging cost.", status: "planned", evidence_required: true, evidence_uris: [] }];
|
|
946
|
+
put(workspace, ".planning/sections/introduction/section.json", { ...section, claims });
|
|
947
|
+
await answer(host, GATE, "protocol-first");
|
|
948
|
+
await answer(host, PLAN_GATE, "approve");
|
|
949
|
+
const readyNow = async () => ((await host.tool("readiness", { section: "introduction" })).data as Json).ready;
|
|
950
|
+
assert.equal(await readyNow(), false, "the unsupported required claim holds the section");
|
|
951
|
+
// Renaming the record inside the file must not move its claims out of the section the outline names.
|
|
952
|
+
put(workspace, ".planning/sections/introduction/section.json", { ...section, id: "intro-other", claims });
|
|
953
|
+
assert.equal(await readyNow(), false);
|
|
954
|
+
assert.ok(blocked(await write(host, "paper/introduction.md")));
|
|
955
|
+
assert.match((await host.command("validate")).text, /record-ignored \.planning\/sections\/introduction\/section\.json/);
|
|
956
|
+
}, SERVED));
|
|
957
|
+
|
|
958
|
+
test("a renamed section record cannot make a pending plan gate look superseded", () =>
|
|
959
|
+
withDesk(async (host, workspace) => {
|
|
960
|
+
const section = read(workspace, ".planning/sections/introduction/section.json");
|
|
961
|
+
put(workspace, ".planning/sections/introduction/section.json", { ...section, id: "intro-other", artifacts: { ...(section.artifacts as Json), plans: [PLAN_URI, "project://sections/introduction/plans/decoy"] } });
|
|
962
|
+
const checkpoint = read(workspace, `.planning/checkpoints/${PLAN_GATE}.json`);
|
|
963
|
+
const expired = await host.tool("record", { uri: `project://checkpoints/${PLAN_GATE}`, record: { ...checkpoint, status: "expired" }, expect_sha256: sha(workspace, `.planning/checkpoints/${PLAN_GATE}.json`) });
|
|
964
|
+
assert.match(expired.text, /cannot be expired by the agent/);
|
|
965
|
+
}));
|
|
966
|
+
|
|
967
|
+
test("turning a gate off needs the author's confirmation at the desk", () =>
|
|
968
|
+
withDesk(async (host, workspace) => {
|
|
969
|
+
const config = read(workspace, ".planning/config.json");
|
|
970
|
+
const proposal = { ...config, gates: { ...(config.gates as Json), confirm_plan: false } };
|
|
971
|
+
const expect_sha256 = sha(workspace, ".planning/config.json");
|
|
972
|
+
const asked = await host.tool("record", { uri: "project://config", record: proposal, expect_sha256 });
|
|
973
|
+
assert.equal(asked.interview?.id, "confirm-write");
|
|
974
|
+
assert.match(JSON.stringify(asked.interview?.step.intro), /gates.confirm_plan: on → off/);
|
|
975
|
+
const declined = await host.interview({ id: "confirm-write", step: asked.interview?.step.key as string, nav: "next", answers: { choice: "decline" } });
|
|
976
|
+
assert.match("done" in declined ? declined.text : "", /kept the current settings/);
|
|
977
|
+
assert.equal(((read(workspace, ".planning/config.json").gates as Json).confirm_plan), true);
|
|
978
|
+
const again = await host.tool("record", { uri: "project://config", record: proposal, expect_sha256 });
|
|
979
|
+
const approved = await host.interview({ id: "confirm-write", step: again.interview?.step.key as string, nav: "next", answers: { choice: "approve" } });
|
|
980
|
+
assert.match("done" in approved ? approved.text : "", /approved the change/);
|
|
981
|
+
assert.equal(((read(workspace, ".planning/config.json").gates as Json).confirm_plan), false);
|
|
982
|
+
assert.deepEqual(interactions(workspace).map((entry) => `${entry.kind}:${entry.outcome}`).sort(), ["record-change:approved", "record-change:declined"]);
|
|
983
|
+
// With confirm_plan off, a contained linked plan stands without approval once no gate holds the section.
|
|
984
|
+
rmSync(path.join(workspace, `.planning/checkpoints/${PLAN_GATE}.json`));
|
|
985
|
+
assert.match(blocked(await write(host, "paper/introduction.md")) ?? "", /has not answered "Lead with the protocol/);
|
|
986
|
+
await answer(host, GATE, "protocol-first");
|
|
987
|
+
assert.equal(blocked(await write(host, "paper/introduction.md")), null);
|
|
988
|
+
}));
|
|
989
|
+
|
|
990
|
+
test("an armed action writes only what its contract declares, for the section it names, until its turn ends", () =>
|
|
991
|
+
withDesk(async (host, workspace) => {
|
|
992
|
+
const armed = await host.hook({ point: "prompt_submit", text: "/wtfp:plan-section introduction" });
|
|
993
|
+
assert.match(JSON.stringify(armed.effects), /plan-section introduction: files stay under \.planning\/sections\/introduction\/plans/);
|
|
994
|
+
assert.match(blocked(await write(host, "paper/introduction.md")) ?? "", /may write only under \.planning\/sections\/introduction\/plans/);
|
|
995
|
+
assert.equal(blocked(await write(host, ".planning/sections/introduction/plans/second.md")), null);
|
|
996
|
+
assert.ok(blocked(await write(host, ".planning/sections/methods/plans/second.md")));
|
|
997
|
+
const manifest = read(workspace, ".planning/project.json");
|
|
998
|
+
const undeclared = await host.tool("record", { uri: "project://manifest", record: { ...manifest, title: "Retitled" }, expect_sha256: sha(workspace, ".planning/project.json") });
|
|
999
|
+
assert.match(undeclared.text, /plan-section does not declare updating project:\/\/manifest/);
|
|
1000
|
+
await host.observe({ event: "turn_end", turnId: "t1", outcome: "completed", usage: null });
|
|
1001
|
+
assert.ok(!blocked(await write(host, ".planning/sections/methods/notes.md")), "the guard disarms when its turn ends");
|
|
1002
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:progress" });
|
|
1003
|
+
assert.match(blocked(await write(host, ".planning/sections/introduction/notes.md")) ?? "", /declares no file outputs/);
|
|
1004
|
+
}, SERVED));
|
|
1005
|
+
|
|
1006
|
+
// --- the advance driver ------------------------------------------------------------
|
|
1007
|
+
// `/wtfp:advance` runs one long turn. The desk, never the model, picks each step
|
|
1008
|
+
// by the progress ladder and arms the write guard for that action alone; a gate
|
|
1009
|
+
// stops the run until the author answers it at the desk.
|
|
1010
|
+
|
|
1011
|
+
const DRIVEN_PLUGIN = {
|
|
1012
|
+
id: "wtfp",
|
|
1013
|
+
prompts: [...SERVED.prompts, "wtfp:advance", "wtfp:review-section", "wtfp:discuss-section", "wtfp:create-outline", "wtfp:verify-work", "wtfp:plan-revision"],
|
|
1014
|
+
};
|
|
1015
|
+
/** Stamps the manuscript as written `offsetMs` from the desk's clock, after or before the plan's approval. */
|
|
1016
|
+
const drafted = (host: Host, workspace: string, offsetMs: number): void => {
|
|
1017
|
+
const at = new Date(host.now + offsetMs);
|
|
1018
|
+
utimesSync(path.join(workspace, "paper/introduction.md"), at, at);
|
|
1019
|
+
};
|
|
1020
|
+
const nextStep = async (host: Host): Promise<{ text: string; data: Json; isError?: boolean }> => {
|
|
1021
|
+
const result = await host.tool("next_step", {});
|
|
1022
|
+
return { text: result.text, data: (result.data ?? {}) as Json, ...(result.isError ? { isError: true } : {}) };
|
|
1023
|
+
};
|
|
1024
|
+
|
|
1025
|
+
test("only an advance turn may ask the desk for a step, and the turn's end ends the run", () =>
|
|
1026
|
+
withDesk(async (host) => {
|
|
1027
|
+
assert.equal((await nextStep(host)).isError, true, "no drive outside an advance turn");
|
|
1028
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:write-section introduction" });
|
|
1029
|
+
assert.equal((await nextStep(host)).isError, true, "an ordinary action cannot drive");
|
|
1030
|
+
const armed = await host.hook({ point: "prompt_submit", text: "/wtfp:advance" });
|
|
1031
|
+
assert.match(JSON.stringify(armed.effects), /WTF-P driver armed/);
|
|
1032
|
+
assert.match(blocked(await write(host, "paper/introduction.md")) ?? "", /nothing is armed between \/wtfp:advance steps.*Call extension_wtfp__next_step/, "nothing is writable before the desk arms a step, and the refusal says how to get one");
|
|
1033
|
+
assert.equal((await nextStep(host)).data.kind, "gate");
|
|
1034
|
+
await host.observe({ event: "turn_end", turnId: "t1", outcome: "completed", usage: null });
|
|
1035
|
+
assert.equal((await nextStep(host)).isError, true, "the drive ends with its turn");
|
|
1036
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:advance" });
|
|
1037
|
+
// Clio continuing the turn after its tool budget or loop guard resumes the drive the turn had.
|
|
1038
|
+
assert.equal((await nextStep(host)).data.kind, "gate");
|
|
1039
|
+
await host.observe({ event: "turn_end", turnId: "t2", outcome: "completed", usage: null });
|
|
1040
|
+
assert.equal((await nextStep(host)).isError, true, "between turns nothing drives");
|
|
1041
|
+
await host.hook({ point: "prompt_submit", text: "Continue.", origin: "continuation", continuation: { index: 1, cap: 3 } } as never);
|
|
1042
|
+
const resumed = await nextStep(host);
|
|
1043
|
+
assert.notEqual(resumed.isError, true, resumed.text);
|
|
1044
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:progress" });
|
|
1045
|
+
assert.equal((await nextStep(host)).isError, true, "any other prompt ends the drive");
|
|
1046
|
+
await host.observe({ event: "turn_end", turnId: "t3", outcome: "completed", usage: null });
|
|
1047
|
+
await host.hook({ point: "prompt_submit", text: "Continue.", origin: "continuation", continuation: { index: 1, cap: 3 } } as never);
|
|
1048
|
+
assert.equal((await nextStep(host)).isError, true, "a continuation resumes only the drive its own turn had");
|
|
1049
|
+
}, DRIVEN_PLUGIN));
|
|
1050
|
+
|
|
1051
|
+
test("advance puts each gate to the author, then arms exactly the step the ladder names", () =>
|
|
1052
|
+
withDesk(async (host, workspace) => {
|
|
1053
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:advance" });
|
|
1054
|
+
// The desk names the gates in its own order; each is answered as the author would.
|
|
1055
|
+
const choices: Record<string, string> = { [GATE]: "protocol-first", [PLAN_GATE]: "approve" };
|
|
1056
|
+
const asked: string[] = [];
|
|
1057
|
+
for (let round = 0; round < 2; round += 1) {
|
|
1058
|
+
const gate = await nextStep(host);
|
|
1059
|
+
assert.equal(gate.data.kind, "gate", gate.text);
|
|
1060
|
+
asked.push(gate.data.checkpoint as string);
|
|
1061
|
+
assert.match(blocked(await write(host, "paper/introduction.md")) ?? "", /nothing is armed between \/wtfp:advance steps/, "a gate leaves nothing armed");
|
|
1062
|
+
await answer(host, gate.data.checkpoint as string, choices[gate.data.checkpoint as string] as string);
|
|
1063
|
+
}
|
|
1064
|
+
assert.deepEqual(asked.sort(), [GATE, PLAN_GATE].sort());
|
|
1065
|
+
const step = await nextStep(host);
|
|
1066
|
+
assert.deepEqual([step.data.kind, step.data.action, step.data.section, step.data.prompt], ["step", "write-section", "introduction", "ai.iowarp.clio/prompts/wtfp/write-section.md"]);
|
|
1067
|
+
assert.match(step.text, /armed for write-section introduction only/);
|
|
1068
|
+
assert.equal(blocked(await write(host, "paper/introduction.md")), null, "the armed step may write its manuscript");
|
|
1069
|
+
assert.ok(blocked(await write(host, ".planning/sections/introduction/plans/second.md")), "but nothing write-section does not declare");
|
|
1070
|
+
const outline = read(workspace, ".planning/structure/outline.json");
|
|
1071
|
+
const undeclared = await host.tool("record", { uri: "project://structure/outline", record: { ...outline, thesis: "Changed." }, expect_revision: 1 });
|
|
1072
|
+
assert.match(undeclared.text, /write-section does not declare updating project:\/\/structure\/outline/);
|
|
1073
|
+
// The drafted section moves to review, and the desk arms the review next, not the draft.
|
|
1074
|
+
drafted(host, workspace, 60_000);
|
|
1075
|
+
put(workspace, ".planning/sections/introduction/section.json", { ...read(workspace, ".planning/sections/introduction/section.json"), status: "reviewing" });
|
|
1076
|
+
const review = await nextStep(host);
|
|
1077
|
+
assert.deepEqual([review.data.kind, review.data.action, review.data.section], ["step", "review-section", "introduction"]);
|
|
1078
|
+
assert.ok(blocked(await write(host, "paper/introduction.md")), "the review step may not touch the manuscript the draft step could");
|
|
1079
|
+
// A step that changed nothing the ladder reads is handed back once to record its outputs, then not run again.
|
|
1080
|
+
const finish = await nextStep(host);
|
|
1081
|
+
assert.deepEqual([finish.data.kind, finish.data.action, finish.data.finish], ["step", "review-section", true]);
|
|
1082
|
+
assert.match(finish.text, /Continue \/wtfp:review-section introduction; it has not failed\. It recorded nothing.*project:\/\/sections\/introduction\/reviews\/\{review\}/);
|
|
1083
|
+
const again = await nextStep(host);
|
|
1084
|
+
assert.equal(again.data.kind, "stop");
|
|
1085
|
+
assert.match(again.text, /changed nothing/);
|
|
1086
|
+
assert.match(blocked(await write(host, "paper/introduction.md")) ?? "", /nothing is armed between \/wtfp:advance steps/, "a stop disarms the last step");
|
|
1087
|
+
}, DRIVEN_PLUGIN));
|
|
1088
|
+
|
|
1089
|
+
test("every next_step result restates the driver rule, so a compacted turn can continue from the last result alone", () =>
|
|
1090
|
+
withDesk(async (host) => {
|
|
1091
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:advance" });
|
|
1092
|
+
const ruleOf = (text: string): string => /Driver rule for this \/wtfp:advance run: .*$/u.exec(text)?.[0] ?? "";
|
|
1093
|
+
const gate = await nextStep(host);
|
|
1094
|
+
assert.equal(gate.data.kind, "gate");
|
|
1095
|
+
assert.match(gate.text, new RegExp(`Call extension_wtfp__gate with checkpoint ${gate.data.checkpoint as string}\\.`));
|
|
1096
|
+
const rule = ruleOf(gate.text);
|
|
1097
|
+
assert.match(rule, /the desk, not you, picks every step/);
|
|
1098
|
+
assert.match(rule, /call extension_wtfp__next_step/);
|
|
1099
|
+
assert.match(rule, /call extension_wtfp__gate with the checkpoint it names and then extension_wtfp__next_step/);
|
|
1100
|
+
assert.match(rule, /on a stop, a failed step or a refused call report the steps taken and end the turn/);
|
|
1101
|
+
await answer(host, GATE, "protocol-first");
|
|
1102
|
+
await answer(host, PLAN_GATE, "approve");
|
|
1103
|
+
const step = await nextStep(host);
|
|
1104
|
+
assert.equal(step.data.kind, "step");
|
|
1105
|
+
assert.match(step.text, /^Step 1: \/wtfp:write-section introduction\./);
|
|
1106
|
+
assert.match(step.text, /Read and follow <plugin root>\/ai\.iowarp\.clio\/prompts\/wtfp\/write-section\.md, where <plugin root> is the WTF-P plugin root \(two directories above the base_dir of the loaded wtfp-manage-project skill/);
|
|
1107
|
+
assert.match(step.text, /invocation input introduction/);
|
|
1108
|
+
assert.equal(ruleOf(step.text), rule);
|
|
1109
|
+
const finish = await nextStep(host);
|
|
1110
|
+
assert.equal(finish.data.finish, true);
|
|
1111
|
+
assert.equal(ruleOf(finish.text), rule);
|
|
1112
|
+
const stop = await nextStep(host);
|
|
1113
|
+
assert.equal(stop.data.kind, "stop");
|
|
1114
|
+
assert.equal(ruleOf(stop.text), rule);
|
|
1115
|
+
}, DRIVEN_PLUGIN));
|
|
1116
|
+
|
|
1117
|
+
test("a gate the author keeps pending, or that no author can answer, stops the run with the gate open", () =>
|
|
1118
|
+
withDesk(async (host, workspace) => {
|
|
1119
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:advance" });
|
|
1120
|
+
const first = (await nextStep(host)).data.checkpoint as string;
|
|
1121
|
+
assert.ok([GATE, PLAN_GATE].includes(first));
|
|
1122
|
+
await answer(host, first, "__keep");
|
|
1123
|
+
const kept = await nextStep(host);
|
|
1124
|
+
assert.equal(kept.data.kind, "stop");
|
|
1125
|
+
assert.match(kept.text, new RegExp(`${first} is still waiting on you`));
|
|
1126
|
+
assert.equal((read(workspace, `.planning/checkpoints/${first}.json`) as Json).status, "pending");
|
|
1127
|
+
await host.observe({ event: "turn_end", turnId: "t1", outcome: "completed", usage: null });
|
|
1128
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:advance" });
|
|
1129
|
+
assert.equal((await nextStep(host)).data.checkpoint, first, "a new run asks the kept gate again");
|
|
1130
|
+
const recorded = interactions(workspace).length;
|
|
1131
|
+
const key = await ask(host, first);
|
|
1132
|
+
await host.interview({ id: "gate-one", step: key, nav: "cancel", answers: {}, reason: "headless" });
|
|
1133
|
+
const headless = await nextStep(host);
|
|
1134
|
+
assert.equal(headless.data.kind, "stop");
|
|
1135
|
+
assert.equal((read(workspace, `.planning/checkpoints/${first}.json`) as Json).status, "pending");
|
|
1136
|
+
assert.equal(interactions(workspace).length, recorded, "no answer was recorded for an author who was never asked");
|
|
1137
|
+
}, DRIVEN_PLUGIN));
|
|
1138
|
+
|
|
1139
|
+
test("advance never starts a project and never runs an action the plugin does not serve", () =>
|
|
1140
|
+
withDesk(async (host, workspace) => {
|
|
1141
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:advance" });
|
|
1142
|
+
await answer(host, GATE, "protocol-first");
|
|
1143
|
+
await answer(host, PLAN_GATE, "approve");
|
|
1144
|
+
// write-section is next, but this plugin serves only advance.
|
|
1145
|
+
const unserved = await nextStep(host);
|
|
1146
|
+
assert.equal(unserved.data.kind, "stop");
|
|
1147
|
+
assert.match(unserved.text, /needs the WTF-P plugin/);
|
|
1148
|
+
rmSync(path.join(workspace, ".planning"), { recursive: true, force: true });
|
|
1149
|
+
const empty = await nextStep(host);
|
|
1150
|
+
assert.equal(empty.data.kind, "stop");
|
|
1151
|
+
assert.match(empty.text, /never starts one/);
|
|
1152
|
+
}, { id: "wtfp", prompts: ["wtfp:advance"] }));
|
|
1153
|
+
|
|
1154
|
+
test("advance creates the section records an outline lists before any section step", () =>
|
|
1155
|
+
withDesk(async (host, workspace) => {
|
|
1156
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:advance" });
|
|
1157
|
+
await answer(host, GATE, "protocol-first");
|
|
1158
|
+
await answer(host, PLAN_GATE, "approve");
|
|
1159
|
+
// new-paper leaves an outline with no section records; only create-outline may create one.
|
|
1160
|
+
rmSync(path.join(workspace, ".planning/sections/introduction/section.json"));
|
|
1161
|
+
const step = await nextStep(host);
|
|
1162
|
+
assert.deepEqual([step.data.kind, step.data.action, step.data.section], ["step", "create-outline", null], step.text);
|
|
1163
|
+
assert.match(step.text, /lists introduction without a section record/);
|
|
1164
|
+
}, DRIVEN_PLUGIN));
|
|
1165
|
+
|
|
1166
|
+
test("after review the author accepts a section or sends it back, and advance follows the sealed answer", () =>
|
|
1167
|
+
withDesk(async (host, workspace) => {
|
|
1168
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:advance" });
|
|
1169
|
+
await answer(host, GATE, "protocol-first");
|
|
1170
|
+
await answer(host, PLAN_GATE, "approve");
|
|
1171
|
+
drafted(host, workspace, 60_000);
|
|
1172
|
+
const sectionFile = ".planning/sections/introduction/section.json";
|
|
1173
|
+
const validation = (id: string, action: string, at: string): Json => ({
|
|
1174
|
+
schema: "wtfp.project.validation/v1",
|
|
1175
|
+
id,
|
|
1176
|
+
project_id: PROJECT,
|
|
1177
|
+
subject_uri: "project://paper/introduction",
|
|
1178
|
+
validator_role: action === "review-section" ? "section-reviewer" : "author",
|
|
1179
|
+
action_id: action,
|
|
1180
|
+
status: "passed",
|
|
1181
|
+
checks: [{ id: "plan-criteria", status: "passed", summary: "Every plan criterion holds.", evidence: ["The bottleneck and contribution are stated."] }],
|
|
1182
|
+
issues: [],
|
|
1183
|
+
next_actions: [],
|
|
1184
|
+
effects_applied: [],
|
|
1185
|
+
executed_at: at,
|
|
1186
|
+
});
|
|
1187
|
+
put(workspace, sectionFile, { ...read(workspace, sectionFile), status: "reviewing" });
|
|
1188
|
+
put(workspace, ".planning/validations/introduction-review.json", validation("introduction-review", "review-section", "2026-09-01T10:00:00Z"));
|
|
1189
|
+
// Review is critique only; the author's acceptance is verify-work's.
|
|
1190
|
+
const verify = await nextStep(host);
|
|
1191
|
+
assert.deepEqual([verify.data.kind, verify.data.action, verify.data.section], ["step", "verify-work", "introduction"], verify.text);
|
|
1192
|
+
assert.match(verify.text, /is reviewed; the author checks it against its plan/);
|
|
1193
|
+
put(workspace, ".planning/validations/introduction-verified.json", validation("introduction-verified", "verify-work", "2026-09-01T11:00:00Z"));
|
|
1194
|
+
put(workspace, ".planning/checkpoints/accept-introduction.json", {
|
|
1195
|
+
schema: "wtfp.project.checkpoint/v1",
|
|
1196
|
+
id: "accept-introduction",
|
|
1197
|
+
project_id: PROJECT,
|
|
1198
|
+
kind: "decision",
|
|
1199
|
+
status: "pending",
|
|
1200
|
+
blocking: true,
|
|
1201
|
+
scope_uri: "project://validations/introduction-verified",
|
|
1202
|
+
request: "Accept the introduction as written?",
|
|
1203
|
+
options: [
|
|
1204
|
+
{ id: "accept", label: "Revise", implication: "A checkpoint may label its options as it likes." },
|
|
1205
|
+
{ id: "revise", label: "Accept", implication: "The desk's own words decide what reads as acceptance." },
|
|
1206
|
+
],
|
|
1207
|
+
resume_action: "verify-work",
|
|
1208
|
+
created_at: "2026-09-01T11:00:00Z",
|
|
1209
|
+
});
|
|
1210
|
+
const gate = await nextStep(host);
|
|
1211
|
+
assert.deepEqual([gate.data.kind, gate.data.checkpoint], ["gate", "accept-introduction"], gate.text);
|
|
1212
|
+
const asked = await host.tool("gate", { checkpoint: "accept-introduction" });
|
|
1213
|
+
const options = asked.interview?.step.questions[0]?.options ?? [];
|
|
1214
|
+
assert.match(options.find((option) => option.value === "accept")?.label ?? "", /^Accept this section as written/);
|
|
1215
|
+
assert.ok(!options.some((option) => option.value !== "accept" && /^accept/iu.test(option.label)), "no other option may read as acceptance");
|
|
1216
|
+
await host.interview({ id: "gate-one", step: asked.interview?.step.key as string, nav: "next", answers: { choice: "revise" } });
|
|
1217
|
+
const revise = await nextStep(host);
|
|
1218
|
+
assert.deepEqual([revise.data.kind, revise.data.action, revise.data.section], ["step", "plan-revision", "introduction"], revise.text);
|
|
1219
|
+
// A later review supersedes that verification, so the author is asked again.
|
|
1220
|
+
put(workspace, ".planning/validations/introduction-review-2.json", validation("introduction-review-2", "review-section", "2026-09-01T12:00:00Z"));
|
|
1221
|
+
const again = await nextStep(host);
|
|
1222
|
+
assert.deepEqual([again.data.action, again.data.section], ["verify-work", "introduction"], again.text);
|
|
1223
|
+
assert.match(again.text, /is reviewed; the author checks it against its plan/);
|
|
1224
|
+
}, DRIVEN_PLUGIN));
|
|
1225
|
+
|
|
1226
|
+
test("a reviewed section whose approved revision plan no draft has applied goes back to write-section", () =>
|
|
1227
|
+
withDesk(async (host, workspace) => {
|
|
1228
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:advance" });
|
|
1229
|
+
await answer(host, GATE, "protocol-first");
|
|
1230
|
+
// The draft predates the plan the author approves now: live, plan-02 was approved and advance armed review again.
|
|
1231
|
+
await host.advance(7_200_000);
|
|
1232
|
+
drafted(host, workspace, -3_600_000);
|
|
1233
|
+
await answer(host, PLAN_GATE, "approve");
|
|
1234
|
+
const sectionFile = ".planning/sections/introduction/section.json";
|
|
1235
|
+
put(workspace, sectionFile, { ...read(workspace, sectionFile), status: "reviewing", artifacts: { ...(read(workspace, sectionFile).artifacts as Json), reviews: ["project://sections/introduction/reviews/review-01"] } });
|
|
1236
|
+
const rewrite = await nextStep(host);
|
|
1237
|
+
assert.deepEqual([rewrite.data.kind, rewrite.data.action, rewrite.data.section], ["step", "write-section", "introduction"], rewrite.text);
|
|
1238
|
+
assert.match(rewrite.text, /approved revision plan that no draft has applied yet/);
|
|
1239
|
+
// Once the draft is written after the approval, it is reviewed again: the earlier review read the earlier draft.
|
|
1240
|
+
drafted(host, workspace, 60_000);
|
|
1241
|
+
const review = await nextStep(host);
|
|
1242
|
+
assert.deepEqual([review.data.action, review.data.section], ["review-section", "introduction"], review.text);
|
|
1243
|
+
}, DRIVEN_PLUGIN));
|
|
1244
|
+
|
|
1245
|
+
test("a section drafted from its approved plan goes to review even if its record still says writing", () =>
|
|
1246
|
+
withDesk(async (host, workspace) => {
|
|
1247
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:advance" });
|
|
1248
|
+
await answer(host, GATE, "protocol-first");
|
|
1249
|
+
await answer(host, PLAN_GATE, "approve");
|
|
1250
|
+
// Live, write-section drafted method-admission but left status writing, and the desk re-armed the draft.
|
|
1251
|
+
drafted(host, workspace, 60_000);
|
|
1252
|
+
const sectionFile = ".planning/sections/introduction/section.json";
|
|
1253
|
+
put(workspace, sectionFile, { ...read(workspace, sectionFile), status: "writing" });
|
|
1254
|
+
const review = await nextStep(host);
|
|
1255
|
+
assert.deepEqual([review.data.kind, review.data.action, review.data.section], ["step", "review-section", "introduction"], review.text);
|
|
1256
|
+
assert.match(review.text, /is drafted and waits for review/);
|
|
1257
|
+
// Live, the review was recorded but the status stayed writing, and the desk named the review again.
|
|
1258
|
+
const reviewFile = ".planning/validations/introduction-review.json";
|
|
1259
|
+
put(workspace, reviewFile, {
|
|
1260
|
+
schema: "wtfp.project.validation/v1", id: "introduction-review", project_id: PROJECT, subject_uri: "project://paper/introduction",
|
|
1261
|
+
validator_role: "section-reviewer", action_id: "review-section", status: "passed",
|
|
1262
|
+
checks: [{ id: "plan-criteria", status: "passed", summary: "Every plan criterion holds.", evidence: ["Stated."] }],
|
|
1263
|
+
issues: [], next_actions: [], effects_applied: [], executed_at: "2026-09-01T10:00:00Z",
|
|
1264
|
+
});
|
|
1265
|
+
const after = new Date(host.now + 120_000);
|
|
1266
|
+
utimesSync(path.join(workspace, reviewFile), after, after);
|
|
1267
|
+
const verify = await nextStep(host);
|
|
1268
|
+
assert.deepEqual([verify.data.action, verify.data.section], ["verify-work", "introduction"], verify.text);
|
|
1269
|
+
}, DRIVEN_PLUGIN));
|
|
1270
|
+
|
|
1271
|
+
test("a review counts only for the draft it read", () =>
|
|
1272
|
+
withDesk(async (host, workspace) => {
|
|
1273
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:advance" });
|
|
1274
|
+
await answer(host, GATE, "protocol-first");
|
|
1275
|
+
await answer(host, PLAN_GATE, "approve");
|
|
1276
|
+
drafted(host, workspace, 60_000);
|
|
1277
|
+
const sectionFile = ".planning/sections/introduction/section.json";
|
|
1278
|
+
put(workspace, sectionFile, { ...read(workspace, sectionFile), status: "reviewing" });
|
|
1279
|
+
const reviewFile = ".planning/validations/introduction-review.json";
|
|
1280
|
+
put(workspace, reviewFile, {
|
|
1281
|
+
schema: "wtfp.project.validation/v1", id: "introduction-review", project_id: PROJECT, subject_uri: "project://paper/introduction",
|
|
1282
|
+
validator_role: "section-reviewer", action_id: "review-section", status: "passed",
|
|
1283
|
+
checks: [{ id: "plan-criteria", status: "passed", summary: "Every plan criterion holds.", evidence: ["Stated."] }],
|
|
1284
|
+
issues: [], next_actions: [], effects_applied: [], executed_at: "2026-09-01T10:00:00Z",
|
|
1285
|
+
});
|
|
1286
|
+
// The desk recorded the review after the draft, so it covers it: the author checks it next.
|
|
1287
|
+
const after = new Date(host.now + 120_000);
|
|
1288
|
+
utimesSync(path.join(workspace, reviewFile), after, after);
|
|
1289
|
+
assert.equal((await nextStep(host)).data.action, "verify-work");
|
|
1290
|
+
// A revision written after that review waits for a new one, whatever the review claims as its time.
|
|
1291
|
+
drafted(host, workspace, 180_000);
|
|
1292
|
+
const again = await nextStep(host);
|
|
1293
|
+
assert.deepEqual([again.data.action, again.data.section], ["review-section", "introduction"], again.text);
|
|
1294
|
+
}, DRIVEN_PLUGIN));
|
|
1295
|
+
|
|
1296
|
+
test("an accepted section is handed back to verify-work, which marks it complete", () =>
|
|
1297
|
+
withDesk(async (host, workspace) => {
|
|
1298
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:advance" });
|
|
1299
|
+
await answer(host, GATE, "protocol-first");
|
|
1300
|
+
await answer(host, PLAN_GATE, "approve");
|
|
1301
|
+
drafted(host, workspace, 60_000);
|
|
1302
|
+
const sectionFile = ".planning/sections/introduction/section.json";
|
|
1303
|
+
put(workspace, sectionFile, { ...read(workspace, sectionFile), status: "reviewing" });
|
|
1304
|
+
for (const [id, action, at] of [["introduction-review", "review-section", "2026-09-01T10:00:00Z"], ["introduction-verified", "verify-work", "2026-09-01T11:00:00Z"]])
|
|
1305
|
+
put(workspace, `.planning/validations/${id}.json`, {
|
|
1306
|
+
schema: "wtfp.project.validation/v1",
|
|
1307
|
+
id,
|
|
1308
|
+
project_id: PROJECT,
|
|
1309
|
+
subject_uri: "project://sections/introduction",
|
|
1310
|
+
validator_role: "author",
|
|
1311
|
+
action_id: action,
|
|
1312
|
+
status: "passed",
|
|
1313
|
+
checks: [],
|
|
1314
|
+
issues: [],
|
|
1315
|
+
next_actions: [],
|
|
1316
|
+
effects_applied: [],
|
|
1317
|
+
executed_at: at,
|
|
1318
|
+
});
|
|
1319
|
+
put(workspace, ".planning/checkpoints/accept-introduction.json", {
|
|
1320
|
+
schema: "wtfp.project.checkpoint/v1",
|
|
1321
|
+
id: "accept-introduction",
|
|
1322
|
+
project_id: PROJECT,
|
|
1323
|
+
kind: "decision",
|
|
1324
|
+
status: "pending",
|
|
1325
|
+
blocking: true,
|
|
1326
|
+
scope_uri: "project://validations/introduction-verified",
|
|
1327
|
+
request: "Accept the introduction as written?",
|
|
1328
|
+
options: [
|
|
1329
|
+
{ id: "accept", label: "Accept", implication: "Mark it complete." },
|
|
1330
|
+
{ id: "revise", label: "Revise", implication: "Plan a revision." },
|
|
1331
|
+
],
|
|
1332
|
+
resume_action: "verify-work",
|
|
1333
|
+
created_at: "2026-09-01T11:00:00Z",
|
|
1334
|
+
});
|
|
1335
|
+
assert.equal((await nextStep(host)).data.kind, "gate");
|
|
1336
|
+
await answer(host, "accept-introduction", "accept");
|
|
1337
|
+
const apply = await nextStep(host);
|
|
1338
|
+
assert.deepEqual([apply.data.kind, apply.data.action, apply.data.section], ["step", "verify-work", "introduction"], apply.text);
|
|
1339
|
+
assert.match(apply.text, /accepted Introduction; verify-work marks it complete/);
|
|
1340
|
+
}, DRIVEN_PLUGIN));
|
|
1341
|
+
|
|
1342
|
+
test("the desk's advance key fills the advance prompt only while the plugin serves it", () =>
|
|
1343
|
+
withDesk(async (host) => {
|
|
1344
|
+
const filled = await host.action("advance");
|
|
1345
|
+
assert.equal(filled.text, "/wtfp:advance");
|
|
1346
|
+
}, DRIVEN_PLUGIN));
|
|
1347
|
+
|
|
1348
|
+
test("status gives an agent the whole project in one read, matching what the desk draws", () =>
|
|
1349
|
+
withDesk(async (host, workspace) => {
|
|
1350
|
+
const status = await host.tool("status", {});
|
|
1351
|
+
const data = status.data as Json;
|
|
1352
|
+
assert.equal(data.present, true);
|
|
1353
|
+
assert.equal(data.phase, "writing");
|
|
1354
|
+
const [section] = data.sections as Json[];
|
|
1355
|
+
assert.equal(section?.id, "introduction");
|
|
1356
|
+
assert.equal((section?.plan as Json).state, "awaiting");
|
|
1357
|
+
assert.ok((section?.blockers as string[]).length > 0, "a gated section reports why it cannot be drafted");
|
|
1358
|
+
assert.deepEqual((data.open_gates as Json[]).map((gate) => gate.id).sort(), [GATE, PLAN_GATE].sort());
|
|
1359
|
+
assert.ok(((data.next as Json).gate as string) !== null);
|
|
1360
|
+
assert.match(status.text, /introduction: planned/);
|
|
1361
|
+
rmSync(path.join(workspace, ".planning"), { recursive: true, force: true });
|
|
1362
|
+
assert.equal(((await host.tool("status", {})).data as Json).present, false);
|
|
1363
|
+
}, SERVED));
|
|
1364
|
+
|
|
1365
|
+
// --- the turn_start status reminder ------------------------------------------------
|
|
1366
|
+
// Clio fires turn_start once per operator prompt; the desk answers with its status
|
|
1367
|
+
// only when that prompt armed a WTF-P action or advance in a project.
|
|
1368
|
+
|
|
1369
|
+
const turnStart = (host: Host) => host.hook({ point: "turn_start", turnId: "t1" });
|
|
1370
|
+
const reminderOf = (result: { effects?: Array<{ kind: string }> }): string | null =>
|
|
1371
|
+
(result.effects?.find((effect) => effect.kind === "inject_reminder") as { message?: string } | undefined)?.message ?? null;
|
|
1372
|
+
|
|
1373
|
+
test("a WTF-P turn starts from the desk's status, and no other turn does", () =>
|
|
1374
|
+
withDesk(async (host, workspace) => {
|
|
1375
|
+
assert.equal(reminderOf(await turnStart(host)), null, "nothing armed, nothing injected");
|
|
1376
|
+
await host.hook({ point: "prompt_submit", text: "explain the flush bottleneck" });
|
|
1377
|
+
assert.equal(reminderOf(await turnStart(host)), null, "an ordinary prompt gets no reminder");
|
|
1378
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:plan-section introduction" });
|
|
1379
|
+
const armed = await turnStart(host);
|
|
1380
|
+
const message = reminderOf(armed) ?? "";
|
|
1381
|
+
assert.match(message, /^WTF-P desk status at the start of this turn/);
|
|
1382
|
+
assert.match(message, /introduction: planned/);
|
|
1383
|
+
assert.match(message, new RegExp(`Open gates: .*${GATE}`));
|
|
1384
|
+
assert.ok(message.length <= 2000);
|
|
1385
|
+
assert.equal((armed.effects as Array<{ kind: string; audience?: string }>)[0]?.audience, "model");
|
|
1386
|
+
await host.observe({ event: "turn_end", turnId: "t1", outcome: "completed", usage: null });
|
|
1387
|
+
assert.equal(reminderOf(await turnStart(host)), null, "the turn's end disarms the reminder");
|
|
1388
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:advance" });
|
|
1389
|
+
assert.match(reminderOf(await turnStart(host)) ?? "", /WTF-P desk status/, "an advance run starts from the status too");
|
|
1390
|
+
rmSync(path.join(workspace, ".planning"), { recursive: true, force: true });
|
|
1391
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:advance" });
|
|
1392
|
+
assert.equal(reminderOf(await turnStart(host)), null, "no project, no reminder");
|
|
1393
|
+
}, DRIVEN_PLUGIN));
|
|
1394
|
+
|
|
1395
|
+
test("a status too long for one Clio effect is cut to 2,000 characters and points at the status tool", () =>
|
|
1396
|
+
withDesk(async (host, workspace) => {
|
|
1397
|
+
const outline = read(workspace, ".planning/structure/outline.json");
|
|
1398
|
+
const extra = Array.from({ length: 60 }, (_, index) => ({
|
|
1399
|
+
...((outline.sections as Json[])[0] as Json),
|
|
1400
|
+
id: `appendix-measurement-detail-${String(index).padStart(2, "0")}`,
|
|
1401
|
+
title: `Appendix ${index}`,
|
|
1402
|
+
wave: 2,
|
|
1403
|
+
depends_on: ["introduction"],
|
|
1404
|
+
}));
|
|
1405
|
+
put(workspace, ".planning/structure/outline.json", { ...outline, sections: [...(outline.sections as Json[]), ...extra] });
|
|
1406
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:progress" });
|
|
1407
|
+
const message = reminderOf(await turnStart(host)) ?? "";
|
|
1408
|
+
assert.ok(message.length > 1990 && message.length <= 2000, `length ${message.length}`);
|
|
1409
|
+
assert.match(message, /… \(truncated; call extension_wtfp__status\)$/);
|
|
1410
|
+
assert.equal(((await host.tool("status", {})).data as { sections: Json[] }).sections.length, 61, "the full status stays one call away");
|
|
1411
|
+
}, SERVED));
|
|
1412
|
+
|
|
1413
|
+
// --- the manuscript write note ------------------------------------------------------
|
|
1414
|
+
// A write that changes a manuscript the armed action may measure gets one note on
|
|
1415
|
+
// its result naming the measure_section call. It spends none of the turn's shared
|
|
1416
|
+
// continuation budget, and the desk declares no turn_end hook at all.
|
|
1417
|
+
|
|
1418
|
+
const wrote = (host: Host, target: string, outcome: "ok" | "error" = "ok") =>
|
|
1419
|
+
host.hook({ point: "after_tool", tool: "write", turnId: "t1", outcome, durationMs: 1, args: { path: target } } as never);
|
|
1420
|
+
const noteOf = (result: { effects?: Array<{ kind: string }> }): string | null =>
|
|
1421
|
+
(result.effects?.find((effect) => effect.kind === "annotate_tool_result") as { message?: string } | undefined)?.message ?? null;
|
|
1422
|
+
|
|
1423
|
+
test("a manuscript write inside an action that may measure it is noted once with the exact measure_section call", () =>
|
|
207
1424
|
withDesk(async (host) => {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
assert.equal(
|
|
213
|
-
assert.
|
|
1425
|
+
assert.equal(noteOf(await wrote(host, "paper/introduction.md")), null, "nothing armed, no note");
|
|
1426
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:progress" });
|
|
1427
|
+
assert.equal(noteOf(await wrote(host, "paper/introduction.md")), null, "an action that declares no manuscript gets no note");
|
|
1428
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:write-section introduction" });
|
|
1429
|
+
assert.equal(noteOf(await wrote(host, "paper/introduction.md", "error")), null, "a failed write changed nothing");
|
|
1430
|
+
assert.equal(noteOf(await wrote(host, ".planning/sections/introduction/summary.md")), null, "only a manuscript is measured");
|
|
1431
|
+
const note = noteOf(await wrote(host, "paper/introduction.md")) ?? "";
|
|
1432
|
+
assert.match(note, /^WTF-P: paper\/introduction\.md is the manuscript of introduction/);
|
|
1433
|
+
assert.match(note, /gateway\(op="call", capability="extension_wtfp__measure_section", args=\{section: "introduction"\}\)/);
|
|
1434
|
+
assert.match(note, /A dispatched worker leaves this call to the action that dispatched it/);
|
|
1435
|
+
assert.equal(noteOf(await wrote(host, "paper/introduction.md")), null, "noted once per section");
|
|
1436
|
+
assert.match((await host.tool("measure_section", { section: "introduction" })).text, /has 11 body words/);
|
|
1437
|
+
assert.ok(noteOf(await wrote(host, "paper/introduction.md")), "a write after measuring is noted again");
|
|
1438
|
+
await host.observe({ event: "turn_end", turnId: "t1", outcome: "completed", usage: null });
|
|
1439
|
+
assert.equal(noteOf(await wrote(host, "paper/introduction.md")), null, "the turn's end disarms the note");
|
|
1440
|
+
}, SERVED));
|
|
1441
|
+
|
|
1442
|
+
test("inside an advance run only the armed step's manuscript writes are noted", () =>
|
|
1443
|
+
withDesk(async (host) => {
|
|
1444
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:advance" });
|
|
1445
|
+
assert.equal(noteOf(await wrote(host, "paper/introduction.md")), null, "an idle run measures nothing");
|
|
1446
|
+
await answer(host, GATE, "protocol-first");
|
|
1447
|
+
await answer(host, PLAN_GATE, "approve");
|
|
1448
|
+
assert.equal((await nextStep(host)).data.action, "write-section");
|
|
1449
|
+
assert.match(noteOf(await wrote(host, "paper/introduction.md")) ?? "", /args=\{section: "introduction"\}/);
|
|
1450
|
+
assert.equal((await nextStep(host)).data.finish, true, "an unchanged step is handed back once");
|
|
1451
|
+
assert.equal((await nextStep(host)).data.kind, "stop");
|
|
1452
|
+
assert.equal(noteOf(await wrote(host, "paper/introduction.md")), null, "after a stop nothing is armed to measure");
|
|
1453
|
+
}, DRIVEN_PLUGIN));
|
|
1454
|
+
|
|
1455
|
+
test("inside a WTF-P action every question goes to the author as one only the author may answer", () =>
|
|
1456
|
+
withDesk(async (host) => {
|
|
1457
|
+
const ask = (args: Json) => host.hook({ point: "before_tool", tool: "ask_user", turnId: "t1", args });
|
|
1458
|
+
const question = { question: "Lead with the protocol?", options: [{ label: "Yes" }, { label: "No" }] };
|
|
1459
|
+
assert.equal(rewriteOf(await ask({ action: "ask", questions: [question] })), null, "outside an action the desk leaves questions alone");
|
|
1460
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:discuss-section introduction" });
|
|
1461
|
+
const marked = rewriteOf(await ask({ action: "ask", questions: [question] }));
|
|
1462
|
+
assert.deepEqual((marked?.questions as Json[] | undefined)?.[0], { ...question, operator_only: true });
|
|
1463
|
+
assert.match(blocked(await ask({ action: "ask", questions: [question, { question: "And the venue?" }] })) ?? "", /one call at a time, each with operator_only: true and its own options/);
|
|
1464
|
+
assert.equal(rewriteOf(await ask({ action: "ask", questions: [{ ...question, operator_only: true }] })), null, "a question already marked passes unchanged");
|
|
1465
|
+
assert.equal(blocked(await ask({ action: "complete", decisions: [] })), null);
|
|
1466
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:advance" });
|
|
1467
|
+
assert.ok(rewriteOf(await ask({ action: "ask", questions: [question] })), "an advance turn marks them too");
|
|
1468
|
+
}, DRIVEN_PLUGIN));
|
|
1469
|
+
|
|
1470
|
+
test("WTF-P workers are dispatched only inside their action and only to manuscripts that are ready (W3)", () =>
|
|
1471
|
+
withDesk(async (host, workspace) => {
|
|
1472
|
+
const dispatch = (args: Json) => host.hook({ point: "before_tool", tool: "dispatch", turnId: "t1", args });
|
|
1473
|
+
assert.match(blocked(await dispatch({ agent: "wtfp-section-writer", task: "Draft the introduction." })) ?? "", /run only inside the WTF-P action/);
|
|
1474
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:write-section introduction" });
|
|
1475
|
+
assert.match(blocked(await dispatch({ agent: "wtfp-section-writer", task: "Draft the introduction." })) ?? "", /would have no manuscript it may write/);
|
|
1476
|
+
await answer(host, GATE, "protocol-first");
|
|
1477
|
+
await answer(host, PLAN_GATE, "approve");
|
|
1478
|
+
const allowed = await dispatch({ agent: "wtfp-section-writer", task: "Draft the introduction." });
|
|
1479
|
+
assert.deepEqual(rootsOf(rewriteOf(allowed)), [".planning/sections/introduction/summary.md", "paper/introduction.md", "paper/introduction/"]);
|
|
1480
|
+
assert.ok(!Object.keys(rewriteOf(allowed) ?? {}).some((key) => key.startsWith("__clio_")), "Clio recomputes its own admission keys for a rewritten call");
|
|
1481
|
+
const narrowed = await dispatch({ agent: "wtfp-section-writer", task: "Draft.", intent: { write_roots: ["."] } });
|
|
1482
|
+
assert.deepEqual(rootsOf(rewriteOf(narrowed)), [".planning/sections/introduction/summary.md", "paper/introduction.md", "paper/introduction/"]);
|
|
1483
|
+
// Roots that already are the confinement, in any order, need no rewrite.
|
|
1484
|
+
assert.equal(rewriteOf(await dispatch({ agent: "wtfp-section-writer", task: "Draft.", intent: { write_roots: ["paper/introduction/", "paper/introduction.md", ".planning/sections/introduction/summary.md"] } })), null);
|
|
1485
|
+
// Live, a local model named project:// URIs and a .planning/paper path; the refusal names the workspace roots it would accept.
|
|
1486
|
+
assert.match(
|
|
1487
|
+
blocked(await dispatch({ agent: "wtfp-section-writer", task: "Draft.", intent: { write_roots: ["project://paper/introduction", ".planning/paper/introduction.md"] } })) ?? "",
|
|
1488
|
+
/names write_roots .*\.planning\/paper\/introduction\.md.*project:.*which reach no manuscript .* give it intent\.write_roots .*paper\/introduction\.md.* \(workspace paths, not project:\/\/ URIs\)/,
|
|
1489
|
+
);
|
|
1490
|
+
assert.match(
|
|
1491
|
+
blocked(await dispatch({ tasks: [{ agent: "wtfp-section-writer", task: "a" }, { agent: "wtfp-section-writer", task: "b" }] })) ?? "",
|
|
1492
|
+
/Clio: parallel writers need disjoint intent\.write_roots/,
|
|
1493
|
+
);
|
|
1494
|
+
assert.match(blocked(await dispatch({ agent: "coder", task: "x", intent: { write_roots: ["src"] } })) ?? "", /delegates only to wtfp-argument-verifier, wtfp-section-writer, and this call would start coder/);
|
|
1495
|
+
assert.ok(existsSync(path.join(workspace, "paper/introduction.md")));
|
|
1496
|
+
// A root the action itself grants is refused when a link makes it lead somewhere else.
|
|
1497
|
+
symlinkSync(path.join(workspace, ".planning/sections"), path.join(workspace, "paper/introduction"));
|
|
1498
|
+
assert.match(blocked(await dispatch({ agent: "wtfp-section-writer", task: "Draft." })) ?? "", /paper\/introduction\/ does not lead where it reads/);
|
|
1499
|
+
}, SERVED));
|
|
1500
|
+
|
|
1501
|
+
test("the guard judges the file Clio's tools open, however the path is spelled (W2)", () =>
|
|
1502
|
+
withDesk(async (host, workspace) => {
|
|
1503
|
+
const manuscript = path.join(workspace, "paper/introduction.md");
|
|
1504
|
+
for (const spelling of ["@paper/introduction.md", `~/${path.relative(homedir(), manuscript)}`, "paper/./introduction.md"])
|
|
1505
|
+
assert.match(blocked(await write(host, spelling)) ?? "", /cannot be written yet/, spelling);
|
|
1506
|
+
assert.match(blocked(await write(host, "@.planning/config.json")) ?? "", /portable record/);
|
|
1507
|
+
// The kernel reads a link before the `..` after it, so latest/.. is paper/, not the workspace.
|
|
1508
|
+
mkdirSync(path.join(workspace, "paper/introduction"), { recursive: true });
|
|
1509
|
+
symlinkSync(path.join(workspace, "paper/introduction"), path.join(workspace, "latest"));
|
|
1510
|
+
assert.match(blocked(await write(host, "latest/../introduction.md")) ?? "", /cannot be written yet/);
|
|
1511
|
+
// The artifact tool trims its path and writes it like write does.
|
|
1512
|
+
const artifact = await host.hook({ point: "before_tool", tool: "artifact", turnId: "t1", args: { kind: "report", path: " paper/introduction.md ", content: "x" } });
|
|
1513
|
+
assert.match(blocked(artifact) ?? "", /cannot be written yet/);
|
|
1514
|
+
const script = await host.hook({ point: "before_tool", tool: "run_script", turnId: "t1", args: { interpreter: "python3", script: "x.py", args: [".planning/interactions/x.json"] } });
|
|
1515
|
+
assert.match(blocked(script) ?? "", /desk's own records/);
|
|
1516
|
+
const manifest = readFileSync(path.join(ROOT, "clio-coder-extension.yaml"), "utf8");
|
|
1517
|
+
const hooked = /on: before_tool, tools: \[([^\]]*)\]/u.exec(manifest)?.[1]?.split(/,\s*/u) ?? [];
|
|
1518
|
+
for (const tool of ["write", "edit", "artifact", "dispatch", "bash", "run_script", "job"]) assert.ok(hooked.includes(tool), `${tool} is hooked`);
|
|
1519
|
+
}));
|
|
1520
|
+
|
|
1521
|
+
test("where Clio resolves a call's landing and dispatch plan, the desk judges what Clio resolved", () =>
|
|
1522
|
+
withDesk(async (host, workspace) => {
|
|
1523
|
+
const real = realpathSync(workspace);
|
|
1524
|
+
const manuscript = path.join(real, "paper/introduction.md");
|
|
1525
|
+
const landed = (args: Json, target: unknown) => host.hook({ point: "before_tool", tool: "write", turnId: "t1", args, target });
|
|
1526
|
+
// The landing Clio sends is the file the tool opens, whatever the call spells.
|
|
1527
|
+
assert.match(blocked(await landed({ path: "notes.md" }, { arg: "path", path: manuscript, resolved: true, workspacePath: "paper/introduction.md" })) ?? "", /cannot be written yet/);
|
|
1528
|
+
// A path the desk could not inspect is judged where Clio says it lands.
|
|
1529
|
+
assert.match(blocked(await landed({ path: "/proc/self/cwd/paper/introduction.md" }, { arg: "path", path: manuscript, resolved: true, workspacePath: "paper/introduction.md" })) ?? "", /cannot be written yet/);
|
|
1530
|
+
// A worker's write in a task worktree is judged at the checkout path it merges into.
|
|
1531
|
+
assert.match(blocked(await landed({ path: "paper/introduction.md" }, { arg: "path", path: "/elsewhere/worktree/paper/introduction.md", resolved: true, workspacePath: "paper/introduction.md" })) ?? "", /cannot be written yet/);
|
|
1532
|
+
// Without a workspace path, the desk maps Clio's physical path itself.
|
|
1533
|
+
assert.match(blocked(await landed({ path: "x" }, { arg: "path", path: manuscript, resolved: true })) ?? "", /cannot be written yet/);
|
|
1534
|
+
assert.equal(blocked(await landed({ path: "/elsewhere/notes.md" }, { arg: "path", path: "/elsewhere/notes.md", resolved: true, workspacePath: null })), null);
|
|
1535
|
+
assert.match(blocked(await landed({ path: "loop/x" }, { arg: "path", path: path.join(real, "loop/x"), resolved: false, workspacePath: null })) ?? "", /Clio could not resolve/);
|
|
1536
|
+
assert.match(blocked(await landed({ path: "x" }, { arg: "path", path: 7, resolved: true })) ?? "", /form the desk cannot read/);
|
|
1537
|
+
|
|
1538
|
+
const dispatch = (args: Json, plan: unknown) => host.hook({ point: "before_tool", tool: "dispatch", turnId: "t1", args, dispatch: plan });
|
|
1539
|
+
const task = (agent: string, extra: Json = {}) => ({ role: "task", agent, cwd: real, writeRoots: [], writeBoundaries: [], worktree: false, readOnly: false, ...extra });
|
|
1540
|
+
const plan = (...tasks: Json[]) => ({ kind: "tasks", mode: "single", tasks });
|
|
1541
|
+
const coder = { agent: "coder", task: "x", intent: { write_roots: ["src"] } };
|
|
1542
|
+
assert.equal(blocked(await dispatch(coder, plan(task("coder", { writeRoots: ["src"], writeBoundaries: [path.join(real, "src")] })))), null);
|
|
1543
|
+
// Clio resolves auto; a WTF-P agent it picks outside its action is refused like one named.
|
|
1544
|
+
assert.match(blocked(await dispatch({ agent: "auto", task: "Draft." }, plan(task("wtfp-section-writer")))) ?? "", /run only inside the WTF-P action/);
|
|
1545
|
+
assert.match(blocked(await dispatch(coder, plan(task("coder", { cwd: path.join(real, "paper") })))) ?? "", /cwd moves the write roots/);
|
|
1546
|
+
assert.match(
|
|
1547
|
+
blocked(await dispatch(coder, { kind: "tasks", mode: "compete", candidates: 2, tasks: [task("coder", { role: "candidate", worktree: true }), task("verifier", { role: "judge", readOnly: true })] })) ?? "",
|
|
1548
|
+
/refuses worktree writers/,
|
|
1549
|
+
);
|
|
1550
|
+
assert.match(blocked(await dispatch(coder, plan(task("coder", { writeRoots: ["src"] })))) ?? "", /form the desk cannot read/, "every root has its boundary");
|
|
1551
|
+
// A root lands where Clio says: one that resolves elsewhere does not lead where it reads, and one on the whole project is no boundary.
|
|
1552
|
+
assert.match(blocked(await dispatch(coder, plan(task("coder", { writeRoots: ["drafts/"], writeBoundaries: [path.join(real, "paper")] })))) ?? "", /drafts\/ does not lead where it reads/);
|
|
1553
|
+
assert.match(blocked(await dispatch(coder, plan(task("coder", { writeRoots: ["src", "."], writeBoundaries: [path.join(real, "src"), real] })))) ?? "", /intent\.write_roots/);
|
|
1554
|
+
assert.match(blocked(await dispatch({}, { kind: "apply-winner", branch: "winner", cwd: real })) ?? "", /compete winner/);
|
|
1555
|
+
assert.equal(blocked(await dispatch({}, { kind: "list" })), null);
|
|
1556
|
+
assert.match(blocked(await dispatch(coder, plan({ agent: "coder" }))) ?? "", /form the desk cannot read/);
|
|
1557
|
+
assert.match(blocked(await dispatch(coder, plan(task("coder", { agent: 7 })))) ?? "", /form the desk cannot read/);
|
|
1558
|
+
// Outside an action, a worker Clio runs read-only needs no roots either.
|
|
1559
|
+
assert.equal(blocked(await dispatch({ agent: "auto", task: "Look." }, plan(task("scout", { readOnly: true })))), null);
|
|
1560
|
+
// Clio could not prepare this call and refuses it itself, with its own reason.
|
|
1561
|
+
assert.equal(blocked(await dispatch({ agent: "coder", task: "x", __clio_dispatch_plan_preparation_error: "write_roots entries may not start with ./" }, undefined)), null);
|
|
1562
|
+
// A host that has sent facts once lacks them for a call only when Clio failed on it, and the desk says so.
|
|
1563
|
+
assert.match(blocked(await host.hook({ point: "before_tool", tool: "write", turnId: "t1", args: { path: "src/x.md" }, bare: true } as never)) ?? "", /Clio sent no landing for this call/);
|
|
1564
|
+
assert.match(blocked(await dispatch(coder, { kind: "council-of-elders", tasks: [] })) ?? "", /form the desk cannot read/, "an unknown plan is no plan");
|
|
1565
|
+
// A name that starts with `..` is still inside the project.
|
|
1566
|
+
assert.equal(blocked(await dispatch({ ...coder, intent: { write_roots: ["..notes/"] } }, plan(task("coder", { writeRoots: ["..notes/"], writeBoundaries: [path.join(real, "..notes")] })))), null);
|
|
1567
|
+
// Inside an action, a review loop's reviewer only judges: the builder is confined and the gate role leaves the count alone.
|
|
1568
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:write-section introduction" });
|
|
1569
|
+
await answer(host, GATE, "protocol-first");
|
|
1570
|
+
await answer(host, PLAN_GATE, "approve");
|
|
1571
|
+
// Clio admits a rewritten call afresh, without the approval a review loop needs, so the desk names the exact roots instead of rewriting.
|
|
1572
|
+
const roots = [".planning/sections/introduction/summary.md", "paper/introduction.md", "paper/introduction/"];
|
|
1573
|
+
const review = [task("wtfp-section-writer", { role: "builder" }), task("wtfp-section-reviewer", { role: "reviewer", readOnly: true })];
|
|
1574
|
+
const loop = await dispatch({ agent: "wtfp-section-writer", tasks: [{ task: "Draft the introduction." }], review: { reviewer: "wtfp-section-reviewer" } }, { kind: "tasks", mode: "review", tasks: review });
|
|
1575
|
+
assert.match(blocked(loop) ?? "", /task 1 \(wtfp-section-writer\): \.planning\/sections\/introduction\/summary\.md, paper\/introduction\.md, paper\/introduction\//);
|
|
1576
|
+
const sent = { ...review[0], writeRoots: roots, writeBoundaries: roots.map((root) => path.join(real, root)) };
|
|
1577
|
+
const confined = await dispatch({ agent: "wtfp-section-writer", tasks: [{ task: "Draft the introduction.", intent: { write_roots: roots } }], review: { reviewer: "wtfp-section-reviewer" } }, { kind: "tasks", mode: "review", tasks: [sent, review[1]] });
|
|
1578
|
+
assert.equal(blocked(confined), null, "a loop that already names its roots runs as approved");
|
|
1579
|
+
assert.equal(rewriteOf(confined), null);
|
|
1580
|
+
// A worker Clio runs read-only needs no write roots, whatever its recipe is called.
|
|
1581
|
+
const reader = await dispatch({ agent: "auto", tasks: [{ task: "Review the introduction." }] }, plan(task("scout", { readOnly: true })));
|
|
1582
|
+
assert.equal(blocked(reader), null);
|
|
1583
|
+
assert.equal(rewriteOf(reader), null);
|
|
1584
|
+
// The desk takes that from Clio: a verifier Clio does not report read-only is confined like any writer.
|
|
1585
|
+
assert.deepEqual(rootsOf(rewriteOf(await dispatch({ agent: "wtfp-argument-verifier", tasks: [{ task: "Verify." }] }, plan(task("wtfp-argument-verifier"))))), roots);
|
|
1586
|
+
// A writer the action does not delegate to is refused by name, as is Clio's default worker when the call names no agent.
|
|
1587
|
+
assert.match(blocked(await dispatch({ agent: "wtfp-section-reviewer", tasks: [{ task: "Review." }] }, plan(task("wtfp-section-reviewer")))) ?? "", /delegates only to wtfp-argument-verifier, wtfp-section-writer, and this call would start wtfp-section-reviewer/);
|
|
1588
|
+
assert.match(blocked(await dispatch({ tasks: [{ task: "Draft." }] }, plan(task("coder")))) ?? "", /would start coder; name the role with agent \(for example agent: "wtfp-section-writer"\)/);
|
|
1589
|
+
assert.match(
|
|
1590
|
+
blocked(await dispatch({ agent: "wtfp-argument-verifier", task: "x", intent: { write_roots: ["src"] } }, plan(task("wtfp-argument-verifier", { writeRoots: ["src"], writeBoundaries: [path.join(real, "src")] })))) ?? "",
|
|
1591
|
+
/src lie outside what write-section may write/,
|
|
1592
|
+
);
|
|
1593
|
+
// A declared empty write_roots is no boundary to the worker, and Clio refuses a rewrite that fills it, so the desk names the roots.
|
|
1594
|
+
assert.match(
|
|
1595
|
+
blocked(await dispatch({ agent: "wtfp-section-writer", task: "Draft.", intent: { read_roots: [".planning"], write_roots: [] } }, plan(task("wtfp-section-writer")))) ?? "",
|
|
1596
|
+
/intent without write_roots bounds nothing.*Send intent\.write_roots \.planning\/sections\/introduction\/summary\.md, paper\/introduction\.md, paper\/introduction\//,
|
|
1597
|
+
);
|
|
1598
|
+
assert.match(blocked(await dispatch({ agent: "wtfp-section-writer", task: "Draft.", intent: { read_roots: [".planning"] } }, plan(task("wtfp-section-writer")))) ?? "", /intent without write_roots/);
|
|
1599
|
+
// A task Clio keeps as a string is confined as a task object, and Clio's private keys are left for Clio to recompute.
|
|
1600
|
+
const spelled = await dispatch({ agent: "wtfp-section-writer", tasks: ["Draft."], __clio_resolved_dispatch_plan: { resolvedBy: "clio" } }, plan(task("wtfp-section-writer")));
|
|
1601
|
+
assert.deepEqual(rewriteOf(spelled), { agent: "wtfp-section-writer", tasks: [{ task: "Draft.", intent: { write_roots: roots } }] });
|
|
1602
|
+
// Clio's own artifact directory is no project file, but a landing elsewhere in the project, such as through a link, is judged there.
|
|
1603
|
+
const artifact = (target: unknown) => host.hook({ point: "before_tool", tool: "artifact", turnId: "t1", args: { kind: "plan", content: "x" }, target });
|
|
1604
|
+
assert.equal(blocked(await artifact({ arg: "path", path: path.join(real, ".clio-coder/artifacts/plan.md"), resolved: true, workspacePath: ".clio-coder/artifacts/plan.md" })), null);
|
|
1605
|
+
assert.match(blocked(await artifact({ arg: "path", path: path.join(real, "src/plan.md"), resolved: true, workspacePath: "src/plan.md" })) ?? "", /may write only under/);
|
|
214
1606
|
}, SERVED));
|
|
215
1607
|
|
|
1608
|
+
test("a Clio that sends no landing or dispatch plan is refused inside a WTF-P project or action and left alone elsewhere", async () => {
|
|
1609
|
+
await withDesk(async (host) => {
|
|
1610
|
+
const bare = (tool: string, args: Json) => host.hook({ point: "before_tool", tool, turnId: "t1", args, bare: true } as never);
|
|
1611
|
+
assert.match(blocked(await bare("write", { path: "src/notes.md" })) ?? "", /needs Clio 0\.6\.3/);
|
|
1612
|
+
assert.match(blocked(await bare("dispatch", { agent: "coder", task: "x", intent: { write_roots: ["src/"] } })) ?? "", /needs Clio 0\.6\.3/);
|
|
1613
|
+
assert.equal(blocked(await bare("dispatch", { list: true })), null);
|
|
1614
|
+
assert.equal(blocked(await bare("bash", { command: "ls" })), null);
|
|
1615
|
+
});
|
|
1616
|
+
const folder = mkdtempSync(path.join(process.env.TMPDIR as string, "wtfp-no-project-"));
|
|
1617
|
+
const host = await createExtensionTestHost(ROOT, { workspace: folder, plugin: null });
|
|
1618
|
+
try {
|
|
1619
|
+
const bare = (tool: string, args: Json) => host.hook({ point: "before_tool", tool, turnId: "t1", args } as never);
|
|
1620
|
+
assert.equal(blocked(await bare("write", { path: "notes.md" })), null, "a folder that is no WTF-P project is not the desk's to guard");
|
|
1621
|
+
assert.equal(blocked(await bare("dispatch", { agent: "coder", task: "x" })), null);
|
|
1622
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:new-paper durable workflows" });
|
|
1623
|
+
assert.match(blocked(await bare("write", { path: "notes.md" })) ?? "", /needs Clio 0\.6\.3/, "inside a WTF-P action it is");
|
|
1624
|
+
await host.hook({ point: "prompt_submit", text: "thanks" });
|
|
1625
|
+
// With Clio 0.6.3's facts, only the WTF-P recipes are the desk's business there.
|
|
1626
|
+
const facts = withClioFacts(host, folder);
|
|
1627
|
+
symlinkSync(os.tmpdir(), path.join(folder, "elsewhere"));
|
|
1628
|
+
assert.equal(blocked(await facts.hook({ point: "before_tool", tool: "dispatch", turnId: "t1", args: { agent: "coder", task: "x", cwd: "..", intent: { write_roots: ["elsewhere/"] } } } as never)), null);
|
|
1629
|
+
assert.match(blocked(await facts.hook({ point: "before_tool", tool: "dispatch", turnId: "t1", args: { agent: "wtfp-section-writer", task: "x" } } as never)) ?? "", /run only inside the WTF-P action/);
|
|
1630
|
+
assert.equal(blocked(await facts.hook({ point: "before_tool", tool: "dispatch", turnId: "t1", args: { agent: "coder", task: "x" }, dispatch: { kind: "council-of-elders" } } as never)), null, "a plan the desk cannot read is no plan, and this folder is not its to guard");
|
|
1631
|
+
assert.equal(blocked(await facts.hook({ point: "before_tool", tool: "write", turnId: "t1", args: { path: "x.md" }, target: { path: 7 } } as never)), null);
|
|
1632
|
+
// Once this Clio has sent facts, a call it sends none for failed in Clio, and an armed action says so.
|
|
1633
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:new-paper durable workflows" });
|
|
1634
|
+
assert.match(blocked(await bare("write", { path: "notes.md" })) ?? "", /Clio sent no landing for this call/);
|
|
1635
|
+
} finally {
|
|
1636
|
+
await host.dispose();
|
|
1637
|
+
rmSync(folder, { recursive: true, force: true });
|
|
1638
|
+
}
|
|
1639
|
+
});
|
|
1640
|
+
|
|
1641
|
+
/** Loads the desk the way Clio's runtime child does, prints the before_tool verdict for each call, then the result of each desk tool call. */
|
|
1642
|
+
const HARNESS = `
|
|
1643
|
+
import { pathToFileURL } from "node:url";
|
|
1644
|
+
const [entry, workspace, calls, toolCalls = "[]"] = process.argv.slice(2);
|
|
1645
|
+
const hooks = new Map();
|
|
1646
|
+
const tools = new Map();
|
|
1647
|
+
const noop = () => {};
|
|
1648
|
+
const kv = () => {
|
|
1649
|
+
const map = new Map();
|
|
1650
|
+
return {
|
|
1651
|
+
async get(key) { return map.has(key) ? { value: structuredClone(map.get(key)), version: 1 } : { value: undefined, version: 0 }; },
|
|
1652
|
+
async set(key, value) { map.set(key, structuredClone(value)); return { ok: true }; },
|
|
1653
|
+
async delete(key) { map.delete(key); },
|
|
1654
|
+
async keys() { return [...map.keys()]; },
|
|
1655
|
+
};
|
|
1656
|
+
};
|
|
1657
|
+
const ctx = { snapshot: { plugin: null, workspace, sessionId: "s", generation: 1, mode: "interactive", activeWorkspace: null }, requestId: "r", signal: new AbortController().signal, options: {}, state: kv(), store: kv() };
|
|
1658
|
+
const module = await import(pathToFileURL(entry).href);
|
|
1659
|
+
module.default({ handle: noop, action: noop, tool: (name, handler) => tools.set(name, handler), interview: noop, on: noop, hook: (point, handler) => hooks.set(point, handler) });
|
|
1660
|
+
const verdicts = [];
|
|
1661
|
+
for (const call of JSON.parse(calls)) {
|
|
1662
|
+
const out = await hooks.get("before_tool")({ point: "before_tool", turnId: "t1", ...call }, ctx);
|
|
1663
|
+
verdicts.push(out?.effects?.find((effect) => effect.kind === "block_tool")?.reason ?? null);
|
|
1664
|
+
}
|
|
1665
|
+
const results = [];
|
|
1666
|
+
for (const [name, input] of JSON.parse(toolCalls)) {
|
|
1667
|
+
const out = await tools.get(name)(input, ctx);
|
|
1668
|
+
results.push({ isError: out.isError ?? false, text: out.text });
|
|
1669
|
+
}
|
|
1670
|
+
console.log(JSON.stringify(toolCalls === "[]" ? verdicts : { verdicts, results }));
|
|
1671
|
+
`;
|
|
1672
|
+
|
|
1673
|
+
test("under the read and write access Clio grants the desk, it judges every call by the landing and plan Clio sends (W2)", async () => {
|
|
1674
|
+
const workspace = project();
|
|
1675
|
+
const harness = path.join(process.env.TMPDIR as string, `wtfp-host-harness-${process.pid}-${Date.now()}.mjs`);
|
|
1676
|
+
try {
|
|
1677
|
+
symlinkSync(path.join(workspace, "paper"), path.join(workspace, "drafts"));
|
|
1678
|
+
mkdirSync(path.join(workspace, "notes"));
|
|
1679
|
+
symlinkSync(path.join(workspace, ".planning"), path.join(workspace, "notes/records"));
|
|
1680
|
+
writeFileSync(harness, HARNESS);
|
|
1681
|
+
// The flags Clio 0.6.2 builds from the manifest (runtimePermissionArgs in runtime-process-v2.ts).
|
|
1682
|
+
const declared = /fs: \{ read: \[([^\]]*)\], write: \[([^\]]*)\] \}/u.exec(readFileSync(path.join(ROOT, "clio-coder-extension.yaml"), "utf8"));
|
|
1683
|
+
assert.ok(declared, "the manifest declares its file access");
|
|
1684
|
+
const entries = (list: string): string[] => list.split(",").map((entry) => entry.trim().replace(/^"|"$/gu, "")).filter(Boolean);
|
|
1685
|
+
const directory = (root: string): string => (root.endsWith(path.sep) ? root : `${root}${path.sep}`);
|
|
1686
|
+
const read = entries(declared[1] as string).map((entry) => directory(entry === "workspace" ? workspace : entry === "home" ? homedir() : path.join(workspace, entry)));
|
|
1687
|
+
const write = entries(declared[2] as string).filter((entry) => entry !== "store").map((entry) => directory(path.join(workspace, entry)));
|
|
1688
|
+
const calls: Array<[Json, boolean]> = [
|
|
1689
|
+
[{ tool: "write", args: { path: "paper/introduction.md" } }, true],
|
|
1690
|
+
[{ tool: "write", args: { path: "drafts/introduction.md" } }, true],
|
|
1691
|
+
[{ tool: "write", args: { path: "notes/records/config.json" } }, true],
|
|
1692
|
+
[{ tool: "write", args: { path: "src/notes.md" } }, false],
|
|
1693
|
+
[{ tool: "dispatch", args: { agent: "coder", task: "x", intent: { write_roots: ["drafts/"] } } }, true],
|
|
1694
|
+
[{ tool: "dispatch", args: { agent: "coder", task: "x", intent: { write_roots: ["src/"] } } }, false],
|
|
1695
|
+
...(existsSync("/proc/self/cwd") ? ([[{ tool: "write", args: { path: "/proc/self/cwd/paper/introduction.md" } }, true]] as Array<[Json, boolean]>) : []),
|
|
1696
|
+
];
|
|
1697
|
+
const run = spawnSync(
|
|
1698
|
+
process.execPath,
|
|
1699
|
+
["--permission", ...[directory(ROOT), harness, ...read].map((root) => `--allow-fs-read=${root}`), ...write.map((root) => `--allow-fs-write=${root}`), harness, path.join(ROOT, "runtime/extension.ts"), workspace, JSON.stringify(calls.map(([call]) => withFacts({ point: "before_tool", ...call }, workspace)))],
|
|
1700
|
+
{ cwd: workspace, encoding: "utf8", timeout: 60000 },
|
|
1701
|
+
);
|
|
1702
|
+
assert.equal(run.status, 0, run.stderr);
|
|
1703
|
+
const verdicts = JSON.parse(run.stdout) as Array<string | null>;
|
|
1704
|
+
calls.forEach(([call, refused], index) => assert.equal(verdicts[index] !== null, refused, `${JSON.stringify(call)}: ${verdicts[index]}`));
|
|
1705
|
+
} finally {
|
|
1706
|
+
rmSync(harness, { force: true });
|
|
1707
|
+
rmSync(workspace, { recursive: true, force: true });
|
|
1708
|
+
}
|
|
1709
|
+
});
|
|
1710
|
+
|
|
1711
|
+
test("under the write access Clio grants the desk, which refuses every flush, a record write still lands whole", () => {
|
|
1712
|
+
const workspace = project();
|
|
1713
|
+
const harness = path.join(process.env.TMPDIR as string, `wtfp-host-harness-${process.pid}-${Date.now()}.mjs`);
|
|
1714
|
+
try {
|
|
1715
|
+
writeFileSync(harness, HARNESS);
|
|
1716
|
+
const state = read(workspace, ".planning/state.json");
|
|
1717
|
+
const run = spawnSync(
|
|
1718
|
+
process.execPath,
|
|
1719
|
+
[
|
|
1720
|
+
"--permission",
|
|
1721
|
+
...[`${ROOT}${path.sep}`, harness, `${workspace}${path.sep}`].map((root) => `--allow-fs-read=${root}`),
|
|
1722
|
+
`--allow-fs-write=${path.join(workspace, ".planning")}${path.sep}`,
|
|
1723
|
+
harness,
|
|
1724
|
+
path.join(ROOT, "runtime/extension.ts"),
|
|
1725
|
+
workspace,
|
|
1726
|
+
"[]",
|
|
1727
|
+
JSON.stringify([["record", { uri: "project://state", record: { ...state, phase: "reviewing" }, expect_revision: 3 }]]),
|
|
1728
|
+
],
|
|
1729
|
+
{ cwd: workspace, encoding: "utf8", timeout: 60000 },
|
|
1730
|
+
);
|
|
1731
|
+
assert.equal(run.status, 0, run.stderr);
|
|
1732
|
+
const { results } = JSON.parse(run.stdout) as { results: Array<{ isError: boolean; text: string }> };
|
|
1733
|
+
assert.equal(results[0]?.isError, false, results[0]?.text);
|
|
1734
|
+
assert.deepEqual([read(workspace, ".planning/state.json").phase, read(workspace, ".planning/state.json").revision], ["reviewing", 4]);
|
|
1735
|
+
const leftovers = readdirSync(path.join(workspace, ".planning"), { recursive: true }).map(String).filter((name) => name.endsWith(".partial"));
|
|
1736
|
+
assert.deepEqual(leftovers, [], "no staged file is left behind");
|
|
1737
|
+
} finally {
|
|
1738
|
+
rmSync(harness, { force: true });
|
|
1739
|
+
rmSync(workspace, { recursive: true, force: true });
|
|
1740
|
+
}
|
|
1741
|
+
});
|
|
1742
|
+
|
|
1743
|
+
test("a manuscript nested under another section's stem is judged by every section it belongs to", () =>
|
|
1744
|
+
withDesk(async (host, workspace) => {
|
|
1745
|
+
const outline = read(workspace, ".planning/structure/outline.json");
|
|
1746
|
+
const [entry] = outline.sections as Json[];
|
|
1747
|
+
put(workspace, ".planning/structure/outline.json", { ...outline, sections: [entry, { ...entry, id: "appendix", title: "Appendix" }] });
|
|
1748
|
+
const intro = read(workspace, ".planning/sections/introduction/section.json");
|
|
1749
|
+
put(workspace, ".planning/sections/appendix/section.json", {
|
|
1750
|
+
...intro,
|
|
1751
|
+
id: "appendix",
|
|
1752
|
+
title: "Appendix",
|
|
1753
|
+
artifacts: { plans: [], reviews: [], manuscript: "project://paper/introduction/appendix" },
|
|
1754
|
+
checkpoint_uris: [],
|
|
1755
|
+
});
|
|
1756
|
+
await answer(host, GATE, "protocol-first");
|
|
1757
|
+
await answer(host, PLAN_GATE, "approve");
|
|
1758
|
+
assert.equal(blocked(await write(host, "paper/introduction.md")), null);
|
|
1759
|
+
assert.match(blocked(await write(host, "paper/introduction/appendix.md")) ?? "", /Appendix cannot be written yet/);
|
|
1760
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:write-section introduction" });
|
|
1761
|
+
const result = await host.hook({ point: "before_tool", tool: "dispatch", turnId: "t1", args: { agent: "wtfp-section-writer", task: "Draft." } });
|
|
1762
|
+
const roots = rootsOf(rewriteOf(result));
|
|
1763
|
+
assert.deepEqual(roots, [".planning/sections/introduction/summary.md", "paper/introduction.md"], "no worker root covers the appendix");
|
|
1764
|
+
}, SERVED));
|
|
1765
|
+
|
|
1766
|
+
test("dispatch is judged as Clio parses it, and no worker gets an unbounded or record-covering root (W3)", () =>
|
|
1767
|
+
withDesk(async (host, workspace) => {
|
|
1768
|
+
const dispatch = (args: Json) => host.hook({ point: "before_tool", tool: "dispatch", turnId: "t1", args });
|
|
1769
|
+
// Clio trims agent ids and accepts a batch as a JSON string or a single object.
|
|
1770
|
+
for (const args of [
|
|
1771
|
+
{ tasks: [{ agent: "wtfp-section-writer ", task: "Draft." }] },
|
|
1772
|
+
{ tasks: JSON.stringify([{ agent: "wtfp-section-writer", task: "Draft." }]) },
|
|
1773
|
+
{ tasks: { agent: "wtfp-section-writer", task: "Draft." } },
|
|
1774
|
+
{ agent: " wtfp-section-writer", task: "Draft." },
|
|
1775
|
+
])
|
|
1776
|
+
assert.match(blocked(await dispatch(args)) ?? "", /run only inside the WTF-P action/, JSON.stringify(args));
|
|
1777
|
+
// Outside an action, a generic worker must name roots that leave the records and gated manuscripts alone.
|
|
1778
|
+
assert.match(blocked(await dispatch({ agent: "coder", task: "x" })) ?? "", /intent\.write_roots/);
|
|
1779
|
+
assert.match(blocked(await dispatch({ agent: "coder", task: "x", intent: { write_roots: ["."] } })) ?? "", /intent\.write_roots/);
|
|
1780
|
+
assert.match(blocked(await dispatch({ agent: "coder", task: "x", intent: { write_roots: ["paper/"] } })) ?? "", /paper\/introduction\.md/);
|
|
1781
|
+
assert.match(blocked(await dispatch({ agent: "coder", task: "x", intent: { write_roots: [".planning/sections/"] } })) ?? "", /\.planning/);
|
|
1782
|
+
assert.equal(blocked(await dispatch({ agent: "coder", task: "x", intent: { write_roots: ["src/"] } })), null);
|
|
1783
|
+
// Every spelling the section's manuscript can take is held, not only the file that exists now.
|
|
1784
|
+
for (const root of ["paper/introduction.tex", "paper/introduction.typ", "paper/introduction", "paper/introduction.v2.md"])
|
|
1785
|
+
assert.match(blocked(await dispatch({ agent: "coder", task: "x", intent: { write_roots: [root] } })) ?? "", /may not change/, root);
|
|
1786
|
+
assert.match(blocked(await dispatch({ apply_winner: { branch: "clio-coder/compete/g/1" } })) ?? "", /cannot see what/);
|
|
1787
|
+
// Clio resolves write roots against a worker's cwd, and fixes a boundary where a root physically leads.
|
|
1788
|
+
assert.match(blocked(await dispatch({ agent: "coder", task: "x", cwd: "paper", intent: { write_roots: ["introduction.md"] } })) ?? "", /cwd/);
|
|
1789
|
+
assert.match(blocked(await dispatch({ tasks: [{ agent: "coder", task: "x", cwd: ".planning", intent: { write_roots: ["checkpoints/"] } }] })) ?? "", /cwd/);
|
|
1790
|
+
assert.equal(blocked(await dispatch({ agent: "coder", task: "x", cwd: ".", intent: { write_roots: ["src/"] } })), null);
|
|
1791
|
+
symlinkSync(path.join(workspace, "paper"), path.join(workspace, "drafts"));
|
|
1792
|
+
assert.match(blocked(await dispatch({ agent: "coder", task: "x", intent: { write_roots: ["drafts/"] } })) ?? "", /does not lead where it reads/);
|
|
1793
|
+
// An action that declares no file outputs never hands a writer an empty list, which Clio reads as no boundary.
|
|
1794
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:progress" });
|
|
1795
|
+
assert.match(blocked(await dispatch({ tasks: [{ agent: "wtfp-section-planner", task: "x" }] })) ?? "", /declares no file outputs/);
|
|
1796
|
+
const reviewer = await dispatch({ tasks: [{ agent: "wtfp-plan-checker", task: "x" }] });
|
|
1797
|
+
assert.equal(blocked(reviewer), null, "a read-only reviewer needs no roots");
|
|
1798
|
+
assert.equal(rewriteOf(reviewer), null, "and is not given an empty list");
|
|
1799
|
+
// Without a named section, a planner would get every section's directory, records included.
|
|
1800
|
+
await host.observe({ event: "turn_end", turnId: "t1", outcome: "completed", usage: null });
|
|
1801
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:plan-section" });
|
|
1802
|
+
assert.match(blocked(await dispatch({ agent: "wtfp-section-planner", task: "x" })) ?? "", /name the section/);
|
|
1803
|
+
}, SERVED));
|
|
1804
|
+
|
|
1805
|
+
test("changes that loosen what the desk holds wait for the author at the desk", () =>
|
|
1806
|
+
withDesk(async (host, workspace) => {
|
|
1807
|
+
const asks = async (uri: string, file: string, record: Json, expect: Json) => {
|
|
1808
|
+
const before = sha(workspace, file);
|
|
1809
|
+
const result = await host.tool("record", { uri, record, ...expect });
|
|
1810
|
+
assert.equal(result.interview?.id, "confirm-write", `${uri}: ${result.text}`);
|
|
1811
|
+
assert.equal(sha(workspace, file), before, `${uri} was not written before the author answered`);
|
|
1812
|
+
return JSON.stringify(result.interview?.step.intro);
|
|
1813
|
+
};
|
|
1814
|
+
const sectionFile = ".planning/sections/introduction/section.json";
|
|
1815
|
+
const section = read(workspace, sectionFile);
|
|
1816
|
+
const artifacts = section.artifacts as Json;
|
|
1817
|
+
assert.match(
|
|
1818
|
+
await asks("project://sections/introduction", sectionFile, { ...section, artifacts: { ...artifacts, manuscript: "project://paper/elsewhere" } }, { expect_sha256: sha(workspace, sectionFile) }),
|
|
1819
|
+
/manuscript/,
|
|
1820
|
+
);
|
|
1821
|
+
assert.match(await asks("project://sections/introduction", sectionFile, { ...section, artifacts: { ...artifacts, plans: [] } }, { expect_sha256: sha(workspace, sectionFile) }), /plan history/);
|
|
1822
|
+
const claim = { id: "claim-flush", statement: "Flushes dominate logging cost.", status: "planned", evidence_required: true, evidence_uris: [] };
|
|
1823
|
+
put(workspace, sectionFile, { ...section, claims: [claim] });
|
|
1824
|
+
assert.match(
|
|
1825
|
+
await asks("project://sections/introduction", sectionFile, { ...section, claims: [{ ...claim, evidence_required: false }] }, { expect_sha256: sha(workspace, sectionFile) }),
|
|
1826
|
+
/claim-flush/,
|
|
1827
|
+
);
|
|
1828
|
+
const outlineFile = ".planning/structure/outline.json";
|
|
1829
|
+
const outline = read(workspace, outlineFile);
|
|
1830
|
+
const [entry] = outline.sections as Json[];
|
|
1831
|
+
assert.match(await asks("project://structure/outline", outlineFile, { ...outline, sections: [{ ...entry, id: "intro-renamed" }] }, { expect_revision: 1 }), /introduction/);
|
|
1832
|
+
put(workspace, outlineFile, { ...outline, sections: [{ ...entry, research: { required: true, topics: ["logging"] } }] });
|
|
1833
|
+
assert.match(await asks("project://structure/outline", outlineFile, { ...outline, sections: [{ ...entry, research: { required: false, topics: [] } }] }, { expect_revision: 1 }), /research/);
|
|
1834
|
+
const configFile = ".planning/config.json";
|
|
1835
|
+
const config = read(workspace, configFile);
|
|
1836
|
+
assert.match(
|
|
1837
|
+
await asks("project://config", configFile, { ...config, safety: { ...(config.safety as Json), backup_before_major_edits: false } }, { expect_sha256: sha(workspace, configFile) }),
|
|
1838
|
+
/safety\.backup_before_major_edits/,
|
|
1839
|
+
);
|
|
1840
|
+
put(workspace, configFile, { ...config, interaction_mode: "guided" });
|
|
1841
|
+
assert.match(await asks("project://config", configFile, { ...config, interaction_mode: "standard" }, { expect_sha256: sha(workspace, configFile) }), /guided → standard/);
|
|
1842
|
+
}));
|
|
1843
|
+
|
|
1844
|
+
test("a pending plan gate cannot be retired by briefly linking a decoy plan", () =>
|
|
1845
|
+
withDesk(async (host, workspace) => {
|
|
1846
|
+
await answer(host, GATE, "protocol-first");
|
|
1847
|
+
const sectionFile = ".planning/sections/introduction/section.json";
|
|
1848
|
+
const section = read(workspace, sectionFile);
|
|
1849
|
+
const decoy = { ...(section.artifacts as Json), plans: [PLAN_URI, "project://sections/introduction/plans/decoy"] };
|
|
1850
|
+
assert.equal((await host.tool("record", { uri: "project://sections/introduction", record: { ...section, artifacts: decoy }, expect_sha256: sha(workspace, sectionFile) })).isError, undefined);
|
|
1851
|
+
const checkpoint = read(workspace, `.planning/checkpoints/${PLAN_GATE}.json`);
|
|
1852
|
+
await host.tool("record", { uri: `project://checkpoints/${PLAN_GATE}`, record: { ...checkpoint, status: "expired" }, expect_sha256: sha(workspace, `.planning/checkpoints/${PLAN_GATE}.json`) });
|
|
1853
|
+
const restored = await host.tool("record", { uri: "project://sections/introduction", record: section, expect_sha256: sha(workspace, sectionFile) });
|
|
1854
|
+
assert.equal(restored.interview?.id, "confirm-write", "unlinking the decoy rewrites the plan history, so the author is asked");
|
|
1855
|
+
assert.ok(blocked(await write(host, "paper/introduction.md")), "the manuscript still waits on an approved current plan");
|
|
1856
|
+
}));
|
|
1857
|
+
|
|
1858
|
+
test("the author approves a plan under the desk's own label, whatever the checkpoint calls its options", () =>
|
|
1859
|
+
withDesk(async (host, workspace) => {
|
|
1860
|
+
const checkpoint = read(workspace, `.planning/checkpoints/${PLAN_GATE}.json`);
|
|
1861
|
+
const swapped = await host.tool("record", {
|
|
1862
|
+
uri: `project://checkpoints/${PLAN_GATE}`,
|
|
1863
|
+
record: {
|
|
1864
|
+
...checkpoint,
|
|
1865
|
+
options: [
|
|
1866
|
+
{ id: "approve", label: "Send it back for revision", implication: "The plan is rewritten." },
|
|
1867
|
+
{ id: "revise", label: "Approve", implication: "Draft from this plan." },
|
|
1868
|
+
],
|
|
1869
|
+
},
|
|
1870
|
+
expect_sha256: sha(workspace, `.planning/checkpoints/${PLAN_GATE}.json`),
|
|
1871
|
+
});
|
|
1872
|
+
assert.equal(swapped.isError, undefined, swapped.text);
|
|
1873
|
+
const asked = await host.tool("gate", { checkpoint: PLAN_GATE });
|
|
1874
|
+
const options = asked.interview?.step.questions[0]?.options ?? [];
|
|
1875
|
+
const approve = options.find((option) => option.value === "approve");
|
|
1876
|
+
assert.match(approve?.label ?? "", /^Approve this plan/);
|
|
1877
|
+
assert.ok(!options.some((option) => option.value !== "approve" && /approve/iu.test(option.label)), "no other option may read as approval");
|
|
1878
|
+
}));
|
|
1879
|
+
|
|
1880
|
+
test("a seal counts only in the exact form the desk writes", () =>
|
|
1881
|
+
withDesk(async (host, workspace) => {
|
|
1882
|
+
await answer(host, GATE, "protocol-first");
|
|
1883
|
+
const [name] = readdirSync(path.join(workspace, ".planning/interactions"));
|
|
1884
|
+
const file = `.planning/interactions/${name}`;
|
|
1885
|
+
const interaction = read(workspace, file);
|
|
1886
|
+
const seal = interaction.seal as Json;
|
|
1887
|
+
for (const altered of [{ ...seal, mac: String(seal.mac).toUpperCase() }, { ...seal, method: "none" }]) {
|
|
1888
|
+
put(workspace, file, { ...interaction, seal: altered });
|
|
1889
|
+
assert.notEqual(((await host.tool("read_record", { uri: `project://checkpoints/${GATE}` })).data as Json).trust, "attested", JSON.stringify(altered));
|
|
1890
|
+
}
|
|
1891
|
+
// Even sealed with this machine's key, only an answer given at the desk's interview counts.
|
|
1892
|
+
const key = Buffer.from(String((await host.store.get("seal-key")).value), "hex");
|
|
1893
|
+
const { seal: _seal, ...body } = interaction;
|
|
1894
|
+
put(workspace, file, resealed({ ...body, channel: "host-prompt" }, key));
|
|
1895
|
+
assert.notEqual(((await host.tool("read_record", { uri: `project://checkpoints/${GATE}` })).data as Json).trust, "attested", "a host-prompt answer");
|
|
1896
|
+
put(workspace, file, interaction);
|
|
1897
|
+
assert.equal(((await host.tool("read_record", { uri: `project://checkpoints/${GATE}` })).data as Json).trust, "attested");
|
|
1898
|
+
}));
|
|
1899
|
+
|
|
1900
|
+
test("a sealed answer stands only behind the exact question, option and project it answered", () =>
|
|
1901
|
+
withDesk(async (host, workspace) => {
|
|
1902
|
+
await answer(host, GATE, "protocol-first");
|
|
1903
|
+
const trust = async () => ((await host.tool("read_record", { uri: `project://checkpoints/${GATE}` })).data as Json).trust;
|
|
1904
|
+
assert.equal(await trust(), "attested");
|
|
1905
|
+
const checkpointFile = `.planning/checkpoints/${GATE}.json`;
|
|
1906
|
+
const checkpoint = read(workspace, checkpointFile);
|
|
1907
|
+
const resolution = checkpoint.resolution as Json;
|
|
1908
|
+
put(workspace, checkpointFile, { ...checkpoint, resolution: { ...resolution, selected_option: "workflow-first" } });
|
|
1909
|
+
assert.equal(await trust(), "unattested", "a hand-swapped option");
|
|
1910
|
+
put(workspace, checkpointFile, { ...checkpoint, request: "A question the author never saw." });
|
|
1911
|
+
assert.equal(await trust(), "unattested", "a rewritten question");
|
|
1912
|
+
put(workspace, checkpointFile, checkpoint);
|
|
1913
|
+
const [name] = readdirSync(path.join(workspace, ".planning/interactions"));
|
|
1914
|
+
const interaction = read(workspace, `.planning/interactions/${name}`);
|
|
1915
|
+
const { seal: _seal, ...body } = interaction;
|
|
1916
|
+
const key = Buffer.from(String((await host.store.get("seal-key")).value), "hex");
|
|
1917
|
+
put(workspace, `.planning/interactions/${name}`, resealed({ ...body, project_id: "another-project" }, key));
|
|
1918
|
+
assert.equal(await trust(), "unattested", "an answer sealed for another project");
|
|
1919
|
+
assert.match(blocked(await write(host, "paper/introduction.md")) ?? "", /not observed by this desk/);
|
|
1920
|
+
}));
|
|
1921
|
+
|
|
1922
|
+
test("recovery finishes only a journal of the desk's own record writes", () =>
|
|
1923
|
+
withDesk(async (host, workspace) => {
|
|
1924
|
+
put(workspace, "notes/draft.md", "Unplanned prose.\n");
|
|
1925
|
+
const digest = createHash("sha256").update("Unplanned prose.\n").digest("hex");
|
|
1926
|
+
const before = sha(workspace, "paper/introduction.md");
|
|
1927
|
+
for (const entries of [
|
|
1928
|
+
[{ file: "paper/introduction.md", staging: "notes/draft.md", sha256: digest }],
|
|
1929
|
+
[{ file: ".planning/state.json", staging: "notes/draft.md", sha256: digest }],
|
|
1930
|
+
]) {
|
|
1931
|
+
put(workspace, ".planning/.wtfp-journal.json", { schema: "wtfp.clio-journal/v1", at: AT, entries });
|
|
1932
|
+
assert.match((await host.command("validate")).text, /Set aside a journal/);
|
|
1933
|
+
}
|
|
1934
|
+
assert.equal(sha(workspace, "paper/introduction.md"), before);
|
|
1935
|
+
assert.equal(read(workspace, ".planning/state.json").revision, 3);
|
|
1936
|
+
assert.ok(existsSync(path.join(workspace, "notes/draft.md")));
|
|
1937
|
+
}));
|
|
1938
|
+
|
|
1939
|
+
// --- durability and recovery ---------------------------------------------------------
|
|
1940
|
+
|
|
1941
|
+
test("measure_section counts body words by the desk's one method and commits the section and state together", () =>
|
|
1942
|
+
withDesk(async (host, workspace) => {
|
|
1943
|
+
const measured = await host.tool("measure_section", { section: "introduction" });
|
|
1944
|
+
assert.equal(measured.isError, undefined, measured.text);
|
|
1945
|
+
assert.deepEqual(measured.data, { words: 11, target: 100, file: "paper/introduction.md", total: 11, recorded: true });
|
|
1946
|
+
assert.equal(read(workspace, ".planning/sections/introduction/section.json").word_count, 11);
|
|
1947
|
+
assert.equal((read(workspace, ".planning/state.json").progress as Json).word_count, 11);
|
|
1948
|
+
assert.equal(read(workspace, ".planning/state.json").revision, 4);
|
|
1949
|
+
}));
|
|
1950
|
+
|
|
1951
|
+
test("an action that may not record a count still gets the desk's count instead of counting by hand", () =>
|
|
1952
|
+
withDesk(async (host, workspace) => {
|
|
1953
|
+
// Live, review-section was refused measure_section and the model counted words with a script.
|
|
1954
|
+
await host.hook({ point: "prompt_submit", text: "/wtfp:review-section introduction" });
|
|
1955
|
+
const before = read(workspace, ".planning/state.json").revision;
|
|
1956
|
+
const measured = await host.tool("measure_section", { section: "introduction" });
|
|
1957
|
+
assert.equal(measured.isError, undefined, measured.text);
|
|
1958
|
+
assert.equal((measured.data as Json).words, 11);
|
|
1959
|
+
assert.equal((measured.data as Json).recorded, false);
|
|
1960
|
+
assert.match(measured.text, /Not recorded: .*review-section does not update the section's word count; use this count instead of counting by hand/);
|
|
1961
|
+
assert.equal(read(workspace, ".planning/state.json").revision, before, "nothing was written");
|
|
1962
|
+
}, DRIVEN_PLUGIN));
|
|
1963
|
+
|
|
1964
|
+
test("a failure between paired writes leaves a journal the next write completes; one before the commit point leaves nothing (R2)", () =>
|
|
1965
|
+
withDesk(async (host, workspace) => {
|
|
1966
|
+
process.env.WTFP_DESK_TEST_FAULT = "between-renames";
|
|
1967
|
+
try {
|
|
1968
|
+
const failed = await host.tool("measure_section", { section: "introduction" });
|
|
1969
|
+
assert.equal(failed.isError, true);
|
|
1970
|
+
assert.match(failed.text, /injected fault at between-renames/);
|
|
1971
|
+
assert.match(failed.text, /^Committed; recovery pending: injected fault at between-renames/);
|
|
1972
|
+
} finally {
|
|
1973
|
+
delete process.env.WTFP_DESK_TEST_FAULT;
|
|
1974
|
+
}
|
|
1975
|
+
assert.ok(existsSync(path.join(workspace, ".planning/.wtfp-journal.json")));
|
|
1976
|
+
assert.equal(read(workspace, ".planning/sections/introduction/section.json").word_count, 11);
|
|
1977
|
+
assert.equal((read(workspace, ".planning/state.json").progress as Json).word_count, 0);
|
|
1978
|
+
const before = tree(workspace);
|
|
1979
|
+
const progress = await host.command("progress");
|
|
1980
|
+
assert.match(progress.text, /interrupted record write awaits recovery/);
|
|
1981
|
+
assert.deepEqual(tree(workspace), before, "progress reads and never repairs");
|
|
1982
|
+
const validated = await host.command("validate");
|
|
1983
|
+
assert.match(validated.text, /Completed an interrupted write of \.planning\/sections\/introduction\/section\.json, \.planning\/state\.json/);
|
|
1984
|
+
assert.equal((read(workspace, ".planning/state.json").progress as Json).word_count, 11);
|
|
1985
|
+
assert.ok(!existsSync(path.join(workspace, ".planning/.wtfp-journal.json")));
|
|
1986
|
+
|
|
1987
|
+
process.env.WTFP_DESK_TEST_FAULT = "before-commit";
|
|
1988
|
+
const sectionBefore = sha(workspace, ".planning/sections/introduction/section.json");
|
|
1989
|
+
try {
|
|
1990
|
+
writeFileSync(path.join(workspace, "paper/introduction.md"), "Just four words here.\n");
|
|
1991
|
+
const failed = await host.tool("measure_section", { section: "introduction" });
|
|
1992
|
+
assert.match(failed.text, /injected fault at before-commit/);
|
|
1993
|
+
} finally {
|
|
1994
|
+
delete process.env.WTFP_DESK_TEST_FAULT;
|
|
1995
|
+
}
|
|
1996
|
+
assert.equal(sha(workspace, ".planning/sections/introduction/section.json"), sectionBefore);
|
|
1997
|
+
assert.ok(!existsSync(path.join(workspace, ".planning/.wtfp-journal.json")));
|
|
1998
|
+
assert.deepEqual(
|
|
1999
|
+
readdirSync(path.join(workspace, ".planning/sections/introduction")).filter((name) => name.endsWith(".partial")),
|
|
2000
|
+
[],
|
|
2001
|
+
);
|
|
2002
|
+
}));
|
|
2003
|
+
|
|
2004
|
+
test("a fresh process trusts only answers it can verify and reports drift instead of inventing state (L1)", async () => {
|
|
2005
|
+
const workspace = project();
|
|
2006
|
+
let key: unknown;
|
|
2007
|
+
const first = withClioFacts(await createExtensionTestHost(ROOT, { workspace, sessionId: "first" }), workspace);
|
|
2008
|
+
try {
|
|
2009
|
+
await answer(first, GATE, "protocol-first");
|
|
2010
|
+
await answer(first, PLAN_GATE, "approve");
|
|
2011
|
+
key = (await first.store.get("seal-key")).value;
|
|
2012
|
+
assert.match(String(key), /^[a-f0-9]{64}$/);
|
|
2013
|
+
} finally {
|
|
2014
|
+
await first.dispose();
|
|
2015
|
+
}
|
|
2016
|
+
const resumed = withClioFacts(await createExtensionTestHost(ROOT, { workspace, sessionId: "resumed" }), workspace);
|
|
2017
|
+
const elsewhere = withClioFacts(await createExtensionTestHost(ROOT, { workspace, sessionId: "other-machine" }), workspace);
|
|
2018
|
+
try {
|
|
2019
|
+
await resumed.store.set("seal-key", key);
|
|
2020
|
+
assert.equal(blocked(await write(resumed, "paper/introduction.md")), null, "the same machine's key verifies the sealed answers");
|
|
2021
|
+
assert.match(blocked(await write(elsewhere, "paper/introduction.md")) ?? "", /not observed by this desk/);
|
|
2022
|
+
const validated = await resumed.command("validate");
|
|
2023
|
+
assert.match(validated.text, /words-unmeasured/);
|
|
2024
|
+
writeFileSync(path.join(workspace, PLAN_FILE), "# Plan\n\nChanged between sessions.\n");
|
|
2025
|
+
assert.match(blocked(await write(resumed, "paper/introduction.md")) ?? "", /plan changed after the author approved it/);
|
|
2026
|
+
} finally {
|
|
2027
|
+
await resumed.dispose();
|
|
2028
|
+
await elsewhere.dispose();
|
|
2029
|
+
rmSync(workspace, { recursive: true, force: true });
|
|
2030
|
+
}
|
|
2031
|
+
});
|
|
2032
|
+
|
|
2033
|
+
// --- simulated lifecycle rehearsal --------------------------------------------------------
|
|
2034
|
+
|
|
2035
|
+
/**
|
|
2036
|
+
* SIMULATED: every "author" answer below is a scripted interview event, not a
|
|
2037
|
+
* person. This rehearses the desk's bookkeeping across a whole section
|
|
2038
|
+
* lifecycle; it is never evidence that an author decided anything.
|
|
2039
|
+
*/
|
|
2040
|
+
test("SIMULATED rehearsal: initialize, outline, reject then approve a plan, draft through an interruption, review, revise, pause and resume in a fresh process", async () => {
|
|
2041
|
+
assert.ok(process.env.TMPDIR, "Tests need a task-owned TMPDIR.");
|
|
2042
|
+
const workspace = mkdtempSync(path.join(process.env.TMPDIR, "wtfp-desk-rehearsal-"));
|
|
2043
|
+
const ID = "rehearsal";
|
|
2044
|
+
const S = "evaluation";
|
|
2045
|
+
let host = withClioFacts(await createExtensionTestHost(ROOT, { workspace, plugin: SERVED, sessionId: "s1" }), workspace);
|
|
2046
|
+
const turn = async (command: string) => {
|
|
2047
|
+
await host.observe({ event: "turn_end", turnId: "t", outcome: "completed", usage: null });
|
|
2048
|
+
const armed = await host.hook({ point: "prompt_submit", text: command });
|
|
2049
|
+
assert.equal(armed.effects?.[0]?.kind, "notify_operator", `${command} did not arm`);
|
|
2050
|
+
};
|
|
2051
|
+
const write = async (uri: string, change: (record: Json | null) => Json) => {
|
|
2052
|
+
const seen = (await host.tool("read_record", { uri })).data as Json;
|
|
2053
|
+
const record = change(seen.exists ? (seen.record as Json) : null);
|
|
2054
|
+
const expect = !seen.exists ? {} : typeof seen.revision === "number" ? { expect_revision: seen.revision } : { expect_sha256: seen.sha256 };
|
|
2055
|
+
const result = await host.tool("record", { uri, record, ...expect });
|
|
2056
|
+
assert.equal(result.isError, undefined, `${uri}: ${result.text}`);
|
|
2057
|
+
};
|
|
2058
|
+
const file = async (relative: string, text: string) => {
|
|
2059
|
+
assert.equal(blocked(await host.hook({ point: "before_tool", tool: "write", turnId: "t", args: { path: relative } })), null, `writing ${relative} was refused`);
|
|
2060
|
+
put(workspace, relative, text);
|
|
2061
|
+
};
|
|
2062
|
+
const ask = async (checkpoint: string, choice: string) => {
|
|
2063
|
+
const asked = await host.tool("gate", { checkpoint });
|
|
2064
|
+
const done = await host.interview({ id: "gate-one", step: asked.interview?.step.key as string, nav: "next", answers: { choice } });
|
|
2065
|
+
assert.ok("done" in done, `answering ${checkpoint} was asked again`);
|
|
2066
|
+
return done.text;
|
|
2067
|
+
};
|
|
2068
|
+
const checkpoint = (id: string, scope: string, request: string, options: Array<[string, string]>): Json => ({
|
|
2069
|
+
schema: "wtfp.project.checkpoint/v1", id, project_id: ID, kind: "decision", status: "pending", blocking: true,
|
|
2070
|
+
scope_uri: scope, request, options: options.map(([option, label]) => ({ id: option, label, implication: `${label}.` })),
|
|
2071
|
+
resume_action: "write-section", created_at: AT,
|
|
2072
|
+
});
|
|
2073
|
+
const sectionUri = `project://sections/${S}`;
|
|
2074
|
+
try {
|
|
2075
|
+
await turn("/wtfp:new-paper durable workflows");
|
|
2076
|
+
await write("project://manifest", () => ({
|
|
2077
|
+
schema: "wtfp.project.manifest/v1", protocol_version: 1, id: ID, title: "Resilient Checkpoint Coordination",
|
|
2078
|
+
document_type: "research-article", core_argument: "Coordinated incremental checkpoints reduce interruption.",
|
|
2079
|
+
target: { audience: "Systems researchers", word_limit: 120 }, requirements: { must_have: [], should_have: [], out_of_scope: [] },
|
|
2080
|
+
created_at: AT, updated_at: AT,
|
|
2081
|
+
artifacts: { manifest: "project://manifest", config: "project://config", state: "project://state", decisions: "project://decisions", outline: "project://structure/outline", materials: [], manuscripts: [], deliverables: [], archives: [] },
|
|
2082
|
+
}));
|
|
2083
|
+
await write("project://config", () => ({ schema: "wtfp.project.config/v1", project_id: ID, interaction_mode: "standard", depth: "standard", output_format: "markdown", language: "en-US", gates: { confirm_outline: true, confirm_plan: true, confirm_write: true, confirm_review: true, confirm_delivery: true }, workflow: { research: true, plan_validation: true, argument_validation: true, coherence_validation: true }, safety: { destructive_requires_authorization: true, external_publish_requires_authorization: true, backup_before_major_edits: true }, parallelism: { enabled: false, max_workers: 1 } }));
|
|
2084
|
+
await write("project://state", () => ({ schema: "wtfp.project.state/v1", project_id: ID, revision: 0, phase: "initialized", status: "active", current_section_uri: null, progress: { sections_total: 0, sections_complete: 0, word_target: 120, word_count: 0 }, active_checkpoint_uris: [], updated_at: AT }));
|
|
2085
|
+
await write("project://decisions", () => ({ schema: "wtfp.project.decisions/v1", project_id: ID, revision: 0, items: [], updated_at: AT }));
|
|
2086
|
+
const entry = { id: S, title: "Evaluation", goal: "Report the measurements.", argument_role: "evidence", word_target: 120, wave: 1, depends_on: [], claim_ids: [], research: { required: false, topics: [] } };
|
|
2087
|
+
await write("project://structure/outline", () => ({ schema: "wtfp.project.outline/v1", project_id: ID, revision: 0, thesis: "Coordinated incremental checkpoints reduce interruption.", target_words: 120, sections: [entry], updated_at: AT }));
|
|
2088
|
+
|
|
2089
|
+
await turn("/wtfp:create-outline");
|
|
2090
|
+
await write("project://structure/outline", (outline) => ({ ...(outline as Json), sections: [{ ...entry, goal: "Report the synthetic interruption measurements." }] }));
|
|
2091
|
+
await write(sectionUri, () => ({ schema: "wtfp.project.section/v1", id: S, project_id: ID, outline_uri: "project://structure/outline", title: "Evaluation", goal: "Report the synthetic interruption measurements.", status: "not-started", word_target: 120, word_count: 0, wave: 1, depends_on: [], claims: [], artifacts: { plans: [], reviews: [], manuscript: `project://paper/${S}` }, checkpoint_uris: [], validation_uris: [], updated_at: AT }));
|
|
2092
|
+
await write("project://state", (state) => ({ ...(state as Json), phase: "outlining", progress: { ...((state as Json).progress as Json), sections_total: 1 } }));
|
|
2093
|
+
|
|
2094
|
+
await turn(`/wtfp:discuss-section ${S}`);
|
|
2095
|
+
await file(`.planning/sections/${S}/context.md`, "# Context\n\nReport only the supplied synthetic observations.\n");
|
|
2096
|
+
await write("project://checkpoints/framing", () => checkpoint("framing", sectionUri, "Lead with interruption time or recovery coverage?", [["interruption", "Interruption time"], ["coverage", "Recovery coverage"]]));
|
|
2097
|
+
assert.match(await ask("framing", "interruption"), /Recorded the author's answer/);
|
|
2098
|
+
await write(sectionUri, (section) => ({ ...(section as Json), checkpoint_uris: ["project://checkpoints/framing"], artifacts: { ...((section as Json).artifacts as Json), context: `${sectionUri}/context` } }));
|
|
2099
|
+
|
|
2100
|
+
await turn(`/wtfp:plan-section ${S}`);
|
|
2101
|
+
await file(`.planning/sections/${S}/plans/first.md`, "# Plan\n\n1. Report every measurement at once.\n");
|
|
2102
|
+
await write("project://checkpoints/approve-first", () => checkpoint("approve-first", `${sectionUri}/plans/first`, "Approve the evaluation plan?", [["approve", "Approve"], ["revise", "Revise"], ["reject", "Reject"]]));
|
|
2103
|
+
assert.match(await ask("approve-first", "revise"), /Revise/, "the author's rejection is recorded, not approval");
|
|
2104
|
+
await file(`.planning/sections/${S}/plans/second.md`, "# Plan\n\n1. Lead with interruption time.\n2. Bound every claim to the synthetic workload.\n");
|
|
2105
|
+
await write("project://checkpoints/approve-second", () => checkpoint("approve-second", `${sectionUri}/plans/second`, "Approve the revised evaluation plan?", [["approve", "Approve"], ["revise", "Revise"], ["reject", "Reject"]]));
|
|
2106
|
+
assert.match(await ask("approve-second", "approve"), /Approve/);
|
|
2107
|
+
await write(sectionUri, (section) => ({ ...(section as Json), status: "planned", artifacts: { ...((section as Json).artifacts as Json), plans: [`${sectionUri}/plans/second`] } }));
|
|
2108
|
+
await write("project://state", (state) => ({ ...(state as Json), phase: "planning", current_section_uri: sectionUri }));
|
|
2109
|
+
|
|
2110
|
+
await turn(`/wtfp:write-section ${S}`);
|
|
2111
|
+
assert.equal((((await host.tool("readiness", { section: S })).data) as Json).ready, true);
|
|
2112
|
+
const dispatched = await host.hook({ point: "before_tool", tool: "dispatch", turnId: "t", args: { agent: "wtfp-section-writer", task: "Draft the evaluation." } });
|
|
2113
|
+
assert.ok(dispatched.effects?.some((effect) => effect.kind === "rewrite_tool_input"), "the writer is dispatched with confined roots");
|
|
2114
|
+
await file(`paper/${S}.md`, "# Evaluation\n\nCoordinated incremental checkpoints reduced measured interruption in the synthetic workload.\n");
|
|
2115
|
+
process.env.WTFP_DESK_TEST_FAULT = "between-renames";
|
|
2116
|
+
try {
|
|
2117
|
+
assert.match((await host.tool("measure_section", { section: S })).text, /injected fault/);
|
|
2118
|
+
} finally {
|
|
2119
|
+
delete process.env.WTFP_DESK_TEST_FAULT;
|
|
2120
|
+
}
|
|
2121
|
+
assert.match((await host.command("validate")).text, /Completed an interrupted write/);
|
|
2122
|
+
await file(`.planning/sections/${S}/summary.md`, "Drafted from the second plan; eleven body words.\n");
|
|
2123
|
+
await write("project://manifest", (manifest) => ({ ...(manifest as Json), artifacts: { ...((manifest as Json).artifacts as Json), manuscripts: [`project://paper/${S}`] } }));
|
|
2124
|
+
await write(sectionUri, (section) => ({ ...(section as Json), status: "reviewing", artifacts: { ...((section as Json).artifacts as Json), summary: `${sectionUri}/summary` } }));
|
|
2125
|
+
|
|
2126
|
+
await turn(`/wtfp:review-section ${S}`);
|
|
2127
|
+
await file(`.planning/sections/${S}/reviews/first.md`, "# Review\n\nThe sentence needs the workload size.\n");
|
|
2128
|
+
await write("project://validations/review-first", () => ({ schema: "wtfp.project.validation/v1", id: "review-first", project_id: ID, subject_uri: sectionUri, validator_role: "section-reviewer", action_id: "review-section", status: "issues-found", checks: [{ id: "scope", status: "failed", summary: "Workload size is missing.", evidence: ["paper/evaluation.md"] }], issues: [{ severity: "error", summary: "State the workload size." }], next_actions: [{ action: "plan-revision", reason: "One error to fix." }], effects_applied: [], executed_at: AT }));
|
|
2129
|
+
await write(sectionUri, (section) => ({ ...(section as Json), validation_uris: ["project://validations/review-first"], artifacts: { ...((section as Json).artifacts as Json), reviews: [`${sectionUri}/reviews/first`] } }));
|
|
2130
|
+
|
|
2131
|
+
await turn(`/wtfp:plan-revision ${S}`);
|
|
2132
|
+
assert.ok(blocked(await host.hook({ point: "before_tool", tool: "write", turnId: "t", args: { path: `.planning/sections/${S}/plans/second.md` } })), "the approved plan cannot be edited in place");
|
|
2133
|
+
await file(`.planning/sections/${S}/plans/revision.md`, "# Revision plan\n\n1. Add the workload size to the measured sentence.\n");
|
|
2134
|
+
await write("project://checkpoints/approve-revision", () => checkpoint("approve-revision", `${sectionUri}/plans/revision`, "Approve the revision plan?", [["approve", "Approve"], ["revise", "Revise"], ["reject", "Reject"]]));
|
|
2135
|
+
assert.ok(blocked(await host.hook({ point: "before_tool", tool: "write", turnId: "t", args: { path: `paper/${S}.md` } })), "plan-revision never writes the manuscript");
|
|
2136
|
+
assert.match(await ask("approve-revision", "approve"), /Approve/);
|
|
2137
|
+
await write(sectionUri, (section) => ({ ...(section as Json), status: "writing", artifacts: { ...((section as Json).artifacts as Json), plans: [`${sectionUri}/plans/second`, `${sectionUri}/plans/revision`] } }));
|
|
2138
|
+
|
|
2139
|
+
await turn(`/wtfp:write-section ${S}`);
|
|
2140
|
+
await file(`paper/${S}.md`, "# Evaluation\n\nIn the synthetic 512-node workload, coordinated incremental checkpoints reduced measured interruption.\n");
|
|
2141
|
+
assert.equal((await host.tool("measure_section", { section: S })).isError, undefined);
|
|
2142
|
+
|
|
2143
|
+
await turn("/wtfp:pause-writing");
|
|
2144
|
+
await file(`.planning/sections/${S}/handoff.md`, "Resume by verifying the revised evaluation.\n");
|
|
2145
|
+
await write("project://checkpoints/resume", () => ({ ...checkpoint("resume", sectionUri, "Which action resumes the work?", [["verify", "Verify the section"], ["review", "Review again"]]), kind: "human-action", resume_action: "verify-work" }));
|
|
2146
|
+
await write(sectionUri, (section) => ({ ...(section as Json), checkpoint_uris: ["project://checkpoints/framing", "project://checkpoints/resume"], artifacts: { ...((section as Json).artifacts as Json), handoff: `${sectionUri}/handoff` } }));
|
|
2147
|
+
await write("project://state", (state) => ({ ...(state as Json), status: "paused", phase: "writing", active_checkpoint_uris: ["project://checkpoints/resume"] }));
|
|
2148
|
+
|
|
2149
|
+
// A fresh process: no session state, the same machine's store.
|
|
2150
|
+
const key = (await host.store.get("seal-key")).value;
|
|
2151
|
+
await host.dispose();
|
|
2152
|
+
host = withClioFacts(await createExtensionTestHost(ROOT, { workspace, plugin: SERVED, sessionId: "s2" }), workspace);
|
|
2153
|
+
await host.store.set("seal-key", key);
|
|
2154
|
+
const progress = await host.command("progress");
|
|
2155
|
+
assert.match(progress.text, /evaluation: writing .* plan approved/);
|
|
2156
|
+
assert.match(progress.text, /Next: \/wtfp:check-todos \(Gate waiting on you: Which action resumes the work\?\)/);
|
|
2157
|
+
await turn("/wtfp:resume-writing");
|
|
2158
|
+
assert.match(await ask("resume", "verify"), /Verify the section/);
|
|
2159
|
+
await write("project://state", (state) => ({ ...(state as Json), status: "active" }));
|
|
2160
|
+
const validated = await host.command("validate");
|
|
2161
|
+
assert.doesNotMatch(validated.text, /^(blocker|error) /m, validated.text);
|
|
2162
|
+
assert.ok(blocked(await host.hook({ point: "before_tool", tool: "write", turnId: "t", args: { path: `paper/${S}.md` } })), "resume-writing declares no manuscript output");
|
|
2163
|
+
await host.observe({ event: "turn_end", turnId: "t", outcome: "completed", usage: null });
|
|
2164
|
+
assert.equal((((await host.tool("readiness", { section: S })).data) as Json).ready, true);
|
|
2165
|
+
assert.equal(blocked(await host.hook({ point: "before_tool", tool: "write", turnId: "t", args: { path: `paper/${S}.md` } })), null, "the approved revision still authorizes the manuscript");
|
|
2166
|
+
const decisions = interactions(workspace).map((entry) => `${entry.subject_uri}:${entry.outcome}:${entry.selected_option ?? ""}`).sort();
|
|
2167
|
+
assert.deepEqual(decisions, [
|
|
2168
|
+
"project://checkpoints/approve-first:selected:revise",
|
|
2169
|
+
"project://checkpoints/approve-revision:selected:approve",
|
|
2170
|
+
"project://checkpoints/approve-second:selected:approve",
|
|
2171
|
+
"project://checkpoints/framing:selected:interruption",
|
|
2172
|
+
"project://checkpoints/resume:selected:verify",
|
|
2173
|
+
]);
|
|
2174
|
+
} finally {
|
|
2175
|
+
await host.dispose();
|
|
2176
|
+
rmSync(workspace, { recursive: true, force: true });
|
|
2177
|
+
}
|
|
2178
|
+
});
|
|
2179
|
+
|
|
2180
|
+
// --- the desk itself -------------------------------------------------------------------
|
|
2181
|
+
|
|
216
2182
|
test("the desk enters with its four regions and clears its ambient UI when left in a folder with no project", async () => {
|
|
217
2183
|
assert.ok(process.env.TMPDIR, "Tests need a task-owned TMPDIR.");
|
|
218
2184
|
const workspace = mkdtempSync(path.join(process.env.TMPDIR, "wtfp-desk-empty-"));
|
|
219
|
-
const host = await createExtensionTestHost(ROOT, { workspace });
|
|
2185
|
+
const host = withClioFacts(await createExtensionTestHost(ROOT, { workspace }), workspace);
|
|
220
2186
|
try {
|
|
221
2187
|
const entered = await host.command("desk");
|
|
222
2188
|
assert.deepEqual(entered.workspace, { enter: "desk" });
|
|
@@ -224,6 +2190,7 @@ test("the desk enters with its four regions and clears its ambient UI when left
|
|
|
224
2190
|
assert.match(JSON.stringify(entered.band), /new-paper/);
|
|
225
2191
|
const left = await host.observe({ event: "workspace_leave", workspace: "desk" });
|
|
226
2192
|
assert.deepEqual(left, { text: "", status: null, band: null, islands: null });
|
|
2193
|
+
assert.ok(!existsSync(path.join(workspace, ".planning")), "drawing the desk creates nothing");
|
|
227
2194
|
} finally {
|
|
228
2195
|
await host.dispose();
|
|
229
2196
|
rmSync(workspace, { recursive: true, force: true });
|
|
@@ -231,18 +2198,20 @@ test("the desk enters with its four regions and clears its ambient UI when left
|
|
|
231
2198
|
});
|
|
232
2199
|
|
|
233
2200
|
test("without its plugin the desk names only its own commands and never a /wtfp: prompt", () =>
|
|
234
|
-
withDesk(async (host) => {
|
|
2201
|
+
withDesk(async (host, workspace) => {
|
|
2202
|
+
const before = statSync(path.join(workspace, ".planning/state.json")).mtimeMs;
|
|
235
2203
|
const outputs: unknown[] = [];
|
|
236
|
-
for (const name of ["desk", "progress", "help", "
|
|
2204
|
+
for (const name of ["desk", "progress", "help", "checkpoints", "validate"]) outputs.push(await host.command(name));
|
|
237
2205
|
for (const id of ["next", "help"]) outputs.push(await host.action(id));
|
|
238
2206
|
outputs.push(await host.action("section", "introduction"));
|
|
239
2207
|
outputs.push(await host.hook({ point: "prompt_submit", text: "/wtfp:write-section introduction" }));
|
|
240
|
-
outputs.push(await host
|
|
2208
|
+
outputs.push(await write(host, "src/notes.md"));
|
|
241
2209
|
await host.hook({ point: "prompt_submit", text: "plain text" });
|
|
242
|
-
outputs.push(await host
|
|
2210
|
+
outputs.push(await write(host, "paper/introduction.md"));
|
|
243
2211
|
outputs.push(await host.observe({ event: "session_open", reason: "startup" }));
|
|
244
2212
|
const emitted = JSON.stringify(outputs);
|
|
245
2213
|
assert.doesNotMatch(emitted, /\/wtfp:/);
|
|
246
2214
|
assert.match(emitted, /\/ext:wtfp:check-todos/);
|
|
247
2215
|
assert.match(emitted, /needs the WTF-P plugin|not installed and enabled/);
|
|
2216
|
+
assert.equal(statSync(path.join(workspace, ".planning/state.json")).mtimeMs, before);
|
|
248
2217
|
}));
|