@agimon-ai/doompi-git 0.0.1-alpha.5 → 0.0.1-alpha.7
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 +2 -0
- package/dist/api-contracts.cjs +1 -0
- package/dist/api-contracts.d.cts +2 -0
- package/dist/api-contracts.d.mts +2 -0
- package/dist/api-contracts.mjs +1 -0
- package/dist/constants/git.cjs +2 -0
- package/dist/constants/git.cjs.map +1 -0
- package/dist/constants/git.mjs +2 -0
- package/dist/constants/git.mjs.map +1 -0
- package/dist/controllers/gitCommand.cjs +2 -0
- package/dist/controllers/gitCommand.cjs.map +1 -0
- package/dist/controllers/gitCommand.mjs +2 -0
- package/dist/controllers/gitCommand.mjs.map +1 -0
- package/dist/controllers/gitSession.cjs +2 -0
- package/dist/controllers/gitSession.cjs.map +1 -0
- package/dist/controllers/gitSession.mjs +2 -0
- package/dist/controllers/gitSession.mjs.map +1 -0
- package/dist/controllers/hubApi.cjs +2 -0
- package/dist/controllers/hubApi.cjs.map +1 -0
- package/dist/controllers/hubApi.mjs +2 -0
- package/dist/controllers/hubApi.mjs.map +1 -0
- package/dist/controllers/worktreesChannel.cjs +2 -0
- package/dist/controllers/worktreesChannel.cjs.map +1 -0
- package/dist/controllers/worktreesChannel.mjs +2 -0
- package/dist/controllers/worktreesChannel.mjs.map +1 -0
- package/dist/extensions/pi.cjs +2 -1
- package/dist/extensions/pi.cjs.map +1 -0
- package/dist/extensions/pi.d.cts +6 -2
- package/dist/extensions/pi.d.cts.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 +2 -1
- package/dist/extensions/pi.mjs.map +1 -0
- package/dist/extensions/server.cjs +2 -0
- package/dist/extensions/server.cjs.map +1 -0
- package/dist/extensions/server.d.cts +5 -0
- package/dist/extensions/server.d.cts.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 +2 -0
- package/dist/extensions/server.mjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +3 -4
- package/dist/index.d.mts +3 -4
- package/dist/index.mjs +1 -1
- package/dist/schemas/apiContracts.cjs +2 -0
- package/dist/schemas/apiContracts.cjs.map +1 -0
- package/dist/schemas/apiContracts.d.cts +53 -0
- package/dist/schemas/apiContracts.d.cts.map +1 -0
- package/dist/schemas/apiContracts.d.mts +53 -0
- package/dist/schemas/apiContracts.d.mts.map +1 -0
- package/dist/schemas/apiContracts.mjs +2 -0
- package/dist/schemas/apiContracts.mjs.map +1 -0
- package/dist/{adapters/filesystem/atomicJson.cjs → services/atomicJson/index.cjs} +1 -1
- package/dist/services/atomicJson/index.cjs.map +1 -0
- package/dist/{adapters/filesystem/atomicJson.mjs → services/atomicJson/index.mjs} +1 -1
- package/dist/services/atomicJson/index.mjs.map +1 -0
- package/dist/{adapters/worktree/compositionMirror.cjs → services/compositionMirror/index.cjs} +1 -1
- package/dist/services/compositionMirror/index.cjs.map +1 -0
- package/dist/{adapters/worktree/compositionMirror.mjs → services/compositionMirror/index.mjs} +1 -1
- package/dist/services/compositionMirror/index.mjs.map +1 -0
- package/dist/services/errors/index.cjs +2 -0
- package/dist/services/errors/index.cjs.map +1 -0
- package/dist/services/errors/index.mjs +2 -0
- package/dist/services/errors/index.mjs.map +1 -0
- package/dist/services/{extensionService.cjs → extensionService/index.cjs} +1 -1
- package/dist/services/extensionService/index.cjs.map +1 -0
- package/dist/services/extensionService/index.d.cts +8 -0
- package/dist/services/extensionService/index.d.cts.map +1 -0
- package/dist/services/extensionService/index.d.mts +8 -0
- package/dist/services/extensionService/index.d.mts.map +1 -0
- package/dist/services/{extensionService.mjs → extensionService/index.mjs} +1 -1
- package/dist/services/extensionService/index.mjs.map +1 -0
- package/dist/{adapters/worktree/gitCli.cjs → services/gitCli/index.cjs} +1 -1
- package/dist/services/gitCli/index.cjs.map +1 -0
- package/dist/{adapters/worktree/gitCli.mjs → services/gitCli/index.mjs} +1 -1
- package/dist/services/gitCli/index.mjs.map +1 -0
- package/dist/services/gitDependencies/index.cjs +2 -0
- package/dist/services/gitDependencies/index.cjs.map +1 -0
- package/dist/services/gitDependencies/index.d.cts +6 -0
- package/dist/services/gitDependencies/index.d.cts.map +1 -0
- package/dist/services/gitDependencies/index.d.mts +6 -0
- package/dist/services/gitDependencies/index.d.mts.map +1 -0
- package/dist/services/gitDependencies/index.mjs +2 -0
- package/dist/services/gitDependencies/index.mjs.map +1 -0
- package/dist/services/paths/index.cjs +2 -0
- package/dist/services/paths/index.cjs.map +1 -0
- package/dist/services/paths/index.mjs +2 -0
- package/dist/services/paths/index.mjs.map +1 -0
- package/dist/{adapters/worktree/repositoryIdentity.cjs → services/repositoryIdentity/index.cjs} +1 -1
- package/dist/services/repositoryIdentity/index.cjs.map +1 -0
- package/dist/{adapters/worktree/repositoryIdentity.mjs → services/repositoryIdentity/index.mjs} +1 -1
- package/dist/services/repositoryIdentity/index.mjs.map +1 -0
- package/dist/services/runWorktree/index.cjs +15 -0
- package/dist/services/runWorktree/index.cjs.map +1 -0
- package/dist/services/runWorktree/index.mjs +15 -0
- package/dist/services/runWorktree/index.mjs.map +1 -0
- package/dist/services/worktreeEvents/index.cjs +2 -0
- package/dist/services/worktreeEvents/index.cjs.map +1 -0
- package/dist/services/worktreeEvents/index.d.cts +15 -0
- package/dist/services/worktreeEvents/index.d.cts.map +1 -0
- package/dist/services/worktreeEvents/index.d.mts +15 -0
- package/dist/services/worktreeEvents/index.d.mts.map +1 -0
- package/dist/services/worktreeEvents/index.mjs +2 -0
- package/dist/services/worktreeEvents/index.mjs.map +1 -0
- package/dist/services/{worktreeNaming.cjs → worktreeNaming/index.cjs} +1 -1
- package/dist/services/{worktreeNaming.cjs.map → worktreeNaming/index.cjs.map} +1 -1
- package/dist/services/{worktreeNaming.d.mts → worktreeNaming/index.d.cts} +3 -3
- package/dist/services/worktreeNaming/index.d.cts.map +1 -0
- package/dist/services/{worktreeNaming.d.cts → worktreeNaming/index.d.mts} +3 -3
- package/dist/services/worktreeNaming/index.d.mts.map +1 -0
- package/dist/services/{worktreeNaming.mjs → worktreeNaming/index.mjs} +1 -1
- package/dist/services/{worktreeNaming.mjs.map → worktreeNaming/index.mjs.map} +1 -1
- package/dist/services/worktreeOperations/index.cjs +2 -0
- package/dist/services/worktreeOperations/index.cjs.map +1 -0
- package/dist/{adapters/worktree/worktreeOperations.d.cts → services/worktreeOperations/index.d.cts} +6 -6
- package/dist/services/worktreeOperations/index.d.cts.map +1 -0
- package/dist/{adapters/worktree/worktreeOperations.d.mts → services/worktreeOperations/index.d.mts} +6 -6
- package/dist/services/worktreeOperations/index.d.mts.map +1 -0
- package/dist/services/worktreeOperations/index.mjs +2 -0
- package/dist/services/worktreeOperations/index.mjs.map +1 -0
- package/dist/services/worktreeRegistry/index.cjs +2 -0
- package/dist/services/worktreeRegistry/index.cjs.map +1 -0
- package/dist/services/worktreeRegistry/index.mjs +2 -0
- package/dist/services/worktreeRegistry/index.mjs.map +1 -0
- package/dist/tools/runWorktree.cjs +2 -0
- package/dist/tools/runWorktree.cjs.map +1 -0
- package/dist/tools/runWorktree.mjs +2 -0
- package/dist/tools/runWorktree.mjs.map +1 -0
- package/dist/types/extension.d.cts +1 -1
- package/dist/types/extension.d.mts +1 -1
- package/package.json +27 -21
- package/src/extensions/web.ts +33 -0
- package/src/web/components/RunWorktreeToolMessage.tsx +1 -1
- package/src/web/components/WorktreesActivitySection.tsx +5 -4
- package/src/web/components/WorktreesPanel.tsx +4 -3
- package/src/web/components/toolRenderers.ts +3 -2
- package/src/web/stores/worktreesActivityStore.ts +3 -2
- package/src/web/tsconfig.json +1 -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.map +0 -1
- 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/compositionMirror.cjs.map +0 -1
- package/dist/adapters/worktree/compositionMirror.mjs.map +0 -1
- package/dist/adapters/worktree/gitCli.cjs.map +0 -1
- package/dist/adapters/worktree/gitCli.mjs.map +0 -1
- package/dist/adapters/worktree/repositoryIdentity.cjs.map +0 -1
- 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.map +0 -1
- 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/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/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.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.d.cts.map +0 -1
- package/dist/services/worktreeNaming.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/web/index.ts +0 -30
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"worktreesChannel.mjs","names":[],"sources":["../../../src/adapters/web/worktreesChannel.ts"],"sourcesContent":["/**\n * The worktrees data channel, and the commands the dock sends back through it.\n *\n * DESIGN PATTERNS:\n * - Hub-scoped: it reads this machine's registry files, which a browser cannot.\n * - Scoped to the session that owns the worktree, not to the repository. Two\n * sessions in one checkout are two pieces of work; showing each the other's\n * worktrees offered a close button for something the reader never made.\n * A worktree whose parent session is gone is the exception: it is shown to\n * everyone in the repository, marked unowned, or nobody could ever close it.\n * - Poll, do not watch. The registry is a single small JSON file written by\n * this package alone, and a watcher on a path that may not exist yet costs\n * more than re-reading a few hundred bytes.\n * - Commands run the same `worktreeOperations` the tool runs, so the panel and\n * the agent cannot drift into two ideas of what creating a worktree means.\n * - Publish only what the dock renders. Paths and provenance stay in the\n * registry; the page gets a view.\n *\n * AVOID:\n * - Throwing out of a poll or a command. A registry that cannot be read is an\n * empty list, and a failed command is an error string on the next frame:\n * the dock degrades to what it can tell the reader, never to a dead channel.\n */\nimport type { HubChannelSource, HubSessionScope, WebHubChannel } from '@agimon-ai/doompi-web-contracts';\nimport { GIT_WORKTREES_TYPE, type GitWorktreesCommand, type WorktreeView } from '../../types/webWorktrees.ts';\nimport { DoomGitExpectedError } from '../../services/support/errors.ts';\nimport { hubRegistryDir, registryFile } from '../filesystem/paths.ts';\nimport { sessionIsLive } from '../hub/hubClient.ts';\nimport { createWorktreeGit } from '../worktree/gitCli.ts';\nimport { createWorktreeOperations, type WorktreeOperations } from '../worktree/worktreeOperations.ts';\nimport { createWorktreeRegistry } from '../worktree/worktreeRegistry.ts';\n\n/** How often a session's registry is re-read. Worktrees change by hand, not by the second. */\nconst POLL_MS = 4000;\n\ninterface SessionState {\n worktrees: WorktreeView[];\n pending: string | undefined;\n error: string | undefined;\n}\n\nfunction payloadOf(state: SessionState): Record<string, unknown> {\n return {\n worktrees: state.worktrees,\n ...(state.pending === undefined ? {} : { pending: state.pending }),\n ...(state.error === undefined ? {} : { error: state.error }),\n };\n}\n\n/** What the channel needs from its surroundings, injected so tests stay off this machine. */\nexport interface WorktreesChannelOptions {\n intervalMs?: number;\n operations?: WorktreeOperations;\n homeDir?: string;\n registryDir?: string;\n isSessionLive?: (registryDir: string, sessionId: string) => boolean;\n}\n\ninterface ViewDeps {\n registryDir: string;\n homeDir: string | undefined;\n isSessionLive: (registryDir: string, sessionId: string) => boolean;\n}\n\n/**\n * The worktrees one session may see: its own, plus any whose parent session\n * has gone. Liveness is the registry record's presence, the same signal the\n * rail uses to decide a session exists at all.\n */\nfunction viewsFor(scope: HubSessionScope, deps: ViewDeps): WorktreeView[] {\n try {\n return createWorktreeRegistry(registryFile(scope.cwd, deps.homeDir))\n .list()\n .flatMap((record) => {\n const owned = record.parentSessionId === scope.sessionId;\n const unowned = !owned && !deps.isSessionLive(deps.registryDir, record.parentSessionId);\n if (!owned && !unowned) return [];\n return [\n {\n id: record.id,\n branch: record.branch,\n path: record.path,\n sessionId: record.status === 'orphaned' ? null : record.sessionId,\n orphaned: record.status === 'orphaned',\n unowned,\n },\n ];\n });\n } catch {\n return [];\n }\n}\n\nfunction sameList(left: readonly WorktreeView[], right: readonly WorktreeView[]): boolean {\n if (left.length !== right.length) return false;\n return left.every((entry, index) => {\n const other = right[index];\n return (\n other !== undefined &&\n entry.id === other.id &&\n entry.branch === other.branch &&\n entry.sessionId === other.sessionId &&\n entry.orphaned === other.orphaned &&\n entry.unowned === other.unowned\n );\n });\n}\n\n/** A command the page sent, or undefined when the frame was not one. */\nfunction parseCommand(payload: unknown): GitWorktreesCommand | undefined {\n if (typeof payload !== 'object' || payload === null) return undefined;\n const value = payload as Record<string, unknown>;\n if (value.action === 'create') {\n if (typeof value.branch !== 'string' || value.branch.trim() === '') return undefined;\n return {\n action: 'create',\n branch: value.branch.trim(),\n ...(typeof value.baseRef === 'string' && value.baseRef.trim() !== '' ? { baseRef: value.baseRef.trim() } : {}),\n };\n }\n if (value.action === 'close') {\n if (typeof value.id !== 'string' || value.id === '') return undefined;\n return { action: 'close', id: value.id, ...(value.force === true ? { force: true } : {}) };\n }\n return undefined;\n}\n\n/**\n * What the reader is told when a command fails.\n *\n * An expected failure explains itself. Anything else is summarised, never\n * echoed: a git error can carry a remote URL with a token in it.\n */\nfunction failureText(error: unknown): string {\n return error instanceof DoomGitExpectedError ? error.message : 'The worktree operation failed.';\n}\n\n/**\n * One poller per managed session, publishing only when the list actually\n * changed so an idle cockpit stays quiet.\n */\nexport function createWorktreesChannel(options: WorktreesChannelOptions = {}): WebHubChannel {\n const intervalMs = options.intervalMs ?? POLL_MS;\n // Assigned by start, because receive is reachable only while the channel is\n // running and the command needs the state the poller keeps.\n let receiveCommand: ((scope: HubSessionScope, payload: unknown) => void) | undefined;\n\n return {\n frameType: GIT_WORKTREES_TYPE,\n start(host) {\n const worktrees = options.operations ?? createWorktreeOperations({ git: createWorktreeGit() });\n const views: ViewDeps = {\n registryDir: options.registryDir ?? hubRegistryDir(),\n homeDir: options.homeDir,\n isSessionLive: options.isSessionLive ?? sessionIsLive,\n };\n const latest = new Map<string, SessionState>();\n const scopes = new Map<string, HubSessionScope>();\n const timers = new Map<string, ReturnType<typeof setInterval>>();\n const busy = new Set<string>();\n\n /** Republishes a session, skipping a frame that would say nothing new. */\n const publish = (scope: HubSessionScope, force: boolean): void => {\n const previous = latest.get(scope.sessionId);\n const next: SessionState = {\n worktrees: viewsFor(scope, views),\n pending: previous?.pending,\n error: previous?.error,\n };\n if (\n !force &&\n previous !== undefined &&\n sameList(previous.worktrees, next.worktrees) &&\n previous.pending === next.pending &&\n previous.error === next.error\n ) {\n return;\n }\n latest.set(scope.sessionId, next);\n host.publish(scope.sessionId, payloadOf(next));\n };\n\n /** Sets the operation label and clears the last failure, then publishes. */\n const mark = (scope: HubSessionScope, pending: string | undefined, error: string | undefined): void => {\n const previous = latest.get(scope.sessionId);\n latest.set(scope.sessionId, {\n worktrees: previous?.worktrees ?? viewsFor(scope, views),\n pending,\n error,\n });\n publish(scope, true);\n };\n\n const run = async (scope: HubSessionScope, command: GitWorktreesCommand): Promise<void> => {\n const context = { cwd: scope.cwd, sessionId: scope.sessionId };\n if (command.action === 'create') {\n mark(scope, `creating ${command.branch}\\u2026`, undefined);\n await worktrees.spawn(\n context,\n {\n branch: command.branch,\n ...(command.baseRef === undefined ? {} : { baseRef: command.baseRef }),\n },\n // Each phase replaces the label, so the panel says what is\n // happening instead of holding one line for the whole wait.\n { onProgress: (label) => mark(scope, label, undefined) },\n );\n return;\n }\n mark(scope, `closing ${command.id}\\u2026`, undefined);\n await worktrees.close(context, command.id, command.force ?? false);\n };\n\n const source: HubChannelSource = {\n payloadFor(scope) {\n const state = latest.get(scope.sessionId);\n return state === undefined ? undefined : payloadOf(state);\n },\n sessionAdded(scope) {\n scopes.set(scope.sessionId, scope);\n publish(scope, false);\n const timer = setInterval(() => {\n publish(scope, false);\n }, intervalMs);\n timer.unref?.();\n timers.set(scope.sessionId, timer);\n },\n sessionRemoved(sessionId) {\n const timer = timers.get(sessionId);\n if (timer !== undefined) clearInterval(timer);\n timers.delete(sessionId);\n latest.delete(sessionId);\n scopes.delete(sessionId);\n busy.delete(sessionId);\n },\n close() {\n for (const timer of timers.values()) clearInterval(timer);\n timers.clear();\n latest.clear();\n scopes.clear();\n busy.clear();\n },\n };\n receiveCommand = (scope, payload) => {\n const command = parseCommand(payload);\n if (command === undefined) return;\n // One operation per session. A create runs for minutes, and a second\n // click must not start a second worktree behind the first.\n if (busy.has(scope.sessionId)) return;\n busy.add(scope.sessionId);\n void run(scope, command)\n .then(() => {\n mark(scope, undefined, undefined);\n })\n .catch((error: unknown) => {\n host.onNotice(`worktree command failed for ${scope.sessionId} (${failureText(error)})`);\n mark(scope, undefined, failureText(error));\n })\n .finally(() => {\n busy.delete(scope.sessionId);\n });\n };\n\n return source;\n },\n receive(scope, payload) {\n receiveCommand?.(scope, payload);\n },\n };\n}\n\n/** The named export the generated hub channel registry imports. */\nexport const webHubChannels: readonly WebHubChannel[] = [createWorktreesChannel()];\n"],"mappings":"8dAyCA,SAAS,EAAU,EAA8C,CAC/D,MAAO,CACL,UAAW,EAAM,UACjB,GAAI,EAAM,UAAY,IAAA,GAAY,CAAC,EAAI,CAAE,QAAS,EAAM,OAAQ,EAChE,GAAI,EAAM,QAAU,IAAA,GAAY,CAAC,EAAI,CAAE,MAAO,EAAM,KAAM,CAC5D,CACF,CAsBA,SAAS,EAAS,EAAwB,EAAgC,CACxE,GAAI,CACF,OAAO,EAAuB,EAAa,EAAM,IAAK,EAAK,OAAO,CAAC,CAAC,CACjE,KAAK,CAAC,CACN,QAAS,GAAW,CACnB,IAAM,EAAQ,EAAO,kBAAoB,EAAM,UACzC,EAAU,CAAC,GAAS,CAAC,EAAK,cAAc,EAAK,YAAa,EAAO,eAAe,EAEtF,MADI,CAAC,GAAS,CAAC,EAAgB,CAAC,EACzB,CACL,CACE,GAAI,EAAO,GACX,OAAQ,EAAO,OACf,KAAM,EAAO,KACb,UAAW,EAAO,SAAW,WAAa,KAAO,EAAO,UACxD,SAAU,EAAO,SAAW,WAC5B,SACF,CACF,CACF,CAAC,CACL,MAAQ,CACN,MAAO,CAAC,CACV,CACF,CAEA,SAAS,EAAS,EAA+B,EAAyC,CAExF,O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,EAAO,IAAA,GAAW,IAAA,EAAS,CAClC,CAAC,CAAC,CACD,MAAO,GAAmB,CACzB,EAAK,SAAS,+BAA+B,EAAM,UAAU,IAAI,EAAY,CAAK,EAAE,EAAE,EACtF,EAAK,EAAO,IAAA,GAAW,EAAY,CAAK,CAAC,CAC3C,CAAC,CAAC,CACD,YAAc,CACb,EAAK,OAAO,EAAM,SAAS,CAC7B,CAAC,GACL,EAEO,CAjDL,WAAW,EAAO,CAChB,IAAM,EAAQ,EAAO,IAAI,EAAM,SAAS,EACxC,OAAO,IAAU,IAAA,GAAY,IAAA,GAAY,EAAU,CAAK,CAC1D,EACA,aAAa,EAAO,CAClB,EAAO,IAAI,EAAM,UAAW,CAAK,EACjC,EAAQ,EAAO,EAAK,EACpB,IAAM,EAAQ,gBAAkB,CAC9B,EAAQ,EAAO,EAAK,CACtB,EAAG,CAAU,EACb,EAAM,QAAQ,EACd,EAAO,IAAI,EAAM,UAAW,CAAK,CACnC,EACA,eAAe,EAAW,CACxB,IAAM,EAAQ,EAAO,IAAI,CAAS,EAC9B,IAAU,IAAA,IAAW,cAAc,CAAK,EAC5C,EAAO,OAAO,CAAS,EACvB,EAAO,OAAO,CAAS,EACvB,EAAO,OAAO,CAAS,EACvB,EAAK,OAAO,CAAS,CACvB,EACA,OAAQ,CACN,IAAK,IAAM,KAAS,EAAO,OAAO,EAAG,cAAc,CAAK,EACxD,EAAO,MAAM,EACb,EAAO,MAAM,EACb,EAAO,MAAM,EACb,EAAK,MAAM,CACb,CAsBK,CACT,EACA,QAAQ,EAAO,EAAS,CACtB,IAAiB,EAAO,CAAO,CACjC,CACF,CACF,CAGA,MAAa,EAA2C,CAAC,EAAuB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compositionMirror.cjs","names":["fs","path"],"sources":["../../../src/adapters/worktree/compositionMirror.ts"],"sourcesContent":["/**\n * Giving a new worktree the build output its parent checkout already has.\n *\n * DESIGN PATTERNS:\n * - Mirrors, never builds. Everything here is a copy or a symlink of something\n * the parent checkout already produced, so it costs seconds and cannot fail\n * the way a package manager or a compiler can.\n * - `node_modules` is linked, `dist` is copied. The module tree is gigabytes\n * and read-only in practice, so a link is right; build output is small and a\n * link would send a build run inside the worktree straight into the parent's\n * directory.\n * - Absent parent output means nothing to do. A repository with no\n * `node_modules` at its root is either not a JS project or not installed, and\n * either way this has no opinion about it, so a Rust, Go or Python worktree\n * pays nothing.\n *\n * WHY THIS EXISTS:\n * A DoomPi session composes the extensions its repository's config names, and\n * this repository names its own workspace packages by relative path. Those\n * packages declare `pi.extensions` under `dist/`, which git does not track, so\n * a fresh worktree resolves none of them and the session dies on start. The\n * parent checkout has already built exactly what the child needs.\n *\n * AVOID:\n * - Recursing into `node_modules`. The scan is bounded and skips it; without\n * that this walks a gigabyte to find nothing.\n * - Treating a mirror failure as fatal. The worktree is good either way; only\n * the session's composition is poorer for it.\n */\nimport fs from 'node:fs';\nimport path from 'node:path';\n\n/** Directories that are build output worth copying into a new worktree. */\nconst OUTPUT_DIRECTORY = 'dist';\nconst MODULES_DIRECTORY = 'node_modules';\nconst GIT_DIRECTORY = '.git';\n/**\n * How deep the scan goes.\n *\n * Four levels reaches `layers/<group>/<package>/dist` in this repository's\n * layout, and a workspace that buries a package deeper than that gets a\n * partial mirror rather than a slow one.\n */\nconst MAX_DEPTH = 4;\n\nexport type MirrorOutcome =\n | { kind: 'skipped'; reason: 'no-modules' }\n | { kind: 'mirrored'; copied: number; linked: number };\n\ninterface Found {\n /** Paths relative to the source root. */\n outputs: string[];\n modules: string[];\n}\n\nfunction scan(root: string): Found {\n const found: Found = { outputs: [], modules: [] };\n const walk = (relative: string, depth: number): void => {\n let entries: fs.Dirent[];\n try {\n entries = fs.readdirSync(path.join(root, relative), { withFileTypes: true });\n } catch {\n return;\n }\n for (const entry of entries) {\n if (!entry.isDirectory()) continue;\n const child = relative === '' ? entry.name : `${relative}/${entry.name}`;\n if (entry.name === GIT_DIRECTORY) continue;\n // Both of these are destinations, not places to look inside.\n if (entry.name === MODULES_DIRECTORY) {\n found.modules.push(child);\n continue;\n }\n if (entry.name === OUTPUT_DIRECTORY) {\n found.outputs.push(child);\n continue;\n }\n if (depth < MAX_DEPTH) walk(child, depth + 1);\n }\n };\n walk('', 1);\n return found;\n}\n\n/**\n * Copies the parent's build output into a worktree and links its modules.\n *\n * Individual failures are counted out rather than thrown: a mirror that lands\n * partly is still better than none, and the caller has a worktree either way.\n */\nexport function mirrorComposition(source: string, target: string): MirrorOutcome {\n if (!fs.existsSync(path.join(source, MODULES_DIRECTORY))) return { kind: 'skipped', reason: 'no-modules' };\n\n const found = scan(source);\n let copied = 0;\n let linked = 0;\n\n for (const relative of found.modules) {\n const destination = path.join(target, relative);\n if (fs.existsSync(destination)) continue;\n try {\n fs.mkdirSync(path.dirname(destination), { recursive: true });\n fs.symlinkSync(path.join(source, relative), destination, 'dir');\n linked += 1;\n } catch {\n // A link the filesystem refuses costs this package one resolution, not\n // the worktree.\n }\n }\n\n for (const relative of found.outputs) {\n const destination = path.join(target, relative);\n if (fs.existsSync(destination)) continue;\n try {\n fs.mkdirSync(path.dirname(destination), { recursive: true });\n fs.cpSync(path.join(source, relative), destination, { recursive: true });\n copied += 1;\n } catch {\n // Same reasoning as a failed link.\n }\n }\n\n return { kind: 'mirrored', copied, linked };\n}\n"],"mappings":"8IAiCA,MACM,EAAoB,eAqB1B,SAAS,EAAK,EAAqB,CACjC,IAAM,EAAe,CAAE,QAAS,CAAC,EAAG,QAAS,CAAC,CAAE,EAC1C,GAAQ,EAAkB,IAAwB,CACtD,IAAI,EACJ,GAAI,CACF,EAAUA,EAAAA,QAAG,YAAYC,EAAAA,QAAK,KAAK,EAAM,CAAQ,EAAG,CAAE,cAAe,EAAK,CAAC,CAC7E,MAAQ,CACN,MACF,CACA,IAAK,IAAM,KAAS,EAAS,CAC3B,GAAI,CAAC,EAAM,YAAY,EAAG,SAC1B,IAAM,EAAQ,IAAa,GAAK,EAAM,KAAO,GAAG,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|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compositionMirror.mjs","names":[],"sources":["../../../src/adapters/worktree/compositionMirror.ts"],"sourcesContent":["/**\n * Giving a new worktree the build output its parent checkout already has.\n *\n * DESIGN PATTERNS:\n * - Mirrors, never builds. Everything here is a copy or a symlink of something\n * the parent checkout already produced, so it costs seconds and cannot fail\n * the way a package manager or a compiler can.\n * - `node_modules` is linked, `dist` is copied. The module tree is gigabytes\n * and read-only in practice, so a link is right; build output is small and a\n * link would send a build run inside the worktree straight into the parent's\n * directory.\n * - Absent parent output means nothing to do. A repository with no\n * `node_modules` at its root is either not a JS project or not installed, and\n * either way this has no opinion about it, so a Rust, Go or Python worktree\n * pays nothing.\n *\n * WHY THIS EXISTS:\n * A DoomPi session composes the extensions its repository's config names, and\n * this repository names its own workspace packages by relative path. Those\n * packages declare `pi.extensions` under `dist/`, which git does not track, so\n * a fresh worktree resolves none of them and the session dies on start. The\n * parent checkout has already built exactly what the child needs.\n *\n * AVOID:\n * - Recursing into `node_modules`. The scan is bounded and skips it; without\n * that this walks a gigabyte to find nothing.\n * - Treating a mirror failure as fatal. The worktree is good either way; only\n * the session's composition is poorer for it.\n */\nimport fs from 'node:fs';\nimport path from 'node:path';\n\n/** Directories that are build output worth copying into a new worktree. */\nconst OUTPUT_DIRECTORY = 'dist';\nconst MODULES_DIRECTORY = 'node_modules';\nconst GIT_DIRECTORY = '.git';\n/**\n * How deep the scan goes.\n *\n * Four levels reaches `layers/<group>/<package>/dist` in this repository's\n * layout, and a workspace that buries a package deeper than that gets a\n * partial mirror rather than a slow one.\n */\nconst MAX_DEPTH = 4;\n\nexport type MirrorOutcome =\n | { kind: 'skipped'; reason: 'no-modules' }\n | { kind: 'mirrored'; copied: number; linked: number };\n\ninterface Found {\n /** Paths relative to the source root. */\n outputs: string[];\n modules: string[];\n}\n\nfunction scan(root: string): Found {\n const found: Found = { outputs: [], modules: [] };\n const walk = (relative: string, depth: number): void => {\n let entries: fs.Dirent[];\n try {\n entries = fs.readdirSync(path.join(root, relative), { withFileTypes: true });\n } catch {\n return;\n }\n for (const entry of entries) {\n if (!entry.isDirectory()) continue;\n const child = relative === '' ? entry.name : `${relative}/${entry.name}`;\n if (entry.name === GIT_DIRECTORY) continue;\n // Both of these are destinations, not places to look inside.\n if (entry.name === MODULES_DIRECTORY) {\n found.modules.push(child);\n continue;\n }\n if (entry.name === OUTPUT_DIRECTORY) {\n found.outputs.push(child);\n continue;\n }\n if (depth < MAX_DEPTH) walk(child, depth + 1);\n }\n };\n walk('', 1);\n return found;\n}\n\n/**\n * Copies the parent's build output into a worktree and links its modules.\n *\n * Individual failures are counted out rather than thrown: a mirror that lands\n * partly is still better than none, and the caller has a worktree either way.\n */\nexport function mirrorComposition(source: string, target: string): MirrorOutcome {\n if (!fs.existsSync(path.join(source, MODULES_DIRECTORY))) return { kind: 'skipped', reason: 'no-modules' };\n\n const found = scan(source);\n let copied = 0;\n let linked = 0;\n\n for (const relative of found.modules) {\n const destination = path.join(target, relative);\n if (fs.existsSync(destination)) continue;\n try {\n fs.mkdirSync(path.dirname(destination), { recursive: true });\n fs.symlinkSync(path.join(source, relative), destination, 'dir');\n linked += 1;\n } catch {\n // A link the filesystem refuses costs this package one resolution, not\n // the worktree.\n }\n }\n\n for (const relative of found.outputs) {\n const destination = path.join(target, relative);\n if (fs.existsSync(destination)) continue;\n try {\n fs.mkdirSync(path.dirname(destination), { recursive: true });\n fs.cpSync(path.join(source, relative), destination, { recursive: true });\n copied += 1;\n } catch {\n // Same reasoning as a failed link.\n }\n }\n\n return { kind: 'mirrored', copied, linked };\n}\n"],"mappings":"gDAiCA,MACM,EAAoB,eAqB1B,SAAS,EAAK,EAAqB,CACjC,IAAM,EAAe,CAAE,QAAS,CAAC,EAAG,QAAS,CAAC,CAAE,EAC1C,GAAQ,EAAkB,IAAwB,CACtD,IAAI,EACJ,GAAI,CACF,EAAU,EAAG,YAAY,EAAK,KAAK,EAAM,CAAQ,EAAG,CAAE,cAA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AAO,CAAE,KAAM,WAAY,SAAQ,QAAO,CAC5C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gitCli.cjs","names":["fs"],"sources":["../../../src/adapters/worktree/gitCli.ts"],"sourcesContent":["import { execFile } from 'node:child_process';\nimport fs from 'node:fs';\nimport type { WorktreeGit } from '../../types/worktreeRegistry.ts';\n\n/**\n * Git, as this package needs it.\n *\n * The timeouts are not uniform because the operations are not comparable. A\n * read answers in milliseconds; `worktree add` copies an entire checkout and\n * `worktree remove` deletes one, both bounded by the filesystem rather than by\n * git, and both minutes rather than seconds on a large repository or on\n * Windows. A single timeout would either fail honest work or hang on a wedged\n * one.\n */\nconst READ_TIMEOUT_MS = 30_000;\nconst ADD_TIMEOUT_MS = 300_000;\nconst REMOVE_TIMEOUT_MS = 300_000;\nconst PRUNE_TIMEOUT_MS = 15_000;\nconst MAX_OUTPUT_BYTES = 1_000_000;\n\ninterface GitResult {\n code: number;\n stdout: string;\n stderr: string;\n}\n\n/**\n * Runs git and reports the outcome without ever throwing on a non-zero exit.\n *\n * LC_ALL is pinned because two callers below decide what to do by matching\n * git's own wording, and a translated message would silently turn a recognised\n * condition into an unrecognised failure.\n */\nfunction git(cwd: string, args: readonly string[], timeout: number): Promise<GitResult> {\n return new Promise((resolve) => {\n execFile(\n 'git',\n [...args],\n { cwd, timeout, maxBuffer: MAX_OUTPUT_BYTES, env: { ...process.env, LC_ALL: 'C' } },\n (error, stdout, stderr) => {\n const code = error && typeof error.code === 'number' ? error.code : error ? 1 : 0;\n resolve({ code, stdout: String(stdout), stderr: String(stderr) });\n },\n );\n });\n}\n\n/**\n * The message a failed git call is allowed to surface.\n *\n * Raw stderr never travels: it can carry a remote URL with a token in it, and\n * this text ends up in a tool result the model reads and may repeat.\n */\nfunction failure(operation: string, result: GitResult): Error {\n return new Error(\n `git ${operation} failed (exit ${String(result.code)}, ${String(result.stderr.length)} bytes of stderr)`,\n );\n}\n\n/** Git's own words for \"that worktree is not there any more\". */\nfunction missingWorktree(stderr: string): boolean {\n const normalized = stderr.toLowerCase();\n return normalized.includes('is not a working tree') || normalized.includes('cannot remove working tree');\n}\n\nexport function createWorktreeGit(): WorktreeGit {\n const prune = async (repositoryRoot: string): Promise<void> => {\n await git(repositoryRoot, ['worktree', 'prune'], PRUNE_TIMEOUT_MS);\n };\n\n return {\n async addWorktree({ repositoryRoot, path, branch, baseRef }) {\n const result = await git(repositoryRoot, ['worktree', 'add', '-b', branch, path, baseRef], ADD_TIMEOUT_MS);\n if (result.code !== 0) throw failure('worktree add', result);\n },\n\n async removeWorktree({ repositoryRoot, path, force }) {\n const args = ['worktree', 'remove', ...(force ? ['--force'] : []), path];\n const result = await git(repositoryRoot, args, REMOVE_TIMEOUT_MS);\n if (result.code === 0) return;\n // A directory deleted behind git's back leaves an administrative entry\n // that makes a later `worktree add` at the same path refuse. Treating\n // \"already gone\" as success and pruning is what keeps that path reusable,\n // and it makes remove idempotent for a caller retrying after a crash.\n if (missingWorktree(result.stderr) && !fs.existsSync(path)) {\n await prune(repositoryRoot);\n return;\n }\n throw failure('worktree remove', result);\n },\n\n async deleteBranch({ repositoryRoot, branch }) {\n // -d, never -D: git refuses a branch that still holds unmerged commits,\n // and that refusal is the whole safety property. A rollback that could\n // throw away work someone committed in the worktree is worse than a\n // branch left behind.\n const result = await git(repositoryRoot, ['branch', '-d', branch], READ_TIMEOUT_MS);\n return result.code === 0;\n },\n pruneWorktrees: prune,\n\n async listWorktreePaths(repositoryRoot) {\n const result = await git(repositoryRoot, ['worktree', 'list', '--porcelain'], READ_TIMEOUT_MS);\n if (result.code !== 0) return [];\n return result.stdout\n .split('\\n')\n .filter((line) => line.startsWith('worktree '))\n .map((line) => line.slice('worktree '.length).trim())\n .filter((line) => line !== '');\n },\n\n async dirtyFiles(path) {\n const result = await git(path, ['status', '--porcelain'], READ_TIMEOUT_MS);\n if (result.code !== 0) return [];\n return result.stdout\n .split('\\n')\n .map((line) => line.slice(3).trim())\n .filter((line) => line !== '');\n },\n\n async repositoryRoot(cwd) {\n const result = await git(cwd, ['rev-parse', '--show-toplevel'], READ_TIMEOUT_MS);\n if (result.code !== 0) return undefined;\n const root = result.stdout.trim();\n return root === '' ? undefined : root;\n },\n\n async currentBranch(cwd) {\n const result = await git(cwd, ['rev-parse', '--abbrev-ref', 'HEAD'], READ_TIMEOUT_MS);\n if (result.code !== 0) return undefined;\n const branch = result.stdout.trim();\n return branch === '' ? undefined : branch;\n },\n\n async mergeBranch({ repositoryRoot, branch, message }) {\n // --no-ff so the worktree's work stays identifiable as a unit after the\n // fact. A fast-forward would erase the fact that it was ever separate,\n // which is the one thing worth keeping about a worktree.\n const args = ['merge', '--no-ff', ...(message === undefined ? [] : ['-m', message]), branch];\n const result = await git(repositoryRoot, args, READ_TIMEOUT_MS);\n if (result.code === 0) return;\n // A conflicted merge leaves the parent mid-merge, which is a state the\n // person has to resolve; aborting for them would throw away the conflict\n // markers they need to see.\n throw failure('merge', result);\n },\n };\n}\n"],"mappings":"kIAcA,MAAM,EAAkB,IAmBxB,SAAS,EAAI,EAAa,EAAyB,EAAqC,CACtF,OAAO,IAAI,QAAS,GAAY,EAC9B,EAAA,EAAA,SAAA,CACE,MACA,CAAC,GAAG,CAAI,EACR,CAAE,MAAK,UAAS,UAAW,IAAkB,IAAK,CAAE,GAAG,QAAQ,IAAK,OAAQ,GAAI,CAAE,GACjF,EAAO,EAAQ,IAAW,CAEzB,EAAQ,CAAE,KADG,GAAS,OAAO,EAAM,MAAS,SAAW,EAAM,KAAO,KACpD,OAAQ,OAAO,CAAM,EAAG,OAAQ,OAAO,CAAM,CAAE,CAAC,CAClE,CACF,CACF,CAAC,CACH,CAQA,SAAS,EAAQ,EAAmB,EAA0B,CAC5D,OAAW,MACT,OAAO,EAAU,gBAAgB,OAAO,EAAO,IAAI,EAAE,IAAI,OAAO,EAAO,OAAO,MAAM,EAAE,kBACxF,CACF,CAGA,SAAS,EAAgB,EAAyB,CAChD,IAAM,EAAa,EAAO,YAAY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,EAAM,CACrB,IAAM,EAAS,MAAM,EAAI,EAAM,CAAC,SAAU,aAAa,EAAG,CAAe,EAEzE,OADI,EAAO,OAAS,EACb,EAAO,OACX,MAAM;CAAI,CAAC,CACX,IAAK,GAAS,EAAK,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CACnC,OAAQ,GAAS,IAAS,EAAE,EAJD,CAAC,CAKjC,EAEA,MAAM,eAAe,EAAK,CACxB,IAAM,EAAS,MAAM,EAAI,EAAK,CAAC,YAAa,iBAAiB,EAAG,CAAe,EAC/E,GAAI,EAAO,OAAS,EAAG,OACvB,IAAM,EAAO,EAAO,OAAO,KAAK,EAChC,OAAO,IAAS,GAAK,IAAA,GAAY,CACnC,EAEA,MAAM,cAAc,EAAK,CACvB,IAAM,EAAS,MAAM,EAAI,EAAK,CAAC,YAAa,eAAgB,MAAM,EAAG,CAAe,EACpF,GAAI,EAAO,OAAS,EAAG,OACvB,IAAM,EAAS,EAAO,OAAO,KAAK,EAClC,OAAO,IAAW,GAAK,IAAA,GAAY,CACrC,EAEA,MAAM,YAAY,CAAE,iBAAgB,SAAQ,WAAW,CAKrD,IAAM,EAAS,MAAM,EAAI,EAAgB,CAD3B,QAAS,UAAW,GAAI,IAAY,IAAA,GAAY,CAAC,EAAI,CAAC,KAAM,CAAO,EAAI,CACzC,EAAG,CAAe,EAC1D,KAAO,OAAS,EAIpB,MAAM,EAAQ,QAAS,CAAM,CAC/B,CACF,CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gitCli.mjs","names":[],"sources":["../../../src/adapters/worktree/gitCli.ts"],"sourcesContent":["import { execFile } from 'node:child_process';\nimport fs from 'node:fs';\nimport type { WorktreeGit } from '../../types/worktreeRegistry.ts';\n\n/**\n * Git, as this package needs it.\n *\n * The timeouts are not uniform because the operations are not comparable. A\n * read answers in milliseconds; `worktree add` copies an entire checkout and\n * `worktree remove` deletes one, both bounded by the filesystem rather than by\n * git, and both minutes rather than seconds on a large repository or on\n * Windows. A single timeout would either fail honest work or hang on a wedged\n * one.\n */\nconst READ_TIMEOUT_MS = 30_000;\nconst ADD_TIMEOUT_MS = 300_000;\nconst REMOVE_TIMEOUT_MS = 300_000;\nconst PRUNE_TIMEOUT_MS = 15_000;\nconst MAX_OUTPUT_BYTES = 1_000_000;\n\ninterface GitResult {\n code: number;\n stdout: string;\n stderr: string;\n}\n\n/**\n * Runs git and reports the outcome without ever throwing on a non-zero exit.\n *\n * LC_ALL is pinned because two callers below decide what to do by matching\n * git's own wording, and a translated message would silently turn a recognised\n * condition into an unrecognised failure.\n */\nfunction git(cwd: string, args: readonly string[], timeout: number): Promise<GitResult> {\n return new Promise((resolve) => {\n execFile(\n 'git',\n [...args],\n { cwd, timeout, maxBuffer: MAX_OUTPUT_BYTES, env: { ...process.env, LC_ALL: 'C' } },\n (error, stdout, stderr) => {\n const code = error && typeof error.code === 'number' ? error.code : error ? 1 : 0;\n resolve({ code, stdout: String(stdout), stderr: String(stderr) });\n },\n );\n });\n}\n\n/**\n * The message a failed git call is allowed to surface.\n *\n * Raw stderr never travels: it can carry a remote URL with a token in it, and\n * this text ends up in a tool result the model reads and may repeat.\n */\nfunction failure(operation: string, result: GitResult): Error {\n return new Error(\n `git ${operation} failed (exit ${String(result.code)}, ${String(result.stderr.length)} bytes of stderr)`,\n );\n}\n\n/** Git's own words for \"that worktree is not there any more\". */\nfunction missingWorktree(stderr: string): boolean {\n const normalized = stderr.toLowerCase();\n return normalized.includes('is not a working tree') || normalized.includes('cannot remove working tree');\n}\n\nexport function createWorktreeGit(): WorktreeGit {\n const prune = async (repositoryRoot: string): Promise<void> => {\n await git(repositoryRoot, ['worktree', 'prune'], PRUNE_TIMEOUT_MS);\n };\n\n return {\n async addWorktree({ repositoryRoot, path, branch, baseRef }) {\n const result = await git(repositoryRoot, ['worktree', 'add', '-b', branch, path, baseRef], ADD_TIMEOUT_MS);\n if (result.code !== 0) throw failure('worktree add', result);\n },\n\n async removeWorktree({ repositoryRoot, path, force }) {\n const args = ['worktree', 'remove', ...(force ? ['--force'] : []), path];\n const result = await git(repositoryRoot, args, REMOVE_TIMEOUT_MS);\n if (result.code === 0) return;\n // A directory deleted behind git's back leaves an administrative entry\n // that makes a later `worktree add` at the same path refuse. Treating\n // \"already gone\" as success and pruning is what keeps that path reusable,\n // and it makes remove idempotent for a caller retrying after a crash.\n if (missingWorktree(result.stderr) && !fs.existsSync(path)) {\n await prune(repositoryRoot);\n return;\n }\n throw failure('worktree remove', result);\n },\n\n async deleteBranch({ repositoryRoot, branch }) {\n // -d, never -D: git refuses a branch that still holds unmerged commits,\n // and that refusal is the whole safety property. A rollback that could\n // throw away work someone committed in the worktree is worse than a\n // branch left behind.\n const result = await git(repositoryRoot, ['branch', '-d', branch], READ_TIMEOUT_MS);\n return result.code === 0;\n },\n pruneWorktrees: prune,\n\n async listWorktreePaths(repositoryRoot) {\n const result = await git(repositoryRoot, ['worktree', 'list', '--porcelain'], READ_TIMEOUT_MS);\n if (result.code !== 0) return [];\n return result.stdout\n .split('\\n')\n .filter((line) => line.startsWith('worktree '))\n .map((line) => line.slice('worktree '.length).trim())\n .filter((line) => line !== '');\n },\n\n async dirtyFiles(path) {\n const result = await git(path, ['status', '--porcelain'], READ_TIMEOUT_MS);\n if (result.code !== 0) return [];\n return result.stdout\n .split('\\n')\n .map((line) => line.slice(3).trim())\n .filter((line) => line !== '');\n },\n\n async repositoryRoot(cwd) {\n const result = await git(cwd, ['rev-parse', '--show-toplevel'], READ_TIMEOUT_MS);\n if (result.code !== 0) return undefined;\n const root = result.stdout.trim();\n return root === '' ? undefined : root;\n },\n\n async currentBranch(cwd) {\n const result = await git(cwd, ['rev-parse', '--abbrev-ref', 'HEAD'], READ_TIMEOUT_MS);\n if (result.code !== 0) return undefined;\n const branch = result.stdout.trim();\n return branch === '' ? undefined : branch;\n },\n\n async mergeBranch({ repositoryRoot, branch, message }) {\n // --no-ff so the worktree's work stays identifiable as a unit after the\n // fact. A fast-forward would erase the fact that it was ever separate,\n // which is the one thing worth keeping about a worktree.\n const args = ['merge', '--no-ff', ...(message === undefined ? [] : ['-m', message]), branch];\n const result = await git(repositoryRoot, args, READ_TIMEOUT_MS);\n if (result.code === 0) return;\n // A conflicted merge leaves the parent mid-merge, which is a state the\n // person has to resolve; aborting for them would throw away the conflict\n // markers they need to see.\n throw failure('merge', result);\n },\n };\n}\n"],"mappings":"qEAcA,MAAM,EAAkB,IAmBxB,SAAS,EAAI,EAAa,EAAyB,EAAqC,CACtF,OAAO,IAAI,QAAS,GAAY,CAC9B,EACE,MACA,CAAC,GAAG,CAAI,EACR,CAAE,MAAK,UAAS,UAAW,IAAkB,IAAK,CAAE,GAAG,QAAQ,IAAK,OAAQ,GAAI,CAAE,GACjF,EAAO,EAAQ,IAAW,CAEzB,EAAQ,CAAE,KADG,GAAS,OAAO,EAAM,MAAS,SAAW,EAAM,KAAO,KACpD,OAAQ,OAAO,CAAM,EAAG,OAAQ,OAAO,CAAM,CAAE,CAAC,CAClE,CACF,CACF,CAAC,CACH,CAQA,SAAS,EAAQ,EAAmB,EAA0B,CAC5D,OAAW,MACT,OAAO,EAAU,gBAAgB,OAAO,EAAO,IAAI,EAAE,IAAI,OAAO,EAAO,OAAO,MAAM,EAAE,kBACxF,CACF,CAGA,SAAS,EAAgB,EAAyB,CAChD,IAAM,EAAa,EAAO,YAAY,EACtC,OAAO,EAAW,SAAS,uBAAuB,GAAK,EAAW,SAAS,4BAA4B,CACzG,CAEA,SAAgB,GAAiC,CAC/C,IAAM,EAAQ,KAAO,IAA0C,CAC7D,MAAM,EAAI,EAAgB,CAAC,WAAY,OAAO,EAAG,IAAgB,CACnE,EAEA,MAAO,CACL,MAAM,YAAY,CAAE,iBAAgB,OAAM,SAAQ,WAAW,CAC3D,IAAM,EAAS,MAAM,EAAI,EAAgB,CAAC,WAAY,MAAO,KAAM,EAAQ,EAAM,CAAO,EAAG,GAAc,EACzG,GAAI,EAAO,OAAS,EAAG,MAAM,EAAQ,eAAgB,C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,KAAK,EAChC,OAAO,IAAS,GAAK,IAAA,GAAY,CACnC,EAEA,MAAM,cAAc,EAAK,CACvB,IAAM,EAAS,MAAM,EAAI,EAAK,CAAC,YAAa,eAAgB,MAAM,EAAG,CAAe,EACpF,GAAI,EAAO,OAAS,EAAG,OACvB,IAAM,EAAS,EAAO,OAAO,KAAK,EAClC,OAAO,IAAW,GAAK,IAAA,GAAY,CACrC,EAEA,MAAM,YAAY,CAAE,iBAAgB,SAAQ,WAAW,CAKrD,IAAM,EAAS,MAAM,EAAI,EAAgB,CAD3B,QAAS,UAAW,GAAI,IAAY,IAAA,GAAY,CAAC,EAAI,CAAC,KAAM,CAAO,EAAI,CACzC,EAAG,CAAe,EAC1D,KAAO,OAAS,EAIpB,MAAM,EAAQ,QAAS,CAAM,CAC/B,CACF,CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"repositoryIdentity.cjs","names":["path","fs","createHash"],"sources":["../../../src/adapters/worktree/repositoryIdentity.ts"],"sourcesContent":["import { createHash } from 'node:crypto';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nconst ID_LENGTH = 12;\nconst MAX_LABEL_LENGTH = 32;\n\n/**\n * The git directory shared by a repository and all of its worktrees.\n *\n * A normal checkout has a `.git` directory. A linked worktree has a `.git`\n * FILE pointing at `<common>/worktrees/<name>`, whose `commondir` points back\n * at the shared directory. Following that chain is what makes every worktree of\n * one repository agree on the repository's identity, which matters here because\n * the registry is per repository and must be found from inside a worktree too.\n */\nexport function gitCommonDirectory(root: string): string | undefined {\n const marker = path.join(root, '.git');\n let stat: fs.Stats;\n try {\n stat = fs.statSync(marker);\n } catch {\n return undefined;\n }\n if (stat.isDirectory()) return marker;\n let pointer: string;\n try {\n pointer = fs.readFileSync(marker, 'utf8').trim();\n } catch {\n return undefined;\n }\n if (!pointer.startsWith('gitdir:')) return undefined;\n const gitDir = path.resolve(root, pointer.slice('gitdir:'.length).trim());\n try {\n const common = fs.readFileSync(path.join(gitDir, 'commondir'), 'utf8').trim();\n return path.resolve(gitDir, common);\n } catch {\n // A submodule's .git file has no commondir; its gitdir is already common.\n return gitDir;\n }\n}\n\n/** A directory name that is recognisable to a person and safe on a filesystem. */\nexport function repositoryLabel(root: string): string {\n const label = path\n .basename(root)\n .toLowerCase()\n .replace(/[^a-z0-9]+/gu, '-')\n .replace(/^-+|-+$/gu, '')\n .slice(0, MAX_LABEL_LENGTH);\n return label === '' ? 'repository' : label;\n}\n\n/**\n * A stable id for the repository a directory belongs to.\n *\n * Keyed on the common git directory rather than the given path, so the main\n * checkout and every worktree of it resolve to one id and therefore to one\n * registry. Falling back to the path keeps a non-repository directory usable\n * instead of failing, though nothing here should reach that case.\n */\nexport function repositoryId(root: string): string {\n const common = gitCommonDirectory(root);\n const token = common === undefined ? `root:${path.resolve(root)}` : `git:${common}`;\n return createHash('sha256').update(token).digest('hex').slice(0, ID_LENGTH);\n}\n\n/** A short, collision-resistant suffix for one worktree directory. */\nexport function shortId(seed: string): string {\n return createHash('sha256').update(seed).digest('hex').slice(0, 8);\n}\n"],"mappings":"uKAgBA,SAAgB,EAAmB,EAAkC,CACnE,IAAM,EAASA,EAAAA,QAAK,KAAK,EAAM,MAAM,EACjC,EACJ,GAAI,CACF,EAAOC,EAAAA,QAAG,SAAS,CAAM,CAC3B,MAAQ,CACN,MACF,CACA,GAAI,EAAK,YAAY,EAAG,OAAO,EAC/B,IAAI,EACJ,GAAI,CACF,EAAUA,EAAAA,QAAG,aAAa,EAAQ,MAAM,CAAC,CAAC,KAAK,CACjD,MAAQ,CACN,MACF,CACA,GAAI,CAAC,EAAQ,WAAW,SAAS,EAAG,OACpC,IAAM,EAASD,EAAAA,QAAK,QAAQ,EAAM,EAAQ,MAAM,CAAgB,CAAC,CAAC,KAAK,CAAC,EACxE,GAAI,CACF,IAAM,EAASC,EAAAA,QAAG,aAAaD,EAAAA,QAAK,KAAK,EAAQ,WAAW,EAAG,MAAM,CAAC,CAAC,KAAK,EAC5E,OAAOA,EAAAA,QAAK,QAAQ,EAAQ,CAAM,CACpC,MAAQ,CAEN,OAAO,CACT,CACF,CAGA,SAAgB,EAAgB,EAAsB,CACpD,IAAM,EAAQA,EAAAA,QACX,SAAS,CAAI,CAAC,CACd,YAAY,CAAC,CACb,QAAQ,eAAgB,GAAG,CAAC,CAC5B,QAAQ,YAAa,EAAE,CAAC,CACxB,MAAM,EAAG,EAAgB,EAC5B,OAAO,IAAU,GAAK,aAAe,CACvC,CAUA,SAAgB,EAAa,EAAsB,CACjD,IAAM,EAAS,EAAmB,CAAI,EAChC,EAAQ,IAAW,IAAA,GAAY,QAAQA,EAAAA,QAAK,QAAQ,CAAI,IAAM,OAAO,IAC3E,OAAA,EAAOE,EAAAA,WAAAA,CAAW,QAAQ,CAAC,CAAC,OAAO,CAAK,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,EAAG,EAAS,CAC5E,CAGA,SAAgB,EAAQ,EAAsB,CAC5C,OAAA,EAAOA,EAAAA,WAAAA,CAAW,QAAQ,CAAC,CAAC,OAAO,CAAI,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,EAAG,CAAC,CACnE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"repositoryIdentity.mjs","names":[],"sources":["../../../src/adapters/worktree/repositoryIdentity.ts"],"sourcesContent":["import { createHash } from 'node:crypto';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nconst ID_LENGTH = 12;\nconst MAX_LABEL_LENGTH = 32;\n\n/**\n * The git directory shared by a repository and all of its worktrees.\n *\n * A normal checkout has a `.git` directory. A linked worktree has a `.git`\n * FILE pointing at `<common>/worktrees/<name>`, whose `commondir` points back\n * at the shared directory. Following that chain is what makes every worktree of\n * one repository agree on the repository's identity, which matters here because\n * the registry is per repository and must be found from inside a worktree too.\n */\nexport function gitCommonDirectory(root: string): string | undefined {\n const marker = path.join(root, '.git');\n let stat: fs.Stats;\n try {\n stat = fs.statSync(marker);\n } catch {\n return undefined;\n }\n if (stat.isDirectory()) return marker;\n let pointer: string;\n try {\n pointer = fs.readFileSync(marker, 'utf8').trim();\n } catch {\n return undefined;\n }\n if (!pointer.startsWith('gitdir:')) return undefined;\n const gitDir = path.resolve(root, pointer.slice('gitdir:'.length).trim());\n try {\n const common = fs.readFileSync(path.join(gitDir, 'commondir'), 'utf8').trim();\n return path.resolve(gitDir, common);\n } catch {\n // A submodule's .git file has no commondir; its gitdir is already common.\n return gitDir;\n }\n}\n\n/** A directory name that is recognisable to a person and safe on a filesystem. */\nexport function repositoryLabel(root: string): string {\n const label = path\n .basename(root)\n .toLowerCase()\n .replace(/[^a-z0-9]+/gu, '-')\n .replace(/^-+|-+$/gu, '')\n .slice(0, MAX_LABEL_LENGTH);\n return label === '' ? 'repository' : label;\n}\n\n/**\n * A stable id for the repository a directory belongs to.\n *\n * Keyed on the common git directory rather than the given path, so the main\n * checkout and every worktree of it resolve to one id and therefore to one\n * registry. Falling back to the path keeps a non-repository directory usable\n * instead of failing, though nothing here should reach that case.\n */\nexport function repositoryId(root: string): string {\n const common = gitCommonDirectory(root);\n const token = common === undefined ? `root:${path.resolve(root)}` : `git:${common}`;\n return createHash('sha256').update(token).digest('hex').slice(0, ID_LENGTH);\n}\n\n/** A short, collision-resistant suffix for one worktree directory. */\nexport function shortId(seed: string): string {\n return createHash('sha256').update(seed).digest('hex').slice(0, 8);\n}\n"],"mappings":"yFAgBA,SAAgB,EAAmB,EAAkC,CACnE,IAAM,EAAS,EAAK,KAAK,EAAM,MAAM,EACjC,EACJ,GAAI,CACF,EAAO,EAAG,SAAS,CAAM,CAC3B,MAAQ,CACN,MACF,CACA,GAAI,EAAK,YAAY,EAAG,OAAO,EAC/B,IAAI,EACJ,GAAI,CACF,EAAU,EAAG,aAAa,EAAQ,MAAM,CAAC,CAAC,KAAK,CACjD,MAAQ,CACN,MACF,CACA,GAAI,CAAC,EAAQ,WAAW,SAAS,EAAG,OACpC,IAAM,EAAS,EAAK,QAAQ,EAAM,EAAQ,MAAM,CAAgB,CAAC,CAAC,KAAK,CAAC,EACxE,GAAI,CACF,IAAM,EAAS,EAAG,aAAa,EAAK,KAAK,EAAQ,WAAW,EAAG,MAAM,CAAC,CAAC,KAAK,EAC5E,OAAO,EAAK,QAAQ,EAAQ,CAAM,CACpC,MAAQ,CAEN,OAAO,CACT,CACF,CAGA,SAAgB,EAAgB,EAAsB,CACpD,IAAM,EAAQ,EACX,SAAS,CAAI,CAAC,CACd,YAAY,CAAC,CACb,QAAQ,eAAgB,GAAG,CAAC,CAC5B,QAAQ,YAAa,EAAE,CAAC,CACxB,MAAM,EAAG,EAAgB,EAC5B,OAAO,IAAU,GAAK,aAAe,CACvC,CAUA,SAAgB,EAAa,EAAsB,CACjD,IAAM,EAAS,EAAmB,CAAI,EAChC,EAAQ,IAAW,IAAA,GAAY,QAAQ,EAAK,QAAQ,CAAI,IAAM,OAAO,IAC3E,OAAO,EAAW,QAAQ,CAAC,CAAC,OAAO,CAAK,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,EAAG,EAAS,CAC5E,CAGA,SAAgB,EAAQ,EAAsB,CAC5C,OAAO,EAAW,QAAQ,CAAC,CAAC,OAAO,CAAI,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,EAAG,CAAC,CACnE"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("./compositionMirror.cjs"),n=require("../hub/hubClient.cjs"),r=require("./repositoryIdentity.cjs"),i=require("../filesystem/paths.cjs"),a=require("../channel/worktreeChannel.cjs"),o=require("./worktreeRegistry.cjs"),s=require("../../services/worktreeNaming.cjs"),c=require("../../services/support/errors.cjs");let l=require("node:fs");l=e.__toESM(l,1);let u=require("node:crypto");function d(e){let{git:d}=e,f=e.createSession??n.createWorktreeSession,p=e.stopSession??n.stopWorktreeSession,m=e.mirror??t.mirrorComposition,h=e.isSessionLive??n.sessionIsLive,g=e.registryDir??i.hubRegistryDir(),_=e.now??(()=>new Date),v={alive:e=>h(g,e.sessionId),exists:e=>l.default.existsSync(e)},y=async t=>{let n=await d.repositoryRoot(t.cwd);if(n===void 0)throw new c.DoomGitExpectedError(`not_a_repository`,`${t.cwd} is not inside a git repository.`,!1,`Run this from a repository checkout.`);let r=o.createWorktreeRegistry(i.registryFile(n,e.homeDir));return{root:n,store:r,records:r.list()}},b=(e,t)=>{let n=e.find(e=>e.id===t);if(n===void 0)throw new c.DoomGitExpectedError(`worktree_not_found`,`No worktree with id ${t}.`,!1,`Call list to see the current ids.`);return n},x=(e,t,n)=>{if(t.parentSessionId!==e.sessionId&&h(g,t.parentSessionId))throw new c.DoomGitExpectedError(`worktree_not_owned`,`Worktree ${t.id} belongs to another session.`,!1,`Ask the session that created it to ${n} it, or close that session first.`)};return{async spawn(t,a,o){let{root:l,store:h,records:v}=await y(t),b=s.refuseSpawn({branch:a.branch,existing:v});if(b!==void 0)throw new c.DoomGitExpectedError(`worktree_exists`,b,!1,`Pick another branch name, or close it.`);let x=a.baseRef??await d.currentBranch(l)??`HEAD`,S=r.shortId((0,u.randomUUID)()),C=s.worktreeDirectory({worktreesRoot:i.worktreesRoot(e.homeDir),repositoryLabel:r.repositoryLabel(l),repositoryId:r.repositoryId(l),branch:a.branch,shortId:S}),w=()=>o?.signal?.aborted===!0,T=async()=>(await d.removeWorktree({repositoryRoot:l,path:C,force:!0}).catch(()=>void 0),await d.deleteBranch({repositoryRoot:l,branch:a.branch}).catch(()=>!1)?``:` The branch ${a.branch} has work on it and was kept.`);if(o?.onProgress?.(`creating branch ${a.branch}\u2026`),await d.addWorktree({repositoryRoot:l,path:C,branch:a.branch,baseRef:x}),w()){let e=await T();throw new c.DoomGitExpectedError(`spawn_cancelled`,`Cancelled before the session started.${e}`,!1,`The worktree was removed; run it again when you are ready.`)}o?.onProgress?.(`mirroring build output…`),m(l,C),o?.onProgress?.(`starting session…`);let E;try{E=await f({cwd:C,name:a.name??a.branch,parentSessionId:t.sessionId,registryDir:g,...o?.signal===void 0?{}:{signal:o.signal}})}catch(e){let t=await T();throw w()?new c.DoomGitExpectedError(`spawn_cancelled`,`Cancelled while the session was starting.${t}`,!1,`The worktree was removed; run it again when you are ready.`):e instanceof n.HubUnavailableError?new c.DoomGitExpectedError(`hub_unavailable`,`${e.message}${t}`,!0,`Start the cockpit and try again.`):e}let D={version:1,id:S,branch:a.branch,baseRef:x,path:C,repositoryRoot:l,sessionId:E,parentSessionId:t.sessionId,status:`running`,createdAt:_().toISOString()};try{h.replace([...v,D])}catch(e){await p(g,E).catch(()=>void 0);let t=await T();throw new c.DoomGitExpectedError(`registry_write_failed`,`The worktree was created but the registry could not be written (${e.message}).${t}`,!0,`Check the registry file for permissions or free space, then try again.`)}return D},async close(e,t,n){let{root:r,store:i,records:a}=await y(e),o=b(a,t);x(e,o,`close`);let u=l.default.existsSync(o.path)?await d.dirtyFiles(o.path):[],f=s.refuseClose({record:o,dirtyFiles:u,force:n});if(f!==void 0)throw new c.DoomGitExpectedError(`worktree_dirty`,f,!1,`Commit the work, or pass force: true.`);return await p(g,o.sessionId),await d.removeWorktree({repositoryRoot:r,path:o.path,force:n}),i.replace(a.filter(e=>e.id!==t)),o},async list(e){let{store:t,records:n}=await y(e),r=s.reconcile(n,v);return r.changed.length>0&&t.replace(r.records),r.records},async status(e,t){let{records:n}=await y(e),r=b(n,t);return{record:r,dirtyFiles:l.default.existsSync(r.path)?await d.dirtyFiles(r.path):[]}},async merge(e,t,n){let{root:r,records:i}=await y(e),a=b(i,t);x(e,a,`merge`);let o=await d.dirtyFiles(r);if(o.length>0)throw new c.DoomGitExpectedError(`worktree_dirty`,`The parent checkout has ${String(o.length)} uncommitted file(s): ${o.slice(0,10).join(`, `)}.`,!1,`Commit or stash the parent checkout first.`);return await d.mergeBranch({repositoryRoot:r,branch:a.branch,...n===void 0?{}:{message:n}}),a},async send(t,n,r){let{records:o}=await y(t),s=b(o,n),c=t.sessionId===s.sessionId?`parent`:`child`;a.createWorktreeChannel(i.channelRoot(s.id,e.homeDir)).send(c,r)},async messages(t,n){let{records:r}=await y(t),o=b(r,n),s=a.createWorktreeChannel(i.channelRoot(o.id,e.homeDir));s.sweep();let c=t.sessionId===o.sessionId?`child`:`parent`;return s.receive(c)},async prune(t,n){let{root:r,store:a,records:o}=await y(t),c=s.reconcile(o,v),u=await d.listWorktreePaths(r),f=new Map;for(let e of c.records)e.status===`orphaned`&&l.default.existsSync(e.path)&&f.set(e.path,await d.dirtyFiles(e.path));let p=s.planPrune({records:c.records,gitPaths:u,worktreesRoot:i.worktreesRoot(e.homeDir),dirtyByPath:f});if(n)return a.replace(c.records),p;for(let e of p.remove)await d.removeWorktree({repositoryRoot:r,path:e.path,force:!1});for(let e of[...p.remove,...p.forget])await d.deleteBranch({repositoryRoot:r,branch:e.branch}).catch(()=>!1)||p.keptBranches.push(e.branch);let m=new Set([...p.remove,...p.forget].map(e=>e.id));return a.replace(c.records.filter(e=>!m.has(e.id))),p}}}exports.createWorktreeOperations=d;
|
|
2
|
-
//# sourceMappingURL=worktreeOperations.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"worktreeOperations.cjs","names":["createWorktreeSession","stopWorktreeSession","mirrorComposition","sessionIsLive","hubRegistryDir","fs","DoomGitExpectedError","createWorktreeRegistry","registryFile","require","refuseSpawn","shortId","randomUUID","worktreeDirectory","worktreesRoot","repositoryLabel","repositoryId","HubUnavailableError","refuseClose","reconcile","channelRoot","createWorktreeChannel","planPrune"],"sources":["../../../src/adapters/worktree/worktreeOperations.ts"],"sourcesContent":["import fs from 'node:fs';\nimport { randomUUID } from 'node:crypto';\nimport { mirrorComposition } from './compositionMirror.ts';\nimport { createWorktreeSession, HubUnavailableError, sessionIsLive, stopWorktreeSession } from '../hub/hubClient.ts';\nimport { channelRoot, hubRegistryDir, registryFile, worktreesRoot } from '../filesystem/paths.ts';\nimport { repositoryId, repositoryLabel, shortId } from './repositoryIdentity.ts';\nimport { createWorktreeChannel } from '../channel/worktreeChannel.ts';\nimport type { ChannelMessage, ChannelParty } from '../channel/worktreeChannel.ts';\nimport { createWorktreeRegistry } from './worktreeRegistry.ts';\nimport { WORKTREE_RECORD_VERSION } from '../../types/worktreeRegistry.ts';\nimport type { WorktreeGit, WorktreeRecord } from '../../types/worktreeRegistry.ts';\nimport { planPrune, reconcile, refuseClose, refuseSpawn, worktreeDirectory } from '../../services/worktreeNaming.ts';\nimport { DoomGitExpectedError } from '../../services/support/errors.ts';\n\nexport interface WorktreeContext {\n /** Where the calling session is working, used to find the repository. */\n cwd: string;\n /** The calling session, recorded as the new session's parent. */\n sessionId: string;\n}\n\nexport interface SpawnWorktreeRequest {\n branch: string;\n baseRef?: string;\n name?: string;\n}\n\nexport interface SpawnOptions {\n /** Aborted when the caller gives up, so a spawn nobody is waiting for stops. */\n signal?: AbortSignal;\n /** Phase labels, for a caller that can show them while the work runs. */\n onProgress?: (label: string) => void;\n}\n\nexport interface WorktreeOperations {\n spawn(context: WorktreeContext, request: SpawnWorktreeRequest, options?: SpawnOptions): Promise<WorktreeRecord>;\n close(context: WorktreeContext, id: string, force: boolean): Promise<WorktreeRecord>;\n list(context: WorktreeContext): Promise<WorktreeRecord[]>;\n status(context: WorktreeContext, id: string): Promise<{ record: WorktreeRecord; dirtyFiles: string[] }>;\n merge(context: WorktreeContext, id: string, message?: string): Promise<WorktreeRecord>;\n prune(context: WorktreeContext, dryRun: boolean): Promise<ReturnType<typeof planPrune>>;\n send(context: WorktreeContext, id: string, message: string): Promise<void>;\n messages(context: WorktreeContext, id: string): Promise<ChannelMessage[]>;\n}\n\nexport interface WorktreeOperationsDeps {\n git: WorktreeGit;\n /** Injected so tests never reach the network. */\n createSession?: typeof createWorktreeSession;\n stopSession?: typeof stopWorktreeSession;\n /** Injected so a test never copies a real dependency tree. */\n mirror?: typeof mirrorComposition;\n isSessionLive?: typeof sessionIsLive;\n homeDir?: string;\n registryDir?: string;\n /** Injected so a record's createdAt is reproducible in a test. */\n now?: () => Date;\n}\n\nexport function createWorktreeOperations(deps: WorktreeOperationsDeps): WorktreeOperations {\n const { git } = deps;\n const createSession = deps.createSession ?? createWorktreeSession;\n const stopSession = deps.stopSession ?? stopWorktreeSession;\n const mirror = deps.mirror ?? mirrorComposition;\n const isSessionLive = deps.isSessionLive ?? sessionIsLive;\n const registryDir = deps.registryDir ?? hubRegistryDir();\n const now = deps.now ?? (() => new Date());\n const probe = {\n alive: (record: WorktreeRecord) => isSessionLive(registryDir, record.sessionId),\n exists: (path: string) => fs.existsSync(path),\n };\n\n /**\n * Everything an action needs about the repository it is acting on.\n *\n * Resolved per call rather than cached: a session's cwd is stable, but the\n * registry file is shared with the cockpit panel and another process may\n * have written it since the last call.\n */\n const resolve = async (context: WorktreeContext) => {\n const root = await git.repositoryRoot(context.cwd);\n if (root === undefined) {\n throw new DoomGitExpectedError(\n 'not_a_repository',\n `${context.cwd} is not inside a git repository.`,\n false,\n 'Run this from a repository checkout.',\n );\n }\n const store = createWorktreeRegistry(registryFile(root, deps.homeDir));\n return { root, store, records: store.list() };\n };\n\n const require = (records: readonly WorktreeRecord[], id: string): WorktreeRecord => {\n const record = records.find((entry) => entry.id === id);\n if (record === undefined) {\n throw new DoomGitExpectedError(\n 'worktree_not_found',\n `No worktree with id ${id}.`,\n false,\n 'Call list to see the current ids.',\n );\n }\n return record;\n };\n\n /**\n * Refuses to destroy or merge a worktree another live session is using.\n *\n * `parentSessionId` records who asked for the worktree. Two sessions in one\n * checkout share this registry, so without the check either could close the\n * other's work in progress by id.\n *\n * Once that session is gone there is no owner left to protect, and refusing\n * would strand the worktree: nothing else could ever close it.\n */\n const requireOwner = (context: WorktreeContext, record: WorktreeRecord, action: string): void => {\n if (record.parentSessionId === context.sessionId) return;\n if (!isSessionLive(registryDir, record.parentSessionId)) return;\n throw new DoomGitExpectedError(\n 'worktree_not_owned',\n `Worktree ${record.id} belongs to another session.`,\n false,\n `Ask the session that created it to ${action} it, or close that session first.`,\n );\n };\n\n return {\n async spawn(context, request, options) {\n const { root, store, records } = await resolve(context);\n const refusal = refuseSpawn({ branch: request.branch, existing: records });\n if (refusal !== undefined) {\n throw new DoomGitExpectedError('worktree_exists', refusal, false, 'Pick another branch name, or close it.');\n }\n const baseRef = request.baseRef ?? (await git.currentBranch(root)) ?? 'HEAD';\n const id = shortId(randomUUID());\n const path = worktreeDirectory({\n worktreesRoot: worktreesRoot(deps.homeDir),\n repositoryLabel: repositoryLabel(root),\n repositoryId: repositoryId(root),\n branch: request.branch,\n shortId: id,\n });\n\n // The worktree and the branch are made by one command, so they are undone\n // by one too. `worktree remove` leaves the branch behind, and a branch\n // nobody asked for is what a failed spawn used to leave on the floor.\n const cancelled = (): boolean => options?.signal?.aborted === true;\n const rollback = async (): Promise<string> => {\n await git.removeWorktree({ repositoryRoot: root, path, force: true }).catch(() => undefined);\n const deleted = await git.deleteBranch({ repositoryRoot: root, branch: request.branch }).catch(() => false);\n return deleted ? '' : ` The branch ${request.branch} has work on it and was kept.`;\n };\n\n options?.onProgress?.(`creating branch ${request.branch}\\u2026`);\n await git.addWorktree({ repositoryRoot: root, path, branch: request.branch, baseRef });\n\n // Checked here rather than only inside the session call: this is the\n // point where a checkout exists that nothing has recorded yet, which is\n // exactly the state an interrupted spawn used to leave behind.\n if (cancelled()) {\n const kept = await rollback();\n throw new DoomGitExpectedError(\n 'spawn_cancelled',\n `Cancelled before the session started.${kept}`,\n false,\n 'The worktree was removed; run it again when you are ready.',\n );\n }\n\n // Before the session, because the session composes the extensions this\n // repository's config names and those live in build output git does not\n // track. A worktree without it starts and dies on the first package it\n // cannot resolve. Nothing here can fail the spawn: a repository with no\n // build output to mirror simply has none.\n options?.onProgress?.('mirroring build output\\u2026');\n mirror(root, path);\n\n // The worktree exists from here on, so every later failure has to leave\n // it removed or recorded. An unrecorded directory on disk is the one\n // outcome with no way back: nothing would ever list it again.\n options?.onProgress?.('starting session\\u2026');\n let sessionId: string;\n try {\n sessionId = await createSession({\n cwd: path,\n name: request.name ?? request.branch,\n parentSessionId: context.sessionId,\n registryDir,\n ...(options?.signal === undefined ? {} : { signal: options.signal }),\n });\n } catch (error) {\n const kept = await rollback();\n if (cancelled()) {\n throw new DoomGitExpectedError(\n 'spawn_cancelled',\n `Cancelled while the session was starting.${kept}`,\n false,\n 'The worktree was removed; run it again when you are ready.',\n );\n }\n if (error instanceof HubUnavailableError) {\n throw new DoomGitExpectedError(\n 'hub_unavailable',\n `${error.message}${kept}`,\n true,\n 'Start the cockpit and try again.',\n );\n }\n throw error;\n }\n\n const record: WorktreeRecord = {\n version: WORKTREE_RECORD_VERSION,\n id,\n branch: request.branch,\n baseRef,\n path,\n repositoryRoot: root,\n sessionId,\n parentSessionId: context.sessionId,\n status: 'running',\n createdAt: now().toISOString(),\n };\n try {\n store.replace([...records, record]);\n } catch (error) {\n // A live session with no record is the worst outcome available here:\n // it runs, and no id anything can name points at it. The session goes\n // back too, rather than being left for someone to find by hand.\n await stopSession(registryDir, sessionId).catch(() => undefined);\n const kept = await rollback();\n throw new DoomGitExpectedError(\n 'registry_write_failed',\n `The worktree was created but the registry could not be written (${(error as Error).message}).${kept}`,\n true,\n 'Check the registry file for permissions or free space, then try again.',\n );\n }\n return record;\n },\n\n async close(context, id, force) {\n const { root, store, records } = await resolve(context);\n const record = require(records, id);\n requireOwner(context, record, 'close');\n const dirtyFiles = fs.existsSync(record.path) ? await git.dirtyFiles(record.path) : [];\n const refusal = refuseClose({ record, dirtyFiles, force });\n if (refusal !== undefined) {\n throw new DoomGitExpectedError('worktree_dirty', refusal, false, 'Commit the work, or pass force: true.');\n }\n // The session is stopped before the directory goes. Removing a checkout\n // while a process still holds files open in it is how a half-removed\n // worktree and a stale git administrative entry are made.\n await stopSession(registryDir, record.sessionId);\n await git.removeWorktree({ repositoryRoot: root, path: record.path, force });\n store.replace(records.filter((entry) => entry.id !== id));\n return record;\n },\n\n async list(context) {\n const { store, records } = await resolve(context);\n const outcome = reconcile(records, probe);\n if (outcome.changed.length > 0) store.replace(outcome.records);\n return outcome.records;\n },\n\n async status(context, id) {\n const { records } = await resolve(context);\n const record = require(records, id);\n const dirtyFiles = fs.existsSync(record.path) ? await git.dirtyFiles(record.path) : [];\n return { record, dirtyFiles };\n },\n\n async merge(context, id, message) {\n const { root, records } = await resolve(context);\n const record = require(records, id);\n requireOwner(context, record, 'merge');\n // The merge lands in the parent, so the parent is what must be clean. A\n // dirty parent would mix the person's in-flight edits into a merge commit\n // they did not intend to make.\n const parentDirty = await git.dirtyFiles(root);\n if (parentDirty.length > 0) {\n throw new DoomGitExpectedError(\n 'worktree_dirty',\n `The parent checkout has ${String(parentDirty.length)} uncommitted file(s): ${parentDirty.slice(0, 10).join(', ')}.`,\n false,\n 'Commit or stash the parent checkout first.',\n );\n }\n await git.mergeBranch({\n repositoryRoot: root,\n branch: record.branch,\n ...(message === undefined ? {} : { message }),\n });\n return record;\n },\n\n /**\n * Which side of the channel the caller is.\n *\n * A worktree session is the child of the record it belongs to, and the\n * parent for everything else. Deciding from the session id rather than a\n * flag means neither side can address itself by mistake.\n */\n async send(context, id, message) {\n const { records } = await resolve(context);\n const record = require(records, id);\n const party: ChannelParty = context.sessionId === record.sessionId ? 'parent' : 'child';\n createWorktreeChannel(channelRoot(record.id, deps.homeDir)).send(party, message);\n },\n\n async messages(context, id) {\n const { records } = await resolve(context);\n const record = require(records, id);\n const channel = createWorktreeChannel(channelRoot(record.id, deps.homeDir));\n channel.sweep();\n const party: ChannelParty = context.sessionId === record.sessionId ? 'child' : 'parent';\n return channel.receive(party);\n },\n\n async prune(context, dryRun) {\n const { root, store, records } = await resolve(context);\n const reconciled = reconcile(records, probe);\n const gitPaths = await git.listWorktreePaths(root);\n const dirtyByPath = new Map<string, readonly string[]>();\n for (const record of reconciled.records) {\n if (record.status === 'orphaned' && fs.existsSync(record.path)) {\n dirtyByPath.set(record.path, await git.dirtyFiles(record.path));\n }\n }\n const plan = planPrune({\n records: reconciled.records,\n gitPaths,\n worktreesRoot: worktreesRoot(deps.homeDir),\n dirtyByPath,\n });\n if (dryRun) {\n store.replace(reconciled.records);\n return plan;\n }\n for (const record of plan.remove) {\n await git.removeWorktree({ repositoryRoot: root, path: record.path, force: false });\n }\n // The checkout goes, so the branch it was made for goes with it. Safe\n // delete only: git keeps anything holding commits, and the plan says\n // which ones it kept rather than leaving the reader to notice later.\n for (const record of [...plan.remove, ...plan.forget]) {\n const deleted = await git.deleteBranch({ repositoryRoot: root, branch: record.branch }).catch(() => false);\n if (!deleted) plan.keptBranches.push(record.branch);\n }\n const dropped = new Set([...plan.remove, ...plan.forget].map((record) => record.id));\n store.replace(reconciled.records.filter((record) => !dropped.has(record.id)));\n return plan;\n },\n };\n}\n"],"mappings":"+bA2DA,SAAgB,EAAyB,EAAkD,CACzF,GAAM,CAAE,OAAQ,EACV,EAAgB,EAAK,eAAiBA,EAAAA,sBACtC,EAAc,EAAK,aAAeC,EAAAA,oBAClC,EAAS,EAAK,QAAUC,EAAAA,kBACxB,EAAgB,EAAK,eAAiBC,EAAAA,cACtC,EAAc,EAAK,aAAeC,EAAAA,eAAe,EACjD,EAAM,EAAK,UAAc,IAAI,MAC7B,EAAQ,CACZ,MAAQ,GAA2B,EAAc,EAAa,EAAO,SAAS,EAC9E,OAAS,GAAiBC,EAAAA,QAAG,WAAW,CAAI,CAC9C,EASM,EAAU,KAAO,IAA6B,CAClD,IAAM,EAAO,MAAM,EAAI,eAAe,EAAQ,GAAG,EACjD,GAAI,IAAS,IAAA,GACX,MAAM,IAAIC,EAAAA,qBACR,mBACA,GAAG,EAAQ,IAAI,kCACf,GACA,sCACF,EAEF,IAAM,EAAQC,EAAAA,uBAAuBC,EAAAA,aAAa,EAAM,EAAK,OAAO,CAAC,EACrE,MAAO,CAAE,OAAM,QAAO,QAAS,EAAM,KAAK,CAAE,CAC9C,EAEMC,GAAW,EAAoC,IAA+B,CAClF,IAAM,EAAS,EAAQ,KAAM,GAAU,EAAM,KAAO,CAAE,EACtD,GAAI,IAAW,IAAA,GACb,MAAM,IAAIH,EAAAA,qBACR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gB,EAAM,KAAM,EAAO,KAAM,MAAO,EAAM,CAAC,EAKpF,IAAK,IAAM,IAAU,CAAC,GAAG,EAAK,OAAQ,GAAG,EAAK,MAAM,EAE7C,MADiB,EAAI,aAAa,CAAE,eAAgB,EAAM,OAAQ,EAAO,MAAO,CAAC,CAAC,CAAC,UAAY,EAAK,GAC3F,EAAK,aAAa,KAAK,EAAO,MAAM,EAEpD,IAAM,EAAU,IAAI,IAAI,CAAC,GAAG,EAAK,OAAQ,GAAG,EAAK,MAAM,CAAC,CAAC,IAAK,GAAW,EAAO,EAAE,CAAC,EAEnF,OADA,EAAM,QAAQ,EAAW,QAAQ,OAAQ,GAAW,CAAC,EAAQ,IAAI,EAAO,EAAE,CAAC,CAAC,EACrE,CACT,CACF,CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"worktreeOperations.d.cts","names":[],"sources":["../../../src/adapters/worktree/worktreeOperations.ts"],"mappings":";;;;;UAciB;;EAEf;;EAEA;;UAGe;EACf;EACA;EACA;;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,QAAQ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"worktreeOperations.d.mts","names":[],"sources":["../../../src/adapters/worktree/worktreeOperations.ts"],"mappings":";;;;;UAciB;;EAEf;;EAEA;;UAGe;EACf;EACA;EACA;;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,QAAQ"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{mirrorComposition as e}from"./compositionMirror.mjs";import{HubUnavailableError as t,createWorktreeSession as n,sessionIsLive as r,stopWorktreeSession as i}from"../hub/hubClient.mjs";import{repositoryId as a,repositoryLabel as o,shortId as s}from"./repositoryIdentity.mjs";import{channelRoot as c,hubRegistryDir as l,registryFile as u,worktreesRoot as d}from"../filesystem/paths.mjs";import{createWorktreeChannel as f}from"../channel/worktreeChannel.mjs";import{createWorktreeRegistry as p}from"./worktreeRegistry.mjs";import{planPrune as m,reconcile as h,refuseClose as g,refuseSpawn as _,worktreeDirectory as v}from"../../services/worktreeNaming.mjs";import{DoomGitExpectedError as y}from"../../services/support/errors.mjs";import b from"node:fs";import{randomUUID as x}from"node:crypto";function S(S){let{git:C}=S,w=S.createSession??n,T=S.stopSession??i,E=S.mirror??e,D=S.isSessionLive??r,O=S.registryDir??l(),k=S.now??(()=>new Date),A={alive:e=>D(O,e.sessionId),exists:e=>b.existsSync(e)},j=async e=>{let t=await C.repositoryRoot(e.cwd);if(t===void 0)throw new y(`not_a_repository`,`${e.cwd} is not inside a git repository.`,!1,`Run this from a repository checkout.`);let n=p(u(t,S.homeDir));return{root:t,store:n,records:n.list()}},M=(e,t)=>{let n=e.find(e=>e.id===t);if(n===void 0)throw new y(`worktree_not_found`,`No worktree with id ${t}.`,!1,`Call list to see the current ids.`);return n},N=(e,t,n)=>{if(t.parentSessionId!==e.sessionId&&D(O,t.parentSessionId))throw new y(`worktree_not_owned`,`Worktree ${t.id} belongs to another session.`,!1,`Ask the session that created it to ${n} it, or close that session first.`)};return{async spawn(e,n,r){let{root:i,store:c,records:l}=await j(e),u=_({branch:n.branch,existing:l});if(u!==void 0)throw new y(`worktree_exists`,u,!1,`Pick another branch name, or close it.`);let f=n.baseRef??await C.currentBranch(i)??`HEAD`,p=s(x()),m=v({worktreesRoot:d(S.homeDir),repositoryLabel:o(i),repositoryId:a(i),branch:n.branch,shortId:p}),h=()=>r?.signal?.aborted===!0,g=async()=>(await C.removeWorktree({repositoryRoot:i,path:m,force:!0}).catch(()=>void 0),await C.deleteBranch({repositoryRoot:i,branch:n.branch}).catch(()=>!1)?``:` The branch ${n.branch} has work on it and was kept.`);if(r?.onProgress?.(`creating branch ${n.branch}\u2026`),await C.addWorktree({repositoryRoot:i,path:m,branch:n.branch,baseRef:f}),h()){let e=await g();throw new y(`spawn_cancelled`,`Cancelled before the session started.${e}`,!1,`The worktree was removed; run it again when you are ready.`)}r?.onProgress?.(`mirroring build output…`),E(i,m),r?.onProgress?.(`starting session…`);let b;try{b=await w({cwd:m,name:n.name??n.branch,parentSessionId:e.sessionId,registryDir:O,...r?.signal===void 0?{}:{signal:r.signal}})}catch(e){let n=await g();throw h()?new y(`spawn_cancelled`,`Cancelled while the session was starting.${n}`,!1,`The worktree was removed; run it again when you are ready.`):e instanceof t?new y(`hub_unavailable`,`${e.message}${n}`,!0,`Start the cockpit and try again.`):e}let D={version:1,id:p,branch:n.branch,baseRef:f,path:m,repositoryRoot:i,sessionId:b,parentSessionId:e.sessionId,status:`running`,createdAt:k().toISOString()};try{c.replace([...l,D])}catch(e){await T(O,b).catch(()=>void 0);let t=await g();throw new y(`registry_write_failed`,`The worktree was created but the registry could not be written (${e.message}).${t}`,!0,`Check the registry file for permissions or free space, then try again.`)}return D},async close(e,t,n){let{root:r,store:i,records:a}=await j(e),o=M(a,t);N(e,o,`close`);let s=b.existsSync(o.path)?await C.dirtyFiles(o.path):[],c=g({record:o,dirtyFiles:s,force:n});if(c!==void 0)throw new y(`worktree_dirty`,c,!1,`Commit the work, or pass force: true.`);return await T(O,o.sessionId),await C.removeWorktree({repositoryRoot:r,path:o.path,force:n}),i.replace(a.filter(e=>e.id!==t)),o},async list(e){let{store:t,records:n}=await j(e),r=h(n,A);return r.changed.length>0&&t.replace(r.records),r.records},async status(e,t){let{records:n}=await j(e),r=M(n,t);return{record:r,dirtyFiles:b.existsSync(r.path)?await C.dirtyFiles(r.path):[]}},async merge(e,t,n){let{root:r,records:i}=await j(e),a=M(i,t);N(e,a,`merge`);let o=await C.dirtyFiles(r);if(o.length>0)throw new y(`worktree_dirty`,`The parent checkout has ${String(o.length)} uncommitted file(s): ${o.slice(0,10).join(`, `)}.`,!1,`Commit or stash the parent checkout first.`);return await C.mergeBranch({repositoryRoot:r,branch:a.branch,...n===void 0?{}:{message:n}}),a},async send(e,t,n){let{records:r}=await j(e),i=M(r,t),a=e.sessionId===i.sessionId?`parent`:`child`;f(c(i.id,S.homeDir)).send(a,n)},async messages(e,t){let{records:n}=await j(e),r=M(n,t),i=f(c(r.id,S.homeDir));i.sweep();let a=e.sessionId===r.sessionId?`child`:`parent`;return i.receive(a)},async prune(e,t){let{root:n,store:r,records:i}=await j(e),a=h(i,A),o=await C.listWorktreePaths(n),s=new Map;for(let e of a.records)e.status===`orphaned`&&b.existsSync(e.path)&&s.set(e.path,await C.dirtyFiles(e.path));let c=m({records:a.records,gitPaths:o,worktreesRoot:d(S.homeDir),dirtyByPath:s});if(t)return r.replace(a.records),c;for(let e of c.remove)await C.removeWorktree({repositoryRoot:n,path:e.path,force:!1});for(let e of[...c.remove,...c.forget])await C.deleteBranch({repositoryRoot:n,branch:e.branch}).catch(()=>!1)||c.keptBranches.push(e.branch);let l=new Set([...c.remove,...c.forget].map(e=>e.id));return r.replace(a.records.filter(e=>!l.has(e.id))),c}}}export{S as createWorktreeOperations};
|
|
2
|
-
//# sourceMappingURL=worktreeOperations.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"worktreeOperations.mjs","names":[],"sources":["../../../src/adapters/worktree/worktreeOperations.ts"],"sourcesContent":["import fs from 'node:fs';\nimport { randomUUID } from 'node:crypto';\nimport { mirrorComposition } from './compositionMirror.ts';\nimport { createWorktreeSession, HubUnavailableError, sessionIsLive, stopWorktreeSession } from '../hub/hubClient.ts';\nimport { channelRoot, hubRegistryDir, registryFile, worktreesRoot } from '../filesystem/paths.ts';\nimport { repositoryId, repositoryLabel, shortId } from './repositoryIdentity.ts';\nimport { createWorktreeChannel } from '../channel/worktreeChannel.ts';\nimport type { ChannelMessage, ChannelParty } from '../channel/worktreeChannel.ts';\nimport { createWorktreeRegistry } from './worktreeRegistry.ts';\nimport { WORKTREE_RECORD_VERSION } from '../../types/worktreeRegistry.ts';\nimport type { WorktreeGit, WorktreeRecord } from '../../types/worktreeRegistry.ts';\nimport { planPrune, reconcile, refuseClose, refuseSpawn, worktreeDirectory } from '../../services/worktreeNaming.ts';\nimport { DoomGitExpectedError } from '../../services/support/errors.ts';\n\nexport interface WorktreeContext {\n /** Where the calling session is working, used to find the repository. */\n cwd: string;\n /** The calling session, recorded as the new session's parent. */\n sessionId: string;\n}\n\nexport interface SpawnWorktreeRequest {\n branch: string;\n baseRef?: string;\n name?: string;\n}\n\nexport interface SpawnOptions {\n /** Aborted when the caller gives up, so a spawn nobody is waiting for stops. */\n signal?: AbortSignal;\n /** Phase labels, for a caller that can show them while the work runs. */\n onProgress?: (label: string) => void;\n}\n\nexport interface WorktreeOperations {\n spawn(context: WorktreeContext, request: SpawnWorktreeRequest, options?: SpawnOptions): Promise<WorktreeRecord>;\n close(context: WorktreeContext, id: string, force: boolean): Promise<WorktreeRecord>;\n list(context: WorktreeContext): Promise<WorktreeRecord[]>;\n status(context: WorktreeContext, id: string): Promise<{ record: WorktreeRecord; dirtyFiles: string[] }>;\n merge(context: WorktreeContext, id: string, message?: string): Promise<WorktreeRecord>;\n prune(context: WorktreeContext, dryRun: boolean): Promise<ReturnType<typeof planPrune>>;\n send(context: WorktreeContext, id: string, message: string): Promise<void>;\n messages(context: WorktreeContext, id: string): Promise<ChannelMessage[]>;\n}\n\nexport interface WorktreeOperationsDeps {\n git: WorktreeGit;\n /** Injected so tests never reach the network. */\n createSession?: typeof createWorktreeSession;\n stopSession?: typeof stopWorktreeSession;\n /** Injected so a test never copies a real dependency tree. */\n mirror?: typeof mirrorComposition;\n isSessionLive?: typeof sessionIsLive;\n homeDir?: string;\n registryDir?: string;\n /** Injected so a record's createdAt is reproducible in a test. */\n now?: () => Date;\n}\n\nexport function createWorktreeOperations(deps: WorktreeOperationsDeps): WorktreeOperations {\n const { git } = deps;\n const createSession = deps.createSession ?? createWorktreeSession;\n const stopSession = deps.stopSession ?? stopWorktreeSession;\n const mirror = deps.mirror ?? mirrorComposition;\n const isSessionLive = deps.isSessionLive ?? sessionIsLive;\n const registryDir = deps.registryDir ?? hubRegistryDir();\n const now = deps.now ?? (() => new Date());\n const probe = {\n alive: (record: WorktreeRecord) => isSessionLive(registryDir, record.sessionId),\n exists: (path: string) => fs.existsSync(path),\n };\n\n /**\n * Everything an action needs about the repository it is acting on.\n *\n * Resolved per call rather than cached: a session's cwd is stable, but the\n * registry file is shared with the cockpit panel and another process may\n * have written it since the last call.\n */\n const resolve = async (context: WorktreeContext) => {\n const root = await git.repositoryRoot(context.cwd);\n if (root === undefined) {\n throw new DoomGitExpectedError(\n 'not_a_repository',\n `${context.cwd} is not inside a git repository.`,\n false,\n 'Run this from a repository checkout.',\n );\n }\n const store = createWorktreeRegistry(registryFile(root, deps.homeDir));\n return { root, store, records: store.list() };\n };\n\n const require = (records: readonly WorktreeRecord[], id: string): WorktreeRecord => {\n const record = records.find((entry) => entry.id === id);\n if (record === undefined) {\n throw new DoomGitExpectedError(\n 'worktree_not_found',\n `No worktree with id ${id}.`,\n false,\n 'Call list to see the current ids.',\n );\n }\n return record;\n };\n\n /**\n * Refuses to destroy or merge a worktree another live session is using.\n *\n * `parentSessionId` records who asked for the worktree. Two sessions in one\n * checkout share this registry, so without the check either could close the\n * other's work in progress by id.\n *\n * Once that session is gone there is no owner left to protect, and refusing\n * would strand the worktree: nothing else could ever close it.\n */\n const requireOwner = (context: WorktreeContext, record: WorktreeRecord, action: string): void => {\n if (record.parentSessionId === context.sessionId) return;\n if (!isSessionLive(registryDir, record.parentSessionId)) return;\n throw new DoomGitExpectedError(\n 'worktree_not_owned',\n `Worktree ${record.id} belongs to another session.`,\n false,\n `Ask the session that created it to ${action} it, or close that session first.`,\n );\n };\n\n return {\n async spawn(context, request, options) {\n const { root, store, records } = await resolve(context);\n const refusal = refuseSpawn({ branch: request.branch, existing: records });\n if (refusal !== undefined) {\n throw new DoomGitExpectedError('worktree_exists', refusal, false, 'Pick another branch name, or close it.');\n }\n const baseRef = request.baseRef ?? (await git.currentBranch(root)) ?? 'HEAD';\n const id = shortId(randomUUID());\n const path = worktreeDirectory({\n worktreesRoot: worktreesRoot(deps.homeDir),\n repositoryLabel: repositoryLabel(root),\n repositoryId: repositoryId(root),\n branch: request.branch,\n shortId: id,\n });\n\n // The worktree and the branch are made by one command, so they are undone\n // by one too. `worktree remove` leaves the branch behind, and a branch\n // nobody asked for is what a failed spawn used to leave on the floor.\n const cancelled = (): boolean => options?.signal?.aborted === true;\n const rollback = async (): Promise<string> => {\n await git.removeWorktree({ repositoryRoot: root, path, force: true }).catch(() => undefined);\n const deleted = await git.deleteBranch({ repositoryRoot: root, branch: request.branch }).catch(() => false);\n return deleted ? '' : ` The branch ${request.branch} has work on it and was kept.`;\n };\n\n options?.onProgress?.(`creating branch ${request.branch}\\u2026`);\n await git.addWorktree({ repositoryRoot: root, path, branch: request.branch, baseRef });\n\n // Checked here rather than only inside the session call: this is the\n // point where a checkout exists that nothing has recorded yet, which is\n // exactly the state an interrupted spawn used to leave behind.\n if (cancelled()) {\n const kept = await rollback();\n throw new DoomGitExpectedError(\n 'spawn_cancelled',\n `Cancelled before the session started.${kept}`,\n false,\n 'The worktree was removed; run it again when you are ready.',\n );\n }\n\n // Before the session, because the session composes the extensions this\n // repository's config names and those live in build output git does not\n // track. A worktree without it starts and dies on the first package it\n // cannot resolve. Nothing here can fail the spawn: a repository with no\n // build output to mirror simply has none.\n options?.onProgress?.('mirroring build output\\u2026');\n mirror(root, path);\n\n // The worktree exists from here on, so every later failure has to leave\n // it removed or recorded. An unrecorded directory on disk is the one\n // outcome with no way back: nothing would ever list it again.\n options?.onProgress?.('starting session\\u2026');\n let sessionId: string;\n try {\n sessionId = await createSession({\n cwd: path,\n name: request.name ?? request.branch,\n parentSessionId: context.sessionId,\n registryDir,\n ...(options?.signal === undefined ? {} : { signal: options.signal }),\n });\n } catch (error) {\n const kept = await rollback();\n if (cancelled()) {\n throw new DoomGitExpectedError(\n 'spawn_cancelled',\n `Cancelled while the session was starting.${kept}`,\n false,\n 'The worktree was removed; run it again when you are ready.',\n );\n }\n if (error instanceof HubUnavailableError) {\n throw new DoomGitExpectedError(\n 'hub_unavailable',\n `${error.message}${kept}`,\n true,\n 'Start the cockpit and try again.',\n );\n }\n throw error;\n }\n\n const record: WorktreeRecord = {\n version: WORKTREE_RECORD_VERSION,\n id,\n branch: request.branch,\n baseRef,\n path,\n repositoryRoot: root,\n sessionId,\n parentSessionId: context.sessionId,\n status: 'running',\n createdAt: now().toISOString(),\n };\n try {\n store.replace([...records, record]);\n } catch (error) {\n // A live session with no record is the worst outcome available here:\n // it runs, and no id anything can name points at it. The session goes\n // back too, rather than being left for someone to find by hand.\n await stopSession(registryDir, sessionId).catch(() => undefined);\n const kept = await rollback();\n throw new DoomGitExpectedError(\n 'registry_write_failed',\n `The worktree was created but the registry could not be written (${(error as Error).message}).${kept}`,\n true,\n 'Check the registry file for permissions or free space, then try again.',\n );\n }\n return record;\n },\n\n async close(context, id, force) {\n const { root, store, records } = await resolve(context);\n const record = require(records, id);\n requireOwner(context, record, 'close');\n const dirtyFiles = fs.existsSync(record.path) ? await git.dirtyFiles(record.path) : [];\n const refusal = refuseClose({ record, dirtyFiles, force });\n if (refusal !== undefined) {\n throw new DoomGitExpectedError('worktree_dirty', refusal, false, 'Commit the work, or pass force: true.');\n }\n // The session is stopped before the directory goes. Removing a checkout\n // while a process still holds files open in it is how a half-removed\n // worktree and a stale git administrative entry are made.\n await stopSession(registryDir, record.sessionId);\n await git.removeWorktree({ repositoryRoot: root, path: record.path, force });\n store.replace(records.filter((entry) => entry.id !== id));\n return record;\n },\n\n async list(context) {\n const { store, records } = await resolve(context);\n const outcome = reconcile(records, probe);\n if (outcome.changed.length > 0) store.replace(outcome.records);\n return outcome.records;\n },\n\n async status(context, id) {\n const { records } = await resolve(context);\n const record = require(records, id);\n const dirtyFiles = fs.existsSync(record.path) ? await git.dirtyFiles(record.path) : [];\n return { record, dirtyFiles };\n },\n\n async merge(context, id, message) {\n const { root, records } = await resolve(context);\n const record = require(records, id);\n requireOwner(context, record, 'merge');\n // The merge lands in the parent, so the parent is what must be clean. A\n // dirty parent would mix the person's in-flight edits into a merge commit\n // they did not intend to make.\n const parentDirty = await git.dirtyFiles(root);\n if (parentDirty.length > 0) {\n throw new DoomGitExpectedError(\n 'worktree_dirty',\n `The parent checkout has ${String(parentDirty.length)} uncommitted file(s): ${parentDirty.slice(0, 10).join(', ')}.`,\n false,\n 'Commit or stash the parent checkout first.',\n );\n }\n await git.mergeBranch({\n repositoryRoot: root,\n branch: record.branch,\n ...(message === undefined ? {} : { message }),\n });\n return record;\n },\n\n /**\n * Which side of the channel the caller is.\n *\n * A worktree session is the child of the record it belongs to, and the\n * parent for everything else. Deciding from the session id rather than a\n * flag means neither side can address itself by mistake.\n */\n async send(context, id, message) {\n const { records } = await resolve(context);\n const record = require(records, id);\n const party: ChannelParty = context.sessionId === record.sessionId ? 'parent' : 'child';\n createWorktreeChannel(channelRoot(record.id, deps.homeDir)).send(party, message);\n },\n\n async messages(context, id) {\n const { records } = await resolve(context);\n const record = require(records, id);\n const channel = createWorktreeChannel(channelRoot(record.id, deps.homeDir));\n channel.sweep();\n const party: ChannelParty = context.sessionId === record.sessionId ? 'child' : 'parent';\n return channel.receive(party);\n },\n\n async prune(context, dryRun) {\n const { root, store, records } = await resolve(context);\n const reconciled = reconcile(records, probe);\n const gitPaths = await git.listWorktreePaths(root);\n const dirtyByPath = new Map<string, readonly string[]>();\n for (const record of reconciled.records) {\n if (record.status === 'orphaned' && fs.existsSync(record.path)) {\n dirtyByPath.set(record.path, await git.dirtyFiles(record.path));\n }\n }\n const plan = planPrune({\n records: reconciled.records,\n gitPaths,\n worktreesRoot: worktreesRoot(deps.homeDir),\n dirtyByPath,\n });\n if (dryRun) {\n store.replace(reconciled.records);\n return plan;\n }\n for (const record of plan.remove) {\n await git.removeWorktree({ repositoryRoot: root, path: record.path, force: false });\n }\n // The checkout goes, so the branch it was made for goes with it. Safe\n // delete only: git keeps anything holding commits, and the plan says\n // which ones it kept rather than leaving the reader to notice later.\n for (const record of [...plan.remove, ...plan.forget]) {\n const deleted = await git.deleteBranch({ repositoryRoot: root, branch: record.branch }).catch(() => false);\n if (!deleted) plan.keptBranches.push(record.branch);\n }\n const dropped = new Set([...plan.remove, ...plan.forget].map((record) => record.id));\n store.replace(reconciled.records.filter((record) => !dropped.has(record.id)));\n return plan;\n },\n };\n}\n"],"mappings":"6xBA2DA,SAAgB,EAAyB,EAAkD,CACzF,GAAM,CAAE,OAAQ,EACV,EAAgB,EAAK,eAAiB,EACtC,EAAc,EAAK,aAAe,EAClC,EAAS,EAAK,QAAU,EACxB,EAAgB,EAAK,eAAiB,EACtC,EAAc,EAAK,aAAe,EAAe,EACjD,EAAM,EAAK,UAAc,IAAI,MAC7B,EAAQ,CACZ,MAAQ,GAA2B,EAAc,EAAa,EAAO,SAAS,EAC9E,OAAS,GAAiB,EAAG,WAAW,CAAI,CAC9C,EASM,EAAU,KAAO,IAA6B,CAClD,IAAM,EAAO,MA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AAM,QAAQ,EAAW,OAAO,EACzB,EAET,IAAK,IAAM,KAAU,EAAK,OACxB,MAAM,EAAI,eAAe,CAAE,eAAgB,EAAM,KAAM,EAAO,KAAM,MAAO,EAAM,CAAC,EAKpF,IAAK,IAAM,IAAU,CAAC,GAAG,EAAK,OAAQ,GAAG,EAAK,MAAM,EAE7C,MADiB,EAAI,aAAa,CAAE,eAAgB,EAAM,OAAQ,EAAO,MAAO,CAAC,CAAC,CAAC,UAAY,EAAK,GAC3F,EAAK,aAAa,KAAK,EAAO,MAAM,EAEpD,IAAM,EAAU,IAAI,IAAI,CAAC,GAAG,EAAK,OAAQ,GAAG,EAAK,MAAM,CAAC,CAAC,IAAK,GAAW,EAAO,EAAE,CAAC,EAEnF,OADA,EAAM,QAAQ,EAAW,QAAQ,OAAQ,GAAW,CAAC,EAAQ,IAAI,EAAO,EAAE,CAAC,CAAC,EACrE,CACT,CACF,CACF"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const e=require("../filesystem/atomicJson.cjs");function t(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.version===1&&typeof t.id==`string`&&t.id!==``&&typeof t.path==`string`&&typeof t.branch==`string`&&typeof t.sessionId==`string`}function n(n){return{list(){let r=e.readJson(n);return!r||r.version!==1||!Array.isArray(r.entries)?[]:r.entries.filter(t)},replace(t){e.writeJsonAtomic(n,{version:1,entries:t})}}}exports.createWorktreeRegistry=n;
|
|
2
|
-
//# sourceMappingURL=worktreeRegistry.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"worktreeRegistry.cjs","names":["readJson"],"sources":["../../../src/adapters/worktree/worktreeRegistry.ts"],"sourcesContent":["import { readJson, writeJsonAtomic } from '../filesystem/atomicJson.ts';\nimport {\n WORKTREE_RECORD_VERSION,\n type WorktreeRecord,\n type WorktreeRegistryFile,\n type WorktreeRegistryStore,\n} from '../../types/worktreeRegistry.ts';\n\nfunction isRecord(value: unknown): value is WorktreeRecord {\n if (typeof value !== 'object' || value === null) return false;\n const record = value as Partial<WorktreeRecord>;\n return (\n record.version === WORKTREE_RECORD_VERSION &&\n typeof record.id === 'string' &&\n record.id !== '' &&\n typeof record.path === 'string' &&\n typeof record.branch === 'string' &&\n typeof record.sessionId === 'string'\n );\n}\n\n/**\n * The worktree registry for one repository, as a single JSON file.\n *\n * One file rather than a file per worktree, and read-modify-write rather than\n * merging: every write comes from a tool call in one session's turn, so there\n * is no concurrent writer to reconcile with. Choosing the simpler shape now\n * means a reader can see the whole registry in one place; if concurrent writers\n * ever appear, that is the point to revisit, not before.\n *\n * A file that does not parse is treated as empty rather than fatal. Losing\n * track of worktrees is recoverable through prune; refusing to run is not.\n */\nexport function createWorktreeRegistry(file: string): WorktreeRegistryStore {\n return {\n list() {\n const parsed = readJson<WorktreeRegistryFile>(file);\n if (!parsed || parsed.version !== WORKTREE_RECORD_VERSION || !Array.isArray(parsed.entries)) return [];\n return parsed.entries.filter(isRecord);\n },\n replace(entries) {\n writeJsonAtomic(file, { version: WORKTREE_RECORD_VERSION, entries } satisfies WorktreeRegistryFile);\n },\n };\n}\n"],"mappings":"gDAQA,SAAS,EAAS,EAAyC,CACzD,GAAI,OAAO,GAAU,WAAY,EAAgB,MAAO,GACxD,IAAM,EAAS,EACf,OACE,EAAO,UAAA,GACP,OAAO,EAAO,IAAO,UACrB,EAAO,KAAO,IACd,OAAO,EAAO,MAAS,UACvB,OAAO,EAAO,QAAW,UACzB,OAAO,EAAO,WAAc,QAEhC,CAcA,SAAgB,EAAuB,EAAqC,CAC1E,MAAO,CACL,MAAO,CACL,IAAM,EAASA,EAAAA,SAA+B,CAAI,EAElD,MADI,CAAC,GAAU,EAAO,UAAA,GAAuC,CAAC,MAAM,QAAQ,EAAO,OAAO,EAAU,CAAC,EAC9F,EAAO,QAAQ,OAAO,CAAQ,CACvC,EACA,QAAQ,EAAS,CACf,EAAA,gBAAgB,EAAM,CAAE,QAAA,EAAkC,SAAQ,CAAgC,CACpG,CACF,CACF"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{readJson as e,writeJsonAtomic as t}from"../filesystem/atomicJson.mjs";function n(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.version===1&&typeof t.id==`string`&&t.id!==``&&typeof t.path==`string`&&typeof t.branch==`string`&&typeof t.sessionId==`string`}function r(r){return{list(){let t=e(r);return!t||t.version!==1||!Array.isArray(t.entries)?[]:t.entries.filter(n)},replace(e){t(r,{version:1,entries:e})}}}export{r as createWorktreeRegistry};
|
|
2
|
-
//# sourceMappingURL=worktreeRegistry.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"worktreeRegistry.mjs","names":[],"sources":["../../../src/adapters/worktree/worktreeRegistry.ts"],"sourcesContent":["import { readJson, writeJsonAtomic } from '../filesystem/atomicJson.ts';\nimport {\n WORKTREE_RECORD_VERSION,\n type WorktreeRecord,\n type WorktreeRegistryFile,\n type WorktreeRegistryStore,\n} from '../../types/worktreeRegistry.ts';\n\nfunction isRecord(value: unknown): value is WorktreeRecord {\n if (typeof value !== 'object' || value === null) return false;\n const record = value as Partial<WorktreeRecord>;\n return (\n record.version === WORKTREE_RECORD_VERSION &&\n typeof record.id === 'string' &&\n record.id !== '' &&\n typeof record.path === 'string' &&\n typeof record.branch === 'string' &&\n typeof record.sessionId === 'string'\n );\n}\n\n/**\n * The worktree registry for one repository, as a single JSON file.\n *\n * One file rather than a file per worktree, and read-modify-write rather than\n * merging: every write comes from a tool call in one session's turn, so there\n * is no concurrent writer to reconcile with. Choosing the simpler shape now\n * means a reader can see the whole registry in one place; if concurrent writers\n * ever appear, that is the point to revisit, not before.\n *\n * A file that does not parse is treated as empty rather than fatal. Losing\n * track of worktrees is recoverable through prune; refusing to run is not.\n */\nexport function createWorktreeRegistry(file: string): WorktreeRegistryStore {\n return {\n list() {\n const parsed = readJson<WorktreeRegistryFile>(file);\n if (!parsed || parsed.version !== WORKTREE_RECORD_VERSION || !Array.isArray(parsed.entries)) return [];\n return parsed.entries.filter(isRecord);\n },\n replace(entries) {\n writeJsonAtomic(file, { version: WORKTREE_RECORD_VERSION, entries } satisfies WorktreeRegistryFile);\n },\n };\n}\n"],"mappings":"6EAQA,SAAS,EAAS,EAAyC,CACzD,GAAI,OAAO,GAAU,WAAY,EAAgB,MAAO,GACxD,IAAM,EAAS,EACf,OACE,EAAO,UAAA,GACP,OAAO,EAAO,IAAO,UACrB,EAAO,KAAO,IACd,OAAO,EAAO,MAAS,UACvB,OAAO,EAAO,QAAW,UACzB,OAAO,EAAO,WAAc,QAEhC,CAcA,SAAgB,EAAuB,EAAqC,CAC1E,MAAO,CACL,MAAO,CACL,IAAM,EAAS,EAA+B,CAAI,EAElD,MADI,CAAC,GAAU,EAAO,UAAA,GAAuC,CAAC,MAAM,QAAQ,EAAO,OAAO,EAAU,CAAC,EAC9F,EAAO,QAAQ,OAAO,CAAQ,CACvC,EACA,QAAQ,EAAS,CACf,EAAgB,EAAM,CAAE,QAAA,EAAkC,SAAQ,CAAgC,CACpG,CACF,CACF"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const e=`doom-git`,t=`Show git worktrees owned by this session`;function n(n,r){n.registerCommand(e,{description:t,handler:async(e,t)=>{let n=await r.execute();t.hasUI&&t.ui.notify(n.message,n.level)}})}exports.COMMAND_DESCRIPTION=t,exports.COMMAND_NAME=e,exports.registerGitCommand=n;
|
|
2
|
-
//# sourceMappingURL=doomGitCommand.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"doomGitCommand.cjs","names":[],"sources":["../../src/commands/doomGitCommand.ts"],"sourcesContent":["// @scaffold-generated\nimport type { ExtensionAPI } from '@earendil-works/pi-coding-agent';\nimport type { GitExtensionService } from '../types/extension.ts';\n\nexport const COMMAND_NAME = 'doom-git';\nexport const COMMAND_DESCRIPTION = 'Show git worktrees owned by this session';\n\nexport function registerGitCommand(pi: Pick<ExtensionAPI, 'registerCommand'>, service: GitExtensionService): void {\n pi.registerCommand(COMMAND_NAME, {\n description: COMMAND_DESCRIPTION,\n handler: async (_args, ctx) => {\n const result = await service.execute();\n if (ctx.hasUI) ctx.ui.notify(result.message, result.level);\n },\n });\n}\n"],"mappings":"AAIA,MAAa,EAAe,WACf,EAAsB,2CAEnC,SAAgB,EAAmB,EAA2C,EAAoC,CAChH,EAAG,gBAAgB,EAAc,CAC/B,YAAa,EACb,QAAS,MAAO,EAAO,IAAQ,CAC7B,IAAM,EAAS,MAAM,EAAQ,QAAQ,EACjC,EAAI,OAAO,EAAI,GAAG,OAAO,EAAO,QAAS,EAAO,KAAK,CAC3D,CACF,CAAC,CACH"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const e=`doom-git`,t=`Show git worktrees owned by this session`;function n(n,r){n.registerCommand(e,{description:t,handler:async(e,t)=>{let n=await r.execute();t.hasUI&&t.ui.notify(n.message,n.level)}})}export{t as COMMAND_DESCRIPTION,e as COMMAND_NAME,n as registerGitCommand};
|
|
2
|
-
//# sourceMappingURL=doomGitCommand.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"doomGitCommand.mjs","names":[],"sources":["../../src/commands/doomGitCommand.ts"],"sourcesContent":["// @scaffold-generated\nimport type { ExtensionAPI } from '@earendil-works/pi-coding-agent';\nimport type { GitExtensionService } from '../types/extension.ts';\n\nexport const COMMAND_NAME = 'doom-git';\nexport const COMMAND_DESCRIPTION = 'Show git worktrees owned by this session';\n\nexport function registerGitCommand(pi: Pick<ExtensionAPI, 'registerCommand'>, service: GitExtensionService): void {\n pi.registerCommand(COMMAND_NAME, {\n description: COMMAND_DESCRIPTION,\n handler: async (_args, ctx) => {\n const result = await service.execute();\n if (ctx.hasUI) ctx.ui.notify(result.message, result.level);\n },\n });\n}\n"],"mappings":"AAIA,MAAa,EAAe,WACf,EAAsB,2CAEnC,SAAgB,EAAmB,EAA2C,EAAoC,CAChH,EAAG,gBAAgB,EAAc,CAC/B,YAAa,EACb,QAAS,MAAO,EAAO,IAAQ,CAC7B,IAAM,EAAS,MAAM,EAAQ,QAAQ,EACjC,EAAI,OAAO,EAAI,GAAG,OAAO,EAAO,QAAS,EAAO,KAAK,CAC3D,CACF,CAAC,CACH"}
|
package/dist/container/index.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const e=require("../adapters/worktree/gitCli.cjs"),t=require("../adapters/worktree/worktreeOperations.cjs"),n=require("../services/extensionService.cjs");function r(r={}){return{service:r.service??new n.DefaultGitExtensionService,operations:r.operations??t.createWorktreeOperations({git:e.createWorktreeGit()})}}exports.createGitContainer=r;
|
|
2
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["DefaultGitExtensionService","createWorktreeOperations","createWorktreeGit"],"sources":["../../src/container/index.ts"],"sourcesContent":["// @scaffold-generated\nimport { createWorktreeGit } from '../adapters/worktree/gitCli.ts';\nimport { DefaultGitExtensionService } from '../services/extensionService.ts';\nimport { createWorktreeOperations } from '../adapters/worktree/worktreeOperations.ts';\nimport type { GitExtensionDependencies } from '../types/extension.ts';\n\nexport function createGitContainer(overrides: Partial<GitExtensionDependencies> = {}): GitExtensionDependencies {\n return {\n service: overrides.service ?? new DefaultGitExtensionService(),\n operations: overrides.operations ?? createWorktreeOperations({ git: createWorktreeGit() }),\n };\n}\n"],"mappings":"0JAMA,SAAgB,EAAmB,EAA+C,CAAC,EAA6B,CAC9G,MAAO,CACL,QAAS,EAAU,SAAW,IAAIA,EAAAA,2BAClC,WAAY,EAAU,YAAcC,EAAAA,yBAAyB,CAAE,IAAKC,EAAAA,kBAAkB,CAAE,CAAC,CAC3F,CACF"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { GitExtensionDependencies } from "../types/extension.cjs";
|
|
2
|
-
//#region src/container/index.d.ts
|
|
3
|
-
declare function createGitContainer(overrides?: Partial<GitExtensionDependencies>): GitExtensionDependencies;
|
|
4
|
-
//#endregion
|
|
5
|
-
export { createGitContainer };
|
|
6
|
-
//# sourceMappingURL=index.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/container/index.ts"],"mappings":";;iBAMgB,mBAAmB,YAAW,QAAQ,4BAAiC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { GitExtensionDependencies } from "../types/extension.mjs";
|
|
2
|
-
//#region src/container/index.d.ts
|
|
3
|
-
declare function createGitContainer(overrides?: Partial<GitExtensionDependencies>): GitExtensionDependencies;
|
|
4
|
-
//#endregion
|
|
5
|
-
export { createGitContainer };
|
|
6
|
-
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/container/index.ts"],"mappings":";;iBAMgB,mBAAmB,YAAW,QAAQ,4BAAiC"}
|
package/dist/container/index.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{createWorktreeGit as e}from"../adapters/worktree/gitCli.mjs";import{createWorktreeOperations as t}from"../adapters/worktree/worktreeOperations.mjs";import{DefaultGitExtensionService as n}from"../services/extensionService.mjs";function r(r={}){return{service:r.service??new n,operations:r.operations??t({git:e()})}}export{r as createGitContainer};
|
|
2
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/container/index.ts"],"sourcesContent":["// @scaffold-generated\nimport { createWorktreeGit } from '../adapters/worktree/gitCli.ts';\nimport { DefaultGitExtensionService } from '../services/extensionService.ts';\nimport { createWorktreeOperations } from '../adapters/worktree/worktreeOperations.ts';\nimport type { GitExtensionDependencies } from '../types/extension.ts';\n\nexport function createGitContainer(overrides: Partial<GitExtensionDependencies> = {}): GitExtensionDependencies {\n return {\n service: overrides.service ?? new DefaultGitExtensionService(),\n operations: overrides.operations ?? createWorktreeOperations({ git: createWorktreeGit() }),\n };\n}\n"],"mappings":"yOAMA,SAAgB,EAAmB,EAA+C,CAAC,EAA6B,CAC9G,MAAO,CACL,QAAS,EAAU,SAAW,IAAI,EAClC,WAAY,EAAU,YAAc,EAAyB,CAAE,IAAK,EAAkB,CAAE,CAAC,CAC3F,CACF"}
|
package/dist/hubApi.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./adapters/worktree/gitCli.cjs"),t=require("./services/support/errors.cjs"),n=require("./adapters/worktree/worktreeOperations.cjs");function r(e){return Response.json({error:e},{status:400})}function i(e){return e instanceof t.DoomGitExpectedError?Response.json({error:e.message,code:e.code},{status:e.retryable?503:409}):Response.json({error:`The worktree operation failed.`},{status:500})}const a={basePath:`git`,start(t){let a=n.createWorktreeOperations({git:e.createWorktreeGit()}),o=e=>{let n=e.searchParams.get(`repositoryId`);if(n===null||n===``)return r(`A repositoryId is required.`);let i=t.resolveRepository?.(n);return i===void 0?r(`That repository is not admitted to this cockpit.`):i};return{async fetch(e){let n=new URL(e.url),s=o(n);if(s instanceof Response)return s;let c={cwd:s,sessionId:n.searchParams.get(`sessionId`)??``};try{if(e.method===`GET`&&n.pathname===`/worktrees`)return Response.json({worktrees:await a.list(c)});if(e.method===`POST`&&n.pathname===`/worktrees`){let t=await e.json();if(typeof t.branch!=`string`||t.branch.trim()===``)return r(`A branch is required.`);let n=await a.spawn(c,{branch:t.branch,...t.baseRef===void 0?{}:{baseRef:t.baseRef},...t.name===void 0?{}:{name:t.name}});return Response.json({worktree:n},{status:201})}let t=/^\/worktrees\/([^/]+)$/u.exec(n.pathname);if(e.method===`DELETE`&&t){let e=await a.close(c,decodeURIComponent(String(t[1])),n.searchParams.get(`force`)===`true`);return Response.json({worktree:e})}return Response.json({error:`No such worktree route.`},{status:404})}catch(e){return t.onNotice(`worktree request failed: ${e.name}`),i(e)}},close(){}}}};exports.api=a;
|
|
2
|
-
//# sourceMappingURL=hubApi.cjs.map
|
package/dist/hubApi.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hubApi.cjs","names":["DoomGitExpectedError","createWorktreeOperations","createWorktreeGit"],"sources":["../src/exports/hubApi.ts"],"sourcesContent":["import type { DoomApi, DoomApiContext, DoomApiHandler } from '@agimon-ai/doompi-extension-contracts/package-api';\nimport { createWorktreeGit } from '../adapters/worktree/gitCli.ts';\nimport { createWorktreeOperations } from '../adapters/worktree/worktreeOperations.ts';\nimport { DoomGitExpectedError } from '../services/support/errors.ts';\n\n/**\n * The worktree surface the cockpit panel calls.\n *\n * Hub-scoped because worktrees are a property of a repository, not of one\n * session: the panel lists and creates them whether or not the session that\n * made them is focused, and a session-scoped API would disappear with it.\n *\n * The panel names a repository by the hub's opaque id and never by path.\n * `resolveRepository` turns that into an admitted root, so a browser cannot\n * point this at a directory the cockpit was never given.\n */\nfunction badRequest(message: string): Response {\n return Response.json({ error: message }, { status: 400 });\n}\n\nfunction failed(error: unknown): Response {\n if (error instanceof DoomGitExpectedError) {\n return Response.json({ error: error.message, code: error.code }, { status: error.retryable ? 503 : 409 });\n }\n // Never the raw message: a git failure can carry a remote URL with a token.\n return Response.json({ error: 'The worktree operation failed.' }, { status: 500 });\n}\n\nexport const api: DoomApi = {\n basePath: 'git',\n start(context: DoomApiContext): DoomApiHandler {\n const operations = createWorktreeOperations({ git: createWorktreeGit() });\n\n /** The admitted root for a request, or a response explaining why not. */\n const rootOf = (url: URL): string | Response => {\n const repositoryId = url.searchParams.get('repositoryId');\n if (repositoryId === null || repositoryId === '') return badRequest('A repositoryId is required.');\n const root = context.resolveRepository?.(repositoryId);\n if (root === undefined) return badRequest('That repository is not admitted to this cockpit.');\n return root;\n };\n\n return {\n async fetch(request) {\n const url = new URL(request.url);\n const root = rootOf(url);\n if (root instanceof Response) return root;\n // The operations layer works from a cwd, and an admitted repository\n // root is one.\n const callerContext = { cwd: root, sessionId: url.searchParams.get('sessionId') ?? '' };\n\n try {\n if (request.method === 'GET' && url.pathname === '/worktrees') {\n return Response.json({ worktrees: await operations.list(callerContext) });\n }\n if (request.method === 'POST' && url.pathname === '/worktrees') {\n const body = (await request.json()) as { branch?: string; baseRef?: string; name?: string };\n if (typeof body.branch !== 'string' || body.branch.trim() === '') {\n return badRequest('A branch is required.');\n }\n const record = await operations.spawn(callerContext, {\n branch: body.branch,\n ...(body.baseRef === undefined ? {} : { baseRef: body.baseRef }),\n ...(body.name === undefined ? {} : { name: body.name }),\n });\n return Response.json({ worktree: record }, { status: 201 });\n }\n const closing = /^\\/worktrees\\/([^/]+)$/u.exec(url.pathname);\n if (request.method === 'DELETE' && closing) {\n const record = await operations.close(\n callerContext,\n decodeURIComponent(String(closing[1])),\n url.searchParams.get('force') === 'true',\n );\n return Response.json({ worktree: record });\n }\n return Response.json({ error: 'No such worktree route.' }, { status: 404 });\n } catch (error) {\n context.onNotice(`worktree request failed: ${(error as Error).name}`);\n return failed(error);\n }\n },\n close() {},\n };\n },\n};\n"],"mappings":"wNAgBA,SAAS,EAAW,EAA2B,CAC7C,OAAO,SAAS,KAAK,CAAE,MAAO,CAAQ,EAAG,CAAE,OAAQ,GAAI,CAAC,CAC1D,CAEA,SAAS,EAAO,EAA0B,CAKxC,OAJI,aAAiBA,EAAAA,qBACZ,SAAS,KAAK,CAAE,MAAO,EAAM,QAAS,KAAM,EAAM,IAAK,EAAG,CAAE,OAAQ,EAAM,UAAY,IAAM,GAAI,CAAC,EAGnG,SAAS,KAAK,CAAE,MAAO,gCAAiC,EAAG,CAAE,OAAQ,GAAI,CAAC,CACnF,CAEA,MAAa,EAAe,CAC1B,SAAU,MACV,MAAM,EAAyC,CAC7C,IAAM,EAAaC,EAAAA,yBAAyB,CAAE,IAAKC,EAAAA,kBAAkB,CAAE,CAAC,EAGlE,EAAU,GAAgC,CAC9C,IAAM,EAAe,EAAI,aAAa,IAAI,cAAc,EACxD,GAAI,IAAiB,MAAQ,IAAiB,GAAI,OAAO,EAAW,6BAA6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AQ,GAAI,CAAC,CAC5E,OAAS,EAAO,CAEd,OADA,EAAQ,SAAS,4BAA6B,EAAgB,MAAM,EAC7D,EAAO,CAAK,CACrB,CACF,EACA,OAAQ,CAAC,CACX,CACF,CACF"}
|
package/dist/hubApi.d.cts
DELETED
package/dist/hubApi.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hubApi.d.cts","names":[],"sources":["../src/exports/hubApi.ts"],"mappings":";;cA4Ba,KAAK"}
|
package/dist/hubApi.d.mts
DELETED
package/dist/hubApi.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hubApi.d.mts","names":[],"sources":["../src/exports/hubApi.ts"],"mappings":";;cA4Ba,KAAK"}
|
package/dist/hubApi.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{createWorktreeGit as e}from"./adapters/worktree/gitCli.mjs";import{DoomGitExpectedError as t}from"./services/support/errors.mjs";import{createWorktreeOperations as n}from"./adapters/worktree/worktreeOperations.mjs";function r(e){return Response.json({error:e},{status:400})}function i(e){return e instanceof t?Response.json({error:e.message,code:e.code},{status:e.retryable?503:409}):Response.json({error:`The worktree operation failed.`},{status:500})}const a={basePath:`git`,start(t){let a=n({git:e()}),o=e=>{let n=e.searchParams.get(`repositoryId`);if(n===null||n===``)return r(`A repositoryId is required.`);let i=t.resolveRepository?.(n);return i===void 0?r(`That repository is not admitted to this cockpit.`):i};return{async fetch(e){let n=new URL(e.url),s=o(n);if(s instanceof Response)return s;let c={cwd:s,sessionId:n.searchParams.get(`sessionId`)??``};try{if(e.method===`GET`&&n.pathname===`/worktrees`)return Response.json({worktrees:await a.list(c)});if(e.method===`POST`&&n.pathname===`/worktrees`){let t=await e.json();if(typeof t.branch!=`string`||t.branch.trim()===``)return r(`A branch is required.`);let n=await a.spawn(c,{branch:t.branch,...t.baseRef===void 0?{}:{baseRef:t.baseRef},...t.name===void 0?{}:{name:t.name}});return Response.json({worktree:n},{status:201})}let t=/^\/worktrees\/([^/]+)$/u.exec(n.pathname);if(e.method===`DELETE`&&t){let e=await a.close(c,decodeURIComponent(String(t[1])),n.searchParams.get(`force`)===`true`);return Response.json({worktree:e})}return Response.json({error:`No such worktree route.`},{status:404})}catch(e){return t.onNotice(`worktree request failed: ${e.name}`),i(e)}},close(){}}}};export{a as api};
|
|
2
|
-
//# sourceMappingURL=hubApi.mjs.map
|
package/dist/hubApi.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hubApi.mjs","names":[],"sources":["../src/exports/hubApi.ts"],"sourcesContent":["import type { DoomApi, DoomApiContext, DoomApiHandler } from '@agimon-ai/doompi-extension-contracts/package-api';\nimport { createWorktreeGit } from '../adapters/worktree/gitCli.ts';\nimport { createWorktreeOperations } from '../adapters/worktree/worktreeOperations.ts';\nimport { DoomGitExpectedError } from '../services/support/errors.ts';\n\n/**\n * The worktree surface the cockpit panel calls.\n *\n * Hub-scoped because worktrees are a property of a repository, not of one\n * session: the panel lists and creates them whether or not the session that\n * made them is focused, and a session-scoped API would disappear with it.\n *\n * The panel names a repository by the hub's opaque id and never by path.\n * `resolveRepository` turns that into an admitted root, so a browser cannot\n * point this at a directory the cockpit was never given.\n */\nfunction badRequest(message: string): Response {\n return Response.json({ error: message }, { status: 400 });\n}\n\nfunction failed(error: unknown): Response {\n if (error instanceof DoomGitExpectedError) {\n return Response.json({ error: error.message, code: error.code }, { status: error.retryable ? 503 : 409 });\n }\n // Never the raw message: a git failure can carry a remote URL with a token.\n return Response.json({ error: 'The worktree operation failed.' }, { status: 500 });\n}\n\nexport const api: DoomApi = {\n basePath: 'git',\n start(context: DoomApiContext): DoomApiHandler {\n const operations = createWorktreeOperations({ git: createWorktreeGit() });\n\n /** The admitted root for a request, or a response explaining why not. */\n const rootOf = (url: URL): string | Response => {\n const repositoryId = url.searchParams.get('repositoryId');\n if (repositoryId === null || repositoryId === '') return badRequest('A repositoryId is required.');\n const root = context.resolveRepository?.(repositoryId);\n if (root === undefined) return badRequest('That repository is not admitted to this cockpit.');\n return root;\n };\n\n return {\n async fetch(request) {\n const url = new URL(request.url);\n const root = rootOf(url);\n if (root instanceof Response) return root;\n // The operations layer works from a cwd, and an admitted repository\n // root is one.\n const callerContext = { cwd: root, sessionId: url.searchParams.get('sessionId') ?? '' };\n\n try {\n if (request.method === 'GET' && url.pathname === '/worktrees') {\n return Response.json({ worktrees: await operations.list(callerContext) });\n }\n if (request.method === 'POST' && url.pathname === '/worktrees') {\n const body = (await request.json()) as { branch?: string; baseRef?: string; name?: string };\n if (typeof body.branch !== 'string' || body.branch.trim() === '') {\n return badRequest('A branch is required.');\n }\n const record = await operations.spawn(callerContext, {\n branch: body.branch,\n ...(body.baseRef === undefined ? {} : { baseRef: body.baseRef }),\n ...(body.name === undefined ? {} : { name: body.name }),\n });\n return Response.json({ worktree: record }, { status: 201 });\n }\n const closing = /^\\/worktrees\\/([^/]+)$/u.exec(url.pathname);\n if (request.method === 'DELETE' && closing) {\n const record = await operations.close(\n callerContext,\n decodeURIComponent(String(closing[1])),\n url.searchParams.get('force') === 'true',\n );\n return Response.json({ worktree: record });\n }\n return Response.json({ error: 'No such worktree route.' }, { status: 404 });\n } catch (error) {\n context.onNotice(`worktree request failed: ${(error as Error).name}`);\n return failed(error);\n }\n },\n close() {},\n };\n },\n};\n"],"mappings":"8NAgBA,SAAS,EAAW,EAA2B,CAC7C,OAAO,SAAS,KAAK,CAAE,MAAO,CAAQ,EAAG,CAAE,OAAQ,GAAI,CAAC,CAC1D,CAEA,SAAS,EAAO,EAA0B,CAKxC,OAJI,aAAiB,EACZ,SAAS,KAAK,CAAE,MAAO,EAAM,QAAS,KAAM,EAAM,IAAK,EAAG,CAAE,OAAQ,EAAM,UAAY,IAAM,GAAI,CAAC,EAGnG,SAAS,KAAK,CAAE,MAAO,gCAAiC,EAAG,CAAE,OAAQ,GAAI,CAAC,CACnF,CAEA,MAAa,EAAe,CAC1B,SAAU,MACV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,EACA,mBAAmB,OAAO,EAAQ,EAAE,CAAC,EACrC,EAAI,aAAa,IAAI,OAAO,IAAM,MACpC,EACA,OAAO,SAAS,KAAK,CAAE,SAAU,CAAO,CAAC,CAC3C,CACA,OAAO,SAAS,KAAK,CAAE,MAAO,yBAA0B,EAAG,CAAE,OAAQ,GAAI,CAAC,CAC5E,OAAS,EAAO,CAEd,OADA,EAAQ,SAAS,4BAA6B,EAAgB,MAAM,EAC7D,EAAO,CAAK,CACrB,CACF,EACA,OAAQ,CAAC,CACX,CACF,CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extensionService.cjs","names":[],"sources":["../../src/services/extensionService.ts"],"sourcesContent":["// @scaffold-generated\nimport type { GitExtensionResult, GitExtensionService } from '../types/extension.ts';\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"],"mappings":"AAGA,IAAa,EAAb,KAAuE,CACrE,MAAM,SAAuC,CAC3C,MAAO,CAAE,QAAS,2CAA4C,MAAO,MAAO,CAC9E,CACF"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { GitExtensionResult, GitExtensionService } from "../types/extension.cjs";
|
|
2
|
-
//#region src/services/extensionService.d.ts
|
|
3
|
-
declare class DefaultGitExtensionService implements GitExtensionService {
|
|
4
|
-
execute(): Promise<GitExtensionResult>;
|
|
5
|
-
}
|
|
6
|
-
//#endregion
|
|
7
|
-
export { DefaultGitExtensionService };
|
|
8
|
-
//# sourceMappingURL=extensionService.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extensionService.d.cts","names":[],"sources":["../../src/services/extensionService.ts"],"mappings":";;cAGa,sCAAsC;EAC3C,WAAW,QAAQ"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { GitExtensionResult, GitExtensionService } from "../types/extension.mjs";
|
|
2
|
-
//#region src/services/extensionService.d.ts
|
|
3
|
-
declare class DefaultGitExtensionService implements GitExtensionService {
|
|
4
|
-
execute(): Promise<GitExtensionResult>;
|
|
5
|
-
}
|
|
6
|
-
//#endregion
|
|
7
|
-
export { DefaultGitExtensionService };
|
|
8
|
-
//# sourceMappingURL=extensionService.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extensionService.d.mts","names":[],"sources":["../../src/services/extensionService.ts"],"mappings":";;cAGa,sCAAsC;EAC3C,WAAW,QAAQ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extensionService.mjs","names":[],"sources":["../../src/services/extensionService.ts"],"sourcesContent":["// @scaffold-generated\nimport type { GitExtensionResult, GitExtensionService } from '../types/extension.ts';\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"],"mappings":"AAGA,IAAa,EAAb,KAAuE,CACrE,MAAM,SAAuC,CAC3C,MAAO,CAAE,QAAS,2CAA4C,MAAO,MAAO,CAC9E,CACF"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var e=class extends Error{code;retryable;recovery;constructor(e,t,n,r){super(`[${e}] ${t}\nRecovery: ${r}`),this.code=e,this.retryable=n,this.recovery=r,this.name=`DoomGitExpectedError`}};function t(t,n){return new e(`invalid_request`,t,!1,n)}exports.DoomGitExpectedError=e,exports.invalidRequest=t;
|
|
2
|
-
//# sourceMappingURL=errors.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.cjs","names":[],"sources":["../../../src/services/support/errors.ts"],"sourcesContent":["/**\n * Expected failures, kept private to this package.\n *\n * `@agimon-ai/doompi-extension-contracts` does not export `invalidRequest` or\n * an expected-error base, so this mirrors doompi-team's shape rather than\n * reaching across a layer boundary for it. The duplication is deliberate and\n * small; a shared helper would be the better answer only once a third package\n * needs one.\n */\n\nexport type DoomGitErrorCode =\n | 'invalid_request'\n | 'not_a_repository'\n | 'worktree_exists'\n | 'worktree_not_found'\n | 'worktree_not_owned'\n | 'worktree_dirty'\n | 'hub_unavailable'\n | 'spawn_cancelled'\n | 'registry_write_failed'\n | 'git_failed';\n\nexport class DoomGitExpectedError extends Error {\n constructor(\n readonly code: DoomGitErrorCode,\n message: string,\n readonly retryable: boolean,\n readonly recovery: string,\n ) {\n // The recovery line rides in the message because a tool result is read as\n // text: an error the model cannot act on costs a turn to rediscover.\n super(`[${code}] ${message}\\nRecovery: ${recovery}`);\n this.name = 'DoomGitExpectedError';\n }\n}\n\nexport function invalidRequest(message: string, recovery: string): DoomGitExpectedError {\n return new DoomGitExpectedError('invalid_request', message, false, recovery);\n}\n"],"mappings":"AAsBA,IAAa,EAAb,cAA0C,KAAM,CAEnC,KAEA,UACA,SAJX,YACE,EACA,EACA,EACA,EACA,CAGA,MAAM,IAAI,EAAK,IAAI,EAAQ,cAAc,GAAU,EAP1C,KAAA,KAAA,EAEA,KAAA,UAAA,EACA,KAAA,SAAA,EAKT,KAAK,KAAO,sBACd,CACF,EAEA,SAAgB,EAAe,EAAiB,EAAwC,CACtF,OAAO,IAAI,EAAqB,kBAAmB,EAAS,GAAO,CAAQ,CAC7E"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var e=class extends Error{code;retryable;recovery;constructor(e,t,n,r){super(`[${e}] ${t}\nRecovery: ${r}`),this.code=e,this.retryable=n,this.recovery=r,this.name=`DoomGitExpectedError`}};function t(t,n){return new e(`invalid_request`,t,!1,n)}export{e as DoomGitExpectedError,t as invalidRequest};
|
|
2
|
-
//# sourceMappingURL=errors.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.mjs","names":[],"sources":["../../../src/services/support/errors.ts"],"sourcesContent":["/**\n * Expected failures, kept private to this package.\n *\n * `@agimon-ai/doompi-extension-contracts` does not export `invalidRequest` or\n * an expected-error base, so this mirrors doompi-team's shape rather than\n * reaching across a layer boundary for it. The duplication is deliberate and\n * small; a shared helper would be the better answer only once a third package\n * needs one.\n */\n\nexport type DoomGitErrorCode =\n | 'invalid_request'\n | 'not_a_repository'\n | 'worktree_exists'\n | 'worktree_not_found'\n | 'worktree_not_owned'\n | 'worktree_dirty'\n | 'hub_unavailable'\n | 'spawn_cancelled'\n | 'registry_write_failed'\n | 'git_failed';\n\nexport class DoomGitExpectedError extends Error {\n constructor(\n readonly code: DoomGitErrorCode,\n message: string,\n readonly retryable: boolean,\n readonly recovery: string,\n ) {\n // The recovery line rides in the message because a tool result is read as\n // text: an error the model cannot act on costs a turn to rediscover.\n super(`[${code}] ${message}\\nRecovery: ${recovery}`);\n this.name = 'DoomGitExpectedError';\n }\n}\n\nexport function invalidRequest(message: string, recovery: string): DoomGitExpectedError {\n return new DoomGitExpectedError('invalid_request', message, false, recovery);\n}\n"],"mappings":"AAsBA,IAAa,EAAb,cAA0C,KAAM,CAEnC,KAEA,UACA,SAJX,YACE,EACA,EACA,EACA,EACA,CAGA,MAAM,IAAI,EAAK,IAAI,EAAQ,cAAc,GAAU,EAP1C,KAAA,KAAA,EAEA,KAAA,UAAA,EACA,KAAA,SAAA,EAKT,KAAK,KAAO,sBACd,CACF,EAEA,SAAgB,EAAe,EAAiB,EAAwC,CACtF,OAAO,IAAI,EAAqB,kBAAmB,EAAS,GAAO,CAAQ,CAC7E"}
|
|
@@ -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;;;;;;;EAOX;;;;;;;;iBASc,UAAU;EACxB,kBAAkB;EAClB;EACA;EACA,aAAa;IACX"}
|
|
@@ -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;;;;;;;EAOX;;;;;;;;iBASc,UAAU;EACxB,kBAAkB;EAClB;EACA;EACA,aAAa;IACX"}
|
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';
|