create-principles-disciple 1.145.15 → 1.145.17

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.
Files changed (67) hide show
  1. package/_release/product-identity.json +2 -2
  2. package/codex-adapter/dist/worker/workspace-worker.js +2 -1
  3. package/console/dist/server/index.js +12 -0
  4. package/console/dist/server/routes/design-gate.d.ts +11 -0
  5. package/console/dist/server/routes/design-gate.js +156 -0
  6. package/console/dist/ui/api.d.ts +29 -1
  7. package/console/dist/ui/api.js +105 -1
  8. package/console/dist/ui/i18n/en.json +45 -0
  9. package/console/dist/ui/i18n/zh-CN.json +45 -0
  10. package/console/dist/ui/pages/control-center/ControlCenterPage.js +2 -1
  11. package/console/dist/ui/pages/control-center/DesignGatePanel.d.ts +1 -0
  12. package/console/dist/ui/pages/control-center/DesignGatePanel.js +137 -0
  13. package/console/dist/web/assets/app.css +6 -0
  14. package/console/dist/web/assets/app.js +30 -30
  15. package/core/dist/runtime-v2/index.d.ts +3 -0
  16. package/core/dist/runtime-v2/index.d.ts.map +1 -1
  17. package/core/dist/runtime-v2/index.js +3 -0
  18. package/core/dist/runtime-v2/index.js.map +1 -1
  19. package/core/dist/runtime-v2/internalization/artificer-intent-preflight.d.ts +12 -0
  20. package/core/dist/runtime-v2/internalization/artificer-intent-preflight.d.ts.map +1 -1
  21. package/core/dist/runtime-v2/internalization/artificer-intent-preflight.js +23 -0
  22. package/core/dist/runtime-v2/internalization/artificer-intent-preflight.js.map +1 -1
  23. package/core/dist/runtime-v2/internalization/artificer-prompt-builder.d.ts +1 -1
  24. package/core/dist/runtime-v2/internalization/artificer-prompt-builder.d.ts.map +1 -1
  25. package/core/dist/runtime-v2/internalization/artificer-prompt-builder.js +15 -5
  26. package/core/dist/runtime-v2/internalization/artificer-prompt-builder.js.map +1 -1
  27. package/core/dist/runtime-v2/internalization/design-gate-facts.d.ts +54 -0
  28. package/core/dist/runtime-v2/internalization/design-gate-facts.d.ts.map +1 -0
  29. package/core/dist/runtime-v2/internalization/design-gate-facts.js +172 -0
  30. package/core/dist/runtime-v2/internalization/design-gate-facts.js.map +1 -0
  31. package/core/dist/runtime-v2/internalization/evaluator-prompt-builder.d.ts +8 -1
  32. package/core/dist/runtime-v2/internalization/evaluator-prompt-builder.d.ts.map +1 -1
  33. package/core/dist/runtime-v2/internalization/evaluator-prompt-builder.js +73 -3
  34. package/core/dist/runtime-v2/internalization/evaluator-prompt-builder.js.map +1 -1
  35. package/core/dist/runtime-v2/internalization/evaluator-runner.d.ts.map +1 -1
  36. package/core/dist/runtime-v2/internalization/evaluator-runner.js +64 -2
  37. package/core/dist/runtime-v2/internalization/evaluator-runner.js.map +1 -1
  38. package/core/dist/runtime-v2/internalization/rule-context-v2.d.ts +3 -0
  39. package/core/dist/runtime-v2/internalization/rule-context-v2.d.ts.map +1 -1
  40. package/core/dist/runtime-v2/internalization/rule-context-v2.js +4 -0
  41. package/core/dist/runtime-v2/internalization/rule-context-v2.js.map +1 -1
  42. package/core/dist/runtime-v2/store/design-gate/sqlite-design-gate-store.d.ts +49 -0
  43. package/core/dist/runtime-v2/store/design-gate/sqlite-design-gate-store.d.ts.map +1 -0
  44. package/core/dist/runtime-v2/store/design-gate/sqlite-design-gate-store.js +274 -0
  45. package/core/dist/runtime-v2/store/design-gate/sqlite-design-gate-store.js.map +1 -0
  46. package/core/dist/runtime-v2/store/sqlite-connection.d.ts.map +1 -1
  47. package/core/dist/runtime-v2/store/sqlite-connection.js +31 -0
  48. package/core/dist/runtime-v2/store/sqlite-connection.js.map +1 -1
  49. package/core/package.json +5 -1
  50. package/host-runtime/dist/codex-artificer-trusted-facts.d.ts +7 -0
  51. package/host-runtime/dist/codex-artificer-trusted-facts.js +17 -0
  52. package/host-runtime/dist/codex-rule-context-provider.js +82 -13
  53. package/host-runtime/dist/design-gate-facts.d.ts +37 -0
  54. package/host-runtime/dist/design-gate-facts.js +249 -0
  55. package/host-runtime/dist/index.d.ts +3 -0
  56. package/host-runtime/dist/index.js +3 -0
  57. package/host-runtime/dist/production-rulehost-gate.js +37 -1
  58. package/host-runtime/dist/workspace-behavior-evidence.d.ts +9 -0
  59. package/host-runtime/dist/workspace-behavior-evidence.js +85 -0
  60. package/host-runtime/package.json +1 -1
  61. package/package.json +1 -1
  62. package/pd-cli/package.json +1 -1
  63. package/plugin/dist/bundle.js +449 -419
  64. package/plugin/dist/rulehost-evidence.js +24 -24
  65. package/release-manager/package.json +1 -1
  66. package/workbuddy-adapter/package.json +1 -1
  67. package/workbuddy-adapter/plugin/.codebuddy-plugin/plugin.json +1 -1
@@ -0,0 +1,137 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
3
+ import { useTranslation } from "react-i18next";
4
+ import { SectionTitle } from "../../components/layout/section-title.js";
5
+ import { createDesignGateDeclaration, fetchDesignGateDeclaration, fetchDesignGateSessions, revokeDesignGateDeclaration, updateDesignGateDecision, } from "../../api.js";
6
+ const decisionTranslationKey = {
7
+ approved: "approved",
8
+ not_approved: "notApproved",
9
+ not_required: "notRequired",
10
+ };
11
+ const actionTranslationKey = {
12
+ read: "read",
13
+ write: "write",
14
+ execute: "execute",
15
+ };
16
+ function sessionKey(session) {
17
+ return `${session.projectWorkspacePath}\u001f${session.hostSessionId}`;
18
+ }
19
+ function parsePaths(value) {
20
+ return value.split(/\r?\n/).map((path) => path.trim()).filter(Boolean);
21
+ }
22
+ function errorFromResponse(response) {
23
+ return { error: response.error, nextAction: response.nextAction, status: response.status };
24
+ }
25
+ function fieldClass() {
26
+ return "mt-1 w-full rounded-[4px] border border-line bg-surface px-3 py-2 text-[13px] text-ink focus-visible:outline-2 focus-visible:outline-gov focus-visible:outline-offset-2";
27
+ }
28
+ function actionButtonClass() {
29
+ return "rounded-[4px] border border-line px-3 py-2 text-[12.5px] font-medium text-ink transition-colors hover:border-line-2 focus-visible:outline-2 focus-visible:outline-gov focus-visible:outline-offset-2 disabled:cursor-not-allowed disabled:opacity-50";
30
+ }
31
+ export function DesignGatePanel() {
32
+ const { t } = useTranslation();
33
+ const [sessions, setSessions] = useState([]);
34
+ const [selectedKey, setSelectedKey] = useState("");
35
+ const [declaration, setDeclaration] = useState(null);
36
+ const [sessionsLoading, setSessionsLoading] = useState(true);
37
+ const [declarationLoading, setDeclarationLoading] = useState(false);
38
+ const [pending, setPending] = useState(false);
39
+ const [error, setError] = useState(null);
40
+ const [specPath, setSpecPath] = useState("");
41
+ const [scopePaths, setScopePaths] = useState("");
42
+ const [scopeActions, setScopeActions] = useState(["write", "execute"]);
43
+ const [newDecision, setNewDecision] = useState("not_approved");
44
+ const declarationRequest = useRef(0);
45
+ const selectedSession = useMemo(() => sessions.find((session) => sessionKey(session) === selectedKey) ?? null, [sessions, selectedKey]);
46
+ const loadSessions = useCallback(async () => {
47
+ setSessionsLoading(true);
48
+ setError(null);
49
+ const result = await fetchDesignGateSessions();
50
+ setSessionsLoading(false);
51
+ if (!result.success) {
52
+ setError(errorFromResponse(result));
53
+ return;
54
+ }
55
+ setSessions(result.data.sessions);
56
+ setSelectedKey((current) => result.data.sessions.some((session) => sessionKey(session) === current)
57
+ ? current
58
+ : result.data.sessions[0] ? sessionKey(result.data.sessions[0]) : "");
59
+ }, []);
60
+ const loadDeclaration = useCallback(async (session) => {
61
+ const requestNumber = ++declarationRequest.current;
62
+ setDeclarationLoading(true);
63
+ setError(null);
64
+ const result = await fetchDesignGateDeclaration(session.projectWorkspacePath, session.hostSessionId);
65
+ if (requestNumber !== declarationRequest.current)
66
+ return;
67
+ setDeclarationLoading(false);
68
+ if (!result.success) {
69
+ setError(errorFromResponse(result));
70
+ setDeclaration(null);
71
+ return;
72
+ }
73
+ setDeclaration(result.data.declaration);
74
+ }, []);
75
+ useEffect(() => { void loadSessions(); }, [loadSessions]);
76
+ useEffect(() => {
77
+ if (selectedSession)
78
+ void loadDeclaration(selectedSession);
79
+ else {
80
+ declarationRequest.current += 1;
81
+ setDeclarationLoading(false);
82
+ setDeclaration(null);
83
+ }
84
+ }, [selectedSession, loadDeclaration]);
85
+ const runMutation = useCallback(async (mutation) => {
86
+ setPending(true);
87
+ setError(null);
88
+ const result = await mutation();
89
+ setPending(false);
90
+ if (!result.success) {
91
+ const failure = errorFromResponse(result);
92
+ setError(failure);
93
+ if (result.status === 409 && selectedSession) {
94
+ await loadDeclaration(selectedSession);
95
+ setError(failure);
96
+ }
97
+ return;
98
+ }
99
+ if (!result.data.declaration) {
100
+ setError({ error: t("pages.controlCenter.designGate.invalidMutationResponse") });
101
+ return;
102
+ }
103
+ setDeclaration(result.data.declaration);
104
+ }, [loadDeclaration, selectedSession, t]);
105
+ const createDeclaration = useCallback(async () => {
106
+ if (!selectedSession)
107
+ return;
108
+ const paths = parsePaths(scopePaths);
109
+ if (!specPath.trim() || paths.length === 0 || scopeActions.length === 0) {
110
+ setError({ error: t("pages.controlCenter.designGate.requiredFields") });
111
+ return;
112
+ }
113
+ await runMutation(() => createDesignGateDeclaration({
114
+ projectWorkspacePath: selectedSession.projectWorkspacePath,
115
+ hostSessionId: selectedSession.hostSessionId,
116
+ specPath: specPath.trim(),
117
+ scope: { paths, actions: scopeActions },
118
+ decision: newDecision,
119
+ }));
120
+ }, [newDecision, runMutation, scopeActions, scopePaths, selectedSession, specPath, t]);
121
+ const mutateDecision = useCallback((decision) => {
122
+ if (!declaration)
123
+ return;
124
+ void runMutation(() => updateDesignGateDecision(declaration.sourceRef, declaration.revision, decision));
125
+ }, [declaration, runMutation]);
126
+ const revoke = useCallback(() => {
127
+ if (!declaration)
128
+ return;
129
+ void runMutation(() => revokeDesignGateDeclaration(declaration.sourceRef, declaration.revision));
130
+ }, [declaration, runMutation]);
131
+ const disabled = pending || declarationLoading || sessionsLoading;
132
+ return (_jsxs("section", { className: "mt-8", "aria-labelledby": "section-design-gate", children: [_jsx(SectionTitle, { id: "section-design-gate", children: t("pages.controlCenter.designGate.title") }), _jsx("p", { className: "mb-4 max-w-[68ch] text-[13px] leading-relaxed text-ink-3", children: t("pages.controlCenter.designGate.description") }), error && (_jsxs("div", { role: "alert", className: "mb-4 rounded-[4px] border border-amber/30 border-l-2 border-l-amber bg-amber/10 p-3 text-[12.5px] text-ink-2", children: [_jsx("p", { children: error.error }), error.nextAction && _jsx("p", { className: "mt-1 text-ink-3", children: error.nextAction }), error.status === 409 && selectedSession && (_jsx("button", { type: "button", className: "mt-2 underline", disabled: disabled, onClick: () => void loadDeclaration(selectedSession), children: t("pages.controlCenter.designGate.refresh") }))] })), sessionsLoading ? (_jsx("p", { className: "text-[13px] text-ink-3", children: t("pages.controlCenter.designGate.loadingSessions") })) : sessions.length === 0 ? (_jsxs("div", { className: "rounded-[4px] border border-line bg-panel p-4 text-[13px] text-ink-3", children: [_jsx("p", { children: t("pages.controlCenter.designGate.noSessions") }), _jsx("button", { type: "button", className: `${actionButtonClass()} mt-3`, disabled: disabled, onClick: () => void loadSessions(), children: t("pages.controlCenter.designGate.refresh") })] })) : (_jsxs("div", { className: "space-y-4 rounded-[4px] border border-line bg-panel p-4", children: [_jsxs("label", { className: "block text-[12.5px] font-medium text-ink", children: [t("pages.controlCenter.designGate.nativeSession"), _jsx("select", { className: fieldClass(), value: selectedKey, disabled: disabled, onChange: (event) => setSelectedKey(event.currentTarget.value), children: sessions.map((session) => (_jsxs("option", { value: sessionKey(session), children: [session.projectWorkspacePath, " \u00B7 ", session.hostSessionId] }, sessionKey(session)))) })] }), declarationLoading ? (_jsx("p", { className: "text-[13px] text-ink-3", children: t("pages.controlCenter.designGate.loadingDeclaration") })) : declaration && !declaration.revoked ? (_jsxs("div", { className: "space-y-3", "aria-live": "polite", children: [_jsxs("div", { className: "grid gap-2 rounded-[4px] border border-line-2 bg-surface p-3 text-[12.5px]", children: [_jsxs("p", { children: [_jsx("strong", { children: t("pages.controlCenter.designGate.decision") }), " ", t(`pages.controlCenter.designGate.decisions.${decisionTranslationKey[declaration.decision]}`), declaration.revoked ? ` · ${t("pages.controlCenter.designGate.revoked")}` : ""] }), _jsxs("p", { children: [_jsx("strong", { children: t("pages.controlCenter.designGate.revision") }), " ", declaration.revision] }), _jsxs("p", { children: [_jsx("strong", { children: t("pages.controlCenter.designGate.spec") }), " ", _jsx("span", { className: "break-all font-mono", children: declaration.specPath })] }), _jsxs("p", { children: [_jsx("strong", { children: t("pages.controlCenter.designGate.specDigest") }), " ", _jsx("span", { className: "break-all font-mono", children: declaration.specDigest })] }), _jsxs("p", { children: [_jsx("strong", { children: t("pages.controlCenter.designGate.scopePaths") }), " ", _jsx("span", { className: "font-mono", children: declaration.scope.paths.join(", ") })] }), _jsxs("p", { children: [_jsx("strong", { children: t("pages.controlCenter.designGate.scopeActions") }), " ", declaration.scope.actions.map((action) => t(`pages.controlCenter.designGate.actions.${actionTranslationKey[action]}`)).join(", ")] }), _jsxs("p", { children: [_jsx("strong", { children: t("pages.controlCenter.designGate.owner") }), " ", _jsx("span", { className: "font-mono", children: declaration.actor.ownerId })] }), _jsxs("p", { children: [_jsx("strong", { children: t("pages.controlCenter.designGate.decidedAt") }), " ", declaration.decidedAt] })] }), _jsx("p", { className: "border-l-2 border-amber pl-3 text-[12.5px] leading-relaxed text-ink-3", children: t("pages.controlCenter.designGate.semanticLimit") }), !declaration.revoked && (_jsxs("div", { className: "flex flex-wrap gap-2", children: [_jsx("button", { type: "button", className: actionButtonClass(), disabled: disabled || declaration.decision === "approved", onClick: () => mutateDecision("approved"), children: pending ? t("pages.controlCenter.designGate.saving") : t("pages.controlCenter.designGate.approve") }), _jsx("button", { type: "button", className: actionButtonClass(), disabled: disabled || declaration.decision === "not_approved", onClick: () => mutateDecision("not_approved"), children: t("pages.controlCenter.designGate.markPending") }), _jsx("button", { type: "button", className: actionButtonClass(), disabled: disabled, onClick: revoke, children: t("pages.controlCenter.designGate.revoke") })] }))] })) : (_jsxs("div", { className: "space-y-3 border-t border-line pt-4", children: [declaration?.revoked && (_jsxs("div", { className: "rounded-[4px] border border-line-2 bg-surface p-3 text-[12.5px] text-ink-3", children: [_jsx("p", { children: t("pages.controlCenter.designGate.revokedLatest", { revision: declaration.revision }) }), _jsxs("p", { className: "mt-1 break-all font-mono", children: [declaration.specPath, " \u00B7 ", declaration.scope.paths.join(", ")] })] })), _jsx("p", { className: "text-[12.5px] text-ink-3", children: t("pages.controlCenter.designGate.noDeclaration") }), _jsxs("label", { className: "block text-[12.5px] font-medium text-ink", children: [t("pages.controlCenter.designGate.specPath"), _jsx("input", { className: fieldClass(), value: specPath, onChange: (event) => setSpecPath(event.currentTarget.value), placeholder: t("pages.controlCenter.designGate.specPathHint"), disabled: disabled })] }), _jsxs("label", { className: "block text-[12.5px] font-medium text-ink", children: [t("pages.controlCenter.designGate.scopePathsInput"), _jsx("textarea", { className: fieldClass(), rows: 3, value: scopePaths, onChange: (event) => setScopePaths(event.currentTarget.value), placeholder: t("pages.controlCenter.designGate.scopePathsHint"), disabled: disabled })] }), _jsx("p", { className: "-mt-2 text-[12px] leading-relaxed text-ink-4", children: t("pages.controlCenter.designGate.scopePathsHelp") }), _jsxs("fieldset", { disabled: disabled, children: [_jsx("legend", { className: "text-[12.5px] font-medium text-ink", children: t("pages.controlCenter.designGate.scopeActionsInput") }), _jsx("div", { className: "mt-2 flex flex-wrap gap-4", children: ["read", "write", "execute"].map((action) => (_jsxs("label", { className: "flex items-center gap-2 text-[12.5px] text-ink-2", children: [_jsx("input", { type: "checkbox", checked: scopeActions.includes(action), onChange: (event) => setScopeActions((current) => event.currentTarget.checked ? [...current, action] : current.filter((entry) => entry !== action)) }), t(`pages.controlCenter.designGate.actions.${actionTranslationKey[action]}`)] }, action))) })] }), _jsxs("label", { className: "block text-[12.5px] font-medium text-ink", children: [t("pages.controlCenter.designGate.initialDecision"), _jsx("select", { className: fieldClass(), value: newDecision, onChange: (event) => {
133
+ const value = event.currentTarget.value;
134
+ if (value === "approved" || value === "not_approved" || value === "not_required")
135
+ setNewDecision(value);
136
+ }, disabled: disabled, children: ["not_approved", "approved", "not_required"].map((decision) => (_jsx("option", { value: decision, children: t(`pages.controlCenter.designGate.decisions.${decisionTranslationKey[decision]}`) }, decision))) })] }), _jsx("p", { className: "text-[12px] leading-relaxed text-ink-4", children: t("pages.controlCenter.designGate.semanticLimit") }), _jsx("button", { type: "button", className: actionButtonClass(), disabled: disabled, onClick: () => void createDeclaration(), children: pending ? t("pages.controlCenter.designGate.saving") : t("pages.controlCenter.designGate.create") })] }))] }))] }));
137
+ }
@@ -401,6 +401,9 @@
401
401
  .my-5 {
402
402
  margin-block: calc(var(--spacing) * 5);
403
403
  }
404
+ .-mt-2 {
405
+ margin-top: calc(var(--spacing) * -2);
406
+ }
404
407
  .mt-0\.5 {
405
408
  margin-top: calc(var(--spacing) * 0.5);
406
409
  }
@@ -783,6 +786,9 @@
783
786
  .max-w-\[60ch\] {
784
787
  max-width: 60ch;
785
788
  }
789
+ .max-w-\[68ch\] {
790
+ max-width: 68ch;
791
+ }
786
792
  .max-w-\[85vw\] {
787
793
  max-width: 85vw;
788
794
  }