@cleocode/worktree 2026.5.100 → 2026.5.102
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/copy-on-write.d.ts +46 -16
- package/dist/copy-on-write.d.ts.map +1 -1
- package/dist/copy-on-write.js +40 -110
- package/dist/copy-on-write.js.map +1 -1
- package/dist/git.d.ts +57 -0
- package/dist/git.d.ts.map +1 -1
- package/dist/git.js +41 -0
- package/dist/git.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/napi-binding.d.ts +76 -0
- package/dist/napi-binding.d.ts.map +1 -0
- package/dist/napi-binding.js +43 -0
- package/dist/napi-binding.js.map +1 -0
- package/dist/worktree-create.d.ts +5 -3
- package/dist/worktree-create.d.ts.map +1 -1
- package/dist/worktree-create.js +21 -51
- package/dist/worktree-create.js.map +1 -1
- package/dist/worktree-destroy.d.ts.map +1 -1
- package/dist/worktree-destroy.js +16 -5
- package/dist/worktree-destroy.js.map +1 -1
- package/dist/worktree-include.d.ts +42 -29
- package/dist/worktree-include.d.ts.map +1 -1
- package/dist/worktree-include.js +121 -46
- package/dist/worktree-include.js.map +1 -1
- package/dist/worktree-list.d.ts +11 -2
- package/dist/worktree-list.d.ts.map +1 -1
- package/dist/worktree-list.js +55 -28
- package/dist/worktree-list.js.map +1 -1
- package/package.json +5 -4
- package/dist/compat.d.ts +0 -126
- package/dist/compat.d.ts.map +0 -1
- package/dist/compat.js +0 -163
- package/dist/compat.js.map +0 -1
package/dist/worktree-create.js
CHANGED
|
@@ -12,9 +12,8 @@
|
|
|
12
12
|
*
|
|
13
13
|
* @task T1161
|
|
14
14
|
*/
|
|
15
|
-
import { existsSync, mkdirSync,
|
|
15
|
+
import { existsSync, mkdirSync, rmSync } from 'node:fs';
|
|
16
16
|
import { join } from 'node:path';
|
|
17
|
-
import { copyPathsWithReflock } from './copy-on-write.js';
|
|
18
17
|
import { BRANCH_LOCK_ERROR_CODES } from '@cleocode/contracts';
|
|
19
18
|
import { getCleoWorktreesRoot } from '@cleocode/paths';
|
|
20
19
|
import { getGitRoot, gitSilent, gitSync, resolveHeadRef } from './git.js';
|
|
@@ -100,30 +99,6 @@ function applySpawnScope(worktreePath, scope) {
|
|
|
100
99
|
return null;
|
|
101
100
|
}
|
|
102
101
|
}
|
|
103
|
-
function isPathSpecifiedInInclude(patterns, targetPath) {
|
|
104
|
-
return patterns.some((p) => {
|
|
105
|
-
if (p.negated)
|
|
106
|
-
return false;
|
|
107
|
-
if (p.pattern === targetPath)
|
|
108
|
-
return true;
|
|
109
|
-
if (p.pattern.startsWith(`${targetPath}/`))
|
|
110
|
-
return true;
|
|
111
|
-
if (targetPath.startsWith(`${p.pattern}/`))
|
|
112
|
-
return true;
|
|
113
|
-
return false;
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
function isPackagesDistSpecifiedInInclude(patterns) {
|
|
117
|
-
return patterns.some((p) => {
|
|
118
|
-
if (p.negated)
|
|
119
|
-
return false;
|
|
120
|
-
if (p.pattern === 'packages/*/dist')
|
|
121
|
-
return true;
|
|
122
|
-
if (p.pattern.startsWith('packages/') && p.pattern.includes('/dist'))
|
|
123
|
-
return true;
|
|
124
|
-
return false;
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
102
|
/**
|
|
128
103
|
* Create a git worktree for an agent task.
|
|
129
104
|
*
|
|
@@ -135,9 +110,11 @@ function isPackagesDistSpecifiedInInclude(patterns) {
|
|
|
135
110
|
* Otherwise create a new branch via `git worktree add -b <branch> <path> <baseRef>`.
|
|
136
111
|
* 4. Optionally apply `git worktree lock` to prevent pruning.
|
|
137
112
|
* 5. Run declarative `post-create` hooks.
|
|
138
|
-
* 6. Apply `.cleo/worktree-include` glob patterns
|
|
139
|
-
*
|
|
140
|
-
*
|
|
113
|
+
* 6. Apply `.worktreeinclude` (or legacy `.cleo/worktree-include`) glob patterns —
|
|
114
|
+
* real ignore::gitignore matching is delegated to `@cleocode/worktree-napi`.
|
|
115
|
+
* 7. NO hardcoded bootstrap copy (T9982). Projects that need node_modules /
|
|
116
|
+
* packages/* /dist mirrored into the worktree MUST declare them in
|
|
117
|
+
* `.worktreeinclude` — the multi-language native include file.
|
|
141
118
|
* 8. Run declarative `post-start` hooks.
|
|
142
119
|
* 9. Build and return the {@link CreateWorktreeResult}.
|
|
143
120
|
*
|
|
@@ -262,33 +239,26 @@ export async function createWorktree(projectRoot, options) {
|
|
|
262
239
|
: null;
|
|
263
240
|
// Run post-create hooks before returning the handle.
|
|
264
241
|
const postCreateHookResults = await runWorktreeHooks(hooks, 'post-create', worktreePath);
|
|
265
|
-
// Apply .cleo/worktree-include patterns.
|
|
242
|
+
// Apply .worktreeinclude (or legacy .cleo/worktree-include) patterns.
|
|
243
|
+
// The matcher in @cleocode/worktree-napi uses real ignore::gitignore
|
|
244
|
+
// semantics — the prior existsSync-on-literal-pattern bug is gone.
|
|
245
|
+
//
|
|
246
|
+
// T9982 — REMOVED: hardcoded ['node_modules', 'packages/*/dist'] copy block.
|
|
247
|
+
// Projects MUST declare the paths they want mirrored into worktrees via
|
|
248
|
+
// .worktreeinclude. The default with no file is: copy nothing. This avoids
|
|
249
|
+
// the pnpm-monorepo-only 1.9 GB / 69k-file blast radius the hardcoded list
|
|
250
|
+
// imposed on every spawn (the 60s timeout root cause).
|
|
266
251
|
let appliedPatterns = [];
|
|
267
252
|
if (applyInclude) {
|
|
268
253
|
const patterns = loadWorktreeIncludePatterns(projectRoot);
|
|
269
254
|
appliedPatterns = applyIncludePatterns(patterns, projectRoot, worktreePath);
|
|
270
255
|
}
|
|
271
|
-
//
|
|
272
|
-
//
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
}
|
|
278
|
-
if (!isPackagesDistSpecifiedInInclude(includePatterns)) {
|
|
279
|
-
const packagesDir = join(projectRoot, 'packages');
|
|
280
|
-
if (existsSync(packagesDir)) {
|
|
281
|
-
for (const entry of readdirSync(packagesDir, { withFileTypes: true })) {
|
|
282
|
-
if (!entry.isDirectory())
|
|
283
|
-
continue;
|
|
284
|
-
const distRel = join('packages', entry.name, 'dist');
|
|
285
|
-
if (existsSync(join(projectRoot, distRel))) {
|
|
286
|
-
pathsToCopy.push(distRel);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
const { copied: copiedPaths, failed: failedPaths } = await copyPathsWithReflock(pathsToCopy, projectRoot, worktreePath);
|
|
256
|
+
// Bootstrap fields preserved for envelope compatibility — populated by the
|
|
257
|
+
// include-pattern symlink phase above. The copy-on-write hot path is no
|
|
258
|
+
// longer auto-invoked from createWorktree; callers that need explicit
|
|
259
|
+
// copying should call copyPathsWithReflock directly.
|
|
260
|
+
const copiedPaths = [];
|
|
261
|
+
const failedPaths = [];
|
|
292
262
|
// Run post-start hooks after copy-on-write bootstrap.
|
|
293
263
|
const postStartHookResults = await runWorktreeHooks(hooks, 'post-start', worktreePath);
|
|
294
264
|
// Build env vars for agent spawn.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worktree-create.js","sourceRoot":"","sources":["../src/worktree-create.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"worktree-create.js","sourceRoot":"","sources":["../src/worktree-create.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AA6BjC,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,E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sB;QACtB,YAAY;QACZ,SAAS,EAAE;YACT,WAAW;YACX,WAAW;YACX,WAAW,EAAE,oBAAoB;SAClC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worktree-destroy.d.ts","sourceRoot":"","sources":["../src/worktree-destroy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"worktree-destroy.d.ts","sourceRoot":"","sources":["../src/worktree-destroy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAOzF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,eAAe,CACnC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,qBAAqB,CAAC,CAsIhC"}
|
package/dist/worktree-destroy.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { existsSync, rmSync } from 'node:fs';
|
|
13
13
|
import { getGitRoot, gitSilent, gitSync } from './git.js';
|
|
14
|
+
import { destroyWorktree as napiDestroyWorktree } from './napi-binding.js';
|
|
14
15
|
import { computeProjectHash, resolveTaskWorktreePath } from './paths.js';
|
|
15
16
|
import { appendWorktreeAuditLog, removeWorktreeFromSentinelIndex } from './worktree-audit.js';
|
|
16
17
|
import { runWorktreeHooks } from './worktree-hooks.js';
|
|
@@ -89,20 +90,30 @@ export async function destroyWorktree(projectRoot, options) {
|
|
|
89
90
|
};
|
|
90
91
|
}
|
|
91
92
|
}
|
|
92
|
-
// Step 3: Unlock + remove the worktree
|
|
93
|
+
// Step 3: Unlock + remove the worktree (T9982 — git plumbing routed through
|
|
94
|
+
// @cleocode/worktree-napi → worktrunk-core::git_wt::destroy_worktree).
|
|
95
|
+
// The TS layer still owns the unlock + filesystem-rm fallback so a locked or
|
|
96
|
+
// partially-removed worktree can be force-cleaned without a second napi call.
|
|
93
97
|
if (existsSync(worktreePath)) {
|
|
94
98
|
gitSilent(['worktree', 'unlock', worktreePath], gitRoot);
|
|
95
|
-
|
|
96
|
-
|
|
99
|
+
try {
|
|
100
|
+
const result = napiDestroyWorktree({
|
|
101
|
+
repoRoot: gitRoot,
|
|
102
|
+
worktreePath,
|
|
103
|
+
force: true,
|
|
104
|
+
});
|
|
105
|
+
worktreeRemoved = result.removed;
|
|
97
106
|
}
|
|
98
|
-
|
|
107
|
+
catch (err) {
|
|
108
|
+
// napi reported failure — fall back to filesystem rm so the audit log
|
|
109
|
+
// still captures the cleanup attempt.
|
|
99
110
|
try {
|
|
100
111
|
rmSync(worktreePath, { recursive: true, force: true });
|
|
101
112
|
worktreeRemoved = true;
|
|
102
113
|
}
|
|
103
114
|
catch (err2) {
|
|
104
115
|
if (!error) {
|
|
105
|
-
error = `Failed to remove worktree:
|
|
116
|
+
error = `Failed to remove worktree: napi=${err instanceof Error ? err.message : String(err)}; fs=${err2 instanceof Error ? err2.message : String(err2)}`;
|
|
106
117
|
}
|
|
107
118
|
}
|
|
108
119
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worktree-destroy.js","sourceRoot":"","sources":["../src/worktree-destroy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAE7C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,EAAE,sBAAsB,EAAE,+BAA+B,EAAE,MAAM,qBAAqB,CAAC;AAC9F,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AA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AAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,gBAAgB,GAAG,eAAe,IAAI,CAAC,KAAK,CAAC;IAEnD,+DAA+D;IAC/D,sBAAsB,CAAC,WAAW,EAAE;QAClC,MAAM,EAAE,SAAS;QACjB,OAAO,EAAE,YAAY;QACrB,MAAM;QACN,MAAM;QACN,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,QAAQ;QAClC,OAAO,EAAE,gBAAgB;QACzB,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC1C,CAAC,CAAC;IAEH,mFAAmF;IACnF,IAAI,gBAAgB,EAAE,CAAC;QACrB,+BAA+B,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACnD,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC;AACtF,CAAC"}
|
|
@@ -1,36 +1,43 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* worktree-include feature per D030.
|
|
4
|
-
*
|
|
5
|
-
* The file `.cleo/worktree-include` in the project root contains glob patterns
|
|
6
|
-
* (one per line, `#`-prefixed comments stripped, blank lines ignored) that
|
|
7
|
-
* control which files/directories from the main project tree are symlinked
|
|
8
|
-
* into a newly created worktree.
|
|
9
|
-
*
|
|
10
|
-
* Lines prefixed with `!` are negated patterns (exclusions).
|
|
11
|
-
*
|
|
12
|
-
* Example `.cleo/worktree-include`:
|
|
13
|
-
* ```
|
|
14
|
-
* # Include pnpm store to avoid re-downloading in each worktree
|
|
15
|
-
* node_modules/.pnpm
|
|
16
|
-
* # Include shared config
|
|
17
|
-
* .env.local
|
|
18
|
-
* # Exclude secrets
|
|
19
|
-
* !.env.production
|
|
20
|
-
* ```
|
|
2
|
+
* Worktree include-pattern parsing and application.
|
|
21
3
|
*
|
|
4
|
+
* Reads the project's include patterns (gitignore-syntax) and creates symlinks
|
|
5
|
+
* from the worktree back to the project tree for matched paths. The actual
|
|
6
|
+
* pattern matching is delegated to `@cleocode/worktree-napi`'s
|
|
7
|
+
* `readWorktreeInclude` which uses `ignore::gitignore` under the hood — a real
|
|
8
|
+
* glob matcher that replaces the prior `existsSync`-on-literal-pattern bug.
|
|
9
|
+
*
|
|
10
|
+
* Canonical file: `<projectRoot>/.worktreeinclude` (multi-language native;
|
|
11
|
+
* matches the worktrunk-core spec, Claude Code Desktop, etc.).
|
|
12
|
+
*
|
|
13
|
+
* Legacy file: `<projectRoot>/.cleo/worktree-include` (1-cycle deprecation —
|
|
14
|
+
* still read when `.worktreeinclude` is absent, with a one-time stderr warning).
|
|
15
|
+
*
|
|
16
|
+
* @task T9982
|
|
22
17
|
* @task T1161
|
|
23
18
|
*/
|
|
24
19
|
import type { WorktreeIncludePattern } from '@cleocode/contracts';
|
|
25
20
|
/**
|
|
26
|
-
* Load and parse the
|
|
21
|
+
* Load and parse the project's worktree-include file.
|
|
22
|
+
*
|
|
23
|
+
* Resolution order (T9982):
|
|
24
|
+
* 1. `<projectRoot>/.worktreeinclude` — canonical multi-language native path
|
|
25
|
+
* consumed directly by `napi.readWorktreeInclude` (real ignore::gitignore
|
|
26
|
+
* matcher).
|
|
27
|
+
* 2. `<projectRoot>/.cleo/worktree-include` — 1-cycle deprecation fallback
|
|
28
|
+
* that copies the legacy file into a temp `.worktreeinclude` shim so the
|
|
29
|
+
* napi reader still applies real glob semantics. Emits a one-time
|
|
30
|
+
* `DeprecationWarning` via `process.emitWarning`.
|
|
27
31
|
*
|
|
28
|
-
* Returns an empty array if
|
|
29
|
-
*
|
|
30
|
-
*
|
|
32
|
+
* Returns an empty array if neither file exists. The napi binding handles
|
|
33
|
+
* blank lines, comments (`#`-prefixed), and negation (`!`-prefixed) per the
|
|
34
|
+
* gitignore spec.
|
|
31
35
|
*
|
|
32
36
|
* @param projectRoot - Absolute path to the project root.
|
|
33
|
-
* @returns Parsed include patterns, or empty array
|
|
37
|
+
* @returns Parsed include patterns, or empty array when no file is present.
|
|
38
|
+
*
|
|
39
|
+
* @task T9982
|
|
40
|
+
* @task T1161
|
|
34
41
|
*/
|
|
35
42
|
export declare function loadWorktreeIncludePatterns(projectRoot: string): WorktreeIncludePattern[];
|
|
36
43
|
/**
|
|
@@ -40,7 +47,7 @@ export declare function loadWorktreeIncludePatterns(projectRoot: string): Worktr
|
|
|
40
47
|
* Only non-negated patterns are symlinked. Negated patterns are recorded for
|
|
41
48
|
* audit purposes but do not cause any filesystem action.
|
|
42
49
|
*
|
|
43
|
-
* Symlinks are created as: `<worktreePath>/<pattern>` → `<projectRoot>/<pattern
|
|
50
|
+
* Symlinks are created as: `<worktreePath>/<pattern>` → `<projectRoot>/<pattern>`.
|
|
44
51
|
*
|
|
45
52
|
* Already-existing paths in the worktree are skipped (not overwritten) — git
|
|
46
53
|
* worktree add may have already created them.
|
|
@@ -48,15 +55,21 @@ export declare function loadWorktreeIncludePatterns(projectRoot: string): Worktr
|
|
|
48
55
|
* When the target path has a parent directory that does not yet exist in the
|
|
49
56
|
* worktree (e.g. `.vscode/settings.json` when `.vscode/` was never created),
|
|
50
57
|
* the parent is created with `mkdirSync({ recursive: true })` before the
|
|
51
|
-
* `symlinkSync` call. This prevents the `ENOENT` error
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
58
|
+
* `symlinkSync` call. This prevents the `ENOENT` error reported in T9807.
|
|
59
|
+
*
|
|
60
|
+
* The pattern-evaluation strategy stays in TS for now because each pattern
|
|
61
|
+
* needs an existence check against the project tree + a per-pattern symlink —
|
|
62
|
+
* a thin wrapper that defers to the napi matcher would not measurably improve
|
|
63
|
+
* the hot path here (pattern lists are short and the work is dominated by
|
|
64
|
+
* filesystem syscalls, not regex matching).
|
|
55
65
|
*
|
|
56
66
|
* @param patterns - Parsed include patterns from {@link loadWorktreeIncludePatterns}.
|
|
57
67
|
* @param projectRoot - Absolute path to the project root (symlink target base).
|
|
58
68
|
* @param worktreePath - Absolute path to the worktree directory.
|
|
59
69
|
* @returns Array of patterns that were successfully symlinked.
|
|
70
|
+
*
|
|
71
|
+
* @task T9982
|
|
72
|
+
* @task T9807
|
|
60
73
|
*/
|
|
61
74
|
export declare function applyIncludePatterns(patterns: readonly WorktreeIncludePattern[], projectRoot: string, worktreePath: string): WorktreeIncludePattern[];
|
|
62
75
|
//# sourceMappingURL=worktree-include.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worktree-include.d.ts","sourceRoot":"","sources":["../src/worktree-include.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"worktree-include.d.ts","sourceRoot":"","sources":["../src/worktree-include.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAYH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AA0BlE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,MAAM,GAAG,sBAAsB,EAAE,CAazF;AA0DD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,SAAS,sBAAsB,EAAE,EAC3C,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,GACnB,sBAAsB,EAAE,CAyC1B"}
|
package/dist/worktree-include.js
CHANGED
|
@@ -1,57 +1,126 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* worktree-include feature per D030.
|
|
4
|
-
*
|
|
5
|
-
* The file `.cleo/worktree-include` in the project root contains glob patterns
|
|
6
|
-
* (one per line, `#`-prefixed comments stripped, blank lines ignored) that
|
|
7
|
-
* control which files/directories from the main project tree are symlinked
|
|
8
|
-
* into a newly created worktree.
|
|
9
|
-
*
|
|
10
|
-
* Lines prefixed with `!` are negated patterns (exclusions).
|
|
11
|
-
*
|
|
12
|
-
* Example `.cleo/worktree-include`:
|
|
13
|
-
* ```
|
|
14
|
-
* # Include pnpm store to avoid re-downloading in each worktree
|
|
15
|
-
* node_modules/.pnpm
|
|
16
|
-
* # Include shared config
|
|
17
|
-
* .env.local
|
|
18
|
-
* # Exclude secrets
|
|
19
|
-
* !.env.production
|
|
20
|
-
* ```
|
|
2
|
+
* Worktree include-pattern parsing and application.
|
|
21
3
|
*
|
|
4
|
+
* Reads the project's include patterns (gitignore-syntax) and creates symlinks
|
|
5
|
+
* from the worktree back to the project tree for matched paths. The actual
|
|
6
|
+
* pattern matching is delegated to `@cleocode/worktree-napi`'s
|
|
7
|
+
* `readWorktreeInclude` which uses `ignore::gitignore` under the hood — a real
|
|
8
|
+
* glob matcher that replaces the prior `existsSync`-on-literal-pattern bug.
|
|
9
|
+
*
|
|
10
|
+
* Canonical file: `<projectRoot>/.worktreeinclude` (multi-language native;
|
|
11
|
+
* matches the worktrunk-core spec, Claude Code Desktop, etc.).
|
|
12
|
+
*
|
|
13
|
+
* Legacy file: `<projectRoot>/.cleo/worktree-include` (1-cycle deprecation —
|
|
14
|
+
* still read when `.worktreeinclude` is absent, with a one-time stderr warning).
|
|
15
|
+
*
|
|
16
|
+
* @task T9982
|
|
22
17
|
* @task T1161
|
|
23
18
|
*/
|
|
24
|
-
import { existsSync, mkdirSync, readFileSync, symlinkSync } from 'node:fs';
|
|
19
|
+
import { existsSync, mkdirSync, mkdtempSync, readFileSync, symlinkSync, writeFileSync, } from 'node:fs';
|
|
20
|
+
import { tmpdir } from 'node:os';
|
|
25
21
|
import { dirname, join, resolve } from 'node:path';
|
|
26
|
-
|
|
22
|
+
import { readWorktreeInclude as napiReadWorktreeInclude } from './napi-binding.js';
|
|
23
|
+
const CANONICAL_INCLUDE_FILE = '.worktreeinclude';
|
|
24
|
+
const LEGACY_INCLUDE_FILE_DIR = '.cleo';
|
|
25
|
+
const LEGACY_INCLUDE_FILE_NAME = 'worktree-include';
|
|
26
|
+
let legacyWarningEmitted = false;
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* Emit a one-time deprecation warning when the legacy path is in use.
|
|
29
29
|
*
|
|
30
|
-
*
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
function emitLegacyWarning(legacyPath) {
|
|
33
|
+
if (legacyWarningEmitted)
|
|
34
|
+
return;
|
|
35
|
+
legacyWarningEmitted = true;
|
|
36
|
+
process.emitWarning(`[@cleocode/worktree] Found legacy "${legacyPath}". Migrate to ` +
|
|
37
|
+
`".worktreeinclude" at the project root — run \`cleo doctor --migrate-worktree-include\` ` +
|
|
38
|
+
`for an automated migration. The legacy path will be removed in a future release.`, 'DeprecationWarning', 'CLEO_WORKTREE_INCLUDE_LEGACY');
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Load and parse the project's worktree-include file.
|
|
42
|
+
*
|
|
43
|
+
* Resolution order (T9982):
|
|
44
|
+
* 1. `<projectRoot>/.worktreeinclude` — canonical multi-language native path
|
|
45
|
+
* consumed directly by `napi.readWorktreeInclude` (real ignore::gitignore
|
|
46
|
+
* matcher).
|
|
47
|
+
* 2. `<projectRoot>/.cleo/worktree-include` — 1-cycle deprecation fallback
|
|
48
|
+
* that copies the legacy file into a temp `.worktreeinclude` shim so the
|
|
49
|
+
* napi reader still applies real glob semantics. Emits a one-time
|
|
50
|
+
* `DeprecationWarning` via `process.emitWarning`.
|
|
51
|
+
*
|
|
52
|
+
* Returns an empty array if neither file exists. The napi binding handles
|
|
53
|
+
* blank lines, comments (`#`-prefixed), and negation (`!`-prefixed) per the
|
|
54
|
+
* gitignore spec.
|
|
33
55
|
*
|
|
34
56
|
* @param projectRoot - Absolute path to the project root.
|
|
35
|
-
* @returns Parsed include patterns, or empty array
|
|
57
|
+
* @returns Parsed include patterns, or empty array when no file is present.
|
|
58
|
+
*
|
|
59
|
+
* @task T9982
|
|
60
|
+
* @task T1161
|
|
36
61
|
*/
|
|
37
62
|
export function loadWorktreeIncludePatterns(projectRoot) {
|
|
38
|
-
const
|
|
39
|
-
if (
|
|
63
|
+
const canonicalPath = join(projectRoot, CANONICAL_INCLUDE_FILE);
|
|
64
|
+
if (existsSync(canonicalPath)) {
|
|
65
|
+
return readPatternsViaNapi(projectRoot);
|
|
66
|
+
}
|
|
67
|
+
const legacyPath = join(projectRoot, LEGACY_INCLUDE_FILE_DIR, LEGACY_INCLUDE_FILE_NAME);
|
|
68
|
+
if (existsSync(legacyPath)) {
|
|
69
|
+
emitLegacyWarning(legacyPath);
|
|
70
|
+
return readPatternsFromLegacyShim(legacyPath);
|
|
71
|
+
}
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Read patterns via the canonical `.worktreeinclude` path through napi.
|
|
76
|
+
*
|
|
77
|
+
* Wraps `napi.readWorktreeInclude` and maps the FFI shape (camelCase already
|
|
78
|
+
* applied by napi-derive) into the existing TS {@link WorktreeIncludePattern}
|
|
79
|
+
* surface so existing callers compile unchanged.
|
|
80
|
+
*
|
|
81
|
+
* @internal
|
|
82
|
+
*/
|
|
83
|
+
function readPatternsViaNapi(repoRoot) {
|
|
84
|
+
try {
|
|
85
|
+
const napiPatterns = napiReadWorktreeInclude(repoRoot);
|
|
86
|
+
return napiPatterns.map((p) => ({
|
|
87
|
+
pattern: p.pattern,
|
|
88
|
+
negated: p.isNegation,
|
|
89
|
+
}));
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
process.stderr.write(`[worktree-include] napi.readWorktreeInclude failed: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
40
93
|
return [];
|
|
41
|
-
const raw = readFileSync(filePath, 'utf-8');
|
|
42
|
-
const patterns = [];
|
|
43
|
-
for (const line of raw.split('\n')) {
|
|
44
|
-
const trimmed = line.trim();
|
|
45
|
-
// Skip blank lines and comments
|
|
46
|
-
if (!trimmed || trimmed.startsWith('#'))
|
|
47
|
-
continue;
|
|
48
|
-
const negated = trimmed.startsWith('!');
|
|
49
|
-
const pattern = negated ? trimmed.slice(1).trim() : trimmed;
|
|
50
|
-
if (pattern) {
|
|
51
|
-
patterns.push({ pattern, negated });
|
|
52
|
-
}
|
|
53
94
|
}
|
|
54
|
-
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Stage the legacy `.cleo/worktree-include` file into a temp `.worktreeinclude`
|
|
98
|
+
* directory and feed it to the napi reader.
|
|
99
|
+
*
|
|
100
|
+
* Keeps the deprecation strictly behind a 1-cycle bridge — the legacy text
|
|
101
|
+
* format is unchanged, and the gitignore matcher in `worktrunk-core` does the
|
|
102
|
+
* real work.
|
|
103
|
+
*
|
|
104
|
+
* @internal
|
|
105
|
+
*/
|
|
106
|
+
function readPatternsFromLegacyShim(legacyPath) {
|
|
107
|
+
let raw;
|
|
108
|
+
try {
|
|
109
|
+
raw = readFileSync(legacyPath, 'utf-8');
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
return [];
|
|
113
|
+
}
|
|
114
|
+
let shimDir;
|
|
115
|
+
try {
|
|
116
|
+
shimDir = mkdtempSync(join(tmpdir(), 'cleo-worktree-include-shim-'));
|
|
117
|
+
writeFileSync(join(shimDir, CANONICAL_INCLUDE_FILE), raw);
|
|
118
|
+
}
|
|
119
|
+
catch (err) {
|
|
120
|
+
process.stderr.write(`[worktree-include] failed to stage legacy file via shim: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
121
|
+
return [];
|
|
122
|
+
}
|
|
123
|
+
return readPatternsViaNapi(shimDir);
|
|
55
124
|
}
|
|
56
125
|
/**
|
|
57
126
|
* Apply include patterns to a newly created worktree by creating symlinks
|
|
@@ -60,7 +129,7 @@ export function loadWorktreeIncludePatterns(projectRoot) {
|
|
|
60
129
|
* Only non-negated patterns are symlinked. Negated patterns are recorded for
|
|
61
130
|
* audit purposes but do not cause any filesystem action.
|
|
62
131
|
*
|
|
63
|
-
* Symlinks are created as: `<worktreePath>/<pattern>` → `<projectRoot>/<pattern
|
|
132
|
+
* Symlinks are created as: `<worktreePath>/<pattern>` → `<projectRoot>/<pattern>`.
|
|
64
133
|
*
|
|
65
134
|
* Already-existing paths in the worktree are skipped (not overwritten) — git
|
|
66
135
|
* worktree add may have already created them.
|
|
@@ -68,15 +137,21 @@ export function loadWorktreeIncludePatterns(projectRoot) {
|
|
|
68
137
|
* When the target path has a parent directory that does not yet exist in the
|
|
69
138
|
* worktree (e.g. `.vscode/settings.json` when `.vscode/` was never created),
|
|
70
139
|
* the parent is created with `mkdirSync({ recursive: true })` before the
|
|
71
|
-
* `symlinkSync` call. This prevents the `ENOENT` error
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
140
|
+
* `symlinkSync` call. This prevents the `ENOENT` error reported in T9807.
|
|
141
|
+
*
|
|
142
|
+
* The pattern-evaluation strategy stays in TS for now because each pattern
|
|
143
|
+
* needs an existence check against the project tree + a per-pattern symlink —
|
|
144
|
+
* a thin wrapper that defers to the napi matcher would not measurably improve
|
|
145
|
+
* the hot path here (pattern lists are short and the work is dominated by
|
|
146
|
+
* filesystem syscalls, not regex matching).
|
|
75
147
|
*
|
|
76
148
|
* @param patterns - Parsed include patterns from {@link loadWorktreeIncludePatterns}.
|
|
77
149
|
* @param projectRoot - Absolute path to the project root (symlink target base).
|
|
78
150
|
* @param worktreePath - Absolute path to the worktree directory.
|
|
79
151
|
* @returns Array of patterns that were successfully symlinked.
|
|
152
|
+
*
|
|
153
|
+
* @task T9982
|
|
154
|
+
* @task T9807
|
|
80
155
|
*/
|
|
81
156
|
export function applyIncludePatterns(patterns, projectRoot, worktreePath) {
|
|
82
157
|
const applied = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worktree-include.js","sourceRoot":"","sources":["../src/worktree-include.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"worktree-include.js","sourceRoot":"","sources":["../src/worktree-include.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,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"}
|
package/dist/worktree-list.d.ts
CHANGED
|
@@ -2,8 +2,14 @@
|
|
|
2
2
|
* Worktree listing operations for @cleocode/worktree.
|
|
3
3
|
*
|
|
4
4
|
* `listWorktrees` and `listWorktreesByProjectRoot` scan the CLEO XDG worktrees
|
|
5
|
-
* directory
|
|
5
|
+
* directory and use `@cleocode/worktree-napi` (`listWorktrees` →
|
|
6
|
+
* `worktrunk_core::git_wt::list_worktrees`) to look up per-entry branch info
|
|
7
|
+
* in a single Rust call — the prior N+1 `git rev-parse` loop is gone.
|
|
6
8
|
*
|
|
9
|
+
* Classification of each entry (status / stale / orphan / owningTask) stays in
|
|
10
|
+
* TS because it consumes the tasks DB and other CLEO-specific state.
|
|
11
|
+
*
|
|
12
|
+
* @task T9982
|
|
7
13
|
* @task T1161
|
|
8
14
|
*/
|
|
9
15
|
import type { ListWorktreesOptions, WorktreeListEntry } from '@cleocode/contracts';
|
|
@@ -21,10 +27,13 @@ export declare function resolveWorktreeRoot(projectHash: string, worktreeRoot?:
|
|
|
21
27
|
* List all active CLEO worktrees scoped to a specific project hash.
|
|
22
28
|
*
|
|
23
29
|
* Scans the XDG worktrees filesystem directory. Entries without a valid
|
|
24
|
-
* worktree path on disk are omitted.
|
|
30
|
+
* worktree path on disk are omitted. Branch lookup is performed once per call
|
|
31
|
+
* via `napi.listWorktrees` — no per-entry `git rev-parse` invocation.
|
|
25
32
|
*
|
|
26
33
|
* @param options - Listing options including optional project hash filter.
|
|
27
34
|
* @returns Array of worktree entries.
|
|
35
|
+
*
|
|
36
|
+
* @task T9982
|
|
28
37
|
*/
|
|
29
38
|
export declare function listWorktrees(options?: ListWorktreesOptions): WorktreeListEntry[];
|
|
30
39
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worktree-list.d.ts","sourceRoot":"","sources":["../src/worktree-list.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"worktree-list.d.ts","sourceRoot":"","sources":["../src/worktree-list.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AASnF;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAEtF;AA0BD;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,OAAO,GAAE,oBAAyB,GAAG,iBAAiB,EAAE,CA0DrF;AAED;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAGnF"}
|