create-principles-disciple 1.93.0 → 1.95.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/WorkspaceConfigStore.js +2 -1
- package/console/dist/server/config/pd-config-store.d.ts +40 -1
- package/console/dist/server/config/pd-config-store.js +170 -1
- package/console/dist/server/index.js +28 -10
- package/console/dist/server/models/ApprovalsConsoleModel.js +4 -12
- package/console/dist/server/models/EvidenceChainConsoleModel.d.ts +0 -2
- package/console/dist/server/models/EvidenceChainConsoleModel.js +36 -2
- package/console/dist/server/models/HealthCheckModel.js +5 -3
- package/console/dist/server/models/IntentDecisionModel.d.ts +66 -0
- package/console/dist/server/models/IntentDecisionModel.js +207 -0
- package/console/dist/server/models/IntentPageModel.d.ts +18 -0
- package/console/dist/server/models/IntentPageModel.js +90 -0
- package/console/dist/server/models/PrinciplesConsoleModel.d.ts +2 -0
- package/console/dist/server/models/PrinciplesConsoleModel.js +37 -1
- package/console/dist/server/models/WorkspaceService.d.ts +0 -28
- package/console/dist/server/models/WorkspaceService.js +0 -115
- package/console/dist/server/routes/config.js +55 -1
- package/console/dist/server/routes/feedback-reports.js +1 -1
- package/console/dist/server/routes/intent-decisions.d.ts +33 -0
- package/console/dist/server/routes/intent-decisions.js +499 -0
- package/console/dist/server/routes/intent.d.ts +3 -0
- package/console/dist/server/routes/intent.js +35 -0
- package/console/dist/server/routes/principles.js +67 -1
- package/console/dist/server/routes/update.d.ts +0 -1
- package/console/dist/server/routes/update.js +14 -11
- package/console/dist/ui/App.js +2 -7
- package/console/dist/ui/api.d.ts +44 -18
- package/console/dist/ui/api.js +44 -5
- package/console/dist/ui/components/layout/app-sidebar.js +2 -1
- package/console/dist/ui/components/ui/badge.d.ts +1 -1
- package/console/dist/ui/components/ui/button.d.ts +1 -1
- package/console/dist/ui/components/ui/shiny-text.d.ts +28 -0
- package/console/dist/ui/components/ui/shiny-text.js +46 -0
- package/console/dist/ui/i18n/en.json +167 -3
- package/console/dist/ui/i18n/zh-CN.json +167 -3
- package/console/dist/ui/pages/activation/ActivationPage.js +2 -1
- package/console/dist/ui/pages/control-center/ControlCenterPage.js +28 -2
- package/console/dist/ui/pages/control-center/EmpathyObserverCostHint.d.ts +28 -0
- package/console/dist/ui/pages/control-center/EmpathyObserverCostHint.js +38 -0
- package/console/dist/ui/pages/debt/DebtPage.js +219 -2
- package/console/dist/ui/pages/focus/FocusPage.js +2 -1
- package/console/dist/ui/pages/intent/IntentPage.d.ts +1 -0
- package/console/dist/ui/pages/intent/IntentPage.js +147 -0
- package/console/dist/ui/pages/pain/PainPage.js +234 -4
- package/console/dist/ui/pages/pain/pain-card-helpers.d.ts +75 -0
- package/console/dist/ui/pages/pain/pain-card-helpers.js +78 -0
- package/console/dist/ui/pages/principles/PrinciplesPage.js +2 -1
- package/console/dist/ui/utils/validators.d.ts +163 -0
- package/console/dist/ui/utils/validators.js +433 -0
- package/console/dist/web/assets/app.css +138 -0
- package/console/dist/web/assets/app.js +3124 -1288
- package/console/package.json +3 -0
- package/core/dist/index.d.ts +2 -2
- package/core/dist/index.d.ts.map +1 -1
- package/core/dist/index.js +1 -1
- package/core/dist/index.js.map +1 -1
- package/core/dist/principle-tree-ledger.d.ts +55 -4
- package/core/dist/principle-tree-ledger.d.ts.map +1 -1
- package/core/dist/principle-tree-ledger.js +472 -13
- 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__/prompt-builder-core.test.js +58 -0
- package/core/dist/prompt-builder/__tests__/prompt-builder-core.test.js.map +1 -1
- 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/empathy-keyword-matching.d.ts.map +1 -1
- package/core/dist/prompt-builder/empathy-keyword-matching.js +9 -6
- package/core/dist/prompt-builder/empathy-keyword-matching.js.map +1 -1
- 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/size-guard.d.ts +1 -0
- package/core/dist/prompt-builder/size-guard.d.ts.map +1 -1
- package/core/dist/prompt-builder/size-guard.js +21 -0
- package/core/dist/prompt-builder/size-guard.js.map +1 -1
- package/core/dist/prompt-builder/types.d.ts +2 -0
- package/core/dist/prompt-builder/types.d.ts.map +1 -1
- 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 +205 -48
- package/core/dist/runtime-v2/__tests__/architecture-regression.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/evidence-chain-intent-tension.test.d.ts +2 -0
- package/core/dist/runtime-v2/__tests__/evidence-chain-intent-tension.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/__tests__/evidence-chain-intent-tension.test.js +284 -0
- package/core/dist/runtime-v2/__tests__/evidence-chain-intent-tension.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 +500 -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 +7 -5
- package/core/dist/runtime-v2/__tests__/pain-signal-observability.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/pi-artifact-store.test.js +11 -0
- package/core/dist/runtime-v2/__tests__/pi-artifact-store.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/proven-channel-baseline.test.js +15 -2
- package/core/dist/runtime-v2/__tests__/proven-channel-baseline.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/schema-float-precision.test.d.ts +2 -0
- package/core/dist/runtime-v2/__tests__/schema-float-precision.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/__tests__/schema-float-precision.test.js +290 -0
- package/core/dist/runtime-v2/__tests__/schema-float-precision.test.js.map +1 -0
- package/core/dist/runtime-v2/__tests__/schema-orphan-detection.test.d.ts +2 -0
- package/core/dist/runtime-v2/__tests__/schema-orphan-detection.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/__tests__/schema-orphan-detection.test.js +158 -0
- package/core/dist/runtime-v2/__tests__/schema-orphan-detection.test.js.map +1 -0
- package/core/dist/runtime-v2/activation/__tests__/approval-store-extended.test.js +15 -1
- package/core/dist/runtime-v2/activation/__tests__/approval-store-extended.test.js.map +1 -1
- package/core/dist/runtime-v2/activation/__tests__/sqlite-activation-state-store-fk.test.d.ts +2 -0
- package/core/dist/runtime-v2/activation/__tests__/sqlite-activation-state-store-fk.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/activation/__tests__/sqlite-activation-state-store-fk.test.js +62 -0
- package/core/dist/runtime-v2/activation/__tests__/sqlite-activation-state-store-fk.test.js.map +1 -0
- package/core/dist/runtime-v2/activation/__tests__/sqlite-activation-state-store.test.js +12 -2
- package/core/dist/runtime-v2/activation/__tests__/sqlite-activation-state-store.test.js.map +1 -1
- package/core/dist/runtime-v2/activation/__tests__/sqlite-approval-store-fk.test.d.ts +2 -0
- package/core/dist/runtime-v2/activation/__tests__/sqlite-approval-store-fk.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/activation/__tests__/sqlite-approval-store-fk.test.js +56 -0
- package/core/dist/runtime-v2/activation/__tests__/sqlite-approval-store-fk.test.js.map +1 -0
- package/core/dist/runtime-v2/activation/__tests__/sqlite-approval-store.test.js +8 -0
- package/core/dist/runtime-v2/activation/__tests__/sqlite-approval-store.test.js.map +1 -1
- package/core/dist/runtime-v2/activation/__tests__/story-a-acceptance.test.js +20 -0
- package/core/dist/runtime-v2/activation/__tests__/story-a-acceptance.test.js.map +1 -1
- package/core/dist/runtime-v2/activation/sqlite-activation-state-store.d.ts.map +1 -1
- package/core/dist/runtime-v2/activation/sqlite-activation-state-store.js +6 -0
- package/core/dist/runtime-v2/activation/sqlite-activation-state-store.js.map +1 -1
- package/core/dist/runtime-v2/activation/sqlite-approval-store.d.ts.map +1 -1
- package/core/dist/runtime-v2/activation/sqlite-approval-store.js +86 -32
- package/core/dist/runtime-v2/activation/sqlite-approval-store.js.map +1 -1
- package/core/dist/runtime-v2/activation/writers/__tests__/rule-host-writer.test.js +65 -1
- package/core/dist/runtime-v2/activation/writers/__tests__/rule-host-writer.test.js.map +1 -1
- package/core/dist/runtime-v2/activation/writers/rule-host-writer.d.ts.map +1 -1
- package/core/dist/runtime-v2/activation/writers/rule-host-writer.js +33 -11
- package/core/dist/runtime-v2/activation/writers/rule-host-writer.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 +134 -15
- package/core/dist/runtime-v2/diagnostician/__tests__/diag-rootcause-output.test.js.map +1 -1
- package/core/dist/runtime-v2/diagnostician/__tests__/intent-tension-schema.test.d.ts +18 -0
- package/core/dist/runtime-v2/diagnostician/__tests__/intent-tension-schema.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/diagnostician/__tests__/intent-tension-schema.test.js +251 -0
- package/core/dist/runtime-v2/diagnostician/__tests__/intent-tension-schema.test.js.map +1 -0
- package/core/dist/runtime-v2/diagnostician/__tests__/rootcause-prompt-builder.test.js +73 -0
- package/core/dist/runtime-v2/diagnostician/__tests__/rootcause-prompt-builder.test.js.map +1 -1
- package/core/dist/runtime-v2/diagnostician/diag-rootcause-output.d.ts +98 -0
- package/core/dist/runtime-v2/diagnostician/diag-rootcause-output.d.ts.map +1 -1
- package/core/dist/runtime-v2/diagnostician/diag-rootcause-output.js +131 -0
- package/core/dist/runtime-v2/diagnostician/diag-rootcause-output.js.map +1 -1
- package/core/dist/runtime-v2/diagnostician/rootcause-prompt-builder.d.ts +8 -0
- package/core/dist/runtime-v2/diagnostician/rootcause-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime-v2/diagnostician/rootcause-prompt-builder.js +66 -3
- package/core/dist/runtime-v2/diagnostician/rootcause-prompt-builder.js.map +1 -1
- package/core/dist/runtime-v2/diagnostician-output.d.ts +23 -0
- package/core/dist/runtime-v2/diagnostician-output.d.ts.map +1 -1
- package/core/dist/runtime-v2/diagnostician-output.js +16 -0
- package/core/dist/runtime-v2/diagnostician-output.js.map +1 -1
- package/core/dist/runtime-v2/diagnostician-prompt-builder.d.ts +32 -0
- package/core/dist/runtime-v2/diagnostician-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime-v2/diagnostician-prompt-builder.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/source-descriptors.d.ts +1 -1
- package/core/dist/runtime-v2/evidence-triage/source-descriptors.js +1 -1
- 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 +56 -4
- package/core/dist/runtime-v2/feature-flags/__tests__/feature-flag-contract.test.js.map +1 -1
- package/core/dist/runtime-v2/feature-flags/__tests__/intent-engineering-flag.test.d.ts +2 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/intent-engineering-flag.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/intent-engineering-flag.test.js +30 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/intent-engineering-flag.test.js.map +1 -0
- 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 +11 -2
- package/core/dist/runtime-v2/feature-flags/feature-flag-contract.js.map +1 -1
- package/core/dist/runtime-v2/feature-flags/plugin-surface-registry.d.ts.map +1 -1
- package/core/dist/runtime-v2/feature-flags/plugin-surface-registry.js +0 -9
- package/core/dist/runtime-v2/feature-flags/plugin-surface-registry.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 +15 -6
- package/core/dist/runtime-v2/index.d.ts.map +1 -1
- package/core/dist/runtime-v2/index.js +15 -4
- package/core/dist/runtime-v2/index.js.map +1 -1
- package/core/dist/runtime-v2/intent/__tests__/intent-decision-record.test.d.ts +2 -0
- package/core/dist/runtime-v2/intent/__tests__/intent-decision-record.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/intent/__tests__/intent-decision-record.test.js +185 -0
- package/core/dist/runtime-v2/intent/__tests__/intent-decision-record.test.js.map +1 -0
- package/core/dist/runtime-v2/intent/__tests__/intent-doc.test.d.ts +2 -0
- package/core/dist/runtime-v2/intent/__tests__/intent-doc.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/intent/__tests__/intent-doc.test.js +91 -0
- package/core/dist/runtime-v2/intent/__tests__/intent-doc.test.js.map +1 -0
- package/core/dist/runtime-v2/intent/__tests__/intent-friction-block.test.d.ts +2 -0
- package/core/dist/runtime-v2/intent/__tests__/intent-friction-block.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/intent/__tests__/intent-friction-block.test.js +168 -0
- package/core/dist/runtime-v2/intent/__tests__/intent-friction-block.test.js.map +1 -0
- package/core/dist/runtime-v2/intent/__tests__/intent-patch-proposal.test.d.ts +2 -0
- package/core/dist/runtime-v2/intent/__tests__/intent-patch-proposal.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/intent/__tests__/intent-patch-proposal.test.js +121 -0
- package/core/dist/runtime-v2/intent/__tests__/intent-patch-proposal.test.js.map +1 -0
- package/core/dist/runtime-v2/intent/index.d.ts +6 -0
- package/core/dist/runtime-v2/intent/index.d.ts.map +1 -0
- package/core/dist/runtime-v2/intent/index.js +6 -0
- package/core/dist/runtime-v2/intent/index.js.map +1 -0
- package/core/dist/runtime-v2/intent/intent-decision-record.d.ts +125 -0
- package/core/dist/runtime-v2/intent/intent-decision-record.d.ts.map +1 -0
- package/core/dist/runtime-v2/intent/intent-decision-record.js +21 -0
- package/core/dist/runtime-v2/intent/intent-decision-record.js.map +1 -0
- package/core/dist/runtime-v2/intent/intent-doc-reader-port.d.ts +95 -0
- package/core/dist/runtime-v2/intent/intent-doc-reader-port.d.ts.map +1 -0
- package/core/dist/runtime-v2/intent/intent-doc-reader-port.js +43 -0
- package/core/dist/runtime-v2/intent/intent-doc-reader-port.js.map +1 -0
- package/core/dist/runtime-v2/intent/intent-doc.d.ts +19 -0
- package/core/dist/runtime-v2/intent/intent-doc.d.ts.map +1 -0
- package/core/dist/runtime-v2/intent/intent-doc.js +70 -0
- package/core/dist/runtime-v2/intent/intent-doc.js.map +1 -0
- package/core/dist/runtime-v2/intent/intent-friction-block.d.ts +63 -0
- package/core/dist/runtime-v2/intent/intent-friction-block.d.ts.map +1 -0
- package/core/dist/runtime-v2/intent/intent-friction-block.js +129 -0
- package/core/dist/runtime-v2/intent/intent-friction-block.js.map +1 -0
- package/core/dist/runtime-v2/intent/intent-patch-proposal.d.ts +42 -0
- package/core/dist/runtime-v2/intent/intent-patch-proposal.d.ts.map +1 -0
- package/core/dist/runtime-v2/intent/intent-patch-proposal.js +81 -0
- package/core/dist/runtime-v2/intent/intent-patch-proposal.js.map +1 -0
- package/core/dist/runtime-v2/internalization/__tests__/__fixtures__/intent-tension-cases.d.ts +54 -0
- package/core/dist/runtime-v2/internalization/__tests__/__fixtures__/intent-tension-cases.d.ts.map +1 -0
- package/core/dist/runtime-v2/internalization/__tests__/__fixtures__/intent-tension-cases.js +219 -0
- package/core/dist/runtime-v2/internalization/__tests__/__fixtures__/intent-tension-cases.js.map +1 -0
- 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/__tests__/diag-rootcause-intent-tension.test.d.ts +2 -0
- package/core/dist/runtime-v2/internalization/__tests__/diag-rootcause-intent-tension.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/internalization/__tests__/diag-rootcause-intent-tension.test.js +360 -0
- package/core/dist/runtime-v2/internalization/__tests__/diag-rootcause-intent-tension.test.js.map +1 -0
- package/core/dist/runtime-v2/internalization/__tests__/diag-router-intent-tension.test.d.ts +2 -0
- package/core/dist/runtime-v2/internalization/__tests__/diag-router-intent-tension.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/internalization/__tests__/diag-router-intent-tension.test.js +333 -0
- package/core/dist/runtime-v2/internalization/__tests__/diag-router-intent-tension.test.js.map +1 -0
- package/core/dist/runtime-v2/internalization/__tests__/intent-tension-cases.test.d.ts +2 -0
- package/core/dist/runtime-v2/internalization/__tests__/intent-tension-cases.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/internalization/__tests__/intent-tension-cases.test.js +113 -0
- package/core/dist/runtime-v2/internalization/__tests__/intent-tension-cases.test.js.map +1 -0
- package/core/dist/runtime-v2/internalization/diag-rootcause-runner.d.ts +13 -0
- package/core/dist/runtime-v2/internalization/diag-rootcause-runner.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/diag-rootcause-runner.js +42 -0
- package/core/dist/runtime-v2/internalization/diag-rootcause-runner.js.map +1 -1
- package/core/dist/runtime-v2/internalization/diag-router-runner.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/diag-router-runner.js +27 -0
- package/core/dist/runtime-v2/internalization/diag-router-runner.js.map +1 -1
- 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 +272 -61
- package/core/dist/runtime-v2/pain-signal-observability.js.map +1 -1
- package/core/dist/runtime-v2/pain-signal-runtime-factory.d.ts +12 -0
- package/core/dist/runtime-v2/pain-signal-runtime-factory.d.ts.map +1 -1
- package/core/dist/runtime-v2/pain-signal-runtime-factory.js +1 -1
- package/core/dist/runtime-v2/pain-signal-runtime-factory.js.map +1 -1
- package/core/dist/runtime-v2/pain-to-principle-service.d.ts +6 -0
- package/core/dist/runtime-v2/pain-to-principle-service.d.ts.map +1 -1
- package/core/dist/runtime-v2/pain-to-principle-service.js +2 -0
- package/core/dist/runtime-v2/pain-to-principle-service.js.map +1 -1
- package/core/dist/runtime-v2/principle-tree/ledger-codec.js.map +1 -1
- package/core/dist/runtime-v2/proven-channel-baseline.js +1 -1
- package/core/dist/runtime-v2/proven-channel-baseline.js.map +1 -1
- package/core/dist/runtime-v2/store/artifact/__tests__/sqlite-pi-artifact-store-fk.test.d.ts +2 -0
- package/core/dist/runtime-v2/store/artifact/__tests__/sqlite-pi-artifact-store-fk.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/store/artifact/__tests__/sqlite-pi-artifact-store-fk.test.js +55 -0
- package/core/dist/runtime-v2/store/artifact/__tests__/sqlite-pi-artifact-store-fk.test.js.map +1 -0
- package/core/dist/runtime-v2/store/artifact/sqlite-pi-artifact-store.d.ts.map +1 -1
- package/core/dist/runtime-v2/store/artifact/sqlite-pi-artifact-store.js +6 -0
- package/core/dist/runtime-v2/store/artifact/sqlite-pi-artifact-store.js.map +1 -1
- package/core/dist/runtime-v2/store/intent/__tests__/sqlite-intent-decision-store.test.d.ts +2 -0
- package/core/dist/runtime-v2/store/intent/__tests__/sqlite-intent-decision-store.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/store/intent/__tests__/sqlite-intent-decision-store.test.js +272 -0
- package/core/dist/runtime-v2/store/intent/__tests__/sqlite-intent-decision-store.test.js.map +1 -0
- package/core/dist/runtime-v2/store/intent/index.d.ts +6 -0
- package/core/dist/runtime-v2/store/intent/index.d.ts.map +1 -0
- package/core/dist/runtime-v2/store/intent/index.js +5 -0
- package/core/dist/runtime-v2/store/intent/index.js.map +1 -0
- package/core/dist/runtime-v2/store/intent/sqlite-intent-decision-store.d.ts +51 -0
- package/core/dist/runtime-v2/store/intent/sqlite-intent-decision-store.d.ts.map +1 -0
- package/core/dist/runtime-v2/store/intent/sqlite-intent-decision-store.js +306 -0
- package/core/dist/runtime-v2/store/intent/sqlite-intent-decision-store.js.map +1 -0
- package/core/dist/runtime-v2/store/sqlite-connection-pragma.test.js +14 -3
- package/core/dist/runtime-v2/store/sqlite-connection-pragma.test.js.map +1 -1
- package/core/dist/runtime-v2/store/sqlite-connection-schema-version.test.d.ts +2 -0
- package/core/dist/runtime-v2/store/sqlite-connection-schema-version.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/store/sqlite-connection-schema-version.test.js +72 -0
- package/core/dist/runtime-v2/store/sqlite-connection-schema-version.test.js.map +1 -0
- package/core/dist/runtime-v2/store/sqlite-connection.d.ts +27 -0
- package/core/dist/runtime-v2/store/sqlite-connection.d.ts.map +1 -1
- package/core/dist/runtime-v2/store/sqlite-connection.js +124 -12
- package/core/dist/runtime-v2/store/sqlite-connection.js.map +1 -1
- package/core/dist/runtime-v2/types/event-payload.d.ts +1 -20
- package/core/dist/runtime-v2/types/event-payload.d.ts.map +1 -1
- package/core/dist/runtime-v2/types/event-payload.js +0 -12
- package/core/dist/runtime-v2/types/event-payload.js.map +1 -1
- package/core/dist/runtime-v2/types/event-types.d.ts +5 -61
- package/core/dist/runtime-v2/types/event-types.d.ts.map +1 -1
- package/core/dist/runtime-v2/types/event-types.js +2 -36
- package/core/dist/runtime-v2/types/event-types.js.map +1 -1
- package/core/dist/runtime-v2/types/evidence-chain-contract.d.ts +63 -0
- package/core/dist/runtime-v2/types/evidence-chain-contract.d.ts.map +1 -1
- package/core/dist/runtime-v2/types/evidence-chain-contract.js +234 -9
- package/core/dist/runtime-v2/types/evidence-chain-contract.js.map +1 -1
- package/core/dist/runtime-v2/types/index.d.ts +5 -5
- package/core/dist/runtime-v2/types/index.d.ts.map +1 -1
- package/core/dist/runtime-v2/types/index.js +7 -3
- package/core/dist/runtime-v2/types/index.js.map +1 -1
- package/core/dist/runtime-v2/types/ledger-store.d.ts +30 -30
- package/core/dist/runtime-v2/types/ledger-store.d.ts.map +1 -1
- package/core/dist/runtime-v2/types/ledger-store.js +10 -5
- package/core/dist/runtime-v2/types/ledger-store.js.map +1 -1
- package/core/dist/runtime-v2/types/pain-signal.d.ts +2 -2
- package/core/dist/runtime-v2/types/pain-signal.js +2 -2
- package/core/dist/workflow-funnel-loader.d.ts +2 -2
- package/core/dist/workflow-funnel-loader.d.ts.map +1 -1
- package/dist/installer.d.ts.map +1 -1
- package/dist/installer.js +16 -0
- 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 -65
- package/dist/mvp-config.js.map +1 -1
- package/package.json +1 -1
- package/pd-cli/dist/commands/__tests__/intent-flag-wiring.test.d.ts +9 -0
- package/pd-cli/dist/commands/__tests__/intent-flag-wiring.test.d.ts.map +1 -0
- package/pd-cli/dist/commands/__tests__/intent-flag-wiring.test.js +166 -0
- package/pd-cli/dist/commands/__tests__/intent-flag-wiring.test.js.map +1 -0
- package/pd-cli/dist/commands/intent.d.ts +59 -0
- package/pd-cli/dist/commands/intent.d.ts.map +1 -0
- package/pd-cli/dist/commands/intent.js +350 -0
- package/pd-cli/dist/commands/intent.js.map +1 -0
- 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-init.d.ts +43 -0
- package/pd-cli/dist/commands/runtime-init.d.ts.map +1 -0
- package/pd-cli/dist/commands/runtime-init.js +264 -0
- package/pd-cli/dist/commands/runtime-init.js.map +1 -0
- 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.js +1 -1
- package/pd-cli/dist/commands/runtime.js.map +1 -1
- package/pd-cli/dist/index.js +92 -34
- package/pd-cli/dist/index.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 +20 -12
- package/pd-cli/dist/services/__tests__/runtime-adapter-resolver.test.js.map +1 -1
- package/pd-cli/dist/services/demo-story-a-runner.d.ts.map +1 -1
- package/pd-cli/dist/services/demo-story-a-runner.js +6 -0
- package/pd-cli/dist/services/demo-story-a-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.js +3 -3
- package/pd-cli/dist/services/runtime-adapter-resolver.js.map +1 -1
- package/pd-cli/package.json +1 -0
- package/plugin/dist/commands/evolution-status.js +0 -2
- package/plugin/dist/commands/pain.js +2 -0
- package/plugin/dist/core/control-ui-db.d.ts +11 -0
- package/plugin/dist/core/control-ui-db.js +40 -16
- 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 +5 -21
- package/plugin/dist/core/evolution-reducer.d.ts +0 -8
- package/plugin/dist/core/evolution-reducer.js +9 -19
- package/plugin/dist/core/intent-doc-reader-adapter.d.ts +28 -0
- package/plugin/dist/core/intent-doc-reader-adapter.js +56 -0
- package/plugin/dist/core/intent-doc-reader.d.ts +80 -0
- package/plugin/dist/core/intent-doc-reader.js +189 -0
- 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-tree-ledger.d.ts +27 -79
- package/plugin/dist/core/principle-tree-ledger.js +39 -524
- package/plugin/dist/core/reflection/reflection-context.d.ts +2 -2
- 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/trajectory.d.ts +16 -16
- package/plugin/dist/core/trajectory.js +338 -311
- package/plugin/dist/core/workspace-context.d.ts +2 -3
- 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 +124 -49
- package/plugin/dist/hooks/prompt-helpers.d.ts +105 -0
- package/plugin/dist/hooks/prompt-helpers.js +288 -0
- package/plugin/dist/hooks/prompt-types.d.ts +74 -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 +433 -338
- 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/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.d.ts +3 -1
- package/plugin/dist/index.js +9 -5
- package/plugin/dist/service/evolution-worker.js +6 -64
- package/plugin/dist/service/runtime-summary-service.d.ts +0 -2
- package/plugin/dist/service/runtime-summary-service.js +1 -5
- package/plugin/dist/service/subagent-workflow/workflow-store.d.ts +14 -0
- package/plugin/dist/service/subagent-workflow/workflow-store.js +91 -2
- package/plugin/dist/types/event-types.d.ts +1 -1
- package/plugin/package.json +6 -3
- package/plugin/scripts/acceptance-test.mjs +3 -3
- package/plugin/scripts/sync-plugin.mjs +33 -22
- 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/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/core/principle-tree-ledger-adapter.d.ts +0 -32
- package/plugin/dist/core/principle-tree-ledger-adapter.js +0 -125
- package/plugin/dist/hooks/subagent.d.ts +0 -9
- package/plugin/dist/hooks/subagent.js +0 -122
- package/plugin/dist/service/central-database.d.ts +0 -138
- package/plugin/dist/service/central-database.js +0 -731
- package/plugin/dist/service/central-sync-service.d.ts +0 -8
- package/plugin/dist/service/central-sync-service.js +0 -71
- package/plugin/scripts/validate-live-path.ts +0 -480
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect, useCallback } from "react";
|
|
3
|
+
import { useTranslation } from "react-i18next";
|
|
4
|
+
import { toast } from "sonner";
|
|
5
|
+
import { PageShell } from "../../components/layout/page-shell.js";
|
|
6
|
+
import { PageLoading } from "../../components/layout/page-loading.js";
|
|
7
|
+
import { SectionTitle } from "../../components/layout/section-title.js";
|
|
8
|
+
import { fetchIntentSummary, fetchIntentDecisionSummary, patchFeatureFlag } from "../../api.js";
|
|
9
|
+
// ── Sub-components ────────────────────────────────────────────────────────────
|
|
10
|
+
function FlagStatusBadge({ enabled }) {
|
|
11
|
+
const { t } = useTranslation();
|
|
12
|
+
// SPEC §22.1.1: Intent Page must show intent_engineering flag status.
|
|
13
|
+
// Badge has a text label, not color-only (SPEC §23.14.10).
|
|
14
|
+
const label = enabled
|
|
15
|
+
? t("pages.intent.flagStatus.enabled")
|
|
16
|
+
: t("pages.intent.flagStatus.disabled");
|
|
17
|
+
return (_jsxs("span", { className: `inline-flex items-center gap-1.5 px-2 py-0.5 rounded-[3px] text-[11px] font-mono border ${enabled
|
|
18
|
+
? "border-emerald/40 text-emerald bg-emerald/5"
|
|
19
|
+
: "border-line text-ink-3 bg-surface"}`, role: "status", "aria-label": t("pages.intent.flagStatus.ariaLabel"), children: [_jsx("span", { className: `w-1.5 h-1.5 rounded-full ${enabled ? "bg-emerald" : "bg-ink-4"}`, "aria-hidden": "true" }), label] }));
|
|
20
|
+
}
|
|
21
|
+
function EditEntry({ filePath }) {
|
|
22
|
+
const { t } = useTranslation();
|
|
23
|
+
// SPEC §22.1.1 line 1402: Intent Page must show "edit INTENT.md 入口".
|
|
24
|
+
// INTENT.md is Owner-owned; PD never auto-modifies it. This entry only
|
|
25
|
+
// surfaces the file path so the Owner can edit it in their own editor.
|
|
26
|
+
return (_jsxs("div", { className: "bg-panel border border-line rounded-[6px] p-4", children: [_jsx("h3", { className: "font-mono text-[11px] uppercase tracking-[0.08em] text-ink-3 mb-2", children: t("pages.intent.editEntry.title") }), _jsx("p", { className: "text-ink-3 text-[13px] leading-relaxed mb-2", children: t("pages.intent.editEntry.description") }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx("code", { className: "text-[12px] text-ink-2 bg-surface border border-line rounded-[3px] px-2 py-1 break-all", children: filePath }), _jsx("button", { type: "button", onClick: () => {
|
|
27
|
+
// Copy to clipboard — Owner pastes into their editor.
|
|
28
|
+
void navigator.clipboard?.writeText(filePath);
|
|
29
|
+
}, className: "shrink-0 border border-line bg-surface text-ink-2 rounded-[3px] px-2 py-1 text-[11px] hover:border-line-2 transition-colors focus-visible:outline-2 focus-visible:outline-gov focus-visible:outline-offset-2", "aria-label": t("pages.intent.editEntry.copyAriaLabel"), children: t("pages.intent.editEntry.copy") })] })] }));
|
|
30
|
+
}
|
|
31
|
+
function FlagToggleCard({ flagEnabled, onAfterEnable }) {
|
|
32
|
+
const { t } = useTranslation();
|
|
33
|
+
const [busy, setBusy] = useState(false);
|
|
34
|
+
const [acknowledged, setAcknowledged] = useState(false);
|
|
35
|
+
// Only show when disabled and not yet acknowledged.
|
|
36
|
+
// flagEnabled === true → already on, nothing to toggle.
|
|
37
|
+
// acknowledged === true → owner just enabled, parent will re-fetch and
|
|
38
|
+
// flagEnabled will flip to true; this prevents a flash of the card.
|
|
39
|
+
if (flagEnabled || acknowledged)
|
|
40
|
+
return null;
|
|
41
|
+
return (_jsxs("div", { className: "bg-panel border border-amber/20 border-l-2 border-l-amber rounded-[6px] p-4 mb-5", children: [_jsx("h2", { className: "text-ink text-[15px] font-semibold mb-2", children: t("pages.intent.flagDisabled.title") }), _jsx("p", { className: "text-ink-3 text-[13px] leading-relaxed mb-3", children: t("pages.intent.flagDisabled.description") }), _jsx("button", { type: "button", disabled: busy, onClick: async () => {
|
|
42
|
+
setBusy(true);
|
|
43
|
+
try {
|
|
44
|
+
const res = await patchFeatureFlag("intent_engineering", true);
|
|
45
|
+
if (!res.success) {
|
|
46
|
+
toast.error(res.error ?? t("pages.intent.flagStatus.enableFailed"));
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
setAcknowledged(true);
|
|
50
|
+
onAfterEnable?.();
|
|
51
|
+
}
|
|
52
|
+
finally {
|
|
53
|
+
setBusy(false);
|
|
54
|
+
}
|
|
55
|
+
}, className: "border border-gov bg-gov text-paper rounded-[3px] px-[14px] py-[6px] text-[12.5px] font-medium hover:bg-gov-2 transition-colors disabled:opacity-50 focus-visible:outline-2 focus-visible:outline-gov focus-visible:outline-offset-2", "aria-label": t("pages.intent.flagStatus.enable"), children: busy ? t("pages.intent.flagStatus.enabling") : t("pages.intent.flagStatus.enable") })] }));
|
|
56
|
+
}
|
|
57
|
+
function NotFoundBanner() {
|
|
58
|
+
const { t } = useTranslation();
|
|
59
|
+
return (_jsxs("div", { className: "bg-panel border border-line rounded-[6px] p-5", children: [_jsx("h2", { className: "text-ink text-[15px] font-semibold mb-2", children: t("pages.intent.notFound.title") }), _jsx("p", { className: "text-ink-3 text-[13px] leading-relaxed mb-3", children: t("pages.intent.notFound.description") }), _jsx("div", { className: "font-mono text-[12px] text-ink-2 bg-surface border border-line rounded-[3px] px-3 py-2", children: t("pages.intent.notFound.nextAction") })] }));
|
|
60
|
+
}
|
|
61
|
+
function OversizedBanner() {
|
|
62
|
+
const { t } = useTranslation();
|
|
63
|
+
return (_jsxs("div", { className: "bg-panel border border-amber/30 rounded-[6px] p-5", children: [_jsx("h2", { className: "text-ink text-[15px] font-semibold mb-2", children: t("pages.intent.oversized.title") }), _jsx("p", { className: "text-ink-3 text-[13px] leading-relaxed mb-3", children: t("pages.intent.oversized.description") }), _jsx("div", { className: "font-mono text-[12px] text-ink-2 bg-surface border border-line rounded-[3px] px-3 py-2", children: t("pages.intent.oversized.nextAction") })] }));
|
|
64
|
+
}
|
|
65
|
+
function WarningItem({ warning }) {
|
|
66
|
+
const { t } = useTranslation();
|
|
67
|
+
// SPEC: warnings are rendered as governance hints via i18n code key,
|
|
68
|
+
// not raw server-side English message text (P2 i18n fix).
|
|
69
|
+
const labelKey = `pages.intent.warnings.${warning.code}`;
|
|
70
|
+
return (_jsxs("li", { className: "flex items-start gap-2 text-ink-2 text-[13px]", children: [_jsx("span", { className: "text-amber shrink-0 mt-0.5", "aria-hidden": "true", children: "!" }), _jsxs("span", { children: [_jsx("span", { className: "font-medium", children: t(labelKey) }), warning.section && (_jsxs("span", { className: "text-ink-3 font-mono ml-2", children: ["[", warning.section, "]"] }))] })] }));
|
|
71
|
+
}
|
|
72
|
+
function SectionContent({ label, content }) {
|
|
73
|
+
if (content === undefined || content.trim() === "")
|
|
74
|
+
return null;
|
|
75
|
+
return (_jsxs("div", { children: [_jsx("h3", { className: "font-mono text-[11px] uppercase tracking-[0.08em] text-ink-3 mb-1.5", children: label }), _jsx("p", { className: "text-ink-2 text-[13px] leading-relaxed whitespace-pre-wrap", children: content })] }));
|
|
76
|
+
}
|
|
77
|
+
function MetaRow({ label, value }) {
|
|
78
|
+
return (_jsxs("div", { className: "flex items-baseline gap-3", children: [_jsx("span", { className: "font-mono text-[11px] uppercase tracking-[0.08em] text-ink-3 w-32 shrink-0", children: label }), _jsx("span", { className: "text-ink-2 text-[12px] font-mono break-all", children: value })] }));
|
|
79
|
+
}
|
|
80
|
+
// Static mapping from ownerAction enum value to its i18n label key.
|
|
81
|
+
// Avoids dynamic string construction so i18n extraction tools can find keys.
|
|
82
|
+
const DECISION_COUNT_LABEL_KEYS = [
|
|
83
|
+
{ action: "confirm_drift", labelKey: "pages.intent.decisions.countConfirmDrift" },
|
|
84
|
+
{ action: "revise_intent", labelKey: "pages.intent.decisions.countReviseIntent" },
|
|
85
|
+
{ action: "observe", labelKey: "pages.intent.decisions.countObserve" },
|
|
86
|
+
{ action: "dismiss", labelKey: "pages.intent.decisions.countDismiss" },
|
|
87
|
+
{ action: "promote_to_principle", labelKey: "pages.intent.decisions.countPromoteToPrinciple" },
|
|
88
|
+
{ action: "promote_to_rulehost", labelKey: "pages.intent.decisions.countPromoteToRulehost" },
|
|
89
|
+
];
|
|
90
|
+
function DecisionSummarySection() {
|
|
91
|
+
const { t } = useTranslation();
|
|
92
|
+
const [state, setState] = useState("loading");
|
|
93
|
+
const [summary, setSummary] = useState(null);
|
|
94
|
+
const loadSummary = useCallback(async () => {
|
|
95
|
+
setState("loading");
|
|
96
|
+
const result = await fetchIntentDecisionSummary();
|
|
97
|
+
if (!result.success) {
|
|
98
|
+
// ERR-002: graceful degradation with reason; section collapses to a single line.
|
|
99
|
+
setState("error");
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
setSummary(result.data);
|
|
103
|
+
setState("loaded");
|
|
104
|
+
}, []);
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
loadSummary();
|
|
107
|
+
}, [loadSummary]);
|
|
108
|
+
return (_jsxs("section", { className: "mt-8", "aria-labelledby": "section-decisions", children: [_jsx(SectionTitle, { id: "section-decisions", children: t("pages.intent.decisions.sectionTitle") }), _jsx("p", { className: "text-ink-3 text-[13px] leading-relaxed mb-3", children: t("pages.intent.decisions.sectionSubtitle") }), state === "loading" && (_jsx("div", { className: "bg-panel border border-line rounded-[6px] p-4 text-ink-3 text-[13px]", children: t("common.loading") })), state === "error" && (_jsx("div", { className: "bg-panel border border-line rounded-[6px] p-4 text-ink-3 text-[13px]", children: t("pages.intent.decisions.loadError") })), state === "loaded" && summary && (_jsxs("div", { className: "bg-panel border border-line rounded-[6px] p-4", children: [_jsx("dl", { className: "grid grid-cols-2 gap-x-6 gap-y-2 sm:grid-cols-3", children: DECISION_COUNT_LABEL_KEYS.map(({ action, labelKey }) => {
|
|
109
|
+
const count = summary.counts[action];
|
|
110
|
+
return (_jsxs("div", { className: "flex items-baseline gap-2", children: [_jsx("dt", { className: "text-ink-3 text-[12px]", children: t(labelKey) }), _jsx("dd", { className: "text-ink font-mono text-[13px]", children: count })] }, action));
|
|
111
|
+
}) }), _jsx("div", { className: "mt-4 pt-3 border-t border-line", children: summary.lastDecisionAt === null ? (_jsx("p", { className: "text-ink-4 text-[12px]", children: t("pages.intent.decisions.noDecisions") })) : (_jsxs("div", { className: "flex items-baseline gap-2", children: [_jsx("span", { className: "font-mono text-[11px] uppercase tracking-[0.08em] text-ink-3", children: t("pages.intent.decisions.lastDecisionAtLabel") }), _jsx("span", { className: "text-ink-2 text-[12px] font-mono break-all", children: summary.lastDecisionAt })] })) })] }))] }));
|
|
112
|
+
}
|
|
113
|
+
// ── Main page component ──────────────────────────────────────────────────────
|
|
114
|
+
export function IntentPage() {
|
|
115
|
+
const { t } = useTranslation();
|
|
116
|
+
const [data, setData] = useState(null);
|
|
117
|
+
const [pageState, setPageState] = useState("loading");
|
|
118
|
+
const [errorMsg, setErrorMsg] = useState(null);
|
|
119
|
+
const loadData = useCallback(async () => {
|
|
120
|
+
setPageState("loading");
|
|
121
|
+
setErrorMsg(null);
|
|
122
|
+
const result = await fetchIntentSummary();
|
|
123
|
+
if (!result.success) {
|
|
124
|
+
// ERR-002: graceful degradation with reason
|
|
125
|
+
setErrorMsg(result.error ?? t("pages.intent.loadError"));
|
|
126
|
+
setPageState("error");
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
// result.data is already validated by validateIntentSummary in the API layer
|
|
130
|
+
setData(result.data);
|
|
131
|
+
setPageState("loaded");
|
|
132
|
+
}, [t]);
|
|
133
|
+
useEffect(() => {
|
|
134
|
+
loadData();
|
|
135
|
+
}, [loadData]);
|
|
136
|
+
// ── Loading state ────────────────────────────────────────────────────────
|
|
137
|
+
if (pageState === "loading") {
|
|
138
|
+
return (_jsx(PageShell, { children: _jsx(PageLoading, { cardCount: 3, label: t("common.loading") }) }));
|
|
139
|
+
}
|
|
140
|
+
// ── Error state (ERR-002: degradation with reason) ───────────────────────
|
|
141
|
+
if (pageState === "error") {
|
|
142
|
+
return (_jsxs(PageShell, { children: [_jsx("div", { className: "font-mono text-[12px] tracking-[0.14em] text-ink-3 uppercase mb-3", children: t("pages.intent.eyebrow") }), _jsx("h1", { className: "text-[29px] font-semibold tracking-tight text-ink mb-2", children: t("pages.intent.title") }), _jsxs("div", { className: "mt-6 p-4 bg-panel border border-line rounded-[6px] text-ink-2 text-sm", children: [_jsx("p", { children: t("pages.intent.loadError") }), errorMsg && (_jsx("p", { className: "mt-2 text-ink-4 text-[13px] font-mono", children: errorMsg }))] }), _jsx("div", { className: "mt-4", children: _jsx("button", { type: "button", onClick: loadData, className: "border border-line bg-surface text-ink rounded-[3px] px-[14px] py-[6px] text-[12.5px] hover:border-line-2 transition-colors focus-visible:outline-2 focus-visible:outline-gov focus-visible:outline-offset-2", children: t("common.refresh") }) })] }));
|
|
143
|
+
}
|
|
144
|
+
// ── Loaded state ─────────────────────────────────────────────────────────
|
|
145
|
+
const summary = data;
|
|
146
|
+
return (_jsx(PageShell, { children: _jsxs("div", { className: "animate-[pdFadeIn_400ms_ease-out]", children: [_jsx("div", { className: "font-mono text-[12px] tracking-[0.14em] text-ink-3 uppercase mb-3", children: t("pages.intent.eyebrow") }), _jsxs("div", { className: "flex items-center gap-3 mb-2", children: [_jsx("h1", { className: "text-[29px] font-semibold tracking-tight text-ink", children: t("pages.intent.title") }), summary && (_jsx(FlagStatusBadge, { enabled: summary.flagEnabled }))] }), _jsx("p", { className: "text-ink-3 text-[14px] max-w-[760px] leading-relaxed mb-7", children: t("pages.intent.subtitle") }), summary && !summary.flagEnabled && (_jsx(FlagToggleCard, { flagEnabled: summary.flagEnabled, onAfterEnable: loadData })), summary && summary.flagEnabled && !summary.found && summary.reason === "not_found" && (_jsx(NotFoundBanner, {})), summary && summary.flagEnabled && summary.found && summary.reason === "oversized" && (_jsx(OversizedBanner, {})), summary && summary.flagEnabled && summary.ok && summary.sections && (_jsxs(_Fragment, { children: [_jsxs("section", { "aria-labelledby": "section-content", children: [_jsx(SectionTitle, { id: "section-content", children: t("pages.intent.title") }), _jsxs("div", { className: "bg-panel border border-line rounded-[6px] p-5 space-y-5", children: [_jsx(SectionContent, { label: t("pages.intent.sections.why"), content: summary.sections.why }), _jsx(SectionContent, { label: t("pages.intent.sections.desiredOutcome"), content: summary.sections.desiredOutcome }), _jsx(SectionContent, { label: t("pages.intent.sections.nonNegotiables"), content: summary.sections.nonNegotiables }), _jsx(SectionContent, { label: t("pages.intent.sections.stopEscalation"), content: summary.sections.stopEscalation }), _jsx(SectionContent, { label: t("pages.intent.sections.currentStrategicFocus"), content: summary.sections.currentStrategicFocus })] })] }), _jsxs("section", { className: "mt-8", "aria-labelledby": "section-warnings", children: [_jsx(SectionTitle, { id: "section-warnings", children: t("pages.intent.warnings.title") }), summary.warnings.length === 0 ? (_jsx("p", { className: "text-ink-3 text-[13px] leading-relaxed", children: t("pages.intent.warnings.empty") })) : (_jsx("ul", { className: "bg-panel border border-line rounded-[6px] p-4 space-y-2", children: summary.warnings.map((w, i) => (_jsx(WarningItem, { warning: w }, i))) }))] }), _jsxs("section", { className: "mt-8", "aria-labelledby": "section-meta", children: [_jsx(SectionTitle, { id: "section-meta", children: t("pages.intent.meta.title") }), _jsxs("div", { className: "bg-panel border border-line rounded-[6px] p-4 space-y-2", children: [summary.lastEditedAt && (_jsx(MetaRow, { label: t("pages.intent.meta.lastEditedAt"), value: summary.lastEditedAt })), summary.contentHash && (_jsx(MetaRow, { label: t("pages.intent.meta.contentHash"), value: summary.contentHash })), summary.path && (_jsx(MetaRow, { label: t("pages.intent.meta.path"), value: summary.path }))] })] }), summary.path && (_jsxs("section", { className: "mt-8", "aria-labelledby": "section-edit", children: [_jsx(SectionTitle, { id: "section-edit", children: t("pages.intent.editEntry.heading") }), _jsx(EditEntry, { filePath: summary.path })] }))] })), summary && summary.flagEnabled && !summary.ok && summary.reason && summary.reason !== "not_found" && summary.reason !== "oversized" && (_jsxs("div", { className: "bg-panel border border-red-200 rounded-[6px] p-5", children: [_jsx("h2", { className: "text-ink text-[15px] font-semibold mb-2", children: t("pages.intent.loadError") }), _jsx("p", { className: "text-ink-3 text-[13px] leading-relaxed mb-3 font-mono", children: summary.reason }), summary.nextAction && (_jsx("p", { className: "text-ink-2 text-[13px] leading-relaxed", children: summary.nextAction }))] })), summary && summary.flagEnabled && (_jsx(DecisionSummarySection, {}))] }) }));
|
|
147
|
+
}
|
|
@@ -17,9 +17,10 @@ import { PageLoading } from '../../components/layout/page-loading.js';
|
|
|
17
17
|
import { Badge } from '../../components/ui/badge.js';
|
|
18
18
|
import { Card, CardContent, CardHeader, CardTitle } from '../../components/ui/card.js';
|
|
19
19
|
import { Button } from '../../components/ui/button.js';
|
|
20
|
-
import {
|
|
20
|
+
import { ShinyText } from '../../components/ui/shiny-text.js';
|
|
21
|
+
import { fetchEvidenceChain, recordIntentDecision, listIntentDecisionsByPainId, listIntentDecisionsByTaskId, dispatchFollowUp } from '../../api.js';
|
|
21
22
|
import { formatDate } from '../../utils/format.js';
|
|
22
|
-
import { buildCardLayers, buildDebugIdSummary, isLayer2EffectivelyEmpty } from './pain-card-helpers.js';
|
|
23
|
+
import { buildCardLayers, buildDebugIdSummary, isLayer2EffectivelyEmpty, shouldRenderIntentTensionPanel, shouldRenderFollowUpActions, buildIntentDecisionPayload } from './pain-card-helpers.js';
|
|
23
24
|
import { enumLabel } from '../../utils/enum-labels.js';
|
|
24
25
|
function groupForState(state) {
|
|
25
26
|
switch (state) {
|
|
@@ -84,7 +85,7 @@ export function PainPage() {
|
|
|
84
85
|
return next;
|
|
85
86
|
});
|
|
86
87
|
};
|
|
87
|
-
return (_jsxs(PageShell, { children: [_jsxs("div", { className: "mb-8", children: [_jsx("div", { className: "font-mono text-[11px] uppercase tracking-[0.14em] text-ink-3", children: t('pages.pain.eyebrow') }), _jsx("h1",
|
|
88
|
+
return (_jsxs(PageShell, { children: [_jsxs("div", { className: "mb-8", children: [_jsx("div", { className: "font-mono text-[11px] uppercase tracking-[0.14em] text-ink-3", children: t('pages.pain.eyebrow') }), _jsx(ShinyText, { as: "h1", className: "text-[29px] font-semibold tracking-tight text-ink mt-3 mb-2", duration: 4.5, brightness: 0.5, disabled: state.status !== 'loaded' || state.data.records.length === 0, children: t('pages.pain.title') }), _jsx("p", { className: "text-ink-3 text-sm leading-relaxed max-w-[712px]", children: t('pages.pain.description') })] }), _jsx("div", { className: "mb-6 p-3 bg-panel border border-line rounded-[var(--radius-md)] text-ink-3 text-[13px] leading-relaxed", children: t('pages.pain.honestyNote') }), state.status === 'loading' && (_jsx(PageLoading, { cardCount: 4, label: t('common.loading') })), state.status === 'error' && (_jsxs("div", { className: "py-8", children: [_jsxs("div", { className: "text-danger text-sm mb-2", children: [t('pages.pain.loadError'), ": ", state.message] }), _jsx(Button, { variant: "outline", size: "sm", onClick: loadData, children: t('common.refresh') })] })), state.status === 'loaded' && (_jsx("div", { className: "animate-[pdFadeIn_400ms_ease-out]", children: _jsx(LoadedContent, { data: state.data, expandedIds: expandedIds, onToggle: toggleExpanded, onRefresh: loadData, t: t }) }))] }));
|
|
88
89
|
}
|
|
89
90
|
function LoadedContent({ data, expandedIds, onToggle, onRefresh, t }) {
|
|
90
91
|
const [reviewQueueExpanded, setReviewQueueExpanded] = useState(false);
|
|
@@ -132,7 +133,7 @@ function EvidenceChainCard({ record, expanded, onToggle, t }) {
|
|
|
132
133
|
const confidenceDisplay = layers.layer2.confidence
|
|
133
134
|
? `${enumLabel('confidence', layers.layer2.confidence.label, t)} (${layers.layer2.confidence.raw.toFixed(2)})`
|
|
134
135
|
: null;
|
|
135
|
-
return (_jsxs(Card, { className: "overflow-hidden", children: [_jsx(CardHeader, { children: _jsxs("div", { className: "flex items-start justify-between gap-3", children: [_jsxs("div", { className: "flex items-center gap-2 flex-wrap", children: [_jsx(Badge, { variant: stateVariant, children: stateLabel }), _jsx(Badge, { variant: "outline", children: sourceLabel }), record.admissionDecision && (_jsx(Badge, { variant: "secondary", children: enumLabel('admission', record.admissionDecision, t) }))] }), _jsx("span", { className: "font-mono text-[11px] text-ink-4 whitespace-nowrap", children: formatDate(record.observedAt) })] }) }), _jsxs(CardContent, { children: [_jsxs("div", { className: "space-y-3 mb-4", children: [_jsxs("div", { children: [_jsx("div", { className: "font-mono text-[11px] uppercase tracking-[0.08em] text-ink-4 mb-1", children: t('pages.pain.fieldTrigger') }), layer2Empty ? (_jsx("p", { className: "text-ink-3 text-sm italic leading-relaxed", children: t('pages.pain.noHumanSummary') })) : (_jsx(CardTitle, { className: "text-[15px] leading-relaxed", children: layers.layer2.triggerSummary }))] }), layers.layer2.conclusion && (_jsxs("div", { children: [_jsx("div", { className: "font-mono text-[11px] uppercase tracking-[0.08em] text-ink-4 mb-1", children: t('pages.pain.fieldConclusion') }), _jsx("p", { className: "text-ink text-sm leading-relaxed font-medium", children: layers.layer2.conclusion })] })), layers.layer2.applicability && (_jsxs("div", { children: [_jsx("div", { className: "font-mono text-[11px] uppercase tracking-[0.08em] text-ink-4 mb-1", children: t('pages.pain.fieldApplicability') }), _jsx("p", { className: "text-ink-2 text-sm leading-relaxed", children: layers.layer2.applicability })] })), confidenceDisplay && (_jsxs("div", { children: [_jsx("div", { className: "font-mono text-[11px] uppercase tracking-[0.08em] text-ink-4 mb-1", children: t('pages.pain.fieldConfidence') }), _jsx("p", { className: "text-ink-2 text-sm", children: confidenceDisplay })] })), layers.layer2.failureReason && (_jsxs("div", { children: [_jsx("div", { className: "font-mono text-[11px] uppercase tracking-[0.08em] text-ink-4 mb-1", children: t('pages.pain.fieldFailureReason') }), _jsx("p", { className: "text-danger text-sm leading-relaxed", children: layers.layer2.failureReason })] })), layers.layer2.degradedReason && (_jsxs("div", { children: [_jsx("div", { className: "font-mono text-[11px] uppercase tracking-[0.08em] text-ink-4 mb-1", children: t('pages.pain.fieldDegradedReason') }), _jsx("p", { className: "text-amber text-sm leading-relaxed", children: layers.layer2.degradedReason })] })), layers.layer2.nextAction && (_jsxs("div", { children: [_jsx("div", { className: "font-mono text-[11px] uppercase tracking-[0.08em] text-ink-4 mb-1", children: t('pages.pain.fieldNextAction') }), _jsx("p", { className: "text-ink-2 text-sm leading-relaxed", children: layers.layer2.nextAction })] }))] }), _jsxs("div", { className: "mt-4 pt-3 border-t border-line", children: [_jsxs("div", { className: "flex items-center gap-3 flex-wrap", children: [_jsx(Button, { variant: "ghost", size: "sm", onClick: async () => {
|
|
136
|
+
return (_jsxs(Card, { className: "overflow-hidden", children: [_jsx(CardHeader, { children: _jsxs("div", { className: "flex items-start justify-between gap-3", children: [_jsxs("div", { className: "flex items-center gap-2 flex-wrap", children: [_jsx(Badge, { variant: stateVariant, children: stateLabel }), _jsx(Badge, { variant: "outline", children: sourceLabel }), record.admissionDecision && (_jsx(Badge, { variant: "secondary", children: enumLabel('admission', record.admissionDecision, t) }))] }), _jsx("span", { className: "font-mono text-[11px] text-ink-4 whitespace-nowrap", children: formatDate(record.observedAt) })] }) }), _jsxs(CardContent, { children: [_jsxs("div", { className: "space-y-3 mb-4", children: [_jsxs("div", { children: [_jsx("div", { className: "font-mono text-[11px] uppercase tracking-[0.08em] text-ink-4 mb-1", children: t('pages.pain.fieldTrigger') }), layer2Empty ? (_jsx("p", { className: "text-ink-3 text-sm italic leading-relaxed", children: t('pages.pain.noHumanSummary') })) : (_jsx(CardTitle, { className: "text-[15px] leading-relaxed", children: layers.layer2.triggerSummary }))] }), layers.layer2.conclusion && (_jsxs("div", { children: [_jsx("div", { className: "font-mono text-[11px] uppercase tracking-[0.08em] text-ink-4 mb-1", children: t('pages.pain.fieldConclusion') }), _jsx("p", { className: "text-ink text-sm leading-relaxed font-medium", children: layers.layer2.conclusion })] })), layers.layer2.applicability && (_jsxs("div", { children: [_jsx("div", { className: "font-mono text-[11px] uppercase tracking-[0.08em] text-ink-4 mb-1", children: t('pages.pain.fieldApplicability') }), _jsx("p", { className: "text-ink-2 text-sm leading-relaxed", children: layers.layer2.applicability })] })), confidenceDisplay && (_jsxs("div", { children: [_jsx("div", { className: "font-mono text-[11px] uppercase tracking-[0.08em] text-ink-4 mb-1", children: t('pages.pain.fieldConfidence') }), _jsx("p", { className: "text-ink-2 text-sm", children: confidenceDisplay })] })), layers.layer2.failureReason && (_jsxs("div", { children: [_jsx("div", { className: "font-mono text-[11px] uppercase tracking-[0.08em] text-ink-4 mb-1", children: t('pages.pain.fieldFailureReason') }), _jsx("p", { className: "text-danger text-sm leading-relaxed", children: layers.layer2.failureReason })] })), layers.layer2.degradedReason && (_jsxs("div", { children: [_jsx("div", { className: "font-mono text-[11px] uppercase tracking-[0.08em] text-ink-4 mb-1", children: t('pages.pain.fieldDegradedReason') }), _jsx("p", { className: "text-amber text-sm leading-relaxed", children: layers.layer2.degradedReason })] })), layers.layer2.nextAction && (_jsxs("div", { children: [_jsx("div", { className: "font-mono text-[11px] uppercase tracking-[0.08em] text-ink-4 mb-1", children: t('pages.pain.fieldNextAction') }), _jsx("p", { className: "text-ink-2 text-sm leading-relaxed", children: layers.layer2.nextAction })] }))] }), shouldRenderIntentTensionPanel(layers.layer2.intentTension) && (_jsx(IntentTensionPanel, { tension: layers.layer2.intentTension, recordId: record.id, painId: record.id, taskId: record.linkedTaskId ?? undefined, linkedCandidateId: record.linkedCandidateId ?? undefined, t: t })), _jsxs("div", { className: "mt-4 pt-3 border-t border-line", children: [_jsxs("div", { className: "flex items-center gap-3 flex-wrap", children: [_jsx(Button, { variant: "ghost", size: "sm", onClick: async () => {
|
|
136
137
|
try {
|
|
137
138
|
await navigator.clipboard.writeText(buildDebugIdSummary(record));
|
|
138
139
|
setCopied(true);
|
|
@@ -173,3 +174,232 @@ function stateToVariant(state) {
|
|
|
173
174
|
return 'secondary';
|
|
174
175
|
}
|
|
175
176
|
}
|
|
177
|
+
// ── PRI-469: Intent Tension panel (SPEC §22.1) ───────────────────────────────
|
|
178
|
+
/**
|
|
179
|
+
* Convert a snake_case enum value to a PascalCase suffix for i18n keys.
|
|
180
|
+
* E.g. 'action_drift' → 'ActionDrift', 'none' → 'None'.
|
|
181
|
+
*/
|
|
182
|
+
function snakeToPascal(value) {
|
|
183
|
+
return value
|
|
184
|
+
.split('_')
|
|
185
|
+
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
186
|
+
.join('');
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Resolve an intentTension enum value to its localized label.
|
|
190
|
+
* kind determines the i18n key prefix:
|
|
191
|
+
* - 'source' → pages.pain.intentTensionSource{Pascal}
|
|
192
|
+
* - 'evidenceStrength' → pages.pain.intentTensionEvidenceStrength{Pascal}
|
|
193
|
+
* - 'suggestedAction' → pages.pain.intentTensionSuggestedAction{Pascal}
|
|
194
|
+
*/
|
|
195
|
+
function intentTensionEnumLabel(value, kind, t) {
|
|
196
|
+
const keyPrefix = kind === 'source'
|
|
197
|
+
? 'intentTensionSource'
|
|
198
|
+
: kind === 'evidenceStrength'
|
|
199
|
+
? 'intentTensionEvidenceStrength'
|
|
200
|
+
: 'intentTensionSuggestedAction';
|
|
201
|
+
return t(`pages.pain.${keyPrefix}${snakeToPascal(value)}`);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* IntentTensionPanel — renders the intent tension decision panel (SPEC §22.1.2).
|
|
205
|
+
*
|
|
206
|
+
* This panel is rendered only when shouldRenderIntentTensionPanel returns true
|
|
207
|
+
* (i.e., tension is non-null AND source !== 'none' per SPEC §22.1.3).
|
|
208
|
+
*
|
|
209
|
+
* Follow-up actions (SPEC §22.1.4) appear only after a decision is persisted
|
|
210
|
+
* (PRI-471). The FollowUpActions component is rendered inside OwnerDecisionPanel
|
|
211
|
+
* when shouldRenderFollowUpActions returns true.
|
|
212
|
+
*
|
|
213
|
+
* Accessibility (EP-09):
|
|
214
|
+
* - Uses semantic <section> with aria-label
|
|
215
|
+
* - Uses <dl>/<dt>/<dd> for label-value pairs
|
|
216
|
+
* - Color is not the only indicator (text labels always present)
|
|
217
|
+
*/
|
|
218
|
+
function IntentTensionPanel({ tension, recordId, painId, taskId, linkedCandidateId, t }) {
|
|
219
|
+
const sourceLabel = intentTensionEnumLabel(tension.source, 'source', t);
|
|
220
|
+
const strengthLabel = intentTensionEnumLabel(tension.evidenceStrength, 'evidenceStrength', t);
|
|
221
|
+
const actionLabel = intentTensionEnumLabel(tension.suggestedOwnerAction, 'suggestedAction', t);
|
|
222
|
+
return (_jsxs("section", { className: "mt-4 p-4 border border-line rounded-[var(--radius-sm)] bg-paper-2", "aria-label": t('pages.pain.intentTensionTitle'), children: [_jsxs("h4", { className: "text-[13px] font-semibold text-ink mb-3 flex items-center gap-2", children: [_jsx("span", { "aria-hidden": "true", className: "inline-block w-1.5 h-1.5 rounded-full bg-amber" }), t('pages.pain.intentTensionTitle')] }), _jsxs("dl", { className: "grid grid-cols-[auto_1fr] gap-x-4 gap-y-2 text-[13px]", children: [_jsx("dt", { className: "font-mono text-ink-4", children: t('pages.pain.intentTensionSourceLabel') }), _jsx("dd", { className: "text-ink-2", children: sourceLabel }), _jsx("dt", { className: "font-mono text-ink-4", children: t('pages.pain.intentTensionEvidenceStrengthLabel') }), _jsx("dd", { className: "text-ink-2", children: strengthLabel }), _jsx("dt", { className: "font-mono text-ink-4", children: t('pages.pain.intentTensionSuggestedActionLabel') }), _jsx("dd", { className: "text-ink-2 font-medium", children: actionLabel })] }), tension.relatedIntentFields.length > 0 && (_jsxs("div", { className: "mt-3", children: [_jsx("div", { className: "font-mono text-[11px] uppercase tracking-[0.08em] text-ink-4 mb-1", children: t('pages.pain.intentTensionRelatedIntentFieldsLabel') }), _jsx("div", { className: "flex flex-wrap gap-1.5", children: tension.relatedIntentFields.map((field, idx) => (_jsx(Badge, { variant: "outline", children: field }, `${field}-${idx}`))) })] })), tension.evidence.length > 0 && (_jsxs("div", { className: "mt-3", children: [_jsx("div", { className: "font-mono text-[11px] uppercase tracking-[0.08em] text-ink-4 mb-1", children: t('pages.pain.intentTensionEvidenceLabel') }), _jsx("ul", { className: "text-ink-2 text-sm leading-relaxed space-y-1", children: tension.evidence.map((item, idx) => (_jsx("li", { className: "pl-3 relative before:content-[''] before:absolute before:left-0 before:top-2 before:w-1 before:h-1 before:rounded-full before:bg-ink-4", children: item }, `${idx}-${item.slice(0, 12)}`))) })] })), _jsxs("div", { className: "mt-3", children: [_jsx("div", { className: "font-mono text-[11px] uppercase tracking-[0.08em] text-ink-4 mb-1", children: t('pages.pain.intentTensionExplanationLabel') }), _jsx("p", { className: "text-ink-2 text-sm leading-relaxed", children: tension.explanation })] }), tension.intentDocHash && (_jsxs("div", { className: "mt-3", children: [_jsx("div", { className: "font-mono text-[11px] uppercase tracking-[0.08em] text-ink-4 mb-1", children: t('pages.pain.intentTensionIntentDocHashLabel') }), _jsx("p", { className: "font-mono text-[11px] text-ink-3 break-all", children: tension.intentDocHash })] })), _jsx(OwnerDecisionPanel, { tension: tension, recordId: recordId, painId: painId, taskId: taskId, linkedCandidateId: linkedCandidateId, t: t })] }));
|
|
223
|
+
}
|
|
224
|
+
const OWNER_ACTION_BUTTONS = [
|
|
225
|
+
{ action: 'confirm_drift', labelKey: 'pages.pain.ownerDecisionSubmitConfirmDrift' },
|
|
226
|
+
{ action: 'revise_intent', labelKey: 'pages.pain.ownerDecisionSubmitReviseIntent' },
|
|
227
|
+
{ action: 'observe', labelKey: 'pages.pain.ownerDecisionSubmitObserve' },
|
|
228
|
+
{ action: 'dismiss', labelKey: 'pages.pain.ownerDecisionSubmitDismiss' },
|
|
229
|
+
{ action: 'promote_to_principle', labelKey: 'pages.pain.ownerDecisionSubmitPromoteToPrinciple' },
|
|
230
|
+
{ action: 'promote_to_rulehost', labelKey: 'pages.pain.ownerDecisionSubmitPromoteToRulehost' },
|
|
231
|
+
];
|
|
232
|
+
/**
|
|
233
|
+
* SPEC §22.1.3 + §24.5: each `source` value has exactly ONE primary action.
|
|
234
|
+
* - action_drift → Confirm Drift (primary)
|
|
235
|
+
* - intent_suspect → Revise Intent (primary)
|
|
236
|
+
* - healthy_tension → Observe (primary)
|
|
237
|
+
* - none → (no decision panel rendered — handled by shouldRenderIntentTensionPanel)
|
|
238
|
+
*
|
|
239
|
+
* The primary button uses `variant="default"` (the Button component's primary
|
|
240
|
+
* style: bg-gov text-paper); all others use `variant="outline"`.
|
|
241
|
+
* This satisfies §24.5 acceptance criterion 4: "primary action 不相同,且每种状态只有一个 primary".
|
|
242
|
+
*/
|
|
243
|
+
const PRIMARY_ACTION_BY_SOURCE = {
|
|
244
|
+
action_drift: 'confirm_drift',
|
|
245
|
+
intent_suspect: 'revise_intent',
|
|
246
|
+
healthy_tension: 'observe',
|
|
247
|
+
};
|
|
248
|
+
/**
|
|
249
|
+
* OwnerDecisionPanel — renders the Owner decision flow for an intent tension.
|
|
250
|
+
*
|
|
251
|
+
* State machine: 'idle' | 'submitting' | 'recorded' | 'error'
|
|
252
|
+
* - On mount, fetches existing decisions by painId (or taskId fallback).
|
|
253
|
+
* - Shows 6 action buttons + optional note input.
|
|
254
|
+
* - On submit, calls buildIntentDecisionPayload + recordIntentDecision.
|
|
255
|
+
* - Follow-up actions placeholder appears when existingDecisions is non-empty.
|
|
256
|
+
*
|
|
257
|
+
* Accessibility (EP-09):
|
|
258
|
+
* - Uses semantic <section> with aria-label
|
|
259
|
+
* - Buttons have descriptive text labels
|
|
260
|
+
*/
|
|
261
|
+
function OwnerDecisionPanel({ tension, recordId, painId, taskId, linkedCandidateId, t }) {
|
|
262
|
+
const [panelState, setPanelState] = useState('idle');
|
|
263
|
+
const [loadState, setLoadState] = useState('loading');
|
|
264
|
+
const [existingDecisions, setExistingDecisions] = useState([]);
|
|
265
|
+
const [note, setNote] = useState('');
|
|
266
|
+
const [errorMsg, setErrorMsg] = useState(null);
|
|
267
|
+
// Fetch existing decisions on mount — use painId when available, fall back to taskId.
|
|
268
|
+
useEffect(() => {
|
|
269
|
+
let cancelled = false;
|
|
270
|
+
const loadExisting = async () => {
|
|
271
|
+
setLoadState('loading');
|
|
272
|
+
const hasPainId = painId !== undefined && painId.length > 0;
|
|
273
|
+
const hasTaskId = taskId !== undefined && taskId.length > 0;
|
|
274
|
+
if (!hasPainId && !hasTaskId) {
|
|
275
|
+
// Nothing to query by — skip loading, treat as empty.
|
|
276
|
+
if (!cancelled)
|
|
277
|
+
setLoadState('loaded');
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
const result = hasPainId
|
|
281
|
+
? await listIntentDecisionsByPainId(painId)
|
|
282
|
+
: await listIntentDecisionsByTaskId(taskId);
|
|
283
|
+
if (cancelled)
|
|
284
|
+
return;
|
|
285
|
+
if (!result.success) {
|
|
286
|
+
setLoadState('error');
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
setExistingDecisions(result.data);
|
|
290
|
+
setLoadState('loaded');
|
|
291
|
+
};
|
|
292
|
+
void loadExisting();
|
|
293
|
+
return () => { cancelled = true; };
|
|
294
|
+
}, [painId, taskId]);
|
|
295
|
+
const handleSubmit = async (ownerAction) => {
|
|
296
|
+
setPanelState('submitting');
|
|
297
|
+
setErrorMsg(null);
|
|
298
|
+
// P0 fix (PRI-471): server requires a caller-supplied decision id.
|
|
299
|
+
// Use crypto.randomUUID() — available in modern browsers and Node 19+.
|
|
300
|
+
// Fallback to a timestamp-based id if crypto is unavailable (defensive).
|
|
301
|
+
const decisionId = (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function')
|
|
302
|
+
? crypto.randomUUID()
|
|
303
|
+
: 'decision-' + Date.now() + '-' + Math.random().toString(36).slice(2, 10);
|
|
304
|
+
const context = {
|
|
305
|
+
id: decisionId,
|
|
306
|
+
recordId,
|
|
307
|
+
painId,
|
|
308
|
+
taskId,
|
|
309
|
+
intentDocHash: tension.intentDocHash,
|
|
310
|
+
};
|
|
311
|
+
const payload = buildIntentDecisionPayload(tension, context, { ownerAction, note });
|
|
312
|
+
const result = await recordIntentDecision(payload);
|
|
313
|
+
if (!result.success) {
|
|
314
|
+
setPanelState('error');
|
|
315
|
+
setErrorMsg(result.error ?? t('pages.pain.ownerDecisionFailed'));
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
setPanelState('recorded');
|
|
319
|
+
// Add the new decision so follow-up actions appear.
|
|
320
|
+
setExistingDecisions([result.data.record, ...existingDecisions]);
|
|
321
|
+
};
|
|
322
|
+
const hasExisting = existingDecisions.length > 0;
|
|
323
|
+
const showFollowUp = shouldRenderFollowUpActions(existingDecisions);
|
|
324
|
+
// PRI-471: the most recent decision drives which follow-up actions are shown.
|
|
325
|
+
// Decisions are sorted DESC by createdAt (server side), so [0] is the latest.
|
|
326
|
+
const latestDecision = existingDecisions[0];
|
|
327
|
+
return (_jsxs("div", { className: "mt-4 pt-3 border-t border-line", children: [_jsx("h5", { className: "text-[13px] font-semibold text-ink mb-1", children: t('pages.pain.ownerDecisionPanelTitle') }), _jsx("p", { className: "text-ink-3 text-[12px] leading-relaxed mb-3", children: t('pages.pain.ownerDecisionPanelSubtitle') }), loadState === 'loading' && (_jsx("p", { className: "text-ink-4 text-[12px] italic", children: t('pages.pain.ownerDecisionLoadingExisting') })), loadState === 'error' && (_jsx("p", { className: "text-amber text-[12px]", children: t('pages.pain.ownerDecisionLoadFailed') })), loadState === 'loaded' && hasExisting && panelState !== 'recorded' && (_jsx("p", { className: "text-ink-3 text-[12px] mb-3 italic", children: t('pages.pain.ownerDecisionExisting') })), panelState === 'recorded' && (_jsx("p", { className: "text-emerald text-[12px] mb-3 font-medium", children: t('pages.pain.ownerDecisionRecorded') })), panelState === 'error' && errorMsg && (_jsxs("p", { className: "text-danger text-[12px] mb-3", children: [t('pages.pain.ownerDecisionFailed'), ": ", errorMsg] })), panelState !== 'recorded' && loadState === 'loaded' && (_jsxs(_Fragment, { children: [_jsxs("div", { className: "mb-3", children: [_jsx("label", { className: "block font-mono text-[11px] uppercase tracking-[0.08em] text-ink-4 mb-1", children: t('pages.pain.ownerDecisionNoteLabel') }), _jsx("input", { type: "text", value: note, onChange: (e) => setNote(e.target.value), placeholder: t('pages.pain.ownerDecisionNotePlaceholder'), disabled: panelState === 'submitting', className: "w-full px-3 py-1.5 text-[13px] bg-surface border border-line rounded-[var(--radius-sm)] text-ink-2 focus-visible:outline-2 focus-visible:outline-gov focus-visible:outline-offset-2 disabled:opacity-50" })] }), _jsx("div", { className: "flex flex-wrap gap-2", children: OWNER_ACTION_BUTTONS.map(({ action, labelKey }) => {
|
|
328
|
+
// SPEC §22.1.3: the source determines which single button is primary.
|
|
329
|
+
const isPrimary = PRIMARY_ACTION_BY_SOURCE[tension.source] === action;
|
|
330
|
+
return (_jsx(Button, { variant: isPrimary ? 'default' : 'outline', size: "sm", disabled: panelState === 'submitting', onClick: () => void handleSubmit(action), children: panelState === 'submitting'
|
|
331
|
+
? t('pages.pain.ownerDecisionSubmitting')
|
|
332
|
+
: t(labelKey) }, action));
|
|
333
|
+
}) })] })), showFollowUp && latestDecision && (_jsx(FollowUpActions, { decision: latestDecision, linkedCandidateId: linkedCandidateId, onDecisionUpdated: (updated) => {
|
|
334
|
+
// Replace the updated decision in the list (idempotent on id).
|
|
335
|
+
setExistingDecisions((prev) => prev.map((d) => (d.id === updated.id ? updated : d)));
|
|
336
|
+
}, t: t }))] }));
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* FollowUpActions — renders the governed follow-up actions available after an
|
|
340
|
+
* Owner decision has been persisted (SPEC §22.1.4).
|
|
341
|
+
*
|
|
342
|
+
* Which actions are shown depends on the decision's `ownerAction`:
|
|
343
|
+
* - `confirm_drift` → "Link Existing Candidate" (links to the evidence chain's
|
|
344
|
+
* linkedCandidateId, or prompts the Owner to enter one if not available).
|
|
345
|
+
* - `promote_to_rulehost` → "View RuleHost Guidance" (returns CLI command).
|
|
346
|
+
* - `revise_intent` → "View Intent Patch Proposal" (returns read-only markdown).
|
|
347
|
+
* - `observe` / `dismiss` → no follow-up actions rendered (SPEC §22.1.4).
|
|
348
|
+
*
|
|
349
|
+
* Boundaries respected:
|
|
350
|
+
* - No new activation channel — `link_candidate` only records an audit link.
|
|
351
|
+
* - No SkillFileWriter, no auto-modification of INTENT.md — the patch proposal
|
|
352
|
+
* is display-only.
|
|
353
|
+
* - No direct rule creation — `guide_rulehost` only returns CLI guidance.
|
|
354
|
+
*
|
|
355
|
+
* Accessibility (EP-09):
|
|
356
|
+
* - Uses semantic <section> with aria-label
|
|
357
|
+
* - Buttons have descriptive text labels
|
|
358
|
+
* - Status messages use role="status" for screen readers
|
|
359
|
+
*/
|
|
360
|
+
function FollowUpActions({ decision, linkedCandidateId, onDecisionUpdated, t }) {
|
|
361
|
+
const [busyState, setBusyState] = useState('idle');
|
|
362
|
+
const [errorMsg, setErrorMsg] = useState(null);
|
|
363
|
+
const [response, setResponse] = useState(null);
|
|
364
|
+
const [candidateIdInput, setCandidateIdInput] = useState(linkedCandidateId ?? '');
|
|
365
|
+
const ownerAction = decision.ownerAction;
|
|
366
|
+
// SPEC §22.1.4: observe and dismiss record decisions without follow-up actions.
|
|
367
|
+
if (ownerAction === 'observe' || ownerAction === 'dismiss') {
|
|
368
|
+
return null;
|
|
369
|
+
}
|
|
370
|
+
const handleDispatch = async (type) => {
|
|
371
|
+
setBusyState('dispatching');
|
|
372
|
+
setErrorMsg(null);
|
|
373
|
+
setResponse(null);
|
|
374
|
+
// Trim the candidate id so leading/trailing whitespace never reaches the
|
|
375
|
+
// audit trail (the disable-check already trims; the payload must match it).
|
|
376
|
+
// The server re-trims as the trust-boundary authority (EP-01).
|
|
377
|
+
const payload = type === 'link_candidate'
|
|
378
|
+
? { type, candidateId: candidateIdInput.trim() }
|
|
379
|
+
: { type };
|
|
380
|
+
const result = await dispatchFollowUp(decision.id, payload);
|
|
381
|
+
if (!result.success) {
|
|
382
|
+
setBusyState('error');
|
|
383
|
+
setErrorMsg(result.error ?? t('pages.pain.followUpDispatchFailed'));
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
setBusyState('dispatched');
|
|
387
|
+
setResponse(result.data);
|
|
388
|
+
// For follow-up types that update the record (link_candidate,
|
|
389
|
+
// generate_patch_proposal), propagate the updated record up so the
|
|
390
|
+
// parent's existingDecisions list stays in sync.
|
|
391
|
+
if (result.data.type === 'link_candidate' || result.data.type === 'generate_patch_proposal') {
|
|
392
|
+
onDecisionUpdated(result.data.record);
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
const isDispatching = busyState === 'dispatching';
|
|
396
|
+
return (_jsxs("div", { className: "mt-4 p-3 bg-paper-2 border border-line rounded-[var(--radius-sm)]", children: [_jsx("div", { className: "font-mono text-[11px] uppercase tracking-[0.08em] text-ink-4 mb-2", children: t('pages.pain.followUpActionsTitle') }), ownerAction === 'confirm_drift' && (_jsxs("div", { className: "space-y-2", children: [_jsx("p", { className: "text-ink-2 text-[13px] leading-relaxed", children: t('pages.pain.followUpLinkCandidateDescription') }), _jsxs("div", { className: "flex gap-2 items-start", children: [_jsx("input", { type: "text", value: candidateIdInput, onChange: (e) => setCandidateIdInput(e.target.value), placeholder: t('pages.pain.followUpCandidateIdPlaceholder'), "aria-label": t('pages.pain.followUpCandidateIdAriaLabel'), disabled: isDispatching, className: "flex-1 px-3 py-1.5 text-[13px] bg-surface border border-line rounded-[var(--radius-sm)] text-ink-2 focus-visible:outline-2 focus-visible:outline-gov focus-visible:outline-offset-2 disabled:opacity-50 font-mono" }), _jsx(Button, { variant: "outline", size: "sm", disabled: isDispatching || candidateIdInput.trim() === '', onClick: () => void handleDispatch('link_candidate'), children: isDispatching
|
|
397
|
+
? t('pages.pain.followUpDispatching')
|
|
398
|
+
: t('pages.pain.followUpLinkCandidateButton') })] }), linkedCandidateId && (_jsx("p", { className: "text-ink-4 text-[11px] italic", children: t('pages.pain.followUpPrefilledFromEvidenceChain') })), busyState === 'dispatched' && response?.type === 'link_candidate' && (_jsxs("p", { role: "status", className: "text-emerald text-[12px] font-medium", children: [t('pages.pain.followUpLinkedSuccess'), ": ", _jsx("span", { className: "font-mono", children: response.linkedCandidateId })] }))] })), ownerAction === 'promote_to_rulehost' && (_jsxs("div", { className: "space-y-2", children: [_jsx("p", { className: "text-ink-2 text-[13px] leading-relaxed", children: t('pages.pain.followUpGuideRulehostDescription') }), _jsx(Button, { variant: "outline", size: "sm", disabled: isDispatching, onClick: () => void handleDispatch('guide_rulehost'), children: isDispatching
|
|
399
|
+
? t('pages.pain.followUpDispatching')
|
|
400
|
+
: t('pages.pain.followUpGuideRulehostButton') }), busyState === 'dispatched' && response?.type === 'guide_rulehost' && (_jsxs("div", { role: "status", className: "mt-2 p-2 bg-surface border border-line rounded-[var(--radius-sm)]", children: [_jsx("div", { className: "font-mono text-[11px] uppercase tracking-[0.08em] text-ink-4 mb-1", children: t('pages.pain.followUpCliCommandLabel') }), _jsx("pre", { className: "font-mono text-[12px] text-ink-2 whitespace-pre-wrap break-all", children: response.cliCommand }), _jsx("p", { className: "text-ink-3 text-[12px] mt-2 leading-relaxed", children: response.note })] }))] })), ownerAction === 'revise_intent' && (_jsxs("div", { className: "space-y-2", children: [_jsx("p", { className: "text-ink-2 text-[13px] leading-relaxed", children: t('pages.pain.followUpPatchProposalDescription') }), _jsx(Button, { variant: "outline", size: "sm", disabled: isDispatching, onClick: () => void handleDispatch('generate_patch_proposal'), children: isDispatching
|
|
401
|
+
? t('pages.pain.followUpDispatching')
|
|
402
|
+
: t('pages.pain.followUpViewPatchProposalButton') }), busyState === 'dispatched' && response?.type === 'generate_patch_proposal' && (_jsxs("div", { role: "status", className: "mt-2 p-2 bg-surface border border-line rounded-[var(--radius-sm)]", children: [_jsxs("div", { className: "flex items-center gap-2 mb-2", children: [_jsx("div", { className: "font-mono text-[11px] uppercase tracking-[0.08em] text-ink-4", children: t('pages.pain.followUpPatchProposalLabel') }), _jsx(Badge, { variant: "outline", className: "text-[10px]", children: t('pages.pain.followUpPatchProposalReadOnlyBadge') })] }), _jsx("pre", { className: "font-mono text-[11px] text-ink-2 whitespace-pre-wrap break-all bg-paper-2 p-2 rounded-[var(--radius-sm)] border border-line max-h-80 overflow-y-auto", children: response.patchProposal.markdown }), _jsx("p", { className: "text-amber text-[11px] mt-2 italic", children: t('pages.pain.followUpPatchProposalWarning') })] }))] })), ownerAction === 'promote_to_principle' && (_jsxs("div", { className: "space-y-2", children: [_jsx("p", { className: "text-ink-2 text-[13px] leading-relaxed", children: t('pages.pain.followUpPromoteToPrincipleDescription') }), _jsxs("div", { className: "flex gap-2 items-start", children: [_jsx("input", { type: "text", value: candidateIdInput, onChange: (e) => setCandidateIdInput(e.target.value), placeholder: t('pages.pain.followUpCandidateIdPlaceholder'), "aria-label": t('pages.pain.followUpCandidateIdAriaLabel'), disabled: isDispatching, className: "flex-1 px-3 py-1.5 text-[13px] bg-surface border border-line rounded-[var(--radius-sm)] text-ink-2 focus-visible:outline-2 focus-visible:outline-gov focus-visible:outline-offset-2 disabled:opacity-50 font-mono" }), _jsx(Button, { variant: "outline", size: "sm", disabled: isDispatching || candidateIdInput.trim() === '', onClick: () => void handleDispatch('link_candidate'), children: isDispatching
|
|
403
|
+
? t('pages.pain.followUpDispatching')
|
|
404
|
+
: t('pages.pain.followUpLinkCandidateButton') })] }), linkedCandidateId && (_jsx("p", { className: "text-ink-4 text-[11px] italic", children: t('pages.pain.followUpPrefilledFromEvidenceChain') })), busyState === 'dispatched' && response?.type === 'link_candidate' && (_jsxs("p", { role: "status", className: "text-emerald text-[12px] font-medium", children: [t('pages.pain.followUpLinkedSuccess'), ": ", _jsx("span", { className: "font-mono", children: response.linkedCandidateId })] }))] })), busyState === 'error' && errorMsg && (_jsxs("p", { role: "alert", className: "text-danger text-[12px] mt-2", children: [t('pages.pain.followUpDispatchFailed'), ": ", errorMsg] }))] }));
|
|
405
|
+
}
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* PRI-344: Extracted from PainPage.tsx for testability.
|
|
5
5
|
* No React dependency, no I/O. All functions are pure.
|
|
6
6
|
*/
|
|
7
|
+
import type { IntentTensionData, IntentDecisionRecordData } from '../../utils/validators.js';
|
|
8
|
+
import type { IntentDecisionInputPayload } from '../../api.js';
|
|
7
9
|
export type ConfidenceLabel = 'high' | 'mid' | 'low';
|
|
8
10
|
/**
|
|
9
11
|
* Map a numeric confidence to a human-readable label.
|
|
@@ -33,6 +35,12 @@ export interface Layer2Data {
|
|
|
33
35
|
degradedReason: string | null;
|
|
34
36
|
/** next action guidance */
|
|
35
37
|
nextAction: string | null;
|
|
38
|
+
/**
|
|
39
|
+
* PRI-469: optional intent tension from the diagnostician artifact.
|
|
40
|
+
* Present only when the record carries a validated intentTension.
|
|
41
|
+
* The UI renders an IntentTensionPanel when this is non-null (SPEC §22.1.2).
|
|
42
|
+
*/
|
|
43
|
+
intentTension: IntentTensionData | null;
|
|
36
44
|
}
|
|
37
45
|
export interface Layer3Data {
|
|
38
46
|
id: string;
|
|
@@ -72,6 +80,8 @@ export interface RecordData {
|
|
|
72
80
|
/** PRI-380: internalization task linkage */
|
|
73
81
|
internalizationTaskId?: string;
|
|
74
82
|
dreamerTaskStatus?: string;
|
|
83
|
+
/** PRI-469: optional intent tension from diagnostician artifact (SPEC §16). */
|
|
84
|
+
intentTension?: IntentTensionData;
|
|
75
85
|
}
|
|
76
86
|
/**
|
|
77
87
|
* Build the three-layer card data from a record.
|
|
@@ -98,3 +108,68 @@ export declare function buildDebugIdSummary(record: RecordData): string;
|
|
|
98
108
|
* string, AND no conclusion/applicability/failureReason/degradedReason.
|
|
99
109
|
*/
|
|
100
110
|
export declare function isLayer2EffectivelyEmpty(record: RecordData): boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Whether the IntentTensionPanel should render a high-salience decision panel.
|
|
113
|
+
*
|
|
114
|
+
* SPEC §22.1.3: when `source = none`, do NOT render a high-salience decision
|
|
115
|
+
* panel. The tension may still be shown in technical details as "no intent
|
|
116
|
+
* tension", but it must not compete for the Owner's attention.
|
|
117
|
+
*
|
|
118
|
+
* This helper is pure and tested independently of the React component.
|
|
119
|
+
*/
|
|
120
|
+
export declare function shouldRenderIntentTensionPanel(tension: IntentTensionData | null | undefined): tension is IntentTensionData;
|
|
121
|
+
/**
|
|
122
|
+
* Whether follow-up actions (precipitate candidate principle, promote to
|
|
123
|
+
* RuleHost, view Intent Patch Proposal) should be visible.
|
|
124
|
+
*
|
|
125
|
+
* SPEC §22.1.4: follow-up actions are NOT the first-layer decision. They only
|
|
126
|
+
* appear after the Owner has confirmed a decision (an IntentDecisionRecord
|
|
127
|
+
* has been persisted for this tension).
|
|
128
|
+
*
|
|
129
|
+
* PRI-470: replaced the PRI-469 stub. Now returns true only when a non-empty
|
|
130
|
+
* decisions array exists — i.e., at least one IntentDecisionRecord has been
|
|
131
|
+
* persisted for this tension.
|
|
132
|
+
*/
|
|
133
|
+
export declare function shouldRenderFollowUpActions(decisions?: IntentDecisionRecordData[] | null): boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Context needed to build an IntentDecisionInputPayload from a tension.
|
|
136
|
+
* `id` is a caller-supplied UUID for the decision record. `recordId` is the
|
|
137
|
+
* evidence chain record ID used as a fallback when taskId is not available.
|
|
138
|
+
* `painId` and `intentDocHash` are optional.
|
|
139
|
+
*/
|
|
140
|
+
export interface IntentDecisionContext {
|
|
141
|
+
id: string;
|
|
142
|
+
recordId: string;
|
|
143
|
+
painId?: string;
|
|
144
|
+
taskId?: string;
|
|
145
|
+
intentDocHash?: string;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* The Owner's decision on an intent tension. `ownerAction` overrides
|
|
149
|
+
* `tension.suggestedOwnerAction` — the Owner may choose a different action
|
|
150
|
+
* than the one PD suggested. `note` is an optional trimmed annotation.
|
|
151
|
+
*/
|
|
152
|
+
export interface IntentDecisionChoice {
|
|
153
|
+
ownerAction: string;
|
|
154
|
+
note?: string;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Build an IntentDecisionInputPayload from an IntentTension and the Owner's
|
|
158
|
+
* chosen action. The payload is sent to POST /api/v1/intent-decisions.
|
|
159
|
+
*
|
|
160
|
+
* - `id` is the caller-supplied decision UUID (P0 fix: server requires this).
|
|
161
|
+
* - `taskId` falls back to `recordId` when not provided.
|
|
162
|
+
* - Optional fields (painId, intentDocHash, note) are omitted when empty.
|
|
163
|
+
* - `note` is trimmed before being included.
|
|
164
|
+
* - `evidenceRefs` is passed through as-is; truncation is the backend's job
|
|
165
|
+
* (the frontend must not silently drop evidence the Owner might rely on).
|
|
166
|
+
* - `ownerAction` overrides `tension.suggestedOwnerAction` — the Owner may
|
|
167
|
+
* choose a different action than the one PD suggested.
|
|
168
|
+
*
|
|
169
|
+
* P0 fix (PRI-471): the previous payload used `evidence` + `explanation` +
|
|
170
|
+
* `suggestedAction` and omitted `id`, which did not match the server's
|
|
171
|
+
* `IntentDecisionInput` contract (SPEC §21.7). The server requires `id` and
|
|
172
|
+
* `evidenceRefs`, and does not accept `explanation` or `suggestedAction` —
|
|
173
|
+
* those are snapshot fields the server persists from the tension, not inputs.
|
|
174
|
+
*/
|
|
175
|
+
export declare function buildIntentDecisionPayload(tension: IntentTensionData, context: IntentDecisionContext, choice: IntentDecisionChoice): IntentDecisionInputPayload;
|