{"version":3,"file":"mcp.mjs","names":["skillDoompiUsePlan","toolCompletePlan","toolRecordDebugEvidence","toolRunFablePlan","toolWritePlan"],"sources":["../../src/extensions/workspaces/sessions/(backend)/skill/doompi-use-plan.mcp.ts","../../src/schemas/mcpTools.ts","../../src/services/mcpTools/index.ts","../../src/extensions/workspaces/sessions/(backend)/tool/complete_plan.mcp.ts","../../src/extensions/workspaces/sessions/(backend)/tool/record_debug_evidence.mcp.ts","../../src/extensions/workspaces/sessions/(backend)/tool/run_fable_plan.mcp.ts","../../src/extensions/workspaces/sessions/(backend)/tool/write_plan.mcp.ts","../../generated/mcp.ts"],"sourcesContent":["import { defineMcpSkill } from '@agimon-ai/doompi-core/mcpFacet';\nimport { readPackageResource } from '@agimon-ai/doompi-core/serverFacet';\n\nexport default defineMcpSkill({\n  name: 'doompi-use-plan',\n  description:\n    'Use Doom Pi Plan to draft reviewable normal, debug, or Fable-assisted plans, persist them, and exit safely.',\n  read: () => readPackageResource(import.meta.url, 'src/prompts/doompi-use-plan/SKILL.md'),\n});\n","import { Type } from 'typebox';\n\nconst markdown = Type.String({ minLength: 1 });\n\nexport const remoteWritePlanParameters = Type.Object({ markdown }, { additionalProperties: false });\nexport const writePlanParameters = Type.Object({ markdown: Type.Optional(markdown) }, { additionalProperties: false });\n","import type { DoomHeadlessTool } from '@agimon-ai/doompi-core/headless';\nimport type { DoomMcpPluginContext } from '@agimon-ai/doompi-core/mcpFacet';\nimport type { Context } from '@deepseek-ai/cordis';\n\nimport { remoteWritePlanParameters } from '../../schemas/mcpTools';\n\nexport const PLAN_MCP_TOOLS_SERVICE = 'doom/plan-mcp-tools';\n\nconst MODE_ID = 'plan';\nconst MODE_LABEL = 'Plan';\n\nexport interface McpToolCatalog {\n  get(name: string): DoomHeadlessTool | undefined;\n  names(): readonly string[];\n}\n\nexport function mountMcpTools(tools: readonly DoomHeadlessTool[]) {\n  return (context: Context): void => {\n    context.plugin((providerContext) => {\n      providerContext.provide(PLAN_MCP_TOOLS_SERVICE, {\n        get: (name) => tools.find((tool) => tool.name === name),\n        names: () => tools.map((tool) => tool.name),\n      } satisfies McpToolCatalog);\n    });\n  };\n}\n\nexport function bindMcpTool(context: DoomMcpPluginContext, name: string): DoomHeadlessTool {\n  const catalog = context.services.get<McpToolCatalog>(PLAN_MCP_TOOLS_SERVICE);\n  const tool = catalog?.get(name);\n  if (!tool || !catalog) throw new Error(`Plan tool is unavailable: ${name}`);\n  const writesPlan = name === 'write_plan';\n  return {\n    ...tool,\n    ...(writesPlan\n      ? {\n          description:\n            'Save the supplied Markdown plan in the bound session. Requires active Plan mode. Saving does not approve implementation.',\n          parameters: remoteWritePlanParameters,\n          annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: false },\n        }\n      : {}),\n    execute(toolCallId, parameters, signal, onUpdate) {\n      const activeModes = context.selection.read().state?.['minor-mode'] ?? [];\n      if (!activeModes.includes(MODE_ID)) {\n        const inactiveTools = [...catalog.names()].sort().join(', ');\n        throw new Error(`${MODE_LABEL} minor mode is inactive. Inactive ${MODE_LABEL} tools: ${inactiveTools}.`);\n      }\n      if (\n        writesPlan &&\n        (typeof parameters !== 'object' ||\n          parameters === null ||\n          !('markdown' in parameters) ||\n          typeof parameters.markdown !== 'string' ||\n          !parameters.markdown.trim())\n      ) {\n        throw new Error(\n          'Supply the complete visible plan in the markdown argument. Remote calls cannot read the ChatGPT transcript.',\n        );\n      }\n      const executionSignal = AbortSignal.any([context.signal, signal ?? context.signal]);\n      return tool.execute(toolCallId, parameters, executionSignal, onUpdate, context.execution);\n    },\n  };\n}\n","import { defineMcpTool, type DoomMcpPluginContext } from '@agimon-ai/doompi-core/mcpFacet';\n\nimport { bindMcpTool } from '../../../../../services/mcpTools';\n\nexport default defineMcpTool((context: DoomMcpPluginContext) => bindMcpTool(context, 'complete_plan'));\n","import { defineMcpTool, type DoomMcpPluginContext } from '@agimon-ai/doompi-core/mcpFacet';\n\nimport { bindMcpTool } from '../../../../../services/mcpTools';\n\nexport default defineMcpTool((context: DoomMcpPluginContext) => bindMcpTool(context, 'record_debug_evidence'));\n","import { defineMcpTool, type DoomMcpPluginContext } from '@agimon-ai/doompi-core/mcpFacet';\n\nimport { bindMcpTool } from '../../../../../services/mcpTools';\n\nexport default defineMcpTool((context: DoomMcpPluginContext) => bindMcpTool(context, 'run_fable_plan'));\n","import { defineMcpTool, type DoomMcpPluginContext } from '@agimon-ai/doompi-core/mcpFacet';\n\nimport { bindMcpTool } from '../../../../../services/mcpTools';\n\nexport default defineMcpTool((context: DoomMcpPluginContext) => bindMcpTool(context, 'write_plan'));\n","// Generated by @agimon-ai/doompi-build. Do not edit by hand.\nimport { defineMcpPlugin, type DoomMcpSessionPlugin } from '@agimon-ai/doompi-core/mcpFacet';\n\nimport skillDoompiUsePlan from '../src/extensions/workspaces/sessions/(backend)/skill/doompi-use-plan.mcp';\nimport toolCompletePlan from '../src/extensions/workspaces/sessions/(backend)/tool/complete_plan.mcp';\nimport toolRecordDebugEvidence from '../src/extensions/workspaces/sessions/(backend)/tool/record_debug_evidence.mcp';\nimport toolRunFablePlan from '../src/extensions/workspaces/sessions/(backend)/tool/run_fable_plan.mcp';\nimport toolWritePlan from '../src/extensions/workspaces/sessions/(backend)/tool/write_plan.mcp';\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 mcp = defineMcpPlugin({\n  name: '@agimon-ai/doompi-plan',\n  session: (context) => ({\n    get skills(): DoomMcpSessionPlugin['skills'] { return [at(skillDoompiUsePlan, context)]; },\n    get tools(): DoomMcpSessionPlugin['tools'] { return [via({ name: 'complete_plan' }, at(toolCompletePlan, context)), via({ name: 'record_debug_evidence' }, at(toolRecordDebugEvidence, context)), via({ name: 'run_fable_plan' }, at(toolRunFablePlan, context)), via({ name: 'write_pl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