@lssm/lib.personalization 0.0.0-canary-20251212230121 → 0.0.0-canary-20251213172311

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.
@@ -1 +1 @@
1
- import{docBlockToPresentationSpec as e,docBlockToPresentationV2 as t,docBlocksToPresentationRoutes as n}from"./presentations.js";import{DocRegistry as r,defaultDocRegistry as i,registerDocBlocks as a}from"./registry.js";import"./PUBLISHING.docblock.js";import"./accessibility_wcag_compliance_specs.docblock.js";import"./tech/PHASE_1_QUICKSTART.docblock.js";import"./tech/PHASE_2_AI_NATIVE_OPERATIONS.docblock.js";import"./tech/PHASE_3_AUTO_EVOLUTION.docblock.js";import"./tech/PHASE_4_PERSONALIZATION_ENGINE.docblock.js";import"./tech/PHASE_5_ZERO_TOUCH_OPERATIONS.docblock.js";import"./tech/lifecycle-stage-system.docblock.js";import"./tech/presentation-runtime.docblock.js";import"./tech/schema/README.docblock.js";import"./tech/templates/runtime.docblock.js";import"./tech/workflows/overview.docblock.js";import"./tech/mcp-endpoints.docblock.js";
1
+ import{docBlockToPresentationSpec as e,docBlockToPresentationV2 as t,docBlocksToPresentationRoutes as n}from"./presentations.js";import{DocRegistry as r,defaultDocRegistry as i,registerDocBlocks as a}from"./registry.js";import"./PUBLISHING.docblock.js";import"./accessibility_wcag_compliance_specs.docblock.js";import"./tech/PHASE_1_QUICKSTART.docblock.js";import"./tech/PHASE_2_AI_NATIVE_OPERATIONS.docblock.js";import"./tech/PHASE_3_AUTO_EVOLUTION.docblock.js";import"./tech/PHASE_4_PERSONALIZATION_ENGINE.docblock.js";import"./tech/PHASE_5_ZERO_TOUCH_OPERATIONS.docblock.js";import"./tech/lifecycle-stage-system.docblock.js";import"./tech/presentation-runtime.docblock.js";import"./tech/schema/README.docblock.js";import"./tech/templates/runtime.docblock.js";import"./tech/workflows/overview.docblock.js";import"./tech/mcp-endpoints.docblock.js";import"./tech/vscode-extension.docblock.js";import"./tech/telemetry-ingest.docblock.js";import"./tech/contracts/openapi-export.docblock.js";
@@ -0,0 +1,38 @@
1
+ import{registerDocBlocks as e}from"../../registry.js";e([{id:`docs.tech.contracts.openapi-export`,title:`OpenAPI export (OpenAPI 3.1) from SpecRegistry`,summary:`Generate a deterministic OpenAPI document from a SpecRegistry using jsonSchemaForSpec + REST transport metadata.`,kind:`reference`,visibility:`public`,route:`/docs/tech/contracts/openapi-export`,tags:[`contracts`,`openapi`,`rest`],body:`## OpenAPI export (OpenAPI 3.1) from SpecRegistry
2
+
3
+ ### Purpose
4
+
5
+ ContractSpec specs can be exported into an **OpenAPI 3.1** document for tooling (SDK generation, docs, gateways).
6
+
7
+ The export is **spec-first**:
8
+
9
+ - Uses \`jsonSchemaForSpec(spec)\` for input/output JSON Schema (from SchemaModel → zod → JSON Schema)
10
+ - Uses \`spec.transport.rest.method/path\` when present
11
+ - Falls back to deterministic defaults:
12
+ - Method: \`POST\` for commands, \`GET\` for queries
13
+ - Path: \`defaultRestPath(name, version)\` → \`/<dot/name>/v<version>\`
14
+
15
+ ### Library API
16
+
17
+ - Function: \`openApiForRegistry(registry, options?)\`
18
+ - Location: \`@lssm/lib.contracts/openapi\`
19
+
20
+ ### CLI
21
+
22
+ Export OpenAPI from a registry module:
23
+
24
+ \`\`\`bash
25
+ contractspec openapi --registry ./src/registry.ts --out ./openapi.json
26
+ \`\`\`
27
+
28
+ The registry module must export one of:
29
+
30
+ - \`registry: SpecRegistry\`
31
+ - \`default(): SpecRegistry | Promise<SpecRegistry>\`
32
+ - \`createRegistry(): SpecRegistry | Promise<SpecRegistry>\`
33
+
34
+ ### Notes / limitations (current)
35
+
36
+ - Responses are generated as a basic \`200\` response (plus schemas when available).
37
+ - Query (GET) inputs are currently represented as a JSON request body when an input schema exists.
38
+ - Errors are not yet expanded into OpenAPI responses; that will be added when we standardize error envelopes.`}]);
@@ -1 +1 @@
1
- import{registerDocBlocks as e}from"../registry.js";e([{id:`docs.tech.mcp.endpoints`,title:`ContractSpec MCP endpoints`,summary:`Dedicated MCP servers for docs, CLI usage, and internal development.`,kind:`reference`,visibility:`mixed`,route:`/docs/tech/mcp/endpoints`,tags:[`mcp`,`docs`,`cli`,`internal`],body:"# ContractSpec MCP endpoints\n\nThree dedicated MCP servers keep AI agents efficient and scoped:\n\n- **Docs MCP**: `/api/mcp/docs` — exposes DocBlocks as resources + presentations. Tool: `docs.search`.\n- **CLI MCP**: `/api/mcp/cli` — surfaces CLI quickstart/reference/README and suggests commands. Tool: `cli.suggestCommand`.\n- **Internal MCP**: `/api/mcp/internal` — internal routing hints and playbook. Tool: `internal.describe`.\n\n### Usage notes\n- Transports are HTTP POST (streamable HTTP); SSE is disabled.\n- Resources are namespaced (`docs://*`, `cli://*`, `internal://*`) and are read-only.\n- Prompts mirror each surface (navigator, usage, bootstrap) for quick agent onboarding.\n- GraphQL remains at `/graphql`; health at `/health`.\n"}]);
1
+ import{registerDocBlocks as e}from"../registry.js";e([{id:`docs.tech.mcp.endpoints`,title:`ContractSpec MCP endpoints`,summary:`Dedicated MCP servers for docs, CLI usage, and internal development.`,kind:`reference`,visibility:`mixed`,route:`/docs/tech/mcp/endpoints`,tags:[`mcp`,`docs`,`cli`,`internal`],body:"# ContractSpec MCP endpoints\n\nThree dedicated MCP servers keep AI agents efficient and scoped:\n\n- **Docs MCP**: `/api/mcp/docs` — exposes DocBlocks as resources + presentations. Tool: `docs.search`.\n- **CLI MCP**: `/api/mcp/cli` — surfaces CLI quickstart/reference/README and suggests commands. Tool: `cli.suggestCommand`.\n- **Internal MCP**: `/api/mcp/internal` — internal routing hints, playbook, and example registry access. Tool: `internal.describe`.\n\n### Usage notes\n- Transports are HTTP POST (streamable HTTP); SSE is disabled.\n- Resources are namespaced (`docs://*`, `cli://*`, `internal://*`) and are read-only.\n- Internal MCP also exposes the examples registry via `examples://*` resources:\n - `examples://list?q=<query>`\n - `examples://example/<id>`\n- Prompts mirror each surface (navigator, usage, bootstrap) for quick agent onboarding.\n- GraphQL remains at `/graphql`; health at `/health`.\n"}]);
@@ -0,0 +1,122 @@
1
+ import{registerDocBlocks as e}from"../registry.js";e([{id:`docs.tech.telemetry.ingest`,title:`Telemetry Ingest Endpoint`,summary:`Server-side telemetry ingestion for ContractSpec clients (VS Code extension, CLI, etc.).`,kind:`reference`,visibility:`internal`,route:`/docs/tech/telemetry/ingest`,tags:[`telemetry`,`api`,`posthog`,`analytics`],body:`# Telemetry Ingest Endpoint
2
+
3
+ The ContractSpec API provides a telemetry ingest endpoint for clients to send product analytics events.
4
+
5
+ ## Endpoint
6
+
7
+ \`\`\`
8
+ POST /api/telemetry/ingest
9
+ \`\`\`
10
+
11
+ ## Request
12
+
13
+ \`\`\`json
14
+ {
15
+ "event": "contractspec.vscode.command_run",
16
+ "distinct_id": "client-uuid",
17
+ "properties": {
18
+ "command": "validate"
19
+ },
20
+ "timestamp": "2024-01-15T10:30:00.000Z"
21
+ }
22
+ \`\`\`
23
+
24
+ ### Headers
25
+
26
+ | Header | Description |
27
+ |--------|-------------|
28
+ | \`x-contractspec-client-id\` | Optional client identifier (used as fallback for distinct_id) |
29
+ | \`Content-Type\` | Must be \`application/json\` |
30
+
31
+ ### Body
32
+
33
+ | Field | Type | Required | Description |
34
+ |-------|------|----------|-------------|
35
+ | \`event\` | string | Yes | Event name (e.g., \`contractspec.vscode.activated\`) |
36
+ | \`distinct_id\` | string | Yes | Anonymous client identifier |
37
+ | \`properties\` | object | No | Event properties |
38
+ | \`timestamp\` | string | No | ISO 8601 timestamp |
39
+
40
+ ## Response
41
+
42
+ \`\`\`json
43
+ {
44
+ "success": true
45
+ }
46
+ \`\`\`
47
+
48
+ ## Configuration
49
+
50
+ The endpoint requires \`POSTHOG_PROJECT_KEY\` environment variable to be set. If not configured, events are accepted but not forwarded.
51
+
52
+ | Environment Variable | Description | Default |
53
+ |---------------------|-------------|---------|
54
+ | \`POSTHOG_HOST\` | PostHog host URL | \`https://eu.posthog.com\` |
55
+ | \`POSTHOG_PROJECT_KEY\` | PostHog project API key | (required) |
56
+
57
+ ## Privacy
58
+
59
+ - No PII is collected or stored
60
+ - \`distinct_id\` is an anonymous client-generated UUID
61
+ - File paths and source code are never included in events
62
+ - Respects VS Code telemetry settings on the client side
63
+
64
+ ## Events
65
+
66
+ ### Extension Events
67
+
68
+ | Event | Description | Properties |
69
+ |-------|-------------|------------|
70
+ | \`contractspec.vscode.activated\` | Extension activated | \`version\` |
71
+ | \`contractspec.vscode.command_run\` | Command executed | \`command\` |
72
+ | \`contractspec.vscode.mcp_call\` | MCP call made | \`endpoint\`, \`tool\` |
73
+
74
+ ### API Events
75
+
76
+ | Event | Description | Properties |
77
+ |-------|-------------|------------|
78
+ | \`contractspec.api.mcp_request\` | MCP request processed | \`endpoint\`, \`method\`, \`success\`, \`duration_ms\` |
79
+ `},{id:`docs.tech.telemetry.hybrid`,title:`Hybrid Telemetry Model`,summary:`How ContractSpec clients choose between direct PostHog and API-routed telemetry.`,kind:`usage`,visibility:`internal`,route:`/docs/tech/telemetry/hybrid`,tags:[`telemetry`,`architecture`,`posthog`],body:`# Hybrid Telemetry Model
80
+
81
+ ContractSpec uses a hybrid telemetry model where clients can send events either directly to PostHog or via the API server.
82
+
83
+ ## Decision Flow
84
+
85
+ \`\`\`
86
+ Is contractspec.api.baseUrl configured?
87
+ ├── Yes → Send via /api/telemetry/ingest
88
+ └── No → Is posthogProjectKey configured?
89
+ ├── Yes → Send directly to PostHog
90
+ └── No → Telemetry disabled
91
+ \`\`\`
92
+
93
+ ## Benefits
94
+
95
+ ### Direct PostHog
96
+ - No server dependency
97
+ - Works offline (with batching)
98
+ - Lower latency
99
+
100
+ ### Via API
101
+ - Centralized key management (no client-side keys)
102
+ - Server-side enrichment and validation
103
+ - Rate limiting and abuse prevention
104
+ - Easier migration to other providers
105
+
106
+ ## Recommendation
107
+
108
+ - **Development**: Use direct PostHog with a dev project key
109
+ - **Production**: Route via API for better governance
110
+
111
+ ## Future: OpenTelemetry
112
+
113
+ The current PostHog implementation is behind a simple interface that can be swapped for OpenTelemetry:
114
+
115
+ \`\`\`typescript
116
+ interface TelemetryClient {
117
+ send(event: TelemetryEvent): Promise<void>;
118
+ }
119
+ \`\`\`
120
+
121
+ This allows future migration without changing client code.
122
+ `}]);
@@ -0,0 +1,68 @@
1
+ import{registerDocBlocks as e}from"../registry.js";e([{id:`docs.tech.vscode.extension`,title:`ContractSpec VS Code Extension`,summary:`VS Code extension for spec-first development with validation, scaffolding, and MCP integration.`,kind:`reference`,visibility:`public`,route:`/docs/tech/vscode/extension`,tags:[`vscode`,`extension`,`tooling`,`dx`],body:`# ContractSpec VS Code Extension
2
+
3
+ The ContractSpec VS Code extension provides spec-first development tooling directly in your editor.
4
+
5
+ ## Features
6
+
7
+ - **Real-time Validation**: Get instant feedback on spec errors and warnings as you save files
8
+ - **Build/Scaffold**: Generate handler and component skeletons from specs (no AI required)
9
+ - **Spec Explorer**: List and navigate all specs in your workspace
10
+ - **Dependency Analysis**: Visualize spec dependencies and detect cycles
11
+ - **MCP Integration**: Search ContractSpec documentation via Model Context Protocol
12
+ - **Snippets**: Code snippets for common ContractSpec patterns
13
+
14
+ ## Commands
15
+
16
+ | Command | Description |
17
+ |---------|-------------|
18
+ | \`ContractSpec: Validate Current Spec\` | Validate the currently open spec file |
19
+ | \`ContractSpec: Validate All Specs\` | Validate all spec files in the workspace |
20
+ | \`ContractSpec: Build/Scaffold\` | Generate handler/component from the current spec |
21
+ | \`ContractSpec: List All Specs\` | Show all specs in the workspace |
22
+ | \`ContractSpec: Analyze Dependencies\` | Analyze and visualize spec dependencies |
23
+ | \`ContractSpec: Search Docs (MCP)\` | Search documentation via MCP |
24
+
25
+ ## Configuration
26
+
27
+ | Setting | Description | Default |
28
+ |---------|-------------|---------|
29
+ | \`contractspec.api.baseUrl\` | Base URL for ContractSpec API (enables MCP + remote telemetry) | \`""\` |
30
+ | \`contractspec.telemetry.posthogHost\` | PostHog host URL for direct telemetry | \`"https://eu.posthog.com"\` |
31
+ | \`contractspec.telemetry.posthogProjectKey\` | PostHog project key for direct telemetry | \`""\` |
32
+ | \`contractspec.validation.onSave\` | Run validation on save | \`true\` |
33
+ | \`contractspec.validation.onOpen\` | Run validation on open | \`true\` |
34
+
35
+ ## Architecture
36
+
37
+ The extension uses:
38
+ - \`@lssm/module.contractspec-workspace\` for pure analysis + templates
39
+ - \`@lssm/bundle.contractspec-workspace\` for workspace services + adapters
40
+
41
+ This allows the extension to work without requiring the CLI to be installed.
42
+
43
+ ## Telemetry
44
+
45
+ The extension uses a hybrid telemetry approach:
46
+ 1. If \`contractspec.api.baseUrl\` is configured → send to API \`/api/telemetry/ingest\`
47
+ 2. Otherwise → send directly to PostHog (if project key configured)
48
+
49
+ Telemetry respects VS Code's telemetry settings. No file paths, source code, or PII is collected.
50
+ `},{id:`docs.tech.vscode.snippets`,title:`ContractSpec Snippets`,summary:`Code snippets for common ContractSpec patterns in VS Code.`,kind:`reference`,visibility:`public`,route:`/docs/tech/vscode/snippets`,tags:[`vscode`,`snippets`,`dx`],body:`# ContractSpec Snippets
51
+
52
+ The VS Code extension includes snippets for common ContractSpec patterns.
53
+
54
+ ## Available Snippets
55
+
56
+ | Prefix | Description |
57
+ |--------|-------------|
58
+ | \`contractspec-command\` | Create a new command (write operation) |
59
+ | \`contractspec-query\` | Create a new query (read-only operation) |
60
+ | \`contractspec-event\` | Create a new event |
61
+ | \`contractspec-docblock\` | Create a new DocBlock |
62
+ | \`contractspec-telemetry\` | Create a new TelemetrySpec |
63
+ | \`contractspec-presentation\` | Create a new Presentation |
64
+
65
+ ## Usage
66
+
67
+ Type the prefix in a TypeScript file and press Tab to expand the snippet. Tab through the placeholders to fill in your values.
68
+ `}]);
@@ -1,4 +1,4 @@
1
- import{registerDocBlocks as e}from"../contracts/src/docs/registry.js";import"../contracts/src/docs/index.js";e([{id:`docs.personalization.behavior-tracking`,title:`Behavior Tracking`,summary:"`@lssm/lib.personalization` provides primitives to observe how tenants/users interact with specs and turn that telemetry into personalization insights.",kind:`reference`,visibility:`public`,route:`/docs/personalization/behavior-tracking`,tags:[`personalization`,`behavior-tracking`],body:`# Behavior Tracking
1
+ import{registerDocBlocks as e}from"../contracts/src/docs/registry.js";import"../contracts/src/docs/index.js";const t=[{id:`docs.personalization.behavior-tracking`,title:`Behavior Tracking`,summary:"`@lssm/lib.personalization` provides primitives to observe how tenants/users interact with specs and turn that telemetry into personalization insights.",kind:`reference`,visibility:`public`,route:`/docs/personalization/behavior-tracking`,tags:[`personalization`,`behavior-tracking`],body:`# Behavior Tracking
2
2
 
3
3
  \`@lssm/lib.personalization\` provides primitives to observe how tenants/users interact with specs and turn that telemetry into personalization insights.
4
4
 
@@ -77,4 +77,4 @@ When the adapter returns an overlay spec, pass it to the overlay engine to regis
77
77
 
78
78
 
79
79
 
80
- `}]);
80
+ `}];e(t);export{t as personalization_behavior_tracking_DocBlocks};
@@ -1,4 +1,4 @@
1
- import{registerDocBlocks as e}from"../contracts/src/docs/registry.js";import"../contracts/src/docs/index.js";e([{id:`docs.personalization.overlay-engine`,title:`Overlay Engine`,summary:"`@lssm/lib.overlay-engine` is the canonical runtime for OverlaySpecs. It validates specs, tracks scope precedence, and exposes hooks for React renderers.",kind:`reference`,visibility:`public`,route:`/docs/personalization/overlay-engine`,tags:[`personalization`,`overlay-engine`],body:`# Overlay Engine
1
+ import{registerDocBlocks as e}from"../contracts/src/docs/registry.js";import"../contracts/src/docs/index.js";const t=[{id:`docs.personalization.overlay-engine`,title:`Overlay Engine`,summary:"`@lssm/lib.overlay-engine` is the canonical runtime for OverlaySpecs. It validates specs, tracks scope precedence, and exposes hooks for React renderers.",kind:`reference`,visibility:`public`,route:`/docs/personalization/overlay-engine`,tags:[`personalization`,`overlay-engine`],body:`# Overlay Engine
2
2
 
3
3
  \`@lssm/lib.overlay-engine\` is the canonical runtime for OverlaySpecs. It validates specs, tracks scope precedence, and exposes hooks for React renderers.
4
4
 
@@ -78,4 +78,4 @@ const result = engine.apply({
78
78
 
79
79
 
80
80
 
81
- `}]);
81
+ `}];e(t);export{t as personalization_overlay_engine_DocBlocks};
@@ -1,4 +1,4 @@
1
- import{registerDocBlocks as e}from"../contracts/src/docs/registry.js";import"../contracts/src/docs/index.js";e([{id:`docs.personalization.workflow-composition`,title:`Workflow Composition`,summary:"`@lssm/lib.workflow-composer` composes base WorkflowSpecs with tenant/role/device-specific extensions.",kind:`reference`,visibility:`public`,route:`/docs/personalization/workflow-composition`,tags:[`personalization`,`workflow-composition`],body:`# Workflow Composition
1
+ import{registerDocBlocks as e}from"../contracts/src/docs/registry.js";import"../contracts/src/docs/index.js";const t=[{id:`docs.personalization.workflow-composition`,title:`Workflow Composition`,summary:"`@lssm/lib.workflow-composer` composes base WorkflowSpecs with tenant/role/device-specific extensions.",kind:`reference`,visibility:`public`,route:`/docs/personalization/workflow-composition`,tags:[`personalization`,`workflow-composition`],body:`# Workflow Composition
2
2
 
3
3
  \`@lssm/lib.workflow-composer\` composes base WorkflowSpecs with tenant/role/device-specific extensions.
4
4
 
@@ -63,4 +63,4 @@ The composer uses anchor references (\`after\`/\`before\`) to place injected ste
63
63
 
64
64
 
65
65
 
66
- `}]);
66
+ `}];e(t);export{t as personalization_workflow_composition_DocBlocks};
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{InMemoryBehaviorStore as e}from"./store.js";import{BehaviorTracker as t,createBehaviorTracker as n}from"./tracker.js";import{BehaviorAnalyzer as r}from"./analyzer.js";import{insightsToOverlaySuggestion as i,insightsToWorkflowAdaptations as a}from"./adapter.js";import"./docs/index.js";export{r as BehaviorAnalyzer,t as BehaviorTracker,e as InMemoryBehaviorStore,n as createBehaviorTracker,i as insightsToOverlaySuggestion,a as insightsToWorkflowAdaptations};
1
+ import{insightsToOverlaySuggestion as e,insightsToWorkflowAdaptations as t}from"./adapter.js";import{BehaviorAnalyzer as n}from"./analyzer.js";import{InMemoryBehaviorStore as r}from"./store.js";import{BehaviorTracker as i,createBehaviorTracker as a}from"./tracker.js";import"./docs/index.js";export{n as BehaviorAnalyzer,i as BehaviorTracker,r as InMemoryBehaviorStore,a as createBehaviorTracker,e as insightsToOverlaySuggestion,t as insightsToWorkflowAdaptations};
package/dist/types.js ADDED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lssm/lib.personalization",
3
- "version": "0.0.0-canary-20251212230121",
3
+ "version": "0.0.0-canary-20251213172311",
4
4
  "description": "Behavior tracking, analysis, and adaptation helpers for ContractSpec personalization.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -38,12 +38,30 @@
38
38
  },
39
39
  "exports": {
40
40
  ".": "./src/index.ts",
41
+ "./adapter": "./src/adapter.ts",
42
+ "./analyzer": "./src/analyzer.ts",
43
+ "./docs": "./src/docs/index.ts",
44
+ "./docs/behavior-tracking.docblock": "./src/docs/behavior-tracking.docblock.ts",
45
+ "./docs/overlay-engine.docblock": "./src/docs/overlay-engine.docblock.ts",
46
+ "./docs/workflow-composition.docblock": "./src/docs/workflow-composition.docblock.ts",
47
+ "./store": "./src/store.ts",
48
+ "./tracker": "./src/tracker.ts",
49
+ "./types": "./src/types.ts",
41
50
  "./*": "./*"
42
51
  },
43
52
  "publishConfig": {
44
53
  "access": "public",
45
54
  "exports": {
46
55
  ".": "./dist/index.js",
56
+ "./adapter": "./dist/adapter.js",
57
+ "./analyzer": "./dist/analyzer.js",
58
+ "./docs": "./dist/docs/index.js",
59
+ "./docs/behavior-tracking.docblock": "./dist/docs/behavior-tracking.docblock.js",
60
+ "./docs/overlay-engine.docblock": "./dist/docs/overlay-engine.docblock.js",
61
+ "./docs/workflow-composition.docblock": "./dist/docs/workflow-composition.docblock.js",
62
+ "./store": "./dist/store.js",
63
+ "./tracker": "./dist/tracker.js",
64
+ "./types": "./dist/types.js",
47
65
  "./*": "./*"
48
66
  }
49
67
  }