@principles/pd-cli 1.152.12 → 1.152.14
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.d.ts.map +1 -1
- package/dist/commands/candidate.js +34 -7
- package/dist/commands/candidate.js.map +1 -1
- package/dist/commands/diagnose.d.ts.map +1 -1
- package/dist/commands/diagnose.js +23 -7
- package/dist/commands/diagnose.js.map +1 -1
- package/dist/commands/pain-retry.d.ts.map +1 -1
- package/dist/commands/pain-retry.js +21 -7
- package/dist/commands/pain-retry.js.map +1 -1
- package/package.json +13 -7
- package/CHANGELOG.md +0 -23
- package/dist/commands/__tests__/intent-flag-wiring.test.d.ts +0 -9
- package/dist/commands/__tests__/intent-flag-wiring.test.d.ts.map +0 -1
- package/dist/commands/__tests__/intent-flag-wiring.test.js +0 -237
- package/dist/commands/__tests__/intent-flag-wiring.test.js.map +0 -1
- package/dist/commands/__tests__/legacy-cleanup.test.d.ts +0 -18
- package/dist/commands/__tests__/legacy-cleanup.test.d.ts.map +0 -1
- package/dist/commands/__tests__/legacy-cleanup.test.js +0 -467
- package/dist/commands/__tests__/legacy-cleanup.test.js.map +0 -1
- package/dist/commands/__tests__/mvp-smoke.test.d.ts +0 -15
- package/dist/commands/__tests__/mvp-smoke.test.d.ts.map +0 -1
- package/dist/commands/__tests__/mvp-smoke.test.js +0 -262
- package/dist/commands/__tests__/mvp-smoke.test.js.map +0 -1
- package/dist/commands/__tests__/pain-retry-maxTokens-flag.test.d.ts +0 -2
- package/dist/commands/__tests__/pain-retry-maxTokens-flag.test.d.ts.map +0 -1
- package/dist/commands/__tests__/pain-retry-maxTokens-flag.test.js +0 -60
- package/dist/commands/__tests__/pain-retry-maxTokens-flag.test.js.map +0 -1
- package/dist/commands/__tests__/rulecode-flag-wiring.test.d.ts +0 -21
- package/dist/commands/__tests__/rulecode-flag-wiring.test.d.ts.map +0 -1
- package/dist/commands/__tests__/rulecode-flag-wiring.test.js +0 -186
- package/dist/commands/__tests__/rulecode-flag-wiring.test.js.map +0 -1
- package/dist/commands/__tests__/rulecode-handler.test.d.ts +0 -16
- package/dist/commands/__tests__/rulecode-handler.test.d.ts.map +0 -1
- package/dist/commands/__tests__/rulecode-handler.test.js +0 -285
- package/dist/commands/__tests__/rulecode-handler.test.js.map +0 -1
- package/dist/commands/__tests__/run-rulehost-flag-wiring.test.d.ts +0 -24
- package/dist/commands/__tests__/run-rulehost-flag-wiring.test.d.ts.map +0 -1
- package/dist/commands/__tests__/run-rulehost-flag-wiring.test.js +0 -232
- package/dist/commands/__tests__/run-rulehost-flag-wiring.test.js.map +0 -1
- package/dist/commands/__tests__/runtime-activation-nextaction.test.d.ts +0 -15
- package/dist/commands/__tests__/runtime-activation-nextaction.test.d.ts.map +0 -1
- package/dist/commands/__tests__/runtime-activation-nextaction.test.js +0 -73
- package/dist/commands/__tests__/runtime-activation-nextaction.test.js.map +0 -1
- package/dist/commands/__tests__/runtime-probe-config.test.d.ts +0 -20
- package/dist/commands/__tests__/runtime-probe-config.test.d.ts.map +0 -1
- package/dist/commands/__tests__/runtime-probe-config.test.js +0 -389
- package/dist/commands/__tests__/runtime-probe-config.test.js.map +0 -1
- package/dist/commands/__tests__/telemetry-flag-wiring.test.d.ts +0 -9
- package/dist/commands/__tests__/telemetry-flag-wiring.test.d.ts.map +0 -1
- package/dist/commands/__tests__/telemetry-flag-wiring.test.js +0 -76
- package/dist/commands/__tests__/telemetry-flag-wiring.test.js.map +0 -1
- package/dist/commands/__tests__/version.test.d.ts +0 -2
- package/dist/commands/__tests__/version.test.d.ts.map +0 -1
- package/dist/commands/__tests__/version.test.js +0 -238
- package/dist/commands/__tests__/version.test.js.map +0 -1
- package/dist/commands/runtime-uat.guard.test.d.ts +0 -2
- package/dist/commands/runtime-uat.guard.test.d.ts.map +0 -1
- package/dist/commands/runtime-uat.guard.test.js +0 -153
- package/dist/commands/runtime-uat.guard.test.js.map +0 -1
- package/dist/services/__tests__/cli-output.test.d.ts +0 -18
- package/dist/services/__tests__/cli-output.test.d.ts.map +0 -1
- package/dist/services/__tests__/cli-output.test.js +0 -103
- package/dist/services/__tests__/cli-output.test.js.map +0 -1
- package/dist/services/__tests__/evaluator-runner-deps.test.d.ts +0 -2
- package/dist/services/__tests__/evaluator-runner-deps.test.d.ts.map +0 -1
- package/dist/services/__tests__/evaluator-runner-deps.test.js +0 -343
- package/dist/services/__tests__/evaluator-runner-deps.test.js.map +0 -1
- package/dist/services/__tests__/rulehost-readiness.test.d.ts +0 -2
- package/dist/services/__tests__/rulehost-readiness.test.d.ts.map +0 -1
- package/dist/services/__tests__/rulehost-readiness.test.js +0 -311
- package/dist/services/__tests__/rulehost-readiness.test.js.map +0 -1
- package/dist/services/__tests__/runtime-adapter-resolver.test.d.ts +0 -18
- package/dist/services/__tests__/runtime-adapter-resolver.test.d.ts.map +0 -1
- package/dist/services/__tests__/runtime-adapter-resolver.test.js +0 -673
- package/dist/services/__tests__/runtime-adapter-resolver.test.js.map +0 -1
- package/dist/utils/production-workspace-guard.test.d.ts +0 -2
- package/dist/utils/production-workspace-guard.test.d.ts.map +0 -1
- package/dist/utils/production-workspace-guard.test.js +0 -137
- package/dist/utils/production-workspace-guard.test.js.map +0 -1
- package/scripts/llm-dogfood.ts +0 -456
- package/scripts/migrate-illegal-expected-decision.ts +0 -252
- package/src/commands/__tests__/intent-flag-wiring.test.ts +0 -282
- package/src/commands/__tests__/legacy-cleanup.test.ts +0 -602
- package/src/commands/__tests__/mvp-smoke.test.ts +0 -300
- package/src/commands/__tests__/pain-retry-maxTokens-flag.test.ts +0 -73
- package/src/commands/__tests__/rulecode-flag-wiring.test.ts +0 -237
- package/src/commands/__tests__/rulecode-handler.test.ts +0 -369
- package/src/commands/__tests__/run-rulehost-flag-wiring.test.ts +0 -292
- package/src/commands/__tests__/runtime-activation-nextaction.test.ts +0 -81
- package/src/commands/__tests__/runtime-probe-config.test.ts +0 -432
- package/src/commands/__tests__/telemetry-flag-wiring.test.ts +0 -84
- package/src/commands/__tests__/version.test.ts +0 -251
- package/src/commands/admission-gate.ts +0 -30
- package/src/commands/artifact.ts +0 -82
- package/src/commands/build-trajectory-evidence.ts +0 -298
- package/src/commands/candidate.ts +0 -1250
- package/src/commands/codex-ingest-catchup.ts +0 -114
- package/src/commands/codex-ingest-quarantine.ts +0 -127
- package/src/commands/codex-reconcile.ts +0 -84
- package/src/commands/codex-setup.ts +0 -476
- package/src/commands/codex-worker.ts +0 -185
- package/src/commands/command-helpers.ts +0 -24
- package/src/commands/config-doctor.ts +0 -193
- package/src/commands/console.ts +0 -797
- package/src/commands/context.ts +0 -72
- package/src/commands/demo-story-a.ts +0 -241
- package/src/commands/diagnose.ts +0 -756
- package/src/commands/errors-list.ts +0 -441
- package/src/commands/evolution-tasks-list.ts +0 -48
- package/src/commands/evolution-tasks-show.ts +0 -62
- package/src/commands/flow.ts +0 -60
- package/src/commands/health-codex.ts +0 -576
- package/src/commands/health.ts +0 -315
- package/src/commands/history.ts +0 -63
- package/src/commands/intent.ts +0 -457
- package/src/commands/legacy-cleanup.ts +0 -531
- package/src/commands/legacy-import.ts +0 -104
- package/src/commands/mvp-smoke.ts +0 -160
- package/src/commands/pain-evidence.ts +0 -226
- package/src/commands/pain-list.ts +0 -239
- package/src/commands/pain-record.ts +0 -612
- package/src/commands/pain-retry.ts +0 -916
- package/src/commands/principles-stats.ts +0 -700
- package/src/commands/proven-channel-baseline.ts +0 -115
- package/src/commands/quality-scorecard.ts +0 -272
- package/src/commands/remediation-output.ts +0 -66
- package/src/commands/rulecode.ts +0 -465
- package/src/commands/run.ts +0 -89
- package/src/commands/runtime-activation.ts +0 -1629
- package/src/commands/runtime-artifact-repair.ts +0 -524
- package/src/commands/runtime-canary.ts +0 -395
- package/src/commands/runtime-compatibility-scan.ts +0 -105
- package/src/commands/runtime-diagnostics-export.ts +0 -229
- package/src/commands/runtime-features.ts +0 -153
- package/src/commands/runtime-gfi-snapshot.ts +0 -135
- package/src/commands/runtime-health-snapshot.ts +0 -108
- package/src/commands/runtime-init.ts +0 -429
- package/src/commands/runtime-internalization-enqueue-successors.ts +0 -530
- package/src/commands/runtime-internalization-integrity-repair.ts +0 -79
- package/src/commands/runtime-internalization-integrity.ts +0 -107
- package/src/commands/runtime-internalization-queue.ts +0 -135
- package/src/commands/runtime-internalization-retry.ts +0 -191
- package/src/commands/runtime-internalization-run-once.ts +0 -791
- package/src/commands/runtime-internalization-run-rulehost.ts +0 -749
- package/src/commands/runtime-internalization-wake-once.ts +0 -87
- package/src/commands/runtime-pain-flood-simulation.ts +0 -121
- package/src/commands/runtime-pruning.ts +0 -438
- package/src/commands/runtime-recovery-failed-tasks.ts +0 -258
- package/src/commands/runtime-recovery.ts +0 -109
- package/src/commands/runtime-synthetic-baseline.ts +0 -70
- package/src/commands/runtime-uat.guard.test.ts +0 -175
- package/src/commands/runtime-uat.ts +0 -380
- package/src/commands/runtime.ts +0 -473
- package/src/commands/samples-list.ts +0 -39
- package/src/commands/samples-review.ts +0 -36
- package/src/commands/task.ts +0 -271
- package/src/commands/telemetry.ts +0 -349
- package/src/commands/trace.ts +0 -174
- package/src/commands/trajectory-db-unavailable.ts +0 -19
- package/src/commands/trajectory.ts +0 -64
- package/src/commands/version.ts +0 -49
- package/src/config-reader.ts +0 -122
- package/src/index.ts +0 -1276
- package/src/legacy/legacy-import.ts +0 -179
- package/src/legacy/session-history-import.ts +0 -203
- package/src/resolve-workspace.ts +0 -106
- package/src/services/__tests__/cli-output.test.ts +0 -130
- package/src/services/__tests__/evaluator-runner-deps.test.ts +0 -382
- package/src/services/__tests__/rulehost-readiness.test.ts +0 -363
- package/src/services/__tests__/runtime-adapter-resolver.test.ts +0 -793
- package/src/services/cli-output.ts +0 -95
- package/src/services/config-doctor.ts +0 -697
- package/src/services/console-launcher.ts +0 -537
- package/src/services/demo-rule-compiler.ts +0 -40
- package/src/services/demo-story-a-runner.ts +0 -471
- package/src/services/mainline-snapshot-assembler.ts +0 -579
- package/src/services/pain-flood-simulation-runner.ts +0 -462
- package/src/services/pd-config-loader.ts +0 -433
- package/src/services/proven-channel-baseline-runner.ts +0 -157
- package/src/services/quality-scorecard/data-extractor.ts +0 -150
- package/src/services/quality-scorecard/local-evaluator.ts +0 -142
- package/src/services/quality-scorecard/strong-model-gate.ts +0 -202
- package/src/services/resolve-runtime-from-pd-config.ts +0 -230
- package/src/services/rulehost-pipeline-runner.ts +0 -1214
- package/src/services/rulehost-readiness.ts +0 -326
- package/src/services/runtime-adapter-resolver.ts +0 -364
- package/src/services/synthetic-baseline-runner.ts +0 -400
- package/src/services/version-report.ts +0 -253
- package/src/services/workspace-tool-semantics.ts +0 -26
- package/src/utils/path-security.ts +0 -96
- package/src/utils/production-workspace-guard.test.ts +0 -157
- package/src/utils/production-workspace-guard.ts +0 -210
- package/tests/bdd/cli-contract.steps.ts +0 -346
- package/tests/bdd/principles-stats.steps.ts +0 -211
- package/tests/bdd/support/gherkin-loader.ts +0 -147
- package/tests/bdd/support/repo-root.ts +0 -62
- package/tests/bdd/support/vitest-bdd.ts +0 -179
- package/tests/commands/admission-gate-coverage.test.ts +0 -79
- package/tests/commands/build-trajectory-evidence.test.ts +0 -508
- package/tests/commands/candidate-audit-repair.test.ts +0 -421
- package/tests/commands/candidate-intake.test.ts +0 -732
- package/tests/commands/candidate-internalization-backfill.test.ts +0 -548
- package/tests/commands/candidate-internalize-lineage.test.ts +0 -628
- package/tests/commands/candidate-internalize.test.ts +0 -299
- package/tests/commands/candidate-route.test.ts +0 -329
- package/tests/commands/candidate-show.test.ts +0 -95
- package/tests/commands/cli-command-tree.test.ts +0 -144
- package/tests/commands/cli-help-snapshot.test.ts +0 -155
- package/tests/commands/cli-skill-contract.test.ts +0 -121
- package/tests/commands/codex-consent-reversibility.steps.test.ts +0 -299
- package/tests/commands/codex-ingest-quarantine.test.ts +0 -136
- package/tests/commands/codex-setup.test.ts +0 -297
- package/tests/commands/codex-worker-daemon.test.ts +0 -95
- package/tests/commands/codex-worker-registration.test.ts +0 -207
- package/tests/commands/config-doctor.test.ts +0 -336
- package/tests/commands/console-launcher-edge-cases.test.ts +0 -388
- package/tests/commands/console-open.test.ts +0 -1381
- package/tests/commands/context.test.ts +0 -114
- package/tests/commands/demo-story-a.test.ts +0 -318
- package/tests/commands/diagnose.test.ts +0 -1803
- package/tests/commands/errors-list.test.ts +0 -679
- package/tests/commands/evolution-tasks-list.test.ts +0 -41
- package/tests/commands/evolution-tasks-show.test.ts +0 -46
- package/tests/commands/health-codex.test.ts +0 -349
- package/tests/commands/health-host-wiring.test.ts +0 -76
- package/tests/commands/health-reliability.test.ts +0 -99
- package/tests/commands/health.test.ts +0 -413
- package/tests/commands/intent.test.ts +0 -321
- package/tests/commands/legacy-cleanup.test.ts +0 -148
- package/tests/commands/pain-evidence.test.ts +0 -518
- package/tests/commands/pain-list.test.ts +0 -219
- package/tests/commands/pain-record-async.test.ts +0 -335
- package/tests/commands/pain-record-session-parser.test.ts +0 -228
- package/tests/commands/pain-record.test.ts +0 -851
- package/tests/commands/pain-retry.test.ts +0 -1121
- package/tests/commands/plugin-config-resolution-cutover.test.ts +0 -229
- package/tests/commands/pri-393-runtime-config-unification.test.ts +0 -443
- package/tests/commands/principles-stats-wiring.test.ts +0 -135
- package/tests/commands/principles-stats.test.ts +0 -274
- package/tests/commands/product-path-regression.test.ts +0 -86
- package/tests/commands/proven-channel-baseline.test.ts +0 -441
- package/tests/commands/rulecode.test.ts +0 -177
- package/tests/commands/run-rulehost-handler.test.ts +0 -908
- package/tests/commands/runtime-activation-approve-flag-wiring.test.ts +0 -227
- package/tests/commands/runtime-activation-deactivate-flag-wiring.test.ts +0 -167
- package/tests/commands/runtime-activation-dispatch-flag-wiring.test.ts +0 -262
- package/tests/commands/runtime-activation-governance-audit.test.ts +0 -95
- package/tests/commands/runtime-activation-list-flag-wiring.test.ts +0 -193
- package/tests/commands/runtime-activation-promote-flag-wiring.test.ts +0 -248
- package/tests/commands/runtime-activation-shadow-telemetry.test.ts +0 -130
- package/tests/commands/runtime-activation.test.ts +0 -2052
- package/tests/commands/runtime-artifact-repair-registration.test.ts +0 -74
- package/tests/commands/runtime-artifact-repair.test.ts +0 -404
- package/tests/commands/runtime-canary.test.ts +0 -430
- package/tests/commands/runtime-compatibility-scan.test.ts +0 -146
- package/tests/commands/runtime-diagnostics-export.test.ts +0 -175
- package/tests/commands/runtime-features.test.ts +0 -249
- package/tests/commands/runtime-health-snapshot.test.ts +0 -358
- package/tests/commands/runtime-init-empty-workspace.test.ts +0 -252
- package/tests/commands/runtime-init.test.ts +0 -420
- package/tests/commands/runtime-internalization-enqueue-successors.test.ts +0 -782
- package/tests/commands/runtime-internalization-integrity-repair.test.ts +0 -239
- package/tests/commands/runtime-internalization-integrity.test.ts +0 -140
- package/tests/commands/runtime-internalization-queue.test.ts +0 -380
- package/tests/commands/runtime-internalization-retry-owner-authority.test.ts +0 -431
- package/tests/commands/runtime-internalization-run-once-evaluator-parity.test.ts +0 -269
- package/tests/commands/runtime-internalization-run-once-language.test.ts +0 -303
- package/tests/commands/runtime-internalization-run-once-real-config.test.ts +0 -237
- package/tests/commands/runtime-internalization-run-once-rollout-parity.test.ts +0 -706
- package/tests/commands/runtime-internalization-run-once.test.ts +0 -1791
- package/tests/commands/runtime-internalization-wake-once.test.ts +0 -171
- package/tests/commands/runtime-internalization.test.ts +0 -53
- package/tests/commands/runtime-pain-flood-simulation.test.ts +0 -418
- package/tests/commands/runtime-pruning.test.ts +0 -694
- package/tests/commands/runtime-recovery-failed-tasks.test.ts +0 -328
- package/tests/commands/runtime-recovery.test.ts +0 -120
- package/tests/commands/runtime-synthetic-baseline.test.ts +0 -249
- package/tests/commands/runtime-uat.test.ts +0 -397
- package/tests/commands/runtime.test.ts +0 -392
- package/tests/commands/samples-list.test.ts +0 -43
- package/tests/commands/samples-review.test.ts +0 -41
- package/tests/commands/task.test.ts +0 -153
- package/tests/commands/telemetry.test.ts +0 -190
- package/tests/commands/trace.test.ts +0 -316
- package/tests/config-reader.test.ts +0 -143
- package/tests/e2e/candidate-intake-e2e.test.ts +0 -338
- package/tests/e2e/cli-full-flow.test.ts +0 -233
- package/tests/e2e/cross-package-acceptance.test.ts +0 -635
- package/tests/helpers/pd-cli-path.ts +0 -5
- package/tests/pd-cli-smoke.test.ts +0 -13
- package/tests/resolve-workspace.test.ts +0 -196
- package/tests/services/config-doctor-signal-health.test.ts +0 -109
- package/tests/services/console-launcher.test.ts +0 -114
- package/tests/services/demo-rule-compiler.test.ts +0 -242
- package/tests/services/mainline-snapshot-assembler.test.ts +0 -572
- package/tests/services/pd-config-loader.test.ts +0 -505
- package/tests/services/proven-channel-baseline-runner.test.ts +0 -30
- package/tests/services/quality-scorecard/strong-model-gate.test.ts +0 -133
- package/tests/services/resolve-runtime-from-pd-config.test.ts +0 -485
- package/tests/services/rulehost-pipeline-e2e.test.ts +0 -538
- package/tests/services/rulehost-pipeline-runner.test.ts +0 -1242
- package/tests/services/workspace-tool-semantics.test.ts +0 -76
- package/tests/utils/path-security.test.ts +0 -180
- package/tsconfig.json +0 -26
- package/vitest.config.ts +0 -10
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Regression test for nextAction CLI hints in `pd activation list`.
|
|
3
|
-
*
|
|
4
|
-
* Bug #1367: `pd activation list` emitted `--confirm` in the deactivate
|
|
5
|
-
* nextAction, but the `deactivate` command has no `--confirm` option
|
|
6
|
-
* (`error: unknown option '--confirm'`).
|
|
7
|
-
*
|
|
8
|
-
* Root cause: the nextAction template was copy-pasted from `promote`
|
|
9
|
-
* (which DOES support --confirm) without adjusting the deactivate variant.
|
|
10
|
-
*
|
|
11
|
-
* Guard: deactivate nextAction must never contain `--confirm`;
|
|
12
|
-
* promote nextAction must always contain `--confirm`.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
import { describe, it, expect } from 'vitest';
|
|
16
|
-
import { deriveActivationStatusAndNextAction } from '../runtime-activation.js';
|
|
17
|
-
|
|
18
|
-
describe('deriveActivationStatusAndNextAction', () => {
|
|
19
|
-
const base = {
|
|
20
|
-
deactivatedAt: null,
|
|
21
|
-
contextVersion: 'v1' as const,
|
|
22
|
-
v2FlagEnabled: true,
|
|
23
|
-
activationId: 'act_code_rule-test-123',
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
it('live mode: deactivate nextAction must NOT contain --confirm (bug #1367)', () => {
|
|
27
|
-
const { status, nextAction } = deriveActivationStatusAndNextAction({
|
|
28
|
-
...base,
|
|
29
|
-
mode: 'live',
|
|
30
|
-
});
|
|
31
|
-
expect(status).toBe('active');
|
|
32
|
-
expect(nextAction).toBeDefined();
|
|
33
|
-
expect(nextAction).toContain('pd activation deactivate');
|
|
34
|
-
expect(nextAction).not.toContain('--confirm');
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('shadow mode: nextAction requires Owner review instead of advertising direct mutation', () => {
|
|
38
|
-
const { status, nextAction } = deriveActivationStatusAndNextAction({
|
|
39
|
-
...base,
|
|
40
|
-
mode: 'shadow',
|
|
41
|
-
});
|
|
42
|
-
expect(status).toBe('active');
|
|
43
|
-
expect(nextAction).toBeDefined();
|
|
44
|
-
expect(nextAction).toBe(
|
|
45
|
-
'Keep shadow; promotion requires an authenticated Owner decision, immutable evidence bindings, and a passing Promotion Readiness result.',
|
|
46
|
-
);
|
|
47
|
-
expect(nextAction).not.toContain('pd activation promote');
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('deactivated record: status deactivated, no nextAction', () => {
|
|
51
|
-
const { status, nextAction } = deriveActivationStatusAndNextAction({
|
|
52
|
-
...base,
|
|
53
|
-
mode: 'live',
|
|
54
|
-
deactivatedAt: '2026-08-21T00:51:10.026Z',
|
|
55
|
-
});
|
|
56
|
-
expect(status).toBe('deactivated');
|
|
57
|
-
expect(nextAction).toBeUndefined();
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('v2 activation with flag off: suspended_by_flag, deactivate hint without --confirm', () => {
|
|
61
|
-
const { status, nextAction } = deriveActivationStatusAndNextAction({
|
|
62
|
-
...base,
|
|
63
|
-
mode: 'live',
|
|
64
|
-
contextVersion: 'v2',
|
|
65
|
-
v2FlagEnabled: false,
|
|
66
|
-
});
|
|
67
|
-
expect(status).toBe('suspended_by_flag');
|
|
68
|
-
expect(nextAction).toBeDefined();
|
|
69
|
-
expect(nextAction).toContain('pd activation deactivate');
|
|
70
|
-
expect(nextAction).not.toContain('--confirm');
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('unknown mode: active with no nextAction', () => {
|
|
74
|
-
const { status, nextAction } = deriveActivationStatusAndNextAction({
|
|
75
|
-
...base,
|
|
76
|
-
mode: undefined,
|
|
77
|
-
});
|
|
78
|
-
expect(status).toBe('active');
|
|
79
|
-
expect(nextAction).toBeUndefined();
|
|
80
|
-
});
|
|
81
|
-
});
|
|
@@ -1,432 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PRI-402: pd runtime probe reads .pd/config.yaml for pi-ai config.
|
|
3
|
-
*
|
|
4
|
-
* Tests cover:
|
|
5
|
-
* - probe reads config from .pd/config.yaml when --workspace is provided
|
|
6
|
-
* - JSON output includes configSource, runtimeProfileId, runtimeProfileLabel
|
|
7
|
-
* - explicit --provider overrides config.yaml
|
|
8
|
-
* - fail-loud JSON when config.yaml is missing or incomplete
|
|
9
|
-
* - program.parseAsync against real Commander registration (EP-04)
|
|
10
|
-
*
|
|
11
|
-
* ERR refs:
|
|
12
|
-
* - EP-04 (CLI gate): --json stdout single object, process.exit(1) + return
|
|
13
|
-
* - EP-03 (fail loud): structured JSON with reason + nextAction on failure
|
|
14
|
-
* - EP-07 (source alignment): probe and doctor read same config source
|
|
15
|
-
* - ERR-004 (source alignment): profileId/label must match doctor output
|
|
16
|
-
* - ERR-021 (handler-only tests): add program.parseAsync tests
|
|
17
|
-
* - ERR-029 (fail-loud JSON): config missing → structured JSON, not bare error
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
21
|
-
import { Command } from 'commander';
|
|
22
|
-
import * as fs from 'fs';
|
|
23
|
-
import * as path from 'path';
|
|
24
|
-
import * as os from 'os';
|
|
25
|
-
|
|
26
|
-
// ─── Mocks ─────────────────────────────────────────────────────────────────
|
|
27
|
-
|
|
28
|
-
// Mock only probeRuntime so we don't need a real LLM provider.
|
|
29
|
-
// All other core functions (validatePdConfig, computeEffectivePdConfig,
|
|
30
|
-
// resolveAgentRuntimeBinding, etc.) use their real implementations.
|
|
31
|
-
const mockProbeRuntime = vi.fn();
|
|
32
|
-
vi.mock('@principles/core/runtime-v2', async (importOriginal) => {
|
|
33
|
-
const actual = await importOriginal<Record<string, unknown>>();
|
|
34
|
-
return {
|
|
35
|
-
...actual,
|
|
36
|
-
probeRuntime: mockProbeRuntime,
|
|
37
|
-
};
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const { handleRuntimeProbe } = await import('../runtime.js');
|
|
41
|
-
|
|
42
|
-
// ─── Test Setup ─────────────────────────────────────────────────────────────
|
|
43
|
-
|
|
44
|
-
const capturedStdout: string[] = [];
|
|
45
|
-
const capturedStderr: string[] = [];
|
|
46
|
-
let capturedExitCode: number | null = null;
|
|
47
|
-
|
|
48
|
-
const originalExit = process.exit;
|
|
49
|
-
const originalLog = console.log;
|
|
50
|
-
const originalError = console.error;
|
|
51
|
-
const originalWarn = console.warn;
|
|
52
|
-
const originalEnv = { ...process.env };
|
|
53
|
-
|
|
54
|
-
beforeEach(() => {
|
|
55
|
-
capturedExitCode = null;
|
|
56
|
-
capturedStdout.length = 0;
|
|
57
|
-
capturedStderr.length = 0;
|
|
58
|
-
process.exit = vi.fn(((code?: number) => {
|
|
59
|
-
capturedExitCode = code ?? 0;
|
|
60
|
-
}) as typeof process.exit);
|
|
61
|
-
console.log = vi.fn((...args: unknown[]) => { capturedStdout.push(args.join(' ')); });
|
|
62
|
-
console.error = vi.fn((...args: unknown[]) => { capturedStderr.push(args.join(' ')); });
|
|
63
|
-
console.warn = vi.fn(() => { /* capture warnings */ });
|
|
64
|
-
mockProbeRuntime.mockReset();
|
|
65
|
-
process.env = { ...originalEnv, LMSTUDIO_API_KEY: 'test-key-for-pri-402', OPENROUTER_API_KEY: 'test-key-for-pri-402' };
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
afterEach(() => {
|
|
69
|
-
process.exit = originalExit;
|
|
70
|
-
console.log = originalLog;
|
|
71
|
-
console.error = originalError;
|
|
72
|
-
console.warn = originalWarn;
|
|
73
|
-
process.env = originalEnv;
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
// ─── Helper: create temp workspace with .pd/config.yaml ────────────────────
|
|
77
|
-
|
|
78
|
-
/** Create a scratch workspace with .pd/config.yaml under a unique temp root. */
|
|
79
|
-
function createTempWorkspace(configYaml: string): string {
|
|
80
|
-
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'pd-probe-test-'));
|
|
81
|
-
const pdDir = path.join(tmpDir, '.pd');
|
|
82
|
-
fs.mkdirSync(pdDir, { recursive: true });
|
|
83
|
-
// Replace __WORKSPACE_DIR__ placeholder with actual path
|
|
84
|
-
const resolvedYaml = configYaml.replace(/__WORKSPACE_DIR__/g, tmpDir.replace(/\\/g, '/'));
|
|
85
|
-
fs.writeFileSync(path.join(pdDir, 'config.yaml'), resolvedYaml, 'utf-8');
|
|
86
|
-
return tmpDir;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function cleanupWorkspace(dir: string): void {
|
|
90
|
-
try {
|
|
91
|
-
fs.rmSync(dir, { recursive: true, force: true });
|
|
92
|
-
} catch {
|
|
93
|
-
// best effort
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const PI_AI_CONFIG_YAML = `
|
|
98
|
-
version: 1
|
|
99
|
-
features:
|
|
100
|
-
prompt: { category: core, enabled: true }
|
|
101
|
-
code_tool_hook: { category: core, enabled: true }
|
|
102
|
-
defer_archive: { category: core, enabled: true }
|
|
103
|
-
workspace:
|
|
104
|
-
default: __WORKSPACE_DIR__
|
|
105
|
-
internalAgents:
|
|
106
|
-
defaultRuntime: pi-ai.lmstudio
|
|
107
|
-
agents:
|
|
108
|
-
diagnostician:
|
|
109
|
-
enabled: true
|
|
110
|
-
runtimeProfile: pi-ai.lmstudio
|
|
111
|
-
dreamer:
|
|
112
|
-
enabled: true
|
|
113
|
-
philosopher:
|
|
114
|
-
enabled: true
|
|
115
|
-
scribe:
|
|
116
|
-
enabled: true
|
|
117
|
-
artificer:
|
|
118
|
-
enabled: true
|
|
119
|
-
runtimeProfiles:
|
|
120
|
-
pi-ai.lmstudio:
|
|
121
|
-
type: pi-ai
|
|
122
|
-
provider: lmstudio
|
|
123
|
-
model: qwen3.6-27b-mtp
|
|
124
|
-
apiKeyEnv: LMSTUDIO_API_KEY
|
|
125
|
-
baseUrl: http://localhost:1234/v1
|
|
126
|
-
`;
|
|
127
|
-
|
|
128
|
-
// ─── Tests: probe reads config from .pd/config.yaml ────────────────────────
|
|
129
|
-
|
|
130
|
-
describe('PRI-402: probe reads .pd/config.yaml for pi-ai config', () => {
|
|
131
|
-
it('reads provider/model from config.yaml when --workspace provided without --provider', async () => {
|
|
132
|
-
const workspace = createTempWorkspace(PI_AI_CONFIG_YAML);
|
|
133
|
-
try {
|
|
134
|
-
mockProbeRuntime.mockResolvedValue({
|
|
135
|
-
runtimeKind: 'pi-ai',
|
|
136
|
-
provider: 'lmstudio',
|
|
137
|
-
model: 'qwen3.6-27b-mtp',
|
|
138
|
-
health: { healthy: true, degraded: false, warnings: [], lastCheckedAt: '2026-01-01T00:00:00Z' },
|
|
139
|
-
capabilities: { streaming: true },
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
await handleRuntimeProbe({
|
|
143
|
-
runtime: 'pi-ai',
|
|
144
|
-
workspace,
|
|
145
|
-
json: true,
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
// probeRuntime should be called with config.yaml values
|
|
149
|
-
expect(mockProbeRuntime).toHaveBeenCalled();
|
|
150
|
-
const callArgs = mockProbeRuntime.mock.calls[0]?.[0];
|
|
151
|
-
expect(callArgs?.provider).toBe('lmstudio');
|
|
152
|
-
expect(callArgs?.model).toBe('qwen3.6-27b-mtp');
|
|
153
|
-
expect(callArgs?.apiKeyEnv).toBe('LMSTUDIO_API_KEY');
|
|
154
|
-
|
|
155
|
-
// JSON output should contain configSource, runtimeProfileId, runtimeProfileLabel
|
|
156
|
-
const output = JSON.parse(capturedStdout.join(''));
|
|
157
|
-
expect(output.configSource).toBe('.pd/config.yaml');
|
|
158
|
-
expect(output.runtimeProfileId).toBe('pi-ai.lmstudio');
|
|
159
|
-
expect(output.runtimeProfileLabel).toBe('pi-ai: lmstudio/qwen3.6-27b-mtp');
|
|
160
|
-
expect(output.ok).toBe(true);
|
|
161
|
-
} finally {
|
|
162
|
-
cleanupWorkspace(workspace);
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
it('explicit --provider overrides config.yaml value', async () => {
|
|
167
|
-
const workspace = createTempWorkspace(PI_AI_CONFIG_YAML);
|
|
168
|
-
try {
|
|
169
|
-
mockProbeRuntime.mockResolvedValue({
|
|
170
|
-
runtimeKind: 'pi-ai',
|
|
171
|
-
provider: 'openrouter',
|
|
172
|
-
model: 'qwen3.6-27b-mtp',
|
|
173
|
-
health: { healthy: true, degraded: false, warnings: [], lastCheckedAt: '2026-01-01T00:00:00Z' },
|
|
174
|
-
capabilities: { streaming: true },
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
await handleRuntimeProbe({
|
|
178
|
-
runtime: 'pi-ai',
|
|
179
|
-
workspace,
|
|
180
|
-
provider: 'openrouter',
|
|
181
|
-
model: 'anthropic/claude-sonnet-4',
|
|
182
|
-
apiKeyEnv: 'OPENROUTER_API_KEY',
|
|
183
|
-
json: true,
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
const callArgs = mockProbeRuntime.mock.calls[0]?.[0];
|
|
187
|
-
// CLI flags override config.yaml
|
|
188
|
-
expect(callArgs?.provider).toBe('openrouter');
|
|
189
|
-
expect(callArgs?.model).toBe('anthropic/claude-sonnet-4');
|
|
190
|
-
expect(callArgs?.apiKeyEnv).toBe('OPENROUTER_API_KEY');
|
|
191
|
-
|
|
192
|
-
// Profile info still comes from config.yaml (EP-07: source alignment)
|
|
193
|
-
const output = JSON.parse(capturedStdout.join(''));
|
|
194
|
-
expect(output.configSource).toBe('.pd/config.yaml');
|
|
195
|
-
expect(output.runtimeProfileId).toBe('pi-ai.lmstudio');
|
|
196
|
-
} finally {
|
|
197
|
-
cleanupWorkspace(workspace);
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
it('fail-loud JSON when config.yaml is missing and no --provider', async () => {
|
|
202
|
-
const workspace = path.join(os.tmpdir(), `pd-probe-test-missing-${Date.now()}`);
|
|
203
|
-
fs.mkdirSync(workspace, { recursive: true });
|
|
204
|
-
// No .pd/config.yaml created
|
|
205
|
-
try {
|
|
206
|
-
await handleRuntimeProbe({
|
|
207
|
-
runtime: 'pi-ai',
|
|
208
|
-
workspace,
|
|
209
|
-
json: true,
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
expect(capturedExitCode).toBe(1);
|
|
213
|
-
const output = JSON.parse(capturedStdout.join(''));
|
|
214
|
-
expect(output.ok).toBe(false);
|
|
215
|
-
expect(output.status).toBe('failed');
|
|
216
|
-
expect(typeof output.reason).toBe('string');
|
|
217
|
-
expect(typeof output.nextAction).toBe('string');
|
|
218
|
-
// Single parseable JSON object (EP-04 Rule 1)
|
|
219
|
-
expect(Array.isArray(output)).toBe(false);
|
|
220
|
-
} finally {
|
|
221
|
-
cleanupWorkspace(workspace);
|
|
222
|
-
}
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
it('fail-loud JSON when provider missing from config.yaml', async () => {
|
|
226
|
-
const workspace = createTempWorkspace(`
|
|
227
|
-
version: 1
|
|
228
|
-
features:
|
|
229
|
-
prompt: { category: core, enabled: true }
|
|
230
|
-
code_tool_hook: { category: core, enabled: true }
|
|
231
|
-
defer_archive: { category: core, enabled: true }
|
|
232
|
-
workspace:
|
|
233
|
-
default: __WORKSPACE_DIR__
|
|
234
|
-
internalAgents:
|
|
235
|
-
defaultRuntime: pi-ai.broken
|
|
236
|
-
agents:
|
|
237
|
-
diagnostician:
|
|
238
|
-
enabled: true
|
|
239
|
-
runtimeProfile: pi-ai.broken
|
|
240
|
-
runtimeProfiles:
|
|
241
|
-
pi-ai.broken:
|
|
242
|
-
type: pi-ai
|
|
243
|
-
# Missing provider, model, apiKeyEnv
|
|
244
|
-
`);
|
|
245
|
-
try {
|
|
246
|
-
await handleRuntimeProbe({
|
|
247
|
-
runtime: 'pi-ai',
|
|
248
|
-
workspace,
|
|
249
|
-
json: true,
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
expect(capturedExitCode).toBe(1);
|
|
253
|
-
const output = JSON.parse(capturedStdout.join(''));
|
|
254
|
-
expect(output.ok).toBe(false);
|
|
255
|
-
expect(output.status).toBe('failed');
|
|
256
|
-
expect(typeof output.reason).toBe('string');
|
|
257
|
-
expect(typeof output.nextAction).toBe('string');
|
|
258
|
-
} finally {
|
|
259
|
-
cleanupWorkspace(workspace);
|
|
260
|
-
}
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
it('fail-loud JSON when apiKeyEnv env var is not set', async () => {
|
|
264
|
-
const workspace = createTempWorkspace(PI_AI_CONFIG_YAML);
|
|
265
|
-
try {
|
|
266
|
-
// Remove the API key env var
|
|
267
|
-
delete process.env.LMSTUDIO_API_KEY;
|
|
268
|
-
|
|
269
|
-
await handleRuntimeProbe({
|
|
270
|
-
runtime: 'pi-ai',
|
|
271
|
-
workspace,
|
|
272
|
-
json: true,
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
expect(capturedExitCode).toBe(1);
|
|
276
|
-
const output = JSON.parse(capturedStdout.join(''));
|
|
277
|
-
expect(output.ok).toBe(false);
|
|
278
|
-
// When apiKeyEnv is not set, resolveRuntimeConfigFromPdConfig returns
|
|
279
|
-
// a config error (not_ready), so the error comes from the config resolution path
|
|
280
|
-
expect(typeof output.reason).toBe('string');
|
|
281
|
-
expect(typeof output.nextAction).toBe('string');
|
|
282
|
-
} finally {
|
|
283
|
-
cleanupWorkspace(workspace);
|
|
284
|
-
}
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
it('human-readable output includes Profile and Config lines', async () => {
|
|
288
|
-
const workspace = createTempWorkspace(PI_AI_CONFIG_YAML);
|
|
289
|
-
try {
|
|
290
|
-
mockProbeRuntime.mockResolvedValue({
|
|
291
|
-
runtimeKind: 'pi-ai',
|
|
292
|
-
provider: 'lmstudio',
|
|
293
|
-
model: 'qwen3.6-27b-mtp',
|
|
294
|
-
health: { healthy: true, degraded: false, warnings: [], lastCheckedAt: '2026-01-01T00:00:00Z' },
|
|
295
|
-
capabilities: { streaming: true },
|
|
296
|
-
});
|
|
297
|
-
|
|
298
|
-
await handleRuntimeProbe({
|
|
299
|
-
runtime: 'pi-ai',
|
|
300
|
-
workspace,
|
|
301
|
-
json: false,
|
|
302
|
-
});
|
|
303
|
-
|
|
304
|
-
const output = capturedStdout.join('\n');
|
|
305
|
-
expect(output).toContain('Profile:');
|
|
306
|
-
expect(output).toContain('pi-ai: lmstudio/qwen3.6-27b-mtp');
|
|
307
|
-
expect(output).toContain('Config:');
|
|
308
|
-
expect(output).toContain('.pd/config.yaml');
|
|
309
|
-
} finally {
|
|
310
|
-
cleanupWorkspace(workspace);
|
|
311
|
-
}
|
|
312
|
-
});
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
// ─── Tests: program.parseAsync against real Commander registration (EP-04) ──
|
|
316
|
-
|
|
317
|
-
// Import the real command registration function to test actual production wiring
|
|
318
|
-
const { registerRuntimeProbeCommand } = await import('../runtime.js');
|
|
319
|
-
|
|
320
|
-
interface CapturedAction {
|
|
321
|
-
opts: Record<string, unknown> | null;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
function attachCapture(cmd: Command, state: CapturedAction): void {
|
|
325
|
-
// Override the action handler to capture opts without calling the real handler
|
|
326
|
-
cmd.action((...args: unknown[]) => {
|
|
327
|
-
// Find the opts object (last non-Command, non-null object arg)
|
|
328
|
-
let optsArg: Record<string, unknown> | null = null;
|
|
329
|
-
for (let i = args.length - 1; i >= 0; i--) {
|
|
330
|
-
const arg: unknown = args[i];
|
|
331
|
-
if (arg !== null && typeof arg === 'object' && !(arg instanceof Command)) {
|
|
332
|
-
optsArg = arg as Record<string, unknown>;
|
|
333
|
-
break;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
state.opts = optsArg ?? {};
|
|
337
|
-
// Do NOT call original action (would call handleRuntimeProbe which needs real runtime)
|
|
338
|
-
});
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
function freshProgram(): Command {
|
|
342
|
-
const program = new Command();
|
|
343
|
-
program.name('pd').exitOverride();
|
|
344
|
-
return program;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
describe('PRI-402: probe command flag wiring (EP-04 real registration)', () => {
|
|
348
|
-
it('registers --runtime as required option via real registration', () => {
|
|
349
|
-
const program = freshProgram();
|
|
350
|
-
const runtimeCmd = program.command('runtime');
|
|
351
|
-
const probeCmd = registerRuntimeProbeCommand(runtimeCmd);
|
|
352
|
-
|
|
353
|
-
const runtimeOpt = probeCmd.options.find((o) => o.long === '--runtime');
|
|
354
|
-
expect(runtimeOpt).toBeDefined();
|
|
355
|
-
expect(runtimeOpt?.required).toBe(true);
|
|
356
|
-
});
|
|
357
|
-
|
|
358
|
-
it('registers --workspace with -w shorthand via real registration', () => {
|
|
359
|
-
const program = freshProgram();
|
|
360
|
-
const runtimeCmd = program.command('runtime');
|
|
361
|
-
const probeCmd = registerRuntimeProbeCommand(runtimeCmd);
|
|
362
|
-
|
|
363
|
-
const wsOpt = probeCmd.options.find((o) => o.short === '-w');
|
|
364
|
-
expect(wsOpt).toBeDefined();
|
|
365
|
-
expect(wsOpt?.long).toBe('--workspace');
|
|
366
|
-
});
|
|
367
|
-
|
|
368
|
-
it('parses --runtime pi-ai --workspace <dir> --json correctly via real registration', async () => {
|
|
369
|
-
const program = freshProgram();
|
|
370
|
-
const runtimeCmd = program.command('runtime');
|
|
371
|
-
const probeCmd = registerRuntimeProbeCommand(runtimeCmd);
|
|
372
|
-
const captured: CapturedAction = { opts: null };
|
|
373
|
-
attachCapture(probeCmd, captured);
|
|
374
|
-
|
|
375
|
-
await program.parseAsync(['node', 'pd', 'runtime', 'probe', '--runtime', 'pi-ai', '--workspace', '/tmp/test', '--json']);
|
|
376
|
-
|
|
377
|
-
expect(captured.opts).not.toBeNull();
|
|
378
|
-
if (!captured.opts) throw new Error('captured.opts is null');
|
|
379
|
-
expect(captured.opts.runtime).toBe('pi-ai');
|
|
380
|
-
expect(captured.opts.workspace).toBe('/tmp/test');
|
|
381
|
-
expect(captured.opts.json).toBe(true);
|
|
382
|
-
});
|
|
383
|
-
|
|
384
|
-
it('parses --runtime config --workspace <dir> correctly via real registration', async () => {
|
|
385
|
-
const program = freshProgram();
|
|
386
|
-
const runtimeCmd = program.command('runtime');
|
|
387
|
-
const probeCmd = registerRuntimeProbeCommand(runtimeCmd);
|
|
388
|
-
const captured: CapturedAction = { opts: null };
|
|
389
|
-
attachCapture(probeCmd, captured);
|
|
390
|
-
|
|
391
|
-
await program.parseAsync(['node', 'pd', 'runtime', 'probe', '--runtime', 'config', '--workspace', '/tmp/test']);
|
|
392
|
-
|
|
393
|
-
expect(captured.opts).not.toBeNull();
|
|
394
|
-
if (!captured.opts) throw new Error('captured.opts is null');
|
|
395
|
-
expect(captured.opts.runtime).toBe('config');
|
|
396
|
-
expect(captured.opts.workspace).toBe('/tmp/test');
|
|
397
|
-
});
|
|
398
|
-
});
|
|
399
|
-
|
|
400
|
-
// ─── Tests: resolve-runtime-from-pd-config profile extraction ───────────────
|
|
401
|
-
|
|
402
|
-
describe('PRI-402: resolveRuntimeWithOverrides returns profile info', () => {
|
|
403
|
-
it('returns runtimeProfileId and runtimeProfileLabel from config.yaml', async () => {
|
|
404
|
-
const workspace = createTempWorkspace(PI_AI_CONFIG_YAML);
|
|
405
|
-
try {
|
|
406
|
-
const { resolveRuntimeWithOverrides } = await import('../../services/resolve-runtime-from-pd-config.js');
|
|
407
|
-
const result = resolveRuntimeWithOverrides(workspace, {});
|
|
408
|
-
|
|
409
|
-
expect(result.configSource).toBe('.pd/config.yaml');
|
|
410
|
-
expect(result.runtimeProfileId).toBe('pi-ai.lmstudio');
|
|
411
|
-
expect(result.runtimeProfileLabel).toBe('pi-ai: lmstudio/qwen3.6-27b-mtp');
|
|
412
|
-
} finally {
|
|
413
|
-
cleanupWorkspace(workspace);
|
|
414
|
-
}
|
|
415
|
-
});
|
|
416
|
-
|
|
417
|
-
it('returns default profile when config.yaml is missing', async () => {
|
|
418
|
-
const workspace = path.join(os.tmpdir(), `pd-probe-test-noprofile-${Date.now()}`);
|
|
419
|
-
fs.mkdirSync(workspace, { recursive: true });
|
|
420
|
-
try {
|
|
421
|
-
const { resolveRuntimeWithOverrides } = await import('../../services/resolve-runtime-from-pd-config.js');
|
|
422
|
-
const result = resolveRuntimeWithOverrides(workspace, {});
|
|
423
|
-
|
|
424
|
-
// Missing config → defaults, which use openclaw.default as defaultRuntime
|
|
425
|
-
expect(result.configSource).toBe('.pd/config.yaml');
|
|
426
|
-
expect(result.runtimeProfileId).toBe('openclaw.default');
|
|
427
|
-
expect(typeof result.runtimeProfileLabel).toBe('string');
|
|
428
|
-
} finally {
|
|
429
|
-
cleanupWorkspace(workspace);
|
|
430
|
-
}
|
|
431
|
-
});
|
|
432
|
-
});
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* pd telemetry — parser-level flag wiring tests (PRI-597, CLI Operator Gate
|
|
3
|
-
* rule 7 / EP-04).
|
|
4
|
-
*
|
|
5
|
-
* Exercises the real Commander tree via registerTelemetryCommand; actions are
|
|
6
|
-
* captured so no handler logic runs.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { describe, it, expect } from 'vitest';
|
|
10
|
-
import { Command } from 'commander';
|
|
11
|
-
import { registerTelemetryCommand } from '../telemetry.js';
|
|
12
|
-
|
|
13
|
-
function freshProgram(): Command {
|
|
14
|
-
const program = new Command();
|
|
15
|
-
program.name('pd').exitOverride();
|
|
16
|
-
return program;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function requireCmd(cmd: Command | undefined, name: string): Command {
|
|
20
|
-
if (cmd === undefined) {
|
|
21
|
-
throw new Error(`Command '${name}' not found in tree`);
|
|
22
|
-
}
|
|
23
|
-
return cmd;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function telemetrySub(name: string): Command {
|
|
27
|
-
const program = freshProgram();
|
|
28
|
-
registerTelemetryCommand(program);
|
|
29
|
-
const telemetry = requireCmd(program.commands.find((c) => c.name() === 'telemetry'), 'telemetry');
|
|
30
|
-
return requireCmd(telemetry.commands.find((c) => c.name() === name), `telemetry ${name}`);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
describe('pd telemetry — command registration', () => {
|
|
34
|
-
it('registers the telemetry group with all five subcommands', () => {
|
|
35
|
-
const program = freshProgram();
|
|
36
|
-
registerTelemetryCommand(program);
|
|
37
|
-
const telemetry = requireCmd(program.commands.find((c) => c.name() === 'telemetry'), 'telemetry');
|
|
38
|
-
const subNames = telemetry.commands.map((c) => c.name()).sort();
|
|
39
|
-
expect(subNames).toEqual(['disable', 'enable', 'preview', 'reset', 'status']);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('status registers --workspace (-w) and --json', () => {
|
|
43
|
-
const status = telemetrySub('status');
|
|
44
|
-
expect(status.options.find((o) => o.long === '--workspace')?.short).toBe('-w');
|
|
45
|
-
expect(status.options.find((o) => o.long === '--json')).toBeDefined();
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('enable/disable/reset register the dry-run/confirm pair (cli-4) plus --workspace and --json', () => {
|
|
49
|
-
for (const name of ['enable', 'disable', 'reset']) {
|
|
50
|
-
const cmd = telemetrySub(name);
|
|
51
|
-
expect(cmd.options.find((o) => o.long === '--dry-run'), name).toBeDefined();
|
|
52
|
-
expect(cmd.options.find((o) => o.long === '--confirm'), name).toBeDefined();
|
|
53
|
-
expect(cmd.options.find((o) => o.long === '--workspace'), name).toBeDefined();
|
|
54
|
-
expect(cmd.options.find((o) => o.long === '--json'), name).toBeDefined();
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('preview registers --workspace (-w) and --json', () => {
|
|
59
|
-
const preview = telemetrySub('preview');
|
|
60
|
-
expect(preview.options.find((o) => o.long === '--workspace')?.short).toBe('-w');
|
|
61
|
-
expect(preview.options.find((o) => o.long === '--json')).toBeDefined();
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('parser dispatches telemetry enable with --confirm as opts.confirm === true', async () => {
|
|
65
|
-
const program = freshProgram();
|
|
66
|
-
registerTelemetryCommand(program);
|
|
67
|
-
const holder: { opts: Record<string, unknown> | null } = { opts: null };
|
|
68
|
-
const telemetry = requireCmd(program.commands.find((c) => c.name() === 'telemetry'), 'telemetry');
|
|
69
|
-
const enable = requireCmd(telemetry.commands.find((c) => c.name() === 'enable'), 'enable');
|
|
70
|
-
enable.action((...args: unknown[]) => {
|
|
71
|
-
for (let i = args.length - 1; i >= 0; i--) {
|
|
72
|
-
const arg = args[i];
|
|
73
|
-
if (arg !== null && typeof arg === 'object' && !(arg instanceof Command)) {
|
|
74
|
-
holder.opts = arg as Record<string, unknown>;
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
await program.parseAsync(['node', 'pd', 'telemetry', 'enable', '--confirm', '--json']);
|
|
80
|
-
expect(holder.opts).not.toBeNull();
|
|
81
|
-
expect(holder.opts?.confirm).toBe(true);
|
|
82
|
-
expect(holder.opts?.json).toBe(true);
|
|
83
|
-
});
|
|
84
|
-
});
|