@contractspec/example.policy-safe-knowledge-assistant 3.7.6 → 3.7.7
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 +3 -3
- package/AGENTS.md +50 -26
- 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 +12 -12
- 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/.turbo/turbo-build.log
CHANGED
|
@@ -3,7 +3,7 @@ $ bun run prebuild && bun run build:bundle && bun run build:types
|
|
|
3
3
|
$ contractspec-bun-build prebuild
|
|
4
4
|
$ contractspec-bun-build transpile
|
|
5
5
|
[contractspec-bun-build] transpile target=bun root=src entries=14 noBundle=false
|
|
6
|
-
Bundled 14 modules in
|
|
6
|
+
Bundled 14 modules in 31ms
|
|
7
7
|
|
|
8
8
|
docs/index.js 1.86 KB (entry point)
|
|
9
9
|
seeders/index.js 0.51 KB (entry point)
|
|
@@ -21,7 +21,7 @@ Bundled 14 modules in 47ms
|
|
|
21
21
|
./policy-safe-knowledge-assistant.feature.js 2.67 KB (entry point)
|
|
22
22
|
|
|
23
23
|
[contractspec-bun-build] transpile target=node root=src entries=14 noBundle=false
|
|
24
|
-
Bundled 14 modules in
|
|
24
|
+
Bundled 14 modules in 35ms
|
|
25
25
|
|
|
26
26
|
docs/index.js 1.85 KB (entry point)
|
|
27
27
|
seeders/index.js 506 bytes (entry point)
|
|
@@ -39,7 +39,7 @@ Bundled 14 modules in 40ms
|
|
|
39
39
|
./policy-safe-knowledge-assistant.feature.js 2.66 KB (entry point)
|
|
40
40
|
|
|
41
41
|
[contractspec-bun-build] transpile target=browser root=src entries=14 noBundle=false
|
|
42
|
-
Bundled 14 modules in
|
|
42
|
+
Bundled 14 modules in 31ms
|
|
43
43
|
|
|
44
44
|
docs/index.js 1.85 KB (entry point)
|
|
45
45
|
seeders/index.js 506 bytes (entry point)
|
package/AGENTS.md
CHANGED
|
@@ -1,35 +1,59 @@
|
|
|
1
|
-
# AI Agent Guide
|
|
1
|
+
# AI Agent Guide — `@contractspec/example.policy-safe-knowledge-assistant`
|
|
2
2
|
|
|
3
3
|
Scope: `packages/examples/policy-safe-knowledge-assistant/*`
|
|
4
4
|
|
|
5
|
-
All-in-one template: policy-safe knowledge assistant with locale/jurisdiction gating, versioned KB snapshots, HITL update pipeline, and learning hub.
|
|
5
|
+
All-in-one template example: policy-safe knowledge assistant with locale/jurisdiction gating, versioned KB snapshots, HITL update pipeline, and learning hub.
|
|
6
6
|
|
|
7
7
|
## Quick Context
|
|
8
8
|
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
-
|
|
27
|
-
- `./
|
|
28
|
-
- `./docs
|
|
9
|
+
- Layer: `example`.
|
|
10
|
+
- Package visibility: published package.
|
|
11
|
+
- Primary consumers are example explorers, template authors, and documentation readers.
|
|
12
|
+
- Related packages: `@contractspec/example.kb-update-pipeline`, `@contractspec/example.learning-patterns`, `@contractspec/example.locale-jurisdiction-gate`, `@contractspec/example.versioned-knowledge-base`, `@contractspec/lib.contracts-spec`, `@contractspec/lib.design-system`, ...
|
|
13
|
+
|
|
14
|
+
## Architecture
|
|
15
|
+
|
|
16
|
+
- `src/docs/` contains docblocks and documentation-facing exports.
|
|
17
|
+
- `src/example.ts` is the runnable example entrypoint.
|
|
18
|
+
- `src/handlers/` contains handlers or demo adapters wired to contract surfaces.
|
|
19
|
+
- `src/index.ts` is the root public barrel and package entrypoint.
|
|
20
|
+
- `src/integration.test.ts` is part of the package's public or composition surface.
|
|
21
|
+
- `src/orchestrator` is part of the package's public or composition surface.
|
|
22
|
+
- `src/policy-safe-knowledge-assistant.feature.ts` defines a feature entrypoint.
|
|
23
|
+
|
|
24
|
+
## Public Surface
|
|
25
|
+
|
|
26
|
+
- Export `.` resolves through `./src/index.ts`.
|
|
27
|
+
- Export `./docs` resolves through `./src/docs/index.ts`.
|
|
28
|
+
- Export `./docs/policy-safe-knowledge-assistant.docblock` resolves through `./src/docs/policy-safe-knowledge-assistant.docblock.ts`.
|
|
29
|
+
- Export `./example` resolves through `./src/example.ts`.
|
|
30
|
+
- Export `./handlers` resolves through `./src/handlers/index.ts`.
|
|
31
|
+
- Export `./handlers/policy-safe-knowledge-assistant.handlers` resolves through `./src/handlers/policy-safe-knowledge-assistant.handlers.ts`.
|
|
32
|
+
- Export `./orchestrator/buildAnswer` resolves through `./src/orchestrator/buildAnswer.ts`.
|
|
33
|
+
- Export `./policy-safe-knowledge-assistant.feature` resolves through `./src/policy-safe-knowledge-assistant.feature.ts`.
|
|
34
|
+
- Export `./seed` resolves through `./src/seed/index.ts`.
|
|
35
|
+
- Export `./seed/fixtures` resolves through `./src/seed/fixtures.ts`.
|
|
36
|
+
- The package publishes 14 total export subpaths; keep docs aligned with `package.json`.
|
|
37
|
+
|
|
38
|
+
## Guardrails
|
|
39
|
+
|
|
40
|
+
- Keep the example package demonstrative, buildable, and aligned with the exported feature surface.
|
|
41
|
+
- Do not add hidden production assumptions that are not actually implemented in the example.
|
|
42
|
+
- Changes here can affect downstream packages such as `@contractspec/example.kb-update-pipeline`, `@contractspec/example.learning-patterns`, `@contractspec/example.locale-jurisdiction-gate`, `@contractspec/example.versioned-knowledge-base`, `@contractspec/lib.contracts-spec`, `@contractspec/lib.design-system`, ....
|
|
43
|
+
- Changes here can affect downstream packages such as `@contractspec/example.kb-update-pipeline`, `@contractspec/example.learning-patterns`, `@contractspec/example.locale-jurisdiction-gate`, `@contractspec/example.versioned-knowledge-base`, `@contractspec/lib.contracts-spec`, `@contractspec/lib.design-system`, ...
|
|
29
44
|
|
|
30
45
|
## Local Commands
|
|
31
46
|
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
-
|
|
47
|
+
- `bun run dev` — contractspec-bun-build dev
|
|
48
|
+
- `bun run build` — bun run prebuild && bun run build:bundle && bun run build:types
|
|
49
|
+
- `bun run test` — bun test
|
|
50
|
+
- `bun run lint` — bun lint:fix
|
|
51
|
+
- `bun run lint:check` — biome check .
|
|
52
|
+
- `bun run lint:fix` — biome check --write --unsafe --only=nursery/useSortedClasses . && biome check --write .
|
|
53
|
+
- `bun run typecheck` — tsc --noEmit
|
|
54
|
+
- `bun run publish:pkg` — bun publish --tolerate-republish --ignore-scripts --verbose
|
|
55
|
+
- `bun run publish:pkg:canary` — bun publish:pkg --tag canary
|
|
56
|
+
- `bun run clean` — rimraf dist .turbo
|
|
57
|
+
- `bun run build:bundle` — contractspec-bun-build transpile
|
|
58
|
+
- `bun run build:types` — contractspec-bun-build types
|
|
59
|
+
- `bun run prebuild` — contractspec-bun-build prebuild
|
package/README.md
CHANGED
|
@@ -1,22 +1,75 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @contractspec/example.policy-safe-knowledge-assistant
|
|
2
2
|
|
|
3
|
-
Website: https://contractspec.io
|
|
3
|
+
Website: https://contractspec.io
|
|
4
4
|
|
|
5
|
+
**All-in-one template example: policy-safe knowledge assistant with locale/jurisdiction gating, versioned KB snapshots, HITL update pipeline, and learning hub.**
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
## What This Demonstrates
|
|
7
8
|
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
9
|
+
- Composition of multiple example packages into a full-stack assistant.
|
|
10
|
+
- Orchestrator pattern (`buildAnswer`) for policy-gated responses.
|
|
11
|
+
- React dashboard with hooks and UI components.
|
|
12
|
+
- Seed data and fixture patterns.
|
|
13
|
+
- Feature definition aggregating sub-features.
|
|
14
|
+
- `src/docs/` contains docblocks and documentation-facing exports.
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
## Running Locally
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
From `packages/examples/policy-safe-knowledge-assistant`:
|
|
19
|
+
- `bun run dev`
|
|
20
|
+
- `bun run build`
|
|
21
|
+
- `bun run test`
|
|
22
|
+
- `bun run typecheck`
|
|
18
23
|
|
|
19
|
-
##
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
Use `@contractspec/example.policy-safe-knowledge-assistant` as a reference implementation, or import its exported surfaces into a workspace that composes ContractSpec examples and bundles.
|
|
27
|
+
|
|
28
|
+
## Architecture
|
|
29
|
+
|
|
30
|
+
- `src/docs/` contains docblocks and documentation-facing exports.
|
|
31
|
+
- `src/example.ts` is the runnable example entrypoint.
|
|
32
|
+
- `src/handlers/` contains handlers or demo adapters wired to contract surfaces.
|
|
33
|
+
- `src/index.ts` is the root public barrel and package entrypoint.
|
|
34
|
+
- `src/integration.test.ts` is part of the package's public or composition surface.
|
|
35
|
+
- `src/orchestrator` is part of the package's public or composition surface.
|
|
36
|
+
- `src/policy-safe-knowledge-assistant.feature.ts` defines a feature entrypoint.
|
|
37
|
+
|
|
38
|
+
## Public Entry Points
|
|
39
|
+
|
|
40
|
+
- Export `.` resolves through `./src/index.ts`.
|
|
41
|
+
- Export `./docs` resolves through `./src/docs/index.ts`.
|
|
42
|
+
- Export `./docs/policy-safe-knowledge-assistant.docblock` resolves through `./src/docs/policy-safe-knowledge-assistant.docblock.ts`.
|
|
43
|
+
- Export `./example` resolves through `./src/example.ts`.
|
|
44
|
+
- Export `./handlers` resolves through `./src/handlers/index.ts`.
|
|
45
|
+
- Export `./handlers/policy-safe-knowledge-assistant.handlers` resolves through `./src/handlers/policy-safe-knowledge-assistant.handlers.ts`.
|
|
46
|
+
- Export `./orchestrator/buildAnswer` resolves through `./src/orchestrator/buildAnswer.ts`.
|
|
47
|
+
- Export `./policy-safe-knowledge-assistant.feature` resolves through `./src/policy-safe-knowledge-assistant.feature.ts`.
|
|
48
|
+
- Export `./seed` resolves through `./src/seed/index.ts`.
|
|
49
|
+
- Export `./seed/fixtures` resolves through `./src/seed/fixtures.ts`.
|
|
50
|
+
- The package publishes 14 total export subpaths; keep docs aligned with `package.json`.
|
|
51
|
+
|
|
52
|
+
## Local Commands
|
|
53
|
+
|
|
54
|
+
- `bun run dev` — contractspec-bun-build dev
|
|
55
|
+
- `bun run build` — bun run prebuild && bun run build:bundle && bun run build:types
|
|
56
|
+
- `bun run test` — bun test
|
|
57
|
+
- `bun run lint` — bun lint:fix
|
|
58
|
+
- `bun run lint:check` — biome check .
|
|
59
|
+
- `bun run lint:fix` — biome check --write --unsafe --only=nursery/useSortedClasses . && biome check --write .
|
|
60
|
+
- `bun run typecheck` — tsc --noEmit
|
|
61
|
+
- `bun run publish:pkg` — bun publish --tolerate-republish --ignore-scripts --verbose
|
|
62
|
+
- `bun run publish:pkg:canary` — bun publish:pkg --tag canary
|
|
63
|
+
- `bun run clean` — rimraf dist .turbo
|
|
64
|
+
- `bun run build:bundle` — contractspec-bun-build transpile
|
|
65
|
+
- `bun run build:types` — contractspec-bun-build types
|
|
66
|
+
- `bun run prebuild` — contractspec-bun-build prebuild
|
|
67
|
+
|
|
68
|
+
## Recent Updates
|
|
69
|
+
|
|
70
|
+
- Replace eslint+prettier by biomejs to optimize speed.
|
|
71
|
+
- Missing contract layers.
|
|
72
|
+
|
|
73
|
+
## Notes
|
|
74
|
+
|
|
75
|
+
- Works alongside `@contractspec/example.kb-update-pipeline`, `@contractspec/example.learning-patterns`, `@contractspec/example.locale-jurisdiction-gate`, `@contractspec/example.versioned-knowledge-base`, `@contractspec/lib.contracts-spec`, ...
|
package/dist/browser/index.js
CHANGED
|
@@ -498,8 +498,8 @@ var DEMO_FIXTURES = {
|
|
|
498
498
|
}
|
|
499
499
|
};
|
|
500
500
|
// src/ui/hooks/usePolicySafeKnowledgeAssistant.ts
|
|
501
|
-
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
502
501
|
import { useTemplateRuntime } from "@contractspec/lib.example-shared-ui";
|
|
502
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
503
503
|
"use client";
|
|
504
504
|
function isCitationLike(value) {
|
|
505
505
|
if (!value || typeof value !== "object")
|
|
@@ -650,7 +650,6 @@ function usePolicySafeKnowledgeAssistant() {
|
|
|
650
650
|
}
|
|
651
651
|
|
|
652
652
|
// src/ui/PolicySafeKnowledgeAssistantDashboard.tsx
|
|
653
|
-
import { useCallback as useCallback2, useMemo as useMemo2, useState as useState2 } from "react";
|
|
654
653
|
import {
|
|
655
654
|
Button,
|
|
656
655
|
ErrorState,
|
|
@@ -660,7 +659,6 @@ import {
|
|
|
660
659
|
} from "@contractspec/lib.design-system";
|
|
661
660
|
import { Card } from "@contractspec/lib.ui-kit-web/ui/card";
|
|
662
661
|
import { Input } from "@contractspec/lib.ui-kit-web/ui/input";
|
|
663
|
-
import { Textarea } from "@contractspec/lib.ui-kit-web/ui/textarea";
|
|
664
662
|
import {
|
|
665
663
|
Select,
|
|
666
664
|
SelectContent,
|
|
@@ -668,6 +666,8 @@ import {
|
|
|
668
666
|
SelectTrigger,
|
|
669
667
|
SelectValue
|
|
670
668
|
} from "@contractspec/lib.ui-kit-web/ui/select";
|
|
669
|
+
import { Textarea } from "@contractspec/lib.ui-kit-web/ui/textarea";
|
|
670
|
+
import { useCallback as useCallback2, useMemo as useMemo2, useState as useState2 } from "react";
|
|
671
671
|
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
672
672
|
"use client";
|
|
673
673
|
function PolicySafeKnowledgeAssistantDashboard() {
|
|
@@ -730,7 +730,7 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
730
730
|
className: "p-4",
|
|
731
731
|
children: [
|
|
732
732
|
/* @__PURE__ */ jsxDEV("h3", {
|
|
733
|
-
className: "text-lg
|
|
733
|
+
className: "font-semibold text-lg",
|
|
734
734
|
children: "1) Onboarding (explicit locale + jurisdiction)"
|
|
735
735
|
}, undefined, false, undefined, this),
|
|
736
736
|
/* @__PURE__ */ jsxDEV("div", {
|
|
@@ -739,7 +739,7 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
739
739
|
/* @__PURE__ */ jsxDEV("div", {
|
|
740
740
|
children: [
|
|
741
741
|
/* @__PURE__ */ jsxDEV("div", {
|
|
742
|
-
className: "text-muted-foreground
|
|
742
|
+
className: "mb-1 font-semibold text-muted-foreground text-xs uppercase tracking-wide",
|
|
743
743
|
children: "Locale"
|
|
744
744
|
}, undefined, false, undefined, this),
|
|
745
745
|
/* @__PURE__ */ jsxDEV(Input, {
|
|
@@ -751,7 +751,7 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
751
751
|
/* @__PURE__ */ jsxDEV("div", {
|
|
752
752
|
children: [
|
|
753
753
|
/* @__PURE__ */ jsxDEV("div", {
|
|
754
|
-
className: "text-muted-foreground
|
|
754
|
+
className: "mb-1 font-semibold text-muted-foreground text-xs uppercase tracking-wide",
|
|
755
755
|
children: "Jurisdiction"
|
|
756
756
|
}, undefined, false, undefined, this),
|
|
757
757
|
/* @__PURE__ */ jsxDEV(Input, {
|
|
@@ -763,7 +763,7 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
763
763
|
/* @__PURE__ */ jsxDEV("div", {
|
|
764
764
|
children: [
|
|
765
765
|
/* @__PURE__ */ jsxDEV("div", {
|
|
766
|
-
className: "text-muted-foreground
|
|
766
|
+
className: "mb-1 font-semibold text-muted-foreground text-xs uppercase tracking-wide",
|
|
767
767
|
children: "Allowed scope"
|
|
768
768
|
}, undefined, false, undefined, this),
|
|
769
769
|
/* @__PURE__ */ jsxDEV(Select, {
|
|
@@ -817,7 +817,7 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
817
817
|
className: "p-4",
|
|
818
818
|
children: [
|
|
819
819
|
/* @__PURE__ */ jsxDEV("h3", {
|
|
820
|
-
className: "text-lg
|
|
820
|
+
className: "font-semibold text-lg",
|
|
821
821
|
children: "2) Ask the assistant (must cite KB snapshot)"
|
|
822
822
|
}, undefined, false, undefined, this),
|
|
823
823
|
/* @__PURE__ */ jsxDEV("div", {
|
|
@@ -840,7 +840,7 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
840
840
|
className: "mt-4 space-y-3",
|
|
841
841
|
children: [
|
|
842
842
|
state.lastAnswer.refused ? /* @__PURE__ */ jsxDEV("div", {
|
|
843
|
-
className: "text-
|
|
843
|
+
className: "text-red-600 text-sm",
|
|
844
844
|
children: [
|
|
845
845
|
"Refused: ",
|
|
846
846
|
state.lastAnswer.refusalReason ?? "UNKNOWN"
|
|
@@ -849,7 +849,7 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
849
849
|
state.lastAnswer.sections.map((s, idx) => /* @__PURE__ */ jsxDEV("div", {
|
|
850
850
|
children: [
|
|
851
851
|
/* @__PURE__ */ jsxDEV("div", {
|
|
852
|
-
className: "text-sm
|
|
852
|
+
className: "font-semibold text-sm",
|
|
853
853
|
children: s.heading
|
|
854
854
|
}, undefined, false, undefined, this),
|
|
855
855
|
/* @__PURE__ */ jsxDEV("div", {
|
|
@@ -859,11 +859,11 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
859
859
|
]
|
|
860
860
|
}, `${s.heading}-${idx}`, true, undefined, this)),
|
|
861
861
|
/* @__PURE__ */ jsxDEV("div", {
|
|
862
|
-
className: "text-sm
|
|
862
|
+
className: "font-semibold text-sm",
|
|
863
863
|
children: "Citations"
|
|
864
864
|
}, undefined, false, undefined, this),
|
|
865
865
|
/* @__PURE__ */ jsxDEV("ul", {
|
|
866
|
-
className: "
|
|
866
|
+
className: "list-disc pl-5 text-muted-foreground text-sm",
|
|
867
867
|
children: state.lastAnswer.citations.map((c) => /* @__PURE__ */ jsxDEV("li", {
|
|
868
868
|
children: [
|
|
869
869
|
c.kbSnapshotId,
|
|
@@ -880,7 +880,7 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
880
880
|
className: "p-4",
|
|
881
881
|
children: [
|
|
882
882
|
/* @__PURE__ */ jsxDEV("h3", {
|
|
883
|
-
className: "text-lg
|
|
883
|
+
className: "font-semibold text-lg",
|
|
884
884
|
children: "3) Admin: publish a new snapshot (HITL)"
|
|
885
885
|
}, undefined, false, undefined, this),
|
|
886
886
|
/* @__PURE__ */ jsxDEV("div", {
|
|
@@ -902,11 +902,11 @@ function PolicySafeKnowledgeAssistantDashboard() {
|
|
|
902
902
|
className: "p-4",
|
|
903
903
|
children: [
|
|
904
904
|
/* @__PURE__ */ jsxDEV("h3", {
|
|
905
|
-
className: "text-lg
|
|
905
|
+
className: "font-semibold text-lg",
|
|
906
906
|
children: "4) Learning hub (patterns)"
|
|
907
907
|
}, undefined, false, undefined, this),
|
|
908
908
|
/* @__PURE__ */ jsxDEV("p", {
|
|
909
|
-
className: "text-muted-foreground
|
|
909
|
+
className: "mt-2 text-muted-foreground text-sm",
|
|
910
910
|
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."
|
|
911
911
|
}, undefined, false, undefined, this)
|
|
912
912
|
]
|
|
@@ -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,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")
|
package/dist/browser/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
|
]
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Policy-safe Knowledge Assistant (all-in-one template) — spec-first exports.
|
|
3
3
|
*/
|
|
4
|
+
export { default as example } from './example';
|
|
5
|
+
export * from './handlers/policy-safe-knowledge-assistant.handlers';
|
|
6
|
+
export * from './orchestrator/buildAnswer';
|
|
4
7
|
export * from './policy-safe-knowledge-assistant.feature';
|
|
5
8
|
export * from './seed';
|
|
6
|
-
export * from './orchestrator/buildAnswer';
|
|
7
|
-
export * from './handlers/policy-safe-knowledge-assistant.handlers';
|
|
8
9
|
export * from './ui';
|
|
9
|
-
export { default as example } from './example';
|
|
10
10
|
import './docs';
|