@cleocode/paths 2026.5.95 → 2026.5.97

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/dist/index.d.ts CHANGED
@@ -12,7 +12,7 @@
12
12
  * {@link getCleoSystemInfo}, {@link getCleoTemplatesTildePath}
13
13
  * - Worktree primitives: {@link computeProjectHash},
14
14
  * {@link resolveWorktreeRootForHash}, {@link resolveTaskWorktreePath},
15
- * {@link getCleoWorktreesRoot}
15
+ * {@link getCleoWorktreesRoot}, {@link resolveWorktreeIndexPath}
16
16
  * - {@link isAbsolutePath} — cross-platform abs-path check
17
17
  *
18
18
  * @packageDocumentation
@@ -21,5 +21,5 @@
21
21
  export { isAbsolutePath } from './abs-path.js';
22
22
  export { _resetCleoPlatformPathsCache, getCanonicalTemplatesTildePath, getCleoHome, getCleoPlatformPaths, getCleoSystemInfo, getCleoTemplatesTildePath, resolveLegacyCleoDir, } from './cleo-paths.js';
23
23
  export { createPlatformPathsResolver, type PlatformPaths, type PlatformPathsResolver, type SystemInfo, } from './platform-paths.js';
24
- export { computeProjectHash, getCleoWorktreesRoot, resolveTaskWorktreePath, resolveWorktreeRootForHash, } from './worktree-paths.js';
24
+ export { computeProjectHash, getCleoWorktreesRoot, resolveTaskWorktreePath, resolveWorktreeIndexPath, resolveWorktreeRootForHash, } from './worktree-paths.js';
25
25
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EACL,4BAA4B,EAC5B,8BAA8B,EAC9B,WAAW,EACX,oBAAoB,EACpB,iBAAiB,EACjB,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,2BAA2B,EAC3B,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAC1B,KAAK,UAAU,GAChB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACvB,0BAA0B,GAC3B,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EACL,4BAA4B,EAC5B,8BAA8B,EAC9B,WAAW,EACX,oBAAoB,EACpB,iBAAiB,EACjB,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,2BAA2B,EAC3B,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAC1B,KAAK,UAAU,GAChB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACvB,wBAAwB,EACxB,0BAA0B,GAC3B,MAAM,qBAAqB,CAAC"}
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@
12
12
  * {@link getCleoSystemInfo}, {@link getCleoTemplatesTildePath}
13
13
  * - Worktree primitives: {@link computeProjectHash},
14
14
  * {@link resolveWorktreeRootForHash}, {@link resolveTaskWorktreePath},
15
- * {@link getCleoWorktreesRoot}
15
+ * {@link getCleoWorktreesRoot}, {@link resolveWorktreeIndexPath}
16
16
  * - {@link isAbsolutePath} — cross-platform abs-path check
17
17
  *
18
18
  * @packageDocumentation
@@ -21,5 +21,5 @@
21
21
  export { isAbsolutePath } from './abs-path.js';
22
22
  export { _resetCleoPlatformPathsCache, getCanonicalTemplatesTildePath, getCleoHome, getCleoPlatformPaths, getCleoSystemInfo, getCleoTemplatesTildePath, resolveLegacyCleoDir, } from './cleo-paths.js';
23
23
  export { createPlatformPathsResolver, } from './platform-paths.js';
24
- export { computeProjectHash, getCleoWorktreesRoot, resolveTaskWorktreePath, resolveWorktreeRootForHash, } from './worktree-paths.js';
24
+ export { computeProjectHash, getCleoWorktreesRoot, resolveTaskWorktreePath, resolveWorktreeIndexPath, resolveWorktreeRootForHash, } from './worktree-paths.js';
25
25
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EACL,4BAA4B,EAC5B,8BAA8B,EAC9B,WAAW,EACX,oBAAoB,EACpB,iBAAiB,EACjB,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,2BAA2B,GAI5B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACvB,0BAA0B,GAC3B,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EACL,4BAA4B,EAC5B,8BAA8B,EAC9B,WAAW,EACX,oBAAoB,EACpB,iBAAiB,EACjB,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,2BAA2B,GAI5B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACvB,wBAAwB,EACxB,0BAA0B,GAC3B,MAAM,qBAAqB,CAAC"}
@@ -6,7 +6,13 @@
6
6
  *
7
7
  * `cleoHome` is resolved via {@link getCleoHome} (env-paths + `CLEO_HOME` override).
8
8
  *
9
+ * Council verdict D009 (T9802 / SG-WORKTREE-CANON) added the hybrid sentinel
10
+ * index concept: a per-project JSON file at `<projectRoot>/.cleo/worktrees.json`
11
+ * that acts as the canonical registry of active worktrees for that project.
12
+ * Use {@link resolveWorktreeIndexPath} to get this path.
13
+ *
9
14
  * @task T1883
15
+ * @task T9802
10
16
  */
11
17
  /**
12
18
  * Compute a stable 16-character project hash from an absolute project root path.
@@ -61,4 +67,43 @@ export declare function resolveTaskWorktreePath(projectHash: string, taskId: str
61
67
  * @public
62
68
  */
63
69
  export declare function getCleoWorktreesRoot(): string;
70
+ /**
71
+ * Resolve the canonical SENTINEL INDEX path for active worktrees associated
72
+ * with a project — `<projectRoot>/.cleo/worktrees.json`.
73
+ *
74
+ * Council verdict D009 (T9802 / SG-WORKTREE-CANON) introduced the hybrid
75
+ * worktree-location model: worktree directories themselves live under the XDG
76
+ * data directory (see {@link resolveWorktreeRootForHash}), while a lightweight
77
+ * JSON index file lives **inside the project** at
78
+ * `<projectRoot>/.cleo/worktrees.json`. This sentinel acts as the canonical
79
+ * registry of active worktrees for that project and is:
80
+ *
81
+ * - **Tracked alongside project state** — lives in `.cleo/` (git-ignored),
82
+ * survives across `CLEO_HOME` changes and machine migrations.
83
+ * - **Machine-local** — absolute XDG paths inside the JSON are valid only on
84
+ * the machine that created them; consumers must handle stale entries.
85
+ * - **FILE not DIRECTORY** — the path ends in `.json`, never a directory.
86
+ * Create with `JSON.stringify` + `fs.writeFileSync`; read with
87
+ * `JSON.parse(fs.readFileSync(...))`.
88
+ *
89
+ * Invariant: the returned path is always
90
+ * `<projectRoot>/.cleo/worktrees.json` regardless of `CLEO_HOME`, XDG
91
+ * environment variables, or platform. It is the T9805 lifecycle hook's
92
+ * canonical write target.
93
+ *
94
+ * @param projectRoot - Absolute path to the project root (the directory that
95
+ * contains the `.cleo/` subdirectory for this project).
96
+ * @returns Absolute path to `<projectRoot>/.cleo/worktrees.json`.
97
+ *
98
+ * @example
99
+ * ```typescript
100
+ * import { resolveWorktreeIndexPath } from '@cleocode/paths';
101
+ *
102
+ * const indexPath = resolveWorktreeIndexPath('/mnt/projects/cleocode');
103
+ * // "/mnt/projects/cleocode/.cleo/worktrees.json"
104
+ * ```
105
+ *
106
+ * @public
107
+ */
108
+ export declare function resolveWorktreeIndexPath(projectRoot: string): string;
64
109
  //# sourceMappingURL=worktree-paths.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"worktree-paths.d.ts","sourceRoot":"","sources":["../src/worktree-paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA0BH;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAG7F;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,EACd,YAAY,CAAC,EAAE,MAAM,GACpB,MAAM,CAGR;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C"}
1
+ {"version":3,"file":"worktree-paths.d.ts","sourceRoot":"","sources":["../src/worktree-paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AA0BH;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAG7F;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,EACd,YAAY,CAAC,EAAE,MAAM,GACpB,MAAM,CAGR;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAEpE"}
@@ -6,7 +6,13 @@
6
6
  *
7
7
  * `cleoHome` is resolved via {@link getCleoHome} (env-paths + `CLEO_HOME` override).
8
8
  *
9
+ * Council verdict D009 (T9802 / SG-WORKTREE-CANON) added the hybrid sentinel
10
+ * index concept: a per-project JSON file at `<projectRoot>/.cleo/worktrees.json`
11
+ * that acts as the canonical registry of active worktrees for that project.
12
+ * Use {@link resolveWorktreeIndexPath} to get this path.
13
+ *
9
14
  * @task T1883
15
+ * @task T9802
10
16
  */
11
17
  import { createHash } from 'node:crypto';
12
18
  import { join } from 'node:path';
@@ -93,4 +99,45 @@ export function resolveTaskWorktreePath(projectHash, taskId, worktreeRoot) {
93
99
  export function getCleoWorktreesRoot() {
94
100
  return joinSegments(getCleoHome(), WORKTREES_SUBDIR);
95
101
  }
102
+ /**
103
+ * Resolve the canonical SENTINEL INDEX path for active worktrees associated
104
+ * with a project — `<projectRoot>/.cleo/worktrees.json`.
105
+ *
106
+ * Council verdict D009 (T9802 / SG-WORKTREE-CANON) introduced the hybrid
107
+ * worktree-location model: worktree directories themselves live under the XDG
108
+ * data directory (see {@link resolveWorktreeRootForHash}), while a lightweight
109
+ * JSON index file lives **inside the project** at
110
+ * `<projectRoot>/.cleo/worktrees.json`. This sentinel acts as the canonical
111
+ * registry of active worktrees for that project and is:
112
+ *
113
+ * - **Tracked alongside project state** — lives in `.cleo/` (git-ignored),
114
+ * survives across `CLEO_HOME` changes and machine migrations.
115
+ * - **Machine-local** — absolute XDG paths inside the JSON are valid only on
116
+ * the machine that created them; consumers must handle stale entries.
117
+ * - **FILE not DIRECTORY** — the path ends in `.json`, never a directory.
118
+ * Create with `JSON.stringify` + `fs.writeFileSync`; read with
119
+ * `JSON.parse(fs.readFileSync(...))`.
120
+ *
121
+ * Invariant: the returned path is always
122
+ * `<projectRoot>/.cleo/worktrees.json` regardless of `CLEO_HOME`, XDG
123
+ * environment variables, or platform. It is the T9805 lifecycle hook's
124
+ * canonical write target.
125
+ *
126
+ * @param projectRoot - Absolute path to the project root (the directory that
127
+ * contains the `.cleo/` subdirectory for this project).
128
+ * @returns Absolute path to `<projectRoot>/.cleo/worktrees.json`.
129
+ *
130
+ * @example
131
+ * ```typescript
132
+ * import { resolveWorktreeIndexPath } from '@cleocode/paths';
133
+ *
134
+ * const indexPath = resolveWorktreeIndexPath('/mnt/projects/cleocode');
135
+ * // "/mnt/projects/cleocode/.cleo/worktrees.json"
136
+ * ```
137
+ *
138
+ * @public
139
+ */
140
+ export function resolveWorktreeIndexPath(projectRoot) {
141
+ return joinSegments(projectRoot, '.cleo', 'worktrees.json');
142
+ }
96
143
  //# sourceMappingURL=worktree-paths.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"worktree-paths.js","sourceRoot":"","sources":["../src/worktree-paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,MAAM,gBAAgB,GAAG,WAAW,CAAC;AACrC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAE/B;;;;;;;;;GASG;AACH,SAAS,YAAY,CAAC,IAAY,EAAE,GAAG,KAAe;IACpD,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/C,OAAO,CAAC,IAAI,EAAE,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC;IACD,OAAO,IAAI,CAAC,IAAI,EAAE,GAAG,KAAK,CAAC,CAAC;AAC9B,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,kB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private": false,
5
5
  "type": "module",
6
6
  "description": "CLEO XDG/env-paths SSoT — createPlatformPathsResolver factory, cleo-bound platform paths, project hash + worktree root primitives, isAbsolutePath. Zero-dep leaf package consumed by core, worktree, brain, adapters, and caamp.",