@contractspec/example.policy-safe-knowledge-assistant 3.7.6 → 3.7.10
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/.turbo/turbo-build.log +2 -2
- package/AGENTS.md +50 -26
- package/CHANGELOG.md +37 -0
- package/README.md +68 -15
- package/dist/browser/index.js +15 -15
- package/dist/browser/ui/PolicySafeKnowledgeAssistantDashboard.js +15 -15
- package/dist/browser/ui/hooks/usePolicySafeKnowledgeAssistant.js +1 -1
- package/dist/browser/ui/index.js +15 -15
- package/dist/index.d.ts +3 -3
- package/dist/index.js +15 -15
- package/dist/node/index.js +15 -15
- package/dist/node/ui/PolicySafeKnowledgeAssistantDashboard.js +15 -15
- package/dist/node/ui/hooks/usePolicySafeKnowledgeAssistant.js +1 -1
- package/dist/node/ui/index.js +15 -15
- package/dist/ui/PolicySafeKnowledgeAssistantDashboard.js +15 -15
- package/dist/ui/hooks/usePolicySafeKnowledgeAssistant.js +1 -1
- package/dist/ui/index.js +15 -15
- package/package.json +15 -15
- package/src/docs/policy-safe-knowledge-assistant.docblock.ts +21 -21
- package/src/example.ts +30 -30
- package/src/handlers/policy-safe-knowledge-assistant.handlers.ts +426 -425
- package/src/index.ts +4 -3
- package/src/integration.test.ts +87 -88
- package/src/orchestrator/buildAnswer.ts +97 -97
- package/src/policy-safe-knowledge-assistant.feature.ts +61 -61
- package/src/seed/fixtures.ts +29 -29
- package/src/seeders/index.ts +12 -12
- package/src/ui/PolicySafeKnowledgeAssistantDashboard.tsx +191 -191
- package/src/ui/hooks/usePolicySafeKnowledgeAssistant.ts +204 -204
- package/tsconfig.json +7 -17
- package/tsdown.config.js +7 -13
package/dist/node/ui/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/ui/hooks/usePolicySafeKnowledgeAssistant.ts
|
|
2
|
-
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
3
2
|
import { useTemplateRuntime } from "@contractspec/lib.example-shared-ui";
|
|
3
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
4
4
|
"use client";
|
|
5
5
|
function isCitationLike(value) {
|
|
6
6
|
if (!value || typeof value !== "object")
|
|
@@ -151,7 +151,6 @@ function usePolicySafeKnowledgeAssistant() {
|
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
// src/ui/PolicySafeKnowledgeAssistantDashboard.tsx
|
|
154
|
-
import { useCallback as useCallback2, useMemo as useMemo2, useState as useState2 } from "react";
|
|
155
154
|
import {
|
|
156
155
|
Button,
|
|
157
156
|
ErrorState,
|
|
@@ -161,7 +160,6 @@ import {
|
|
|
161
160
|
} from "@contractspec/lib.design-system";
|
|
162
161
|
import { Card } from "@contractspec/lib.ui-kit-web/ui/card";
|
|
163
162
|
import { Input } from "@contractspec/lib.ui-kit-web/ui/input";
|
|
164
|
-
import { Textarea } from "@contractspec/lib.ui-kit-web/ui/textarea";
|
|
165
163
|
import {
|
|
166
164
|
Select,
|
|
167
165
|
SelectContent,
|
|
@@ -169,6 +167,8 @@ import {
|
|
|
169
167
|
SelectTrigger,
|
|
170
168
|
SelectValue
|
|
171
169
|
} from "@contractspec/lib.ui-kit-web/ui/select";
|
|
170
|
+
import { Textarea } from "@contractspec/lib.ui-kit-web/ui/textarea";
|
|
171
|
+
import { useCallback as useCallback2, useMemo as useMemo2, useState as useState2 } from "react";
|
|
172
172
|
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
173
173
|
"use client";
|
|
174
174
|
function PolicySafeKnowledgeAssistantDashboard() {
|
|
@@ -231,7 +231,7 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
231
231
|
className: "p-4",
|
|
232
232
|
children: [
|
|
233
233
|
/* @__PURE__ */ jsxDEV("h3", {
|
|
234
|
-
className: "text-lg
|
|
234
|
+
className: "font-semibold text-lg",
|
|
235
235
|
children: "1) Onboarding (explicit locale + jurisdiction)"
|
|
236
236
|
}, undefined, false, undefined, this),
|
|
237
237
|
/* @__PURE__ */ jsxDEV("div", {
|
|
@@ -240,7 +240,7 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
240
240
|
/* @__PURE__ */ jsxDEV("div", {
|
|
241
241
|
children: [
|
|
242
242
|
/* @__PURE__ */ jsxDEV("div", {
|
|
243
|
-
className: "text-muted-foreground
|
|
243
|
+
className: "mb-1 font-semibold text-muted-foreground text-xs uppercase tracking-wide",
|
|
244
244
|
children: "Locale"
|
|
245
245
|
}, undefined, false, undefined, this),
|
|
246
246
|
/* @__PURE__ */ jsxDEV(Input, {
|
|
@@ -252,7 +252,7 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
252
252
|
/* @__PURE__ */ jsxDEV("div", {
|
|
253
253
|
children: [
|
|
254
254
|
/* @__PURE__ */ jsxDEV("div", {
|
|
255
|
-
className: "text-muted-foreground
|
|
255
|
+
className: "mb-1 font-semibold text-muted-foreground text-xs uppercase tracking-wide",
|
|
256
256
|
children: "Jurisdiction"
|
|
257
257
|
}, undefined, false, undefined, this),
|
|
258
258
|
/* @__PURE__ */ jsxDEV(Input, {
|
|
@@ -264,7 +264,7 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
264
264
|
/* @__PURE__ */ jsxDEV("div", {
|
|
265
265
|
children: [
|
|
266
266
|
/* @__PURE__ */ jsxDEV("div", {
|
|
267
|
-
className: "text-muted-foreground
|
|
267
|
+
className: "mb-1 font-semibold text-muted-foreground text-xs uppercase tracking-wide",
|
|
268
268
|
children: "Allowed scope"
|
|
269
269
|
}, undefined, false, undefined, this),
|
|
270
270
|
/* @__PURE__ */ jsxDEV(Select, {
|
|
@@ -318,7 +318,7 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
318
318
|
className: "p-4",
|
|
319
319
|
children: [
|
|
320
320
|
/* @__PURE__ */ jsxDEV("h3", {
|
|
321
|
-
className: "text-lg
|
|
321
|
+
className: "font-semibold text-lg",
|
|
322
322
|
children: "2) Ask the assistant (must cite KB snapshot)"
|
|
323
323
|
}, undefined, false, undefined, this),
|
|
324
324
|
/* @__PURE__ */ jsxDEV("div", {
|
|
@@ -341,7 +341,7 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
341
341
|
className: "mt-4 space-y-3",
|
|
342
342
|
children: [
|
|
343
343
|
state.lastAnswer.refused ? /* @__PURE__ */ jsxDEV("div", {
|
|
344
|
-
className: "text-
|
|
344
|
+
className: "text-red-600 text-sm",
|
|
345
345
|
children: [
|
|
346
346
|
"Refused: ",
|
|
347
347
|
state.lastAnswer.refusalReason ?? "UNKNOWN"
|
|
@@ -350,7 +350,7 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
350
350
|
state.lastAnswer.sections.map((s, idx) => /* @__PURE__ */ jsxDEV("div", {
|
|
351
351
|
children: [
|
|
352
352
|
/* @__PURE__ */ jsxDEV("div", {
|
|
353
|
-
className: "text-sm
|
|
353
|
+
className: "font-semibold text-sm",
|
|
354
354
|
children: s.heading
|
|
355
355
|
}, undefined, false, undefined, this),
|
|
356
356
|
/* @__PURE__ */ jsxDEV("div", {
|
|
@@ -360,11 +360,11 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
360
360
|
]
|
|
361
361
|
}, `${s.heading}-${idx}`, true, undefined, this)),
|
|
362
362
|
/* @__PURE__ */ jsxDEV("div", {
|
|
363
|
-
className: "text-sm
|
|
363
|
+
className: "font-semibold text-sm",
|
|
364
364
|
children: "Citations"
|
|
365
365
|
}, undefined, false, undefined, this),
|
|
366
366
|
/* @__PURE__ */ jsxDEV("ul", {
|
|
367
|
-
className: "
|
|
367
|
+
className: "list-disc pl-5 text-muted-foreground text-sm",
|
|
368
368
|
children: state.lastAnswer.citations.map((c) => /* @__PURE__ */ jsxDEV("li", {
|
|
369
369
|
children: [
|
|
370
370
|
c.kbSnapshotId,
|
|
@@ -381,7 +381,7 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
381
381
|
className: "p-4",
|
|
382
382
|
children: [
|
|
383
383
|
/* @__PURE__ */ jsxDEV("h3", {
|
|
384
|
-
className: "text-lg
|
|
384
|
+
className: "font-semibold text-lg",
|
|
385
385
|
children: "3) Admin: publish a new snapshot (HITL)"
|
|
386
386
|
}, undefined, false, undefined, this),
|
|
387
387
|
/* @__PURE__ */ jsxDEV("div", {
|
|
@@ -403,11 +403,11 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
403
403
|
className: "p-4",
|
|
404
404
|
children: [
|
|
405
405
|
/* @__PURE__ */ jsxDEV("h3", {
|
|
406
|
-
className: "text-lg
|
|
406
|
+
className: "font-semibold text-lg",
|
|
407
407
|
children: "4) Learning hub (patterns)"
|
|
408
408
|
}, undefined, false, undefined, this),
|
|
409
409
|
/* @__PURE__ */ jsxDEV("p", {
|
|
410
|
-
className: "text-muted-foreground
|
|
410
|
+
className: "mt-2 text-muted-foreground text-sm",
|
|
411
411
|
children: "This template includes drills, ambient coach, and quests as reusable Learning Journey tracks. The interactive learning UI is demonstrated in dedicated Learning Journey examples."
|
|
412
412
|
}, undefined, false, undefined, this)
|
|
413
413
|
]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// src/ui/hooks/usePolicySafeKnowledgeAssistant.ts
|
|
3
|
-
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
4
3
|
import { useTemplateRuntime } from "@contractspec/lib.example-shared-ui";
|
|
4
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
5
5
|
"use client";
|
|
6
6
|
function isCitationLike(value) {
|
|
7
7
|
if (!value || typeof value !== "object")
|
|
@@ -152,7 +152,6 @@ function usePolicySafeKnowledgeAssistant() {
|
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
// src/ui/PolicySafeKnowledgeAssistantDashboard.tsx
|
|
155
|
-
import { useCallback as useCallback2, useMemo as useMemo2, useState as useState2 } from "react";
|
|
156
155
|
import {
|
|
157
156
|
Button,
|
|
158
157
|
ErrorState,
|
|
@@ -162,7 +161,6 @@ import {
|
|
|
162
161
|
} from "@contractspec/lib.design-system";
|
|
163
162
|
import { Card } from "@contractspec/lib.ui-kit-web/ui/card";
|
|
164
163
|
import { Input } from "@contractspec/lib.ui-kit-web/ui/input";
|
|
165
|
-
import { Textarea } from "@contractspec/lib.ui-kit-web/ui/textarea";
|
|
166
164
|
import {
|
|
167
165
|
Select,
|
|
168
166
|
SelectContent,
|
|
@@ -170,6 +168,8 @@ import {
|
|
|
170
168
|
SelectTrigger,
|
|
171
169
|
SelectValue
|
|
172
170
|
} from "@contractspec/lib.ui-kit-web/ui/select";
|
|
171
|
+
import { Textarea } from "@contractspec/lib.ui-kit-web/ui/textarea";
|
|
172
|
+
import { useCallback as useCallback2, useMemo as useMemo2, useState as useState2 } from "react";
|
|
173
173
|
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
174
174
|
"use client";
|
|
175
175
|
function PolicySafeKnowledgeAssistantDashboard() {
|
|
@@ -232,7 +232,7 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
232
232
|
className: "p-4",
|
|
233
233
|
children: [
|
|
234
234
|
/* @__PURE__ */ jsxDEV("h3", {
|
|
235
|
-
className: "text-lg
|
|
235
|
+
className: "font-semibold text-lg",
|
|
236
236
|
children: "1) Onboarding (explicit locale + jurisdiction)"
|
|
237
237
|
}, undefined, false, undefined, this),
|
|
238
238
|
/* @__PURE__ */ jsxDEV("div", {
|
|
@@ -241,7 +241,7 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
241
241
|
/* @__PURE__ */ jsxDEV("div", {
|
|
242
242
|
children: [
|
|
243
243
|
/* @__PURE__ */ jsxDEV("div", {
|
|
244
|
-
className: "text-muted-foreground
|
|
244
|
+
className: "mb-1 font-semibold text-muted-foreground text-xs uppercase tracking-wide",
|
|
245
245
|
children: "Locale"
|
|
246
246
|
}, undefined, false, undefined, this),
|
|
247
247
|
/* @__PURE__ */ jsxDEV(Input, {
|
|
@@ -253,7 +253,7 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
253
253
|
/* @__PURE__ */ jsxDEV("div", {
|
|
254
254
|
children: [
|
|
255
255
|
/* @__PURE__ */ jsxDEV("div", {
|
|
256
|
-
className: "text-muted-foreground
|
|
256
|
+
className: "mb-1 font-semibold text-muted-foreground text-xs uppercase tracking-wide",
|
|
257
257
|
children: "Jurisdiction"
|
|
258
258
|
}, undefined, false, undefined, this),
|
|
259
259
|
/* @__PURE__ */ jsxDEV(Input, {
|
|
@@ -265,7 +265,7 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
265
265
|
/* @__PURE__ */ jsxDEV("div", {
|
|
266
266
|
children: [
|
|
267
267
|
/* @__PURE__ */ jsxDEV("div", {
|
|
268
|
-
className: "text-muted-foreground
|
|
268
|
+
className: "mb-1 font-semibold text-muted-foreground text-xs uppercase tracking-wide",
|
|
269
269
|
children: "Allowed scope"
|
|
270
270
|
}, undefined, false, undefined, this),
|
|
271
271
|
/* @__PURE__ */ jsxDEV(Select, {
|
|
@@ -319,7 +319,7 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
319
319
|
className: "p-4",
|
|
320
320
|
children: [
|
|
321
321
|
/* @__PURE__ */ jsxDEV("h3", {
|
|
322
|
-
className: "text-lg
|
|
322
|
+
className: "font-semibold text-lg",
|
|
323
323
|
children: "2) Ask the assistant (must cite KB snapshot)"
|
|
324
324
|
}, undefined, false, undefined, this),
|
|
325
325
|
/* @__PURE__ */ jsxDEV("div", {
|
|
@@ -342,7 +342,7 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
342
342
|
className: "mt-4 space-y-3",
|
|
343
343
|
children: [
|
|
344
344
|
state.lastAnswer.refused ? /* @__PURE__ */ jsxDEV("div", {
|
|
345
|
-
className: "text-
|
|
345
|
+
className: "text-red-600 text-sm",
|
|
346
346
|
children: [
|
|
347
347
|
"Refused: ",
|
|
348
348
|
state.lastAnswer.refusalReason ?? "UNKNOWN"
|
|
@@ -351,7 +351,7 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
351
351
|
state.lastAnswer.sections.map((s, idx) => /* @__PURE__ */ jsxDEV("div", {
|
|
352
352
|
children: [
|
|
353
353
|
/* @__PURE__ */ jsxDEV("div", {
|
|
354
|
-
className: "text-sm
|
|
354
|
+
className: "font-semibold text-sm",
|
|
355
355
|
children: s.heading
|
|
356
356
|
}, undefined, false, undefined, this),
|
|
357
357
|
/* @__PURE__ */ jsxDEV("div", {
|
|
@@ -361,11 +361,11 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
361
361
|
]
|
|
362
362
|
}, `${s.heading}-${idx}`, true, undefined, this)),
|
|
363
363
|
/* @__PURE__ */ jsxDEV("div", {
|
|
364
|
-
className: "text-sm
|
|
364
|
+
className: "font-semibold text-sm",
|
|
365
365
|
children: "Citations"
|
|
366
366
|
}, undefined, false, undefined, this),
|
|
367
367
|
/* @__PURE__ */ jsxDEV("ul", {
|
|
368
|
-
className: "
|
|
368
|
+
className: "list-disc pl-5 text-muted-foreground text-sm",
|
|
369
369
|
children: state.lastAnswer.citations.map((c) => /* @__PURE__ */ jsxDEV("li", {
|
|
370
370
|
children: [
|
|
371
371
|
c.kbSnapshotId,
|
|
@@ -382,7 +382,7 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
382
382
|
className: "p-4",
|
|
383
383
|
children: [
|
|
384
384
|
/* @__PURE__ */ jsxDEV("h3", {
|
|
385
|
-
className: "text-lg
|
|
385
|
+
className: "font-semibold text-lg",
|
|
386
386
|
children: "3) Admin: publish a new snapshot (HITL)"
|
|
387
387
|
}, undefined, false, undefined, this),
|
|
388
388
|
/* @__PURE__ */ jsxDEV("div", {
|
|
@@ -404,11 +404,11 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
404
404
|
className: "p-4",
|
|
405
405
|
children: [
|
|
406
406
|
/* @__PURE__ */ jsxDEV("h3", {
|
|
407
|
-
className: "text-lg
|
|
407
|
+
className: "font-semibold text-lg",
|
|
408
408
|
children: "4) Learning hub (patterns)"
|
|
409
409
|
}, undefined, false, undefined, this),
|
|
410
410
|
/* @__PURE__ */ jsxDEV("p", {
|
|
411
|
-
className: "text-muted-foreground
|
|
411
|
+
className: "mt-2 text-muted-foreground text-sm",
|
|
412
412
|
children: "This template includes drills, ambient coach, and quests as reusable Learning Journey tracks. The interactive learning UI is demonstrated in dedicated Learning Journey examples."
|
|
413
413
|
}, undefined, false, undefined, this)
|
|
414
414
|
]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// src/ui/hooks/usePolicySafeKnowledgeAssistant.ts
|
|
3
|
-
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
4
3
|
import { useTemplateRuntime } from "@contractspec/lib.example-shared-ui";
|
|
4
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
5
5
|
"use client";
|
|
6
6
|
function isCitationLike(value) {
|
|
7
7
|
if (!value || typeof value !== "object")
|
package/dist/ui/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// src/ui/hooks/usePolicySafeKnowledgeAssistant.ts
|
|
3
|
-
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
4
3
|
import { useTemplateRuntime } from "@contractspec/lib.example-shared-ui";
|
|
4
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
5
5
|
"use client";
|
|
6
6
|
function isCitationLike(value) {
|
|
7
7
|
if (!value || typeof value !== "object")
|
|
@@ -152,7 +152,6 @@ function usePolicySafeKnowledgeAssistant() {
|
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
// src/ui/PolicySafeKnowledgeAssistantDashboard.tsx
|
|
155
|
-
import { useCallback as useCallback2, useMemo as useMemo2, useState as useState2 } from "react";
|
|
156
155
|
import {
|
|
157
156
|
Button,
|
|
158
157
|
ErrorState,
|
|
@@ -162,7 +161,6 @@ import {
|
|
|
162
161
|
} from "@contractspec/lib.design-system";
|
|
163
162
|
import { Card } from "@contractspec/lib.ui-kit-web/ui/card";
|
|
164
163
|
import { Input } from "@contractspec/lib.ui-kit-web/ui/input";
|
|
165
|
-
import { Textarea } from "@contractspec/lib.ui-kit-web/ui/textarea";
|
|
166
164
|
import {
|
|
167
165
|
Select,
|
|
168
166
|
SelectContent,
|
|
@@ -170,6 +168,8 @@ import {
|
|
|
170
168
|
SelectTrigger,
|
|
171
169
|
SelectValue
|
|
172
170
|
} from "@contractspec/lib.ui-kit-web/ui/select";
|
|
171
|
+
import { Textarea } from "@contractspec/lib.ui-kit-web/ui/textarea";
|
|
172
|
+
import { useCallback as useCallback2, useMemo as useMemo2, useState as useState2 } from "react";
|
|
173
173
|
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
174
174
|
"use client";
|
|
175
175
|
function PolicySafeKnowledgeAssistantDashboard() {
|
|
@@ -232,7 +232,7 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
232
232
|
className: "p-4",
|
|
233
233
|
children: [
|
|
234
234
|
/* @__PURE__ */ jsxDEV("h3", {
|
|
235
|
-
className: "text-lg
|
|
235
|
+
className: "font-semibold text-lg",
|
|
236
236
|
children: "1) Onboarding (explicit locale + jurisdiction)"
|
|
237
237
|
}, undefined, false, undefined, this),
|
|
238
238
|
/* @__PURE__ */ jsxDEV("div", {
|
|
@@ -241,7 +241,7 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
241
241
|
/* @__PURE__ */ jsxDEV("div", {
|
|
242
242
|
children: [
|
|
243
243
|
/* @__PURE__ */ jsxDEV("div", {
|
|
244
|
-
className: "text-muted-foreground
|
|
244
|
+
className: "mb-1 font-semibold text-muted-foreground text-xs uppercase tracking-wide",
|
|
245
245
|
children: "Locale"
|
|
246
246
|
}, undefined, false, undefined, this),
|
|
247
247
|
/* @__PURE__ */ jsxDEV(Input, {
|
|
@@ -253,7 +253,7 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
253
253
|
/* @__PURE__ */ jsxDEV("div", {
|
|
254
254
|
children: [
|
|
255
255
|
/* @__PURE__ */ jsxDEV("div", {
|
|
256
|
-
className: "text-muted-foreground
|
|
256
|
+
className: "mb-1 font-semibold text-muted-foreground text-xs uppercase tracking-wide",
|
|
257
257
|
children: "Jurisdiction"
|
|
258
258
|
}, undefined, false, undefined, this),
|
|
259
259
|
/* @__PURE__ */ jsxDEV(Input, {
|
|
@@ -265,7 +265,7 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
265
265
|
/* @__PURE__ */ jsxDEV("div", {
|
|
266
266
|
children: [
|
|
267
267
|
/* @__PURE__ */ jsxDEV("div", {
|
|
268
|
-
className: "text-muted-foreground
|
|
268
|
+
className: "mb-1 font-semibold text-muted-foreground text-xs uppercase tracking-wide",
|
|
269
269
|
children: "Allowed scope"
|
|
270
270
|
}, undefined, false, undefined, this),
|
|
271
271
|
/* @__PURE__ */ jsxDEV(Select, {
|
|
@@ -319,7 +319,7 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
319
319
|
className: "p-4",
|
|
320
320
|
children: [
|
|
321
321
|
/* @__PURE__ */ jsxDEV("h3", {
|
|
322
|
-
className: "text-lg
|
|
322
|
+
className: "font-semibold text-lg",
|
|
323
323
|
children: "2) Ask the assistant (must cite KB snapshot)"
|
|
324
324
|
}, undefined, false, undefined, this),
|
|
325
325
|
/* @__PURE__ */ jsxDEV("div", {
|
|
@@ -342,7 +342,7 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
342
342
|
className: "mt-4 space-y-3",
|
|
343
343
|
children: [
|
|
344
344
|
state.lastAnswer.refused ? /* @__PURE__ */ jsxDEV("div", {
|
|
345
|
-
className: "text-
|
|
345
|
+
className: "text-red-600 text-sm",
|
|
346
346
|
children: [
|
|
347
347
|
"Refused: ",
|
|
348
348
|
state.lastAnswer.refusalReason ?? "UNKNOWN"
|
|
@@ -351,7 +351,7 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
351
351
|
state.lastAnswer.sections.map((s, idx) => /* @__PURE__ */ jsxDEV("div", {
|
|
352
352
|
children: [
|
|
353
353
|
/* @__PURE__ */ jsxDEV("div", {
|
|
354
|
-
className: "text-sm
|
|
354
|
+
className: "font-semibold text-sm",
|
|
355
355
|
children: s.heading
|
|
356
356
|
}, undefined, false, undefined, this),
|
|
357
357
|
/* @__PURE__ */ jsxDEV("div", {
|
|
@@ -361,11 +361,11 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
361
361
|
]
|
|
362
362
|
}, `${s.heading}-${idx}`, true, undefined, this)),
|
|
363
363
|
/* @__PURE__ */ jsxDEV("div", {
|
|
364
|
-
className: "text-sm
|
|
364
|
+
className: "font-semibold text-sm",
|
|
365
365
|
children: "Citations"
|
|
366
366
|
}, undefined, false, undefined, this),
|
|
367
367
|
/* @__PURE__ */ jsxDEV("ul", {
|
|
368
|
-
className: "
|
|
368
|
+
className: "list-disc pl-5 text-muted-foreground text-sm",
|
|
369
369
|
children: state.lastAnswer.citations.map((c) => /* @__PURE__ */ jsxDEV("li", {
|
|
370
370
|
children: [
|
|
371
371
|
c.kbSnapshotId,
|
|
@@ -382,7 +382,7 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
382
382
|
className: "p-4",
|
|
383
383
|
children: [
|
|
384
384
|
/* @__PURE__ */ jsxDEV("h3", {
|
|
385
|
-
className: "text-lg
|
|
385
|
+
className: "font-semibold text-lg",
|
|
386
386
|
children: "3) Admin: publish a new snapshot (HITL)"
|
|
387
387
|
}, undefined, false, undefined, this),
|
|
388
388
|
/* @__PURE__ */ jsxDEV("div", {
|
|
@@ -404,11 +404,11 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
404
404
|
className: "p-4",
|
|
405
405
|
children: [
|
|
406
406
|
/* @__PURE__ */ jsxDEV("h3", {
|
|
407
|
-
className: "text-lg
|
|
407
|
+
className: "font-semibold text-lg",
|
|
408
408
|
children: "4) Learning hub (patterns)"
|
|
409
409
|
}, undefined, false, undefined, this),
|
|
410
410
|
/* @__PURE__ */ jsxDEV("p", {
|
|
411
|
-
className: "text-muted-foreground
|
|
411
|
+
className: "mt-2 text-muted-foreground text-sm",
|
|
412
412
|
children: "This template includes drills, ambient coach, and quests as reusable Learning Journey tracks. The interactive learning UI is demonstrated in dedicated Learning Journey examples."
|
|
413
413
|
}, undefined, false, undefined, this)
|
|
414
414
|
]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contractspec/example.policy-safe-knowledge-assistant",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.10",
|
|
4
4
|
"description": "All-in-one template example: policy-safe knowledge assistant with locale/jurisdiction gating, versioned KB snapshots, HITL update pipeline, and learning hub.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -113,32 +113,32 @@
|
|
|
113
113
|
"dev": "contractspec-bun-build dev",
|
|
114
114
|
"clean": "rimraf dist .turbo",
|
|
115
115
|
"lint": "bun lint:fix",
|
|
116
|
-
"lint:fix": "
|
|
117
|
-
"lint:check": "
|
|
116
|
+
"lint:fix": "biome check --write --unsafe --only=nursery/useSortedClasses . && biome check --write .",
|
|
117
|
+
"lint:check": "biome check .",
|
|
118
118
|
"test": "bun test",
|
|
119
119
|
"prebuild": "contractspec-bun-build prebuild",
|
|
120
120
|
"typecheck": "tsc --noEmit"
|
|
121
121
|
},
|
|
122
122
|
"dependencies": {
|
|
123
|
-
"@contractspec/example.kb-update-pipeline": "3.7.
|
|
124
|
-
"@contractspec/example.learning-patterns": "3.7.
|
|
125
|
-
"@contractspec/example.locale-jurisdiction-gate": "3.7.
|
|
126
|
-
"@contractspec/example.versioned-knowledge-base": "3.7.
|
|
127
|
-
"@contractspec/lib.contracts-spec": "
|
|
128
|
-
"@contractspec/lib.design-system": "3.
|
|
129
|
-
"@contractspec/lib.example-shared-ui": "6.0.
|
|
130
|
-
"@contractspec/lib.runtime-sandbox": "2.7.
|
|
131
|
-
"@contractspec/lib.ui-kit-web": "3.
|
|
132
|
-
"@contractspec/module.learning-journey": "3.7.
|
|
123
|
+
"@contractspec/example.kb-update-pipeline": "3.7.10",
|
|
124
|
+
"@contractspec/example.learning-patterns": "3.7.10",
|
|
125
|
+
"@contractspec/example.locale-jurisdiction-gate": "3.7.10",
|
|
126
|
+
"@contractspec/example.versioned-knowledge-base": "3.7.10",
|
|
127
|
+
"@contractspec/lib.contracts-spec": "4.1.2",
|
|
128
|
+
"@contractspec/lib.design-system": "3.8.3",
|
|
129
|
+
"@contractspec/lib.example-shared-ui": "6.0.10",
|
|
130
|
+
"@contractspec/lib.runtime-sandbox": "2.7.9",
|
|
131
|
+
"@contractspec/lib.ui-kit-web": "3.9.2",
|
|
132
|
+
"@contractspec/module.learning-journey": "3.7.10",
|
|
133
133
|
"react": "19.2.0",
|
|
134
134
|
"react-dom": "19.2.0"
|
|
135
135
|
},
|
|
136
136
|
"devDependencies": {
|
|
137
|
-
"@contractspec/tool.typescript": "3.7.
|
|
137
|
+
"@contractspec/tool.typescript": "3.7.8",
|
|
138
138
|
"typescript": "^5.9.3",
|
|
139
139
|
"@types/react": "^19.2.14",
|
|
140
140
|
"@types/react-dom": "^19.2.2",
|
|
141
|
-
"@contractspec/tool.bun": "3.7.
|
|
141
|
+
"@contractspec/tool.bun": "3.7.8"
|
|
142
142
|
},
|
|
143
143
|
"publishConfig": {
|
|
144
144
|
"access": "public",
|
|
@@ -2,27 +2,27 @@ import type { DocBlock } from '@contractspec/lib.contracts-spec/docs';
|
|
|
2
2
|
import { registerDocBlocks } from '@contractspec/lib.contracts-spec/docs';
|
|
3
3
|
|
|
4
4
|
const docBlocks: DocBlock[] = [
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
5
|
+
{
|
|
6
|
+
id: 'docs.examples.policy-safe-knowledge-assistant.goal',
|
|
7
|
+
title: 'Policy-safe Knowledge Assistant — Goal',
|
|
8
|
+
summary:
|
|
9
|
+
'End-to-end example: versioned KB snapshots + locale/jurisdiction gating + HITL pipeline + learning hub.',
|
|
10
|
+
kind: 'goal',
|
|
11
|
+
visibility: 'public',
|
|
12
|
+
route: '/docs/examples/policy-safe-knowledge-assistant/goal',
|
|
13
|
+
tags: ['assistant', 'knowledge', 'policy', 'hitl', 'learning'],
|
|
14
|
+
body: `## What this template proves\n- Assistant answers are structured and must cite a KB snapshot (or refuse).\n- Locale + jurisdiction are mandatory inputs for every assistant call.\n- Automation proposes KB patches; humans verify; publishing stays blocked until approvals.\n- Learning hub demonstrates drills + coaching + quests without spam.\n\n## Offline-first\n- Seeded fixtures are deterministic and require no external services.\n- Optional non-authoritative fallback can be added behind a single feature flag (disabled by default).`,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
id: 'docs.examples.policy-safe-knowledge-assistant.usage',
|
|
18
|
+
title: 'Policy-safe Knowledge Assistant — Usage',
|
|
19
|
+
summary: '5–10 minute sandbox walkthrough for developers.',
|
|
20
|
+
kind: 'usage',
|
|
21
|
+
visibility: 'public',
|
|
22
|
+
route: '/docs/examples/policy-safe-knowledge-assistant/usage',
|
|
23
|
+
tags: ['assistant', 'knowledge', 'usage'],
|
|
24
|
+
body: `## Demo walkthrough (high level)\n1) Onboard: set locale + jurisdiction.\n2) Publish snapshot: ingest source -> propose rule -> approve -> publish.\n3) Ask assistant: must pass gate and cite snapshot.\n4) Simulate change: watcher -> review -> publish new snapshot.\n5) Learning hub: drills session, ambient tip, quest start + step completion.`,
|
|
25
|
+
},
|
|
26
26
|
];
|
|
27
27
|
|
|
28
28
|
registerDocBlocks(docBlocks);
|
package/src/example.ts
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
import { defineExample } from '@contractspec/lib.contracts-spec';
|
|
2
2
|
|
|
3
3
|
const example = defineExample({
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
4
|
+
meta: {
|
|
5
|
+
key: 'policy-safe-knowledge-assistant',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
title: 'Policy-safe Knowledge Assistant',
|
|
8
|
+
description:
|
|
9
|
+
'All-in-one template: locale/jurisdiction gating + versioned KB snapshots + HITL update pipeline + learning hub.',
|
|
10
|
+
kind: 'template',
|
|
11
|
+
visibility: 'public',
|
|
12
|
+
stability: 'experimental',
|
|
13
|
+
owners: ['@platform.core'],
|
|
14
|
+
tags: ['assistant', 'knowledge', 'policy', 'hitl', 'learning'],
|
|
15
|
+
},
|
|
16
|
+
docs: {
|
|
17
|
+
goalDocId: 'docs.examples.policy-safe-knowledge-assistant.goal',
|
|
18
|
+
usageDocId: 'docs.examples.policy-safe-knowledge-assistant.usage',
|
|
19
|
+
},
|
|
20
|
+
entrypoints: {
|
|
21
|
+
packageName: '@contractspec/example.policy-safe-knowledge-assistant',
|
|
22
|
+
feature: './policy-safe-knowledge-assistant.feature',
|
|
23
|
+
docs: './docs',
|
|
24
|
+
},
|
|
25
|
+
surfaces: {
|
|
26
|
+
templates: true,
|
|
27
|
+
sandbox: {
|
|
28
|
+
enabled: true,
|
|
29
|
+
modes: ['playground', 'specs', 'builder', 'markdown', 'evolution'],
|
|
30
|
+
},
|
|
31
|
+
studio: { enabled: true, installable: true },
|
|
32
|
+
mcp: { enabled: true },
|
|
33
|
+
},
|
|
34
34
|
});
|
|
35
35
|
|
|
36
36
|
export default example;
|