@cleocode/worktree 2026.5.99 → 2026.5.101
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/copy-on-write.d.ts
CHANGED
|
@@ -1,36 +1,66 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copy-on-write file utility for `@cleocode/worktree`.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* (
|
|
4
|
+
* Thin TS wrapper around `@cleocode/worktree-napi`'s parallel reflink-aware
|
|
5
|
+
* copy primitive ({@link copyPathsParallel}). Replaces the prior 150-LOC
|
|
6
|
+
* sequential `execFile('cp')` loop — the worktree bootstrap is now a single
|
|
7
|
+
* Rust call backed by a 4-thread rayon pool with reflink probing.
|
|
6
8
|
*
|
|
7
|
-
* Platform support
|
|
8
|
-
* - macOS (darwin): APFS clonefile via `cp -
|
|
9
|
-
* - Linux: btrfs / xfs / zfs reflink via `cp
|
|
10
|
-
* - Windows:
|
|
11
|
-
* regular recursive copy for directories
|
|
9
|
+
* Platform support inherited from `worktrunk-core::copy::copy_leaf`:
|
|
10
|
+
* - macOS (darwin): APFS clonefile via `cp -c`
|
|
11
|
+
* - Linux: btrfs / xfs / zfs reflink via `cp --reflink=auto`
|
|
12
|
+
* - Windows: regular copyFile with FICLONE on supported FS
|
|
12
13
|
*
|
|
14
|
+
* @task T9982
|
|
13
15
|
* @task T1161
|
|
14
16
|
*/
|
|
15
17
|
/**
|
|
16
|
-
*
|
|
17
|
-
* copy-on-write when available.
|
|
18
|
+
* Optional knobs for {@link copyPathsWithReflock}.
|
|
18
19
|
*
|
|
19
|
-
*
|
|
20
|
-
* the
|
|
20
|
+
* Mirrors the napi `CopyOpts` shape with TS-friendly defaults. The `rootGuard`
|
|
21
|
+
* option keeps every destination resolution inside the supplied root — the
|
|
22
|
+
* canonical XDG worktree path is the recommended value for production callers.
|
|
21
23
|
*
|
|
22
|
-
*
|
|
23
|
-
|
|
24
|
+
* @task T9982
|
|
25
|
+
*/
|
|
26
|
+
export interface CopyPathsOptions {
|
|
27
|
+
/** Overwrite existing entries at the destination. Default `false`. */
|
|
28
|
+
force?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* When set, every destination must resolve inside this root. Used as a
|
|
31
|
+
* safety belt against path traversal in the supplied `paths` list.
|
|
32
|
+
*/
|
|
33
|
+
rootGuard?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Reserved for future use — symlinks are always followed by the underlying
|
|
36
|
+
* `worktrunk_core::copy::copy_leaf` today. Default `true`.
|
|
37
|
+
*/
|
|
38
|
+
includeSymlinks?: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Copy multiple paths from a source directory to a target directory using
|
|
42
|
+
* copy-on-write when available, in parallel via the Rust binding.
|
|
24
43
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
44
|
+
* Each entry in `paths` is treated as relative to `sourceDir` and copied to
|
|
45
|
+
* the corresponding location under `targetDir`. Missing source paths or paths
|
|
46
|
+
* that already exist at the destination are silently skipped by
|
|
47
|
+
* `worktrunk-core` — see the {@link CopyPathsResult.failed} list for true
|
|
48
|
+
* failures.
|
|
49
|
+
*
|
|
50
|
+
* The synchronous-looking call boundary hides 4-thread parallelism behind the
|
|
51
|
+
* napi layer; the `Promise` wrapper preserves the legacy async signature for
|
|
52
|
+
* existing TS callers.
|
|
27
53
|
*
|
|
28
54
|
* @param paths - Array of relative paths to copy.
|
|
29
55
|
* @param sourceDir - Absolute path to the source directory.
|
|
30
56
|
* @param targetDir - Absolute path to the target directory.
|
|
57
|
+
* @param options - Optional copy-options forwarded to the napi layer.
|
|
31
58
|
* @returns Object with arrays of successfully copied and failed paths.
|
|
59
|
+
*
|
|
60
|
+
* @task T9982
|
|
61
|
+
* @task T1161
|
|
32
62
|
*/
|
|
33
|
-
export declare function copyPathsWithReflock(paths: string[], sourceDir: string, targetDir: string): Promise<{
|
|
63
|
+
export declare function copyPathsWithReflock(paths: string[], sourceDir: string, targetDir: string, options?: CopyPathsOptions): Promise<{
|
|
34
64
|
copied: string[];
|
|
35
65
|
failed: string[];
|
|
36
66
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copy-on-write.d.ts","sourceRoot":"","sources":["../src/copy-on-write.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"copy-on-write.d.ts","sourceRoot":"","sources":["../src/copy-on-write.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH;;;;;;;;GAQG;AACH,MAAM,WAAW,gBAAgB;IAC/B,sEAAsE;IACtE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,MAAM,EAAE,EACf,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAwBjD"}
|
package/dist/copy-on-write.js
CHANGED
|
@@ -1,133 +1,63 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copy-on-write file utility for `@cleocode/worktree`.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* (
|
|
4
|
+
* Thin TS wrapper around `@cleocode/worktree-napi`'s parallel reflink-aware
|
|
5
|
+
* copy primitive ({@link copyPathsParallel}). Replaces the prior 150-LOC
|
|
6
|
+
* sequential `execFile('cp')` loop — the worktree bootstrap is now a single
|
|
7
|
+
* Rust call backed by a 4-thread rayon pool with reflink probing.
|
|
6
8
|
*
|
|
7
|
-
* Platform support
|
|
8
|
-
* - macOS (darwin): APFS clonefile via `cp -
|
|
9
|
-
* - Linux: btrfs / xfs / zfs reflink via `cp
|
|
10
|
-
* - Windows:
|
|
11
|
-
* regular recursive copy for directories
|
|
9
|
+
* Platform support inherited from `worktrunk-core::copy::copy_leaf`:
|
|
10
|
+
* - macOS (darwin): APFS clonefile via `cp -c`
|
|
11
|
+
* - Linux: btrfs / xfs / zfs reflink via `cp --reflink=auto`
|
|
12
|
+
* - Windows: regular copyFile with FICLONE on supported FS
|
|
12
13
|
*
|
|
14
|
+
* @task T9982
|
|
13
15
|
* @task T1161
|
|
14
16
|
*/
|
|
15
|
-
import {
|
|
16
|
-
import { constants, existsSync, promises as fs, mkdirSync } from 'node:fs';
|
|
17
|
-
import { dirname, join } from 'node:path';
|
|
18
|
-
import { promisify } from 'node:util';
|
|
19
|
-
import { DEFAULT_GIT_TIMEOUT_MS } from './git.js';
|
|
20
|
-
const execFileAsync = promisify(execFile);
|
|
21
|
-
/**
|
|
22
|
-
* Default per-copy subprocess timeout in milliseconds (T9545).
|
|
23
|
-
*
|
|
24
|
-
* Reuses {@link DEFAULT_GIT_TIMEOUT_MS} so spawn-pipeline subprocess budgets
|
|
25
|
-
* stay aligned across git and `cp` invocations.
|
|
26
|
-
*/
|
|
27
|
-
const DEFAULT_COPY_TIMEOUT_MS = DEFAULT_GIT_TIMEOUT_MS;
|
|
17
|
+
import { copyPathsParallel } from './napi-binding.js';
|
|
28
18
|
/**
|
|
29
19
|
* Copy multiple paths from a source directory to a target directory using
|
|
30
|
-
* copy-on-write when available.
|
|
20
|
+
* copy-on-write when available, in parallel via the Rust binding.
|
|
31
21
|
*
|
|
32
|
-
* Each
|
|
33
|
-
* the corresponding location under `targetDir`.
|
|
22
|
+
* Each entry in `paths` is treated as relative to `sourceDir` and copied to
|
|
23
|
+
* the corresponding location under `targetDir`. Missing source paths or paths
|
|
24
|
+
* that already exist at the destination are silently skipped by
|
|
25
|
+
* `worktrunk-core` — see the {@link CopyPathsResult.failed} list for true
|
|
26
|
+
* failures.
|
|
34
27
|
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* If a copy-on-write attempt fails, a regular recursive copy is attempted
|
|
39
|
-
* as fallback. If that also fails, the path is recorded in `failed`.
|
|
28
|
+
* The synchronous-looking call boundary hides 4-thread parallelism behind the
|
|
29
|
+
* napi layer; the `Promise` wrapper preserves the legacy async signature for
|
|
30
|
+
* existing TS callers.
|
|
40
31
|
*
|
|
41
32
|
* @param paths - Array of relative paths to copy.
|
|
42
33
|
* @param sourceDir - Absolute path to the source directory.
|
|
43
34
|
* @param targetDir - Absolute path to the target directory.
|
|
35
|
+
* @param options - Optional copy-options forwarded to the napi layer.
|
|
44
36
|
* @returns Object with arrays of successfully copied and failed paths.
|
|
45
|
-
*/
|
|
46
|
-
export async function copyPathsWithReflock(paths, sourceDir, targetDir) {
|
|
47
|
-
const copied = [];
|
|
48
|
-
const failed = [];
|
|
49
|
-
for (const relativePath of paths) {
|
|
50
|
-
const sourcePath = join(sourceDir, relativePath);
|
|
51
|
-
const targetPath = join(targetDir, relativePath);
|
|
52
|
-
if (!existsSync(sourcePath)) {
|
|
53
|
-
process.stderr.write(`[copy-on-write] skipping missing source: ${sourcePath}\n`);
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
if (existsSync(targetPath)) {
|
|
57
|
-
continue;
|
|
58
|
-
}
|
|
59
|
-
try {
|
|
60
|
-
mkdirSync(dirname(targetPath), { recursive: true });
|
|
61
|
-
}
|
|
62
|
-
catch {
|
|
63
|
-
process.stderr.write(`[copy-on-write] failed to create parent directory for: ${targetPath}\n`);
|
|
64
|
-
failed.push(relativePath);
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
try {
|
|
68
|
-
await copyWithReflock(sourcePath, targetPath);
|
|
69
|
-
copied.push(relativePath);
|
|
70
|
-
}
|
|
71
|
-
catch {
|
|
72
|
-
try {
|
|
73
|
-
await copyRegular(sourcePath, targetPath);
|
|
74
|
-
copied.push(relativePath);
|
|
75
|
-
}
|
|
76
|
-
catch {
|
|
77
|
-
failed.push(relativePath);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return { copied, failed };
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Attempt a copy-on-write copy from source to target.
|
|
85
37
|
*
|
|
86
|
-
* @
|
|
87
|
-
* @
|
|
88
|
-
* @throws Error if the copy operation fails or the platform is unsupported.
|
|
38
|
+
* @task T9982
|
|
39
|
+
* @task T1161
|
|
89
40
|
*/
|
|
90
|
-
async function
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
41
|
+
export async function copyPathsWithReflock(paths, sourceDir, targetDir, options = {}) {
|
|
42
|
+
if (paths.length === 0)
|
|
43
|
+
return { copied: [], failed: [] };
|
|
44
|
+
let result;
|
|
45
|
+
try {
|
|
46
|
+
result = copyPathsParallel(sourceDir, targetDir, paths, {
|
|
47
|
+
force: options.force ?? false,
|
|
48
|
+
...(options.rootGuard !== undefined ? { rootGuard: options.rootGuard } : {}),
|
|
49
|
+
includeSymlinks: options.includeSymlinks ?? true,
|
|
97
50
|
});
|
|
98
|
-
return;
|
|
99
51
|
}
|
|
100
|
-
|
|
101
|
-
//
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
if (platform === 'win32') {
|
|
108
|
-
const stat = await fs.stat(sourcePath);
|
|
109
|
-
if (stat.isDirectory()) {
|
|
110
|
-
throw new Error('Windows directories do not support copy-on-write');
|
|
111
|
-
}
|
|
112
|
-
await fs.copyFile(sourcePath, targetPath, constants.COPYFILE_FICLONE);
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
throw new Error(`Unsupported platform: ${platform}`);
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Perform a regular recursive copy as fallback.
|
|
119
|
-
*
|
|
120
|
-
* @param sourcePath - Absolute path to the source file or directory.
|
|
121
|
-
* @param targetPath - Absolute path to the target location.
|
|
122
|
-
* @throws Error if the copy operation fails.
|
|
123
|
-
*/
|
|
124
|
-
async function copyRegular(sourcePath, targetPath) {
|
|
125
|
-
const stat = await fs.stat(sourcePath);
|
|
126
|
-
if (stat.isDirectory()) {
|
|
127
|
-
await fs.cp(sourcePath, targetPath, { recursive: true });
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
await fs.copyFile(sourcePath, targetPath);
|
|
52
|
+
catch (err) {
|
|
53
|
+
// A whole-batch failure (matcher / IO error before any leaf was tried)
|
|
54
|
+
// reports every path as failed so callers can recover or audit.
|
|
55
|
+
process.stderr.write(`[copy-on-write] napi.copyPathsParallel failed: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
56
|
+
return { copied: [], failed: [...paths] };
|
|
131
57
|
}
|
|
58
|
+
const failedSet = new Set(result.failedPaths);
|
|
59
|
+
const copied = paths.filter((p) => !failedSet.has(p));
|
|
60
|
+
const failed = paths.filter((p) => failedSet.has(p));
|
|
61
|
+
return { copied, failed };
|
|
132
62
|
}
|
|
133
63
|
//# sourceMappingURL=copy-on-write.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copy-on-write.js","sourceRoot":"","sources":["../src/copy-on-write.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"copy-on-write.js","sourceRoot":"","sources":["../src/copy-on-write.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAuB,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AA0B3E;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,KAAe,EACf,SAAiB,EACjB,SAAiB,EACjB,UAA4B,EAAE;IAE9B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;IAE1D,IAAI,MAAsB,CAAC;IAC3B,IAAI,CAAC;QACH,MAAM,GAAG,iBAAiB,CAAC,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE;YACtD,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,KAAK;YAC7B,GAAG,CAAC,OAAO,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5E,eAAe,EAAE,OAAO,CAAC,eAAe,IAAI,IAAI;SACjD,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,uEAAuE;QACvE,gEAAgE;QAChE,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,kDAAkD,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CACvG,CAAC;QACF,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC;IAC5C,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAC9C,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACtD,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAErD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAC5B,CAAC"}
|
package/dist/git.d.ts
CHANGED
|
@@ -74,4 +74,61 @@ export declare function getGitRoot(projectRoot: string): string;
|
|
|
74
74
|
* @returns Current HEAD ref string.
|
|
75
75
|
*/
|
|
76
76
|
export declare function resolveHeadRef(gitRoot: string, fallback?: string): string;
|
|
77
|
+
/**
|
|
78
|
+
* Options for {@link addTransientWorktree}.
|
|
79
|
+
*
|
|
80
|
+
* @task T9984
|
|
81
|
+
*/
|
|
82
|
+
export interface AddTransientWorktreeOptions {
|
|
83
|
+
/** Absolute project root the worktree is added to. */
|
|
84
|
+
projectRoot: string;
|
|
85
|
+
/** Absolute path where the worktree directory will be created. */
|
|
86
|
+
worktreePath: string;
|
|
87
|
+
/** Branch name (created or reused if already present). */
|
|
88
|
+
branch: string;
|
|
89
|
+
/** Ref to branch from (e.g. `origin/main`, `origin/<branch>`). */
|
|
90
|
+
baseRef: string;
|
|
91
|
+
/**
|
|
92
|
+
* When true, pass `-B` (force-reset the branch ref). Otherwise `-b` is used
|
|
93
|
+
* (fail if the branch already exists locally).
|
|
94
|
+
*
|
|
95
|
+
* @default true
|
|
96
|
+
*/
|
|
97
|
+
resetBranch?: boolean;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Add a **transient** (non-canonical-location) worktree via `git worktree add`.
|
|
101
|
+
*
|
|
102
|
+
* This is the legitimate escape hatch for callers that need a worktree
|
|
103
|
+
* OUTSIDE the canonical XDG agent-worktree root — for example the
|
|
104
|
+
* `cleo docs publish-pr` flow which provisions a temporary worktree in the
|
|
105
|
+
* OS tmpdir to produce a doc-PR commit/push.
|
|
106
|
+
*
|
|
107
|
+
* Routing through this helper keeps the raw `git worktree add` shell-out
|
|
108
|
+
* confined to `@cleocode/worktree` (the legitimate owner) so the lint gate
|
|
109
|
+
* introduced in T9984 can reject inline `git worktree` calls everywhere
|
|
110
|
+
* else.
|
|
111
|
+
*
|
|
112
|
+
* For AGENT worktrees (under XDG canonical root) use {@link createWorktree}
|
|
113
|
+
* from `@cleocode/worktree/worktree-create.js` instead — it adds locking,
|
|
114
|
+
* include-patterns, hook lifecycle, and sentinel-index registration.
|
|
115
|
+
*
|
|
116
|
+
* @param options - Provisioning options.
|
|
117
|
+
* @throws Error if `git worktree add` exits non-zero.
|
|
118
|
+
*
|
|
119
|
+
* @task T9984
|
|
120
|
+
*/
|
|
121
|
+
export declare function addTransientWorktree(options: AddTransientWorktreeOptions): Promise<void>;
|
|
122
|
+
/**
|
|
123
|
+
* Remove a transient worktree previously created via {@link addTransientWorktree}.
|
|
124
|
+
*
|
|
125
|
+
* Best-effort — failures throw, but callers SHOULD swallow in `finally`
|
|
126
|
+
* blocks so cleanup never masks the underlying error.
|
|
127
|
+
*
|
|
128
|
+
* @param projectRoot - Absolute project root.
|
|
129
|
+
* @param worktreePath - Absolute path to the worktree to remove.
|
|
130
|
+
*
|
|
131
|
+
* @task T9984
|
|
132
|
+
*/
|
|
133
|
+
export declare function removeTransientWorktree(projectRoot: string, worktreePath: string): Promise<void>;
|
|
77
134
|
//# sourceMappingURL=git.d.ts.map
|
package/dist/git.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../src/git.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAOH;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,QAAS,CAAC;AAE7C;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAO/E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAWlF;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAO/F;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAMtD;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,SAAS,GAAG,MAAM,CAMzE"}
|
|
1
|
+
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../src/git.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAOH;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,QAAS,CAAC;AAE7C;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE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|
|
121
|
+
* Add a **transient** (non-canonical-location) worktree via `git worktree add`.
|
|
122
|
+
*
|
|
123
|
+
* This is the legitimate escape hatch for callers that need a worktree
|
|
124
|
+
* OUTSIDE the canonical XDG agent-worktree root — for example the
|
|
125
|
+
* `cleo docs publish-pr` flow which provisions a temporary worktree in the
|
|
126
|
+
* OS tmpdir to produce a doc-PR commit/push.
|
|
127
|
+
*
|
|
128
|
+
* Routing through this helper keeps the raw `git worktree add` shell-out
|
|
129
|
+
* confined to `@cleocode/worktree` (the legitimate owner) so the lint gate
|
|
130
|
+
* introduced in T9984 can reject inline `git worktree` calls everywhere
|
|
131
|
+
* else.
|
|
132
|
+
*
|
|
133
|
+
* For AGENT worktrees (under XDG canonical root) use {@link createWorktree}
|
|
134
|
+
* from `@cleocode/worktree/worktree-create.js` instead — it adds locking,
|
|
135
|
+
* include-patterns, hook lifecycle, and sentinel-index registration.
|
|
136
|
+
*
|
|
137
|
+
* @param options - Provisioning options.
|
|
138
|
+
* @throws Error if `git worktree add` exits non-zero.
|
|
139
|
+
*
|
|
140
|
+
* @task T9984
|
|
141
|
+
*/
|
|
142
|
+
export async function addTransientWorktree(options) {
|
|
143
|
+
const { projectRoot, worktreePath, branch, baseRef, resetBranch = true } = options;
|
|
144
|
+
const flag = resetBranch ? '-B' : '-b';
|
|
145
|
+
await gitAsync(['worktree', 'add', flag, branch, worktreePath, baseRef], projectRoot);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Remove a transient worktree previously created via {@link addTransientWorktree}.
|
|
149
|
+
*
|
|
150
|
+
* Best-effort — failures throw, but callers SHOULD swallow in `finally`
|
|
151
|
+
* blocks so cleanup never masks the underlying error.
|
|
152
|
+
*
|
|
153
|
+
* @param projectRoot - Absolute project root.
|
|
154
|
+
* @param worktreePath - Absolute path to the worktree to remove.
|
|
155
|
+
*
|
|
156
|
+
* @task T9984
|
|
157
|
+
*/
|
|
158
|
+
export async function removeTransientWorktree(projectRoot, worktreePath) {
|
|
159
|
+
await gitAsync(['worktree', 'remove', '--force', worktreePath], projectRoot);
|
|
160
|
+
}
|
|
120
161
|
//# sourceMappingURL=git.js.map
|
package/dist/git.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git.js","sourceRoot":"","sources":["../src/git.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAE1C;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC;AAE7C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,OAAO,CAAC,IAAc,EAAE,GAAW,EAAE,SAAkB;IACrE,OAAO,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE;QAC/B,GAAG;QACH,QAAQ,EAAE,OAAO;QACjB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;QAC/B,OAAO,EAAE,SAAS,IAAI,sBAAsB;KAC7C,CAAC,CAAC,IAAI,EAAE,CAAC;AACZ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,SAAS,CAAC,IAAc,EAAE,GAAW,EAAE,SAAkB;IACvE,IAAI,CAAC;QACH,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE;YACxB,GAAG;YACH,KAAK,EAAE,MAAM;YACb,OAAO,EAAE,SAAS,IAAI,sBAAsB;SAC7C,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,IAAc,EAAE,GAAW,EAAE,SAAkB;IAC5E,MAAM,EAAE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M,CAAC,EAAE,OAAO,CAAC,CAAC;IACjE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,QAAQ,CAAC;IAClB,CAAC;AACH,CAAC;AAyBD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,OAAoC;IAC7E,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IACnF,MAAM,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IACvC,MAAM,QAAQ,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,WAAW,CAAC,CAAC;AACxF,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,WAAmB,EACnB,YAAoB;IAEpB,MAAM,QAAQ,CAAC,CAAC,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,CAAC,EAAE,WAAW,CAAC,CAAC;AAC/E,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
* @adr ADR-055
|
|
22
22
|
*/
|
|
23
23
|
export type { CreateWorktreeOptions, CreateWorktreeResult, DestroyWorktreeOptions, DestroyWorktreeResult, ListWorktreesOptions, PruneWorktreesOptions, PruneWorktreesResult, WorktreeHook, WorktreeHookResult, WorktreeIncludePattern, WorktreeListEntry, } from '@cleocode/contracts';
|
|
24
|
-
export type {
|
|
25
|
-
export { legacyCreateWorktree, legacyListWorktrees, legacyMergeWorktree, legacyResolveWorktreeRoot, } from './compat.js';
|
|
24
|
+
export type { CopyPathsOptions } from './copy-on-write.js';
|
|
26
25
|
export { copyPathsWithReflock } from './copy-on-write.js';
|
|
26
|
+
export { type AddTransientWorktreeOptions, addTransientWorktree, removeTransientWorktree, } from './git.js';
|
|
27
27
|
export type { WorktreeAuditPayload } from './worktree-audit.js';
|
|
28
28
|
export { addWorktreeToSentinelIndex, appendWorktreeAuditLog, removeWorktreeFromSentinelIndex, resolveWorktreeIndexPath, WORKTREE_INDEX_RELATIVE_PATH, WORKTREE_LIFECYCLE_AUDIT_FILE, } from './worktree-audit.js';
|
|
29
29
|
export { createWorktree } from './worktree-create.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,YAAY,EACV,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAClB,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,YAAY,EACV,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAClB,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EACL,KAAK,2BAA2B,EAChC,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,UAAU,CAAC;AAClB,YAAY,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EACL,0BAA0B,EAC1B,sBAAsB,EACtB,+BAA+B,EAC/B,wBAAwB,EACxB,4BAA4B,EAC5B,6BAA6B,GAC9B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAC1F,OAAO,EACL,aAAa,EACb,0BAA0B,EAC1B,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
* @task T1161
|
|
21
21
|
* @adr ADR-055
|
|
22
22
|
*/
|
|
23
|
-
export { legacyCreateWorktree, legacyListWorktrees, legacyMergeWorktree, legacyResolveWorktreeRoot, } from './compat.js';
|
|
24
23
|
export { copyPathsWithReflock } from './copy-on-write.js';
|
|
24
|
+
export { addTransientWorktree, removeTransientWorktree, } from './git.js';
|
|
25
25
|
export { addWorktreeToSentinelIndex, appendWorktreeAuditLog, removeWorktreeFromSentinelIndex, resolveWorktreeIndexPath, WORKTREE_INDEX_RELATIVE_PATH, WORKTREE_LIFECYCLE_AUDIT_FILE, } from './worktree-audit.js';
|
|
26
26
|
export { createWorktree } from './worktree-create.js';
|
|
27
27
|
export { destroyWorktree } from './worktree-destroy.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAiBH,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAEL,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,0BAA0B,EAC1B,sBAAsB,EACtB,+BAA+B,EAC/B,wBAAwB,EACxB,4BAA4B,EAC5B,6BAA6B,GAC9B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAC1F,OAAO,EACL,aAAa,EACb,0BAA0B,EAC1B,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ESM-friendly bridge to `@cleocode/worktree-napi` (a CommonJS native addon).
|
|
3
|
+
*
|
|
4
|
+
* The napi-rs loader at `crates/worktree-napi/index.cjs` exposes its surface as
|
|
5
|
+
* `module.exports = nativeBinding` — Node.js's CJS-to-ESM interop cannot
|
|
6
|
+
* statically detect named exports from a dynamic require(), so direct
|
|
7
|
+
* `import { copyPathsParallel } from '@cleocode/worktree-napi'` throws
|
|
8
|
+
* "does not provide an export named ..." at link time.
|
|
9
|
+
*
|
|
10
|
+
* This module wraps the native binding via `createRequire` so the import looks
|
|
11
|
+
* like a regular dynamic require from a CJS context. All consumers in this
|
|
12
|
+
* package import napi functions from THIS module, never directly from
|
|
13
|
+
* `@cleocode/worktree-napi`.
|
|
14
|
+
*
|
|
15
|
+
* @task T9982
|
|
16
|
+
*/
|
|
17
|
+
interface CopyOptsNapi {
|
|
18
|
+
/** Overwrite existing entries at the destination. */
|
|
19
|
+
force: boolean;
|
|
20
|
+
/** When set, every destination must resolve inside this root. */
|
|
21
|
+
rootGuard?: string;
|
|
22
|
+
/** Reserved for future use — symlinks are always followed by copy_leaf. */
|
|
23
|
+
includeSymlinks: boolean;
|
|
24
|
+
}
|
|
25
|
+
interface CopyResultNapi {
|
|
26
|
+
copiedCount: number;
|
|
27
|
+
skippedCount: number;
|
|
28
|
+
failedPaths: string[];
|
|
29
|
+
totalBytes: number;
|
|
30
|
+
}
|
|
31
|
+
interface DestroyOptsNapi {
|
|
32
|
+
repoRoot: string;
|
|
33
|
+
worktreePath: string;
|
|
34
|
+
force: boolean;
|
|
35
|
+
}
|
|
36
|
+
interface DestroyResultNapi {
|
|
37
|
+
removed: boolean;
|
|
38
|
+
branchDeleted: boolean;
|
|
39
|
+
}
|
|
40
|
+
interface IncludePatternNapi {
|
|
41
|
+
pattern: string;
|
|
42
|
+
isNegation: boolean;
|
|
43
|
+
}
|
|
44
|
+
interface ListOptsNapi {
|
|
45
|
+
repoRoot: string;
|
|
46
|
+
}
|
|
47
|
+
interface WorktreeInfoNapi {
|
|
48
|
+
path: string;
|
|
49
|
+
branch?: string;
|
|
50
|
+
head: string;
|
|
51
|
+
isLocked: boolean;
|
|
52
|
+
isPrunable: boolean;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Shape of the native module exported by `@cleocode/worktree-napi`.
|
|
56
|
+
*
|
|
57
|
+
* Mirrors the napi-rs `index.d.ts` but mapped into TS-friendly types that
|
|
58
|
+
* this package owns (the `.d.ts` from the crate uses `Array<T>` and is
|
|
59
|
+
* regenerated at every build, so we don't import from it directly).
|
|
60
|
+
*
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
63
|
+
interface WorktreeNapiModule {
|
|
64
|
+
copyPathsParallel(srcDir: string, destDir: string, paths: string[], opts: CopyOptsNapi): CopyResultNapi;
|
|
65
|
+
destroyWorktree(opts: DestroyOptsNapi): DestroyResultNapi;
|
|
66
|
+
readWorktreeInclude(repoRoot: string): IncludePatternNapi[];
|
|
67
|
+
applyInclude(patterns: IncludePatternNapi[], srcDir: string, destDir: string, opts: CopyOptsNapi): CopyResultNapi;
|
|
68
|
+
listWorktrees(opts: ListOptsNapi): WorktreeInfoNapi[];
|
|
69
|
+
}
|
|
70
|
+
export declare const copyPathsParallel: WorktreeNapiModule['copyPathsParallel'];
|
|
71
|
+
export declare const destroyWorktree: WorktreeNapiModule['destroyWorktree'];
|
|
72
|
+
export declare const readWorktreeInclude: WorktreeNapiModule['readWorktreeInclude'];
|
|
73
|
+
export declare const applyInclude: WorktreeNapiModule['applyInclude'];
|
|
74
|
+
export declare const listWorktrees: WorktreeNapiModule['listWorktrees'];
|
|
75
|
+
export type { CopyOptsNapi, CopyResultNapi, DestroyOptsNapi, DestroyResultNapi, IncludePatternNapi, ListOptsNapi, WorktreeInfoNapi, };
|
|
76
|
+
//# sourceMappingURL=napi-binding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"napi-binding.d.ts","sourceRoot":"","sources":["../src/napi-binding.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAMH,UAAU,YAAY;IACpB,qDAAqD;IACrD,KAAK,EAAE,OAAO,CAAC;IACf,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2EAA2E;IAC3E,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED,UAAU,cAAc;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,eAAe;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,UAAU,iBAAiB;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,UAAU,kBAAkB;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EA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1
|
+
/**
|
|
2
|
+
* ESM-friendly bridge to `@cleocode/worktree-napi` (a CommonJS native addon).
|
|
3
|
+
*
|
|
4
|
+
* The napi-rs loader at `crates/worktree-napi/index.cjs` exposes its surface as
|
|
5
|
+
* `module.exports = nativeBinding` — Node.js's CJS-to-ESM interop cannot
|
|
6
|
+
* statically detect named exports from a dynamic require(), so direct
|
|
7
|
+
* `import { copyPathsParallel } from '@cleocode/worktree-napi'` throws
|
|
8
|
+
* "does not provide an export named ..." at link time.
|
|
9
|
+
*
|
|
10
|
+
* This module wraps the native binding via `createRequire` so the import looks
|
|
11
|
+
* like a regular dynamic require from a CJS context. All consumers in this
|
|
12
|
+
* package import napi functions from THIS module, never directly from
|
|
13
|
+
* `@cleocode/worktree-napi`.
|
|
14
|
+
*
|
|
15
|
+
* @task T9982
|
|
16
|
+
*/
|
|
17
|
+
import { createRequire } from 'node:module';
|
|
18
|
+
const require_ = createRequire(import.meta.url);
|
|
19
|
+
/**
|
|
20
|
+
* Lazy-loaded handle to the native binding. The first call to any exported
|
|
21
|
+
* function triggers a `require()` of `@cleocode/worktree-napi`; subsequent
|
|
22
|
+
* calls reuse the cached module. This keeps the load failure off the
|
|
23
|
+
* import-time critical path so:
|
|
24
|
+
*
|
|
25
|
+
* - Compile-time consumers (tsc, biome) never touch the native module.
|
|
26
|
+
* - CLI startup never crashes when the .node is missing on a partial
|
|
27
|
+
* install (the failure is deferred until an actual worktree op runs).
|
|
28
|
+
*
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
let nativeBinding = null;
|
|
32
|
+
function getNative() {
|
|
33
|
+
if (nativeBinding === null) {
|
|
34
|
+
nativeBinding = require_('@cleocode/worktree-napi');
|
|
35
|
+
}
|
|
36
|
+
return nativeBinding;
|
|
37
|
+
}
|
|
38
|
+
export const copyPathsParallel = (srcDir, destDir, paths, opts) => getNative().copyPathsParallel(srcDir, destDir, paths, opts);
|
|
39
|
+
export const destroyWorktree = (opts) => getNative().destroyWorktree(opts);
|
|
40
|
+
export const readWorktreeInclude = (repoRoot) => getNative().readWorktreeInclude(repoRoot);
|
|
41
|
+
export const applyInclude = (patterns, srcDir, destDir, opts) => getNative().applyInclude(patterns, srcDir, destDir, opts);
|
|
42
|
+
export const listWorktrees = (opts) => getNative().listWorktrees(opts);
|
|
43
|
+
//# sourceMappingURL=napi-binding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"napi-binding.js","sourceRoot":"","sources":["../src/napi-binding.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAyEhD;;;;;;;;;;;GAWG;AACH,IAAI,aAAa,GAA8B,IAAI,CAAC;AACpD,SAAS,SAAS;IAChB,IAAI,aAAa,KAAK,IAAI,EAAE,CAAC;QAC3B,aAAa,GAAG,QAAQ,CAAC,yBAAyB,CAAuB,CAAC;IAC5E,CAAC;IACD,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,MAAM,CAAC,MAAM,iBAAiB,GAA4C,CACxE,MAAM,EACN,OAAO,EACP,KAAK,EACL,IAAI,EACJ,EAAE,CAAC,SAAS,EAAE,CAAC,iBAAiB,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;AAEjE,MAAM,CAAC,MAAM,eAAe,GAA0C,CAAC,IAAI,EAAE,EAAE,CAC7E,SAAS,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;AAEpC,MAAM,CAAC,MAAM,mBAAmB,GAA8C,CAAC,QAAQ,EAAE,EAAE,CACzF,SAAS,EAAE,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;AAE5C,MAAM,CAAC,MAAM,YAAY,GAAuC,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAClG,SAAS,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;AAE5D,MAAM,CAAC,MAAM,aAAa,GAAwC,CAAC,IAAI,EAAE,EAAE,CACzE,SAAS,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -45,9 +45,11 @@ interface CreateWorktreeResultWithBootstrap extends CreateWorktreeResult {
|
|
|
45
45
|
* Otherwise create a new branch via `git worktree add -b <branch> <path> <baseRef>`.
|
|
46
46
|
* 4. Optionally apply `git worktree lock` to prevent pruning.
|
|
47
47
|
* 5. Run declarative `post-create` hooks.
|
|
48
|
-
* 6. Apply `.cleo/worktree-include` glob patterns
|
|
49
|
-
*
|
|
50
|
-
*
|
|
48
|
+
* 6. Apply `.worktreeinclude` (or legacy `.cleo/worktree-include`) glob patterns —
|
|
49
|
+
* real ignore::gitignore matching is delegated to `@cleocode/worktree-napi`.
|
|
50
|
+
* 7. NO hardcoded bootstrap copy (T9982). Projects that need node_modules /
|
|
51
|
+
* packages/* /dist mirrored into the worktree MUST declare them in
|
|
52
|
+
* `.worktreeinclude` — the multi-language native include file.
|
|
51
53
|
* 8. Run declarative `post-start` hooks.
|
|
52
54
|
* 9. Build and return the {@link CreateWorktreeResult}.
|
|
53
55
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worktree-create.d.ts","sourceRoot":"","sources":["../src/worktree-create.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,KAAK,EACV,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"worktree-create.d.ts","sourceRoot":"","sources":["../src/worktree-create.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,KAAK,EACV,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EACnB,MAAM,qBAAqB,CAAC;AAE7B;;;;;;GAMG;AACH,UAAU,iCAAkC,SAAQ,oBAAoB;IACtE,SAAS,EAAE;QACT,WAAW,EAAE,MAAM,EAAE,CAAC;QACtB,WAAW,EAAE,MAAM,EAAE,CAAC;QACtB,WAAW,EAAE,kBAAkB,EAAE,CAAC;KACnC,CAAC;IACF,mEAAmE;IACnE,sBAAsB,EAAE,MAAM,EAAE,CAAC;IACjC;;;OAGG;IACH,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAqGD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAsB,cAAc,CAClC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,iCAAiC,CAAC,CA2N5C"}
|