@cleocode/worktree 2026.5.120 → 2026.5.122
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 +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/recovery.d.ts +77 -0
- package/dist/recovery.d.ts.map +1 -0
- package/dist/recovery.js +172 -0
- package/dist/recovery.js.map +1 -0
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -24,6 +24,8 @@ export type { CreateWorktreeOptions, CreateWorktreeResult, DestroyWorktreeOption
|
|
|
24
24
|
export type { CopyPathsOptions } from './copy-on-write.js';
|
|
25
25
|
export { copyPathsWithReflock } from './copy-on-write.js';
|
|
26
26
|
export { type AddTransientWorktreeOptions, addTransientWorktree, DEFAULT_GIT_TIMEOUT_MS, removeTransientWorktree, } from './git.js';
|
|
27
|
+
export type { PartialWorktreeSignals, RecoveryResult } from './recovery.js';
|
|
28
|
+
export { detectPartialWorktree, recoverPartialWorktree } from './recovery.js';
|
|
27
29
|
export type { WorktreeAuditPayload } from './worktree-audit.js';
|
|
28
30
|
export { addWorktreeToSentinelIndex, appendWorktreeAuditLog, removeWorktreeFromSentinelIndex, resolveWorktreeIndexPath, WORKTREE_INDEX_RELATIVE_PATH, WORKTREE_LIFECYCLE_AUDIT_FILE, } from './worktree-audit.js';
|
|
29
31
|
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,iBA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oB,EACpB,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,UAAU,CAAC;AAClB,YAAY,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAC9E,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
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
*/
|
|
23
23
|
export { copyPathsWithReflock } from './copy-on-write.js';
|
|
24
24
|
export { addTransientWorktree, DEFAULT_GIT_TIMEOUT_MS, removeTransientWorktree, } from './git.js';
|
|
25
|
+
export { detectPartialWorktree, recoverPartialWorktree } from './recovery.js';
|
|
25
26
|
export { addWorktreeToSentinelIndex, appendWorktreeAuditLog, removeWorktreeFromSentinelIndex, resolveWorktreeIndexPath, WORKTREE_INDEX_RELATIVE_PATH, WORKTREE_LIFECYCLE_AUDIT_FILE, } from './worktree-audit.js';
|
|
26
27
|
export { createWorktree } from './worktree-create.js';
|
|
27
28
|
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;AAiBH,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAEL,oBAAoB,EACpB,sBAAsB,EACtB,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"}
|
|
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,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAE9E,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,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Worktree recovery operations for @cleocode/worktree.
|
|
3
|
+
*
|
|
4
|
+
* T10456 — Auto-adopt partial worktrees:
|
|
5
|
+
* When a spawn hits ETIMEDOUT and leaves a worktree in a partial state,
|
|
6
|
+
* the recovery function:
|
|
7
|
+
* 1. Detects partial state (git status, node_modules, index.lock)
|
|
8
|
+
* 2. Runs `pnpm install` to restore node_modules
|
|
9
|
+
* 3. Unlocks the git index if a stale index.lock is present
|
|
10
|
+
* 4. Resumes from the last checkpoint (if any)
|
|
11
|
+
*
|
|
12
|
+
* @task T10456
|
|
13
|
+
* @epic T10435
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Signals that indicate a worktree may be in a partial / wedged state.
|
|
17
|
+
*
|
|
18
|
+
* @task T10456
|
|
19
|
+
*/
|
|
20
|
+
export interface PartialWorktreeSignals {
|
|
21
|
+
/** True when `git status --porcelain` returns non-empty output. */
|
|
22
|
+
hasUncommittedChanges: boolean;
|
|
23
|
+
/** True when `node_modules` is missing from the worktree root. */
|
|
24
|
+
nodeModulesMissing: boolean;
|
|
25
|
+
/** True when `.git/index.lock` exists (wedged git index). */
|
|
26
|
+
indexLockPresent: boolean;
|
|
27
|
+
/** True when the worktree directory itself exists but looks incomplete. */
|
|
28
|
+
worktreeExists: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Result of a recovery attempt.
|
|
32
|
+
*
|
|
33
|
+
* @task T10456
|
|
34
|
+
*/
|
|
35
|
+
export interface RecoveryResult {
|
|
36
|
+
/** Whether the recovery succeeded overall. */
|
|
37
|
+
success: boolean;
|
|
38
|
+
/** What actions were taken. */
|
|
39
|
+
actions: string[];
|
|
40
|
+
/** Error message if recovery failed. */
|
|
41
|
+
error?: string;
|
|
42
|
+
/** The partial-state signals that were detected before recovery. */
|
|
43
|
+
signals: PartialWorktreeSignals;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Detect whether a worktree is in a partial state.
|
|
47
|
+
*
|
|
48
|
+
* Checks for:
|
|
49
|
+
* 1. Uncommitted changes (`git status --porcelain`)
|
|
50
|
+
* 2. Missing `node_modules`
|
|
51
|
+
* 3. Stale `.git/index.lock`
|
|
52
|
+
*
|
|
53
|
+
* @param worktreePath - Absolute path to the worktree directory.
|
|
54
|
+
* @returns Detection signals.
|
|
55
|
+
* @task T10456
|
|
56
|
+
*/
|
|
57
|
+
export declare function detectPartialWorktree(worktreePath: string): PartialWorktreeSignals;
|
|
58
|
+
/**
|
|
59
|
+
* Auto-adopt a partial worktree by running recovery steps.
|
|
60
|
+
*
|
|
61
|
+
* Steps:
|
|
62
|
+
* 1. Detect partial state via {@link detectPartialWorktree}.
|
|
63
|
+
* 2. If `node_modules` is missing, run `pnpm install` (bounded by 120s).
|
|
64
|
+
* 3. If `.git/index.lock` is present, remove it and run `git worktree unlock`.
|
|
65
|
+
* 4. If a checkpoint file (`.cleo/checkpoint.json`) exists, read it and
|
|
66
|
+
* return the checkpoint state so the caller can resume.
|
|
67
|
+
*
|
|
68
|
+
* All steps are best-effort: a failure in one step does not abort the others.
|
|
69
|
+
*
|
|
70
|
+
* @param projectRoot - Absolute path to the project root.
|
|
71
|
+
* @param worktreePath - Absolute path to the partial worktree.
|
|
72
|
+
* @param taskId - Task ID associated with the worktree.
|
|
73
|
+
* @returns Recovery result with actions taken and any error.
|
|
74
|
+
* @task T10456
|
|
75
|
+
*/
|
|
76
|
+
export declare function recoverPartialWorktree(projectRoot: string, worktreePath: string, taskId: string): RecoveryResult;
|
|
77
|
+
//# sourceMappingURL=recovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recovery.d.ts","sourceRoot":"","sources":["../src/recovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AA2BH;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,mEAAmE;IACnE,qBAAqB,EAAE,OAAO,CAAC;IAC/B,kEAAkE;IAClE,kBAAkB,EAAE,OAAO,CAAC;IAC5B,6DAA6D;IAC7D,gBAAgB,EAAE,OAAO,CAAC;IAC1B,2EAA2E;IAC3E,cAAc,EAAE,OAAO,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,8CAA8C;IAC9C,OAAO,EAAE,OAAO,CAAC;IACjB,+BAA+B;IAC/B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oEAAoE;IACpE,OAAO,EAAE,sBAAsB,CAAC;CACjC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,MAAM,GAAG,sBAAsB,CAgClF;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,GACb,cAAc,CA+EhB"}
|
package/dist/recovery.js
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Worktree recovery operations for @cleocode/worktree.
|
|
3
|
+
*
|
|
4
|
+
* T10456 — Auto-adopt partial worktrees:
|
|
5
|
+
* When a spawn hits ETIMEDOUT and leaves a worktree in a partial state,
|
|
6
|
+
* the recovery function:
|
|
7
|
+
* 1. Detects partial state (git status, node_modules, index.lock)
|
|
8
|
+
* 2. Runs `pnpm install` to restore node_modules
|
|
9
|
+
* 3. Unlocks the git index if a stale index.lock is present
|
|
10
|
+
* 4. Resumes from the last checkpoint (if any)
|
|
11
|
+
*
|
|
12
|
+
* @task T10456
|
|
13
|
+
* @epic T10435
|
|
14
|
+
*/
|
|
15
|
+
import { execFileSync } from 'node:child_process';
|
|
16
|
+
import { existsSync, readFileSync, rmSync } from 'node:fs';
|
|
17
|
+
import { join } from 'node:path';
|
|
18
|
+
function resolveGitAdminDir(worktreePath) {
|
|
19
|
+
const gitPath = join(worktreePath, '.git');
|
|
20
|
+
if (!existsSync(gitPath))
|
|
21
|
+
return gitPath;
|
|
22
|
+
try {
|
|
23
|
+
const gitContent = readFileSync(gitPath, 'utf-8').trim();
|
|
24
|
+
if (gitContent.startsWith('gitdir: ')) {
|
|
25
|
+
const adminDir = gitContent.slice('gitdir: '.length).trim();
|
|
26
|
+
return adminDir.startsWith('/') ? adminDir : join(worktreePath, adminDir);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
// `.git` is normally a directory for the primary checkout; fall through.
|
|
31
|
+
}
|
|
32
|
+
return gitPath;
|
|
33
|
+
}
|
|
34
|
+
function resolveIndexLockPath(worktreePath) {
|
|
35
|
+
return join(resolveGitAdminDir(worktreePath), 'index.lock');
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Detect whether a worktree is in a partial state.
|
|
39
|
+
*
|
|
40
|
+
* Checks for:
|
|
41
|
+
* 1. Uncommitted changes (`git status --porcelain`)
|
|
42
|
+
* 2. Missing `node_modules`
|
|
43
|
+
* 3. Stale `.git/index.lock`
|
|
44
|
+
*
|
|
45
|
+
* @param worktreePath - Absolute path to the worktree directory.
|
|
46
|
+
* @returns Detection signals.
|
|
47
|
+
* @task T10456
|
|
48
|
+
*/
|
|
49
|
+
export function detectPartialWorktree(worktreePath) {
|
|
50
|
+
const signals = {
|
|
51
|
+
hasUncommittedChanges: false,
|
|
52
|
+
nodeModulesMissing: false,
|
|
53
|
+
indexLockPresent: false,
|
|
54
|
+
worktreeExists: existsSync(worktreePath),
|
|
55
|
+
};
|
|
56
|
+
if (!signals.worktreeExists) {
|
|
57
|
+
return signals;
|
|
58
|
+
}
|
|
59
|
+
// 1. Check for uncommitted changes
|
|
60
|
+
try {
|
|
61
|
+
const status = execFileSync('git', ['status', '--porcelain'], {
|
|
62
|
+
cwd: worktreePath,
|
|
63
|
+
encoding: 'utf-8',
|
|
64
|
+
timeout: 5_000,
|
|
65
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
66
|
+
});
|
|
67
|
+
signals.hasUncommittedChanges = status.trim().length > 0;
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
signals.hasUncommittedChanges = false;
|
|
71
|
+
}
|
|
72
|
+
// 2. Check for missing node_modules
|
|
73
|
+
signals.nodeModulesMissing = !existsSync(join(worktreePath, 'node_modules'));
|
|
74
|
+
// 3. Check for stale index.lock
|
|
75
|
+
signals.indexLockPresent = existsSync(resolveIndexLockPath(worktreePath));
|
|
76
|
+
return signals;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Auto-adopt a partial worktree by running recovery steps.
|
|
80
|
+
*
|
|
81
|
+
* Steps:
|
|
82
|
+
* 1. Detect partial state via {@link detectPartialWorktree}.
|
|
83
|
+
* 2. If `node_modules` is missing, run `pnpm install` (bounded by 120s).
|
|
84
|
+
* 3. If `.git/index.lock` is present, remove it and run `git worktree unlock`.
|
|
85
|
+
* 4. If a checkpoint file (`.cleo/checkpoint.json`) exists, read it and
|
|
86
|
+
* return the checkpoint state so the caller can resume.
|
|
87
|
+
*
|
|
88
|
+
* All steps are best-effort: a failure in one step does not abort the others.
|
|
89
|
+
*
|
|
90
|
+
* @param projectRoot - Absolute path to the project root.
|
|
91
|
+
* @param worktreePath - Absolute path to the partial worktree.
|
|
92
|
+
* @param taskId - Task ID associated with the worktree.
|
|
93
|
+
* @returns Recovery result with actions taken and any error.
|
|
94
|
+
* @task T10456
|
|
95
|
+
*/
|
|
96
|
+
export function recoverPartialWorktree(projectRoot, worktreePath, taskId) {
|
|
97
|
+
const actions = [];
|
|
98
|
+
const signals = detectPartialWorktree(worktreePath);
|
|
99
|
+
if (!signals.worktreeExists) {
|
|
100
|
+
return {
|
|
101
|
+
success: false,
|
|
102
|
+
actions: ['detect-partial-state'],
|
|
103
|
+
error: `Worktree does not exist: ${worktreePath}`,
|
|
104
|
+
signals,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
// Step 2: pnpm install when node_modules is missing
|
|
108
|
+
if (signals.nodeModulesMissing) {
|
|
109
|
+
try {
|
|
110
|
+
execFileSync('pnpm', ['install'], {
|
|
111
|
+
cwd: worktreePath,
|
|
112
|
+
encoding: 'utf-8',
|
|
113
|
+
timeout: 120_000,
|
|
114
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
115
|
+
});
|
|
116
|
+
actions.push('pnpm-install');
|
|
117
|
+
}
|
|
118
|
+
catch (err) {
|
|
119
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
120
|
+
actions.push(`pnpm-install-failed: ${message}`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
// Step 3: unlock git index when index.lock is present
|
|
124
|
+
if (signals.indexLockPresent) {
|
|
125
|
+
try {
|
|
126
|
+
const lockPath = resolveIndexLockPath(worktreePath);
|
|
127
|
+
if (existsSync(lockPath)) {
|
|
128
|
+
rmSync(lockPath, { force: true });
|
|
129
|
+
}
|
|
130
|
+
execFileSync('git', ['worktree', 'unlock', worktreePath], {
|
|
131
|
+
cwd: projectRoot,
|
|
132
|
+
encoding: 'utf-8',
|
|
133
|
+
timeout: 10_000,
|
|
134
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
135
|
+
});
|
|
136
|
+
actions.push('unlock-git-index');
|
|
137
|
+
}
|
|
138
|
+
catch (err) {
|
|
139
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
140
|
+
actions.push(`unlock-git-index-failed: ${message}`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
// Step 4: resume from checkpoint if present
|
|
144
|
+
const checkpointPath = join(worktreePath, '.cleo', 'checkpoint.json');
|
|
145
|
+
if (existsSync(checkpointPath)) {
|
|
146
|
+
try {
|
|
147
|
+
const raw = readFileSync(checkpointPath, 'utf-8');
|
|
148
|
+
const checkpoint = JSON.parse(raw);
|
|
149
|
+
actions.push('checkpoint-resumed');
|
|
150
|
+
// Return success but surface the checkpoint in the error field for
|
|
151
|
+
// upstream callers that want to act on it.
|
|
152
|
+
return {
|
|
153
|
+
success: true,
|
|
154
|
+
actions,
|
|
155
|
+
signals,
|
|
156
|
+
error: JSON.stringify({ checkpointResumed: true, checkpoint }),
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
catch (err) {
|
|
160
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
161
|
+
actions.push(`checkpoint-read-failed: ${message}`);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
const success = actions.some((a) => a === 'pnpm-install' || a === 'unlock-git-index') ||
|
|
165
|
+
(!signals.nodeModulesMissing && !signals.indexLockPresent);
|
|
166
|
+
return {
|
|
167
|
+
success,
|
|
168
|
+
actions,
|
|
169
|
+
signals,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=recovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recovery.js","sourceRoot":"","sources":["../src/recovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,SAAS,kBAAkB,CAAC,YAAoB;IAC9C,MAAM,OAAO,GAAG,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IAC3C,IAAI,CAAC,UAA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CAAC,KAAK,CAAC,GAAG,CAAY,CAAC;YAC9C,OAAO,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;YACnC,mEAAmE;YACnE,2CAA2C;YAC3C,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,OAAO;gBACP,OAAO;gBACP,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,iBAAiB,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;aAC/D,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACjE,OAAO,CAAC,IAAI,CAAC,2BAA2B,OAAO,EAAE,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;IAED,MAAM,OAAO,GACX,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,cAAc,IAAI,CAAC,KAAK,kBAAkB,CAAC;QACrE,CAAC,CAAC,OAAO,CAAC,kBAAkB,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAE7D,OAAO;QACL,OAAO;QACP,OAAO;QACP,OAAO;KACR,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cleocode/worktree",
|
|
3
|
-
"version": "2026.5.
|
|
3
|
+
"version": "2026.5.122",
|
|
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,17 +30,17 @@
|
|
|
30
30
|
"author": "CLEO Code <hello@cleocode.dev>",
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@cleocode/paths": "2026.5.
|
|
34
|
-
"@cleocode/contracts": "2026.5.
|
|
33
|
+
"@cleocode/paths": "2026.5.122",
|
|
34
|
+
"@cleocode/contracts": "2026.5.122"
|
|
35
35
|
},
|
|
36
36
|
"optionalDependencies": {
|
|
37
|
-
"@cleocode/worktree-napi": "2026.5.
|
|
37
|
+
"@cleocode/worktree-napi": "2026.5.122"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/node": "^24.3.0",
|
|
41
41
|
"typescript": "^6.0.2",
|
|
42
42
|
"vitest": "^4.1.4",
|
|
43
|
-
"@cleocode/core": "2026.5.
|
|
43
|
+
"@cleocode/core": "2026.5.122"
|
|
44
44
|
},
|
|
45
45
|
"repository": {
|
|
46
46
|
"type": "git",
|