@agimon-ai/doompi-git 0.0.1-alpha.4 → 0.0.1-alpha.41
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/README.md +33 -1
- package/dist/apiContracts.cjs +387 -0
- package/dist/apiContracts.cjs.map +1 -0
- package/dist/apiContracts.d.mts +53 -0
- package/dist/apiContracts.d.mts.map +1 -0
- package/dist/apiContracts.mjs +382 -0
- package/dist/apiContracts.mjs.map +1 -0
- package/dist/extensions/pi.cjs +105 -1
- package/dist/extensions/pi.cjs.map +1 -0
- package/dist/extensions/pi.d.mts +6 -2
- package/dist/extensions/pi.d.mts.map +1 -0
- package/dist/extensions/pi.mjs +100 -1
- package/dist/extensions/pi.mjs.map +1 -0
- package/dist/extensions/server.cjs +1828 -0
- package/dist/extensions/server.cjs.map +1 -0
- package/dist/extensions/server.d.mts +5 -0
- package/dist/extensions/server.d.mts.map +1 -0
- package/dist/extensions/server.mjs +1820 -0
- package/dist/extensions/server.mjs.map +1 -0
- package/dist/extensions/web.mjs +2641 -0
- package/dist/extensions/web.mjs.map +1 -0
- package/dist/gitDependencies-CtVubYvU.mjs +22 -0
- package/dist/gitDependencies-CtVubYvU.mjs.map +1 -0
- package/dist/gitDependencies-Dqsz2HjK.cjs +33 -0
- package/dist/gitDependencies-Dqsz2HjK.cjs.map +1 -0
- package/dist/index-D79MSCee.d.mts +145 -0
- package/dist/index-D79MSCee.d.mts.map +1 -0
- package/dist/index.cjs +4 -1
- package/dist/index.d.mts +2 -5
- package/dist/index.mjs +2 -1
- package/dist/runWorktree-BE795LxL.cjs +374 -0
- package/dist/runWorktree-BE795LxL.cjs.map +1 -0
- package/dist/runWorktree-SPzJvIBt.mjs +303 -0
- package/dist/runWorktree-SPzJvIBt.mjs.map +1 -0
- package/dist/worktreeOperations-BYmVU0UV.cjs +1350 -0
- package/dist/worktreeOperations-BYmVU0UV.cjs.map +1 -0
- package/dist/worktreeOperations-BrWG2muV.mjs +1194 -0
- package/dist/worktreeOperations-BrWG2muV.mjs.map +1 -0
- package/llms.txt +4 -0
- package/package.json +56 -41
- package/src/prompts/doompi-use-git/SKILL.md +26 -3
- package/dist/_virtual/_rolldown/runtime.cjs +0 -1
- package/dist/adapters/channel/worktreeChannel.cjs +0 -2
- package/dist/adapters/channel/worktreeChannel.cjs.map +0 -1
- package/dist/adapters/channel/worktreeChannel.d.cts +0 -40
- package/dist/adapters/channel/worktreeChannel.d.cts.map +0 -1
- package/dist/adapters/channel/worktreeChannel.d.mts +0 -40
- package/dist/adapters/channel/worktreeChannel.d.mts.map +0 -1
- package/dist/adapters/channel/worktreeChannel.mjs +0 -2
- package/dist/adapters/channel/worktreeChannel.mjs.map +0 -1
- package/dist/adapters/filesystem/atomicJson.cjs +0 -2
- package/dist/adapters/filesystem/atomicJson.cjs.map +0 -1
- package/dist/adapters/filesystem/atomicJson.mjs +0 -2
- package/dist/adapters/filesystem/atomicJson.mjs.map +0 -1
- package/dist/adapters/filesystem/paths.cjs +0 -2
- package/dist/adapters/filesystem/paths.cjs.map +0 -1
- package/dist/adapters/filesystem/paths.mjs +0 -2
- package/dist/adapters/filesystem/paths.mjs.map +0 -1
- package/dist/adapters/hub/hubClient.cjs +0 -2
- package/dist/adapters/hub/hubClient.cjs.map +0 -1
- package/dist/adapters/hub/hubClient.d.cts +0 -1
- package/dist/adapters/hub/hubClient.d.mts +0 -1
- package/dist/adapters/hub/hubClient.mjs +0 -2
- package/dist/adapters/hub/hubClient.mjs.map +0 -1
- package/dist/adapters/pi/extension.cjs +0 -2
- package/dist/adapters/pi/extension.cjs.map +0 -1
- package/dist/adapters/pi/extension.d.cts +0 -9
- package/dist/adapters/pi/extension.d.cts.map +0 -1
- package/dist/adapters/pi/extension.d.mts +0 -9
- package/dist/adapters/pi/extension.d.mts.map +0 -1
- package/dist/adapters/pi/extension.mjs +0 -2
- package/dist/adapters/pi/extension.mjs.map +0 -1
- package/dist/adapters/pi/extensions/runWorktreeTool.cjs +0 -15
- package/dist/adapters/pi/extensions/runWorktreeTool.cjs.map +0 -1
- package/dist/adapters/pi/extensions/runWorktreeTool.mjs +0 -15
- package/dist/adapters/pi/extensions/runWorktreeTool.mjs.map +0 -1
- package/dist/adapters/web/worktreesChannel.cjs +0 -2
- package/dist/adapters/web/worktreesChannel.cjs.map +0 -1
- package/dist/adapters/web/worktreesChannel.d.cts +0 -21
- package/dist/adapters/web/worktreesChannel.d.cts.map +0 -1
- package/dist/adapters/web/worktreesChannel.d.mts +0 -21
- package/dist/adapters/web/worktreesChannel.d.mts.map +0 -1
- package/dist/adapters/web/worktreesChannel.mjs +0 -2
- package/dist/adapters/web/worktreesChannel.mjs.map +0 -1
- package/dist/adapters/worktree/dependencyInstall.cjs +0 -2
- package/dist/adapters/worktree/dependencyInstall.cjs.map +0 -1
- package/dist/adapters/worktree/dependencyInstall.mjs +0 -2
- package/dist/adapters/worktree/dependencyInstall.mjs.map +0 -1
- package/dist/adapters/worktree/gitCli.cjs +0 -4
- package/dist/adapters/worktree/gitCli.cjs.map +0 -1
- package/dist/adapters/worktree/gitCli.mjs +0 -4
- package/dist/adapters/worktree/gitCli.mjs.map +0 -1
- package/dist/adapters/worktree/repositoryIdentity.cjs +0 -2
- package/dist/adapters/worktree/repositoryIdentity.cjs.map +0 -1
- package/dist/adapters/worktree/repositoryIdentity.mjs +0 -2
- package/dist/adapters/worktree/repositoryIdentity.mjs.map +0 -1
- package/dist/adapters/worktree/worktreeOperations.cjs +0 -2
- package/dist/adapters/worktree/worktreeOperations.cjs.map +0 -1
- package/dist/adapters/worktree/worktreeOperations.d.cts +0 -32
- package/dist/adapters/worktree/worktreeOperations.d.cts.map +0 -1
- package/dist/adapters/worktree/worktreeOperations.d.mts +0 -32
- package/dist/adapters/worktree/worktreeOperations.d.mts.map +0 -1
- package/dist/adapters/worktree/worktreeOperations.mjs +0 -2
- package/dist/adapters/worktree/worktreeOperations.mjs.map +0 -1
- package/dist/adapters/worktree/worktreeRegistry.cjs +0 -2
- package/dist/adapters/worktree/worktreeRegistry.cjs.map +0 -1
- package/dist/adapters/worktree/worktreeRegistry.mjs +0 -2
- package/dist/adapters/worktree/worktreeRegistry.mjs.map +0 -1
- package/dist/commands/doomGitCommand.cjs +0 -2
- package/dist/commands/doomGitCommand.cjs.map +0 -1
- package/dist/commands/doomGitCommand.mjs +0 -2
- package/dist/commands/doomGitCommand.mjs.map +0 -1
- package/dist/container/index.cjs +0 -2
- package/dist/container/index.cjs.map +0 -1
- package/dist/container/index.d.cts +0 -6
- package/dist/container/index.d.cts.map +0 -1
- package/dist/container/index.d.mts +0 -6
- package/dist/container/index.d.mts.map +0 -1
- package/dist/container/index.mjs +0 -2
- package/dist/container/index.mjs.map +0 -1
- package/dist/extensions/pi.d.cts +0 -2
- package/dist/hubApi.cjs +0 -2
- package/dist/hubApi.cjs.map +0 -1
- package/dist/hubApi.d.cts +0 -6
- package/dist/hubApi.d.cts.map +0 -1
- package/dist/hubApi.d.mts +0 -6
- package/dist/hubApi.d.mts.map +0 -1
- package/dist/hubApi.mjs +0 -2
- package/dist/hubApi.mjs.map +0 -1
- package/dist/index.d.cts +0 -5
- package/dist/schemas/runWorktreeTool.cjs +0 -2
- package/dist/schemas/runWorktreeTool.cjs.map +0 -1
- package/dist/schemas/runWorktreeTool.mjs +0 -2
- package/dist/schemas/runWorktreeTool.mjs.map +0 -1
- package/dist/services/extensionService.cjs +0 -2
- package/dist/services/extensionService.cjs.map +0 -1
- package/dist/services/extensionService.d.cts +0 -8
- package/dist/services/extensionService.d.cts.map +0 -1
- package/dist/services/extensionService.d.mts +0 -8
- package/dist/services/extensionService.d.mts.map +0 -1
- package/dist/services/extensionService.mjs +0 -2
- package/dist/services/extensionService.mjs.map +0 -1
- package/dist/services/support/errors.cjs +0 -2
- package/dist/services/support/errors.cjs.map +0 -1
- package/dist/services/support/errors.mjs +0 -2
- package/dist/services/support/errors.mjs.map +0 -1
- package/dist/services/worktreeNaming.cjs +0 -2
- package/dist/services/worktreeNaming.cjs.map +0 -1
- package/dist/services/worktreeNaming.d.cts +0 -27
- package/dist/services/worktreeNaming.d.cts.map +0 -1
- package/dist/services/worktreeNaming.d.mts +0 -27
- package/dist/services/worktreeNaming.d.mts.map +0 -1
- package/dist/services/worktreeNaming.mjs +0 -2
- package/dist/services/worktreeNaming.mjs.map +0 -1
- package/dist/types/extension.d.cts +0 -17
- package/dist/types/extension.d.cts.map +0 -1
- package/dist/types/extension.d.mts +0 -17
- package/dist/types/extension.d.mts.map +0 -1
- package/dist/types/webWorktrees.cjs +0 -2
- package/dist/types/webWorktrees.cjs.map +0 -1
- package/dist/types/webWorktrees.mjs +0 -2
- package/dist/types/webWorktrees.mjs.map +0 -1
- package/dist/types/worktreeRegistry.d.cts +0 -41
- package/dist/types/worktreeRegistry.d.cts.map +0 -1
- package/dist/types/worktreeRegistry.d.mts +0 -41
- package/dist/types/worktreeRegistry.d.mts.map +0 -1
- package/dist/webHub.cjs +0 -1
- package/dist/webHub.d.cts +0 -2
- package/dist/webHub.d.mts +0 -2
- package/dist/webHub.mjs +0 -1
- package/src/exports/webClient.ts +0 -1
- package/src/types/webWorktrees.ts +0 -55
- package/src/types/worktreeRegistry.ts +0 -69
- package/src/web/components/RunWorktreeToolMessage.tsx +0 -37
- package/src/web/components/WorktreesActivitySection.tsx +0 -64
- package/src/web/components/WorktreesPanel.tsx +0 -125
- package/src/web/components/toolRenderers.ts +0 -7
- package/src/web/index.ts +0 -30
- package/src/web/stores/worktreesActivityStore.ts +0 -124
- package/src/web/tsconfig.json +0 -22
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"worktreeNaming.cjs","names":[],"sources":["../../src/services/worktreeNaming.ts"],"sourcesContent":["/**\n * Naming and reconciliation rules for worktrees, as pure functions.\n *\n * Everything here is a function of its arguments so the interesting decisions,\n * which are the ones about destroying work, can be tested without a repository\n * or a filesystem.\n */\n\nimport type { WorktreeRecord } from '../types/worktreeRegistry.ts';\n\nconst MAX_SLUG_LENGTH = 64;\n\n/**\n * A branch name reduced to one safe path segment.\n *\n * Slashes are the point: `wt/fix-auth` is a perfectly good branch and a\n * terrible directory name, because the nested directory it implies is not the\n * one the worktree lives in.\n */\nexport function branchSlug(branch: string): string {\n const slug = branch\n .toLowerCase()\n .replace(/[^a-z0-9]+/gu, '-')\n .replace(/^-+|-+$/gu, '')\n .slice(0, MAX_SLUG_LENGTH)\n .replace(/-+$/gu, '');\n return slug === '' ? 'worktree' : slug;\n}\n\n/**\n * The directory for one worktree.\n *\n * The short id disambiguates two branches whose slugs collide, such as\n * `feature/x` and `feature_x`, which would otherwise want the same directory.\n */\nexport function worktreeDirectory(input: {\n worktreesRoot: string;\n repositoryLabel: string;\n repositoryId: string;\n branch: string;\n shortId: string;\n}): string {\n const repository = `${input.repositoryLabel}--${input.repositoryId}`;\n return `${input.worktreesRoot}/${repository}/${branchSlug(input.branch)}--${input.shortId}`;\n}\n\n/** Why a worktree cannot be created, or undefined when it can. */\nexport function refuseSpawn(input: { branch: string; existing: readonly WorktreeRecord[] }): string | undefined {\n if (input.branch.trim() === '') return 'A branch name is required.';\n // Git refuses a second worktree on one branch, but its message names a path\n // the caller never chose, so this says it in the caller's own terms first.\n const live = input.existing.find((record) => record.branch === input.branch && record.status !== 'orphaned');\n if (live) return `Branch ${input.branch} already has a worktree (${live.id}).`;\n return undefined;\n}\n\n/** Why a worktree cannot be closed, or undefined when it can. */\nexport function refuseClose(input: {\n record: WorktreeRecord | undefined;\n dirtyFiles: readonly string[];\n force: boolean;\n}): string | undefined {\n if (!input.record) return 'No worktree with that id. Call list to see the current ids.';\n if (input.dirtyFiles.length === 0 || input.force) return undefined;\n // Naming the files is the point: \"the tree is dirty\" sends the reader to go\n // look, and the answer is usually a file they forgot rather than one they\n // meant to keep.\n const names = input.dirtyFiles.slice(0, 10).join(', ');\n const more = input.dirtyFiles.length > 10 ? `, and ${String(input.dirtyFiles.length - 10)} more` : '';\n return `${String(input.dirtyFiles.length)} uncommitted file(s): ${names}${more}. Pass force: true to discard them.`;\n}\n\nexport interface Reconciliation {\n records: WorktreeRecord[];\n /** Ids whose status changed, so a caller can report what it noticed. */\n changed: string[];\n}\n\n/**\n * Marks records whose process or directory is gone as orphaned.\n *\n * Nothing is deleted here. A doompi-git orphan owns a directory that may hold\n * uncommitted work, so losing the record would lose the only pointer to it.\n * Deletion is always a separate, named decision.\n */\nexport function reconcile(\n records: readonly WorktreeRecord[],\n probe: { alive: (record: WorktreeRecord) => boolean; exists: (path: string) => boolean },\n): Reconciliation {\n const changed: string[] = [];\n const next = records.map((record) => {\n if (record.status === 'orphaned') return record;\n const gone = !probe.exists(record.path) || !probe.alive(record);\n if (!gone) return record;\n changed.push(record.id);\n return { ...record, status: 'orphaned' as const };\n });\n return { records: next, changed };\n}\n\nexport interface PrunePlan {\n /** Orphans whose directory git still lists, safe to remove. */\n remove: WorktreeRecord[];\n /** Orphans whose directory is already gone; drop the record only. */\n forget: WorktreeRecord[];\n /** Paths git lists under our root that we have no record of; report, never touch. */\n untracked: string[];\n /** Orphans left alone because they still hold uncommitted work. */\n keptDirty: WorktreeRecord[];\n}\n\n/**\n * What a prune would do, decided before anything is destroyed.\n *\n * Separating the plan from the execution is what makes dryRun honest and lets\n * the destructive half be reviewed on its own.\n */\nexport function planPrune(input: {\n records: readonly WorktreeRecord[];\n gitPaths: readonly string[];\n worktreesRoot: string;\n dirtyByPath: ReadonlyMap<string, readonly string[]>;\n}): PrunePlan {\n const plan: PrunePlan = { remove: [], forget: [], untracked: [], keptDirty: [] };\n const known = new Set(input.records.map((record) => record.path));\n const listed = new Set(input.gitPaths);\n for (const record of input.records) {\n if (record.status !== 'orphaned') continue;\n if (!listed.has(record.path)) {\n plan.forget.push(record);\n continue;\n }\n if ((input.dirtyByPath.get(record.path) ?? []).length > 0) {\n plan.keptDirty.push(record);\n continue;\n }\n plan.remove.push(record);\n }\n for (const path of input.gitPaths) {\n // Only ever inside our own root: a worktree the user made by hand is none\n // of this package's business, even when it looks abandoned.\n if (path.startsWith(`${input.worktreesRoot}/`) && !known.has(path)) plan.untracked.push(path);\n }\n return plan;\n}\n"],"mappings":"AAmBA,SAAgB,EAAW,EAAwB,CACjD,IAAM,EAAO,EACV,YAAY,CAAC,CACb,QAAQ,eAAgB,GAAG,CAAC,CAC5B,QAAQ,YAAa,EAAE,CAAC,CACxB,MAAM,EAAG,EAAe,CAAC,CACzB,QAAQ,QAAS,EAAE,EACtB,OAAO,IAAS,GAAK,WAAa,CACpC,CAQA,SAAgB,EAAkB,EAMvB,CACT,IAAM,EAAa,GAAG,EAAM,gBAAgB,IAAI,EAAM,eACtD,MAAO,GAAG,EAAM,cAAc,GAAG,EAAW,GAAG,EAAW,EAAM,MAAM,EAAE,IAAI,EAAM,SACpF,CAGA,SAAgB,EAAY,EAAoF,CAC9G,GAAI,EAAM,OAAO,KAAK,IAAM,GAAI,MAAO,6BAGvC,IAAM,EAAO,EAAM,SAAS,KAAM,GAAW,EAAO,SAAW,EAAM,QAAU,EAAO,SAAW,UAAU,EAC3G,GAAI,EAAM,MAAO,UAAU,EAAM,OAAO,2BAA2B,EAAK,GAAG,GAE7E,CAGA,SAAgB,EAAY,EAIL,CACrB,GAAI,CAAC,EAAM,OAAQ,MAAO,8DAC1B,GAAI,EAAM,WAAW,SAAW,GAAK,EAAM,MAAO,OAIlD,IAAM,EAAQ,EAAM,WAAW,MAAM,EAAG,EAAE,CAAC,CAAC,KAAK,IAAI,EAC/C,EAAO,EAAM,WAAW,OAAS,GAAK,SAAS,OAAO,EAAM,WAAW,OAAS,EAAE,EAAE,OAAS,GACnG,MAAO,GAAG,OAAO,EAAM,WAAW,MAAM,EAAE,wBAAwB,IAAQ,EAAK,oCACjF,CAeA,SAAgB,EACd,EACA,EACgB,CAChB,IAAM,EAAoB,CAAC,EAQ3B,MAAO,CAAE,QAPI,EAAQ,IAAK,GACpB,EAAO,SAAW,YACR,EAAM,OAAO,EAAO,IAAI,GAAM,EAAM,MAAM,CAAM,EAC5C,GAClB,EAAQ,KAAK,EAAO,EAAE,EACf,CAAE,GAAG,EAAQ,OAAQ,UAAoB,EAE7B,EAAG,SAAQ,CAClC,CAmBA,SAAgB,EAAU,EAKZ,CACZ,IAAM,EAAkB,CAAE,OAAQ,CAAC,EAAG,OAAQ,CAAC,EAAG,UAAW,CAAC,EAAG,UAAW,CAAC,CAAE,EACzE,EAAQ,IAAI,IAAI,EAAM,QAAQ,IAAK,GAAW,EAAO,IAAI,CAAC,EAC1D,EAAS,IAAI,IAAI,EAAM,QAAQ,EACrC,IAAK,IAAM,KAAU,EAAM,QACrB,KAAO,SAAW,WACtB,IAAI,CAAC,EAAO,IAAI,EAAO,IAAI,EAAG,CAC5B,EAAK,OAAO,KAAK,CAAM,EACvB,QACF,CACA,IAAK,EAAM,YAAY,IAAI,EAAO,IAAI,GAAK,CAAC,EAAA,CAAG,OAAS,EAAG,CACzD,EAAK,UAAU,KAAK,CAAM,EAC1B,QACF,CACA,EAAK,OAAO,KAAK,CAAM,CALvB,CAOF,IAAK,IAAM,KAAQ,EAAM,SAGnB,EAAK,WAAW,GAAG,EAAM,cAAc,EAAE,GAAK,CAAC,EAAM,IAAI,CAAI,GAAG,EAAK,UAAU,KAAK,CAAI,EAE9F,OAAO,CACT"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { WorktreeRecord } from "../types/worktreeRegistry.cjs";
|
|
2
|
-
//#region src/services/worktreeNaming.d.ts
|
|
3
|
-
interface PrunePlan {
|
|
4
|
-
/** Orphans whose directory git still lists, safe to remove. */
|
|
5
|
-
remove: WorktreeRecord[];
|
|
6
|
-
/** Orphans whose directory is already gone; drop the record only. */
|
|
7
|
-
forget: WorktreeRecord[];
|
|
8
|
-
/** Paths git lists under our root that we have no record of; report, never touch. */
|
|
9
|
-
untracked: string[];
|
|
10
|
-
/** Orphans left alone because they still hold uncommitted work. */
|
|
11
|
-
keptDirty: WorktreeRecord[];
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* What a prune would do, decided before anything is destroyed.
|
|
15
|
-
*
|
|
16
|
-
* Separating the plan from the execution is what makes dryRun honest and lets
|
|
17
|
-
* the destructive half be reviewed on its own.
|
|
18
|
-
*/
|
|
19
|
-
declare function planPrune(input: {
|
|
20
|
-
records: readonly WorktreeRecord[];
|
|
21
|
-
gitPaths: readonly string[];
|
|
22
|
-
worktreesRoot: string;
|
|
23
|
-
dirtyByPath: ReadonlyMap<string, readonly string[]>;
|
|
24
|
-
}): PrunePlan;
|
|
25
|
-
//#endregion
|
|
26
|
-
export { PrunePlan, planPrune };
|
|
27
|
-
//# sourceMappingURL=worktreeNaming.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"worktreeNaming.d.cts","names":[],"sources":["../../src/services/worktreeNaming.ts"],"mappings":";;UAoGiB;;EAEf,QAAQ;;EAER,QAAQ;;EAER;;EAEA,WAAW;;;;;;;;iBASG,UAAU;EACxB,kBAAkB;EAClB;EACA;EACA,aAAa;IACX"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { WorktreeRecord } from "../types/worktreeRegistry.mjs";
|
|
2
|
-
//#region src/services/worktreeNaming.d.ts
|
|
3
|
-
interface PrunePlan {
|
|
4
|
-
/** Orphans whose directory git still lists, safe to remove. */
|
|
5
|
-
remove: WorktreeRecord[];
|
|
6
|
-
/** Orphans whose directory is already gone; drop the record only. */
|
|
7
|
-
forget: WorktreeRecord[];
|
|
8
|
-
/** Paths git lists under our root that we have no record of; report, never touch. */
|
|
9
|
-
untracked: string[];
|
|
10
|
-
/** Orphans left alone because they still hold uncommitted work. */
|
|
11
|
-
keptDirty: WorktreeRecord[];
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* What a prune would do, decided before anything is destroyed.
|
|
15
|
-
*
|
|
16
|
-
* Separating the plan from the execution is what makes dryRun honest and lets
|
|
17
|
-
* the destructive half be reviewed on its own.
|
|
18
|
-
*/
|
|
19
|
-
declare function planPrune(input: {
|
|
20
|
-
records: readonly WorktreeRecord[];
|
|
21
|
-
gitPaths: readonly string[];
|
|
22
|
-
worktreesRoot: string;
|
|
23
|
-
dirtyByPath: ReadonlyMap<string, readonly string[]>;
|
|
24
|
-
}): PrunePlan;
|
|
25
|
-
//#endregion
|
|
26
|
-
export { PrunePlan, planPrune };
|
|
27
|
-
//# sourceMappingURL=worktreeNaming.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"worktreeNaming.d.mts","names":[],"sources":["../../src/services/worktreeNaming.ts"],"mappings":";;UAoGiB;;EAEf,QAAQ;;EAER,QAAQ;;EAER;;EAEA,WAAW;;;;;;;;iBASG,UAAU;EACxB,kBAAkB;EAClB;EACA;EACA,aAAa;IACX"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
function e(e){let t=e.toLowerCase().replace(/[^a-z0-9]+/gu,`-`).replace(/^-+|-+$/gu,``).slice(0,64).replace(/-+$/gu,``);return t===``?`worktree`:t}function t(t){let n=`${t.repositoryLabel}--${t.repositoryId}`;return`${t.worktreesRoot}/${n}/${e(t.branch)}--${t.shortId}`}function n(e){if(e.branch.trim()===``)return`A branch name is required.`;let t=e.existing.find(t=>t.branch===e.branch&&t.status!==`orphaned`);if(t)return`Branch ${e.branch} already has a worktree (${t.id}).`}function r(e){if(!e.record)return`No worktree with that id. Call list to see the current ids.`;if(e.dirtyFiles.length===0||e.force)return;let t=e.dirtyFiles.slice(0,10).join(`, `),n=e.dirtyFiles.length>10?`, and ${String(e.dirtyFiles.length-10)} more`:``;return`${String(e.dirtyFiles.length)} uncommitted file(s): ${t}${n}. Pass force: true to discard them.`}function i(e,t){let n=[];return{records:e.map(e=>e.status===`orphaned`||t.exists(e.path)&&t.alive(e)?e:(n.push(e.id),{...e,status:`orphaned`})),changed:n}}function a(e){let t={remove:[],forget:[],untracked:[],keptDirty:[]},n=new Set(e.records.map(e=>e.path)),r=new Set(e.gitPaths);for(let n of e.records)if(n.status===`orphaned`){if(!r.has(n.path)){t.forget.push(n);continue}if((e.dirtyByPath.get(n.path)??[]).length>0){t.keptDirty.push(n);continue}t.remove.push(n)}for(let r of e.gitPaths)r.startsWith(`${e.worktreesRoot}/`)&&!n.has(r)&&t.untracked.push(r);return t}export{e as branchSlug,a as planPrune,i as reconcile,r as refuseClose,n as refuseSpawn,t as worktreeDirectory};
|
|
2
|
-
//# sourceMappingURL=worktreeNaming.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"worktreeNaming.mjs","names":[],"sources":["../../src/services/worktreeNaming.ts"],"sourcesContent":["/**\n * Naming and reconciliation rules for worktrees, as pure functions.\n *\n * Everything here is a function of its arguments so the interesting decisions,\n * which are the ones about destroying work, can be tested without a repository\n * or a filesystem.\n */\n\nimport type { WorktreeRecord } from '../types/worktreeRegistry.ts';\n\nconst MAX_SLUG_LENGTH = 64;\n\n/**\n * A branch name reduced to one safe path segment.\n *\n * Slashes are the point: `wt/fix-auth` is a perfectly good branch and a\n * terrible directory name, because the nested directory it implies is not the\n * one the worktree lives in.\n */\nexport function branchSlug(branch: string): string {\n const slug = branch\n .toLowerCase()\n .replace(/[^a-z0-9]+/gu, '-')\n .replace(/^-+|-+$/gu, '')\n .slice(0, MAX_SLUG_LENGTH)\n .replace(/-+$/gu, '');\n return slug === '' ? 'worktree' : slug;\n}\n\n/**\n * The directory for one worktree.\n *\n * The short id disambiguates two branches whose slugs collide, such as\n * `feature/x` and `feature_x`, which would otherwise want the same directory.\n */\nexport function worktreeDirectory(input: {\n worktreesRoot: string;\n repositoryLabel: string;\n repositoryId: string;\n branch: string;\n shortId: string;\n}): string {\n const repository = `${input.repositoryLabel}--${input.repositoryId}`;\n return `${input.worktreesRoot}/${repository}/${branchSlug(input.branch)}--${input.shortId}`;\n}\n\n/** Why a worktree cannot be created, or undefined when it can. */\nexport function refuseSpawn(input: { branch: string; existing: readonly WorktreeRecord[] }): string | undefined {\n if (input.branch.trim() === '') return 'A branch name is required.';\n // Git refuses a second worktree on one branch, but its message names a path\n // the caller never chose, so this says it in the caller's own terms first.\n const live = input.existing.find((record) => record.branch === input.branch && record.status !== 'orphaned');\n if (live) return `Branch ${input.branch} already has a worktree (${live.id}).`;\n return undefined;\n}\n\n/** Why a worktree cannot be closed, or undefined when it can. */\nexport function refuseClose(input: {\n record: WorktreeRecord | undefined;\n dirtyFiles: readonly string[];\n force: boolean;\n}): string | undefined {\n if (!input.record) return 'No worktree with that id. Call list to see the current ids.';\n if (input.dirtyFiles.length === 0 || input.force) return undefined;\n // Naming the files is the point: \"the tree is dirty\" sends the reader to go\n // look, and the answer is usually a file they forgot rather than one they\n // meant to keep.\n const names = input.dirtyFiles.slice(0, 10).join(', ');\n const more = input.dirtyFiles.length > 10 ? `, and ${String(input.dirtyFiles.length - 10)} more` : '';\n return `${String(input.dirtyFiles.length)} uncommitted file(s): ${names}${more}. Pass force: true to discard them.`;\n}\n\nexport interface Reconciliation {\n records: WorktreeRecord[];\n /** Ids whose status changed, so a caller can report what it noticed. */\n changed: string[];\n}\n\n/**\n * Marks records whose process or directory is gone as orphaned.\n *\n * Nothing is deleted here. A doompi-git orphan owns a directory that may hold\n * uncommitted work, so losing the record would lose the only pointer to it.\n * Deletion is always a separate, named decision.\n */\nexport function reconcile(\n records: readonly WorktreeRecord[],\n probe: { alive: (record: WorktreeRecord) => boolean; exists: (path: string) => boolean },\n): Reconciliation {\n const changed: string[] = [];\n const next = records.map((record) => {\n if (record.status === 'orphaned') return record;\n const gone = !probe.exists(record.path) || !probe.alive(record);\n if (!gone) return record;\n changed.push(record.id);\n return { ...record, status: 'orphaned' as const };\n });\n return { records: next, changed };\n}\n\nexport interface PrunePlan {\n /** Orphans whose directory git still lists, safe to remove. */\n remove: WorktreeRecord[];\n /** Orphans whose directory is already gone; drop the record only. */\n forget: WorktreeRecord[];\n /** Paths git lists under our root that we have no record of; report, never touch. */\n untracked: string[];\n /** Orphans left alone because they still hold uncommitted work. */\n keptDirty: WorktreeRecord[];\n}\n\n/**\n * What a prune would do, decided before anything is destroyed.\n *\n * Separating the plan from the execution is what makes dryRun honest and lets\n * the destructive half be reviewed on its own.\n */\nexport function planPrune(input: {\n records: readonly WorktreeRecord[];\n gitPaths: readonly string[];\n worktreesRoot: string;\n dirtyByPath: ReadonlyMap<string, readonly string[]>;\n}): PrunePlan {\n const plan: PrunePlan = { remove: [], forget: [], untracked: [], keptDirty: [] };\n const known = new Set(input.records.map((record) => record.path));\n const listed = new Set(input.gitPaths);\n for (const record of input.records) {\n if (record.status !== 'orphaned') continue;\n if (!listed.has(record.path)) {\n plan.forget.push(record);\n continue;\n }\n if ((input.dirtyByPath.get(record.path) ?? []).length > 0) {\n plan.keptDirty.push(record);\n continue;\n }\n plan.remove.push(record);\n }\n for (const path of input.gitPaths) {\n // Only ever inside our own root: a worktree the user made by hand is none\n // of this package's business, even when it looks abandoned.\n if (path.startsWith(`${input.worktreesRoot}/`) && !known.has(path)) plan.untracked.push(path);\n }\n return plan;\n}\n"],"mappings":"AAmBA,SAAgB,EAAW,EAAwB,CACjD,IAAM,EAAO,EACV,YAAY,CAAC,CACb,QAAQ,eAAgB,GAAG,CAAC,CAC5B,QAAQ,YAAa,EAAE,CAAC,CACxB,MAAM,EAAG,EAAe,CAAC,CACzB,QAAQ,QAAS,EAAE,EACtB,OAAO,IAAS,GAAK,WAAa,CACpC,CAQA,SAAgB,EAAkB,EAMvB,CACT,IAAM,EAAa,GAAG,EAAM,gBAAgB,IAAI,EAAM,eACtD,MAAO,GAAG,EAAM,cAAc,GAAG,EAAW,GAAG,EAAW,EAAM,MAAM,EAAE,IAAI,EAAM,SACpF,CAGA,SAAgB,EAAY,EAAoF,CAC9G,GAAI,EAAM,OAAO,KAAK,IAAM,GAAI,MAAO,6BAGvC,IAAM,EAAO,EAAM,SAAS,KAAM,GAAW,EAAO,SAAW,EAAM,QAAU,EAAO,SAAW,UAAU,EAC3G,GAAI,EAAM,MAAO,UAAU,EAAM,OAAO,2BAA2B,EAAK,GAAG,GAE7E,CAGA,SAAgB,EAAY,EAIL,CACrB,GAAI,CAAC,EAAM,OAAQ,MAAO,8DAC1B,GAAI,EAAM,WAAW,SAAW,GAAK,EAAM,MAAO,OAIlD,IAAM,EAAQ,EAAM,WAAW,MAAM,EAAG,EAAE,CAAC,CAAC,KAAK,IAAI,EAC/C,EAAO,EAAM,WAAW,OAAS,GAAK,SAAS,OAAO,EAAM,WAAW,OAAS,EAAE,EAAE,OAAS,GACnG,MAAO,GAAG,OAAO,EAAM,WAAW,MAAM,EAAE,wBAAwB,IAAQ,EAAK,oCACjF,CAeA,SAAgB,EACd,EACA,EACgB,CAChB,IAAM,EAAoB,CAAC,EAQ3B,MAAO,CAAE,QAPI,EAAQ,IAAK,GACpB,EAAO,SAAW,YACR,EAAM,OAAO,EAAO,IAAI,GAAM,EAAM,MAAM,CAAM,EAC5C,GAClB,EAAQ,KAAK,EAAO,EAAE,EACf,CAAE,GAAG,EAAQ,OAAQ,UAAoB,EAE7B,EAAG,SAAQ,CAClC,CAmBA,SAAgB,EAAU,EAKZ,CACZ,IAAM,EAAkB,CAAE,OAAQ,CAAC,EAAG,OAAQ,CAAC,EAAG,UAAW,CAAC,EAAG,UAAW,CAAC,CAAE,EACzE,EAAQ,IAAI,IAAI,EAAM,QAAQ,IAAK,GAAW,EAAO,IAAI,CAAC,EAC1D,EAAS,IAAI,IAAI,EAAM,QAAQ,EACrC,IAAK,IAAM,KAAU,EAAM,QACrB,KAAO,SAAW,WACtB,IAAI,CAAC,EAAO,IAAI,EAAO,IAAI,EAAG,CAC5B,EAAK,OAAO,KAAK,CAAM,EACvB,QACF,CACA,IAAK,EAAM,YAAY,IAAI,EAAO,IAAI,GAAK,CAAC,EAAA,CAAG,OAAS,EAAG,CACzD,EAAK,UAAU,KAAK,CAAM,EAC1B,QACF,CACA,EAAK,OAAO,KAAK,CAAM,CALvB,CAOF,IAAK,IAAM,KAAQ,EAAM,SAGnB,EAAK,WAAW,GAAG,EAAM,cAAc,EAAE,GAAK,CAAC,EAAM,IAAI,CAAI,GAAG,EAAK,UAAU,KAAK,CAAI,EAE9F,OAAO,CACT"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { WorktreeOperations } from "../adapters/worktree/worktreeOperations.cjs";
|
|
2
|
-
//#region src/types/extension.d.ts
|
|
3
|
-
type GitNotificationLevel = 'info';
|
|
4
|
-
interface GitExtensionResult {
|
|
5
|
-
message: string;
|
|
6
|
-
level: GitNotificationLevel;
|
|
7
|
-
}
|
|
8
|
-
interface GitExtensionService {
|
|
9
|
-
execute(): Promise<GitExtensionResult>;
|
|
10
|
-
}
|
|
11
|
-
interface GitExtensionDependencies {
|
|
12
|
-
service: GitExtensionService;
|
|
13
|
-
operations: WorktreeOperations;
|
|
14
|
-
}
|
|
15
|
-
//#endregion
|
|
16
|
-
export { GitExtensionDependencies, GitExtensionResult, GitExtensionService, GitNotificationLevel };
|
|
17
|
-
//# sourceMappingURL=extension.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extension.d.cts","names":[],"sources":["../../src/types/extension.ts"],"mappings":";;KAGY;UAEK;EACf;EACA,OAAO;;UAGQ;EACf,WAAW,QAAQ;;UAGJ;EACf,SAAS;EACT,YAAY"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { WorktreeOperations } from "../adapters/worktree/worktreeOperations.mjs";
|
|
2
|
-
//#region src/types/extension.d.ts
|
|
3
|
-
type GitNotificationLevel = 'info';
|
|
4
|
-
interface GitExtensionResult {
|
|
5
|
-
message: string;
|
|
6
|
-
level: GitNotificationLevel;
|
|
7
|
-
}
|
|
8
|
-
interface GitExtensionService {
|
|
9
|
-
execute(): Promise<GitExtensionResult>;
|
|
10
|
-
}
|
|
11
|
-
interface GitExtensionDependencies {
|
|
12
|
-
service: GitExtensionService;
|
|
13
|
-
operations: WorktreeOperations;
|
|
14
|
-
}
|
|
15
|
-
//#endregion
|
|
16
|
-
export { GitExtensionDependencies, GitExtensionResult, GitExtensionService, GitNotificationLevel };
|
|
17
|
-
//# sourceMappingURL=extension.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extension.d.mts","names":[],"sources":["../../src/types/extension.ts"],"mappings":";;KAGY;UAEK;EACf;EACA,OAAO;;UAGQ;EACf,WAAW,QAAQ;;UAGJ;EACf,SAAS;EACT,YAAY"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"webWorktrees.cjs","names":[],"sources":["../../src/types/webWorktrees.ts"],"sourcesContent":["/**\n * The cockpit's view of this session's worktrees.\n *\n * DESIGN PATTERNS:\n * - Declarations only. The channel frame type is a constant so the hub and the\n * page cannot drift apart on a string.\n * - A view is the subset of a record the dock needs, not the record. The\n * registry may hold paths and provenance the page has no business rendering.\n *\n * AVOID:\n * - Adding behaviour here. This file is imported by browser code, so it must\n * stay free of node builtins.\n */\n\n/** The data channel carrying one session's worktrees to the page. */\nexport const GIT_WORKTREES_TYPE = 'git_worktrees';\n\n/** One worktree, as the activity dock and its panel render it. */\nexport interface WorktreeView {\n id: string;\n branch: string;\n path: string;\n /** The session the hub started for this worktree, when it is still live. */\n sessionId: string | null;\n /** True once the directory the record names has gone missing. */\n orphaned: boolean;\n /**\n * True when the session that asked for this worktree is gone.\n *\n * An owned worktree is only ever shown to its own session. This flag marks\n * the exception: once the parent is dead nobody would see the worktree at\n * all, so every session in the repository does, and may close it.\n */\n unowned: boolean;\n}\n\n/**\n * What the panel asks the hub channel to do.\n *\n * The dock acts through its own channel rather than through the agent: a\n * worktree made from the panel and one made by the tool take the same\n * `worktreeOperations` path, but the panel no longer has to spend a turn of\n * the conversation to get there.\n */\nexport type GitWorktreesCommand =\n | { action: 'create'; branch: string; baseRef?: string }\n | { action: 'close'; id: string; force?: boolean };\n\nexport interface GitWorktreesPayload {\n worktrees: WorktreeView[];\n /** Label of the operation in flight, absent when the session is idle. */\n pending?: string;\n /** The last failure, cleared when the next command starts. */\n error?: string;\n}\n"],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"webWorktrees.mjs","names":[],"sources":["../../src/types/webWorktrees.ts"],"sourcesContent":["/**\n * The cockpit's view of this session's worktrees.\n *\n * DESIGN PATTERNS:\n * - Declarations only. The channel frame type is a constant so the hub and the\n * page cannot drift apart on a string.\n * - A view is the subset of a record the dock needs, not the record. The\n * registry may hold paths and provenance the page has no business rendering.\n *\n * AVOID:\n * - Adding behaviour here. This file is imported by browser code, so it must\n * stay free of node builtins.\n */\n\n/** The data channel carrying one session's worktrees to the page. */\nexport const GIT_WORKTREES_TYPE = 'git_worktrees';\n\n/** One worktree, as the activity dock and its panel render it. */\nexport interface WorktreeView {\n id: string;\n branch: string;\n path: string;\n /** The session the hub started for this worktree, when it is still live. */\n sessionId: string | null;\n /** True once the directory the record names has gone missing. */\n orphaned: boolean;\n /**\n * True when the session that asked for this worktree is gone.\n *\n * An owned worktree is only ever shown to its own session. This flag marks\n * the exception: once the parent is dead nobody would see the worktree at\n * all, so every session in the repository does, and may close it.\n */\n unowned: boolean;\n}\n\n/**\n * What the panel asks the hub channel to do.\n *\n * The dock acts through its own channel rather than through the agent: a\n * worktree made from the panel and one made by the tool take the same\n * `worktreeOperations` path, but the panel no longer has to spend a turn of\n * the conversation to get there.\n */\nexport type GitWorktreesCommand =\n | { action: 'create'; branch: string; baseRef?: string }\n | { action: 'close'; id: string; force?: boolean };\n\nexport interface GitWorktreesPayload {\n worktrees: WorktreeView[];\n /** Label of the operation in flight, absent when the session is idle. */\n pending?: string;\n /** The last failure, cleared when the next command starts. */\n error?: string;\n}\n"],"mappings":"AAeA,MAAa,EAAqB"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
//#region src/types/worktreeRegistry.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* The worktree registry: what this package knows about the worktrees it made.
|
|
4
|
-
*
|
|
5
|
-
* It deliberately does not mirror `git worktree list`. Git knows which
|
|
6
|
-
* worktrees exist; only this registry knows which of them this package created,
|
|
7
|
-
* which session runs in each, and which process to signal. Reconciling the two
|
|
8
|
-
* is how orphans are found, so the two views are kept separate on purpose.
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* A worktree's lifecycle as this package sees it.
|
|
12
|
-
*
|
|
13
|
-
* `orphaned` is a finding, not a cleanup: the session process is gone or the
|
|
14
|
-
* directory has vanished, but the worktree may still hold uncommitted work, so
|
|
15
|
-
* the record is kept until someone decides what to do with it.
|
|
16
|
-
*/
|
|
17
|
-
type WorktreeStatus = 'spawning' | 'running' | 'closing' | 'orphaned';
|
|
18
|
-
declare const WORKTREE_RECORD_VERSION = 1;
|
|
19
|
-
interface WorktreeRecord {
|
|
20
|
-
version: typeof WORKTREE_RECORD_VERSION;
|
|
21
|
-
/** This registry's own id, distinct from the session id, and stable across restarts. */
|
|
22
|
-
id: string;
|
|
23
|
-
/** The branch checked out in the worktree. */
|
|
24
|
-
branch: string;
|
|
25
|
-
/** The ref the branch was created from, kept so a merge can name its base. */
|
|
26
|
-
baseRef: string;
|
|
27
|
-
/** Absolute path to the worktree directory. */
|
|
28
|
-
path: string;
|
|
29
|
-
/** Absolute path to the repository the worktree belongs to. */
|
|
30
|
-
repositoryRoot: string;
|
|
31
|
-
/** The session spawned into the worktree. */
|
|
32
|
-
sessionId: string;
|
|
33
|
-
/** The session that asked for the worktree; the rail nests one under the other. */
|
|
34
|
-
parentSessionId: string;
|
|
35
|
-
status: WorktreeStatus;
|
|
36
|
-
/** ISO 8601. */
|
|
37
|
-
createdAt: string;
|
|
38
|
-
}
|
|
39
|
-
//#endregion
|
|
40
|
-
export { WORKTREE_RECORD_VERSION, WorktreeRecord, WorktreeStatus };
|
|
41
|
-
//# sourceMappingURL=worktreeRegistry.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"worktreeRegistry.d.cts","names":[],"sources":["../../src/types/worktreeRegistry.ts"],"mappings":";;;;;;;;;;;;;;;;KAgBY;cAEC;UAEI;EACf,gBAAgB;;EAEhB;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;EACA,QAAQ;;EAER"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
//#region src/types/worktreeRegistry.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* The worktree registry: what this package knows about the worktrees it made.
|
|
4
|
-
*
|
|
5
|
-
* It deliberately does not mirror `git worktree list`. Git knows which
|
|
6
|
-
* worktrees exist; only this registry knows which of them this package created,
|
|
7
|
-
* which session runs in each, and which process to signal. Reconciling the two
|
|
8
|
-
* is how orphans are found, so the two views are kept separate on purpose.
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* A worktree's lifecycle as this package sees it.
|
|
12
|
-
*
|
|
13
|
-
* `orphaned` is a finding, not a cleanup: the session process is gone or the
|
|
14
|
-
* directory has vanished, but the worktree may still hold uncommitted work, so
|
|
15
|
-
* the record is kept until someone decides what to do with it.
|
|
16
|
-
*/
|
|
17
|
-
type WorktreeStatus = 'spawning' | 'running' | 'closing' | 'orphaned';
|
|
18
|
-
declare const WORKTREE_RECORD_VERSION = 1;
|
|
19
|
-
interface WorktreeRecord {
|
|
20
|
-
version: typeof WORKTREE_RECORD_VERSION;
|
|
21
|
-
/** This registry's own id, distinct from the session id, and stable across restarts. */
|
|
22
|
-
id: string;
|
|
23
|
-
/** The branch checked out in the worktree. */
|
|
24
|
-
branch: string;
|
|
25
|
-
/** The ref the branch was created from, kept so a merge can name its base. */
|
|
26
|
-
baseRef: string;
|
|
27
|
-
/** Absolute path to the worktree directory. */
|
|
28
|
-
path: string;
|
|
29
|
-
/** Absolute path to the repository the worktree belongs to. */
|
|
30
|
-
repositoryRoot: string;
|
|
31
|
-
/** The session spawned into the worktree. */
|
|
32
|
-
sessionId: string;
|
|
33
|
-
/** The session that asked for the worktree; the rail nests one under the other. */
|
|
34
|
-
parentSessionId: string;
|
|
35
|
-
status: WorktreeStatus;
|
|
36
|
-
/** ISO 8601. */
|
|
37
|
-
createdAt: string;
|
|
38
|
-
}
|
|
39
|
-
//#endregion
|
|
40
|
-
export { WORKTREE_RECORD_VERSION, WorktreeRecord, WorktreeStatus };
|
|
41
|
-
//# sourceMappingURL=worktreeRegistry.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"worktreeRegistry.d.mts","names":[],"sources":["../../src/types/worktreeRegistry.ts"],"mappings":";;;;;;;;;;;;;;;;KAgBY;cAEC;UAEI;EACf,gBAAgB;;EAEhB;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;EACA,QAAQ;;EAER"}
|
package/dist/webHub.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./adapters/web/worktreesChannel.cjs");exports.createWorktreesChannel=e.createWorktreesChannel,exports.webHubChannels=e.webHubChannels;
|
package/dist/webHub.d.cts
DELETED
package/dist/webHub.d.mts
DELETED
package/dist/webHub.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createWorktreesChannel as e,webHubChannels as t}from"./adapters/web/worktreesChannel.mjs";export{e as createWorktreesChannel,t as webHubChannels};
|
package/src/exports/webClient.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { webPlugin } from '../web/index.ts';
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The cockpit's view of this session's worktrees.
|
|
3
|
-
*
|
|
4
|
-
* DESIGN PATTERNS:
|
|
5
|
-
* - Declarations only. The channel frame type is a constant so the hub and the
|
|
6
|
-
* page cannot drift apart on a string.
|
|
7
|
-
* - A view is the subset of a record the dock needs, not the record. The
|
|
8
|
-
* registry may hold paths and provenance the page has no business rendering.
|
|
9
|
-
*
|
|
10
|
-
* AVOID:
|
|
11
|
-
* - Adding behaviour here. This file is imported by browser code, so it must
|
|
12
|
-
* stay free of node builtins.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/** The data channel carrying one session's worktrees to the page. */
|
|
16
|
-
export const GIT_WORKTREES_TYPE = 'git_worktrees';
|
|
17
|
-
|
|
18
|
-
/** One worktree, as the activity dock and its panel render it. */
|
|
19
|
-
export interface WorktreeView {
|
|
20
|
-
id: string;
|
|
21
|
-
branch: string;
|
|
22
|
-
path: string;
|
|
23
|
-
/** The session the hub started for this worktree, when it is still live. */
|
|
24
|
-
sessionId: string | null;
|
|
25
|
-
/** True once the directory the record names has gone missing. */
|
|
26
|
-
orphaned: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* True when the session that asked for this worktree is gone.
|
|
29
|
-
*
|
|
30
|
-
* An owned worktree is only ever shown to its own session. This flag marks
|
|
31
|
-
* the exception: once the parent is dead nobody would see the worktree at
|
|
32
|
-
* all, so every session in the repository does, and may close it.
|
|
33
|
-
*/
|
|
34
|
-
unowned: boolean;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* What the panel asks the hub channel to do.
|
|
39
|
-
*
|
|
40
|
-
* The dock acts through its own channel rather than through the agent: a
|
|
41
|
-
* worktree made from the panel and one made by the tool take the same
|
|
42
|
-
* `worktreeOperations` path, but the panel no longer has to spend a turn of
|
|
43
|
-
* the conversation to get there.
|
|
44
|
-
*/
|
|
45
|
-
export type GitWorktreesCommand =
|
|
46
|
-
| { action: 'create'; branch: string; baseRef?: string }
|
|
47
|
-
| { action: 'close'; id: string; force?: boolean };
|
|
48
|
-
|
|
49
|
-
export interface GitWorktreesPayload {
|
|
50
|
-
worktrees: WorktreeView[];
|
|
51
|
-
/** Label of the operation in flight, absent when the session is idle. */
|
|
52
|
-
pending?: string;
|
|
53
|
-
/** The last failure, cleared when the next command starts. */
|
|
54
|
-
error?: string;
|
|
55
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The worktree registry: what this package knows about the worktrees it made.
|
|
3
|
-
*
|
|
4
|
-
* It deliberately does not mirror `git worktree list`. Git knows which
|
|
5
|
-
* worktrees exist; only this registry knows which of them this package created,
|
|
6
|
-
* which session runs in each, and which process to signal. Reconciling the two
|
|
7
|
-
* is how orphans are found, so the two views are kept separate on purpose.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* A worktree's lifecycle as this package sees it.
|
|
12
|
-
*
|
|
13
|
-
* `orphaned` is a finding, not a cleanup: the session process is gone or the
|
|
14
|
-
* directory has vanished, but the worktree may still hold uncommitted work, so
|
|
15
|
-
* the record is kept until someone decides what to do with it.
|
|
16
|
-
*/
|
|
17
|
-
export type WorktreeStatus = 'spawning' | 'running' | 'closing' | 'orphaned';
|
|
18
|
-
|
|
19
|
-
export const WORKTREE_RECORD_VERSION = 1;
|
|
20
|
-
|
|
21
|
-
export interface WorktreeRecord {
|
|
22
|
-
version: typeof WORKTREE_RECORD_VERSION;
|
|
23
|
-
/** This registry's own id, distinct from the session id, and stable across restarts. */
|
|
24
|
-
id: string;
|
|
25
|
-
/** The branch checked out in the worktree. */
|
|
26
|
-
branch: string;
|
|
27
|
-
/** The ref the branch was created from, kept so a merge can name its base. */
|
|
28
|
-
baseRef: string;
|
|
29
|
-
/** Absolute path to the worktree directory. */
|
|
30
|
-
path: string;
|
|
31
|
-
/** Absolute path to the repository the worktree belongs to. */
|
|
32
|
-
repositoryRoot: string;
|
|
33
|
-
/** The session spawned into the worktree. */
|
|
34
|
-
sessionId: string;
|
|
35
|
-
/** The session that asked for the worktree; the rail nests one under the other. */
|
|
36
|
-
parentSessionId: string;
|
|
37
|
-
status: WorktreeStatus;
|
|
38
|
-
/** ISO 8601. */
|
|
39
|
-
createdAt: string;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export interface WorktreeRegistryFile {
|
|
43
|
-
version: typeof WORKTREE_RECORD_VERSION;
|
|
44
|
-
entries: readonly WorktreeRecord[];
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/** Reads the registry back, treating anything unusable as an empty registry. */
|
|
48
|
-
export interface WorktreeRegistryStore {
|
|
49
|
-
list(): WorktreeRecord[];
|
|
50
|
-
/** Replaces the whole file. One writer per repository, so no merge is attempted. */
|
|
51
|
-
replace(entries: readonly WorktreeRecord[]): void;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/** The git operations this package needs, named in its own vocabulary. */
|
|
55
|
-
export interface WorktreeGit {
|
|
56
|
-
addWorktree(input: { repositoryRoot: string; path: string; branch: string; baseRef: string }): Promise<void>;
|
|
57
|
-
removeWorktree(input: { repositoryRoot: string; path: string; force: boolean }): Promise<void>;
|
|
58
|
-
pruneWorktrees(repositoryRoot: string): Promise<void>;
|
|
59
|
-
/** Paths git currently lists for the repository, used to find orphans. */
|
|
60
|
-
listWorktreePaths(repositoryRoot: string): Promise<string[]>;
|
|
61
|
-
/** Files with uncommitted changes, empty when the tree is clean. */
|
|
62
|
-
dirtyFiles(path: string): Promise<string[]>;
|
|
63
|
-
/** The repository root for a directory, or undefined when it is not a repository. */
|
|
64
|
-
repositoryRoot(cwd: string): Promise<string | undefined>;
|
|
65
|
-
/** The branch currently checked out, used as the default base ref. */
|
|
66
|
-
currentBranch(cwd: string): Promise<string | undefined>;
|
|
67
|
-
/** Merges a worktree's branch into whatever the given root has checked out. */
|
|
68
|
-
mergeBranch(input: { repositoryRoot: string; branch: string; message?: string }): Promise<void>;
|
|
69
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { ToolMessageRenderProps } from '@agimon-ai/doompi-web-contracts';
|
|
2
|
-
|
|
3
|
-
const ACTION_LABEL: Readonly<Record<string, string>> = {
|
|
4
|
-
spawn_worktree: 'Create worktree',
|
|
5
|
-
close_worktree: 'Close worktree',
|
|
6
|
-
list: 'List worktrees',
|
|
7
|
-
status: 'Worktree status',
|
|
8
|
-
merge: 'Merge worktree',
|
|
9
|
-
prune: 'Prune worktrees',
|
|
10
|
-
send: 'Message worktree',
|
|
11
|
-
messages: 'Read worktree messages',
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* The timeline item for `run_worktree`.
|
|
16
|
-
*
|
|
17
|
-
* The action and its subject go in the heading because that is what a reader
|
|
18
|
-
* scanning a transcript needs: "close_worktree a1b2c3d4" answers the question
|
|
19
|
-
* the raw JSON arguments make them decode.
|
|
20
|
-
*/
|
|
21
|
-
export function RunWorktreeToolMessage({ args, output, running, isError }: ToolMessageRenderProps) {
|
|
22
|
-
const action = typeof args.action === 'string' ? args.action : '';
|
|
23
|
-
const subject = typeof args.branch === 'string' ? args.branch : typeof args.id === 'string' ? args.id : '';
|
|
24
|
-
|
|
25
|
-
return (
|
|
26
|
-
<div className="flex flex-col gap-0.5">
|
|
27
|
-
<span className="text-sm font-bold text-doom-hi">
|
|
28
|
-
{ACTION_LABEL[action] ?? 'Worktree'}
|
|
29
|
-
{subject === '' ? '' : ` ${subject}`}
|
|
30
|
-
{running ? ' …' : ''}
|
|
31
|
-
</span>
|
|
32
|
-
{output !== '' && (
|
|
33
|
-
<pre className={`whitespace-pre-wrap text-xs ${isError ? 'text-doom-red' : 'text-doom-dim'}`}>{output}</pre>
|
|
34
|
-
)}
|
|
35
|
-
</div>
|
|
36
|
-
);
|
|
37
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The '# git' group's body in the activity dock.
|
|
3
|
-
*
|
|
4
|
-
* DESIGN PATTERNS:
|
|
5
|
-
* - One line per worktree, the same rule the runners rail follows: enough to
|
|
6
|
-
* notice it, not enough to work with it. The group's own name opens the tab
|
|
7
|
-
* that has room.
|
|
8
|
-
* - Idle still shows the launcher. A repository with no worktrees is the state
|
|
9
|
-
* where someone most wants to make one.
|
|
10
|
-
*
|
|
11
|
-
* AVOID:
|
|
12
|
-
* - Doing work here. This section reports and launches; the panel and the tool
|
|
13
|
-
* own everything else.
|
|
14
|
-
*/
|
|
15
|
-
import { Button } from '@agimon-ai/doompi-web-components';
|
|
16
|
-
import type { WebPluginSlotProps } from '@agimon-ai/doompi-web-contracts';
|
|
17
|
-
import { useStore } from '@tanstack/react-store';
|
|
18
|
-
import type { WorktreeView } from '../../types/webWorktrees.ts';
|
|
19
|
-
import { worktreeActivity } from '../stores/worktreesActivityStore.ts';
|
|
20
|
-
import { worktreesTab } from './WorktreesPanel.tsx';
|
|
21
|
-
|
|
22
|
-
export function WorktreesActivitySection({ sessionId, openTransientTab }: WebPluginSlotProps) {
|
|
23
|
-
const session = useStore(worktreeActivity.store, (state) => worktreeActivity.select(state, sessionId));
|
|
24
|
-
|
|
25
|
-
if (session.worktrees.length === 0 && session.pending === undefined) {
|
|
26
|
-
return (
|
|
27
|
-
<div className="flex items-center gap-2 px-1">
|
|
28
|
-
<p data-testid="activity-summary-git" className="px-1 text-xs text-doom-faint">
|
|
29
|
-
idle
|
|
30
|
-
</p>
|
|
31
|
-
{sessionId === null ? null : (
|
|
32
|
-
<Button
|
|
33
|
-
variant="link"
|
|
34
|
-
size="xs"
|
|
35
|
-
data-testid="activity-git-create"
|
|
36
|
-
className="px-0"
|
|
37
|
-
onClick={() => openTransientTab(worktreesTab())}
|
|
38
|
-
>
|
|
39
|
-
create a worktree
|
|
40
|
-
</Button>
|
|
41
|
-
)}
|
|
42
|
-
</div>
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return (
|
|
47
|
-
<div data-testid="activity-git-worktrees" className="flex flex-col gap-0.5">
|
|
48
|
-
{session.pending === undefined ? null : <p className="px-1 text-xs text-doom-dim">{session.pending}</p>}
|
|
49
|
-
{session.worktrees.map((worktree: WorktreeView) => (
|
|
50
|
-
<button
|
|
51
|
-
key={worktree.id}
|
|
52
|
-
type="button"
|
|
53
|
-
data-testid={`activity-git-worktree-${worktree.id}`}
|
|
54
|
-
className="flex items-center gap-2 px-1 text-left text-sm text-doom-dim hover:text-doom-bright"
|
|
55
|
-
onClick={() => openTransientTab(worktreesTab())}
|
|
56
|
-
>
|
|
57
|
-
<span className="truncate">{worktree.branch}</span>
|
|
58
|
-
{worktree.orphaned ? <span className="text-xs text-doom-faint">orphaned</span> : null}
|
|
59
|
-
{worktree.unowned ? <span className="text-xs text-doom-faint">unowned</span> : null}
|
|
60
|
-
</button>
|
|
61
|
-
))}
|
|
62
|
-
</div>
|
|
63
|
-
);
|
|
64
|
-
}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The '# git' group's tab: this session's worktrees, and the form that makes one.
|
|
3
|
-
*
|
|
4
|
-
* DESIGN PATTERNS:
|
|
5
|
-
* - Lives in the activity dock, opened by the group's name. A worktree is work
|
|
6
|
-
* in progress belonging to the session that started it, so it sits beside
|
|
7
|
-
* agents, runners and workflows rather than in a settings screen.
|
|
8
|
-
* - Local form state is never reset by a data refresh. The hub republishes this
|
|
9
|
-
* list on a timer, and a half-typed branch name must survive that.
|
|
10
|
-
* - Acts through the plugin's own hub channel, so a worktree made here and one
|
|
11
|
-
* made by the tool take exactly the same path.
|
|
12
|
-
* - Creating takes minutes, so the hub reports progress and failure on that
|
|
13
|
-
* channel and this panel renders both. A button that looks idle for two
|
|
14
|
-
* minutes reads as broken.
|
|
15
|
-
*
|
|
16
|
-
* AVOID:
|
|
17
|
-
* - Deriving form state from props or store data. That is what wiped the
|
|
18
|
-
* fields on every poll.
|
|
19
|
-
*/
|
|
20
|
-
import { Button, Input } from '@agimon-ai/doompi-web-components';
|
|
21
|
-
import type { TransientTab, WebPluginSlotProps } from '@agimon-ai/doompi-web-contracts';
|
|
22
|
-
import { useStore } from '@tanstack/react-store';
|
|
23
|
-
import { useState } from 'react';
|
|
24
|
-
import type { WorktreeView } from '../../types/webWorktrees.ts';
|
|
25
|
-
import { requestWorktreeClose, requestWorktreeCreate, worktreeActivity } from '../stores/worktreesActivityStore.ts';
|
|
26
|
-
|
|
27
|
-
const WORKTREES_TAB_ID = 'git-worktrees';
|
|
28
|
-
|
|
29
|
-
export function worktreesTab(): TransientTab {
|
|
30
|
-
return { id: WORKTREES_TAB_ID, label: 'worktrees', panel: WorktreesPanel };
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function WorktreesPanel({ sessionId }: WebPluginSlotProps) {
|
|
34
|
-
const session = useStore(worktreeActivity.store, (state) => worktreeActivity.select(state, sessionId));
|
|
35
|
-
const [branch, setBranch] = useState('');
|
|
36
|
-
const [baseRef, setBaseRef] = useState('');
|
|
37
|
-
|
|
38
|
-
const busy = session.pending !== undefined;
|
|
39
|
-
const canCreate = sessionId !== null && branch.trim() !== '' && !busy;
|
|
40
|
-
|
|
41
|
-
const create = (): void => {
|
|
42
|
-
if (sessionId === null || !canCreate) return;
|
|
43
|
-
requestWorktreeCreate(sessionId, branch, baseRef);
|
|
44
|
-
setBranch('');
|
|
45
|
-
setBaseRef('');
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
return (
|
|
49
|
-
<div className="flex flex-col gap-3 p-3" data-testid="git-worktrees-panel">
|
|
50
|
-
<div className="flex flex-col gap-1">
|
|
51
|
-
<div className="flex items-center gap-2">
|
|
52
|
-
<Input
|
|
53
|
-
data-testid="git-worktree-branch"
|
|
54
|
-
aria-label="Branch"
|
|
55
|
-
placeholder="wt/fix-auth"
|
|
56
|
-
value={branch}
|
|
57
|
-
onChange={(event) => setBranch(event.target.value)}
|
|
58
|
-
onKeyDown={(event) => {
|
|
59
|
-
if (event.key === 'Enter') create();
|
|
60
|
-
}}
|
|
61
|
-
/>
|
|
62
|
-
<Input
|
|
63
|
-
data-testid="git-worktree-base"
|
|
64
|
-
aria-label="Base ref"
|
|
65
|
-
placeholder="base (current)"
|
|
66
|
-
value={baseRef}
|
|
67
|
-
onChange={(event) => setBaseRef(event.target.value)}
|
|
68
|
-
className="w-40"
|
|
69
|
-
/>
|
|
70
|
-
<Button data-testid="git-worktree-create" size="xs" disabled={!canCreate} onClick={create}>
|
|
71
|
-
Create
|
|
72
|
-
</Button>
|
|
73
|
-
</div>
|
|
74
|
-
<p className="text-xs text-doom-faint">
|
|
75
|
-
Creates the worktree outside the repository, installs its dependencies, then starts a session nested under
|
|
76
|
-
this one. The install is what makes the wait; a warm store is under a minute.
|
|
77
|
-
</p>
|
|
78
|
-
{session.pending === undefined ? null : (
|
|
79
|
-
<p data-testid="git-worktree-pending" className="text-xs text-doom-dim">
|
|
80
|
-
{session.pending}
|
|
81
|
-
</p>
|
|
82
|
-
)}
|
|
83
|
-
{session.error === undefined ? null : (
|
|
84
|
-
<p data-testid="git-worktree-error" className="text-xs text-doom-error">
|
|
85
|
-
{session.error}
|
|
86
|
-
</p>
|
|
87
|
-
)}
|
|
88
|
-
</div>
|
|
89
|
-
|
|
90
|
-
{session.worktrees.length === 0 ? (
|
|
91
|
-
<p className="text-sm text-doom-faint">No worktrees yet.</p>
|
|
92
|
-
) : (
|
|
93
|
-
<ul className="flex flex-col gap-1">
|
|
94
|
-
{session.worktrees.map((worktree: WorktreeView) => (
|
|
95
|
-
<li
|
|
96
|
-
key={worktree.id}
|
|
97
|
-
data-testid={`git-worktree-${worktree.id}`}
|
|
98
|
-
className="flex items-center justify-between gap-2 border border-doom-line px-2 py-1"
|
|
99
|
-
>
|
|
100
|
-
<div className="flex min-w-0 flex-col">
|
|
101
|
-
<span className="truncate text-sm text-doom-bright">{worktree.branch}</span>
|
|
102
|
-
<span className="truncate text-xs text-doom-faint">{worktree.path}</span>
|
|
103
|
-
</div>
|
|
104
|
-
<div className="flex items-center gap-2">
|
|
105
|
-
{worktree.orphaned ? <span className="text-xs text-doom-faint">orphaned</span> : null}
|
|
106
|
-
{worktree.unowned ? <span className="text-xs text-doom-faint">unowned</span> : null}
|
|
107
|
-
{sessionId === null ? null : (
|
|
108
|
-
<Button
|
|
109
|
-
variant="link"
|
|
110
|
-
size="xs"
|
|
111
|
-
disabled={busy}
|
|
112
|
-
data-testid={`git-worktree-close-${worktree.id}`}
|
|
113
|
-
onClick={() => requestWorktreeClose(sessionId, worktree.id)}
|
|
114
|
-
>
|
|
115
|
-
close
|
|
116
|
-
</Button>
|
|
117
|
-
)}
|
|
118
|
-
</div>
|
|
119
|
-
</li>
|
|
120
|
-
))}
|
|
121
|
-
</ul>
|
|
122
|
-
)}
|
|
123
|
-
</div>
|
|
124
|
-
);
|
|
125
|
-
}
|