@duckwalk/mcp-server 0.1.2 → 0.1.3
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.
|
@@ -3,7 +3,7 @@ function getDuckWalkContract() {
|
|
|
3
3
|
return {
|
|
4
4
|
server: {
|
|
5
5
|
name: "duckwalk-mcp",
|
|
6
|
-
version: "0.1.
|
|
6
|
+
version: "0.1.3"
|
|
7
7
|
},
|
|
8
8
|
guidance: {
|
|
9
9
|
summary: "Use this contract instead of searching the duckWalk repo or the user's home directory for examples.",
|
|
@@ -1292,4 +1292,4 @@ export {
|
|
|
1292
1292
|
getGuidedSession,
|
|
1293
1293
|
updateStepStatus
|
|
1294
1294
|
};
|
|
1295
|
-
//# sourceMappingURL=chunk-
|
|
1295
|
+
//# sourceMappingURL=chunk-7CJLN27A.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/contract.ts","../../../packages/core/src/markdown-writer.ts","../../../packages/core/src/recipe-writer.ts","../../../packages/core/src/state.ts","../../../packages/core/src/session.ts","../../../packages/core/src/session-history.ts","../../../packages/schema/src/guided-session.ts","../../../packages/core/src/validation.ts","../src/service.ts","../src/walkthrough-validation.ts"],"sourcesContent":["export function getDuckWalkContract() {\n return {\n server: {\n name: \"duckwalk-mcp\",\n version: \"0.1.2\"\n },\n guidance: {\n summary:\n \"Use this contract instead of searching the duckWalk repo or the user's home directory for examples.\",\n workspaceRoot:\n \"Always pass workspaceRoot as the absolute target task workspace path when creating, reading, or updating guided sessions.\",\n gitignore:\n \"Session creation automatically adds .guided-implementation/ to the target workspace .gitignore when no equivalent ignore rule already exists.\",\n commentStyle:\n \"For functions or non-trivial logic in ghostCode, include short pragmatic comments that say what the code does. Only use an `Important:` comment when the behavior is safety-critical, stateful, or easy to misuse.\",\n pathfinderAuthoringHints: [\n \"Start at the real entrypoint for the user's question, such as middleware, controller, route, job handler, or event subscriber.\",\n \"Follow calls, hooks, guards, and data handoffs in execution order until the question is answered.\",\n \"Use one step per touchpoint, not one step per file.\",\n \"Use named subranges so the walkthrough can distinguish action ranges from supporting context.\",\n \"Fill step links explicitly so the graph and story can show why control moves to the next touchpoint.\"\n ],\n recommendedFlow: [\n \"Inspect only the current task workspace to choose file targets.\",\n \"Call get_duckwalk_contract when you need the session shape or examples.\",\n \"Call create_guided_session for implementation playback or create_pr_review_session for review playback.\",\n \"Call pathfinder for question-driven codebase walkthroughs that explain architecture flow.\",\n \"Only call get_guided_session when you explicitly need current session data.\",\n \"Only call update_step_status when the user explicitly wants step state changed from Codex.\"\n ]\n },\n tools: {\n get_duckwalk_contract: {\n description: \"Returns the duckWalk contract, rules, and example payloads.\"\n },\n create_guided_session: {\n description: \"Validate and persist an implementation guided session.\",\n input: {\n workspaceRoot: \"string, absolute path, recommended\",\n session: \"GuidedSession with mode implementation\"\n }\n },\n create_pr_review_session: {\n description: \"Validate and persist a PR review guided session.\",\n input: {\n workspaceRoot: \"string, absolute path, recommended\",\n session: \"GuidedSession with mode pr_review\"\n }\n },\n pathfinder: {\n description:\n \"Validate and persist a question-driven codebase walkthrough guided session.\",\n input: {\n workspaceRoot: \"string, absolute path, recommended\",\n session: \"GuidedSession with mode codebase_walkthrough\"\n }\n },\n get_guided_session: {\n description: \"Read the current session or a specific session by ID.\",\n input: {\n workspaceRoot: \"string, absolute path, recommended\",\n sessionId: \"optional string\"\n }\n },\n update_step_status: {\n description: \"Update one step status in the current guided session state.\",\n input: {\n workspaceRoot: \"string, absolute path, recommended\",\n sessionId: \"string\",\n stepId: \"string\",\n status: [\"pending\", \"active\", \"complete\", \"skipped\"]\n }\n }\n },\n schema: {\n sessionModes: [\"implementation\", \"pr_review\", \"codebase_walkthrough\"],\n implementationStepRequiredFields: [\n \"id\",\n \"order\",\n \"mode\",\n \"file\",\n \"location\",\n \"explanation\",\n \"ghostCode\"\n ],\n prReviewStepRequiredFields: [\n \"id\",\n \"order\",\n \"mode\",\n \"file\",\n \"location\",\n \"explanation\",\n \"review\"\n ],\n codebaseWalkthroughRequiredFields: [\n \"question\",\n \"lens\",\n \"flow\",\n \"id\",\n \"order\",\n \"mode\",\n \"touchpoint\",\n \"confidence\",\n \"evidenceQuality\",\n \"fileRationale\",\n \"file\",\n \"location\",\n \"explanation\",\n \"snippet\",\n \"subranges\"\n ],\n walkthroughFlowFields: [\"summary\", \"path\", \"entrypoint?\", \"outcome?\"],\n walkthroughSubrangeFields: [\n \"id\",\n \"label\",\n \"role\",\n \"range\",\n \"summary?\",\n \"snippet?\",\n \"symbols?\"\n ],\n walkthroughLinkFields: [\"stepId\", \"subrangeId?\", \"type\", \"why\", \"viaSymbol?\"],\n walkthroughBranchFields: [\n \"id\",\n \"label\",\n \"condition\",\n \"outcome\",\n \"targetStepId?\",\n \"targetSubrangeId?\"\n ],\n walkthroughFollowUpFields: [\"id\", \"kind\", \"label\", \"description\", \"stepId?\", \"file?\"],\n optionalStepFields: [\"links?\", \"branches?\", \"symbols?\"],\n guidedFileTargetFields: [\"path\", \"exists?\", \"createIfMissing?\"],\n locationStrategies: [\"create_file\", \"line\", \"range\", \"after_text\", \"before_text\"],\n explanationFields: [\"title\", \"what\", \"why\", \"how?\", \"impact?\", \"risk?\", \"narration?\"],\n validation: {\n default: {\n type: \"normalised_match\"\n },\n optionalFields: [\"expectedText\", \"scope\"]\n },\n prReviewRangeRule:\n \"Each pr_review step must include a usable range through location.range or review.changedRange.\",\n codebaseWalkthroughRangeRule:\n \"Each codebase_walkthrough step must include location.strategy = range and a usable location.range.\",\n codebaseWalkthroughSubrangeRules: [\n \"Each codebase_walkthrough step must include named subranges.\",\n \"Exactly one subrange must use role primary and it must match location.range.\",\n \"Additional subranges should usually use role action or context.\",\n \"Subrange IDs and ranges must be unique within the step.\",\n \"Links must point to real step IDs in the same walkthrough.\",\n \"When links or branches target subranges, the target subrange ID must exist on the target step.\"\n ]\n },\n examples: {\n create_guided_session: {\n workspaceRoot: \"/absolute/path/to/task/workspace\",\n session: {\n id: \"feature-auth-middleware\",\n mode: \"implementation\",\n title: \"Create auth middleware\",\n summary: \"Adds a reusable auth middleware and wires it into routes.\",\n createdAt: \"2026-06-18T00:00:00.000Z\",\n steps: [\n {\n id: \"step-1\",\n order: 1,\n mode: \"implementation\",\n file: {\n path: \"src/middleware/auth.ts\",\n createIfMissing: true\n },\n location: {\n strategy: \"create_file\"\n },\n explanation: {\n title: \"Create the auth middleware\",\n what: \"Adds a reusable authorization middleware.\",\n why: \"Route handlers should not repeat auth checks.\"\n },\n ghostCode:\n \"import type { FastifyReply, FastifyRequest } from 'fastify';\\n\\n// Rejects unauthenticated requests before route handlers run.\\nexport async function authMiddleware(request: FastifyRequest, reply: FastifyReply) {\\n const authHeader = request.headers.authorization;\\n\\n // Important: fail fast so protected handlers never run without auth.\\n if (!authHeader) {\\n return reply.code(401).send({ error: 'Missing authorization header' });\\n }\\n}\\n\",\n validation: {\n type: \"normalised_match\"\n }\n }\n ]\n }\n },\n create_pr_review_session: {\n workspaceRoot: \"/absolute/path/to/task/workspace\",\n session: {\n id: \"review-auth-middleware\",\n mode: \"pr_review\",\n title: \"Review auth middleware changes\",\n summary: \"Walks through the middleware and route wiring changes.\",\n createdAt: \"2026-06-18T00:00:00.000Z\",\n steps: [\n {\n id: \"review-step-1\",\n order: 1,\n mode: \"pr_review\",\n file: {\n path: \"src/middleware/auth.ts\"\n },\n location: {\n strategy: \"range\",\n range: {\n startLine: 1,\n startCharacter: 0,\n endLine: 12,\n endCharacter: 0\n }\n },\n explanation: {\n title: \"Review the middleware implementation\",\n what: \"Adds a reusable auth check.\",\n why: \"Routes should fail fast before business logic.\",\n impact: \"Protected handlers now reject missing authorization headers.\"\n },\n review: {\n beforeCode: \"\",\n afterCode: \"export async function authMiddleware() {}\\n\",\n changedRange: {\n startLine: 1,\n startCharacter: 0,\n endLine: 12,\n endCharacter: 0\n }\n }\n }\n ]\n }\n },\n pathfinder: {\n workspaceRoot: \"/absolute/path/to/task/workspace\",\n session: {\n id: \"walkthrough-authentication-flow\",\n mode: \"codebase_walkthrough\",\n title: \"Trace backend authentication flow\",\n summary: \"Shows how a protected request moves from middleware into token validation.\",\n question: \"How does authentication work in this backend project?\",\n lens: \"permission_flow\",\n flow: {\n summary: \"Request -> auth middleware -> auth service -> route guard\",\n path: [\"Request\", \"authMiddleware\", \"resolveAuthenticatedUser\", \"requireRole\"],\n entrypoint: \"HTTP request to a protected route\",\n outcome: \"Only authenticated requests with the right role reach the handler.\"\n },\n followUps: [\n {\n id: \"follow-up-tests\",\n kind: \"tests\",\n label: \"Inspect auth tests\",\n description: \"Open the middleware tests to confirm the success path and failure branches.\",\n file: \"tests/auth/middleware.test.ts\"\n }\n ],\n createdAt: \"2026-06-18T00:00:00.000Z\",\n steps: [\n {\n id: \"walkthrough-step-1\",\n order: 1,\n mode: \"codebase_walkthrough\",\n touchpoint: \"entry\",\n confidence: \"direct\",\n evidenceQuality: \"high\",\n fileRationale:\n \"This file is the first protected-route touchpoint where authentication begins.\",\n file: {\n path: \"src/auth/middleware.ts\"\n },\n location: {\n strategy: \"range\",\n range: {\n startLine: 1,\n startCharacter: 0,\n endLine: 12,\n endCharacter: 0\n }\n },\n subranges: [\n {\n id: \"middleware-entry\",\n label: \"Middleware entry\",\n role: \"primary\",\n range: {\n startLine: 1,\n startCharacter: 0,\n endLine: 12,\n endCharacter: 0\n },\n summary: \"Reads the Authorization header and extracts the bearer token.\",\n symbols: [\"authMiddleware\"]\n },\n {\n id: \"downstream-policy-context\",\n label: \"Downstream policy context\",\n role: \"context\",\n range: {\n startLine: 130,\n startCharacter: 0,\n endLine: 190,\n endCharacter: 0\n },\n summary: \"Later role checks depend on the authenticated user injected here.\",\n symbols: [\"requireRole\"]\n }\n ],\n symbols: [\"authMiddleware\", \"resolveAuthenticatedUser\", \"requireRole\"],\n explanation: {\n title: \"Start at the auth middleware\",\n what: \"This middleware extracts the bearer token from the request.\",\n why: \"Every protected route enters the authentication flow here.\",\n how: \"The request header is parsed and the token is passed to the downstream auth service.\",\n impact: \"Requests without a token fail before route handlers run.\"\n },\n snippet:\n \"export async function authMiddleware(request, reply) {\\n const authHeader = request.headers.authorization;\\n const token = authHeader?.replace('Bearer ', '');\\n}\\n\",\n links: [\n {\n stepId: \"walkthrough-step-2\",\n subrangeId: \"token-validate\",\n type: \"calls\",\n why: \"The extracted token is validated by the auth service before the request can continue.\",\n viaSymbol: \"resolveAuthenticatedUser\"\n }\n ],\n branches: [\n {\n id: \"missing-token\",\n label: \"Missing token\",\n condition: \"The Authorization header is missing or malformed.\",\n outcome: \"The request fails before the route handler runs.\"\n },\n {\n id: \"success-path\",\n label: \"Success path\",\n condition: \"A bearer token is present.\",\n outcome: \"The request continues into the token validation step.\",\n targetStepId: \"walkthrough-step-2\",\n targetSubrangeId: \"token-validate\"\n }\n ]\n },\n {\n id: \"walkthrough-step-2\",\n order: 2,\n mode: \"codebase_walkthrough\",\n touchpoint: \"transform\",\n confidence: \"direct\",\n evidenceQuality: \"high\",\n fileRationale:\n \"This file turns the raw token into a trusted identity object for downstream guards.\",\n file: {\n path: \"src/auth/service.ts\"\n },\n location: {\n strategy: \"range\",\n range: {\n startLine: 10,\n startCharacter: 0,\n endLine: 24,\n endCharacter: 0\n }\n },\n subranges: [\n {\n id: \"token-validate\",\n label: \"Token validation\",\n role: \"primary\",\n range: {\n startLine: 10,\n startCharacter: 0,\n endLine: 24,\n endCharacter: 0\n },\n summary: \"Verifies the token and resolves the authenticated user.\",\n symbols: [\"resolveAuthenticatedUser\", \"verifyToken\"]\n }\n ],\n symbols: [\"resolveAuthenticatedUser\", \"verifyToken\"],\n explanation: {\n title: \"Validate the token and resolve the user\",\n what: \"The auth service verifies the token and builds the authenticated user context.\",\n why: \"Downstream guards can only make authorization decisions from a trusted identity.\",\n how: \"The token verifier decodes claims and returns a resolved actor for later guards.\"\n },\n snippet:\n \"export async function resolveAuthenticatedUser(token) {\\n const payload = await verifyToken(token);\\n return { userId: payload.sub, roles: payload.roles };\\n}\\n\"\n }\n ]\n }\n }\n }\n };\n}\n","import type { GuidedSession } from \"@duckwalk/schema\";\n\nfunction formatStepLocation(step: GuidedSession[\"steps\"][number]): string | null {\n const labels: string[] = [];\n\n if (step.mode === \"pr_review\" && step.review.changedRange) {\n labels.push(\n `${step.review.changedRange.startLine}:${step.review.changedRange.startCharacter} - ${step.review.changedRange.endLine}:${step.review.changedRange.endCharacter}`\n );\n } else if (step.location.strategy === \"range\" && step.location.range) {\n labels.push(\n `${step.location.range.startLine}:${step.location.range.startCharacter} - ${step.location.range.endLine}:${step.location.range.endCharacter}`\n );\n } else if (step.location.strategy === \"line\" && step.location.line) {\n labels.push(`${step.location.line}:${step.location.column ?? 0}`);\n } else if (\n (step.location.strategy === \"after_text\" || step.location.strategy === \"before_text\") &&\n step.location.anchorText\n ) {\n labels.push(step.location.anchorText);\n }\n\n for (const subrange of step.subranges ?? []) {\n labels.push(\n `${subrange.label} (${subrange.role}): ${subrange.range.startLine}:${subrange.range.startCharacter} - ${subrange.range.endLine}:${subrange.range.endCharacter}`\n );\n }\n\n return labels.length > 0 ? labels.join(\"; \") : null;\n}\n\nexport function renderSessionMarkdown(session: GuidedSession): string {\n const lines: string[] = [\n `# ${session.title}`,\n \"\",\n `- Session ID: \\`${session.id}\\``,\n `- Mode: \\`${session.mode}\\``,\n `- Created At: \\`${session.createdAt}\\``,\n \"\",\n session.summary\n ];\n\n if (session.mode === \"codebase_walkthrough\" && session.question) {\n lines.push(\"\", `Question: ${session.question}`);\n }\n if (session.mode === \"codebase_walkthrough\" && session.lens) {\n lines.push(`Lens: ${session.lens}`);\n }\n\n if (session.mode === \"codebase_walkthrough\" && session.flow) {\n lines.push(\"\", \"## Flow Summary\", \"\");\n lines.push(`- Summary: ${session.flow.summary}`);\n lines.push(`- Path: ${session.flow.path.join(\" -> \")}`);\n if (session.flow.entrypoint) {\n lines.push(`- Entrypoint: ${session.flow.entrypoint}`);\n }\n if (session.flow.outcome) {\n lines.push(`- Outcome: ${session.flow.outcome}`);\n }\n }\n\n lines.push(\"\");\n\n for (const step of [...session.steps].sort((left, right) => left.order - right.order)) {\n lines.push(`## Step ${step.order}: ${step.explanation.title}`, \"\");\n lines.push(`- File: \\`${step.file.path}\\``);\n lines.push(`- Location strategy: \\`${step.location.strategy}\\``);\n const locationDetail = formatStepLocation(step);\n if (locationDetail) {\n lines.push(`- Where: ${locationDetail}`);\n }\n if (step.mode === \"codebase_walkthrough\") {\n lines.push(`- Touchpoint: ${step.touchpoint}`);\n lines.push(`- Confidence: ${step.confidence}`);\n lines.push(`- Evidence quality: ${step.evidenceQuality}`);\n lines.push(`- File rationale: ${step.fileRationale}`);\n }\n lines.push(`- What: ${step.explanation.what}`);\n lines.push(`- Why: ${step.explanation.why}`);\n if (step.explanation.how) {\n lines.push(`- How: ${step.explanation.how}`);\n }\n if (step.explanation.impact) {\n lines.push(`- Impact: ${step.explanation.impact}`);\n }\n if (step.explanation.risk) {\n lines.push(`- Risk: ${step.explanation.risk}`);\n }\n if (step.symbols?.length) {\n lines.push(`- Symbols: ${step.symbols.join(\", \")}`);\n }\n lines.push(\"\");\n\n if (step.mode === \"implementation\") {\n lines.push(\"```ts\", step.ghostCode, \"```\", \"\");\n } else if (step.mode === \"pr_review\") {\n if (step.review.beforeCode) {\n lines.push(\"### Before\", \"\", \"```ts\", step.review.beforeCode, \"```\", \"\");\n }\n if (step.review.afterCode) {\n lines.push(\"### After\", \"\", \"```ts\", step.review.afterCode, \"```\", \"\");\n }\n } else {\n lines.push(\"### Snippet\", \"\", \"```ts\", step.snippet, \"```\", \"\");\n if (step.subranges?.length) {\n lines.push(\"### Evidence\", \"\");\n\n for (const subrange of step.subranges) {\n lines.push(\n `- ${subrange.label} [${subrange.role}] ${subrange.range.startLine}:${subrange.range.startCharacter} - ${subrange.range.endLine}:${subrange.range.endCharacter}`\n );\n if (subrange.summary) {\n lines.push(` Summary: ${subrange.summary}`);\n }\n if (subrange.symbols?.length) {\n lines.push(` Symbols: ${subrange.symbols.join(\", \")}`);\n }\n if (subrange.snippet) {\n lines.push(\"\", \"```ts\", subrange.snippet, \"```\");\n }\n }\n\n lines.push(\"\");\n }\n\n if (step.links?.length) {\n lines.push(\"### Links\", \"\");\n for (const link of step.links) {\n const via = link.viaSymbol ? ` via ${link.viaSymbol}` : \"\";\n const target = link.subrangeId ? `${link.stepId}#${link.subrangeId}` : link.stepId;\n lines.push(`- ${link.type} -> ${target}${via}: ${link.why}`);\n }\n lines.push(\"\");\n }\n\n if (step.branches?.length) {\n lines.push(\"### Branches\", \"\");\n for (const branch of step.branches) {\n const target = branch.targetStepId\n ? ` -> ${branch.targetStepId}${branch.targetSubrangeId ? `#${branch.targetSubrangeId}` : \"\"}`\n : \"\";\n lines.push(`- ${branch.label}${target}`);\n lines.push(` Condition: ${branch.condition}`);\n lines.push(` Outcome: ${branch.outcome}`);\n }\n lines.push(\"\");\n }\n }\n }\n\n if (session.mode === \"codebase_walkthrough\" && session.followUps?.length) {\n lines.push(\"## Follow-ups\", \"\");\n for (const followUp of session.followUps) {\n const target = followUp.stepId\n ? `step ${followUp.stepId}`\n : followUp.file\n ? `file ${followUp.file}`\n : \"general\";\n lines.push(`- ${followUp.label} [${followUp.kind}] (${target})`);\n lines.push(` ${followUp.description}`);\n }\n }\n\n return `${lines.join(\"\\n\").trim()}\\n`;\n}\n","import { readFile, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nimport type { GuidedSession } from \"@duckwalk/schema\";\n\nimport { renderSessionMarkdown } from \"./markdown-writer\";\nimport { createInitialSessionState, ensureGuidedDirectories, writeGuidedState } from \"./state\";\n\nconst guidedImplementationIgnoreRule = \".guided-implementation/\";\n\nasync function ensureGuidedImplementationGitignore(rootDir: string) {\n const gitignorePath = path.join(rootDir, \".gitignore\");\n let existing = \"\";\n\n try {\n existing = await readFile(gitignorePath, \"utf8\");\n } catch {\n existing = \"\";\n }\n\n const hasRule = existing\n .split(/\\r?\\n/)\n .map((line) => line.trim())\n .some(\n (line) =>\n line === guidedImplementationIgnoreRule ||\n line === \".guided-implementation\" ||\n line === \".guided-implementation/*\"\n );\n\n if (hasRule) {\n return;\n }\n\n const prefix = existing.length > 0 && !existing.endsWith(\"\\n\") ? \"\\n\" : \"\";\n await writeFile(gitignorePath, `${existing}${prefix}${guidedImplementationIgnoreRule}\\n`);\n}\n\nexport async function writeRecipeFiles(rootDir: string, session: GuidedSession) {\n const paths = await ensureGuidedDirectories(rootDir);\n const recipePayload = `${JSON.stringify(session, null, 2)}\\n`;\n const markdownPayload = renderSessionMarkdown(session);\n const sessionRecipePath = path.join(paths.sessionsDir, `${session.id}.recipe.json`);\n const sessionMarkdownPath = path.join(paths.sessionsDir, `${session.id}.recipe.md`);\n\n await ensureGuidedImplementationGitignore(rootDir);\n await writeFile(paths.currentRecipePath, recipePayload);\n await writeFile(paths.currentMarkdownPath, markdownPayload);\n await writeFile(sessionRecipePath, recipePayload);\n await writeFile(sessionMarkdownPath, markdownPayload);\n await writeGuidedState(rootDir, createInitialSessionState(session));\n\n return {\n recipePath: paths.currentRecipePath,\n markdownPath: paths.currentMarkdownPath,\n statePath: paths.statePath,\n sessionRecipePath,\n sessionMarkdownPath\n };\n}\n\nexport async function readGuidedSession(rootDir: string, sessionId?: string): Promise<GuidedSession> {\n const paths = await ensureGuidedDirectories(rootDir);\n const recipePath = sessionId\n ? path.join(paths.sessionsDir, `${sessionId}.recipe.json`)\n : paths.currentRecipePath;\n const raw = await readFile(recipePath, \"utf8\");\n return JSON.parse(raw) as GuidedSession;\n}\n","import { mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nimport type { GuidedSession, StepStatus } from \"@duckwalk/schema\";\nimport { z } from \"zod\";\n\nexport const guidedPaths = {\n directoryName: \".guided-implementation\",\n currentRecipeName: \"current.recipe.json\",\n currentMarkdownName: \"current.recipe.md\",\n stateName: \"state.json\",\n sessionsDirectoryName: \"sessions\"\n} as const;\n\nconst stepStateSchema = z.object({\n status: z.enum([\"pending\", \"active\", \"complete\", \"skipped\"]),\n completedAt: z.string().optional()\n});\n\nexport const guidedSessionStateSchema = z.object({\n sessionId: z.string().min(1),\n activeStepId: z.string().min(1).nullable(),\n activeStepOrder: z.number().int().positive().nullable(),\n updatedAt: z.string().min(1),\n steps: z.record(stepStateSchema)\n});\n\nexport type GuidedSessionState = z.infer<typeof guidedSessionStateSchema>;\n\nexport function resolveGuidedPaths(rootDir: string) {\n const baseDir = path.join(rootDir, guidedPaths.directoryName);\n return {\n baseDir,\n currentRecipePath: path.join(baseDir, guidedPaths.currentRecipeName),\n currentMarkdownPath: path.join(baseDir, guidedPaths.currentMarkdownName),\n statePath: path.join(baseDir, guidedPaths.stateName),\n sessionsDir: path.join(baseDir, guidedPaths.sessionsDirectoryName)\n };\n}\n\nfunction getSessionStatePath(paths: ReturnType<typeof resolveGuidedPaths>, sessionId: string) {\n return path.join(paths.sessionsDir, `${sessionId}.state.json`);\n}\n\nexport function createInitialSessionState(session: GuidedSession): GuidedSessionState {\n const orderedSteps = [...session.steps].sort((left, right) => left.order - right.order);\n const firstStep = orderedSteps[0] ?? null;\n const steps: GuidedSessionState[\"steps\"] = {};\n\n for (const step of orderedSteps) {\n steps[step.id] = {\n status: step.id === firstStep?.id ? \"active\" : \"pending\"\n };\n }\n\n return {\n sessionId: session.id,\n activeStepId: firstStep?.id ?? null,\n activeStepOrder: firstStep?.order ?? null,\n updatedAt: new Date().toISOString(),\n steps\n };\n}\n\nexport async function ensureGuidedDirectories(rootDir: string): Promise<ReturnType<typeof resolveGuidedPaths>> {\n const paths = resolveGuidedPaths(rootDir);\n await mkdir(paths.baseDir, { recursive: true });\n await mkdir(paths.sessionsDir, { recursive: true });\n return paths;\n}\n\nexport async function readGuidedState(\n rootDir: string,\n sessionId?: string\n): Promise<GuidedSessionState | null> {\n const paths = resolveGuidedPaths(rootDir);\n const statePath = sessionId ? getSessionStatePath(paths, sessionId) : paths.statePath;\n try {\n const raw = await readFile(statePath, \"utf8\");\n return guidedSessionStateSchema.parse(JSON.parse(raw));\n } catch {\n return null;\n }\n}\n\nexport async function writeGuidedState(\n rootDir: string,\n state: GuidedSessionState,\n options: { writeCurrent?: boolean } = {}\n): Promise<string> {\n const paths = await ensureGuidedDirectories(rootDir);\n const nextState = {\n ...state,\n updatedAt: new Date().toISOString()\n };\n const payload = JSON.stringify(nextState, null, 2);\n const sessionStatePath = getSessionStatePath(paths, nextState.sessionId);\n\n await writeFile(sessionStatePath, payload);\n if (options.writeCurrent ?? true) {\n await writeFile(paths.statePath, payload);\n return paths.statePath;\n }\n\n return sessionStatePath;\n}\n\nexport async function setActiveStep(\n rootDir: string,\n session: GuidedSession,\n stepId: string\n): Promise<GuidedSessionState> {\n const existing = (await readGuidedState(rootDir, session.id)) ?? createInitialSessionState(session);\n const step = session.steps.find((candidate) => candidate.id === stepId);\n\n if (!step) {\n throw new Error(`Unknown step ID: ${stepId}`);\n }\n\n const nextSteps = { ...existing.steps };\n const previousActiveStepId = existing.activeStepId;\n if (previousActiveStepId && nextSteps[previousActiveStepId]?.status === \"active\") {\n nextSteps[previousActiveStepId] = { status: \"pending\" };\n }\n\n if (nextSteps[stepId]?.status !== \"complete\") {\n nextSteps[stepId] = { status: \"active\" };\n }\n\n const nextState: GuidedSessionState = {\n ...existing,\n sessionId: session.id,\n activeStepId: stepId,\n activeStepOrder: step.order,\n steps: nextSteps,\n updatedAt: new Date().toISOString()\n };\n\n await writeGuidedState(rootDir, nextState);\n return nextState;\n}\n\nexport async function updateGuidedStepStatus(\n rootDir: string,\n session: GuidedSession,\n stepId: string,\n status: StepStatus,\n options: { writeCurrent?: boolean } = {}\n): Promise<GuidedSessionState> {\n const existing = (await readGuidedState(rootDir, session.id)) ?? createInitialSessionState(session);\n const orderedSteps = [...session.steps].sort((left, right) => left.order - right.order);\n const currentIndex = orderedSteps.findIndex((step) => step.id === stepId);\n\n if (currentIndex === -1) {\n throw new Error(`Unknown step ID: ${stepId}`);\n }\n\n const nextSteps = {\n ...existing.steps,\n [stepId]: {\n status,\n completedAt: status === \"complete\" ? new Date().toISOString() : undefined\n }\n };\n\n let activeStepId = existing.activeStepId;\n let activeStepOrder = existing.activeStepOrder;\n\n if (status === \"complete\") {\n const nextStep = orderedSteps[currentIndex + 1];\n if (nextStep) {\n if (nextSteps[nextStep.id]?.status !== \"complete\") {\n nextSteps[nextStep.id] = { status: \"active\" };\n }\n activeStepId = nextStep.id;\n activeStepOrder = nextStep.order;\n } else {\n activeStepId = null;\n activeStepOrder = null;\n }\n }\n\n const nextState: GuidedSessionState = {\n sessionId: session.id,\n activeStepId,\n activeStepOrder,\n updatedAt: new Date().toISOString(),\n steps: nextSteps\n };\n\n await writeGuidedState(rootDir, nextState, options);\n return nextState;\n}\n\nexport async function undoGuidedStepCompletion(\n rootDir: string,\n session: GuidedSession,\n stepId: string,\n options: { writeCurrent?: boolean } = {}\n): Promise<GuidedSessionState> {\n const existing = (await readGuidedState(rootDir, session.id)) ?? createInitialSessionState(session);\n const orderedSteps = [...session.steps].sort((left, right) => left.order - right.order);\n const currentIndex = orderedSteps.findIndex((step) => step.id === stepId);\n\n if (currentIndex === -1) {\n throw new Error(`Unknown step ID: ${stepId}`);\n }\n\n const targetStep = orderedSteps[currentIndex]!;\n const nextSteps = { ...existing.steps };\n\n orderedSteps.forEach((step, index) => {\n if (index < currentIndex) {\n return;\n }\n\n if (step.id === targetStep.id) {\n nextSteps[step.id] = { status: \"active\" };\n return;\n }\n\n nextSteps[step.id] = { status: \"pending\" };\n });\n\n const nextState: GuidedSessionState = {\n sessionId: session.id,\n activeStepId: targetStep.id,\n activeStepOrder: targetStep.order,\n updatedAt: new Date().toISOString(),\n steps: nextSteps\n };\n\n await writeGuidedState(rootDir, nextState, options);\n return nextState;\n}\n\nexport async function reopenGuidedStep(\n rootDir: string,\n session: GuidedSession,\n stepId: string,\n options: { writeCurrent?: boolean } = {}\n): Promise<GuidedSessionState> {\n const existing = (await readGuidedState(rootDir, session.id)) ?? createInitialSessionState(session);\n const targetStep = session.steps.find((candidate) => candidate.id === stepId);\n\n if (!targetStep) {\n throw new Error(`Unknown step ID: ${stepId}`);\n }\n\n const nextSteps = { ...existing.steps };\n\n if (existing.activeStepId && existing.activeStepId !== stepId) {\n const currentActive = nextSteps[existing.activeStepId];\n if (currentActive?.status === \"active\") {\n nextSteps[existing.activeStepId] = { status: \"pending\" };\n }\n }\n\n nextSteps[stepId] = { status: \"active\" };\n\n const nextState: GuidedSessionState = {\n sessionId: session.id,\n activeStepId: targetStep.id,\n activeStepOrder: targetStep.order,\n updatedAt: new Date().toISOString(),\n steps: nextSteps\n };\n\n await writeGuidedState(rootDir, nextState, options);\n return nextState;\n}\n","import type { GuidedSession } from \"@duckwalk/schema\";\n\nexport function getOrderedSteps(session: GuidedSession) {\n return [...session.steps].sort((left, right) => left.order - right.order);\n}\n\nexport function validateDuplicateStepIds(session: GuidedSession) {\n const seen = new Set<string>();\n\n for (const step of session.steps) {\n if (seen.has(step.id)) {\n throw new Error(`Duplicate step ID detected: ${step.id}`);\n }\n seen.add(step.id);\n }\n}\n\nexport function validateSessionOrder(session: GuidedSession) {\n const ordered = getOrderedSteps(session);\n\n ordered.forEach((step, index) => {\n const expectedOrder = index + 1;\n if (step.order !== expectedOrder) {\n throw new Error(\n `Invalid step ordering. Expected step ${step.id} to have order ${expectedOrder}, received ${step.order}`\n );\n }\n });\n}\n\nexport function validateSessionIntegrity(session: GuidedSession) {\n validateDuplicateStepIds(session);\n validateSessionOrder(session);\n}\n","import { readdir, writeFile } from \"node:fs/promises\";\n\nimport {\n guidedSessionSchema,\n type GuidedSession,\n type SessionMode\n} from \"@duckwalk/schema\";\n\nimport { renderSessionMarkdown } from \"./markdown-writer\";\nimport { readGuidedSession } from \"./recipe-writer\";\nimport {\n createInitialSessionState,\n ensureGuidedDirectories,\n readGuidedState,\n resolveGuidedPaths,\n writeGuidedState,\n type GuidedSessionState\n} from \"./state\";\n\nexport type GuidedSessionHistoryStatus = \"pending\" | \"complete\";\n\nexport type GuidedSessionHistoryEntry = {\n id: string;\n mode: SessionMode;\n title: string;\n summary: string;\n createdAt: string;\n question?: string | undefined;\n stepCount: number;\n completedStepCount: number;\n status: GuidedSessionHistoryStatus;\n isCurrent: boolean;\n};\n\nasync function readCurrentSession(rootDir: string): Promise<GuidedSession | null> {\n try {\n return guidedSessionSchema.parse(await readGuidedSession(rootDir));\n } catch {\n return null;\n }\n}\n\nasync function readSessionStateForHistory(\n rootDir: string,\n session: GuidedSession,\n currentSessionId: string | null\n): Promise<GuidedSessionState> {\n const archivedState = await readGuidedState(rootDir, session.id);\n if (archivedState) {\n return archivedState;\n }\n\n if (currentSessionId === session.id) {\n const currentState = await readGuidedState(rootDir);\n if (currentState) {\n return currentState;\n }\n }\n\n return createInitialSessionState(session);\n}\n\nfunction toHistoryEntry(\n session: GuidedSession,\n state: GuidedSessionState,\n currentSessionId: string | null\n): GuidedSessionHistoryEntry {\n const completedStepCount = session.steps.filter(\n (step) => state.steps[step.id]?.status === \"complete\"\n ).length;\n\n return {\n id: session.id,\n mode: session.mode,\n title: session.title,\n summary: session.summary,\n createdAt: session.createdAt,\n question: session.mode === \"codebase_walkthrough\" ? session.question : undefined,\n stepCount: session.steps.length,\n completedStepCount,\n status: completedStepCount === session.steps.length ? \"complete\" : \"pending\",\n isCurrent: currentSessionId === session.id\n };\n}\n\nasync function readSessionIds(paths: ReturnType<typeof resolveGuidedPaths>): Promise<string[]> {\n const entries = await readdir(paths.sessionsDir, { withFileTypes: true });\n return entries\n .filter((entry) => entry.isFile() && entry.name.endsWith(\".recipe.json\"))\n .map((entry) => entry.name.replace(/\\.recipe\\.json$/, \"\"));\n}\n\nasync function loadSessionById(\n rootDir: string,\n sessionId: string,\n currentSession: GuidedSession | null\n): Promise<GuidedSession> {\n if (currentSession?.id === sessionId) {\n return currentSession;\n }\n\n return guidedSessionSchema.parse(await readGuidedSession(rootDir, sessionId));\n}\n\nexport async function listGuidedSessions(rootDir: string): Promise<GuidedSessionHistoryEntry[]> {\n const paths = await ensureGuidedDirectories(rootDir);\n const currentSession = await readCurrentSession(rootDir);\n const sessionIds = new Set(await readSessionIds(paths));\n\n if (currentSession) {\n sessionIds.add(currentSession.id);\n }\n\n const entries = await Promise.all(\n [...sessionIds].map(async (sessionId) => {\n const session = await loadSessionById(rootDir, sessionId, currentSession);\n const state = await readSessionStateForHistory(rootDir, session, currentSession?.id ?? null);\n return toHistoryEntry(session, state, currentSession?.id ?? null);\n })\n );\n\n return entries.sort((left, right) => {\n if (left.isCurrent !== right.isCurrent) {\n return left.isCurrent ? -1 : 1;\n }\n return right.createdAt.localeCompare(left.createdAt);\n });\n}\n\nexport async function switchGuidedSession(\n rootDir: string,\n sessionId: string\n): Promise<{ session: GuidedSession; state: GuidedSessionState }> {\n const paths = await ensureGuidedDirectories(rootDir);\n const currentSession = await readCurrentSession(rootDir);\n const session = await loadSessionById(rootDir, sessionId, currentSession);\n const state = await readSessionStateForHistory(rootDir, session, currentSession?.id ?? null);\n\n const recipePayload = `${JSON.stringify(session, null, 2)}\\n`;\n const markdownPayload = renderSessionMarkdown(session);\n\n await writeFile(paths.currentRecipePath, recipePayload);\n await writeFile(paths.currentMarkdownPath, markdownPayload);\n await writeGuidedState(rootDir, state);\n\n return {\n session,\n state\n };\n}\n","import { z } from \"zod\";\n\nexport const sessionModeSchema = z.enum([\n \"implementation\",\n \"pr_review\",\n \"codebase_walkthrough\"\n]);\nexport const stepStatusSchema = z.enum([\"pending\", \"active\", \"complete\", \"skipped\"]);\n\nexport const narrationSchema = z.object({\n short: z.string().min(1),\n detailed: z.string().min(1).optional()\n});\n\nexport const stepExplanationSchema = z.object({\n title: z.string().min(1),\n what: z.string().min(1),\n why: z.string().min(1),\n how: z.string().min(1).optional(),\n impact: z.string().min(1).optional(),\n risk: z.string().min(1).optional(),\n narration: narrationSchema.optional()\n});\n\nexport const guidedFileTargetSchema = z.object({\n path: z.string().min(1),\n exists: z.boolean().optional(),\n createIfMissing: z.boolean().optional()\n});\n\nexport const guidedRangeSchema = z.object({\n startLine: z.number().int().positive(),\n startCharacter: z.number().int().nonnegative().default(0),\n endLine: z.number().int().positive(),\n endCharacter: z.number().int().nonnegative().default(0)\n});\n\nexport const guidedLocationSchema = z.object({\n strategy: z.enum([\"create_file\", \"line\", \"range\", \"after_text\", \"before_text\"]),\n line: z.number().int().positive().optional(),\n column: z.number().int().nonnegative().optional(),\n range: guidedRangeSchema.optional(),\n anchorText: z.string().min(1).optional()\n});\n\nexport const walkthroughSubrangeRoleSchema = z.enum([\"primary\", \"action\", \"context\"]);\nexport const walkthroughLinkTypeSchema = z.enum([\n \"calls\",\n \"returns\",\n \"guards\",\n \"dispatches\",\n \"reads\",\n \"writes\",\n \"configures\",\n \"emits\"\n]);\nexport const walkthroughTouchpointTypeSchema = z.enum([\n \"entry\",\n \"guard\",\n \"read\",\n \"write\",\n \"transform\",\n \"emit\",\n \"respond\",\n \"config\"\n]);\nexport const walkthroughConfidenceSchema = z.enum([\"direct\", \"mixed\", \"inferred\"]);\nexport const walkthroughEvidenceQualitySchema = z.enum([\"high\", \"medium\", \"low\"]);\nexport const walkthroughLensSchema = z.enum([\n \"request_flow\",\n \"data_flow\",\n \"permission_flow\",\n \"error_path\",\n \"config_dependency_flow\"\n]);\nexport const walkthroughFollowUpKindSchema = z.enum([\n \"implementation\",\n \"tests\",\n \"config\",\n \"docs\",\n \"investigate\"\n]);\n\nexport const walkthroughSubrangeSchema = z.object({\n id: z.string().min(1),\n label: z.string().min(1),\n role: walkthroughSubrangeRoleSchema,\n range: guidedRangeSchema,\n summary: z.string().min(1).optional(),\n snippet: z.string().min(1).optional(),\n symbols: z.array(z.string().min(1)).min(1).optional()\n});\n\nexport const walkthroughLinkSchema = z.object({\n stepId: z.string().min(1),\n subrangeId: z.string().min(1).optional(),\n type: walkthroughLinkTypeSchema,\n why: z.string().min(1),\n viaSymbol: z.string().min(1).optional()\n});\n\nexport const walkthroughBranchSchema = z.object({\n id: z.string().min(1),\n label: z.string().min(1),\n condition: z.string().min(1),\n outcome: z.string().min(1),\n targetStepId: z.string().min(1).optional(),\n targetSubrangeId: z.string().min(1).optional()\n});\n\nexport const walkthroughFlowSchema = z.object({\n summary: z.string().min(1),\n path: z.array(z.string().min(1)).min(2),\n entrypoint: z.string().min(1).optional(),\n outcome: z.string().min(1).optional()\n});\n\nexport const walkthroughFollowUpSchema = z.object({\n id: z.string().min(1),\n kind: walkthroughFollowUpKindSchema,\n label: z.string().min(1),\n description: z.string().min(1),\n stepId: z.string().min(1).optional(),\n file: z.string().min(1).optional()\n});\n\nexport const stepValidationSchema = z.object({\n type: z.literal(\"normalised_match\"),\n expectedText: z.string().optional(),\n scope: z.enum([\"file\", \"range\"]).optional()\n});\n\nexport const reviewPlaybackSchema = z\n .object({\n beforeCode: z.string().optional(),\n afterCode: z.string().optional(),\n changedRange: guidedRangeSchema.optional()\n })\n .refine(\n (value) =>\n Boolean(value.beforeCode) || Boolean(value.afterCode) || Boolean(value.changedRange),\n {\n message: \"review playback requires beforeCode, afterCode, or changedRange\"\n }\n );\n\nconst baseStepSchema = z.object({\n id: z.string().min(1),\n order: z.number().int().positive(),\n mode: sessionModeSchema,\n file: guidedFileTargetSchema,\n location: guidedLocationSchema,\n subranges: z.array(walkthroughSubrangeSchema).min(1).optional(),\n symbols: z.array(z.string().min(1)).min(1).optional(),\n explanation: stepExplanationSchema,\n validation: stepValidationSchema.optional(),\n status: stepStatusSchema.optional()\n});\n\nexport const implementationStepSchema = baseStepSchema.extend({\n mode: z.literal(\"implementation\"),\n ghostCode: z.string().min(1)\n});\n\nexport const prReviewStepSchema = baseStepSchema.extend({\n mode: z.literal(\"pr_review\"),\n review: reviewPlaybackSchema\n});\n\nexport const codebaseWalkthroughStepSchema = baseStepSchema\n .extend({\n mode: z.literal(\"codebase_walkthrough\"),\n touchpoint: walkthroughTouchpointTypeSchema,\n confidence: walkthroughConfidenceSchema,\n evidenceQuality: walkthroughEvidenceQualitySchema,\n fileRationale: z.string().min(1),\n snippet: z.string().min(1),\n links: z.array(walkthroughLinkSchema).optional(),\n branches: z.array(walkthroughBranchSchema).optional()\n })\n .superRefine((step, context) => {\n if (step.location.strategy !== \"range\" || !step.location.range) {\n context.addIssue({\n code: z.ZodIssueCode.custom,\n path: [\"location\"],\n message: \"codebase walkthrough steps require a location range\"\n });\n }\n\n if (!step.explanation.how) {\n context.addIssue({\n code: z.ZodIssueCode.custom,\n path: [\"explanation\", \"how\"],\n message: \"codebase walkthrough steps require explanation.how\"\n });\n }\n\n if (!step.subranges?.length) {\n context.addIssue({\n code: z.ZodIssueCode.custom,\n path: [\"subranges\"],\n message: \"codebase walkthrough steps require named subranges\"\n });\n return;\n }\n\n const primarySubranges = step.subranges.filter((subrange) => subrange.role === \"primary\");\n if (primarySubranges.length !== 1) {\n context.addIssue({\n code: z.ZodIssueCode.custom,\n path: [\"subranges\"],\n message: \"codebase walkthrough steps require exactly one primary subrange\"\n });\n }\n });\n\nexport const guidedStepSchema = z.union([\n implementationStepSchema,\n prReviewStepSchema,\n codebaseWalkthroughStepSchema\n]);\n\nexport const guidedSessionSchema = z\n .object({\n id: z.string().min(1),\n mode: sessionModeSchema,\n title: z.string().min(1),\n summary: z.string().min(1),\n createdAt: z.string().min(1),\n question: z.string().min(1).optional(),\n lens: walkthroughLensSchema.optional(),\n flow: walkthroughFlowSchema.optional(),\n followUps: z.array(walkthroughFollowUpSchema).optional(),\n steps: z.array(guidedStepSchema).min(1)\n })\n .superRefine((session, context) => {\n if (session.mode === \"codebase_walkthrough\" && !session.question) {\n context.addIssue({\n code: z.ZodIssueCode.custom,\n path: [\"question\"],\n message: \"codebase walkthrough sessions require a question\"\n });\n }\n\n if (session.mode === \"codebase_walkthrough\" && !session.flow) {\n context.addIssue({\n code: z.ZodIssueCode.custom,\n path: [\"flow\"],\n message: \"codebase walkthrough sessions require a flow summary\"\n });\n }\n\n if (session.mode === \"codebase_walkthrough\" && !session.lens) {\n context.addIssue({\n code: z.ZodIssueCode.custom,\n path: [\"lens\"],\n message: \"codebase walkthrough sessions require a lens\"\n });\n }\n\n session.steps.forEach((step, index) => {\n if (step.mode !== session.mode) {\n context.addIssue({\n code: z.ZodIssueCode.custom,\n path: [\"steps\", index, \"mode\"],\n message: `step mode ${step.mode} does not match session mode ${session.mode}`\n });\n }\n });\n });\n\nexport type SessionMode = z.infer<typeof sessionModeSchema>;\nexport type StepStatus = z.infer<typeof stepStatusSchema>;\nexport type StepExplanation = z.infer<typeof stepExplanationSchema>;\nexport type GuidedFileTarget = z.infer<typeof guidedFileTargetSchema>;\nexport type GuidedRange = z.infer<typeof guidedRangeSchema>;\nexport type GuidedLocation = z.infer<typeof guidedLocationSchema>;\nexport type WalkthroughSubrangeRole = z.infer<typeof walkthroughSubrangeRoleSchema>;\nexport type WalkthroughLinkType = z.infer<typeof walkthroughLinkTypeSchema>;\nexport type WalkthroughTouchpointType = z.infer<typeof walkthroughTouchpointTypeSchema>;\nexport type WalkthroughConfidence = z.infer<typeof walkthroughConfidenceSchema>;\nexport type WalkthroughEvidenceQuality = z.infer<typeof walkthroughEvidenceQualitySchema>;\nexport type WalkthroughLens = z.infer<typeof walkthroughLensSchema>;\nexport type WalkthroughFollowUpKind = z.infer<typeof walkthroughFollowUpKindSchema>;\nexport type WalkthroughSubrange = z.infer<typeof walkthroughSubrangeSchema>;\nexport type WalkthroughLink = z.infer<typeof walkthroughLinkSchema>;\nexport type WalkthroughBranch = z.infer<typeof walkthroughBranchSchema>;\nexport type WalkthroughFlow = z.infer<typeof walkthroughFlowSchema>;\nexport type WalkthroughFollowUp = z.infer<typeof walkthroughFollowUpSchema>;\nexport type StepValidation = z.infer<typeof stepValidationSchema>;\nexport type ReviewPlayback = z.infer<typeof reviewPlaybackSchema>;\nexport type ImplementationStep = z.infer<typeof implementationStepSchema>;\nexport type PrReviewStep = z.infer<typeof prReviewStepSchema>;\nexport type CodebaseWalkthroughStep = z.infer<typeof codebaseWalkthroughStepSchema>;\nexport type GuidedStep = z.infer<typeof guidedStepSchema>;\nexport type GuidedSession = z.infer<typeof guidedSessionSchema>;\n","import type { GuidedLocation, GuidedStep, StepValidation } from \"@duckwalk/schema\";\n\nexport function normaliseCode(input: string): string {\n return input\n .replace(/\\r\\n/g, \"\\n\")\n .split(\"\\n\")\n .map((line) => line.replace(/[ \\t]+$/g, \"\"))\n .join(\"\\n\")\n .trim();\n}\n\nfunction getLineSlice(content: string, startLine: number, endLine: number): string {\n const lines = content.replace(/\\r\\n/g, \"\\n\").split(\"\\n\");\n return lines.slice(startLine - 1, endLine).join(\"\\n\");\n}\n\nexport function getValidationText(step: GuidedStep): string {\n if (step.validation?.expectedText) {\n return step.validation.expectedText;\n }\n\n if (step.mode === \"implementation\") {\n return step.ghostCode;\n }\n\n if (step.mode === \"pr_review\") {\n return step.review.afterCode ?? step.review.beforeCode ?? \"\";\n }\n\n return step.snippet;\n}\n\nexport function extractValidationWindow(\n content: string,\n location: GuidedLocation,\n validation?: StepValidation\n): string {\n if (validation?.scope !== \"range\") {\n return content;\n }\n\n if (location.strategy === \"range\" && location.range) {\n return getLineSlice(content, location.range.startLine, location.range.endLine);\n }\n\n if (location.strategy === \"line\" && location.line) {\n const expectedLines = validation.expectedText\n ? normaliseCode(validation.expectedText).split(\"\\n\").length\n : 1;\n return getLineSlice(content, location.line, location.line + expectedLines - 1);\n }\n\n return content;\n}\n\nexport function validateExpectedCode(actual: string, expected: string): boolean {\n if (!expected.trim()) {\n return false;\n }\n\n return normaliseCode(actual).includes(normaliseCode(expected));\n}\n\nexport function validateStepAgainstContent(step: GuidedStep, content: string): boolean {\n const expectedText = getValidationText(step);\n const validationWindow = extractValidationWindow(content, step.location, step.validation);\n return validateExpectedCode(validationWindow, expectedText);\n}\n","import {\n guidedSessionStateSchema,\n readGuidedSession,\n readGuidedState,\n updateGuidedStepStatus,\n validateSessionIntegrity,\n writeRecipeFiles\n} from \"@duckwalk/core\";\nimport {\n sessionModeSchema,\n guidedSessionSchema,\n stepStatusSchema,\n type GuidedSession,\n type SessionMode,\n type StepStatus\n} from \"@duckwalk/schema\";\nimport { z } from \"zod\";\n\nimport { getDuckWalkContract } from \"./contract\";\nimport {\n validateCodebaseWalkthroughSession,\n validateCodebaseWalkthroughWorkspace,\n validatePrReviewStepRanges\n} from \"./walkthrough-validation\";\n\nconst updateStepStatusInputSchema = z.object({\n sessionId: z.string().min(1),\n stepId: z.string().min(1),\n status: stepStatusSchema\n});\n\nconst validateGuidedSessionInputSchema = z.object({\n session: guidedSessionSchema,\n expectMode: sessionModeSchema.optional()\n});\n\nexport type CreateGuidedSessionResult = {\n sessionId: string;\n recipePath: string;\n markdownPath: string;\n statePath: string;\n};\n\nexport { getDuckWalkContract };\n\nexport function validateGuidedSessionInput(input: {\n session: GuidedSession;\n expectMode?: SessionMode;\n}) {\n const payload = validateGuidedSessionInputSchema.parse(input);\n const session = guidedSessionSchema.parse(payload.session);\n\n if (payload.expectMode && session.mode !== payload.expectMode) {\n throw new Error(`Expected session mode \"${payload.expectMode}\" but received \"${session.mode}\"`);\n }\n\n validateSessionIntegrity(session);\n if (session.mode === \"pr_review\") {\n validatePrReviewStepRanges(session);\n }\n if (session.mode === \"codebase_walkthrough\") {\n validateCodebaseWalkthroughSession(session);\n }\n\n return {\n valid: true,\n session: {\n id: session.id,\n mode: session.mode,\n title: session.title,\n summary: session.summary,\n stepCount: session.steps.length,\n files: session.steps.map((step) => step.file.path),\n locationStrategies: [...new Set(session.steps.map((step) => step.location.strategy))]\n }\n };\n}\nasync function isCurrentSession(rootDir: string, sessionId: string): Promise<boolean> {\n try {\n const currentSession = await readGuidedSession(rootDir);\n return currentSession.id === sessionId;\n } catch {\n return false;\n }\n}\n\nexport async function createGuidedSession(\n rootDir: string,\n sessionInput: GuidedSession\n): Promise<CreateGuidedSessionResult> {\n const session = guidedSessionSchema.parse(sessionInput);\n validateSessionIntegrity(session);\n const files = await writeRecipeFiles(rootDir, session);\n\n return {\n sessionId: session.id,\n recipePath: files.recipePath,\n markdownPath: files.markdownPath,\n statePath: files.statePath\n };\n}\n\nexport async function createPrReviewSession(\n rootDir: string,\n sessionInput: GuidedSession\n): Promise<CreateGuidedSessionResult> {\n const session = guidedSessionSchema.parse(sessionInput);\n\n if (session.mode !== \"pr_review\") {\n throw new Error('create_pr_review_session requires mode \"pr_review\"');\n }\n\n validateSessionIntegrity(session);\n validatePrReviewStepRanges(session);\n const files = await writeRecipeFiles(rootDir, session);\n\n return {\n sessionId: session.id,\n recipePath: files.recipePath,\n markdownPath: files.markdownPath,\n statePath: files.statePath\n };\n}\n\nexport async function pathfinder(\n rootDir: string,\n sessionInput: GuidedSession\n): Promise<CreateGuidedSessionResult> {\n const session = guidedSessionSchema.parse(sessionInput);\n\n if (session.mode !== \"codebase_walkthrough\") {\n throw new Error('pathfinder requires mode \"codebase_walkthrough\"');\n }\n\n validateSessionIntegrity(session);\n const walkthroughSteps = validateCodebaseWalkthroughSession(session);\n await validateCodebaseWalkthroughWorkspace(rootDir, walkthroughSteps);\n const files = await writeRecipeFiles(rootDir, session);\n\n return {\n sessionId: session.id,\n recipePath: files.recipePath,\n markdownPath: files.markdownPath,\n statePath: files.statePath\n };\n}\n\nexport async function getGuidedSession(rootDir: string, sessionId?: string) {\n const session = guidedSessionSchema.parse(await readGuidedSession(rootDir, sessionId));\n let state = await readGuidedState(rootDir, sessionId);\n\n if (!state && sessionId && (await isCurrentSession(rootDir, sessionId))) {\n state = await readGuidedState(rootDir);\n }\n\n return {\n session,\n state: state ? guidedSessionStateSchema.parse(state) : null\n };\n}\n\nexport async function updateStepStatus(\n rootDir: string,\n input: { sessionId: string; stepId: string; status: StepStatus }\n) {\n const payload = updateStepStatusInputSchema.parse(input);\n const session = guidedSessionSchema.parse(await readGuidedSession(rootDir, payload.sessionId));\n\n if (session.id !== payload.sessionId) {\n throw new Error(`Session mismatch for ${payload.sessionId}`);\n }\n\n const state = await updateGuidedStepStatus(\n rootDir,\n session,\n payload.stepId,\n payload.status,\n {\n writeCurrent: await isCurrentSession(rootDir, session.id)\n }\n );\n\n return {\n sessionId: session.id,\n stepId: payload.stepId,\n status: payload.status,\n state: guidedSessionStateSchema.parse(state)\n };\n}\n","import { readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nimport { normaliseCode } from \"@duckwalk/core\";\nimport {\n codebaseWalkthroughStepSchema,\n type CodebaseWalkthroughStep,\n type GuidedRange,\n type GuidedSession,\n type GuidedStep\n} from \"@duckwalk/schema\";\n\ntype WalkthroughStepWithEvidence = CodebaseWalkthroughStep & {\n location: {\n strategy: \"range\";\n range: GuidedRange;\n };\n subranges: NonNullable<CodebaseWalkthroughStep[\"subranges\"]>;\n};\n\nexport function validatePrReviewStepRanges(session: GuidedSession) {\n for (const step of session.steps) {\n if (\n step.mode !== \"pr_review\" ||\n ((step.location.strategy !== \"range\" || !step.location.range) && !step.review.changedRange)\n ) {\n throw new Error(\n `PR review step ${step.id} requires a location range or review.changedRange`\n );\n }\n }\n}\n\nexport function validateCodebaseWalkthroughSession(\n session: GuidedSession\n): WalkthroughStepWithEvidence[] {\n const walkthroughSteps = session.steps.map(parseWalkthroughStep);\n validateWalkthroughGraph(session, walkthroughSteps);\n return walkthroughSteps;\n}\n\nexport async function validateCodebaseWalkthroughWorkspace(\n rootDir: string,\n walkthroughSteps: WalkthroughStepWithEvidence[]\n): Promise<void> {\n for (const step of walkthroughSteps) {\n await validateWalkthroughFileEvidence(rootDir, step);\n }\n}\n\nfunction parseWalkthroughStep(step: GuidedStep): WalkthroughStepWithEvidence {\n if (step.mode !== \"codebase_walkthrough\") {\n throw new Error(`Codebase walkthrough step ${step.id} requires mode codebase_walkthrough`);\n }\n if (step.location.strategy !== \"range\" || !step.location.range) {\n throw new Error(`Codebase walkthrough step ${step.id} requires a location range`);\n }\n\n const walkthroughStep = codebaseWalkthroughStepSchema.parse(step);\n const locationRange = walkthroughStep.location.range;\n if (!locationRange) {\n throw new Error(`Codebase walkthrough step ${walkthroughStep.id} requires a location range`);\n }\n if (!walkthroughStep.subranges?.length) {\n throw new Error(`Codebase walkthrough step ${walkthroughStep.id} requires named subranges`);\n }\n\n const primarySubranges = walkthroughStep.subranges.filter(\n (subrange) => subrange.role === \"primary\"\n );\n const primarySubrange = primarySubranges[0];\n if (!primarySubrange || !rangeMatches(primarySubrange.range, locationRange)) {\n throw new Error(\n `Codebase walkthrough step ${walkthroughStep.id} primary subrange must match location.range`\n );\n }\n\n const seenSubrangeIds = new Set<string>();\n const seenRanges = new Set<string>();\n for (const subrange of walkthroughStep.subranges) {\n if (seenSubrangeIds.has(subrange.id)) {\n throw new Error(\n `Codebase walkthrough step ${walkthroughStep.id} contains duplicate subrange id ${subrange.id}`\n );\n }\n seenSubrangeIds.add(subrange.id);\n\n const key = rangeKey(subrange.range);\n if (seenRanges.has(key)) {\n throw new Error(\n `Codebase walkthrough step ${walkthroughStep.id} contains duplicate subrange range ${key}`\n );\n }\n seenRanges.add(key);\n }\n\n return walkthroughStep as WalkthroughStepWithEvidence;\n}\n\nfunction rangeKey(range: GuidedRange) {\n return `${range.startLine}:${range.startCharacter}-${range.endLine}:${range.endCharacter}`;\n}\n\nfunction rangeMatches(left: GuidedRange, right: GuidedRange) {\n return (\n left.startLine === right.startLine &&\n left.startCharacter === right.startCharacter &&\n left.endLine === right.endLine &&\n left.endCharacter === right.endCharacter\n );\n}\n\nfunction getRangeEvidenceText(content: string, range: GuidedRange): string {\n const normalized = content.replace(/\\r\\n/g, \"\\n\");\n const lines = normalized.split(\"\\n\");\n return lines.slice(range.startLine - 1, range.endLine).join(\"\\n\");\n}\n\nfunction snippetsOverlap(actualRangeText: string, expectedSnippet: string): boolean {\n const normalizedActual = normaliseCode(actualRangeText);\n const expectedLines = normaliseCode(expectedSnippet)\n .split(\"\\n\")\n .map((line) => line.trim())\n .filter(Boolean);\n\n if (!expectedLines.length) {\n return false;\n }\n\n const matchingLineCount = expectedLines.filter((line) => normalizedActual.includes(line)).length;\n const requiredMatches = Math.min(expectedLines.length, 2);\n return matchingLineCount >= requiredMatches;\n}\n\nfunction validateWalkthroughLinks(steps: WalkthroughStepWithEvidence[]) {\n const stepIds = new Set(steps.map((step) => step.id));\n const subrangesByStepId = new Map(\n steps.map((step) => [step.id, new Set(step.subranges.map((subrange) => subrange.id))])\n );\n\n steps.forEach((step, index) => {\n const nextOrderedStep = steps[index + 1];\n if (nextOrderedStep && (!step.links || step.links.length === 0)) {\n throw new Error(`Codebase walkthrough step ${step.id} requires at least one outgoing link`);\n }\n\n const seenTargetIds = new Set<string>();\n for (const link of step.links ?? []) {\n if (!stepIds.has(link.stepId)) {\n throw new Error(`Codebase walkthrough step ${step.id} links to unknown step ${link.stepId}`);\n }\n if (link.subrangeId && !subrangesByStepId.get(link.stepId)?.has(link.subrangeId)) {\n throw new Error(\n `Codebase walkthrough step ${step.id} links to unknown subrange ${link.subrangeId} on ${link.stepId}`\n );\n }\n if (seenTargetIds.has(link.stepId)) {\n throw new Error(`Codebase walkthrough step ${step.id} links to ${link.stepId} more than once`);\n }\n seenTargetIds.add(link.stepId);\n }\n });\n}\n\nfunction validateWalkthroughBranches(steps: WalkthroughStepWithEvidence[]) {\n const stepIds = new Set(steps.map((step) => step.id));\n const subrangesByStepId = new Map(\n steps.map((step) => [step.id, new Set(step.subranges.map((subrange) => subrange.id))])\n );\n\n for (const step of steps) {\n const seenBranchIds = new Set<string>();\n for (const branch of step.branches ?? []) {\n if (seenBranchIds.has(branch.id)) {\n throw new Error(`Codebase walkthrough step ${step.id} contains duplicate branch id ${branch.id}`);\n }\n seenBranchIds.add(branch.id);\n\n if (branch.targetSubrangeId && !branch.targetStepId) {\n throw new Error(\n `Codebase walkthrough step ${step.id} branch ${branch.id} requires targetStepId when targetSubrangeId is present`\n );\n }\n if (branch.targetStepId && !stepIds.has(branch.targetStepId)) {\n throw new Error(\n `Codebase walkthrough step ${step.id} branch ${branch.id} points to unknown step ${branch.targetStepId}`\n );\n }\n if (\n branch.targetStepId &&\n branch.targetSubrangeId &&\n !subrangesByStepId.get(branch.targetStepId)?.has(branch.targetSubrangeId)\n ) {\n throw new Error(\n `Codebase walkthrough step ${step.id} branch ${branch.id} points to unknown subrange ${branch.targetSubrangeId} on ${branch.targetStepId}`\n );\n }\n }\n }\n}\n\nfunction validateWalkthroughFollowUps(\n session: GuidedSession,\n steps: WalkthroughStepWithEvidence[]\n) {\n const stepIds = new Set(steps.map((step) => step.id));\n\n for (const followUp of session.followUps ?? []) {\n if (followUp.stepId && !stepIds.has(followUp.stepId)) {\n throw new Error(\n `Codebase walkthrough follow-up ${followUp.id} points to unknown step ${followUp.stepId}`\n );\n }\n }\n}\n\nfunction validateWalkthroughGraph(\n session: GuidedSession,\n steps: WalkthroughStepWithEvidence[]\n) {\n validateWalkthroughLinks(steps);\n validateWalkthroughBranches(steps);\n validateWalkthroughFollowUps(session, steps);\n}\n\nasync function validateWalkthroughFileEvidence(\n rootDir: string,\n step: WalkthroughStepWithEvidence\n): Promise<void> {\n const filePath = path.join(rootDir, step.file.path);\n const fileContent = await readFile(filePath, \"utf8\");\n\n const snippetMatchesAnyRange = step.subranges.some((subrange) =>\n snippetsOverlap(getRangeEvidenceText(fileContent, subrange.range), step.snippet)\n );\n\n if (!snippetMatchesAnyRange) {\n throw new Error(\n `Codebase walkthrough step ${step.id} snippet must overlap one of its declared subranges`\n );\n }\n\n for (const subrange of step.subranges) {\n if (!subrange.snippet) {\n continue;\n }\n\n const rangeText = getRangeEvidenceText(fileContent, subrange.range);\n if (!snippetsOverlap(rangeText, subrange.snippet)) {\n throw new Error(\n `Codebase walkthrough step ${step.id} subrange ${subrange.id} snippet must overlap its range`\n );\n }\n }\n}\n"],"mappings":";AAAO,SAAS,sBAAsB;AACpC,SAAO;AAAA,IACL,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,IACA,UAAU;AAAA,MACR,SACE;AAAA,MACF,eACE;AAAA,MACF,WACE;AAAA,MACF,cACE;AAAA,MACF,0BAA0B;AAAA,QACxB;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MACA,iBAAiB;AAAA,QACf;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,Q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GAAI;AACvE,YAAQ,MAAM,gBAAgB,OAAO;AAAA,EACvC;AAEA,SAAO;AAAA,IACL;AAAA,IACA,OAAO,QAAQ,yBAAyB,MAAM,KAAK,IAAI;AAAA,EACzD;AACF;AAEA,eAAsB,iBACpB,SACA,OACA;AACA,QAAM,UAAU,4BAA4B,MAAM,KAAK;AACvD,QAAM,UAAU,oBAAoB,MAAM,MAAM,kBAAkB,SAAS,QAAQ,SAAS,CAAC;AAE7F,MAAI,QAAQ,OAAO,QAAQ,WAAW;AACpC,UAAM,IAAI,MAAM,wBAAwB,QAAQ,SAAS,EAAE;AAAA,EAC7D;AAEA,QAAM,QAAQ,MAAM;AAAA,IAClB;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR;AAAA,MACE,cAAc,MAAM,iBAAiB,SAAS,QAAQ,EAAE;AAAA,IAC1D;AAAA,EACF;AAEA,SAAO;AAAA,IACL,WAAW,QAAQ;AAAA,IACnB,QAAQ,QAAQ;AAAA,IAChB,QAAQ,QAAQ;AAAA,IAChB,OAAO,yBAAyB,MAAM,KAAK;AAAA,EAC7C;AACF;","names":["readFile","writeFile","path","path","readFile","writeFile","writeFile","z","z","readFile","path","path","readFile","z"]}
|
|
1
|
+
{"version":3,"sources":["../src/contract.ts","../../../packages/core/src/markdown-writer.ts","../../../packages/core/src/recipe-writer.ts","../../../packages/core/src/state.ts","../../../packages/core/src/session.ts","../../../packages/core/src/session-history.ts","../../../packages/schema/src/guided-session.ts","../../../packages/core/src/validation.ts","../src/service.ts","../src/walkthrough-validation.ts"],"sourcesContent":["export function getDuckWalkContract() {\n return {\n server: {\n name: \"duckwalk-mcp\",\n version: \"0.1.3\"\n },\n guidance: {\n summary:\n \"Use this contract instead of searching the duckWalk repo or the user's home directory for examples.\",\n workspaceRoot:\n \"Always pass workspaceRoot as the absolute target task workspace path when creating, reading, or updating guided sessions.\",\n gitignore:\n \"Session creation automatically adds .guided-implementation/ to the target workspace .gitignore when no equivalent ignore rule already exists.\",\n commentStyle:\n \"For functions or non-trivial logic in ghostCode, include short pragmatic comments that say what the code does. Only use an `Important:` comment when the behavior is safety-critical, stateful, or easy to misuse.\",\n pathfinderAuthoringHints: [\n \"Start at the real entrypoint for the user's question, such as middleware, controller, route, job handler, or event subscriber.\",\n \"Follow calls, hooks, guards, and data handoffs in execution order until the question is answered.\",\n \"Use one step per touchpoint, not one step per file.\",\n \"Use named subranges so the walkthrough can distinguish action ranges from supporting context.\",\n \"Fill step links explicitly so the graph and story can show why control moves to the next touchpoint.\"\n ],\n recommendedFlow: [\n \"Inspect only the current task workspace to choose file targets.\",\n \"Call get_duckwalk_contract when you need the session shape or examples.\",\n \"Call create_guided_session for implementation playback or create_pr_review_session for review playback.\",\n \"Call pathfinder for question-driven codebase walkthroughs that explain architecture flow.\",\n \"Only call get_guided_session when you explicitly need current session data.\",\n \"Only call update_step_status when the user explicitly wants step state changed from Codex.\"\n ]\n },\n tools: {\n get_duckwalk_contract: {\n description: \"Returns the duckWalk contract, rules, and example payloads.\"\n },\n create_guided_session: {\n description: \"Validate and persist an implementation guided session.\",\n input: {\n workspaceRoot: \"string, absolute path, recommended\",\n session: \"GuidedSession with mode implementation\"\n }\n },\n create_pr_review_session: {\n description: \"Validate and persist a PR review guided session.\",\n input: {\n workspaceRoot: \"string, absolute path, recommended\",\n session: \"GuidedSession with mode pr_review\"\n }\n },\n pathfinder: {\n description:\n \"Validate and persist a question-driven codebase walkthrough guided session.\",\n input: {\n workspaceRoot: \"string, absolute path, recommended\",\n session: \"GuidedSession with mode codebase_walkthrough\"\n }\n },\n get_guided_session: {\n description: \"Read the current session or a specific session by ID.\",\n input: {\n workspaceRoot: \"string, absolute path, recommended\",\n sessionId: \"optional string\"\n }\n },\n update_step_status: {\n description: \"Update one step status in the current guided session state.\",\n input: {\n workspaceRoot: \"string, absolute path, recommended\",\n sessionId: \"string\",\n stepId: \"string\",\n status: [\"pending\", \"active\", \"complete\", \"skipped\"]\n }\n }\n },\n schema: {\n sessionModes: [\"implementation\", \"pr_review\", \"codebase_walkthrough\"],\n implementationStepRequiredFields: [\n \"id\",\n \"order\",\n \"mode\",\n \"file\",\n \"location\",\n \"explanation\",\n \"ghostCode\"\n ],\n prReviewStepRequiredFields: [\n \"id\",\n \"order\",\n \"mode\",\n \"file\",\n \"location\",\n \"explanation\",\n \"review\"\n ],\n codebaseWalkthroughRequiredFields: [\n \"question\",\n \"lens\",\n \"flow\",\n \"id\",\n \"order\",\n \"mode\",\n \"touchpoint\",\n \"confidence\",\n \"evidenceQuality\",\n \"fileRationale\",\n \"file\",\n \"location\",\n \"explanation\",\n \"snippet\",\n \"subranges\"\n ],\n walkthroughFlowFields: [\"summary\", \"path\", \"entrypoint?\", \"outcome?\"],\n walkthroughSubrangeFields: [\n \"id\",\n \"label\",\n \"role\",\n \"range\",\n \"summary?\",\n \"snippet?\",\n \"symbols?\"\n ],\n walkthroughLinkFields: [\"stepId\", \"subrangeId?\", \"type\", \"why\", \"viaSymbol?\"],\n walkthroughBranchFields: [\n \"id\",\n \"label\",\n \"condition\",\n \"outcome\",\n \"targetStepId?\",\n \"targetSubrangeId?\"\n ],\n walkthroughFollowUpFields: [\"id\", \"kind\", \"label\", \"description\", \"stepId?\", \"file?\"],\n optionalStepFields: [\"links?\", \"branches?\", \"symbols?\"],\n guidedFileTargetFields: [\"path\", \"exists?\", \"createIfMissing?\"],\n locationStrategies: [\"create_file\", \"line\", \"range\", \"after_text\", \"before_text\"],\n explanationFields: [\"title\", \"what\", \"why\", \"how?\", \"impact?\", \"risk?\", \"narration?\"],\n validation: {\n default: {\n type: \"normalised_match\"\n },\n optionalFields: [\"expectedText\", \"scope\"]\n },\n prReviewRangeRule:\n \"Each pr_review step must include a usable range through location.range or review.changedRange.\",\n codebaseWalkthroughRangeRule:\n \"Each codebase_walkthrough step must include location.strategy = range and a usable location.range.\",\n codebaseWalkthroughSubrangeRules: [\n \"Each codebase_walkthrough step must include named subranges.\",\n \"Exactly one subrange must use role primary and it must match location.range.\",\n \"Additional subranges should usually use role action or context.\",\n \"Subrange IDs and ranges must be unique within the step.\",\n \"Links must point to real step IDs in the same walkthrough.\",\n \"When links or branches target subranges, the target subrange ID must exist on the target step.\"\n ]\n },\n examples: {\n create_guided_session: {\n workspaceRoot: \"/absolute/path/to/task/workspace\",\n session: {\n id: \"feature-auth-middleware\",\n mode: \"implementation\",\n title: \"Create auth middleware\",\n summary: \"Adds a reusable auth middleware and wires it into routes.\",\n createdAt: \"2026-06-18T00:00:00.000Z\",\n steps: [\n {\n id: \"step-1\",\n order: 1,\n mode: \"implementation\",\n file: {\n path: \"src/middleware/auth.ts\",\n createIfMissing: true\n },\n location: {\n strategy: \"create_file\"\n },\n explanation: {\n title: \"Create the auth middleware\",\n what: \"Adds a reusable authorization middleware.\",\n why: \"Route handlers should not repeat auth checks.\"\n },\n ghostCode:\n \"import type { FastifyReply, FastifyRequest } from 'fastify';\\n\\n// Rejects unauthenticated requests before route handlers run.\\nexport async function authMiddleware(request: FastifyRequest, reply: FastifyReply) {\\n const authHeader = request.headers.authorization;\\n\\n // Important: fail fast so protected handlers never run without auth.\\n if (!authHeader) {\\n return reply.code(401).send({ error: 'Missing authorization header' });\\n }\\n}\\n\",\n validation: {\n type: \"normalised_match\"\n }\n }\n ]\n }\n },\n create_pr_review_session: {\n workspaceRoot: \"/absolute/path/to/task/workspace\",\n session: {\n id: \"review-auth-middleware\",\n mode: \"pr_review\",\n title: \"Review auth middleware changes\",\n summary: \"Walks through the middleware and route wiring changes.\",\n createdAt: \"2026-06-18T00:00:00.000Z\",\n steps: [\n {\n id: \"review-step-1\",\n order: 1,\n mode: \"pr_review\",\n file: {\n path: \"src/middleware/auth.ts\"\n },\n location: {\n strategy: \"range\",\n range: {\n startLine: 1,\n startCharacter: 0,\n endLine: 12,\n endCharacter: 0\n }\n },\n explanation: {\n title: \"Review the middleware implementation\",\n what: \"Adds a reusable auth check.\",\n why: \"Routes should fail fast before business logic.\",\n impact: \"Protected handlers now reject missing authorization headers.\"\n },\n review: {\n beforeCode: \"\",\n afterCode: \"export async function authMiddleware() {}\\n\",\n changedRange: {\n startLine: 1,\n startCharacter: 0,\n endLine: 12,\n endCharacter: 0\n }\n }\n }\n ]\n }\n },\n pathfinder: {\n workspaceRoot: \"/absolute/path/to/task/workspace\",\n session: {\n id: \"walkthrough-authentication-flow\",\n mode: \"codebase_walkthrough\",\n title: \"Trace backend authentication flow\",\n summary: \"Shows how a protected request moves from middleware into token validation.\",\n question: \"How does authentication work in this backend project?\",\n lens: \"permission_flow\",\n flow: {\n summary: \"Request -> auth middleware -> auth service -> route guard\",\n path: [\"Request\", \"authMiddleware\", \"resolveAuthenticatedUser\", \"requireRole\"],\n entrypoint: \"HTTP request to a protected route\",\n outcome: \"Only authenticated requests with the right role reach the handler.\"\n },\n followUps: [\n {\n id: \"follow-up-tests\",\n kind: \"tests\",\n label: \"Inspect auth tests\",\n description: \"Open the middleware tests to confirm the success path and failure branches.\",\n file: \"tests/auth/middleware.test.ts\"\n }\n ],\n createdAt: \"2026-06-18T00:00:00.000Z\",\n steps: [\n {\n id: \"walkthrough-step-1\",\n order: 1,\n mode: \"codebase_walkthrough\",\n touchpoint: \"entry\",\n confidence: \"direct\",\n evidenceQuality: \"high\",\n fileRationale:\n \"This file is the first protected-route touchpoint where authentication begins.\",\n file: {\n path: \"src/auth/middleware.ts\"\n },\n location: {\n strategy: \"range\",\n range: {\n startLine: 1,\n startCharacter: 0,\n endLine: 12,\n endCharacter: 0\n }\n },\n subranges: [\n {\n id: \"middleware-entry\",\n label: \"Middleware entry\",\n role: \"primary\",\n range: {\n startLine: 1,\n startCharacter: 0,\n endLine: 12,\n endCharacter: 0\n },\n summary: \"Reads the Authorization header and extracts the bearer token.\",\n symbols: [\"authMiddleware\"]\n },\n {\n id: \"downstream-policy-context\",\n label: \"Downstream policy context\",\n role: \"context\",\n range: {\n startLine: 130,\n startCharacter: 0,\n endLine: 190,\n endCharacter: 0\n },\n summary: \"Later role checks depend on the authenticated user injected here.\",\n symbols: [\"requireRole\"]\n }\n ],\n symbols: [\"authMiddleware\", \"resolveAuthenticatedUser\", \"requireRole\"],\n explanation: {\n title: \"Start at the auth middleware\",\n what: \"This middleware extracts the bearer token from the request.\",\n why: \"Every protected route enters the authentication flow here.\",\n how: \"The request header is parsed and the token is passed to the downstream auth service.\",\n impact: \"Requests without a token fail before route handlers run.\"\n },\n snippet:\n \"export async function authMiddleware(request, reply) {\\n const authHeader = request.headers.authorization;\\n const token = authHeader?.replace('Bearer ', '');\\n}\\n\",\n links: [\n {\n stepId: \"walkthrough-step-2\",\n subrangeId: \"token-validate\",\n type: \"calls\",\n why: \"The extracted token is validated by the auth service before the request can continue.\",\n viaSymbol: \"resolveAuthenticatedUser\"\n }\n ],\n branches: [\n {\n id: \"missing-token\",\n label: \"Missing token\",\n condition: \"The Authorization header is missing or malformed.\",\n outcome: \"The request fails before the route handler runs.\"\n },\n {\n id: \"success-path\",\n label: \"Success path\",\n condition: \"A bearer token is present.\",\n outcome: \"The request continues into the token validation step.\",\n targetStepId: \"walkthrough-step-2\",\n targetSubrangeId: \"token-validate\"\n }\n ]\n },\n {\n id: \"walkthrough-step-2\",\n order: 2,\n mode: \"codebase_walkthrough\",\n touchpoint: \"transform\",\n confidence: \"direct\",\n evidenceQuality: \"high\",\n fileRationale:\n \"This file turns the raw token into a trusted identity object for downstream guards.\",\n file: {\n path: \"src/auth/service.ts\"\n },\n location: {\n strategy: \"range\",\n range: {\n startLine: 10,\n startCharacter: 0,\n endLine: 24,\n endCharacter: 0\n }\n },\n subranges: [\n {\n id: \"token-validate\",\n label: \"Token validation\",\n role: \"primary\",\n range: {\n startLine: 10,\n startCharacter: 0,\n endLine: 24,\n endCharacter: 0\n },\n summary: \"Verifies the token and resolves the authenticated user.\",\n symbols: [\"resolveAuthenticatedUser\", \"verifyToken\"]\n }\n ],\n symbols: [\"resolveAuthenticatedUser\", \"verifyToken\"],\n explanation: {\n title: \"Validate the token and resolve the user\",\n what: \"The auth service verifies the token and builds the authenticated user context.\",\n why: \"Downstream guards can only make authorization decisions from a trusted identity.\",\n how: \"The token verifier decodes claims and returns a resolved actor for later guards.\"\n },\n snippet:\n \"export async function resolveAuthenticatedUser(token) {\\n const payload = await verifyToken(token);\\n return { userId: payload.sub, roles: payload.roles };\\n}\\n\"\n }\n ]\n }\n }\n }\n };\n}\n","import type { GuidedSession } from \"@duckwalk/schema\";\n\nfunction formatStepLocation(step: GuidedSession[\"steps\"][number]): string | null {\n const labels: string[] = [];\n\n if (step.mode === \"pr_review\" && step.review.changedRange) {\n labels.push(\n `${step.review.changedRange.startLine}:${step.review.changedRange.startCharacter} - ${step.review.changedRange.endLine}:${step.review.changedRange.endCharacter}`\n );\n } else if (step.location.strategy === \"range\" && step.location.range) {\n labels.push(\n `${step.location.range.startLine}:${step.location.range.startCharacter} - ${step.location.range.endLine}:${step.location.range.endCharacter}`\n );\n } else if (step.location.strategy === \"line\" && step.location.line) {\n labels.push(`${step.location.line}:${step.location.column ?? 0}`);\n } else if (\n (step.location.strategy === \"after_text\" || step.location.strategy === \"before_text\") &&\n step.location.anchorText\n ) {\n labels.push(step.location.anchorText);\n }\n\n for (const subrange of step.subranges ?? []) {\n labels.push(\n `${subrange.label} (${subrange.role}): ${subrange.range.startLine}:${subrange.range.startCharacter} - ${subrange.range.endLine}:${subrange.range.endCharacter}`\n );\n }\n\n return labels.length > 0 ? labels.join(\"; \") : null;\n}\n\nexport function renderSessionMarkdown(session: GuidedSession): string {\n const lines: string[] = [\n `# ${session.title}`,\n \"\",\n `- Session ID: \\`${session.id}\\``,\n `- Mode: \\`${session.mode}\\``,\n `- Created At: \\`${session.createdAt}\\``,\n \"\",\n session.summary\n ];\n\n if (session.mode === \"codebase_walkthrough\" && session.question) {\n lines.push(\"\", `Question: ${session.question}`);\n }\n if (session.mode === \"codebase_walkthrough\" && session.lens) {\n lines.push(`Lens: ${session.lens}`);\n }\n\n if (session.mode === \"codebase_walkthrough\" && session.flow) {\n lines.push(\"\", \"## Flow Summary\", \"\");\n lines.push(`- Summary: ${session.flow.summary}`);\n lines.push(`- Path: ${session.flow.path.join(\" -> \")}`);\n if (session.flow.entrypoint) {\n lines.push(`- Entrypoint: ${session.flow.entrypoint}`);\n }\n if (session.flow.outcome) {\n lines.push(`- Outcome: ${session.flow.outcome}`);\n }\n }\n\n lines.push(\"\");\n\n for (const step of [...session.steps].sort((left, right) => left.order - right.order)) {\n lines.push(`## Step ${step.order}: ${step.explanation.title}`, \"\");\n lines.push(`- File: \\`${step.file.path}\\``);\n lines.push(`- Location strategy: \\`${step.location.strategy}\\``);\n const locationDetail = formatStepLocation(step);\n if (locationDetail) {\n lines.push(`- Where: ${locationDetail}`);\n }\n if (step.mode === \"codebase_walkthrough\") {\n lines.push(`- Touchpoint: ${step.touchpoint}`);\n lines.push(`- Confidence: ${step.confidence}`);\n lines.push(`- Evidence quality: ${step.evidenceQuality}`);\n lines.push(`- File rationale: ${step.fileRationale}`);\n }\n lines.push(`- What: ${step.explanation.what}`);\n lines.push(`- Why: ${step.explanation.why}`);\n if (step.explanation.how) {\n lines.push(`- How: ${step.explanation.how}`);\n }\n if (step.explanation.impact) {\n lines.push(`- Impact: ${step.explanation.impact}`);\n }\n if (step.explanation.risk) {\n lines.push(`- Risk: ${step.explanation.risk}`);\n }\n if (step.symbols?.length) {\n lines.push(`- Symbols: ${step.symbols.join(\", \")}`);\n }\n lines.push(\"\");\n\n if (step.mode === \"implementation\") {\n lines.push(\"```ts\", step.ghostCode, \"```\", \"\");\n } else if (step.mode === \"pr_review\") {\n if (step.review.beforeCode) {\n lines.push(\"### Before\", \"\", \"```ts\", step.review.beforeCode, \"```\", \"\");\n }\n if (step.review.afterCode) {\n lines.push(\"### After\", \"\", \"```ts\", step.review.afterCode, \"```\", \"\");\n }\n } else {\n lines.push(\"### Snippet\", \"\", \"```ts\", step.snippet, \"```\", \"\");\n if (step.subranges?.length) {\n lines.push(\"### Evidence\", \"\");\n\n for (const subrange of step.subranges) {\n lines.push(\n `- ${subrange.label} [${subrange.role}] ${subrange.range.startLine}:${subrange.range.startCharacter} - ${subrange.range.endLine}:${subrange.range.endCharacter}`\n );\n if (subrange.summary) {\n lines.push(` Summary: ${subrange.summary}`);\n }\n if (subrange.symbols?.length) {\n lines.push(` Symbols: ${subrange.symbols.join(\", \")}`);\n }\n if (subrange.snippet) {\n lines.push(\"\", \"```ts\", subrange.snippet, \"```\");\n }\n }\n\n lines.push(\"\");\n }\n\n if (step.links?.length) {\n lines.push(\"### Links\", \"\");\n for (const link of step.links) {\n const via = link.viaSymbol ? ` via ${link.viaSymbol}` : \"\";\n const target = link.subrangeId ? `${link.stepId}#${link.subrangeId}` : link.stepId;\n lines.push(`- ${link.type} -> ${target}${via}: ${link.why}`);\n }\n lines.push(\"\");\n }\n\n if (step.branches?.length) {\n lines.push(\"### Branches\", \"\");\n for (const branch of step.branches) {\n const target = branch.targetStepId\n ? ` -> ${branch.targetStepId}${branch.targetSubrangeId ? `#${branch.targetSubrangeId}` : \"\"}`\n : \"\";\n lines.push(`- ${branch.label}${target}`);\n lines.push(` Condition: ${branch.condition}`);\n lines.push(` Outcome: ${branch.outcome}`);\n }\n lines.push(\"\");\n }\n }\n }\n\n if (session.mode === \"codebase_walkthrough\" && session.followUps?.length) {\n lines.push(\"## Follow-ups\", \"\");\n for (const followUp of session.followUps) {\n const target = followUp.stepId\n ? `step ${followUp.stepId}`\n : followUp.file\n ? `file ${followUp.file}`\n : \"general\";\n lines.push(`- ${followUp.label} [${followUp.kind}] (${target})`);\n lines.push(` ${followUp.description}`);\n }\n }\n\n return `${lines.join(\"\\n\").trim()}\\n`;\n}\n","import { readFile, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nimport type { GuidedSession } from \"@duckwalk/schema\";\n\nimport { renderSessionMarkdown } from \"./markdown-writer\";\nimport { createInitialSessionState, ensureGuidedDirectories, writeGuidedState } from \"./state\";\n\nconst guidedImplementationIgnoreRule = \".guided-implementation/\";\n\nasync function ensureGuidedImplementationGitignore(rootDir: string) {\n const gitignorePath = path.join(rootDir, \".gitignore\");\n let existing = \"\";\n\n try {\n existing = await readFile(gitignorePath, \"utf8\");\n } catch {\n existing = \"\";\n }\n\n const hasRule = existing\n .split(/\\r?\\n/)\n .map((line) => line.trim())\n .some(\n (line) =>\n line === guidedImplementationIgnoreRule ||\n line === \".guided-implementation\" ||\n line === \".guided-implementation/*\"\n );\n\n if (hasRule) {\n return;\n }\n\n const prefix = existing.length > 0 && !existing.endsWith(\"\\n\") ? \"\\n\" : \"\";\n await writeFile(gitignorePath, `${existing}${prefix}${guidedImplementationIgnoreRule}\\n`);\n}\n\nexport async function writeRecipeFiles(rootDir: string, session: GuidedSession) {\n const paths = await ensureGuidedDirectories(rootDir);\n const recipePayload = `${JSON.stringify(session, null, 2)}\\n`;\n const markdownPayload = renderSessionMarkdown(session);\n const sessionRecipePath = path.join(paths.sessionsDir, `${session.id}.recipe.json`);\n const sessionMarkdownPath = path.join(paths.sessionsDir, `${session.id}.recipe.md`);\n\n await ensureGuidedImplementationGitignore(rootDir);\n await writeFile(paths.currentRecipePath, recipePayload);\n await writeFile(paths.currentMarkdownPath, markdownPayload);\n await writeFile(sessionRecipePath, recipePayload);\n await writeFile(sessionMarkdownPath, markdownPayload);\n await writeGuidedState(rootDir, createInitialSessionState(session));\n\n return {\n recipePath: paths.currentRecipePath,\n markdownPath: paths.currentMarkdownPath,\n statePath: paths.statePath,\n sessionRecipePath,\n sessionMarkdownPath\n };\n}\n\nexport async function readGuidedSession(rootDir: string, sessionId?: string): Promise<GuidedSession> {\n const paths = await ensureGuidedDirectories(rootDir);\n const recipePath = sessionId\n ? path.join(paths.sessionsDir, `${sessionId}.recipe.json`)\n : paths.currentRecipePath;\n const raw = await readFile(recipePath, \"utf8\");\n return JSON.parse(raw) as GuidedSession;\n}\n","import { mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nimport type { GuidedSession, StepStatus } from \"@duckwalk/schema\";\nimport { z } from \"zod\";\n\nexport const guidedPaths = {\n directoryName: \".guided-implementation\",\n currentRecipeName: \"current.recipe.json\",\n currentMarkdownName: \"current.recipe.md\",\n stateName: \"state.json\",\n sessionsDirectoryName: \"sessions\"\n} as const;\n\nconst stepStateSchema = z.object({\n status: z.enum([\"pending\", \"active\", \"complete\", \"skipped\"]),\n completedAt: z.string().optional()\n});\n\nexport const guidedSessionStateSchema = z.object({\n sessionId: z.string().min(1),\n activeStepId: z.string().min(1).nullable(),\n activeStepOrder: z.number().int().positive().nullable(),\n updatedAt: z.string().min(1),\n steps: z.record(stepStateSchema)\n});\n\nexport type GuidedSessionState = z.infer<typeof guidedSessionStateSchema>;\n\nexport function resolveGuidedPaths(rootDir: string) {\n const baseDir = path.join(rootDir, guidedPaths.directoryName);\n return {\n baseDir,\n currentRecipePath: path.join(baseDir, guidedPaths.currentRecipeName),\n currentMarkdownPath: path.join(baseDir, guidedPaths.currentMarkdownName),\n statePath: path.join(baseDir, guidedPaths.stateName),\n sessionsDir: path.join(baseDir, guidedPaths.sessionsDirectoryName)\n };\n}\n\nfunction getSessionStatePath(paths: ReturnType<typeof resolveGuidedPaths>, sessionId: string) {\n return path.join(paths.sessionsDir, `${sessionId}.state.json`);\n}\n\nexport function createInitialSessionState(session: GuidedSession): GuidedSessionState {\n const orderedSteps = [...session.steps].sort((left, right) => left.order - right.order);\n const firstStep = orderedSteps[0] ?? null;\n const steps: GuidedSessionState[\"steps\"] = {};\n\n for (const step of orderedSteps) {\n steps[step.id] = {\n status: step.id === firstStep?.id ? \"active\" : \"pending\"\n };\n }\n\n return {\n sessionId: session.id,\n activeStepId: firstStep?.id ?? null,\n activeStepOrder: firstStep?.order ?? null,\n updatedAt: new Date().toISOString(),\n steps\n };\n}\n\nexport async function ensureGuidedDirectories(rootDir: string): Promise<ReturnType<typeof resolveGuidedPaths>> {\n const paths = resolveGuidedPaths(rootDir);\n await mkdir(paths.baseDir, { recursive: true });\n await mkdir(paths.sessionsDir, { recursive: true });\n return paths;\n}\n\nexport async function readGuidedState(\n rootDir: string,\n sessionId?: string\n): Promise<GuidedSessionState | null> {\n const paths = resolveGuidedPaths(rootDir);\n const statePath = sessionId ? getSessionStatePath(paths, sessionId) : paths.statePath;\n try {\n const raw = await readFile(statePath, \"utf8\");\n return guidedSessionStateSchema.parse(JSON.parse(raw));\n } catch {\n return null;\n }\n}\n\nexport async function writeGuidedState(\n rootDir: string,\n state: GuidedSessionState,\n options: { writeCurrent?: boolean } = {}\n): Promise<string> {\n const paths = await ensureGuidedDirectories(rootDir);\n const nextState = {\n ...state,\n updatedAt: new Date().toISOString()\n };\n const payload = JSON.stringify(nextState, null, 2);\n const sessionStatePath = getSessionStatePath(paths, nextState.sessionId);\n\n await writeFile(sessionStatePath, payload);\n if (options.writeCurrent ?? true) {\n await writeFile(paths.statePath, payload);\n return paths.statePath;\n }\n\n return sessionStatePath;\n}\n\nexport async function setActiveStep(\n rootDir: string,\n session: GuidedSession,\n stepId: string\n): Promise<GuidedSessionState> {\n const existing = (await readGuidedState(rootDir, session.id)) ?? createInitialSessionState(session);\n const step = session.steps.find((candidate) => candidate.id === stepId);\n\n if (!step) {\n throw new Error(`Unknown step ID: ${stepId}`);\n }\n\n const nextSteps = { ...existing.steps };\n const previousActiveStepId = existing.activeStepId;\n if (previousActiveStepId && nextSteps[previousActiveStepId]?.status === \"active\") {\n nextSteps[previousActiveStepId] = { status: \"pending\" };\n }\n\n if (nextSteps[stepId]?.status !== \"complete\") {\n nextSteps[stepId] = { status: \"active\" };\n }\n\n const nextState: GuidedSessionState = {\n ...existing,\n sessionId: session.id,\n activeStepId: stepId,\n activeStepOrder: step.order,\n steps: nextSteps,\n updatedAt: new Date().toISOString()\n };\n\n await writeGuidedState(rootDir, nextState);\n return nextState;\n}\n\nexport async function updateGuidedStepStatus(\n rootDir: string,\n session: GuidedSession,\n stepId: string,\n status: StepStatus,\n options: { writeCurrent?: boolean } = {}\n): Promise<GuidedSessionState> {\n const existing = (await readGuidedState(rootDir, session.id)) ?? createInitialSessionState(session);\n const orderedSteps = [...session.steps].sort((left, right) => left.order - right.order);\n const currentIndex = orderedSteps.findIndex((step) => step.id === stepId);\n\n if (currentIndex === -1) {\n throw new Error(`Unknown step ID: ${stepId}`);\n }\n\n const nextSteps = {\n ...existing.steps,\n [stepId]: {\n status,\n completedAt: status === \"complete\" ? new Date().toISOString() : undefined\n }\n };\n\n let activeStepId = existing.activeStepId;\n let activeStepOrder = existing.activeStepOrder;\n\n if (status === \"complete\") {\n const nextStep = orderedSteps[currentIndex + 1];\n if (nextStep) {\n if (nextSteps[nextStep.id]?.status !== \"complete\") {\n nextSteps[nextStep.id] = { status: \"active\" };\n }\n activeStepId = nextStep.id;\n activeStepOrder = nextStep.order;\n } else {\n activeStepId = null;\n activeStepOrder = null;\n }\n }\n\n const nextState: GuidedSessionState = {\n sessionId: session.id,\n activeStepId,\n activeStepOrder,\n updatedAt: new Date().toISOString(),\n steps: nextSteps\n };\n\n await writeGuidedState(rootDir, nextState, options);\n return nextState;\n}\n\nexport async function undoGuidedStepCompletion(\n rootDir: string,\n session: GuidedSession,\n stepId: string,\n options: { writeCurrent?: boolean } = {}\n): Promise<GuidedSessionState> {\n const existing = (await readGuidedState(rootDir, session.id)) ?? createInitialSessionState(session);\n const orderedSteps = [...session.steps].sort((left, right) => left.order - right.order);\n const currentIndex = orderedSteps.findIndex((step) => step.id === stepId);\n\n if (currentIndex === -1) {\n throw new Error(`Unknown step ID: ${stepId}`);\n }\n\n const targetStep = orderedSteps[currentIndex]!;\n const nextSteps = { ...existing.steps };\n\n orderedSteps.forEach((step, index) => {\n if (index < currentIndex) {\n return;\n }\n\n if (step.id === targetStep.id) {\n nextSteps[step.id] = { status: \"active\" };\n return;\n }\n\n nextSteps[step.id] = { status: \"pending\" };\n });\n\n const nextState: GuidedSessionState = {\n sessionId: session.id,\n activeStepId: targetStep.id,\n activeStepOrder: targetStep.order,\n updatedAt: new Date().toISOString(),\n steps: nextSteps\n };\n\n await writeGuidedState(rootDir, nextState, options);\n return nextState;\n}\n\nexport async function reopenGuidedStep(\n rootDir: string,\n session: GuidedSession,\n stepId: string,\n options: { writeCurrent?: boolean } = {}\n): Promise<GuidedSessionState> {\n const existing = (await readGuidedState(rootDir, session.id)) ?? createInitialSessionState(session);\n const targetStep = session.steps.find((candidate) => candidate.id === stepId);\n\n if (!targetStep) {\n throw new Error(`Unknown step ID: ${stepId}`);\n }\n\n const nextSteps = { ...existing.steps };\n\n if (existing.activeStepId && existing.activeStepId !== stepId) {\n const currentActive = nextSteps[existing.activeStepId];\n if (currentActive?.status === \"active\") {\n nextSteps[existing.activeStepId] = { status: \"pending\" };\n }\n }\n\n nextSteps[stepId] = { status: \"active\" };\n\n const nextState: GuidedSessionState = {\n sessionId: session.id,\n activeStepId: targetStep.id,\n activeStepOrder: targetStep.order,\n updatedAt: new Date().toISOString(),\n steps: nextSteps\n };\n\n await writeGuidedState(rootDir, nextState, options);\n return nextState;\n}\n","import type { GuidedSession } from \"@duckwalk/schema\";\n\nexport function getOrderedSteps(session: GuidedSession) {\n return [...session.steps].sort((left, right) => left.order - right.order);\n}\n\nexport function validateDuplicateStepIds(session: GuidedSession) {\n const seen = new Set<string>();\n\n for (const step of session.steps) {\n if (seen.has(step.id)) {\n throw new Error(`Duplicate step ID detected: ${step.id}`);\n }\n seen.add(step.id);\n }\n}\n\nexport function validateSessionOrder(session: GuidedSession) {\n const ordered = getOrderedSteps(session);\n\n ordered.forEach((step, index) => {\n const expectedOrder = index + 1;\n if (step.order !== expectedOrder) {\n throw new Error(\n `Invalid step ordering. Expected step ${step.id} to have order ${expectedOrder}, received ${step.order}`\n );\n }\n });\n}\n\nexport function validateSessionIntegrity(session: GuidedSession) {\n validateDuplicateStepIds(session);\n validateSessionOrder(session);\n}\n","import { readdir, writeFile } from \"node:fs/promises\";\n\nimport {\n guidedSessionSchema,\n type GuidedSession,\n type SessionMode\n} from \"@duckwalk/schema\";\n\nimport { renderSessionMarkdown } from \"./markdown-writer\";\nimport { readGuidedSession } from \"./recipe-writer\";\nimport {\n createInitialSessionState,\n ensureGuidedDirectories,\n readGuidedState,\n resolveGuidedPaths,\n writeGuidedState,\n type GuidedSessionState\n} from \"./state\";\n\nexport type GuidedSessionHistoryStatus = \"pending\" | \"complete\";\n\nexport type GuidedSessionHistoryEntry = {\n id: string;\n mode: SessionMode;\n title: string;\n summary: string;\n createdAt: string;\n question?: string | undefined;\n stepCount: number;\n completedStepCount: number;\n status: GuidedSessionHistoryStatus;\n isCurrent: boolean;\n};\n\nasync function readCurrentSession(rootDir: string): Promise<GuidedSession | null> {\n try {\n return guidedSessionSchema.parse(await readGuidedSession(rootDir));\n } catch {\n return null;\n }\n}\n\nasync function readSessionStateForHistory(\n rootDir: string,\n session: GuidedSession,\n currentSessionId: string | null\n): Promise<GuidedSessionState> {\n const archivedState = await readGuidedState(rootDir, session.id);\n if (archivedState) {\n return archivedState;\n }\n\n if (currentSessionId === session.id) {\n const currentState = await readGuidedState(rootDir);\n if (currentState) {\n return currentState;\n }\n }\n\n return createInitialSessionState(session);\n}\n\nfunction toHistoryEntry(\n session: GuidedSession,\n state: GuidedSessionState,\n currentSessionId: string | null\n): GuidedSessionHistoryEntry {\n const completedStepCount = session.steps.filter(\n (step) => state.steps[step.id]?.status === \"complete\"\n ).length;\n\n return {\n id: session.id,\n mode: session.mode,\n title: session.title,\n summary: session.summary,\n createdAt: session.createdAt,\n question: session.mode === \"codebase_walkthrough\" ? session.question : undefined,\n stepCount: session.steps.length,\n completedStepCount,\n status: completedStepCount === session.steps.length ? \"complete\" : \"pending\",\n isCurrent: currentSessionId === session.id\n };\n}\n\nasync function readSessionIds(paths: ReturnType<typeof resolveGuidedPaths>): Promise<string[]> {\n const entries = await readdir(paths.sessionsDir, { withFileTypes: true });\n return entries\n .filter((entry) => entry.isFile() && entry.name.endsWith(\".recipe.json\"))\n .map((entry) => entry.name.replace(/\\.recipe\\.json$/, \"\"));\n}\n\nasync function loadSessionById(\n rootDir: string,\n sessionId: string,\n currentSession: GuidedSession | null\n): Promise<GuidedSession> {\n if (currentSession?.id === sessionId) {\n return currentSession;\n }\n\n return guidedSessionSchema.parse(await readGuidedSession(rootDir, sessionId));\n}\n\nexport async function listGuidedSessions(rootDir: string): Promise<GuidedSessionHistoryEntry[]> {\n const paths = await ensureGuidedDirectories(rootDir);\n const currentSession = await readCurrentSession(rootDir);\n const sessionIds = new Set(await readSessionIds(paths));\n\n if (currentSession) {\n sessionIds.add(currentSession.id);\n }\n\n const entries = await Promise.all(\n [...sessionIds].map(async (sessionId) => {\n const session = await loadSessionById(rootDir, sessionId, currentSession);\n const state = await readSessionStateForHistory(rootDir, session, currentSession?.id ?? null);\n return toHistoryEntry(session, state, currentSession?.id ?? null);\n })\n );\n\n return entries.sort((left, right) => {\n if (left.isCurrent !== right.isCurrent) {\n return left.isCurrent ? -1 : 1;\n }\n return right.createdAt.localeCompare(left.createdAt);\n });\n}\n\nexport async function switchGuidedSession(\n rootDir: string,\n sessionId: string\n): Promise<{ session: GuidedSession; state: GuidedSessionState }> {\n const paths = await ensureGuidedDirectories(rootDir);\n const currentSession = await readCurrentSession(rootDir);\n const session = await loadSessionById(rootDir, sessionId, currentSession);\n const state = await readSessionStateForHistory(rootDir, session, currentSession?.id ?? null);\n\n const recipePayload = `${JSON.stringify(session, null, 2)}\\n`;\n const markdownPayload = renderSessionMarkdown(session);\n\n await writeFile(paths.currentRecipePath, recipePayload);\n await writeFile(paths.currentMarkdownPath, markdownPayload);\n await writeGuidedState(rootDir, state);\n\n return {\n session,\n state\n };\n}\n","import { z } from \"zod\";\n\nexport const sessionModeSchema = z.enum([\n \"implementation\",\n \"pr_review\",\n \"codebase_walkthrough\"\n]);\nexport const stepStatusSchema = z.enum([\"pending\", \"active\", \"complete\", \"skipped\"]);\n\nexport const narrationSchema = z.object({\n short: z.string().min(1),\n detailed: z.string().min(1).optional()\n});\n\nexport const stepExplanationSchema = z.object({\n title: z.string().min(1),\n what: z.string().min(1),\n why: z.string().min(1),\n how: z.string().min(1).optional(),\n impact: z.string().min(1).optional(),\n risk: z.string().min(1).optional(),\n narration: narrationSchema.optional()\n});\n\nexport const guidedFileTargetSchema = z.object({\n path: z.string().min(1),\n exists: z.boolean().optional(),\n createIfMissing: z.boolean().optional()\n});\n\nexport const guidedRangeSchema = z.object({\n startLine: z.number().int().positive(),\n startCharacter: z.number().int().nonnegative().default(0),\n endLine: z.number().int().positive(),\n endCharacter: z.number().int().nonnegative().default(0)\n});\n\nexport const guidedLocationSchema = z.object({\n strategy: z.enum([\"create_file\", \"line\", \"range\", \"after_text\", \"before_text\"]),\n line: z.number().int().positive().optional(),\n column: z.number().int().nonnegative().optional(),\n range: guidedRangeSchema.optional(),\n anchorText: z.string().min(1).optional()\n});\n\nexport const walkthroughSubrangeRoleSchema = z.enum([\"primary\", \"action\", \"context\"]);\nexport const walkthroughLinkTypeSchema = z.enum([\n \"calls\",\n \"returns\",\n \"guards\",\n \"dispatches\",\n \"reads\",\n \"writes\",\n \"configures\",\n \"emits\"\n]);\nexport const walkthroughTouchpointTypeSchema = z.enum([\n \"entry\",\n \"guard\",\n \"read\",\n \"write\",\n \"transform\",\n \"emit\",\n \"respond\",\n \"config\"\n]);\nexport const walkthroughConfidenceSchema = z.enum([\"direct\", \"mixed\", \"inferred\"]);\nexport const walkthroughEvidenceQualitySchema = z.enum([\"high\", \"medium\", \"low\"]);\nexport const walkthroughLensSchema = z.enum([\n \"request_flow\",\n \"data_flow\",\n \"permission_flow\",\n \"error_path\",\n \"config_dependency_flow\"\n]);\nexport const walkthroughFollowUpKindSchema = z.enum([\n \"implementation\",\n \"tests\",\n \"config\",\n \"docs\",\n \"investigate\"\n]);\n\nexport const walkthroughSubrangeSchema = z.object({\n id: z.string().min(1),\n label: z.string().min(1),\n role: walkthroughSubrangeRoleSchema,\n range: guidedRangeSchema,\n summary: z.string().min(1).optional(),\n snippet: z.string().min(1).optional(),\n symbols: z.array(z.string().min(1)).min(1).optional()\n});\n\nexport const walkthroughLinkSchema = z.object({\n stepId: z.string().min(1),\n subrangeId: z.string().min(1).optional(),\n type: walkthroughLinkTypeSchema,\n why: z.string().min(1),\n viaSymbol: z.string().min(1).optional()\n});\n\nexport const walkthroughBranchSchema = z.object({\n id: z.string().min(1),\n label: z.string().min(1),\n condition: z.string().min(1),\n outcome: z.string().min(1),\n targetStepId: z.string().min(1).optional(),\n targetSubrangeId: z.string().min(1).optional()\n});\n\nexport const walkthroughFlowSchema = z.object({\n summary: z.string().min(1),\n path: z.array(z.string().min(1)).min(2),\n entrypoint: z.string().min(1).optional(),\n outcome: z.string().min(1).optional()\n});\n\nexport const walkthroughFollowUpSchema = z.object({\n id: z.string().min(1),\n kind: walkthroughFollowUpKindSchema,\n label: z.string().min(1),\n description: z.string().min(1),\n stepId: z.string().min(1).optional(),\n file: z.string().min(1).optional()\n});\n\nexport const stepValidationSchema = z.object({\n type: z.literal(\"normalised_match\"),\n expectedText: z.string().optional(),\n scope: z.enum([\"file\", \"range\"]).optional()\n});\n\nexport const reviewPlaybackSchema = z\n .object({\n beforeCode: z.string().optional(),\n afterCode: z.string().optional(),\n changedRange: guidedRangeSchema.optional()\n })\n .refine(\n (value) =>\n Boolean(value.beforeCode) || Boolean(value.afterCode) || Boolean(value.changedRange),\n {\n message: \"review playback requires beforeCode, afterCode, or changedRange\"\n }\n );\n\nconst baseStepSchema = z.object({\n id: z.string().min(1),\n order: z.number().int().positive(),\n mode: sessionModeSchema,\n file: guidedFileTargetSchema,\n location: guidedLocationSchema,\n subranges: z.array(walkthroughSubrangeSchema).min(1).optional(),\n symbols: z.array(z.string().min(1)).min(1).optional(),\n explanation: stepExplanationSchema,\n validation: stepValidationSchema.optional(),\n status: stepStatusSchema.optional()\n});\n\nexport const implementationStepSchema = baseStepSchema.extend({\n mode: z.literal(\"implementation\"),\n ghostCode: z.string().min(1)\n});\n\nexport const prReviewStepSchema = baseStepSchema.extend({\n mode: z.literal(\"pr_review\"),\n review: reviewPlaybackSchema\n});\n\nexport const codebaseWalkthroughStepSchema = baseStepSchema\n .extend({\n mode: z.literal(\"codebase_walkthrough\"),\n touchpoint: walkthroughTouchpointTypeSchema,\n confidence: walkthroughConfidenceSchema,\n evidenceQuality: walkthroughEvidenceQualitySchema,\n fileRationale: z.string().min(1),\n snippet: z.string().min(1),\n links: z.array(walkthroughLinkSchema).optional(),\n branches: z.array(walkthroughBranchSchema).optional()\n })\n .superRefine((step, context) => {\n if (step.location.strategy !== \"range\" || !step.location.range) {\n context.addIssue({\n code: z.ZodIssueCode.custom,\n path: [\"location\"],\n message: \"codebase walkthrough steps require a location range\"\n });\n }\n\n if (!step.explanation.how) {\n context.addIssue({\n code: z.ZodIssueCode.custom,\n path: [\"explanation\", \"how\"],\n message: \"codebase walkthrough steps require explanation.how\"\n });\n }\n\n if (!step.subranges?.length) {\n context.addIssue({\n code: z.ZodIssueCode.custom,\n path: [\"subranges\"],\n message: \"codebase walkthrough steps require named subranges\"\n });\n return;\n }\n\n const primarySubranges = step.subranges.filter((subrange) => subrange.role === \"primary\");\n if (primarySubranges.length !== 1) {\n context.addIssue({\n code: z.ZodIssueCode.custom,\n path: [\"subranges\"],\n message: \"codebase walkthrough steps require exactly one primary subrange\"\n });\n }\n });\n\nexport const guidedStepSchema = z.union([\n implementationStepSchema,\n prReviewStepSchema,\n codebaseWalkthroughStepSchema\n]);\n\nexport const guidedSessionSchema = z\n .object({\n id: z.string().min(1),\n mode: sessionModeSchema,\n title: z.string().min(1),\n summary: z.string().min(1),\n createdAt: z.string().min(1),\n question: z.string().min(1).optional(),\n lens: walkthroughLensSchema.optional(),\n flow: walkthroughFlowSchema.optional(),\n followUps: z.array(walkthroughFollowUpSchema).optional(),\n steps: z.array(guidedStepSchema).min(1)\n })\n .superRefine((session, context) => {\n if (session.mode === \"codebase_walkthrough\" && !session.question) {\n context.addIssue({\n code: z.ZodIssueCode.custom,\n path: [\"question\"],\n message: \"codebase walkthrough sessions require a question\"\n });\n }\n\n if (session.mode === \"codebase_walkthrough\" && !session.flow) {\n context.addIssue({\n code: z.ZodIssueCode.custom,\n path: [\"flow\"],\n message: \"codebase walkthrough sessions require a flow summary\"\n });\n }\n\n if (session.mode === \"codebase_walkthrough\" && !session.lens) {\n context.addIssue({\n code: z.ZodIssueCode.custom,\n path: [\"lens\"],\n message: \"codebase walkthrough sessions require a lens\"\n });\n }\n\n session.steps.forEach((step, index) => {\n if (step.mode !== session.mode) {\n context.addIssue({\n code: z.ZodIssueCode.custom,\n path: [\"steps\", index, \"mode\"],\n message: `step mode ${step.mode} does not match session mode ${session.mode}`\n });\n }\n });\n });\n\nexport type SessionMode = z.infer<typeof sessionModeSchema>;\nexport type StepStatus = z.infer<typeof stepStatusSchema>;\nexport type StepExplanation = z.infer<typeof stepExplanationSchema>;\nexport type GuidedFileTarget = z.infer<typeof guidedFileTargetSchema>;\nexport type GuidedRange = z.infer<typeof guidedRangeSchema>;\nexport type GuidedLocation = z.infer<typeof guidedLocationSchema>;\nexport type WalkthroughSubrangeRole = z.infer<typeof walkthroughSubrangeRoleSchema>;\nexport type WalkthroughLinkType = z.infer<typeof walkthroughLinkTypeSchema>;\nexport type WalkthroughTouchpointType = z.infer<typeof walkthroughTouchpointTypeSchema>;\nexport type WalkthroughConfidence = z.infer<typeof walkthroughConfidenceSchema>;\nexport type WalkthroughEvidenceQuality = z.infer<typeof walkthroughEvidenceQualitySchema>;\nexport type WalkthroughLens = z.infer<typeof walkthroughLensSchema>;\nexport type WalkthroughFollowUpKind = z.infer<typeof walkthroughFollowUpKindSchema>;\nexport type WalkthroughSubrange = z.infer<typeof walkthroughSubrangeSchema>;\nexport type WalkthroughLink = z.infer<typeof walkthroughLinkSchema>;\nexport type WalkthroughBranch = z.infer<typeof walkthroughBranchSchema>;\nexport type WalkthroughFlow = z.infer<typeof walkthroughFlowSchema>;\nexport type WalkthroughFollowUp = z.infer<typeof walkthroughFollowUpSchema>;\nexport type StepValidation = z.infer<typeof stepValidationSchema>;\nexport type ReviewPlayback = z.infer<typeof reviewPlaybackSchema>;\nexport type ImplementationStep = z.infer<typeof implementationStepSchema>;\nexport type PrReviewStep = z.infer<typeof prReviewStepSchema>;\nexport type CodebaseWalkthroughStep = z.infer<typeof codebaseWalkthroughStepSchema>;\nexport type GuidedStep = z.infer<typeof guidedStepSchema>;\nexport type GuidedSession = z.infer<typeof guidedSessionSchema>;\n","import type { GuidedLocation, GuidedStep, StepValidation } from \"@duckwalk/schema\";\n\nexport function normaliseCode(input: string): string {\n return input\n .replace(/\\r\\n/g, \"\\n\")\n .split(\"\\n\")\n .map((line) => line.replace(/[ \\t]+$/g, \"\"))\n .join(\"\\n\")\n .trim();\n}\n\nfunction getLineSlice(content: string, startLine: number, endLine: number): string {\n const lines = content.replace(/\\r\\n/g, \"\\n\").split(\"\\n\");\n return lines.slice(startLine - 1, endLine).join(\"\\n\");\n}\n\nexport function getValidationText(step: GuidedStep): string {\n if (step.validation?.expectedText) {\n return step.validation.expectedText;\n }\n\n if (step.mode === \"implementation\") {\n return step.ghostCode;\n }\n\n if (step.mode === \"pr_review\") {\n return step.review.afterCode ?? step.review.beforeCode ?? \"\";\n }\n\n return step.snippet;\n}\n\nexport function extractValidationWindow(\n content: string,\n location: GuidedLocation,\n validation?: StepValidation\n): string {\n if (validation?.scope !== \"range\") {\n return content;\n }\n\n if (location.strategy === \"range\" && location.range) {\n return getLineSlice(content, location.range.startLine, location.range.endLine);\n }\n\n if (location.strategy === \"line\" && location.line) {\n const expectedLines = validation.expectedText\n ? normaliseCode(validation.expectedText).split(\"\\n\").length\n : 1;\n return getLineSlice(content, location.line, location.line + expectedLines - 1);\n }\n\n return content;\n}\n\nexport function validateExpectedCode(actual: string, expected: string): boolean {\n if (!expected.trim()) {\n return false;\n }\n\n return normaliseCode(actual).includes(normaliseCode(expected));\n}\n\nexport function validateStepAgainstContent(step: GuidedStep, content: string): boolean {\n const expectedText = getValidationText(step);\n const validationWindow = extractValidationWindow(content, step.location, step.validation);\n return validateExpectedCode(validationWindow, expectedText);\n}\n","import {\n guidedSessionStateSchema,\n readGuidedSession,\n readGuidedState,\n updateGuidedStepStatus,\n validateSessionIntegrity,\n writeRecipeFiles\n} from \"@duckwalk/core\";\nimport {\n sessionModeSchema,\n guidedSessionSchema,\n stepStatusSchema,\n type GuidedSession,\n type SessionMode,\n type StepStatus\n} from \"@duckwalk/schema\";\nimport { z } from \"zod\";\n\nimport { getDuckWalkContract } from \"./contract\";\nimport {\n validateCodebaseWalkthroughSession,\n validateCodebaseWalkthroughWorkspace,\n validatePrReviewStepRanges\n} from \"./walkthrough-validation\";\n\nconst updateStepStatusInputSchema = z.object({\n sessionId: z.string().min(1),\n stepId: z.string().min(1),\n status: stepStatusSchema\n});\n\nconst validateGuidedSessionInputSchema = z.object({\n session: guidedSessionSchema,\n expectMode: sessionModeSchema.optional()\n});\n\nexport type CreateGuidedSessionResult = {\n sessionId: string;\n recipePath: string;\n markdownPath: string;\n statePath: string;\n};\n\nexport { getDuckWalkContract };\n\nexport function validateGuidedSessionInput(input: {\n session: GuidedSession;\n expectMode?: SessionMode;\n}) {\n const payload = validateGuidedSessionInputSchema.parse(input);\n const session = guidedSessionSchema.parse(payload.session);\n\n if (payload.expectMode && session.mode !== payload.expectMode) {\n throw new Error(`Expected session mode \"${payload.expectMode}\" but received \"${session.mode}\"`);\n }\n\n validateSessionIntegrity(session);\n if (session.mode === \"pr_review\") {\n validatePrReviewStepRanges(session);\n }\n if (session.mode === \"codebase_walkthrough\") {\n validateCodebaseWalkthroughSession(session);\n }\n\n return {\n valid: true,\n session: {\n id: session.id,\n mode: session.mode,\n title: session.title,\n summary: session.summary,\n stepCount: session.steps.length,\n files: session.steps.map((step) => step.file.path),\n locationStrategies: [...new Set(session.steps.map((step) => step.location.strategy))]\n }\n };\n}\nasync function isCurrentSession(rootDir: string, sessionId: string): Promise<boolean> {\n try {\n const currentSession = await readGuidedSession(rootDir);\n return currentSession.id === sessionId;\n } catch {\n return false;\n }\n}\n\nexport async function createGuidedSession(\n rootDir: string,\n sessionInput: GuidedSession\n): Promise<CreateGuidedSessionResult> {\n const session = guidedSessionSchema.parse(sessionInput);\n validateSessionIntegrity(session);\n const files = await writeRecipeFiles(rootDir, session);\n\n return {\n sessionId: session.id,\n recipePath: files.recipePath,\n markdownPath: files.markdownPath,\n statePath: files.statePath\n };\n}\n\nexport async function createPrReviewSession(\n rootDir: string,\n sessionInput: GuidedSession\n): Promise<CreateGuidedSessionResult> {\n const session = guidedSessionSchema.parse(sessionInput);\n\n if (session.mode !== \"pr_review\") {\n throw new Error('create_pr_review_session requires mode \"pr_review\"');\n }\n\n validateSessionIntegrity(session);\n validatePrReviewStepRanges(session);\n const files = await writeRecipeFiles(rootDir, session);\n\n return {\n sessionId: session.id,\n recipePath: files.recipePath,\n markdownPath: files.markdownPath,\n statePath: files.statePath\n };\n}\n\nexport async function pathfinder(\n rootDir: string,\n sessionInput: GuidedSession\n): Promise<CreateGuidedSessionResult> {\n const session = guidedSessionSchema.parse(sessionInput);\n\n if (session.mode !== \"codebase_walkthrough\") {\n throw new Error('pathfinder requires mode \"codebase_walkthrough\"');\n }\n\n validateSessionIntegrity(session);\n const walkthroughSteps = validateCodebaseWalkthroughSession(session);\n await validateCodebaseWalkthroughWorkspace(rootDir, walkthroughSteps);\n const files = await writeRecipeFiles(rootDir, session);\n\n return {\n sessionId: session.id,\n recipePath: files.recipePath,\n markdownPath: files.markdownPath,\n statePath: files.statePath\n };\n}\n\nexport async function getGuidedSession(rootDir: string, sessionId?: string) {\n const session = guidedSessionSchema.parse(await readGuidedSession(rootDir, sessionId));\n let state = await readGuidedState(rootDir, sessionId);\n\n if (!state && sessionId && (await isCurrentSession(rootDir, sessionId))) {\n state = await readGuidedState(rootDir);\n }\n\n return {\n session,\n state: state ? guidedSessionStateSchema.parse(state) : null\n };\n}\n\nexport async function updateStepStatus(\n rootDir: string,\n input: { sessionId: string; stepId: string; status: StepStatus }\n) {\n const payload = updateStepStatusInputSchema.parse(input);\n const session = guidedSessionSchema.parse(await readGuidedSession(rootDir, payload.sessionId));\n\n if (session.id !== payload.sessionId) {\n throw new Error(`Session mismatch for ${payload.sessionId}`);\n }\n\n const state = await updateGuidedStepStatus(\n rootDir,\n session,\n payload.stepId,\n payload.status,\n {\n writeCurrent: await isCurrentSession(rootDir, session.id)\n }\n );\n\n return {\n sessionId: session.id,\n stepId: payload.stepId,\n status: payload.status,\n state: guidedSessionStateSchema.parse(state)\n };\n}\n","import { readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nimport { normaliseCode } from \"@duckwalk/core\";\nimport {\n codebaseWalkthroughStepSchema,\n type CodebaseWalkthroughStep,\n type GuidedRange,\n type GuidedSession,\n type GuidedStep\n} from \"@duckwalk/schema\";\n\ntype WalkthroughStepWithEvidence = CodebaseWalkthroughStep & {\n location: {\n strategy: \"range\";\n range: GuidedRange;\n };\n subranges: NonNullable<CodebaseWalkthroughStep[\"subranges\"]>;\n};\n\nexport function validatePrReviewStepRanges(session: GuidedSession) {\n for (const step of session.steps) {\n if (\n step.mode !== \"pr_review\" ||\n ((step.location.strategy !== \"range\" || !step.location.range) && !step.review.changedRange)\n ) {\n throw new Error(\n `PR review step ${step.id} requires a location range or review.changedRange`\n );\n }\n }\n}\n\nexport function validateCodebaseWalkthroughSession(\n session: GuidedSession\n): WalkthroughStepWithEvidence[] {\n const walkthroughSteps = session.steps.map(parseWalkthroughStep);\n validateWalkthroughGraph(session, walkthroughSteps);\n return walkthroughSteps;\n}\n\nexport async function validateCodebaseWalkthroughWorkspace(\n rootDir: string,\n walkthroughSteps: WalkthroughStepWithEvidence[]\n): Promise<void> {\n for (const step of walkthroughSteps) {\n await validateWalkthroughFileEvidence(rootDir, step);\n }\n}\n\nfunction parseWalkthroughStep(step: GuidedStep): WalkthroughStepWithEvidence {\n if (step.mode !== \"codebase_walkthrough\") {\n throw new Error(`Codebase walkthrough step ${step.id} requires mode codebase_walkthrough`);\n }\n if (step.location.strategy !== \"range\" || !step.location.range) {\n throw new Error(`Codebase walkthrough step ${step.id} requires a location range`);\n }\n\n const walkthroughStep = codebaseWalkthroughStepSchema.parse(step);\n const locationRange = walkthroughStep.location.range;\n if (!locationRange) {\n throw new Error(`Codebase walkthrough step ${walkthroughStep.id} requires a location range`);\n }\n if (!walkthroughStep.subranges?.length) {\n throw new Error(`Codebase walkthrough step ${walkthroughStep.id} requires named subranges`);\n }\n\n const primarySubranges = walkthroughStep.subranges.filter(\n (subrange) => subrange.role === \"primary\"\n );\n const primarySubrange = primarySubranges[0];\n if (!primarySubrange || !rangeMatches(primarySubrange.range, locationRange)) {\n throw new Error(\n `Codebase walkthrough step ${walkthroughStep.id} primary subrange must match location.range`\n );\n }\n\n const seenSubrangeIds = new Set<string>();\n const seenRanges = new Set<string>();\n for (const subrange of walkthroughStep.subranges) {\n if (seenSubrangeIds.has(subrange.id)) {\n throw new Error(\n `Codebase walkthrough step ${walkthroughStep.id} contains duplicate subrange id ${subrange.id}`\n );\n }\n seenSubrangeIds.add(subrange.id);\n\n const key = rangeKey(subrange.range);\n if (seenRanges.has(key)) {\n throw new Error(\n `Codebase walkthrough step ${walkthroughStep.id} contains duplicate subrange range ${key}`\n );\n }\n seenRanges.add(key);\n }\n\n return walkthroughStep as WalkthroughStepWithEvidence;\n}\n\nfunction rangeKey(range: GuidedRange) {\n return `${range.startLine}:${range.startCharacter}-${range.endLine}:${range.endCharacter}`;\n}\n\nfunction rangeMatches(left: GuidedRange, right: GuidedRange) {\n return (\n left.startLine === right.startLine &&\n left.startCharacter === right.startCharacter &&\n left.endLine === right.endLine &&\n left.endCharacter === right.endCharacter\n );\n}\n\nfunction getRangeEvidenceText(content: string, range: GuidedRange): string {\n const normalized = content.replace(/\\r\\n/g, \"\\n\");\n const lines = normalized.split(\"\\n\");\n return lines.slice(range.startLine - 1, range.endLine).join(\"\\n\");\n}\n\nfunction snippetsOverlap(actualRangeText: string, expectedSnippet: string): boolean {\n const normalizedActual = normaliseCode(actualRangeText);\n const expectedLines = normaliseCode(expectedSnippet)\n .split(\"\\n\")\n .map((line) => line.trim())\n .filter(Boolean);\n\n if (!expectedLines.length) {\n return false;\n }\n\n const matchingLineCount = expectedLines.filter((line) => normalizedActual.includes(line)).length;\n const requiredMatches = Math.min(expectedLines.length, 2);\n return matchingLineCount >= requiredMatches;\n}\n\nfunction validateWalkthroughLinks(steps: WalkthroughStepWithEvidence[]) {\n const stepIds = new Set(steps.map((step) => step.id));\n const subrangesByStepId = new Map(\n steps.map((step) => [step.id, new Set(step.subranges.map((subrange) => subrange.id))])\n );\n\n steps.forEach((step, index) => {\n const nextOrderedStep = steps[index + 1];\n if (nextOrderedStep && (!step.links || step.links.length === 0)) {\n throw new Error(`Codebase walkthrough step ${step.id} requires at least one outgoing link`);\n }\n\n const seenTargetIds = new Set<string>();\n for (const link of step.links ?? []) {\n if (!stepIds.has(link.stepId)) {\n throw new Error(`Codebase walkthrough step ${step.id} links to unknown step ${link.stepId}`);\n }\n if (link.subrangeId && !subrangesByStepId.get(link.stepId)?.has(link.subrangeId)) {\n throw new Error(\n `Codebase walkthrough step ${step.id} links to unknown subrange ${link.subrangeId} on ${link.stepId}`\n );\n }\n if (seenTargetIds.has(link.stepId)) {\n throw new Error(`Codebase walkthrough step ${step.id} links to ${link.stepId} more than once`);\n }\n seenTargetIds.add(link.stepId);\n }\n });\n}\n\nfunction validateWalkthroughBranches(steps: WalkthroughStepWithEvidence[]) {\n const stepIds = new Set(steps.map((step) => step.id));\n const subrangesByStepId = new Map(\n steps.map((step) => [step.id, new Set(step.subranges.map((subrange) => subrange.id))])\n );\n\n for (const step of steps) {\n const seenBranchIds = new Set<string>();\n for (const branch of step.branches ?? []) {\n if (seenBranchIds.has(branch.id)) {\n throw new Error(`Codebase walkthrough step ${step.id} contains duplicate branch id ${branch.id}`);\n }\n seenBranchIds.add(branch.id);\n\n if (branch.targetSubrangeId && !branch.targetStepId) {\n throw new Error(\n `Codebase walkthrough step ${step.id} branch ${branch.id} requires targetStepId when targetSubrangeId is present`\n );\n }\n if (branch.targetStepId && !stepIds.has(branch.targetStepId)) {\n throw new Error(\n `Codebase walkthrough step ${step.id} branch ${branch.id} points to unknown step ${branch.targetStepId}`\n );\n }\n if (\n branch.targetStepId &&\n branch.targetSubrangeId &&\n !subrangesByStepId.get(branch.targetStepId)?.has(branch.targetSubrangeId)\n ) {\n throw new Error(\n `Codebase walkthrough step ${step.id} branch ${branch.id} points to unknown subrange ${branch.targetSubrangeId} on ${branch.targetStepId}`\n );\n }\n }\n }\n}\n\nfunction validateWalkthroughFollowUps(\n session: GuidedSession,\n steps: WalkthroughStepWithEvidence[]\n) {\n const stepIds = new Set(steps.map((step) => step.id));\n\n for (const followUp of session.followUps ?? []) {\n if (followUp.stepId && !stepIds.has(followUp.stepId)) {\n throw new Error(\n `Codebase walkthrough follow-up ${followUp.id} points to unknown step ${followUp.stepId}`\n );\n }\n }\n}\n\nfunction validateWalkthroughGraph(\n session: GuidedSession,\n steps: WalkthroughStepWithEvidence[]\n) {\n validateWalkthroughLinks(steps);\n validateWalkthroughBranches(steps);\n validateWalkthroughFollowUps(session, steps);\n}\n\nasync function validateWalkthroughFileEvidence(\n rootDir: string,\n step: WalkthroughStepWithEvidence\n): Promise<void> {\n const filePath = path.join(rootDir, step.file.path);\n const fileContent = await readFile(filePath, \"utf8\");\n\n const snippetMatchesAnyRange = step.subranges.some((subrange) =>\n snippetsOverlap(getRangeEvidenceText(fileContent, subrange.range), step.snippet)\n );\n\n if (!snippetMatchesAnyRange) {\n throw new Error(\n `Codebase walkthrough step ${step.id} snippet must overlap one of its declared subranges`\n );\n }\n\n for (const subrange of step.subranges) {\n if (!subrange.snippet) {\n continue;\n }\n\n const rangeText = getRangeEvidenceText(fileContent, subrange.range);\n if (!snippetsOverlap(rangeText, subrange.snippet)) {\n throw new Error(\n `Codebase walkthrough step ${step.id} subrange ${subrange.id} snippet must overlap its range`\n );\n }\n }\n}\n"],"mappings":";AAAO,SAAS,sBAAsB;AACpC,SAAO;AAAA,IACL,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,IACA,UAAU;AA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ACnB;AACF;AAEA,eAAsB,iBAAiB,SAAiB,WAAoB;AAC1E,QAAM,UAAU,oBAAoB,MAAM,MAAM,kBAAkB,SAAS,SAAS,CAAC;AACrF,MAAI,QAAQ,MAAM,gBAAgB,SAAS,SAAS;AAEpD,MAAI,CAAC,SAAS,aAAc,MAAM,iBAAiB,SAAS,SAAS,GAAI;AACvE,YAAQ,MAAM,gBAAgB,OAAO;AAAA,EACvC;AAEA,SAAO;AAAA,IACL;AAAA,IACA,OAAO,QAAQ,yBAAyB,MAAM,KAAK,IAAI;AAAA,EACzD;AACF;AAEA,eAAsB,iBACpB,SACA,OACA;AACA,QAAM,UAAU,4BAA4B,MAAM,KAAK;AACvD,QAAM,UAAU,oBAAoB,MAAM,MAAM,kBAAkB,SAAS,QAAQ,SAAS,CAAC;AAE7F,MAAI,QAAQ,OAAO,QAAQ,WAAW;AACpC,UAAM,IAAI,MAAM,wBAAwB,QAAQ,SAAS,EAAE;AAAA,EAC7D;AAEA,QAAM,QAAQ,MAAM;AAAA,IAClB;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR;AAAA,MACE,cAAc,MAAM,iBAAiB,SAAS,QAAQ,EAAE;AAAA,IAC1D;AAAA,EACF;AAEA,SAAO;AAAA,IACL,WAAW,QAAQ;AAAA,IACnB,QAAQ,QAAQ;AAAA,IAChB,QAAQ,QAAQ;AAAA,IAChB,OAAO,yBAAyB,MAAM,KAAK;AAAA,EAC7C;AACF;","names":["readFile","writeFile","path","path","readFile","writeFile","writeFile","z","z","readFile","path","path","readFile","z"]}
|
package/dist/index.js
CHANGED
package/dist/server.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
pathfinder,
|
|
7
7
|
updateStepStatus,
|
|
8
8
|
validateGuidedSessionInput
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-7CJLN27A.js";
|
|
10
10
|
|
|
11
11
|
// src/server.ts
|
|
12
12
|
import path from "path";
|
|
@@ -17,7 +17,7 @@ var rootDir = process.env.DUCKWALK_ROOT ?? process.cwd();
|
|
|
17
17
|
var server = new Server(
|
|
18
18
|
{
|
|
19
19
|
name: "duckwalk-mcp",
|
|
20
|
-
version: "0.1.
|
|
20
|
+
version: "0.1.3"
|
|
21
21
|
},
|
|
22
22
|
{
|
|
23
23
|
capabilities: {
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/server.ts"],"sourcesContent":["import path from \"node:path\";\n\nimport { Server } from \"@modelcontextprotocol/sdk/server/index.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport { CallToolRequestSchema, ListToolsRequestSchema } from \"@modelcontextprotocol/sdk/types.js\";\n\nimport {\n createGuidedSession,\n createPrReviewSession,\n getDuckWalkContract,\n getGuidedSession,\n pathfinder,\n updateStepStatus,\n validateGuidedSessionInput\n} from \"./service\";\n\nconst rootDir = process.env.DUCKWALK_ROOT ?? process.cwd();\n\nconst server = new Server(\n {\n name: \"duckwalk-mcp\",\n version: \"0.1.2\"\n },\n {\n capabilities: {\n tools: {}\n }\n }\n);\n\nfunction textResult(payload: unknown) {\n return {\n content: [\n {\n type: \"text\" as const,\n text: JSON.stringify(payload, null, 2)\n }\n ]\n };\n}\n\nfunction getArguments(input: unknown): Record<string, unknown> {\n if (!input || typeof input !== \"object\") {\n return {};\n }\n return input as Record<string, unknown>;\n}\n\nfunction resolveTargetRoot(args: Record<string, unknown>): string {\n const workspaceRoot = args.workspaceRoot;\n if (typeof workspaceRoot === \"string\" && workspaceRoot.trim().length > 0) {\n return path.resolve(workspaceRoot);\n }\n\n return rootDir;\n}\n\nfunction resolveExpectedMode(\n value: unknown\n): Parameters<typeof validateGuidedSessionInput>[0][\"expectMode\"] {\n return value === \"implementation\" ||\n value === \"pr_review\" ||\n value === \"codebase_walkthrough\"\n ? value\n : undefined;\n}\n\nserver.setRequestHandler(ListToolsRequestSchema, async () => ({\n tools: [\n {\n name: \"get_duckwalk_contract\",\n description:\n \"Return the duckWalk session contract, rules, and example payloads for Codex.\",\n inputSchema: {\n type: \"object\",\n properties: {}\n }\n },\n {\n name: \"validate_guided_session\",\n description:\n \"Validate a GuidedSession payload without writing files, and return a normalized summary.\",\n inputSchema: {\n type: \"object\",\n properties: {\n session: {\n type: \"object\",\n description: \"A full GuidedSession payload.\"\n },\n expectMode: {\n type: \"string\",\n enum: [\"implementation\", \"pr_review\", \"codebase_walkthrough\"],\n description: \"Optional expected mode check for the session.\"\n }\n },\n required: [\"session\"]\n }\n },\n {\n name: \"create_guided_session\",\n description: \"Validate and persist an implementation guided session.\",\n inputSchema: {\n type: \"object\",\n properties: {\n workspaceRoot: {\n type: \"string\",\n description:\n \"Optional absolute workspace root where .guided-implementation files should be written.\"\n },\n session: {\n type: \"object\",\n description: \"A full GuidedSession payload.\"\n }\n },\n required: [\"session\"]\n }\n },\n {\n name: \"create_pr_review_session\",\n description: \"Validate and persist a PR review guided session.\",\n inputSchema: {\n type: \"object\",\n properties: {\n workspaceRoot: {\n type: \"string\",\n description:\n \"Optional absolute workspace root where .guided-implementation files should be written.\"\n },\n session: {\n type: \"object\",\n description: \"A full GuidedSession payload with mode pr_review.\"\n }\n },\n required: [\"session\"]\n }\n },\n {\n name: \"pathfinder\",\n description: \"Validate and persist a question-driven codebase walkthrough session.\",\n inputSchema: {\n type: \"object\",\n properties: {\n workspaceRoot: {\n type: \"string\",\n description:\n \"Optional absolute workspace root where .guided-implementation files should be written.\"\n },\n session: {\n type: \"object\",\n description: \"A full GuidedSession payload with mode codebase_walkthrough.\"\n }\n },\n required: [\"session\"]\n }\n },\n {\n name: \"get_guided_session\",\n description: \"Read the current session or a specific session by ID.\",\n inputSchema: {\n type: \"object\",\n properties: {\n workspaceRoot: {\n type: \"string\",\n description:\n \"Optional absolute workspace root where the guided session should be read.\"\n },\n sessionId: {\n type: \"string\"\n }\n }\n }\n },\n {\n name: \"update_step_status\",\n description: \"Update one step status in the current guided session state.\",\n inputSchema: {\n type: \"object\",\n properties: {\n workspaceRoot: {\n type: \"string\",\n description:\n \"Optional absolute workspace root where the guided session state should be updated.\"\n },\n sessionId: {\n type: \"string\"\n },\n stepId: {\n type: \"string\"\n },\n status: {\n type: \"string\",\n enum: [\"pending\", \"active\", \"complete\", \"skipped\"]\n }\n },\n required: [\"sessionId\", \"stepId\", \"status\"]\n }\n }\n ]\n}));\n\nserver.setRequestHandler(CallToolRequestSchema, async (request) => {\n const args = getArguments(request.params.arguments);\n const targetRoot = resolveTargetRoot(args);\n\n switch (request.params.name) {\n case \"get_duckwalk_contract\":\n return textResult(getDuckWalkContract());\n case \"validate_guided_session\":\n {\n const expectMode = resolveExpectedMode(args.expectMode);\n const payload = {\n session: args.session as Parameters<typeof validateGuidedSessionInput>[0][\"session\"],\n ...(expectMode ? { expectMode } : {})\n };\n\n return textResult(validateGuidedSessionInput(payload));\n }\n case \"create_guided_session\":\n return textResult(\n await createGuidedSession(\n targetRoot,\n args.session as Parameters<typeof createGuidedSession>[1]\n )\n );\n case \"create_pr_review_session\":\n return textResult(\n await createPrReviewSession(\n targetRoot,\n args.session as Parameters<typeof createPrReviewSession>[1]\n )\n );\n case \"pathfinder\":\n return textResult(\n await pathfinder(targetRoot, args.session as Parameters<typeof pathfinder>[1])\n );\n case \"get_guided_session\":\n return textResult(\n await getGuidedSession(\n targetRoot,\n typeof args.sessionId === \"string\" ? args.sessionId : undefined\n )\n );\n case \"update_step_status\":\n return textResult(\n await updateStepStatus(targetRoot, {\n sessionId: String(args.sessionId),\n stepId: String(args.stepId),\n status: args.status as Parameters<typeof updateStepStatus>[1][\"status\"]\n })\n );\n default:\n throw new Error(`Unknown tool: ${request.params.name}`);\n }\n});\n\nasync function main() {\n const transport = new StdioServerTransport();\n await server.connect(transport);\n}\n\nmain().catch((error) => {\n console.error(\"[duckwalk-mcp] fatal error\");\n console.error(error);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;AAAA,OAAO,UAAU;AA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AiB,YAAY;AAAA,UACjC,WAAW,OAAO,KAAK,SAAS;AAAA,UAChC,QAAQ,OAAO,KAAK,MAAM;AAAA,UAC1B,QAAQ,KAAK;AAAA,QACf,CAAC;AAAA,MACH;AAAA,IACF;AACE,YAAM,IAAI,MAAM,iBAAiB,QAAQ,OAAO,IAAI,EAAE;AAAA,EAC1D;AACF,CAAC;AAED,eAAe,OAAO;AACpB,QAAM,YAAY,IAAI,qBAAqB;AAC3C,QAAM,OAAO,QAAQ,SAAS;AAChC;AAEA,KAAK,EAAE,MAAM,CAAC,UAAU;AACtB,UAAQ,MAAM,4BAA4B;AAC1C,UAAQ,MAAM,KAAK;AACnB,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/server.ts"],"sourcesContent":["import path from \"node:path\";\n\nimport { Server } from \"@modelcontextprotocol/sdk/server/index.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport { CallToolRequestSchema, ListToolsRequestSchema } from \"@modelcontextprotocol/sdk/types.js\";\n\nimport {\n createGuidedSession,\n createPrReviewSession,\n getDuckWalkContract,\n getGuidedSession,\n pathfinder,\n updateStepStatus,\n validateGuidedSessionInput\n} from \"./service\";\n\nconst rootDir = process.env.DUCKWALK_ROOT ?? process.cwd();\n\nconst server = new Server(\n {\n name: \"duckwalk-mcp\",\n version: \"0.1.3\"\n },\n {\n capabilities: {\n tools: {}\n }\n }\n);\n\nfunction textResult(payload: unknown) {\n return {\n content: [\n {\n type: \"text\" as const,\n text: JSON.stringify(payload, null, 2)\n }\n ]\n };\n}\n\nfunction getArguments(input: unknown): Record<string, unknown> {\n if (!input || typeof input !== \"object\") {\n return {};\n }\n return input as Record<string, unknown>;\n}\n\nfunction resolveTargetRoot(args: Record<string, unknown>): string {\n const workspaceRoot = args.workspaceRoot;\n if (typeof workspaceRoot === \"string\" && workspaceRoot.trim().length > 0) {\n return path.resolve(workspaceRoot);\n }\n\n return rootDir;\n}\n\nfunction resolveExpectedMode(\n value: unknown\n): Parameters<typeof validateGuidedSessionInput>[0][\"expectMode\"] {\n return value === \"implementation\" ||\n value === \"pr_review\" ||\n value === \"codebase_walkthrough\"\n ? value\n : undefined;\n}\n\nserver.setRequestHandler(ListToolsRequestSchema, async () => ({\n tools: [\n {\n name: \"get_duckwalk_contract\",\n description:\n \"Return the duckWalk session contract, rules, and example payloads for Codex.\",\n inputSchema: {\n type: \"object\",\n properties: {}\n }\n },\n {\n name: \"validate_guided_session\",\n description:\n \"Validate a GuidedSession payload without writing files, and return a normalized summary.\",\n inputSchema: {\n type: \"object\",\n properties: {\n session: {\n type: \"object\",\n description: \"A full GuidedSession payload.\"\n },\n expectMode: {\n type: \"string\",\n enum: [\"implementation\", \"pr_review\", \"codebase_walkthrough\"],\n description: \"Optional expected mode check for the session.\"\n }\n },\n required: [\"session\"]\n }\n },\n {\n name: \"create_guided_session\",\n description: \"Validate and persist an implementation guided session.\",\n inputSchema: {\n type: \"object\",\n properties: {\n workspaceRoot: {\n type: \"string\",\n description:\n \"Optional absolute workspace root where .guided-implementation files should be written.\"\n },\n session: {\n type: \"object\",\n description: \"A full GuidedSession payload.\"\n }\n },\n required: [\"session\"]\n }\n },\n {\n name: \"create_pr_review_session\",\n description: \"Validate and persist a PR review guided session.\",\n inputSchema: {\n type: \"object\",\n properties: {\n workspaceRoot: {\n type: \"string\",\n description:\n \"Optional absolute workspace root where .guided-implementation files should be written.\"\n },\n session: {\n type: \"object\",\n description: \"A full GuidedSession payload with mode pr_review.\"\n }\n },\n required: [\"session\"]\n }\n },\n {\n name: \"pathfinder\",\n description: \"Validate and persist a question-driven codebase walkthrough session.\",\n inputSchema: {\n type: \"object\",\n properties: {\n workspaceRoot: {\n type: \"string\",\n description:\n \"Optional absolute workspace root where .guided-implementation files should be written.\"\n },\n session: {\n type: \"object\",\n description: \"A full GuidedSession payload with mode codebase_walkthrough.\"\n }\n },\n required: [\"session\"]\n }\n },\n {\n name: \"get_guided_session\",\n description: \"Read the current session or a specific session by ID.\",\n inputSchema: {\n type: \"object\",\n properties: {\n workspaceRoot: {\n type: \"string\",\n description:\n \"Optional absolute workspace root where the guided session should be read.\"\n },\n sessionId: {\n type: \"string\"\n }\n }\n }\n },\n {\n name: \"update_step_status\",\n description: \"Update one step status in the current guided session state.\",\n inputSchema: {\n type: \"object\",\n properties: {\n workspaceRoot: {\n type: \"string\",\n description:\n \"Optional absolute workspace root where the guided session state should be updated.\"\n },\n sessionId: {\n type: \"string\"\n },\n stepId: {\n type: \"string\"\n },\n status: {\n type: \"string\",\n enum: [\"pending\", \"active\", \"complete\", \"skipped\"]\n }\n },\n required: [\"sessionId\", \"stepId\", \"status\"]\n }\n }\n ]\n}));\n\nserver.setRequestHandler(CallToolRequestSchema, async (request) => {\n const args = getArguments(request.params.arguments);\n const targetRoot = resolveTargetRoot(args);\n\n switch (request.params.name) {\n case \"get_duckwalk_contract\":\n return textResult(getDuckWalkContract());\n case \"validate_guided_session\":\n {\n const expectMode = resolveExpectedMode(args.expectMode);\n const payload = {\n session: args.session as Parameters<typeof validateGuidedSessionInput>[0][\"session\"],\n ...(expectMode ? { expectMode } : {})\n };\n\n return textResult(validateGuidedSessionInput(payload));\n }\n case \"create_guided_session\":\n return textResult(\n await createGuidedSession(\n targetRoot,\n args.session as Parameters<typeof createGuidedSession>[1]\n )\n );\n case \"create_pr_review_session\":\n return textResult(\n await createPrReviewSession(\n targetRoot,\n args.session as Parameters<typeof createPrReviewSession>[1]\n )\n );\n case \"pathfinder\":\n return textResult(\n await pathfinder(targetRoot, args.session as Parameters<typeof pathfinder>[1])\n );\n case \"get_guided_session\":\n return textResult(\n await getGuidedSession(\n targetRoot,\n typeof args.sessionId === \"string\" ? args.sessionId : undefined\n )\n );\n case \"update_step_status\":\n return textResult(\n await updateStepStatus(targetRoot, {\n sessionId: String(args.sessionId),\n stepId: String(args.stepId),\n status: args.status as Parameters<typeof updateStepStatus>[1][\"status\"]\n })\n );\n default:\n throw new Error(`Unknown tool: ${request.params.name}`);\n }\n});\n\nasync function main() {\n const transport = new StdioServerTransport();\n await server.connect(transport);\n}\n\nmain().catch((error) => {\n console.error(\"[duckwalk-mcp] fatal error\");\n console.error(error);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;AAAA,OAAO,UAAU;AAEjB,SAAS,cAAc;AACvB,SAAS,4BAA4B;AACrC,SAAS,uBAAuB,8BAA8B;AAY9D,IAAM,UAAU,QAAQ,IAAI,iBAAiB,QAAQ,IAAI;AAEzD,IAAM,SAAS,IAAI;AAAA,EACjB;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,cAAc;AAAA,MACZ,OAAO,CAAC;AAAA,IACV;AAAA,EACF;AACF;AAEA,SAAS,WAAW,SAAkB;AACpC,SAAO;AAAA,IACL,SAAS;AAAA,MACP;AAAA,QACE,MAAM;AAAA,QACN,MAAM,KAAK,UAAU,SAAS,MAAM,CAAC;AAAA,MACvC;AAAA,IACF;AAAA,EACF;AACF;AAEA,SAAS,aAAa,OAAyC;AAC7D,MAAI,CAAC,SAAS,OAAO,UAAU,UAAU;AACvC,WAAO,CAAC;AAAA,EACV;AACA,SAAO;AACT;AAEA,SAAS,kBAAkB,MAAuC;AAChE,QAAM,gBAAgB,KAAK;AAC3B,MAAI,OAAO,kBAAkB,YAAY,cAAc,KAAK,EAAE,SAAS,GAAG;AACxE,WAAO,KAAK,QAAQ,aAAa;AAAA,EACnC;AAEA,SAAO;AACT;AAEA,SAAS,oBACP,OACgE;AAChE,SAAO,UAAU,oBACf,UAAU,eACV,UAAU,yBACR,QACA;AACN;AAEA,OAAO,kBAAkB,wBAAwB,aAAa;AAAA,EAC5D,OAAO;AAAA,IACL;AAAA,MACE,MAAM;AAAA,MACN,aACE;AAAA,MACF,aAAa;AAAA,QACX,MAAM;AAAA,QACN,YAAY,CAAC;AAAA,MACf;AAAA,IACF;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,aACE;AA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