@cleocode/worktree 2026.5.95 → 2026.5.97
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +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/worktree-audit.d.ts +128 -0
- package/dist/worktree-audit.d.ts.map +1 -0
- package/dist/worktree-audit.js +167 -0
- package/dist/worktree-audit.js.map +1 -0
- package/dist/worktree-create.d.ts +5 -0
- package/dist/worktree-create.d.ts.map +1 -1
- package/dist/worktree-create.js +84 -0
- package/dist/worktree-create.js.map +1 -1
- package/dist/worktree-destroy.d.ts.map +1 -1
- package/dist/worktree-destroy.js +16 -0
- package/dist/worktree-destroy.js.map +1 -1
- package/dist/worktree-include.d.ts +8 -0
- package/dist/worktree-include.d.ts.map +1 -1
- package/dist/worktree-include.js +22 -2
- package/dist/worktree-include.js.map +1 -1
- package/dist/worktree-prune.d.ts +11 -1
- package/dist/worktree-prune.d.ts.map +1 -1
- package/dist/worktree-prune.js +106 -17
- package/dist/worktree-prune.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -24,6 +24,8 @@ export type { CreateWorktreeOptions, CreateWorktreeResult, DestroyWorktreeOption
|
|
|
24
24
|
export type { LegacyMergeResult, LegacyWorktreeConfig, LegacyWorktreeEntry, LegacyWorktreeHandle, LegacyWorktreeRequest, } from './compat.js';
|
|
25
25
|
export { legacyCreateWorktree, legacyListWorktrees, legacyMergeWorktree, legacyResolveWorktreeRoot, } from './compat.js';
|
|
26
26
|
export { copyPathsWithReflock } from './copy-on-write.js';
|
|
27
|
+
export type { WorktreeAuditPayload } from './worktree-audit.js';
|
|
28
|
+
export { addWorktreeToSentinelIndex, appendWorktreeAuditLog, removeWorktreeFromSentinelIndex, resolveWorktreeIndexPath, WORKTREE_INDEX_RELATIVE_PATH, WORKTREE_LIFECYCLE_AUDIT_FILE, } from './worktree-audit.js';
|
|
27
29
|
export { createWorktree } from './worktree-create.js';
|
|
28
30
|
export { destroyWorktree } from './worktree-destroy.js';
|
|
29
31
|
export { runWorktreeHooks } from './worktree-hooks.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;AAE7B,YAAY,EACV,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,yBAAyB,GAC1B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,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.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;AAE7B,YAAY,EACV,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,yBAAyB,GAC1B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,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 { legacyCreateWorktree, legacyListWorktrees, legacyMergeWorktree, legacyResolveWorktreeRoot, } from './compat.js';
|
|
24
24
|
export { copyPathsWithReflock } from './copy-on-write.js';
|
|
25
|
+
export { addWorktreeToSentinelIndex, appendWorktreeAuditLog, removeWorktreeFromSentinelIndex, resolveWorktreeIndexPath, WORKTREE_INDEX_RELATIVE_PATH, WORKTREE_LIFECYCLE_AUDIT_FILE, } from './worktree-audit.js';
|
|
25
26
|
export { createWorktree } from './worktree-create.js';
|
|
26
27
|
export { destroyWorktree } from './worktree-destroy.js';
|
|
27
28
|
export { runWorktreeHooks } from './worktree-hooks.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAwBH,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,yBAAyB,GAC1B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAwBH,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,yBAAyB,GAC1B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D,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,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared audit-log helper for `@cleocode/worktree` lifecycle operations (T9805).
|
|
3
|
+
*
|
|
4
|
+
* Provides {@link appendWorktreeAuditLog} — the single DRY chokepoint for every
|
|
5
|
+
* write to `<projectRoot>/.cleo/audit/worktree-lifecycle.jsonl` from within the
|
|
6
|
+
* `@cleocode/worktree` package. This mirrors the pattern in
|
|
7
|
+
* `packages/core/src/worktree/audit.ts` but lives in the `worktree` package so
|
|
8
|
+
* that `worktree-create.ts`, `worktree-destroy.ts`, and `worktree-prune.ts` do
|
|
9
|
+
* not depend on `@cleocode/core` (which would create a circular dependency).
|
|
10
|
+
*
|
|
11
|
+
* Also provides {@link resolveWorktreeIndexPath} — canonical path to the
|
|
12
|
+
* per-repo sentinel index `<gitRoot>/.cleo/worktrees.json` used by council
|
|
13
|
+
* verdict D009 (T9805).
|
|
14
|
+
*
|
|
15
|
+
* @task T9805
|
|
16
|
+
* @epic T9800
|
|
17
|
+
*/
|
|
18
|
+
import type { WorktreeLifecycleAction } from '@cleocode/contracts';
|
|
19
|
+
/** Relative path within the project root for the worktree lifecycle audit log. */
|
|
20
|
+
export declare const WORKTREE_LIFECYCLE_AUDIT_FILE = ".cleo/audit/worktree-lifecycle.jsonl";
|
|
21
|
+
/**
|
|
22
|
+
* Relative path within the git repository root for the worktree sentinel index.
|
|
23
|
+
*
|
|
24
|
+
* The sentinel index is a JSON file that tracks every active worktree registered
|
|
25
|
+
* by `cleo orchestrate spawn`. When a worktree is destroyed or pruned the entry
|
|
26
|
+
* is removed so external tooling can read a single file to enumerate all live
|
|
27
|
+
* worktrees without scanning the XDG data directory.
|
|
28
|
+
*
|
|
29
|
+
* Per council verdict D009 (T9805): destroy and prune MUST update this file.
|
|
30
|
+
*/
|
|
31
|
+
export declare const WORKTREE_INDEX_RELATIVE_PATH = ".cleo/worktrees.json";
|
|
32
|
+
/**
|
|
33
|
+
* Payload for a single worktree lifecycle audit entry.
|
|
34
|
+
*
|
|
35
|
+
* Mirrors {@link import('@cleocode/contracts').WorktreeLifecycleAuditEntry} but
|
|
36
|
+
* keeps `timestamp` optional so callers only need to provide the fields they
|
|
37
|
+
* know about — the helper auto-fills `timestamp` when absent.
|
|
38
|
+
*/
|
|
39
|
+
export interface WorktreeAuditPayload {
|
|
40
|
+
/** Action that was performed. */
|
|
41
|
+
action: WorktreeLifecycleAction;
|
|
42
|
+
/** Absolute path to the worktree directory. */
|
|
43
|
+
xdgPath: string;
|
|
44
|
+
/** Task ID the worktree belongs to (e.g. `T9805`). */
|
|
45
|
+
taskId?: string;
|
|
46
|
+
/** Branch name (e.g. `task/T9805`). */
|
|
47
|
+
branch?: string;
|
|
48
|
+
/** Agent ID — defaults to `CLEO_AGENT_ID` env var or `'cleo'`. */
|
|
49
|
+
agentId?: string;
|
|
50
|
+
/** Free-form reason string (e.g. `pr-merged`, `idle-timeout`, `manual`). */
|
|
51
|
+
reason?: string;
|
|
52
|
+
/** Whether the action succeeded. */
|
|
53
|
+
success: boolean;
|
|
54
|
+
/** Error message when {@link success} is false. */
|
|
55
|
+
error?: string;
|
|
56
|
+
/** ISO-8601 timestamp — auto-filled when absent. */
|
|
57
|
+
timestamp?: string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Resolve the absolute path to the per-repo worktree sentinel index.
|
|
61
|
+
*
|
|
62
|
+
* The sentinel index lives at `<gitRoot>/.cleo/worktrees.json` and tracks
|
|
63
|
+
* every active worktree registered by `cleo orchestrate spawn`. Destroying
|
|
64
|
+
* or pruning a worktree MUST remove the entry from this file per council
|
|
65
|
+
* verdict D009.
|
|
66
|
+
*
|
|
67
|
+
* @param gitRoot - Absolute path to the git repository root.
|
|
68
|
+
* @returns Absolute path to `<gitRoot>/.cleo/worktrees.json`.
|
|
69
|
+
*
|
|
70
|
+
* @task T9805
|
|
71
|
+
*/
|
|
72
|
+
export declare function resolveWorktreeIndexPath(gitRoot: string): string;
|
|
73
|
+
/**
|
|
74
|
+
* Append a single JSONL entry to the worktree lifecycle audit log.
|
|
75
|
+
*
|
|
76
|
+
* The function is best-effort: any I/O error is swallowed so an audit
|
|
77
|
+
* failure never blocks the underlying operation. The log directory is
|
|
78
|
+
* created if it does not yet exist.
|
|
79
|
+
*
|
|
80
|
+
* @param projectRoot - Absolute path to the CLEO project root.
|
|
81
|
+
* @param payload - Audit entry fields (timestamp auto-filled when absent).
|
|
82
|
+
* @param auditLogPathOverride - Optional override for the log file path (testing).
|
|
83
|
+
*
|
|
84
|
+
* @task T9805
|
|
85
|
+
*/
|
|
86
|
+
export declare function appendWorktreeAuditLog(projectRoot: string, payload: WorktreeAuditPayload, auditLogPathOverride?: string): void;
|
|
87
|
+
/**
|
|
88
|
+
* Remove a worktree entry from the sentinel index at
|
|
89
|
+
* `<gitRoot>/.cleo/worktrees.json`.
|
|
90
|
+
*
|
|
91
|
+
* Per council verdict D009 (T9805): every destroy and prune operation MUST
|
|
92
|
+
* call this helper to keep the sentinel index in sync. Errors are swallowed
|
|
93
|
+
* so a stale index file never blocks a cleanup path.
|
|
94
|
+
*
|
|
95
|
+
* The index is a JSON object keyed by task ID:
|
|
96
|
+
* ```json
|
|
97
|
+
* {
|
|
98
|
+
* "T9805": { "path": "/xdg/path/T9805", "branch": "task/T9805", "createdAt": "..." }
|
|
99
|
+
* }
|
|
100
|
+
* ```
|
|
101
|
+
*
|
|
102
|
+
* @param gitRoot - Absolute path to the git repository root (where `.cleo/worktrees.json` lives).
|
|
103
|
+
* @param taskId - The task ID to remove from the index.
|
|
104
|
+
* @param indexPathOverride - Optional override for the index file path (testing).
|
|
105
|
+
*
|
|
106
|
+
* @task T9805
|
|
107
|
+
*/
|
|
108
|
+
export declare function removeWorktreeFromSentinelIndex(gitRoot: string, taskId: string, indexPathOverride?: string): void;
|
|
109
|
+
/**
|
|
110
|
+
* Add or update a worktree entry in the sentinel index at
|
|
111
|
+
* `<gitRoot>/.cleo/worktrees.json`.
|
|
112
|
+
*
|
|
113
|
+
* Called by `worktree-create.ts` immediately after the worktree is created.
|
|
114
|
+
* Errors are swallowed so index update failures never block spawn.
|
|
115
|
+
*
|
|
116
|
+
* @param gitRoot - Absolute path to the git repository root.
|
|
117
|
+
* @param taskId - The task ID being registered.
|
|
118
|
+
* @param entry - Metadata to store in the index for this task.
|
|
119
|
+
* @param indexPathOverride - Optional override for the index file path (testing).
|
|
120
|
+
*
|
|
121
|
+
* @task T9805
|
|
122
|
+
*/
|
|
123
|
+
export declare function addWorktreeToSentinelIndex(gitRoot: string, taskId: string, entry: {
|
|
124
|
+
path: string;
|
|
125
|
+
branch: string;
|
|
126
|
+
createdAt: string;
|
|
127
|
+
}, indexPathOverride?: string): void;
|
|
128
|
+
//# sourceMappingURL=worktree-audit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worktree-audit.d.ts","sourceRoot":"","sources":["../src/worktree-audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAEnE,kFAAkF;AAClF,eAAO,MAAM,6BAA6B,yCAAyC,CAAC;AAEpF;;;;;;;;;GASG;AACH,eAAO,MAAM,4BAA4B,yBAAyB,CAAC;AAEnE;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACnC,iCAAiC;IACjC,MAAM,EAAE,uBAAuB,CAAC;IAChC,+CAA+C;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uCAAuC;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4EAA4E;IAC5E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oCAAoC;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,mDAAmD;IACnD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oDAAoD;IACpD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEhE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,oBAAoB,EAC7B,oBAAoB,CAAC,EAAE,MAAM,GAC5B,IAAI,CAsBN;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,iBAAiB,CAAC,EAAE,MAAM,GACzB,IAAI,CAqBN;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,KAAK,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,EAC1D,iBAAiB,CAAC,EAAE,MAAM,GACzB,IAAI,CAmBN"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared audit-log helper for `@cleocode/worktree` lifecycle operations (T9805).
|
|
3
|
+
*
|
|
4
|
+
* Provides {@link appendWorktreeAuditLog} — the single DRY chokepoint for every
|
|
5
|
+
* write to `<projectRoot>/.cleo/audit/worktree-lifecycle.jsonl` from within the
|
|
6
|
+
* `@cleocode/worktree` package. This mirrors the pattern in
|
|
7
|
+
* `packages/core/src/worktree/audit.ts` but lives in the `worktree` package so
|
|
8
|
+
* that `worktree-create.ts`, `worktree-destroy.ts`, and `worktree-prune.ts` do
|
|
9
|
+
* not depend on `@cleocode/core` (which would create a circular dependency).
|
|
10
|
+
*
|
|
11
|
+
* Also provides {@link resolveWorktreeIndexPath} — canonical path to the
|
|
12
|
+
* per-repo sentinel index `<gitRoot>/.cleo/worktrees.json` used by council
|
|
13
|
+
* verdict D009 (T9805).
|
|
14
|
+
*
|
|
15
|
+
* @task T9805
|
|
16
|
+
* @epic T9800
|
|
17
|
+
*/
|
|
18
|
+
import { appendFileSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
19
|
+
import { dirname, join } from 'node:path';
|
|
20
|
+
/** Relative path within the project root for the worktree lifecycle audit log. */
|
|
21
|
+
export const WORKTREE_LIFECYCLE_AUDIT_FILE = '.cleo/audit/worktree-lifecycle.jsonl';
|
|
22
|
+
/**
|
|
23
|
+
* Relative path within the git repository root for the worktree sentinel index.
|
|
24
|
+
*
|
|
25
|
+
* The sentinel index is a JSON file that tracks every active worktree registered
|
|
26
|
+
* by `cleo orchestrate spawn`. When a worktree is destroyed or pruned the entry
|
|
27
|
+
* is removed so external tooling can read a single file to enumerate all live
|
|
28
|
+
* worktrees without scanning the XDG data directory.
|
|
29
|
+
*
|
|
30
|
+
* Per council verdict D009 (T9805): destroy and prune MUST update this file.
|
|
31
|
+
*/
|
|
32
|
+
export const WORKTREE_INDEX_RELATIVE_PATH = '.cleo/worktrees.json';
|
|
33
|
+
/**
|
|
34
|
+
* Resolve the absolute path to the per-repo worktree sentinel index.
|
|
35
|
+
*
|
|
36
|
+
* The sentinel index lives at `<gitRoot>/.cleo/worktrees.json` and tracks
|
|
37
|
+
* every active worktree registered by `cleo orchestrate spawn`. Destroying
|
|
38
|
+
* or pruning a worktree MUST remove the entry from this file per council
|
|
39
|
+
* verdict D009.
|
|
40
|
+
*
|
|
41
|
+
* @param gitRoot - Absolute path to the git repository root.
|
|
42
|
+
* @returns Absolute path to `<gitRoot>/.cleo/worktrees.json`.
|
|
43
|
+
*
|
|
44
|
+
* @task T9805
|
|
45
|
+
*/
|
|
46
|
+
export function resolveWorktreeIndexPath(gitRoot) {
|
|
47
|
+
return join(gitRoot, WORKTREE_INDEX_RELATIVE_PATH);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Append a single JSONL entry to the worktree lifecycle audit log.
|
|
51
|
+
*
|
|
52
|
+
* The function is best-effort: any I/O error is swallowed so an audit
|
|
53
|
+
* failure never blocks the underlying operation. The log directory is
|
|
54
|
+
* created if it does not yet exist.
|
|
55
|
+
*
|
|
56
|
+
* @param projectRoot - Absolute path to the CLEO project root.
|
|
57
|
+
* @param payload - Audit entry fields (timestamp auto-filled when absent).
|
|
58
|
+
* @param auditLogPathOverride - Optional override for the log file path (testing).
|
|
59
|
+
*
|
|
60
|
+
* @task T9805
|
|
61
|
+
*/
|
|
62
|
+
export function appendWorktreeAuditLog(projectRoot, payload, auditLogPathOverride) {
|
|
63
|
+
try {
|
|
64
|
+
const filePath = auditLogPathOverride !== undefined
|
|
65
|
+
? auditLogPathOverride
|
|
66
|
+
: join(projectRoot, WORKTREE_LIFECYCLE_AUDIT_FILE);
|
|
67
|
+
mkdirSync(dirname(filePath), { recursive: true });
|
|
68
|
+
const record = {
|
|
69
|
+
ts: payload.timestamp ?? new Date().toISOString(),
|
|
70
|
+
action: payload.action,
|
|
71
|
+
xdgPath: payload.xdgPath,
|
|
72
|
+
...(payload.taskId !== undefined ? { taskId: payload.taskId } : {}),
|
|
73
|
+
...(payload.branch !== undefined ? { branch: payload.branch } : {}),
|
|
74
|
+
agentId: payload.agentId ?? process.env['CLEO_AGENT_ID'] ?? 'cleo',
|
|
75
|
+
...(payload.reason !== undefined ? { reason: payload.reason } : {}),
|
|
76
|
+
success: payload.success,
|
|
77
|
+
...(payload.error !== undefined ? { error: payload.error } : {}),
|
|
78
|
+
};
|
|
79
|
+
appendFileSync(filePath, `${JSON.stringify(record)}\n`, { encoding: 'utf-8' });
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
// Intentionally swallowed — audit writes must never block lifecycle ops.
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Remove a worktree entry from the sentinel index at
|
|
87
|
+
* `<gitRoot>/.cleo/worktrees.json`.
|
|
88
|
+
*
|
|
89
|
+
* Per council verdict D009 (T9805): every destroy and prune operation MUST
|
|
90
|
+
* call this helper to keep the sentinel index in sync. Errors are swallowed
|
|
91
|
+
* so a stale index file never blocks a cleanup path.
|
|
92
|
+
*
|
|
93
|
+
* The index is a JSON object keyed by task ID:
|
|
94
|
+
* ```json
|
|
95
|
+
* {
|
|
96
|
+
* "T9805": { "path": "/xdg/path/T9805", "branch": "task/T9805", "createdAt": "..." }
|
|
97
|
+
* }
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* @param gitRoot - Absolute path to the git repository root (where `.cleo/worktrees.json` lives).
|
|
101
|
+
* @param taskId - The task ID to remove from the index.
|
|
102
|
+
* @param indexPathOverride - Optional override for the index file path (testing).
|
|
103
|
+
*
|
|
104
|
+
* @task T9805
|
|
105
|
+
*/
|
|
106
|
+
export function removeWorktreeFromSentinelIndex(gitRoot, taskId, indexPathOverride) {
|
|
107
|
+
try {
|
|
108
|
+
const indexPath = indexPathOverride ?? resolveWorktreeIndexPath(gitRoot);
|
|
109
|
+
let index = {};
|
|
110
|
+
try {
|
|
111
|
+
const raw = readFileSync(indexPath, { encoding: 'utf-8' });
|
|
112
|
+
const parsed = JSON.parse(raw);
|
|
113
|
+
if (parsed !== null && typeof parsed === 'object' && !Array.isArray(parsed)) {
|
|
114
|
+
index = parsed;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
// File does not exist or is corrupt — nothing to remove.
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if (!(taskId in index))
|
|
122
|
+
return; // entry not present, no-op
|
|
123
|
+
delete index[taskId];
|
|
124
|
+
mkdirSync(dirname(indexPath), { recursive: true });
|
|
125
|
+
writeFileSync(indexPath, `${JSON.stringify(index, null, 2)}\n`, { encoding: 'utf-8' });
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
// Intentionally swallowed — index update failures must not block cleanup.
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Add or update a worktree entry in the sentinel index at
|
|
133
|
+
* `<gitRoot>/.cleo/worktrees.json`.
|
|
134
|
+
*
|
|
135
|
+
* Called by `worktree-create.ts` immediately after the worktree is created.
|
|
136
|
+
* Errors are swallowed so index update failures never block spawn.
|
|
137
|
+
*
|
|
138
|
+
* @param gitRoot - Absolute path to the git repository root.
|
|
139
|
+
* @param taskId - The task ID being registered.
|
|
140
|
+
* @param entry - Metadata to store in the index for this task.
|
|
141
|
+
* @param indexPathOverride - Optional override for the index file path (testing).
|
|
142
|
+
*
|
|
143
|
+
* @task T9805
|
|
144
|
+
*/
|
|
145
|
+
export function addWorktreeToSentinelIndex(gitRoot, taskId, entry, indexPathOverride) {
|
|
146
|
+
try {
|
|
147
|
+
const indexPath = indexPathOverride ?? resolveWorktreeIndexPath(gitRoot);
|
|
148
|
+
let index = {};
|
|
149
|
+
try {
|
|
150
|
+
const raw = readFileSync(indexPath, { encoding: 'utf-8' });
|
|
151
|
+
const parsed = JSON.parse(raw);
|
|
152
|
+
if (parsed !== null && typeof parsed === 'object' && !Array.isArray(parsed)) {
|
|
153
|
+
index = parsed;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
catch {
|
|
157
|
+
// File does not exist or is corrupt — start fresh.
|
|
158
|
+
}
|
|
159
|
+
index[taskId] = entry;
|
|
160
|
+
mkdirSync(dirname(indexPath), { recursive: true });
|
|
161
|
+
writeFileSync(indexPath, `${JSON.stringify(index, null, 2)}\n`, { encoding: 'utf-8' });
|
|
162
|
+
}
|
|
163
|
+
catch {
|
|
164
|
+
// Intentionally swallowed — index update failures must not block spawn.
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=worktree-audit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worktree-audit.js","sourceRoot":"","sources":["../src/worktree-audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,cAAc,EAAE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C,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;IACzF,CAAC;IAAC,MAAM,CAAC;QACP,wEAAwE;IAC1E,CAAC;AACH,CAAC"}
|
|
@@ -28,6 +28,11 @@ interface CreateWorktreeResultWithBootstrap extends CreateWorktreeResult {
|
|
|
28
28
|
};
|
|
29
29
|
/** Glob patterns actually excluded via sparse-checkout (T9226). */
|
|
30
30
|
appliedExcludePatterns: string[];
|
|
31
|
+
/**
|
|
32
|
+
* The sparse-checkout scope applied to the worktree (T9807), or `null` when
|
|
33
|
+
* no scope was requested or the operation failed.
|
|
34
|
+
*/
|
|
35
|
+
appliedScope: string | null;
|
|
31
36
|
}
|
|
32
37
|
/**
|
|
33
38
|
* Create a git worktree for an agent task.
|
|
@@ -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,EAEnB,MAAM,qBAAqB,CAAC;AAG7B;;;;;;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;
|
|
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,EAEnB,MAAM,qBAAqB,CAAC;AAG7B;;;;;;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;AA2HD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAsB,cAAc,CAClC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,iCAAiC,CAAC,CAyO5C"}
|
package/dist/worktree-create.js
CHANGED
|
@@ -16,8 +16,38 @@ import { existsSync, mkdirSync, readdirSync, rmSync } from 'node:fs';
|
|
|
16
16
|
import { join } from 'node:path';
|
|
17
17
|
import { copyPathsWithReflock } from './copy-on-write.js';
|
|
18
18
|
import { BRANCH_LOCK_ERROR_CODES } from '@cleocode/contracts';
|
|
19
|
+
import { getCleoWorktreesRoot } from '@cleocode/paths';
|
|
19
20
|
import { getGitRoot, gitSilent, gitSync, resolveHeadRef } from './git.js';
|
|
20
21
|
import { computeProjectHash, resolveTaskWorktreePath, resolveWorktreeRootForHash, } from './paths.js';
|
|
22
|
+
import { addWorktreeToSentinelIndex, appendWorktreeAuditLog } from './worktree-audit.js';
|
|
23
|
+
/**
|
|
24
|
+
* Assert that `targetPath` sits inside the canonical XDG worktrees root
|
|
25
|
+
* (`<cleoHome>/worktrees/`). Throws `E_WT_LOCATION_FORBIDDEN` if not.
|
|
26
|
+
*
|
|
27
|
+
* Per AC4 / council verdict D009: there is NO escape hatch — not even a
|
|
28
|
+
* `CLEO_FORCE_LOCATION` env var. Worktrees outside the canonical location
|
|
29
|
+
* are unconditionally rejected.
|
|
30
|
+
*
|
|
31
|
+
* @param targetPath - Absolute path that will be passed to `git worktree add`.
|
|
32
|
+
* @throws Error with code `E_WT_LOCATION_FORBIDDEN` when outside canonical root.
|
|
33
|
+
*
|
|
34
|
+
* @task T9809
|
|
35
|
+
*/
|
|
36
|
+
function assertCanonicalWorktreeLocation(targetPath) {
|
|
37
|
+
const canonicalRoot = getCleoWorktreesRoot();
|
|
38
|
+
// Normalise both paths to use forward slashes and ensure the root ends with
|
|
39
|
+
// a separator so we don't accidentally match a sibling path that shares a
|
|
40
|
+
// prefix (e.g. `/cleo-home/worktrees-other/` vs `/cleo-home/worktrees/`).
|
|
41
|
+
const normalRoot = canonicalRoot.endsWith('/') ? canonicalRoot : `${canonicalRoot}/`;
|
|
42
|
+
const normalTarget = targetPath.replaceAll('\\', '/');
|
|
43
|
+
const normalRootFwd = normalRoot.replaceAll('\\', '/');
|
|
44
|
+
if (!normalTarget.startsWith(normalRootFwd)) {
|
|
45
|
+
throw Object.assign(new Error(`E_WT_LOCATION_FORBIDDEN: worktree path "${targetPath}" is outside the ` +
|
|
46
|
+
`canonical XDG location "${canonicalRoot}". ` +
|
|
47
|
+
`All worktrees MUST live under <cleoHome>/worktrees/<projectHash>/<taskId>/. ` +
|
|
48
|
+
`There is no override — see Saga T9800 SG-WORKTREE-CANON and ADR decision D009.`), { code: 'E_WT_LOCATION_FORBIDDEN', targetPath, canonicalRoot });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
21
51
|
import { runWorktreeHooks } from './worktree-hooks.js';
|
|
22
52
|
import { applyIncludePatterns, loadWorktreeIncludePatterns } from './worktree-include.js';
|
|
23
53
|
/**
|
|
@@ -41,6 +71,35 @@ function applySpawnCloneExcludeFilter(worktreePath, excludePatterns) {
|
|
|
41
71
|
return [];
|
|
42
72
|
}
|
|
43
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Apply T9807 cone-mode sparse-checkout to limit the worktree to a scope
|
|
76
|
+
* directory prefix (e.g. `packages/cleo`).
|
|
77
|
+
*
|
|
78
|
+
* Uses `git sparse-checkout init --cone` followed by
|
|
79
|
+
* `git sparse-checkout set <scope>` — cone mode gives the fastest checkout
|
|
80
|
+
* performance by working at directory granularity instead of arbitrary globs.
|
|
81
|
+
*
|
|
82
|
+
* Failures are silently swallowed — the worktree stays in full-checkout mode
|
|
83
|
+
* when the operation is not supported by the installed git version.
|
|
84
|
+
*
|
|
85
|
+
* @param worktreePath - Absolute path to the newly created worktree.
|
|
86
|
+
* @param scope - Directory prefix to check out (e.g. `packages/cleo`).
|
|
87
|
+
* @returns The applied scope string, or `null` when the operation failed.
|
|
88
|
+
*
|
|
89
|
+
* @task T9807
|
|
90
|
+
*/
|
|
91
|
+
function applySpawnScope(worktreePath, scope) {
|
|
92
|
+
if (!scope.trim())
|
|
93
|
+
return null;
|
|
94
|
+
try {
|
|
95
|
+
gitSilent(['sparse-checkout', 'init', '--cone'], worktreePath);
|
|
96
|
+
gitSilent(['sparse-checkout', 'set', scope.trim()], worktreePath);
|
|
97
|
+
return scope.trim();
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
44
103
|
function isPathSpecifiedInInclude(patterns, targetPath) {
|
|
45
104
|
return patterns.some((p) => {
|
|
46
105
|
if (p.negated)
|
|
@@ -106,6 +165,10 @@ export async function createWorktree(projectRoot, options) {
|
|
|
106
165
|
const branch = options.branchName ?? `task/${taskId}`;
|
|
107
166
|
const baseRef = options.baseRef ?? resolveHeadRef(gitRoot);
|
|
108
167
|
const worktreePath = resolveTaskWorktreePath(projectHash, taskId);
|
|
168
|
+
// AC1 / T9809: reject any path outside the canonical XDG worktrees root.
|
|
169
|
+
// This check runs BEFORE any filesystem mutation so the error is always clean.
|
|
170
|
+
// There is NO escape hatch — per council verdict D009 the ban is absolute.
|
|
171
|
+
assertCanonicalWorktreeLocation(worktreePath);
|
|
109
172
|
// Remove stale worktree at this path if it exists (left from a prior run).
|
|
110
173
|
// Dirty worktrees are preserved to avoid losing uncommitted agent work.
|
|
111
174
|
if (existsSync(worktreePath)) {
|
|
@@ -188,6 +251,15 @@ export async function createWorktree(projectRoot, options) {
|
|
|
188
251
|
// patterns from the worktree via sparse-checkout. Best-effort.
|
|
189
252
|
const excludePatterns = options.spawnCloneExclude ?? [];
|
|
190
253
|
const appliedExcludePatterns = excludePatterns.length > 0 ? applySpawnCloneExcludeFilter(worktreePath, excludePatterns) : [];
|
|
254
|
+
// T9807 — spawn scope: limit the worktree to a directory prefix via cone-mode
|
|
255
|
+
// sparse-checkout (e.g. `packages/cleo` for a CLI-only task). Best-effort;
|
|
256
|
+
// falls back to full checkout when the operation fails or is not supported.
|
|
257
|
+
// Only applied when no exclude-patterns sparse-checkout is already active to
|
|
258
|
+
// avoid conflicting sparse-checkout modes.
|
|
259
|
+
const spawnScope = options.spawnScope ?? null;
|
|
260
|
+
const appliedScope = spawnScope && appliedExcludePatterns.length === 0
|
|
261
|
+
? applySpawnScope(worktreePath, spawnScope)
|
|
262
|
+
: null;
|
|
191
263
|
// Run post-create hooks before returning the handle.
|
|
192
264
|
const postCreateHookResults = await runWorktreeHooks(hooks, 'post-create', worktreePath);
|
|
193
265
|
// Apply .cleo/worktree-include patterns.
|
|
@@ -251,6 +323,17 @@ export async function createWorktree(projectRoot, options) {
|
|
|
251
323
|
'All your commits must land on YOUR branch only.',
|
|
252
324
|
'',
|
|
253
325
|
].join('\n');
|
|
326
|
+
// T9805 AC3: Append audit log entry for every worktree creation.
|
|
327
|
+
appendWorktreeAuditLog(projectRoot, {
|
|
328
|
+
action: reused ? 'adopt' : 'create',
|
|
329
|
+
xdgPath: worktreePath,
|
|
330
|
+
taskId,
|
|
331
|
+
branch,
|
|
332
|
+
reason: reused ? 'branch-reuse' : 'spawn',
|
|
333
|
+
success: true,
|
|
334
|
+
});
|
|
335
|
+
// T9805 D009: Register this worktree in the sentinel index.
|
|
336
|
+
addWorktreeToSentinelIndex(gitRoot, taskId, { path: worktreePath, branch, createdAt });
|
|
254
337
|
return {
|
|
255
338
|
path: worktreePath,
|
|
256
339
|
branch,
|
|
@@ -265,6 +348,7 @@ export async function createWorktree(projectRoot, options) {
|
|
|
265
348
|
hookResults: postCreateHookResults,
|
|
266
349
|
appliedPatterns,
|
|
267
350
|
appliedExcludePatterns,
|
|
351
|
+
appliedScope,
|
|
268
352
|
bootstrap: {
|
|
269
353
|
copiedPaths,
|
|
270
354
|
failedPaths,
|
|
@@ -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,WAAW,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAOjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"worktree-create.js","sourceRoot":"","sources":["../src/worktree-create.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAOjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAwB1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1E,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,0BAA0B,GAC3B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,0BAA0B,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAEzF;;;;;;;;;;;;GAYG;AACH,SAAS,+BAA+B,CAAC,UAAkB;IACzD,MAAM,aAAa,GAAG,oBAAoB,EAAE,CAAC;IAC7C,4EAA4E;IAC5E,0EAA0E;IAC1E,0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,MAAM;QACN,WAAW;QACX,SAAS;QACT,MAAM;QACN,MAAM;QACN,OAAO;QACP,QAAQ;QACR,WAAW,EAAE,qBAAqB;QAClC,eAAe;QACf,sBAAsB;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;AAMzF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,eAAe,CACnC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,qBAAqB,CAAC,CA4HhC"}
|
package/dist/worktree-destroy.js
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
import { existsSync, rmSync } from 'node:fs';
|
|
13
13
|
import { getGitRoot, gitSilent, gitSync } from './git.js';
|
|
14
14
|
import { computeProjectHash, resolveTaskWorktreePath } from './paths.js';
|
|
15
|
+
import { appendWorktreeAuditLog, removeWorktreeFromSentinelIndex } from './worktree-audit.js';
|
|
15
16
|
import { runWorktreeHooks } from './worktree-hooks.js';
|
|
16
17
|
/**
|
|
17
18
|
* Destroy the git worktree for a task.
|
|
@@ -140,6 +141,21 @@ export async function destroyWorktree(projectRoot, options) {
|
|
|
140
141
|
}
|
|
141
142
|
}
|
|
142
143
|
}
|
|
144
|
+
const destroySucceeded = worktreeRemoved && !error;
|
|
145
|
+
// T9805 AC3: Append audit log entry for every destroy attempt.
|
|
146
|
+
appendWorktreeAuditLog(projectRoot, {
|
|
147
|
+
action: 'destroy',
|
|
148
|
+
xdgPath: worktreePath,
|
|
149
|
+
taskId,
|
|
150
|
+
branch,
|
|
151
|
+
reason: options.reason ?? 'manual',
|
|
152
|
+
success: destroySucceeded,
|
|
153
|
+
...(error !== undefined ? { error } : {}),
|
|
154
|
+
});
|
|
155
|
+
// T9805 D009: Remove the entry from the sentinel index when destruction succeeded.
|
|
156
|
+
if (destroySucceeded) {
|
|
157
|
+
removeWorktreeFromSentinelIndex(gitRoot, taskId);
|
|
158
|
+
}
|
|
143
159
|
return { taskId, worktreeRemoved, branchDeleted, error, dirty, force, hookResults };
|
|
144
160
|
}
|
|
145
161
|
//# sourceMappingURL=worktree-destroy.js.map
|
|
@@ -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,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,WAAmB,EACnB,OAA+B;IAE/B,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,EAAE,KAAK,GAAG,KAAK,EAAE,KAAK,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC;IAE3E,MAAM,OAAO,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;IACxC,MAAM,WAAW,GAAG,kBAAkB,CAAC,WAAW,C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K,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACjE,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,KAAK,GAAG,6BAA6B,OAAO,EAAE,CAAC;YACjD,CAAC;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"}
|
|
@@ -45,6 +45,14 @@ export declare function loadWorktreeIncludePatterns(projectRoot: string): Worktr
|
|
|
45
45
|
* Already-existing paths in the worktree are skipped (not overwritten) — git
|
|
46
46
|
* worktree add may have already created them.
|
|
47
47
|
*
|
|
48
|
+
* When the target path has a parent directory that does not yet exist in the
|
|
49
|
+
* worktree (e.g. `.vscode/settings.json` when `.vscode/` was never created),
|
|
50
|
+
* the parent is created with `mkdirSync({ recursive: true })` before the
|
|
51
|
+
* `symlinkSync` call. This prevents the `ENOENT` error that was causing
|
|
52
|
+
* the repeated `[worktree] include-pattern symlink failed` log messages
|
|
53
|
+
* during every spawn for projects whose `.cleo/worktree-include` lists
|
|
54
|
+
* nested paths whose parent directories are not checked in (T9807).
|
|
55
|
+
*
|
|
48
56
|
* @param patterns - Parsed include patterns from {@link loadWorktreeIncludePatterns}.
|
|
49
57
|
* @param projectRoot - Absolute path to the project root (symlink target base).
|
|
50
58
|
* @param worktreePath - Absolute path to the worktree directory.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worktree-include.d.ts","sourceRoot":"","sources":["../src/worktree-include.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAIH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAIlE;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,MAAM,GAAG,sBAAsB,EAAE,CAoBzF;AAED
|
|
1
|
+
{"version":3,"file":"worktree-include.d.ts","sourceRoot":"","sources":["../src/worktree-include.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAIH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAIlE;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,MAAM,GAAG,sBAAsB,EAAE,CAoBzF;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;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
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
*
|
|
22
22
|
* @task T1161
|
|
23
23
|
*/
|
|
24
|
-
import { existsSync, readFileSync, symlinkSync } from 'node:fs';
|
|
25
|
-
import { join, resolve } from 'node:path';
|
|
24
|
+
import { existsSync, mkdirSync, readFileSync, symlinkSync } from 'node:fs';
|
|
25
|
+
import { dirname, join, resolve } from 'node:path';
|
|
26
26
|
const INCLUDE_FILE_NAME = 'worktree-include';
|
|
27
27
|
/**
|
|
28
28
|
* Load and parse the `.cleo/worktree-include` file from the project root.
|
|
@@ -65,6 +65,14 @@ export function loadWorktreeIncludePatterns(projectRoot) {
|
|
|
65
65
|
* Already-existing paths in the worktree are skipped (not overwritten) — git
|
|
66
66
|
* worktree add may have already created them.
|
|
67
67
|
*
|
|
68
|
+
* When the target path has a parent directory that does not yet exist in the
|
|
69
|
+
* worktree (e.g. `.vscode/settings.json` when `.vscode/` was never created),
|
|
70
|
+
* the parent is created with `mkdirSync({ recursive: true })` before the
|
|
71
|
+
* `symlinkSync` call. This prevents the `ENOENT` error that was causing
|
|
72
|
+
* the repeated `[worktree] include-pattern symlink failed` log messages
|
|
73
|
+
* during every spawn for projects whose `.cleo/worktree-include` lists
|
|
74
|
+
* nested paths whose parent directories are not checked in (T9807).
|
|
75
|
+
*
|
|
68
76
|
* @param patterns - Parsed include patterns from {@link loadWorktreeIncludePatterns}.
|
|
69
77
|
* @param projectRoot - Absolute path to the project root (symlink target base).
|
|
70
78
|
* @param worktreePath - Absolute path to the worktree directory.
|
|
@@ -84,6 +92,18 @@ export function applyIncludePatterns(patterns, projectRoot, worktreePath) {
|
|
|
84
92
|
// Skip if a file/dir/symlink already exists at this path in the worktree.
|
|
85
93
|
if (existsSync(targetPath))
|
|
86
94
|
continue;
|
|
95
|
+
// T9807 — ensure the parent directory exists in the worktree before calling
|
|
96
|
+
// symlinkSync. Patterns like `.vscode/settings.json` require `.vscode/` to
|
|
97
|
+
// exist first; without this step, symlinkSync throws ENOENT for every spawn
|
|
98
|
+
// on machines where the parent directory was never checked in.
|
|
99
|
+
const parentDir = dirname(targetPath);
|
|
100
|
+
try {
|
|
101
|
+
mkdirSync(parentDir, { recursive: true });
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
process.stderr.write(`[worktree] include-pattern parent-dir creation failed: ${entry.pattern}\n`);
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
87
107
|
try {
|
|
88
108
|
symlinkSync(sourcePath, targetPath);
|
|
89
109
|
applied.push(entry);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worktree-include.js","sourceRoot":"","sources":["../src/worktree-include.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"worktree-include.js","sourceRoot":"","sources":["../src/worktree-include.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGnD,MAAM,iBAAiB,GAAG,kBAAkB,CAAC;AAE7C;;;;;;;;;GASG;AACH,MAAM,UAAU,2BAA2B,CAAC,WAAmB;IAC7D,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,EAAE,OAAO,EAAE,iBAAiB,CAAC,CAAC;IAC/D,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;QAAE,OAAO,EAAE,CAAC;IAErC,MAAM,GAAG,GAAG,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC5C,MAAM,QAAQ,GAA6B,EAAE,CAAC;IAE9C,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACnC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAC5B,gCAAgC;QAChC,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,SAAS;QAElD,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QACxC,MAAM,OAAO,GAAG,OAAO,CAAC,CAA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,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;QAAC,MAAM,CAAC;YACP,oEAAoE;YACpE,4BAA4B;YAC5B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,8CAA8C,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;QACxF,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/worktree-prune.d.ts
CHANGED
|
@@ -5,9 +5,15 @@
|
|
|
5
5
|
* the provided `preserveTaskIds` set, and optionally runs `git worktree prune`
|
|
6
6
|
* to clean up stale git administrative entries.
|
|
7
7
|
*
|
|
8
|
+
* Supports an `--idle-days` abandonment-timeout threshold (T9805 AC2): when
|
|
9
|
+
* set, worktrees whose branch tip is older than `idleDays` days AND which have
|
|
10
|
+
* no open PR are also eligible for removal, even if their task ID is not in the
|
|
11
|
+
* orphan set.
|
|
12
|
+
*
|
|
8
13
|
* Called periodically by `cleo sentient tick` via `worktree-dispatch.ts`.
|
|
9
14
|
*
|
|
10
15
|
* @task T1161
|
|
16
|
+
* @task T9805
|
|
11
17
|
*/
|
|
12
18
|
import type { PruneWorktreesOptions, PruneWorktreesResult } from '@cleocode/contracts';
|
|
13
19
|
/**
|
|
@@ -16,12 +22,16 @@ import type { PruneWorktreesOptions, PruneWorktreesResult } from '@cleocode/cont
|
|
|
16
22
|
* Algorithm:
|
|
17
23
|
* 1. Optionally run `git worktree prune` to clean up stale git admin entries.
|
|
18
24
|
* 2. Read all subdirectory entries under the project's worktree root.
|
|
19
|
-
* 3. For each entry NOT in `preserveTaskIds
|
|
25
|
+
* 3. For each entry NOT in `preserveTaskIds` (or idle beyond `idleDays`),
|
|
26
|
+
* unlock and remove the worktree.
|
|
27
|
+
* 4. Append an audit-log entry for each removal.
|
|
28
|
+
* 5. Remove the entry from the sentinel index when removal succeeds.
|
|
20
29
|
*
|
|
21
30
|
* @param options - Prune options with project root and optional preserve list.
|
|
22
31
|
* @returns Result listing removed paths and any errors.
|
|
23
32
|
*
|
|
24
33
|
* @task T1161
|
|
34
|
+
* @task T9805
|
|
25
35
|
*/
|
|
26
36
|
export declare function pruneWorktrees(options: PruneWorktreesOptions): PruneWorktreesResult;
|
|
27
37
|
//# sourceMappingURL=worktree-prune.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worktree-prune.d.ts","sourceRoot":"","sources":["../src/worktree-prune.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"worktree-prune.d.ts","sourceRoot":"","sources":["../src/worktree-prune.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAKH,OAAO,KAAK,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAKvF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,oBAAoB,CA+GnF"}
|
package/dist/worktree-prune.js
CHANGED
|
@@ -5,38 +5,57 @@
|
|
|
5
5
|
* the provided `preserveTaskIds` set, and optionally runs `git worktree prune`
|
|
6
6
|
* to clean up stale git administrative entries.
|
|
7
7
|
*
|
|
8
|
+
* Supports an `--idle-days` abandonment-timeout threshold (T9805 AC2): when
|
|
9
|
+
* set, worktrees whose branch tip is older than `idleDays` days AND which have
|
|
10
|
+
* no open PR are also eligible for removal, even if their task ID is not in the
|
|
11
|
+
* orphan set.
|
|
12
|
+
*
|
|
8
13
|
* Called periodically by `cleo sentient tick` via `worktree-dispatch.ts`.
|
|
9
14
|
*
|
|
10
15
|
* @task T1161
|
|
16
|
+
* @task T9805
|
|
11
17
|
*/
|
|
18
|
+
import { execFileSync } from 'node:child_process';
|
|
12
19
|
import { existsSync, readdirSync, rmSync } from 'node:fs';
|
|
13
20
|
import { join } from 'node:path';
|
|
14
21
|
import { getGitRoot, gitSilent } from './git.js';
|
|
15
22
|
import { computeProjectHash, resolveWorktreeRootForHash } from './paths.js';
|
|
23
|
+
import { appendWorktreeAuditLog, removeWorktreeFromSentinelIndex } from './worktree-audit.js';
|
|
16
24
|
/**
|
|
17
25
|
* Prune orphaned agent worktrees for a project.
|
|
18
26
|
*
|
|
19
27
|
* Algorithm:
|
|
20
28
|
* 1. Optionally run `git worktree prune` to clean up stale git admin entries.
|
|
21
29
|
* 2. Read all subdirectory entries under the project's worktree root.
|
|
22
|
-
* 3. For each entry NOT in `preserveTaskIds
|
|
30
|
+
* 3. For each entry NOT in `preserveTaskIds` (or idle beyond `idleDays`),
|
|
31
|
+
* unlock and remove the worktree.
|
|
32
|
+
* 4. Append an audit-log entry for each removal.
|
|
33
|
+
* 5. Remove the entry from the sentinel index when removal succeeds.
|
|
23
34
|
*
|
|
24
35
|
* @param options - Prune options with project root and optional preserve list.
|
|
25
36
|
* @returns Result listing removed paths and any errors.
|
|
26
37
|
*
|
|
27
38
|
* @task T1161
|
|
39
|
+
* @task T9805
|
|
28
40
|
*/
|
|
29
41
|
export function pruneWorktrees(options) {
|
|
30
|
-
const { projectRoot, preserveTaskIds, gitPrune = true } = options;
|
|
42
|
+
const { projectRoot, preserveTaskIds, gitPrune = true, idleDays } = options;
|
|
31
43
|
const projectHash = computeProjectHash(projectRoot);
|
|
32
44
|
const worktreeRoot = resolveWorktreeRootForHash(projectHash);
|
|
33
45
|
const removed = [];
|
|
34
46
|
const errors = [];
|
|
35
47
|
let gitPruneRan = false;
|
|
48
|
+
let gitRoot;
|
|
49
|
+
try {
|
|
50
|
+
gitRoot = getGitRoot(projectRoot);
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
// If there's no git root, we can still remove dirs — just skip git cmds.
|
|
54
|
+
gitRoot = projectRoot;
|
|
55
|
+
}
|
|
36
56
|
// Step 1: Run git worktree prune if requested.
|
|
37
57
|
if (gitPrune) {
|
|
38
58
|
try {
|
|
39
|
-
const gitRoot = getGitRoot(projectRoot);
|
|
40
59
|
gitSilent(['worktree', 'prune'], gitRoot);
|
|
41
60
|
gitPruneRan = true;
|
|
42
61
|
}
|
|
@@ -46,7 +65,8 @@ export function pruneWorktrees(options) {
|
|
|
46
65
|
}
|
|
47
66
|
}
|
|
48
67
|
// Step 2: Remove orphaned worktree directories.
|
|
49
|
-
|
|
68
|
+
const shouldCheckDirectories = (preserveTaskIds !== undefined || idleDays !== undefined) && existsSync(worktreeRoot);
|
|
69
|
+
if (shouldCheckDirectories) {
|
|
50
70
|
let entries;
|
|
51
71
|
try {
|
|
52
72
|
entries = readdirSync(worktreeRoot);
|
|
@@ -54,38 +74,107 @@ export function pruneWorktrees(options) {
|
|
|
54
74
|
catch {
|
|
55
75
|
return { removed: 0, removedPaths: [], errors, gitPruneRan };
|
|
56
76
|
}
|
|
57
|
-
let gitRoot;
|
|
58
|
-
try {
|
|
59
|
-
gitRoot = getGitRoot(projectRoot);
|
|
60
|
-
}
|
|
61
|
-
catch {
|
|
62
|
-
// If there's no git root, we can still remove dirs — just skip git cmds.
|
|
63
|
-
gitRoot = projectRoot;
|
|
64
|
-
}
|
|
65
77
|
for (const entry of entries) {
|
|
66
|
-
if (preserveTaskIds.has(entry))
|
|
67
|
-
continue;
|
|
68
78
|
const worktreePath = join(worktreeRoot, entry);
|
|
79
|
+
// Determine whether this entry is a prune candidate.
|
|
80
|
+
let reason = 'orphan';
|
|
81
|
+
let shouldPrune = false;
|
|
82
|
+
if (preserveTaskIds !== undefined) {
|
|
83
|
+
if (preserveTaskIds.has(entry)) {
|
|
84
|
+
// Still check idle-days even for preserved IDs when idleDays is set.
|
|
85
|
+
if (idleDays !== undefined && isWorktreeIdle(worktreePath, idleDays)) {
|
|
86
|
+
shouldPrune = true;
|
|
87
|
+
reason = `idle-${idleDays}d`;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
shouldPrune = true;
|
|
92
|
+
reason = 'orphan';
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else if (idleDays !== undefined) {
|
|
96
|
+
// preserveTaskIds not set — only idle-days check applies.
|
|
97
|
+
if (isWorktreeIdle(worktreePath, idleDays)) {
|
|
98
|
+
shouldPrune = true;
|
|
99
|
+
reason = `idle-${idleDays}d`;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (!shouldPrune)
|
|
103
|
+
continue;
|
|
69
104
|
// Try git-aware removal first.
|
|
70
105
|
gitSilent(['worktree', 'unlock', worktreePath], gitRoot);
|
|
106
|
+
let pruneSuccess = false;
|
|
71
107
|
if (gitSilent(['worktree', 'remove', '--force', worktreePath], gitRoot)) {
|
|
72
108
|
removed.push(worktreePath);
|
|
109
|
+
pruneSuccess = true;
|
|
73
110
|
}
|
|
74
111
|
else {
|
|
75
112
|
// Fall back to rmSync for directories that aren't registered worktrees.
|
|
76
113
|
try {
|
|
77
114
|
rmSync(worktreePath, { recursive: true, force: true });
|
|
78
115
|
removed.push(worktreePath);
|
|
116
|
+
pruneSuccess = true;
|
|
79
117
|
}
|
|
80
118
|
catch (err) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
119
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
120
|
+
errors.push({ path: worktreePath, reason: errMsg });
|
|
121
|
+
// T9805 AC3: Audit the failed removal.
|
|
122
|
+
appendWorktreeAuditLog(projectRoot, {
|
|
123
|
+
action: 'prune',
|
|
124
|
+
xdgPath: worktreePath,
|
|
125
|
+
taskId: entry,
|
|
126
|
+
reason,
|
|
127
|
+
success: false,
|
|
128
|
+
error: errMsg,
|
|
84
129
|
});
|
|
85
130
|
}
|
|
86
131
|
}
|
|
132
|
+
if (pruneSuccess) {
|
|
133
|
+
// T9805 AC3: Audit the successful removal.
|
|
134
|
+
appendWorktreeAuditLog(projectRoot, {
|
|
135
|
+
action: 'prune',
|
|
136
|
+
xdgPath: worktreePath,
|
|
137
|
+
taskId: entry,
|
|
138
|
+
reason,
|
|
139
|
+
success: true,
|
|
140
|
+
});
|
|
141
|
+
// T9805 D009: Remove from sentinel index.
|
|
142
|
+
removeWorktreeFromSentinelIndex(gitRoot, entry);
|
|
143
|
+
}
|
|
87
144
|
}
|
|
88
145
|
}
|
|
89
146
|
return { removed: removed.length, removedPaths: removed, errors, gitPruneRan };
|
|
90
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* Check whether the last commit on a worktree's branch is older than
|
|
150
|
+
* `thresholdDays` days (abandonment-timeout heuristic for T9805 AC2).
|
|
151
|
+
*
|
|
152
|
+
* Returns `false` when git is unavailable or the path is not a valid worktree.
|
|
153
|
+
*
|
|
154
|
+
* @param worktreePath - Absolute path to the worktree directory.
|
|
155
|
+
* @param thresholdDays - Number of idle days before the worktree is eligible.
|
|
156
|
+
* @returns `true` if the last commit is older than `thresholdDays` days.
|
|
157
|
+
*
|
|
158
|
+
* @internal
|
|
159
|
+
*/
|
|
160
|
+
function isWorktreeIdle(worktreePath, thresholdDays) {
|
|
161
|
+
try {
|
|
162
|
+
const epochStr = execFileSync('git', ['-C', worktreePath, 'log', '-1', '--format=%ct'], {
|
|
163
|
+
encoding: 'utf-8',
|
|
164
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
165
|
+
timeout: 10_000,
|
|
166
|
+
}).trim();
|
|
167
|
+
if (epochStr.length === 0)
|
|
168
|
+
return false;
|
|
169
|
+
const lastCommitEpochMs = Number.parseInt(epochStr, 10) * 1000;
|
|
170
|
+
if (Number.isNaN(lastCommitEpochMs))
|
|
171
|
+
return false;
|
|
172
|
+
const idleMs = Date.now() - lastCommitEpochMs;
|
|
173
|
+
const idleDaysActual = idleMs / (1000 * 60 * 60 * 24);
|
|
174
|
+
return idleDaysActual >= thresholdDays;
|
|
175
|
+
}
|
|
176
|
+
catch {
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
91
180
|
//# sourceMappingURL=worktree-prune.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worktree-prune.js","sourceRoot":"","sources":["../src/worktree-prune.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"worktree-prune.js","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1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cleocode/worktree",
|
|
3
|
-
"version": "2026.5.
|
|
3
|
+
"version": "2026.5.97",
|
|
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,14 +30,14 @@
|
|
|
30
30
|
"author": "CLEO Code <hello@cleocode.dev>",
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@cleocode/contracts": "2026.5.
|
|
34
|
-
"@cleocode/paths": "2026.5.
|
|
33
|
+
"@cleocode/contracts": "2026.5.97",
|
|
34
|
+
"@cleocode/paths": "2026.5.97"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/node": "^24.3.0",
|
|
38
38
|
"typescript": "^6.0.2",
|
|
39
39
|
"vitest": "^4.1.4",
|
|
40
|
-
"@cleocode/core": "2026.5.
|
|
40
|
+
"@cleocode/core": "2026.5.97"
|
|
41
41
|
},
|
|
42
42
|
"repository": {
|
|
43
43
|
"type": "git",
|