fifony 0.1.21 → 0.1.22-next.ca3682c
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 +19 -7
- package/app/dist/assets/KeyboardShortcutsHelp-CqCRSinb.js +1 -0
- package/app/dist/assets/OnboardingWizard-sB4Jirx5.js +1 -0
- package/app/dist/assets/analytics.lazy-BPdQoH_Z.js +1 -0
- package/app/dist/assets/{createLucideIcon-DtZs0TX0.js → createLucideIcon-BWC-guQt.js} +1 -1
- package/app/dist/assets/index-BaDR-1h-.js +43 -0
- package/app/dist/assets/index-DjmUHXd1.css +1 -0
- package/app/dist/assets/vendor-BTlTWMUF.js +9 -0
- package/app/dist/dinofffaur.png +0 -0
- package/app/dist/index.html +4 -5
- package/app/dist/service-worker.js +1 -1
- package/app/public/dinofffaur.png +0 -0
- package/bin/fifony-wrap.js +53 -0
- package/dist/agent/cli-wrapper.js +78 -0
- package/dist/agent/cli-wrapper.js.map +1 -0
- package/dist/agent/run-local.js +217 -7893
- package/dist/agent/run-local.js.map +1 -1
- package/dist/chunk-CWC7H4H3.js +91 -0
- package/dist/chunk-CWC7H4H3.js.map +1 -0
- package/dist/{chunk-SMGXYOWU.js → chunk-DD5BE2W6.js} +430 -31
- package/dist/chunk-DD5BE2W6.js.map +1 -0
- package/dist/chunk-DVU3CXWA.js +75 -0
- package/dist/chunk-DVU3CXWA.js.map +1 -0
- package/dist/chunk-IXE2JEIU.js +7115 -0
- package/dist/chunk-IXE2JEIU.js.map +1 -0
- package/dist/chunk-NA6PJPZD.js +2110 -0
- package/dist/chunk-NA6PJPZD.js.map +1 -0
- package/dist/cli.js +187 -1
- package/dist/cli.js.map +1 -1
- package/dist/issue-runner-OEUARE4A.js +13 -0
- package/dist/issue-runner-OEUARE4A.js.map +1 -0
- package/dist/issue-state-machine-OKQIWTVN.js +37 -0
- package/dist/issue-state-machine-OKQIWTVN.js.map +1 -0
- package/dist/mcp/server.js +592 -605
- package/dist/mcp/server.js.map +1 -1
- package/dist/queue-workers-SVNB4ESJ.js +20 -0
- package/dist/queue-workers-SVNB4ESJ.js.map +1 -0
- package/dist/store-NIW6OEYC.js +56 -0
- package/dist/store-NIW6OEYC.js.map +1 -0
- package/package.json +10 -9
- package/FIFONY.md +0 -173
- package/app/dist/assets/KeyboardShortcutsHelp-BTjiQe_Y.js +0 -1
- package/app/dist/assets/OnboardingWizard-BALlquG0.js +0 -1
- package/app/dist/assets/analytics.lazy-DjSzXIey.js +0 -1
- package/app/dist/assets/index-BV11ScVl.js +0 -42
- package/app/dist/assets/index-DWbxgKSd.css +0 -1
- package/app/dist/assets/vendor-BoGBoEwT.js +0 -9
- package/app/dist/assets/zap-DpjdVd1i.js +0 -1
- package/dist/chunk-SMGXYOWU.js.map +0 -1
- package/src/fixtures/agent-catalog.json +0 -208
- package/src/fixtures/skill-catalog.json +0 -67
package/dist/mcp/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mcp/server.ts","../../src/integrations/catalog.ts","../../src/mcp/database.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { existsSync } from \"node:fs\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { env, stdin, stdout } from \"node:process\";\nimport { fileURLToPath } from \"node:url\";\nimport { renderPrompt } from \"../prompting.ts\";\nimport { buildIntegrationSnippet, discoverIntegrations } from \"../integrations/catalog.ts\";\nimport { inferCapabilityPaths, resolveTaskCapabilities } from \"../routing/capability-resolver.ts\";\nimport {\n type IssueRecord,\n initDatabase,\n getDatabase,\n getResources,\n getIssues,\n getIssue,\n listIssues,\n listEvents,\n listRecords,\n getRuntimeSnapshot,\n appendEvent,\n nowIso,\n safeRead,\n WORKSPACE_ROOT,\n PERSISTENCE_ROOT,\n STATE_ROOT,\n} from \"./database.ts\";\n\ntype JsonRpcId = string | number | null;\n\ntype JsonRpcRequest = {\n jsonrpc: \"2.0\";\n id?: JsonRpcId;\n method: string;\n params?: Record<string, unknown>;\n};\n\ntype JsonRpcResponse = {\n jsonrpc: \"2.0\";\n id: JsonRpcId;\n result?: unknown;\n error?: {\n code: number;\n message: string;\n data?: unknown;\n };\n};\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\nconst PACKAGE_ROOT = resolve(__dirname, \"../..\");\nconst WORKFLOW_PATH = join(WORKSPACE_ROOT, \"WORKFLOW.md\");\nconst README_PATH = join(PACKAGE_ROOT, \"README.md\");\nconst FIFONY_GUIDE_PATH = join(PACKAGE_ROOT, \"FIFONY.md\");\nconst DEBUG_BOOT = env.FIFONY_DEBUG_BOOT === \"1\";\n\nlet incomingBuffer = Buffer.alloc(0);\n\nfunction debugBoot(message: string): void {\n if (!DEBUG_BOOT) return;\n process.stderr.write(`[FIFONY_DEBUG_BOOT] ${message}\\n`);\n}\n\nfunction hashInput(value: string): string {\n return createHash(\"sha1\").update(value).digest(\"hex\").slice(0, 10);\n}\n\nasync function buildIntegrationGuide(): Promise<string> {\n return renderPrompt(\"mcp-integration-guide\", {\n workspaceRoot: WORKSPACE_ROOT,\n persistenceRoot: PERSISTENCE_ROOT,\n stateRoot: STATE_ROOT,\n });\n}\n\nfunction computeCapabilityCounts(issues: IssueRecord[]): Record<string, number> {\n return issues.reduce<Record<string, number>>((accumulator, issue) => {\n const key = typeof issue.capabilityCategory === \"string\" && issue.capabilityCategory.trim()\n ? issue.capabilityCategory.trim()\n : \"default\";\n accumulator[key] = (accumulator[key] ?? 0) + 1;\n return accumulator;\n }, {});\n}\n\nasync function buildStateSummary(): Promise<string> {\n const runtime = await getRuntimeSnapshot();\n const issues = await getIssues();\n const { sessionResource, pipelineResource } = getResources();\n const sessions = await listRecords(sessionResource, 500);\n const pipelines = await listRecords(pipelineResource, 500);\n const events = await listEvents({ limit: 100 });\n\n const byState = issues.reduce<Record<string, number>>((accumulator, issue) => {\n const key = issue.state ?? \"Unknown\";\n accumulator[key] = (accumulator[key] ?? 0) + 1;\n return accumulator;\n }, {});\n const byCapability = computeCapabilityCounts(issues);\n\n return JSON.stringify({\n workspaceRoot: WORKSPACE_ROOT,\n persistenceRoot: PERSISTENCE_ROOT,\n stateRoot: STATE_ROOT,\n workflowPresent: existsSync(WORKFLOW_PATH),\n runtimeUpdatedAt: runtime.updatedAt ?? null,\n issueCount: issues.length,\n issuesByState: byState,\n issuesByCapability: byCapability,\n sessionCount: sessions.length,\n pipelineCount: pipelines.length,\n recentEventCount: events.length,\n }, null, 2);\n}\n\nasync function buildIssuePrompt(issue: IssueRecord, provider: string, role: string): Promise<string> {\n const resolution = resolveTaskCapabilities({\n id: issue.id,\n identifier: issue.identifier,\n title: issue.title,\n description: typeof issue.description === \"string\" ? issue.description : \"\",\n labels: Array.isArray(issue.labels) ? issue.labels.filter((value): value is string => typeof value === \"string\") : [],\n paths: Array.isArray(issue.paths) ? issue.paths.filter((value): value is string => typeof value === \"string\") : [],\n });\n return renderPrompt(\"mcp-issue\", {\n role,\n provider,\n id: issue.id,\n title: issue.title,\n state: issue.state ?? \"Todo\",\n capabilityCategory: resolution.category,\n overlays: resolution.overlays,\n paths: Array.isArray(issue.paths) ? issue.paths.filter((value): value is string => typeof value === \"string\") : [],\n description: issue.description || \"No description provided.\",\n });\n}\n\nasync function listResourcesMcp(): Promise<Array<Record<string, unknown>>> {\n const issues = await getIssues();\n const resources: Array<Record<string, unknown>> = [\n { uri: \"fifony://guide/overview\", name: \"Fifony overview\", description: \"High-level overview and local integration guide.\", mimeType: \"text/markdown\" },\n { uri: \"fifony://guide/runtime\", name: \"Fifony runtime guide\", description: \"Detailed local runtime reference for the package.\", mimeType: \"text/markdown\" },\n { uri: \"fifony://guide/integration\", name: \"Fifony MCP integration guide\", description: \"How to wire an MCP client to this Fifony workspace.\", mimeType: \"text/markdown\" },\n { uri: \"fifony://state/summary\", name: \"Fifony state summary\", description: \"Compact summary of the current runtime, issue, and pipeline state.\", mimeType: \"application/json\" },\n { uri: \"fifony://issues\", name: \"Fifony issues\", description: \"Full issue list from the durable Fifony store.\", mimeType: \"application/json\" },\n { uri: \"fifony://integrations\", name: \"Fifony integrations\", description: \"Discovered local integrations such as agency-agents and impeccable skills.\", mimeType: \"application/json\" },\n { uri: \"fifony://capabilities\", name: \"Fifony capability routing\", description: \"How Fifony would route current issues to providers, profiles, and overlays.\", mimeType: \"application/json\" },\n ];\n\n if (existsSync(WORKFLOW_PATH)) {\n resources.push({ uri: \"fifony://workspace/workflow\", name: \"Workspace workflow\", description: \"The active WORKFLOW.md from the target workspace.\", mimeType: \"text/markdown\" });\n }\n\n resources.push(\n { uri: \"fifony://analytics\", name: \"Token usage analytics\", description: \"Token usage analytics snapshot including totals, cost estimates, and per-model breakdown.\", mimeType: \"application/json\" },\n { uri: \"fifony://workflow/config\", name: \"Workflow config\", description: \"Current pipeline workflow configuration (plan/execute/review providers, models, and effort).\", mimeType: \"application/json\" },\n { uri: \"fifony://agents/catalog\", name: \"Agent catalog\", description: \"Available agents from the Fifony catalog.\", mimeType: \"application/json\" },\n { uri: \"fifony://skills/catalog\", name: \"Skill catalog\", description: \"Available skills from the Fifony catalog.\", mimeType: \"application/json\" },\n { uri: \"fifony://events/recent\", name: \"Recent events\", description: \"Last 50 events across all issues.\", mimeType: \"application/json\" },\n );\n\n for (const issue of issues.slice(0, 100)) {\n resources.push(\n { uri: `fifony://issue/${encodeURIComponent(issue.id)}`, name: `Issue ${issue.id}`, description: issue.title, mimeType: \"application/json\" },\n { uri: `fifony://issue/${encodeURIComponent(issue.id)}/plan`, name: `Issue ${issue.id} plan`, description: `Plan for: ${issue.title}`, mimeType: \"application/json\" },\n { uri: `fifony://issue/${encodeURIComponent(issue.id)}/diff`, name: `Issue ${issue.id} diff`, description: `Git diff for: ${issue.title}`, mimeType: \"application/json\" },\n { uri: `fifony://issue/${encodeURIComponent(issue.id)}/events`, name: `Issue ${issue.id} events`, description: `Events for: ${issue.title}`, mimeType: \"application/json\" },\n );\n }\n\n return resources;\n}\n\nasync function readResource(uri: string): Promise<Array<Record<string, unknown>>> {\n if (uri === \"fifony://guide/overview\") return [{ uri, mimeType: \"text/markdown\", text: safeRead(README_PATH) }];\n if (uri === \"fifony://guide/runtime\") return [{ uri, mimeType: \"text/markdown\", text: safeRead(FIFONY_GUIDE_PATH) }];\n if (uri === \"fifony://guide/integration\") return [{ uri, mimeType: \"text/markdown\", text: await buildIntegrationGuide() }];\n if (uri === \"fifony://state/summary\") return [{ uri, mimeType: \"application/json\", text: await buildStateSummary() }];\n if (uri === \"fifony://issues\") return [{ uri, mimeType: \"application/json\", text: JSON.stringify(await getIssues(), null, 2) }];\n\n if (uri === \"fifony://integrations\") {\n return [{ uri, mimeType: \"application/json\", text: JSON.stringify(discoverIntegrations(WORKSPACE_ROOT), null, 2) }];\n }\n\n if (uri === \"fifony://capabilities\") {\n const issues = await getIssues();\n return [{\n uri,\n mimeType: \"application/json\",\n text: JSON.stringify(\n issues.map((issue) => ({\n issueId: issue.id,\n title: issue.title,\n paths: Array.isArray(issue.paths) ? issue.paths.filter((value): value is string => typeof value === \"string\") : [],\n inferredPaths: inferCapabilityPaths({\n id: issue.id, identifier: issue.identifier, title: issue.title, description: issue.description,\n labels: Array.isArray(issue.labels) ? issue.labels.filter((value): value is string => typeof value === \"string\") : [],\n paths: Array.isArray(issue.paths) ? issue.paths.filter((value): value is string => typeof value === \"string\") : [],\n }),\n resolution: resolveTaskCapabilities({\n id: issue.id, identifier: issue.identifier, title: issue.title, description: issue.description,\n labels: Array.isArray(issue.labels) ? issue.labels.filter((value): value is string => typeof value === \"string\") : [],\n paths: Array.isArray(issue.paths) ? issue.paths.filter((value): value is string => typeof value === \"string\") : [],\n }),\n })),\n null, 2,\n ),\n }];\n }\n\n if (uri === \"fifony://workspace/workflow\") return [{ uri, mimeType: \"text/markdown\", text: safeRead(WORKFLOW_PATH) }];\n\n if (uri === \"fifony://analytics\") {\n try {\n const result = await apiGet(\"/api/analytics/tokens\");\n return [{ uri, mimeType: \"application/json\", text: JSON.stringify(result, null, 2) }];\n } catch (error) {\n return [{ uri, mimeType: \"application/json\", text: JSON.stringify({ error: String(error) }, null, 2) }];\n }\n }\n\n if (uri === \"fifony://workflow/config\") {\n try {\n const result = await apiGet(\"/api/config/workflow\");\n return [{ uri, mimeType: \"application/json\", text: JSON.stringify(result, null, 2) }];\n } catch (error) {\n return [{ uri, mimeType: \"application/json\", text: JSON.stringify({ error: String(error) }, null, 2) }];\n }\n }\n\n if (uri === \"fifony://agents/catalog\") {\n try {\n const result = await apiGet(\"/api/catalog/agents\");\n return [{ uri, mimeType: \"application/json\", text: JSON.stringify(result, null, 2) }];\n } catch (error) {\n return [{ uri, mimeType: \"application/json\", text: JSON.stringify({ error: String(error) }, null, 2) }];\n }\n }\n\n if (uri === \"fifony://skills/catalog\") {\n try {\n const result = await apiGet(\"/api/catalog/skills\");\n return [{ uri, mimeType: \"application/json\", text: JSON.stringify(result, null, 2) }];\n } catch (error) {\n return [{ uri, mimeType: \"application/json\", text: JSON.stringify({ error: String(error) }, null, 2) }];\n }\n }\n\n if (uri === \"fifony://events/recent\") {\n try {\n const result = await apiGet(\"/api/events/feed\");\n const events = Array.isArray((result as any).events) ? (result as any).events.slice(0, 50) : [];\n return [{ uri, mimeType: \"application/json\", text: JSON.stringify({ events }, null, 2) }];\n } catch (error) {\n const events = await listEvents({ limit: 50 });\n return [{ uri, mimeType: \"application/json\", text: JSON.stringify({ events }, null, 2) }];\n }\n }\n\n if (uri.startsWith(\"fifony://issue/\")) {\n const remainder = uri.substring(\"fifony://issue/\".length);\n\n // fifony://issue/{id}/plan\n const planMatch = remainder.match(/^(.+)\\/plan$/);\n if (planMatch) {\n const issueId = decodeURIComponent(planMatch[1]);\n const issue = await getIssue(issueId);\n if (!issue) throw new Error(`Issue not found: ${issueId}`);\n const plan = (issue as any).plan ?? null;\n return [{ uri, mimeType: \"application/json\", text: JSON.stringify({ issueId, plan }, null, 2) }];\n }\n\n // fifony://issue/{id}/diff\n const diffMatch = remainder.match(/^(.+)\\/diff$/);\n if (diffMatch) {\n const issueId = decodeURIComponent(diffMatch[1]);\n try {\n const result = await apiGet(`/api/diff/${encodeURIComponent(issueId)}`);\n return [{ uri, mimeType: \"application/json\", text: JSON.stringify(result, null, 2) }];\n } catch (error) {\n return [{ uri, mimeType: \"application/json\", text: JSON.stringify({ error: String(error) }, null, 2) }];\n }\n }\n\n // fifony://issue/{id}/events\n const eventsMatch = remainder.match(/^(.+)\\/events$/);\n if (eventsMatch) {\n const issueId = decodeURIComponent(eventsMatch[1]);\n try {\n const result = await apiGet(`/api/events/feed?issueId=${encodeURIComponent(issueId)}`);\n return [{ uri, mimeType: \"application/json\", text: JSON.stringify(result, null, 2) }];\n } catch (error) {\n const events = await listEvents({ limit: 100 });\n const filtered = events.filter((event: any) => event.issueId === issueId);\n return [{ uri, mimeType: \"application/json\", text: JSON.stringify({ events: filtered }, null, 2) }];\n }\n }\n\n // fifony://issue/{id} (base case)\n const issueId = decodeURIComponent(remainder);\n const issue = await getIssue(issueId);\n if (!issue) throw new Error(`Issue not found: ${issueId}`);\n return [{ uri, mimeType: \"application/json\", text: JSON.stringify(issue, null, 2) }];\n }\n\n throw new Error(`Unknown resource: ${uri}`);\n}\n\nfunction listPrompts(): Array<Record<string, unknown>> {\n return [\n { name: \"fifony-integrate-client\", description: \"Generate setup instructions for connecting an MCP-capable client to Fifony.\", arguments: [{ name: \"client\", description: \"Client name, e.g. codex or claude.\", required: true }, { name: \"goal\", description: \"What the client should do with Fifony.\", required: false }] },\n { name: \"fifony-plan-issue\", description: \"Generate a planning prompt for a specific issue in the Fifony store.\", arguments: [{ name: \"issueId\", description: \"Issue identifier.\", required: true }, { name: \"provider\", description: \"Agent provider name.\", required: false }] },\n { name: \"fifony-review-workflow\", description: \"Review the current WORKFLOW.md and propose improvements for orchestration quality.\", arguments: [{ name: \"provider\", description: \"Reviewing model or client.\", required: false }] },\n { name: \"fifony-use-integration\", description: \"Generate a concrete integration prompt for agency-agents or impeccable.\", arguments: [{ name: \"integration\", description: \"Integration id: agency-agents or impeccable.\", required: true }] },\n { name: \"fifony-route-task\", description: \"Explain which providers, profiles, and overlays Fifony would choose for a task.\", arguments: [{ name: \"title\", description: \"Task title.\", required: true }, { name: \"description\", description: \"Task description.\", required: false }, { name: \"labels\", description: \"Comma-separated labels.\", required: false }, { name: \"paths\", description: \"Comma-separated target paths or files.\", required: false }] },\n { name: \"fifony-diagnose-blocked\", description: \"Help diagnose why an issue is blocked or failing, analyzing the issue plan, last error, history, and events.\", arguments: [{ name: \"issueId\", description: \"Issue identifier to diagnose.\", required: true }] },\n { name: \"fifony-weekly-summary\", description: \"Generate a weekly progress summary including issues created, completed, blocked, and token usage.\", arguments: [] },\n { name: \"fifony-refine-plan\", description: \"Guided plan refinement prompt that shows the current plan and helps provide specific feedback.\", arguments: [{ name: \"issueId\", description: \"Issue identifier whose plan to refine.\", required: true }, { name: \"concern\", description: \"Optional specific concern to address in refinement.\", required: false }] },\n { name: \"fifony-code-review\", description: \"Review code changes for an issue by analyzing its git diff.\", arguments: [{ name: \"issueId\", description: \"Issue identifier to review.\", required: true }] },\n ];\n}\n\nasync function getPrompt(name: string, args: Record<string, unknown> = {}): Promise<Record<string, unknown>> {\n if (name === \"fifony-integrate-client\") {\n const client = typeof args.client === \"string\" && args.client.trim() ? args.client.trim() : \"mcp-client\";\n const goal = typeof args.goal === \"string\" && args.goal.trim() ? args.goal.trim() : \"integrate with the local Fifony workspace\";\n const integrationGuide = await buildIntegrationGuide();\n return {\n description: \"Client integration prompt for Fifony.\",\n messages: [{\n role: \"user\",\n content: {\n type: \"text\",\n text: await renderPrompt(\"mcp-integrate-client\", { client, goal, integrationGuide }),\n },\n }],\n };\n }\n\n if (name === \"fifony-plan-issue\") {\n const issueId = typeof args.issueId === \"string\" ? args.issueId : \"\";\n const provider = typeof args.provider === \"string\" && args.provider.trim() ? args.provider.trim() : \"codex\";\n const issue = issueId ? await getIssue(issueId) : null;\n if (!issue) throw new Error(`Issue not found: ${issueId}`);\n return {\n description: \"Issue planning prompt grounded in the Fifony issue store.\",\n messages: [{\n role: \"user\",\n content: { type: \"text\", text: await buildIssuePrompt(issue, provider, \"planner\") },\n }],\n };\n }\n\n if (name === \"fifony-review-workflow\") {\n const provider = typeof args.provider === \"string\" && args.provider.trim() ? args.provider.trim() : \"claude\";\n return {\n description: \"Workflow review prompt for Fifony orchestration.\",\n messages: [{\n role: \"user\",\n content: {\n type: \"text\",\n text: await renderPrompt(\"mcp-review-workflow\", {\n provider,\n workspaceRoot: WORKSPACE_ROOT,\n workflowPresent: existsSync(WORKFLOW_PATH) ? \"yes\" : \"no\",\n }),\n },\n }],\n };\n }\n\n if (name === \"fifony-use-integration\") {\n const integration = typeof args.integration === \"string\" ? args.integration : \"\";\n return {\n description: \"Integration guidance for a discovered Fifony extension.\",\n messages: [{\n role: \"user\",\n content: { type: \"text\", text: await buildIntegrationSnippet(integration, WORKSPACE_ROOT) },\n }],\n };\n }\n\n if (name === \"fifony-route-task\") {\n const title = typeof args.title === \"string\" ? args.title : \"\";\n const description = typeof args.description === \"string\" ? args.description : \"\";\n const labels = typeof args.labels === \"string\" ? args.labels.split(\",\").map((label) => label.trim()).filter(Boolean) : [];\n const paths = typeof args.paths === \"string\" ? args.paths.split(\",\").map((value) => value.trim()).filter(Boolean) : [];\n const resolution = resolveTaskCapabilities({ title, description, labels, paths });\n return {\n description: \"Task routing prompt produced by the Fifony capability resolver.\",\n messages: [{\n role: \"user\",\n content: {\n type: \"text\",\n text: await renderPrompt(\"mcp-route-task\", {\n resolutionJson: JSON.stringify(resolution, null, 2),\n }),\n },\n }],\n };\n }\n\n if (name === \"fifony-diagnose-blocked\") {\n const issueId = typeof args.issueId === \"string\" ? args.issueId.trim() : \"\";\n if (!issueId) throw new Error(\"issueId is required\");\n const issue = await getIssue(issueId);\n if (!issue) throw new Error(`Issue not found: ${issueId}`);\n const issueData = issue as any;\n let events: unknown[] = [];\n try {\n const evResult = await apiGet(`/api/events/feed?issueId=${encodeURIComponent(issueId)}`);\n events = Array.isArray((evResult as any).events) ? (evResult as any).events.slice(0, 30) : [];\n } catch {\n const localEvents = await listEvents({ limit: 100 });\n events = localEvents.filter((event: any) => event.issueId === issueId).slice(0, 30);\n }\n const plan = issueData.plan ?? null;\n const history = Array.isArray(issueData.history) ? issueData.history : [];\n const lastError = issueData.lastError ?? null;\n const state = issueData.state ?? \"Unknown\";\n const attempts = issueData.attempts ?? 0;\n const maxAttempts = issueData.maxAttempts ?? 3;\n\n const diagnosticText = [\n `# Diagnostic Report for Issue ${issueId}`,\n ``,\n `## Issue Details`,\n `- **Title**: ${issueData.title ?? \"Unknown\"}`,\n `- **State**: ${state}`,\n `- **Attempts**: ${attempts} / ${maxAttempts}`,\n `- **Last Error**: ${lastError ?? \"None\"}`,\n `- **Updated At**: ${issueData.updatedAt ?? \"Unknown\"}`,\n ``,\n `## Plan`,\n plan ? `- **Summary**: ${plan.summary ?? plan.title ?? \"No summary\"}` : \"No plan generated.\",\n plan?.steps ? `- **Steps**: ${plan.steps.length} step(s)` : \"\",\n plan?.estimatedComplexity ? `- **Estimated Complexity**: ${plan.estimatedComplexity}` : \"\",\n ``,\n `## History`,\n ...(history.length > 0 ? history.slice(-15).map((entry: string) => `- ${entry}`) : [\"No history entries.\"]),\n ``,\n `## Recent Events`,\n ...(events.length > 0 ? (events as any[]).slice(0, 15).map((event: any) => `- [${event.kind ?? \"info\"}] ${event.at ?? \"\"}: ${event.message ?? \"\"}`) : [\"No events found.\"]),\n ``,\n `## Diagnostic Questions`,\n `Based on the information above, please analyze:`,\n `1. What is the root cause of the issue being in \"${state}\" state?`,\n `2. Is the error recoverable? If so, what steps should be taken?`,\n `3. Does the plan need modification before retrying?`,\n `4. Are there any dependency or configuration issues that need resolution?`,\n `5. What is the recommended next action?`,\n ].filter((line) => line !== undefined).join(\"\\n\");\n\n return {\n description: `Diagnostic prompt for blocked/failed issue ${issueId}.`,\n messages: [{\n role: \"user\",\n content: { type: \"text\", text: diagnosticText },\n }],\n };\n }\n\n if (name === \"fifony-weekly-summary\") {\n const issues = await getIssues();\n let analytics: Record<string, unknown> = {};\n try { analytics = await apiGet(\"/api/analytics/tokens\"); } catch {}\n const overall = (analytics as any).overall ?? {};\n const byState = issues.reduce<Record<string, number>>((accumulator, issue: any) => {\n const key = issue.state ?? \"Unknown\";\n accumulator[key] = (accumulator[key] ?? 0) + 1;\n return accumulator;\n }, {});\n const totalIssues = issues.length;\n const completed = byState[\"Done\"] ?? 0;\n const blocked = (byState[\"Blocked\"] ?? 0) + (byState[\"Failed\"] ?? 0);\n const inProgress = (byState[\"Running\"] ?? 0) + (byState[\"In Review\"] ?? 0) + (byState[\"Queued\"] ?? 0);\n const todo = byState[\"Todo\"] ?? 0;\n const planning = byState[\"Planning\"] ?? 0;\n const cancelled = byState[\"Cancelled\"] ?? 0;\n const inputTokens = typeof overall.inputTokens === \"number\" ? overall.inputTokens : 0;\n const outputTokens = typeof overall.outputTokens === \"number\" ? overall.outputTokens : 0;\n const totalTokens = typeof overall.totalTokens === \"number\" ? overall.totalTokens : 0;\n const estimatedCost = (inputTokens / 1_000_000) * 3 + (outputTokens / 1_000_000) * 15;\n\n const summaryText = [\n `# Fifony Weekly Progress Summary`,\n ``,\n `## Issue Statistics`,\n `| Status | Count |`,\n `|--------|-------|`,\n `| Total Issues | ${totalIssues} |`,\n `| Completed (Done) | ${completed} |`,\n `| In Progress | ${inProgress} |`,\n `| Todo | ${todo} |`,\n `| Planning | ${planning} |`,\n `| Blocked/Failed | ${blocked} |`,\n `| Cancelled | ${cancelled} |`,\n ``,\n `## Token Usage`,\n `- **Total Tokens**: ${totalTokens.toLocaleString()}`,\n `- **Input Tokens**: ${inputTokens.toLocaleString()}`,\n `- **Output Tokens**: ${outputTokens.toLocaleString()}`,\n `- **Estimated Cost**: $${(Math.round(estimatedCost * 100) / 100).toFixed(2)}`,\n ``,\n `## Analysis Request`,\n `Based on these metrics, please provide:`,\n `1. A brief summary of overall progress this week`,\n `2. Identification of any bottlenecks (blocked/failed issues)`,\n `3. Token usage efficiency assessment`,\n `4. Recommendations for improving throughput`,\n `5. Priority items for next week`,\n ].join(\"\\n\");\n\n return {\n description: \"Weekly progress summary prompt for the Fifony workspace.\",\n messages: [{\n role: \"user\",\n content: { type: \"text\", text: summaryText },\n }],\n };\n }\n\n if (name === \"fifony-refine-plan\") {\n const issueId = typeof args.issueId === \"string\" ? args.issueId.trim() : \"\";\n const concern = typeof args.concern === \"string\" ? args.concern.trim() : \"\";\n if (!issueId) throw new Error(\"issueId is required\");\n const issue = await getIssue(issueId);\n if (!issue) throw new Error(`Issue not found: ${issueId}`);\n const issueData = issue as any;\n const plan = issueData.plan ?? null;\n\n const steps = plan?.steps ?? [];\n const stepsText = steps.length > 0\n ? steps.map((step: any, index: number) => `${index + 1}. **${step.title ?? step.description ?? \"Step\"}**\\n ${step.description ?? step.detail ?? \"\"}`).join(\"\\n\")\n : \"No steps defined.\";\n\n const refinementText = [\n `# Plan Refinement for Issue ${issueId}`,\n ``,\n `## Issue`,\n `- **Title**: ${issueData.title ?? \"Unknown\"}`,\n `- **Description**: ${issueData.description ?? \"No description\"}`,\n ``,\n `## Current Plan`,\n plan ? `- **Summary**: ${plan.summary ?? plan.title ?? \"No summary\"}` : \"No plan exists yet.\",\n plan?.estimatedComplexity ? `- **Complexity**: ${plan.estimatedComplexity}` : \"\",\n ``,\n `### Steps`,\n stepsText,\n ``,\n concern ? `## Specific Concern\\n${concern}\\n` : \"\",\n `## Refinement Guidance`,\n `Please review the current plan and provide specific, actionable feedback:`,\n `1. Are the steps correctly ordered and complete?`,\n `2. Are there missing edge cases or error handling steps?`,\n `3. Is the complexity estimate accurate?`,\n `4. Are the file paths and affected areas correct?`,\n `5. Should any steps be split, merged, or removed?`,\n ``,\n `Provide your feedback, and it will be used to refine the plan via \\`fifony.refine\\`.`,\n ].filter((line) => line !== undefined).join(\"\\n\");\n\n return {\n description: `Plan refinement prompt for issue ${issueId}.`,\n messages: [{\n role: \"user\",\n content: { type: \"text\", text: refinementText },\n }],\n };\n }\n\n if (name === \"fifony-code-review\") {\n const issueId = typeof args.issueId === \"string\" ? args.issueId.trim() : \"\";\n if (!issueId) throw new Error(\"issueId is required\");\n const issue = await getIssue(issueId);\n if (!issue) throw new Error(`Issue not found: ${issueId}`);\n const issueData = issue as any;\n\n let diffData: Record<string, unknown> = {};\n try {\n diffData = await apiGet(`/api/diff/${encodeURIComponent(issueId)}`);\n } catch (error) {\n throw new Error(`Cannot fetch diff for issue ${issueId}. Is the runtime running? ${String(error)}`);\n }\n\n const files = Array.isArray((diffData as any).files) ? (diffData as any).files : [];\n const diff = typeof (diffData as any).diff === \"string\" ? (diffData as any).diff : \"\";\n const totalAdditions = typeof (diffData as any).totalAdditions === \"number\" ? (diffData as any).totalAdditions : 0;\n const totalDeletions = typeof (diffData as any).totalDeletions === \"number\" ? (diffData as any).totalDeletions : 0;\n\n if (!diff.trim()) {\n return {\n description: `Code review prompt for issue ${issueId} (no changes).`,\n messages: [{\n role: \"user\",\n content: { type: \"text\", text: `# Code Review for ${issueId}\\n\\nNo code changes found for this issue. The workspace may not have been created yet or no modifications were made.` },\n }],\n };\n }\n\n const filesTable = files.map((file: any) => `| ${file.path} | ${file.status} | +${file.additions} | -${file.deletions} |`).join(\"\\n\");\n\n const reviewText = [\n `# Code Review for Issue ${issueId}`,\n ``,\n `## Issue Context`,\n `- **Title**: ${issueData.title ?? \"Unknown\"}`,\n `- **Description**: ${issueData.description ?? \"No description\"}`,\n `- **State**: ${issueData.state ?? \"Unknown\"}`,\n ``,\n `## Change Summary`,\n `- **Files Changed**: ${files.length}`,\n `- **Total Additions**: +${totalAdditions}`,\n `- **Total Deletions**: -${totalDeletions}`,\n ``,\n `### Files`,\n `| Path | Status | Additions | Deletions |`,\n `|------|--------|-----------|-----------|`,\n filesTable,\n ``,\n `## Diff`,\n \"```diff\",\n diff.length > 50000 ? diff.substring(0, 50000) + \"\\n... (diff truncated at 50KB)\" : diff,\n \"```\",\n ``,\n `## Review Checklist`,\n `Please review the changes and evaluate:`,\n `1. **Correctness**: Do the changes correctly implement what the issue describes?`,\n `2. **Code Quality**: Is the code clean, readable, and follows project conventions?`,\n `3. **Error Handling**: Are edge cases and errors properly handled?`,\n `4. **Security**: Are there any security concerns (hardcoded secrets, SQL injection, XSS)?`,\n `5. **Performance**: Are there any performance concerns or inefficiencies?`,\n `6. **Tests**: Are changes adequately covered by tests?`,\n `7. **Breaking Changes**: Do any changes break backward compatibility?`,\n ].join(\"\\n\");\n\n return {\n description: `Code review prompt for issue ${issueId}.`,\n messages: [{\n role: \"user\",\n content: { type: \"text\", text: reviewText },\n }],\n };\n }\n\n throw new Error(`Unknown prompt: ${name}`);\n}\n\nfunction listTools(): Array<Record<string, unknown>> {\n return [\n { name: \"fifony.status\", description: \"Return a compact status summary for the current Fifony workspace.\", inputSchema: { type: \"object\", properties: {}, additionalProperties: false } },\n { name: \"fifony.list_issues\", description: \"List issues from the Fifony durable store.\", inputSchema: { type: \"object\", properties: { state: { type: \"string\" }, capabilityCategory: { type: \"string\" }, category: { type: \"string\" } }, additionalProperties: false } },\n { name: \"fifony.create_issue\", description: \"Create a new issue directly in the Fifony durable store.\", inputSchema: { type: \"object\", properties: { id: { type: \"string\" }, title: { type: \"string\" }, description: { type: \"string\" }, priority: { type: \"number\" }, state: { type: \"string\" }, labels: { type: \"array\", items: { type: \"string\" } }, paths: { type: \"array\", items: { type: \"string\" } } }, required: [\"title\"], additionalProperties: false } },\n { name: \"fifony.update_issue_state\", description: \"Update an issue state in the Fifony store and append an event.\", inputSchema: { type: \"object\", properties: { issueId: { type: \"string\" }, state: { type: \"string\" }, note: { type: \"string\" } }, required: [\"issueId\", \"state\"], additionalProperties: false } },\n { name: \"fifony.plan\", description: \"Generate an AI plan for an issue. The issue must be in Planning state. Returns the plan summary and step count.\", inputSchema: { type: \"object\", properties: { issueId: { type: \"string\", description: \"The issue identifier to plan.\" }, fast: { type: \"boolean\", description: \"Use fast planning mode (less thorough but quicker).\" } }, required: [\"issueId\"], additionalProperties: false } },\n { name: \"fifony.refine\", description: \"Refine an existing plan with feedback. The issue must already have a plan.\", inputSchema: { type: \"object\", properties: { issueId: { type: \"string\", description: \"The issue identifier whose plan to refine.\" }, feedback: { type: \"string\", description: \"Feedback to guide the plan refinement.\" } }, required: [\"issueId\", \"feedback\"], additionalProperties: false } },\n { name: \"fifony.approve\", description: \"Approve a plan and move the issue to Todo for execution.\", inputSchema: { type: \"object\", properties: { issueId: { type: \"string\", description: \"The issue identifier to approve.\" } }, required: [\"issueId\"], additionalProperties: false } },\n { name: \"fifony.merge\", description: \"Merge workspace changes back into the project root. Copies new/modified files from the issue workspace to TARGET_ROOT and removes files that were deleted. Skips fifony internal files, node_modules, .git, and dist.\", inputSchema: { type: \"object\", properties: { issueId: { type: \"string\", description: \"The issue identifier whose workspace to merge.\" } }, required: [\"issueId\"], additionalProperties: false } },\n { name: \"fifony.analytics\", description: \"Get token usage analytics including overall totals, cost estimates, and top issues by token consumption.\", inputSchema: { type: \"object\", properties: {}, additionalProperties: false } },\n { name: \"fifony.integration_config\", description: \"Generate a ready-to-paste MCP client configuration snippet for this Fifony workspace.\", inputSchema: { type: \"object\", properties: { client: { type: \"string\" } }, additionalProperties: false } },\n { name: \"fifony.list_integrations\", description: \"List discovered local integrations such as agency-agents profiles and impeccable skills.\", inputSchema: { type: \"object\", properties: {}, additionalProperties: false } },\n { name: \"fifony.integration_snippet\", description: \"Generate a workflow or prompt snippet for a discovered integration.\", inputSchema: { type: \"object\", properties: { integration: { type: \"string\" } }, required: [\"integration\"], additionalProperties: false } },\n { name: \"fifony.resolve_capabilities\", description: \"Resolve which providers, roles, profiles, and overlays Fifony should use for a task.\", inputSchema: { type: \"object\", properties: { title: { type: \"string\" }, description: { type: \"string\" }, labels: { type: \"array\", items: { type: \"string\" } }, paths: { type: \"array\", items: { type: \"string\" } } }, required: [\"title\"], additionalProperties: false } },\n { name: \"fifony.get_issue\", description: \"Get full detail of a single issue including plan, history, events, and diff status.\", inputSchema: { type: \"object\", properties: { issueId: { type: \"string\", description: \"The issue identifier.\" } }, required: [\"issueId\"], additionalProperties: false } },\n { name: \"fifony.cancel_issue\", description: \"Cancel an issue, moving it to Cancelled state.\", inputSchema: { type: \"object\", properties: { issueId: { type: \"string\", description: \"The issue identifier to cancel.\" } }, required: [\"issueId\"], additionalProperties: false } },\n { name: \"fifony.retry_issue\", description: \"Retry a failed or blocked issue, resetting it to Todo state.\", inputSchema: { type: \"object\", properties: { issueId: { type: \"string\", description: \"The issue identifier to retry.\" } }, required: [\"issueId\"], additionalProperties: false } },\n { name: \"fifony.enhance\", description: \"AI-enhance an issue title or description. Provide either an issueId to enhance an existing issue, or title+description for standalone enhancement.\", inputSchema: { type: \"object\", properties: { issueId: { type: \"string\", description: \"Issue identifier (optional, for existing issues).\" }, title: { type: \"string\", description: \"Issue title (for standalone enhancement).\" }, description: { type: \"string\", description: \"Issue description (for standalone enhancement).\" }, field: { type: \"string\", enum: [\"title\", \"description\"], description: \"Which field to enhance.\" } }, required: [\"field\"], additionalProperties: false } },\n { name: \"fifony.get_diff\", description: \"Get git diff for an issue's workspace, including per-file summary and full diff text.\", inputSchema: { type: \"object\", properties: { issueId: { type: \"string\", description: \"The issue identifier.\" } }, required: [\"issueId\"], additionalProperties: false } },\n { name: \"fifony.get_live\", description: \"Get live agent output for a running issue, including log tail, PID, elapsed time, and status.\", inputSchema: { type: \"object\", properties: { issueId: { type: \"string\", description: \"The issue identifier.\" } }, required: [\"issueId\"], additionalProperties: false } },\n { name: \"fifony.get_events\", description: \"Get event feed, optionally filtered by issue, kind, or limited.\", inputSchema: { type: \"object\", properties: { issueId: { type: \"string\", description: \"Filter events by issue identifier.\" }, kind: { type: \"string\", description: \"Filter events by kind (info, error, state, manual, progress).\" }, limit: { type: \"number\", description: \"Maximum number of events to return (default 50).\" } }, additionalProperties: false } },\n { name: \"fifony.get_workflow\", description: \"Get the current pipeline workflow configuration including providers, models, and effort for plan/execute/review stages.\", inputSchema: { type: \"object\", properties: {}, additionalProperties: false } },\n { name: \"fifony.set_workflow\", description: \"Update the pipeline workflow configuration. Each stage (plan, execute, review) needs provider, model, and effort.\", inputSchema: { type: \"object\", properties: { plan: { type: \"object\", properties: { provider: { type: \"string\" }, model: { type: \"string\" }, effort: { type: \"string\" } }, required: [\"provider\", \"model\", \"effort\"] }, execute: { type: \"object\", properties: { provider: { type: \"string\" }, model: { type: \"string\" }, effort: { type: \"string\" } }, required: [\"provider\", \"model\", \"effort\"] }, review: { type: \"object\", properties: { provider: { type: \"string\" }, model: { type: \"string\" }, effort: { type: \"string\" } }, required: [\"provider\", \"model\", \"effort\"] } }, required: [\"plan\", \"execute\", \"review\"], additionalProperties: false } },\n { name: \"fifony.scan_project\", description: \"Scan the target project structure, returning files, directories, and detected technologies.\", inputSchema: { type: \"object\", properties: {}, additionalProperties: false } },\n { name: \"fifony.install_agents\", description: \"Install agents from the Fifony catalog into the target workspace.\", inputSchema: { type: \"object\", properties: { agents: { type: \"array\", items: { type: \"string\" }, description: \"List of agent names to install.\" } }, required: [\"agents\"], additionalProperties: false } },\n { name: \"fifony.install_skills\", description: \"Install skills from the Fifony catalog into the target workspace.\", inputSchema: { type: \"object\", properties: { skills: { type: \"array\", items: { type: \"string\" }, description: \"List of skill names to install.\" } }, required: [\"skills\"], additionalProperties: false } },\n ];\n}\n\nfunction toolText(text: string): Record<string, unknown> {\n return { content: [{ type: \"text\", text }] };\n}\n\nasync function resolveApiBaseUrl(): Promise<string> {\n const envPort = env.FIFONY_API_PORT;\n if (envPort) return `http://localhost:${envPort}`;\n\n const runtime = await getRuntimeSnapshot();\n const config = runtime.config as Record<string, unknown> | undefined;\n const port = config?.dashboardPort;\n if (port) return `http://localhost:${port}`;\n\n // Fallback: try common ports\n for (const candidate of [4000, 3000, 8080]) {\n try {\n const res = await fetch(`http://localhost:${candidate}/health`, { signal: AbortSignal.timeout(1000) });\n if (res.ok) return `http://localhost:${candidate}`;\n } catch {}\n }\n\n throw new Error(\"Fifony runtime API is not reachable. Start the runtime with --port to enable plan/refine/approve/analytics tools.\");\n}\n\nasync function apiPost(path: string, body: Record<string, unknown> = {}): Promise<Record<string, unknown>> {\n const base = await resolveApiBaseUrl();\n const res = await fetch(`${base}${path}`, {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify(body),\n signal: AbortSignal.timeout(120_000),\n });\n const json = await res.json() as Record<string, unknown>;\n if (!res.ok || json.ok === false) {\n throw new Error(typeof json.error === \"string\" ? json.error : `API request failed: ${res.status}`);\n }\n return json;\n}\n\nasync function apiGet(path: string): Promise<Record<string, unknown>> {\n const base = await resolveApiBaseUrl();\n const res = await fetch(`${base}${path}`, {\n signal: AbortSignal.timeout(30_000),\n });\n const json = await res.json() as Record<string, unknown>;\n if (!res.ok || json.ok === false) {\n throw new Error(typeof json.error === \"string\" ? json.error : `API request failed: ${res.status}`);\n }\n return json;\n}\n\nasync function callTool(name: string, args: Record<string, unknown> = {}): Promise<Record<string, unknown>> {\n if (name === \"fifony.status\") return toolText(await buildStateSummary());\n\n if (name === \"fifony.list_issues\") {\n const stateFilter = typeof args.state === \"string\" && args.state.trim() ? args.state.trim() : \"\";\n const capabilityCategory = typeof args.capabilityCategory === \"string\" && args.capabilityCategory.trim()\n ? args.capabilityCategory.trim()\n : typeof args.category === \"string\" && args.category.trim() ? args.category.trim() : \"\";\n return toolText(JSON.stringify(await listIssues({ state: stateFilter || undefined, capabilityCategory: capabilityCategory || undefined }), null, 2));\n }\n\n if (name === \"fifony.create_issue\") {\n await initDatabase();\n const { issueResource } = getResources();\n const title = typeof args.title === \"string\" ? args.title.trim() : \"\";\n if (!title) throw new Error(\"title is required\");\n\n const explicitId = typeof args.id === \"string\" && args.id.trim() ? args.id.trim() : \"\";\n const issueId = explicitId || `LOCAL-${hashInput(`${title}:${nowIso()}`)}`.toUpperCase();\n const description = typeof args.description === \"string\" ? args.description : \"\";\n const priority = typeof args.priority === \"number\" ? args.priority : 2;\n const state = typeof args.state === \"string\" && args.state.trim() ? args.state.trim() : \"Todo\";\n const baseLabels = Array.isArray(args.labels) ? args.labels.filter((value): value is string => typeof value === \"string\") : [\"fifony\", \"mcp\"];\n const paths = Array.isArray(args.paths) ? args.paths.filter((value): value is string => typeof value === \"string\") : [];\n const inferredPaths = inferCapabilityPaths({ id: issueId, identifier: issueId, title, description, labels: baseLabels, paths });\n const resolution = resolveTaskCapabilities({ id: issueId, identifier: issueId, title, description, labels: baseLabels, paths });\n const labels = [...new Set([...baseLabels, resolution.category ? `capability:${resolution.category}` : \"\", ...resolution.overlays.map((overlay) => `overlay:${overlay}`)].filter(Boolean))];\n\n const record = await issueResource?.insert({\n id: issueId, identifier: issueId, title, description, priority, state, labels, paths, inferredPaths,\n capabilityCategory: resolution.category, capabilityOverlays: resolution.overlays, capabilityRationale: resolution.rationale,\n blockedBy: [], assignedToWorker: false, createdAt: nowIso(), url: `fifony://local/${issueId}`,\n updatedAt: nowIso(), history: [`[${nowIso()}] Issue created via MCP.`], attempts: 0, maxAttempts: 3,\n });\n\n await appendEvent(\"info\", `Issue ${issueId} created through MCP.`, { title, state, labels, paths, inferredPaths, capabilityCategory: resolution.category }, issueId);\n return toolText(JSON.stringify(record ?? { id: issueId }, null, 2));\n }\n\n if (name === \"fifony.update_issue_state\") {\n await initDatabase();\n const { issueResource } = getResources();\n const issueId = typeof args.issueId === \"string\" ? args.issueId.trim() : \"\";\n const state = typeof args.state === \"string\" ? args.state.trim() : \"\";\n const note = typeof args.note === \"string\" ? args.note : \"\";\n if (!issueId || !state) throw new Error(\"issueId and state are required\");\n\n const current = await issueResource?.get(issueId);\n if (!current) throw new Error(`Issue not found: ${issueId}`);\n\n const updated = await issueResource?.update(issueId, { state, updatedAt: nowIso() });\n await appendEvent(\"info\", note || `Issue ${issueId} moved to ${state} through MCP.`, { state }, issueId);\n return toolText(JSON.stringify(updated ?? { id: issueId, state }, null, 2));\n }\n\n if (name === \"fifony.plan\") {\n const issueId = typeof args.issueId === \"string\" ? args.issueId.trim() : \"\";\n if (!issueId) throw new Error(\"issueId is required\");\n const fast = args.fast === true;\n const result = await apiPost(`/api/issues/${encodeURIComponent(issueId)}/plan`, { fast });\n const issue = result.issue as Record<string, unknown> | undefined;\n const plan = issue?.plan as Record<string, unknown> | undefined;\n const steps = Array.isArray(plan?.steps) ? plan.steps : [];\n return toolText(JSON.stringify({\n issueId,\n state: issue?.state ?? \"Planning\",\n planSummary: plan?.summary ?? plan?.title ?? \"Plan generation started in background.\",\n stepCount: steps.length,\n estimatedComplexity: plan?.estimatedComplexity ?? null,\n message: steps.length > 0\n ? `Plan generated with ${steps.length} step(s). Use fifony.approve to start execution or fifony.refine to adjust.`\n : \"Plan generation started in background. Poll the issue status to check progress.\",\n }, null, 2));\n }\n\n if (name === \"fifony.refine\") {\n const issueId = typeof args.issueId === \"string\" ? args.issueId.trim() : \"\";\n const feedback = typeof args.feedback === \"string\" ? args.feedback.trim() : \"\";\n if (!issueId) throw new Error(\"issueId is required\");\n if (!feedback) throw new Error(\"feedback is required\");\n const result = await apiPost(`/api/issues/${encodeURIComponent(issueId)}/plan/refine`, { feedback });\n const issue = result.issue as Record<string, unknown> | undefined;\n const plan = issue?.plan as Record<string, unknown> | undefined;\n const steps = Array.isArray(plan?.steps) ? plan.steps : [];\n return toolText(JSON.stringify({\n issueId,\n planSummary: plan?.summary ?? plan?.title ?? \"Plan refinement started in background.\",\n stepCount: steps.length,\n estimatedComplexity: plan?.estimatedComplexity ?? null,\n message: \"Plan refinement started in background. The plan will be updated via WebSocket when complete.\",\n }, null, 2));\n }\n\n if (name === \"fifony.approve\") {\n const issueId = typeof args.issueId === \"string\" ? args.issueId.trim() : \"\";\n if (!issueId) throw new Error(\"issueId is required\");\n const result = await apiPost(`/api/issues/${encodeURIComponent(issueId)}/approve`);\n const issue = result.issue as Record<string, unknown> | undefined;\n return toolText(JSON.stringify({\n issueId,\n state: issue?.state ?? \"Todo\",\n message: `Plan approved for ${issueId}. Issue moved to Todo and is ready for execution.`,\n }, null, 2));\n }\n\n if (name === \"fifony.merge\") {\n const issueId = typeof args.issueId === \"string\" ? args.issueId.trim() : \"\";\n if (!issueId) throw new Error(\"issueId is required\");\n const result = await apiPost(`/api/issues/${encodeURIComponent(issueId)}/merge`);\n return toolText(JSON.stringify({\n issueId,\n copied: result.copied,\n deleted: result.deleted,\n skipped: result.skipped,\n message: `Merged ${(result.copied as string[])?.length ?? 0} files into project root. ${(result.deleted as string[])?.length ?? 0} files removed.`,\n }, null, 2));\n }\n\n if (name === \"fifony.analytics\") {\n const result = await apiGet(\"/api/analytics/tokens\");\n const overall = result.overall as Record<string, unknown> | undefined;\n const topIssues = result.topIssues as Array<Record<string, unknown>> | undefined;\n const byModel = result.byModel as Record<string, Record<string, unknown>> | undefined;\n\n // Compute cost estimate (rough: $3/M input, $15/M output for Claude-class models)\n const inputTokens = typeof overall?.inputTokens === \"number\" ? overall.inputTokens : 0;\n const outputTokens = typeof overall?.outputTokens === \"number\" ? overall.outputTokens : 0;\n const totalTokens = typeof overall?.totalTokens === \"number\" ? overall.totalTokens : 0;\n const estimatedCost = (inputTokens / 1_000_000) * 3 + (outputTokens / 1_000_000) * 15;\n\n return toolText(JSON.stringify({\n overall: { inputTokens, outputTokens, totalTokens },\n estimatedCostUsd: Math.round(estimatedCost * 100) / 100,\n modelBreakdown: byModel ?? {},\n topIssues: (topIssues ?? []).slice(0, 10).map((issue) => ({\n id: issue.id,\n totalTokens: issue.totalTokens,\n inputTokens: issue.inputTokens,\n outputTokens: issue.outputTokens,\n })),\n }, null, 2));\n }\n\n if (name === \"fifony.integration_config\") {\n const client = typeof args.client === \"string\" && args.client.trim() ? args.client.trim() : \"client\";\n return toolText(JSON.stringify({ client, mcpServers: { fifony: { command: \"npx\", args: [\"fifony\", \"mcp\", \"--workspace\", WORKSPACE_ROOT, \"--persistence\", PERSISTENCE_ROOT] } } }, null, 2));\n }\n\n if (name === \"fifony.list_integrations\") return toolText(JSON.stringify(discoverIntegrations(WORKSPACE_ROOT), null, 2));\n\n if (name === \"fifony.integration_snippet\") {\n const integration = typeof args.integration === \"string\" ? args.integration : \"\";\n return toolText(await buildIntegrationSnippet(integration, WORKSPACE_ROOT));\n }\n\n if (name === \"fifony.resolve_capabilities\") {\n const title = typeof args.title === \"string\" ? args.title : \"\";\n const description = typeof args.description === \"string\" ? args.description : \"\";\n const labels = Array.isArray(args.labels) ? args.labels.filter((value): value is string => typeof value === \"string\") : [];\n const paths = Array.isArray(args.paths) ? args.paths.filter((value): value is string => typeof value === \"string\") : [];\n return toolText(JSON.stringify({ inferredPaths: inferCapabilityPaths({ title, description, labels, paths }), resolution: resolveTaskCapabilities({ title, description, labels, paths }) }, null, 2));\n }\n\n if (name === \"fifony.get_issue\") {\n const issueId = typeof args.issueId === \"string\" ? args.issueId.trim() : \"\";\n if (!issueId) throw new Error(\"issueId is required\");\n const issue = await getIssue(issueId);\n if (!issue) throw new Error(`Issue not found: ${issueId}`);\n // Enrich with diff status and events from API when available\n let diff: Record<string, unknown> | null = null;\n let events: unknown[] = [];\n try { diff = await apiGet(`/api/diff/${encodeURIComponent(issueId)}`); } catch {}\n try {\n const evResult = await apiGet(`/api/events/feed?issueId=${encodeURIComponent(issueId)}`);\n events = Array.isArray((evResult as any).events) ? (evResult as any).events : [];\n } catch {}\n const issueObj = issue as Record<string, unknown>;\n const mergeInfo = issueObj.mergedAt\n ? { mergedAt: issueObj.mergedAt, mergeResult: issueObj.mergeResult, message: `Code merged to project root at ${issueObj.mergedAt}. Available for testing.` }\n : null;\n return toolText(JSON.stringify({\n issue,\n mergeStatus: mergeInfo,\n diffSummary: diff ? { files: (diff as any).files, totalAdditions: (diff as any).totalAdditions, totalDeletions: (diff as any).totalDeletions } : null,\n recentEvents: (events as any[]).slice(0, 20),\n }, null, 2));\n }\n\n if (name === \"fifony.cancel_issue\") {\n const issueId = typeof args.issueId === \"string\" ? args.issueId.trim() : \"\";\n if (!issueId) throw new Error(\"issueId is required\");\n try {\n const result = await apiPost(`/api/issues/${encodeURIComponent(issueId)}/cancel`);\n const issue = result.issue as Record<string, unknown> | undefined;\n return toolText(JSON.stringify({ issueId, state: issue?.state ?? \"Cancelled\", message: `Issue ${issueId} has been cancelled.` }, null, 2));\n } catch (error) {\n throw new Error(`Failed to cancel issue ${issueId}: ${String(error)}`);\n }\n }\n\n if (name === \"fifony.retry_issue\") {\n const issueId = typeof args.issueId === \"string\" ? args.issueId.trim() : \"\";\n if (!issueId) throw new Error(\"issueId is required\");\n try {\n const result = await apiPost(`/api/issues/${encodeURIComponent(issueId)}/retry`);\n const issue = result.issue as Record<string, unknown> | undefined;\n return toolText(JSON.stringify({ issueId, state: issue?.state ?? \"Todo\", message: `Issue ${issueId} has been retried and reset to Todo.` }, null, 2));\n } catch (error) {\n throw new Error(`Failed to retry issue ${issueId}: ${String(error)}`);\n }\n }\n\n if (name === \"fifony.enhance\") {\n const field = typeof args.field === \"string\" ? args.field.trim() : \"\";\n if (field !== \"title\" && field !== \"description\") throw new Error('field must be \"title\" or \"description\"');\n const issueId = typeof args.issueId === \"string\" ? args.issueId.trim() : \"\";\n let title = typeof args.title === \"string\" ? args.title.trim() : \"\";\n let description = typeof args.description === \"string\" ? args.description.trim() : \"\";\n // If issueId given, fetch issue data to fill in title/description\n if (issueId && (!title || !description)) {\n const issue = await getIssue(issueId);\n if (!issue) throw new Error(`Issue not found: ${issueId}`);\n if (!title) title = (issue as any).title ?? \"\";\n if (!description) description = (issue as any).description ?? \"\";\n }\n try {\n const result = await apiPost(\"/api/issues/enhance\", { field, title, description });\n return toolText(JSON.stringify({ field: (result as any).field, value: (result as any).value, provider: (result as any).provider, issueId: issueId || undefined }, null, 2));\n } catch (error) {\n throw new Error(`Failed to enhance ${field}: ${String(error)}`);\n }\n }\n\n if (name === \"fifony.get_diff\") {\n const issueId = typeof args.issueId === \"string\" ? args.issueId.trim() : \"\";\n if (!issueId) throw new Error(\"issueId is required\");\n try {\n const result = await apiGet(`/api/diff/${encodeURIComponent(issueId)}`);\n return toolText(JSON.stringify(result, null, 2));\n } catch (error) {\n throw new Error(`Failed to get diff for ${issueId}: ${String(error)}`);\n }\n }\n\n if (name === \"fifony.get_live\") {\n const issueId = typeof args.issueId === \"string\" ? args.issueId.trim() : \"\";\n if (!issueId) throw new Error(\"issueId is required\");\n try {\n const result = await apiGet(`/api/live/${encodeURIComponent(issueId)}`);\n return toolText(JSON.stringify(result, null, 2));\n } catch (error) {\n throw new Error(`Failed to get live output for ${issueId}: ${String(error)}`);\n }\n }\n\n if (name === \"fifony.get_events\") {\n const issueId = typeof args.issueId === \"string\" ? args.issueId.trim() : \"\";\n const kind = typeof args.kind === \"string\" ? args.kind.trim() : \"\";\n const limit = typeof args.limit === \"number\" ? args.limit : 50;\n const params = new URLSearchParams();\n if (issueId) params.set(\"issueId\", issueId);\n if (kind) params.set(\"kind\", kind);\n const query = params.toString();\n try {\n const result = await apiGet(`/api/events/feed${query ? `?${query}` : \"\"}`);\n const events = Array.isArray((result as any).events) ? (result as any).events.slice(0, limit) : [];\n return toolText(JSON.stringify({ events, count: events.length }, null, 2));\n } catch (error) {\n // Fallback to local events\n const events = await listEvents({ limit: limit });\n const filtered = events.filter((event: any) => {\n if (issueId && event.issueId !== issueId) return false;\n if (kind && event.kind !== kind) return false;\n return true;\n }).slice(0, limit);\n return toolText(JSON.stringify({ events: filtered, count: filtered.length }, null, 2));\n }\n }\n\n if (name === \"fifony.get_workflow\") {\n try {\n const result = await apiGet(\"/api/config/workflow\");\n return toolText(JSON.stringify(result, null, 2));\n } catch (error) {\n throw new Error(`Failed to get workflow config: ${String(error)}`);\n }\n }\n\n if (name === \"fifony.set_workflow\") {\n const plan = args.plan as Record<string, unknown> | undefined;\n const execute = args.execute as Record<string, unknown> | undefined;\n const review = args.review as Record<string, unknown> | undefined;\n if (!plan || !execute || !review) throw new Error(\"plan, execute, and review are all required\");\n try {\n const result = await apiPost(\"/api/config/workflow\", { workflow: { plan, execute, review } });\n return toolText(JSON.stringify({ message: \"Workflow configuration updated successfully.\", workflow: (result as any).workflow }, null, 2));\n } catch (error) {\n throw new Error(`Failed to set workflow config: ${String(error)}`);\n }\n }\n\n if (name === \"fifony.scan_project\") {\n try {\n const result = await apiGet(\"/api/scan/project\");\n return toolText(JSON.stringify(result, null, 2));\n } catch (error) {\n throw new Error(`Failed to scan project: ${String(error)}`);\n }\n }\n\n if (name === \"fifony.install_agents\") {\n const agents = Array.isArray(args.agents) ? args.agents.filter((value): value is string => typeof value === \"string\") : [];\n if (agents.length === 0) throw new Error(\"At least one agent name is required\");\n try {\n const result = await apiPost(\"/api/install/agents\", { agents });\n return toolText(JSON.stringify(result, null, 2));\n } catch (error) {\n throw new Error(`Failed to install agents: ${String(error)}`);\n }\n }\n\n if (name === \"fifony.install_skills\") {\n const skills = Array.isArray(args.skills) ? args.skills.filter((value): value is string => typeof value === \"string\") : [];\n if (skills.length === 0) throw new Error(\"At least one skill name is required\");\n try {\n const result = await apiPost(\"/api/install/skills\", { skills });\n return toolText(JSON.stringify(result, null, 2));\n } catch (error) {\n throw new Error(`Failed to install skills: ${String(error)}`);\n }\n }\n\n throw new Error(`Unknown tool: ${name}`);\n}\n\n// ── JSON-RPC transport ───────────────────────────────────────────────────────\n\nfunction sendMessage(message: JsonRpcResponse): void {\n const payload = Buffer.from(JSON.stringify(message), \"utf8\");\n stdout.write(`Content-Length: ${payload.length}\\r\\n\\r\\n`);\n stdout.write(payload);\n}\n\nfunction sendResult(id: JsonRpcId, result: unknown): void {\n sendMessage({ jsonrpc: \"2.0\", id, result });\n}\n\nfunction sendError(id: JsonRpcId, code: number, message: string, data?: unknown): void {\n sendMessage({ jsonrpc: \"2.0\", id, error: { code, message, data } });\n}\n\nasync function handleRequest(request: JsonRpcRequest): Promise<void> {\n const id = request.id ?? null;\n try {\n switch (request.method) {\n case \"initialize\":\n sendResult(id, { protocolVersion: \"2024-11-05\", capabilities: { resources: {}, tools: {}, prompts: {} }, serverInfo: { name: \"fifony\", version: \"0.1.0\" } });\n return;\n case \"notifications/initialized\": return;\n case \"ping\": sendResult(id, {}); return;\n case \"resources/list\": sendResult(id, { resources: await listResourcesMcp() }); return;\n case \"resources/read\": sendResult(id, { contents: await readResource(String(request.params?.uri ?? \"\")) }); return;\n case \"tools/list\": sendResult(id, { tools: listTools() }); return;\n case \"tools/call\": sendResult(id, await callTool(String(request.params?.name ?? \"\"), (request.params?.arguments as Record<string, unknown> | undefined) ?? {})); return;\n case \"prompts/list\": sendResult(id, { prompts: listPrompts() }); return;\n case \"prompts/get\": sendResult(id, await getPrompt(String(request.params?.name ?? \"\"), (request.params?.arguments as Record<string, unknown> | undefined) ?? {})); return;\n default: sendError(id, -32601, `Method not found: ${request.method}`);\n }\n } catch (error) {\n sendError(id, -32000, String(error));\n }\n}\n\nfunction processIncomingBuffer(): void {\n while (true) {\n const separatorIndex = incomingBuffer.indexOf(\"\\r\\n\\r\\n\");\n if (separatorIndex === -1) return;\n\n const headerText = incomingBuffer.subarray(0, separatorIndex).toString(\"utf8\");\n const contentLengthHeader = headerText.split(\"\\r\\n\").find((line) => line.toLowerCase().startsWith(\"content-length:\"));\n if (!contentLengthHeader) { incomingBuffer = Buffer.alloc(0); return; }\n\n const contentLength = Number.parseInt(contentLengthHeader.split(\":\")[1]?.trim() ?? \"0\", 10);\n const messageStart = separatorIndex + 4;\n const messageEnd = messageStart + contentLength;\n if (incomingBuffer.length < messageEnd) return;\n\n const messageBody = incomingBuffer.subarray(messageStart, messageEnd).toString(\"utf8\");\n incomingBuffer = incomingBuffer.subarray(messageEnd);\n\n let request: JsonRpcRequest;\n try {\n request = JSON.parse(messageBody) as JsonRpcRequest;\n } catch (error) {\n sendError(null, -32700, `Invalid JSON: ${String(error)}`);\n continue;\n }\n\n void handleRequest(request);\n }\n}\n\n// ── Bootstrap ────────────────────────────────────────────────────────────────\n\nasync function bootstrap(): Promise<void> {\n debugBoot(\"mcp:bootstrap:start\");\n await initDatabase();\n debugBoot(\"mcp:bootstrap:database-ready\");\n await appendEvent(\"info\", \"Fifony MCP server started.\", { workspaceRoot: WORKSPACE_ROOT, persistenceRoot: PERSISTENCE_ROOT });\n\n stdin.on(\"data\", (chunk: Buffer) => {\n incomingBuffer = Buffer.concat([incomingBuffer, chunk]);\n processIncomingBuffer();\n });\n\n stdin.resume();\n debugBoot(\"mcp:bootstrap:stdin-ready\");\n}\n\nbootstrap().catch((error) => {\n sendError(null, -32001, `Failed to start Fifony MCP server: ${String(error)}`);\n process.exit(1);\n});\n\nprocess.on(\"SIGINT\", async () => {\n const db = getDatabase();\n if (db) await db.disconnect();\n process.exit(0);\n});\n\nprocess.on(\"SIGTERM\", async () => {\n const db = getDatabase();\n if (db) await db.disconnect();\n process.exit(0);\n});\n","import { existsSync, readdirSync, readFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { join, resolve } from \"node:path\";\nimport { renderPrompt } from \"../prompting.ts\";\n\nexport type FifonyIntegration = {\n id: \"agency-agents\" | \"impeccable\";\n kind: \"agents\" | \"skills\";\n installed: boolean;\n locations: string[];\n items: string[];\n summary: string;\n};\n\nfunction listNames(basePath: string): string[] {\n if (!existsSync(basePath)) {\n return [];\n }\n\n return readdirSync(basePath, { withFileTypes: true })\n .filter((entry) => entry.isDirectory() || entry.isFile())\n .map((entry) => entry.name)\n .sort((left, right) => left.localeCompare(right));\n}\n\nfunction readSkillSummary(skillPath: string): string {\n try {\n const skillFile = join(skillPath, \"SKILL.md\");\n if (!existsSync(skillFile)) {\n return \"\";\n }\n const contents = readFileSync(skillFile, \"utf8\");\n const firstParagraph = contents\n .split(\"\\n\")\n .map((line) => line.trim())\n .filter(Boolean)\n .find((line) => !line.startsWith(\"#\"));\n return firstParagraph ?? \"\";\n } catch {\n return \"\";\n }\n}\n\nexport function discoverIntegrations(workspaceRoot: string): FifonyIntegration[] {\n const home = homedir();\n const agentLocations = [\n resolve(workspaceRoot, \".codex\", \"agents\"),\n resolve(workspaceRoot, \"agents\"),\n join(home, \".codex\", \"agents\"),\n join(home, \".claude\", \"agents\"),\n ];\n const skillLocations = [\n resolve(workspaceRoot, \".codex\", \"skills\"),\n resolve(workspaceRoot, \".claude\", \"skills\"),\n join(home, \".codex\", \"skills\"),\n join(home, \".claude\", \"skills\"),\n ];\n\n const agencyItems = agentLocations\n .flatMap((location) => listNames(location).map((name) => ({ location, name })))\n .filter(({ name }) => name.startsWith(\"agency-\"))\n .map(({ location, name }) => `${name} @ ${location}`);\n\n const impeccableItems = skillLocations\n .flatMap((location) => listNames(location).map((name) => ({ location, name })))\n .filter(({ name }) =>\n name === \"teach-impeccable\"\n || name === \"frontend-design\"\n || name === \"polish\"\n || name === \"audit\"\n || name === \"critique\"\n || name.includes(\"impeccable\")\n )\n .map(({ location, name }) => {\n const summary = readSkillSummary(join(location, name));\n return summary ? `${name} @ ${location} — ${summary}` : `${name} @ ${location}`;\n });\n\n return [\n {\n id: \"agency-agents\",\n kind: \"agents\",\n installed: agencyItems.length > 0,\n locations: agentLocations.filter((location) => existsSync(location)),\n items: agencyItems,\n summary: agencyItems.length > 0\n ? \"Local specialized agent profiles are available for planner/executor/reviewer roles.\"\n : \"No agency agent profiles were detected in the standard local locations.\",\n },\n {\n id: \"impeccable\",\n kind: \"skills\",\n installed: impeccableItems.length > 0,\n locations: skillLocations.filter((location) => existsSync(location)),\n items: impeccableItems,\n summary: impeccableItems.length > 0\n ? \"Frontend and design-oriented skills are available for review and polish workflows.\"\n : \"No impeccable-related skills were detected in the standard local skill directories.\",\n },\n ];\n}\n\nexport async function buildIntegrationSnippet(integrationId: string, workspaceRoot: string): Promise<string> {\n if (integrationId === \"agency-agents\") {\n return renderPrompt(\"integrations-agency-agents\", { workspaceRoot });\n }\n\n if (integrationId === \"impeccable\") {\n return renderPrompt(\"integrations-impeccable\");\n }\n\n return \"Unknown integration.\";\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { basename, join, resolve } from \"node:path\";\nimport { env } from \"node:process\";\nimport { homedir } from \"node:os\";\nimport { fileURLToPath } from \"node:url\";\n\n// ── Types ────────────────────────────────────────────────────────────────────\n\nexport type IssueRecord = {\n id: string;\n identifier?: string;\n title: string;\n description?: string;\n priority?: number;\n state?: string;\n labels?: string[];\n paths?: string[];\n url?: string;\n assigned_to_worker?: boolean;\n [key: string]: unknown;\n};\n\nexport type RuntimeSnapshot = {\n updatedAt?: string;\n config?: Record<string, unknown>;\n issues?: IssueRecord[];\n metrics?: Record<string, unknown>;\n notes?: string[];\n [key: string]: unknown;\n};\n\nexport type S3dbResource = {\n insert: (record: Record<string, unknown>) => Promise<Record<string, unknown>>;\n get: (id: string) => Promise<Record<string, unknown> | null>;\n update: (id: string, patch: Record<string, unknown>) => Promise<Record<string, unknown>>;\n list: (options?: {\n partition?: string | null;\n partitionValues?: Record<string, string | number>;\n limit?: number;\n offset?: number;\n }) => Promise<Record<string, unknown>[]>;\n query?: (options?: Record<string, unknown>) => Promise<Record<string, unknown>[]>;\n};\n\nexport type S3dbDatabase = {\n connect: () => Promise<void>;\n disconnect: () => Promise<void>;\n createResource: (config: Record<string, unknown>) => Promise<S3dbResource>;\n resources: Record<string, S3dbResource>;\n};\n\ntype S3dbModule = {\n default: new (config: Record<string, unknown>) => S3dbDatabase;\n FileSystemClient: new (config: Record<string, unknown>) => unknown;\n};\n\n// ── Constants ────────────────────────────────────────────────────────────────\n\nconst WORKSPACE_ROOT = env.FIFONY_WORKSPACE_ROOT ?? process.cwd();\nconst PERSISTENCE_ROOT = env.FIFONY_PERSISTENCE ?? WORKSPACE_ROOT;\nconst STATE_ROOT = resolvePersistenceRoot(PERSISTENCE_ROOT);\nconst DATABASE_PATH = join(STATE_ROOT, \"s3db\");\nconst STORAGE_BUCKET = env.FIFONY_STORAGE_BUCKET ?? \"fifony\";\nconst STORAGE_KEY_PREFIX = env.FIFONY_STORAGE_KEY_PREFIX ?? \"state\";\nconst DEBUG_BOOT = env.FIFONY_DEBUG_BOOT === \"1\";\n\nfunction resolvePersistenceRoot(value: string): string {\n const resolved = value.startsWith(\"file://\")\n ? fileURLToPath(value)\n : value.startsWith(\"~/\")\n ? resolve(homedir(), value.slice(2))\n : resolve(value);\n\n return basename(resolved) === \".fifony\" ? resolved : join(resolved, \".fifony\");\n}\n\nexport const RUNTIME_RESOURCE = \"runtime_state\";\nexport const ISSUE_RESOURCE = \"issues\";\nexport const EVENT_RESOURCE = \"events\";\nexport const SESSION_RESOURCE = \"agent_sessions\";\nexport const PIPELINE_RESOURCE = \"agent_pipelines\";\nexport const RUNTIME_RECORD_ID = \"current\";\nexport { WORKSPACE_ROOT, PERSISTENCE_ROOT, STATE_ROOT };\n\n// ── State ────────────────────────────────────────────────────────────────────\n\nlet database: S3dbDatabase | null = null;\nlet runtimeResource: S3dbResource | null = null;\nlet issueResource: S3dbResource | null = null;\nlet eventResource: S3dbResource | null = null;\nlet sessionResource: S3dbResource | null = null;\nlet pipelineResource: S3dbResource | null = null;\n\nexport function getResources() {\n return { runtimeResource, issueResource, eventResource, sessionResource, pipelineResource };\n}\n\nexport function getDatabase(): S3dbDatabase | null {\n return database;\n}\n\n// ── Helpers ──────────────────────────────────────────────────────────────────\n\nfunction debugBoot(message: string): void {\n if (!DEBUG_BOOT) return;\n process.stderr.write(`[FIFONY_DEBUG_BOOT] ${message}\\n`);\n}\n\nexport function nowIso(): string {\n return new Date().toISOString();\n}\n\nexport function safeRead(path: string): string {\n return existsSync(path) ? readFileSync(path, \"utf8\") : \"\";\n}\n\n// ── Module loading ───────────────────────────────────────────────────────────\n\nasync function loadS3dbModule(): Promise<S3dbModule> {\n try {\n const imported = await import(\"s3db.js/lite\");\n return {\n default: imported.default,\n FileSystemClient: imported.FileSystemClient,\n };\n } catch (error) {\n throw new Error(`Unable to load s3db.js: ${String(error)}`);\n }\n}\n\n// ── Database initialization ──────────────────────────────────────────────────\n\nexport async function initDatabase(): Promise<S3dbDatabase> {\n if (database) return database;\n\n debugBoot(\"mcp:getDatabase:start\");\n const s3db = await loadS3dbModule();\n debugBoot(\"mcp:getDatabase:module-loaded\");\n const client = new s3db.FileSystemClient({\n basePath: DATABASE_PATH,\n bucket: STORAGE_BUCKET,\n keyPrefix: STORAGE_KEY_PREFIX,\n verbose: false,\n });\n\n database = new s3db.default({ client, verbose: false });\n await database.connect();\n debugBoot(\"mcp:getDatabase:connected\");\n\n runtimeResource = database.resources[RUNTIME_RESOURCE] ?? await database.createResource({\n name: RUNTIME_RESOURCE,\n behavior: \"body-overflow\",\n attributes: {\n updatedAt: \"datetime|required\",\n state: \"json|required\",\n },\n });\n\n issueResource = database.resources[ISSUE_RESOURCE] ?? await database.createResource({\n name: ISSUE_RESOURCE,\n behavior: \"body-overflow\",\n attributes: {\n id: \"string|required\",\n identifier: \"string|required\",\n title: \"string|required\",\n description: \"string|optional\",\n priority: \"number|required\",\n state: \"string|required\",\n branchName: \"string|optional\",\n labels: \"json|required\",\n paths: \"json|optional\",\n inferredPaths: \"json|optional\",\n capabilityCategory: \"string|optional\",\n capabilityOverlays: \"json|optional\",\n capabilityRationale: \"json|optional\",\n blockedBy: \"json|required\",\n assignedToWorker: \"boolean|required\",\n createdAt: \"datetime|required\",\n updatedAt: \"datetime|required\",\n history: \"json|required\",\n attempts: \"number|required\",\n maxAttempts: \"number|required\",\n url: \"string|optional\",\n assigneeId: \"string|optional\",\n startedAt: \"datetime|optional\",\n completedAt: \"datetime|optional\",\n nextRetryAt: \"datetime|optional\",\n workspacePath: \"string|optional\",\n workspacePreparedAt: \"datetime|optional\",\n lastError: \"string|optional\",\n durationMs: \"number|optional\",\n commandExitCode: \"number|optional\",\n commandOutputTail: \"string|optional\",\n },\n partitions: {\n byState: { fields: { state: \"string\" } },\n byCapabilityCategory: { fields: { capabilityCategory: \"string\" } },\n byStateAndCapability: {\n fields: { state: \"string\", capabilityCategory: \"string\" },\n },\n },\n asyncPartitions: true,\n });\n\n eventResource = database.resources[EVENT_RESOURCE] ?? await database.createResource({\n name: EVENT_RESOURCE,\n behavior: \"body-overflow\",\n attributes: {\n id: \"string|required\",\n issueId: \"string|optional\",\n kind: \"string|required\",\n message: \"string|required\",\n at: \"datetime|required\",\n },\n partitions: {\n byIssueId: { fields: { issueId: \"string\" } },\n byKind: { fields: { kind: \"string\" } },\n byIssueIdAndKind: { fields: { issueId: \"string\", kind: \"string\" } },\n },\n asyncPartitions: true,\n });\n\n sessionResource = database.resources[SESSION_RESOURCE] ?? await database.createResource({\n name: SESSION_RESOURCE,\n behavior: \"body-overflow\",\n attributes: {\n id: \"string|required\",\n issueId: \"string|required\",\n issueIdentifier: \"string|required\",\n attempt: \"number|required\",\n provider: \"string|required\",\n role: \"string|required\",\n cycle: \"number|required\",\n session: \"json|required\",\n updatedAt: \"datetime|required\",\n },\n partitions: {\n byIssueId: { fields: { issueId: \"string\" } },\n byIssueAttempt: { fields: { issueId: \"string\", attempt: \"number\" } },\n byProviderRole: { fields: { provider: \"string\", role: \"string\" } },\n },\n asyncPartitions: true,\n });\n\n pipelineResource = database.resources[PIPELINE_RESOURCE] ?? await database.createResource({\n name: PIPELINE_RESOURCE,\n behavior: \"body-overflow\",\n attributes: {\n id: \"string|required\",\n issueId: \"string|required\",\n issueIdentifier: \"string|required\",\n attempt: \"number|required\",\n pipeline: \"json|required\",\n updatedAt: \"datetime|required\",\n },\n partitions: {\n byIssueId: { fields: { issueId: \"string\" } },\n byIssueAttempt: { fields: { issueId: \"string\", attempt: \"number\" } },\n },\n asyncPartitions: true,\n });\n\n debugBoot(\"mcp:getDatabase:resources-ready\");\n return database;\n}\n\n// ── Query helpers ────────────────────────────────────────────────────────────\n\nexport async function listRecords(resource: S3dbResource | null, limit: number = 100): Promise<Record<string, unknown>[]> {\n if (!resource) return [];\n if (typeof resource.query === \"function\") return await resource.query({});\n return await resource.list({ limit });\n}\n\nexport async function listIssues(filters: { state?: string; capabilityCategory?: string } = {}): Promise<IssueRecord[]> {\n await initDatabase();\n const { state, capabilityCategory } = filters;\n\n if (!issueResource) return [];\n\n const partition = state && capabilityCategory\n ? \"byStateAndCapability\"\n : state ? \"byState\"\n : capabilityCategory ? \"byCapabilityCategory\"\n : null;\n const partitionValues = state && capabilityCategory\n ? { state, capabilityCategory }\n : state ? { state }\n : capabilityCategory ? { capabilityCategory }\n : {};\n\n const records = await issueResource.list({ partition, partitionValues, limit: 500 });\n return records.map((record) => record as IssueRecord);\n}\n\nexport async function listEvents(filters: { issueId?: string; kind?: string; limit?: number } = {}): Promise<Record<string, unknown>[]> {\n await initDatabase();\n const { issueId, kind, limit = 100 } = filters;\n\n if (!eventResource) return [];\n\n const partition = issueId && kind\n ? \"byIssueIdAndKind\"\n : issueId ? \"byIssueId\"\n : kind ? \"byKind\"\n : null;\n const partitionValues = issueId && kind\n ? { issueId, kind }\n : issueId ? { issueId }\n : kind ? { kind }\n : {};\n\n return await eventResource.list({ partition, partitionValues, limit });\n}\n\nexport async function getRuntimeSnapshot(): Promise<RuntimeSnapshot> {\n await initDatabase();\n const record = await runtimeResource?.get(RUNTIME_RECORD_ID);\n const state = record?.state;\n if (state && typeof state === \"object\") return state as RuntimeSnapshot;\n return {};\n}\n\nexport async function getIssues(): Promise<IssueRecord[]> {\n return await listIssues();\n}\n\nexport async function getIssue(issueId: string): Promise<IssueRecord | null> {\n await initDatabase();\n const issue = await issueResource?.get(issueId);\n return (issue as IssueRecord | null) ?? null;\n}\n\nexport async function appendEvent(level: string, message: string, payload: Record<string, unknown> = {}, issueId?: string): Promise<void> {\n await initDatabase();\n const { randomUUID } = await import(\"node:crypto\");\n await eventResource?.insert({\n id: randomUUID(),\n issueId,\n kind: level,\n message,\n at: nowIso(),\n });\n}\n"],"mappings":";;;;;;;AAAA,SAAS,kBAAkB;AAC3B,SAAS,cAAAA,mBAAkB;AAC3B,SAAS,SAAS,QAAAC,OAAM,WAAAC,gBAAe;AACvC,SAAS,OAAAC,MAAK,OAAO,cAAc;AACnC,SAAS,iBAAAC,sBAAqB;;;ACJ9B,SAAS,YAAY,aAAa,oBAAoB;AACtD,SAAS,eAAe;AACxB,SAAS,MAAM,eAAe;AAY9B,SAAS,UAAU,UAA4B;AAC7C,MAAI,CAAC,WAAW,QAAQ,GAAG;AACzB,WAAO,CAAC;AAAA,EACV;AAEA,SAAO,Y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AAIA,eAAe,YAA2B;AACxC,EAAAN,WAAU,qBAAqB;AAC/B,QAAM,aAAa;AACnB,EAAAA,WAAU,8BAA8B;AACxC,QAAM,YAAY,QAAQ,8BAA8B,EAAE,eAAe,gBAAgB,iBAAiB,iBAAiB,CAAC;AAE5H,QAAM,GAAG,QAAQ,CAAC,UAAkB;AAClC,qBAAiB,OAAO,OAAO,CAAC,gBAAgB,KAAK,CAAC;AACtD,0BAAsB;AAAA,EACxB,CAAC;AAED,QAAM,OAAO;AACb,EAAAA,WAAU,2BAA2B;AACvC;AAEA,UAAU,EAAE,MAAM,CAAC,UAAU;AAC3B,YAAU,MAAM,QAAQ,sCAAsC,OAAO,KAAK,CAAC,EAAE;AAC7E,UAAQ,KAAK,CAAC;AAChB,CAAC;AAED,QAAQ,GAAG,UAAU,YAAY;AAC/B,QAAM,KAAK,YAAY;AACvB,MAAI,GAAI,OAAM,GAAG,WAAW;AAC5B,UAAQ,KAAK,CAAC;AAChB,CAAC;AAED,QAAQ,GAAG,WAAW,YAAY;AAChC,QAAM,KAAK,YAAY;AACvB,MAAI,GAAI,OAAM,GAAG,WAAW;AAC5B,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["existsSync","join","resolve","env","fileURLToPath","existsSync","readFileSync","join","resolve","homedir","existsSync","readFileSync","fileURLToPath","resolve","join","DEBUG_BOOT","env","debugBoot","sessionResource","pipelineResource","existsSync","issueId","issue","issueResource"]}
|
|
1
|
+
{"version":3,"sources":["../../src/mcp/server.ts","../../src/mcp/database.ts","../../src/mcp/jsonrpc-transport.ts","../../src/agents/integrations/catalog.ts","../../src/mcp/api-client.ts","../../src/mcp/resources/resource-builder.ts","../../src/mcp/resources/resource-handlers.ts","../../src/mcp/tools/tool-list.ts","../../src/mcp/tools/tool-executor.ts","../../src/mcp/prompts/prompt-list.ts","../../src/mcp/prompts/prompt-handler.ts"],"sourcesContent":["import { env, stdin } from \"node:process\";\nimport {\n initDatabase,\n getDatabase,\n appendEvent,\n WORKSPACE_ROOT,\n PERSISTENCE_ROOT,\n} from \"./database.js\";\nimport {\n incomingBuffer,\n setIncomingBuffer,\n sendError,\n processIncomingBuffer,\n} from \"./jsonrpc-transport.js\";\n\nconst DEBUG_BOOT = env.FIFONY_DEBUG_BOOT === \"1\";\n\nfunction debugBoot(message: string): void {\n if (!DEBUG_BOOT) return;\n process.stderr.write(`[FIFONY_DEBUG_BOOT] ${message}\\n`);\n}\n\nasync function bootstrap(): Promise<void> {\n debugBoot(\"mcp:bootstrap:start\");\n await initDatabase();\n debugBoot(\"mcp:bootstrap:database-ready\");\n await appendEvent(\"info\", \"Fifony MCP server started.\", { workspaceRoot: WORKSPACE_ROOT, persistenceRoot: PERSISTENCE_ROOT });\n\n stdin.on(\"data\", (chunk: Buffer) => {\n setIncomingBuffer(Buffer.concat([incomingBuffer, chunk]));\n processIncomingBuffer();\n });\n\n stdin.resume();\n debugBoot(\"mcp:bootstrap:stdin-ready\");\n}\n\nbootstrap().catch((error) => {\n sendError(null, -32001, `Failed to start Fifony MCP server: ${String(error)}`);\n process.exit(1);\n});\n\nprocess.on(\"SIGINT\", async () => {\n const db = getDatabase();\n if (db) await db.disconnect();\n process.exit(0);\n});\n\nprocess.on(\"SIGTERM\", async () => {\n const db = getDatabase();\n if (db) await db.disconnect();\n process.exit(0);\n});\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { basename, join, resolve } from \"node:path\";\nimport { env } from \"node:process\";\nimport { homedir } from \"node:os\";\nimport { fileURLToPath } from \"node:url\";\n\n// ── Types ────────────────────────────────────────────────────────────────────\n\nexport type IssueRecord = {\n id: string;\n identifier?: string;\n title: string;\n description?: string;\n priority?: number;\n state?: string;\n labels?: string[];\n paths?: string[];\n url?: string;\n assigned_to_worker?: boolean;\n [key: string]: unknown;\n};\n\nexport type RuntimeSnapshot = {\n updatedAt?: string;\n config?: Record<string, unknown>;\n issues?: IssueRecord[];\n metrics?: Record<string, unknown>;\n notes?: string[];\n [key: string]: unknown;\n};\n\nexport type S3dbResource = {\n insert: (record: Record<string, unknown>) => Promise<Record<string, unknown>>;\n get: (id: string) => Promise<Record<string, unknown> | null>;\n update: (id: string, patch: Record<string, unknown>) => Promise<Record<string, unknown>>;\n list: (options?: {\n partition?: string | null;\n partitionValues?: Record<string, string | number>;\n limit?: number;\n offset?: number;\n }) => Promise<Record<string, unknown>[]>;\n query?: (options?: Record<string, unknown>) => Promise<Record<string, unknown>[]>;\n};\n\nexport type S3dbDatabase = {\n connect: () => Promise<void>;\n disconnect: () => Promise<void>;\n createResource: (config: Record<string, unknown>) => Promise<S3dbResource>;\n resources: Record<string, S3dbResource>;\n};\n\ntype S3dbModule = {\n default: new (config: Record<string, unknown>) => S3dbDatabase;\n SqliteClient: new (config: Record<string, unknown>) => unknown;\n};\n\n// ── Constants ────────────────────────────────────────────────────────────────\n\nconst WORKSPACE_ROOT = env.FIFONY_WORKSPACE_ROOT ?? process.cwd();\nconst PERSISTENCE_ROOT = env.FIFONY_PERSISTENCE ?? WORKSPACE_ROOT;\nconst STATE_ROOT = resolvePersistenceRoot(PERSISTENCE_ROOT);\nconst DATABASE_PATH = join(STATE_ROOT, \"fifony.sqlite\");\nconst DEBUG_BOOT = env.FIFONY_DEBUG_BOOT === \"1\";\n\nfunction resolvePersistenceRoot(value: string): string {\n const resolved = value.startsWith(\"file://\")\n ? fileURLToPath(value)\n : value.startsWith(\"~/\")\n ? resolve(homedir(), value.slice(2))\n : resolve(value);\n\n return basename(resolved) === \".fifony\" ? resolved : join(resolved, \".fifony\");\n}\n\nexport const RUNTIME_RESOURCE = \"runtime_state\";\nexport const ISSUE_RESOURCE = \"issues\";\nexport const EVENT_RESOURCE = \"events\";\nexport const SESSION_RESOURCE = \"agent_sessions\";\nexport const PIPELINE_RESOURCE = \"agent_pipelines\";\nexport const RUNTIME_RECORD_ID = \"current\";\nexport { WORKSPACE_ROOT, PERSISTENCE_ROOT, STATE_ROOT };\n\n// ── State ────────────────────────────────────────────────────────────────────\n\nlet database: S3dbDatabase | null = null;\nlet runtimeResource: S3dbResource | null = null;\nlet issueResource: S3dbResource | null = null;\nlet eventResource: S3dbResource | null = null;\nlet sessionResource: S3dbResource | null = null;\nlet pipelineResource: S3dbResource | null = null;\n\nexport function getResources() {\n return { runtimeResource, issueResource, eventResource, sessionResource, pipelineResource };\n}\n\nexport function getDatabase(): S3dbDatabase | null {\n return database;\n}\n\n// ── Helpers ──────────────────────────────────────────────────────────────────\n\nfunction debugBoot(message: string): void {\n if (!DEBUG_BOOT) return;\n process.stderr.write(`[FIFONY_DEBUG_BOOT] ${message}\\n`);\n}\n\nexport function nowIso(): string {\n return new Date().toISOString();\n}\n\nexport function safeRead(path: string): string {\n return existsSync(path) ? readFileSync(path, \"utf8\") : \"\";\n}\n\n// ── Module loading ───────────────────────────────────────────────────────────\n\nasync function loadS3dbModule(): Promise<S3dbModule> {\n try {\n const imported = await import(\"s3db.js\");\n return {\n default: imported.default,\n SqliteClient: imported.SqliteClient,\n };\n } catch (error) {\n throw new Error(`Unable to load s3db.js: ${String(error)}`);\n }\n}\n\n// ── Database initialization ──────────────────────────────────────────────────\n\nexport async function initDatabase(): Promise<S3dbDatabase> {\n if (database) return database;\n\n debugBoot(\"mcp:getDatabase:start\");\n const s3db = await loadS3dbModule();\n debugBoot(\"mcp:getDatabase:module-loaded\");\n const client = new s3db.SqliteClient({ basePath: DATABASE_PATH });\n database = new s3db.default({ client, verbose: false });\n await database.connect();\n debugBoot(\"mcp:getDatabase:connected\");\n\n runtimeResource = database.resources[RUNTIME_RESOURCE] ?? await database.createResource({\n name: RUNTIME_RESOURCE,\n behavior: \"body-overflow\",\n attributes: {\n updatedAt: \"datetime|required\",\n state: \"json|required\",\n },\n });\n\n issueResource = database.resources[ISSUE_RESOURCE] ?? await database.createResource({\n name: ISSUE_RESOURCE,\n behavior: \"body-overflow\",\n attributes: {\n id: \"string|required\",\n identifier: \"string|required\",\n title: \"string|required\",\n description: \"string|optional\",\n priority: \"number|required\",\n state: \"string|required\",\n branchName: \"string|optional\",\n labels: \"json|required\",\n paths: \"json|optional\",\n inferredPaths: \"json|optional\",\n capabilityCategory: \"string|optional\",\n capabilityOverlays: \"json|optional\",\n capabilityRationale: \"json|optional\",\n blockedBy: \"json|required\",\n assignedToWorker: \"boolean|required\",\n createdAt: \"datetime|required\",\n updatedAt: \"datetime|required\",\n history: \"json|required\",\n attempts: \"number|required\",\n maxAttempts: \"number|required\",\n url: \"string|optional\",\n assigneeId: \"string|optional\",\n startedAt: \"datetime|optional\",\n completedAt: \"datetime|optional\",\n nextRetryAt: \"datetime|optional\",\n workspacePath: \"string|optional\",\n workspacePreparedAt: \"datetime|optional\",\n lastError: \"string|optional\",\n durationMs: \"number|optional\",\n commandExitCode: \"number|optional\",\n commandOutputTail: \"string|optional\",\n },\n partitions: {\n byState: { fields: { state: \"string\" } },\n byCapabilityCategory: { fields: { capabilityCategory: \"string\" } },\n byStateAndCapability: {\n fields: { state: \"string\", capabilityCategory: \"string\" },\n },\n },\n asyncPartitions: true,\n });\n\n eventResource = database.resources[EVENT_RESOURCE] ?? await database.createResource({\n name: EVENT_RESOURCE,\n behavior: \"body-overflow\",\n attributes: {\n id: \"string|required\",\n issueId: \"string|optional\",\n kind: \"string|required\",\n message: \"string|required\",\n at: \"datetime|required\",\n },\n partitions: {\n byIssueId: { fields: { issueId: \"string\" } },\n byKind: { fields: { kind: \"string\" } },\n byIssueIdAndKind: { fields: { issueId: \"string\", kind: \"string\" } },\n },\n asyncPartitions: true,\n });\n\n sessionResource = database.resources[SESSION_RESOURCE] ?? await database.createResource({\n name: SESSION_RESOURCE,\n behavior: \"body-overflow\",\n attributes: {\n id: \"string|required\",\n issueId: \"string|required\",\n issueIdentifier: \"string|required\",\n attempt: \"number|required\",\n provider: \"string|required\",\n role: \"string|required\",\n cycle: \"number|required\",\n session: \"json|required\",\n updatedAt: \"datetime|required\",\n },\n partitions: {\n byIssueId: { fields: { issueId: \"string\" } },\n byIssueAttempt: { fields: { issueId: \"string\", attempt: \"number\" } },\n byProviderRole: { fields: { provider: \"string\", role: \"string\" } },\n },\n asyncPartitions: true,\n });\n\n pipelineResource = database.resources[PIPELINE_RESOURCE] ?? await database.createResource({\n name: PIPELINE_RESOURCE,\n behavior: \"body-overflow\",\n attributes: {\n id: \"string|required\",\n issueId: \"string|required\",\n issueIdentifier: \"string|required\",\n attempt: \"number|required\",\n pipeline: \"json|required\",\n updatedAt: \"datetime|required\",\n },\n partitions: {\n byIssueId: { fields: { issueId: \"string\" } },\n byIssueAttempt: { fields: { issueId: \"string\", attempt: \"number\" } },\n },\n asyncPartitions: true,\n });\n\n debugBoot(\"mcp:getDatabase:resources-ready\");\n return database;\n}\n\n// ── Query helpers ────────────────────────────────────────────────────────────\n\nexport async function listRecords(resource: S3dbResource | null, limit: number = 100): Promise<Record<string, unknown>[]> {\n if (!resource) return [];\n if (typeof resource.query === \"function\") return await resource.query({});\n return await resource.list({ limit });\n}\n\nexport async function listIssues(filters: { state?: string; capabilityCategory?: string } = {}): Promise<IssueRecord[]> {\n await initDatabase();\n const { state, capabilityCategory } = filters;\n\n if (!issueResource) return [];\n\n const partition = state && capabilityCategory\n ? \"byStateAndCapability\"\n : state ? \"byState\"\n : capabilityCategory ? \"byCapabilityCategory\"\n : null;\n const partitionValues = state && capabilityCategory\n ? { state, capabilityCategory }\n : state ? { state }\n : capabilityCategory ? { capabilityCategory }\n : {};\n\n const records = await issueResource.list({ partition, partitionValues, limit: 500 });\n return records.map((record) => record as IssueRecord);\n}\n\nexport async function listEvents(filters: { issueId?: string; kind?: string; limit?: number } = {}): Promise<Record<string, unknown>[]> {\n await initDatabase();\n const { issueId, kind, limit = 100 } = filters;\n\n if (!eventResource) return [];\n\n const partition = issueId && kind\n ? \"byIssueIdAndKind\"\n : issueId ? \"byIssueId\"\n : kind ? \"byKind\"\n : null;\n const partitionValues = issueId && kind\n ? { issueId, kind }\n : issueId ? { issueId }\n : kind ? { kind }\n : {};\n\n return await eventResource.list({ partition, partitionValues, limit });\n}\n\nexport async function getRuntimeSnapshot(): Promise<RuntimeSnapshot> {\n await initDatabase();\n const record = await runtimeResource?.get(RUNTIME_RECORD_ID);\n const state = record?.state;\n if (state && typeof state === \"object\") return state as RuntimeSnapshot;\n return {};\n}\n\nexport async function getIssues(): Promise<IssueRecord[]> {\n return await listIssues();\n}\n\nexport async function getIssue(issueId: string): Promise<IssueRecord | null> {\n await initDatabase();\n const issue = await issueResource?.get(issueId);\n return (issue as IssueRecord | null) ?? null;\n}\n\nexport async function appendEvent(level: string, message: string, payload: Record<string, unknown> = {}, issueId?: string): Promise<void> {\n await initDatabase();\n const { randomUUID } = await import(\"node:crypto\");\n await eventResource?.insert({\n id: randomUUID(),\n issueId,\n kind: level,\n message,\n at: nowIso(),\n });\n}\n","import { stdout } from \"node:process\";\nimport { type JsonRpcId, type JsonRpcRequest, type JsonRpcResponse } from \"./mcp-types.js\";\nimport { listResourcesMcp, readResource } from \"./resources/resource-handlers.js\";\nimport { listTools } from \"./tools/tool-list.js\";\nimport { callTool } from \"./tools/tool-executor.js\";\nimport { listPrompts } from \"./prompts/prompt-list.js\";\nimport { getPrompt } from \"./prompts/prompt-handler.js\";\n\nexport let incomingBuffer = Buffer.alloc(0);\n\nexport function setIncomingBuffer(buffer: Buffer): void {\n incomingBuffer = buffer;\n}\n\nexport function sendMessage(message: JsonRpcResponse): void {\n const payload = Buffer.from(JSON.stringify(message), \"utf8\");\n stdout.write(`Content-Length: ${payload.length}\\r\\n\\r\\n`);\n stdout.write(payload);\n}\n\nexport function sendResult(id: JsonRpcId, result: unknown): void {\n sendMessage({ jsonrpc: \"2.0\", id, result });\n}\n\nexport function sendError(id: JsonRpcId, code: number, message: string, data?: unknown): void {\n sendMessage({ jsonrpc: \"2.0\", id, error: { code, message, data } });\n}\n\nexport async function handleRequest(request: JsonRpcRequest): Promise<void> {\n const id = request.id ?? null;\n try {\n switch (request.method) {\n case \"initialize\":\n sendResult(id, { protocolVersion: \"2024-11-05\", capabilities: { resources: {}, tools: {}, prompts: {} }, serverInfo: { name: \"fifony\", version: \"0.1.0\" } });\n return;\n case \"notifications/initialized\": return;\n case \"ping\": sendResult(id, {}); return;\n case \"resources/list\": sendResult(id, { resources: await listResourcesMcp() }); return;\n case \"resources/read\": sendResult(id, { contents: await readResource(String(request.params?.uri ?? \"\")) }); return;\n case \"tools/list\": sendResult(id, { tools: listTools() }); return;\n case \"tools/call\": sendResult(id, await callTool(String(request.params?.name ?? \"\"), (request.params?.arguments as Record<string, unknown> | undefined) ?? {})); return;\n case \"prompts/list\": sendResult(id, { prompts: listPrompts() }); return;\n case \"prompts/get\": sendResult(id, await getPrompt(String(request.params?.name ?? \"\"), (request.params?.arguments as Record<string, unknown> | undefined) ?? {})); return;\n default: sendError(id, -32601, `Method not found: ${request.method}`);\n }\n } catch (error) {\n sendError(id, -32000, String(error));\n }\n}\n\nexport function processIncomingBuffer(): void {\n while (true) {\n const separatorIndex = incomingBuffer.indexOf(\"\\r\\n\\r\\n\");\n if (separatorIndex === -1) return;\n\n const headerText = incomingBuffer.subarray(0, separatorIndex).toString(\"utf8\");\n const contentLengthHeader = headerText.split(\"\\r\\n\").find((line) => line.toLowerCase().startsWith(\"content-length:\"));\n if (!contentLengthHeader) { incomingBuffer = Buffer.alloc(0); return; }\n\n const contentLength = Number.parseInt(contentLengthHeader.split(\":\")[1]?.trim() ?? \"0\", 10);\n const messageStart = separatorIndex + 4;\n const messageEnd = messageStart + contentLength;\n if (incomingBuffer.length < messageEnd) return;\n\n const messageBody = incomingBuffer.subarray(messageStart, messageEnd).toString(\"utf8\");\n incomingBuffer = incomingBuffer.subarray(messageEnd);\n\n let request: JsonRpcRequest;\n try {\n request = JSON.parse(messageBody) as JsonRpcRequest;\n } catch (error) {\n sendError(null, -32700, `Invalid JSON: ${String(error)}`);\n continue;\n }\n\n void handleRequest(request);\n }\n}\n","import { existsSync, readdirSync, readFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { join, resolve } from \"node:path\";\nimport { renderPrompt } from \"../prompting.ts\";\n\nexport type FifonyIntegration = {\n id: \"agency-agents\" | \"impeccable\";\n kind: \"agents\" | \"skills\";\n installed: boolean;\n locations: string[];\n items: string[];\n summary: string;\n};\n\nfunction listNames(basePath: string): string[] {\n if (!existsSync(basePath)) {\n return [];\n }\n\n return readdirSync(basePath, { withFileTypes: true })\n .filter((entry) => entry.isDirectory() || entry.isFile())\n .map((entry) => entry.name)\n .sort((left, right) => left.localeCompare(right));\n}\n\nfunction readSkillSummary(skillPath: string): string {\n try {\n const skillFile = join(skillPath, \"SKILL.md\");\n if (!existsSync(skillFile)) {\n return \"\";\n }\n const contents = readFileSync(skillFile, \"utf8\");\n const firstParagraph = contents\n .split(\"\\n\")\n .map((line) => line.trim())\n .filter(Boolean)\n .find((line) => !line.startsWith(\"#\"));\n return firstParagraph ?? \"\";\n } catch {\n return \"\";\n }\n}\n\nexport function discoverIntegrations(workspaceRoot: string): FifonyIntegration[] {\n const home = homedir();\n const agentLocations = [\n resolve(workspaceRoot, \".codex\", \"agents\"),\n resolve(workspaceRoot, \"agents\"),\n join(home, \".codex\", \"agents\"),\n join(home, \".claude\", \"agents\"),\n ];\n const skillLocations = [\n resolve(workspaceRoot, \".codex\", \"skills\"),\n resolve(workspaceRoot, \".claude\", \"skills\"),\n join(home, \".codex\", \"skills\"),\n join(home, \".claude\", \"skills\"),\n ];\n\n const agencyItems = agentLocations\n .flatMap((location) => listNames(location).map((name) => ({ location, name })))\n .filter(({ name }) => name.startsWith(\"agency-\"))\n .map(({ location, name }) => `${name} @ ${location}`);\n\n const impeccableItems = skillLocations\n .flatMap((location) => listNames(location).map((name) => ({ location, name })))\n .filter(({ name }) =>\n name === \"teach-impeccable\"\n || name === \"frontend-design\"\n || name === \"polish\"\n || name === \"audit\"\n || name === \"critique\"\n || name.includes(\"impeccable\")\n )\n .map(({ location, name }) => {\n const summary = readSkillSummary(join(location, name));\n return summary ? `${name} @ ${location} — ${summary}` : `${name} @ ${location}`;\n });\n\n return [\n {\n id: \"agency-agents\",\n kind: \"agents\",\n installed: agencyItems.length > 0,\n locations: agentLocations.filter((location) => existsSync(location)),\n items: agencyItems,\n summary: agencyItems.length > 0\n ? \"Local specialized agent profiles are available for planner/executor/reviewer roles.\"\n : \"No agency agent profiles were detected in the standard local locations.\",\n },\n {\n id: \"impeccable\",\n kind: \"skills\",\n installed: impeccableItems.length > 0,\n locations: skillLocations.filter((location) => existsSync(location)),\n items: impeccableItems,\n summary: impeccableItems.length > 0\n ? \"Frontend and design-oriented skills are available for review and polish workflows.\"\n : \"No impeccable-related skills were detected in the standard local skill directories.\",\n },\n ];\n}\n\nexport async function buildIntegrationSnippet(integrationId: string, workspaceRoot: string): Promise<string> {\n if (integrationId === \"agency-agents\") {\n return renderPrompt(\"integrations-agency-agents\", { workspaceRoot });\n }\n\n if (integrationId === \"impeccable\") {\n return renderPrompt(\"integrations-impeccable\");\n }\n\n return \"Unknown integration.\";\n}\n","import { env } from \"node:process\";\nimport { getRuntimeSnapshot } from \"./database.js\";\n\nexport async function resolveApiBaseUrl(): Promise<string> {\n const envPort = env.FIFONY_API_PORT;\n if (envPort) return `http://localhost:${envPort}`;\n\n const runtime = await getRuntimeSnapshot();\n const config = runtime.config as Record<string, unknown> | undefined;\n const port = config?.dashboardPort;\n if (port) return `http://localhost:${port}`;\n\n // Fallback: try common ports\n for (const candidate of [4000, 3000, 8080]) {\n try {\n const res = await fetch(`http://localhost:${candidate}/health`, { signal: AbortSignal.timeout(1000) });\n if (res.ok) return `http://localhost:${candidate}`;\n } catch {}\n }\n\n throw new Error(\"Fifony runtime API is not reachable. Start the runtime with --port to enable plan/refine/approve/analytics tools.\");\n}\n\nexport async function apiPost(path: string, body: Record<string, unknown> = {}): Promise<Record<string, unknown>> {\n const base = await resolveApiBaseUrl();\n const res = await fetch(`${base}${path}`, {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify(body),\n signal: AbortSignal.timeout(120_000),\n });\n const json = await res.json() as Record<string, unknown>;\n if (!res.ok || json.ok === false) {\n throw new Error(typeof json.error === \"string\" ? json.error : `API request failed: ${res.status}`);\n }\n return json;\n}\n\nexport async function apiGet(path: string): Promise<Record<string, unknown>> {\n const base = await resolveApiBaseUrl();\n const res = await fetch(`${base}${path}`, {\n signal: AbortSignal.timeout(30_000),\n });\n const json = await res.json() as Record<string, unknown>;\n if (!res.ok || json.ok === false) {\n throw new Error(typeof json.error === \"string\" ? json.error : `API request failed: ${res.status}`);\n }\n return json;\n}\n","import { dirname, join, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { renderPrompt } from \"../../agents/prompting.js\";\nimport { resolveTaskCapabilities } from \"../../routing/capability-resolver.js\";\nimport {\n type IssueRecord,\n getIssues,\n getResources,\n listEvents,\n listRecords,\n getRuntimeSnapshot,\n WORKSPACE_ROOT,\n PERSISTENCE_ROOT,\n STATE_ROOT,\n} from \"../database.js\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\nexport const PACKAGE_ROOT = resolve(__dirname, \"../../..\");\nexport const README_PATH = join(PACKAGE_ROOT, \"README.md\");\nexport const FIFONY_GUIDE_PATH = join(PACKAGE_ROOT, \"FIFONY.md\");\n\nexport async function buildIntegrationGuide(): Promise<string> {\n return renderPrompt(\"mcp-integration-guide\", {\n workspaceRoot: WORKSPACE_ROOT,\n persistenceRoot: PERSISTENCE_ROOT,\n stateRoot: STATE_ROOT,\n });\n}\n\nexport function computeCapabilityCounts(issues: IssueRecord[]): Record<string, number> {\n return issues.reduce<Record<string, number>>((accumulator, issue) => {\n const key = typeof issue.capabilityCategory === \"string\" && issue.capabilityCategory.trim()\n ? issue.capabilityCategory.trim()\n : \"default\";\n accumulator[key] = (accumulator[key] ?? 0) + 1;\n return accumulator;\n }, {});\n}\n\nexport async function buildStateSummary(): Promise<string> {\n const runtime = await getRuntimeSnapshot();\n const issues = await getIssues();\n const { sessionResource, pipelineResource } = getResources();\n const sessions = await listRecords(sessionResource, 500);\n const pipelines = await listRecords(pipelineResource, 500);\n const events = await listEvents({ limit: 100 });\n\n const byState = issues.reduce<Record<string, number>>((accumulator, issue) => {\n const key = issue.state ?? \"Unknown\";\n accumulator[key] = (accumulator[key] ?? 0) + 1;\n return accumulator;\n }, {});\n const byCapability = computeCapabilityCounts(issues);\n\n return JSON.stringify({\n workspaceRoot: WORKSPACE_ROOT,\n persistenceRoot: PERSISTENCE_ROOT,\n stateRoot: STATE_ROOT,\n runtimeUpdatedAt: runtime.updatedAt ?? null,\n issueCount: issues.length,\n issuesByState: byState,\n issuesByCapability: byCapability,\n sessionCount: sessions.length,\n pipelineCount: pipelines.length,\n recentEventCount: events.length,\n }, null, 2);\n}\n\nexport async function buildIssuePrompt(issue: IssueRecord, provider: string, role: string): Promise<string> {\n const resolution = resolveTaskCapabilities({\n id: issue.id,\n identifier: issue.identifier,\n title: issue.title,\n description: typeof issue.description === \"string\" ? issue.description : \"\",\n labels: Array.isArray(issue.labels) ? issue.labels.filter((value): value is string => typeof value === \"string\") : [],\n paths: Array.isArray(issue.paths) ? issue.paths.filter((value): value is string => typeof value === \"string\") : [],\n });\n return renderPrompt(\"mcp-issue\", {\n role,\n provider,\n id: issue.id,\n title: issue.title,\n state: issue.state ?? \"Planning\",\n capabilityCategory: resolution.category,\n overlays: resolution.overlays,\n paths: Array.isArray(issue.paths) ? issue.paths.filter((value): value is string => typeof value === \"string\") : [],\n description: issue.description || \"No description provided.\",\n });\n}\n","import { discoverIntegrations } from \"../../agents/integrations/catalog.js\";\nimport { inferCapabilityPaths, resolveTaskCapabilities } from \"../../routing/capability-resolver.js\";\nimport {\n getIssues,\n getIssue,\n listEvents,\n safeRead,\n WORKSPACE_ROOT,\n} from \"../database.js\";\nimport { apiGet } from \"../api-client.js\";\nimport {\n buildIntegrationGuide,\n buildStateSummary,\n README_PATH,\n FIFONY_GUIDE_PATH,\n} from \"./resource-builder.js\";\n\nexport async function listResourcesMcp(): Promise<Array<Record<string, unknown>>> {\n const issues = await getIssues();\n const resources: Array<Record<string, unknown>> = [\n { uri: \"fifony://guide/overview\", name: \"Fifony overview\", description: \"High-level overview and local integration guide.\", mimeType: \"text/markdown\" },\n { uri: \"fifony://guide/runtime\", name: \"Fifony runtime guide\", description: \"Detailed local runtime reference for the package.\", mimeType: \"text/markdown\" },\n { uri: \"fifony://guide/integration\", name: \"Fifony MCP integration guide\", description: \"How to wire an MCP client to this Fifony workspace.\", mimeType: \"text/markdown\" },\n { uri: \"fifony://state/summary\", name: \"Fifony state summary\", description: \"Compact summary of the current runtime, issue, and pipeline state.\", mimeType: \"application/json\" },\n { uri: \"fifony://issues\", name: \"Fifony issues\", description: \"Full issue list from the durable Fifony store.\", mimeType: \"application/json\" },\n { uri: \"fifony://integrations\", name: \"Fifony integrations\", description: \"Discovered local integrations such as agency-agents and impeccable skills.\", mimeType: \"application/json\" },\n { uri: \"fifony://capabilities\", name: \"Fifony capability routing\", description: \"How Fifony would route current issues to providers, profiles, and overlays.\", mimeType: \"application/json\" },\n ];\n\n resources.push(\n { uri: \"fifony://analytics\", name: \"Token usage analytics\", description: \"Token usage analytics snapshot including totals, cost estimates, and per-model breakdown.\", mimeType: \"application/json\" },\n { uri: \"fifony://workflow/config\", name: \"Workflow config\", description: \"Current pipeline workflow configuration (plan/execute/review providers, models, and effort).\", mimeType: \"application/json\" },\n { uri: \"fifony://agents/catalog\", name: \"Agent catalog\", description: \"Available agents from the Fifony catalog.\", mimeType: \"application/json\" },\n { uri: \"fifony://skills/catalog\", name: \"Skill catalog\", description: \"Available skills from the Fifony catalog.\", mimeType: \"application/json\" },\n { uri: \"fifony://events/recent\", name: \"Recent events\", description: \"Last 50 events across all issues.\", mimeType: \"application/json\" },\n );\n\n for (const issue of issues.slice(0, 100)) {\n resources.push(\n { uri: `fifony://issue/${encodeURIComponent(issue.id)}`, name: `Issue ${issue.id}`, description: issue.title, mimeType: \"application/json\" },\n { uri: `fifony://issue/${encodeURIComponent(issue.id)}/plan`, name: `Issue ${issue.id} plan`, description: `Plan for: ${issue.title}`, mimeType: \"application/json\" },\n { uri: `fifony://issue/${encodeURIComponent(issue.id)}/diff`, name: `Issue ${issue.id} diff`, description: `Git diff for: ${issue.title}`, mimeType: \"application/json\" },\n { uri: `fifony://issue/${encodeURIComponent(issue.id)}/events`, name: `Issue ${issue.id} events`, description: `Events for: ${issue.title}`, mimeType: \"application/json\" },\n );\n }\n\n return resources;\n}\n\nexport async function readResource(uri: string): Promise<Array<Record<string, unknown>>> {\n if (uri === \"fifony://guide/overview\") return [{ uri, mimeType: \"text/markdown\", text: safeRead(README_PATH) }];\n if (uri === \"fifony://guide/runtime\") return [{ uri, mimeType: \"text/markdown\", text: safeRead(FIFONY_GUIDE_PATH) }];\n if (uri === \"fifony://guide/integration\") return [{ uri, mimeType: \"text/markdown\", text: await buildIntegrationGuide() }];\n if (uri === \"fifony://state/summary\") return [{ uri, mimeType: \"application/json\", text: await buildStateSummary() }];\n if (uri === \"fifony://issues\") return [{ uri, mimeType: \"application/json\", text: JSON.stringify(await getIssues(), null, 2) }];\n\n if (uri === \"fifony://integrations\") {\n return [{ uri, mimeType: \"application/json\", text: JSON.stringify(discoverIntegrations(WORKSPACE_ROOT), null, 2) }];\n }\n\n if (uri === \"fifony://capabilities\") {\n const issues = await getIssues();\n return [{\n uri,\n mimeType: \"application/json\",\n text: JSON.stringify(\n issues.map((issue) => ({\n issueId: issue.id,\n title: issue.title,\n paths: Array.isArray(issue.paths) ? issue.paths.filter((value): value is string => typeof value === \"string\") : [],\n inferredPaths: inferCapabilityPaths({\n id: issue.id, identifier: issue.identifier, title: issue.title, description: issue.description,\n labels: Array.isArray(issue.labels) ? issue.labels.filter((value): value is string => typeof value === \"string\") : [],\n paths: Array.isArray(issue.paths) ? issue.paths.filter((value): value is string => typeof value === \"string\") : [],\n }),\n resolution: resolveTaskCapabilities({\n id: issue.id, identifier: issue.identifier, title: issue.title, description: issue.description,\n labels: Array.isArray(issue.labels) ? issue.labels.filter((value): value is string => typeof value === \"string\") : [],\n paths: Array.isArray(issue.paths) ? issue.paths.filter((value): value is string => typeof value === \"string\") : [],\n }),\n })),\n null, 2,\n ),\n }];\n }\n\n if (uri === \"fifony://analytics\") {\n try {\n const result = await apiGet(\"/api/analytics/tokens\");\n return [{ uri, mimeType: \"application/json\", text: JSON.stringify(result, null, 2) }];\n } catch (error) {\n return [{ uri, mimeType: \"application/json\", text: JSON.stringify({ error: String(error) }, null, 2) }];\n }\n }\n\n if (uri === \"fifony://workflow/config\") {\n try {\n const result = await apiGet(\"/api/config/workflow\");\n return [{ uri, mimeType: \"application/json\", text: JSON.stringify(result, null, 2) }];\n } catch (error) {\n return [{ uri, mimeType: \"application/json\", text: JSON.stringify({ error: String(error) }, null, 2) }];\n }\n }\n\n if (uri === \"fifony://agents/catalog\") {\n try {\n const result = await apiGet(\"/api/catalog/agents\");\n return [{ uri, mimeType: \"application/json\", text: JSON.stringify(result, null, 2) }];\n } catch (error) {\n return [{ uri, mimeType: \"application/json\", text: JSON.stringify({ error: String(error) }, null, 2) }];\n }\n }\n\n if (uri === \"fifony://skills/catalog\") {\n try {\n const result = await apiGet(\"/api/catalog/skills\");\n return [{ uri, mimeType: \"application/json\", text: JSON.stringify(result, null, 2) }];\n } catch (error) {\n return [{ uri, mimeType: \"application/json\", text: JSON.stringify({ error: String(error) }, null, 2) }];\n }\n }\n\n if (uri === \"fifony://events/recent\") {\n try {\n const result = await apiGet(\"/api/events/feed\");\n const events = Array.isArray((result as any).events) ? (result as any).events.slice(0, 50) : [];\n return [{ uri, mimeType: \"application/json\", text: JSON.stringify({ events }, null, 2) }];\n } catch (error) {\n const events = await listEvents({ limit: 50 });\n return [{ uri, mimeType: \"application/json\", text: JSON.stringify({ events }, null, 2) }];\n }\n }\n\n if (uri.startsWith(\"fifony://issue/\")) {\n const remainder = uri.substring(\"fifony://issue/\".length);\n\n // fifony://issue/{id}/plan\n const planMatch = remainder.match(/^(.+)\\/plan$/);\n if (planMatch) {\n const issueId = decodeURIComponent(planMatch[1]);\n const issue = await getIssue(issueId);\n if (!issue) throw new Error(`Issue not found: ${issueId}`);\n const plan = (issue as any).plan ?? null;\n return [{ uri, mimeType: \"application/json\", text: JSON.stringify({ issueId, plan }, null, 2) }];\n }\n\n // fifony://issue/{id}/diff\n const diffMatch = remainder.match(/^(.+)\\/diff$/);\n if (diffMatch) {\n const issueId = decodeURIComponent(diffMatch[1]);\n try {\n const result = await apiGet(`/api/diff/${encodeURIComponent(issueId)}`);\n return [{ uri, mimeType: \"application/json\", text: JSON.stringify(result, null, 2) }];\n } catch (error) {\n return [{ uri, mimeType: \"application/json\", text: JSON.stringify({ error: String(error) }, null, 2) }];\n }\n }\n\n // fifony://issue/{id}/events\n const eventsMatch = remainder.match(/^(.+)\\/events$/);\n if (eventsMatch) {\n const issueId = decodeURIComponent(eventsMatch[1]);\n try {\n const result = await apiGet(`/api/events/feed?issueId=${encodeURIComponent(issueId)}`);\n return [{ uri, mimeType: \"application/json\", text: JSON.stringify(result, null, 2) }];\n } catch (error) {\n const events = await listEvents({ limit: 100 });\n const filtered = events.filter((event: any) => event.issueId === issueId);\n return [{ uri, mimeType: \"application/json\", text: JSON.stringify({ events: filtered }, null, 2) }];\n }\n }\n\n // fifony://issue/{id} (base case)\n const issueId = decodeURIComponent(remainder);\n const issue = await getIssue(issueId);\n if (!issue) throw new Error(`Issue not found: ${issueId}`);\n return [{ uri, mimeType: \"application/json\", text: JSON.stringify(issue, null, 2) }];\n }\n\n throw new Error(`Unknown resource: ${uri}`);\n}\n","export function listTools(): Array<Record<string, unknown>> {\n return [\n { name: \"fifony.status\", description: \"Return a compact status summary for the current Fifony workspace.\", inputSchema: { type: \"object\", properties: {}, additionalProperties: false } },\n { name: \"fifony.list_issues\", description: \"List issues from the Fifony durable store.\", inputSchema: { type: \"object\", properties: { state: { type: \"string\" }, capabilityCategory: { type: \"string\" }, category: { type: \"string\" } }, additionalProperties: false } },\n { name: \"fifony.create_issue\", description: \"Create a new issue directly in the Fifony durable store.\", inputSchema: { type: \"object\", properties: { id: { type: \"string\" }, title: { type: \"string\" }, description: { type: \"string\" }, priority: { type: \"number\" }, state: { type: \"string\" }, labels: { type: \"array\", items: { type: \"string\" } }, paths: { type: \"array\", items: { type: \"string\" } } }, required: [\"title\"], additionalProperties: false } },\n { name: \"fifony.update_issue_state\", description: \"Update an issue state in the Fifony store and append an event.\", inputSchema: { type: \"object\", properties: { issueId: { type: \"string\" }, state: { type: \"string\" }, note: { type: \"string\" } }, required: [\"issueId\", \"state\"], additionalProperties: false } },\n { name: \"fifony.plan\", description: \"Generate an AI plan for an issue. The issue must be in Planning state. Returns the plan summary and step count.\", inputSchema: { type: \"object\", properties: { issueId: { type: \"string\", description: \"The issue identifier to plan.\" }, fast: { type: \"boolean\", description: \"Use fast planning mode (less thorough but quicker).\" } }, required: [\"issueId\"], additionalProperties: false } },\n { name: \"fifony.refine\", description: \"Refine an existing plan with feedback. The issue must already have a plan.\", inputSchema: { type: \"object\", properties: { issueId: { type: \"string\", description: \"The issue identifier whose plan to refine.\" }, feedback: { type: \"string\", description: \"Feedback to guide the plan refinement.\" } }, required: [\"issueId\", \"feedback\"], additionalProperties: false } },\n { name: \"fifony.approve\", description: \"Approve a plan and move the issue to Planned for execution.\", inputSchema: { type: \"object\", properties: { issueId: { type: \"string\", description: \"The issue identifier to approve.\" } }, required: [\"issueId\"], additionalProperties: false } },\n { name: \"fifony.merge\", description: \"Merge workspace changes back into the project root. Copies new/modified files from the issue workspace to TARGET_ROOT and removes files that were deleted. Skips fifony internal files, node_modules, .git, and dist.\", inputSchema: { type: \"object\", properties: { issueId: { type: \"string\", description: \"The issue identifier whose workspace to merge.\" } }, required: [\"issueId\"], additionalProperties: false } },\n { name: \"fifony.analytics\", description: \"Get token usage analytics including overall totals, cost estimates, and top issues by token consumption.\", inputSchema: { type: \"object\", properties: {}, additionalProperties: false } },\n { name: \"fifony.integration_config\", description: \"Generate a ready-to-paste MCP client configuration snippet for this Fifony workspace.\", inputSchema: { type: \"object\", properties: { client: { type: \"string\" } }, additionalProperties: false } },\n { name: \"fifony.list_integrations\", description: \"List discovered local integrations such as agency-agents profiles and impeccable skills.\", inputSchema: { type: \"object\", properties: {}, additionalProperties: false } },\n { name: \"fifony.integration_snippet\", description: \"Generate a workflow or prompt snippet for a discovered integration.\", inputSchema: { type: \"object\", properties: { integration: { type: \"string\" } }, required: [\"integration\"], additionalProperties: false } },\n { name: \"fifony.resolve_capabilities\", description: \"Resolve which providers, roles, profiles, and overlays Fifony should use for a task.\", inputSchema: { type: \"object\", properties: { title: { type: \"string\" }, description: { type: \"string\" }, labels: { type: \"array\", items: { type: \"string\" } }, paths: { type: \"array\", items: { type: \"string\" } } }, required: [\"title\"], additionalProperties: false } },\n { name: \"fifony.get_issue\", description: \"Get full detail of a single issue including plan, history, events, and diff status.\", inputSchema: { type: \"object\", properties: { issueId: { type: \"string\", description: \"The issue identifier.\" } }, required: [\"issueId\"], additionalProperties: false } },\n { name: \"fifony.cancel_issue\", description: \"Cancel an issue, moving it to Cancelled state.\", inputSchema: { type: \"object\", properties: { issueId: { type: \"string\", description: \"The issue identifier to cancel.\" } }, required: [\"issueId\"], additionalProperties: false } },\n { name: \"fifony.retry_issue\", description: \"Retry a failed or blocked issue, resetting it to Planned state.\", inputSchema: { type: \"object\", properties: { issueId: { type: \"string\", description: \"The issue identifier to retry.\" } }, required: [\"issueId\"], additionalProperties: false } },\n { name: \"fifony.enhance\", description: \"AI-enhance an issue title or description. Provide either an issueId to enhance an existing issue, or title+description for standalone enhancement.\", inputSchema: { type: \"object\", properties: { issueId: { type: \"string\", description: \"Issue identifier (optional, for existing issues).\" }, title: { type: \"string\", description: \"Issue title (for standalone enhancement).\" }, description: { type: \"string\", description: \"Issue description (for standalone enhancement).\" }, field: { type: \"string\", enum: [\"title\", \"description\"], description: \"Which field to enhance.\" } }, required: [\"field\"], additionalProperties: false } },\n { name: \"fifony.get_diff\", description: \"Get git diff for an issue's workspace, including per-file summary and full diff text.\", inputSchema: { type: \"object\", properties: { issueId: { type: \"string\", description: \"The issue identifier.\" } }, required: [\"issueId\"], additionalProperties: false } },\n { name: \"fifony.get_live\", description: \"Get live agent output for a running issue, including log tail, PID, elapsed time, and status.\", inputSchema: { type: \"object\", properties: { issueId: { type: \"string\", description: \"The issue identifier.\" } }, required: [\"issueId\"], additionalProperties: false } },\n { name: \"fifony.get_events\", description: \"Get event feed, optionally filtered by issue, kind, or limited.\", inputSchema: { type: \"object\", properties: { issueId: { type: \"string\", description: \"Filter events by issue identifier.\" }, kind: { type: \"string\", description: \"Filter events by kind (info, error, state, manual, progress).\" }, limit: { type: \"number\", description: \"Maximum number of events to return (default 50).\" } }, additionalProperties: false } },\n { name: \"fifony.get_workflow\", description: \"Get the current pipeline workflow configuration including providers, models, and effort for plan/execute/review stages.\", inputSchema: { type: \"object\", properties: {}, additionalProperties: false } },\n { name: \"fifony.set_workflow\", description: \"Update the pipeline workflow configuration. Each stage (plan, execute, review) needs provider, model, and effort.\", inputSchema: { type: \"object\", properties: { plan: { type: \"object\", properties: { provider: { type: \"string\" }, model: { type: \"string\" }, effort: { type: \"string\" } }, required: [\"provider\", \"model\", \"effort\"] }, execute: { type: \"object\", properties: { provider: { type: \"string\" }, model: { type: \"string\" }, effort: { type: \"string\" } }, required: [\"provider\", \"model\", \"effort\"] }, review: { type: \"object\", properties: { provider: { type: \"string\" }, model: { type: \"string\" }, effort: { type: \"string\" } }, required: [\"provider\", \"model\", \"effort\"] } }, required: [\"plan\", \"execute\", \"review\"], additionalProperties: false } },\n { name: \"fifony.scan_project\", description: \"Scan the target project structure, returning files, directories, and detected technologies.\", inputSchema: { type: \"object\", properties: {}, additionalProperties: false } },\n { name: \"fifony.install_agents\", description: \"Install agents from the Fifony catalog into the target workspace.\", inputSchema: { type: \"object\", properties: { agents: { type: \"array\", items: { type: \"string\" }, description: \"List of agent names to install.\" } }, required: [\"agents\"], additionalProperties: false } },\n { name: \"fifony.install_skills\", description: \"Install skills from the Fifony catalog into the target workspace.\", inputSchema: { type: \"object\", properties: { skills: { type: \"array\", items: { type: \"string\" }, description: \"List of skill names to install.\" } }, required: [\"skills\"], additionalProperties: false } },\n ];\n}\n","import { createHash } from \"node:crypto\";\nimport { discoverIntegrations, buildIntegrationSnippet } from \"../../agents/integrations/catalog.js\";\nimport { inferCapabilityPaths, resolveTaskCapabilities } from \"../../routing/capability-resolver.js\";\nimport {\n initDatabase,\n getResources,\n getIssue,\n listIssues,\n listEvents,\n appendEvent,\n nowIso,\n WORKSPACE_ROOT,\n PERSISTENCE_ROOT,\n} from \"../database.js\";\nimport { apiGet, apiPost } from \"../api-client.js\";\nimport { buildStateSummary } from \"../resources/resource-builder.js\";\nimport { parseIssueState } from \"../../concerns/helpers.js\";\n\nfunction hashInput(value: string): string {\n return createHash(\"sha1\").update(value).digest(\"hex\").slice(0, 10);\n}\n\nexport function toolText(text: string): Record<string, unknown> {\n return { content: [{ type: \"text\", text }] };\n}\n\nexport async function callTool(name: string, args: Record<string, unknown> = {}): Promise<Record<string, unknown>> {\n if (name === \"fifony.status\") return toolText(await buildStateSummary());\n\n if (name === \"fifony.list_issues\") {\n const stateFilter = typeof args.state === \"string\" && args.state.trim() ? args.state.trim() : \"\";\n const capabilityCategory = typeof args.capabilityCategory === \"string\" && args.capabilityCategory.trim()\n ? args.capabilityCategory.trim()\n : typeof args.category === \"string\" && args.category.trim() ? args.category.trim() : \"\";\n return toolText(JSON.stringify(await listIssues({ state: stateFilter || undefined, capabilityCategory: capabilityCategory || undefined }), null, 2));\n }\n\n if (name === \"fifony.create_issue\") {\n await initDatabase();\n const { issueResource } = getResources();\n const title = typeof args.title === \"string\" ? args.title.trim() : \"\";\n if (!title) throw new Error(\"title is required\");\n\n const explicitId = typeof args.id === \"string\" && args.id.trim() ? args.id.trim() : \"\";\n const issueId = explicitId || `LOCAL-${hashInput(`${title}:${nowIso()}`)}`.toUpperCase();\n const description = typeof args.description === \"string\" ? args.description : \"\";\n const priority = typeof args.priority === \"number\" ? args.priority : 2;\n const state = parseIssueState(args.state) ?? \"Planning\";\n const baseLabels = Array.isArray(args.labels) ? args.labels.filter((value): value is string => typeof value === \"string\") : [\"fifony\", \"mcp\"];\n const paths = Array.isArray(args.paths) ? args.paths.filter((value): value is string => typeof value === \"string\") : [];\n const inferredPaths = inferCapabilityPaths({ id: issueId, identifier: issueId, title, description, labels: baseLabels, paths });\n const resolution = resolveTaskCapabilities({ id: issueId, identifier: issueId, title, description, labels: baseLabels, paths });\n const labels = [...new Set([...baseLabels, resolution.category ? `capability:${resolution.category}` : \"\", ...resolution.overlays.map((overlay) => `overlay:${overlay}`)].filter(Boolean))];\n\n const record = await issueResource?.insert({\n id: issueId, identifier: issueId, title, description, priority, state, labels, paths, inferredPaths,\n capabilityCategory: resolution.category, capabilityOverlays: resolution.overlays, capabilityRationale: resolution.rationale,\n blockedBy: [], assignedToWorker: false, createdAt: nowIso(), url: `fifony://local/${issueId}`,\n updatedAt: nowIso(), history: [`[${nowIso()}] Issue created via MCP.`], attempts: 0, maxAttempts: 3,\n });\n\n await appendEvent(\"info\", `Issue ${issueId} created through MCP.`, { title, state, labels, paths, inferredPaths, capabilityCategory: resolution.category }, issueId);\n return toolText(JSON.stringify(record ?? { id: issueId }, null, 2));\n }\n\n if (name === \"fifony.update_issue_state\") {\n await initDatabase();\n const { issueResource } = getResources();\n const issueId = typeof args.issueId === \"string\" ? args.issueId.trim() : \"\";\n const state = parseIssueState(args.state);\n const note = typeof args.note === \"string\" ? args.note : \"\";\n if (!issueId || !state) throw new Error(\"issueId and a valid canonical state are required\");\n\n const current = await issueResource?.get(issueId);\n if (!current) throw new Error(`Issue not found: ${issueId}`);\n\n const updated = await issueResource?.update(issueId, { state, updatedAt: nowIso() });\n await appendEvent(\"info\", note || `Issue ${issueId} moved to ${state} through MCP.`, { state }, issueId);\n return toolText(JSON.stringify(updated ?? { id: issueId, state }, null, 2));\n }\n\n if (name === \"fifony.plan\") {\n const issueId = typeof args.issueId === \"string\" ? args.issueId.trim() : \"\";\n if (!issueId) throw new Error(\"issueId is required\");\n const fast = args.fast === true;\n const result = await apiPost(`/api/issues/${encodeURIComponent(issueId)}/plan`, { fast });\n const issue = result.issue as Record<string, unknown> | undefined;\n const plan = issue?.plan as Record<string, unknown> | undefined;\n const steps = Array.isArray(plan?.steps) ? plan.steps : [];\n return toolText(JSON.stringify({\n issueId,\n state: issue?.state ?? \"Planning\",\n planSummary: plan?.summary ?? plan?.title ?? \"Plan generation started in background.\",\n stepCount: steps.length,\n estimatedComplexity: plan?.estimatedComplexity ?? null,\n message: steps.length > 0\n ? `Plan generated with ${steps.length} step(s). Use fifony.approve to start execution or fifony.refine to adjust.`\n : \"Plan generation started in background. Poll the issue status to check progress.\",\n }, null, 2));\n }\n\n if (name === \"fifony.refine\") {\n const issueId = typeof args.issueId === \"string\" ? args.issueId.trim() : \"\";\n const feedback = typeof args.feedback === \"string\" ? args.feedback.trim() : \"\";\n if (!issueId) throw new Error(\"issueId is required\");\n if (!feedback) throw new Error(\"feedback is required\");\n const result = await apiPost(`/api/issues/${encodeURIComponent(issueId)}/plan/refine`, { feedback });\n const issue = result.issue as Record<string, unknown> | undefined;\n const plan = issue?.plan as Record<string, unknown> | undefined;\n const steps = Array.isArray(plan?.steps) ? plan.steps : [];\n return toolText(JSON.stringify({\n issueId,\n planSummary: plan?.summary ?? plan?.title ?? \"Plan refinement started in background.\",\n stepCount: steps.length,\n estimatedComplexity: plan?.estimatedComplexity ?? null,\n message: \"Plan refinement started in background. The plan will be updated via WebSocket when complete.\",\n }, null, 2));\n }\n\n if (name === \"fifony.approve\") {\n const issueId = typeof args.issueId === \"string\" ? args.issueId.trim() : \"\";\n if (!issueId) throw new Error(\"issueId is required\");\n const result = await apiPost(`/api/issues/${encodeURIComponent(issueId)}/approve`);\n const issue = result.issue as Record<string, unknown> | undefined;\n return toolText(JSON.stringify({\n issueId,\n state: issue?.state ?? \"Planned\",\n message: `Plan approved for ${issueId}. Issue moved to Planned and is ready for execution.`,\n }, null, 2));\n }\n\n if (name === \"fifony.merge\") {\n const issueId = typeof args.issueId === \"string\" ? args.issueId.trim() : \"\";\n if (!issueId) throw new Error(\"issueId is required\");\n const result = await apiPost(`/api/issues/${encodeURIComponent(issueId)}/merge`);\n return toolText(JSON.stringify({\n issueId,\n copied: result.copied,\n deleted: result.deleted,\n skipped: result.skipped,\n message: `Merged ${(result.copied as string[])?.length ?? 0} files into project root. ${(result.deleted as string[])?.length ?? 0} files removed.`,\n }, null, 2));\n }\n\n if (name === \"fifony.analytics\") {\n const result = await apiGet(\"/api/analytics/tokens\");\n const overall = result.overall as Record<string, unknown> | undefined;\n const topIssues = result.topIssues as Array<Record<string, unknown>> | undefined;\n const byModel = result.byModel as Record<string, Record<string, unknown>> | undefined;\n // Compute cost estimate (rough: $3/M input, $15/M output for Claude-class models)\n const inputTokens = typeof overall?.inputTokens === \"number\" ? overall.inputTokens : 0;\n const outputTokens = typeof overall?.outputTokens === \"number\" ? overall.outputTokens : 0;\n const totalTokens = typeof overall?.totalTokens === \"number\" ? overall.totalTokens : 0;\n const estimatedCost = (inputTokens / 1_000_000) * 3 + (outputTokens / 1_000_000) * 15;\n return toolText(JSON.stringify({\n overall: { inputTokens, outputTokens, totalTokens },\n estimatedCostUsd: Math.round(estimatedCost * 100) / 100,\n modelBreakdown: byModel ?? {},\n topIssues: (topIssues ?? []).slice(0, 10).map((issue) => ({ id: issue.id, totalTokens: issue.totalTokens, inputTokens: issue.inputTokens, outputTokens: issue.outputTokens })),\n }, null, 2));\n }\n\n if (name === \"fifony.integration_config\") {\n const client = typeof args.client === \"string\" && args.client.trim() ? args.client.trim() : \"client\";\n return toolText(JSON.stringify({ client, mcpServers: { fifony: { command: \"npx\", args: [\"fifony\", \"mcp\", \"--workspace\", WORKSPACE_ROOT, \"--persistence\", PERSISTENCE_ROOT] } } }, null, 2));\n }\n\n if (name === \"fifony.list_integrations\") return toolText(JSON.stringify(discoverIntegrations(WORKSPACE_ROOT), null, 2));\n\n if (name === \"fifony.integration_snippet\") {\n const integration = typeof args.integration === \"string\" ? args.integration : \"\";\n return toolText(await buildIntegrationSnippet(integration, WORKSPACE_ROOT));\n }\n\n if (name === \"fifony.resolve_capabilities\") {\n const title = typeof args.title === \"string\" ? args.title : \"\";\n const description = typeof args.description === \"string\" ? args.description : \"\";\n const labels = Array.isArray(args.labels) ? args.labels.filter((value): value is string => typeof value === \"string\") : [];\n const paths = Array.isArray(args.paths) ? args.paths.filter((value): value is string => typeof value === \"string\") : [];\n return toolText(JSON.stringify({ inferredPaths: inferCapabilityPaths({ title, description, labels, paths }), resolution: resolveTaskCapabilities({ title, description, labels, paths }) }, null, 2));\n }\n\n if (name === \"fifony.get_issue\") {\n const issueId = typeof args.issueId === \"string\" ? args.issueId.trim() : \"\";\n if (!issueId) throw new Error(\"issueId is required\");\n const issue = await getIssue(issueId);\n if (!issue) throw new Error(`Issue not found: ${issueId}`);\n let diff: Record<string, unknown> | null = null;\n let events: unknown[] = [];\n try { diff = await apiGet(`/api/diff/${encodeURIComponent(issueId)}`); } catch {}\n try { const evResult = await apiGet(`/api/events/feed?issueId=${encodeURIComponent(issueId)}`); events = Array.isArray((evResult as any).events) ? (evResult as any).events : []; } catch {}\n const issueObj = issue as Record<string, unknown>;\n const mergeInfo = issueObj.mergedAt\n ? { mergedAt: issueObj.mergedAt, mergeResult: issueObj.mergeResult, message: `Code merged to project root at ${issueObj.mergedAt}. Available for testing.` }\n : null;\n return toolText(JSON.stringify({\n issue,\n mergeStatus: mergeInfo,\n diffSummary: diff ? { files: (diff as any).files, totalAdditions: (diff as any).totalAdditions, totalDeletions: (diff as any).totalDeletions } : null,\n recentEvents: (events as any[]).slice(0, 20),\n }, null, 2));\n }\n\n if (name === \"fifony.cancel_issue\") {\n const issueId = typeof args.issueId === \"string\" ? args.issueId.trim() : \"\";\n if (!issueId) throw new Error(\"issueId is required\");\n try {\n const result = await apiPost(`/api/issues/${encodeURIComponent(issueId)}/cancel`);\n const issue = result.issue as Record<string, unknown> | undefined;\n return toolText(JSON.stringify({ issueId, state: issue?.state ?? \"Cancelled\", message: `Issue ${issueId} has been cancelled.` }, null, 2));\n } catch (error) {\n throw new Error(`Failed to cancel issue ${issueId}: ${String(error)}`);\n }\n }\n\n if (name === \"fifony.retry_issue\") {\n const issueId = typeof args.issueId === \"string\" ? args.issueId.trim() : \"\";\n if (!issueId) throw new Error(\"issueId is required\");\n try {\n const result = await apiPost(`/api/issues/${encodeURIComponent(issueId)}/retry`);\n const issue = result.issue as Record<string, unknown> | undefined;\n return toolText(JSON.stringify({ issueId, state: issue?.state ?? \"Planned\", message: `Issue ${issueId} has been retried and reset to Planned.` }, null, 2));\n } catch (error) {\n throw new Error(`Failed to retry issue ${issueId}: ${String(error)}`);\n }\n }\n\n if (name === \"fifony.enhance\") {\n const field = typeof args.field === \"string\" ? args.field.trim() : \"\";\n if (field !== \"title\" && field !== \"description\") throw new Error('field must be \"title\" or \"description\"');\n const issueId = typeof args.issueId === \"string\" ? args.issueId.trim() : \"\";\n let title = typeof args.title === \"string\" ? args.title.trim() : \"\";\n let description = typeof args.description === \"string\" ? args.description.trim() : \"\";\n // If issueId given, fetch issue data to fill in title/description\n if (issueId && (!title || !description)) {\n const issue = await getIssue(issueId);\n if (!issue) throw new Error(`Issue not found: ${issueId}`);\n if (!title) title = (issue as any).title ?? \"\";\n if (!description) description = (issue as any).description ?? \"\";\n }\n try {\n const result = await apiPost(\"/api/issues/enhance\", { field, title, description });\n return toolText(JSON.stringify({ field: (result as any).field, value: (result as any).value, provider: (result as any).provider, issueId: issueId || undefined }, null, 2));\n } catch (error) {\n throw new Error(`Failed to enhance ${field}: ${String(error)}`);\n }\n }\n\n if (name === \"fifony.get_diff\") {\n const issueId = typeof args.issueId === \"string\" ? args.issueId.trim() : \"\";\n if (!issueId) throw new Error(\"issueId is required\");\n try {\n const result = await apiGet(`/api/diff/${encodeURIComponent(issueId)}`);\n return toolText(JSON.stringify(result, null, 2));\n } catch (error) {\n throw new Error(`Failed to get diff for ${issueId}: ${String(error)}`);\n }\n }\n\n if (name === \"fifony.get_live\") {\n const issueId = typeof args.issueId === \"string\" ? args.issueId.trim() : \"\";\n if (!issueId) throw new Error(\"issueId is required\");\n try {\n const result = await apiGet(`/api/live/${encodeURIComponent(issueId)}`);\n return toolText(JSON.stringify(result, null, 2));\n } catch (error) {\n throw new Error(`Failed to get live output for ${issueId}: ${String(error)}`);\n }\n }\n\n if (name === \"fifony.get_events\") {\n const issueId = typeof args.issueId === \"string\" ? args.issueId.trim() : \"\";\n const kind = typeof args.kind === \"string\" ? args.kind.trim() : \"\";\n const limit = typeof args.limit === \"number\" ? args.limit : 50;\n const params = new URLSearchParams();\n if (issueId) params.set(\"issueId\", issueId);\n if (kind) params.set(\"kind\", kind);\n const query = params.toString();\n try {\n const result = await apiGet(`/api/events/feed${query ? `?${query}` : \"\"}`);\n const events = Array.isArray((result as any).events) ? (result as any).events.slice(0, limit) : [];\n return toolText(JSON.stringify({ events, count: events.length }, null, 2));\n } catch (error) {\n // Fallback to local events\n const events = await listEvents({ limit: limit });\n const filtered = events.filter((event: any) => {\n if (issueId && event.issueId !== issueId) return false;\n if (kind && event.kind !== kind) return false;\n return true;\n }).slice(0, limit);\n return toolText(JSON.stringify({ events: filtered, count: filtered.length }, null, 2));\n }\n }\n\n if (name === \"fifony.get_workflow\") {\n try {\n const result = await apiGet(\"/api/config/workflow\");\n return toolText(JSON.stringify(result, null, 2));\n } catch (error) {\n throw new Error(`Failed to get workflow config: ${String(error)}`);\n }\n }\n\n if (name === \"fifony.set_workflow\") {\n const plan = args.plan as Record<string, unknown> | undefined;\n const execute = args.execute as Record<string, unknown> | undefined;\n const review = args.review as Record<string, unknown> | undefined;\n if (!plan || !execute || !review) throw new Error(\"plan, execute, and review are all required\");\n try {\n const result = await apiPost(\"/api/config/workflow\", { workflow: { plan, execute, review } });\n return toolText(JSON.stringify({ message: \"Workflow configuration updated successfully.\", workflow: (result as any).workflow }, null, 2));\n } catch (error) {\n throw new Error(`Failed to set workflow config: ${String(error)}`);\n }\n }\n\n if (name === \"fifony.scan_project\") {\n try {\n const result = await apiGet(\"/api/scan/project\");\n return toolText(JSON.stringify(result, null, 2));\n } catch (error) {\n throw new Error(`Failed to scan project: ${String(error)}`);\n }\n }\n\n if (name === \"fifony.install_agents\") {\n const agents = Array.isArray(args.agents) ? args.agents.filter((value): value is string => typeof value === \"string\") : [];\n if (agents.length === 0) throw new Error(\"At least one agent name is required\");\n try {\n const result = await apiPost(\"/api/install/agents\", { agents });\n return toolText(JSON.stringify(result, null, 2));\n } catch (error) {\n throw new Error(`Failed to install agents: ${String(error)}`);\n }\n }\n\n if (name === \"fifony.install_skills\") {\n const skills = Array.isArray(args.skills) ? args.skills.filter((value): value is string => typeof value === \"string\") : [];\n if (skills.length === 0) throw new Error(\"At least one skill name is required\");\n try {\n const result = await apiPost(\"/api/install/skills\", { skills });\n return toolText(JSON.stringify(result, null, 2));\n } catch (error) {\n throw new Error(`Failed to install skills: ${String(error)}`);\n }\n }\n\n throw new Error(`Unknown tool: ${name}`);\n}\n","export function listPrompts(): Array<Record<string, unknown>> {\n return [\n { name: \"fifony-integrate-client\", description: \"Generate setup instructions for connecting an MCP-capable client to Fifony.\", arguments: [{ name: \"client\", description: \"Client name, e.g. codex or claude.\", required: true }, { name: \"goal\", description: \"What the client should do with Fifony.\", required: false }] },\n { name: \"fifony-plan-issue\", description: \"Generate a planning prompt for a specific issue in the Fifony store.\", arguments: [{ name: \"issueId\", description: \"Issue identifier.\", required: true }, { name: \"provider\", description: \"Agent provider name.\", required: false }] },\n{ name: \"fifony-use-integration\", description: \"Generate a concrete integration prompt for agency-agents or impeccable.\", arguments: [{ name: \"integration\", description: \"Integration id: agency-agents or impeccable.\", required: true }] },\n { name: \"fifony-route-task\", description: \"Explain which providers, profiles, and overlays Fifony would choose for a task.\", arguments: [{ name: \"title\", description: \"Task title.\", required: true }, { name: \"description\", description: \"Task description.\", required: false }, { name: \"labels\", description: \"Comma-separated labels.\", required: false }, { name: \"paths\", description: \"Comma-separated target paths or files.\", required: false }] },\n { name: \"fifony-diagnose-blocked\", description: \"Help diagnose why an issue is blocked or failing, analyzing the issue plan, last error, history, and events.\", arguments: [{ name: \"issueId\", description: \"Issue identifier to diagnose.\", required: true }] },\n { name: \"fifony-weekly-summary\", description: \"Generate a weekly progress summary including issues created, completed, blocked, and token usage.\", arguments: [] },\n { name: \"fifony-refine-plan\", description: \"Guided plan refinement prompt that shows the current plan and helps provide specific feedback.\", arguments: [{ name: \"issueId\", description: \"Issue identifier whose plan to refine.\", required: true }, { name: \"concern\", description: \"Optional specific concern to address in refinement.\", required: false }] },\n { name: \"fifony-code-review\", description: \"Review code changes for an issue by analyzing its git diff.\", arguments: [{ name: \"issueId\", description: \"Issue identifier to review.\", required: true }] },\n ];\n}\n","import { renderPrompt } from \"../../agents/prompting.js\";\nimport { buildIntegrationSnippet } from \"../../agents/integrations/catalog.js\";\nimport { resolveTaskCapabilities } from \"../../routing/capability-resolver.js\";\nimport { getIssue, getIssues, listEvents, WORKSPACE_ROOT } from \"../database.js\";\nimport { apiGet, apiPost } from \"../api-client.js\";\nimport { buildIntegrationGuide, buildIssuePrompt } from \"../resources/resource-builder.js\";\n\nexport async function getPrompt(name: string, args: Record<string, unknown> = {}): Promise<Record<string, unknown>> {\n if (name === \"fifony-integrate-client\") {\n const client = typeof args.client === \"string\" && args.client.trim() ? args.client.trim() : \"mcp-client\";\n const goal = typeof args.goal === \"string\" && args.goal.trim() ? args.goal.trim() : \"integrate with the local Fifony workspace\";\n const integrationGuide = await buildIntegrationGuide();\n return {\n description: \"Client integration prompt for Fifony.\",\n messages: [{\n role: \"user\",\n content: {\n type: \"text\",\n text: await renderPrompt(\"mcp-integrate-client\", { client, goal, integrationGuide }),\n },\n }],\n };\n }\n\n if (name === \"fifony-plan-issue\") {\n const issueId = typeof args.issueId === \"string\" ? args.issueId : \"\";\n const provider = typeof args.provider === \"string\" && args.provider.trim() ? args.provider.trim() : \"codex\";\n const issue = issueId ? await getIssue(issueId) : null;\n if (!issue) throw new Error(`Issue not found: ${issueId}`);\n return {\n description: \"Issue planning prompt grounded in the Fifony issue store.\",\n messages: [{\n role: \"user\",\n content: { type: \"text\", text: await buildIssuePrompt(issue, provider, \"planner\") },\n }],\n };\n }\n\n\n if (name === \"fifony-use-integration\") {\n const integration = typeof args.integration === \"string\" ? args.integration : \"\";\n return {\n description: \"Integration guidance for a discovered Fifony extension.\",\n messages: [{\n role: \"user\",\n content: { type: \"text\", text: await buildIntegrationSnippet(integration, WORKSPACE_ROOT) },\n }],\n };\n }\n\n if (name === \"fifony-route-task\") {\n const title = typeof args.title === \"string\" ? args.title : \"\";\n const description = typeof args.description === \"string\" ? args.description : \"\";\n const labels = typeof args.labels === \"string\" ? args.labels.split(\",\").map((label) => label.trim()).filter(Boolean) : [];\n const paths = typeof args.paths === \"string\" ? args.paths.split(\",\").map((value) => value.trim()).filter(Boolean) : [];\n const resolution = resolveTaskCapabilities({ title, description, labels, paths });\n return {\n description: \"Task routing prompt produced by the Fifony capability resolver.\",\n messages: [{\n role: \"user\",\n content: {\n type: \"text\",\n text: await renderPrompt(\"mcp-route-task\", {\n resolutionJson: JSON.stringify(resolution, null, 2),\n }),\n },\n }],\n };\n }\n\n if (name === \"fifony-diagnose-blocked\") {\n const issueId = typeof args.issueId === \"string\" ? args.issueId.trim() : \"\";\n if (!issueId) throw new Error(\"issueId is required\");\n const issue = await getIssue(issueId);\n if (!issue) throw new Error(`Issue not found: ${issueId}`);\n const issueData = issue as any;\n let events: unknown[] = [];\n try {\n const evResult = await apiGet(`/api/events/feed?issueId=${encodeURIComponent(issueId)}`);\n events = Array.isArray((evResult as any).events) ? (evResult as any).events.slice(0, 30) : [];\n } catch {\n const localEvents = await listEvents({ limit: 100 });\n events = localEvents.filter((event: any) => event.issueId === issueId).slice(0, 30);\n }\n const plan = issueData.plan ?? null;\n const history = Array.isArray(issueData.history) ? issueData.history : [];\n const lastError = issueData.lastError ?? null;\n const state = issueData.state ?? \"Unknown\";\n const attempts = issueData.attempts ?? 0;\n const maxAttempts = issueData.maxAttempts ?? 3;\n\n const diagnosticText = [\n `# Diagnostic Report for Issue ${issueId}`,\n ``,\n `## Issue Details`,\n `- **Title**: ${issueData.title ?? \"Unknown\"}`,\n `- **State**: ${state}`,\n `- **Attempts**: ${attempts} / ${maxAttempts}`,\n `- **Last Error**: ${lastError ?? \"None\"}`,\n `- **Updated At**: ${issueData.updatedAt ?? \"Unknown\"}`,\n ``,\n `## Plan`,\n plan ? `- **Summary**: ${plan.summary ?? plan.title ?? \"No summary\"}` : \"No plan generated.\",\n plan?.steps ? `- **Steps**: ${plan.steps.length} step(s)` : \"\",\n plan?.estimatedComplexity ? `- **Estimated Complexity**: ${plan.estimatedComplexity}` : \"\",\n ``,\n `## History`,\n ...(history.length > 0 ? history.slice(-15).map((entry: string) => `- ${entry}`) : [\"No history entries.\"]),\n ``,\n `## Recent Events`,\n ...(events.length > 0 ? (events as any[]).slice(0, 15).map((event: any) => `- [${event.kind ?? \"info\"}] ${event.at ?? \"\"}: ${event.message ?? \"\"}`) : [\"No events found.\"]),\n ``,\n `## Diagnostic Questions`,\n `Based on the information above, please analyze:`,\n `1. What is the root cause of the issue being in \"${state}\" state?`,\n `2. Is the error recoverable? If so, what steps should be taken?`,\n `3. Does the plan need modification before retrying?`,\n `4. Are there any dependency or configuration issues that need resolution?`,\n `5. What is the recommended next action?`,\n ].filter((line) => line !== undefined).join(\"\\n\");\n\n return {\n description: `Diagnostic prompt for blocked/failed issue ${issueId}.`,\n messages: [{\n role: \"user\",\n content: { type: \"text\", text: diagnosticText },\n }],\n };\n }\n\n if (name === \"fifony-weekly-summary\") {\n const issues = await getIssues();\n let analytics: Record<string, unknown> = {};\n try { analytics = await apiGet(\"/api/analytics/tokens\"); } catch {}\n const overall = (analytics as any).overall ?? {};\n const byState = issues.reduce<Record<string, number>>((accumulator, issue: any) => {\n const key = issue.state ?? \"Unknown\";\n accumulator[key] = (accumulator[key] ?? 0) + 1;\n return accumulator;\n }, {});\n const totalIssues = issues.length;\n const completed = byState[\"Done\"] ?? 0;\n const blocked = (byState[\"Blocked\"] ?? 0) + (byState[\"Failed\"] ?? 0);\n const inProgress = (byState[\"Running\"] ?? 0) + (byState[\"Reviewing\"] ?? 0) + (byState[\"Reviewed\"] ?? 0) + (byState[\"Queued\"] ?? 0);\n const planned = byState[\"Planned\"] ?? 0;\n const planning = byState[\"Planning\"] ?? 0;\n const cancelled = byState[\"Cancelled\"] ?? 0;\n const inputTokens = typeof overall.inputTokens === \"number\" ? overall.inputTokens : 0;\n const outputTokens = typeof overall.outputTokens === \"number\" ? overall.outputTokens : 0;\n const totalTokens = typeof overall.totalTokens === \"number\" ? overall.totalTokens : 0;\n const estimatedCost = (inputTokens / 1_000_000) * 3 + (outputTokens / 1_000_000) * 15;\n\n const summaryText = [\n `# Fifony Weekly Progress Summary`,\n ``,\n `## Issue Statistics`,\n `| Status | Count |`,\n `|--------|-------|`,\n `| Total Issues | ${totalIssues} |`,\n `| Completed (Done) | ${completed} |`,\n `| In Progress | ${inProgress} |`,\n `| Planned | ${planned} |`,\n `| Planning | ${planning} |`,\n `| Blocked/Failed | ${blocked} |`,\n `| Cancelled | ${cancelled} |`,\n ``,\n `## Token Usage`,\n `- **Total Tokens**: ${totalTokens.toLocaleString()}`,\n `- **Input Tokens**: ${inputTokens.toLocaleString()}`,\n `- **Output Tokens**: ${outputTokens.toLocaleString()}`,\n `- **Estimated Cost**: $${(Math.round(estimatedCost * 100) / 100).toFixed(2)}`,\n ``,\n `## Analysis Request`,\n `Based on these metrics, please provide:`,\n `1. A brief summary of overall progress this week`,\n `2. Identification of any bottlenecks (blocked/failed issues)`,\n `3. Token usage efficiency assessment`,\n `4. Recommendations for improving throughput`,\n `5. Priority items for next week`,\n ].join(\"\\n\");\n\n return {\n description: \"Weekly progress summary prompt for the Fifony workspace.\",\n messages: [{\n role: \"user\",\n content: { type: \"text\", text: summaryText },\n }],\n };\n }\n\n if (name === \"fifony-refine-plan\") {\n const issueId = typeof args.issueId === \"string\" ? args.issueId.trim() : \"\";\n const concern = typeof args.concern === \"string\" ? args.concern.trim() : \"\";\n if (!issueId) throw new Error(\"issueId is required\");\n const issue = await getIssue(issueId);\n if (!issue) throw new Error(`Issue not found: ${issueId}`);\n const issueData = issue as any;\n const plan = issueData.plan ?? null;\n\n const steps = plan?.steps ?? [];\n const stepsText = steps.length > 0\n ? steps.map((step: any, index: number) => `${index + 1}. **${step.title ?? step.description ?? \"Step\"}**\\n ${step.description ?? step.detail ?? \"\"}`).join(\"\\n\")\n : \"No steps defined.\";\n\n const refinementText = [\n `# Plan Refinement for Issue ${issueId}`,\n ``,\n `## Issue`,\n `- **Title**: ${issueData.title ?? \"Unknown\"}`,\n `- **Description**: ${issueData.description ?? \"No description\"}`,\n ``,\n `## Current Plan`,\n plan ? `- **Summary**: ${plan.summary ?? plan.title ?? \"No summary\"}` : \"No plan exists yet.\",\n plan?.estimatedComplexity ? `- **Complexity**: ${plan.estimatedComplexity}` : \"\",\n ``,\n `### Steps`,\n stepsText,\n ``,\n concern ? `## Specific Concern\\n${concern}\\n` : \"\",\n `## Refinement Guidance`,\n `Please review the current plan and provide specific, actionable feedback:`,\n `1. Are the steps correctly ordered and complete?`,\n `2. Are there missing edge cases or error handling steps?`,\n `3. Is the complexity estimate accurate?`,\n `4. Are the file paths and affected areas correct?`,\n `5. Should any steps be split, merged, or removed?`,\n ``,\n `Provide your feedback, and it will be used to refine the plan via \\`fifony.refine\\`.`,\n ].filter((line) => line !== undefined).join(\"\\n\");\n\n return {\n description: `Plan refinement prompt for issue ${issueId}.`,\n messages: [{\n role: \"user\",\n content: { type: \"text\", text: refinementText },\n }],\n };\n }\n\n if (name === \"fifony-code-review\") {\n const issueId = typeof args.issueId === \"string\" ? args.issueId.trim() : \"\";\n if (!issueId) throw new Error(\"issueId is required\");\n const issue = await getIssue(issueId);\n if (!issue) throw new Error(`Issue not found: ${issueId}`);\n const issueData = issue as any;\n\n let diffData: Record<string, unknown> = {};\n try {\n diffData = await apiGet(`/api/diff/${encodeURIComponent(issueId)}`);\n } catch (error) {\n throw new Error(`Cannot fetch diff for issue ${issueId}. Is the runtime running? ${String(error)}`);\n }\n\n const files = Array.isArray((diffData as any).files) ? (diffData as any).files : [];\n const diff = typeof (diffData as any).diff === \"string\" ? (diffData as any).diff : \"\";\n const totalAdditions = typeof (diffData as any).totalAdditions === \"number\" ? (diffData as any).totalAdditions : 0;\n const totalDeletions = typeof (diffData as any).totalDeletions === \"number\" ? (diffData as any).totalDeletions : 0;\n\n if (!diff.trim()) {\n return {\n description: `Code review prompt for issue ${issueId} (no changes).`,\n messages: [{\n role: \"user\",\n content: { type: \"text\", text: `# Code Review for ${issueId}\\n\\nNo code changes found for this issue. The workspace may not have been created yet or no modifications were made.` },\n }],\n };\n }\n\n const filesTable = files.map((file: any) => `| ${file.path} | ${file.status} | +${file.additions} | -${file.deletions} |`).join(\"\\n\");\n\n const reviewText = [\n `# Code Review for Issue ${issueId}`,\n ``,\n `## Issue Context`,\n `- **Title**: ${issueData.title ?? \"Unknown\"}`,\n `- **Description**: ${issueData.description ?? \"No description\"}`,\n `- **State**: ${issueData.state ?? \"Unknown\"}`,\n ``,\n `## Change Summary`,\n `- **Files Changed**: ${files.length}`,\n `- **Total Additions**: +${totalAdditions}`,\n `- **Total Deletions**: -${totalDeletions}`,\n ``,\n `### Files`,\n `| Path | Status | Additions | Deletions |`,\n `|------|--------|-----------|-----------|`,\n filesTable,\n ``,\n `## Diff`,\n \"```diff\",\n diff.length > 50000 ? diff.substring(0, 50000) + \"\\n... (diff truncated at 50KB)\" : diff,\n \"```\",\n ``,\n `## Review Checklist`,\n `Please review the changes and evaluate:`,\n `1. **Correctness**: Do the changes correctly implement what the issue describes?`,\n `2. **Code Quality**: Is the code clean, readable, and follows project conventions?`,\n `3. **Error Handling**: Are edge cases and errors properly handled?`,\n `4. **Security**: Are there any security concerns (hardcoded secrets, SQL injection, XSS)?`,\n `5. **Performance**: Are there any performance concerns or inefficiencies?`,\n `6. **Tests**: Are changes adequately covered by tests?`,\n `7. **Breaking Changes**: Do any changes break backward compatibility?`,\n ].join(\"\\n\");\n\n return {\n description: `Code review prompt for issue ${issueId}.`,\n messages: [{\n role: \"user\",\n content: { type: \"text\", text: reviewText },\n }],\n };\n }\n\n throw new Error(`Unknown prompt: ${name}`);\n}\n"],"mappings":";;;;;;;;AAAA,SAAS,OAAAA,MAAK,aAAa;;;ACA3B,SAAS,YAAY,oBAAoB;AACzC,SAAS,UAAU,MAAM,eAAe;AACxC,SAAS,WAAW;AACpB,SAAS,eAAe;AACxB,SAAS,qBAAqB;AAsD9B,IAAM,iBAAiB,IAAI,yBAAyB,QAAQ,IAAI;AAChE,IAAM,mBAAmB,IAAI,sBAAsB;AACnD,IAAM,aAAa,uBAAuB,gBAAgB;AAC1D,IAAM,gBAAgB,KAAK,YAAY,eAAe;AACtD,IAAM,aAAa,IAAI,sBAAsB;AAE7C,SAAS,uBAAuB,OAAuB;AACrD,QAAM,WAAW,MAAM,WAAW,SAAS,IACvC,cAAc,KAAK,IACnB,MAAM,WAAW,IAAI,IACnB,QAAQ,QAAQ,GAAG,MAAM,MAAM,CAAC,CAAC,IACjC,QAAQ,KAAK;AAEnB,SAAO,SAAS,QAAQ,MAAM,YAAY,WAAW,KAAK,UAAU,SAAS;AAC/E;AAEO,IAAM,mBAAmB;AACzB,IAAM,iBAAiB;AACvB,IAAM,iBAAiB;AACvB,IAAM,mBAAmB;AACzB,IAAM,oBAAoB;AAC1B,IAAM,oBAAoB;AAKjC,IAAI,WAAgC;AACpC,IAAI,kBAAuC;AAC3C,IAAI,gBAAqC;AACzC,IAAI,gBAAqC;AACzC,IAAI,kBAAuC;AAC3C,IAAI,mBAAwC;AAErC,SAAS,eAAe;AAC7B,SAAO,EAAE,iBAAiB,eAAe,eAAe,iBAAiB,iBAAiB;AAC5F;AAEO,SAAS,cAAmC;AACjD,SAAO;AACT;AAIA,SAAS,UAAU,SAAuB;AACxC,MAAI,CAAC,WAAY;AACjB,UAAQ,OAAO,MAAM,uBAAuB,OAAO;AAAA,CA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U;AAC3B,YAAU,MAAM,QAAQ,sCAAsC,OAAO,KAAK,CAAC,EAAE;AAC7E,UAAQ,KAAK,CAAC;AAChB,CAAC;AAED,QAAQ,GAAG,UAAU,YAAY;AAC/B,QAAM,KAAK,YAAY;AACvB,MAAI,GAAI,OAAM,GAAG,WAAW;AAC5B,UAAQ,KAAK,CAAC;AAChB,CAAC;AAED,QAAQ,GAAG,WAAW,YAAY;AAChC,QAAM,KAAK,YAAY;AACvB,MAAI,GAAI,OAAM,GAAG,WAAW;AAC5B,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["env","existsSync","readFileSync","homedir","join","resolve","existsSync","join","readFileSync","homedir","resolve","env","env","join","resolve","fileURLToPath","fileURLToPath","resolve","join","sessionResource","pipelineResource","issueId","issue","issueResource","DEBUG_BOOT","env","debugBoot"]}
|