@principles/codex-adapter 0.3.0 → 0.4.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/dist/pd-hook.d.ts CHANGED
@@ -5,5 +5,6 @@ export interface PdHookResult {
5
5
  exitCode: number;
6
6
  stderr: string[];
7
7
  }
8
+ export declare function annotateContextWarnings(warnings: readonly string[]): string[];
8
9
  export declare function processHookInvocation(rawStdin: string, _env?: EnvMap, cwd?: string): Promise<PdHookResult>;
9
10
  export {};
package/dist/pd-hook.js CHANGED
@@ -54,6 +54,26 @@ function diagnostic(reason, nextAction) {
54
54
  function errorMessage(error) {
55
55
  return error instanceof Error ? error.message.slice(0, MAX_DIAGNOSTIC) : 'unknown_error';
56
56
  }
57
+ /**
58
+ * PRI-780 Codex capability declaration (structured UNSUPPORTED — suspension
59
+ * semantics, revised after Codex review round 2 P1): the Codex host has no
60
+ * runtime context provider, and the "unavailable → allow" contract is
61
+ * generation-time prompt discipline, NOT a runtime-enforced invariant. Handing
62
+ * v2 rules a truthy unavailable-posture context would let a persisted rule
63
+ * evaluate context-blind and DENY tool calls that were previously suspended —
64
+ * a silent governance behavior change. Codex therefore passes NO context
65
+ * provider: the shared gate skips v2 rules with its structured
66
+ * `rule_context_v2_unavailable` warning, and this hook annotates that warning
67
+ * with the explicit host-unsupported reason before it reaches Codex stderr
68
+ * (see annotateContextWarnings — ticket option B: 明确 unsupported + 结构化
69
+ * warning, never a silent skip).
70
+ */
71
+ const CODEX_CONTEXT_UNSUPPORTED_NOTE = 'codex_runtime_context_unsupported: the Codex host provides no runtime context provider; v2 rules stay suspended on this host';
72
+ export function annotateContextWarnings(warnings) {
73
+ return warnings.map((warning) => warning.startsWith('rule_context_v2_unavailable')
74
+ ? `${warning}; ${CODEX_CONTEXT_UNSUPPORTED_NOTE}`
75
+ : warning);
76
+ }
57
77
  // Bounded governance-observation ingestion (Codex Governance Closure Slice
58
78
  // A) followed by the Slice B signal-admission pass (SPEC §12/§13): detection
59
79
  // → canonical pain → evidence promotion → one pending Diagnostician task.
@@ -163,8 +183,11 @@ export async function processHookInvocation(rawStdin, _env = process.env, cwd =
163
183
  hostKind: 'codex',
164
184
  toolSemantics: CODEX_TOOL_SEMANTICS,
165
185
  events: codexEventEmitter(path.join(resolution.workspaceDir, '.state')),
186
+ // PRI-780 (revised after Codex review round 2 P1): NO context provider —
187
+ // v2 rules stay SUSPENDED on Codex (never loaded context-blind). See
188
+ // annotateContextWarnings for the structured unsupported declaration.
166
189
  }).dispatch(event);
167
- const stderr = [...(result.warnings ?? []).slice(0, 16).map((warning) => diagnostic(warning, 'Inspect PD Workspace state and retry; the hook failed open.')), ...ingestionDiagnostics];
190
+ const stderr = [...annotateContextWarnings(result.warnings ?? []).slice(0, 16).map((warning) => diagnostic(warning, 'Inspect PD Workspace state and retry; the hook failed open.')), ...ingestionDiagnostics];
168
191
  return { stdout: adapter.encodeOutput(result, event.kind), exitCode: 0, stderr };
169
192
  }
170
193
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@principles/codex-adapter",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
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",