create-principles-disciple 1.92.0 → 1.94.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/console/dist/server/config/AuthConfig.js +6 -0
- package/console/dist/server/config/pd-config-store.d.ts +7 -1
- package/console/dist/server/config/pd-config-store.js +11 -1
- package/console/dist/server/index.js +41 -22
- package/console/dist/server/models/ApprovalsConsoleModel.js +4 -12
- 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/utils/enum-labels.js +4 -1
- package/console/dist/web/assets/app.js +5 -2
- package/core/dist/index.d.ts +2 -3
- package/core/dist/index.d.ts.map +1 -1
- package/core/dist/index.js +1 -3
- 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/prompt-builder/__tests__/model-config.test.d.ts +2 -0
- package/core/dist/prompt-builder/__tests__/model-config.test.d.ts.map +1 -0
- package/core/dist/prompt-builder/__tests__/model-config.test.js +158 -0
- package/core/dist/prompt-builder/__tests__/model-config.test.js.map +1 -0
- package/core/dist/prompt-builder/__tests__/xml-escape.test.d.ts +2 -0
- package/core/dist/prompt-builder/__tests__/xml-escape.test.d.ts.map +1 -0
- package/core/dist/prompt-builder/__tests__/xml-escape.test.js +42 -0
- package/core/dist/prompt-builder/__tests__/xml-escape.test.js.map +1 -0
- package/core/dist/prompt-builder/index.d.ts +3 -0
- package/core/dist/prompt-builder/index.d.ts.map +1 -1
- package/core/dist/prompt-builder/index.js +2 -0
- package/core/dist/prompt-builder/index.js.map +1 -1
- package/core/dist/prompt-builder/model-config.d.ts +42 -0
- package/core/dist/prompt-builder/model-config.d.ts.map +1 -0
- package/core/dist/prompt-builder/model-config.js +84 -0
- package/core/dist/prompt-builder/model-config.js.map +1 -0
- package/core/dist/prompt-builder/xml-escape.d.ts +12 -0
- package/core/dist/prompt-builder/xml-escape.d.ts.map +1 -0
- package/core/dist/prompt-builder/xml-escape.js +19 -0
- package/core/dist/prompt-builder/xml-escape.js.map +1 -0
- package/core/dist/runtime-v2/__tests__/architecture-regression.test.js +265 -20
- 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__/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-bridge-result-shaping.test.d.ts +2 -0
- package/core/dist/runtime-v2/__tests__/pain-signal-bridge-result-shaping.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/__tests__/pain-signal-bridge-result-shaping.test.js +395 -0
- package/core/dist/runtime-v2/__tests__/pain-signal-bridge-result-shaping.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/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/bridge-result-shaper.d.ts +53 -0
- package/core/dist/runtime-v2/bridge-result-shaper.d.ts.map +1 -0
- package/core/dist/runtime-v2/bridge-result-shaper.js +117 -0
- package/core/dist/runtime-v2/bridge-result-shaper.js.map +1 -0
- package/core/dist/runtime-v2/detection/__tests__/detection-funnel-policy.test.d.ts +13 -0
- package/core/dist/runtime-v2/detection/__tests__/detection-funnel-policy.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/detection/__tests__/detection-funnel-policy.test.js +111 -0
- package/core/dist/runtime-v2/detection/__tests__/detection-funnel-policy.test.js.map +1 -0
- package/core/dist/runtime-v2/detection/detection-funnel-policy.d.ts +103 -0
- package/core/dist/runtime-v2/detection/detection-funnel-policy.d.ts.map +1 -0
- package/core/dist/runtime-v2/detection/detection-funnel-policy.js +135 -0
- package/core/dist/runtime-v2/detection/detection-funnel-policy.js.map +1 -0
- package/core/dist/runtime-v2/detection/index.d.ts +10 -0
- package/core/dist/runtime-v2/detection/index.d.ts.map +1 -0
- package/core/dist/runtime-v2/detection/index.js +9 -0
- package/core/dist/runtime-v2/detection/index.js.map +1 -0
- 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/evidence-triage/__tests__/observation-resolver.test.d.ts +12 -0
- package/core/dist/runtime-v2/evidence-triage/__tests__/observation-resolver.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/__tests__/observation-resolver.test.js +181 -0
- package/core/dist/runtime-v2/evidence-triage/__tests__/observation-resolver.test.js.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/__tests__/triage-policy.test.js +104 -1
- package/core/dist/runtime-v2/evidence-triage/__tests__/triage-policy.test.js.map +1 -1
- package/core/dist/runtime-v2/evidence-triage/index.d.ts +3 -0
- package/core/dist/runtime-v2/evidence-triage/index.d.ts.map +1 -1
- package/core/dist/runtime-v2/evidence-triage/index.js +3 -0
- package/core/dist/runtime-v2/evidence-triage/index.js.map +1 -1
- package/core/dist/runtime-v2/evidence-triage/observation-resolver.d.ts +128 -0
- package/core/dist/runtime-v2/evidence-triage/observation-resolver.d.ts.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/observation-resolver.js +203 -0
- package/core/dist/runtime-v2/evidence-triage/observation-resolver.js.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/triage-policy.d.ts +4 -0
- package/core/dist/runtime-v2/evidence-triage/triage-policy.d.ts.map +1 -1
- package/core/dist/runtime-v2/evidence-triage/triage-policy.js +66 -9
- package/core/dist/runtime-v2/evidence-triage/triage-policy.js.map +1 -1
- package/core/dist/runtime-v2/evidence-triage/types.d.ts +14 -0
- package/core/dist/runtime-v2/evidence-triage/types.d.ts.map +1 -1
- package/core/dist/runtime-v2/evidence-triage/types.js.map +1 -1
- package/core/dist/runtime-v2/feature-flags/__tests__/feature-flag-contract.test.js +33 -4
- package/core/dist/runtime-v2/feature-flags/__tests__/feature-flag-contract.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 +9 -2
- package/core/dist/runtime-v2/feature-flags/feature-flag-contract.js.map +1 -1
- package/core/dist/runtime-v2/feedback/__tests__/redact-sensitive.test.d.ts +15 -0
- package/core/dist/runtime-v2/feedback/__tests__/redact-sensitive.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/feedback/__tests__/redact-sensitive.test.js +450 -0
- package/core/dist/runtime-v2/feedback/__tests__/redact-sensitive.test.js.map +1 -0
- package/core/dist/runtime-v2/feedback/__tests__/render-github-url.test.d.ts +13 -0
- package/core/dist/runtime-v2/feedback/__tests__/render-github-url.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/feedback/__tests__/render-github-url.test.js +243 -0
- package/core/dist/runtime-v2/feedback/__tests__/render-github-url.test.js.map +1 -0
- package/core/dist/runtime-v2/feedback/__tests__/safe-stringify.test.d.ts +12 -0
- package/core/dist/runtime-v2/feedback/__tests__/safe-stringify.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/feedback/__tests__/safe-stringify.test.js +172 -0
- package/core/dist/runtime-v2/feedback/__tests__/safe-stringify.test.js.map +1 -0
- package/core/dist/runtime-v2/index.d.ts +9 -6
- package/core/dist/runtime-v2/index.d.ts.map +1 -1
- package/core/dist/runtime-v2/index.js +8 -4
- package/core/dist/runtime-v2/index.js.map +1 -1
- package/core/dist/runtime-v2/internalization/__tests__/c2-live-runner-chain.test.d.ts +2 -0
- package/core/dist/runtime-v2/internalization/__tests__/c2-live-runner-chain.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/internalization/__tests__/c2-live-runner-chain.test.js +306 -0
- package/core/dist/runtime-v2/internalization/__tests__/c2-live-runner-chain.test.js.map +1 -0
- package/core/dist/runtime-v2/internalization/index.d.ts +0 -16
- package/core/dist/runtime-v2/internalization/index.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/index.js +0 -8
- package/core/dist/runtime-v2/internalization/index.js.map +1 -1
- package/core/dist/runtime-v2/pain-gate/__tests__/pain-diagnostic-gate-policy.test.d.ts +15 -0
- package/core/dist/runtime-v2/pain-gate/__tests__/pain-diagnostic-gate-policy.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/pain-gate/__tests__/pain-diagnostic-gate-policy.test.js +179 -0
- package/core/dist/runtime-v2/pain-gate/__tests__/pain-diagnostic-gate-policy.test.js.map +1 -0
- package/core/dist/runtime-v2/pain-gate/index.d.ts +10 -0
- package/core/dist/runtime-v2/pain-gate/index.d.ts.map +1 -0
- package/core/dist/runtime-v2/pain-gate/index.js +9 -0
- package/core/dist/runtime-v2/pain-gate/index.js.map +1 -0
- package/core/dist/runtime-v2/pain-gate/pain-diagnostic-gate-policy.d.ts +121 -0
- package/core/dist/runtime-v2/pain-gate/pain-diagnostic-gate-policy.d.ts.map +1 -0
- package/core/dist/runtime-v2/pain-gate/pain-diagnostic-gate-policy.js +157 -0
- package/core/dist/runtime-v2/pain-gate/pain-diagnostic-gate-policy.js.map +1 -0
- package/core/dist/runtime-v2/pain-signal-bridge.d.ts.map +1 -1
- package/core/dist/runtime-v2/pain-signal-bridge.js +14 -88
- package/core/dist/runtime-v2/pain-signal-bridge.js.map +1 -1
- package/core/dist/runtime-v2/pain-signal-observability.d.ts.map +1 -1
- package/core/dist/runtime-v2/pain-signal-observability.js +15 -5
- package/core/dist/runtime-v2/pain-signal-observability.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/types/event-types.d.ts +0 -27
- package/core/dist/runtime-v2/types/event-types.d.ts.map +1 -1
- package/core/dist/runtime-v2/types/event-types.js +2 -17
- package/core/dist/runtime-v2/types/event-types.js.map +1 -1
- package/core/dist/runtime-v2/types/index.d.ts +4 -2
- package/core/dist/runtime-v2/types/index.d.ts.map +1 -1
- package/core/dist/runtime-v2/types/index.js +4 -1
- 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 +7 -5
- package/core/dist/runtime-v2/types/pain-signal.d.ts.map +1 -1
- package/core/dist/runtime-v2/types/pain-signal.js +25 -5
- 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 +9 -3
- package/dist/installer.js.map +1 -1
- package/dist/mvp-config.d.ts +0 -10
- package/dist/mvp-config.d.ts.map +1 -1
- package/dist/mvp-config.js +0 -64
- 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/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/mvp-smoke.js +1 -1
- package/pd-cli/dist/commands/mvp-smoke.js.map +1 -1
- package/pd-cli/dist/commands/rulecode.js +1 -1
- package/pd-cli/dist/commands/rulecode.js.map +1 -1
- package/pd-cli/dist/commands/runtime-canary.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-canary.js +10 -11
- package/pd-cli/dist/commands/runtime-canary.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-queue.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-queue.js +13 -16
- package/pd-cli/dist/commands/runtime-internalization-queue.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 -0
- package/pd-cli/dist/commands/runtime-internalization-run-once.js.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-run-rulehost.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-run-rulehost.js +61 -7
- package/pd-cli/dist/commands/runtime-internalization-run-rulehost.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/commands/runtime.js +1 -1
- package/pd-cli/dist/commands/runtime.js.map +1 -1
- package/pd-cli/dist/index.js +67 -34
- package/pd-cli/dist/index.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__/rulehost-readiness.test.d.ts +2 -0
- package/pd-cli/dist/services/__tests__/rulehost-readiness.test.d.ts.map +1 -0
- package/pd-cli/dist/services/__tests__/rulehost-readiness.test.js +314 -0
- package/pd-cli/dist/services/__tests__/rulehost-readiness.test.js.map +1 -0
- package/pd-cli/dist/services/__tests__/runtime-adapter-resolver.test.js +33 -14
- 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/rulehost-readiness.d.ts +62 -0
- package/pd-cli/dist/services/rulehost-readiness.d.ts.map +1 -0
- package/pd-cli/dist/services/rulehost-readiness.js +214 -0
- package/pd-cli/dist/services/rulehost-readiness.js.map +1 -0
- package/pd-cli/dist/services/runtime-adapter-resolver.d.ts +1 -1
- package/pd-cli/dist/services/runtime-adapter-resolver.d.ts.map +1 -1
- package/pd-cli/dist/services/runtime-adapter-resolver.js +9 -7
- 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/evolution-status.js +0 -2
- 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/detection-funnel.d.ts +25 -11
- package/plugin/dist/core/detection-funnel.js +32 -80
- package/plugin/dist/core/event-log.d.ts +1 -3
- package/plugin/dist/core/event-log.js +27 -31
- package/plugin/dist/core/evolution-reducer.d.ts +0 -8
- package/plugin/dist/core/evolution-reducer.js +9 -19
- package/plugin/dist/core/focus-history.js +1 -1
- package/plugin/dist/core/hygiene/tracker.js +3 -3
- package/plugin/dist/core/pain-diagnostic-gate.d.ts +37 -28
- package/plugin/dist/core/pain-diagnostic-gate.js +53 -89
- package/plugin/dist/core/pain.d.ts +0 -63
- package/plugin/dist/core/pain.js +0 -167
- package/plugin/dist/core/paths.d.ts +0 -1
- package/plugin/dist/core/paths.js +2 -1
- 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/migrations/001-init-trajectory.js +3 -6
- package/plugin/dist/core/schema/schema-definitions.js +4 -9
- package/plugin/dist/core/thinking-os-parser.js +13 -4
- package/plugin/dist/core/trajectory.d.ts +0 -16
- package/plugin/dist/core/trajectory.js +9 -60
- package/plugin/dist/hooks/after-tool-call-helpers.d.ts +4 -1
- package/plugin/dist/hooks/after-tool-call-helpers.js +13 -17
- package/plugin/dist/hooks/gate-block-helper.js +57 -17
- package/plugin/dist/hooks/lifecycle.js +3 -6
- package/plugin/dist/hooks/llm.js +66 -26
- package/plugin/dist/hooks/pain.d.ts +3 -1
- package/plugin/dist/hooks/pain.js +119 -49
- package/plugin/dist/hooks/prompt-helpers.d.ts +87 -0
- package/plugin/dist/hooks/prompt-helpers.js +251 -0
- package/plugin/dist/hooks/prompt-types.d.ts +66 -0
- package/plugin/dist/hooks/prompt-types.js +12 -0
- package/plugin/dist/hooks/prompt.d.ts +7 -38
- package/plugin/dist/hooks/prompt.js +361 -325
- package/plugin/dist/hooks/raw-observation-adapter.d.ts +9 -50
- package/plugin/dist/hooks/raw-observation-adapter.js +9 -164
- package/plugin/dist/hooks/raw-observation-types.d.ts +6 -57
- package/plugin/dist/hooks/raw-observation-types.js +5 -9
- package/plugin/dist/hooks/trajectory-collector.d.ts +20 -4
- package/plugin/dist/hooks/trajectory-collector.js +95 -156
- package/plugin/dist/hooks/triage-adapter.js +6 -26
- package/plugin/dist/hooks/trigger-cooldown-tracker.d.ts +12 -0
- package/plugin/dist/hooks/trigger-cooldown-tracker.js +25 -0
- package/plugin/dist/index.js +7 -2
- package/plugin/dist/openclaw-sdk.d.ts +4 -1
- package/plugin/dist/service/evolution-worker.js +8 -62
- package/plugin/dist/service/internalization-auto-consumer-service.js +2 -1
- package/plugin/dist/service/runtime-summary-service.d.ts +0 -2
- package/plugin/dist/service/runtime-summary-service.js +8 -5
- package/plugin/dist/service/workflow-watchdog.js +2 -1
- package/plugin/dist/types/event-types.d.ts +1 -1
- package/plugin/dist/utils/retry.js +7 -2
- package/plugin/dist/utils/session-key.js +4 -1
- package/plugin/scripts/sync-plugin.mjs +33 -22
- package/plugin/scripts/validate-live-path.ts +0 -18
- package/plugin/templates/langs/en/skills/pd-cli-operator/SKILL.md +20 -11
- package/plugin/templates/langs/en/skills/pd-runtime-v2/SKILL.md +10 -0
- package/plugin/templates/langs/zh/skills/pd-cli-operator/SKILL.md +20 -11
- package/plugin/templates/langs/zh/skills/pd-runtime-v2/SKILL.md +10 -0
- package/console/dist/server/config/feature-flags.d.ts +0 -25
- package/console/dist/server/config/feature-flags.js +0 -101
- 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/pd-cli/dist/commands/central-sync.d.ts +0 -10
- package/pd-cli/dist/commands/central-sync.d.ts.map +0 -1
- package/pd-cli/dist/commands/central-sync.js +0 -32
- package/pd-cli/dist/commands/central-sync.js.map +0 -1
- package/pd-cli/dist/services/feature-flag-loader.d.ts +0 -6
- package/pd-cli/dist/services/feature-flag-loader.d.ts.map +0 -1
- package/pd-cli/dist/services/feature-flag-loader.js +0 -53
- package/pd-cli/dist/services/feature-flag-loader.js.map +0 -1
- package/plugin/dist/core/observability.d.ts +0 -40
- package/plugin/dist/core/observability.js +0 -164
- package/plugin/dist/hooks/subagent.d.ts +0 -9
- package/plugin/dist/hooks/subagent.js +0 -122
|
@@ -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) {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* - ERR-013: Object.hasOwn() for untrusted keys
|
|
14
14
|
* - ERR-045: ANY-segment redaction for sensitive keys
|
|
15
15
|
*/
|
|
16
|
-
import type { EffectivePdConfig, RedactedPdConfigSummary, InternalAgentName } from '@principles/core/runtime-v2';
|
|
16
|
+
import type { EffectivePdConfig, RedactedPdConfigSummary, InternalAgentName, FeatureFlagsResult } from '@principles/core/runtime-v2';
|
|
17
17
|
export interface ConfigLoadResultOk {
|
|
18
18
|
ok: true;
|
|
19
19
|
effective: EffectivePdConfig;
|
|
@@ -76,6 +76,12 @@ export declare function validateBindingPayload(payload: unknown): {
|
|
|
76
76
|
};
|
|
77
77
|
export declare function getPdConfigPath(workspaceDir: string): string;
|
|
78
78
|
export declare function loadPdConfig(workspaceDir: string): ConfigLoadResult;
|
|
79
|
+
/**
|
|
80
|
+
* Compute feature flags from the loaded PD config (PRI-460).
|
|
81
|
+
* Works with both ok and error results (uses defaults for errors).
|
|
82
|
+
* Replaces the legacy `loadWorkspaceFeatureFlags` + `buildFeedbackChannelFlags` path.
|
|
83
|
+
*/
|
|
84
|
+
export declare function computeFlagsFromLoadResult(result: ConfigLoadResult): FeatureFlagsResult;
|
|
79
85
|
export declare function getConfigSummary(workspaceDir: string): {
|
|
80
86
|
summary: RedactedPdConfigSummary;
|
|
81
87
|
errors?: {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import * as fs from 'fs';
|
|
17
17
|
import * as path from 'path';
|
|
18
18
|
import yaml from 'js-yaml';
|
|
19
|
-
import { validatePdConfig, computeEffectivePdConfig, redactPdConfig, checkAgentRuntimeReadiness, resolveAgentRuntimeBinding, INTERNAL_AGENT_NAMES, } from '@principles/core/runtime-v2';
|
|
19
|
+
import { validatePdConfig, computeEffectivePdConfig, computeFeatureFlagsFromConfig, redactPdConfig, checkAgentRuntimeReadiness, resolveAgentRuntimeBinding, INTERNAL_AGENT_NAMES, } from '@principles/core/runtime-v2';
|
|
20
20
|
// ── Constants ────────────────────────────────────────────────────────────────
|
|
21
21
|
const PD_CONFIG_DIR = '.pd';
|
|
22
22
|
const PD_CONFIG_FILENAME = 'config.yaml';
|
|
@@ -211,6 +211,16 @@ export function loadPdConfig(workspaceDir) {
|
|
|
211
211
|
warnings: effective.warnings,
|
|
212
212
|
};
|
|
213
213
|
}
|
|
214
|
+
// ── Feature Flags from Config ────────────────────────────────────────────────
|
|
215
|
+
/**
|
|
216
|
+
* Compute feature flags from the loaded PD config (PRI-460).
|
|
217
|
+
* Works with both ok and error results (uses defaults for errors).
|
|
218
|
+
* Replaces the legacy `loadWorkspaceFeatureFlags` + `buildFeedbackChannelFlags` path.
|
|
219
|
+
*/
|
|
220
|
+
export function computeFlagsFromLoadResult(result) {
|
|
221
|
+
const effective = result.ok ? result.effective : result.defaults;
|
|
222
|
+
return computeFeatureFlagsFromConfig(effective);
|
|
223
|
+
}
|
|
214
224
|
// ── Get Redacted Summary ─────────────────────────────────────────────────────
|
|
215
225
|
export function getConfigSummary(workspaceDir) {
|
|
216
226
|
const result = loadPdConfig(workspaceDir);
|
|
@@ -2,7 +2,7 @@ import * as http from 'http';
|
|
|
2
2
|
import * as fs from 'fs';
|
|
3
3
|
import * as path from 'path';
|
|
4
4
|
import { fileURLToPath } from 'url';
|
|
5
|
-
import {
|
|
5
|
+
import { loadPdConfig, computeFlagsFromLoadResult } from './config/pd-config-store.js';
|
|
6
6
|
import { AuthConfig } from './config/AuthConfig.js';
|
|
7
7
|
import { WorkspaceConfigStore } from './config/WorkspaceConfigStore.js';
|
|
8
8
|
import { WorkspaceService } from './models/WorkspaceService.js';
|
|
@@ -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') {
|
|
@@ -182,11 +197,15 @@ function asyncHandler(fn, timeoutMs = REQUEST_TIMEOUT_MS) {
|
|
|
182
197
|
async function initServices(workspaceDir, authConfig) {
|
|
183
198
|
const configStore = new WorkspaceConfigStore();
|
|
184
199
|
const workspaceService = new WorkspaceService(configStore);
|
|
185
|
-
// Load feature flags — fail-closed: on error, feedback_channel
|
|
186
|
-
const
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
|
|
200
|
+
// Load feature flags from canonical .pd/config.yaml — fail-closed: on error, feedback_channel uses defaults
|
|
201
|
+
const configResult = loadPdConfig(workspaceDir);
|
|
202
|
+
const pdFlags = computeFlagsFromLoadResult(configResult);
|
|
203
|
+
const feedbackChannelEnabled = pdFlags.flags.feedback_channel?.enabled ?? false;
|
|
204
|
+
const feedbackFlags = {
|
|
205
|
+
feedback_channel: { enabled: feedbackChannelEnabled },
|
|
206
|
+
};
|
|
207
|
+
if (!configResult.ok) {
|
|
208
|
+
console.warn('[pd-console] PD config loading failed (using defaults for feedback channel):', configResult.errors.map(e => e.reason).join('; '));
|
|
190
209
|
}
|
|
191
210
|
return {
|
|
192
211
|
workspaceDir,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as fs from 'node:fs';
|
|
2
2
|
import * as path from 'node:path';
|
|
3
3
|
import { SqliteConnection, SqliteApprovalQueueStore, SqliteActivationStateStore, SqlitePIArtifactStore, ActivationDispatcher, PromptWriter, DeferArchiveWriter, RuleHostWriter, createProductionGateDeps, ApprovalCompletionService, ApprovalQueue, mapConfidenceToLabel, isArtifactRevisionOf, MVP_CHANNELS, } from '@principles/core/runtime-v2';
|
|
4
|
-
import {
|
|
4
|
+
import { loadPdConfig, computeFlagsFromLoadResult } from '../config/pd-config-store.js';
|
|
5
5
|
const MVP_PROVEN_CHANNELS = new Set(MVP_CHANNELS);
|
|
6
6
|
const EMPTY_STATS = { pending: 0, approved: 0, rejected: 0, cancelled: 0 };
|
|
7
7
|
function isMissingTableError(err) {
|
|
@@ -216,17 +216,9 @@ export class ApprovalsConsoleModel {
|
|
|
216
216
|
// Feature flag gate (Contract F): when story_a_approval_completion is disabled,
|
|
217
217
|
// the new orchestrator is deactivated without damaging existing data.
|
|
218
218
|
// The approval remains in 'approved' status; only activation is skipped.
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
decision: 'refused',
|
|
223
|
-
reason: `feature_flag_load_failed: ${flagResult.reason}`,
|
|
224
|
-
nextAction: 'fix feature flag config or manually dispatch via pd runtime activation dispatch',
|
|
225
|
-
channel: existing.channel,
|
|
226
|
-
riskLevel: existing.riskLevel,
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
const completionFlag = flagResult.flags.flags.story_a_approval_completion;
|
|
219
|
+
const configResult = loadPdConfig(this.workspaceDir);
|
|
220
|
+
const pdFlags = computeFlagsFromLoadResult(configResult);
|
|
221
|
+
const completionFlag = pdFlags.flags.story_a_approval_completion;
|
|
230
222
|
if (!completionFlag || !completionFlag.enabled) {
|
|
231
223
|
// Flag disabled — return undefined so the caller knows activation was skipped.
|
|
232
224
|
// The approval record itself is not rolled back (Contract F: no data damage).
|
|
@@ -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/config.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++));
|
|
@@ -148,7 +148,10 @@ export function enumLabel(category, value, t) {
|
|
|
148
148
|
// 2. Fall back to local map
|
|
149
149
|
const localMap = LOCAL_LABELS[category];
|
|
150
150
|
if (localMap && Object.hasOwn(localMap, value)) {
|
|
151
|
-
|
|
151
|
+
const label = localMap[value];
|
|
152
|
+
if (label !== undefined) {
|
|
153
|
+
return label;
|
|
154
|
+
}
|
|
152
155
|
}
|
|
153
156
|
// 3. Last resort: raw value
|
|
154
157
|
return value;
|