@paths.design/caws-cli 11.1.6 → 11.1.8

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.
Files changed (190) hide show
  1. package/README.md +1 -1
  2. package/dist/index.js +55 -58
  3. package/dist/init/hook-packs/manifest-claude-code.d.ts +1 -1
  4. package/dist/init/hook-packs/manifest-claude-code.d.ts.map +1 -1
  5. package/dist/init/hook-packs/manifest-claude-code.js +317 -6
  6. package/dist/init/hook-packs/manifest-claude-code.js.map +1 -1
  7. package/dist/init/hook-packs/types.js +1 -1
  8. package/dist/init/hook-packs/types.js.map +1 -1
  9. package/dist/shell/binding/resolve-binding.d.ts.map +1 -1
  10. package/dist/shell/binding/resolve-binding.js +105 -1
  11. package/dist/shell/binding/resolve-binding.js.map +1 -1
  12. package/dist/shell/binding/types.d.ts +47 -3
  13. package/dist/shell/binding/types.d.ts.map +1 -1
  14. package/dist/shell/command-metadata.d.ts +93 -0
  15. package/dist/shell/command-metadata.d.ts.map +1 -0
  16. package/dist/shell/command-metadata.js +687 -0
  17. package/dist/shell/command-metadata.js.map +1 -0
  18. package/dist/shell/commands/agents.d.ts +48 -0
  19. package/dist/shell/commands/agents.d.ts.map +1 -0
  20. package/dist/shell/commands/agents.js +577 -0
  21. package/dist/shell/commands/agents.js.map +1 -0
  22. package/dist/shell/commands/claim.d.ts +16 -0
  23. package/dist/shell/commands/claim.d.ts.map +1 -1
  24. package/dist/shell/commands/claim.js +88 -30
  25. package/dist/shell/commands/claim.js.map +1 -1
  26. package/dist/shell/commands/events.d.ts +106 -0
  27. package/dist/shell/commands/events.d.ts.map +1 -0
  28. package/dist/shell/commands/events.js +510 -0
  29. package/dist/shell/commands/events.js.map +1 -0
  30. package/dist/shell/commands/gates.d.ts +2 -2
  31. package/dist/shell/commands/gates.d.ts.map +1 -1
  32. package/dist/shell/commands/gates.js +106 -25
  33. package/dist/shell/commands/gates.js.map +1 -1
  34. package/dist/shell/commands/init.d.ts.map +1 -1
  35. package/dist/shell/commands/init.js +26 -0
  36. package/dist/shell/commands/init.js.map +1 -1
  37. package/dist/shell/commands/prepush.d.ts +26 -0
  38. package/dist/shell/commands/prepush.d.ts.map +1 -0
  39. package/dist/shell/commands/prepush.js +373 -0
  40. package/dist/shell/commands/prepush.js.map +1 -0
  41. package/dist/shell/commands/scope.d.ts.map +1 -1
  42. package/dist/shell/commands/scope.js +31 -1
  43. package/dist/shell/commands/scope.js.map +1 -1
  44. package/dist/shell/commands/specs.d.ts +44 -3
  45. package/dist/shell/commands/specs.d.ts.map +1 -1
  46. package/dist/shell/commands/specs.js +411 -15
  47. package/dist/shell/commands/specs.js.map +1 -1
  48. package/dist/shell/commands/status.d.ts +12 -0
  49. package/dist/shell/commands/status.d.ts.map +1 -1
  50. package/dist/shell/commands/status.js +236 -21
  51. package/dist/shell/commands/status.js.map +1 -1
  52. package/dist/shell/commands/worktree.d.ts +9 -0
  53. package/dist/shell/commands/worktree.d.ts.map +1 -1
  54. package/dist/shell/commands/worktree.js +353 -1
  55. package/dist/shell/commands/worktree.js.map +1 -1
  56. package/dist/shell/gates/disposition.d.ts.map +1 -1
  57. package/dist/shell/gates/disposition.js +43 -2
  58. package/dist/shell/gates/disposition.js.map +1 -1
  59. package/dist/shell/index.d.ts +14 -6
  60. package/dist/shell/index.d.ts.map +1 -1
  61. package/dist/shell/index.js +32 -1
  62. package/dist/shell/index.js.map +1 -1
  63. package/dist/shell/legacy-command-map.js +832 -0
  64. package/dist/shell/push-range/classify-range.d.ts +99 -0
  65. package/dist/shell/push-range/classify-range.d.ts.map +1 -0
  66. package/dist/shell/push-range/classify-range.js +155 -0
  67. package/dist/shell/push-range/classify-range.js.map +1 -0
  68. package/dist/shell/push-range/scope-match.d.ts +13 -0
  69. package/dist/shell/push-range/scope-match.d.ts.map +1 -0
  70. package/dist/shell/push-range/scope-match.js +53 -0
  71. package/dist/shell/push-range/scope-match.js.map +1 -0
  72. package/dist/shell/register.d.ts.map +1 -1
  73. package/dist/shell/register.js +350 -165
  74. package/dist/shell/register.js.map +1 -1
  75. package/dist/shell/registered-command-groups.js +48 -0
  76. package/dist/shell/render/status.d.ts +7 -1
  77. package/dist/shell/render/status.d.ts.map +1 -1
  78. package/dist/shell/render/status.js +72 -0
  79. package/dist/shell/render/status.js.map +1 -1
  80. package/dist/shell/rules.d.ts +19 -0
  81. package/dist/shell/rules.d.ts.map +1 -1
  82. package/dist/shell/rules.js +27 -0
  83. package/dist/shell/rules.js.map +1 -1
  84. package/dist/shell/session/resolve-session.d.ts +29 -1
  85. package/dist/shell/session/resolve-session.d.ts.map +1 -1
  86. package/dist/shell/session/resolve-session.js +817 -11
  87. package/dist/shell/session/resolve-session.js.map +1 -1
  88. package/dist/shell/session/types.d.ts +127 -1
  89. package/dist/shell/session/types.d.ts.map +1 -1
  90. package/dist/shell/session/types.js +10 -4
  91. package/dist/shell/session/types.js.map +1 -1
  92. package/dist/store/agents-store.d.ts.map +1 -1
  93. package/dist/store/agents-store.js +9 -0
  94. package/dist/store/agents-store.js.map +1 -1
  95. package/dist/store/apply-patch.d.ts.map +1 -1
  96. package/dist/store/apply-patch.js +15 -0
  97. package/dist/store/apply-patch.js.map +1 -1
  98. package/dist/store/doctor-snapshot.d.ts.map +1 -1
  99. package/dist/store/doctor-snapshot.js +169 -3
  100. package/dist/store/doctor-snapshot.js.map +1 -1
  101. package/dist/store/events-migration.d.ts +207 -0
  102. package/dist/store/events-migration.d.ts.map +1 -0
  103. package/dist/store/events-migration.js +358 -0
  104. package/dist/store/events-migration.js.map +1 -0
  105. package/dist/store/events-store.d.ts +47 -1
  106. package/dist/store/events-store.d.ts.map +1 -1
  107. package/dist/store/events-store.js +278 -0
  108. package/dist/store/events-store.js.map +1 -1
  109. package/dist/store/git-autocommit.d.ts +46 -0
  110. package/dist/store/git-autocommit.d.ts.map +1 -0
  111. package/dist/store/git-autocommit.js +198 -0
  112. package/dist/store/git-autocommit.js.map +1 -0
  113. package/dist/store/git-sparse-checkout.d.ts +25 -0
  114. package/dist/store/git-sparse-checkout.d.ts.map +1 -0
  115. package/dist/store/git-sparse-checkout.js +101 -0
  116. package/dist/store/git-sparse-checkout.js.map +1 -0
  117. package/dist/store/index.d.ts +6 -1
  118. package/dist/store/index.d.ts.map +1 -1
  119. package/dist/store/index.js +16 -1
  120. package/dist/store/index.js.map +1 -1
  121. package/dist/store/leases-store.d.ts +89 -0
  122. package/dist/store/leases-store.d.ts.map +1 -0
  123. package/dist/store/leases-store.js +427 -0
  124. package/dist/store/leases-store.js.map +1 -0
  125. package/dist/store/lifecycle-transaction.d.ts.map +1 -1
  126. package/dist/store/lifecycle-transaction.js +34 -1
  127. package/dist/store/lifecycle-transaction.js.map +1 -1
  128. package/dist/store/rules.d.ts +74 -1
  129. package/dist/store/rules.d.ts.map +1 -1
  130. package/dist/store/rules.js +76 -0
  131. package/dist/store/rules.js.map +1 -1
  132. package/dist/store/specs-migration.d.ts +128 -0
  133. package/dist/store/specs-migration.d.ts.map +1 -0
  134. package/dist/store/specs-migration.js +481 -0
  135. package/dist/store/specs-migration.js.map +1 -0
  136. package/dist/store/specs-store.d.ts.map +1 -1
  137. package/dist/store/specs-store.js +14 -2
  138. package/dist/store/specs-store.js.map +1 -1
  139. package/dist/store/specs-writer.d.ts +130 -3
  140. package/dist/store/specs-writer.d.ts.map +1 -1
  141. package/dist/store/specs-writer.js +941 -102
  142. package/dist/store/specs-writer.js.map +1 -1
  143. package/dist/store/types.d.ts +31 -1
  144. package/dist/store/types.d.ts.map +1 -1
  145. package/dist/store/waivers-store.d.ts.map +1 -1
  146. package/dist/store/waivers-store.js +8 -1
  147. package/dist/store/waivers-store.js.map +1 -1
  148. package/dist/store/worktrees-migration.d.ts +141 -0
  149. package/dist/store/worktrees-migration.d.ts.map +1 -0
  150. package/dist/store/worktrees-migration.js +356 -0
  151. package/dist/store/worktrees-migration.js.map +1 -0
  152. package/dist/store/worktrees-writer.d.ts +28 -0
  153. package/dist/store/worktrees-writer.d.ts.map +1 -1
  154. package/dist/store/worktrees-writer.js +147 -13
  155. package/dist/store/worktrees-writer.js.map +1 -1
  156. package/package.json +5 -2
  157. package/templates/hook-packs/claude-code/CLAUDE.md +11 -5
  158. package/templates/hook-packs/claude-code/agent-heartbeat.sh +131 -0
  159. package/templates/hook-packs/claude-code/agent-register.sh +62 -0
  160. package/templates/hook-packs/claude-code/agent-stop.sh +51 -0
  161. package/templates/hook-packs/claude-code/audit.sh +1 -1
  162. package/templates/hook-packs/claude-code/block-dangerous.sh +1 -1
  163. package/templates/hook-packs/claude-code/classify_command.py +1 -1
  164. package/templates/hook-packs/claude-code/cwd-guard.sh +30 -0
  165. package/templates/hook-packs/claude-code/dispatch/post_tool_use.sh +15 -4
  166. package/templates/hook-packs/claude-code/dispatch/pre_tool_use.sh +19 -2
  167. package/templates/hook-packs/claude-code/dispatch/session_start.sh +6 -2
  168. package/templates/hook-packs/claude-code/dispatch/stop.sh +7 -2
  169. package/templates/hook-packs/claude-code/duplicate-export-check.sh +156 -0
  170. package/templates/hook-packs/claude-code/god-object-check.sh +102 -0
  171. package/templates/hook-packs/claude-code/guard-strikes.sh +1 -1
  172. package/templates/hook-packs/claude-code/lib/parse-input.sh +115 -1
  173. package/templates/hook-packs/claude-code/lib/run-handlers.sh +1 -1
  174. package/templates/hook-packs/claude-code/loc-delta-check.sh +91 -0
  175. package/templates/hook-packs/claude-code/naming-check.sh +128 -0
  176. package/templates/hook-packs/claude-code/plan-transcript-finalize.sh +59 -0
  177. package/templates/hook-packs/claude-code/plan-transcript-snapshot.sh +86 -0
  178. package/templates/hook-packs/claude-code/protected-paths.sh +59 -0
  179. package/templates/hook-packs/claude-code/quiet-merge.sh +68 -0
  180. package/templates/hook-packs/claude-code/reset-danger-latch.sh +1 -1
  181. package/templates/hook-packs/claude-code/reset-strikes.sh +1 -1
  182. package/templates/hook-packs/claude-code/runtime-paths.sh +1 -1
  183. package/templates/hook-packs/claude-code/scan-secrets.sh +98 -0
  184. package/templates/hook-packs/claude-code/scope-guard.sh +47 -65
  185. package/templates/hook-packs/claude-code/session-caws-status.sh +7 -1
  186. package/templates/hook-packs/claude-code/session-log.sh +1 -1
  187. package/templates/hook-packs/claude-code/session_log_renderer.py +956 -0
  188. package/templates/hook-packs/claude-code/shortcut-language-check.sh +147 -0
  189. package/templates/hook-packs/claude-code/worktree-guard.sh +130 -4
  190. package/templates/hook-packs/claude-code/worktree-write-guard.sh +133 -18
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ // Sparse-checkout helper for CAWS-created worktrees
3
+ // (WORKTREE-SPEC-AUTHORITY-CONTROL-PLANE-001 A1).
4
+ //
5
+ // CAWS state is control-plane. The .caws/specs/ directory exists exactly
6
+ // once for the project, owned by the main checkout. When `caws worktree
7
+ // create` adds a linked worktree, git's default full checkout would
8
+ // materialize .caws/specs/<id>.yaml into the worktree filesystem,
9
+ // producing the v10.2 split-brain authority class: an editable spec
10
+ // copy inside the worktree, divergent from control-plane bytes,
11
+ // silently consulted by anything that walks cwd upward.
12
+ //
13
+ // This helper configures non-cone sparse-checkout on a freshly-added
14
+ // worktree so the .caws/specs/ tree is excluded from checkout. The
15
+ // rest of the worktree is a normal full checkout — the historic
16
+ // objection to sparse-checkout (broken cross-module imports caused by
17
+ // nearly-empty worktrees) is preserved by including everything OTHER
18
+ // than the authority files.
19
+ //
20
+ // Sparse-checkout vs the worktree-guard.sh hook policy: the hook
21
+ // (`.claude/hooks/worktree-guard.sh:52-56`) blocks agent-issued
22
+ // `git sparse-checkout` commands because sparse-checkout can be
23
+ // misused to hide source files and break work. This helper's use is
24
+ // different: it excludes ONLY the .caws/specs/ authority files, never
25
+ // source code, and runs from the CLI writer (via child_process.spawn)
26
+ // which does not go through the Bash tool hook surface. The hook's
27
+ // purpose is preserved.
28
+ //
29
+ // Pattern: `/*` includes everything; `!/.caws/specs/` excludes the
30
+ // authority directory. Non-cone mode is required because cone mode
31
+ // would force enumeration of all top-level directories. Non-cone
32
+ // sparse-checkout requires git 2.27+, which is documented in the
33
+ // spec's non_functional.reliability clause.
34
+ Object.defineProperty(exports, "__esModule", { value: true });
35
+ exports.configureWorktreeSparseCheckout = configureWorktreeSparseCheckout;
36
+ const child_process_1 = require("child_process");
37
+ /**
38
+ * Configure non-cone sparse-checkout on `wtPath` so that `.caws/specs/`
39
+ * is excluded from checkout, then run `git checkout` to materialize the
40
+ * remaining tree.
41
+ *
42
+ * Returns Result-shape `{ ok: true }` on success or `{ ok: false,
43
+ * reason }` on the first failing git invocation. The caller is
44
+ * responsible for compensating side effects (typically by running
45
+ * `git worktree remove --force <wtPath>` on the partially-created
46
+ * worktree).
47
+ *
48
+ * IMPORTANT: this function does NOT call `git worktree add`. The caller
49
+ * must have already added the worktree with `--no-checkout` so that no
50
+ * files have been materialized yet. Calling this on a worktree that
51
+ * was added with a normal full checkout would not retroactively remove
52
+ * already-checked-out `.caws/specs/` files.
53
+ */
54
+ function configureWorktreeSparseCheckout(wtPath) {
55
+ // 1) Initialize sparse-checkout in non-cone mode.
56
+ const initResult = runGit(wtPath, ['sparse-checkout', 'init', '--no-cone']);
57
+ if (!initResult.ok)
58
+ return { ok: false, reason: initResult.reason, step: 'init' };
59
+ // 2) Set the pattern: include everything, exclude .caws/specs/.
60
+ // Non-cone mode interprets these as gitignore-style patterns
61
+ // relative to the worktree root. The leading slash in '/.caws/specs/'
62
+ // anchors the exclusion to the worktree root (not subdirectories
63
+ // named .caws/specs/ further down — there are none in this
64
+ // project, but the anchor is correct discipline).
65
+ const setResult = runGit(wtPath, [
66
+ 'sparse-checkout',
67
+ 'set',
68
+ '--no-cone',
69
+ '/*',
70
+ '!/.caws/specs/',
71
+ ]);
72
+ if (!setResult.ok)
73
+ return { ok: false, reason: setResult.reason, step: 'set' };
74
+ // 3) Materialize the included files. `git worktree add --no-checkout`
75
+ // leaves the worktree empty; this populates everything sparse-
76
+ // checkout admits.
77
+ const checkoutResult = runGit(wtPath, ['checkout']);
78
+ if (!checkoutResult.ok)
79
+ return { ok: false, reason: checkoutResult.reason, step: 'checkout' };
80
+ return { ok: true };
81
+ }
82
+ function runGit(cwd, args) {
83
+ try {
84
+ const stdout = (0, child_process_1.execFileSync)('git', [...args], {
85
+ cwd,
86
+ encoding: 'utf8',
87
+ stdio: ['ignore', 'pipe', 'pipe'],
88
+ });
89
+ return { ok: true, stdout: stdout.toString() };
90
+ }
91
+ catch (e) {
92
+ const cause = e;
93
+ const stderr = cause.stderr instanceof Buffer
94
+ ? cause.stderr.toString()
95
+ : typeof cause.stderr === 'string'
96
+ ? cause.stderr
97
+ : (cause.message ?? 'unknown git error');
98
+ return { ok: false, reason: stderr.trim() };
99
+ }
100
+ }
101
+ //# sourceMappingURL=git-sparse-checkout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git-sparse-checkout.js","sourceRoot":"","sources":["../../src/store/git-sparse-checkout.ts"],"names":[],"mappings":";AAAA,oDAAoD;AACpD,kDAAkD;AAClD,EAAE;AACF,yEAAyE;AACzE,wEAAwE;AACxE,oEAAoE;AACpE,kEAAkE;AAClE,oEAAoE;AACpE,gEAAgE;AAChE,wDAAwD;AACxD,EAAE;AACF,qEAAqE;AACrE,mEAAmE;AACnE,gEAAgE;AAChE,sEAAsE;AACtE,qEAAqE;AACrE,4BAA4B;AAC5B,EAAE;AACF,iEAAiE;AACjE,gEAAgE;AAChE,gEAAgE;AAChE,oEAAoE;AACpE,sEAAsE;AACtE,sEAAsE;AACtE,mEAAmE;AACnE,wBAAwB;AACxB,EAAE;AACF,mEAAmE;AACnE,mEAAmE;AACnE,iEAAiE;AACjE,iEAAiE;AACjE,4CAA4C;;AAqB5C,0EA8BC;AAjDD,iDAA6C;AAE7C;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,+BAA+B,CAC7C,MAAc;IAEd,kDAAkD;IAClD,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,iBAAiB,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;IAC5E,IAAI,CAAC,UAAU,CAAC,EAAE;QAAE,O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AAM,GACV,KAAK,CAAC,MAAM,YAAY,MAAM;YAC5B,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE;YACzB,CAAC,CAAC,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ;gBAChC,CAAC,CAAC,KAAK,CAAC,MAAM;gBACd,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,mBAAmB,CAAC,CAAC;QAC/C,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;IAC9C,CAAC;AACH,CAAC"}
@@ -7,11 +7,16 @@ export { fsyncDir, writeFileAtomic } from './atomic-write';
7
7
  export { readJsonFile } from './json-store';
8
8
  export { readYamlFile, readYamlSource } from './yaml-store';
9
9
  export { loadSpecs } from './specs-store';
10
+ export { runSpecsMigrateScan, runSpecsMigrateApply, MIGRATION_REPORT_SCHEMA_VERSION, } from './specs-migration';
11
+ export type { ScanEntry, ScanReport, ReportEntry, ReportVerdict, MigrationReport, ApplyResult as SpecsMigrateApplyResult, ScanOptions as SpecsMigrateScanOptions, ApplyOptions as SpecsMigrateApplyOptions, NonYamlObservation, } from './specs-migration';
10
12
  export { loadPolicy } from './policy-store';
11
13
  export { loadWorktrees } from './worktrees-store';
12
14
  export { loadAgents } from './agents-store';
13
- export { appendEvent, loadEvents } from './events-store';
15
+ export { appendEvent, loadEvents, rotateEvents } from './events-store';
16
+ export type { RotateEventsOptions } from './events-store';
14
17
  export { applyRegistryPatch } from './apply-patch';
18
+ export { safeLeaseFilename, loadLeases, applyLeasePatch, applyLeasePatches, pruneLeasesByStatus, } from './leases-store';
19
+ export type { LoadLeasesResult, PruneOptions, PruneResult, } from './leases-store';
15
20
  export { loadWaivers, writeWaiver, markRevoked } from './waivers-store';
16
21
  export type { WaiversLoadResult } from './waivers-store';
17
22
  export { initProject, DEFAULT_POLICY_YAML } from './init-store';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","source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BAAgB,CAAC;AAE1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAKnD,OAAO,EACL,iBAAiB,EACjB,UAAU,EACV,eAAe,EACf,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,gBAAgB,EAChB,YAAY,EACZ,WAAW,GACZ,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACxE,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAChE,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEnE,OAAO,EACL,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,oBAAoB,EACpB,mBAAmB,EACnB,cAAc,GACf,MAAM,mBAAmB,CAAC"}
@@ -5,7 +5,7 @@
5
5
  // It is consumed programmatically; no public CLI commands are registered
6
6
  // here. CLI command surface lands in Slice 5c.
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.composeStoreSnapshot = exports.composeDoctorSnapshot = exports.DEFAULT_POLICY_YAML = exports.initProject = exports.markRevoked = exports.writeWaiver = exports.loadWaivers = exports.applyRegistryPatch = exports.loadEvents = exports.appendEvent = exports.loadAgents = exports.loadWorktrees = exports.loadPolicy = exports.loadSpecs = exports.readYamlSource = exports.readYamlFile = exports.readJsonFile = exports.writeFileAtomic = exports.fsyncDir = exports.storeDiagnostic = exports.resolveRepoRoot = exports.defaultGitRunner = exports.STORE_RULE_PREFIXES = exports.STORE_RULES = void 0;
8
+ exports.composeStoreSnapshot = exports.composeDoctorSnapshot = exports.DEFAULT_POLICY_YAML = exports.initProject = exports.markRevoked = exports.writeWaiver = exports.loadWaivers = exports.pruneLeasesByStatus = exports.applyLeasePatches = exports.applyLeasePatch = exports.loadLeases = exports.safeLeaseFilename = exports.applyRegistryPatch = exports.rotateEvents = exports.loadEvents = exports.appendEvent = exports.loadAgents = exports.loadWorktrees = exports.loadPolicy = exports.MIGRATION_REPORT_SCHEMA_VERSION = exports.runSpecsMigrateApply = exports.runSpecsMigrateScan = exports.loadSpecs = exports.readYamlSource = exports.readYamlFile = exports.readJsonFile = exports.writeFileAtomic = exports.fsyncDir = exports.storeDiagnostic = exports.resolveRepoRoot = exports.defaultGitRunner = exports.STORE_RULE_PREFIXES = exports.STORE_RULES = void 0;
9
9
  var rules_1 = require("./rules");
10
10
  Object.defineProperty(exports, "STORE_RULES", { enumerable: true, get: function () { return rules_1.STORE_RULES; } });
11
11
  Object.defineProperty(exports, "STORE_RULE_PREFIXES", { enumerable: true, get: function () { return rules_1.STORE_RULE_PREFIXES; } });
@@ -23,6 +23,11 @@ Object.defineProperty(exports, "readYamlFile", { enumerable: true, get: function
23
23
  Object.defineProperty(exports, "readYamlSource", { enumerable: true, get: function () { return yaml_store_1.readYamlSource; } });
24
24
  var specs_store_1 = require("./specs-store");
25
25
  Object.defineProperty(exports, "loadSpecs", { enumerable: true, get: function () { return specs_store_1.loadSpecs; } });
26
+ // ─── v10→v11 spec migration (CAWS-MIGRATE-V10-SPECS-001) ─────────────────
27
+ var specs_migration_1 = require("./specs-migration");
28
+ Object.defineProperty(exports, "runSpecsMigrateScan", { enumerable: true, get: function () { return specs_migration_1.runSpecsMigrateScan; } });
29
+ Object.defineProperty(exports, "runSpecsMigrateApply", { enumerable: true, get: function () { return specs_migration_1.runSpecsMigrateApply; } });
30
+ Object.defineProperty(exports, "MIGRATION_REPORT_SCHEMA_VERSION", { enumerable: true, get: function () { return specs_migration_1.MIGRATION_REPORT_SCHEMA_VERSION; } });
26
31
  var policy_store_1 = require("./policy-store");
27
32
  Object.defineProperty(exports, "loadPolicy", { enumerable: true, get: function () { return policy_store_1.loadPolicy; } });
28
33
  var worktrees_store_1 = require("./worktrees-store");
@@ -32,8 +37,18 @@ Object.defineProperty(exports, "loadAgents", { enumerable: true, get: function (
32
37
  var events_store_1 = require("./events-store");
33
38
  Object.defineProperty(exports, "appendEvent", { enumerable: true, get: function () { return events_store_1.appendEvent; } });
34
39
  Object.defineProperty(exports, "loadEvents", { enumerable: true, get: function () { return events_store_1.loadEvents; } });
40
+ Object.defineProperty(exports, "rotateEvents", { enumerable: true, get: function () { return events_store_1.rotateEvents; } });
35
41
  var apply_patch_1 = require("./apply-patch");
36
42
  Object.defineProperty(exports, "applyRegistryPatch", { enumerable: true, get: function () { return apply_patch_1.applyRegistryPatch; } });
43
+ // ─── leases (MULTI-AGENT-ACTIVITY-REGISTRY-001) ──────────────────────────
44
+ // Lease I/O surface — separate from applyRegistryPatch. LeasePatch is
45
+ // applied ONLY through applyLeasePatch / applyLeasePatches.
46
+ var leases_store_1 = require("./leases-store");
47
+ Object.defineProperty(exports, "safeLeaseFilename", { enumerable: true, get: function () { return leases_store_1.safeLeaseFilename; } });
48
+ Object.defineProperty(exports, "loadLeases", { enumerable: true, get: function () { return leases_store_1.loadLeases; } });
49
+ Object.defineProperty(exports, "applyLeasePatch", { enumerable: true, get: function () { return leases_store_1.applyLeasePatch; } });
50
+ Object.defineProperty(exports, "applyLeasePatches", { enumerable: true, get: function () { return leases_store_1.applyLeasePatches; } });
51
+ Object.defineProperty(exports, "pruneLeasesByStatus", { enumerable: true, get: function () { return leases_store_1.pruneLeasesByStatus; } });
37
52
  var waivers_store_1 = require("./waivers-store");
38
53
  Object.defineProperty(exports, "loadWaivers", { enumerable: true, get: function () { return waivers_store_1.loadWaivers; } });
39
54
  Object.defineProperty(exports, "writeWaiver", { enumerable: true, get: function () { return waivers_store_1.writeWaiver; } });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":";AAAA,gDAAgD;AAChD,EAAE;AACF,wEAAwE;AACxE,yEAAyE;AACzE,+CAA+C;;;AAE/C,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,0GAAA,YAAY,OAAA;AACrB,2CAA4D;AAAnD,0GAAA,YAAY,OAAA;AAAE,4GAAA,cAAc,OAAA;AAErC,6CAA0C;AAAjC,wGAAA,SAAS,OAAA;AAElB,4EAA4E;AAC5E,qDAI2B;AAHzB,sHAAA,mBAAmB,OAAA;AACnB,uHAAA,oBAAoB,OAAA;AACpB,kIAAA,+BAA+B,OAAA;AAcjC,+CAA4C;AAAnC,0GAAA,UAAU,OAAA;AACnB,qDAAkD;AAAzC,gHAAA,aAAa,OAAA;AACtB,+CAA4C;AAAnC,0GAAA,UAAU,OAAA;AACnB,+CAAuE;AAA9D,2GAAA,WAAW,OAAA;AAAE,0GAAA,UAAU,OAAA;AAAE,4GAAA,YAAY,OAAA;AAG9C,6CAAmD;AAA1C,iHAAA,kBAAkB,OAAA;AAE3B,4EAA4E;AAC5E,sEAAsE;AACtE,4DAA4D;AAC5D,+CAMwB;AALtB,iHAAA,iBAAiB,OAAA;AACjB,0GAAA,UAAU,OAAA;AACV,+GAAA,eAAe,OAAA;AACf,iHAAA,iBAAiB,OAAA;AACjB,mHAAA,mBAAmB,OAAA;AAQrB,iDAAwE;AAA/D,4GAAA,WAAW,OAAA;AAAE,4GAAA,WAAW,OAAA;AAAE,4GAAA,WAAW,OAAA;AAG9C,2CAAgE;AAAvD,yGAAA,WAAW,OAAA;AAAE,iHAAA,mBAAmB,OAAA;AAGzC,qDAG2B;AAFzB,wHAAA,qBAAqB,OAAA;AACrB,uHAAA,oBAAoB,OAAA"}
@@ -0,0 +1,89 @@
1
+ import { type Diagnostic, type LeasePatch, type LeaseRegistry, type Result } from '@paths.design/caws-kernel';
2
+ export interface LoadLeasesResult {
3
+ readonly leases: LeaseRegistry;
4
+ readonly diagnostics: ReadonlyArray<Diagnostic>;
5
+ }
6
+ /**
7
+ * Validate a session_id for filesystem safety, returning the filename
8
+ * to use (with .json suffix) on success.
9
+ */
10
+ export declare function safeLeaseFilename(sessionId: unknown): Result<string>;
11
+ /**
12
+ * Load all lease files under .caws/leases/.
13
+ *
14
+ * LENIENT per file: a malformed individual lease produces a diagnostic
15
+ * in the returned diagnostics array and is excluded from the registry;
16
+ * the call returns ok with the parseable subset.
17
+ *
18
+ * STRICT on directory: an unreadable .caws/leases/ directory returns
19
+ * err with LEASE_DIR_UNREADABLE. A missing directory returns
20
+ * ok({ leases: {}, diagnostics: [] }) — leases are operational cache;
21
+ * absence is normal.
22
+ *
23
+ * Per-file failure classes (each emits one diagnostic, excludes the file):
24
+ * - filename does not match the lease pattern (skipped silently —
25
+ * these are not lease files, just other content in the dir)
26
+ * - JSON parse failure → LEASE_FILE_MALFORMED
27
+ * - JSON parses but is not an object → LEASE_FILE_MALFORMED
28
+ * - session_id mismatch between filename and content → LEASE_FILE_MALFORMED
29
+ */
30
+ export declare function loadLeases(cawsDir: string): Result<LoadLeasesResult>;
31
+ /**
32
+ * Apply a single LeasePatch via atomic per-file write.
33
+ *
34
+ * Creates the leases directory if missing. No lock acquired (per spec
35
+ * invariant 11). No event emitted (per spec invariant 10 and doctrine
36
+ * §6 invariant 10).
37
+ *
38
+ * Patch semantics:
39
+ * - write_lease: serialize patch.lease as JSON, atomic-write to
40
+ * <cawsDir>/leases/<safe-session-id>.json.
41
+ * - mark_stopped: read existing lease file; if absent, return ok with
42
+ * a warning diagnostic (NOT a fabricated record); if present,
43
+ * update status='stopped', stopped_at=patch.transitioned_at,
44
+ * last_seen_reason='session_stop'; atomic-write back.
45
+ * - delete_lease: fs.unlinkSync the lease file; idempotent on absence.
46
+ */
47
+ export declare function applyLeasePatch(cawsDir: string, patch: LeasePatch): Result<{
48
+ readonly wrote: boolean;
49
+ readonly diagnostics: ReadonlyArray<Diagnostic>;
50
+ }>;
51
+ /**
52
+ * Apply a batch of lease patches. Per-patch failures do NOT abort the
53
+ * batch — each patch's diagnostics are aggregated into the return.
54
+ *
55
+ * Use for operator commands like prune that emit multiple delete_lease
56
+ * patches. Single-session register/heartbeat/stop go through
57
+ * applyLeasePatch directly.
58
+ */
59
+ export declare function applyLeasePatches(cawsDir: string, patches: ReadonlyArray<LeasePatch>): Result<{
60
+ readonly applied: number;
61
+ readonly diagnostics: ReadonlyArray<Diagnostic>;
62
+ }>;
63
+ /**
64
+ * Operator-invoked prune: delete lease files matching a status + age
65
+ * threshold.
66
+ *
67
+ * Selection: status === target AND (now - reference) > retentionMs, where
68
+ * reference is `stopped_at` for status='stopped' and `last_active` for
69
+ * status='active' (with TTL-based read-side 'stale' bucketing).
70
+ *
71
+ * Default `dryRun: true` (caller must explicitly pass false to delete).
72
+ * Returns count of files that would be / were deleted plus any
73
+ * diagnostics from the delete operations.
74
+ */
75
+ export interface PruneOptions {
76
+ readonly status: 'stopped' | 'stale';
77
+ /** Active records whose age exceeds this are bucketed as stale for the prune decision. */
78
+ readonly staleTtlMs?: number;
79
+ readonly retentionMs: number;
80
+ readonly now: Date;
81
+ readonly dryRun?: boolean;
82
+ }
83
+ export interface PruneResult {
84
+ readonly candidates: ReadonlyArray<string>;
85
+ readonly deleted: ReadonlyArray<string>;
86
+ readonly diagnostics: ReadonlyArray<Diagnostic>;
87
+ }
88
+ export declare function pruneLeasesByStatus(cawsDir: string, opts: PruneOptions): Result<PruneResult>;
89
+ //# sourceMappingURL=leases-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"leases-store.d.ts","sourceRoot":"","sources":["../../src/store/leases-store.ts"],"names":[],"mappings":"AAoCA,OAAO,EAKL,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,MAAM,EACZ,MAAM,2BAA2B,CAAC;AA+BnC,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;CACjD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CAuCpE;AAED;;;;;;;;;;;;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