@principles/codex-adapter 0.4.6 → 0.4.7

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 (2) hide show
  1. package/dist/pd-hook.js +30 -4
  2. package/package.json +4 -4
package/dist/pd-hook.js CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { readFileSync } from 'node:fs';
2
+ import { readFileSync, realpathSync } from 'node:fs';
3
3
  import path from 'node:path';
4
4
  import process from 'node:process';
5
- import { pathToFileURL } from 'node:url';
5
+ import { pathToFileURL, fileURLToPath } from 'node:url';
6
6
  import { appendEventLogLine, redactTelemetryString, isRuleHostEvaluatedEventData } from '@principles/core/runtime-v2';
7
7
  import { createProductionHostRuntime, loadPdConfigForPlugin, resolveNearestPdWorkspace } from '@principles/host-runtime';
8
8
  import { CODEX_TOOL_SEMANTICS } from './tool-semantics.js';
@@ -290,6 +290,32 @@ async function main() {
290
290
  process.stdout.write(`${JSON.stringify(result.stdout)}\n`);
291
291
  process.exitCode = result.exitCode;
292
292
  }
293
- const [, entry] = process.argv;
294
- if (entry && import.meta.url === pathToFileURL(entry).href)
293
+ // PRI-892: Node resolves the main module through symlinks/junctions while
294
+ // argv[1] keeps the unresolved link path (npm/npx `.bin` shims, or a
295
+ // junctioned extensions dir), so the old raw comparison silently skipped
296
+ // main() on Windows. Try the raw URL first so an ordinary direct invocation
297
+ // never depends on a filesystem lookup succeeding, then canonicalize through
298
+ // realpath for the linked-path case.
299
+ function isMainModuleEntry() {
300
+ const [, entry] = process.argv;
301
+ if (!entry)
302
+ return false;
303
+ if (pathToFileURL(entry).href === import.meta.url)
304
+ return true;
305
+ try {
306
+ return pathToFileURL(realpathSync(entry)).href === import.meta.url;
307
+ }
308
+ catch (error) {
309
+ // rc-9: realpath is unavailable or failed, so the link cannot be verified.
310
+ // If argv[1] still names this exact file, that is the entry — run main()
311
+ // and leave a bounded diagnostic instead of the silent no-op this ticket
312
+ // exists to remove. A test runner that merely imports this module never
313
+ // satisfies it, because its argv[1] is the runner, not pd-hook.
314
+ if (path.basename(entry) !== path.basename(fileURLToPath(import.meta.url)))
315
+ return false;
316
+ process.stderr.write(`${diagnostic(`entry_identity_unverified:${errorMessage(error)}`, 'Reinstall the Codex adapter; if it repeats, report this line together with the command that invoked the hook.')}\n`);
317
+ return true;
318
+ }
319
+ }
320
+ if (isMainModuleEntry())
295
321
  void main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@principles/codex-adapter",
3
- "version": "0.4.6",
3
+ "version": "0.4.7",
4
4
  "description": "Codex CLI host adapter for Principles Disciple — implements HostAdapter interface for OpenAI Codex CLI's stdin/stdout JSON hook model (ADR-0020).",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -31,9 +31,9 @@
31
31
  "lint": "eslint \"src/**/*.ts\""
32
32
  },
33
33
  "dependencies": {
34
- "@principles/core": "^1.287.1",
35
- "@principles/host-runtime": "^0.7.7",
36
- "@principles/install-layout": "^0.2.0"
34
+ "@principles/core": "^1.287.2",
35
+ "@principles/host-runtime": "^0.7.8",
36
+ "@principles/install-layout": "^0.2.7"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/node": "^26.4.1",