{"version":3,"file":"pi.mjs","names":["contribution","contribution","contribution","rootSession","commandGit","resourceDoompiUseGit","toolRunWorktree"],"sources":["../../src/extensions/workspaces/sessions/(backend)/_lib/root.cli.ts","../../src/extensions/workspaces/sessions/(backend)/root.cli.ts","../../src/extensions/workspaces/sessions/(backend)/command/_lib/git.cli.ts","../../src/extensions/workspaces/sessions/(backend)/command/git.cli.ts","../../src/extensions/workspaces/sessions/(backend)/resource/_lib/doompi-use-git.cli.ts","../../src/extensions/workspaces/sessions/(backend)/resource/doompi-use-git.cli.ts","../../src/extensions/workspaces/sessions/(backend)/tool/_lib/runWorktree.cli.ts","../../src/extensions/workspaces/sessions/(backend)/tool/runWorktree.cli.ts","../../generated/pi.ts"],"sourcesContent":["import { defineRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport type { PiPluginContext } from '@agimon-ai/doompi-core/piExtension';\n\nimport { createGitDependencies } from '../../../../../services/gitDependencies';\nimport type { GitExtensionDependencies } from '../../../../../types/extension';\n\nconst root = defineRoot((context: PiPluginContext<Partial<GitExtensionDependencies>>) => ({\n  value: createGitDependencies(context.options),\n}));\n\nexport type GitPiScope = Awaited<ReturnType<typeof root>>['value'];\nexport default root;\n","import { defineRoot } from '@agimon-ai/doompi-core/extensionFile';\n\nimport contribution from './_lib/root.cli';\n\nexport default defineRoot(contribution);\n","import type { WithRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport type { PiPluginContext } from '@agimon-ai/doompi-core/piExtension';\n// @scaffold-generated\nimport type { ExtensionAPI } from '@earendil-works/pi-coding-agent';\n\nimport { COMMAND_NAME, COMMAND_DESCRIPTION } from '../../../../../../constants/git';\nimport type { GitExtensionDependencies, GitExtensionService } from '../../../../../../types/extension';\nimport type { GitPiScope } from '../../_lib/root.cli';\n\nexport function createGitCommand(\n  service: GitExtensionService,\n): readonly [string, Parameters<ExtensionAPI['registerCommand']>[1]] {\n  return [\n    COMMAND_NAME,\n    {\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}\n\nexport default (context: WithRoot<PiPluginContext<Partial<GitExtensionDependencies>>, GitPiScope>) =>\n  createGitCommand(context.root.service);\n","import { defineCliCommand } from '@agimon-ai/doompi-core/extensionFile';\n\nimport contribution from './_lib/git.cli';\n\nexport default defineCliCommand(contribution);\n","export function createDoompiUseGitResource(moduleUrl: string) {\n  return {\n    source: '@agimon-ai/doompi-git',\n    moduleUrl,\n    skills: [\n      {\n        name: 'doompi-use-git',\n        description:\n          'Use @agimon-ai/doompi-git: Git worktree sessions for DoomPi: spawn an isolated worktree with its own session and manage it from the parent',\n      },\n    ],\n  };\n}\n","import { defineResource } from '@agimon-ai/doompi-core/extensionFile';\n\nimport { createDoompiUseGitResource } from './_lib/doompi-use-git.cli';\n\nexport default defineResource(createDoompiUseGitResource(import.meta.url));\n","import { defineCliTool, type WithRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport { definePiTool, type PiPluginContext } from '@agimon-ai/doompi-core/piExtension';\nimport type { AgentToolResult } from '@earendil-works/pi-agent-core';\nimport type { ToolDefinition } from '@earendil-works/pi-coding-agent';\n\nimport { RunWorktreeToolSchema, type RunWorktreeToolParams } from '../../../../../../schemas/runWorktreeTool';\nimport {\n  executeRunWorktreeTool,\n  RUN_WORKTREE_DESCRIPTION,\n  RUN_WORKTREE_TOOL_NAME,\n  validateParams,\n  type RunWorktreeToolDetails,\n} from '../../../../../../services/runWorktree';\nimport type { WorktreeOperations } from '../../../../../../services/worktreeOperations';\nimport type { GitExtensionDependencies } from '../../../../../../types/extension';\nimport type { GitPiScope } from '../../_lib/root.cli';\n\nexport default defineCliTool((context: WithRoot<PiPluginContext<Partial<GitExtensionDependencies>>, GitPiScope>) =>\n  definePiTool(createRunWorktreeTool(context.root.operations)),\n);\n\nexport { RUN_WORKTREE_TOOL_NAME, validateParams };\nexport type { RunWorktreeToolDetails };\n\n/** Creates the typed Pi worktree tool declaration. */\nexport function createRunWorktreeTool(\n  operations: WorktreeOperations,\n): ToolDefinition<typeof RunWorktreeToolSchema, RunWorktreeToolDetails> {\n  const tool: ToolDefinition<typeof RunWorktreeToolSchema, RunWorktreeToolDetails> = {\n    name: RUN_WORKTREE_TOOL_NAME,\n    label: 'Worktree',\n    description: RUN_WORKTREE_DESCRIPTION,\n    parameters: RunWorktreeToolSchema,\n    prepareArguments: validateParams,\n    // The signal and the progress callback are the host's two answers to a\n    // call that takes minutes. Dropping them is what let an interrupted spawn\n    // run on with nobody waiting for it, and left the caller staring at\n    // nothing while it did.\n    execute: async (_id, rawParams, signal, onUpdate, ctx) => {\n      const params = validateParams(rawParams) as RunWorktreeToolParams;\n      return (await executeRunWorktreeTool(\n        params,\n        operations,\n        {\n          cwd: ctx.cwd,\n          sessionId: ctx.sessionManager.getSessionId(),\n        },\n        {\n          ...(signal === undefined ? {} : { signal }),\n          onProgress: (label) =>\n            onUpdate?.({ content: [{ type: 'text', text: label }], details: { action: params.action } }),\n        },\n      )) as AgentToolResult<RunWorktreeToolDetails>;\n    },\n  };\n  return tool;\n}\n","import { defineCliTool } from '@agimon-ai/doompi-core/extensionFile';\n\nimport contribution from './_lib/runWorktree.cli';\n\nexport default defineCliTool(contribution);\n","// Generated by @agimon-ai/doompi-build. Do not edit by hand.\nimport { definePiExtension, piToolContributions, type PiPluginContext, type PiPluginContributions } from '@agimon-ai/doompi-core/piExtension';\nimport { composeRootHooks } from '@agimon-ai/doompi-core/extensionFile';\n\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.cli';\nimport commandGit from '../src/extensions/workspaces/sessions/(backend)/command/git.cli';\nimport resourceDoompiUseGit from '../src/extensions/workspaces/sessions/(backend)/resource/doompi-use-git.cli';\nimport toolRunWorktree from '../src/extensions/workspaces/sessions/(backend)/tool/runWorktree.cli';\n\ntype OptionsOf<T> = T extends (context: PiPluginContext<infer Options>) => unknown ? Options : never;\ntype InferredOptions = Exclude<OptionsOf<typeof rootSession> | OptionsOf<typeof commandGit> | OptionsOf<typeof resourceDoompiUseGit> | OptionsOf<typeof toolRunWorktree>, undefined>;\ntype Intersect<Union> =\n  (Union extends unknown ? (value: Union) => void : never) extends (value: infer Value) => void ? Value : never;\ntype ExtensionOptions = [InferredOptions] extends [never] ? undefined : Intersect<InferredOptions>;\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n  typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n  (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const extension = definePiExtension<ExtensionOptions>('@agimon-ai/doompi-git', async (context) => {\n  const scopeSession = await rootSession(context);\n  const contextSession = { ...context, root: scopeSession.value };\n  return {\n    ...composeRootHooks(scopeSession),\n    get commands(): PiPluginContributions['commands'] { return [at(commandGit, contextSession)]; },\n    get resources(): PiPluginContributions['resources'] { return [at(resourceDoompiUseGit, contextSession)]; },\n    ...piToolContributions('@agimon-ai/doompi-git', [via({ name: 'run_worktree' }, at(toolRunWorktree, contextSession))]),\n    services: [...(scopeSession.services ?? [])],\n  };\n});\n\nexport default extension;\n"],"mappings":";;;;;AAMA,MAAM,OAAO,YAAY,aAAiE,EACxF,OAAO,sBAAsB,QAAQ,OAAO,EAC9C,EAAE;;;ACJF,IAAA,mBAAe,WAAWA,IAAY;;;ACKtC,SAAgB,iBACd,SACmE;CACnE,OAAO,CACL,cACA;EACE,aAAa;EACb,SAAS,OAAO,OAAO,QAAQ;GAC7B,MAAM,SAAS,MAAM,QAAQ,QAAQ;GACrC,IAAI,IAAI,OAAO,IAAI,GAAG,OAAO,OAAO,SAAS,OAAO,KAAK;EAC3D;CACF,CACF;AACF;AAEA,IAAA,qBAAgB,YACd,iBAAiB,QAAQ,KAAK,OAAO;;;ACrBvC,IAAA,kBAAe,iBAAiBC,iBAAY;;;ACJ5C,SAAgB,2BAA2B,WAAmB;CAC5D,OAAO;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