@glasstrace/sdk 1.10.2 → 1.12.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.
Files changed (91) hide show
  1. package/README.md +63 -8
  2. package/dist/async-context/index.cjs +1189 -440
  3. package/dist/async-context/index.cjs.map +1 -1
  4. package/dist/async-context/index.js +2 -2
  5. package/dist/{capture-error-BeuEXXJO.d.cts → capture-error-CRQSqKgd.d.cts} +2 -2
  6. package/dist/{capture-error-D02pzB7q.d.ts → capture-error-CqCbjoMq.d.ts} +2 -2
  7. package/dist/{chunk-OXM2BZMF.js → chunk-4YRYR32D.js} +2 -2
  8. package/dist/{chunk-XG6WR2KS.js → chunk-6NKMAKMI.js} +3 -3
  9. package/dist/{chunk-6RKS3DNA.js → chunk-BN5DVIUO.js} +1176 -424
  10. package/dist/chunk-BN5DVIUO.js.map +1 -0
  11. package/dist/{chunk-QS5RZ2TC.js → chunk-CZQN6G4I.js} +28 -22
  12. package/dist/chunk-CZQN6G4I.js.map +1 -0
  13. package/dist/{chunk-D54FMQHF.js → chunk-FFNGE5RR.js} +2 -2
  14. package/dist/{chunk-RL43PU2X.js → chunk-J3ZCVE67.js} +2 -2
  15. package/dist/{chunk-BSVWJSVX.js → chunk-KBHGPQZ2.js} +2 -2
  16. package/dist/{chunk-CIKPFJOM.js → chunk-KOYZJN6G.js} +310 -20
  17. package/dist/chunk-KOYZJN6G.js.map +1 -0
  18. package/dist/{chunk-M5GO2SSO.js → chunk-M3ZTG4P5.js} +2 -2
  19. package/dist/{chunk-UMGZJYC4.js → chunk-V75ZB4G4.js} +10 -5
  20. package/dist/chunk-V75ZB4G4.js.map +1 -0
  21. package/dist/{chunk-ZBQQXVHD.js → chunk-YIEXKQYP.js} +2 -67
  22. package/dist/chunk-YIEXKQYP.js.map +1 -0
  23. package/dist/{chunk-QVTONMVZ.js → chunk-ZIL2IY4C.js} +2 -2
  24. package/dist/cli/init.cjs +1672 -576
  25. package/dist/cli/init.cjs.map +1 -1
  26. package/dist/cli/init.js +33 -20
  27. package/dist/cli/init.js.map +1 -1
  28. package/dist/cli/mcp-add.cjs +1509 -521
  29. package/dist/cli/mcp-add.cjs.map +1 -1
  30. package/dist/cli/mcp-add.js +34 -16
  31. package/dist/cli/mcp-add.js.map +1 -1
  32. package/dist/cli/status.cjs +6 -1
  33. package/dist/cli/status.cjs.map +1 -1
  34. package/dist/cli/status.js +7 -2
  35. package/dist/cli/status.js.map +1 -1
  36. package/dist/cli/uninit.cjs +6 -1
  37. package/dist/cli/uninit.cjs.map +1 -1
  38. package/dist/cli/uninit.js +4 -4
  39. package/dist/cli/upgrade-instructions.cjs +383 -112
  40. package/dist/cli/upgrade-instructions.cjs.map +1 -1
  41. package/dist/cli/upgrade-instructions.js +72 -20
  42. package/dist/cli/upgrade-instructions.js.map +1 -1
  43. package/dist/cli/validate.cjs +1168 -422
  44. package/dist/cli/validate.cjs.map +1 -1
  45. package/dist/cli/validate.js +2 -2
  46. package/dist/{correlation-id-NAapJ5jn.d.cts → correlation-id-CFpyJsKv.d.cts} +1 -1
  47. package/dist/{correlation-id-B_K8adD6.d.ts → correlation-id-DPXyY9-3.d.ts} +1 -1
  48. package/dist/edge-entry.cjs +1197 -448
  49. package/dist/edge-entry.cjs.map +1 -1
  50. package/dist/edge-entry.d.cts +2 -2
  51. package/dist/edge-entry.d.ts +2 -2
  52. package/dist/edge-entry.js +4 -4
  53. package/dist/index.cjs +1341 -553
  54. package/dist/index.cjs.map +1 -1
  55. package/dist/{index.d-CkTf_boH.d.cts → index.d-D-jdiIPU.d.cts} +1 -1
  56. package/dist/{index.d-CkTf_boH.d.ts → index.d-D-jdiIPU.d.ts} +1 -1
  57. package/dist/index.d.cts +4 -4
  58. package/dist/index.d.ts +4 -4
  59. package/dist/index.js +14 -7
  60. package/dist/index.js.map +1 -1
  61. package/dist/middleware/index.cjs +1192 -443
  62. package/dist/middleware/index.cjs.map +1 -1
  63. package/dist/middleware/index.js +2 -2
  64. package/dist/node-entry.cjs +1329 -551
  65. package/dist/node-entry.cjs.map +1 -1
  66. package/dist/node-entry.d.cts +3 -3
  67. package/dist/node-entry.d.ts +3 -3
  68. package/dist/node-entry.js +8 -8
  69. package/dist/node-subpath.cjs +1168 -422
  70. package/dist/node-subpath.cjs.map +1 -1
  71. package/dist/node-subpath.d.cts +1 -1
  72. package/dist/node-subpath.d.ts +1 -1
  73. package/dist/node-subpath.js +3 -3
  74. package/dist/{source-map-uploader-CLYCE2TZ.js → source-map-uploader-K67LTPBG.js} +3 -3
  75. package/dist/trpc/index.cjs +1187 -438
  76. package/dist/trpc/index.cjs.map +1 -1
  77. package/dist/trpc/index.js +1 -1
  78. package/package.json +2 -2
  79. package/dist/chunk-6RKS3DNA.js.map +0 -1
  80. package/dist/chunk-CIKPFJOM.js.map +0 -1
  81. package/dist/chunk-QS5RZ2TC.js.map +0 -1
  82. package/dist/chunk-UMGZJYC4.js.map +0 -1
  83. package/dist/chunk-ZBQQXVHD.js.map +0 -1
  84. /package/dist/{chunk-OXM2BZMF.js.map → chunk-4YRYR32D.js.map} +0 -0
  85. /package/dist/{chunk-XG6WR2KS.js.map → chunk-6NKMAKMI.js.map} +0 -0
  86. /package/dist/{chunk-D54FMQHF.js.map → chunk-FFNGE5RR.js.map} +0 -0
  87. /package/dist/{chunk-RL43PU2X.js.map → chunk-J3ZCVE67.js.map} +0 -0
  88. /package/dist/{chunk-BSVWJSVX.js.map → chunk-KBHGPQZ2.js.map} +0 -0
  89. /package/dist/{chunk-M5GO2SSO.js.map → chunk-M3ZTG4P5.js.map} +0 -0
  90. /package/dist/{chunk-QVTONMVZ.js.map → chunk-ZIL2IY4C.js.map} +0 -0
  91. /package/dist/{source-map-uploader-CLYCE2TZ.js.map → source-map-uploader-K67LTPBG.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/cli/upgrade-instructions.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { isAbsolute, relative } from \"node:path\";\nimport { MCP_ENDPOINT } from \"../mcp-runtime.js\";\nimport { detectAgents } from \"../agent-detection/detect.js\";\nimport { generateInfoSection } from \"../agent-detection/configs.js\";\nimport {\n hasManagedSection,\n injectInfoSection,\n} from \"../agent-detection/inject.js\";\n\n// Declare the tsup-injected SDK version literal. Replaced at build time\n// via `define` in tsup.config.ts. Falls back to \"0.0.0-dev\" when\n// running tests under vitest (no tsup build step).\ndeclare const __SDK_VERSION__: string;\n\n/**\n * Options for {@link runUpgradeInstructions}. The CLI entry point in\n * `init.ts` wires `process.cwd()` through `resolveProjectRoot()` so\n * monorepo roots resolve to the active app directory; tests pass an\n * explicit `projectRoot` for isolation.\n */\nexport interface UpgradeInstructionsOptions {\n projectRoot: string;\n}\n\n/**\n * Result of running the upgrade-instructions command. Returned to the\n * CLI entry point so it can render output without forcing the core\n * logic to call `process.stderr.write` / `process.exit`.\n */\nexport interface UpgradeInstructionsResult {\n exitCode: number;\n /**\n * Files whose managed Glasstrace section was refreshed in place.\n * Reported as paths relative to {@link UpgradeInstructionsOptions.projectRoot}\n * so the CLI output stays portable across machines and developer\n * homes; an absolute path is returned only when the detected file\n * lives outside the resolved project root (e.g. Windsurf's global\n * config under `$HOME/.codeium/`), where a relative form would be\n * misleading.\n */\n refreshed: string[];\n /**\n * Files inspected that did not contain a managed section, and were\n * therefore left untouched. Reported so the user can verify the\n * command did not accidentally append a block to a hand-written\n * instruction file. Same path-shape rule as\n * {@link UpgradeInstructionsResult.refreshed}.\n */\n skipped: string[];\n /**\n * Soft warnings (e.g. permission errors handled internally by\n * `injectInfoSection`). One line per issue.\n */\n warnings: string[];\n /**\n * Hard errors that prevented the command from completing.\n */\n errors: string[];\n}\n\n/**\n * Refreshes the managed Glasstrace MCP section in every detected agent\n * instruction file in the project (DISC-1592 / SDK-050 §Required\n * Semantics Item 2). Idempotent and safe to re-run; the helper only\n * touches files that already contain a marker pair, so a hand-written\n * `CLAUDE.md` without a Glasstrace block is left alone.\n *\n * Multi-file projects are handled in a single run (DISC-1592 §Multi-file\n * projects): the same `detectAgents()` call that scaffolds files at\n * `init` time enumerates every detected agent, and this function\n * refreshes every file with a managed section in one pass.\n *\n * The replace-in-place behaviour works for both legacy unstamped\n * markers (pre-SDK-050) and SDK-050+ stamped markers — see\n * `findMarkerBoundaries` in `inject.ts`.\n *\n * @param options - Project root to operate on. The CLI entry point\n * resolves monorepo roots before calling this function.\n */\n/**\n * Renders an absolute file path in a form suitable for CLI output:\n * relative to `projectRoot` when the file lives inside the tree, or\n * the original absolute path otherwise. Keeps output portable for\n * normal in-tree files (`CLAUDE.md`, `.cursorrules`, `codex.md`) while\n * preserving full paths for out-of-tree targets like Windsurf's\n * global config (`$HOME/.codeium/windsurf/mcp_config.json`), where a\n * relative form (e.g. `../../../../home/.../mcp_config.json`) would\n * be harder to read than the absolute path.\n */\nfunction formatPathForOutput(filePath: string, projectRoot: string): string {\n const rel = relative(projectRoot, filePath);\n if (rel === \"\" || rel.startsWith(\"..\") || isAbsolute(rel)) {\n return filePath;\n }\n return rel;\n}\n\nexport async function runUpgradeInstructions(\n options: UpgradeInstructionsOptions,\n): Promise<UpgradeInstructionsResult> {\n const refreshed: string[] = [];\n const skipped: string[] = [];\n const warnings: string[] = [];\n const errors: string[] = [];\n\n let agents;\n try {\n agents = await detectAgents(options.projectRoot);\n } catch (err) {\n errors.push(\n `Failed to detect agents: ${err instanceof Error ? err.message : String(err)}`,\n );\n return { exitCode: 1, refreshed, skipped, warnings, errors };\n }\n\n const sdkVersion =\n typeof __SDK_VERSION__ === \"string\" ? __SDK_VERSION__ : \"0.0.0-dev\";\n\n for (const agent of agents) {\n if (agent.infoFilePath === null) {\n // Generic / gemini / windsurf, or detected agent whose info\n // file does not exist on disk — nothing to refresh.\n continue;\n }\n\n const displayPath = formatPathForOutput(\n agent.infoFilePath,\n options.projectRoot,\n );\n\n let containsSection: boolean;\n try {\n containsSection = await hasManagedSection(agent.infoFilePath);\n } catch (err) {\n // hasManagedSection swallows read errors and returns false, so\n // this branch is defensive against a future refactor.\n warnings.push(\n `Could not inspect ${displayPath}: ${err instanceof Error ? err.message : String(err)}`,\n );\n continue;\n }\n\n if (!containsSection) {\n // The agent was detected (marker file present) but the\n // instruction file has no Glasstrace managed section. Refusing\n // to inject prevents `upgrade-instructions` from accidentally\n // adding a Glasstrace block to a project that opted out.\n skipped.push(displayPath);\n continue;\n }\n\n const content = generateInfoSection(agent, MCP_ENDPOINT, sdkVersion);\n if (content === \"\") {\n // Defensive — agents whose `infoFilePath` is non-null currently\n // always render content. Belt-and-braces guard against a future\n // mismatch.\n continue;\n }\n\n try {\n await injectInfoSection(agent, content, options.projectRoot);\n refreshed.push(displayPath);\n } catch (err) {\n errors.push(\n `Failed to refresh ${displayPath}: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n }\n\n const exitCode = errors.length === 0 ? 0 : 1;\n return { exitCode, refreshed, skipped, warnings, errors };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AACA,SAAS,YAAY,gBAAgB;AAyFrC,SAAS,oBAAoB,UAAkB,aAA6B;AAC1E,QAAM,MAAM,SAAS,aAAa,QAAQ;AAC1C,MAAI,QAAQ,MAAM,IAAI,WAAW,IAAI,KAAK,WAAW,GAAG,GAAG;AACzD,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEA,eAAsB,uBACpB,SACoC;AACpC,QAAM,YAAsB,CAAC;AAC7B,QAAM,UAAoB,CAAC;AAC3B,QAAM,WAAqB,CAAC;AAC5B,QAAM,SAAmB,CAAC;AAE1B,MAAI;AACJ,MAAI;AACF,aAAS,MAAM,aAAa,QAAQ,WAAW;AAAA,EACjD,SAAS,KAAK;AACZ,WAAO;AAAA,MACL,4BAA4B,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC;AAAA,IAC9E;AACA,WAAO,EAAE,UAAU,GAAG,WAAW,SAAS,UAAU,OAAO;AAAA,EAC7D;AAEA,QAAM,aACJ,OAAsC,WAAkB;AAE1D,aAAW,SAAS,QAAQ;AAC1B,QAAI,MAAM,iBAAiB,MAAM;AAG/B;AAAA,IACF;AAEA,UAAM,cAAc;AAAA,MAClB,MAAM;AAAA,MACN,QAAQ;AAAA,IACV;AAEA,QAAI;AACJ,QAAI;AACF,wBAAkB,MAAM,kBAAkB,MAAM,YAAY;AAAA,IAC9D,SAAS,KAAK;AAGZ,eAAS;AAAA,QACP,qBAAqB,WAAW,KAAK,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC;AAAA,MACvF;AACA;AAAA,IACF;AAEA,QAAI,CAAC,iBAAiB;AAKpB,cAAQ,KAAK,WAAW;AACxB;AAAA,IACF;AAEA,UAAM,UAAU,oBAAoB,OAAO,cAAc,UAAU;AACnE,QAAI,YAAY,IAAI;AAIlB;AAAA,IACF;AAEA,QAAI;AACF,YAAM,kBAAkB,OAAO,SAAS,QAAQ,WAAW;AAC3D,gBAAU,KAAK,WAAW;AAAA,IAC5B,SAAS,KAAK;AACZ,aAAO;AAAA,QACL,qBAAqB,WAAW,KAAK,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC;AAAA,MACvF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,WAAW,OAAO,WAAW,IAAI,IAAI;AAC3C,SAAO,EAAE,UAAU,WAAW,SAAS,UAAU,OAAO;AAC1D;","names":[]}
1
+ {"version":3,"sources":["../../src/cli/upgrade-instructions.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { dirname, isAbsolute, join, relative } from \"node:path\";\nimport { MCP_ENDPOINT } from \"../mcp-runtime.js\";\nimport { detectAgents } from \"../agent-detection/detect.js\";\nimport { hasManagedSection } from \"../agent-detection/inject.js\";\nimport { injectAllTargets } from \"../agent-detection/inject-all-targets.js\";\nimport type { DetectedAgent } from \"../agent-detection/detect.js\";\n\n/**\n * Per-agent legacy destinations that may carry a pre-Wave-18 managed\n * section. Used by the upgrade-instructions opted-in gate to detect\n * users who installed via an older SDK and need their managed section\n * migrated to the Wave 18 canonical destinations.\n */\nfunction legacyDestinationsForAgent(agent: DetectedAgent): string[] {\n // Resolve legacy paths relative to the agent's detected `foundDir`\n // (the directory where `detectAgents` resolved the marker), NOT\n // against the project root. `detectAgents` walks up to the git\n // root for monorepo support, so for a project initialized in\n // `packages/api/` with a legacy `codex.md` at the git root, the\n // detected agent's `infoFilePath` is `<gitRoot>/AGENTS.md` and we\n // need the legacy `codex.md` to resolve under `<gitRoot>`, not\n // under `packages/api/` (Codex P2 review of v5).\n if (agent.infoFilePath === null) {\n return [];\n }\n switch (agent.name) {\n case \"codex\":\n // agent.infoFilePath = <foundDir>/AGENTS.md → foundDir = dirname\n return [join(dirname(agent.infoFilePath), \"codex.md\")];\n case \"cursor\":\n // agent.infoFilePath = <foundDir>/.cursor/rules/glasstrace.mdc\n // → foundDir = dirname(dirname(dirname(infoFilePath)))\n return [\n join(dirname(dirname(dirname(agent.infoFilePath))), \".cursorrules\"),\n ];\n case \"windsurf\":\n // agent.infoFilePath = <foundDir>/.windsurf/rules/glasstrace.md\n // → foundDir = dirname(dirname(dirname(infoFilePath)))\n return [\n join(\n dirname(dirname(dirname(agent.infoFilePath))),\n \".windsurfrules\",\n ),\n ];\n case \"claude\":\n case \"gemini\":\n case \"generic\":\n return [];\n }\n}\n\n/**\n * Returns true if any of the candidate file paths contains a managed\n * section. Walks each candidate via `hasManagedSection`; aggregates\n * the result.\n */\nasync function anyHasManagedSection(paths: string[]): Promise<boolean> {\n for (const p of paths) {\n if (await hasManagedSection(p)) {\n return true;\n }\n }\n return false;\n}\n\n// Declare the tsup-injected SDK version literal. Replaced at build time\n// via `define` in tsup.config.ts. Falls back to \"0.0.0-dev\" when\n// running tests under vitest (no tsup build step).\ndeclare const __SDK_VERSION__: string;\n\n/**\n * Options for {@link runUpgradeInstructions}. The CLI entry point in\n * `init.ts` wires `process.cwd()` through `resolveProjectRoot()` so\n * monorepo roots resolve to the active app directory; tests pass an\n * explicit `projectRoot` for isolation.\n */\nexport interface UpgradeInstructionsOptions {\n projectRoot: string;\n}\n\n/**\n * Result of running the upgrade-instructions command. Returned to the\n * CLI entry point so it can render output without forcing the core\n * logic to call `process.stderr.write` / `process.exit`.\n */\nexport interface UpgradeInstructionsResult {\n exitCode: number;\n /**\n * Files whose managed Glasstrace section was refreshed in place.\n * Reported as paths relative to {@link UpgradeInstructionsOptions.projectRoot}\n * so the CLI output stays portable across machines and developer\n * homes; an absolute path is returned only when the detected file\n * lives outside the resolved project root (e.g. Windsurf's global\n * config under `$HOME/.codeium/`), where a relative form would be\n * misleading.\n */\n refreshed: string[];\n /**\n * Files inspected that did not contain a managed section, and were\n * therefore left untouched. Reported so the user can verify the\n * command did not accidentally append a block to a hand-written\n * instruction file. Same path-shape rule as\n * {@link UpgradeInstructionsResult.refreshed}.\n */\n skipped: string[];\n /**\n * Soft warnings (e.g. permission errors handled internally by\n * `injectInfoSection`). One line per issue.\n */\n warnings: string[];\n /**\n * Hard errors that prevented the command from completing.\n */\n errors: string[];\n}\n\n/**\n * Refreshes the managed Glasstrace MCP section in every detected agent\n * instruction file in the project (DISC-1592 / SDK-050 §Required\n * Semantics Item 2). Idempotent and safe to re-run; the helper only\n * touches files that already contain a marker pair, so a hand-written\n * `CLAUDE.md` without a Glasstrace block is left alone.\n *\n * Multi-file projects are handled in a single run (DISC-1592 §Multi-file\n * projects): the same `detectAgents()` call that scaffolds files at\n * `init` time enumerates every detected agent, and this function\n * refreshes every file with a managed section in one pass.\n *\n * The replace-in-place behaviour works for both legacy unstamped\n * markers (pre-SDK-050) and SDK-050+ stamped markers — see\n * `findMarkerBoundaries` in `inject.ts`.\n *\n * @param options - Project root to operate on. The CLI entry point\n * resolves monorepo roots before calling this function.\n */\n/**\n * Renders an absolute file path in a form suitable for CLI output:\n * relative to `projectRoot` when the file lives inside the tree, or\n * the original absolute path otherwise. Keeps output portable for\n * normal in-tree files (`AGENTS.md`, `CLAUDE.md`, `GEMINI.md`,\n * `.cursor/rules/glasstrace.mdc`, `.windsurf/rules/glasstrace.md`, plus\n * legacy `.cursorrules` / `codex.md` / `.windsurfrules`) while\n * preserving full paths for out-of-tree targets like Windsurf's\n * global config (`$HOME/.codeium/windsurf/mcp_config.json`), where a\n * relative form (e.g. `../../../../home/.../mcp_config.json`) would\n * be harder to read than the absolute path.\n */\nfunction formatPathForOutput(filePath: string, projectRoot: string): string {\n const rel = relative(projectRoot, filePath);\n if (rel === \"\" || rel.startsWith(\"..\") || isAbsolute(rel)) {\n return filePath;\n }\n return rel;\n}\n\nexport async function runUpgradeInstructions(\n options: UpgradeInstructionsOptions,\n): Promise<UpgradeInstructionsResult> {\n const refreshed: string[] = [];\n const skipped: string[] = [];\n const warnings: string[] = [];\n const errors: string[] = [];\n\n let agents;\n try {\n agents = await detectAgents(options.projectRoot);\n } catch (err) {\n errors.push(\n `Failed to detect agents: ${err instanceof Error ? err.message : String(err)}`,\n );\n return { exitCode: 1, refreshed, skipped, warnings, errors };\n }\n\n const sdkVersion =\n typeof __SDK_VERSION__ === \"string\" ? __SDK_VERSION__ : \"0.0.0-dev\";\n\n // Track opted-in agents by identity (the agent reference itself),\n // NOT by display path. Multiple agents (notably codex + generic)\n // share the same canonical destination `AGENTS.md`; if we filtered\n // by path-collision against `skipped`, a generic skip would\n // incorrectly remove an opted-in codex from the refresh set\n // (Codex P1 review of PR #274). Identity-based tracking avoids\n // the collision.\n const optedInAgents: DetectedAgent[] = [];\n for (const agent of agents) {\n if (agent.infoFilePath === null) {\n // Detected agent with no canonical infoFilePath — nothing to\n // refresh. (Pre-Wave-18 this branch covered Gemini / Windsurf /\n // generic which had `infoFilePath: null`; Wave 18 wires all six\n // agents to a non-null canonical destination, so in practice\n // this guard is now defensive.)\n continue;\n }\n\n const displayPath = formatPathForOutput(\n agent.infoFilePath,\n options.projectRoot,\n );\n\n // Wave 18: refresh-gate semantics broadened.\n //\n // The pre-Wave-18 logic refused to inject when the canonical\n // `agent.infoFilePath` had no managed section (preserving opt-out\n // for users who deleted CLAUDE.md content). After Wave 18 the\n // canonical destinations changed (Codex `codex.md` → `AGENTS.md`;\n // Cursor `.cursorrules` → `.cursor/rules/glasstrace.mdc`; etc.),\n // so the new canonical file usually does NOT have a managed\n // section yet for legacy users — but the LEGACY file does, and\n // those users intend to migrate. Check both: the canonical 2026\n // destination AND the agent's known legacy destinations. If\n // either has a managed section the user has opted in; refresh\n // proceeds. If neither has one, the user opted out; skip.\n const legacyDestinations = legacyDestinationsForAgent(agent);\n let optedIn: boolean;\n try {\n optedIn = await anyHasManagedSection([\n agent.infoFilePath,\n ...legacyDestinations,\n ]);\n } catch (err) {\n warnings.push(\n `Could not inspect ${displayPath}: ${err instanceof Error ? err.message : String(err)}`,\n );\n continue;\n }\n\n if (!optedIn) {\n // No managed section in any known destination — user opted out\n // (or never installed). Refusing to inject prevents\n // `upgrade-instructions` from adding a Glasstrace block to a\n // project that doesn't want one.\n skipped.push(displayPath);\n continue;\n }\n\n optedInAgents.push(agent);\n }\n\n // Wave 18: refresh via `injectAllTargets` (multi-target dispatcher).\n // Surviving agents pass through this single hoisted dispatch which\n // writes to canonical 2026 destinations + AGENTS.md companion +\n // Cursor `.cursorrules` transitional fallback, deduplicating\n // AGENTS.md across agents.\n if (optedInAgents.length > 0) {\n try {\n await injectAllTargets(\n optedInAgents,\n MCP_ENDPOINT,\n sdkVersion,\n options.projectRoot,\n );\n for (const a of optedInAgents) {\n if (a.infoFilePath !== null) {\n refreshed.push(formatPathForOutput(a.infoFilePath, options.projectRoot));\n }\n }\n } catch (err) {\n errors.push(\n `Failed to refresh agent-instruction files: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n }\n\n // Codex P3 review of v4: dedupe `skipped` against `refreshed`. In\n // a legacy Codex migration, codex (canonical destination AGENTS.md)\n // and generic (also canonical destination AGENTS.md) share the same\n // path; codex's legacy `codex.md` carries the managed section so\n // codex is opted-in and refreshes AGENTS.md, while generic has no\n // managed section anywhere and is recorded in `skipped`. Without\n // this dedup the SAME path \"AGENTS.md\" appears in both `refreshed`\n // and `skipped`, contradicting itself for users and automation\n // parsing the lists. Refresh wins (the file was actually written).\n const refreshedSet = new Set(refreshed);\n const dedupedSkipped = skipped.filter((p) => !refreshedSet.has(p));\n\n const exitCode = errors.length === 0 ? 0 : 1;\n return {\n exitCode,\n refreshed,\n skipped: dedupedSkipped,\n warnings,\n errors,\n };\n}\n"],"mappings":"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","names":[]}