@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
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// `caws init` — store-side bootstrap of the canonical vNext .caws/ shape.
|
|
3
|
+
//
|
|
4
|
+
// What this adapter creates (when absent):
|
|
5
|
+
//
|
|
6
|
+
// .caws/
|
|
7
|
+
// .caws/specs/ empty dir, multi-spec lives here
|
|
8
|
+
// .caws/waivers/ empty dir, slice-7a authority surface
|
|
9
|
+
// .caws/policy.yaml kernel-validated default policy
|
|
10
|
+
// .caws/worktrees.json {}
|
|
11
|
+
// .caws/agents.json {}
|
|
12
|
+
//
|
|
13
|
+
// What this adapter intentionally does NOT create:
|
|
14
|
+
//
|
|
15
|
+
// .caws/working-spec.yaml legacy single-spec entry point — the
|
|
16
|
+
// vNext model is multi-spec under
|
|
17
|
+
// .caws/specs/<id>.yaml. Seeding
|
|
18
|
+
// working-spec.yaml would silently
|
|
19
|
+
// reintroduce the legacy authority.
|
|
20
|
+
// .caws/working-spec.schema.json same reason.
|
|
21
|
+
// .caws/events.jsonl evidence is append-only and
|
|
22
|
+
// created by the first event under
|
|
23
|
+
// lock. Manufacturing an empty file
|
|
24
|
+
// would either be a zero-event chain
|
|
25
|
+
// (no genesis) or require a synthetic
|
|
26
|
+
// init event that doesn't represent
|
|
27
|
+
// any real state transition. The
|
|
28
|
+
// store treats a missing file as
|
|
29
|
+
// `events: []`, so doctor / status /
|
|
30
|
+
// waiver list all work without it.
|
|
31
|
+
//
|
|
32
|
+
// Idempotence and refusal:
|
|
33
|
+
// - missing .caws → create canonical state.
|
|
34
|
+
// - all canonical files exist → no-op, return AlreadyInitialized.
|
|
35
|
+
// - any LEGACY residue → refuse with INIT_LEGACY_RESIDUE
|
|
36
|
+
// naming each offending path. Do NOT
|
|
37
|
+
// touch anything. Repair belongs to a
|
|
38
|
+
// later doctor/repair surface.
|
|
39
|
+
//
|
|
40
|
+
// Authority discipline:
|
|
41
|
+
// - The seeded policy MUST pass `parseAndValidatePolicy` before
|
|
42
|
+
// hitting disk. If it doesn't, init refuses (this is a programmer
|
|
43
|
+
// error in our default, not a user-recoverable condition).
|
|
44
|
+
// - All writes go through `writeFileAtomic`. Concurrent invocations
|
|
45
|
+
// either both see "already initialized" or one wins and the other
|
|
46
|
+
// observes the same canonical state.
|
|
47
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
48
|
+
if (k2 === undefined) k2 = k;
|
|
49
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
50
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
51
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
52
|
+
}
|
|
53
|
+
Object.defineProperty(o, k2, desc);
|
|
54
|
+
}) : (function(o, m, k, k2) {
|
|
55
|
+
if (k2 === undefined) k2 = k;
|
|
56
|
+
o[k2] = m[k];
|
|
57
|
+
}));
|
|
58
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
59
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
60
|
+
}) : function(o, v) {
|
|
61
|
+
o["default"] = v;
|
|
62
|
+
});
|
|
63
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
64
|
+
var ownKeys = function(o) {
|
|
65
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
66
|
+
var ar = [];
|
|
67
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
68
|
+
return ar;
|
|
69
|
+
};
|
|
70
|
+
return ownKeys(o);
|
|
71
|
+
};
|
|
72
|
+
return function (mod) {
|
|
73
|
+
if (mod && mod.__esModule) return mod;
|
|
74
|
+
var result = {};
|
|
75
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
76
|
+
__setModuleDefault(result, mod);
|
|
77
|
+
return result;
|
|
78
|
+
};
|
|
79
|
+
})();
|
|
80
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
81
|
+
exports.DEFAULT_POLICY_YAML = void 0;
|
|
82
|
+
exports.initProject = initProject;
|
|
83
|
+
const fs = __importStar(require("fs"));
|
|
84
|
+
const path = __importStar(require("path"));
|
|
85
|
+
const caws_kernel_1 = require("@paths.design/caws-kernel");
|
|
86
|
+
const caws_kernel_2 = require("@paths.design/caws-kernel");
|
|
87
|
+
const atomic_write_1 = require("./atomic-write");
|
|
88
|
+
const repo_root_1 = require("./repo-root");
|
|
89
|
+
const rules_1 = require("./rules");
|
|
90
|
+
// ---------------------------------------------------------------------------
|
|
91
|
+
// Canonical layout
|
|
92
|
+
// ---------------------------------------------------------------------------
|
|
93
|
+
/** Canonical files/dirs init creates (or expects to be present already). */
|
|
94
|
+
const CANONICAL_PATHS = {
|
|
95
|
+
cawsDir: '.caws',
|
|
96
|
+
specsDir: '.caws/specs',
|
|
97
|
+
waiversDir: '.caws/waivers',
|
|
98
|
+
policyFile: '.caws/policy.yaml',
|
|
99
|
+
worktreesFile: '.caws/worktrees.json',
|
|
100
|
+
agentsFile: '.caws/agents.json',
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Files whose presence inside `.caws/` indicates legacy single-spec /
|
|
104
|
+
* pre-vNext state. init refuses to touch these — repair belongs to a
|
|
105
|
+
* later doctor/repair surface. Adding more entries here is the
|
|
106
|
+
* sanctioned way to extend the legacy-residue check.
|
|
107
|
+
*/
|
|
108
|
+
const LEGACY_PATHS = [
|
|
109
|
+
'.caws/working-spec.yaml',
|
|
110
|
+
'.caws/working-spec.schema.json',
|
|
111
|
+
];
|
|
112
|
+
// ---------------------------------------------------------------------------
|
|
113
|
+
// Default policy
|
|
114
|
+
//
|
|
115
|
+
// The seed below mirrors the gate set the vNext gates command knows
|
|
116
|
+
// about. Block-mode for the structural gates (budget_limit,
|
|
117
|
+
// spec_completeness, scope_boundary), warn for the heuristic gates
|
|
118
|
+
// (god_object, todo_detection). edit_rules is set to the conservative
|
|
119
|
+
// "policy and code may live in the same PR" default; teams can tighten.
|
|
120
|
+
// ---------------------------------------------------------------------------
|
|
121
|
+
exports.DEFAULT_POLICY_YAML = `version: 1
|
|
122
|
+
risk_tiers:
|
|
123
|
+
'1':
|
|
124
|
+
max_files: 5
|
|
125
|
+
max_loc: 200
|
|
126
|
+
'2':
|
|
127
|
+
max_files: 15
|
|
128
|
+
max_loc: 600
|
|
129
|
+
'3':
|
|
130
|
+
max_files: 30
|
|
131
|
+
max_loc: 1500
|
|
132
|
+
gates:
|
|
133
|
+
budget_limit:
|
|
134
|
+
enabled: true
|
|
135
|
+
mode: block
|
|
136
|
+
spec_completeness:
|
|
137
|
+
enabled: true
|
|
138
|
+
mode: block
|
|
139
|
+
scope_boundary:
|
|
140
|
+
enabled: true
|
|
141
|
+
mode: block
|
|
142
|
+
god_object:
|
|
143
|
+
enabled: true
|
|
144
|
+
mode: warn
|
|
145
|
+
todo_detection:
|
|
146
|
+
enabled: true
|
|
147
|
+
mode: warn
|
|
148
|
+
edit_rules:
|
|
149
|
+
policy_and_code_same_pr: true
|
|
150
|
+
require_signed_commits: false
|
|
151
|
+
require_dual_control_for_governance: false
|
|
152
|
+
`;
|
|
153
|
+
// ---------------------------------------------------------------------------
|
|
154
|
+
// Implementation
|
|
155
|
+
// ---------------------------------------------------------------------------
|
|
156
|
+
function abs(repoRoot, rel) {
|
|
157
|
+
return path.join(repoRoot, rel);
|
|
158
|
+
}
|
|
159
|
+
function existsCanonical(repoRoot) {
|
|
160
|
+
const isFile = (p) => fs.existsSync(p) && fs.statSync(p).isFile();
|
|
161
|
+
const isDir = (p) => fs.existsSync(p) && fs.statSync(p).isDirectory();
|
|
162
|
+
return {
|
|
163
|
+
cawsDir: isDir(abs(repoRoot, CANONICAL_PATHS.cawsDir)),
|
|
164
|
+
specsDir: isDir(abs(repoRoot, CANONICAL_PATHS.specsDir)),
|
|
165
|
+
waiversDir: isDir(abs(repoRoot, CANONICAL_PATHS.waiversDir)),
|
|
166
|
+
policyFile: isFile(abs(repoRoot, CANONICAL_PATHS.policyFile)),
|
|
167
|
+
worktreesFile: isFile(abs(repoRoot, CANONICAL_PATHS.worktreesFile)),
|
|
168
|
+
agentsFile: isFile(abs(repoRoot, CANONICAL_PATHS.agentsFile)),
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
function findLegacyResidue(repoRoot) {
|
|
172
|
+
// Use isFile semantics — must match observeInitResidue in
|
|
173
|
+
// doctor-snapshot.ts. A *file* at one of the legacy paths is
|
|
174
|
+
// residue; a *directory* at the same path is a different problem
|
|
175
|
+
// (not yet a separately-modeled rule) and must not be conflated
|
|
176
|
+
// with file-residue. Otherwise init refuses while doctor stays
|
|
177
|
+
// silent on the same project state.
|
|
178
|
+
const found = [];
|
|
179
|
+
for (const rel of LEGACY_PATHS) {
|
|
180
|
+
const p = abs(repoRoot, rel);
|
|
181
|
+
try {
|
|
182
|
+
if (fs.statSync(p).isFile())
|
|
183
|
+
found.push(p);
|
|
184
|
+
}
|
|
185
|
+
catch {
|
|
186
|
+
// ENOENT or similar — not residue.
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return found;
|
|
190
|
+
}
|
|
191
|
+
function legacyDiag(found) {
|
|
192
|
+
return (0, repo_root_1.storeDiagnostic)(rules_1.STORE_RULES.INIT_LEGACY_RESIDUE, `caws init refuses to overwrite legacy state: ${found.join(', ')}.`, {
|
|
193
|
+
narrowRepair: 'Move or remove the listed files manually, then re-run `caws init`. Repair tooling belongs to a later doctor/repair surface; init is intentionally non-destructive.',
|
|
194
|
+
data: { legacy_paths: found.slice() },
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
function mkdirRecursive(target) {
|
|
198
|
+
try {
|
|
199
|
+
fs.mkdirSync(target, { recursive: true });
|
|
200
|
+
return (0, caws_kernel_2.ok)(true);
|
|
201
|
+
}
|
|
202
|
+
catch (e) {
|
|
203
|
+
return (0, caws_kernel_2.err)((0, repo_root_1.storeDiagnostic)(rules_1.STORE_RULES.WRITE_IO_FAILED, `Failed to create ${target}: ${e.message}.`, { subject: target }));
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Idempotent vNext init. Returns:
|
|
208
|
+
*
|
|
209
|
+
* Ok({ outcome: 'created', created: [...], policy })
|
|
210
|
+
* Ok({ outcome: 'already_initialized', created: [], policy })
|
|
211
|
+
* Err on legacy residue (INIT_LEGACY_RESIDUE) or write failure
|
|
212
|
+
* (WRITE_IO_FAILED) or a default-policy that fails kernel
|
|
213
|
+
* validation (INIT_DEFAULT_POLICY_INVALID).
|
|
214
|
+
*/
|
|
215
|
+
function initProject(repoRoot) {
|
|
216
|
+
if (typeof repoRoot !== 'string' || repoRoot.length === 0) {
|
|
217
|
+
throw new TypeError('initProject: repoRoot must be a non-empty string.');
|
|
218
|
+
}
|
|
219
|
+
// 1. Refuse if any legacy residue exists. Do this BEFORE any write so
|
|
220
|
+
// the caller's repo is not mutated when we say "no".
|
|
221
|
+
const residue = findLegacyResidue(repoRoot);
|
|
222
|
+
if (residue.length > 0) {
|
|
223
|
+
return (0, caws_kernel_2.err)(legacyDiag(residue));
|
|
224
|
+
}
|
|
225
|
+
// 2. Validate the default policy through the kernel. If our seed is
|
|
226
|
+
// bad, surface that as INIT_DEFAULT_POLICY_INVALID — do NOT write
|
|
227
|
+
// a known-invalid policy to disk just to keep init succeeding.
|
|
228
|
+
const validatedPolicy = (0, caws_kernel_1.parseAndValidatePolicy)(exports.DEFAULT_POLICY_YAML);
|
|
229
|
+
if (!(0, caws_kernel_1.isOk)(validatedPolicy)) {
|
|
230
|
+
return (0, caws_kernel_2.err)((0, repo_root_1.storeDiagnostic)(rules_1.STORE_RULES.INIT_DEFAULT_POLICY_INVALID, `Default policy failed kernel validation: ${validatedPolicy.errors.map((d) => d.rule).join(', ')}.`, { data: { kernel_diagnostics: validatedPolicy.errors.slice() } }));
|
|
231
|
+
}
|
|
232
|
+
const policy = validatedPolicy.value;
|
|
233
|
+
// 3. Decide outcome. If every canonical file/dir is present, do nothing.
|
|
234
|
+
const present = existsCanonical(repoRoot);
|
|
235
|
+
const allPresent = present.cawsDir &&
|
|
236
|
+
present.specsDir &&
|
|
237
|
+
present.waiversDir &&
|
|
238
|
+
present.policyFile &&
|
|
239
|
+
present.worktreesFile &&
|
|
240
|
+
present.agentsFile;
|
|
241
|
+
if (allPresent) {
|
|
242
|
+
return (0, caws_kernel_2.ok)({
|
|
243
|
+
outcome: 'already_initialized',
|
|
244
|
+
created: [],
|
|
245
|
+
policy,
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
// 4. Create the missing pieces. We track what we actually wrote so the
|
|
249
|
+
// shell can report "what changed" precisely. Each step is its own
|
|
250
|
+
// Ok-or-Err — we abort on the first error rather than continue and
|
|
251
|
+
// partially populate.
|
|
252
|
+
const created = [];
|
|
253
|
+
if (!present.cawsDir) {
|
|
254
|
+
const r = mkdirRecursive(abs(repoRoot, CANONICAL_PATHS.cawsDir));
|
|
255
|
+
if (!(0, caws_kernel_1.isOk)(r))
|
|
256
|
+
return r;
|
|
257
|
+
created.push(abs(repoRoot, CANONICAL_PATHS.cawsDir));
|
|
258
|
+
}
|
|
259
|
+
if (!present.specsDir) {
|
|
260
|
+
const r = mkdirRecursive(abs(repoRoot, CANONICAL_PATHS.specsDir));
|
|
261
|
+
if (!(0, caws_kernel_1.isOk)(r))
|
|
262
|
+
return r;
|
|
263
|
+
created.push(abs(repoRoot, CANONICAL_PATHS.specsDir));
|
|
264
|
+
}
|
|
265
|
+
if (!present.waiversDir) {
|
|
266
|
+
const r = mkdirRecursive(abs(repoRoot, CANONICAL_PATHS.waiversDir));
|
|
267
|
+
if (!(0, caws_kernel_1.isOk)(r))
|
|
268
|
+
return r;
|
|
269
|
+
created.push(abs(repoRoot, CANONICAL_PATHS.waiversDir));
|
|
270
|
+
}
|
|
271
|
+
if (!present.policyFile) {
|
|
272
|
+
const r = (0, atomic_write_1.writeFileAtomic)(abs(repoRoot, CANONICAL_PATHS.policyFile), exports.DEFAULT_POLICY_YAML);
|
|
273
|
+
if (!(0, caws_kernel_1.isOk)(r))
|
|
274
|
+
return r;
|
|
275
|
+
created.push(abs(repoRoot, CANONICAL_PATHS.policyFile));
|
|
276
|
+
}
|
|
277
|
+
if (!present.worktreesFile) {
|
|
278
|
+
const r = (0, atomic_write_1.writeFileAtomic)(abs(repoRoot, CANONICAL_PATHS.worktreesFile), '{}\n');
|
|
279
|
+
if (!(0, caws_kernel_1.isOk)(r))
|
|
280
|
+
return r;
|
|
281
|
+
created.push(abs(repoRoot, CANONICAL_PATHS.worktreesFile));
|
|
282
|
+
}
|
|
283
|
+
if (!present.agentsFile) {
|
|
284
|
+
const r = (0, atomic_write_1.writeFileAtomic)(abs(repoRoot, CANONICAL_PATHS.agentsFile), '{}\n');
|
|
285
|
+
if (!(0, caws_kernel_1.isOk)(r))
|
|
286
|
+
return r;
|
|
287
|
+
created.push(abs(repoRoot, CANONICAL_PATHS.agentsFile));
|
|
288
|
+
}
|
|
289
|
+
return (0, caws_kernel_2.ok)({
|
|
290
|
+
outcome: 'created',
|
|
291
|
+
created,
|
|
292
|
+
policy,
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
//# sourceMappingURL=init-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-store.js","sourceRoot":"","sources":["../../src/store/init-store.ts"],"names":[],"mappings":";AAAA,0EAA0E;AAC1E,EAAE;AACF,2CAA2C;AAC3C,EAAE;AACF,WAAW;AACX,mEAAmE;AACnE,wEAAwE;AACxE,kEAAkE;AAClE,qCAAqC;AACrC,qCAAqC;AACrC,EAAE;AACF,mDAAmD;AACnD,EAAE;AACF,uEAAuE;AACvE,kEAAkE;AAClE,iEAAiE;AACjE,mEAAmE;AACnE,oEAAoE;AACpE,iDAAiD;AACjD,8DAA8D;AAC9D,mEAAmE;AACnE,oEAAoE;AACpE,qEAAqE;AACrE,sEAAsE;AACtE,oEAAoE;AACpE,iEAAiE;AACjE,iEAAiE;AACjE,qEAAqE;AACrE,mEAAmE;AACnE,EAAE;AACF,2BAA2B;AAC3B,yDAAyD;AACzD,oEAAoE;AACpE,iEAAiE;AACjE,oEAAoE;AACpE,qEAAqE;AACrE,8DAA8D;AAC9D,EAAE;AACF,wBAAwB;AACxB,kEAAkE;AAClE,sEAAsE;AACtE,+DAA+D;AAC/D,sEAAsE;AACtE,sEAAsE;AACtE,yCAAyC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuLzC,kCAiGC;AAtRD,uCAAyB;AACzB,2CAA6B;AAE7B,2DAMmC;AACnC,2DAAoD;AAEpD,iDAAiD;AACjD,2CAA8C;AAC9C,mCAAsC;AAEtC,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E,4EAA4E;AAC5E,MAAM,eAAe,GAAG;IACtB,OAAO,EAAE,OAAO;IAChB,QAAQ,EAAE,aAAa;IACvB,UAAU,EAAE,eAAe;IAC3B,UAAU,EAAE,mBAAmB;IAC/B,aAAa,EAAE,sBAAsB;IACrC,UAAU,EAAE,mBAAmB;CACvB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,"file":"json-store.d.ts","sourceRoot":"","sources":["../../src/store/json-store.ts"],"names":[],"mappings":"AAIA,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAIjE,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,CAkC9D"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// JSON read helper. Same shape and discipline as yaml-store: report
|
|
3
|
+
// missing/malformed via discrete rule ids.
|
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
16
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
17
|
+
}) : function(o, v) {
|
|
18
|
+
o["default"] = v;
|
|
19
|
+
});
|
|
20
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
21
|
+
var ownKeys = function(o) {
|
|
22
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
23
|
+
var ar = [];
|
|
24
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
25
|
+
return ar;
|
|
26
|
+
};
|
|
27
|
+
return ownKeys(o);
|
|
28
|
+
};
|
|
29
|
+
return function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
})();
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.readJsonFile = readJsonFile;
|
|
39
|
+
const fs = __importStar(require("fs"));
|
|
40
|
+
const caws_kernel_1 = require("@paths.design/caws-kernel");
|
|
41
|
+
const repo_root_1 = require("./repo-root");
|
|
42
|
+
const rules_1 = require("./rules");
|
|
43
|
+
function readJsonFile(filePath) {
|
|
44
|
+
let raw;
|
|
45
|
+
try {
|
|
46
|
+
raw = fs.readFileSync(filePath, 'utf8');
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
const cause = e;
|
|
50
|
+
if (cause.code === 'ENOENT') {
|
|
51
|
+
return (0, caws_kernel_1.err)((0, repo_root_1.storeDiagnostic)(rules_1.STORE_RULES.READ_MISSING_FILE, `File not found: ${filePath}.`, {
|
|
52
|
+
subject: filePath,
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
return (0, caws_kernel_1.err)((0, repo_root_1.storeDiagnostic)(rules_1.STORE_RULES.READ_IO_FAILED, `Failed to read ${filePath}: ${cause.message ?? 'unknown error'}.`, { subject: filePath, data: { code: cause.code } }));
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
return (0, caws_kernel_1.ok)(JSON.parse(raw));
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
const cause = e;
|
|
62
|
+
return (0, caws_kernel_1.err)((0, repo_root_1.storeDiagnostic)(rules_1.STORE_RULES.READ_JSON_INVALID, `JSON parse failed in ${filePath}: ${cause.message ?? 'unknown error'}.`, { subject: filePath }));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=json-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
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G,EACxE,EAAE,OAAO,EAAE,QAAQ,EAAE,CACtB,CACF,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy-store.d.ts","sourceRoot":"","sources":["../../src/store/policy-store.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,gBAAgB,CAmB5D"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Policy loader.
|
|
3
|
+
//
|
|
4
|
+
// Loads `.caws/policy.yaml`, hands the source to the kernel's
|
|
5
|
+
// `parseAndValidatePolicy`, and surfaces both the parsed value and any
|
|
6
|
+
// non-fatal warnings the kernel emitted. Missing file is NOT an error
|
|
7
|
+
// at the store level — doctor decides whether to emit `POLICY_MISSING`.
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.loadPolicy = loadPolicy;
|
|
43
|
+
const path = __importStar(require("path"));
|
|
44
|
+
const caws_kernel_1 = require("@paths.design/caws-kernel");
|
|
45
|
+
const rules_1 = require("./rules");
|
|
46
|
+
const yaml_store_1 = require("./yaml-store");
|
|
47
|
+
function loadPolicy(cawsDir) {
|
|
48
|
+
const policyPath = path.join(cawsDir, 'policy.yaml');
|
|
49
|
+
const source = (0, yaml_store_1.readYamlSource)(policyPath);
|
|
50
|
+
if (!(0, caws_kernel_1.isOk)(source)) {
|
|
51
|
+
// Distinguish missing file (Ok-shaped) from malformed file (Err).
|
|
52
|
+
const missing = source.errors.some((e) => e.rule === rules_1.STORE_RULES.READ_MISSING_FILE);
|
|
53
|
+
if (missing) {
|
|
54
|
+
return { warnings: [], errors: [] };
|
|
55
|
+
}
|
|
56
|
+
return { warnings: [], errors: [...source.errors] };
|
|
57
|
+
}
|
|
58
|
+
const result = (0, caws_kernel_1.parseAndValidatePolicy)(source.value);
|
|
59
|
+
if (!(0, caws_kernel_1.isOk)(result)) {
|
|
60
|
+
return { warnings: [], errors: [...result.errors] };
|
|
61
|
+
}
|
|
62
|
+
const warnings = result.warnings ?? [];
|
|
63
|
+
return { policy: result.value, warnings: [...warnings], errors: [] };
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=policy-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy-store.js","sourceRoot":"","sources":["../../src/store/policy-store.ts"],"names":[],"mappings":";AAAA,iBAAiB;AACjB,EAAE;AACF,8DAA8D;AAC9D,uEAAuE;AACvE,sEAAsE;AACtE,wEAAwE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYxE,gCAmBC;AA7BD,2CAA6B;AAC7B,2DAImC;AACnC,mCAAsC;AACtC,6CAA8C;AAG9C,SAAgB,UAAU,CAAC,OAAe;IACxC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IACrD,MAAM,MAAM,GAAG,IAAA,2BAAc,EAAC,UAAU,CAAC,CAAC;IAC1C,IAAI,CAAC,IAAA,kBAAI,EAAC,MAAM,CAAC,EAAE,CAAC;QAClB,kEAAkE;QAClE,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,mBAAW,CAAC,iBAAiB,CAAC,CAAC;QACpF,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;QACtC,CAAC;QACD,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;IACtD,CAAC;IAED,MAAM,MAAM,GAAG,IAAA,oCAAsB,EAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACpD,IAAI,CAAC,IAAA,kBAAI,EAAC,MAAM,CAAC,EAAE,CAAC;QAClB,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;IACtD,CAAC;IAED,MAAM,QAAQ,GAA0B,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC;IAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,CAAC,GAAG,QAAQ,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;AACvE,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type Diagnostic, type Result } from '@paths.design/caws-kernel';
|
|
2
|
+
export interface RepoRoot {
|
|
3
|
+
/** Absolute path to the main repository root (parent of .git common dir). */
|
|
4
|
+
readonly repoRoot: string;
|
|
5
|
+
/** Absolute path to the .caws/ directory under the repo root. */
|
|
6
|
+
readonly cawsDir: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Pluggable git invoker. Tests stub this; production uses execFileSync.
|
|
10
|
+
*
|
|
11
|
+
* Returns the trimmed stdout on success, or throws on non-zero exit. The
|
|
12
|
+
* caller distinguishes "not a git repo" by inspecting the thrown error's
|
|
13
|
+
* stderr / status, which production execFileSync surfaces.
|
|
14
|
+
*/
|
|
15
|
+
export type GitRunner = (args: readonly string[], options: {
|
|
16
|
+
cwd: string;
|
|
17
|
+
}) => string;
|
|
18
|
+
export declare const defaultGitRunner: GitRunner;
|
|
19
|
+
export interface ResolveRepoRootOptions {
|
|
20
|
+
readonly git?: GitRunner;
|
|
21
|
+
/**
|
|
22
|
+
* If true, the .caws/ directory must already exist on disk. When false
|
|
23
|
+
* (default) the function only resolves where it WOULD be, leaving
|
|
24
|
+
* creation to a different layer (e.g., `caws init`).
|
|
25
|
+
*/
|
|
26
|
+
readonly requireCawsDir?: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Resolve the main-repo root from `cwd`, even when cwd is inside a linked
|
|
30
|
+
* worktree.
|
|
31
|
+
*
|
|
32
|
+
* Returns Err when:
|
|
33
|
+
* - cwd is not inside a git repository, OR
|
|
34
|
+
* - git invocation fails for another reason, OR
|
|
35
|
+
* - `requireCawsDir: true` and `.caws/` does not exist.
|
|
36
|
+
*
|
|
37
|
+
* Programmer errors (cwd not a string, git binary missing) throw.
|
|
38
|
+
*/
|
|
39
|
+
export declare function resolveRepoRoot(cwd: string, options?: ResolveRepoRootOptions): Result<RepoRoot>;
|
|
40
|
+
/** Construct a structured Diagnostic with the canonical store authority. */
|
|
41
|
+
export declare function storeDiagnostic(rule: string, message: string, extra?: {
|
|
42
|
+
subject?: string;
|
|
43
|
+
narrowRepair?: string;
|
|
44
|
+
data?: Record<string, unknown>;
|
|
45
|
+
}): Diagnostic;
|
|
46
|
+
//# sourceMappingURL=repo-root.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repo-root.d.ts","sourceRoot":"","sources":["../../src/store/repo-root.ts"],"names":[],"mappings":"AAoBA,OAAO,EAIL,KAAK,UAAU,EACf,KAAK,MAAM,EACZ,MAAM,2BAA2B,CAAC;AAOnC,MAAM,WAAW,QAAQ;IACvB,6EAA6E;IAC7E,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,iEAAiE;IACjE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,GAAG,CACtB,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,OAAO,EAAE;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,KACrB,MAAM,CAAC;AAEZ,eAAO,MAAM,gBAAgB,EAAE,SAO9B,CAAC;AAMF,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC;IACzB;;;;OAIG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;CACnC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,sBAA2B,GACnC,MAAM,CAAC,QAAQ,CAAC,CA6DlB;AAMD,4EAA4E;AAC5E,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,KAAK,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAO,GACtF,UAAU,CASZ"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Resolve the canonical CAWS repo root.
|
|
3
|
+
//
|
|
4
|
+
// CAWS lives under a single `.caws/` directory in the *main* repository,
|
|
5
|
+
// not under linked worktrees. A worktree's `.git` is a file pointing at
|
|
6
|
+
// `<main>/.git/worktrees/<name>/`. Using `git rev-parse --show-toplevel`
|
|
7
|
+
// from inside a worktree would return the WORKTREE's filesystem root,
|
|
8
|
+
// not the main repo's — and any path derived from it would write state
|
|
9
|
+
// into the worktree's filesystem.
|
|
10
|
+
//
|
|
11
|
+
// The correct authority is:
|
|
12
|
+
//
|
|
13
|
+
// git rev-parse --path-format=absolute --git-common-dir
|
|
14
|
+
//
|
|
15
|
+
// which returns `<main>/.git` regardless of where the caller stands. The
|
|
16
|
+
// CAWS repo root is the parent of that directory. The `.caws/` directory
|
|
17
|
+
// is one level deeper.
|
|
18
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
19
|
+
if (k2 === undefined) k2 = k;
|
|
20
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
21
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
22
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
23
|
+
}
|
|
24
|
+
Object.defineProperty(o, k2, desc);
|
|
25
|
+
}) : (function(o, m, k, k2) {
|
|
26
|
+
if (k2 === undefined) k2 = k;
|
|
27
|
+
o[k2] = m[k];
|
|
28
|
+
}));
|
|
29
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
30
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
31
|
+
}) : function(o, v) {
|
|
32
|
+
o["default"] = v;
|
|
33
|
+
});
|
|
34
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
35
|
+
var ownKeys = function(o) {
|
|
36
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
37
|
+
var ar = [];
|
|
38
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
39
|
+
return ar;
|
|
40
|
+
};
|
|
41
|
+
return ownKeys(o);
|
|
42
|
+
};
|
|
43
|
+
return function (mod) {
|
|
44
|
+
if (mod && mod.__esModule) return mod;
|
|
45
|
+
var result = {};
|
|
46
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
47
|
+
__setModuleDefault(result, mod);
|
|
48
|
+
return result;
|
|
49
|
+
};
|
|
50
|
+
})();
|
|
51
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
52
|
+
exports.defaultGitRunner = void 0;
|
|
53
|
+
exports.resolveRepoRoot = resolveRepoRoot;
|
|
54
|
+
exports.storeDiagnostic = storeDiagnostic;
|
|
55
|
+
const child_process_1 = require("child_process");
|
|
56
|
+
const fs = __importStar(require("fs"));
|
|
57
|
+
const path = __importStar(require("path"));
|
|
58
|
+
const caws_kernel_1 = require("@paths.design/caws-kernel");
|
|
59
|
+
const rules_1 = require("./rules");
|
|
60
|
+
const defaultGitRunner = (args, options) => {
|
|
61
|
+
const execOptions = {
|
|
62
|
+
cwd: options.cwd,
|
|
63
|
+
encoding: 'utf8',
|
|
64
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
65
|
+
};
|
|
66
|
+
return (0, child_process_1.execFileSync)('git', args, execOptions).trim();
|
|
67
|
+
};
|
|
68
|
+
exports.defaultGitRunner = defaultGitRunner;
|
|
69
|
+
/**
|
|
70
|
+
* Resolve the main-repo root from `cwd`, even when cwd is inside a linked
|
|
71
|
+
* worktree.
|
|
72
|
+
*
|
|
73
|
+
* Returns Err when:
|
|
74
|
+
* - cwd is not inside a git repository, OR
|
|
75
|
+
* - git invocation fails for another reason, OR
|
|
76
|
+
* - `requireCawsDir: true` and `.caws/` does not exist.
|
|
77
|
+
*
|
|
78
|
+
* Programmer errors (cwd not a string, git binary missing) throw.
|
|
79
|
+
*/
|
|
80
|
+
function resolveRepoRoot(cwd, options = {}) {
|
|
81
|
+
if (typeof cwd !== 'string' || cwd.length === 0) {
|
|
82
|
+
throw new TypeError('resolveRepoRoot: cwd must be a non-empty string.');
|
|
83
|
+
}
|
|
84
|
+
const git = options.git ?? exports.defaultGitRunner;
|
|
85
|
+
let commonDir;
|
|
86
|
+
try {
|
|
87
|
+
commonDir = git(['rev-parse', '--path-format=absolute', '--git-common-dir'], {
|
|
88
|
+
cwd,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
catch (e) {
|
|
92
|
+
const cause = e;
|
|
93
|
+
const stderr = typeof cause.stderr === 'string'
|
|
94
|
+
? cause.stderr
|
|
95
|
+
: cause.stderr instanceof Buffer
|
|
96
|
+
? cause.stderr.toString('utf8')
|
|
97
|
+
: '';
|
|
98
|
+
// "not a git repository" surfaces on stderr.
|
|
99
|
+
if (stderr.toLowerCase().includes('not a git repository')) {
|
|
100
|
+
return (0, caws_kernel_1.err)((0, caws_kernel_1.diagnostic)({
|
|
101
|
+
rule: rules_1.STORE_RULES.REPO_ROOT_NOT_A_GIT_REPO,
|
|
102
|
+
authority: 'kernel/diagnostics',
|
|
103
|
+
message: `${cwd} is not inside a git repository.`,
|
|
104
|
+
subject: cwd,
|
|
105
|
+
narrowRepair: 'Run `git init` or change directory to a repository.',
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
return (0, caws_kernel_1.err)((0, caws_kernel_1.diagnostic)({
|
|
109
|
+
rule: rules_1.STORE_RULES.REPO_ROOT_GIT_INVOCATION_FAILED,
|
|
110
|
+
authority: 'kernel/diagnostics',
|
|
111
|
+
message: `git rev-parse failed: ${cause.message ?? 'unknown error'}.`,
|
|
112
|
+
subject: cwd,
|
|
113
|
+
data: { stderr },
|
|
114
|
+
}));
|
|
115
|
+
}
|
|
116
|
+
// commonDir is the path to <main>/.git (or a separate gitdir). The
|
|
117
|
+
// repository root is its parent. We do NOT use --show-toplevel.
|
|
118
|
+
const repoRoot = path.dirname(commonDir);
|
|
119
|
+
const cawsDir = path.join(repoRoot, '.caws');
|
|
120
|
+
if (options.requireCawsDir && !fs.existsSync(cawsDir)) {
|
|
121
|
+
return (0, caws_kernel_1.err)((0, caws_kernel_1.diagnostic)({
|
|
122
|
+
rule: rules_1.STORE_RULES.REPO_ROOT_CAWS_DIR_MISSING,
|
|
123
|
+
authority: 'kernel/diagnostics',
|
|
124
|
+
message: `Resolved repo root has no .caws/ directory: ${repoRoot}.`,
|
|
125
|
+
subject: repoRoot,
|
|
126
|
+
narrowRepair: 'Run `caws init` to bootstrap the repository.',
|
|
127
|
+
}));
|
|
128
|
+
}
|
|
129
|
+
return (0, caws_kernel_1.ok)({ repoRoot, cawsDir });
|
|
130
|
+
}
|
|
131
|
+
// ----------------------------------------------------------------------------
|
|
132
|
+
// Helpers exposed for tests
|
|
133
|
+
// ----------------------------------------------------------------------------
|
|
134
|
+
/** Construct a structured Diagnostic with the canonical store authority. */
|
|
135
|
+
function storeDiagnostic(rule, message, extra = {}) {
|
|
136
|
+
return (0, caws_kernel_1.diagnostic)({
|
|
137
|
+
rule,
|
|
138
|
+
authority: 'kernel/diagnostics',
|
|
139
|
+
message,
|
|
140
|
+
...(extra.subject !== undefined ? { subject: extra.subject } : {}),
|
|
141
|
+
...(extra.narrowRepair !== undefined ? { narrowRepair: extra.narrowRepair } : {}),
|
|
142
|
+
...(extra.data !== undefined ? { data: extra.data } : {}),
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=repo-root.js.map
|