@principles/pd-cli 1.109.4 → 1.111.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/commands/candidate.js +1 -2
- package/dist/commands/candidate.js.map +1 -1
- package/dist/commands/diagnose.js +1 -2
- package/dist/commands/diagnose.js.map +1 -1
- package/dist/commands/pain-retry.js +1 -2
- package/dist/commands/pain-retry.js.map +1 -1
- package/dist/commands/runtime-internalization-run-once.d.ts.map +1 -1
- package/dist/commands/runtime-internalization-run-once.js +57 -2
- package/dist/commands/runtime-internalization-run-once.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +20 -31
- package/dist/index.js.map +1 -1
- package/dist/legacy/session-history-import.js +0 -19
- package/dist/legacy/session-history-import.js.map +1 -1
- package/dist/utils/production-workspace-guard.d.ts +0 -7
- package/dist/utils/production-workspace-guard.d.ts.map +1 -1
- package/dist/utils/production-workspace-guard.js +0 -11
- package/dist/utils/production-workspace-guard.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/candidate.ts +1 -1
- package/src/commands/diagnose.ts +1 -1
- package/src/commands/pain-retry.ts +1 -1
- package/src/commands/runtime-internalization-run-once.ts +68 -1
- package/src/index.ts +20 -32
- package/src/legacy/session-history-import.ts +0 -28
- package/src/utils/production-workspace-guard.ts +0 -12
- package/tests/commands/candidate-audit-repair.test.ts +0 -3
- package/tests/commands/candidate-intake.test.ts +0 -3
- package/tests/commands/candidate-internalization-backfill.test.ts +6 -9
- package/tests/commands/diagnose.test.ts +1 -4
- package/tests/commands/pain-retry.test.ts +1 -4
- package/dist/principle-tree-ledger-adapter.d.ts +0 -12
- package/dist/principle-tree-ledger-adapter.d.ts.map +0 -1
- package/dist/principle-tree-ledger-adapter.js +0 -12
- package/dist/principle-tree-ledger-adapter.js.map +0 -1
- package/src/principle-tree-ledger-adapter.ts +0 -13
package/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* pd CLI
|
|
3
|
+
* pd CLI — Principles Disciple command-line interface.
|
|
4
4
|
*
|
|
5
5
|
* Usage:
|
|
6
6
|
* pd pain record --reason <text> [--score N] [--source manual]
|
|
@@ -186,7 +186,7 @@ centralCmd
|
|
|
186
186
|
await handleCentralSync();
|
|
187
187
|
});
|
|
188
188
|
|
|
189
|
-
//
|
|
189
|
+
// ── Runtime v2 task/run commands ──────────────────────────────────────────────鈹€鈹€鈹€鈹€鈹€鈹€
|
|
190
190
|
|
|
191
191
|
const rtTaskCmd = program
|
|
192
192
|
.command('task')
|
|
@@ -221,7 +221,7 @@ rtRunCmd
|
|
|
221
221
|
await handleRunShow({ id: runId });
|
|
222
222
|
});
|
|
223
223
|
|
|
224
|
-
//
|
|
224
|
+
// ── Runtime v2 trajectory/history/context commands ────────────────────────────鈹€鈹€
|
|
225
225
|
|
|
226
226
|
const trajectoryCmd = program
|
|
227
227
|
.command('trajectory')
|
|
@@ -270,7 +270,7 @@ contextCmd
|
|
|
270
270
|
await handleContextBuild(taskId, opts);
|
|
271
271
|
});
|
|
272
272
|
|
|
273
|
-
//
|
|
273
|
+
// ── Legacy import command ──────────────────────────────────────────────────────鈹€鈹€鈹€鈹€鈹€鈹€鈹€
|
|
274
274
|
|
|
275
275
|
const legacyCmd = program
|
|
276
276
|
.command('legacy')
|
|
@@ -289,7 +289,7 @@ importCmd
|
|
|
289
289
|
await handleLegacyImportOpenClaw(opts);
|
|
290
290
|
});
|
|
291
291
|
|
|
292
|
-
//
|
|
292
|
+
// ── Diagnostician run/status commands ─────────────────────────────────────────鈹€鈹€鈹€鈹€
|
|
293
293
|
|
|
294
294
|
const diagnoseCmd = program
|
|
295
295
|
.command('diagnose')
|
|
@@ -315,19 +315,19 @@ diagnoseCmd
|
|
|
315
315
|
.option('--openclaw-local', 'Use local OpenClaw (mutually exclusive with --openclaw-gateway)')
|
|
316
316
|
.option('--openclaw-gateway', 'Use gateway OpenClaw (mutually exclusive with --openclaw-local)')
|
|
317
317
|
.option('-a, --agent <agentId>', 'Agent ID to invoke')
|
|
318
|
-
.option('--provider <name>', 'LLM provider (e.g., openrouter)
|
|
319
|
-
.option('--model <id>', 'Model ID (e.g., anthropic/claude-sonnet-4)
|
|
320
|
-
.option('--apiKeyEnv <name>', 'Env var name for API key
|
|
321
|
-
.option('--baseUrl <url>', 'Custom base URL
|
|
322
|
-
.option('--maxRetries <n>', 'Max retry attempts for LLM failures
|
|
323
|
-
.option('--timeoutMs <ms>', 'Timeout in milliseconds
|
|
318
|
+
.option('--provider <name>', 'LLM provider (e.g., openrouter) — for pi-ai, falls back to policy')
|
|
319
|
+
.option('--model <id>', 'Model ID (e.g., anthropic/claude-sonnet-4) — for pi-ai, falls back to policy')
|
|
320
|
+
.option('--apiKeyEnv <name>', 'Env var name for API key — for pi-ai, falls back to policy')
|
|
321
|
+
.option('--baseUrl <url>', 'Custom base URL — for pi-ai, falls back to policy')
|
|
322
|
+
.option('--maxRetries <n>', 'Max retry attempts for LLM failures — for pi-ai, falls back to policy', parseInt)
|
|
323
|
+
.option('--timeoutMs <ms>', 'Timeout in milliseconds — for pi-ai, falls back to policy', parseInt)
|
|
324
324
|
.option('--no-intake', 'Skip candidate intake after successful diagnosis')
|
|
325
325
|
.option('--json', 'Output raw JSON')
|
|
326
326
|
.action(async (opts) => {
|
|
327
327
|
await handleDiagnoseRun(opts);
|
|
328
328
|
});
|
|
329
329
|
|
|
330
|
-
//
|
|
330
|
+
// ── Runtime probe command (HG-01 HARD GATE) ───────────────────────────────────鈹€鈹€鈹€鈹€
|
|
331
331
|
|
|
332
332
|
const runtimeCmd = program
|
|
333
333
|
.command('runtime')
|
|
@@ -348,7 +348,7 @@ const synthCmd = runtimeCmd
|
|
|
348
348
|
|
|
349
349
|
synthCmd
|
|
350
350
|
.command('baseline')
|
|
351
|
-
.description('Run synthetic PD workload baseline (PRI-206)
|
|
351
|
+
.description('Run synthetic PD workload baseline (PRI-206) — deterministic, no LLM required')
|
|
352
352
|
.option('-w, --workspace <path>', 'Workspace directory (default: temp workspace)')
|
|
353
353
|
.option('--json', 'Output raw JSON')
|
|
354
354
|
.action(async (opts) => {
|
|
@@ -357,7 +357,7 @@ synthCmd
|
|
|
357
357
|
|
|
358
358
|
synthCmd
|
|
359
359
|
.command('flood')
|
|
360
|
-
.description('Run pain flood simulation (PRI-208)
|
|
360
|
+
.description('Run pain flood simulation (PRI-208) — deterministic dedup/stress test, no LLM required')
|
|
361
361
|
.option('-w, --workspace <path>', 'Workspace directory (default: temp workspace)')
|
|
362
362
|
.option('--json', 'Output raw JSON')
|
|
363
363
|
.option('--identical-count <n>', 'Number of identical pain signals (default: 10)', parseInt)
|
|
@@ -375,7 +375,7 @@ synthCmd
|
|
|
375
375
|
|
|
376
376
|
synthCmd
|
|
377
377
|
.command('proven-channel')
|
|
378
|
-
.description('Run MVP activation continuity baseline (PRI-240)
|
|
378
|
+
.description('Run MVP activation continuity baseline (PRI-240) — deterministic, no LLM required')
|
|
379
379
|
.option('-w, --workspace <path>', 'Workspace directory (default: temp workspace)')
|
|
380
380
|
.option('--json', 'Output raw JSON')
|
|
381
381
|
.option('--channels <channels>', 'Comma-separated channel list (prompt,code_tool_hook,defer_archive)')
|
|
@@ -418,7 +418,7 @@ const demoCmd = program
|
|
|
418
418
|
|
|
419
419
|
demoCmd
|
|
420
420
|
.command('story-a')
|
|
421
|
-
.description('Run Story A\' proven-channel demo (PRI-246)
|
|
421
|
+
.description('Run Story A\'s proven-channel demo (PRI-246) — full evidence→proposal→approval→activation→observation chain')
|
|
422
422
|
.option('-w, --workspace <path>', 'Workspace directory (default: temp workspace)')
|
|
423
423
|
.option('--json', 'Output raw JSON')
|
|
424
424
|
.option('--channels <channels>', 'Comma-separated channel list (prompt,code_tool_hook,defer_archive)')
|
|
@@ -492,19 +492,7 @@ runtimeHealthCmd
|
|
|
492
492
|
|
|
493
493
|
runtimeHealthCmd
|
|
494
494
|
.command('gfi')
|
|
495
|
-
.description('GFI workspace snapshot
|
|
496
|
-
.option('-w, --workspace <path>', 'Workspace directory')
|
|
497
|
-
.option('--json', 'Output raw JSON')
|
|
498
|
-
.action(async (opts) => {
|
|
499
|
-
await handleRuntimeGfiSnapshot({ workspace: opts.workspace, json: opts.json });
|
|
500
|
-
});
|
|
501
|
-
|
|
502
|
-
// PRI-82: pd runtime gfi snapshot 鈥?canonical operator command (alias of runtime health gfi)
|
|
503
|
-
runtimeCmd
|
|
504
|
-
.command('gfi')
|
|
505
|
-
.description('GFI workspace snapshot 鈥?active vs stale session breakdown')
|
|
506
|
-
.command('snapshot')
|
|
507
|
-
.description('GFI workspace snapshot for the operator (alias: pd runtime health gfi)')
|
|
495
|
+
.description('GFI workspace snapshot — active vs stale session breakdown')
|
|
508
496
|
.option('-w, --workspace <path>', 'Workspace directory')
|
|
509
497
|
.option('--json', 'Output raw JSON')
|
|
510
498
|
.action(async (opts) => {
|
|
@@ -656,7 +644,7 @@ const pruningCmd = runtimeCmd
|
|
|
656
644
|
|
|
657
645
|
pruningCmd
|
|
658
646
|
.command('report')
|
|
659
|
-
.description('Show pruning health report
|
|
647
|
+
.description('Show pruning health report — watch/review principle signals')
|
|
660
648
|
.option('-w, --workspace <path>', 'Workspace directory')
|
|
661
649
|
.option('--json', 'Output raw JSON')
|
|
662
650
|
.action((opts) => {
|
|
@@ -727,7 +715,7 @@ pruningCmd
|
|
|
727
715
|
});
|
|
728
716
|
});
|
|
729
717
|
|
|
730
|
-
//
|
|
718
|
+
// ── Candidate inspection commands ─────────────────────────────────────────────
|
|
731
719
|
|
|
732
720
|
const candidateCmd = program
|
|
733
721
|
.command('candidate')
|
|
@@ -831,7 +819,7 @@ candidateInternalizationCmd
|
|
|
831
819
|
await handleCandidateInternalizationBackfill({ workspace: opts.workspace, dryRun: opts.dryRun, confirm: opts.confirm, includePending: opts.includePending, json: opts.json });
|
|
832
820
|
});
|
|
833
821
|
|
|
834
|
-
//
|
|
822
|
+
// ── Artifact inspection commands ──────────────────────────────────────────────
|
|
835
823
|
|
|
836
824
|
const artifactCmd = program
|
|
837
825
|
.command('artifact')
|
|
@@ -201,31 +201,3 @@ export async function importSessionHistory(
|
|
|
201
201
|
|
|
202
202
|
return { sessionsProcessed, entriesImported };
|
|
203
203
|
}
|
|
204
|
-
|
|
205
|
-
function _buildConversationEntries(
|
|
206
|
-
assistantTurns: AssistantTurn[],
|
|
207
|
-
userTurns: UserTurn[],
|
|
208
|
-
toolCalls: ToolCall[],
|
|
209
|
-
): string {
|
|
210
|
-
// Interleave and sort by timestamp for a unified view
|
|
211
|
-
type Entry = { ts: string; role: string; text: string; toolName?: string };
|
|
212
|
-
const entries: Entry[] = [];
|
|
213
|
-
|
|
214
|
-
for (const t of assistantTurns) {
|
|
215
|
-
entries.push({ ts: t.created_at, role: 'assistant', text: t.sanitized_text });
|
|
216
|
-
}
|
|
217
|
-
for (const t of userTurns) {
|
|
218
|
-
entries.push({ ts: t.created_at, role: 'user', text: t.raw_text ?? '' });
|
|
219
|
-
}
|
|
220
|
-
for (const t of toolCalls) {
|
|
221
|
-
entries.push({
|
|
222
|
-
ts: t.created_at,
|
|
223
|
-
role: 'tool',
|
|
224
|
-
text: `${t.tool_name}: ${t.outcome}${t.error_message ? ` — ${t.error_message}` : ''}`,
|
|
225
|
-
toolName: t.tool_name,
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
entries.sort((a, b) => a.ts.localeCompare(b.ts));
|
|
230
|
-
return JSON.stringify(entries, null, 2);
|
|
231
|
-
}
|
|
@@ -173,18 +173,6 @@ export function getSafeUatWorkspacePath(): string {
|
|
|
173
173
|
return uatWorkspace;
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
/**
|
|
177
|
-
* Check if --allow-production-workspace-for-uat flag is set.
|
|
178
|
-
*
|
|
179
|
-
* This is the escape hatch for cases where the operator explicitly wants to run UAT on production.
|
|
180
|
-
* The flag must be very explicit in both name and output (as required by PRI-334).
|
|
181
|
-
*/
|
|
182
|
-
export function isProductionWorkspaceAllowed(): boolean {
|
|
183
|
-
// Check if the flag was parsed and passed through opts
|
|
184
|
-
// This will be called from command handlers after Commander parses flags
|
|
185
|
-
return false; // Placeholder; actual check depends on Commander opts
|
|
186
|
-
}
|
|
187
|
-
|
|
188
176
|
/**
|
|
189
177
|
* Format guard refusal for console output.
|
|
190
178
|
*
|
|
@@ -97,9 +97,6 @@ vi.mock('@principles/core/runtime-v2', () => ({
|
|
|
97
97
|
loadLedger: mockLoadLedger,
|
|
98
98
|
getLedgerFilePathPublic: mockGetLedgerFilePath,
|
|
99
99
|
resolveOutputLanguage: vi.fn().mockReturnValue({ outputLanguage: 'zh-CN' }),
|
|
100
|
-
}));
|
|
101
|
-
|
|
102
|
-
vi.mock('../../src/principle-tree-ledger-adapter.js', () => ({
|
|
103
100
|
PrincipleTreeLedgerAdapter: MockPrincipleTreeLedgerAdapter,
|
|
104
101
|
}));
|
|
105
102
|
|
|
@@ -71,9 +71,6 @@ vi.mock('@principles/core/runtime-v2', () => ({
|
|
|
71
71
|
CandidateIntakeError: MockCandidateIntakeError,
|
|
72
72
|
RuntimeStateManager: MockRuntimeStateManager,
|
|
73
73
|
resolveOutputLanguage: vi.fn().mockReturnValue({ outputLanguage: 'zh-CN' }),
|
|
74
|
-
}));
|
|
75
|
-
|
|
76
|
-
vi.mock('../../src/principle-tree-ledger-adapter.js', () => ({
|
|
77
74
|
PrincipleTreeLedgerAdapter: MockPrincipleTreeLedgerAdapter,
|
|
78
75
|
}));
|
|
79
76
|
|
|
@@ -17,19 +17,16 @@ vi.mock('../../src/resolve-workspace.js', () => ({
|
|
|
17
17
|
resolveWorkspaceDir: vi.fn((workspace?: string) => workspace ?? '/fake/workspace'),
|
|
18
18
|
}));
|
|
19
19
|
|
|
20
|
-
vi.mock('../../src/principle-tree-ledger-adapter.js', () => ({
|
|
21
|
-
PrincipleTreeLedgerAdapter: vi.fn().mockImplementation(function () {
|
|
22
|
-
return {
|
|
23
|
-
intake: mockIntake,
|
|
24
|
-
existsForCandidate: mockExistsForCandidate,
|
|
25
|
-
};
|
|
26
|
-
}),
|
|
27
|
-
}));
|
|
28
|
-
|
|
29
20
|
vi.mock('@principles/core/runtime-v2', async (importOriginal) => {
|
|
30
21
|
const original = await importOriginal() as Record<string, unknown>;
|
|
31
22
|
return {
|
|
32
23
|
...original,
|
|
24
|
+
PrincipleTreeLedgerAdapter: vi.fn().mockImplementation(function () {
|
|
25
|
+
return {
|
|
26
|
+
intake: mockIntake,
|
|
27
|
+
existsForCandidate: mockExistsForCandidate,
|
|
28
|
+
};
|
|
29
|
+
}),
|
|
33
30
|
RuntimeStateManager: vi.fn().mockImplementation(function (opts: Record<string, unknown>) {
|
|
34
31
|
mockRuntimeStateManagerOpts(opts);
|
|
35
32
|
return {
|
|
@@ -123,13 +123,10 @@ vi.mock('@principles/core/runtime-v2', () => {
|
|
|
123
123
|
},
|
|
124
124
|
}),
|
|
125
125
|
status: vi.fn(),
|
|
126
|
+
PrincipleTreeLedgerAdapter: MockPrincipleTreeLedgerAdapter,
|
|
126
127
|
};
|
|
127
128
|
});
|
|
128
129
|
|
|
129
|
-
vi.mock('../../src/principle-tree-ledger-adapter.js', () => ({
|
|
130
|
-
PrincipleTreeLedgerAdapter: MockPrincipleTreeLedgerAdapter,
|
|
131
|
-
}));
|
|
132
|
-
|
|
133
130
|
vi.mock('../../src/config-reader.js', () => ({
|
|
134
131
|
readOutputLanguageFromWorkspace: vi.fn().mockReturnValue({ outputLanguage: 'zh-CN' }),
|
|
135
132
|
}));
|
|
@@ -130,13 +130,10 @@ vi.mock('@principles/core/runtime-v2', () => {
|
|
|
130
130
|
redactPdConfig: vi.fn().mockImplementation((c) => c),
|
|
131
131
|
run: mockRun,
|
|
132
132
|
status: vi.fn(),
|
|
133
|
+
PrincipleTreeLedgerAdapter: MockPrincipleTreeLedgerAdapter,
|
|
133
134
|
};
|
|
134
135
|
});
|
|
135
136
|
|
|
136
|
-
vi.mock('../../src/principle-tree-ledger-adapter.js', () => ({
|
|
137
|
-
PrincipleTreeLedgerAdapter: MockPrincipleTreeLedgerAdapter,
|
|
138
|
-
}));
|
|
139
|
-
|
|
140
137
|
vi.mock('../../src/config-reader.js', () => ({
|
|
141
138
|
readOutputLanguageFromWorkspace: vi.fn().mockReturnValue({ outputLanguage: 'zh-CN' }),
|
|
142
139
|
}));
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Re-exports the canonical PrincipleTreeLedgerAdapter from @principles/core/runtime-v2.
|
|
3
|
-
*
|
|
4
|
-
* This adapter uses @principles/core's addPrincipleToLedger/loadLedger, which write to
|
|
5
|
-
* <stateDir>/principle_training_state.json (HybridLedgerStore format), matching the ledger
|
|
6
|
-
* format used by the OpenClaw plugin's pain-signal-bridge.
|
|
7
|
-
*
|
|
8
|
-
* audit/repair commands use this adapter — it ensures consistency between
|
|
9
|
-
* what intake writes and what audit/repair read back.
|
|
10
|
-
*/
|
|
11
|
-
export { PrincipleTreeLedgerAdapter, } from '@principles/core/runtime-v2';
|
|
12
|
-
//# sourceMappingURL=principle-tree-ledger-adapter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"principle-tree-ledger-adapter.d.ts","sourceRoot":"","sources":["../src/principle-tree-ledger-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,0BAA0B,GAC3B,MAAM,6BAA6B,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Re-exports the canonical PrincipleTreeLedgerAdapter from @principles/core/runtime-v2.
|
|
3
|
-
*
|
|
4
|
-
* This adapter uses @principles/core's addPrincipleToLedger/loadLedger, which write to
|
|
5
|
-
* <stateDir>/principle_training_state.json (HybridLedgerStore format), matching the ledger
|
|
6
|
-
* format used by the OpenClaw plugin's pain-signal-bridge.
|
|
7
|
-
*
|
|
8
|
-
* audit/repair commands use this adapter — it ensures consistency between
|
|
9
|
-
* what intake writes and what audit/repair read back.
|
|
10
|
-
*/
|
|
11
|
-
export { PrincipleTreeLedgerAdapter, } from '@principles/core/runtime-v2';
|
|
12
|
-
//# sourceMappingURL=principle-tree-ledger-adapter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"principle-tree-ledger-adapter.js","sourceRoot":"","sources":["../src/principle-tree-ledger-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,0BAA0B,GAC3B,MAAM,6BAA6B,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Re-exports the canonical PrincipleTreeLedgerAdapter from @principles/core/runtime-v2.
|
|
3
|
-
*
|
|
4
|
-
* This adapter uses @principles/core's addPrincipleToLedger/loadLedger, which write to
|
|
5
|
-
* <stateDir>/principle_training_state.json (HybridLedgerStore format), matching the ledger
|
|
6
|
-
* format used by the OpenClaw plugin's pain-signal-bridge.
|
|
7
|
-
*
|
|
8
|
-
* audit/repair commands use this adapter — it ensures consistency between
|
|
9
|
-
* what intake writes and what audit/repair read back.
|
|
10
|
-
*/
|
|
11
|
-
export {
|
|
12
|
-
PrincipleTreeLedgerAdapter,
|
|
13
|
-
} from '@principles/core/runtime-v2';
|