qfai 2.1.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -36
- package/assets/defaults/agent-routing/qfai-implement.yml +9 -0
- package/assets/defaults/agent-routing/qfai-triage.yml +18 -0
- package/assets/defaults/workflows/answer-in-session.yml +8 -0
- package/assets/defaults/workflows/quarantine-flaky.yml +3 -0
- package/assets/defaults/workflows/repair-consistency.yml +1 -0
- package/assets/defaults/workflows/run-operation.yml +11 -0
- package/assets/defaults/workflows/run-owned-cleanup.yml +12 -0
- package/assets/defaults/workflows/write-procedure.yml +18 -0
- package/assets/graph/codegraph-native.mjs +174 -0
- package/assets/graph/graphify-native.py +72 -0
- package/assets/init/.claude/settings.json +9 -9
- package/assets/init/.codex/hooks.json +8 -8
- package/assets/init/.qfai/assistant/agent/frontend-engineer.md +5 -0
- package/assets/init/.qfai/assistant/agent/product-experience-architect.md +4 -0
- package/assets/init/.qfai/assistant/agent/product-surface-reviewer.md +7 -0
- package/assets/init/.qfai/assistant/agent/requirements-analyst.md +8 -0
- package/assets/init/.qfai/assistant/rule/communication.md +18 -8
- package/assets/init/.qfai/assistant/rule/constitution.md +31 -15
- package/assets/init/.qfai/assistant/rule/drift-protocol.md +119 -2
- package/assets/init/.qfai/assistant/rule/references/asset-authoring.md +6 -4
- package/assets/init/.qfai/assistant/rule/references/codex-delegation.md +27 -0
- package/assets/init/.qfai/assistant/rule/references/griller-recommendations.md +21 -9
- package/assets/init/.qfai/assistant/rule/references/worker-edit-boundary.md +48 -0
- package/assets/init/.qfai/assistant/rule/review-convergence.md +25 -12
- package/assets/init/.qfai/assistant/rule/shared-skill-delegation-baseline.md +16 -25
- package/assets/init/.qfai/assistant/rule/shared-skill-operating-baseline.md +16 -11
- package/assets/init/.qfai/assistant/rule/ui-definition-protocol.md +6 -1
- package/assets/init/.qfai/assistant/rule/workflow.md +2 -1
- package/assets/init/.qfai/assistant/skill/qfai-configure/SKILL.md +3 -3
- package/assets/init/.qfai/assistant/skill/qfai-discussion/SKILL.md +6 -0
- package/assets/init/.qfai/assistant/skill/qfai-discussion/references/discussion-completion-matrix.md +20 -15
- package/assets/init/.qfai/assistant/skill/qfai-discussion/references/ui-bearing-playbook.md +2 -4
- package/assets/init/.qfai/assistant/skill/qfai-discussion/references/ui_ux_best_practices.md +1 -6
- package/assets/init/.qfai/assistant/skill/qfai-discussion/templates/uiux/00_index.md +0 -16
- package/assets/init/.qfai/assistant/skill/qfai-grilling/SKILL.md +30 -20
- package/assets/init/.qfai/assistant/skill/qfai-grilling/references/delegated-session.md +4 -3
- package/assets/init/.qfai/assistant/skill/qfai-grilling/references/session-record.md +8 -2
- package/assets/init/.qfai/assistant/skill/qfai-implement/SKILL.md +16 -3
- package/assets/init/.qfai/assistant/skill/qfai-implement/references/parallelization-policy.md +9 -1
- package/assets/init/.qfai/assistant/skill/qfai-implement/references/red-admissibility.md +46 -0
- package/assets/init/.qfai/assistant/skill/qfai-implement/references/ui-affecting.md +5 -2
- package/assets/init/.qfai/assistant/skill/qfai-maintain/SKILL.md +3 -3
- package/assets/init/.qfai/assistant/skill/qfai-migration-v1-to-v2/SKILL.md +12 -6
- package/assets/init/.qfai/assistant/skill/qfai-migration-v1-to-v2/references/migration-guide.md +1 -265
- package/assets/init/.qfai/assistant/skill/qfai-migration-v1-to-v2/references/migration-placement.md +273 -0
- package/assets/init/.qfai/assistant/skill/qfai-prototyping/SKILL.md +4 -3
- package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/review-payload-schema.md +2 -3
- package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/reviewer-prompt.md +17 -1
- package/assets/init/.qfai/assistant/skill/qfai-run/SKILL.md +52 -37
- package/assets/init/.qfai/assistant/skill/qfai-run/references/codex-cloud-install.md +80 -0
- package/assets/init/.qfai/assistant/skill/qfai-run/references/evidence-delivery.md +322 -0
- package/assets/init/.qfai/assistant/skill/qfai-run/references/extraction.md +83 -49
- package/assets/init/.qfai/assistant/skill/qfai-run/references/operator-screens.md +226 -11
- package/assets/init/.qfai/assistant/skill/qfai-run/references/plan.md +6 -3
- package/assets/init/.qfai/assistant/skill/qfai-run/references/reached-step-observations.md +132 -0
- package/assets/init/.qfai/assistant/skill/qfai-run/references/stage-points.md +14 -0
- package/assets/init/.qfai/assistant/skill/qfai-run/scripts/codex-cloud-install.mjs +117 -0
- package/assets/init/.qfai/assistant/skill/qfai-sdd/SKILL.md +4 -3
- package/assets/init/.qfai/assistant/skill/qfai-sdd/references/contract-artifact-rules.md +1 -0
- package/assets/init/.qfai/assistant/skill/qfai-sdd/references/design-anti-patterns.md +23 -5
- package/assets/init/.qfai/assistant/skill/qfai-sdd/references/design-md-authoring.md +20 -7
- package/assets/init/.qfai/assistant/skill/qfai-sdd/references/requirements-decomposition.md +8 -0
- package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-execution-playbook.md +29 -4
- package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-phase-checklists.md +1 -1
- package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-pre-draft-grilling.md +4 -1
- package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-quality-gate.md +1 -1
- package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-triage.md +159 -4
- package/assets/init/.qfai/assistant/skill/qfai-sdd/references/spec-traceability-rules.md +14 -2
- package/assets/init/.qfai/assistant/skill/qfai-sdd/references/ui-contract-guide.md +146 -0
- package/assets/init/.qfai/assistant/skill/qfai-sdd/references/ui-design-contract-normalization.md +4 -29
- package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/change-request.md +38 -1
- package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/contracts/ui-contract.sample.yaml +52 -5
- package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/spec/decisions.md +12 -0
- package/assets/init/.qfai/assistant/skill/qfai-triage/SKILL.md +34 -21
- package/assets/init/.qfai/assistant/skill/qfai-verify/SKILL.md +5 -4
- package/assets/init/.qfai/assistant/skill/qfai-verify/references/context-load.md +9 -6
- package/assets/init/.qfai/assistant/skill/qfai-verify/references/verify-output-contract.md +80 -15
- package/assets/init/.qfai/assistant/skill/web-research/SKILL.md +35 -21
- package/assets/init/.qfai/assistant/skill/web-research/mcp-templates/brave-search/config.toml +2 -4
- package/assets/init/.qfai/assistant/skill/web-research/mcp-templates/brave-search/mcp-config.json +9 -5
- package/assets/init/.qfai/assistant/skill/web-research/mcp-templates/firecrawl/.mcp.json +1 -2
- package/assets/init/.qfai/assistant/skill/web-research/mcp-templates/firecrawl/config.toml +3 -3
- package/assets/init/.qfai/assistant/skill/web-research/mcp-templates/firecrawl/mcp-config.json +11 -8
- package/assets/init/.qfai/assistant/skill/web-research/mcp-templates/playwright/config.toml +1 -1
- package/assets/init/.qfai/assistant/skill/web-research/mcp-templates/playwright/mcp-config.json +7 -3
- package/assets/init/.qfai/assistant/step/common-design-md/STEP.md +33 -20
- package/assets/init/.qfai/assistant/step/common-gate-run/STEP.md +124 -8
- package/assets/init/.qfai/assistant/step/common-grilling-record/STEP.md +10 -2
- package/assets/init/.qfai/assistant/step/common-policy-check/STEP.md +1 -0
- package/assets/init/.qfai/assistant/step/common-review-cycle/STEP.md +26 -9
- package/assets/init/.qfai/assistant/step/discussion-interview/STEP.md +15 -8
- package/assets/init/.qfai/assistant/step/discussion-oq/STEP.md +5 -1
- package/assets/init/.qfai/assistant/step/discussion-pack/STEP.md +6 -1
- package/assets/init/.qfai/assistant/step/discussion-research/STEP.md +2 -0
- package/assets/init/.qfai/assistant/step/discussion-uiux/STEP.md +6 -4
- package/assets/init/.qfai/assistant/step/implement-backport/STEP.md +1 -1
- package/assets/init/.qfai/assistant/step/implement-benchmark/STEP.md +7 -4
- package/assets/init/.qfai/assistant/step/implement-dep-bump/STEP.md +11 -2
- package/assets/init/.qfai/assistant/step/implement-diagnose/STEP.md +2 -0
- package/assets/init/.qfai/assistant/step/implement-oracle-parity/STEP.md +2 -2
- package/assets/init/.qfai/assistant/step/implement-procedure/STEP.md +69 -0
- package/assets/init/.qfai/assistant/step/implement-quarantine/STEP.md +24 -7
- package/assets/init/.qfai/assistant/step/implement-refactor/STEP.md +2 -2
- package/assets/init/.qfai/assistant/step/implement-regression-fix/STEP.md +7 -6
- package/assets/init/.qfai/assistant/step/implement-retire/STEP.md +6 -3
- package/assets/init/.qfai/assistant/step/implement-revert/STEP.md +4 -3
- package/assets/init/.qfai/assistant/step/implement-seam/STEP.md +6 -5
- package/assets/init/.qfai/assistant/step/implement-stress-harness/STEP.md +34 -3
- package/assets/init/.qfai/assistant/step/implement-sweep/STEP.md +4 -3
- package/assets/init/.qfai/assistant/step/implement-tdd/STEP.md +39 -5
- package/assets/init/.qfai/assistant/step/implement-tooling/STEP.md +22 -2
- package/assets/init/.qfai/assistant/step/maintain-edit/STEP.md +18 -14
- package/assets/init/.qfai/assistant/step/prototyping-grill/STEP.md +4 -3
- package/assets/init/.qfai/assistant/step/prototyping-loop/STEP.md +4 -0
- package/assets/init/.qfai/assistant/step/prototyping-preflight/STEP.md +9 -3
- package/assets/init/.qfai/assistant/step/sdd-contract/STEP.md +11 -0
- package/assets/init/.qfai/assistant/step/sdd-flow/STEP.md +2 -0
- package/assets/init/.qfai/assistant/step/sdd-story/STEP.md +10 -0
- package/assets/init/.qfai/assistant/step/sdd-triage/STEP.md +34 -10
- package/assets/init/.qfai/assistant/step/triage-answer/STEP.md +7 -6
- package/assets/init/.qfai/assistant/step/triage-close/STEP.md +33 -23
- package/assets/init/.qfai/assistant/step/triage-cluster/STEP.md +5 -3
- package/assets/init/.qfai/assistant/step/triage-decompose/STEP.md +2 -0
- package/assets/init/.qfai/assistant/step/triage-dedupe/STEP.md +4 -0
- package/assets/init/.qfai/assistant/step/triage-handoff/STEP.md +13 -4
- package/assets/init/.qfai/assistant/step/triage-investigate/STEP.md +8 -5
- package/assets/init/.qfai/assistant/step/triage-operate/STEP.md +50 -0
- package/assets/init/.qfai/assistant/step/triage-owned-cleanup/STEP.md +86 -0
- package/assets/init/.qfai/assistant/step/triage-request-info/STEP.md +2 -0
- package/assets/init/.qfai/assistant/step/triage-security-intake/STEP.md +6 -3
- package/assets/init/.qfai/assistant/step/verify-change-note/STEP.md +1 -0
- package/assets/init/.qfai/assistant/step/verify-commit/STEP.md +37 -9
- package/assets/init/.qfai/assistant/step/verify-external/STEP.md +5 -2
- package/assets/init/.qfai/assistant/step/verify-qfai-gate/STEP.md +14 -16
- package/assets/init/.qfai/assistant/step/verify-release-notes/STEP.md +1 -0
- package/assets/init/.qfai/assistant/step/verify-repeat-run/STEP.md +46 -4
- package/assets/init/.qfai/assistant/step/verify-repo-gate/STEP.md +133 -30
- package/assets/init/root/.agents/rules/ai-readable-markdown.md +2 -2
- package/assets/init/root/.agents/rules/api-budget.md +187 -8
- package/assets/init/root/.agents/rules/document-schema.md +17 -0
- package/assets/init/root/.agents/rules/documentation-clarity.md +163 -34
- package/assets/init/root/.agents/rules/graph-exploration.md +150 -0
- package/assets/init/root/.agents/rules/grilling.md +100 -43
- package/assets/init/root/.agents/rules/minimal-implementation.md +3 -3
- package/assets/init/root/.agents/rules/reminders.json +27 -18
- package/assets/init/root/.agents/rules/session-feedback.md +131 -0
- package/assets/init/root/.agents/rules/temporary-files.md +33 -0
- package/assets/init/root/.agents/rules/untrusted-content.md +2 -2
- package/assets/init/root/.agents/rules/user-questions.md +51 -40
- package/assets/init/root/.github/workflows/qfai-docs.yml +3 -3
- package/assets/init/root/.github/workflows/qfai-tests.yml +88 -35
- package/assets/init/root/.github/workflows/qfai-validate.yml +2 -2
- package/assets/init/root/AGENTS.md +24 -22
- package/assets/sandbox-templates/default-deny.yaml +9 -3
- package/assets/schemas/workflow/extraction.schema.json +89 -5
- package/assets/scripts/check-mdschema.mjs +77 -8
- package/assets/uix-rev/comparison-review.md +1 -1
- package/assets/uix-rev/contracts-review.md +1 -2
- package/dist/cli/index.cjs +9444 -10071
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.mjs +9421 -10041
- package/dist/cli/index.mjs.map +1 -1
- package/dist/graph/cli.cjs +1568 -0
- package/dist/graph/cli.cjs.map +1 -0
- package/dist/graph/cli.d.cts +9 -0
- package/dist/graph/cli.d.ts +9 -0
- package/dist/graph/cli.mjs +1541 -0
- package/dist/graph/cli.mjs.map +1 -0
- package/dist/graph/hook.cjs +817 -0
- package/dist/graph/hook.cjs.map +1 -0
- package/dist/graph/hook.d.cts +9 -0
- package/dist/graph/hook.d.ts +9 -0
- package/dist/graph/hook.mjs +792 -0
- package/dist/graph/hook.mjs.map +1 -0
- package/dist/index.cjs +7634 -8517
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +146 -658
- package/dist/index.d.ts +146 -658
- package/dist/index.mjs +7462 -8318
- package/dist/index.mjs.map +1 -1
- package/dist/process-C21nTvkT.d.cts +12 -0
- package/dist/process-C21nTvkT.d.ts +12 -0
- package/package.json +4 -6
- package/assets/init/root/CLAUDE.md +0 -46
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/cli/graphCli.ts","../../src/core/graph/codePreparation.ts","../../src/shared/assets.ts","../../src/core/graph/process.ts","../../src/core/graph/layout.ts","../../src/core/graph/storage.ts","../../src/core/fs/errno.ts","../../src/core/graph/reuse.ts","../../src/core/graph/analysis.ts","../../src/core/graph/documents.ts","../../src/core/graph/documentReuse.ts","../../src/core/graph/locks.ts","../../src/core/graph/localFiles.ts","../../src/core/init/fsGuards.ts","../../src/core/graph/query.ts","../../src/core/graph/runner.ts","../../src/core/graph/fallbackState.ts","../../src/core/graph/permissionRecords.ts"],"sourcesContent":["import { queryPreparedGraph } from \"../core/graph/runner.js\";\nimport { runGraphProcess, type GraphProcess } from \"../core/graph/process.js\";\nimport type { GraphQuestion } from \"../core/graph/query.js\";\nimport { requestStoredGraphFallback } from \"../core/graph/fallbackState.js\";\nimport { GRAPH_UUID, graphStateText, GraphLocalStateError } from \"../core/graph/localFiles.js\";\n\nexport interface GraphCliIO {\n output(text: string): void;\n fail(): void;\n}\n\nconst QUERY_USAGE =\n 'Run node .qfai/tools/graph-cli.mjs code \"<question>\" or documents \"<question>\". For a denied search, run node .qfai/tools/graph-cli.mjs fallback --attempt-id <observed-UUID> --question \"<unresolved question>\" --reason \"<graph limitation>\". Supply only the listed arguments.';\n\nexport async function runInstalledGraphCli(\n root: string,\n args: string[],\n io: GraphCliIO = {\n output: (text) => {\n process.stdout.write(text);\n },\n fail: () => {\n process.exitCode = 2;\n },\n },\n run: GraphProcess = runGraphProcess,\n): Promise<void> {\n const request = args[0] === \"fallback\" ? readFallback(args) : readQuestion(args);\n if (!request) {\n io.output(\n JSON.stringify({\n status: \"failed\",\n ...(args[0] === \"fallback\" ? { permitted: false } : {}),\n failure: \"Invalid graph command arguments.\",\n recovery: QUERY_USAGE,\n }) + \"\\n\",\n );\n io.fail();\n return;\n }\n let answer;\n try {\n answer =\n \"attemptId\" in request\n ? await requestStoredGraphFallback(\n root,\n request.attemptId,\n request.question,\n request.reason,\n run,\n )\n : await queryPreparedGraph(root, request, run);\n } catch (cause: unknown) {\n const fallback = \"attemptId\" in request;\n answer = {\n status: \"failed\",\n permitted: false,\n failure:\n cause instanceof GraphLocalStateError\n ? cause.message\n : fallback\n ? \"Search fallback failed.\"\n : \"Graph operation failed.\",\n recovery:\n cause instanceof GraphLocalStateError\n ? cause.recovery\n : fallback\n ? \"Retain .qfai/tools/state and local analysis, repair project-local graph preparation, then retry the same fallback CLI command.\"\n : \"Repair project-local graph preparation and retry the same CLI command.\",\n };\n }\n io.output(JSON.stringify(answer) + \"\\n\");\n if (answer.status === \"failed\" || answer.status === \"not-ready\") io.fail();\n}\n\nfunction readFallback(\n args: string[],\n): { attemptId: string; question: string; reason: string } | undefined {\n if (args.length !== 7) return undefined;\n const values = new Map<string, string>();\n for (let index = 1; index < args.length; index += 2) {\n const flag = args[index];\n const value = args[index + 1]?.trim();\n if (\n !flag ||\n ![\"--attempt-id\", \"--question\", \"--reason\"].includes(flag) ||\n values.has(flag) ||\n !value ||\n value.startsWith(\"--\")\n )\n return undefined;\n values.set(flag, value);\n }\n const attemptId = values.get(\"--attempt-id\");\n const question = values.get(\"--question\");\n const reason = values.get(\"--reason\");\n if (\n !attemptId ||\n !GRAPH_UUID.test(attemptId) ||\n !graphStateText(question, 16384) ||\n !graphStateText(reason, 2048)\n )\n return undefined;\n return { attemptId, question, reason };\n}\n\nfunction readQuestion(args: string[]): GraphQuestion | undefined {\n const domain = args[0];\n const question = args[1]?.trim();\n if (\n (domain !== \"code\" && domain !== \"documents\") ||\n args.length !== 2 ||\n !question ||\n question.length > 16384 ||\n question.includes(\"\\0\") ||\n question.startsWith(\"--\")\n )\n return undefined;\n return { domain, question };\n}\n","import { randomUUID } from \"node:crypto\";\nimport { mkdir, rm } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { getInitAssetsDir } from \"../../shared/assets.js\";\nimport { codegraphEnvironment, type GraphProcess } from \"./process.js\";\nimport {\n publishCompletedCodeAnalysis,\n restoreCompletedCodeAnalysis,\n type GraphReuseEnvironment,\n} from \"./reuse.js\";\nimport { graphAnalysisRoot, graphRuntimePaths } from \"./layout.js\";\nimport {\n inspectCodeAnalysisAt,\n inspectCurrentCodeAnalysis,\n mirrorGraphCorpus,\n} from \"./analysis.js\";\nimport {\n assertGraphStoragePath,\n assertIndependentAnalysis,\n replaceGraphDirectory,\n} from \"./storage.js\";\n\nexport interface CodePreparation {\n status: \"prepared\" | \"failed\";\n source?: \"generated\" | \"restored\" | \"current\";\n recovery?: string;\n reuse?: \"published\" | \"unavailable\";\n}\n\nexport async function prepareCodeAnalysis(\n root: string,\n run: GraphProcess,\n environment?: GraphReuseEnvironment,\n): Promise<CodePreparation> {\n const current = graphAnalysisRoot(root, \"codegraph\");\n const staged = path.join(path.dirname(current), `.preparing-codegraph-${randomUUID()}`);\n let created = false;\n try {\n if (await inspectCurrentCodeAnalysis(root, run))\n return { status: \"prepared\", source: \"current\" };\n if ((await restoreCompletedCodeAnalysis(root, run, environment)) === \"restored\")\n return { status: \"prepared\", source: \"restored\" };\n await assertGraphStoragePath(root, staged);\n await mkdir(staged, { recursive: true });\n created = true;\n await mirrorGraphCorpus(root, staged);\n const runtime = graphRuntimePaths(root);\n const result = await run(\n runtime.codegraphNode,\n [\n \"--liftoff-only\",\n path.resolve(getInitAssetsDir(), \"..\", \"graph\", \"codegraph-native.mjs\"),\n runtime.codegraphSdk,\n staged,\n ],\n { cwd: staged, env: codegraphEnvironment(root) },\n );\n if (result.exitCode !== 0 || !(await inspectCodeAnalysisAt(root, staged, run))) return failed();\n await assertIndependentAnalysis(staged);\n await replaceGraphDirectory(staged, current, root);\n return {\n status: \"prepared\",\n source: \"generated\",\n reuse: await publishCompletedCodeAnalysis(root, run, environment),\n };\n } catch {\n return failed();\n } finally {\n if (created) await rm(staged, { recursive: true, force: true });\n }\n}\n\nfunction failed(): CodePreparation {\n return {\n status: \"failed\",\n recovery: \"Repair the local CodeGraph runtime and prepare independent analysis.\",\n };\n}\n","import { existsSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\n/**\n * `assets/init` candidates for a module sitting at `baseDir`.\n *\n * Three depths, because this module is loaded from three: `src/shared/` and\n * `dist/shared/` are two levels below the package root, and `dist/index.mjs` —\n * the package's public entry, which `tsup` produces with `splitting: false`, so\n * this code is bundled into it — is one. Without the one-level candidate every\n * caller that reaches `validateProject` through the library entry rather than\n * the CLI got `Template assets not found` before any validator ran.\n *\n * **Ordered nearest-first**, because the shallower depths are not the\n * package's own directory once QFAI is installed: from\n * `<project>/node_modules/qfai/dist`, the three-level candidate is\n * `<project>/assets/init`. A consuming project with an unrelated `assets/init`\n * would otherwise be picked as the template root, and a wrong-but-present\n * directory is worse than a missing one — `canonicalSkillIds` would read an\n * empty shipped roster and `QFAI-LINK-001` would pass every broken wrapper\n * without looking at it.\n *\n * Exported for the test that pins those depths; `getInitAssetsDir` is the API.\n */\nexport function initAssetsCandidates(baseDir: string): string[] {\n return [\n path.resolve(baseDir, \"../assets/init\"),\n path.resolve(baseDir, \"../../assets/init\"),\n path.resolve(baseDir, \"../../../assets/init\"),\n ];\n}\n\n/**\n * Files a real `assets/init` tree always has.\n *\n * Existence alone does not identify the directory — the name is generic enough\n * that a consuming project can have one. Both halves of the tree `runInit`\n * copies are required, so an unrelated `assets/init` is rejected and the search\n * continues instead of silently rooting the whole template system somewhere\n * arbitrary.\n */\nconst INIT_ASSETS_SENTINELS = [\n path.join(\".qfai\", \"assistant\"),\n path.join(\"root\", \"qfai.config.yaml\"),\n];\n\nfunction isInitAssetsDir(candidate: string): boolean {\n return INIT_ASSETS_SENTINELS.every((sentinel) => existsSync(path.join(candidate, sentinel)));\n}\n\nexport function getInitAssetsDir(): string {\n const base = import.meta.url;\n const basePath = base.startsWith(\"file:\") ? fileURLToPath(base) : base;\n const baseDir = path.dirname(basePath);\n const candidates = initAssetsCandidates(baseDir);\n\n for (const candidate of candidates) {\n if (isInitAssetsDir(candidate)) {\n return candidate;\n }\n }\n\n throw new Error(\n [\n \"Template assets for init were not found.\",\n \"Checked paths:\",\n ...candidates.map((candidate) => `- ${candidate}`),\n ].join(\"\\n\"),\n );\n}\n","import { execFile } from \"node:child_process\";\nimport { access, lstat, realpath } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { promisify } from \"node:util\";\nimport {\n graphEnvironmentKey,\n graphExecutionEnvironment,\n type GraphExecutionEnvironment,\n} from \"./layout.js\";\nimport { assertGraphStoragePath } from \"./storage.js\";\nimport { isEnoent } from \"../fs/errno.js\";\n\nconst execute = promisify(execFile);\nexport const GRAPH_PYTHON_FLAGS = [\"-I\", \"-X\", \"utf8\"] as const;\n\nexport interface GraphProcessResult {\n exitCode: number;\n stdout: string;\n}\n\nexport type GraphProcess = (\n command: string,\n args: readonly string[],\n options: { cwd: string; env?: NodeJS.ProcessEnv; timeoutMs?: number; maxBufferBytes?: number },\n) => Promise<GraphProcessResult>;\n\nfunction privateEngineEnvironment(\n root: string,\n engine: \"codegraph\" | \"graphify\",\n execution: GraphExecutionEnvironment,\n): NodeJS.ProcessEnv {\n const environment: NodeJS.ProcessEnv = {};\n const allowed: Record<string, string> = {\n path: \"PATH\",\n systemroot: \"SystemRoot\",\n windir: \"WINDIR\",\n comspec: \"ComSpec\",\n pathext: \"PATHEXT\",\n tmp: \"TMP\",\n temp: \"TEMP\",\n lang: \"LANG\",\n lc_all: \"LC_ALL\",\n };\n for (const [name, value] of Object.entries(process.env)) {\n const canonical = allowed[name.toLowerCase()];\n if (canonical) environment[canonical] = value;\n }\n const home = path.join(root, \".qfai\", \"tools\", \"home\", graphEnvironmentKey(execution), engine);\n return {\n ...environment,\n HOME: home,\n USERPROFILE: home,\n APPDATA: path.join(home, \"AppData\", \"Roaming\"),\n LOCALAPPDATA: path.join(home, \"AppData\", \"Local\"),\n XDG_CONFIG_HOME: path.join(home, \".config\"),\n XDG_CACHE_HOME: path.join(home, \".cache\"),\n XDG_DATA_HOME: path.join(home, \".local\", \"share\"),\n XDG_STATE_HOME: path.join(home, \".local\", \"state\"),\n };\n}\n\nexport function graphifyEnvironment(\n root: string,\n environment: GraphExecutionEnvironment = graphExecutionEnvironment(),\n): NodeJS.ProcessEnv {\n return {\n ...privateEngineEnvironment(root, \"graphify\", environment),\n PYTHONUTF8: \"1\",\n PYTHONIOENCODING: \"utf-8\",\n GRAPHIFY_QUERY_LOG_DISABLE: \"1\",\n GRAPHIFY_OUT: \"graphify-out\",\n GRAPHIFY_ALLOW_LOCAL_PROVIDERS: \"0\",\n GRAPHIFY_NO_AUTO_REFRESH: \"1\",\n };\n}\n\nexport function codegraphEnvironment(\n root: string,\n environment: GraphExecutionEnvironment = graphExecutionEnvironment(),\n): NodeJS.ProcessEnv {\n const privateEnvironment = privateEngineEnvironment(root, \"codegraph\", environment);\n const home = privateEnvironment.HOME ?? \"\";\n return {\n ...privateEnvironment,\n CODEGRAPH_INSTALL_DIR: path.join(home, \".codegraph\"),\n CODEGRAPH_NO_DOWNLOAD: \"1\",\n CODEGRAPH_NO_UPDATE_CHECK: \"1\",\n CODEGRAPH_TELEMETRY: \"0\",\n CODEGRAPH_DIR: \".codegraph\",\n };\n}\n\nexport function graphifyCorpusEnvironment(root: string, analysis: string): NodeJS.ProcessEnv {\n return {\n ...graphifyEnvironment(root),\n GRAPHIFY_OUT: path.toNamespacedPath(path.join(analysis, \"graphify-out\")),\n };\n}\n\nexport async function graphifyConfigurationSafe(root: string): Promise<boolean> {\n const home = graphifyEnvironment(root).HOME;\n if (!home) return false;\n try {\n const configuration = path.join(home, \".graphify\");\n await assertGraphStoragePath(root, configuration);\n await lstat(path.join(configuration, \"providers.json\"));\n return false;\n } catch (cause: unknown) {\n return isEnoent(cause);\n }\n}\n\nexport const runGraphProcess: GraphProcess = async (command, args, options) => {\n try {\n const result = await execute(command, [...args], {\n cwd: options.cwd,\n ...(options.env ? { env: options.env } : {}),\n windowsHide: true,\n timeout: options.timeoutMs ?? 120_000,\n maxBuffer: options.maxBufferBytes ?? 4 * 1024 * 1024,\n });\n return { exitCode: 0, stdout: result.stdout };\n } catch (cause: unknown) {\n if (!(cause instanceof Error) || !(\"code\" in cause)) throw cause;\n // Installation and backend stderr can contain credentials. Report the step instead.\n return { exitCode: typeof cause.code === \"number\" ? cause.code : 1, stdout: \"\" };\n }\n};\n\nexport async function npmCommand(): Promise<{ command: string; prefix: string[] }> {\n const node = await realpath(process.execPath);\n const candidates = [\n path.join(path.dirname(node), \"node_modules\", \"npm\", \"bin\", \"npm-cli.js\"),\n path.resolve(path.dirname(node), \"..\", \"lib\", \"node_modules\", \"npm\", \"bin\", \"npm-cli.js\"),\n ];\n for (const candidate of candidates) {\n try {\n await access(candidate);\n return { command: process.execPath, prefix: [candidate] };\n } catch (cause: unknown) {\n if (!(cause instanceof Error) || !(\"code\" in cause) || cause.code !== \"ENOENT\") throw cause;\n }\n }\n // POSIX npm launchers are executable scripts. Windows uses the JS entry above.\n return { command: \"npm\", prefix: [] };\n}\n","import path from \"node:path\";\n\nexport const GRAPH_VERSIONS = { codegraph: \"1.6.2\", graphify: \"0.9.86\" } as const;\n\nexport interface GraphExecutionEnvironment {\n platform: string;\n architecture: string;\n}\n\nexport function graphExecutionEnvironment(): GraphExecutionEnvironment {\n return { platform: process.platform, architecture: process.arch };\n}\n\nexport function graphEnvironmentKey(\n environment: GraphExecutionEnvironment = graphExecutionEnvironment(),\n): string {\n if (!/^[a-z0-9]+$/i.test(environment.platform) || !/^[a-z0-9]+$/i.test(environment.architecture))\n throw new Error(\"Unsupported graph execution environment.\");\n return `${environment.platform}-${environment.architecture}`;\n}\n\nexport function graphRuntimePaths(\n root: string,\n environment: GraphExecutionEnvironment = graphExecutionEnvironment(),\n) {\n const directory = path.join(root, \".qfai\", \"tools\", \"runtimes\", graphEnvironmentKey(environment));\n return {\n directory,\n codegraph: path.join(\n directory,\n \"codegraph\",\n \"node_modules\",\n \"@colbymchenry\",\n \"codegraph\",\n \"npm-shim.js\",\n ),\n codegraphSdk: path.join(\n directory,\n \"codegraph\",\n \"node_modules\",\n \"@colbymchenry\",\n \"codegraph\",\n \"npm-sdk.js\",\n ),\n codegraphNode: path.join(\n directory,\n \"codegraph\",\n \"node_modules\",\n \"@colbymchenry\",\n `codegraph-${environment.platform}-${environment.architecture}`,\n environment.platform === \"win32\" ? \"node.exe\" : \"node\",\n ),\n python:\n environment.platform === \"win32\"\n ? path.join(directory, \"graphify\", \"Scripts\", \"python.exe\")\n : path.join(directory, \"graphify\", \"bin\", \"python\"),\n };\n}\n\nexport function graphAnalysisRoot(\n root: string,\n engine: \"codegraph\" | \"graphify\" | \"graphify-code\",\n environment: GraphExecutionEnvironment = graphExecutionEnvironment(),\n): string {\n return path.join(root, \".qfai\", \"tools\", \"analysis\", graphEnvironmentKey(environment), engine);\n}\n","import { randomUUID } from \"node:crypto\";\nimport { lstat, mkdir, readdir, rename, rm } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { isEnoent } from \"../fs/errno.js\";\n\nexport async function assertGraphStoragePath(root: string, directory: string): Promise<void> {\n const relative = path.relative(root, directory);\n const parts = relative.split(path.sep);\n if (\n path.isAbsolute(relative) ||\n parts[0] !== \".qfai\" ||\n parts[1] !== \"tools\" ||\n parts.includes(\"..\")\n ) {\n throw new Error(\"Graph storage must stay inside project-local .qfai/tools.\");\n }\n for (let depth = 1; depth <= parts.length; depth += 1) {\n try {\n const stats = await lstat(path.join(root, ...parts.slice(0, depth)));\n if (stats.isSymbolicLink() || !stats.isDirectory())\n throw new Error(\n \"Graph storage has an unsafe path component; retain it and repair the project configuration.\",\n );\n } catch (cause: unknown) {\n if (isEnoent(cause)) return;\n throw cause;\n }\n }\n}\n\nexport async function assertIndependentAnalysis(directory: string): Promise<void> {\n for (const entry of await readdir(directory, { withFileTypes: true })) {\n const child = path.join(directory, entry.name);\n const stats = await lstat(child);\n if (stats.isSymbolicLink() || (stats.isFile() && stats.nlink > 1)) {\n throw new Error(\n \"Graph analysis contains a shared file or unsafe link; retain it and prepare an independent copy.\",\n );\n }\n if (stats.isDirectory()) await assertIndependentAnalysis(child);\n }\n}\n\nexport async function replaceGraphDirectory(\n staged: string,\n current: string,\n root: string,\n): Promise<void> {\n await assertGraphStoragePath(root, staged);\n await assertGraphStoragePath(root, current);\n const parent = path.dirname(current);\n await mkdir(parent, { recursive: true });\n const previous = path.join(parent, `.previous-${randomUUID()}`);\n let retained = false;\n try {\n await rename(current, previous);\n retained = true;\n } catch (cause: unknown) {\n if (!isEnoent(cause)) throw cause;\n }\n try {\n await rename(staged, current);\n } catch (cause: unknown) {\n if (retained) await rename(previous, current);\n throw cause;\n }\n if (retained) await rm(previous, { recursive: true, force: true });\n}\n","/**\n * Shared errno helpers for Node.js fs error narrowing.\n *\n * Avoids ad-hoc `(err as { code?: string }).code === \"ENOENT\"` repetition\n * across init / config / prototyping commands. Future errno codes\n * (`EACCES`, `EBUSY`, `EPERM`, ...) extend this module rather than\n * sprouting new inline checks.\n */\n\n/**\n * True iff `err` is a Node.js fs error whose `code` is `\"ENOENT\"`\n * (file or directory does not exist).\n */\nexport function isEnoent(err: unknown): boolean {\n return hasErrnoCode(err) && err.code === \"ENOENT\";\n}\n\n/**\n * True iff `err` is a Node.js fs error whose `code` is `\"EPERM\"`.\n *\n * On Windows this is what `stat` raises for a **file** symlink whose target is\n * a directory: the link is intact and `readlink` returns the right target, but\n * the reparse tag is the wrong kind and the OS refuses to follow it. `git\n * worktree add` produces exactly that for `.claude/skills/*`, because at the\n * moment git writes the link its target does not yet exist in the new worktree\n * and it has no reftype hint. So a reader that treats EPERM as a filesystem\n * fault to propagate crashes on a condition that is structural damage to the\n * path it is inspecting.\n */\nexport function isEperm(err: unknown): boolean {\n return hasErrnoCode(err) && err.code === \"EPERM\";\n}\n\n/**\n * True iff `err` is a Node.js error-shaped object carrying a string\n * `code` (e.g. `\"ENOENT\"`, `\"EACCES\"`, `\"ENOSPC\"`). Narrowing helper\n * shared across the codebase so individual call sites do not sprout\n * ad-hoc `(err as { code?: string }).code` casts (CLAUDE.md\n * \"avoid bare `as` type assertions; prefer type narrowing\").\n */\nexport function hasErrnoCode(err: unknown): err is { code: string } {\n return (\n err !== null &&\n typeof err === \"object\" &&\n \"code\" in err &&\n typeof (err as { code?: unknown }).code === \"string\"\n );\n}\n","import os from \"node:os\";\nimport path from \"node:path\";\n\nimport { randomUUID } from \"node:crypto\";\nimport {\n cp,\n lstat,\n mkdir,\n readFile,\n readdir,\n realpath,\n rename,\n rm,\n writeFile,\n} from \"node:fs/promises\";\nimport { isEnoent } from \"../fs/errno.js\";\nimport {\n GRAPH_VERSIONS,\n graphAnalysisRoot,\n graphRuntimePaths,\n graphEnvironmentKey,\n} from \"./layout.js\";\nimport {\n excludedGraphInput,\n inspectCodeAnalysisAt,\n nativeCodeAnalysisCurrent,\n} from \"./analysis.js\";\nimport {\n assertGraphStoragePath,\n assertIndependentAnalysis,\n replaceGraphDirectory,\n} from \"./storage.js\";\nimport { codegraphEnvironment, type GraphProcess } from \"./process.js\";\nimport { getInitAssetsDir } from \"../../shared/assets.js\";\n\nfunction verifiedNativeRelease(output: string): boolean {\n const release = /^v(\\d+\\.\\d+\\.\\d+)$/.exec(output.trim());\n return release?.[1] === \"24.16.0\";\n}\n\nexport interface GraphReuseEnvironment {\n platform: string;\n architecture: string;\n machine: string;\n}\n\nexport function graphReuseEnvironment(): GraphReuseEnvironment {\n return { platform: process.platform, architecture: process.arch, machine: os.hostname() };\n}\n\nexport async function restoreCompletedCodeAnalysis(\n root: string,\n run: GraphProcess,\n environment: GraphReuseEnvironment = graphReuseEnvironment(),\n): Promise<\"restored\" | \"cold\"> {\n // Other native bundle combinations use generation until independent-copy proof exists.\n if (environment.platform !== \"win32\" || environment.architecture !== \"x64\") return \"cold\";\n const nativeRuntime = await run(graphRuntimePaths(root).codegraphNode, [\"--version\"], {\n cwd: root,\n env: codegraphEnvironment(root),\n });\n if (nativeRuntime.exitCode !== 0 || !verifiedNativeRelease(nativeRuntime.stdout)) return \"cold\";\n const location = await completedAnalysisCache(root, \"codegraph\", run, environment);\n if (!location) return \"cold\";\n let candidates;\n try {\n candidates = await readdir(location.directory, { withFileTypes: true });\n } catch (cause: unknown) {\n if (isEnoent(cause)) return \"cold\";\n throw cause;\n }\n for (const entry of candidates) {\n if (!entry.isDirectory() || entry.isSymbolicLink() || entry.name.startsWith(\".\")) continue;\n const candidate = path.join(location.directory, entry.name);\n if (!(await cacheDirectorySafe(location.repository, candidate))) continue;\n const metadata = await readSnapshotMetadata(candidate);\n if (\n !metadata ||\n Object.keys(metadata).some(\n (key) =>\n ![\"layout\", \"corpusPolicy\", \"repository\", \"engineVersion\", \"environment\"].includes(key),\n ) ||\n metadata.layout !== 1 ||\n metadata.corpusPolicy !== 1 ||\n metadata.repository !== location.repository ||\n metadata.engineVersion !== GRAPH_VERSIONS.codegraph ||\n !sameEnvironment(metadata.environment, environment)\n )\n continue;\n if (!(await safeCompletedCorpus(path.join(candidate, \"analysis\")))) continue;\n if (!(await safeCodegraphInputs(root, path.join(candidate, \"analysis\"), run))) continue;\n const current = graphAnalysisRoot(root, \"codegraph\");\n const staged = path.join(path.dirname(current), `.restoring-codegraph-${randomUUID()}`);\n await assertGraphStoragePath(root, staged);\n try {\n const cached = path.join(candidate, \"analysis\");\n await assertIndependentAnalysis(cached);\n await mkdir(path.dirname(staged), { recursive: true });\n await cp(cached, staged, { recursive: true, dereference: false });\n await assertIndependentAnalysis(staged);\n if (!(await inspectCodeAnalysisAt(root, staged, run))) continue;\n await replaceGraphDirectory(staged, current, root);\n return \"restored\";\n } finally {\n await rm(staged, { recursive: true, force: true });\n }\n }\n return \"cold\";\n}\n\nexport async function completedAnalysisCache(\n root: string,\n engine: \"codegraph\" | \"graphify\" | \"graphify-code\",\n run: GraphProcess,\n environment: GraphReuseEnvironment = graphReuseEnvironment(),\n): Promise<{ repository: string; directory: string } | undefined> {\n const git = await run(\"git\", [\"rev-parse\", \"--path-format=absolute\", \"--git-common-dir\"], {\n cwd: root,\n });\n if (git.exitCode !== 0 || !path.isAbsolute(git.stdout.trim())) return undefined;\n const repository = await realpath(git.stdout.trim());\n return {\n repository,\n directory: path.join(repository, \"qfai-graph-cache\", graphEnvironmentKey(environment), engine),\n };\n}\n\nexport async function publishCompletedCodeAnalysis(\n root: string,\n run: GraphProcess,\n environment: GraphReuseEnvironment = graphReuseEnvironment(),\n): Promise<\"published\" | \"unavailable\"> {\n let staged: string | undefined;\n try {\n if (environment.platform !== \"win32\" || environment.architecture !== \"x64\")\n return \"unavailable\";\n const native = await run(graphRuntimePaths(root).codegraphNode, [\"--version\"], {\n cwd: root,\n env: codegraphEnvironment(root),\n });\n if (native.exitCode !== 0 || !verifiedNativeRelease(native.stdout)) return \"unavailable\";\n const cache = await completedAnalysisCache(root, \"codegraph\", run, environment);\n if (!cache) return \"unavailable\";\n await ensureCacheDirectory(cache.repository, cache.directory);\n const analysis = graphAnalysisRoot(root, \"codegraph\");\n if (!(await safeCompletedCorpus(analysis)) || !(await safeCodegraphInputs(root, analysis, run)))\n return \"unavailable\";\n const identity = randomUUID();\n staged = path.join(cache.directory, `.publishing-${identity}`);\n await mkdir(staged);\n await cp(analysis, path.join(staged, \"analysis\"), { recursive: true, dereference: false });\n await assertIndependentAnalysis(path.join(staged, \"analysis\"));\n if (\n !(await safeCompletedCorpus(path.join(staged, \"analysis\"))) ||\n !(await safeCodegraphInputs(root, path.join(staged, \"analysis\"), run))\n )\n return \"unavailable\";\n if (!(await nativeCodeAnalysisCurrent(root, path.join(staged, \"analysis\"), run)))\n return \"unavailable\";\n await writeFile(\n path.join(staged, \"completed.json\"),\n JSON.stringify({\n layout: 1,\n corpusPolicy: 1,\n repository: cache.repository,\n engineVersion: GRAPH_VERSIONS.codegraph,\n environment,\n }) + \"\\n\",\n );\n await rename(staged, path.join(cache.directory, identity));\n return \"published\";\n } catch {\n return \"unavailable\";\n } finally {\n if (staged) await rm(staged, { recursive: true, force: true });\n }\n}\n\nexport async function ensureCacheDirectory(repository: string, directory: string): Promise<void> {\n const relative = path.relative(repository, directory);\n const parts = relative.split(path.sep);\n if (path.isAbsolute(relative) || parts.includes(\"..\") || parts[0] !== \"qfai-graph-cache\")\n throw new Error(\"Unsafe completed analysis path.\");\n for (let depth = 1; depth <= parts.length; depth += 1) {\n const component = path.join(repository, ...parts.slice(0, depth));\n let stats;\n try {\n stats = await lstat(component);\n } catch (cause: unknown) {\n if (!isEnoent(cause)) throw cause;\n await mkdir(component);\n stats = await lstat(component);\n }\n if (stats.isSymbolicLink() || !stats.isDirectory())\n throw new Error(\"Unsafe completed analysis path.\");\n }\n}\n\nexport async function cacheDirectorySafe(repository: string, candidate: string): Promise<boolean> {\n const relative = path.relative(repository, candidate);\n const parts = relative.split(path.sep);\n if (path.isAbsolute(relative) || parts.includes(\"..\") || parts[0] !== \"qfai-graph-cache\")\n return false;\n for (let depth = 1; depth <= parts.length; depth += 1) {\n const stats = await lstat(path.join(repository, ...parts.slice(0, depth)));\n if (stats.isSymbolicLink() || !stats.isDirectory()) return false;\n }\n return true;\n}\n\nexport async function readSnapshotMetadata(\n candidate: string,\n): Promise<Record<string, unknown> | undefined> {\n try {\n const stats = await lstat(path.join(candidate, \"completed.json\"));\n if (!stats.isFile() || stats.isSymbolicLink() || stats.nlink !== 1) return undefined;\n const metadata: unknown = JSON.parse(\n await readFile(path.join(candidate, \"completed.json\"), \"utf8\"),\n );\n return object(metadata) ? metadata : undefined;\n } catch (cause: unknown) {\n if (isEnoent(cause) || cause instanceof SyntaxError) return undefined;\n throw cause;\n }\n}\n\nexport function sameEnvironment(value: unknown, environment: GraphReuseEnvironment): boolean {\n return (\n object(value) &&\n Object.keys(value).length === 3 &&\n value.platform === environment.platform &&\n value.architecture === environment.architecture &&\n value.machine === environment.machine\n );\n}\n\nexport async function safeCompletedCorpus(\n directory: string,\n relative = \"\",\n engineDirectory = \".codegraph\",\n): Promise<boolean> {\n try {\n for (const entry of await readdir(path.join(directory, ...relative.split(\"/\")), {\n withFileTypes: true,\n })) {\n const next = relative ? `${relative}/${entry.name}` : entry.name;\n const input = next.startsWith(`${engineDirectory}/`)\n ? next.slice(engineDirectory.length + 1)\n : next;\n if (\n (next !== engineDirectory && excludedGraphInput(input)) ||\n /\\.(?:pid|lock)$/i.test(entry.name)\n )\n return false;\n const stats = await lstat(path.join(directory, ...next.split(\"/\")));\n if (stats.isSymbolicLink() || (stats.isFile() && stats.nlink !== 1)) return false;\n if (stats.isDirectory() && !(await safeCompletedCorpus(directory, next, engineDirectory)))\n return false;\n if (!stats.isDirectory() && !stats.isFile()) return false;\n }\n return true;\n } catch {\n return false;\n }\n}\n\nfunction object(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nasync function safeCodegraphInputs(\n root: string,\n analysis: string,\n run: GraphProcess,\n): Promise<boolean> {\n const runtime = graphRuntimePaths(root);\n const result = await run(\n runtime.codegraphNode,\n [\n \"--liftoff-only\",\n path.resolve(getInitAssetsDir(), \"..\", \"graph\", \"codegraph-native.mjs\"),\n runtime.codegraphSdk,\n analysis,\n \"inventory\",\n ],\n { cwd: analysis, env: codegraphEnvironment(root) },\n );\n if (result.exitCode !== 0) return false;\n try {\n const inventory: unknown = JSON.parse(result.stdout);\n if (!object(inventory) || !Array.isArray(inventory.files)) return false;\n for (const file of inventory.files) {\n if (\n typeof file !== \"string\" ||\n !file ||\n path.posix.isAbsolute(file) ||\n path.win32.isAbsolute(file)\n )\n return false;\n const normalized = file.replaceAll(\"\\\\\", \"/\");\n const parts = normalized.split(\"/\");\n if (\n parts.some((part) => !part || part === \".\" || part === \"..\") ||\n excludedGraphInput(normalized)\n )\n return false;\n const stats = await lstat(path.join(analysis, ...parts));\n if (!stats.isFile() || stats.isSymbolicLink() || stats.nlink !== 1) return false;\n }\n return true;\n } catch {\n return false;\n }\n}\n","import path from \"node:path\";\nimport { getInitAssetsDir } from \"../../shared/assets.js\";\nimport { copyFile, lstat, mkdir, readdir, rm } from \"node:fs/promises\";\nimport { isEnoent } from \"../fs/errno.js\";\nimport { GRAPH_VERSIONS, graphRuntimePaths, graphAnalysisRoot } from \"./layout.js\";\nimport type { GraphProcess } from \"./process.js\";\nimport { codegraphEnvironment } from \"./process.js\";\nimport { assertGraphStoragePath, assertIndependentAnalysis } from \"./storage.js\";\nexport { graphAnalysisRoot } from \"./layout.js\";\n\nexport interface CodeAnalysisCoverage {\n complete: boolean;\n unsupported: string[];\n unreadable: string[];\n unparsed: string[];\n}\n\nexport async function inspectCodeCoverage(\n root: string,\n run: GraphProcess,\n): Promise<CodeAnalysisCoverage> {\n const unknown = { complete: false, unsupported: [], unreadable: [], unparsed: [] };\n const runtime = graphRuntimePaths(root);\n const analysis = graphAnalysisRoot(root, \"codegraph\");\n const result = await run(\n runtime.codegraphNode,\n [\n \"--liftoff-only\",\n path.resolve(getInitAssetsDir(), \"..\", \"graph\", \"codegraph-native.mjs\"),\n runtime.codegraphSdk,\n analysis,\n \"coverage\",\n ],\n { cwd: analysis, env: codegraphEnvironment(root) },\n );\n if (result.exitCode !== 0) return unknown;\n let value: unknown;\n try {\n value = JSON.parse(result.stdout);\n } catch {\n return unknown;\n }\n if (\n !object(value) ||\n Object.keys(value).length !== 4 ||\n typeof value.complete !== \"boolean\" ||\n !stringArray(value.unsupported) ||\n !stringArray(value.unreadable) ||\n !stringArray(value.unparsed)\n )\n return unknown;\n return {\n complete:\n value.complete &&\n value.unsupported.length === 0 &&\n value.unreadable.length === 0 &&\n value.unparsed.length === 0,\n unsupported: value.unsupported,\n unreadable: value.unreadable,\n unparsed: value.unparsed,\n };\n}\n\nfunction stringArray(value: unknown): value is string[] {\n return Array.isArray(value) && value.every((entry: unknown) => typeof entry === \"string\");\n}\n\nexport async function inspectCurrentCodeAnalysis(\n root: string,\n run: GraphProcess,\n): Promise<boolean> {\n const analysis = graphAnalysisRoot(root, \"codegraph\");\n return inspectCodeAnalysisAt(root, analysis, run);\n}\n\nexport async function inspectCodeAnalysisAt(\n root: string,\n analysis: string,\n run: GraphProcess,\n): Promise<boolean> {\n await assertGraphStoragePath(root, analysis);\n try {\n if (!(await lstat(path.join(analysis, \".codegraph\", \"codegraph.db\"))).isFile()) return false;\n } catch (cause: unknown) {\n if (isEnoent(cause)) return false;\n throw cause;\n }\n await mirrorGraphCorpus(root, analysis);\n return nativeCodeAnalysisCurrent(root, analysis, run);\n}\n\nexport async function nativeCodeAnalysisCurrent(\n root: string,\n analysis: string,\n run: GraphProcess,\n): Promise<boolean> {\n const result = await run(\n process.execPath,\n [graphRuntimePaths(root).codegraph, \"status\", analysis, \"--json\"],\n { cwd: root, env: codegraphEnvironment(root) },\n );\n if (result.exitCode !== 0) return false;\n let value: unknown;\n try {\n value = JSON.parse(result.stdout);\n } catch (cause: unknown) {\n if (!(cause instanceof SyntaxError)) throw cause;\n return false;\n }\n if (!object(value) || !object(value.index) || !object(value.pendingChanges)) return false;\n const changes = value.pendingChanges;\n return (\n value.initialized === true &&\n value.version === GRAPH_VERSIONS.codegraph &&\n value.projectPath === analysis &&\n value.worktreeMismatch === null &&\n value.index.state === \"complete\" &&\n value.index.pendingRefs === 0 &&\n value.index.reindexRecommended === false &&\n value.index.builtWithVersion === GRAPH_VERSIONS.codegraph &&\n value.index.builtWithExtractionVersion !== undefined &&\n value.index.builtWithExtractionVersion === value.index.currentExtractionVersion &&\n [\"added\", \"modified\", \"removed\"].every((key) => changes[key] === 0)\n );\n}\n\nconst excludedDirectories = new Set([\n \".git\",\n \".codegraph\",\n \".codegraph-wsl\",\n \".graphify\",\n \"graphify-out\",\n \"node_modules\",\n \"dist\",\n \"tmp\",\n \".claude\",\n \".codex\",\n \".vscode\",\n \".ssh\",\n \".aws\",\n \".azure\",\n]);\n\nexport function excludedGraphInput(relative: string): boolean {\n const parts = relative.split(\"/\");\n const name = parts.at(-1) ?? \"\";\n return (\n parts.some((part) => excludedDirectories.has(part.toLowerCase())) ||\n /^\\.qfai\\/(?:tools|report|evidence|review|discussion)(?:\\/|$)/i.test(relative) ||\n relative.toLowerCase() === \".qfai/graph-processing.json\" ||\n /^(?:\\.npmrc|\\.pypirc|\\.netrc|\\.git-credentials)$/i.test(name) ||\n /^\\.env(?:\\.|$)/i.test(name) ||\n /\\.(?:pem|key|p12|pfx|keystore)$/i.test(name) ||\n /^(?:id_(?:rsa|dsa|ecdsa|ed25519)|credentials?(?:\\.|$)|secrets?(?:\\.|$)|\\.mcp\\.json$)/i.test(\n name,\n )\n );\n}\n\nexport async function mirrorGraphCorpus(\n root: string,\n destination: string,\n scope?: readonly string[],\n): Promise<void> {\n await assertGraphStoragePath(root, destination);\n await assertIndependentAnalysis(destination);\n const files = new Set<string>();\n await visit(\"\");\n await removeAbsent(\"\");\n\n async function visit(relative: string): Promise<void> {\n for (const entry of await readdir(path.join(root, ...relative.split(\"/\")), {\n withFileTypes: true,\n })) {\n const next = relative ? `${relative}/${entry.name}` : entry.name;\n if (excludedGraphInput(next) || entry.isSymbolicLink()) continue;\n if (\n scope &&\n !scope.some(\n (item) => item === next || next.startsWith(`${item}/`) || item.startsWith(`${next}/`),\n )\n )\n continue;\n if (entry.isDirectory()) {\n await visit(next);\n } else if (entry.isFile()) {\n const source = path.join(root, ...next.split(\"/\"));\n const stats = await lstat(source);\n if (!stats.isFile() || stats.nlink > 1) continue;\n const target = path.join(destination, ...next.split(\"/\"));\n await mkdir(path.dirname(target), { recursive: true });\n await copyFile(source, target);\n files.add(next);\n }\n }\n }\n\n async function removeAbsent(relative: string): Promise<void> {\n for (const entry of await readdir(path.join(destination, ...relative.split(\"/\")), {\n withFileTypes: true,\n })) {\n const next = relative ? `${relative}/${entry.name}` : entry.name;\n if (entry.name === \".codegraph\" || entry.name === \".git\" || entry.name === \"graphify-out\")\n continue;\n const target = path.join(destination, ...next.split(\"/\"));\n if (entry.isDirectory()) await removeAbsent(next);\n else if (!files.has(next)) await rm(target);\n }\n }\n}\n\nfunction object(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n","import { mkdir, readFile, rm, writeFile } from \"node:fs/promises\";\nimport { randomUUID } from \"node:crypto\";\nimport {\n publishCompletedDocumentAnalysis,\n restoreCompletedDocumentAnalysis,\n safeDocumentCopy,\n} from \"./documentReuse.js\";\nimport type { GraphReuseEnvironment } from \"./reuse.js\";\nimport { withGraphLock } from \"./locks.js\";\nimport path from \"node:path\";\nimport { getInitAssetsDir } from \"../../shared/assets.js\";\nimport { isEnoent } from \"../fs/errno.js\";\nimport { mirrorGraphCorpus } from \"./analysis.js\";\nimport { graphAnalysisRoot, graphRuntimePaths, GRAPH_VERSIONS } from \"./layout.js\";\nimport {\n GRAPH_PYTHON_FLAGS,\n graphifyConfigurationSafe,\n graphifyCorpusEnvironment,\n runGraphProcess,\n type GraphProcess,\n} from \"./process.js\";\nimport {\n assertGraphStoragePath,\n assertIndependentAnalysis,\n replaceGraphDirectory,\n} from \"./storage.js\";\n\nexport interface DocumentPreparation {\n status: \"prepared\" | \"not-ready\" | \"failed\";\n source?: \"current\" | \"restored\" | \"generated\";\n reuse?: \"published\" | \"unavailable\";\n recovery?: string;\n}\n\nexport interface DocumentScopeStatus {\n current: boolean;\n unsupported: string[];\n unreadable: string[];\n}\n\ninterface GraphProcessing {\n readonly backend: \"ollama\" | \"openai\";\n readonly model: string;\n readonly endpoint?: string;\n readonly scope?: string[];\n readonly credentialEnv?: string;\n}\n\nfunction notCurrent(): DocumentScopeStatus {\n return { current: false, unsupported: [], unreadable: [] };\n}\n\nexport interface ExternalProcessingRequest {\n readonly destination: string;\n readonly scope: readonly string[];\n readonly backend: string;\n readonly model: string;\n readonly worktree: string;\n}\n\nexport type ApproveExternalProcessing = (request: ExternalProcessingRequest) => Promise<boolean>;\n\nexport const DOCUMENT_PROCESSING_SETUP =\n 'Configure a selected local backend and model in .qfai/graph-processing.json using .agents/rules/graph-exploration.md, then run node .qfai/tools/graph-cli.mjs documents \"<question>\".';\n\nexport async function prepareGraphifyCodeAnalysis(\n root: string,\n run: GraphProcess = runGraphProcess,\n): Promise<DocumentPreparation> {\n if (!(await graphifyConfigurationSafe(root))) return providerConflict();\n const current = graphAnalysisRoot(root, \"graphify-code\");\n const staged = path.join(path.dirname(current), `.preparing-graphify-code-${randomUUID()}`);\n await assertGraphStoragePath(root, staged);\n await mkdir(staged, { recursive: true });\n try {\n await mirrorGraphCorpus(root, staged);\n const result = await run(\n graphRuntimePaths(root).python,\n [\n ...GRAPH_PYTHON_FLAGS,\n \"-m\",\n \"graphify\",\n \"extract\",\n path.toNamespacedPath(staged),\n \"--code-only\",\n \"--no-cluster\",\n \"--no-dedup\",\n \"--max-workers\",\n \"1\",\n \"--max-concurrency\",\n \"1\",\n ],\n { cwd: staged, env: graphifyCorpusEnvironment(root, staged) },\n );\n if (\n result.exitCode !== 0 ||\n !(await currentGraphifyCorpus(root, staged, graphRuntimePaths(root).python, run, \"ast\"))\n ) {\n return { status: \"failed\", recovery: \"Repair local Graphify code analysis.\" };\n }\n await writeFile(\n path.join(staged, \"graphify-out\", \"managed.json\"),\n JSON.stringify({ engineVersion: GRAPH_VERSIONS.graphify, scope: \"code\" }),\n );\n await assertIndependentAnalysis(staged);\n await replaceGraphDirectory(staged, current, root);\n return { status: \"prepared\" };\n } finally {\n await rm(staged, { recursive: true, force: true });\n }\n}\n\nexport async function prepareDocumentAnalysis(\n root: string,\n run: GraphProcess = runGraphProcess,\n approveExternal: ApproveExternalProcessing = () => Promise.resolve(false),\n environment?: GraphReuseEnvironment,\n): Promise<DocumentPreparation> {\n return withGraphLock(root, \"analysis\", () =>\n prepareDocumentAnalysisLocked(root, run, approveExternal, environment),\n );\n}\n\nexport async function prepareDocumentAnalysisLocked(\n root: string,\n run: GraphProcess = runGraphProcess,\n approveExternal: ApproveExternalProcessing = () => Promise.resolve(false),\n environment?: GraphReuseEnvironment,\n): Promise<DocumentPreparation> {\n if (!(await graphifyConfigurationSafe(root))) return providerConflict();\n if (await inspectDocumentAnalysis(root, run)) return { status: \"prepared\", source: \"current\" };\n const processing = await readGraphProcessing(root);\n if (!processing) {\n return {\n status: \"not-ready\",\n recovery: DOCUMENT_PROCESSING_SETUP,\n };\n }\n const inspect = async (analysis: string, refresh: boolean) =>\n (await inspectDocumentScopeAt(root, analysis, run, refresh)).current;\n if ((await restoreCompletedDocumentAnalysis(root, run, inspect, environment)) === \"restored\")\n return { status: \"prepared\", source: \"restored\" };\n const endpoint = processing.endpoint ?? \"http://127.0.0.1:11434/v1\";\n const selected = new URL(endpoint);\n const backend = processing.backend;\n const credential =\n typeof processing.credentialEnv === \"string\"\n ? process.env[processing.credentialEnv]\n : undefined;\n if (processing.credentialEnv !== undefined && !credential) {\n return {\n status: \"not-ready\",\n recovery:\n \"Set the explicitly selected credential environment variable before document processing.\",\n };\n }\n const local = [\"127.0.0.1\", \"localhost\", \"[::1]\"].includes(selected.hostname);\n let scope: readonly string[] | undefined;\n if (processing.scope !== undefined) {\n if (!validDocumentScope(processing.scope))\n return { status: \"not-ready\", recovery: \"Select the exact document scope for processing.\" };\n scope = Object.freeze(processing.scope.map((item) => item.replaceAll(\"\\\\\", \"/\")));\n }\n if (!local) {\n if (!scope) {\n return {\n status: \"not-ready\",\n recovery: \"Select the exact document scope for external processing.\",\n };\n }\n const approval: unknown = await approveExternal(\n Object.freeze({\n destination: endpoint,\n scope,\n backend,\n model: processing.model,\n worktree: root,\n }),\n );\n if (approval !== true) {\n return {\n status: \"not-ready\",\n recovery:\n \"External document processing requires explicit human authorization of its destination and scope.\",\n };\n }\n }\n const current = graphAnalysisRoot(root, \"graphify\");\n const staged = path.join(path.dirname(current), `.preparing-graphify-${randomUUID()}`);\n await assertGraphStoragePath(root, staged);\n await mkdir(staged, { recursive: true });\n try {\n await mirrorGraphCorpus(root, staged, scope);\n const result = await run(\n graphRuntimePaths(root).python,\n [\n ...GRAPH_PYTHON_FLAGS,\n \"-m\",\n \"graphify\",\n \"extract\",\n path.toNamespacedPath(staged),\n \"--backend\",\n backend,\n \"--model\",\n processing.model,\n \"--no-cluster\",\n \"--no-dedup\",\n \"--max-workers\",\n \"1\",\n \"--max-concurrency\",\n \"1\",\n ],\n {\n cwd: staged,\n env: {\n ...graphifyCorpusEnvironment(root, staged),\n [backend === \"ollama\" ? \"OLLAMA_BASE_URL\" : \"OPENAI_BASE_URL\"]: endpoint,\n ...(credential\n ? { [backend === \"ollama\" ? \"OLLAMA_API_KEY\" : \"OPENAI_API_KEY\"]: credential }\n : {}),\n },\n },\n );\n if (\n result.exitCode !== 0 ||\n !(await currentGraphifyCorpus(root, staged, graphRuntimePaths(root).python, run))\n ) {\n return {\n status: \"failed\",\n recovery: \"Check the selected local model and repair Graphify document analysis.\",\n };\n }\n await writeFile(\n path.join(staged, \"graphify-out\", \"managed.json\"),\n JSON.stringify({ engineVersion: GRAPH_VERSIONS.graphify, scope: \"documents\", processing }),\n );\n await assertIndependentAnalysis(staged);\n await replaceGraphDirectory(staged, current, root);\n return {\n status: \"prepared\",\n source: \"generated\",\n reuse: await publishCompletedDocumentAnalysis(root, run, inspect, environment),\n };\n } finally {\n await rm(staged, { recursive: true, force: true });\n }\n}\n\nexport async function readGraphProcessing(root: string): Promise<GraphProcessing | undefined> {\n const processing = await readOptionalJson(path.join(root, \".qfai\", \"graph-processing.json\"));\n return validGraphProcessing(processing) ? processing : undefined;\n}\n\nfunction validGraphProcessing(processing: unknown): processing is GraphProcessing {\n const allowed = new Set([\"backend\", \"model\", \"endpoint\", \"scope\", \"credentialEnv\"]);\n if (\n !object(processing) ||\n Object.keys(processing).some((key) => !allowed.has(key)) ||\n (processing.backend !== \"ollama\" && processing.backend !== \"openai\") ||\n typeof processing.model !== \"string\" ||\n !processing.model.trim() ||\n (processing.scope !== undefined && !validDocumentScope(processing.scope)) ||\n (processing.credentialEnv !== undefined &&\n (typeof processing.credentialEnv !== \"string\" ||\n !/^[A-Z_][A-Z0-9_]*$/.test(processing.credentialEnv)))\n )\n return false;\n if (processing.endpoint !== undefined) {\n if (typeof processing.endpoint !== \"string\" || !processing.endpoint.trim()) return false;\n try {\n const endpoint = new URL(processing.endpoint);\n if (\n ![\"http:\", \"https:\"].includes(endpoint.protocol) ||\n endpoint.username ||\n endpoint.password ||\n endpoint.search ||\n endpoint.hash\n )\n return false;\n } catch {\n return false;\n }\n }\n return true;\n}\n\nexport async function inspectDocumentAnalysis(root: string, run: GraphProcess): Promise<boolean> {\n return (await inspectDocumentScope(root, run)).current;\n}\n\nexport async function inspectDocumentScope(\n root: string,\n run: GraphProcess,\n): Promise<DocumentScopeStatus> {\n const analysis = graphAnalysisRoot(root, \"graphify\");\n await assertGraphStoragePath(root, analysis);\n return inspectDocumentScopeAt(root, analysis, run);\n}\n\nasync function inspectDocumentScopeAt(\n root: string,\n analysis: string,\n run: GraphProcess,\n refresh = true,\n): Promise<DocumentScopeStatus> {\n const managed = await readOptionalJson(path.join(analysis, \"graphify-out\", \"managed.json\"));\n const selected = await readGraphProcessing(root);\n const processing = await processingForCompletedQuery(\n root,\n selected,\n object(managed) ? managed.processing : undefined,\n );\n if (\n !object(managed) ||\n Object.keys(managed).length !== 3 ||\n managed.engineVersion !== GRAPH_VERSIONS.graphify ||\n managed.scope !== \"documents\" ||\n !sameProcessing(managed.processing, processing)\n )\n return notCurrent();\n if (!(await safeDocumentCopy(root, analysis, run))) return notCurrent();\n const scope =\n object(processing) && validDocumentScope(processing.scope) ? processing.scope : undefined;\n if (refresh) await mirrorGraphCorpus(root, analysis, scope);\n return nativeGraphifyScope(root, analysis, graphRuntimePaths(root).python, run);\n}\n\nasync function processingForCompletedQuery(\n root: string,\n selected: unknown,\n recorded: unknown,\n): Promise<unknown> {\n if (selected !== undefined) return selected;\n try {\n await readFile(path.join(root, \".qfai\", \"graph-processing.json\"));\n return undefined;\n } catch (cause: unknown) {\n if (!isEnoent(cause)) throw cause;\n }\n if (!validGraphProcessing(recorded)) return undefined;\n return recorded;\n}\n\nasync function currentGraphifyCorpus(\n root: string,\n analysis: string,\n python: string,\n run: GraphProcess,\n kind: \"semantic\" | \"ast\" = \"semantic\",\n): Promise<boolean> {\n return (await nativeGraphifyScope(root, analysis, python, run, kind)).current;\n}\n\nasync function nativeGraphifyScope(\n root: string,\n analysis: string,\n python: string,\n run: GraphProcess,\n kind: \"semantic\" | \"ast\" = \"semantic\",\n): Promise<DocumentScopeStatus> {\n if (!(await graphifyConfigurationSafe(root))) return notCurrent();\n const result = await run(\n python,\n [\n ...GRAPH_PYTHON_FLAGS,\n path.resolve(getInitAssetsDir(), \"..\", \"graph\", \"graphify-native.py\"),\n path.toNamespacedPath(analysis),\n kind,\n ],\n {\n cwd: analysis,\n env: graphifyCorpusEnvironment(root, analysis),\n },\n );\n if (result.exitCode !== 0) return notCurrent();\n let state: unknown;\n try {\n state = JSON.parse(result.stdout);\n } catch (cause: unknown) {\n if (!(cause instanceof SyntaxError)) throw cause;\n return notCurrent();\n }\n if (\n !object(state) ||\n typeof state.current !== \"boolean\" ||\n !stringArray(state.unsupported) ||\n !stringArray(state.unreadable)\n )\n return notCurrent();\n const sourcePath = (file: string) =>\n path.isAbsolute(file)\n ? path\n .relative(path.toNamespacedPath(analysis), path.toNamespacedPath(file))\n .split(path.sep)\n .join(\"/\")\n : file;\n return {\n current: state.current,\n unsupported: state.unsupported.map(sourcePath),\n unreadable: state.unreadable.map(sourcePath),\n };\n}\n\nasync function readOptionalJson(file: string): Promise<unknown> {\n try {\n return JSON.parse(await readFile(file, \"utf8\"));\n } catch (cause: unknown) {\n if (isEnoent(cause) || cause instanceof SyntaxError) return undefined;\n throw cause;\n }\n}\n\nfunction object(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction sameProcessing(left: unknown, right: unknown): boolean {\n if (!object(left) || !object(right)) return false;\n const fields = [\"backend\", \"model\", \"endpoint\", \"credentialEnv\", \"scope\"];\n if (Object.keys(left).some((key) => !fields.includes(key))) return false;\n return fields.every((key) => JSON.stringify(left[key]) === JSON.stringify(right[key]));\n}\n\nfunction stringArray(value: unknown): value is string[] {\n return Array.isArray(value) && value.every((item: unknown) => typeof item === \"string\");\n}\n\nfunction validDocumentScope(value: unknown): value is string[] {\n return (\n Array.isArray(value) &&\n value.length > 0 &&\n value.every(\n (item: unknown) =>\n typeof item === \"string\" &&\n item !== \"\" &&\n !path.isAbsolute(item) &&\n !item.split(/[\\\\/]/).some((part) => part === \"..\" || part === \".\" || part === \"\"),\n )\n );\n}\n\nfunction providerConflict(): DocumentPreparation {\n return {\n status: \"not-ready\",\n recovery:\n \"Review private Graphify provider settings and unsafe home paths before processing; existing settings were retained.\",\n };\n}\n","import { randomUUID } from \"node:crypto\";\nimport { cp, lstat, mkdir, readdir, rename, rm, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { getInitAssetsDir } from \"../../shared/assets.js\";\nimport { excludedGraphInput } from \"./analysis.js\";\nimport { GRAPH_VERSIONS, graphAnalysisRoot, graphRuntimePaths } from \"./layout.js\";\nimport {\n GRAPH_PYTHON_FLAGS,\n graphifyEnvironment,\n graphifyCorpusEnvironment,\n type GraphProcess,\n} from \"./process.js\";\nimport {\n cacheDirectorySafe,\n completedAnalysisCache,\n ensureCacheDirectory,\n graphReuseEnvironment,\n readSnapshotMetadata,\n safeCompletedCorpus,\n sameEnvironment,\n type GraphReuseEnvironment,\n} from \"./reuse.js\";\nimport {\n assertGraphStoragePath,\n assertIndependentAnalysis,\n replaceGraphDirectory,\n} from \"./storage.js\";\n\ntype Inspect = (analysis: string, refresh: boolean) => Promise<boolean>;\n\nexport async function restoreCompletedDocumentAnalysis(\n root: string,\n run: GraphProcess,\n inspect: Inspect,\n environment: GraphReuseEnvironment = graphReuseEnvironment(),\n): Promise<\"restored\" | \"cold\"> {\n let staged: string | undefined;\n try {\n if (!(await compatible(root, run, environment))) return \"cold\";\n const cache = await completedAnalysisCache(root, \"graphify\", run, environment);\n if (!cache) return \"cold\";\n for (const entry of await readdir(cache.directory, { withFileTypes: true })) {\n if (!entry.isDirectory() || entry.isSymbolicLink() || entry.name.startsWith(\".\")) continue;\n const candidate = path.join(cache.directory, entry.name);\n if (!(await cacheDirectorySafe(cache.repository, candidate))) continue;\n const metadata = await readSnapshotMetadata(candidate);\n if (\n !metadata ||\n Object.keys(metadata).length !== 5 ||\n metadata.layout !== 1 ||\n metadata.corpusPolicy !== 1 ||\n metadata.repository !== cache.repository ||\n metadata.engineVersion !== GRAPH_VERSIONS.graphify ||\n !sameEnvironment(metadata.environment, environment)\n )\n continue;\n const analysis = path.join(candidate, \"analysis\");\n if (!(await safeDocumentCopy(root, analysis, run))) continue;\n const current = graphAnalysisRoot(root, \"graphify\");\n staged = path.join(path.dirname(current), `.restoring-graphify-${randomUUID()}`);\n await assertGraphStoragePath(root, staged);\n await mkdir(path.dirname(staged), { recursive: true });\n await cp(analysis, staged, { recursive: true, dereference: false });\n await assertIndependentAnalysis(staged);\n if (await inspect(staged, true)) {\n await replaceGraphDirectory(staged, current, root);\n return \"restored\";\n }\n await rm(staged, { recursive: true, force: true });\n staged = undefined;\n }\n } catch {\n return \"cold\";\n } finally {\n if (staged) await discard(staged);\n }\n return \"cold\";\n}\n\nexport async function publishCompletedDocumentAnalysis(\n root: string,\n run: GraphProcess,\n inspect: Inspect,\n environment: GraphReuseEnvironment = graphReuseEnvironment(),\n): Promise<\"published\" | \"unavailable\"> {\n let staged: string | undefined;\n try {\n if (!(await compatible(root, run, environment))) return \"unavailable\";\n const cache = await completedAnalysisCache(root, \"graphify\", run, environment);\n if (!cache) return \"unavailable\";\n await ensureCacheDirectory(cache.repository, cache.directory);\n const analysis = graphAnalysisRoot(root, \"graphify\");\n if (!(await safeDocumentCopy(root, analysis, run))) return \"unavailable\";\n const identity = randomUUID();\n staged = path.join(cache.directory, `.publishing-${identity}`);\n await mkdir(staged);\n const copy = path.join(staged, \"analysis\");\n await cp(analysis, copy, { recursive: true, dereference: false });\n await assertIndependentAnalysis(copy);\n if (!(await safeDocumentCopy(root, copy, run)) || !(await inspect(copy, false)))\n return \"unavailable\";\n await writeFile(\n path.join(staged, \"completed.json\"),\n JSON.stringify({\n layout: 1,\n corpusPolicy: 1,\n repository: cache.repository,\n engineVersion: GRAPH_VERSIONS.graphify,\n environment,\n }) + \"\\n\",\n );\n await rename(staged, path.join(cache.directory, identity));\n return \"published\";\n } catch {\n return \"unavailable\";\n } finally {\n if (staged) await discard(staged);\n }\n}\n\nasync function compatible(\n root: string,\n run: GraphProcess,\n environment: GraphReuseEnvironment,\n): Promise<boolean> {\n if (environment.platform !== \"win32\" || environment.architecture !== \"x64\") return false;\n const result = await run(\n graphRuntimePaths(root).python,\n [...GRAPH_PYTHON_FLAGS, \"-c\", \"import sys; print(sys.version.split()[0])\"],\n { cwd: root, env: graphifyEnvironment(root) },\n );\n return result.exitCode === 0 && result.stdout.trim() === \"3.12.13\";\n}\n\nexport async function safeDocumentCopy(\n root: string,\n analysis: string,\n run: GraphProcess,\n): Promise<boolean> {\n if (!(await safeCompletedCorpus(analysis, \"\", \"graphify-out\"))) return false;\n const result = await run(\n graphRuntimePaths(root).python,\n [\n ...GRAPH_PYTHON_FLAGS,\n path.resolve(getInitAssetsDir(), \"..\", \"graph\", \"graphify-native.py\"),\n path.toNamespacedPath(analysis),\n \"inventory\",\n ],\n { cwd: analysis, env: graphifyCorpusEnvironment(root, analysis) },\n );\n if (result.exitCode !== 0) return false;\n try {\n const inventory: unknown = JSON.parse(result.stdout);\n if (\n typeof inventory !== \"object\" ||\n inventory === null ||\n Object.keys(inventory).length !== 1 ||\n !(\"files\" in inventory) ||\n !Array.isArray(inventory.files)\n )\n return false;\n for (const file of inventory.files) {\n if (typeof file !== \"string\" || path.posix.isAbsolute(file) || path.win32.isAbsolute(file))\n return false;\n const parts = file.replaceAll(\"\\\\\", \"/\").split(\"/\");\n if (\n parts.some((part) => !part || part === \".\" || part === \"..\") ||\n excludedGraphInput(parts.join(\"/\"))\n )\n return false;\n const stats = await lstat(path.join(analysis, ...parts));\n if (!stats.isFile() || stats.isSymbolicLink() || stats.nlink !== 1) return false;\n }\n return true;\n } catch {\n return false;\n }\n}\n\nasync function discard(directory: string): Promise<void> {\n try {\n await rm(directory, { recursive: true, force: true });\n } catch {\n // An unfinished hidden candidate is never eligible for restoration.\n }\n}\n","import { randomUUID } from \"node:crypto\";\nimport { unlink } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { hasErrnoCode } from \"../fs/errno.js\";\nimport { graphEnvironmentKey } from \"./layout.js\";\nimport {\n graphStateDirectory,\n GraphLocalStateError,\n GRAPH_UUID,\n readGraphLocalFile,\n writeGraphLocalFile,\n} from \"./localFiles.js\";\n\nexport async function withGraphLock<T>(\n root: string,\n kind: \"analysis\" | \"state\",\n action: () => Promise<T>,\n): Promise<T> {\n const directory = await graphStateDirectory(root);\n const file = path.join(directory, `${kind}.lock`);\n const owner = {\n kind: \"graph-lock\",\n pid: process.pid,\n createdAt: Date.now(),\n token: randomUUID(),\n };\n try {\n await writeGraphLocalFile(file, owner);\n } catch (cause: unknown) {\n if (!hasErrnoCode(cause) || cause.code !== \"EEXIST\") throw cause;\n const text = await readGraphLocalFile(file);\n let active = false;\n try {\n const existing: unknown = text === undefined ? undefined : JSON.parse(text);\n if (typeof existing !== \"object\" || existing === null || Array.isArray(existing))\n throw new Error(\"Invalid graph lock metadata.\", { cause });\n const value = existing as Record<string, unknown>;\n if (\n Object.keys(value).length !== 4 ||\n value.kind !== \"graph-lock\" ||\n typeof value.pid !== \"number\" ||\n !Number.isSafeInteger(value.pid) ||\n value.pid <= 0 ||\n typeof value.createdAt !== \"number\" ||\n !Number.isSafeInteger(value.createdAt) ||\n value.createdAt < 0 ||\n typeof value.token !== \"string\" ||\n !GRAPH_UUID.test(value.token)\n )\n throw new Error(\"Invalid graph lock metadata.\", { cause });\n try {\n process.kill(value.pid, 0);\n active = true;\n } catch (liveness: unknown) {\n if (!hasErrnoCode(liveness) || liveness.code !== \"ESRCH\") active = true;\n }\n } catch {\n // Invalid metadata is retained for manual recovery.\n }\n throw new GraphLocalStateError(\n `Project graph ${kind} lock ${active ? \"is contended\" : \"requires manual recovery\"}.`,\n active\n ? `Retry after the active worktree ${kind} operation finishes; retain its lock.`\n : `Retain and inspect .qfai/tools/state/${graphEnvironmentKey()}/${kind}.lock; remove only a confirmed abandoned worktree lock before retrying.`,\n { cause },\n );\n }\n try {\n return await action();\n } finally {\n await releaseGraphLock(file, JSON.stringify(owner));\n }\n}\n\nasync function releaseGraphLock(file: string, owner: string): Promise<void> {\n const text = await readGraphLocalFile(file);\n if (text !== owner)\n throw new GraphLocalStateError(\n \"Project graph lock ownership changed.\",\n \"Retain the lock and repair the worktree graph state before retrying.\",\n );\n await unlink(file);\n}\n","import { lstat, mkdir, open } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { isEnoent } from \"../fs/errno.js\";\nimport { readPinnedRegularFileBytes } from \"../init/fsGuards.js\";\nimport { graphEnvironmentKey } from \"./layout.js\";\nimport { assertGraphStoragePath } from \"./storage.js\";\n\nexport const GRAPH_STATE_BYTES = 32768;\nexport const GRAPH_UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;\n\nexport class GraphLocalStateError extends Error {\n constructor(\n message: string,\n readonly recovery: string,\n options?: ErrorOptions,\n ) {\n super(message, options);\n }\n}\n\nexport async function graphStateDirectory(root: string): Promise<string> {\n const directory = path.join(root, \".qfai\", \"tools\", \"state\", graphEnvironmentKey());\n await assertGraphStoragePath(root, directory);\n await mkdir(directory, { recursive: true });\n await assertGraphStoragePath(root, directory);\n return directory;\n}\n\nexport function invalidGraphState(): GraphLocalStateError {\n return new GraphLocalStateError(\n \"Project graph permission state is invalid.\",\n \"Retain the local state and repair .qfai/tools/state before retrying the graph CLI or hook.\",\n );\n}\n\nexport function graphStateText(value: unknown, maximum: number): value is string {\n return (\n typeof value === \"string\" &&\n value.trim().length > 0 &&\n value.length <= maximum &&\n !value.includes(\"\\0\")\n );\n}\n\nexport async function readGraphLocalFile(file: string): Promise<string | undefined> {\n try {\n const before = await lstat(file);\n if (!before.isFile() || before.isSymbolicLink() || before.nlink !== 1)\n throw invalidGraphState();\n const pinned = await readPinnedRegularFileBytes(file, GRAPH_STATE_BYTES);\n const after = await lstat(file);\n if (\n !pinned ||\n before.dev !== pinned.dev ||\n before.ino !== pinned.ino ||\n after.dev !== pinned.dev ||\n after.ino !== pinned.ino ||\n !after.isFile() ||\n after.isSymbolicLink() ||\n after.nlink !== 1\n )\n throw invalidGraphState();\n return pinned.content.toString(\"utf8\");\n } catch (cause: unknown) {\n if (isEnoent(cause)) return undefined;\n throw cause;\n }\n}\n\nexport async function writeGraphLocalFile(file: string, value: unknown): Promise<void> {\n const text = JSON.stringify(value);\n if (Buffer.byteLength(text) > GRAPH_STATE_BYTES) throw invalidGraphState();\n const handle = await open(file, \"wx\", 0o600);\n try {\n await handle.writeFile(text, \"utf8\");\n } finally {\n await handle.close();\n }\n}\n","import { constants } from \"node:fs\";\nimport type { Stats } from \"node:fs\";\nimport { access, lstat, open, readFile, stat } from \"node:fs/promises\";\nimport type { FileHandle } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nimport { isEnoent } from \"../fs/errno.js\";\n\n/**\n * The first component of `target` at or below `destRoot` that is a symbolic\n * link, or `null` when every one of them is an ordinary directory or file.\n */\nexport async function firstLinkedComponent(\n target: string,\n destRoot: string,\n): Promise<string | null> {\n const relative = path.relative(destRoot, target);\n let walked = destRoot;\n for (const segment of relative.split(path.sep)) {\n walked = path.join(walked, segment);\n const entry = await lstat(walked).catch(() => null);\n if (entry?.isSymbolicLink() === true) return walked;\n }\n return null;\n}\n\n/** File contents, or `null` when nothing is there. Other read faults throw. */\nexport async function readTextFileIfPresent(target: string): Promise<string | null> {\n try {\n return await readFile(target, \"utf-8\");\n } catch (err: unknown) {\n if (isEnoent(err)) {\n return null;\n }\n throw err;\n }\n}\n\nexport async function exists(target: string): Promise<boolean> {\n try {\n await access(target);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * The bytes of a regular file no larger than `maxBytes`, read from the inode\n * the size was measured on, or `null` when the entry is not one.\n *\n * **The ceiling binds the entry that is read**, not the one a previous\n * `lstat` saw. Those are two pathname operations, and between them another\n * process can replace the path with a huge file or a FIFO — a bound checked on\n * the old inode does not bind the new one, and the read then exhausted memory\n * or never returned. One `open`, `fstat` on that handle, a bounded read from\n * it.\n *\n * A read fault is thrown rather than answered `null`: an ACL or a transient\n * `EIO` says the content could not be checked, and reporting that as \"not a\n * bounded regular file\" is a decision nobody made.\n */\nexport async function readPinnedRegularFile(\n filePath: string,\n maxBytes: number,\n): Promise<string | null> {\n let handle: FileHandle | undefined;\n try {\n handle = await open(filePath, OPEN_READ_FLAGS);\n const pinned = await handle.stat();\n if (!pinned.isFile() || pinned.size > maxBytes) {\n return null;\n }\n // Read to the end, not once: `read` may return fewer bytes than asked for,\n // and the unfilled tail stayed NUL — a correct flattened wrapper then\n // failed its own signature comparison and was left in place.\n //\n // And to `maxBytes + 1`, not to the size just measured. Another process\n // holding this inode from before the rename can append after the `fstat`,\n // and stopping at the old size read a **prefix** — which still matched the\n // target, so the repair went ahead and the cleanup deleted the sidecar with\n // the appended bytes in it. One byte past the ceiling is what distinguishes\n // \"this is the whole file\" from \"this is as much as I asked for\".\n const buffer = Buffer.alloc(maxBytes + 1);\n let filled = 0;\n while (filled < buffer.length) {\n const { bytesRead } = await handle.read(buffer, filled, buffer.length - filled, filled);\n if (bytesRead === 0) break;\n filled += bytesRead;\n }\n if (filled > maxBytes) return null;\n return buffer.subarray(0, filled).toString(\"utf-8\");\n } catch (error: unknown) {\n const code = (error as NodeJS.ErrnoException | null)?.code;\n // `ENXIO` is what `O_NONBLOCK` returns for a FIFO with no writer, in place\n // of blocking. Neither it nor a directory is a bounded regular file, and\n // `open` is simply where that shows up instead of `fstat`.\n if (code === \"ENXIO\" || code === \"EISDIR\") return null;\n throw error;\n } finally {\n await handle?.close();\n }\n}\n\n/**\n * One bounded read of a regular file: its bytes, and everything a replacement\n * has to put back.\n *\n * `mode`, `uid` and `gid` because an atomic replace writes a **new** inode;\n * `dev` and `ino` so the replacement can tell it is still about to replace the\n * file it read.\n */\nexport type PinnedFileRead = {\n content: Buffer;\n mode: number;\n uid: number;\n gid: number;\n dev: number;\n ino: number;\n};\n\n/**\n * The same read, returning the bytes.\n *\n * The restore copy writes back what it read, and decoding as UTF-8 first\n * replaces every invalid sequence with U+FFFD — irreversibly, since the sidecar\n * is removed straight after.\n *\n * `dev` / `ino` come off the same handle as the content, so a caller that\n * replaces the pathname afterwards can check that the entry it is about to\n * replace is still the inode it read.\n */\nexport async function readPinnedRegularFileBytes(\n filePath: string,\n maxBytes: number,\n): Promise<PinnedFileRead | null> {\n let handle: FileHandle | undefined;\n try {\n handle = await open(filePath, OPEN_READ_FLAGS);\n const pinned = await handle.stat();\n if (!pinned.isFile() || pinned.size > maxBytes) return null;\n const buffer = Buffer.alloc(maxBytes + 1);\n let filled = 0;\n while (filled < buffer.length) {\n const { bytesRead } = await handle.read(buffer, filled, buffer.length - filled, filled);\n if (bytesRead === 0) break;\n filled += bytesRead;\n }\n if (filled > maxBytes) return null;\n // The metadata comes from this `fstat`, not from a separate `stat` on the\n // pathname. Two operations could land on two inodes: content read from a\n // replacement that somebody made `0600` for a reason, restored under the\n // `0644` the old entry carried, and readable by everyone.\n return {\n content: Buffer.from(buffer.subarray(0, filled)),\n mode: pinned.mode & 0o7777,\n uid: pinned.uid,\n gid: pinned.gid,\n dev: pinned.dev,\n ino: pinned.ino,\n };\n } catch (error: unknown) {\n const code = (error as NodeJS.ErrnoException | null)?.code;\n if (code === \"ENXIO\" || code === \"EISDIR\") return null;\n throw error;\n } finally {\n await handle?.close();\n }\n}\n\n/**\n * Read-only, non-blocking where the platform defines it.\n *\n * Opening a FIFO for reading blocks until a writer appears, and the point of a\n * size check is not to be at the mercy of what is at the path. Windows has no\n * `O_NONBLOCK`, and no FIFOs in this sense either.\n */\nconst OPEN_READ_FLAGS =\n typeof constants.O_NONBLOCK === \"number\"\n ? constants.O_RDONLY | constants.O_NONBLOCK\n : constants.O_RDONLY;\n\n/** Message text for an unknown thrown value, without `[object Object]`. */\nexport function describeError(err: unknown): string {\n return err instanceof Error ? err.message : JSON.stringify(err);\n}\n\nexport function isEpermOnWindows(err: unknown, platform = process.platform): boolean {\n return (\n platform === \"win32\" &&\n typeof err === \"object\" &&\n err !== null &&\n \"code\" in err &&\n (err as { code: string }).code === \"EPERM\"\n );\n}\n\nexport async function safeLstat(target: string): Promise<Stats | undefined> {\n try {\n return await lstat(target);\n } catch {\n return undefined;\n }\n}\n\nasync function safeStat(target: string): Promise<Stats | undefined> {\n try {\n return await stat(target);\n } catch {\n return undefined;\n }\n}\n\n/**\n * A path component init must not write through, relative to the project, and\n * whether it is a symlink (a junction included) or not a directory.\n */\nexport type UnsafeComponent = { readonly relativePath: string; readonly symlink: boolean };\n\n/**\n * The first component of `relativeDir` under `destRoot` that must not be\n * written through, or `undefined` when the whole chain is safe.\n *\n * `.codex/agents` is a path an untrusted repository controls, and a directory\n * component of it can be a symlink out of the tree — a checked-in\n * `.codex/agents -> /home/user/.config` is enough. `mkdir` follows it,\n * `writeFile` follows it, and `removeSymlinkAt` cannot see it: that guard\n * looks at the leaf `<name>.toml` only. A plain `qfai init` would then write\n * every profile into that external directory, and `--force` would let it\n * delete the orphan profiles there. So every component is `lstat`-ed before\n * anything is written or removed, and one link anywhere in the chain skips the\n * step whole rather than writing part of it somewhere unexpected.\n *\n * A component that does not exist yet ends the walk: `mkdir` creates real\n * directories, and nothing below an absent parent can exist either.\n *\n * The answer names the component by its path relative to `destRoot`. An\n * absolute path carries the destination directory's own name, which on an\n * untrusted repository can hold a newline or an ANSI escape.\n */\nexport async function findUnsafeWrapperComponent(\n destRoot: string,\n relativeDir: string,\n): Promise<UnsafeComponent | undefined> {\n const segments = relativeDir.split(\"/\");\n for (let depth = 1; depth <= segments.length; depth += 1) {\n const relativePath = segments.slice(0, depth).join(\"/\");\n const stats = await safeLstat(path.join(destRoot, ...segments.slice(0, depth)));\n if (stats === undefined) {\n return undefined;\n }\n if (stats.isSymbolicLink()) {\n return { relativePath, symlink: true };\n }\n if (!stats.isDirectory()) {\n return { relativePath, symlink: false };\n }\n }\n return undefined;\n}\n\n/**\n * The first component of `relativeDir` under `destRoot` that `mkdir` cannot\n * pass: a symbolic link whose target is missing or is not a directory, or an\n * entry that is not a directory. A link to a directory that exists is passed,\n * because the instruction files are written through a shared directory on\n * purpose. `undefined` when the directory can be created or already exists.\n */\nexport async function findUnreachableHostDirComponent(\n destRoot: string,\n relativeDir: string,\n): Promise<UnsafeComponent | undefined> {\n const segments = relativeDir.split(\"/\");\n for (let depth = 1; depth <= segments.length; depth += 1) {\n const relativePath = segments.slice(0, depth).join(\"/\");\n const absolute = path.join(destRoot, ...segments.slice(0, depth));\n const stats = await safeLstat(absolute);\n if (stats === undefined) {\n return undefined;\n }\n if (stats.isSymbolicLink()) {\n if ((await safeStat(absolute))?.isDirectory() !== true) {\n return { relativePath, symlink: true };\n }\n } else if (!stats.isDirectory()) {\n return { relativePath, symlink: false };\n }\n }\n return undefined;\n}\n\n/**\n * The component that keeps a file init writes into a host directory, such as\n * a hook file or `.github/copilot-instructions.md`, from being read or\n * written: a directory on its path that is a symbolic link or not a directory,\n * or the file itself when it is a symbolic link, whether its target exists or\n * not. `undefined` when the path is safe.\n */\nexport async function findUnsafeHostFileComponent(\n destRoot: string,\n segments: readonly string[],\n): Promise<UnsafeComponent | undefined> {\n const parent = segments.slice(0, -1).join(\"/\");\n const unsafeParent =\n parent === \"\" ? undefined : await findUnsafeWrapperComponent(destRoot, parent);\n if (unsafeParent !== undefined) {\n return unsafeParent;\n }\n const leaf = await safeLstat(path.join(destRoot, ...segments));\n return leaf?.isSymbolicLink() === true\n ? { relativePath: segments.join(\"/\"), symlink: true }\n : undefined;\n}\n","import {\n GRAPH_PYTHON_FLAGS,\n codegraphEnvironment,\n graphifyCorpusEnvironment,\n runGraphProcess,\n type GraphProcess,\n} from \"./process.js\";\nimport { inspectCodeCoverage, inspectCurrentCodeAnalysis } from \"./analysis.js\";\nimport { graphAnalysisRoot, graphRuntimePaths } from \"./layout.js\";\nimport { readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { findUnsafeHostFileComponent } from \"../init/fsGuards.js\";\nimport { inspectDocumentScope, readGraphProcessing } from \"./documents.js\";\n\nexport interface GraphQuestion {\n domain: \"code\" | \"documents\";\n question: string;\n}\n\nexport interface GraphAnswer {\n requestedScope: Readonly<GraphQuestion>;\n engine: \"codegraph\" | \"graphify\";\n status: \"answered\" | \"not-ready\" | \"failed\" | \"no-match\" | \"incomplete\";\n coverage?: {\n unsupported: string[];\n unreadable: string[];\n unparsed?: string[];\n complete?: boolean;\n };\n answer?: string;\n failure?: string;\n inferenceNotice?: string;\n recovery?: string;\n}\n\nexport async function readKnownGraphFile(root: string, relative: string): Promise<string> {\n const parts = relative.split(/[\\\\/]/);\n if (\n path.isAbsolute(relative) ||\n parts.some((part) => part === \"..\" || part === \"\" || part === \".\") ||\n (await findUnsafeHostFileComponent(root, parts))\n ) {\n throw new Error(\"Use an exact known source file inside the project.\");\n }\n return readFile(path.join(root, ...parts), \"utf8\");\n}\n\nexport async function continueGraphExploration(\n root: string,\n previous: GraphAnswer,\n unresolved: GraphQuestion,\n run: GraphProcess = runGraphProcess,\n): Promise<GraphAnswer> {\n const nextEngine = unresolved.domain === \"code\" ? \"codegraph\" : \"graphify\";\n if (\n previous.status !== \"answered\" ||\n previous.engine === nextEngine ||\n unresolved.question.trim() === \"\"\n ) {\n throw new Error(\n \"State the unresolved question in the other domain after an answered graph query.\",\n );\n }\n return exploreGraph(root, unresolved, run);\n}\n\nexport async function exploreGraph(\n root: string,\n request: GraphQuestion,\n run: GraphProcess = runGraphProcess,\n): Promise<GraphAnswer> {\n const requestedScope = Object.freeze({ ...request });\n try {\n return { ...(await exploreGraphScope(root, request, run)), requestedScope };\n } catch {\n const engine = request.domain === \"code\" ? \"codegraph\" : \"graphify\";\n return {\n requestedScope,\n engine,\n status: \"failed\",\n failure: `${engine === \"codegraph\" ? \"CodeGraph\" : \"Graphify\"} operation failed.`,\n recovery: `Repair ${engine === \"codegraph\" ? \"CodeGraph\" : \"Graphify\"} analysis and retry the graph query.`,\n };\n }\n}\n\nasync function exploreGraphScope(\n root: string,\n request: GraphQuestion,\n run: GraphProcess,\n): Promise<Omit<GraphAnswer, \"requestedScope\">> {\n const documentScope =\n request.domain === \"documents\" ? await inspectDocumentScope(root, run) : undefined;\n if (documentScope?.current) {\n const result = await run(\n graphRuntimePaths(root).python,\n [\n ...GRAPH_PYTHON_FLAGS,\n \"-m\",\n \"graphify\",\n \"query\",\n request.question,\n \"--graph\",\n path.toNamespacedPath(\n path.join(graphAnalysisRoot(root, \"graphify\"), \"graphify-out\", \"graph.json\"),\n ),\n ],\n {\n cwd: graphAnalysisRoot(root, \"graphify\"),\n env: graphifyCorpusEnvironment(root, graphAnalysisRoot(root, \"graphify\")),\n },\n );\n if (result.exitCode !== 0 && result.exitCode !== 4) {\n return {\n engine: \"graphify\",\n status: \"failed\",\n failure: \"Graphify query failed.\",\n recovery: \"Repair Graphify analysis and retry the graph query.\",\n };\n }\n const coverage = {\n unsupported: documentScope.unsupported,\n unreadable: documentScope.unreadable,\n };\n const inference = result.stdout.includes(\"[INFERRED]\")\n ? {\n inferenceNotice:\n \"Inferred relationships need source confirmation; they do not establish semantic correctness or complete coverage.\",\n }\n : {};\n if (coverage.unsupported.length > 0 || coverage.unreadable.length > 0) {\n return {\n engine: \"graphify\",\n status: \"incomplete\",\n answer: result.stdout,\n coverage,\n ...inference,\n recovery:\n \"Review unsupported and unreadable scope; this result does not establish absence.\",\n };\n }\n return {\n engine: \"graphify\",\n status: result.exitCode === 4 ? \"no-match\" : \"answered\",\n answer: result.stdout,\n coverage,\n ...inference,\n };\n }\n if (request.domain === \"code\" && (await inspectCurrentCodeAnalysis(root, run))) {\n const result = await run(\n process.execPath,\n [\n graphRuntimePaths(root).codegraph,\n \"context\",\n request.question,\n \"--path\",\n graphAnalysisRoot(root, \"codegraph\"),\n \"--format\",\n \"json\",\n \"--no-code\",\n ],\n {\n cwd: root,\n env: codegraphEnvironment(root),\n },\n );\n const context = nativeCodeContext(result.stdout, request.question);\n if (result.exitCode !== 0 || !context)\n return {\n engine: \"codegraph\",\n status: \"failed\",\n failure: \"CodeGraph query failed or returned unusable data.\",\n recovery: \"Repair CodeGraph analysis and retry the graph query.\",\n };\n const coverage = await inspectCodeCoverage(root, run);\n if (!coverage.complete)\n return {\n engine: \"codegraph\",\n status: \"incomplete\",\n answer: result.stdout,\n coverage,\n recovery:\n \"Review unknown, unsupported, unreadable and unparsed code scope; this result does not establish absence.\",\n };\n return {\n engine: \"codegraph\",\n status: context.empty ? \"no-match\" : \"answered\",\n answer: result.stdout,\n coverage,\n ...(context.empty\n ? {\n inferenceNotice:\n \"No match in this context search over the confirmed native code scope; this does not establish global absence.\",\n }\n : {}),\n };\n }\n return {\n engine: request.domain === \"code\" ? \"codegraph\" : \"graphify\",\n status: \"not-ready\",\n recovery:\n request.domain === \"documents\" && (await readGraphProcessing(root)) === undefined\n ? \"Select document processing in .qfai/graph-processing.json before preparing document analysis.\"\n : \"Prepare the requested graph analysis before querying it.\",\n };\n}\n\nfunction nativeCodeContext(stdout: string, question: string): { empty: boolean } | undefined {\n let value: unknown;\n try {\n value = JSON.parse(stdout);\n } catch {\n return undefined;\n }\n if (!object(value) || value.query !== question || typeof value.summary !== \"string\")\n return undefined;\n const arrays = [\"entryPoints\", \"nodes\", \"edges\", \"codeBlocks\", \"relatedFiles\"];\n if (arrays.some((key) => !Array.isArray(value[key])) || !object(value.stats)) return undefined;\n const stats = value.stats;\n const counts = [\"nodeCount\", \"edgeCount\", \"fileCount\", \"codeBlockCount\", \"totalCodeSize\"];\n if (counts.some((key) => !Number.isSafeInteger(stats[key]) || Number(stats[key]) < 0))\n return undefined;\n for (const [count, entries] of [\n [\"nodeCount\", \"nodes\"],\n [\"edgeCount\", \"edges\"],\n [\"fileCount\", \"relatedFiles\"],\n [\"codeBlockCount\", \"codeBlocks\"],\n ] as const) {\n const list = value[entries];\n if (!Array.isArray(list) || stats[count] !== list.length) return undefined;\n }\n const empty = stats.nodeCount === 0;\n if (\n empty &&\n (arrays.some((key) => Array.isArray(value[key]) && value[key].length !== 0) ||\n counts.some((key) => stats[key] !== 0))\n )\n return undefined;\n return { empty };\n}\n\nfunction object(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n","import { prepareCodeAnalysis } from \"./codePreparation.js\";\nimport { prepareDocumentAnalysisLocked } from \"./documents.js\";\nimport { withGraphLock } from \"./locks.js\";\nimport { exploreGraph, type GraphAnswer, type GraphQuestion } from \"./query.js\";\nimport { runGraphProcess, type GraphProcess } from \"./process.js\";\n\nexport async function queryPreparedGraph(\n root: string,\n request: GraphQuestion,\n run: GraphProcess = runGraphProcess,\n): Promise<GraphAnswer> {\n return withGraphLock(root, \"analysis\", async () => {\n const initial = await exploreGraph(root, request, run);\n if (initial.status !== \"not-ready\") return initial;\n const preparation =\n request.domain === \"code\"\n ? await prepareCodeAnalysis(root, run)\n : await prepareDocumentAnalysisLocked(root, run);\n if (preparation.status !== \"prepared\")\n return {\n ...initial,\n status: preparation.status === \"failed\" ? \"failed\" : \"not-ready\",\n ...(preparation.status === \"failed\"\n ? {\n failure: `${initial.engine === \"codegraph\" ? \"CodeGraph\" : \"Graphify\"} analysis preparation failed.`,\n }\n : {}),\n ...(preparation.recovery ? { recovery: preparation.recovery } : {}),\n };\n return exploreGraph(root, request, run);\n });\n}\n","import { randomUUID } from \"node:crypto\";\nimport { rename, unlink } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport {\n classifyGraphExploration,\n graphFallbackUnavailable,\n type GraphHookDecision,\n type GraphHookEvent,\n} from \"./hooks.js\";\nimport { withGraphLock } from \"./locks.js\";\nimport {\n graphStateDirectory,\n graphStateText,\n invalidGraphState,\n writeGraphLocalFile,\n} from \"./localFiles.js\";\nimport {\n fullGraphState,\n readGraphSearchRecords,\n type PendingGraphSearch,\n type GrantedGraphSearch,\n} from \"./permissionRecords.js\";\nimport { queryPreparedGraph } from \"./runner.js\";\nimport { runGraphProcess, type GraphProcess } from \"./process.js\";\nimport { assertGraphStoragePath } from \"./storage.js\";\n\nexport async function classifyStoredGraphExploration(\n root: string,\n event: GraphHookEvent,\n): Promise<GraphHookDecision> {\n const decision = classifyGraphExploration(event);\n if (decision.decision !== \"deny\" || decision.state !== \"configured\") return decision;\n if (decision.exceptionEligible === false)\n return decision.fallbackUnavailable\n ? decision\n : graphFallbackUnavailable(\n decision,\n \"The search target or operation cannot be scoped.\",\n \"Run a single search with one explicit project-relative target, then retry the denied action.\",\n );\n if (!event.cwd || !graphStateText(event.session, 4096))\n return graphFallbackUnavailable(\n decision,\n \"Observed session and worktree are required.\",\n \"Enable session and cwd in the host event, run qfai init, then retry the denied action from this project worktree.\",\n );\n if (path.resolve(event.cwd) !== path.resolve(root))\n return graphFallbackUnavailable(\n decision,\n \"The observed worktree differs from this project worktree.\",\n \"Run the denied action from this project worktree, or run qfai init in the intended worktree before retrying.\",\n );\n if (event.workdir && path.resolve(event.cwd, event.workdir) !== path.resolve(root))\n return graphFallbackUnavailable(\n decision,\n \"The requested workdir differs from this project worktree.\",\n \"Set workdir to this project worktree and retry the denied action.\",\n );\n if (!decision.target || !decision.operation || !decision.domain) return decision;\n const worktree = path.resolve(root);\n const session = event.session;\n return withGraphLock<GraphHookDecision>(root, \"state\", async () => {\n const directory = await graphStateDirectory(root);\n const records = await readGraphSearchRecords(root, directory);\n const classified = classifyGraphExploration(event, (candidate) => {\n if (candidate.decision !== \"deny\" || candidate.exceptionEligible === false) return candidate;\n const grant = records.find(\n (item) =>\n !item.draft &&\n item.record.kind === \"grant\" &&\n item.record.target === candidate.target &&\n item.record.operation === candidate.operation &&\n item.record.domain === candidate.domain &&\n item.record.worktree === worktree &&\n item.record.session === session &&\n Date.now() < item.record.expiresAt,\n );\n return grant?.record.kind === \"grant\"\n ? {\n ...candidate,\n decision: \"allow\",\n message: `AI-decided search fallback: ${grant.record.reason}`,\n }\n : candidate;\n });\n if (\n classified.decision !== \"deny\" ||\n classified.state !== \"configured\" ||\n classified.exceptionEligible === false ||\n !classified.target ||\n !classified.operation ||\n !classified.domain\n )\n return classified;\n const observed = {\n target: classified.target,\n operation: classified.operation,\n domain: classified.domain,\n worktree,\n session,\n };\n if (records.length >= 128) throw fullGraphState();\n const createdAt = Date.now();\n const pending: PendingGraphSearch = {\n ...observed,\n id: randomUUID(),\n kind: \"pending\",\n createdAt,\n expiresAt: createdAt + 600000,\n };\n await writeGraphLocalFile(path.join(directory, `${pending.id}.pending.json`), pending);\n return { ...classified, message: `${classified.message} Observed attempt: ${pending.id}.` };\n });\n}\n\nexport async function requestStoredGraphFallback(\n root: string,\n attemptId: string,\n question: string,\n reason: string,\n run: GraphProcess = runGraphProcess,\n) {\n const observed = await withGraphLock(root, \"state\", async () => {\n const directory = await graphStateDirectory(root);\n const records = await readGraphSearchRecords(root, directory);\n const pending = records.find(\n (item) => item.record.kind === \"pending\" && item.record.id === attemptId,\n );\n if (!pending || pending.record.kind !== \"pending\") throw invalidGraphState();\n return pending.record;\n });\n const graph = await queryPreparedGraph(root, { domain: observed.domain, question }, run);\n const publication = await withGraphLock(root, \"state\", async () => {\n const directory = await graphStateDirectory(root);\n const records = await readGraphSearchRecords(root, directory);\n const pending = records.find(\n (item) => item.record.kind === \"pending\" && item.record.id === attemptId,\n );\n if (!pending || JSON.stringify(pending.record) !== JSON.stringify(observed))\n throw invalidGraphState();\n if (records.length >= 128) throw fullGraphState();\n const createdAt = Date.now();\n const grant: GrantedGraphSearch = {\n ...observed,\n kind: \"grant\",\n reason,\n createdAt,\n expiresAt: createdAt + 60000,\n };\n const draft = path.join(directory, `${grant.id}.draft.json`);\n await writeGraphLocalFile(draft, grant);\n await unlink(pending.file);\n return { directory, draft, grant };\n });\n await assertGraphStoragePath(root, publication.directory);\n if (Date.now() >= publication.grant.expiresAt) throw invalidGraphState();\n await rename(\n publication.draft,\n path.join(publication.directory, `${publication.grant.id}.grant.json`),\n );\n const { target, operation, worktree, session, expiresAt } = publication.grant;\n return {\n status: \"ready\",\n permitted: true,\n domain: observed.domain,\n scope: { target, operation, worktree, session, reason, expiresAt },\n graph,\n };\n}\n","import { opendir, unlink } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport {\n GRAPH_UUID,\n graphStateText,\n invalidGraphState,\n readGraphLocalFile,\n GraphLocalStateError,\n} from \"./localFiles.js\";\n\ninterface ObservedScope {\n id: string;\n domain: \"code\" | \"documents\";\n target: string;\n operation: string;\n worktree: string;\n session: string;\n createdAt: number;\n expiresAt: number;\n}\n\nexport type PendingGraphSearch = ObservedScope & { kind: \"pending\" };\nexport type GrantedGraphSearch = ObservedScope & { kind: \"grant\"; reason: string };\nexport type GraphSearchRecord = PendingGraphSearch | GrantedGraphSearch;\nexport interface StoredGraphRecord {\n file: string;\n record: GraphSearchRecord;\n draft: boolean;\n}\n\nexport async function readGraphSearchRecords(\n root: string,\n directory: string,\n): Promise<StoredGraphRecord[]> {\n const records: StoredGraphRecord[] = [];\n const entries = await opendir(directory);\n for await (const entry of entries) {\n if (entry.name === \"state.lock\" || entry.name === \"analysis.lock\") continue;\n if (records.length >= 128) throw fullGraphState();\n const match = /^(.+)\\.(pending|grant|draft)\\.json$/.exec(entry.name);\n if (!match || !GRAPH_UUID.test(match[1] ?? \"\")) throw invalidGraphState();\n const file = path.join(directory, entry.name);\n const text = await readGraphLocalFile(file);\n if (text === undefined) throw invalidGraphState();\n let input: unknown;\n try {\n input = JSON.parse(text);\n } catch {\n throw invalidGraphState();\n }\n const record = parseGraphSearchRecord(input, root);\n if (\n !record ||\n record.id !== match[1] ||\n (match[2] === \"pending\" ? record.kind !== \"pending\" : record.kind !== \"grant\")\n )\n throw invalidGraphState();\n records.push({ file, record, draft: match[2] === \"draft\" });\n }\n const current: StoredGraphRecord[] = [];\n for (const item of records) {\n if (Date.now() >= item.record.expiresAt) await unlink(item.file);\n else current.push(item);\n }\n return current;\n}\n\nexport function fullGraphState(): GraphLocalStateError {\n return new GraphLocalStateError(\n \"Project graph permission state is full.\",\n \"Retry after pending attempts or search grants expire; retain valid worktree state.\",\n );\n}\n\nfunction parseGraphSearchRecord(input: unknown, root: string): GraphSearchRecord | undefined {\n if (typeof input !== \"object\" || input === null || Array.isArray(input)) return undefined;\n const value = input as Record<string, unknown>;\n const fields = [\n \"id\",\n \"kind\",\n \"domain\",\n \"target\",\n \"operation\",\n \"worktree\",\n \"session\",\n \"createdAt\",\n \"expiresAt\",\n ];\n if (value.kind === \"grant\") fields.push(\"reason\");\n if (\n Object.keys(value).length !== fields.length ||\n fields.some((field) => !Object.hasOwn(value, field)) ||\n typeof value.id !== \"string\" ||\n !GRAPH_UUID.test(value.id) ||\n (value.kind !== \"pending\" && value.kind !== \"grant\") ||\n (value.domain !== \"code\" && value.domain !== \"documents\") ||\n !graphStateText(value.target, 4096) ||\n !graphStateText(value.operation, 128) ||\n !graphStateText(value.worktree, 4096) ||\n value.worktree !== path.resolve(root) ||\n !graphStateText(value.session, 4096) ||\n typeof value.createdAt !== \"number\" ||\n typeof value.expiresAt !== \"number\" ||\n !Number.isSafeInteger(value.createdAt) ||\n value.createdAt < 0 ||\n value.createdAt > Date.now() ||\n !Number.isSafeInteger(value.expiresAt) ||\n value.expiresAt !== value.createdAt + (value.kind === \"pending\" ? 600000 : 60000)\n )\n return undefined;\n const scope: ObservedScope = {\n id: value.id,\n domain: value.domain,\n target: value.target,\n operation: value.operation,\n worktree: value.worktree,\n session: value.session,\n createdAt: value.createdAt,\n expiresAt: value.expiresAt,\n };\n if (value.kind === \"pending\") return { ...scope, kind: \"pending\" };\n return graphStateText(value.reason, 2048)\n ? { ...scope, kind: \"grant\", reason: value.reason }\n : undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,sBAA2B;AAC3B,IAAAC,mBAA0B;AAC1B,IAAAC,oBAAiB;;;ACFjB,qBAA2B;AAC3B,uBAAiB;AACjB,sBAA8B;AAuBvB,SAAS,qBAAqB,SAA2B;AAC9D,SAAO;AAAA,IACL,iBAAAC,QAAK,QAAQ,SAAS,gBAAgB;AAAA,IACtC,iBAAAA,QAAK,QAAQ,SAAS,mBAAmB;AAAA,IACzC,iBAAAA,QAAK,QAAQ,SAAS,sBAAsB;AAAA,EAC9C;AACF;AAWA,IAAM,wBAAwB;AAAA,EAC5B,iBAAAA,QAAK,KAAK,SAAS,WAAW;AAAA,EAC9B,iBAAAA,QAAK,KAAK,QAAQ,kBAAkB;AACtC;AAEA,SAAS,gBAAgB,WAA4B;AACnD,SAAO,sBAAsB,MAAM,CAAC,iBAAa,2BAAW,iBAAAA,QAAK,KAAK,WAAW,QAAQ,CAAC,CAAC;AAC7F;AAEO,SAAS,mBAA2B;AACzC,QAAM,OAAO;AACb,QAAM,WAAW,KAAK,WAAW,OAAO,QAAI,+BAAc,IAAI,IAAI;AAClE,QAAM,UAAU,iBAAAA,QAAK,QAAQ,QAAQ;AACrC,QAAM,aAAa,qBAAqB,OAAO;AA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EA,SAAS,aAAa,MAA2C;AAC/D,QAAM,SAAS,KAAK,CAAC;AACrB,QAAM,WAAW,KAAK,CAAC,GAAG,KAAK;AAC/B,MACG,WAAW,UAAU,WAAW,eACjC,KAAK,WAAW,KAChB,CAAC,YACD,SAAS,SAAS,SAClB,SAAS,SAAS,IAAI,KACtB,SAAS,WAAW,IAAI;AAExB,WAAO;AACT,SAAO,EAAE,QAAQ,SAAS;AAC5B;","names":["import_node_crypto","import_promises","import_node_path","path","import_promises","import_node_path","import_node_path","path","import_node_path","path","path","import_node_path","import_node_crypto","import_promises","import_node_path","import_promises","path","os","path","object","path","import_promises","import_node_crypto","import_node_crypto","import_promises","import_node_path","path","import_node_crypto","import_promises","import_node_path","import_promises","import_node_path","import_node_fs","import_promises","import_node_path","path","path","import_node_path","path","object","stringArray","import_promises","import_node_path","path","object","import_node_crypto","import_promises","import_node_path","import_promises","import_node_path","path","path"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { G as GraphProcess } from '../process-C21nTvkT.cjs';
|
|
2
|
+
|
|
3
|
+
interface GraphCliIO {
|
|
4
|
+
output(text: string): void;
|
|
5
|
+
fail(): void;
|
|
6
|
+
}
|
|
7
|
+
declare function runInstalledGraphCli(root: string, args: string[], io?: GraphCliIO, run?: GraphProcess): Promise<void>;
|
|
8
|
+
|
|
9
|
+
export { type GraphCliIO, runInstalledGraphCli };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { G as GraphProcess } from '../process-C21nTvkT.js';
|
|
2
|
+
|
|
3
|
+
interface GraphCliIO {
|
|
4
|
+
output(text: string): void;
|
|
5
|
+
fail(): void;
|
|
6
|
+
}
|
|
7
|
+
declare function runInstalledGraphCli(root: string, args: string[], io?: GraphCliIO, run?: GraphProcess): Promise<void>;
|
|
8
|
+
|
|
9
|
+
export { type GraphCliIO, runInstalledGraphCli };
|