@principles/pd-cli 1.129.0 → 1.131.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 (39) hide show
  1. package/dist/commands/__tests__/intent-flag-wiring.test.d.ts +9 -0
  2. package/dist/commands/__tests__/intent-flag-wiring.test.d.ts.map +1 -0
  3. package/dist/commands/__tests__/intent-flag-wiring.test.js +166 -0
  4. package/dist/commands/__tests__/intent-flag-wiring.test.js.map +1 -0
  5. package/dist/commands/intent.d.ts +59 -0
  6. package/dist/commands/intent.d.ts.map +1 -0
  7. package/dist/commands/intent.js +350 -0
  8. package/dist/commands/intent.js.map +1 -0
  9. package/dist/commands/runtime-canary.d.ts.map +1 -1
  10. package/dist/commands/runtime-canary.js +10 -11
  11. package/dist/commands/runtime-canary.js.map +1 -1
  12. package/dist/commands/runtime-internalization-queue.d.ts.map +1 -1
  13. package/dist/commands/runtime-internalization-queue.js +13 -16
  14. package/dist/commands/runtime-internalization-queue.js.map +1 -1
  15. package/dist/index.js +4 -0
  16. package/dist/index.js.map +1 -1
  17. package/dist/services/__tests__/runtime-adapter-resolver.test.js +20 -12
  18. package/dist/services/__tests__/runtime-adapter-resolver.test.js.map +1 -1
  19. package/dist/services/runtime-adapter-resolver.d.ts +1 -1
  20. package/dist/services/runtime-adapter-resolver.js +3 -3
  21. package/dist/services/runtime-adapter-resolver.js.map +1 -1
  22. package/package.json +1 -1
  23. package/src/commands/__tests__/intent-flag-wiring.test.ts +197 -0
  24. package/src/commands/intent.ts +388 -0
  25. package/src/commands/runtime-canary.ts +11 -13
  26. package/src/commands/runtime-internalization-queue.ts +14 -19
  27. package/src/index.ts +6 -0
  28. package/src/services/__tests__/runtime-adapter-resolver.test.ts +20 -12
  29. package/src/services/runtime-adapter-resolver.ts +3 -3
  30. package/tests/commands/intent.test.ts +321 -0
  31. package/tests/commands/runtime-canary.test.ts +46 -36
  32. package/tests/commands/runtime-internalization-queue.test.ts +11 -24
  33. package/tests/commands/runtime-internalization-run-once.test.ts +14 -6
  34. package/dist/services/feature-flag-loader.d.ts +0 -6
  35. package/dist/services/feature-flag-loader.d.ts.map +0 -1
  36. package/dist/services/feature-flag-loader.js +0 -53
  37. package/dist/services/feature-flag-loader.js.map +0 -1
  38. package/src/services/feature-flag-loader.ts +0 -73
  39. package/tests/services/feature-flag-loader.test.ts +0 -207
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-adapter-resolver.js","sourceRoot":"","sources":["../../src/services/runtime-adapter-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,yBAAyB,EACzB,kBAAkB,EAClB,gCAAgC,EAChC,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AACpE,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AAkBjF,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IACrC,IAAI,CAA4B;IAChC,OAAO,CAAY;IACnB,UAAU,CAAU;IAE7B,YACE,OAAe,EACf,IAA+B,EAC/B,OAAsC;QAEtC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;QACpC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,EAAE,OAAO,CAAC;QAChC,IAAI,CAAC,UAAU,GAAG,OAAO,EAAE,UAAU,CAAC;IACxC,CAAC;CACF;AAkED,8EAA8E;AAE9E,MAAM,UAAU,+BAA+B,CAAC,IAA2B;IACzE,2EAA2E;IAC3E,IAAI,IAAI,CAAC,WAAW,KAAK,aAAa,EAAE,CAAC;QACvC,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC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AAU,EACR,2HAA2H;aAC9H,CACF,CAAC;QACJ,CAAC;QACD,iGAAiG;QACjG,MAAM,mBAAmB,GAIrB;YACF,WAAW,EAAE,YAAY;YACzB,YAAY,EAAE,IAAI,CAAC,YAAY;SAChC,CAAC;QACF,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YAC/B,mBAAmB,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC7C,CAAC;QACD,OAAO,IAAI,yBAAyB,CAAC,mBAAmB,CAAC,CAAC;IAC5D,CAAC;IAED,0EAA0E;IAC1E,MAAM,IAAI,KAAK,CACb,6BAA6B,IAAI,CAAC,WAAW,uDAAuD,CACrG,CAAC;AACJ,CAAC;AAKD,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,CAAC"}
1
+ {"version":3,"file":"runtime-adapter-resolver.js","sourceRoot":"","sources":["../../src/services/runtime-adapter-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,yBAAyB,EACzB,kBAAkB,EAClB,gCAAgC,EAChC,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AACjF,OAAO,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AAkBjF,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IACrC,IAAI,CAA4B;IAChC,OAAO,CAAY;IACnB,UAAU,CAAU;IAE7B,YACE,OAAe,EACf,IAA+B,EAC/B,OAAsC;QAEtC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;QACpC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI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AC,YAAY,CAAC;YACrF,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,YAAY,CAAC;QACjB,4CAA4C;QAC5C,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,IAAI,oBAAoB,CAAC,YAAY,CAAC;QAC5E,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,MAAM,IAAI,qBAAqB,CAC7B,mDAAmD,EACnD,gBAAgB,EAChB;gBACE,OAAO,EAAE,CAAC,cAAc,CAAC;gBACzB,UAAU,EACR,2HAA2H;aAC9H,CACF,CAAC;QACJ,CAAC;QACD,iGAAiG;QACjG,MAAM,mBAAmB,GAIrB;YACF,WAAW,EAAE,YAAY;YACzB,YAAY,EAAE,IAAI,CAAC,YAAY;SAChC,CAAC;QACF,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YAC/B,mBAAmB,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC7C,CAAC;QACD,OAAO,IAAI,yBAAyB,CAAC,mBAAmB,CAAC,CAAC;IAC5D,CAAC;IAED,0EAA0E;IAC1E,MAAM,IAAI,KAAK,CACb,6BAA6B,IAAI,CAAC,WAAW,uDAAuD,CACrG,CAAC;AACJ,CAAC;AAKD,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@principles/pd-cli",
3
- "version": "1.129.0",
3
+ "version": "1.131.0",
4
4
  "description": "PD CLI — Pain recording, sample management, and evolution tasks",
5
5
  "type": "module",
6
6
  "bin": {
@@ -0,0 +1,197 @@
1
+ /**
2
+ * PRI-466: pd intent — parser-level flag wiring tests.
3
+ *
4
+ * Exercises the real Commander command tree via registerIntentCommand,
5
+ * verifying option metadata and parser-level dispatch (CLI Operator Gate
6
+ * rule 7). No handler logic is invoked — actions are captured.
7
+ */
8
+
9
+ import { describe, it, expect } from 'vitest';
10
+ import { Command } from 'commander';
11
+ import { registerIntentCommand } from '../intent.js';
12
+
13
+ type ActionOptions = Record<string, unknown>;
14
+ interface CapturedAction {
15
+ opts: ActionOptions | null;
16
+ }
17
+
18
+ function attachCapture(cmd: Command, state: CapturedAction): void {
19
+ cmd.action(function captureAction(...args: unknown[]): void {
20
+ let optsArg: unknown = null;
21
+ for (let i = args.length - 1; i >= 0; i--) {
22
+ const arg = args[i];
23
+ if (arg !== null && typeof arg === 'object' && !(arg instanceof Command)) {
24
+ optsArg = arg;
25
+ break;
26
+ }
27
+ }
28
+ state.opts = optsArg && typeof optsArg === 'object' ? (optsArg as ActionOptions) : {};
29
+ });
30
+ }
31
+
32
+ function freshProgram(): Command {
33
+ const program = new Command();
34
+ program.name('pd').exitOverride();
35
+ return program;
36
+ }
37
+
38
+ function requireCmd(cmd: Command | undefined, name: string): Command {
39
+ if (cmd === undefined) {
40
+ throw new Error(`Command '${name}' not found in tree`);
41
+ }
42
+ return cmd;
43
+ }
44
+
45
+ describe('pd intent — command registration', () => {
46
+ it('registers "intent" command with "init" and "show" subcommands', () => {
47
+ const program = freshProgram();
48
+ registerIntentCommand(program);
49
+ const intentCmd = requireCmd(program.commands.find((c) => c.name() === 'intent'), 'intent');
50
+ const subNames = intentCmd.commands.map((c) => c.name());
51
+ expect(subNames).toContain('init');
52
+ expect(subNames).toContain('show');
53
+ });
54
+ });
55
+
56
+ describe('pd intent init — option metadata', () => {
57
+ it('has --workspace (-w), --force, --dry-run, --confirm, and --json options', () => {
58
+ const program = freshProgram();
59
+ registerIntentCommand(program);
60
+ const intentCmd = requireCmd(program.commands.find((c) => c.name() === 'intent'), 'intent');
61
+ const initCmd = requireCmd(intentCmd.commands.find((c) => c.name() === 'init'), 'init');
62
+
63
+ expect(initCmd.options.find((o) => o.long === '--workspace')).toBeDefined();
64
+ expect(initCmd.options.find((o) => o.long === '--workspace')?.short).toBe('-w');
65
+ expect(initCmd.options.find((o) => o.long === '--force')).toBeDefined();
66
+ expect(initCmd.options.find((o) => o.long === '--dry-run')).toBeDefined();
67
+ expect(initCmd.options.find((o) => o.long === '--confirm')).toBeDefined();
68
+ expect(initCmd.options.find((o) => o.long === '--json')).toBeDefined();
69
+ });
70
+
71
+ it('does not register --no-json or --no-force negations', () => {
72
+ const program = freshProgram();
73
+ registerIntentCommand(program);
74
+ const intentCmd = requireCmd(program.commands.find((c) => c.name() === 'intent'), 'intent');
75
+ const initCmd = requireCmd(intentCmd.commands.find((c) => c.name() === 'init'), 'init');
76
+
77
+ const noJson = initCmd.options.find((o) => o.long === '--no-json');
78
+ const noForce = initCmd.options.find((o) => o.long === '--no-force');
79
+ expect(noJson).toBeUndefined();
80
+ expect(noForce).toBeUndefined();
81
+ });
82
+ });
83
+
84
+ describe('pd intent show — option metadata', () => {
85
+ it('has --workspace (-w) and --json options, no --force', () => {
86
+ const program = freshProgram();
87
+ registerIntentCommand(program);
88
+ const intentCmd = requireCmd(program.commands.find((c) => c.name() === 'intent'), 'intent');
89
+ const showCmd = requireCmd(intentCmd.commands.find((c) => c.name() === 'show'), 'show');
90
+
91
+ expect(showCmd.options.find((o) => o.long === '--workspace')).toBeDefined();
92
+ expect(showCmd.options.find((o) => o.long === '--workspace')?.short).toBe('-w');
93
+ expect(showCmd.options.find((o) => o.long === '--json')).toBeDefined();
94
+ expect(showCmd.options.find((o) => o.long === '--force')).toBeUndefined();
95
+ });
96
+ });
97
+
98
+ describe('pd intent init — parser-level dispatch', () => {
99
+ it('parses --json as true', async () => {
100
+ const program = freshProgram();
101
+ const intentCmd = registerIntentCommand(program);
102
+ const initCmd = requireCmd(intentCmd.commands.find((c) => c.name() === 'init'), 'init');
103
+ const captured: CapturedAction = { opts: null };
104
+ attachCapture(initCmd, captured);
105
+
106
+ await program.parseAsync(['node', 'pd', 'intent', 'init', '--json']);
107
+ expect(captured.opts).not.toBeNull();
108
+ expect(captured.opts?.json).toBe(true);
109
+ });
110
+
111
+ it('parses --force as true', async () => {
112
+ const program = freshProgram();
113
+ const intentCmd = registerIntentCommand(program);
114
+ const initCmd = requireCmd(intentCmd.commands.find((c) => c.name() === 'init'), 'init');
115
+ const captured: CapturedAction = { opts: null };
116
+ attachCapture(initCmd, captured);
117
+
118
+ await program.parseAsync(['node', 'pd', 'intent', 'init', '--force']);
119
+ expect(captured.opts).not.toBeNull();
120
+ expect(captured.opts?.force).toBe(true);
121
+ });
122
+
123
+ it('parses -w as --workspace', async () => {
124
+ const program = freshProgram();
125
+ const intentCmd = registerIntentCommand(program);
126
+ const initCmd = requireCmd(intentCmd.commands.find((c) => c.name() === 'init'), 'init');
127
+ const captured: CapturedAction = { opts: null };
128
+ attachCapture(initCmd, captured);
129
+
130
+ await program.parseAsync(['node', 'pd', 'intent', 'init', '-w', '/tmp/ws']);
131
+ expect(captured.opts).not.toBeNull();
132
+ expect(captured.opts?.workspace).toBe('/tmp/ws');
133
+ });
134
+
135
+ it('defaults json and force to undefined when not passed', async () => {
136
+ const program = freshProgram();
137
+ const intentCmd = registerIntentCommand(program);
138
+ const initCmd = requireCmd(intentCmd.commands.find((c) => c.name() === 'init'), 'init');
139
+ const captured: CapturedAction = { opts: null };
140
+ attachCapture(initCmd, captured);
141
+
142
+ await program.parseAsync(['node', 'pd', 'intent', 'init']);
143
+ expect(captured.opts).not.toBeNull();
144
+ expect(captured.opts?.json).toBeUndefined();
145
+ expect(captured.opts?.force).toBeUndefined();
146
+ });
147
+
148
+ it('parses --dry-run as true', async () => {
149
+ const program = freshProgram();
150
+ const intentCmd = registerIntentCommand(program);
151
+ const initCmd = requireCmd(intentCmd.commands.find((c) => c.name() === 'init'), 'init');
152
+ const captured: CapturedAction = { opts: null };
153
+ attachCapture(initCmd, captured);
154
+
155
+ await program.parseAsync(['node', 'pd', 'intent', 'init', '--dry-run']);
156
+ expect(captured.opts).not.toBeNull();
157
+ expect(captured.opts?.dryRun).toBe(true);
158
+ });
159
+
160
+ it('parses --confirm as true', async () => {
161
+ const program = freshProgram();
162
+ const intentCmd = registerIntentCommand(program);
163
+ const initCmd = requireCmd(intentCmd.commands.find((c) => c.name() === 'init'), 'init');
164
+ const captured: CapturedAction = { opts: null };
165
+ attachCapture(initCmd, captured);
166
+
167
+ await program.parseAsync(['node', 'pd', 'intent', 'init', '--confirm']);
168
+ expect(captured.opts).not.toBeNull();
169
+ expect(captured.opts?.confirm).toBe(true);
170
+ });
171
+ });
172
+
173
+ describe('pd intent show — parser-level dispatch', () => {
174
+ it('parses --json as true', async () => {
175
+ const program = freshProgram();
176
+ const intentCmd = registerIntentCommand(program);
177
+ const showCmd = requireCmd(intentCmd.commands.find((c) => c.name() === 'show'), 'show');
178
+ const captured: CapturedAction = { opts: null };
179
+ attachCapture(showCmd, captured);
180
+
181
+ await program.parseAsync(['node', 'pd', 'intent', 'show', '--json']);
182
+ expect(captured.opts).not.toBeNull();
183
+ expect(captured.opts?.json).toBe(true);
184
+ });
185
+
186
+ it('parses -w as --workspace', async () => {
187
+ const program = freshProgram();
188
+ const intentCmd = registerIntentCommand(program);
189
+ const showCmd = requireCmd(intentCmd.commands.find((c) => c.name() === 'show'), 'show');
190
+ const captured: CapturedAction = { opts: null };
191
+ attachCapture(showCmd, captured);
192
+
193
+ await program.parseAsync(['node', 'pd', 'intent', 'show', '-w', '/tmp/ws']);
194
+ expect(captured.opts).not.toBeNull();
195
+ expect(captured.opts?.workspace).toBe('/tmp/ws');
196
+ });
197
+ });
@@ -0,0 +1,388 @@
1
+ /**
2
+ * pd intent — Owner-authored INTENT.md management (PRI-466).
3
+ *
4
+ * Subcommands:
5
+ * - init : create .principles/INTENT.md from the canonical template
6
+ * - show : display a read-only summary of INTENT.md (sections, hash, warnings)
7
+ *
8
+ * `init` is not gated by the intent_engineering flag — the Owner can
9
+ * initialise the intent doc at any time. `show` IS gated: flag-off returns
10
+ * a structured `flag_disabled` result without touching the filesystem,
11
+ * matching the Console backend contract.
12
+ *
13
+ * JSON mode is strict: --json outputs exactly one parseable JSON object on
14
+ * stdout (CLI Operator Gate rule 1). Failure paths include structured
15
+ * reason + nextAction (rule 6).
16
+ *
17
+ * ERR refs:
18
+ * - ERR-001 (no any): all types explicit
19
+ * - ERR-005 (no as bypass): no type casts on untrusted data
20
+ * - ERR-002 (graceful degradation with reason): all failure paths include
21
+ * reason + nextAction
22
+ * - ERR-009 (fail loud): missing file / flag-off surfaced explicitly
23
+ */
24
+
25
+ import * as fs from 'node:fs';
26
+ import * as path from 'node:path';
27
+ import type { Command } from 'commander';
28
+ import {
29
+ INTENT_MAX_BYTES,
30
+ INTENT_DOC_TEMPLATE,
31
+ parseIntentDocSections,
32
+ computeIntentContentHash,
33
+ validateIntentDocSections,
34
+ isFeatureEnabled,
35
+ } from '@principles/core/runtime-v2';
36
+ import type { IntentDocSections, IntentDocWarning } from '@principles/core/runtime-v2';
37
+ import { resolveWorkspaceDir } from '../resolve-workspace.js';
38
+ import { loadPdConfig, computeFlagsFromLoadResult } from '../services/pd-config-loader.js';
39
+ import { emitResult } from '../services/cli-output.js';
40
+
41
+ // ── Constants ────────────────────────────────────────────────────────────────
42
+
43
+ const INTENT_DIR = '.principles';
44
+ const INTENT_FILENAME = 'INTENT.md';
45
+
46
+ // ── Output types ─────────────────────────────────────────────────────────────
47
+
48
+ export interface IntentInitOutput {
49
+ status: 'ok' | 'skipped' | 'dry_run' | 'read_error';
50
+ path: string;
51
+ overwritten: boolean;
52
+ reason?: string;
53
+ nextAction?: string;
54
+ }
55
+
56
+ export interface IntentShowOutput {
57
+ status: 'ok' | 'flag_disabled' | 'not_found' | 'oversized' | 'read_error';
58
+ flagEnabled: boolean;
59
+ found: boolean;
60
+ path?: string;
61
+ contentHash?: string;
62
+ lastEditedAt?: string;
63
+ sections?: Record<string, string>;
64
+ warnings: IntentDocWarning[];
65
+ reason?: string;
66
+ nextAction?: string;
67
+ }
68
+
69
+ // ── Helpers ──────────────────────────────────────────────────────────────────
70
+
71
+ function getIntentFilePath(workspaceDir: string): string {
72
+ return path.join(workspaceDir, INTENT_DIR, INTENT_FILENAME);
73
+ }
74
+
75
+ function sectionsToRecord(sections: IntentDocSections): Record<string, string> {
76
+ const record: Record<string, string> = {};
77
+ if (sections.why !== undefined) { record.why = sections.why; }
78
+ if (sections.desiredOutcome !== undefined) { record.desiredOutcome = sections.desiredOutcome; }
79
+ if (sections.nonNegotiables !== undefined) { record.nonNegotiables = sections.nonNegotiables; }
80
+ if (sections.stopEscalation !== undefined) { record.stopEscalation = sections.stopEscalation; }
81
+ if (sections.currentStrategicFocus !== undefined) { record.currentStrategicFocus = sections.currentStrategicFocus; }
82
+ return record;
83
+ }
84
+
85
+ function formatIntentShowText(o: IntentShowOutput): string {
86
+ const lines: string[] = [];
87
+ lines.push(`INTENT.md — ${o.path}`);
88
+ lines.push(`Content hash: ${o.contentHash}`);
89
+ lines.push(`Last edited: ${o.lastEditedAt}`);
90
+ lines.push('');
91
+ if (o.sections) {
92
+ if (o.sections.why) { lines.push('## 1. Why'); lines.push(o.sections.why); lines.push(''); }
93
+ if (o.sections.desiredOutcome) { lines.push('## 2. Desired Outcome'); lines.push(o.sections.desiredOutcome); lines.push(''); }
94
+ if (o.sections.nonNegotiables) { lines.push('## 3. Non-negotiables'); lines.push(o.sections.nonNegotiables); lines.push(''); }
95
+ if (o.sections.stopEscalation) { lines.push('## 4. Stop / Escalation'); lines.push(o.sections.stopEscalation); lines.push(''); }
96
+ if (o.sections.currentStrategicFocus) { lines.push('## 5. Current Strategic Focus'); lines.push(o.sections.currentStrategicFocus); lines.push(''); }
97
+ }
98
+ if (o.warnings.length > 0) {
99
+ lines.push('Warnings:');
100
+ for (const w of o.warnings) {
101
+ lines.push(` [${w.code}] ${w.message}`);
102
+ }
103
+ } else {
104
+ lines.push('No warnings.');
105
+ }
106
+ return lines.join('\n');
107
+ }
108
+
109
+ // ── Handlers ─────────────────────────────────────────────────────────────────
110
+
111
+ export interface IntentInitOptions {
112
+ workspace?: string;
113
+ force?: boolean;
114
+ json?: boolean;
115
+ dryRun?: boolean;
116
+ confirm?: boolean;
117
+ }
118
+
119
+ export async function handleIntentInit(opts: IntentInitOptions): Promise<void> {
120
+ // CLI Gate rule 4: --dry-run and --confirm must be mutually exclusive.
121
+ if (opts.dryRun && opts.confirm) {
122
+ const output: IntentInitOutput = {
123
+ status: 'skipped',
124
+ path: '',
125
+ overwritten: false,
126
+ reason: 'flag_conflict',
127
+ nextAction: 'Use either --dry-run or --confirm, not both.',
128
+ };
129
+ emitResult(output, {
130
+ json: opts.json ?? false,
131
+ formatText: (o) => `Error: ${o.reason}\n→ ${o.nextAction}`,
132
+ });
133
+ process.exitCode = 1;
134
+ return;
135
+ }
136
+
137
+ // CLI Gate rule 6: workspace resolution inside try/catch so failures emit
138
+ // structured JSON with reason + nextAction instead of an uncaught stack trace.
139
+ let workspaceDir: string;
140
+ let filePath: string;
141
+ let dir: string;
142
+ try {
143
+ workspaceDir = resolveWorkspaceDir(opts.workspace);
144
+ filePath = getIntentFilePath(workspaceDir);
145
+ dir = path.dirname(filePath);
146
+ } catch (err) {
147
+ const reason = err instanceof Error ? err.message : String(err);
148
+ const output: IntentInitOutput = {
149
+ status: 'read_error',
150
+ path: '',
151
+ overwritten: false,
152
+ reason,
153
+ nextAction: 'Provide a valid --workspace <path> argument.',
154
+ };
155
+ emitResult(output, {
156
+ json: opts.json ?? false,
157
+ formatText: (o) => `Error: ${o.reason}\n→ ${o.nextAction}`,
158
+ });
159
+ process.exitCode = 1;
160
+ return;
161
+ }
162
+
163
+ // CLI Gate rule 4: state-mutating command defaults to dry-run unless --confirm.
164
+ const isDryRun = opts.dryRun === true || opts.confirm !== true;
165
+
166
+ try {
167
+ if (fs.existsSync(filePath) && !opts.force) {
168
+ const output: IntentInitOutput = {
169
+ status: 'skipped',
170
+ path: filePath,
171
+ overwritten: false,
172
+ reason: 'file_exists',
173
+ nextAction: `Use --force to overwrite: pd intent init --force --confirm --workspace "${workspaceDir}"`,
174
+ };
175
+ emitResult(output, {
176
+ json: opts.json ?? false,
177
+ formatText: (o) => `INTENT.md already exists at ${o.path}\n→ ${o.nextAction}`,
178
+ });
179
+ process.exitCode = 1;
180
+ return;
181
+ }
182
+
183
+ if (isDryRun) {
184
+ const output: IntentInitOutput = {
185
+ status: 'dry_run',
186
+ path: filePath,
187
+ overwritten: opts.force === true,
188
+ reason: 'dry_run',
189
+ nextAction: `Confirm write: pd intent init --confirm${opts.force ? ' --force' : ''} --workspace "${workspaceDir}"`,
190
+ };
191
+ emitResult(output, {
192
+ json: opts.json ?? false,
193
+ formatText: (o) => `[dry-run] Would create INTENT.md at ${o.path}${o.overwritten ? ' (overwritten)' : ''}\n→ ${o.nextAction}`,
194
+ });
195
+ return;
196
+ }
197
+
198
+ fs.mkdirSync(dir, { recursive: true });
199
+ fs.writeFileSync(filePath, INTENT_DOC_TEMPLATE, 'utf8');
200
+
201
+ const output: IntentInitOutput = {
202
+ status: 'ok',
203
+ path: filePath,
204
+ overwritten: opts.force === true,
205
+ };
206
+ emitResult(output, {
207
+ json: opts.json ?? false,
208
+ formatText: (o) => `Created INTENT.md at ${o.path}${o.overwritten ? ' (overwritten)' : ''}\nNext: edit the file to declare your project intent, then run "pd intent show".`,
209
+ });
210
+ } catch (err) {
211
+ const reason = err instanceof Error ? err.message : String(err);
212
+ // CLI Gate rule 1: route through emitResult for consistent IntentInitOutput shape.
213
+ const output: IntentInitOutput = {
214
+ status: 'read_error',
215
+ path: filePath,
216
+ overwritten: false,
217
+ reason,
218
+ nextAction: `Check filesystem permissions for ${filePath}`,
219
+ };
220
+ emitResult(output, {
221
+ json: opts.json ?? false,
222
+ formatText: (o) => `Error: ${o.reason}\n→ ${o.nextAction}`,
223
+ });
224
+ process.exitCode = 1;
225
+ }
226
+ }
227
+
228
+ export interface IntentShowOptions {
229
+ workspace?: string;
230
+ json?: boolean;
231
+ }
232
+
233
+ export async function handleIntentShow(opts: IntentShowOptions): Promise<void> {
234
+ // CLI Gate rule 6: workspace resolution inside try/catch for structured errors.
235
+ let workspaceDir: string;
236
+ try {
237
+ workspaceDir = resolveWorkspaceDir(opts.workspace);
238
+ } catch (err) {
239
+ const reason = err instanceof Error ? err.message : String(err);
240
+ const output: IntentShowOutput = {
241
+ status: 'read_error',
242
+ flagEnabled: false,
243
+ found: false,
244
+ warnings: [],
245
+ reason,
246
+ nextAction: 'Provide a valid --workspace <path> argument.',
247
+ };
248
+ emitResult(output, {
249
+ json: opts.json ?? false,
250
+ formatText: (o) => `Error: ${o.reason}\n→ ${o.nextAction}`,
251
+ });
252
+ process.exitCode = 1;
253
+ return;
254
+ }
255
+
256
+ // Flag check — flag-off short-circuits without fs access
257
+ const configResult = loadPdConfig(workspaceDir);
258
+ const flagsResult = computeFlagsFromLoadResult(configResult);
259
+ const flagEnabled = isFeatureEnabled(flagsResult, 'intent_engineering');
260
+
261
+ if (!flagEnabled) {
262
+ const output: IntentShowOutput = {
263
+ status: 'flag_disabled',
264
+ flagEnabled: false,
265
+ found: false,
266
+ warnings: [],
267
+ reason: 'flag_disabled',
268
+ nextAction: 'Enable the intent_engineering feature flag in .pd/config.yaml to read INTENT.md.',
269
+ };
270
+ emitResult(output, {
271
+ json: opts.json ?? false,
272
+ formatText: (o) => `Intent Engineering is disabled (flag off).\n→ ${o.nextAction}`,
273
+ });
274
+ return;
275
+ }
276
+
277
+ const filePath = getIntentFilePath(workspaceDir);
278
+
279
+ try {
280
+ if (!fs.existsSync(filePath)) {
281
+ const output: IntentShowOutput = {
282
+ status: 'not_found',
283
+ flagEnabled: true,
284
+ found: false,
285
+ warnings: [],
286
+ reason: 'not_found',
287
+ nextAction: `Create INTENT.md: pd intent init --workspace "${workspaceDir}"`,
288
+ };
289
+ emitResult(output, {
290
+ json: opts.json ?? false,
291
+ formatText: (o) => `INTENT.md not found.\n→ ${o.nextAction}`,
292
+ });
293
+ return;
294
+ }
295
+
296
+ const stat = fs.statSync(filePath);
297
+ if (stat.size > INTENT_MAX_BYTES) {
298
+ const output: IntentShowOutput = {
299
+ status: 'oversized',
300
+ flagEnabled: true,
301
+ found: true,
302
+ warnings: [],
303
+ reason: 'oversized',
304
+ nextAction: `INTENT.md exceeds ${INTENT_MAX_BYTES} bytes (${stat.size} bytes). Reduce content.`,
305
+ };
306
+ emitResult(output, {
307
+ json: opts.json ?? false,
308
+ formatText: (o) => `INTENT.md is too large.\n→ ${o.nextAction}`,
309
+ });
310
+ return;
311
+ }
312
+
313
+ const raw = fs.readFileSync(filePath, 'utf8');
314
+ const sections = parseIntentDocSections(raw);
315
+ const warnings = validateIntentDocSections(sections);
316
+ const contentHash = computeIntentContentHash(raw);
317
+
318
+ const output: IntentShowOutput = {
319
+ status: 'ok',
320
+ flagEnabled: true,
321
+ found: true,
322
+ path: filePath,
323
+ contentHash,
324
+ lastEditedAt: stat.mtime.toISOString(),
325
+ sections: sectionsToRecord(sections),
326
+ warnings,
327
+ };
328
+ emitResult(output, {
329
+ json: opts.json ?? false,
330
+ formatText: (o) => formatIntentShowText(o),
331
+ });
332
+ } catch (err) {
333
+ const reason = err instanceof Error ? err.message : String(err);
334
+ const output: IntentShowOutput = {
335
+ status: 'read_error',
336
+ flagEnabled: true,
337
+ found: false,
338
+ warnings: [],
339
+ reason,
340
+ nextAction: `Check filesystem permissions for ${filePath}`,
341
+ };
342
+ emitResult(output, {
343
+ json: opts.json ?? false,
344
+ formatText: (o) => `Error reading INTENT.md: ${o.reason}\n→ ${o.nextAction}`,
345
+ });
346
+ process.exitCode = 1;
347
+ }
348
+ }
349
+
350
+ // ── Command registration ─────────────────────────────────────────────────────
351
+
352
+ export function registerIntentCommand(parentCmd: Command): Command {
353
+ const intentCmd = parentCmd
354
+ .command('intent')
355
+ .description('Owner-authored INTENT.md management (init, show)');
356
+
357
+ intentCmd
358
+ .command('init')
359
+ .description('Create .principles/INTENT.md from the canonical template')
360
+ .option('-w, --workspace <path>', 'Workspace directory')
361
+ .option('--force', 'Overwrite existing INTENT.md')
362
+ .option('--dry-run', 'Show what would happen without writing (default)')
363
+ .option('--confirm', 'Actually write the file (required to create INTENT.md)')
364
+ .option('--json', 'Output raw JSON')
365
+ .action(async (opts) => {
366
+ await handleIntentInit({
367
+ workspace: opts.workspace,
368
+ force: opts.force === true,
369
+ json: opts.json === true,
370
+ dryRun: opts.dryRun === true,
371
+ confirm: opts.confirm === true,
372
+ });
373
+ });
374
+
375
+ intentCmd
376
+ .command('show')
377
+ .description('Display a read-only summary of INTENT.md (sections, hash, warnings)')
378
+ .option('-w, --workspace <path>', 'Workspace directory')
379
+ .option('--json', 'Output raw JSON')
380
+ .action(async (opts) => {
381
+ await handleIntentShow({
382
+ workspace: opts.workspace,
383
+ json: opts.json === true,
384
+ });
385
+ });
386
+
387
+ return intentCmd;
388
+ }
@@ -2,7 +2,7 @@ import * as path from 'path';
2
2
  import { OperatorHealthReadModel, SchemaConformanceReadModel, PruningReadModel, createInternalizationQueueReadModel, auditCandidateLedgerConsistency, buildGfiWorkspaceSnapshot, classifyGfiWorkspaceHealth } from '@principles/core/runtime-v2';
3
3
  import type { OperatorHealthSnapshot, SchemaConformanceResult, OrphanDetectionResult, InternalizationQueueSnapshot, GfiWorkspaceSnapshot, CandidateAuditResult } from '@principles/core/runtime-v2';
4
4
  import { resolveWorkspaceDir } from '../resolve-workspace.js';
5
- import { loadEffectiveFeatureFlags } from '../services/feature-flag-loader.js';
5
+ import { loadPdConfig, computeFlagsFromLoadResult } from '../services/pd-config-loader.js';
6
6
 
7
7
  export interface CanaryCheck {
8
8
  name: string;
@@ -60,7 +60,7 @@ function buildRecommendedActions(checks: CanaryCheck[]): string[] {
60
60
  case 'gfi_snapshot': {
61
61
  const gfiDetails = check.details as { warnings?: string[]; configPath?: string } | undefined;
62
62
  if (gfiDetails && gfiDetails.warnings && gfiDetails.warnings.length > 0) {
63
- actions.push(`Review .pd/feature-flags.yaml and rerun \`pd runtime features --workspace <path> --json\`.`);
63
+ actions.push(`Review .pd/config.yaml and rerun \`pd runtime features --workspace <path> --json\`.`);
64
64
  } else {
65
65
  actions.push('Investigate GFI sessions — consider cleanup or session lifecycle review.');
66
66
  }
@@ -100,6 +100,10 @@ function buildRecommendedActions(checks: CanaryCheck[]): string[] {
100
100
  export async function runCanaryChecks(workspaceDir: string): Promise<CanaryOutput> {
101
101
  const generatedAt = new Date().toISOString();
102
102
 
103
+ // Single canonical config load — shared across gfi_snapshot and internalization_queue checks (PRI-460).
104
+ const pdConfigResult = loadPdConfig(workspaceDir);
105
+ const pdFlags = computeFlagsFromLoadResult(pdConfigResult);
106
+
103
107
  const checkPromises: Promise<CanaryCheck>[] = [
104
108
  (async (): Promise<CanaryCheck> => {
105
109
  try {
@@ -137,15 +141,14 @@ export async function runCanaryChecks(workspaceDir: string): Promise<CanaryOutpu
137
141
  })(),
138
142
  (async (): Promise<CanaryCheck> => {
139
143
  try {
140
- const featureFlags = loadEffectiveFeatureFlags(workspaceDir);
141
- const gfiFlag = featureFlags.flags.gfi;
144
+ const gfiFlag = pdFlags.flags.gfi;
142
145
  if (!gfiFlag || !gfiFlag.enabled) {
143
- if (featureFlags.warnings.length > 0) {
146
+ if (pdFlags.warnings.length > 0) {
144
147
  return {
145
148
  name: 'gfi_snapshot',
146
149
  status: 'degraded',
147
- summary: `GFI disabled but config has warnings: ${featureFlags.warnings.join('; ')}`,
148
- details: { warnings: featureFlags.warnings, configPath: featureFlags.configPath },
150
+ summary: `GFI disabled but config has warnings: ${pdFlags.warnings.join('; ')}`,
151
+ details: { warnings: pdFlags.warnings, configPath: pdConfigResult.configPath },
149
152
  };
150
153
  }
151
154
  return {
@@ -208,12 +211,7 @@ export async function runCanaryChecks(workspaceDir: string): Promise<CanaryOutpu
208
211
  })(),
209
212
  (async (): Promise<CanaryCheck> => {
210
213
  try {
211
- const featureFlags = loadEffectiveFeatureFlags(workspaceDir);
212
- const enabledChannels = new Set(
213
- Object.values(featureFlags.flags)
214
- .filter(f => f.enabled)
215
- .map(f => f.id),
216
- );
214
+ const enabledChannels = new Set(pdFlags.enabledChannels);
217
215
  const { readModel, close } = await createInternalizationQueueReadModel({ workspaceDir, readonly: true, enabledChannels });
218
216
  try {
219
217
  const snapshot: InternalizationQueueSnapshot = await readModel.getSnapshot();