@cleocode/contracts 2026.4.113 → 2026.4.115

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 CHANGED
@@ -53,7 +53,9 @@ export type { CittyArgDef, OperationParams, ParamCliDef, ParamDef, ParamType, }
53
53
  export { paramsToCittyArgs } from './operations/params.js';
54
54
  export type { DecisionRecord, SessionBriefingShowParams, SessionBriefingShowResult, SessionContextDriftParams, SessionContextDriftResult, SessionDecisionLogParams, SessionDecisionLogResult, SessionEndParams, SessionEndResult, SessionFindParams, SessionFindResult, SessionGcParams, SessionGcResult, SessionHandoffShowParams, SessionHandoffShowResult, SessionListParams, SessionListResult, SessionOps, SessionRecordAssumptionParams, SessionRecordAssumptionResult, SessionRecordDecisionParams, SessionRecordDecisionResult, SessionResumeParams, SessionResumeResult, SessionShowParams, SessionShowResult, SessionStartParams, SessionStatusParams, SessionStatusResult, SessionSuspendParams, SessionSuspendResult, } from './operations/session.js';
55
55
  export type { ResolvedVariable, SubstitutionContext, SubstitutionOptions, SubstitutionResult, SubstitutionSource, VariableResolver, } from './operations/variable-substitution.js';
56
+ export type { CreateWorktreeOptions, CreateWorktreeResult, DestroyWorktreeOptions, DestroyWorktreeResult, ListWorktreesOptions, PruneWorktreesOptions, PruneWorktreesResult, WorktreeHook, WorktreeHookResult, WorktreeIncludePattern, WorktreeListEntry, } from './operations/worktree.js';
56
57
  export { type AgentHierarchy, type AgentHierarchyEntry, type EscalationChain, type OrchestrationHierarchyAPI, OrchestrationLevel, } from './orchestration-hierarchy.js';
58
+ export { assertPeerIdentity, filterPeerIdentities, isPeerIdentity, type PeerIdentity, type PeerKind, } from './peer.js';
57
59
  export type { PlaybookAgenticNode, PlaybookApproval, PlaybookApprovalNode, PlaybookApprovalStatus, PlaybookDefinition, PlaybookDeterministicNode, PlaybookEdge, PlaybookEnsures, PlaybookErrorHandler, PlaybookInput, PlaybookNode, PlaybookNodeBase, PlaybookNodeOnFailure, PlaybookNodeType, PlaybookPolicy, PlaybookRequires, PlaybookRun, PlaybookRunStatus, } from './playbook.js';
58
60
  export type { AdapterPathProvider } from './provider-paths.js';
59
61
  export type { BottleneckTask, CompleteTaskUnblocked, ContextResult, DashboardResult, LabelCount, LeveragedTask, LogQueryResult, SequenceResult, StatsActivityMetrics, StatsAllTime, StatsCompletionMetrics, StatsCurrentState, StatsCycleTimes, StatsResult, TaskAnalysisResult, TaskDepsResult, TaskRef, TaskRefPriority, TaskSummary, } from './results.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,YAAY,EACV,cAAc,EACd,kBAAkB,EAClB,oBAAoB,EACpB,WAAW,EACX,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,iBAAiB,EACjB,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,QAAQ,GACT,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,oBAAoB,EACpB,yBAAyB,EACzB,yBAAyB,EACzB,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC1B,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,uBAAuB,EACvB,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,cAAc,GACf,MAAM,6BAA6B,CAAC;AAErC,YAAY,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAE7E,YAAY,EACV,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,wBAAwB,EACxB,eAAe,EACf,eAAe,GAChB,MAAM,qBAAqB,CAAC;AAE7B,YAAY,EACV,eAAe,EACf,kBAAkB,EAClB,2BAA2B,EAC3B,gBAAgB,EAChB,oBAAoB,EACpB,SAAS,EACT,YAAY,EACZ,aAAa,GACd,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ClB,iBAAiB,EACjB,QAAQ,EACR,SAAS,GACV,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,YAAY,EACV,cAAc,EACd,kBAAkB,EAClB,oBAAoB,EACpB,WAAW,EACX,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,iBAAiB,EACjB,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,QAAQ,GACT,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,oBAAoB,EACpB,yBAAyB,EACzB,yBAAyB,EACzB,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC1B,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,uBAAuB,EACvB,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,cAAc,GACf,MAAM,6BAA6B,CAAC;AAErC,YAAY,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAE7E,YAAY,EACV,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,wBAAwB,EACxB,eAAe,EACf,eAAe,GAChB,MAAM,qBAAqB,CAAC;AAE7B,YAAY,EACV,eAAe,EACf,kBAAkB,EAClB,2BAA2B,EAC3B,gBAAgB,EAChB,oBAAoB,EACpB,SAAS,EACT,YAAY,EACZ,aAAa,GACd,MAAM,wBAAwB,CAAC;AAEhC,YAAY,EACV,uBAAuB,EACvB,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,cAAc,CAAC;AAEtB,YAAY,EACV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V,YAAY,EACZ,SAAS,EACT,kBAAkB,EAClB,iBAAiB,EACjB,QAAQ,EACR,SAAS,GACV,MAAM,iBAAiB,CAAC"}
package/dist/index.js CHANGED
@@ -25,6 +25,8 @@ export * as ops from './operations/index.js';
25
25
  export { paramsToCittyArgs } from './operations/params.js';
26
26
  // === Orchestration Hierarchy ===
27
27
  export { OrchestrationLevel, } from './orchestration-hierarchy.js';
28
+ // === Peer Identity (T1210 — SDK-first CANT persona contract) ===
29
+ export { assertPeerIdentity, filterPeerIdentities, isPeerIdentity, } from './peer.js';
28
30
  // === Session Types ===
29
31
  export { SessionView } from './session.js';
30
32
  // === Status Registry (MUST be first — everything depends on this) ===
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAyBH,2DAA2D;AAC3D,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC1B,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,uBAAuB,EACvB,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,cAAc,GACf,MAAM,6BAA6B,CAAC;AA0DrC,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,EACvB,yBAAyB,EACzB,yBAAyB,EACzB,mBAAmB,GACpB,MAAM,wBAAwB,CAAC;AA8ChC,iDAAiD;AACjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAwE3D,0BAA0B;AAC1B,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,WAAW,EACX,eAAe,EACf,aAAa,EACb,WAAW,EACX,yBAAyB,EACzB,cAAc,EACd,uBAAuB,GACxB,MAAM,aAAa,CAAC;AAmBrB,2DAA2D;AAC3D,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EACpB,oBAAoB,EACpB,sBAA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,cAAc,GAGf,MAAM,WAAW,CAAC;AA4DnB,wBAAwB;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAa3C,uEAAuE;AACvE,OAAO,EACL,YAAY,EAIZ,aAAa,EAEb,aAAa,EACb,2BAA2B,EAC3B,wBAAwB,EACxB,iBAAiB;AAEjB,gBAAgB;AAChB,qBAAqB,EAErB,gBAAgB,EAEhB,kBAAkB,EAClB,eAAe,EAEf,yBAAyB,EACzB,2BAA2B;AAC3B,YAAY;AACZ,aAAa,EAGb,0BAA0B,EAC1B,uBAAuB;AACvB,sBAAsB;AACtB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AA8C9B,OAAO,EACL,2BAA2B,EAC3B,kBAAkB,EAClB,iBAAiB,EACjB,wBAAwB,EACxB,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,oBAAoB,CAAC;AAiD5B,yCAAyC"}
@@ -20,4 +20,5 @@ export * from './system.js';
20
20
  export * from './tasks.js';
21
21
  export * from './validate.js';
22
22
  export * from './variable-substitution.js';
23
+ export * from './worktree.js';
23
24
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/operations/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/operations/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,eAAe,CAAC"}
@@ -20,4 +20,5 @@ export * from './system.js';
20
20
  export * from './tasks.js';
21
21
  export * from './validate.js';
22
22
  export * from './variable-substitution.js';
23
+ export * from './worktree.js';
23
24
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/operations/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/operations/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,eAAe,CAAC"}
@@ -0,0 +1,264 @@
1
+ /**
2
+ * Worktree backend SDK operation types (T1161).
3
+ *
4
+ * Wire-format types for the `@cleocode/worktree-backend` SDK surface.
5
+ * Defines the contract for createWorktree, destroyWorktree, listWorktrees,
6
+ * and pruneWorktrees operations with XDG path canon (D029) and declarative
7
+ * hooks (D030 native lift of worktrunk missing features).
8
+ *
9
+ * @task T1161
10
+ * @adr ADR-055
11
+ */
12
+ /**
13
+ * A declarative lifecycle hook definition for worktree events.
14
+ *
15
+ * Hooks are executed synchronously (shell commands) or via node spawns
16
+ * in the worktree directory. Mirrors the worktrunk hooks contract lifted
17
+ * natively per D030.
18
+ *
19
+ * @task T1161
20
+ */
21
+ export interface WorktreeHook {
22
+ /** Shell command to run (executed via `sh -c` in the worktree dir). */
23
+ command: string;
24
+ /**
25
+ * When to run the hook.
26
+ *
27
+ * - `post-create` — immediately after `git worktree add` succeeds.
28
+ * - `post-start` — after the agent CWD is established (env vars injected).
29
+ */
30
+ event: 'post-create' | 'post-start';
31
+ /**
32
+ * Optional timeout in milliseconds before the hook is killed.
33
+ *
34
+ * @default 30000
35
+ */
36
+ timeoutMs?: number;
37
+ /**
38
+ * When true, a non-zero exit from this hook causes the worktree operation
39
+ * to fail. When false (default), errors are logged but ignored.
40
+ *
41
+ * @default false
42
+ */
43
+ failOnError?: boolean;
44
+ }
45
+ /**
46
+ * Result of a single hook execution.
47
+ *
48
+ * @task T1161
49
+ */
50
+ export interface WorktreeHookResult {
51
+ /** The hook that was executed. */
52
+ hook: WorktreeHook;
53
+ /** Whether the hook exited with code 0. */
54
+ success: boolean;
55
+ /** Hook stdout (trimmed). */
56
+ stdout: string;
57
+ /** Hook stderr (trimmed). */
58
+ stderr: string;
59
+ /** Exit code (null if killed by timeout). */
60
+ exitCode: number | null;
61
+ /** Duration in milliseconds. */
62
+ durationMs: number;
63
+ }
64
+ /**
65
+ * A parsed entry from `.cleo/worktree-include`.
66
+ *
67
+ * The file lists glob patterns (one per line, `#` comments stripped) that
68
+ * control which files from the main project tree are symlinked or copied
69
+ * into new worktrees on creation. This is a native lift of the worktrunk
70
+ * `.cleo/worktree-include` feature (D030).
71
+ *
72
+ * @task T1161
73
+ */
74
+ export interface WorktreeIncludePattern {
75
+ /** The raw glob pattern string (e.g. `node_modules/.pnpm/**`). */
76
+ pattern: string;
77
+ /**
78
+ * Whether this entry was negated (prefixed with `!`).
79
+ *
80
+ * @default false
81
+ */
82
+ negated: boolean;
83
+ }
84
+ /**
85
+ * Options for creating a new agent worktree.
86
+ *
87
+ * @task T1161
88
+ */
89
+ export interface CreateWorktreeOptions {
90
+ /** The task ID that will own this worktree. */
91
+ taskId: string;
92
+ /** The base ref to branch from (default: current HEAD). */
93
+ baseRef?: string;
94
+ /** Explicit branch name. Defaults to `task/<taskId>`. */
95
+ branchName?: string;
96
+ /**
97
+ * Reason for creation. Used for git worktree lock comment and audit logs.
98
+ *
99
+ * @default 'subagent'
100
+ */
101
+ reason?: 'subagent' | 'experiment' | 'parallel-wave';
102
+ /** Declarative hooks to run after creation. */
103
+ hooks?: WorktreeHook[];
104
+ /**
105
+ * When true, read `.cleo/worktree-include` from the project root and apply
106
+ * any declared include patterns to the new worktree.
107
+ *
108
+ * @default true
109
+ */
110
+ applyIncludePatterns?: boolean;
111
+ /**
112
+ * When true, apply git worktree lock (`git worktree lock`) to prevent
113
+ * accidental pruning by git.
114
+ *
115
+ * @default true
116
+ */
117
+ lockWorktree?: boolean;
118
+ }
119
+ /**
120
+ * Result of a successful worktree creation.
121
+ *
122
+ * @task T1161
123
+ */
124
+ export interface CreateWorktreeResult {
125
+ /**
126
+ * Absolute path to the created worktree directory.
127
+ *
128
+ * Always under `~/.local/share/cleo/worktrees/<projectHash>/<taskId>/`
129
+ * per D029 canonical layout.
130
+ */
131
+ path: string;
132
+ /** Branch name created for this worktree (format: `task/<taskId>`). */
133
+ branch: string;
134
+ /** Base ref the branch was created from. */
135
+ baseRef: string;
136
+ /** Task ID that owns this worktree. */
137
+ taskId: string;
138
+ /** Project hash scoping this worktree under the XDG root. */
139
+ projectHash: string;
140
+ /** ISO 8601 timestamp when the worktree was created. */
141
+ createdAt: string;
142
+ /** Whether git worktree lock was applied. */
143
+ locked: boolean;
144
+ /** Environment variables to inject into the spawned agent process. */
145
+ envVars: Record<string, string>;
146
+ /** Prompt preamble text for agent isolation context. */
147
+ preamble: string;
148
+ /** Results of any post-create hooks that were executed. */
149
+ hookResults: WorktreeHookResult[];
150
+ /** Include patterns that were applied (empty if none). */
151
+ appliedPatterns: WorktreeIncludePattern[];
152
+ }
153
+ /**
154
+ * Options for destroying a worktree.
155
+ *
156
+ * @task T1161
157
+ */
158
+ export interface DestroyWorktreeOptions {
159
+ /** Task ID whose worktree to destroy. */
160
+ taskId: string;
161
+ /**
162
+ * When true, delete the associated git branch after removing the worktree.
163
+ *
164
+ * @default true
165
+ */
166
+ deleteBranch?: boolean;
167
+ /**
168
+ * When true, cherry-pick any commits on the task branch back to the
169
+ * orchestrator's current branch before destroying.
170
+ *
171
+ * @default false
172
+ */
173
+ cherryPickFirst?: boolean;
174
+ }
175
+ /**
176
+ * Result of a worktree destroy operation.
177
+ *
178
+ * @task T1161
179
+ */
180
+ export interface DestroyWorktreeResult {
181
+ /** Task ID that was destroyed. */
182
+ taskId: string;
183
+ /** Whether the worktree directory was successfully removed. */
184
+ worktreeRemoved: boolean;
185
+ /** Whether the task branch was deleted. */
186
+ branchDeleted: boolean;
187
+ /** Whether cherry-pick was attempted and succeeded. */
188
+ cherryPicked: boolean;
189
+ /** Number of commits cherry-picked (0 if none or not requested). */
190
+ commitCount: number;
191
+ /** Error message if any step failed (non-fatal — caller decides). */
192
+ error?: string;
193
+ }
194
+ /**
195
+ * A single entry from the worktree listing.
196
+ *
197
+ * @task T1161
198
+ */
199
+ export interface WorktreeListEntry {
200
+ /** Absolute path to the worktree directory. */
201
+ path: string;
202
+ /** Branch checked out in this worktree. */
203
+ branch: string;
204
+ /**
205
+ * Task ID derived from the worktree directory name.
206
+ *
207
+ * Convention: the last path segment is the taskId.
208
+ */
209
+ taskId: string;
210
+ /** Project hash derived from the path. */
211
+ projectHash: string;
212
+ }
213
+ /**
214
+ * Options for listing worktrees.
215
+ *
216
+ * @task T1161
217
+ */
218
+ export interface ListWorktreesOptions {
219
+ /** Filter to only return worktrees for a specific project hash. */
220
+ projectHash?: string;
221
+ }
222
+ /**
223
+ * Options for pruning orphaned worktrees.
224
+ *
225
+ * @task T1161
226
+ */
227
+ export interface PruneWorktreesOptions {
228
+ /** Absolute path to the project root (used to resolve the worktree root). */
229
+ projectRoot: string;
230
+ /**
231
+ * Set of task IDs to preserve. Any worktree directory whose name is NOT in
232
+ * this set will be pruned.
233
+ *
234
+ * When omitted, only stale git administrative entries are pruned (via
235
+ * `git worktree prune`). No worktree directories are removed.
236
+ */
237
+ preserveTaskIds?: Set<string>;
238
+ /**
239
+ * When true, also run `git worktree prune` to clean up stale git
240
+ * administrative entries even if `preserveTaskIds` is not provided.
241
+ *
242
+ * @default true
243
+ */
244
+ gitPrune?: boolean;
245
+ }
246
+ /**
247
+ * Result of a prune operation.
248
+ *
249
+ * @task T1161
250
+ */
251
+ export interface PruneWorktreesResult {
252
+ /** Number of worktree directories removed. */
253
+ removed: number;
254
+ /** Absolute paths that were removed. */
255
+ removedPaths: string[];
256
+ /** Entries that failed to remove (with reasons). */
257
+ errors: Array<{
258
+ path: string;
259
+ reason: string;
260
+ }>;
261
+ /** Whether `git worktree prune` was run. */
262
+ gitPruneRan: boolean;
263
+ }
264
+ //# sourceMappingURL=worktree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worktree.d.ts","sourceRoot":"","sources":["../../src/operations/worktree.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH;;;;;;;;GAQG;AACH,MAAM,WAAW,YAAY;IAC3B,uEAAuE;IACvE,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,KAAK,EAAE,aAAa,GAAG,YAAY,CAAC;IACpC;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,kCAAkC;IAClC,IAAI,EAAE,YAAY,CAAC;IACnB,2CAA2C;IAC3C,OAAO,EAAE,OAAO,CAAC;IACjB,6BAA6B;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,6BAA6B;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,gCAAgC;IAChC,UAAU,EAAE,MAAM,CAAC;CACpB;AAMD;;;;;;;;;GASG;AACH,MAAM,WAAW,sBAAsB;IACrC,kEAAkE;IAClE,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,OAAO,EAAE,OAAO,CAAC;CAClB;AAMD;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAC;IACf,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yDAAyD;IACzD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,MAAM,CAAC,EAAE,UAAU,GAAG,YAA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AAC;IACpB,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAMD;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,+CAA+C;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,0CAA0C;IAC1C,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,mEAAmE;IACnE,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAMD;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC,6EAA6E;IAC7E,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC9B;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,8CAA8C;IAC9C,OAAO,EAAE,MAAM,CAAC;IAChB,wCAAwC;IACxC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,oDAAoD;IACpD,MAAM,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChD,4CAA4C;IAC5C,WAAW,EAAE,OAAO,CAAC;CACtB"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Worktree backend SDK operation types (T1161).
3
+ *
4
+ * Wire-format types for the `@cleocode/worktree-backend` SDK surface.
5
+ * Defines the contract for createWorktree, destroyWorktree, listWorktrees,
6
+ * and pruneWorktrees operations with XDG path canon (D029) and declarative
7
+ * hooks (D030 native lift of worktrunk missing features).
8
+ *
9
+ * @task T1161
10
+ * @adr ADR-055
11
+ */
12
+ export {};
13
+ //# sourceMappingURL=worktree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worktree.js","sourceRoot":"","sources":["../../src/operations/worktree.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
package/dist/peer.d.ts ADDED
@@ -0,0 +1,125 @@
1
+ /**
2
+ * PeerIdentity — canonical type for CANT agent persona records.
3
+ *
4
+ * Introduced by T1210 (v2026.4.110 Wave 0.2) as the SDK-first contract
5
+ * for agent identity. `packages/cant/src/native-loader.ts` produces
6
+ * `PeerIdentity[]` from the canonical seed-agents path; dispatch and
7
+ * CLI layers consume it to drive `cleo agents list` and spawn routing.
8
+ *
9
+ * Design constraints (ADR-055 / D028 boundary rules):
10
+ * - Lives in `packages/contracts/` — ZERO runtime dependencies.
11
+ * - Consumed by `packages/cant/` (loader) and `packages/cleo/` (CLI).
12
+ * - No cross-package relative imports.
13
+ *
14
+ * @module peer
15
+ * @task T1210
16
+ * @epic T1144
17
+ */
18
+ /**
19
+ * Classification of a peer agent's role in the orchestration hierarchy.
20
+ *
21
+ * Mirrors the three-tier model in {@link AgentSpawnCapability}:
22
+ * - `orchestrator` — coordinates multi-agent workflows; may spawn leads and workers
23
+ * - `lead` — specialist; dispatches workers only
24
+ * - `worker` — terminal; executes tasks, cannot spawn
25
+ * - `subagent` — universal base role; resolved to a specific tier at spawn time
26
+ */
27
+ export type PeerKind = 'orchestrator' | 'lead' | 'worker' | 'subagent';
28
+ /**
29
+ * Canonical identity record for a CANT-defined agent persona.
30
+ *
31
+ * Produced by `loadSeedAgentIdentities()` in `packages/cant/src/native-loader.ts`
32
+ * and consumed by the dispatch layer + `cleo agents list`. Every field is
33
+ * required — loaders MUST supply a value for each field, using empty strings
34
+ * for absent optional content in the source `.cant` file.
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * import type { PeerIdentity } from '@cleocode/contracts';
39
+ *
40
+ * const personas: PeerIdentity[] = loadSeedAgentIdentities();
41
+ * for (const p of personas) {
42
+ * console.log(`${p.peerId} (${p.peerKind}): ${p.displayName}`);
43
+ * }
44
+ * ```
45
+ *
46
+ * @task T1210
47
+ * @epic T1144
48
+ */
49
+ export interface PeerIdentity {
50
+ /**
51
+ * Stable business identifier for the agent, matching the `agent <id>:` block
52
+ * name in the `.cant` file and the `agents.agent_id` column in the registry.
53
+ *
54
+ * @example `"cleo-prime"`, `"cleo-dev"`, `"cleo-subagent"`
55
+ */
56
+ peerId: string;
57
+ /**
58
+ * Role classification derived from the `role:` field in the `.cant` agent
59
+ * block. Determines spawn authority in the orchestration hierarchy.
60
+ */
61
+ peerKind: PeerKind;
62
+ /**
63
+ * Absolute path to the canonical `.cant` file that defines this persona.
64
+ *
65
+ * For seed-agents this is inside `packages/agents/seed-agents/` or
66
+ * `packages/agents/cleo-subagent.cant` (universal base). For project-tier
67
+ * personas it is inside `.cleo/cant/agents/`.
68
+ */
69
+ cantFile: string;
70
+ /**
71
+ * Human-readable name for the persona, derived from the `display_name:` or
72
+ * `description:` field. Falls back to the `peerId` value when neither field
73
+ * is present in the source `.cant`.
74
+ */
75
+ displayName: string;
76
+ /**
77
+ * Short description of the persona's purpose, taken from the `description:`
78
+ * field in the `.cant` agent block. Empty string when absent.
79
+ */
80
+ description: string;
81
+ }
82
+ /**
83
+ * Validate that an unknown value conforms to the {@link PeerIdentity} shape.
84
+ *
85
+ * Performs a lightweight structural check without Zod to keep `packages/contracts`
86
+ * dependency-free at runtime. Callers that need schema-level validation
87
+ * (e.g., test fixtures) can use {@link assertPeerIdentity}.
88
+ *
89
+ * @param value - Value to test.
90
+ * @returns `true` when `value` is a valid {@link PeerIdentity}.
91
+ *
92
+ * @example
93
+ * ```ts
94
+ * if (isPeerIdentity(raw)) {
95
+ * console.log(raw.peerId);
96
+ * }
97
+ * ```
98
+ */
99
+ export declare function isPeerIdentity(value: unknown): value is PeerIdentity;
100
+ /**
101
+ * Assert that a value is a valid {@link PeerIdentity}, throwing a descriptive
102
+ * error when the shape does not conform.
103
+ *
104
+ * @param value - Value to assert.
105
+ * @throws {TypeError} When the value does not satisfy {@link isPeerIdentity}.
106
+ *
107
+ * @example
108
+ * ```ts
109
+ * assertPeerIdentity(raw); // throws if invalid
110
+ * console.log(raw.peerId); // safe
111
+ * ```
112
+ */
113
+ export declare function assertPeerIdentity(value: unknown): asserts value is PeerIdentity;
114
+ /**
115
+ * Validate and filter an array of unknown values to {@link PeerIdentity}[].
116
+ *
117
+ * Invalid entries are silently dropped. This is the safe variant for loading
118
+ * from untrusted sources (e.g., the result of parsing a directory of `.cant`
119
+ * files whose format may vary).
120
+ *
121
+ * @param values - Array of unknown values.
122
+ * @returns Array containing only values that pass {@link isPeerIdentity}.
123
+ */
124
+ export declare function filterPeerIdentities(values: unknown[]): PeerIdentity[];
125
+ //# sourceMappingURL=peer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"peer.d.ts","sourceRoot":"","sources":["../src/peer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAMH;;;;;;;;GAQG;AACH,MAAM,MAAM,QAAQ,GAAG,cAAc,GAAG,MAAM,GAAG,QAAQ,GAAG,UAAU,CAAC;AAMvE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;;OAKG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,QAAQ,EAAE,QAAQ,CAAC;IAEnB;;;;;;OAMG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB;AAMD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAapE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,YAAY,CAMhF;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,YAAY,EAAE,CAEtE"}
package/dist/peer.js ADDED
@@ -0,0 +1,82 @@
1
+ /**
2
+ * PeerIdentity — canonical type for CANT agent persona records.
3
+ *
4
+ * Introduced by T1210 (v2026.4.110 Wave 0.2) as the SDK-first contract
5
+ * for agent identity. `packages/cant/src/native-loader.ts` produces
6
+ * `PeerIdentity[]` from the canonical seed-agents path; dispatch and
7
+ * CLI layers consume it to drive `cleo agents list` and spawn routing.
8
+ *
9
+ * Design constraints (ADR-055 / D028 boundary rules):
10
+ * - Lives in `packages/contracts/` — ZERO runtime dependencies.
11
+ * - Consumed by `packages/cant/` (loader) and `packages/cleo/` (CLI).
12
+ * - No cross-package relative imports.
13
+ *
14
+ * @module peer
15
+ * @task T1210
16
+ * @epic T1144
17
+ */
18
+ // ============================================================================
19
+ // Runtime validation
20
+ // ============================================================================
21
+ /**
22
+ * Validate that an unknown value conforms to the {@link PeerIdentity} shape.
23
+ *
24
+ * Performs a lightweight structural check without Zod to keep `packages/contracts`
25
+ * dependency-free at runtime. Callers that need schema-level validation
26
+ * (e.g., test fixtures) can use {@link assertPeerIdentity}.
27
+ *
28
+ * @param value - Value to test.
29
+ * @returns `true` when `value` is a valid {@link PeerIdentity}.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * if (isPeerIdentity(raw)) {
34
+ * console.log(raw.peerId);
35
+ * }
36
+ * ```
37
+ */
38
+ export function isPeerIdentity(value) {
39
+ if (typeof value !== 'object' || value === null)
40
+ return false;
41
+ const v = value;
42
+ return (typeof v['peerId'] === 'string' &&
43
+ v['peerId'].length > 0 &&
44
+ typeof v['peerKind'] === 'string' &&
45
+ ['orchestrator', 'lead', 'worker', 'subagent'].includes(v['peerKind']) &&
46
+ typeof v['cantFile'] === 'string' &&
47
+ v['cantFile'].length > 0 &&
48
+ typeof v['displayName'] === 'string' &&
49
+ typeof v['description'] === 'string');
50
+ }
51
+ /**
52
+ * Assert that a value is a valid {@link PeerIdentity}, throwing a descriptive
53
+ * error when the shape does not conform.
54
+ *
55
+ * @param value - Value to assert.
56
+ * @throws {TypeError} When the value does not satisfy {@link isPeerIdentity}.
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * assertPeerIdentity(raw); // throws if invalid
61
+ * console.log(raw.peerId); // safe
62
+ * ```
63
+ */
64
+ export function assertPeerIdentity(value) {
65
+ if (!isPeerIdentity(value)) {
66
+ throw new TypeError(`Expected PeerIdentity { peerId, peerKind, cantFile, displayName, description } — got: ${JSON.stringify(value)}`);
67
+ }
68
+ }
69
+ /**
70
+ * Validate and filter an array of unknown values to {@link PeerIdentity}[].
71
+ *
72
+ * Invalid entries are silently dropped. This is the safe variant for loading
73
+ * from untrusted sources (e.g., the result of parsing a directory of `.cant`
74
+ * files whose format may vary).
75
+ *
76
+ * @param values - Array of unknown values.
77
+ * @returns Array containing only values that pass {@link isPeerIdentity}.
78
+ */
79
+ export function filterPeerIdentities(values) {
80
+ return values.filter(isPeerIdentity);
81
+ }
82
+ //# sourceMappingURL=peer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"peer.js","sourceRoot":"","sources":["../src/peer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAgFH,+EAA+E;AAC/E,qBAAqB;AACrB,+EAA+E;AAE/E;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC9D,MAAM,CAAC,GAAG,KAAgC,CAAC;IAC3C,OAAO,CACL,OAAO,CAAC,CAAC,QAAQ,CAAC,KAAK,QAAQ;QAC/B,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,GAAG,CAAC;QACtB,OAAO,CAAC,CAAC,UAAU,CAAC,KAAK,QAAQ;QACjC,CAAC,cAAc,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAW,CAAC;QAChF,OAAO,CAAC,CAAC,UAAU,CAAC,KAAK,QAAQ;QACjC,CAAC,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC;QACxB,OAAO,CAAC,CAAC,aAAa,CAAC,KAAK,QAAQ;QACpC,OAAO,CAAC,CAAC,aAAa,CAAC,KAAK,QAAQ,CACrC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,SAAS,CACjB,yFAAyF,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CACjH,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAiB;IACpD,OAAO,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;AACvC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cleocode/contracts",
3
- "version": "2026.4.113",
3
+ "version": "2026.4.115",
4
4
  "description": "Domain types, interfaces, and contracts for the CLEO ecosystem",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/src/index.ts CHANGED
@@ -491,6 +491,22 @@ export type {
491
491
  SubstitutionSource,
492
492
  VariableResolver,
493
493
  } from './operations/variable-substitution.js';
494
+ // === Worktree Backend SDK Types (T1161) ===
495
+ // Re-exported at top level so @cleocode/worktree-backend and callers can
496
+ // import without the `ops.` namespace hop.
497
+ export type {
498
+ CreateWorktreeOptions,
499
+ CreateWorktreeResult,
500
+ DestroyWorktreeOptions,
501
+ DestroyWorktreeResult,
502
+ ListWorktreesOptions,
503
+ PruneWorktreesOptions,
504
+ PruneWorktreesResult,
505
+ WorktreeHook,
506
+ WorktreeHookResult,
507
+ WorktreeIncludePattern,
508
+ WorktreeListEntry,
509
+ } from './operations/worktree.js';
494
510
  // === Orchestration Hierarchy ===
495
511
  export {
496
512
  type AgentHierarchy,
@@ -499,6 +515,14 @@ export {
499
515
  type OrchestrationHierarchyAPI,
500
516
  OrchestrationLevel,
501
517
  } from './orchestration-hierarchy.js';
518
+ // === Peer Identity (T1210 — SDK-first CANT persona contract) ===
519
+ export {
520
+ assertPeerIdentity,
521
+ filterPeerIdentities,
522
+ isPeerIdentity,
523
+ type PeerIdentity,
524
+ type PeerKind,
525
+ } from './peer.js';
502
526
  // === Playbook DSL Types (T889 / T904 / W4-6) ===
503
527
  export type {
504
528
  PlaybookAgenticNode,
@@ -21,3 +21,4 @@ export * from './system.js';
21
21
  export * from './tasks.js';
22
22
  export * from './validate.js';
23
23
  export * from './variable-substitution.js';
24
+ export * from './worktree.js';
@@ -0,0 +1,295 @@
1
+ /**
2
+ * Worktree backend SDK operation types (T1161).
3
+ *
4
+ * Wire-format types for the `@cleocode/worktree-backend` SDK surface.
5
+ * Defines the contract for createWorktree, destroyWorktree, listWorktrees,
6
+ * and pruneWorktrees operations with XDG path canon (D029) and declarative
7
+ * hooks (D030 native lift of worktrunk missing features).
8
+ *
9
+ * @task T1161
10
+ * @adr ADR-055
11
+ */
12
+
13
+ // ---------------------------------------------------------------------------
14
+ // Hooks framework
15
+ // ---------------------------------------------------------------------------
16
+
17
+ /**
18
+ * A declarative lifecycle hook definition for worktree events.
19
+ *
20
+ * Hooks are executed synchronously (shell commands) or via node spawns
21
+ * in the worktree directory. Mirrors the worktrunk hooks contract lifted
22
+ * natively per D030.
23
+ *
24
+ * @task T1161
25
+ */
26
+ export interface WorktreeHook {
27
+ /** Shell command to run (executed via `sh -c` in the worktree dir). */
28
+ command: string;
29
+ /**
30
+ * When to run the hook.
31
+ *
32
+ * - `post-create` — immediately after `git worktree add` succeeds.
33
+ * - `post-start` — after the agent CWD is established (env vars injected).
34
+ */
35
+ event: 'post-create' | 'post-start';
36
+ /**
37
+ * Optional timeout in milliseconds before the hook is killed.
38
+ *
39
+ * @default 30000
40
+ */
41
+ timeoutMs?: number;
42
+ /**
43
+ * When true, a non-zero exit from this hook causes the worktree operation
44
+ * to fail. When false (default), errors are logged but ignored.
45
+ *
46
+ * @default false
47
+ */
48
+ failOnError?: boolean;
49
+ }
50
+
51
+ /**
52
+ * Result of a single hook execution.
53
+ *
54
+ * @task T1161
55
+ */
56
+ export interface WorktreeHookResult {
57
+ /** The hook that was executed. */
58
+ hook: WorktreeHook;
59
+ /** Whether the hook exited with code 0. */
60
+ success: boolean;
61
+ /** Hook stdout (trimmed). */
62
+ stdout: string;
63
+ /** Hook stderr (trimmed). */
64
+ stderr: string;
65
+ /** Exit code (null if killed by timeout). */
66
+ exitCode: number | null;
67
+ /** Duration in milliseconds. */
68
+ durationMs: number;
69
+ }
70
+
71
+ // ---------------------------------------------------------------------------
72
+ // Worktree-include glob pattern
73
+ // ---------------------------------------------------------------------------
74
+
75
+ /**
76
+ * A parsed entry from `.cleo/worktree-include`.
77
+ *
78
+ * The file lists glob patterns (one per line, `#` comments stripped) that
79
+ * control which files from the main project tree are symlinked or copied
80
+ * into new worktrees on creation. This is a native lift of the worktrunk
81
+ * `.cleo/worktree-include` feature (D030).
82
+ *
83
+ * @task T1161
84
+ */
85
+ export interface WorktreeIncludePattern {
86
+ /** The raw glob pattern string (e.g. `node_modules/.pnpm/**`). */
87
+ pattern: string;
88
+ /**
89
+ * Whether this entry was negated (prefixed with `!`).
90
+ *
91
+ * @default false
92
+ */
93
+ negated: boolean;
94
+ }
95
+
96
+ // ---------------------------------------------------------------------------
97
+ // Create operation
98
+ // ---------------------------------------------------------------------------
99
+
100
+ /**
101
+ * Options for creating a new agent worktree.
102
+ *
103
+ * @task T1161
104
+ */
105
+ export interface CreateWorktreeOptions {
106
+ /** The task ID that will own this worktree. */
107
+ taskId: string;
108
+ /** The base ref to branch from (default: current HEAD). */
109
+ baseRef?: string;
110
+ /** Explicit branch name. Defaults to `task/<taskId>`. */
111
+ branchName?: string;
112
+ /**
113
+ * Reason for creation. Used for git worktree lock comment and audit logs.
114
+ *
115
+ * @default 'subagent'
116
+ */
117
+ reason?: 'subagent' | 'experiment' | 'parallel-wave';
118
+ /** Declarative hooks to run after creation. */
119
+ hooks?: WorktreeHook[];
120
+ /**
121
+ * When true, read `.cleo/worktree-include` from the project root and apply
122
+ * any declared include patterns to the new worktree.
123
+ *
124
+ * @default true
125
+ */
126
+ applyIncludePatterns?: boolean;
127
+ /**
128
+ * When true, apply git worktree lock (`git worktree lock`) to prevent
129
+ * accidental pruning by git.
130
+ *
131
+ * @default true
132
+ */
133
+ lockWorktree?: boolean;
134
+ }
135
+
136
+ /**
137
+ * Result of a successful worktree creation.
138
+ *
139
+ * @task T1161
140
+ */
141
+ export interface CreateWorktreeResult {
142
+ /**
143
+ * Absolute path to the created worktree directory.
144
+ *
145
+ * Always under `~/.local/share/cleo/worktrees/<projectHash>/<taskId>/`
146
+ * per D029 canonical layout.
147
+ */
148
+ path: string;
149
+ /** Branch name created for this worktree (format: `task/<taskId>`). */
150
+ branch: string;
151
+ /** Base ref the branch was created from. */
152
+ baseRef: string;
153
+ /** Task ID that owns this worktree. */
154
+ taskId: string;
155
+ /** Project hash scoping this worktree under the XDG root. */
156
+ projectHash: string;
157
+ /** ISO 8601 timestamp when the worktree was created. */
158
+ createdAt: string;
159
+ /** Whether git worktree lock was applied. */
160
+ locked: boolean;
161
+ /** Environment variables to inject into the spawned agent process. */
162
+ envVars: Record<string, string>;
163
+ /** Prompt preamble text for agent isolation context. */
164
+ preamble: string;
165
+ /** Results of any post-create hooks that were executed. */
166
+ hookResults: WorktreeHookResult[];
167
+ /** Include patterns that were applied (empty if none). */
168
+ appliedPatterns: WorktreeIncludePattern[];
169
+ }
170
+
171
+ // ---------------------------------------------------------------------------
172
+ // Destroy operation
173
+ // ---------------------------------------------------------------------------
174
+
175
+ /**
176
+ * Options for destroying a worktree.
177
+ *
178
+ * @task T1161
179
+ */
180
+ export interface DestroyWorktreeOptions {
181
+ /** Task ID whose worktree to destroy. */
182
+ taskId: string;
183
+ /**
184
+ * When true, delete the associated git branch after removing the worktree.
185
+ *
186
+ * @default true
187
+ */
188
+ deleteBranch?: boolean;
189
+ /**
190
+ * When true, cherry-pick any commits on the task branch back to the
191
+ * orchestrator's current branch before destroying.
192
+ *
193
+ * @default false
194
+ */
195
+ cherryPickFirst?: boolean;
196
+ }
197
+
198
+ /**
199
+ * Result of a worktree destroy operation.
200
+ *
201
+ * @task T1161
202
+ */
203
+ export interface DestroyWorktreeResult {
204
+ /** Task ID that was destroyed. */
205
+ taskId: string;
206
+ /** Whether the worktree directory was successfully removed. */
207
+ worktreeRemoved: boolean;
208
+ /** Whether the task branch was deleted. */
209
+ branchDeleted: boolean;
210
+ /** Whether cherry-pick was attempted and succeeded. */
211
+ cherryPicked: boolean;
212
+ /** Number of commits cherry-picked (0 if none or not requested). */
213
+ commitCount: number;
214
+ /** Error message if any step failed (non-fatal — caller decides). */
215
+ error?: string;
216
+ }
217
+
218
+ // ---------------------------------------------------------------------------
219
+ // List operation
220
+ // ---------------------------------------------------------------------------
221
+
222
+ /**
223
+ * A single entry from the worktree listing.
224
+ *
225
+ * @task T1161
226
+ */
227
+ export interface WorktreeListEntry {
228
+ /** Absolute path to the worktree directory. */
229
+ path: string;
230
+ /** Branch checked out in this worktree. */
231
+ branch: string;
232
+ /**
233
+ * Task ID derived from the worktree directory name.
234
+ *
235
+ * Convention: the last path segment is the taskId.
236
+ */
237
+ taskId: string;
238
+ /** Project hash derived from the path. */
239
+ projectHash: string;
240
+ }
241
+
242
+ /**
243
+ * Options for listing worktrees.
244
+ *
245
+ * @task T1161
246
+ */
247
+ export interface ListWorktreesOptions {
248
+ /** Filter to only return worktrees for a specific project hash. */
249
+ projectHash?: string;
250
+ }
251
+
252
+ // ---------------------------------------------------------------------------
253
+ // Prune operation
254
+ // ---------------------------------------------------------------------------
255
+
256
+ /**
257
+ * Options for pruning orphaned worktrees.
258
+ *
259
+ * @task T1161
260
+ */
261
+ export interface PruneWorktreesOptions {
262
+ /** Absolute path to the project root (used to resolve the worktree root). */
263
+ projectRoot: string;
264
+ /**
265
+ * Set of task IDs to preserve. Any worktree directory whose name is NOT in
266
+ * this set will be pruned.
267
+ *
268
+ * When omitted, only stale git administrative entries are pruned (via
269
+ * `git worktree prune`). No worktree directories are removed.
270
+ */
271
+ preserveTaskIds?: Set<string>;
272
+ /**
273
+ * When true, also run `git worktree prune` to clean up stale git
274
+ * administrative entries even if `preserveTaskIds` is not provided.
275
+ *
276
+ * @default true
277
+ */
278
+ gitPrune?: boolean;
279
+ }
280
+
281
+ /**
282
+ * Result of a prune operation.
283
+ *
284
+ * @task T1161
285
+ */
286
+ export interface PruneWorktreesResult {
287
+ /** Number of worktree directories removed. */
288
+ removed: number;
289
+ /** Absolute paths that were removed. */
290
+ removedPaths: string[];
291
+ /** Entries that failed to remove (with reasons). */
292
+ errors: Array<{ path: string; reason: string }>;
293
+ /** Whether `git worktree prune` was run. */
294
+ gitPruneRan: boolean;
295
+ }
package/src/peer.ts ADDED
@@ -0,0 +1,166 @@
1
+ /**
2
+ * PeerIdentity — canonical type for CANT agent persona records.
3
+ *
4
+ * Introduced by T1210 (v2026.4.110 Wave 0.2) as the SDK-first contract
5
+ * for agent identity. `packages/cant/src/native-loader.ts` produces
6
+ * `PeerIdentity[]` from the canonical seed-agents path; dispatch and
7
+ * CLI layers consume it to drive `cleo agents list` and spawn routing.
8
+ *
9
+ * Design constraints (ADR-055 / D028 boundary rules):
10
+ * - Lives in `packages/contracts/` — ZERO runtime dependencies.
11
+ * - Consumed by `packages/cant/` (loader) and `packages/cleo/` (CLI).
12
+ * - No cross-package relative imports.
13
+ *
14
+ * @module peer
15
+ * @task T1210
16
+ * @epic T1144
17
+ */
18
+
19
+ // ============================================================================
20
+ // PeerKind taxonomy
21
+ // ============================================================================
22
+
23
+ /**
24
+ * Classification of a peer agent's role in the orchestration hierarchy.
25
+ *
26
+ * Mirrors the three-tier model in {@link AgentSpawnCapability}:
27
+ * - `orchestrator` — coordinates multi-agent workflows; may spawn leads and workers
28
+ * - `lead` — specialist; dispatches workers only
29
+ * - `worker` — terminal; executes tasks, cannot spawn
30
+ * - `subagent` — universal base role; resolved to a specific tier at spawn time
31
+ */
32
+ export type PeerKind = 'orchestrator' | 'lead' | 'worker' | 'subagent';
33
+
34
+ // ============================================================================
35
+ // PeerIdentity
36
+ // ============================================================================
37
+
38
+ /**
39
+ * Canonical identity record for a CANT-defined agent persona.
40
+ *
41
+ * Produced by `loadSeedAgentIdentities()` in `packages/cant/src/native-loader.ts`
42
+ * and consumed by the dispatch layer + `cleo agents list`. Every field is
43
+ * required — loaders MUST supply a value for each field, using empty strings
44
+ * for absent optional content in the source `.cant` file.
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * import type { PeerIdentity } from '@cleocode/contracts';
49
+ *
50
+ * const personas: PeerIdentity[] = loadSeedAgentIdentities();
51
+ * for (const p of personas) {
52
+ * console.log(`${p.peerId} (${p.peerKind}): ${p.displayName}`);
53
+ * }
54
+ * ```
55
+ *
56
+ * @task T1210
57
+ * @epic T1144
58
+ */
59
+ export interface PeerIdentity {
60
+ /**
61
+ * Stable business identifier for the agent, matching the `agent <id>:` block
62
+ * name in the `.cant` file and the `agents.agent_id` column in the registry.
63
+ *
64
+ * @example `"cleo-prime"`, `"cleo-dev"`, `"cleo-subagent"`
65
+ */
66
+ peerId: string;
67
+
68
+ /**
69
+ * Role classification derived from the `role:` field in the `.cant` agent
70
+ * block. Determines spawn authority in the orchestration hierarchy.
71
+ */
72
+ peerKind: PeerKind;
73
+
74
+ /**
75
+ * Absolute path to the canonical `.cant` file that defines this persona.
76
+ *
77
+ * For seed-agents this is inside `packages/agents/seed-agents/` or
78
+ * `packages/agents/cleo-subagent.cant` (universal base). For project-tier
79
+ * personas it is inside `.cleo/cant/agents/`.
80
+ */
81
+ cantFile: string;
82
+
83
+ /**
84
+ * Human-readable name for the persona, derived from the `display_name:` or
85
+ * `description:` field. Falls back to the `peerId` value when neither field
86
+ * is present in the source `.cant`.
87
+ */
88
+ displayName: string;
89
+
90
+ /**
91
+ * Short description of the persona's purpose, taken from the `description:`
92
+ * field in the `.cant` agent block. Empty string when absent.
93
+ */
94
+ description: string;
95
+ }
96
+
97
+ // ============================================================================
98
+ // Runtime validation
99
+ // ============================================================================
100
+
101
+ /**
102
+ * Validate that an unknown value conforms to the {@link PeerIdentity} shape.
103
+ *
104
+ * Performs a lightweight structural check without Zod to keep `packages/contracts`
105
+ * dependency-free at runtime. Callers that need schema-level validation
106
+ * (e.g., test fixtures) can use {@link assertPeerIdentity}.
107
+ *
108
+ * @param value - Value to test.
109
+ * @returns `true` when `value` is a valid {@link PeerIdentity}.
110
+ *
111
+ * @example
112
+ * ```ts
113
+ * if (isPeerIdentity(raw)) {
114
+ * console.log(raw.peerId);
115
+ * }
116
+ * ```
117
+ */
118
+ export function isPeerIdentity(value: unknown): value is PeerIdentity {
119
+ if (typeof value !== 'object' || value === null) return false;
120
+ const v = value as Record<string, unknown>;
121
+ return (
122
+ typeof v['peerId'] === 'string' &&
123
+ v['peerId'].length > 0 &&
124
+ typeof v['peerKind'] === 'string' &&
125
+ ['orchestrator', 'lead', 'worker', 'subagent'].includes(v['peerKind'] as string) &&
126
+ typeof v['cantFile'] === 'string' &&
127
+ v['cantFile'].length > 0 &&
128
+ typeof v['displayName'] === 'string' &&
129
+ typeof v['description'] === 'string'
130
+ );
131
+ }
132
+
133
+ /**
134
+ * Assert that a value is a valid {@link PeerIdentity}, throwing a descriptive
135
+ * error when the shape does not conform.
136
+ *
137
+ * @param value - Value to assert.
138
+ * @throws {TypeError} When the value does not satisfy {@link isPeerIdentity}.
139
+ *
140
+ * @example
141
+ * ```ts
142
+ * assertPeerIdentity(raw); // throws if invalid
143
+ * console.log(raw.peerId); // safe
144
+ * ```
145
+ */
146
+ export function assertPeerIdentity(value: unknown): asserts value is PeerIdentity {
147
+ if (!isPeerIdentity(value)) {
148
+ throw new TypeError(
149
+ `Expected PeerIdentity { peerId, peerKind, cantFile, displayName, description } — got: ${JSON.stringify(value)}`,
150
+ );
151
+ }
152
+ }
153
+
154
+ /**
155
+ * Validate and filter an array of unknown values to {@link PeerIdentity}[].
156
+ *
157
+ * Invalid entries are silently dropped. This is the safe variant for loading
158
+ * from untrusted sources (e.g., the result of parsing a directory of `.cant`
159
+ * files whose format may vary).
160
+ *
161
+ * @param values - Array of unknown values.
162
+ * @returns Array containing only values that pass {@link isPeerIdentity}.
163
+ */
164
+ export function filterPeerIdentities(values: unknown[]): PeerIdentity[] {
165
+ return values.filter(isPeerIdentity);
166
+ }