@agimon-ai/doompi-git 0.0.1-alpha.30 → 0.0.1-alpha.32

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.
Files changed (41) hide show
  1. package/README.md +10 -0
  2. package/dist/apiContracts.cjs +51 -2
  3. package/dist/apiContracts.cjs.map +1 -1
  4. package/dist/apiContracts.mjs +51 -2
  5. package/dist/apiContracts.mjs.map +1 -1
  6. package/dist/extensions/pi.cjs +4 -8
  7. package/dist/extensions/pi.cjs.map +1 -1
  8. package/dist/extensions/pi.d.mts +1 -1
  9. package/dist/extensions/pi.mjs +2 -6
  10. package/dist/extensions/pi.mjs.map +1 -1
  11. package/dist/extensions/server.cjs +98 -5
  12. package/dist/extensions/server.cjs.map +1 -1
  13. package/dist/extensions/server.mjs +98 -5
  14. package/dist/extensions/server.mjs.map +1 -1
  15. package/dist/extensions/web.mjs +334 -3
  16. package/dist/extensions/web.mjs.map +1 -1
  17. package/dist/{gitDependencies-D-EUEIkE.mjs → gitDependencies-CJFmhrG1.mjs} +2 -2
  18. package/dist/{gitDependencies-D-EUEIkE.mjs.map → gitDependencies-CJFmhrG1.mjs.map} +1 -1
  19. package/dist/{gitDependencies-DKJr5kLQ.cjs → gitDependencies-CWsygnLQ.cjs} +2 -2
  20. package/dist/{gitDependencies-DKJr5kLQ.cjs.map → gitDependencies-CWsygnLQ.cjs.map} +1 -1
  21. package/dist/{index-BQq2vblZ.d.mts → index-D79MSCee.d.mts} +15 -13
  22. package/dist/index-D79MSCee.d.mts.map +1 -0
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.d.mts +1 -1
  25. package/dist/index.mjs +1 -1
  26. package/dist/{runWorktree-BL99h9oH.mjs → runWorktree-BdK3oRtX.mjs} +18 -9
  27. package/dist/runWorktree-BdK3oRtX.mjs.map +1 -0
  28. package/dist/{runWorktree-B6ikYRrG.cjs → runWorktree-D0bsyYc0.cjs} +41 -8
  29. package/dist/runWorktree-D0bsyYc0.cjs.map +1 -0
  30. package/dist/{worktreeOperations-DAbs0ZTX.mjs → worktreeOperations-CijBzYEf.mjs} +130 -21
  31. package/dist/worktreeOperations-CijBzYEf.mjs.map +1 -0
  32. package/dist/{worktreeOperations-DjO_Y5Yv.cjs → worktreeOperations-FJDk44Zt.cjs} +135 -20
  33. package/dist/worktreeOperations-FJDk44Zt.cjs.map +1 -0
  34. package/llms.txt +4 -0
  35. package/package.json +8 -7
  36. package/src/prompts/doompi-use-git/SKILL.md +21 -1
  37. package/dist/index-BQq2vblZ.d.mts.map +0 -1
  38. package/dist/runWorktree-B6ikYRrG.cjs.map +0 -1
  39. package/dist/runWorktree-BL99h9oH.mjs.map +0 -1
  40. package/dist/worktreeOperations-DAbs0ZTX.mjs.map +0 -1
  41. package/dist/worktreeOperations-DjO_Y5Yv.cjs.map +0 -1
@@ -1,4 +1,4 @@
1
- const require_worktreeOperations = require("./worktreeOperations-DjO_Y5Yv.cjs");
1
+ const require_worktreeOperations = require("./worktreeOperations-FJDk44Zt.cjs");
2
2
  //#region src/services/extensionService/index.ts
3
3
  var DefaultGitExtensionService = class {
4
4
  async execute() {
@@ -30,4 +30,4 @@ Object.defineProperty(exports, "createGitDependencies", {
30
30
  }
31
31
  });
32
32
 
33
- //# sourceMappingURL=gitDependencies-DKJr5kLQ.cjs.map
33
+ //# sourceMappingURL=gitDependencies-CWsygnLQ.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"gitDependencies-DKJr5kLQ.cjs","names":["createWorktreeOperations","createWorktreeGit"],"sources":["../src/services/extensionService/index.ts","../src/services/gitDependencies/index.ts"],"sourcesContent":["// @scaffold-generated\nimport type { GitExtensionResult, GitExtensionService } from '../../types/extension';\n\nexport class DefaultGitExtensionService implements GitExtensionService {\n async execute(): Promise<GitExtensionResult> {\n return { message: 'Show git worktrees owned by this session', level: 'info' };\n }\n}\n","import type { GitExtensionDependencies } from '../../types/extension';\nimport { DefaultGitExtensionService } from '../extensionService';\n// @scaffold-generated\nimport { createWorktreeGit } from '../gitCli';\nimport { createWorktreeOperations } from '../worktreeOperations';\n\nexport function createGitDependencies(overrides: Partial<GitExtensionDependencies> = {}): GitExtensionDependencies {\n return {\n service: overrides.service ?? new DefaultGitExtensionService(),\n operations: overrides.operations ?? createWorktreeOperations({ git: createWorktreeGit() }),\n };\n}\n"],"mappings":";;AAGA,IAAa,6BAAb,MAAuE;CACrE,MAAM,UAAuC;EAC3C,OAAO;GAAE,SAAS;GAA4C,OAAO;EAAO;CAC9E;AACF;;;ACDA,SAAgB,sBAAsB,YAA+C,CAAC,GAA6B;CACjH,OAAO;EACL,SAAS,UAAU,WAAW,IAAI,2BAA2B;EAC7D,YAAY,UAAU,cAAcA,2BAAAA,yBAAyB,EAAE,KAAKC,2BAAAA,kBAAkB,EAAE,CAAC;CAC3F;AACF"}
1
+ {"version":3,"file":"gitDependencies-CWsygnLQ.cjs","names":["createWorktreeOperations","createWorktreeGit"],"sources":["../src/services/extensionService/index.ts","../src/services/gitDependencies/index.ts"],"sourcesContent":["// @scaffold-generated\nimport type { GitExtensionResult, GitExtensionService } from '../../types/extension';\n\nexport class DefaultGitExtensionService implements GitExtensionService {\n async execute(): Promise<GitExtensionResult> {\n return { message: 'Show git worktrees owned by this session', level: 'info' };\n }\n}\n","import type { GitExtensionDependencies } from '../../types/extension';\nimport { DefaultGitExtensionService } from '../extensionService';\n// @scaffold-generated\nimport { createWorktreeGit } from '../gitCli';\nimport { createWorktreeOperations } from '../worktreeOperations';\n\nexport function createGitDependencies(overrides: Partial<GitExtensionDependencies> = {}): GitExtensionDependencies {\n return {\n service: overrides.service ?? new DefaultGitExtensionService(),\n operations: overrides.operations ?? createWorktreeOperations({ git: createWorktreeGit() }),\n };\n}\n"],"mappings":";;AAGA,IAAa,6BAAb,MAAuE;CACrE,MAAM,UAAuC;EAC3C,OAAO;GAAE,SAAS;GAA4C,OAAO;EAAO;CAC9E;AACF;;;ACDA,SAAgB,sBAAsB,YAA+C,CAAC,GAA6B;CACjH,OAAO;EACL,SAAS,UAAU,WAAW,IAAI,2BAA2B;EAC7D,YAAY,UAAU,cAAcA,2BAAAA,yBAAyB,EAAE,KAAKC,2BAAAA,kBAAkB,EAAE,CAAC;CAC3F;AACF"}
@@ -13,14 +13,6 @@ interface WorktreeMessage {
13
13
  }
14
14
  //#endregion
15
15
  //#region src/types/worktreeRegistry.d.ts
16
- /**
17
- * The worktree registry: what this package knows about the worktrees it made.
18
- *
19
- * It deliberately does not mirror `git worktree list`. Git knows which
20
- * worktrees exist; only this registry knows which of them this package created,
21
- * which session runs in each, and which process to signal. Reconciling the two
22
- * is how orphans are found, so the two views are kept separate on purpose.
23
- */
24
16
  /**
25
17
  * A worktree's lifecycle as this package sees it.
26
18
  *
@@ -44,8 +36,11 @@ interface WorktreeRecord {
44
36
  repositoryRoot: string;
45
37
  /** The session spawned into the worktree. */
46
38
  sessionId: string;
47
- /** The session that asked for the worktree; the rail nests one under the other. */
48
- parentSessionId: string;
39
+ /**
40
+ * The session that asked for the worktree; the rail nests one under the other.
41
+ * Absent for a worktree opened from the new-session dialog, which has no parent.
42
+ */
43
+ parentSessionId?: string;
49
44
  status: WorktreeStatus;
50
45
  /** ISO 8601. */
51
46
  createdAt: string;
@@ -86,8 +81,11 @@ declare function planPrune(input: {
86
81
  interface WorktreeContext {
87
82
  /** Where the calling session is working, used to find the repository. */
88
83
  cwd: string;
89
- /** The calling session, recorded as the new session's parent. */
90
- sessionId: string;
84
+ /**
85
+ * The calling session, recorded as the new session's parent. Absent when the
86
+ * new-session dialog opens a top-level worktree session for the workspace.
87
+ */
88
+ sessionId?: string;
91
89
  }
92
90
  interface SpawnWorktreeRequest {
93
91
  branch: string;
@@ -96,6 +94,10 @@ interface SpawnWorktreeRequest {
96
94
  task?: string;
97
95
  /** Host-owned execution setup, exposed by the UI rather than the agent tool. */
98
96
  reservationId?: string;
97
+ /** `existing` checks out a branch that already exists instead of creating one from `baseRef`. */
98
+ checkout?: 'new' | 'existing';
99
+ /** With `existing`: the branch exists only on this remote; a local tracking branch is created. */
100
+ remote?: string;
99
101
  }
100
102
  interface SpawnOptions {
101
103
  /** Aborted when the caller gives up, so a spawn nobody is waiting for stops. */
@@ -140,4 +142,4 @@ declare class DefaultGitExtensionService implements GitExtensionService {
140
142
  declare function createGitDependencies(overrides?: Partial<GitExtensionDependencies>): GitExtensionDependencies;
141
143
  //#endregion
142
144
  export { GitExtensionService as a, GitExtensionResult as i, DefaultGitExtensionService as n, GitExtensionDependencies as r, createGitDependencies as t };
143
- //# sourceMappingURL=index-BQq2vblZ.d.mts.map
145
+ //# sourceMappingURL=index-D79MSCee.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-D79MSCee.d.mts","names":[],"sources":["../src/services/worktreeEvents/index.ts","../src/types/worktreeRegistry.ts","../src/services/worktreeNaming/index.ts","../src/services/worktreeOperations/index.ts","../src/types/extension.ts","../src/services/extensionService/index.ts","../src/services/gitDependencies/index.ts"],"mappings":";;;cAIa;KASD;UAEK;WACN,gBAAgB;WAChB;WACA;WACA,MAAM;WACN;WACA;;;;;;;;;;;KCHC;cAEC;UAEI;EACf,gBAAgB;;EAEhB;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;;;EAKA;EACA,QAAQ;;EAER;;;;UC8De;;EAEf,QAAQ;;EAER,QAAQ;;EAER;;EAEA,WAAW;;;;;;;EAOX;;;;;;;;iBASc,UAAU;EACxB,kBAAkB;EAClB;EACA;EACA,aAAa;IACX;;;UClHa;;EAEf;;;;;EAKA;;UAGe;EACf;EACA;EACA;EACA;;EAEA;;EAEA;;EAEA;;UAGe;;EAEf,SAAS;;EAET,cAAc;;UAGC;EACf,MAAM,SAAS,iBAAiB,SAAS,sBAAsB,UAAU,eAAe,QAAQ;EAChG,MAAM,SAAS,iBAAiB,YAAY,iBAAiB,QAAQ;EACrE,KAAK,SAAS,kBAAkB,QAAQ;EACxC,OAAO,SAAS,iBAAiB,aAAa;IAAU,QAAQ;IAAgB;;EAChF,MAAM,SAAS,iBAAiB,YAAY,mBAAmB,QAAQ;EACvE,MAAM,SAAS,iBAAiB,kBAAkB,QAAQ,kBAAkB;EAC5E,KAAK,SAAS,iBAAiB,YAAY,kBAAkB;EAC7D,SAAS,SAAS,iBAAiB,aAAa,QAA9B;;;;KCvDR;UAEK;EACf;EACA,OAAO;;UAGQ;EACf,WAAW,QAAQ;;UAGJ;EACf,SAAS;EACT,YAAY;;;;cCbD,sCAAsC;EAC3C,WAAW,QAAQ;;;;iBCEX,sBAAsB,YAAW,QAAQ,4BAAiC"}
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_gitDependencies = require("./gitDependencies-DKJr5kLQ.cjs");
2
+ const require_gitDependencies = require("./gitDependencies-CWsygnLQ.cjs");
3
3
  exports.DefaultGitExtensionService = require_gitDependencies.DefaultGitExtensionService;
4
4
  exports.createGitDependencies = require_gitDependencies.createGitDependencies;
package/dist/index.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as GitExtensionService, i as GitExtensionResult, n as DefaultGitExtensionService, r as GitExtensionDependencies, t as createGitDependencies } from "./index-BQq2vblZ.mjs";
1
+ import { a as GitExtensionService, i as GitExtensionResult, n as DefaultGitExtensionService, r as GitExtensionDependencies, t as createGitDependencies } from "./index-D79MSCee.mjs";
2
2
  export { DefaultGitExtensionService, type GitExtensionDependencies, type GitExtensionResult, type GitExtensionService, createGitDependencies };
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { n as DefaultGitExtensionService, t as createGitDependencies } from "./gitDependencies-D-EUEIkE.mjs";
1
+ import { n as DefaultGitExtensionService, t as createGitDependencies } from "./gitDependencies-CJFmhrG1.mjs";
2
2
  export { DefaultGitExtensionService, createGitDependencies };
@@ -1,5 +1,12 @@
1
- import { l as invalidRequest } from "./worktreeOperations-DAbs0ZTX.mjs";
1
+ import { u as invalidRequest } from "./worktreeOperations-CijBzYEf.mjs";
2
2
  import { Type } from "typebox";
3
+ //#region src/constants/git.ts
4
+ const COMMAND_NAME = "doom-git";
5
+ const COMMAND_DESCRIPTION = "Show git worktrees owned by this session";
6
+ /** Workspace-mounted routes behind the new-session dialog. */
7
+ const GIT_BRANCHES_PATH = "/branches";
8
+ const GIT_SESSIONS_PATH = "/sessions";
9
+ //#endregion
3
10
  //#region src/schemas/runWorktreeTool.ts
4
11
  /**
5
12
  * The tool's action vocabulary.
@@ -154,13 +161,14 @@ const RUN_WORKTREE_DESCRIPTION = `Create and manage git worktrees, each with its
154
161
  Actions:
155
162
  - spawn_worktree: create a worktree on a new branch and start a session in it. Requires 'branch'. Optional 'baseRef' (defaults to the current branch's remote-tracking ref, then the remote default branch), 'name' for the rail, 'task' as the first message.
156
163
  - close_worktree: stop a worktree's session, delete its checkout, and remove its generated sync storage. Requires 'id'. Refuses a dirty tree unless 'force' is true.
157
- - list: every worktree for this repository, with status.
158
- - status: one worktree and its uncommitted files. Requires 'id'.
164
+ - list: every worktree for this repository, with status and relationship to the calling session.
165
+ - status: one worktree, its relationship to the calling session, and its uncommitted files. Requires 'id'.
159
166
  - merge: merge a worktree's branch into this checkout. Requires 'id'. Refuses when this checkout is dirty.
160
167
  - prune: remove orphaned worktrees and their generated sync storage. Pass 'dryRun' to see the plan without destroying anything.
161
168
  - send: send a message to the other side of a worktree. Requires 'id' and 'message'.
162
169
  - messages: read messages waiting for you from a worktree. Requires 'id'.
163
170
 
171
+ For a nested worktree session, use the record labelled 'child' in list to report to your parent. Use records labelled 'parent' to contact your own children. Other records are not communication edges.
164
172
  Worktrees live outside the repository, under ~/.pi/.doom/git/worktrees.`;
165
173
  /** Rejects calls that do not match one documented action shape. */
166
174
  function validateParams(input) {
@@ -187,8 +195,9 @@ function validateParams(input) {
187
195
  if ((action === WORKTREE_ACTIONS.close_worktree || action === WORKTREE_ACTIONS.status || action === WORKTREE_ACTIONS.merge || action === WORKTREE_ACTIONS.send || action === WORKTREE_ACTIONS.messages) && typeof record.id !== "string") throw invalidRequest(`action='${action}' requires 'id'.`, "Call list to see the current ids.");
188
196
  return record;
189
197
  }
190
- function describe(record) {
191
- return `${record.id} ${record.branch} ${record.status} ${record.path}`;
198
+ function describe(record, sessionId) {
199
+ const relationship = record.parentSessionId === sessionId ? "parent" : record.sessionId === sessionId ? "child" : "other session";
200
+ return `${record.id} ${record.branch} ${record.status} (${relationship}) ${record.path}`;
192
201
  }
193
202
  function text(...lines) {
194
203
  return [{
@@ -226,7 +235,7 @@ async function executeRunWorktreeTool(params, operations, context, options = {})
226
235
  case WORKTREE_ACTIONS.list: {
227
236
  const records = await operations.list(context);
228
237
  return {
229
- content: records.length === 0 ? text("No worktrees for this repository.") : text(`${String(records.length)} worktree(s):`, ...records.map(describe)),
238
+ content: records.length === 0 ? text("No worktrees for this repository.") : text(`${String(records.length)} worktree(s):`, ...records.map((record) => describe(record, context.sessionId))),
230
239
  details: {
231
240
  action: params.action,
232
241
  records
@@ -236,7 +245,7 @@ async function executeRunWorktreeTool(params, operations, context, options = {})
236
245
  case WORKTREE_ACTIONS.status: {
237
246
  const { record, dirtyFiles } = await operations.status(context, params.id);
238
247
  return {
239
- content: text(describe(record), `Session: ${record.sessionId}`, dirtyFiles.length === 0 ? "Clean." : `${String(dirtyFiles.length)} uncommitted file(s): ${dirtyFiles.slice(0, 20).join(", ")}`),
248
+ content: text(describe(record, context.sessionId), `Session: ${record.sessionId}`, dirtyFiles.length === 0 ? "Clean." : `${String(dirtyFiles.length)} uncommitted file(s): ${dirtyFiles.slice(0, 20).join(", ")}`),
240
249
  details: {
241
250
  action: params.action,
242
251
  records: [record]
@@ -284,6 +293,6 @@ async function executeRunWorktreeTool(params, operations, context, options = {})
284
293
  }
285
294
  }
286
295
  //#endregion
287
- export { RunWorktreeToolSchema as a, validateParams as i, RUN_WORKTREE_TOOL_NAME as n, executeRunWorktreeTool as r, RUN_WORKTREE_DESCRIPTION as t };
296
+ export { RunWorktreeToolSchema as a, GIT_BRANCHES_PATH as c, validateParams as i, GIT_SESSIONS_PATH as l, RUN_WORKTREE_TOOL_NAME as n, COMMAND_DESCRIPTION as o, executeRunWorktreeTool as r, COMMAND_NAME as s, RUN_WORKTREE_DESCRIPTION as t };
288
297
 
289
- //# sourceMappingURL=runWorktree-BL99h9oH.mjs.map
298
+ //# sourceMappingURL=runWorktree-BdK3oRtX.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runWorktree-BdK3oRtX.mjs","names":[],"sources":["../src/constants/git.ts","../src/schemas/runWorktreeTool.ts","../src/services/runWorktree/index.ts"],"sourcesContent":["export const COMMAND_NAME = 'doom-git';\nexport const COMMAND_DESCRIPTION = 'Show git worktrees owned by this session';\n/** The package API base path; the cockpit mounts it at /api/workspaces/<id>/plugins/git. */\nexport const GIT_API_BASE_PATH = 'git';\n/** Workspace-mounted routes behind the new-session dialog. */\nexport const GIT_BRANCHES_PATH = '/branches';\nexport const GIT_SESSIONS_PATH = '/sessions';\n","import { type Static, Type } from 'typebox';\n\n/**\n * The tool's action vocabulary.\n *\n * One tool with an action field rather than six tools, matching `subagent`:\n * the actions share a subject and are meaningless apart from it, and six\n * separate tools would spend six description budgets teaching the same nouns.\n */\nexport const WORKTREE_ACTIONS = {\n spawn_worktree: 'spawn_worktree',\n close_worktree: 'close_worktree',\n list: 'list',\n status: 'status',\n merge: 'merge',\n prune: 'prune',\n send: 'send',\n messages: 'messages',\n} as const;\n\nexport type WorktreeAction = (typeof WORKTREE_ACTIONS)[keyof typeof WORKTREE_ACTIONS];\n\n/**\n * Which fields each action accepts.\n *\n * Rejecting an unknown field is what stops a plausible-looking call from doing\n * something other than what it reads like: `close_worktree` with `branch`\n * instead of `id` would otherwise close whatever the default resolved to.\n */\nexport const WORKTREE_ACTION_FIELDS: Record<WorktreeAction, readonly string[]> = {\n spawn_worktree: ['action', 'branch', 'baseRef', 'task', 'name'],\n close_worktree: ['action', 'id', 'force'],\n list: ['action'],\n status: ['action', 'id'],\n merge: ['action', 'id', 'message'],\n prune: ['action', 'dryRun'],\n send: ['action', 'id', 'message'],\n messages: ['action', 'id'],\n};\n\nconst SpawnParams = Type.Object(\n {\n action: Type.Literal(WORKTREE_ACTIONS.spawn_worktree),\n branch: Type.String({ minLength: 1 }),\n baseRef: Type.Optional(Type.String({ minLength: 1 })),\n task: Type.Optional(Type.String({ minLength: 1 })),\n name: Type.Optional(Type.String({ minLength: 1 })),\n },\n { additionalProperties: false },\n);\n\nconst CloseParams = Type.Object(\n {\n action: Type.Literal(WORKTREE_ACTIONS.close_worktree),\n id: Type.String({ minLength: 1 }),\n force: Type.Optional(Type.Boolean()),\n },\n { additionalProperties: false },\n);\n\nconst ListParams = Type.Object({ action: Type.Literal(WORKTREE_ACTIONS.list) }, { additionalProperties: false });\n\nconst StatusParams = Type.Object(\n { action: Type.Literal(WORKTREE_ACTIONS.status), id: Type.String({ minLength: 1 }) },\n { additionalProperties: false },\n);\n\nconst MergeParams = Type.Object(\n {\n action: Type.Literal(WORKTREE_ACTIONS.merge),\n id: Type.String({ minLength: 1 }),\n message: Type.Optional(Type.String({ minLength: 1 })),\n },\n { additionalProperties: false },\n);\n\nconst PruneParams = Type.Object(\n { action: Type.Literal(WORKTREE_ACTIONS.prune), dryRun: Type.Optional(Type.Boolean()) },\n { additionalProperties: false },\n);\n\nconst SendParams = Type.Object(\n {\n action: Type.Literal(WORKTREE_ACTIONS.send),\n id: Type.String({ minLength: 1 }),\n message: Type.String({ minLength: 1 }),\n },\n { additionalProperties: false },\n);\n\nconst MessagesParams = Type.Object(\n { action: Type.Literal(WORKTREE_ACTIONS.messages), id: Type.String({ minLength: 1 }) },\n { additionalProperties: false },\n);\n\nexport const RunWorktreeParams = Type.Union([\n SpawnParams,\n CloseParams,\n ListParams,\n StatusParams,\n MergeParams,\n PruneParams,\n SendParams,\n MessagesParams,\n]);\n\n/** The actions that accept `field`, so the declared docs cannot drift from the validator. */\nfunction acceptingActions(field: string): string {\n return Object.values(WORKTREE_ACTIONS)\n .filter((action) => WORKTREE_ACTION_FIELDS[action].includes(field))\n .join(', ');\n}\n\n/**\n * The schema declared to the model.\n *\n * A flat object rather than `RunWorktreeParams` itself. A top-level union is\n * `{anyOf:[...]}` with no `properties`, and Pi's Anthropic Messages adapter\n * rebuilds tool input as `{type:'object', properties: schema.properties ?? {},\n * required: schema.required ?? []}`, so the union arrived at the model as an\n * empty object while the host went on validating calls against it. Nothing here\n * relaxes what is accepted: `validateParams` still rejects an unknown action, a\n * field the action does not take, and a missing required one.\n */\nexport const RunWorktreeToolSchema = Type.Object(\n {\n action: Type.String({\n enum: Object.values(WORKTREE_ACTIONS),\n description: 'The operation to run. Every other field is accepted only by the actions its description names.',\n }),\n branch: Type.Optional(\n Type.String({ minLength: 1, description: `New branch to create. Actions: ${acceptingActions('branch')}.` }),\n ),\n baseRef: Type.Optional(\n Type.String({\n minLength: 1,\n description: `Base ref, defaulting to the current branch. Actions: ${acceptingActions('baseRef')}.`,\n }),\n ),\n task: Type.Optional(\n Type.String({\n minLength: 1,\n description: `First message for the new session. Actions: ${acceptingActions('task')}.`,\n }),\n ),\n name: Type.Optional(\n Type.String({ minLength: 1, description: `Rail label for the worktree. Actions: ${acceptingActions('name')}.` }),\n ),\n id: Type.Optional(Type.String({ minLength: 1, description: `Worktree id. Actions: ${acceptingActions('id')}.` })),\n force: Type.Optional(\n Type.Boolean({ description: `Close even when the tree is dirty. Actions: ${acceptingActions('force')}.` }),\n ),\n message: Type.Optional(\n Type.String({\n minLength: 1,\n description: `Merge commit message, or the text to send. Actions: ${acceptingActions('message')}.`,\n }),\n ),\n dryRun: Type.Optional(\n Type.Boolean({\n description: `Report the plan without destroying anything. Actions: ${acceptingActions('dryRun')}.`,\n }),\n ),\n },\n { additionalProperties: false },\n);\n\nexport type RunWorktreeToolParams = Static<typeof RunWorktreeParams>;\n","import {\n RunWorktreeParams,\n WORKTREE_ACTION_FIELDS,\n WORKTREE_ACTIONS,\n type WorktreeAction,\n type RunWorktreeToolParams,\n} from '../../schemas/runWorktreeTool';\nimport type { WorktreeRecord } from '../../types/worktreeRegistry';\nimport { invalidRequest } from '../errors';\nimport type { WorktreeOperations } from '../worktreeOperations';\n\nexport { RunWorktreeParams };\nexport type { RunWorktreeToolParams, WorktreeAction };\n\nexport const RUN_WORKTREE_TOOL_NAME = 'run_worktree';\n\nconst IMPLEMENTED_ACTIONS: ReadonlySet<string> = new Set(Object.values(WORKTREE_ACTIONS));\n\nexport const RUN_WORKTREE_DESCRIPTION = `Create and manage git worktrees, each with its own DoomPi session nested under this one.\n\nActions:\n- spawn_worktree: create a worktree on a new branch and start a session in it. Requires 'branch'. Optional 'baseRef' (defaults to the current branch's remote-tracking ref, then the remote default branch), 'name' for the rail, 'task' as the first message.\n- close_worktree: stop a worktree's session, delete its checkout, and remove its generated sync storage. Requires 'id'. Refuses a dirty tree unless 'force' is true.\n- list: every worktree for this repository, with status and relationship to the calling session.\n- status: one worktree, its relationship to the calling session, and its uncommitted files. Requires 'id'.\n- merge: merge a worktree's branch into this checkout. Requires 'id'. Refuses when this checkout is dirty.\n- prune: remove orphaned worktrees and their generated sync storage. Pass 'dryRun' to see the plan without destroying anything.\n- send: send a message to the other side of a worktree. Requires 'id' and 'message'.\n- messages: read messages waiting for you from a worktree. Requires 'id'.\n\nFor a nested worktree session, use the record labelled 'child' in list to report to your parent. Use records labelled 'parent' to contact your own children. Other records are not communication edges.\nWorktrees live outside the repository, under ~/.pi/.doom/git/worktrees.`;\n\nexport interface RunWorktreeToolDetails {\n action: WorktreeAction;\n records?: WorktreeRecord[];\n}\n\nexport interface RunWorktreeToolResult {\n content: [{ type: 'text'; text: string }];\n details: RunWorktreeToolDetails;\n}\n\nexport interface RunWorktreeExecutionContext {\n readonly cwd: string;\n readonly sessionId: string;\n}\n\nexport interface RunWorktreeExecutionOptions {\n readonly signal?: AbortSignal;\n readonly onProgress?: (label: string) => void;\n}\n\n/** Rejects calls that do not match one documented action shape. */\nexport function validateParams(input: unknown): RunWorktreeToolParams {\n if (typeof input !== 'object' || input === null || Array.isArray(input)) {\n throw invalidRequest('run_worktree parameters must be an object.', 'Call it with one documented action shape.');\n }\n const record = input as Record<string, unknown>;\n const action = record.action;\n if (typeof action !== 'string' || !IMPLEMENTED_ACTIONS.has(action)) {\n throw invalidRequest(\n `Unknown action ${typeof action === 'string' ? `'${action}'` : 'value'}.`,\n `Use one of: ${[...IMPLEMENTED_ACTIONS].join(', ')}.`,\n );\n }\n const allowed = WORKTREE_ACTION_FIELDS[action as WorktreeAction];\n const unexpected = Object.keys(record).filter((key) => !allowed.includes(key));\n if (unexpected.length > 0) {\n throw invalidRequest(\n `action='${action}' does not accept: ${unexpected.join(', ')}.`,\n `Fields for '${action}': ${allowed.join(', ')}.`,\n );\n }\n for (const field of ['branch', 'id'] as const) {\n if (allowed.includes(field) && field in record) {\n const value = record[field];\n if (typeof value !== 'string' || value.trim() === '') {\n throw invalidRequest(`action='${action}' requires a nonblank '${field}'.`, `Pass a ${field}.`);\n }\n }\n }\n const stringFields = ['baseRef', 'name', 'task', 'message'] as const;\n for (const field of stringFields) {\n if (field in record && (typeof record[field] !== 'string' || record[field].trim() === '')) {\n throw invalidRequest(`action='${action}' requires a nonblank '${field}'.`, `Pass a ${field}.`);\n }\n }\n for (const field of ['force', 'dryRun'] as const) {\n if (field in record && typeof record[field] !== 'boolean') {\n throw invalidRequest(`action='${action}' requires boolean '${field}'.`, `Pass true or false for ${field}.`);\n }\n }\n if (action === WORKTREE_ACTIONS.send && typeof record.message !== 'string') {\n throw invalidRequest(\"action='send' requires 'message'.\", 'Pass the message to send.');\n }\n if (action === WORKTREE_ACTIONS.spawn_worktree && typeof record.branch !== 'string') {\n throw invalidRequest(\"action='spawn_worktree' requires 'branch'.\", 'Name the branch to create.');\n }\n if (\n (action === WORKTREE_ACTIONS.close_worktree ||\n action === WORKTREE_ACTIONS.status ||\n action === WORKTREE_ACTIONS.merge ||\n action === WORKTREE_ACTIONS.send ||\n action === WORKTREE_ACTIONS.messages) &&\n typeof record.id !== 'string'\n ) {\n throw invalidRequest(`action='${action}' requires 'id'.`, 'Call list to see the current ids.');\n }\n return record as RunWorktreeToolParams;\n}\n\nfunction describe(record: WorktreeRecord, sessionId: string): string {\n const relationship =\n record.parentSessionId === sessionId ? 'parent' : record.sessionId === sessionId ? 'child' : 'other session';\n return `${record.id} ${record.branch} ${record.status} (${relationship}) ${record.path}`;\n}\n\nfunction text(...lines: readonly string[]): [{ type: 'text'; text: string }] {\n return [{ type: 'text', text: lines.join('\\n') }];\n}\n\nexport async function executeRunWorktreeTool(\n params: RunWorktreeToolParams,\n operations: WorktreeOperations,\n context: RunWorktreeExecutionContext,\n options: RunWorktreeExecutionOptions = {},\n): Promise<RunWorktreeToolResult> {\n switch (params.action) {\n case WORKTREE_ACTIONS.spawn_worktree: {\n const record = await operations.spawn(\n context,\n {\n branch: params.branch,\n ...(params.baseRef === undefined ? {} : { baseRef: params.baseRef }),\n ...(params.name === undefined ? {} : { name: params.name }),\n ...(params.task === undefined ? {} : { task: params.task }),\n },\n options,\n );\n return {\n content: text(\n `Worktree ${record.id} created on ${record.branch} from ${record.baseRef}.`,\n `Path: ${record.path}`,\n params.task === undefined\n ? `Session ${record.sessionId} is starting; it appears nested under this one in the rail.`\n : `Session ${record.sessionId} is starting with its task; it appears nested under this one in the rail.`,\n ),\n details: { action: params.action, records: [record] },\n };\n }\n case WORKTREE_ACTIONS.close_worktree: {\n const record = await operations.close(context, params.id, params.force ?? false);\n return {\n content: text(`Worktree ${record.id} (${record.branch}) closed and removed.`),\n details: { action: params.action, records: [record] },\n };\n }\n case WORKTREE_ACTIONS.list: {\n const records = await operations.list(context);\n return {\n content:\n records.length === 0\n ? text('No worktrees for this repository.')\n : text(\n `${String(records.length)} worktree(s):`,\n ...records.map((record) => describe(record, context.sessionId)),\n ),\n details: { action: params.action, records },\n };\n }\n case WORKTREE_ACTIONS.status: {\n const { record, dirtyFiles } = await operations.status(context, params.id);\n return {\n content: text(\n describe(record, context.sessionId),\n `Session: ${record.sessionId}`,\n dirtyFiles.length === 0\n ? 'Clean.'\n : `${String(dirtyFiles.length)} uncommitted file(s): ${dirtyFiles.slice(0, 20).join(', ')}`,\n ),\n details: { action: params.action, records: [record] },\n };\n }\n case WORKTREE_ACTIONS.merge: {\n const record = await operations.merge(\n context,\n params.id,\n ...(params.message === undefined ? [] : ([params.message] as const)),\n );\n return {\n content: text(`Merged ${record.branch} into this checkout.`),\n details: { action: params.action, records: [record] },\n };\n }\n case WORKTREE_ACTIONS.send: {\n await operations.send(context, params.id, params.message);\n return { content: text(`Message sent to worktree ${params.id}.`), details: { action: params.action } };\n }\n case WORKTREE_ACTIONS.messages: {\n const waiting = await operations.messages(context, params.id);\n return {\n content:\n waiting.length === 0\n ? text('No messages.')\n : text(\n `${String(waiting.length)} message(s):`,\n ...waiting.map((entry) => `[${entry.sentAt}] ${entry.from}: ${entry.text}`),\n ),\n details: { action: params.action },\n };\n }\n case WORKTREE_ACTIONS.prune: {\n const dryRun = params.dryRun ?? false;\n const plan = await operations.prune(context, dryRun);\n const lines = [\n dryRun ? 'Prune plan (nothing was changed):' : 'Pruned:',\n `Remove: ${plan.remove.length === 0 ? 'none' : plan.remove.map((record) => record.id).join(', ')}`,\n `Forget: ${plan.forget.length === 0 ? 'none' : plan.forget.map((record) => record.id).join(', ')}`,\n `Kept, uncommitted work: ${plan.keptDirty.length === 0 ? 'none' : plan.keptDirty.map((record) => record.id).join(', ')}`,\n `Untracked directories, left alone: ${plan.untracked.length === 0 ? 'none' : plan.untracked.join(', ')}`,\n ...(plan.keptBranches.length === 0\n ? []\n : [`Branches kept, they hold commits: ${plan.keptBranches.join(', ')}`]),\n ];\n return { content: text(...lines), details: { action: params.action } };\n }\n }\n}\n"],"mappings":";;;AAAA,MAAa,eAAe;AAC5B,MAAa,sBAAsB;;AAInC,MAAa,oBAAoB;AACjC,MAAa,oBAAoB;;;;;;;;;;ACGjC,MAAa,mBAAmB;CAC9B,gBAAgB;CAChB,gBAAgB;CAChB,MAAM;CACN,QAAQ;CACR,OAAO;CACP,OAAO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M,OAAO,IAAI,MAAM,KAAK,IAAI,MAAM,MAAM,CAC5E;IACN,SAAS,EAAE,QAAQ,OAAO,OAAO;GACnC;EACF;EACA,KAAK,iBAAiB,OAAO;GAC3B,MAAM,SAAS,OAAO,UAAU;GAChC,MAAM,OAAO,MAAM,WAAW,MAAM,SAAS,MAAM;GAWnD,OAAO;IAAE,SAAS,KAAK,GAAG;KATxB,SAAS,sCAAsC;KAC/C,WAAW,KAAK,OAAO,WAAW,IAAI,SAAS,KAAK,OAAO,KAAK,WAAW,OAAO,EAAE,CAAC,CAAC,KAAK,IAAI;KAC/F,WAAW,KAAK,OAAO,WAAW,IAAI,SAAS,KAAK,OAAO,KAAK,WAAW,OAAO,EAAE,CAAC,CAAC,KAAK,IAAI;KAC/F,2BAA2B,KAAK,UAAU,WAAW,IAAI,SAAS,KAAK,UAAU,KAAK,WAAW,OAAO,EAAE,CAAC,CAAC,KAAK,IAAI;KACrH,sCAAsC,KAAK,UAAU,WAAW,IAAI,SAAS,KAAK,UAAU,KAAK,IAAI;KACrG,GAAI,KAAK,aAAa,WAAW,IAC7B,CAAC,IACD,CAAC,qCAAqC,KAAK,aAAa,KAAK,IAAI,GAAG;IAE5C,CAAC;IAAG,SAAS,EAAE,QAAQ,OAAO,OAAO;GAAE;EACvE;CACF;AACF"}
@@ -1,5 +1,12 @@
1
- const require_worktreeOperations = require("./worktreeOperations-DjO_Y5Yv.cjs");
1
+ const require_worktreeOperations = require("./worktreeOperations-FJDk44Zt.cjs");
2
2
  let typebox = require("typebox");
3
+ //#region src/constants/git.ts
4
+ const COMMAND_NAME = "doom-git";
5
+ const COMMAND_DESCRIPTION = "Show git worktrees owned by this session";
6
+ /** Workspace-mounted routes behind the new-session dialog. */
7
+ const GIT_BRANCHES_PATH = "/branches";
8
+ const GIT_SESSIONS_PATH = "/sessions";
9
+ //#endregion
3
10
  //#region src/schemas/runWorktreeTool.ts
4
11
  /**
5
12
  * The tool's action vocabulary.
@@ -154,13 +161,14 @@ const RUN_WORKTREE_DESCRIPTION = `Create and manage git worktrees, each with its
154
161
  Actions:
155
162
  - spawn_worktree: create a worktree on a new branch and start a session in it. Requires 'branch'. Optional 'baseRef' (defaults to the current branch's remote-tracking ref, then the remote default branch), 'name' for the rail, 'task' as the first message.
156
163
  - close_worktree: stop a worktree's session, delete its checkout, and remove its generated sync storage. Requires 'id'. Refuses a dirty tree unless 'force' is true.
157
- - list: every worktree for this repository, with status.
158
- - status: one worktree and its uncommitted files. Requires 'id'.
164
+ - list: every worktree for this repository, with status and relationship to the calling session.
165
+ - status: one worktree, its relationship to the calling session, and its uncommitted files. Requires 'id'.
159
166
  - merge: merge a worktree's branch into this checkout. Requires 'id'. Refuses when this checkout is dirty.
160
167
  - prune: remove orphaned worktrees and their generated sync storage. Pass 'dryRun' to see the plan without destroying anything.
161
168
  - send: send a message to the other side of a worktree. Requires 'id' and 'message'.
162
169
  - messages: read messages waiting for you from a worktree. Requires 'id'.
163
170
 
171
+ For a nested worktree session, use the record labelled 'child' in list to report to your parent. Use records labelled 'parent' to contact your own children. Other records are not communication edges.
164
172
  Worktrees live outside the repository, under ~/.pi/.doom/git/worktrees.`;
165
173
  /** Rejects calls that do not match one documented action shape. */
166
174
  function validateParams(input) {
@@ -187,8 +195,9 @@ function validateParams(input) {
187
195
  if ((action === WORKTREE_ACTIONS.close_worktree || action === WORKTREE_ACTIONS.status || action === WORKTREE_ACTIONS.merge || action === WORKTREE_ACTIONS.send || action === WORKTREE_ACTIONS.messages) && typeof record.id !== "string") throw require_worktreeOperations.invalidRequest(`action='${action}' requires 'id'.`, "Call list to see the current ids.");
188
196
  return record;
189
197
  }
190
- function describe(record) {
191
- return `${record.id} ${record.branch} ${record.status} ${record.path}`;
198
+ function describe(record, sessionId) {
199
+ const relationship = record.parentSessionId === sessionId ? "parent" : record.sessionId === sessionId ? "child" : "other session";
200
+ return `${record.id} ${record.branch} ${record.status} (${relationship}) ${record.path}`;
192
201
  }
193
202
  function text(...lines) {
194
203
  return [{
@@ -226,7 +235,7 @@ async function executeRunWorktreeTool(params, operations, context, options = {})
226
235
  case WORKTREE_ACTIONS.list: {
227
236
  const records = await operations.list(context);
228
237
  return {
229
- content: records.length === 0 ? text("No worktrees for this repository.") : text(`${String(records.length)} worktree(s):`, ...records.map(describe)),
238
+ content: records.length === 0 ? text("No worktrees for this repository.") : text(`${String(records.length)} worktree(s):`, ...records.map((record) => describe(record, context.sessionId))),
230
239
  details: {
231
240
  action: params.action,
232
241
  records
@@ -236,7 +245,7 @@ async function executeRunWorktreeTool(params, operations, context, options = {})
236
245
  case WORKTREE_ACTIONS.status: {
237
246
  const { record, dirtyFiles } = await operations.status(context, params.id);
238
247
  return {
239
- content: text(describe(record), `Session: ${record.sessionId}`, dirtyFiles.length === 0 ? "Clean." : `${String(dirtyFiles.length)} uncommitted file(s): ${dirtyFiles.slice(0, 20).join(", ")}`),
248
+ content: text(describe(record, context.sessionId), `Session: ${record.sessionId}`, dirtyFiles.length === 0 ? "Clean." : `${String(dirtyFiles.length)} uncommitted file(s): ${dirtyFiles.slice(0, 20).join(", ")}`),
240
249
  details: {
241
250
  action: params.action,
242
251
  records: [record]
@@ -284,6 +293,30 @@ async function executeRunWorktreeTool(params, operations, context, options = {})
284
293
  }
285
294
  }
286
295
  //#endregion
296
+ Object.defineProperty(exports, "COMMAND_DESCRIPTION", {
297
+ enumerable: true,
298
+ get: function() {
299
+ return COMMAND_DESCRIPTION;
300
+ }
301
+ });
302
+ Object.defineProperty(exports, "COMMAND_NAME", {
303
+ enumerable: true,
304
+ get: function() {
305
+ return COMMAND_NAME;
306
+ }
307
+ });
308
+ Object.defineProperty(exports, "GIT_BRANCHES_PATH", {
309
+ enumerable: true,
310
+ get: function() {
311
+ return GIT_BRANCHES_PATH;
312
+ }
313
+ });
314
+ Object.defineProperty(exports, "GIT_SESSIONS_PATH", {
315
+ enumerable: true,
316
+ get: function() {
317
+ return GIT_SESSIONS_PATH;
318
+ }
319
+ });
287
320
  Object.defineProperty(exports, "RUN_WORKTREE_DESCRIPTION", {
288
321
  enumerable: true,
289
322
  get: function() {
@@ -315,4 +348,4 @@ Object.defineProperty(exports, "validateParams", {
315
348
  }
316
349
  });
317
350
 
318
- //# sourceMappingURL=runWorktree-B6ikYRrG.cjs.map
351
+ //# sourceMappingURL=runWorktree-D0bsyYc0.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runWorktree-D0bsyYc0.cjs","names":["Type","invalidRequest"],"sources":["../src/constants/git.ts","../src/schemas/runWorktreeTool.ts","../src/services/runWorktree/index.ts"],"sourcesContent":["export const COMMAND_NAME = 'doom-git';\nexport const COMMAND_DESCRIPTION = 'Show git worktrees owned by this session';\n/** The package API base path; the cockpit mounts it at /api/workspaces/<id>/plugins/git. */\nexport const GIT_API_BASE_PATH = 'git';\n/** Workspace-mounted routes behind the new-session dialog. */\nexport const GIT_BRANCHES_PATH = '/branches';\nexport const GIT_SESSIONS_PATH = '/sessions';\n","import { type Static, Type } from 'typebox';\n\n/**\n * The tool's action vocabulary.\n *\n * One tool with an action field rather than six tools, matching `subagent`:\n * the actions share a subject and are meaningless apart from it, and six\n * separate tools would spend six description budgets teaching the same nouns.\n */\nexport const WORKTREE_ACTIONS = {\n spawn_worktree: 'spawn_worktree',\n close_worktree: 'close_worktree',\n list: 'list',\n status: 'status',\n merge: 'merge',\n prune: 'prune',\n send: 'send',\n messages: 'messages',\n} as const;\n\nexport type WorktreeAction = (typeof WORKTREE_ACTIONS)[keyof typeof WORKTREE_ACTIONS];\n\n/**\n * Which fields each action accepts.\n *\n * Rejecting an unknown field is what stops a plausible-looking call from doing\n * something other than what it reads like: `close_worktree` with `branch`\n * instead of `id` would otherwise close whatever the default resolved to.\n */\nexport const WORKTREE_ACTION_FIELDS: Record<WorktreeAction, readonly string[]> = {\n spawn_worktree: ['action', 'branch', 'baseRef', 'task', 'name'],\n close_worktree: ['action', 'id', 'force'],\n list: ['action'],\n status: ['action', 'id'],\n merge: ['action', 'id', 'message'],\n prune: ['action', 'dryRun'],\n send: ['action', 'id', 'message'],\n messages: ['action', 'id'],\n};\n\nconst SpawnParams = Type.Object(\n {\n action: Type.Literal(WORKTREE_ACTIONS.spawn_worktree),\n branch: Type.String({ minLength: 1 }),\n baseRef: Type.Optional(Type.String({ minLength: 1 })),\n task: Type.Optional(Type.String({ minLength: 1 })),\n name: Type.Optional(Type.String({ minLength: 1 })),\n },\n { additionalProperties: false },\n);\n\nconst CloseParams = Type.Object(\n {\n action: Type.Literal(WORKTREE_ACTIONS.close_worktree),\n id: Type.String({ minLength: 1 }),\n force: Type.Optional(Type.Boolean()),\n },\n { additionalProperties: false },\n);\n\nconst ListParams = Type.Object({ action: Type.Literal(WORKTREE_ACTIONS.list) }, { additionalProperties: false });\n\nconst StatusParams = Type.Object(\n { action: Type.Literal(WORKTREE_ACTIONS.status), id: Type.String({ minLength: 1 }) },\n { additionalProperties: false },\n);\n\nconst MergeParams = Type.Object(\n {\n action: Type.Literal(WORKTREE_ACTIONS.merge),\n id: Type.String({ minLength: 1 }),\n message: Type.Optional(Type.String({ minLength: 1 })),\n },\n { additionalProperties: false },\n);\n\nconst PruneParams = Type.Object(\n { action: Type.Literal(WORKTREE_ACTIONS.prune), dryRun: Type.Optional(Type.Boolean()) },\n { additionalProperties: false },\n);\n\nconst SendParams = Type.Object(\n {\n action: Type.Literal(WORKTREE_ACTIONS.send),\n id: Type.String({ minLength: 1 }),\n message: Type.String({ minLength: 1 }),\n },\n { additionalProperties: false },\n);\n\nconst MessagesParams = Type.Object(\n { action: Type.Literal(WORKTREE_ACTIONS.messages), id: Type.String({ minLength: 1 }) },\n { additionalProperties: false },\n);\n\nexport const RunWorktreeParams = Type.Union([\n SpawnParams,\n CloseParams,\n ListParams,\n StatusParams,\n MergeParams,\n PruneParams,\n SendParams,\n MessagesParams,\n]);\n\n/** The actions that accept `field`, so the declared docs cannot drift from the validator. */\nfunction acceptingActions(field: string): string {\n return Object.values(WORKTREE_ACTIONS)\n .filter((action) => WORKTREE_ACTION_FIELDS[action].includes(field))\n .join(', ');\n}\n\n/**\n * The schema declared to the model.\n *\n * A flat object rather than `RunWorktreeParams` itself. A top-level union is\n * `{anyOf:[...]}` with no `properties`, and Pi's Anthropic Messages adapter\n * rebuilds tool input as `{type:'object', properties: schema.properties ?? {},\n * required: schema.required ?? []}`, so the union arrived at the model as an\n * empty object while the host went on validating calls against it. Nothing here\n * relaxes what is accepted: `validateParams` still rejects an unknown action, a\n * field the action does not take, and a missing required one.\n */\nexport const RunWorktreeToolSchema = Type.Object(\n {\n action: Type.String({\n enum: Object.values(WORKTREE_ACTIONS),\n description: 'The operation to run. Every other field is accepted only by the actions its description names.',\n }),\n branch: Type.Optional(\n Type.String({ minLength: 1, description: `New branch to create. Actions: ${acceptingActions('branch')}.` }),\n ),\n baseRef: Type.Optional(\n Type.String({\n minLength: 1,\n description: `Base ref, defaulting to the current branch. Actions: ${acceptingActions('baseRef')}.`,\n }),\n ),\n task: Type.Optional(\n Type.String({\n minLength: 1,\n description: `First message for the new session. Actions: ${acceptingActions('task')}.`,\n }),\n ),\n name: Type.Optional(\n Type.String({ minLength: 1, description: `Rail label for the worktree. Actions: ${acceptingActions('name')}.` }),\n ),\n id: Type.Optional(Type.String({ minLength: 1, description: `Worktree id. Actions: ${acceptingActions('id')}.` })),\n force: Type.Optional(\n Type.Boolean({ description: `Close even when the tree is dirty. Actions: ${acceptingActions('force')}.` }),\n ),\n message: Type.Optional(\n Type.String({\n minLength: 1,\n description: `Merge commit message, or the text to send. Actions: ${acceptingActions('message')}.`,\n }),\n ),\n dryRun: Type.Optional(\n Type.Boolean({\n description: `Report the plan without destroying anything. Actions: ${acceptingActions('dryRun')}.`,\n }),\n ),\n },\n { additionalProperties: false },\n);\n\nexport type RunWorktreeToolParams = Static<typeof RunWorktreeParams>;\n","import {\n RunWorktreeParams,\n WORKTREE_ACTION_FIELDS,\n WORKTREE_ACTIONS,\n type WorktreeAction,\n type RunWorktreeToolParams,\n} from '../../schemas/runWorktreeTool';\nimport type { WorktreeRecord } from '../../types/worktreeRegistry';\nimport { invalidRequest } from '../errors';\nimport type { WorktreeOperations } from '../worktreeOperations';\n\nexport { RunWorktreeParams };\nexport type { RunWorktreeToolParams, WorktreeAction };\n\nexport const RUN_WORKTREE_TOOL_NAME = 'run_worktree';\n\nconst IMPLEMENTED_ACTIONS: ReadonlySet<string> = new Set(Object.values(WORKTREE_ACTIONS));\n\nexport const RUN_WORKTREE_DESCRIPTION = `Create and manage git worktrees, each with its own DoomPi session nested under this one.\n\nActions:\n- spawn_worktree: create a worktree on a new branch and start a session in it. Requires 'branch'. Optional 'baseRef' (defaults to the current branch's remote-tracking ref, then the remote default branch), 'name' for the rail, 'task' as the first message.\n- close_worktree: stop a worktree's session, delete its checkout, and remove its generated sync storage. Requires 'id'. Refuses a dirty tree unless 'force' is true.\n- list: every worktree for this repository, with status and relationship to the calling session.\n- status: one worktree, its relationship to the calling session, and its uncommitted files. Requires 'id'.\n- merge: merge a worktree's branch into this checkout. Requires 'id'. Refuses when this checkout is dirty.\n- prune: remove orphaned worktrees and their generated sync storage. Pass 'dryRun' to see the plan without destroying anything.\n- send: send a message to the other side of a worktree. Requires 'id' and 'message'.\n- messages: read messages waiting for you from a worktree. Requires 'id'.\n\nFor a nested worktree session, use the record labelled 'child' in list to report to your parent. Use records labelled 'parent' to contact your own children. Other records are not communication edges.\nWorktrees live outside the repository, under ~/.pi/.doom/git/worktrees.`;\n\nexport interface RunWorktreeToolDetails {\n action: WorktreeAction;\n records?: WorktreeRecord[];\n}\n\nexport interface RunWorktreeToolResult {\n content: [{ type: 'text'; text: string }];\n details: RunWorktreeToolDetails;\n}\n\nexport interface RunWorktreeExecutionContext {\n readonly cwd: string;\n readonly sessionId: string;\n}\n\nexport interface RunWorktreeExecutionOptions {\n readonly signal?: AbortSignal;\n readonly onProgress?: (label: string) => void;\n}\n\n/** Rejects calls that do not match one documented action shape. */\nexport function validateParams(input: unknown): RunWorktreeToolParams {\n if (typeof input !== 'object' || input === null || Array.isArray(input)) {\n throw invalidRequest('run_worktree parameters must be an object.', 'Call it with one documented action shape.');\n }\n const record = input as Record<string, unknown>;\n const action = record.action;\n if (typeof action !== 'string' || !IMPLEMENTED_ACTIONS.has(action)) {\n throw invalidRequest(\n `Unknown action ${typeof action === 'string' ? `'${action}'` : 'value'}.`,\n `Use one of: ${[...IMPLEMENTED_ACTIONS].join(', ')}.`,\n );\n }\n const allowed = WORKTREE_ACTION_FIELDS[action as WorktreeAction];\n const unexpected = Object.keys(record).filter((key) => !allowed.includes(key));\n if (unexpected.length > 0) {\n throw invalidRequest(\n `action='${action}' does not accept: ${unexpected.join(', ')}.`,\n `Fields for '${action}': ${allowed.join(', ')}.`,\n );\n }\n for (const field of ['branch', 'id'] as const) {\n if (allowed.includes(field) && field in record) {\n const value = record[field];\n if (typeof value !== 'string' || value.trim() === '') {\n throw invalidRequest(`action='${action}' requires a nonblank '${field}'.`, `Pass a ${field}.`);\n }\n }\n }\n const stringFields = ['baseRef', 'name', 'task', 'message'] as const;\n for (const field of stringFields) {\n if (field in record && (typeof record[field] !== 'string' || record[field].trim() === '')) {\n throw invalidRequest(`action='${action}' requires a nonblank '${field}'.`, `Pass a ${field}.`);\n }\n }\n for (const field of ['force', 'dryRun'] as const) {\n if (field in record && typeof record[field] !== 'boolean') {\n throw invalidRequest(`action='${action}' requires boolean '${field}'.`, `Pass true or false for ${field}.`);\n }\n }\n if (action === WORKTREE_ACTIONS.send && typeof record.message !== 'string') {\n throw invalidRequest(\"action='send' requires 'message'.\", 'Pass the message to send.');\n }\n if (action === WORKTREE_ACTIONS.spawn_worktree && typeof record.branch !== 'string') {\n throw invalidRequest(\"action='spawn_worktree' requires 'branch'.\", 'Name the branch to create.');\n }\n if (\n (action === WORKTREE_ACTIONS.close_worktree ||\n action === WORKTREE_ACTIONS.status ||\n action === WORKTREE_ACTIONS.merge ||\n action === WORKTREE_ACTIONS.send ||\n action === WORKTREE_ACTIONS.messages) &&\n typeof record.id !== 'string'\n ) {\n throw invalidRequest(`action='${action}' requires 'id'.`, 'Call list to see the current ids.');\n }\n return record as RunWorktreeToolParams;\n}\n\nfunction describe(record: WorktreeRecord, sessionId: string): string {\n const relationship =\n record.parentSessionId === sessionId ? 'parent' : record.sessionId === sessionId ? 'child' : 'other session';\n return `${record.id} ${record.branch} ${record.status} (${relationship}) ${record.path}`;\n}\n\nfunction text(...lines: readonly string[]): [{ type: 'text'; text: string }] {\n return [{ type: 'text', text: lines.join('\\n') }];\n}\n\nexport async function executeRunWorktreeTool(\n params: RunWorktreeToolParams,\n operations: WorktreeOperations,\n context: RunWorktreeExecutionContext,\n options: RunWorktreeExecutionOptions = {},\n): Promise<RunWorktreeToolResult> {\n switch (params.action) {\n case WORKTREE_ACTIONS.spawn_worktree: {\n const record = await operations.spawn(\n context,\n {\n branch: params.branch,\n ...(params.baseRef === undefined ? {} : { baseRef: params.baseRef }),\n ...(params.name === undefined ? {} : { name: params.name }),\n ...(params.task === undefined ? {} : { task: params.task }),\n },\n options,\n );\n return {\n content: text(\n `Worktree ${record.id} created on ${record.branch} from ${record.baseRef}.`,\n `Path: ${record.path}`,\n params.task === undefined\n ? `Session ${record.sessionId} is starting; it appears nested under this one in the rail.`\n : `Session ${record.sessionId} is starting with its task; it appears nested under this one in the rail.`,\n ),\n details: { action: params.action, records: [record] },\n };\n }\n case WORKTREE_ACTIONS.close_worktree: {\n const record = await operations.close(context, params.id, params.force ?? false);\n return {\n content: text(`Worktree ${record.id} (${record.branch}) closed and removed.`),\n details: { action: params.action, records: [record] },\n };\n }\n case WORKTREE_ACTIONS.list: {\n const records = await operations.list(context);\n return {\n content:\n records.length === 0\n ? text('No worktrees for this repository.')\n : text(\n `${String(records.length)} worktree(s):`,\n ...records.map((record) => describe(record, context.sessionId)),\n ),\n details: { action: params.action, records },\n };\n }\n case WORKTREE_ACTIONS.status: {\n const { record, dirtyFiles } = await operations.status(context, params.id);\n return {\n content: text(\n describe(record, context.sessionId),\n `Session: ${record.sessionId}`,\n dirtyFiles.length === 0\n ? 'Clean.'\n : `${String(dirtyFiles.length)} uncommitted file(s): ${dirtyFiles.slice(0, 20).join(', ')}`,\n ),\n details: { action: params.action, records: [record] },\n };\n }\n case WORKTREE_ACTIONS.merge: {\n const record = await operations.merge(\n context,\n params.id,\n ...(params.message === undefined ? [] : ([params.message] as const)),\n );\n return {\n content: text(`Merged ${record.branch} into this checkout.`),\n details: { action: params.action, records: [record] },\n };\n }\n case WORKTREE_ACTIONS.send: {\n await operations.send(context, params.id, params.message);\n return { content: text(`Message sent to worktree ${params.id}.`), details: { action: params.action } };\n }\n case WORKTREE_ACTIONS.messages: {\n const waiting = await operations.messages(context, params.id);\n return {\n content:\n waiting.length === 0\n ? text('No messages.')\n : text(\n `${String(waiting.length)} message(s):`,\n ...waiting.map((entry) => `[${entry.sentAt}] ${entry.from}: ${entry.text}`),\n ),\n details: { action: params.action },\n };\n }\n case WORKTREE_ACTIONS.prune: {\n const dryRun = params.dryRun ?? false;\n const plan = await operations.prune(context, dryRun);\n const lines = [\n dryRun ? 'Prune plan (nothing was changed):' : 'Pruned:',\n `Remove: ${plan.remove.length === 0 ? 'none' : plan.remove.map((record) => record.id).join(', ')}`,\n `Forget: ${plan.forget.length === 0 ? 'none' : plan.forget.map((record) => record.id).join(', ')}`,\n `Kept, uncommitted work: ${plan.keptDirty.length === 0 ? 'none' : plan.keptDirty.map((record) => record.id).join(', ')}`,\n `Untracked directories, left alone: ${plan.untracked.length === 0 ? 'none' : plan.untracked.join(', ')}`,\n ...(plan.keptBranches.length === 0\n ? []\n : [`Branches kept, they hold commits: ${plan.keptBranches.join(', ')}`]),\n ];\n return { content: text(...lines), details: { action: params.action } };\n }\n }\n}\n"],"mappings":";;;AAAA,MAAa,eAAe;AAC5B,MAAa,sBAAsB;;AAInC,MAAa,oBAAoB;AACjC,MAAa,oBAAoB;;;;;;;;;;ACGjC,MAAa,mBAAmB;CAC9B,gBAAgB;CAChB,gBAAgB;CAChB,MAAM;CACN,QAAQ;CACR,OAAO;CACP,OAA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