create-principles-disciple 1.91.0 → 1.93.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/README.md +1 -1
- package/console/dist/server/config/AuthConfig.js +6 -0
- package/console/dist/server/index.js +31 -16
- package/console/dist/server/models/ApprovalsGroupedConsoleModel.js +6 -3
- package/console/dist/server/models/ConsoleLifecycleDatasource.js +1 -1
- package/console/dist/server/routes/activations.js +4 -0
- package/console/dist/server/routes/approvals.js +24 -4
- package/console/dist/server/routes/feedback-reports.js +7 -5
- package/console/dist/server/routes/lifecycle.js +6 -1
- package/console/dist/server/routes/principles.js +10 -2
- package/console/dist/server/routes/workspaces.js +4 -0
- package/console/dist/ui/components/ui/charts.js +4 -1
- package/console/dist/ui/components/ui/markdown.js +9 -5
- package/console/dist/ui/i18n/en.json +1 -2
- package/console/dist/ui/i18n/zh-CN.json +1 -2
- package/console/dist/ui/utils/enum-labels.js +4 -2
- package/console/dist/web/assets/app.js +8 -8
- package/core/dist/index.d.ts +0 -1
- package/core/dist/index.d.ts.map +1 -1
- package/core/dist/index.js +0 -2
- package/core/dist/index.js.map +1 -1
- package/core/dist/pain-signal.d.ts +11 -71
- package/core/dist/pain-signal.d.ts.map +1 -1
- package/core/dist/pain-signal.js +10 -120
- package/core/dist/pain-signal.js.map +1 -1
- package/core/dist/principle-tree-ledger.d.ts +4 -87
- package/core/dist/principle-tree-ledger.d.ts.map +1 -1
- package/core/dist/principle-tree-ledger.js +51 -148
- package/core/dist/principle-tree-ledger.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/activation-types-helpers.test.js +6 -14
- package/core/dist/runtime-v2/__tests__/activation-types-helpers.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/architecture-regression.test.js +180 -70
- package/core/dist/runtime-v2/__tests__/architecture-regression.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/barrel-io-cleanup.test.d.ts +12 -0
- package/core/dist/runtime-v2/__tests__/barrel-io-cleanup.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/__tests__/barrel-io-cleanup.test.js +46 -0
- package/core/dist/runtime-v2/__tests__/barrel-io-cleanup.test.js.map +1 -0
- package/core/dist/runtime-v2/__tests__/intake-to-internalization-bridge.test.js +1 -2
- package/core/dist/runtime-v2/__tests__/intake-to-internalization-bridge.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/internalization-orchestrator.test.js +8 -8
- package/core/dist/runtime-v2/__tests__/internalization-orchestrator.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/internalization-peer-runner-contracts.test.js +45 -80
- package/core/dist/runtime-v2/__tests__/internalization-peer-runner-contracts.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/internalization-state-machine.test.js +31 -130
- package/core/dist/runtime-v2/__tests__/internalization-state-machine.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/io-deletion.test.d.ts +12 -0
- package/core/dist/runtime-v2/__tests__/io-deletion.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/__tests__/io-deletion.test.js +92 -0
- package/core/dist/runtime-v2/__tests__/io-deletion.test.js.map +1 -0
- package/core/dist/runtime-v2/__tests__/ledger-codec.test.d.ts +2 -0
- package/core/dist/runtime-v2/__tests__/ledger-codec.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/__tests__/ledger-codec.test.js +429 -0
- package/core/dist/runtime-v2/__tests__/ledger-codec.test.js.map +1 -0
- package/core/dist/runtime-v2/__tests__/ledger-store.test.d.ts +2 -0
- package/core/dist/runtime-v2/__tests__/ledger-store.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/__tests__/ledger-store.test.js +65 -0
- package/core/dist/runtime-v2/__tests__/ledger-store.test.js.map +1 -0
- package/core/dist/runtime-v2/__tests__/pain-signal-observability.test.js +146 -0
- package/core/dist/runtime-v2/__tests__/pain-signal-observability.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/pain-signal-unification.test.d.ts +2 -0
- package/core/dist/runtime-v2/__tests__/pain-signal-unification.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/__tests__/pain-signal-unification.test.js +150 -0
- package/core/dist/runtime-v2/__tests__/pain-signal-unification.test.js.map +1 -0
- package/core/dist/runtime-v2/__tests__/pain-to-principle-service.test.js +0 -1
- package/core/dist/runtime-v2/__tests__/pain-to-principle-service.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/pitask-metadata.test.js +4 -4
- package/core/dist/runtime-v2/__tests__/pitask-metadata.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/proven-channel-baseline.test.js +2 -5
- package/core/dist/runtime-v2/__tests__/proven-channel-baseline.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/story-a-demo.test.js +2 -2
- package/core/dist/runtime-v2/__tests__/story-a-demo.test.js.map +1 -1
- package/core/dist/runtime-v2/activation/__tests__/activation-dispatcher.test.js +7 -10
- package/core/dist/runtime-v2/activation/__tests__/activation-dispatcher.test.js.map +1 -1
- package/core/dist/runtime-v2/activation/__tests__/approval-queue.test.js +1 -3
- package/core/dist/runtime-v2/activation/__tests__/approval-queue.test.js.map +1 -1
- package/core/dist/runtime-v2/activation/__tests__/approval-store-extended.test.js +4 -4
- package/core/dist/runtime-v2/activation/__tests__/sqlite-approval-store.test.js +6 -6
- package/core/dist/runtime-v2/activation/__tests__/sqlite-approval-store.test.js.map +1 -1
- package/core/dist/runtime-v2/activation/activation-dispatcher.d.ts.map +1 -1
- package/core/dist/runtime-v2/activation/activation-dispatcher.js +0 -1
- package/core/dist/runtime-v2/activation/activation-dispatcher.js.map +1 -1
- package/core/dist/runtime-v2/activation/activation-types.d.ts.map +1 -1
- package/core/dist/runtime-v2/activation/activation-types.js +0 -1
- package/core/dist/runtime-v2/activation/activation-types.js.map +1 -1
- package/core/dist/runtime-v2/adapter/__tests__/test-double-runtime-adapter.test.js +199 -0
- package/core/dist/runtime-v2/adapter/__tests__/test-double-runtime-adapter.test.js.map +1 -1
- package/core/dist/runtime-v2/adapter/pi-ai-runtime-adapter.d.ts.map +1 -1
- package/core/dist/runtime-v2/adapter/pi-ai-runtime-adapter.js +0 -2
- package/core/dist/runtime-v2/adapter/pi-ai-runtime-adapter.js.map +1 -1
- package/core/dist/runtime-v2/config/__tests__/pd-config-agent-binding.test.js +0 -7
- package/core/dist/runtime-v2/config/__tests__/pd-config-agent-binding.test.js.map +1 -1
- package/core/dist/runtime-v2/config/__tests__/pd-config-contract.test.js +5 -6
- package/core/dist/runtime-v2/config/__tests__/pd-config-contract.test.js.map +1 -1
- package/core/dist/runtime-v2/config/__tests__/pd-config-redaction-deep.test.js +0 -1
- package/core/dist/runtime-v2/config/__tests__/pd-config-redaction-deep.test.js.map +1 -1
- package/core/dist/runtime-v2/config/__tests__/pd-config-validation-edge-cases.test.js +0 -1
- package/core/dist/runtime-v2/config/__tests__/pd-config-validation-edge-cases.test.js.map +1 -1
- package/core/dist/runtime-v2/config/pd-config-defaults.d.ts.map +1 -1
- package/core/dist/runtime-v2/config/pd-config-defaults.js +0 -1
- package/core/dist/runtime-v2/config/pd-config-defaults.js.map +1 -1
- package/core/dist/runtime-v2/config/pd-config-types.d.ts +1 -1
- package/core/dist/runtime-v2/config/pd-config-types.d.ts.map +1 -1
- package/core/dist/runtime-v2/config/pd-config-types.js +0 -1
- package/core/dist/runtime-v2/config/pd-config-types.js.map +1 -1
- package/core/dist/runtime-v2/diagnostician/__tests__/diag-rootcause-output.test.js +156 -0
- package/core/dist/runtime-v2/diagnostician/__tests__/diag-rootcause-output.test.js.map +1 -1
- package/core/dist/runtime-v2/feature-flags/feature-flag-contract.d.ts.map +1 -1
- package/core/dist/runtime-v2/feature-flags/feature-flag-contract.js +0 -2
- package/core/dist/runtime-v2/feature-flags/feature-flag-contract.js.map +1 -1
- package/core/dist/runtime-v2/index.d.ts +2 -9
- package/core/dist/runtime-v2/index.d.ts.map +1 -1
- package/core/dist/runtime-v2/index.js +5 -6
- package/core/dist/runtime-v2/index.js.map +1 -1
- package/core/dist/runtime-v2/internalization/__tests__/diag-chain-e2e.test.js +0 -3
- package/core/dist/runtime-v2/internalization/__tests__/diag-chain-e2e.test.js.map +1 -1
- package/core/dist/runtime-v2/internalization/__tests__/internalization-job-graph.test.js +4 -36
- package/core/dist/runtime-v2/internalization/__tests__/internalization-job-graph.test.js.map +1 -1
- package/core/dist/runtime-v2/internalization/__tests__/peer-runner-lineage-injection.test.js +0 -1
- package/core/dist/runtime-v2/internalization/__tests__/peer-runner-lineage-injection.test.js.map +1 -1
- package/core/dist/runtime-v2/internalization/__tests__/queue-actionability.test.js +0 -15
- package/core/dist/runtime-v2/internalization/__tests__/queue-actionability.test.js.map +1 -1
- package/core/dist/runtime-v2/internalization/index.d.ts +1 -7
- package/core/dist/runtime-v2/internalization/index.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/index.js +1 -4
- package/core/dist/runtime-v2/internalization/index.js.map +1 -1
- package/core/dist/runtime-v2/internalization/internalization-job-graph.d.ts +7 -18
- package/core/dist/runtime-v2/internalization/internalization-job-graph.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/internalization-job-graph.js +7 -24
- package/core/dist/runtime-v2/internalization/internalization-job-graph.js.map +1 -1
- package/core/dist/runtime-v2/internalization/internalization-state-machine.d.ts +3 -2
- package/core/dist/runtime-v2/internalization/internalization-state-machine.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/internalization-state-machine.js +4 -3
- package/core/dist/runtime-v2/internalization/internalization-state-machine.js.map +1 -1
- package/core/dist/runtime-v2/internalization/peer-runner-contracts.d.ts +6 -6
- package/core/dist/runtime-v2/internalization/peer-runner-contracts.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/peer-runner-contracts.js +0 -3
- package/core/dist/runtime-v2/internalization/peer-runner-contracts.js.map +1 -1
- package/core/dist/runtime-v2/principle-tree/ledger-codec.d.ts +30 -0
- package/core/dist/runtime-v2/principle-tree/ledger-codec.d.ts.map +1 -0
- package/core/dist/runtime-v2/principle-tree/ledger-codec.js +154 -0
- package/core/dist/runtime-v2/principle-tree/ledger-codec.js.map +1 -0
- package/core/dist/runtime-v2/recovery-sweep-service.d.ts.map +1 -1
- package/core/dist/runtime-v2/recovery-sweep-service.js +2 -2
- package/core/dist/runtime-v2/recovery-sweep-service.js.map +1 -1
- package/core/dist/runtime-v2/store/candidate/__tests__/recommendation-kind-resolver.test.js +1 -1
- package/core/dist/runtime-v2/store/candidate/__tests__/recommendation-kind-resolver.test.js.map +1 -1
- package/core/dist/runtime-v2/types/index.d.ts +2 -0
- package/core/dist/runtime-v2/types/index.d.ts.map +1 -1
- package/core/dist/runtime-v2/types/index.js +1 -0
- package/core/dist/runtime-v2/types/index.js.map +1 -1
- package/core/dist/runtime-v2/types/ledger-store.d.ts +101 -0
- package/core/dist/runtime-v2/types/ledger-store.d.ts.map +1 -0
- package/core/dist/runtime-v2/types/ledger-store.js +15 -0
- package/core/dist/runtime-v2/types/ledger-store.js.map +1 -0
- package/core/dist/runtime-v2/types/pain-signal.d.ts +5 -3
- package/core/dist/runtime-v2/types/pain-signal.d.ts.map +1 -1
- package/core/dist/runtime-v2/types/pain-signal.js +23 -3
- package/core/dist/runtime-v2/types/pain-signal.js.map +1 -1
- package/core/package.json +3 -3
- package/dist/installer.d.ts.map +1 -1
- package/dist/installer.js +42 -5
- package/dist/installer.js.map +1 -1
- package/dist/mvp-config.d.ts +1 -1
- package/dist/mvp-config.d.ts.map +1 -1
- package/dist/mvp-config.js +4 -8
- package/dist/mvp-config.js.map +1 -1
- package/dist/utils/env.d.ts.map +1 -1
- package/dist/utils/env.js +10 -4
- package/dist/utils/env.js.map +1 -1
- package/package.json +1 -1
- package/pd-cli/dist/commands/__tests__/legacy-cleanup.test.js +11 -3
- package/pd-cli/dist/commands/__tests__/legacy-cleanup.test.js.map +1 -1
- package/pd-cli/dist/commands/build-trajectory-evidence.d.ts.map +1 -1
- package/pd-cli/dist/commands/build-trajectory-evidence.js +11 -5
- package/pd-cli/dist/commands/build-trajectory-evidence.js.map +1 -1
- package/pd-cli/dist/commands/candidate.d.ts.map +1 -1
- package/pd-cli/dist/commands/candidate.js +2 -1
- package/pd-cli/dist/commands/candidate.js.map +1 -1
- package/pd-cli/dist/commands/health.d.ts.map +1 -1
- package/pd-cli/dist/commands/health.js +2 -1
- package/pd-cli/dist/commands/health.js.map +1 -1
- package/pd-cli/dist/commands/runtime-activation.js.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-integrity.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-integrity.js +3 -1
- package/pd-cli/dist/commands/runtime-internalization-integrity.js.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-run-once.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-run-once.js +3 -61
- package/pd-cli/dist/commands/runtime-internalization-run-once.js.map +1 -1
- package/pd-cli/dist/commands/runtime-uat.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-uat.js +4 -1
- package/pd-cli/dist/commands/runtime-uat.js.map +1 -1
- package/pd-cli/dist/legacy/session-history-import.js +7 -5
- package/pd-cli/dist/legacy/session-history-import.js.map +1 -1
- package/pd-cli/dist/services/__tests__/runtime-adapter-resolver.test.js +13 -2
- package/pd-cli/dist/services/__tests__/runtime-adapter-resolver.test.js.map +1 -1
- package/pd-cli/dist/services/pain-flood-simulation-runner.d.ts.map +1 -1
- package/pd-cli/dist/services/pain-flood-simulation-runner.js +6 -2
- package/pd-cli/dist/services/pain-flood-simulation-runner.js.map +1 -1
- package/pd-cli/dist/services/runtime-adapter-resolver.d.ts.map +1 -1
- package/pd-cli/dist/services/runtime-adapter-resolver.js +6 -4
- package/pd-cli/dist/services/runtime-adapter-resolver.js.map +1 -1
- package/plugin/dist/commands/capabilities.js +3 -2
- package/plugin/dist/commands/disable-impl.js +1 -1
- package/plugin/dist/commands/focus.js +10 -2
- package/plugin/dist/commands/rollback-impl.js +1 -1
- package/plugin/dist/commands/thinking-os.js +5 -1
- package/plugin/dist/core/correction-cue-learner.js +2 -0
- package/plugin/dist/core/event-log.js +17 -10
- package/plugin/dist/core/focus-history.js +1 -1
- package/plugin/dist/core/hygiene/tracker.js +3 -3
- package/plugin/dist/core/principle-compiler/compiler.js +2 -0
- package/plugin/dist/core/replay-engine.js +1 -1
- package/plugin/dist/core/rule-host.js +3 -1
- package/plugin/dist/core/schema/schema-definitions.js +3 -0
- package/plugin/dist/core/thinking-os-parser.js +13 -4
- package/plugin/dist/core/trajectory-types.d.ts +5 -0
- package/plugin/dist/core/trajectory.d.ts +1 -0
- package/plugin/dist/core/trajectory.js +29 -8
- package/plugin/dist/hooks/after-tool-call-helpers.d.ts +5 -0
- package/plugin/dist/hooks/after-tool-call-helpers.js +64 -0
- package/plugin/dist/hooks/llm.d.ts +8 -0
- package/plugin/dist/hooks/llm.js +30 -0
- package/plugin/dist/hooks/trajectory-collector.d.ts +20 -4
- package/plugin/dist/hooks/trajectory-collector.js +95 -156
- package/plugin/dist/hooks/trajectory-evidence.js +6 -2
- package/plugin/dist/index.js +7 -2
- package/plugin/dist/openclaw-sdk.d.ts +5 -1
- package/plugin/dist/service/evolution-worker.js +7 -3
- package/plugin/dist/service/internalization-auto-consumer-service.js +2 -1
- package/plugin/dist/service/runtime-summary-service.js +8 -1
- package/plugin/dist/service/workflow-watchdog.js +2 -1
- package/plugin/dist/utils/retry.js +7 -2
- package/plugin/dist/utils/session-key.js +4 -1
- package/core/dist/io.d.ts +0 -35
- package/core/dist/io.d.ts.map +0 -1
- package/core/dist/io.js +0 -95
- package/core/dist/io.js.map +0 -1
- package/core/dist/runtime-v2/__tests__/trainer-output-validator.test.d.ts +0 -2
- package/core/dist/runtime-v2/__tests__/trainer-output-validator.test.d.ts.map +0 -1
- package/core/dist/runtime-v2/__tests__/trainer-output-validator.test.js +0 -257
- package/core/dist/runtime-v2/__tests__/trainer-output-validator.test.js.map +0 -1
- package/core/dist/runtime-v2/__tests__/trainer-runner-vslice.test.d.ts +0 -2
- package/core/dist/runtime-v2/__tests__/trainer-runner-vslice.test.d.ts.map +0 -1
- package/core/dist/runtime-v2/__tests__/trainer-runner-vslice.test.js +0 -514
- package/core/dist/runtime-v2/__tests__/trainer-runner-vslice.test.js.map +0 -1
- package/core/dist/runtime-v2/internalization/__tests__/trainer-prompt-builder.test.d.ts +0 -2
- package/core/dist/runtime-v2/internalization/__tests__/trainer-prompt-builder.test.d.ts.map +0 -1
- package/core/dist/runtime-v2/internalization/__tests__/trainer-prompt-builder.test.js +0 -141
- package/core/dist/runtime-v2/internalization/__tests__/trainer-prompt-builder.test.js.map +0 -1
- package/core/dist/runtime-v2/internalization/trainer-output.d.ts +0 -122
- package/core/dist/runtime-v2/internalization/trainer-output.d.ts.map +0 -1
- package/core/dist/runtime-v2/internalization/trainer-output.js +0 -223
- package/core/dist/runtime-v2/internalization/trainer-output.js.map +0 -1
- package/core/dist/runtime-v2/internalization/trainer-prompt-builder.d.ts +0 -24
- package/core/dist/runtime-v2/internalization/trainer-prompt-builder.d.ts.map +0 -1
- package/core/dist/runtime-v2/internalization/trainer-prompt-builder.js +0 -57
- package/core/dist/runtime-v2/internalization/trainer-prompt-builder.js.map +0 -1
- package/core/dist/runtime-v2/internalization/trainer-runner.d.ts +0 -76
- package/core/dist/runtime-v2/internalization/trainer-runner.d.ts.map +0 -1
- package/core/dist/runtime-v2/internalization/trainer-runner.js +0 -540
- package/core/dist/runtime-v2/internalization/trainer-runner.js.map +0 -1
- package/plugin/dist/core/external-training-contract.d.ts +0 -276
- package/plugin/dist/core/external-training-contract.js +0 -269
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ Three MVP-Core channels are always enabled and cannot be disabled:
|
|
|
18
18
|
- `code_tool_hook` — RuleHost hard enforcement
|
|
19
19
|
- `defer_archive` — graceful deferral
|
|
20
20
|
|
|
21
|
-
Quiet and gone capabilities (gfi, nocturnal, idle_trigger
|
|
21
|
+
Quiet and gone capabilities (gfi, nocturnal, idle_trigger) are **not surfaced** to users.
|
|
22
22
|
|
|
23
23
|
## Usage
|
|
24
24
|
|
|
@@ -26,6 +26,12 @@ export class AuthConfig {
|
|
|
26
26
|
return false;
|
|
27
27
|
}
|
|
28
28
|
const [, provided] = match;
|
|
29
|
+
if (!provided) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
if (!this.token) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
29
35
|
const providedBuf = Buffer.from(provided, 'utf8');
|
|
30
36
|
const expectedBuf = Buffer.from(this.token, 'utf8');
|
|
31
37
|
if (providedBuf.length !== expectedBuf.length) {
|
|
@@ -45,7 +45,10 @@ function resolveWorkspaceDir(argv) {
|
|
|
45
45
|
let explicitWorkspace = undefined;
|
|
46
46
|
for (let i = 0; i < args.length; i++) {
|
|
47
47
|
if (args[i] === '--workspace' && i + 1 < args.length) {
|
|
48
|
-
|
|
48
|
+
const next = args[i + 1];
|
|
49
|
+
if (next !== undefined) {
|
|
50
|
+
explicitWorkspace = path.resolve(next);
|
|
51
|
+
}
|
|
49
52
|
break;
|
|
50
53
|
}
|
|
51
54
|
}
|
|
@@ -60,12 +63,15 @@ function resolveWorkspaceDir(argv) {
|
|
|
60
63
|
const workspaces = configStore.getWorkspaces();
|
|
61
64
|
const enabled = workspaces.filter(e => e.config?.enabled !== false);
|
|
62
65
|
if (enabled.length > 0) {
|
|
63
|
-
const
|
|
64
|
-
if (
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
const [first] = enabled;
|
|
67
|
+
if (first) {
|
|
68
|
+
const resolved = path.resolve(first.path);
|
|
69
|
+
if (fs.existsSync(resolved)) {
|
|
70
|
+
console.log('[pd-console] No --workspace flag; using registered workspace: ' + resolved);
|
|
71
|
+
return resolved;
|
|
72
|
+
}
|
|
73
|
+
console.warn('[pd-console] Registered workspace path does not exist: ' + resolved + ', falling back to cwd');
|
|
67
74
|
}
|
|
68
|
-
console.warn('[pd-console] Registered workspace path does not exist: ' + resolved + ', falling back to cwd');
|
|
69
75
|
}
|
|
70
76
|
return process.cwd();
|
|
71
77
|
}
|
|
@@ -78,24 +84,33 @@ function parseArgs(argv) {
|
|
|
78
84
|
let token = undefined;
|
|
79
85
|
for (let i = 0; i < args.length; i++) {
|
|
80
86
|
if (args[i] === '--port' && i + 1 < args.length) {
|
|
81
|
-
const
|
|
82
|
-
if (
|
|
83
|
-
|
|
84
|
-
|
|
87
|
+
const portStr = args[i + 1];
|
|
88
|
+
if (portStr !== undefined) {
|
|
89
|
+
const parsed = parseInt(portStr, 10);
|
|
90
|
+
if (Number.isNaN(parsed) || parsed < 1 || parsed > 65535) {
|
|
91
|
+
console.error('Invalid port: ' + portStr + '. Must be 1-65535.');
|
|
92
|
+
process.exit(1);
|
|
93
|
+
}
|
|
94
|
+
port = parsed;
|
|
95
|
+
i++;
|
|
85
96
|
}
|
|
86
|
-
port = parsed;
|
|
87
|
-
i++;
|
|
88
97
|
}
|
|
89
98
|
else if (args[i] === '--host' && i + 1 < args.length) {
|
|
90
|
-
|
|
91
|
-
|
|
99
|
+
const next = args[i + 1];
|
|
100
|
+
if (next !== undefined) {
|
|
101
|
+
host = next;
|
|
102
|
+
i++;
|
|
103
|
+
}
|
|
92
104
|
}
|
|
93
105
|
else if (args[i] === '--no-auth') {
|
|
94
106
|
noAuth = true;
|
|
95
107
|
}
|
|
96
108
|
else if (args[i] === '--token' && i + 1 < args.length) {
|
|
97
|
-
|
|
98
|
-
|
|
109
|
+
const next = args[i + 1];
|
|
110
|
+
if (next !== undefined) {
|
|
111
|
+
token = next;
|
|
112
|
+
i++;
|
|
113
|
+
}
|
|
99
114
|
}
|
|
100
115
|
}
|
|
101
116
|
if (noAuth && host !== '127.0.0.1' && host !== 'localhost') {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { SqliteConnection, SqliteApprovalQueueStore, SqlitePIArtifactStore, ApprovalQueue,
|
|
1
|
+
import { SqliteConnection, SqliteApprovalQueueStore, SqlitePIArtifactStore, ApprovalQueue, } from '@principles/core/runtime-v2';
|
|
2
|
+
import { loadLedger } from '@principles/core/principle-tree-ledger';
|
|
2
3
|
import * as fs from 'node:fs';
|
|
3
4
|
import * as path from 'node:path';
|
|
4
5
|
/** Type guard: non-null object (not array). Replaces `as Record<string, unknown>` assertions. */
|
|
@@ -41,8 +42,10 @@ function extractCandidateDescription(contentJson) {
|
|
|
41
42
|
if (typeof obj.implementationCode === 'string') {
|
|
42
43
|
const principleMatch = /\/\/\s*Principle:\s*(.+)/.exec(obj.implementationCode);
|
|
43
44
|
const ruleMatch = /\/\/\s*Rule:\s*(.+)/.exec(obj.implementationCode);
|
|
44
|
-
const
|
|
45
|
-
const
|
|
45
|
+
const principleRaw = principleMatch ? principleMatch[1] : undefined;
|
|
46
|
+
const ruleRaw = ruleMatch ? ruleMatch[1] : undefined;
|
|
47
|
+
const principleText = principleRaw ? principleRaw.trim() : null;
|
|
48
|
+
const ruleText = ruleRaw ? ruleRaw.trim() : null;
|
|
46
49
|
if (principleText && ruleText)
|
|
47
50
|
return `${principleText} — ${ruleText}`;
|
|
48
51
|
if (ruleText)
|
|
@@ -49,6 +49,10 @@ export async function handleActivationsRoute(req, res, workspaceDir, subPath) {
|
|
|
49
49
|
const disableExec = /^\/([^/]+)\/disable$/.exec(subPath);
|
|
50
50
|
if (req.method === 'POST' && disableExec) {
|
|
51
51
|
const [, rawId] = disableExec;
|
|
52
|
+
if (!rawId) {
|
|
53
|
+
sendError(res, 400, 'invalid_id', 'Activation ID is missing');
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
52
56
|
let activationId;
|
|
53
57
|
try {
|
|
54
58
|
activationId = decodeURIComponent(rawId);
|
|
@@ -77,9 +77,14 @@ export async function handleApprovalsRoute(req, res, workspaceDir, subPath) {
|
|
|
77
77
|
// GET /api/v1/approvals/:id - detail
|
|
78
78
|
const detailMatch = /^[/]([^/]+)$/.exec(subPath);
|
|
79
79
|
if (req.method === 'GET' && detailMatch) {
|
|
80
|
+
const [, rawId] = detailMatch;
|
|
81
|
+
if (!rawId) {
|
|
82
|
+
sendError(res, 400, 'invalid_id', 'Approval ID is missing');
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
80
85
|
let approvalId;
|
|
81
86
|
try {
|
|
82
|
-
approvalId = decodeURIComponent(
|
|
87
|
+
approvalId = decodeURIComponent(rawId);
|
|
83
88
|
}
|
|
84
89
|
catch {
|
|
85
90
|
sendError(res, 400, 'invalid_id', 'Approval ID contains invalid URI encoding');
|
|
@@ -101,9 +106,14 @@ export async function handleApprovalsRoute(req, res, workspaceDir, subPath) {
|
|
|
101
106
|
// POST /api/v1/approvals/:id/approve
|
|
102
107
|
const approveMatch = /^[/]([^/]+)[/]approve$/.exec(subPath);
|
|
103
108
|
if (req.method === 'POST' && approveMatch) {
|
|
109
|
+
const [, rawId] = approveMatch;
|
|
110
|
+
if (!rawId) {
|
|
111
|
+
sendError(res, 400, 'invalid_id', 'Approval ID is missing');
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
104
114
|
let approvalId;
|
|
105
115
|
try {
|
|
106
|
-
approvalId = decodeURIComponent(
|
|
116
|
+
approvalId = decodeURIComponent(rawId);
|
|
107
117
|
}
|
|
108
118
|
catch {
|
|
109
119
|
sendError(res, 400, 'invalid_id', 'Approval ID contains invalid URI encoding');
|
|
@@ -151,9 +161,14 @@ export async function handleApprovalsRoute(req, res, workspaceDir, subPath) {
|
|
|
151
161
|
// POST /api/v1/approvals/:id/reject
|
|
152
162
|
const rejectMatch = /^[/]([^/]+)[/]reject$/.exec(subPath);
|
|
153
163
|
if (req.method === 'POST' && rejectMatch) {
|
|
164
|
+
const [, rawId] = rejectMatch;
|
|
165
|
+
if (!rawId) {
|
|
166
|
+
sendError(res, 400, 'invalid_id', 'Approval ID is missing');
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
154
169
|
let approvalId;
|
|
155
170
|
try {
|
|
156
|
-
approvalId = decodeURIComponent(
|
|
171
|
+
approvalId = decodeURIComponent(rawId);
|
|
157
172
|
}
|
|
158
173
|
catch {
|
|
159
174
|
sendError(res, 400, 'invalid_id', 'Approval ID contains invalid URI encoding');
|
|
@@ -201,9 +216,14 @@ export async function handleApprovalsRoute(req, res, workspaceDir, subPath) {
|
|
|
201
216
|
// POST /api/v1/approvals/:id/edit — edit a pending approval's artifact (P1 #2 fix)
|
|
202
217
|
const editMatch = /^[/]([^/]+)[/]edit$/.exec(subPath);
|
|
203
218
|
if (req.method === 'POST' && editMatch) {
|
|
219
|
+
const [, rawId] = editMatch;
|
|
220
|
+
if (!rawId) {
|
|
221
|
+
sendError(res, 400, 'invalid_id', 'Approval ID is missing');
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
204
224
|
let approvalId;
|
|
205
225
|
try {
|
|
206
|
-
approvalId = decodeURIComponent(
|
|
226
|
+
approvalId = decodeURIComponent(rawId);
|
|
207
227
|
}
|
|
208
228
|
catch {
|
|
209
229
|
sendError(res, 400, 'invalid_id', 'Approval ID contains invalid URI encoding');
|
|
@@ -78,17 +78,19 @@ export async function handleFeedbackReportsRoute(req, res, ctx) {
|
|
|
78
78
|
if (method === 'POST') {
|
|
79
79
|
// Feature flag gate — feedback_channel must be enabled to create drafts
|
|
80
80
|
if (ctx.featureFlags
|
|
81
|
-
&& Object.hasOwn(ctx.featureFlags, 'feedback_channel')
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
&& Object.hasOwn(ctx.featureFlags, 'feedback_channel')) {
|
|
82
|
+
const feedbackChannel = ctx.featureFlags.feedback_channel;
|
|
83
|
+
if (feedbackChannel && !feedbackChannel.enabled) {
|
|
84
|
+
sendError(res, 403, 'feedback_channel_disabled', 'feedback_channel feature flag is disabled. Enable feedback_channel in .pd/feature-flags.yaml to use feedback reports.');
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
85
87
|
}
|
|
86
88
|
const bodyResult = await readJsonBody(req);
|
|
87
89
|
if (!bodyResult.ok) {
|
|
88
90
|
sendBadRequest(res, bodyResult.error);
|
|
89
91
|
return;
|
|
90
92
|
}
|
|
91
|
-
if (bodyResult.value === null || typeof bodyResult.value !== 'object') {
|
|
93
|
+
if (bodyResult.value === null || typeof bodyResult.value !== 'object' || Array.isArray(bodyResult.value)) {
|
|
92
94
|
sendBadRequest(res, 'request body must be a JSON object with {input, diagnostics}');
|
|
93
95
|
return;
|
|
94
96
|
}
|
|
@@ -18,9 +18,14 @@ export async function handleLifecycleRoute(req, res, workspaceDir, subPath) {
|
|
|
18
18
|
// GET /api/v1/lifecycle/principles/:principleId
|
|
19
19
|
const principleMatch = /^[/]principles[/]([^/]+)$/.exec(subPath);
|
|
20
20
|
if (principleMatch) {
|
|
21
|
+
const [, rawId] = principleMatch;
|
|
22
|
+
if (!rawId) {
|
|
23
|
+
sendError(res, 400, 'invalid_encoding', 'Principle ID is missing');
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
21
26
|
let principleId;
|
|
22
27
|
try {
|
|
23
|
-
principleId = decodeURIComponent(
|
|
28
|
+
principleId = decodeURIComponent(rawId);
|
|
24
29
|
}
|
|
25
30
|
catch {
|
|
26
31
|
sendError(res, 400, 'invalid_encoding', 'Principle ID contains invalid percent encoding');
|
|
@@ -96,7 +96,7 @@ export async function handlePrinciplesRoute({ req, res, workspaceDir, subPath, }
|
|
|
96
96
|
sendSuccess(res, result);
|
|
97
97
|
}
|
|
98
98
|
catch (err) {
|
|
99
|
-
sendError(res, 500, 'principles_list_error', err.message);
|
|
99
|
+
sendError(res, 500, 'principles_list_error', err instanceof Error ? err.message : String(err));
|
|
100
100
|
}
|
|
101
101
|
return;
|
|
102
102
|
}
|
|
@@ -104,6 +104,10 @@ export async function handlePrinciplesRoute({ req, res, workspaceDir, subPath, }
|
|
|
104
104
|
const trajectoryMatch = /^\/([^/]+)\/trajectory$/.exec(subPath);
|
|
105
105
|
if (trajectoryMatch) {
|
|
106
106
|
const [, rawPrincipleId] = trajectoryMatch;
|
|
107
|
+
if (!rawPrincipleId) {
|
|
108
|
+
sendError(res, 400, 'invalid_principle_id', 'Principle ID is missing');
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
107
111
|
let decodedPrincipleId;
|
|
108
112
|
try {
|
|
109
113
|
decodedPrincipleId = decodeURIComponent(rawPrincipleId);
|
|
@@ -130,6 +134,10 @@ export async function handlePrinciplesRoute({ req, res, workspaceDir, subPath, }
|
|
|
130
134
|
const detailMatch = /^\/([^/]+)$/.exec(subPath);
|
|
131
135
|
if (detailMatch) {
|
|
132
136
|
const [, principleId] = detailMatch;
|
|
137
|
+
if (!principleId) {
|
|
138
|
+
sendError(res, 400, 'invalid_principle_id', 'Principle ID is missing');
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
133
141
|
try {
|
|
134
142
|
const result = await model.getPrincipleDetail(principleId);
|
|
135
143
|
if (!result) {
|
|
@@ -139,7 +147,7 @@ export async function handlePrinciplesRoute({ req, res, workspaceDir, subPath, }
|
|
|
139
147
|
sendSuccess(res, result);
|
|
140
148
|
}
|
|
141
149
|
catch (err) {
|
|
142
|
-
sendError(res, 500, 'principle_detail_error', err.message);
|
|
150
|
+
sendError(res, 500, 'principle_detail_error', err instanceof Error ? err.message : String(err));
|
|
143
151
|
}
|
|
144
152
|
return;
|
|
145
153
|
}
|
|
@@ -56,6 +56,10 @@ export function createWorkspacesRoutes(configStore, workspaceService) {
|
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
58
|
const [, wsName, rest] = nameMatch;
|
|
59
|
+
if (!wsName) {
|
|
60
|
+
sendError(res, 400, 'invalid_name', 'Workspace name is missing');
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
59
63
|
let decodedWsName;
|
|
60
64
|
try {
|
|
61
65
|
decodedWsName = decodeURIComponent(wsName);
|
|
@@ -63,7 +63,10 @@ export function computeValueBuckets(principles, bucketCount = 5) {
|
|
|
63
63
|
}));
|
|
64
64
|
for (const p of principles) {
|
|
65
65
|
const bucketIndex = Math.min(Math.floor(p.valueScore / bucketSize), bucketCount - 1);
|
|
66
|
-
buckets[bucketIndex]
|
|
66
|
+
const bucket = buckets[bucketIndex];
|
|
67
|
+
if (bucket) {
|
|
68
|
+
bucket.count++;
|
|
69
|
+
}
|
|
67
70
|
}
|
|
68
71
|
return buckets;
|
|
69
72
|
}
|
|
@@ -27,7 +27,7 @@ function detectCodeBlocks(text) {
|
|
|
27
27
|
if (match.index > lastIndex) {
|
|
28
28
|
parts.push({ type: "text", content: text.slice(lastIndex, match.index) });
|
|
29
29
|
}
|
|
30
|
-
parts.push({ type: "code", language: match[1] || "", code: match[2].trimEnd() });
|
|
30
|
+
parts.push({ type: "code", language: match[1] || "", code: (match[2] ?? "").trimEnd() });
|
|
31
31
|
lastIndex = match.index + match[0].length;
|
|
32
32
|
}
|
|
33
33
|
if (lastIndex < text.length) {
|
|
@@ -77,18 +77,22 @@ function renderTextBlock(text) {
|
|
|
77
77
|
inList = false;
|
|
78
78
|
}
|
|
79
79
|
if (headingMatch) {
|
|
80
|
-
const
|
|
80
|
+
const levelStr = headingMatch[1] ?? "";
|
|
81
|
+
const content = headingMatch[2] ?? "";
|
|
82
|
+
const level = levelStr.length;
|
|
81
83
|
const Tag = `h${level}`;
|
|
82
84
|
const sizeClass = level === 1 ? "text-lg" : level === 2 ? "text-base" : "text-sm";
|
|
83
|
-
nodes.push(_jsx(Tag, { className: cn("font-semibold mt-3 mb-1", sizeClass), children: renderInlineMarkdown(
|
|
85
|
+
nodes.push(_jsx(Tag, { className: cn("font-semibold mt-3 mb-1", sizeClass), children: renderInlineMarkdown(content) }, key++));
|
|
84
86
|
}
|
|
85
87
|
else if (listItemMatch) {
|
|
86
88
|
inList = true;
|
|
87
|
-
|
|
89
|
+
const itemText = listItemMatch[1] ?? "";
|
|
90
|
+
nodes.push(_jsxs("div", { className: "flex items-start gap-2 ml-2", children: [_jsx("span", { className: "text-muted-foreground mt-0.5", children: "\u2022" }), _jsx("span", { className: "flex-1", children: renderInlineMarkdown(itemText) })] }, key++));
|
|
88
91
|
}
|
|
89
92
|
else if (numberedItemMatch) {
|
|
90
93
|
inList = true;
|
|
91
|
-
|
|
94
|
+
const itemText = numberedItemMatch[1] ?? "";
|
|
95
|
+
nodes.push(_jsxs("div", { className: "flex items-start gap-2 ml-2", children: [_jsx("span", { className: "text-muted-foreground text-xs tabular-nums", children: "\u2022" }), _jsx("span", { className: "flex-1", children: renderInlineMarkdown(itemText) })] }, key++));
|
|
92
96
|
}
|
|
93
97
|
else if (line.trim() === "") {
|
|
94
98
|
nodes.push(_jsx("div", { className: "h-2" }, key++));
|
|
@@ -726,8 +726,7 @@
|
|
|
726
726
|
"code_tool_hook": "RuleHost",
|
|
727
727
|
"defer_archive": "Defer Archive",
|
|
728
728
|
"prompt": "Prompt",
|
|
729
|
-
"skill": "Skill (retired)"
|
|
730
|
-
"model_training": "Model Training (retired)"
|
|
729
|
+
"skill": "Skill (retired)"
|
|
731
730
|
},
|
|
732
731
|
"retired": "This channel is retired and cannot be actioned",
|
|
733
732
|
"riskLevel": "Risk Level"
|
|
@@ -53,7 +53,6 @@ const LOCAL_LABELS = {
|
|
|
53
53
|
'defer_archive': '延迟归档',
|
|
54
54
|
'code_tool_hook': 'Code Tool Hook',
|
|
55
55
|
'skill': '技能激活(已停用)',
|
|
56
|
-
'model_training': '模型训练(已停用)',
|
|
57
56
|
},
|
|
58
57
|
readiness: {
|
|
59
58
|
'ready': '就绪',
|
|
@@ -149,7 +148,10 @@ export function enumLabel(category, value, t) {
|
|
|
149
148
|
// 2. Fall back to local map
|
|
150
149
|
const localMap = LOCAL_LABELS[category];
|
|
151
150
|
if (localMap && Object.hasOwn(localMap, value)) {
|
|
152
|
-
|
|
151
|
+
const label = localMap[value];
|
|
152
|
+
if (label !== undefined) {
|
|
153
|
+
return label;
|
|
154
|
+
}
|
|
153
155
|
}
|
|
154
156
|
// 3. Last resort: raw value
|
|
155
157
|
return value;
|