context-mode 1.0.133 → 1.0.135

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.
@@ -23,7 +23,7 @@
23
23
  */
24
24
  import { resolve } from "node:path";
25
25
  import { homedir } from "node:os";
26
- import { createRequire } from "node:module";
26
+ import { detectPlatform, getSessionDirSegments } from "../adapters/detect.js";
27
27
  export function resolveClaudeConfigDir(env = process.env) {
28
28
  const envVal = env.CLAUDE_CONFIG_DIR;
29
29
  if (envVal && envVal.trim() !== "") {
@@ -50,34 +50,27 @@ export function resolveClaudeGlobalSettingsPath(env = process.env) {
50
50
  * adapter is non-claude — claude is already covered by entry 2).
51
51
  * 2. The claude global settings.json (always — defense in depth).
52
52
  *
53
- * Lazy import of `./adapters/detect.js` keeps this file free of any direct
54
- * adapter dependency: the detect module itself only `import type`s adapter
55
- * types at the top level (concrete adapters are loaded dynamically inside
56
- * `getAdapter()`), so a static import is safe — but we use `createRequire`
57
- * to make the dependency direction crystal clear and to avoid surprising
58
- * future maintainers who add eager adapter imports to detect.ts.
53
+ * Static import of `../adapters/detect.js` is safe detect.ts only imports
54
+ * `node:` builtins, `./types.js` (type-only), and `./client-map.js` (pure
55
+ * data). It does NOT import claude-config back, so no cycle.
56
+ *
57
+ * History: this used `createRequire(import.meta.url).resolve(...)` to lazy-
58
+ * load detect at call time. That pattern requires `require(esm)`, which is
59
+ * flag-gated on Node 22.x before 22.12 (`--experimental-require-module`).
60
+ * CI run 25877550371 on Node 22.5 silently failed every detect.* call —
61
+ * the catch block ate the error and every cross-adapter deny-policy test
62
+ * returned an empty policy list. Static import sidesteps the require(esm)
63
+ * gate entirely, so the same code works on every supported Node version
64
+ * (20.x, 22.5, 22.12+, 24+) without needing the experimental flag.
59
65
  *
60
66
  * The returned array is deduplicated and order-stable: adapter-specific path
61
67
  * first (most specific), claude global second (fallback).
62
68
  */
63
69
  export function resolveAdapterGlobalSettingsPaths(env = process.env) {
64
70
  const paths = [];
65
- // Lazy-load detect module to avoid any chance of an adapter import cycle.
66
- // `detect.ts` exports pure functions — `detectPlatform` (env-driven) and
67
- // `getSessionDirSegments` (sync map). Neither instantiates an adapter.
68
- let detected = null;
69
- let segmentsFor = null;
70
- try {
71
- const lazyRequire = createRequire(import.meta.url);
72
- const detect = lazyRequire("../adapters/detect.js");
73
- detected = detect.detectPlatform();
74
- segmentsFor = detect.getSessionDirSegments;
75
- }
76
- catch {
77
- // If detection fails for any reason, fall back to claude-only behavior.
78
- }
79
- if (detected && segmentsFor && detected.platform !== "claude-code") {
80
- const segments = segmentsFor(detected.platform);
71
+ const detected = detectPlatform();
72
+ if (detected.platform !== "claude-code") {
73
+ const segments = getSessionDirSegments(detected.platform);
81
74
  if (segments && segments.length > 0) {
82
75
  paths.push(resolve(homedir(), ...segments, "settings.json"));
83
76
  }