@cleocode/worktree 2026.5.26 → 2026.5.28

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/paths.d.ts CHANGED
@@ -1,51 +1,18 @@
1
1
  /**
2
- * XDG-compliant worktree path resolution for @cleocode/worktree.
2
+ * Worktree path resolution for `@cleocode/worktree`.
3
+ *
4
+ * Re-exports the worktree primitives from `@cleocode/paths` (the XDG / env-paths
5
+ * SSoT) — `computeProjectHash`, `resolveWorktreeRootForHash`, and
6
+ * `resolveTaskWorktreePath`. Public API of this file is unchanged; the
7
+ * implementation now lives in the shared package.
3
8
  *
4
9
  * Canonical layout per D029:
5
10
  * Linux: ~/.local/share/cleo/worktrees/<projectHash>/<taskId>/
6
11
  * macOS: ~/Library/Application Support/cleo/worktrees/<projectHash>/<taskId>/
7
12
  * Windows: %LOCALAPPDATA%\cleo\Data\worktrees\<projectHash>\<taskId>\
8
13
  *
9
- * All path derivation flows through `resolveWorktreeRootForHash` — never
10
- * hardcode `~/.local/share/cleo`. Use env-paths + `CLEO_HOME` env override
11
- * matching the convention in `packages/core/src/system/platform-paths.ts`.
12
- *
13
- * @task T1161
14
- */
15
- /**
16
- * Compute a project hash from an absolute project root path.
17
- *
18
- * Produces a 16-character hex prefix of SHA-256 to stay consistent with
19
- * `packages/core/src/spawn/branch-lock.ts#resolveAgentWorktreeRoot`.
20
- *
21
- * @param projectRoot - Absolute path to the project root.
22
- * @returns 16-character lowercase hex string.
23
- */
24
- export declare function computeProjectHash(projectRoot: string): string;
25
- /**
26
- * Resolve the XDG worktrees root directory for a given project hash.
27
- *
28
- * Priority order:
29
- * 1. `worktreeRoot` arg (explicit override — for tests or config)
30
- * 2. `CLEO_HOME` env var (backward-compat with legacy installations)
31
- * 3. env-paths XDG data dir (platform-appropriate default)
32
- *
33
- * Result: `<dataDir>/worktrees/<projectHash>/`
34
- *
35
- * @param projectHash - 16-char project hash from {@link computeProjectHash}.
36
- * @param worktreeRoot - Optional override for the full worktree root.
37
- * @returns Absolute path to the project-scoped worktree root directory.
38
- */
39
- export declare function resolveWorktreeRootForHash(projectHash: string, worktreeRoot?: string): string;
40
- /**
41
- * Resolve the worktree directory for a specific task.
42
- *
43
- * Result: `<worktreeRoot>/<taskId>/`
44
- *
45
- * @param projectHash - 16-char project hash.
46
- * @param taskId - The task ID.
47
- * @param worktreeRoot - Optional override for the root directory.
48
- * @returns Absolute path to the task-specific worktree directory.
14
+ * @task T1161 (original)
15
+ * @task T1885 (migrated to @cleocode/paths SSoT)
49
16
  */
50
- export declare function resolveTaskWorktreePath(projectHash: string, taskId: string, worktreeRoot?: string): string;
17
+ export { computeProjectHash, resolveTaskWorktreePath, resolveWorktreeRootForHash, } from '@cleocode/paths';
51
18
  //# sourceMappingURL=paths.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAQH;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAM7F;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,EACd,YAAY,CAAC,EAAE,MAAM,GACpB,MAAM,CAER"}
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,0BAA0B,GAC3B,MAAM,iBAAiB,CAAC"}
package/dist/paths.js CHANGED
@@ -1,66 +1,18 @@
1
1
  /**
2
- * XDG-compliant worktree path resolution for @cleocode/worktree.
2
+ * Worktree path resolution for `@cleocode/worktree`.
3
+ *
4
+ * Re-exports the worktree primitives from `@cleocode/paths` (the XDG / env-paths
5
+ * SSoT) — `computeProjectHash`, `resolveWorktreeRootForHash`, and
6
+ * `resolveTaskWorktreePath`. Public API of this file is unchanged; the
7
+ * implementation now lives in the shared package.
3
8
  *
4
9
  * Canonical layout per D029:
5
10
  * Linux: ~/.local/share/cleo/worktrees/<projectHash>/<taskId>/
6
11
  * macOS: ~/Library/Application Support/cleo/worktrees/<projectHash>/<taskId>/
7
12
  * Windows: %LOCALAPPDATA%\cleo\Data\worktrees\<projectHash>\<taskId>\
8
13
  *
9
- * All path derivation flows through `resolveWorktreeRootForHash` — never
10
- * hardcode `~/.local/share/cleo`. Use env-paths + `CLEO_HOME` env override
11
- * matching the convention in `packages/core/src/system/platform-paths.ts`.
12
- *
13
- * @task T1161
14
- */
15
- import { createHash } from 'node:crypto';
16
- import { join } from 'node:path';
17
- import envPaths from 'env-paths';
18
- const APP_NAME = 'cleo';
19
- /**
20
- * Compute a project hash from an absolute project root path.
21
- *
22
- * Produces a 16-character hex prefix of SHA-256 to stay consistent with
23
- * `packages/core/src/spawn/branch-lock.ts#resolveAgentWorktreeRoot`.
24
- *
25
- * @param projectRoot - Absolute path to the project root.
26
- * @returns 16-character lowercase hex string.
27
- */
28
- export function computeProjectHash(projectRoot) {
29
- return createHash('sha256').update(projectRoot).digest('hex').slice(0, 16);
30
- }
31
- /**
32
- * Resolve the XDG worktrees root directory for a given project hash.
33
- *
34
- * Priority order:
35
- * 1. `worktreeRoot` arg (explicit override — for tests or config)
36
- * 2. `CLEO_HOME` env var (backward-compat with legacy installations)
37
- * 3. env-paths XDG data dir (platform-appropriate default)
38
- *
39
- * Result: `<dataDir>/worktrees/<projectHash>/`
40
- *
41
- * @param projectHash - 16-char project hash from {@link computeProjectHash}.
42
- * @param worktreeRoot - Optional override for the full worktree root.
43
- * @returns Absolute path to the project-scoped worktree root directory.
44
- */
45
- export function resolveWorktreeRootForHash(projectHash, worktreeRoot) {
46
- if (worktreeRoot)
47
- return worktreeRoot;
48
- const ep = envPaths(APP_NAME, { suffix: '' });
49
- // CLEO_HOME overrides the data path for backward compatibility.
50
- const dataDir = process.env['CLEO_HOME'] ?? ep.data;
51
- return join(dataDir, 'worktrees', projectHash);
52
- }
53
- /**
54
- * Resolve the worktree directory for a specific task.
55
- *
56
- * Result: `<worktreeRoot>/<taskId>/`
57
- *
58
- * @param projectHash - 16-char project hash.
59
- * @param taskId - The task ID.
60
- * @param worktreeRoot - Optional override for the root directory.
61
- * @returns Absolute path to the task-specific worktree directory.
14
+ * @task T1161 (original)
15
+ * @task T1885 (migrated to @cleocode/paths SSoT)
62
16
  */
63
- export function resolveTaskWorktreePath(projectHash, taskId, worktreeRoot) {
64
- return join(resolveWorktreeRootForHash(projectHash, worktreeRoot), taskId);
65
- }
17
+ export { computeProjectHash, resolveTaskWorktreePath, resolveWorktreeRootForHash, } from '@cleocode/paths';
66
18
  //# sourceMappingURL=paths.js.map
package/dist/paths.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"paths.js","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,QAAQ,MAAM,WAAW,CAAC;AAEjC,MAAM,QAAQ,GAAG,MAAM,CAAC;AAExB;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAAC,WAAmB;IACpD,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC7E,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,0BAA0B,CAAC,WAAmB,EAAE,YAAqB;IACnF,IAAI,YAAY;QAAE,OAAO,YAAY,CAAC;IACtC,MAAM,EAAE,GAAG,QAAQ,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;IAC9C,gEAAgE;IAChE,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC;IACpD,OAAO,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;AACjD,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,uBAAuB,CACrC,WAAmB,EACnB,MAAc,EACd,YAAqB;IAErB,OAAO,IAAI,CAAC,0BAA0B,CAAC,WAAW,EAAE,YAAY,CAAC,EAAE,MAAM,CAAC,CAAC;AAC7E,CAAC"}
1
+ {"version":3,"file":"paths.js","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,0BAA0B,GAC3B,MAAM,iBAAiB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"worktree-list.d.ts","sourceRoot":"","sources":["../src/worktree-list.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAMnF;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAEtF;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,OAAO,GAAE,oBAAyB,GAAG,iBAAiB,EAAE,CA2CrF;AAED;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAGnF"}
1
+ {"version":3,"file":"worktree-list.d.ts","sourceRoot":"","sources":["../src/worktree-list.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAOnF;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAEtF;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,OAAO,GAAE,oBAAyB,GAAG,iBAAiB,EAAE,CAyCrF;AAED;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAGnF"}
@@ -9,9 +9,7 @@
9
9
  import { execFileSync } from 'node:child_process';
10
10
  import { existsSync, readdirSync } from 'node:fs';
11
11
  import { join } from 'node:path';
12
- import envPaths from 'env-paths';
13
- import { computeProjectHash, resolveWorktreeRootForHash } from './paths.js';
14
- const APP_NAME = 'cleo';
12
+ import { computeProjectHash, getCleoWorktreesRoot, resolveWorktreeRootForHash, } from '@cleocode/paths';
15
13
  /**
16
14
  * Resolve the worktree root directory for a given project hash.
17
15
  *
@@ -34,9 +32,7 @@ export function resolveWorktreeRoot(projectHash, worktreeRoot) {
34
32
  * @returns Array of worktree entries.
35
33
  */
36
34
  export function listWorktrees(options = {}) {
37
- const ep = envPaths(APP_NAME, { suffix: '' });
38
- const dataDir = process.env['CLEO_HOME'] ?? ep.data;
39
- const worktreesBase = join(dataDir, 'worktrees');
35
+ const worktreesBase = getCleoWorktreesRoot();
40
36
  if (!existsSync(worktreesBase))
41
37
  return [];
42
38
  const entries = [];
@@ -1 +1 @@
1
- {"version":3,"file":"worktree-list.js","sourceRoot":"","sources":["../src/worktree-list.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;A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E,YAAY;gBAClB,MAAM;gBACN,MAAM;gBACN,WAAW,EAAE,IAAI;aAClB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,0BAA0B,CAAC,WAAmB;IAC5D,MAAM,WAAW,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAC;IACpD,OAAO,aAAa,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC;AACxC,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,qBAAqB,CAAC,YAAoB;IACjD,IAAI,CAAC;QACH,OAAO,YAAY,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,CAAC,EAAE;YACpF,QAAQ,EAAE,OAAO;YACjB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;SAChC,CAAC,CAAC,IAAI,EAAE,CAAC;IACZ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cleocode/worktree",
3
- "version": "2026.5.26",
3
+ "version": "2026.5.28",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Native CLEO worktree backend SDK — createWorktree, destroyWorktree, listWorktrees, pruneWorktrees with XDG path canon and declarative hooks (T1161)",
@@ -30,8 +30,8 @@
30
30
  "author": "CLEO Code <hello@cleocode.dev>",
31
31
  "license": "MIT",
32
32
  "dependencies": {
33
- "env-paths": "^4.0.0",
34
- "@cleocode/contracts": "2026.5.26"
33
+ "@cleocode/contracts": "2026.5.28",
34
+ "@cleocode/paths": "2026.5.28"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/node": "^24.3.0",