@paths.design/caws-cli 10.1.0 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +125 -374
- package/dist/index.js +43 -756
- package/dist/shell/binding/resolve-binding.d.ts +4 -0
- package/dist/shell/binding/resolve-binding.d.ts.map +1 -0
- package/dist/shell/binding/resolve-binding.js +228 -0
- package/dist/shell/binding/resolve-binding.js.map +1 -0
- package/dist/shell/binding/types.d.ts +42 -0
- package/dist/shell/binding/types.d.ts.map +1 -0
- package/dist/shell/binding/types.js +21 -0
- package/dist/shell/binding/types.js.map +1 -0
- package/dist/shell/commands/claim.d.ts +14 -0
- package/dist/shell/commands/claim.d.ts.map +1 -0
- package/dist/shell/commands/claim.js +197 -0
- package/dist/shell/commands/claim.js.map +1 -0
- package/dist/shell/commands/doctor.d.ts +13 -0
- package/dist/shell/commands/doctor.d.ts.map +1 -0
- package/dist/shell/commands/doctor.js +97 -0
- package/dist/shell/commands/doctor.js.map +1 -0
- package/dist/shell/commands/evidence.d.ts +28 -0
- package/dist/shell/commands/evidence.d.ts.map +1 -0
- package/dist/shell/commands/evidence.js +166 -0
- package/dist/shell/commands/evidence.js.map +1 -0
- package/dist/shell/commands/gates.d.ts +19 -0
- package/dist/shell/commands/gates.d.ts.map +1 -0
- package/dist/shell/commands/gates.js +181 -0
- package/dist/shell/commands/gates.js.map +1 -0
- package/dist/shell/commands/init.d.ts +8 -0
- package/dist/shell/commands/init.d.ts.map +1 -0
- package/dist/shell/commands/init.js +64 -0
- package/dist/shell/commands/init.js.map +1 -0
- package/dist/shell/commands/scope.d.ts +11 -0
- package/dist/shell/commands/scope.d.ts.map +1 -0
- package/dist/shell/commands/scope.js +92 -0
- package/dist/shell/commands/scope.js.map +1 -0
- package/dist/shell/commands/status.d.ts +15 -0
- package/dist/shell/commands/status.d.ts.map +1 -0
- package/dist/shell/commands/status.js +106 -0
- package/dist/shell/commands/status.js.map +1 -0
- package/dist/shell/commands/waiver.d.ts +38 -0
- package/dist/shell/commands/waiver.d.ts.map +1 -0
- package/dist/shell/commands/waiver.js +240 -0
- package/dist/shell/commands/waiver.js.map +1 -0
- package/dist/shell/gates/disposition.d.ts +23 -0
- package/dist/shell/gates/disposition.d.ts.map +1 -0
- package/dist/shell/gates/disposition.js +87 -0
- package/dist/shell/gates/disposition.js.map +1 -0
- package/dist/shell/gates/gate-result-contract.d.ts +39 -0
- package/dist/shell/gates/gate-result-contract.d.ts.map +1 -0
- package/dist/shell/gates/gate-result-contract.js +150 -0
- package/dist/shell/gates/gate-result-contract.js.map +1 -0
- package/dist/shell/gates/quality-gates-adapter.d.ts +55 -0
- package/dist/shell/gates/quality-gates-adapter.d.ts.map +1 -0
- package/dist/shell/gates/quality-gates-adapter.js +161 -0
- package/dist/shell/gates/quality-gates-adapter.js.map +1 -0
- package/dist/shell/gates/waiver-filter.d.ts +58 -0
- package/dist/shell/gates/waiver-filter.d.ts.map +1 -0
- package/dist/shell/gates/waiver-filter.js +119 -0
- package/dist/shell/gates/waiver-filter.js.map +1 -0
- package/dist/shell/index.d.ts +50 -0
- package/dist/shell/index.d.ts.map +1 -0
- package/dist/shell/index.js +73 -0
- package/dist/shell/index.js.map +1 -0
- package/dist/shell/register.d.ts +11 -0
- package/dist/shell/register.d.ts.map +1 -0
- package/dist/shell/register.js +274 -0
- package/dist/shell/register.js.map +1 -0
- package/dist/shell/render/claim.d.ts +22 -0
- package/dist/shell/render/claim.d.ts.map +1 -0
- package/dist/shell/render/claim.js +75 -0
- package/dist/shell/render/claim.js.map +1 -0
- package/dist/shell/render/decision.d.ts +15 -0
- package/dist/shell/render/decision.d.ts.map +1 -0
- package/dist/shell/render/decision.js +66 -0
- package/dist/shell/render/decision.js.map +1 -0
- package/dist/shell/render/diagnostic.d.ts +19 -0
- package/dist/shell/render/diagnostic.d.ts.map +1 -0
- package/dist/shell/render/diagnostic.js +76 -0
- package/dist/shell/render/diagnostic.js.map +1 -0
- package/dist/shell/render/finding.d.ts +15 -0
- package/dist/shell/render/finding.d.ts.map +1 -0
- package/dist/shell/render/finding.js +57 -0
- package/dist/shell/render/finding.js.map +1 -0
- package/dist/shell/render/gates.d.ts +3 -0
- package/dist/shell/render/gates.d.ts.map +1 -0
- package/dist/shell/render/gates.js +56 -0
- package/dist/shell/render/gates.js.map +1 -0
- package/dist/shell/render/init.d.ts +11 -0
- package/dist/shell/render/init.d.ts.map +1 -0
- package/dist/shell/render/init.js +32 -0
- package/dist/shell/render/init.js.map +1 -0
- package/dist/shell/render/status.d.ts +26 -0
- package/dist/shell/render/status.d.ts.map +1 -0
- package/dist/shell/render/status.js +143 -0
- package/dist/shell/render/status.js.map +1 -0
- package/dist/shell/render/waiver.d.ts +21 -0
- package/dist/shell/render/waiver.d.ts.map +1 -0
- package/dist/shell/render/waiver.js +94 -0
- package/dist/shell/render/waiver.js.map +1 -0
- package/dist/shell/rules.d.ts +37 -0
- package/dist/shell/rules.d.ts.map +1 -0
- package/dist/shell/rules.js +51 -0
- package/dist/shell/rules.js.map +1 -0
- package/dist/shell/session/actor.d.ts +14 -0
- package/dist/shell/session/actor.d.ts.map +1 -0
- package/dist/shell/session/actor.js +34 -0
- package/dist/shell/session/actor.js.map +1 -0
- package/dist/shell/session/resolve-session.d.ts +5 -0
- package/dist/shell/session/resolve-session.d.ts.map +1 -0
- package/dist/shell/session/resolve-session.js +239 -0
- package/dist/shell/session/resolve-session.js.map +1 -0
- package/dist/shell/session/types.d.ts +56 -0
- package/dist/shell/session/types.d.ts.map +1 -0
- package/dist/shell/session/types.js +15 -0
- package/dist/shell/session/types.js.map +1 -0
- package/dist/store/agents-store.d.ts +3 -0
- package/dist/store/agents-store.d.ts.map +1 -0
- package/dist/store/agents-store.js +63 -0
- package/dist/store/agents-store.js.map +1 -0
- package/dist/store/apply-patch.d.ts +16 -0
- package/dist/store/apply-patch.d.ts.map +1 -0
- package/dist/store/apply-patch.js +191 -0
- package/dist/store/apply-patch.js.map +1 -0
- package/dist/store/atomic-write.d.ts +16 -0
- package/dist/store/atomic-write.d.ts.map +1 -0
- package/dist/store/atomic-write.js +132 -0
- package/dist/store/atomic-write.js.map +1 -0
- package/dist/store/doctor-snapshot.d.ts +20 -0
- package/dist/store/doctor-snapshot.d.ts.map +1 -0
- package/dist/store/doctor-snapshot.js +176 -0
- package/dist/store/doctor-snapshot.js.map +1 -0
- package/dist/store/events-store.d.ts +33 -0
- package/dist/store/events-store.d.ts.map +1 -0
- package/dist/store/events-store.js +297 -0
- package/dist/store/events-store.js.map +1 -0
- package/dist/store/index.d.ts +21 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.js +47 -0
- package/dist/store/index.js.map +1 -0
- package/dist/store/init-store.d.ts +21 -0
- package/dist/store/init-store.d.ts.map +1 -0
- package/dist/store/init-store.js +295 -0
- package/dist/store/init-store.js.map +1 -0
- package/dist/store/json-store.d.ts +3 -0
- package/dist/store/json-store.d.ts.map +1 -0
- package/dist/store/json-store.js +65 -0
- package/dist/store/json-store.js.map +1 -0
- package/dist/store/policy-store.d.ts +3 -0
- package/dist/store/policy-store.d.ts.map +1 -0
- package/dist/store/policy-store.js +65 -0
- package/dist/store/policy-store.js.map +1 -0
- package/dist/store/repo-root.d.ts +46 -0
- package/dist/store/repo-root.d.ts.map +1 -0
- package/dist/store/repo-root.js +145 -0
- package/dist/store/repo-root.js.map +1 -0
- package/dist/store/rules.d.ts +53 -0
- package/dist/store/rules.d.ts.map +1 -0
- package/dist/store/rules.js +78 -0
- package/dist/store/rules.js.map +1 -0
- package/dist/store/specs-store.d.ts +3 -0
- package/dist/store/specs-store.d.ts.map +1 -0
- package/dist/store/specs-store.js +131 -0
- package/dist/store/specs-store.js.map +1 -0
- package/dist/store/types.d.ts +84 -0
- package/dist/store/types.d.ts.map +1 -0
- package/dist/store/types.js +14 -0
- package/dist/store/types.js.map +1 -0
- package/dist/store/waivers-store.d.ts +25 -0
- package/dist/store/waivers-store.d.ts.map +1 -0
- package/dist/store/waivers-store.js +232 -0
- package/dist/store/waivers-store.js.map +1 -0
- package/dist/store/worktrees-store.d.ts +3 -0
- package/dist/store/worktrees-store.d.ts.map +1 -0
- package/dist/store/worktrees-store.js +62 -0
- package/dist/store/worktrees-store.js.map +1 -0
- package/dist/store/yaml-store.d.ts +9 -0
- package/dist/store/yaml-store.d.ts.map +1 -0
- package/dist/store/yaml-store.js +121 -0
- package/dist/store/yaml-store.js.map +1 -0
- package/package.json +15 -13
- package/dist/budget-derivation.js +0 -751
- package/dist/cicd-optimizer.js +0 -504
- package/dist/commands/archive.js +0 -500
- package/dist/commands/burnup.js +0 -198
- package/dist/commands/diagnose.js +0 -525
- package/dist/commands/evaluate.js +0 -314
- package/dist/commands/gates.js +0 -149
- package/dist/commands/init.js +0 -857
- package/dist/commands/iterate.js +0 -417
- package/dist/commands/mode.js +0 -269
- package/dist/commands/parallel.js +0 -242
- package/dist/commands/plan.js +0 -438
- package/dist/commands/provenance.js +0 -1143
- package/dist/commands/quality-monitor.js +0 -284
- package/dist/commands/scope.js +0 -264
- package/dist/commands/session.js +0 -312
- package/dist/commands/sidecar.js +0 -74
- package/dist/commands/specs.js +0 -1448
- package/dist/commands/status.js +0 -1151
- package/dist/commands/templates.js +0 -237
- package/dist/commands/tool.js +0 -136
- package/dist/commands/tutorial.js +0 -480
- package/dist/commands/validate.js +0 -357
- package/dist/commands/verify-acs.js +0 -443
- package/dist/commands/waivers.js +0 -599
- package/dist/commands/workflow.js +0 -243
- package/dist/commands/worktree.js +0 -386
- package/dist/config/lite-scope.js +0 -158
- package/dist/config/modes.js +0 -347
- package/dist/constants/spec-types.js +0 -65
- package/dist/gates/budget-limit.js +0 -121
- package/dist/gates/feedback.js +0 -260
- package/dist/gates/format.js +0 -179
- package/dist/gates/god-object.js +0 -117
- package/dist/gates/pipeline.js +0 -167
- package/dist/gates/scope-boundary.js +0 -93
- package/dist/gates/spec-completeness.js +0 -109
- package/dist/gates/todo-detection.js +0 -205
- package/dist/generators/jest-config-generator.js +0 -242
- package/dist/generators/working-spec.js +0 -237
- package/dist/minimal-cli.js +0 -88
- package/dist/parallel/parallel-manager.js +0 -433
- package/dist/policy/PolicyManager.js +0 -465
- package/dist/scaffold/claude-hooks.js +0 -443
- package/dist/scaffold/cursor-hooks.js +0 -177
- package/dist/scaffold/git-hooks.js +0 -928
- package/dist/scaffold/index.js +0 -794
- package/dist/session/session-manager.js +0 -653
- package/dist/sidecars/index.js +0 -33
- package/dist/sidecars/listeners.js +0 -40
- package/dist/sidecars/provenance-summary.js +0 -238
- package/dist/sidecars/quality-gaps.js +0 -258
- package/dist/sidecars/schema.js +0 -149
- package/dist/sidecars/spec-drift.js +0 -151
- package/dist/sidecars/waiver-draft.js +0 -176
- package/dist/spec/SpecFileManager.js +0 -419
- package/dist/templates/.caws/schemas/policy.schema.json +0 -112
- package/dist/templates/.caws/schemas/scope.schema.json +0 -52
- package/dist/templates/.caws/schemas/waivers.schema.json +0 -106
- package/dist/templates/.caws/schemas/working-spec.schema.json +0 -340
- package/dist/templates/.caws/schemas/worktrees.schema.json +0 -38
- package/dist/templates/.caws/templates/working-spec.template.yml +0 -80
- package/dist/templates/.caws/tools/README.md +0 -18
- package/dist/templates/.caws/tools/scope-guard.js +0 -203
- package/dist/templates/.caws/tools-allow.json +0 -331
- package/dist/templates/.caws/waivers.yml +0 -19
- package/dist/templates/.claude/README.md +0 -190
- package/dist/templates/.claude/hooks/audit.sh +0 -121
- package/dist/templates/.claude/hooks/block-dangerous.sh +0 -203
- package/dist/templates/.claude/hooks/classify_command.py +0 -592
- package/dist/templates/.claude/hooks/doc-frontmatter-check.sh +0 -173
- package/dist/templates/.claude/hooks/lite-sprawl-check.sh +0 -145
- package/dist/templates/.claude/hooks/naming-check.sh +0 -100
- package/dist/templates/.claude/hooks/protected-paths.sh +0 -39
- package/dist/templates/.claude/hooks/quality-check.sh +0 -81
- package/dist/templates/.claude/hooks/scan-secrets.sh +0 -85
- package/dist/templates/.claude/hooks/scope-guard.sh +0 -381
- package/dist/templates/.claude/hooks/session-caws-status.sh +0 -117
- package/dist/templates/.claude/hooks/session-log.sh +0 -634
- package/dist/templates/.claude/hooks/simplification-guard.sh +0 -92
- package/dist/templates/.claude/hooks/stop-worktree-check.sh +0 -46
- package/dist/templates/.claude/hooks/test_classify_command.py +0 -370
- package/dist/templates/.claude/hooks/test_wrapper_smoke.sh +0 -96
- package/dist/templates/.claude/hooks/validate-spec.sh +0 -76
- package/dist/templates/.claude/hooks/worktree-guard.sh +0 -220
- package/dist/templates/.claude/hooks/worktree-write-guard.sh +0 -190
- package/dist/templates/.claude/rules/git-safety.md +0 -26
- package/dist/templates/.claude/rules/worktree-isolation.md +0 -83
- package/dist/templates/.claude/settings.json +0 -141
- package/dist/templates/.cursor/README.md +0 -299
- package/dist/templates/.cursor/hooks/audit.sh +0 -55
- package/dist/templates/.cursor/hooks/block-dangerous.sh +0 -84
- package/dist/templates/.cursor/hooks/caws-quality-check.sh +0 -52
- package/dist/templates/.cursor/hooks/caws-scope-guard.sh +0 -130
- package/dist/templates/.cursor/hooks/format.sh +0 -38
- package/dist/templates/.cursor/hooks/naming-check.sh +0 -64
- package/dist/templates/.cursor/hooks/scan-secrets.sh +0 -51
- package/dist/templates/.cursor/hooks/scope-guard.sh +0 -52
- package/dist/templates/.cursor/hooks/session-log.sh +0 -924
- package/dist/templates/.cursor/hooks/validate-spec.sh +0 -83
- package/dist/templates/.cursor/hooks.json +0 -76
- package/dist/templates/.cursor/rules/00-claims-verification.mdc +0 -144
- package/dist/templates/.cursor/rules/01-working-style.mdc +0 -50
- package/dist/templates/.cursor/rules/02-quality-gates.mdc +0 -368
- package/dist/templates/.cursor/rules/03-naming-and-refactor.mdc +0 -33
- package/dist/templates/.cursor/rules/04-logging-language-style.mdc +0 -23
- package/dist/templates/.cursor/rules/05-safe-defaults-guards.mdc +0 -23
- package/dist/templates/.cursor/rules/06-typescript-conventions.mdc +0 -36
- package/dist/templates/.cursor/rules/07-process-ops.mdc +0 -20
- package/dist/templates/.cursor/rules/08-solid-and-architecture.mdc +0 -16
- package/dist/templates/.cursor/rules/09-docstrings.mdc +0 -89
- package/dist/templates/.cursor/rules/10-documentation-quality-standards.mdc +0 -385
- package/dist/templates/.cursor/rules/11-scope-management-waivers.mdc +0 -381
- package/dist/templates/.cursor/rules/12-implementation-completeness.mdc +0 -516
- package/dist/templates/.cursor/rules/13-language-agnostic-standards.mdc +0 -578
- package/dist/templates/.cursor/rules/README.md +0 -148
- package/dist/templates/.github/copilot-instructions.md +0 -82
- package/dist/templates/.idea/runConfigurations/CAWS_Evaluate.xml +0 -5
- package/dist/templates/.idea/runConfigurations/CAWS_Validate.xml +0 -5
- package/dist/templates/.junie/guidelines.md +0 -73
- package/dist/templates/.vscode/launch.json +0 -17
- package/dist/templates/.vscode/settings.json +0 -95
- package/dist/templates/.windsurf/rules/caws-quality-standards.md +0 -54
- package/dist/templates/.windsurf/workflows/caws-guided-development.md +0 -92
- package/dist/templates/CLAUDE.md +0 -174
- package/dist/templates/COMMIT_CONVENTIONS.md +0 -86
- package/dist/templates/OIDC_SETUP.md +0 -300
- package/dist/templates/agents.md +0 -145
- package/dist/templates/codemod/README.md +0 -1
- package/dist/templates/codemod/test.js +0 -93
- package/dist/templates/docs/README.md +0 -151
- package/dist/templates/scripts/new_feature.sh +0 -80
- package/dist/templates/scripts/quality-gates/check-god-objects.js +0 -146
- package/dist/templates/scripts/quality-gates/run-quality-gates.js +0 -50
- package/dist/templates/scripts/v3/analysis/todo_analyzer.py +0 -1997
- package/dist/test-analysis.js +0 -786
- package/dist/tool-interface.js +0 -314
- package/dist/tool-loader.js +0 -303
- package/dist/tool-validator.js +0 -393
- package/dist/utils/agent-session.js +0 -202
- package/dist/utils/async-utils.js +0 -188
- package/dist/utils/command-wrapper.js +0 -200
- package/dist/utils/event-log.js +0 -584
- package/dist/utils/event-renderer.js +0 -521
- package/dist/utils/finalization.js +0 -230
- package/dist/utils/git-lock.js +0 -119
- package/dist/utils/gitignore-updater.js +0 -158
- package/dist/utils/ide-detection.js +0 -133
- package/dist/utils/lifecycle-events.js +0 -94
- package/dist/utils/project-analysis.js +0 -367
- package/dist/utils/promise-utils.js +0 -72
- package/dist/utils/quality-gates-errors.js +0 -520
- package/dist/utils/quality-gates-utils.js +0 -387
- package/dist/utils/schema-validator.js +0 -50
- package/dist/utils/spec-resolver.js +0 -711
- package/dist/utils/typescript-detector.js +0 -369
- package/dist/utils/working-state.js +0 -530
- package/dist/utils/yaml-validation.js +0 -156
- package/dist/validation/spec-validation.js +0 -921
- package/dist/waivers-manager.js +0 -732
- package/dist/worktree/worktree-manager.js +0 -1374
- package/templates/.caws/schemas/policy.schema.json +0 -112
- package/templates/.caws/schemas/scope.schema.json +0 -52
- package/templates/.caws/schemas/waivers.schema.json +0 -106
- package/templates/.caws/schemas/working-spec.schema.json +0 -340
- package/templates/.caws/schemas/worktrees.schema.json +0 -38
- package/templates/.caws/templates/working-spec.template.yml +0 -80
- package/templates/.caws/tools/README.md +0 -18
- package/templates/.caws/tools/scope-guard.js +0 -203
- package/templates/.caws/tools-allow.json +0 -331
- package/templates/.caws/waivers.yml +0 -19
- package/templates/.claude/README.md +0 -190
- package/templates/.claude/hooks/audit.sh +0 -121
- package/templates/.claude/hooks/block-dangerous.sh +0 -203
- package/templates/.claude/hooks/classify_command.py +0 -592
- package/templates/.claude/hooks/doc-frontmatter-check.sh +0 -173
- package/templates/.claude/hooks/lite-sprawl-check.sh +0 -145
- package/templates/.claude/hooks/naming-check.sh +0 -100
- package/templates/.claude/hooks/protected-paths.sh +0 -39
- package/templates/.claude/hooks/quality-check.sh +0 -81
- package/templates/.claude/hooks/scan-secrets.sh +0 -85
- package/templates/.claude/hooks/scope-guard.sh +0 -381
- package/templates/.claude/hooks/session-caws-status.sh +0 -117
- package/templates/.claude/hooks/session-log.sh +0 -634
- package/templates/.claude/hooks/simplification-guard.sh +0 -92
- package/templates/.claude/hooks/stop-worktree-check.sh +0 -46
- package/templates/.claude/hooks/test_classify_command.py +0 -370
- package/templates/.claude/hooks/test_wrapper_smoke.sh +0 -96
- package/templates/.claude/hooks/validate-spec.sh +0 -76
- package/templates/.claude/hooks/worktree-guard.sh +0 -220
- package/templates/.claude/hooks/worktree-write-guard.sh +0 -190
- package/templates/.claude/rules/git-safety.md +0 -26
- package/templates/.claude/rules/worktree-isolation.md +0 -83
- package/templates/.claude/settings.json +0 -141
- package/templates/.cursor/README.md +0 -299
- package/templates/.cursor/hooks/audit.sh +0 -55
- package/templates/.cursor/hooks/block-dangerous.sh +0 -84
- package/templates/.cursor/hooks/caws-quality-check.sh +0 -52
- package/templates/.cursor/hooks/caws-scope-guard.sh +0 -130
- package/templates/.cursor/hooks/format.sh +0 -38
- package/templates/.cursor/hooks/naming-check.sh +0 -64
- package/templates/.cursor/hooks/scan-secrets.sh +0 -51
- package/templates/.cursor/hooks/scope-guard.sh +0 -52
- package/templates/.cursor/hooks/session-log.sh +0 -924
- package/templates/.cursor/hooks/validate-spec.sh +0 -83
- package/templates/.cursor/hooks.json +0 -76
- package/templates/.cursor/rules/00-claims-verification.mdc +0 -144
- package/templates/.cursor/rules/01-working-style.mdc +0 -50
- package/templates/.cursor/rules/02-quality-gates.mdc +0 -368
- package/templates/.cursor/rules/03-naming-and-refactor.mdc +0 -33
- package/templates/.cursor/rules/04-logging-language-style.mdc +0 -23
- package/templates/.cursor/rules/05-safe-defaults-guards.mdc +0 -23
- package/templates/.cursor/rules/06-typescript-conventions.mdc +0 -36
- package/templates/.cursor/rules/07-process-ops.mdc +0 -20
- package/templates/.cursor/rules/08-solid-and-architecture.mdc +0 -16
- package/templates/.cursor/rules/09-docstrings.mdc +0 -89
- package/templates/.cursor/rules/10-documentation-quality-standards.mdc +0 -385
- package/templates/.cursor/rules/11-scope-management-waivers.mdc +0 -381
- package/templates/.cursor/rules/12-implementation-completeness.mdc +0 -516
- package/templates/.cursor/rules/13-language-agnostic-standards.mdc +0 -578
- package/templates/.cursor/rules/README.md +0 -148
- package/templates/.github/copilot-instructions.md +0 -82
- package/templates/.idea/runConfigurations/CAWS_Evaluate.xml +0 -5
- package/templates/.idea/runConfigurations/CAWS_Validate.xml +0 -5
- package/templates/.junie/guidelines.md +0 -73
- package/templates/.vscode/launch.json +0 -17
- package/templates/.vscode/settings.json +0 -95
- package/templates/.windsurf/rules/caws-quality-standards.md +0 -54
- package/templates/.windsurf/workflows/caws-guided-development.md +0 -92
- package/templates/CLAUDE.md +0 -174
- package/templates/COMMIT_CONVENTIONS.md +0 -86
- package/templates/OIDC_SETUP.md +0 -300
- package/templates/agents.md +0 -145
- package/templates/codemod/README.md +0 -1
- package/templates/codemod/test.js +0 -93
- package/templates/docs/README.md +0 -151
- package/templates/scripts/new_feature.sh +0 -80
- package/templates/scripts/quality-gates/check-god-objects.js +0 -146
- package/templates/scripts/quality-gates/run-quality-gates.js +0 -50
- package/templates/scripts/v3/analysis/todo_analyzer.py +0 -1997
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CAWS Workflow Command
|
|
3
|
-
*
|
|
4
|
-
* Provides workflow-specific guidance for development tasks.
|
|
5
|
-
* Supports TDD, refactor, and feature development workflows.
|
|
6
|
-
*
|
|
7
|
-
* @author @darianrosebrook
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
const chalk = require('chalk');
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Workflow templates with steps and guidance
|
|
14
|
-
*/
|
|
15
|
-
const WORKFLOW_TEMPLATES = {
|
|
16
|
-
tdd: {
|
|
17
|
-
name: 'Test-Driven Development',
|
|
18
|
-
steps: [
|
|
19
|
-
'Define requirements and acceptance criteria',
|
|
20
|
-
'Write failing test',
|
|
21
|
-
'Implement minimal code to pass test',
|
|
22
|
-
'Run CAWS validation',
|
|
23
|
-
'Refactor while maintaining tests',
|
|
24
|
-
'Repeat for next requirement',
|
|
25
|
-
],
|
|
26
|
-
guidance: {
|
|
27
|
-
1: 'Start by clearly defining what the code should do. Use CAWS working spec to document requirements.',
|
|
28
|
-
2: 'Write a test that captures the desired behavior but will initially fail.',
|
|
29
|
-
3: 'Implement only the minimal code needed to make the test pass.',
|
|
30
|
-
4: 'Run CAWS evaluation to ensure quality standards are maintained.',
|
|
31
|
-
5: 'Improve code structure while keeping all tests passing.',
|
|
32
|
-
6: 'Move to the next requirement and repeat the cycle.',
|
|
33
|
-
},
|
|
34
|
-
recommendations: {
|
|
35
|
-
1: ['caws evaluate --feedback-only', 'Ensure spec completeness'],
|
|
36
|
-
2: ['Write failing test first', 'caws validate for basic checks'],
|
|
37
|
-
3: ['Implement minimal solution', 'Run tests to verify'],
|
|
38
|
-
4: ['caws evaluate', 'Address any quality issues'],
|
|
39
|
-
5: ['Refactor safely', 'Re-run CAWS validation'],
|
|
40
|
-
6: ['caws iterate for next steps', 'Continue TDD cycle'],
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
refactor: {
|
|
44
|
-
name: 'Refactoring Workflow',
|
|
45
|
-
steps: [
|
|
46
|
-
'Establish baseline quality metrics',
|
|
47
|
-
'Apply refactoring changes',
|
|
48
|
-
'Run comprehensive validation',
|
|
49
|
-
'Address any quality gate failures',
|
|
50
|
-
'Document changes and rationale',
|
|
51
|
-
],
|
|
52
|
-
guidance: {
|
|
53
|
-
1: 'Run CAWS evaluation to establish current quality baseline.',
|
|
54
|
-
2: 'Make your refactoring changes incrementally.',
|
|
55
|
-
3: 'Run full CAWS validation to ensure no quality degradation.',
|
|
56
|
-
4: 'Address any failing quality gates with waivers if necessary.',
|
|
57
|
-
5: 'Update documentation and provenance records.',
|
|
58
|
-
},
|
|
59
|
-
recommendations: {
|
|
60
|
-
1: ['caws evaluate', 'Establish quality baseline'],
|
|
61
|
-
2: ['Apply changes incrementally', 'caws validate frequently'],
|
|
62
|
-
3: ['caws evaluate', 'Full quality assessment'],
|
|
63
|
-
4: ['Create waivers if needed', 'Document rationale'],
|
|
64
|
-
5: ['Update provenance', 'caws provenance update'],
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
feature: {
|
|
68
|
-
name: 'Feature Development',
|
|
69
|
-
steps: [
|
|
70
|
-
'Create working specification',
|
|
71
|
-
'Design and plan implementation',
|
|
72
|
-
'Implement core functionality',
|
|
73
|
-
'Add comprehensive testing',
|
|
74
|
-
'Run full quality validation',
|
|
75
|
-
'Prepare for integration',
|
|
76
|
-
],
|
|
77
|
-
guidance: {
|
|
78
|
-
1: 'Define clear requirements, acceptance criteria, and risk assessment.',
|
|
79
|
-
2: 'Break down the feature into manageable tasks.',
|
|
80
|
-
3: 'Implement core functionality with error handling.',
|
|
81
|
-
4: 'Add unit, integration, and contract tests.',
|
|
82
|
-
5: 'Run complete CAWS validation and address issues.',
|
|
83
|
-
6: 'Ensure documentation and provenance are complete.',
|
|
84
|
-
},
|
|
85
|
-
recommendations: {
|
|
86
|
-
1: ['caws init --interactive', 'Create comprehensive spec'],
|
|
87
|
-
2: ['caws iterate', 'Get implementation guidance'],
|
|
88
|
-
3: ['caws evaluate', 'Validate progress'],
|
|
89
|
-
4: ['Add comprehensive tests', 'Run test suite'],
|
|
90
|
-
5: ['caws validate', 'Final quality gates'],
|
|
91
|
-
6: ['caws provenance update', 'Prepare for integration'],
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Generate workflow guidance
|
|
98
|
-
*
|
|
99
|
-
* @param {string} workflowType - Type of workflow (tdd, refactor, feature)
|
|
100
|
-
* @param {number} currentStep - Current step number (1-based)
|
|
101
|
-
* @param {object} context - Optional context information
|
|
102
|
-
* @returns {object} Workflow guidance
|
|
103
|
-
*/
|
|
104
|
-
function generateWorkflowGuidance(workflowType, currentStep, context = {}) {
|
|
105
|
-
const template = WORKFLOW_TEMPLATES[workflowType];
|
|
106
|
-
|
|
107
|
-
if (!template) {
|
|
108
|
-
return {
|
|
109
|
-
error: `Unknown workflow type: ${workflowType}`,
|
|
110
|
-
available_types: Object.keys(WORKFLOW_TEMPLATES),
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const step = parseInt(currentStep, 10);
|
|
115
|
-
if (isNaN(step) || step < 1 || step > template.steps.length) {
|
|
116
|
-
return {
|
|
117
|
-
error: `Invalid step number: ${currentStep}. Must be between 1 and ${template.steps.length}`,
|
|
118
|
-
total_steps: template.steps.length,
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const currentGuidance = template.guidance[step] || 'Continue with the next logical step.';
|
|
123
|
-
const nextStep = step < template.steps.length ? step + 1 : null;
|
|
124
|
-
|
|
125
|
-
return {
|
|
126
|
-
workflow_type: workflowType,
|
|
127
|
-
workflow_name: template.name,
|
|
128
|
-
current_step: step,
|
|
129
|
-
total_steps: template.steps.length,
|
|
130
|
-
step_description: template.steps[step - 1] || 'Unknown step',
|
|
131
|
-
guidance: currentGuidance,
|
|
132
|
-
next_step: nextStep,
|
|
133
|
-
next_step_description: nextStep ? template.steps[nextStep - 1] : null,
|
|
134
|
-
all_steps: template.steps,
|
|
135
|
-
caws_recommendations: template.recommendations[step] || ['caws evaluate'],
|
|
136
|
-
context: context.description || null,
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Workflow command handler
|
|
142
|
-
*
|
|
143
|
-
* @param {string} workflowType - Type of workflow
|
|
144
|
-
* @param {object} options - Command options
|
|
145
|
-
*/
|
|
146
|
-
async function workflowCommand(workflowType, options = {}) {
|
|
147
|
-
try {
|
|
148
|
-
const step = parseInt(options.step || '1', 10);
|
|
149
|
-
let context = {};
|
|
150
|
-
|
|
151
|
-
// Parse context if provided
|
|
152
|
-
if (options.currentState) {
|
|
153
|
-
try {
|
|
154
|
-
context =
|
|
155
|
-
typeof options.currentState === 'string'
|
|
156
|
-
? JSON.parse(options.currentState)
|
|
157
|
-
: options.currentState;
|
|
158
|
-
} catch (e) {
|
|
159
|
-
console.warn(chalk.yellow('Invalid context JSON, ignoring'));
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// Generate guidance
|
|
164
|
-
const guidance = generateWorkflowGuidance(workflowType, step, context);
|
|
165
|
-
|
|
166
|
-
// Handle errors
|
|
167
|
-
if (guidance.error) {
|
|
168
|
-
console.error(chalk.red(`\n${guidance.error}`));
|
|
169
|
-
if (guidance.available_types) {
|
|
170
|
-
console.log(chalk.blue('\nAvailable workflow types:'));
|
|
171
|
-
guidance.available_types.forEach((type) => {
|
|
172
|
-
console.log(chalk.blue(` - ${type}`));
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
if (guidance.total_steps) {
|
|
176
|
-
console.log(chalk.blue(`\nValid steps: 1-${guidance.total_steps}`));
|
|
177
|
-
}
|
|
178
|
-
process.exit(1);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// Display guidance
|
|
182
|
-
console.log(chalk.bold('\nCAWS Workflow Guidance\n'));
|
|
183
|
-
console.log('-'.repeat(60));
|
|
184
|
-
console.log(chalk.bold(`\nWorkflow: ${guidance.workflow_name} (${guidance.workflow_type})`));
|
|
185
|
-
console.log(
|
|
186
|
-
chalk.bold(
|
|
187
|
-
`Step ${guidance.current_step}/${guidance.total_steps}: ${guidance.step_description}`
|
|
188
|
-
)
|
|
189
|
-
);
|
|
190
|
-
|
|
191
|
-
if (guidance.context) {
|
|
192
|
-
console.log(chalk.gray(`\nContext: ${guidance.context}`));
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
console.log(chalk.bold('\nGuidance:\n'));
|
|
196
|
-
console.log(` ${guidance.guidance}`);
|
|
197
|
-
|
|
198
|
-
console.log(chalk.bold('\nCAWS Recommendations:\n'));
|
|
199
|
-
guidance.caws_recommendations.forEach((rec) => {
|
|
200
|
-
console.log(chalk.blue(` - ${rec}`));
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
// Show next step if available
|
|
204
|
-
if (guidance.next_step) {
|
|
205
|
-
console.log(chalk.bold('\nNext Step:\n'));
|
|
206
|
-
console.log(chalk.gray(` Step ${guidance.next_step}: ${guidance.next_step_description}`));
|
|
207
|
-
console.log(
|
|
208
|
-
chalk.gray(`\n Run: caws workflow ${workflowType} --step ${guidance.next_step}`)
|
|
209
|
-
);
|
|
210
|
-
} else {
|
|
211
|
-
console.log(chalk.bold('\nWorkflow Complete!\n'));
|
|
212
|
-
console.log(chalk.green(' All steps in this workflow have been completed.'));
|
|
213
|
-
console.log(chalk.blue('\n Run: caws evaluate to check final quality'));
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
// Show all steps for reference
|
|
217
|
-
console.log(chalk.bold('\nAll Steps:\n'));
|
|
218
|
-
guidance.all_steps.forEach((stepDesc, idx) => {
|
|
219
|
-
const stepNum = idx + 1;
|
|
220
|
-
const icon =
|
|
221
|
-
stepNum === guidance.current_step ? '' : stepNum < guidance.current_step ? '' : '';
|
|
222
|
-
const color =
|
|
223
|
-
stepNum === guidance.current_step
|
|
224
|
-
? chalk.bold
|
|
225
|
-
: stepNum < guidance.current_step
|
|
226
|
-
? chalk.green
|
|
227
|
-
: chalk.gray;
|
|
228
|
-
console.log(color(` ${icon}${stepNum}. ${stepDesc}`));
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
console.log('\n' + '-'.repeat(60) + '\n');
|
|
232
|
-
} catch (error) {
|
|
233
|
-
console.error(chalk.red(`\nWorkflow guidance failed: ${error.message}`));
|
|
234
|
-
console.error(chalk.gray(error.stack));
|
|
235
|
-
process.exit(1);
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
module.exports = {
|
|
240
|
-
workflowCommand,
|
|
241
|
-
generateWorkflowGuidance,
|
|
242
|
-
WORKFLOW_TEMPLATES,
|
|
243
|
-
};
|
|
@@ -1,386 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview CAWS Worktree CLI Command
|
|
3
|
-
* Manages git worktrees for agent scope isolation
|
|
4
|
-
* @author @darianrosebrook
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const chalk = require('chalk');
|
|
8
|
-
const {
|
|
9
|
-
createWorktree,
|
|
10
|
-
listWorktrees,
|
|
11
|
-
destroyWorktree,
|
|
12
|
-
mergeWorktree,
|
|
13
|
-
pruneWorktrees,
|
|
14
|
-
repairWorktrees,
|
|
15
|
-
loadRegistry,
|
|
16
|
-
saveRegistry,
|
|
17
|
-
getRepoRoot,
|
|
18
|
-
findFeatureSpecPath,
|
|
19
|
-
} = require('../worktree/worktree-manager');
|
|
20
|
-
const { getAgentSessionId } = require('../utils/agent-session');
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Handle worktree subcommands
|
|
24
|
-
* @param {string} subcommand - Subcommand name
|
|
25
|
-
* @param {Object} options - Command options
|
|
26
|
-
*/
|
|
27
|
-
async function worktreeCommand(subcommand, options = {}) {
|
|
28
|
-
try {
|
|
29
|
-
switch (subcommand) {
|
|
30
|
-
case 'create':
|
|
31
|
-
return handleCreate(options);
|
|
32
|
-
case 'list':
|
|
33
|
-
return handleList();
|
|
34
|
-
case 'destroy':
|
|
35
|
-
return handleDestroy(options);
|
|
36
|
-
case 'merge':
|
|
37
|
-
return handleMerge(options);
|
|
38
|
-
case 'prune':
|
|
39
|
-
return handlePrune(options);
|
|
40
|
-
case 'repair':
|
|
41
|
-
return handleRepair(options);
|
|
42
|
-
case 'bind':
|
|
43
|
-
return handleBind(options);
|
|
44
|
-
default:
|
|
45
|
-
console.error(chalk.red(`Unknown worktree subcommand: ${subcommand}`));
|
|
46
|
-
console.log(chalk.blue('Available: create, list, destroy, merge, prune, repair, bind'));
|
|
47
|
-
process.exit(1);
|
|
48
|
-
}
|
|
49
|
-
} catch (error) {
|
|
50
|
-
console.error(chalk.red(`${error.message}`));
|
|
51
|
-
process.exit(1);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function handleCreate(options) {
|
|
56
|
-
const { name, scope, baseBranch, specId } = options;
|
|
57
|
-
|
|
58
|
-
if (!name) {
|
|
59
|
-
console.error(chalk.red('Worktree name is required'));
|
|
60
|
-
console.log(chalk.blue('Usage: caws worktree create <name> [--scope "src/auth/**"]'));
|
|
61
|
-
process.exit(1);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
console.log(chalk.cyan(`Creating worktree: ${name}`));
|
|
65
|
-
|
|
66
|
-
const entry = createWorktree(name, { scope, baseBranch, specId });
|
|
67
|
-
|
|
68
|
-
console.log(chalk.green(`Worktree created`));
|
|
69
|
-
console.log(chalk.gray(` Path: ${entry.path}`));
|
|
70
|
-
console.log(chalk.gray(` Branch: ${entry.branch}`));
|
|
71
|
-
if (entry.scope) console.log(chalk.gray(` Scope: ${entry.scope}`));
|
|
72
|
-
if (entry.specId) console.log(chalk.gray(` Spec: ${entry.specId}`));
|
|
73
|
-
console.log(chalk.blue(`\ncd ${entry.path} to start working in the isolated worktree`));
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function handleList() {
|
|
77
|
-
const entries = listWorktrees();
|
|
78
|
-
|
|
79
|
-
if (entries.length === 0) {
|
|
80
|
-
console.log(chalk.gray('No worktrees registered.'));
|
|
81
|
-
console.log(chalk.blue('Create one with: caws worktree create <name>'));
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const maxNameLen = Math.max(18, ...entries.map((e) => e.name.length + 2));
|
|
86
|
-
const maxBranchLen = Math.max(20, ...entries.map((e) => (e.branch || '').length + 2));
|
|
87
|
-
const totalWidth = maxNameLen + 14 + maxBranchLen + 16 + 16;
|
|
88
|
-
console.log(chalk.bold.cyan('CAWS Worktrees'));
|
|
89
|
-
console.log(chalk.cyan('='.repeat(totalWidth)));
|
|
90
|
-
console.log(
|
|
91
|
-
chalk.bold(
|
|
92
|
-
'Name'.padEnd(maxNameLen) +
|
|
93
|
-
'Status'.padEnd(14) +
|
|
94
|
-
'Branch'.padEnd(maxBranchLen) +
|
|
95
|
-
'Last Commit'.padEnd(16) +
|
|
96
|
-
'Session'
|
|
97
|
-
)
|
|
98
|
-
);
|
|
99
|
-
console.log(chalk.gray('-'.repeat(totalWidth)));
|
|
100
|
-
|
|
101
|
-
// Show current session for comparison
|
|
102
|
-
const currentSession = getAgentSessionId(process.cwd());
|
|
103
|
-
if (currentSession) {
|
|
104
|
-
const shortCurrent = currentSession.length > 8 ? '...' + currentSession.slice(-8) : currentSession;
|
|
105
|
-
console.log(chalk.gray(`You: ${shortCurrent}`));
|
|
106
|
-
console.log(chalk.gray('-'.repeat(totalWidth)));
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
for (const entry of entries) {
|
|
110
|
-
const statusColors = {
|
|
111
|
-
active: chalk.green,
|
|
112
|
-
fresh: chalk.cyan,
|
|
113
|
-
merged: chalk.blue,
|
|
114
|
-
destroyed: chalk.gray,
|
|
115
|
-
missing: chalk.red,
|
|
116
|
-
'stale-merged': chalk.yellow,
|
|
117
|
-
orphaned: chalk.yellow,
|
|
118
|
-
unregistered: chalk.yellow,
|
|
119
|
-
};
|
|
120
|
-
const statusColor = statusColors[entry.status] || chalk.white;
|
|
121
|
-
|
|
122
|
-
// Build status string with dirty indicator
|
|
123
|
-
let statusStr = entry.status;
|
|
124
|
-
if (entry.dirty && (entry.status === 'active' || entry.status === 'fresh')) {
|
|
125
|
-
statusStr += '*';
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// Format last commit age
|
|
129
|
-
let commitAge = chalk.gray('-');
|
|
130
|
-
if (entry.lastCommit) {
|
|
131
|
-
commitAge = chalk.white(entry.lastCommit.age);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// Format owner — show truncated session ID, highlight if it's the current session
|
|
135
|
-
let ownerStr = chalk.gray('-');
|
|
136
|
-
if (entry.owner) {
|
|
137
|
-
const short = entry.owner.length > 8 ? '...' + entry.owner.slice(-8) : entry.owner;
|
|
138
|
-
if (currentSession && entry.owner === currentSession) {
|
|
139
|
-
ownerStr = chalk.green(short + ' (you)');
|
|
140
|
-
} else {
|
|
141
|
-
ownerStr = chalk.yellow(short);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
console.log(
|
|
146
|
-
entry.name.padEnd(maxNameLen) +
|
|
147
|
-
statusColor(statusStr.padEnd(14)) +
|
|
148
|
-
(entry.branch || '').padEnd(maxBranchLen) +
|
|
149
|
-
commitAge.padEnd(16 + 10) + // +10 for chalk color codes
|
|
150
|
-
ownerStr
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// Legend
|
|
155
|
-
console.log('');
|
|
156
|
-
console.log(chalk.gray('Status: fresh = no commits yet, active = has commits/changes, active* = dirty files'));
|
|
157
|
-
console.log('');
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
function handleDestroy(options) {
|
|
161
|
-
const { name, deleteBranch, force } = options;
|
|
162
|
-
|
|
163
|
-
if (!name) {
|
|
164
|
-
console.error(chalk.red('Worktree name is required'));
|
|
165
|
-
console.log(chalk.blue('Usage: caws worktree destroy <name> [--delete-branch] [--force]'));
|
|
166
|
-
process.exit(1);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
console.log(chalk.cyan(`Destroying worktree: ${name}`));
|
|
170
|
-
destroyWorktree(name, { deleteBranch, force });
|
|
171
|
-
console.log(chalk.green(`Worktree '${name}' destroyed`));
|
|
172
|
-
if (deleteBranch) {
|
|
173
|
-
console.log(chalk.gray(' Branch also deleted'));
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
function handleMerge(options) {
|
|
178
|
-
const { name, dryRun, deleteBranch = true, message } = options;
|
|
179
|
-
|
|
180
|
-
if (!name) {
|
|
181
|
-
console.error(chalk.red('Worktree name is required'));
|
|
182
|
-
console.log(
|
|
183
|
-
chalk.blue(
|
|
184
|
-
'Usage: caws worktree merge <name> [--dry-run] [--message "..."] [--no-delete-branch]'
|
|
185
|
-
)
|
|
186
|
-
);
|
|
187
|
-
process.exit(1);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
if (dryRun) {
|
|
191
|
-
console.log(chalk.cyan(`Dry-run merge preview for: ${name}`));
|
|
192
|
-
} else {
|
|
193
|
-
console.log(chalk.cyan(`Merging worktree: ${name}`));
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
const result = mergeWorktree(name, { dryRun, deleteBranch, message });
|
|
197
|
-
|
|
198
|
-
if (dryRun) {
|
|
199
|
-
if (result.conflicts.length > 0) {
|
|
200
|
-
console.log(chalk.yellow(`\nConflicts detected (${result.conflicts.length}):`));
|
|
201
|
-
for (const conflict of result.conflicts) {
|
|
202
|
-
console.log(chalk.yellow(` ${conflict}`));
|
|
203
|
-
}
|
|
204
|
-
console.log(
|
|
205
|
-
chalk.blue('\nResolve conflicts in the worktree before merging, or merge manually.')
|
|
206
|
-
);
|
|
207
|
-
} else {
|
|
208
|
-
console.log(chalk.green(`\nNo conflicts detected. Safe to merge.`));
|
|
209
|
-
console.log(chalk.blue(`Run without --dry-run to merge: caws worktree merge ${name}`));
|
|
210
|
-
}
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
if (result.merged) {
|
|
215
|
-
console.log(chalk.green(`Worktree '${name}' merged to ${result.baseBranch}`));
|
|
216
|
-
if (deleteBranch) {
|
|
217
|
-
console.log(chalk.gray(` Branch ${result.branch} deleted`));
|
|
218
|
-
}
|
|
219
|
-
} else {
|
|
220
|
-
console.log(chalk.red(`Merge failed for '${name}'`));
|
|
221
|
-
for (const conflict of result.conflicts) {
|
|
222
|
-
console.log(chalk.yellow(` ${conflict}`));
|
|
223
|
-
}
|
|
224
|
-
console.log(chalk.blue('\nThe worktree has been destroyed but the merge has conflicts.'));
|
|
225
|
-
console.log(chalk.blue('Resolve conflicts and commit manually:'));
|
|
226
|
-
console.log(chalk.gray(` git merge --no-ff ${result.branch}`));
|
|
227
|
-
console.log(chalk.gray(` # resolve conflicts`));
|
|
228
|
-
console.log(chalk.gray(` git commit -m "merge(worktree): ${name}"`));
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
function handlePrune(options) {
|
|
233
|
-
const maxAge = options.maxAge !== undefined ? parseInt(options.maxAge, 10) : 30;
|
|
234
|
-
const force = options.force || false;
|
|
235
|
-
|
|
236
|
-
console.log(chalk.cyan(`Pruning worktrees (max age: ${maxAge} days)`));
|
|
237
|
-
const result = pruneWorktrees({ maxAgeDays: maxAge, force });
|
|
238
|
-
|
|
239
|
-
// Handle both old return format (array) and new format (object with pruned/skipped)
|
|
240
|
-
const pruned = Array.isArray(result) ? result : result.pruned;
|
|
241
|
-
const skipped = Array.isArray(result) ? [] : result.skipped || [];
|
|
242
|
-
|
|
243
|
-
if (pruned.length === 0 && skipped.length === 0) {
|
|
244
|
-
console.log(chalk.gray('Nothing to prune.'));
|
|
245
|
-
} else {
|
|
246
|
-
if (pruned.length > 0) {
|
|
247
|
-
console.log(chalk.green(`Pruned ${pruned.length} worktree(s):`));
|
|
248
|
-
for (const entry of pruned) {
|
|
249
|
-
console.log(chalk.gray(` - ${entry.name} (created ${entry.createdAt})`));
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
if (skipped.length > 0) {
|
|
253
|
-
console.log(chalk.yellow(`\nSkipped ${skipped.length} worktree(s) with recent activity:`));
|
|
254
|
-
for (const { name: skName, reason } of skipped) {
|
|
255
|
-
console.log(chalk.yellow(` - ${skName}: ${reason}`));
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
function handleRepair(options) {
|
|
263
|
-
const dryRun = options.dryRun || false;
|
|
264
|
-
const shouldPrune = options.prune || false;
|
|
265
|
-
const force = options.force || false;
|
|
266
|
-
|
|
267
|
-
if (dryRun) {
|
|
268
|
-
console.log(chalk.cyan('Repair dry-run (no changes will be persisted)'));
|
|
269
|
-
} else {
|
|
270
|
-
console.log(chalk.cyan('Repairing worktree registry'));
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
const result = repairWorktrees({ prune: shouldPrune, dryRun, force });
|
|
274
|
-
|
|
275
|
-
if (result.repaired.length === 0 && result.pruned.length === 0 && result.skipped.length === 0) {
|
|
276
|
-
console.log(chalk.green('Registry is consistent. Nothing to repair.'));
|
|
277
|
-
return;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
if (result.repaired.length > 0) {
|
|
281
|
-
console.log(chalk.green('\nRepaired ' + result.repaired.length + ' entry/entries:'));
|
|
282
|
-
for (const r of result.repaired) {
|
|
283
|
-
const ownerTag = r.owner ? chalk.yellow(` [owner: ${r.owner}]`) : '';
|
|
284
|
-
if (r.action === 'registered') {
|
|
285
|
-
console.log(chalk.gray(' + ' + r.name + ' (auto-registered from git)'));
|
|
286
|
-
} else {
|
|
287
|
-
console.log(chalk.gray(' ~ ' + r.name + ' (' + r.from + ' -> ' + r.to + ')') + ownerTag);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
if (result.pruned.length > 0) {
|
|
293
|
-
console.log(chalk.green('\nPruned ' + result.pruned.length + ' stale entry/entries:'));
|
|
294
|
-
for (const p of result.pruned) {
|
|
295
|
-
const ownerTag = p.owner ? chalk.yellow(` [owner: ${p.owner}]`) : '';
|
|
296
|
-
console.log(chalk.gray(' - ' + p.name + ' (' + p.status + ')') + ownerTag);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
if (result.skipped.length > 0) {
|
|
301
|
-
console.log(chalk.yellow('\nSkipped ' + result.skipped.length + ' entry/entries:'));
|
|
302
|
-
for (const s of result.skipped) {
|
|
303
|
-
console.log(chalk.yellow(' ? ' + s.name + ': ' + s.reason));
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
if (dryRun) {
|
|
308
|
-
console.log(chalk.blue('\nDry-run complete. Run without --dry-run to persist changes.'));
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
function handleBind(options) {
|
|
313
|
-
const path = require('path');
|
|
314
|
-
const fs = require('fs-extra');
|
|
315
|
-
const yaml = require('js-yaml');
|
|
316
|
-
const { specId, name } = options;
|
|
317
|
-
|
|
318
|
-
if (!specId) {
|
|
319
|
-
console.error(chalk.red('Spec ID is required'));
|
|
320
|
-
console.log(chalk.blue('Usage: caws worktree bind <spec-id> [--name <worktree-name>]'));
|
|
321
|
-
process.exit(1);
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
// Determine worktree name: from option, or detect from cwd
|
|
325
|
-
let worktreeName = name;
|
|
326
|
-
if (!worktreeName) {
|
|
327
|
-
const root = getRepoRoot();
|
|
328
|
-
const cwd = process.cwd();
|
|
329
|
-
const worktreesBase = path.join(root, '.caws', 'worktrees');
|
|
330
|
-
|
|
331
|
-
if (cwd.startsWith(worktreesBase + path.sep)) {
|
|
332
|
-
const relative = path.relative(worktreesBase, cwd);
|
|
333
|
-
worktreeName = relative.split(path.sep)[0];
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
if (!worktreeName) {
|
|
338
|
-
console.error(chalk.red('Could not determine worktree name.'));
|
|
339
|
-
console.log(chalk.blue('Either run this from inside a worktree, or pass --name <worktree-name>'));
|
|
340
|
-
process.exit(1);
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
const root = getRepoRoot();
|
|
344
|
-
const registry = loadRegistry(root);
|
|
345
|
-
|
|
346
|
-
// Find the worktree entry in the registry
|
|
347
|
-
if (!registry.worktrees || !registry.worktrees[worktreeName]) {
|
|
348
|
-
console.error(chalk.red(`Worktree '${worktreeName}' not found in registry.`));
|
|
349
|
-
console.log(chalk.blue('Run: caws worktree list to see available worktrees'));
|
|
350
|
-
process.exit(1);
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
// Load the spec file
|
|
354
|
-
const specPath = findFeatureSpecPath(root, specId);
|
|
355
|
-
if (!specPath) {
|
|
356
|
-
console.error(chalk.red(`Spec '${specId}' not found in .caws/specs/`));
|
|
357
|
-
console.log(chalk.blue('Run: caws specs list to see available specs'));
|
|
358
|
-
process.exit(1);
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
const specContent = fs.readFileSync(specPath, 'utf8');
|
|
362
|
-
const specData = yaml.load(specContent);
|
|
363
|
-
|
|
364
|
-
// Warn if spec already bound to a different worktree
|
|
365
|
-
if (specData.worktree && specData.worktree !== worktreeName) {
|
|
366
|
-
console.log(chalk.yellow(`Warning: Spec '${specId}' is currently bound to worktree '${specData.worktree}'.`));
|
|
367
|
-
console.log(chalk.yellow(`Rebinding to '${worktreeName}'.`));
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
// Update registry side: set specId on the worktree entry
|
|
371
|
-
registry.worktrees[worktreeName].specId = specId;
|
|
372
|
-
saveRegistry(root, registry);
|
|
373
|
-
|
|
374
|
-
// Update spec side: set worktree field
|
|
375
|
-
specData.worktree = worktreeName;
|
|
376
|
-
const updatedYaml = yaml.dump(specData, { lineWidth: 120, noRefs: true });
|
|
377
|
-
fs.writeFileSync(specPath, updatedYaml, 'utf8');
|
|
378
|
-
|
|
379
|
-
console.log(chalk.green(`Binding established`));
|
|
380
|
-
console.log(chalk.gray(` Worktree: ${worktreeName} -> spec: ${specId}`));
|
|
381
|
-
console.log(chalk.gray(` Spec: ${specId} -> worktree: ${worktreeName}`));
|
|
382
|
-
console.log(chalk.gray(` Registry: ${path.join(root, '.caws', 'worktrees.json')}`));
|
|
383
|
-
console.log(chalk.gray(` Spec file: ${specPath}`));
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
module.exports = { worktreeCommand };
|