@lssm/example.learning-journey-quest-challenges 0.0.0-canary-20251217080011 → 0.0.0-canary-20251219202229
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$colon$bundle.log +76 -23
- package/.turbo/turbo-build.log +77 -10
- package/CHANGELOG.md +4 -4
- package/LICENSE +21 -0
- package/dist/docs/index.js +1 -0
- package/dist/{quest-challenges.docblock-dlZBb7sW.mjs → docs/quest-challenges.docblock.js} +3 -2
- package/dist/docs/quest-challenges.docblock.js.map +1 -0
- package/dist/{index.d.mts → example.d.ts} +2 -4
- package/dist/example.d.ts.map +1 -0
- package/dist/{index.mjs → example.js} +2 -5
- package/dist/example.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +5 -0
- package/dist/libs/contracts/dist/docs/accessibility_wcag_compliance_specs.docblock.js +17 -0
- package/dist/libs/contracts/dist/docs/accessibility_wcag_compliance_specs.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/index.js +25 -0
- package/dist/libs/contracts/dist/docs/meta.docs.js +30 -0
- package/dist/libs/contracts/dist/docs/meta.docs.js.map +1 -0
- package/dist/libs/contracts/dist/docs/presentations.js +72 -0
- package/dist/libs/contracts/dist/docs/presentations.js.map +1 -0
- package/dist/libs/contracts/dist/docs/registry.js +45 -0
- package/dist/libs/contracts/dist/docs/registry.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/auth/better-auth-nextjs.docblock.js +81 -0
- package/dist/libs/contracts/dist/docs/tech/auth/better-auth-nextjs.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/contracts/openapi-export.docblock.js +58 -0
- package/dist/libs/contracts/dist/docs/tech/contracts/openapi-export.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/lifecycle-stage-system.docblock.js +17 -0
- package/dist/libs/contracts/dist/docs/tech/lifecycle-stage-system.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/llm/llm-integration.docblock.js +358 -0
- package/dist/libs/contracts/dist/docs/tech/llm/llm-integration.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/mcp-endpoints.docblock.js +38 -0
- package/dist/libs/contracts/dist/docs/tech/mcp-endpoints.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/presentation-runtime.docblock.js +17 -0
- package/dist/libs/contracts/dist/docs/tech/presentation-runtime.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/schema/README.docblock.js +21 -0
- package/dist/libs/contracts/dist/docs/tech/schema/README.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/studio/learning-events.docblock.js +49 -0
- package/dist/libs/contracts/dist/docs/tech/studio/learning-events.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/studio/learning-journeys.docblock.js +80 -0
- package/dist/libs/contracts/dist/docs/tech/studio/learning-journeys.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/studio/platform-admin-panel.docblock.js +85 -0
- package/dist/libs/contracts/dist/docs/tech/studio/platform-admin-panel.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/studio/project-access-teams.docblock.js +46 -0
- package/dist/libs/contracts/dist/docs/tech/studio/project-access-teams.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/studio/project-routing.docblock.js +68 -0
- package/dist/libs/contracts/dist/docs/tech/studio/project-routing.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/studio/sandbox-unlogged.docblock.js +41 -0
- package/dist/libs/contracts/dist/docs/tech/studio/sandbox-unlogged.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/studio/team-invitations.docblock.js +70 -0
- package/dist/libs/contracts/dist/docs/tech/studio/team-invitations.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/studio/workspace-ops.docblock.js +48 -0
- package/dist/libs/contracts/dist/docs/tech/studio/workspace-ops.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/studio/workspaces.docblock.js +63 -0
- package/dist/libs/contracts/dist/docs/tech/studio/workspaces.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/telemetry-ingest.docblock.js +156 -0
- package/dist/libs/contracts/dist/docs/tech/telemetry-ingest.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/templates/runtime.docblock.js +21 -0
- package/dist/libs/contracts/dist/docs/tech/templates/runtime.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/vscode-extension.docblock.js +102 -0
- package/dist/libs/contracts/dist/docs/tech/vscode-extension.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/workflows/overview.docblock.js +21 -0
- package/dist/libs/contracts/dist/docs/tech/workflows/overview.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech-contracts.docs.js +97 -0
- package/dist/libs/contracts/dist/docs/tech-contracts.docs.js.map +1 -0
- package/dist/{track-B4IVSL73.d.mts → track.d.ts} +2 -1
- package/dist/track.d.ts.map +1 -0
- package/dist/{track-UnyS-rkK.mjs → track.js} +2 -1
- package/dist/track.js.map +1 -0
- package/package.json +14 -13
- package/tsconfig.tsbuildinfo +1 -1
- package/tsdown.config.js +15 -11
- package/dist/docs/index.mjs +0 -3
- package/dist/docs/quest-challenges.docblock.mjs +0 -3
- package/dist/quest-challenges.docblock-D0rnszAi.d.mts +0 -1
- package/dist/track.d.mts +0 -2
- package/dist/track.mjs +0 -3
- /package/dist/docs/{index.d.mts → index.d.ts} +0 -0
- /package/dist/docs/{quest-challenges.docblock.d.mts → quest-challenges.docblock.d.ts} +0 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { docBlockToPresentationSpec, docBlocksToPresentationRoutes } from "./presentations.js";
|
|
2
|
+
|
|
3
|
+
//#region ../../libs/contracts/dist/docs/registry.js
|
|
4
|
+
var DocRegistry = class {
|
|
5
|
+
routes = /* @__PURE__ */ new Map();
|
|
6
|
+
constructor(blocks = [], options) {
|
|
7
|
+
blocks.forEach((block) => this.register(block, options));
|
|
8
|
+
}
|
|
9
|
+
register(block, options) {
|
|
10
|
+
const [route] = docBlocksToPresentationRoutes([block], options);
|
|
11
|
+
if (route) this.routes.set(block.id, route);
|
|
12
|
+
return this;
|
|
13
|
+
}
|
|
14
|
+
list() {
|
|
15
|
+
return [...this.routes.values()];
|
|
16
|
+
}
|
|
17
|
+
get(id) {
|
|
18
|
+
return this.routes.get(id);
|
|
19
|
+
}
|
|
20
|
+
toRouteTuples() {
|
|
21
|
+
return this.list().map(({ route, descriptor }) => [route, descriptor]);
|
|
22
|
+
}
|
|
23
|
+
toPresentationSpecs(options) {
|
|
24
|
+
return this.list().map(({ block }) => docBlockToPresentationSpec(block, options));
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const requiredFields = [
|
|
28
|
+
"id",
|
|
29
|
+
"title",
|
|
30
|
+
"body",
|
|
31
|
+
"kind",
|
|
32
|
+
"visibility",
|
|
33
|
+
"route"
|
|
34
|
+
];
|
|
35
|
+
const defaultDocRegistry = new DocRegistry();
|
|
36
|
+
function registerDocBlocks(blocks) {
|
|
37
|
+
for (const block of blocks) {
|
|
38
|
+
for (const field of requiredFields) if (!block[field]) throw new Error(`DocBlock ${block.id ?? "<missing id>"} missing field ${String(field)}`);
|
|
39
|
+
defaultDocRegistry.register(block);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
export { DocRegistry, defaultDocRegistry, registerDocBlocks };
|
|
45
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","names":[],"sources":["../../../../../../../libs/contracts/dist/docs/registry.js"],"sourcesContent":["import { docBlockToPresentationSpec, docBlocksToPresentationRoutes } from \"./presentations.js\";\n\n//#region src/docs/registry.ts\nvar DocRegistry = class {\n\troutes = /* @__PURE__ */ new Map();\n\tconstructor(blocks = [], options) {\n\t\tblocks.forEach((block) => this.register(block, options));\n\t}\n\tregister(block, options) {\n\t\tconst [route] = docBlocksToPresentationRoutes([block], options);\n\t\tif (route) this.routes.set(block.id, route);\n\t\treturn this;\n\t}\n\tlist() {\n\t\treturn [...this.routes.values()];\n\t}\n\tget(id) {\n\t\treturn this.routes.get(id);\n\t}\n\ttoRouteTuples() {\n\t\treturn this.list().map(({ route, descriptor }) => [route, descriptor]);\n\t}\n\ttoPresentationSpecs(options) {\n\t\treturn this.list().map(({ block }) => docBlockToPresentationSpec(block, options));\n\t}\n};\nconst requiredFields = [\n\t\"id\",\n\t\"title\",\n\t\"body\",\n\t\"kind\",\n\t\"visibility\",\n\t\"route\"\n];\nconst defaultDocRegistry = new DocRegistry();\nfunction registerDocBlocks(blocks) {\n\tfor (const block of blocks) {\n\t\tfor (const field of requiredFields) if (!block[field]) throw new Error(`DocBlock ${block.id ?? \"<missing id>\"} missing field ${String(field)}`);\n\t\tdefaultDocRegistry.register(block);\n\t}\n}\nfunction listRegisteredDocBlocks() {\n\treturn defaultDocRegistry.list().map((r) => r.block);\n}\nfunction docId(id) {\n\tif (!defaultDocRegistry.get(id)) throw new Error(`DocBlock not registered: ${id}`);\n\treturn id;\n}\n\n//#endregion\nexport { DocRegistry, defaultDocRegistry, docId, listRegisteredDocBlocks, registerDocBlocks };\n//# sourceMappingURL=registry.js.map"],"mappings":";;;AAGA,IAAI,cAAc,MAAM;CACvB,yBAAyB,IAAI,KAAK;CAClC,YAAY,SAAS,EAAE,EAAE,SAAS;AACjC,SAAO,SAAS,UAAU,KAAK,SAAS,OAAO,QAAQ,CAAC;;CAEzD,SAAS,OAAO,SAAS;EACxB,MAAM,CAAC,SAAS,8BAA8B,CAAC,MAAM,EAAE,QAAQ;AAC/D,MAAI,MAAO,MAAK,OAAO,IAAI,MAAM,IAAI,MAAM;AAC3C,SAAO;;CAER,OAAO;AACN,SAAO,CAAC,GAAG,KAAK,OAAO,QAAQ,CAAC;;CAEjC,IAAI,IAAI;AACP,SAAO,KAAK,OAAO,IAAI,GAAG;;CAE3B,gBAAgB;AACf,SAAO,KAAK,MAAM,CAAC,KAAK,EAAE,OAAO,iBAAiB,CAAC,OAAO,WAAW,CAAC;;CAEvE,oBAAoB,SAAS;AAC5B,SAAO,KAAK,MAAM,CAAC,KAAK,EAAE,YAAY,2BAA2B,OAAO,QAAQ,CAAC;;;AAGnF,MAAM,iBAAiB;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;AACD,MAAM,qBAAqB,IAAI,aAAa;AAC5C,SAAS,kBAAkB,QAAQ;AAClC,MAAK,MAAM,SAAS,QAAQ;AAC3B,OAAK,MAAM,SAAS,eAAgB,KAAI,CAAC,MAAM,OAAQ,OAAM,IAAI,MAAM,YAAY,MAAM,MAAM,eAAe,iBAAiB,OAAO,MAAM,GAAG;AAC/I,qBAAmB,SAAS,MAAM"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { registerDocBlocks } from "../../registry.js";
|
|
2
|
+
|
|
3
|
+
//#region ../../libs/contracts/dist/docs/tech/auth/better-auth-nextjs.docblock.js
|
|
4
|
+
const tech_auth_better_auth_nextjs_DocBlocks = [{
|
|
5
|
+
id: "docs.tech.auth.better-auth-nextjs",
|
|
6
|
+
title: "Better Auth + Next.js integration (ContractSpec)",
|
|
7
|
+
summary: "How ContractSpec wires Better Auth into Next.js (server config, client singleton, and proxy cookie-only redirects).",
|
|
8
|
+
kind: "reference",
|
|
9
|
+
visibility: "public",
|
|
10
|
+
route: "/docs/tech/auth/better-auth-nextjs",
|
|
11
|
+
tags: [
|
|
12
|
+
"auth",
|
|
13
|
+
"better-auth",
|
|
14
|
+
"nextjs",
|
|
15
|
+
"cookies",
|
|
16
|
+
"proxy",
|
|
17
|
+
"hmr"
|
|
18
|
+
],
|
|
19
|
+
body: `# Better Auth + Next.js integration (ContractSpec)
|
|
20
|
+
|
|
21
|
+
This repo uses Better Auth as the primary auth layer (sessions, organizations, teams, API keys, and OAuth).
|
|
22
|
+
|
|
23
|
+
## Server config (Better Auth)
|
|
24
|
+
|
|
25
|
+
- Source: \`packages/bundles/contractspec-studio/src/application/services/auth.ts\`
|
|
26
|
+
- Important: \`nextCookies()\` must be the **last** plugin in the Better Auth plugin list so \`Set-Cookie\` is applied correctly in Next.js environments.
|
|
27
|
+
|
|
28
|
+
## Better Auth Admin plugin
|
|
29
|
+
|
|
30
|
+
ContractSpec Studio enables the Better Auth **Admin plugin** to support platform-admin user operations (list users, impersonation, etc.).
|
|
31
|
+
|
|
32
|
+
- Server: \`admin()\` plugin in \`packages/bundles/contractspec-studio/src/application/services/auth.ts\`
|
|
33
|
+
- Client: \`adminClient()\` in \`packages/bundles/contractspec-studio/src/presentation/providers/auth/client.ts\`
|
|
34
|
+
|
|
35
|
+
### PLATFORM_ADMIN ⇒ Better Auth admin role
|
|
36
|
+
|
|
37
|
+
Better Auth Admin endpoints authorize via \`user.role\`. ContractSpec enforces an org-driven rule:
|
|
38
|
+
|
|
39
|
+
- If the **active organization** has \`type = PLATFORM_ADMIN\`, the signed-in user is ensured to have \`User.role\` containing \`admin\`.
|
|
40
|
+
- This is applied in the session creation hook and re-checked in \`assertsPlatformAdmin()\`.
|
|
41
|
+
|
|
42
|
+
This keeps admin enablement deterministic and avoids manual role backfills.
|
|
43
|
+
|
|
44
|
+
## Client config (React web + Expo)
|
|
45
|
+
|
|
46
|
+
To avoid duplicate background refresh/polling loops in dev (Fast Refresh/HMR), the Better Auth client is implemented as a singleton cached on \`globalThis\`.
|
|
47
|
+
|
|
48
|
+
- Web client: \`packages/bundles/contractspec-studio/src/presentation/providers/auth/client.ts\`
|
|
49
|
+
- Native client: \`packages/bundles/contractspec-studio/src/presentation/providers/auth/client.native.ts\`
|
|
50
|
+
|
|
51
|
+
Import guidance:
|
|
52
|
+
|
|
53
|
+
- If you only need the context/hook, prefer importing from \`@lssm/bundle.contractspec-studio/presentation/providers/auth\`.
|
|
54
|
+
- If you explicitly need the Better Auth client instance (e.g. admin impersonation, direct API calls), import from \`@lssm/bundle.contractspec-studio/presentation/providers/auth/client\`.
|
|
55
|
+
|
|
56
|
+
## Public routes (login / signup)
|
|
57
|
+
|
|
58
|
+
Public auth pages should avoid eager \`authClient\` initialization.
|
|
59
|
+
|
|
60
|
+
Pattern used:
|
|
61
|
+
|
|
62
|
+
- In the submit handler, dynamically import \`@lssm/bundle.contractspec-studio/presentation/providers/auth/index.web\` and call \`authClient.signIn.*\` / \`authClient.signUp.*\`.
|
|
63
|
+
|
|
64
|
+
This prevents session refresh behavior from starting just because a public page rendered.
|
|
65
|
+
|
|
66
|
+
## Next.js proxy auth (web-landing)
|
|
67
|
+
|
|
68
|
+
The Next.js proxy/middleware is used for **redirect decisions only**. It must not perform DB-backed session reads on every request.
|
|
69
|
+
|
|
70
|
+
- Source: \`packages/apps/web-landing/src/proxy.ts\`
|
|
71
|
+
- Approach: cookie-only checks via Better Auth cookies helpers:
|
|
72
|
+
- \`getSessionCookie(request)\`
|
|
73
|
+
- \`getCookieCache(request)\`
|
|
74
|
+
|
|
75
|
+
These checks are intentionally optimistic and should only gate routing. Full authorization must still be enforced on server-side actions/routes and GraphQL resolvers.
|
|
76
|
+
`
|
|
77
|
+
}];
|
|
78
|
+
registerDocBlocks(tech_auth_better_auth_nextjs_DocBlocks);
|
|
79
|
+
|
|
80
|
+
//#endregion
|
|
81
|
+
//# sourceMappingURL=better-auth-nextjs.docblock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"better-auth-nextjs.docblock.js","names":[],"sources":["../../../../../../../../../libs/contracts/dist/docs/tech/auth/better-auth-nextjs.docblock.js"],"sourcesContent":["import { registerDocBlocks } from \"../../registry.js\";\n\n//#region src/docs/tech/auth/better-auth-nextjs.docblock.ts\nconst tech_auth_better_auth_nextjs_DocBlocks = [{\n\tid: \"docs.tech.auth.better-auth-nextjs\",\n\ttitle: \"Better Auth + Next.js integration (ContractSpec)\",\n\tsummary: \"How ContractSpec wires Better Auth into Next.js (server config, client singleton, and proxy cookie-only redirects).\",\n\tkind: \"reference\",\n\tvisibility: \"public\",\n\troute: \"/docs/tech/auth/better-auth-nextjs\",\n\ttags: [\n\t\t\"auth\",\n\t\t\"better-auth\",\n\t\t\"nextjs\",\n\t\t\"cookies\",\n\t\t\"proxy\",\n\t\t\"hmr\"\n\t],\n\tbody: `# Better Auth + Next.js integration (ContractSpec)\n\nThis repo uses Better Auth as the primary auth layer (sessions, organizations, teams, API keys, and OAuth).\n\n## Server config (Better Auth)\n\n- Source: \\`packages/bundles/contractspec-studio/src/application/services/auth.ts\\`\n- Important: \\`nextCookies()\\` must be the **last** plugin in the Better Auth plugin list so \\`Set-Cookie\\` is applied correctly in Next.js environments.\n\n## Better Auth Admin plugin\n\nContractSpec Studio enables the Better Auth **Admin plugin** to support platform-admin user operations (list users, impersonation, etc.).\n\n- Server: \\`admin()\\` plugin in \\`packages/bundles/contractspec-studio/src/application/services/auth.ts\\`\n- Client: \\`adminClient()\\` in \\`packages/bundles/contractspec-studio/src/presentation/providers/auth/client.ts\\`\n\n### PLATFORM_ADMIN ⇒ Better Auth admin role\n\nBetter Auth Admin endpoints authorize via \\`user.role\\`. ContractSpec enforces an org-driven rule:\n\n- If the **active organization** has \\`type = PLATFORM_ADMIN\\`, the signed-in user is ensured to have \\`User.role\\` containing \\`admin\\`.\n- This is applied in the session creation hook and re-checked in \\`assertsPlatformAdmin()\\`.\n\nThis keeps admin enablement deterministic and avoids manual role backfills.\n\n## Client config (React web + Expo)\n\nTo avoid duplicate background refresh/polling loops in dev (Fast Refresh/HMR), the Better Auth client is implemented as a singleton cached on \\`globalThis\\`.\n\n- Web client: \\`packages/bundles/contractspec-studio/src/presentation/providers/auth/client.ts\\`\n- Native client: \\`packages/bundles/contractspec-studio/src/presentation/providers/auth/client.native.ts\\`\n\nImport guidance:\n\n- If you only need the context/hook, prefer importing from \\`@lssm/bundle.contractspec-studio/presentation/providers/auth\\`.\n- If you explicitly need the Better Auth client instance (e.g. admin impersonation, direct API calls), import from \\`@lssm/bundle.contractspec-studio/presentation/providers/auth/client\\`.\n\n## Public routes (login / signup)\n\nPublic auth pages should avoid eager \\`authClient\\` initialization.\n\nPattern used:\n\n- In the submit handler, dynamically import \\`@lssm/bundle.contractspec-studio/presentation/providers/auth/index.web\\` and call \\`authClient.signIn.*\\` / \\`authClient.signUp.*\\`.\n\nThis prevents session refresh behavior from starting just because a public page rendered.\n\n## Next.js proxy auth (web-landing)\n\nThe Next.js proxy/middleware is used for **redirect decisions only**. It must not perform DB-backed session reads on every request.\n\n- Source: \\`packages/apps/web-landing/src/proxy.ts\\`\n- Approach: cookie-only checks via Better Auth cookies helpers:\n - \\`getSessionCookie(request)\\`\n - \\`getCookieCache(request)\\`\n\nThese checks are intentionally optimistic and should only gate routing. Full authorization must still be enforced on server-side actions/routes and GraphQL resolvers.\n`\n}];\nregisterDocBlocks(tech_auth_better_auth_nextjs_DocBlocks);\n\n//#endregion\nexport { tech_auth_better_auth_nextjs_DocBlocks };\n//# sourceMappingURL=better-auth-nextjs.docblock.js.map"],"mappings":";;;AAGA,MAAM,yCAAyC,CAAC;CAC/C,IAAI;CACJ,OAAO;CACP,SAAS;CACT,MAAM;CACN,YAAY;CACZ,OAAO;CACP,MAAM;EACL;EACA;EACA;EACA;EACA;EACA;EACA;CACD,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0DN,CAAC;AACF,kBAAkB,uCAAuC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { registerDocBlocks } from "../../registry.js";
|
|
2
|
+
|
|
3
|
+
//#region ../../libs/contracts/dist/docs/tech/contracts/openapi-export.docblock.js
|
|
4
|
+
const tech_contracts_openapi_export_DocBlocks = [{
|
|
5
|
+
id: "docs.tech.contracts.openapi-export",
|
|
6
|
+
title: "OpenAPI export (OpenAPI 3.1) from SpecRegistry",
|
|
7
|
+
summary: "Generate a deterministic OpenAPI document from a SpecRegistry using jsonSchemaForSpec + REST transport metadata.",
|
|
8
|
+
kind: "reference",
|
|
9
|
+
visibility: "public",
|
|
10
|
+
route: "/docs/tech/contracts/openapi-export",
|
|
11
|
+
tags: [
|
|
12
|
+
"contracts",
|
|
13
|
+
"openapi",
|
|
14
|
+
"rest"
|
|
15
|
+
],
|
|
16
|
+
body: `## OpenAPI export (OpenAPI 3.1) from SpecRegistry
|
|
17
|
+
|
|
18
|
+
### Purpose
|
|
19
|
+
|
|
20
|
+
ContractSpec specs can be exported into an **OpenAPI 3.1** document for tooling (SDK generation, docs, gateways).
|
|
21
|
+
|
|
22
|
+
The export is **spec-first**:
|
|
23
|
+
|
|
24
|
+
- Uses \`jsonSchemaForSpec(spec)\` for input/output JSON Schema (from SchemaModel → zod → JSON Schema)
|
|
25
|
+
- Uses \`spec.transport.rest.method/path\` when present
|
|
26
|
+
- Falls back to deterministic defaults:
|
|
27
|
+
- Method: \`POST\` for commands, \`GET\` for queries
|
|
28
|
+
- Path: \`defaultRestPath(name, version)\` → \`/<dot/name>/v<version>\`
|
|
29
|
+
|
|
30
|
+
### Library API
|
|
31
|
+
|
|
32
|
+
- Function: \`openApiForRegistry(registry, options?)\`
|
|
33
|
+
- Location: \`@lssm/lib.contracts/openapi\`
|
|
34
|
+
|
|
35
|
+
### CLI
|
|
36
|
+
|
|
37
|
+
Export OpenAPI from a registry module:
|
|
38
|
+
|
|
39
|
+
\`\`\`bash
|
|
40
|
+
contractspec openapi --registry ./src/registry.ts --out ./openapi.json
|
|
41
|
+
\`\`\`
|
|
42
|
+
|
|
43
|
+
The registry module must export one of:
|
|
44
|
+
|
|
45
|
+
- \`registry: SpecRegistry\`
|
|
46
|
+
- \`default(): SpecRegistry | Promise<SpecRegistry>\`
|
|
47
|
+
- \`createRegistry(): SpecRegistry | Promise<SpecRegistry>\`
|
|
48
|
+
|
|
49
|
+
### Notes / limitations (current)
|
|
50
|
+
|
|
51
|
+
- Responses are generated as a basic \`200\` response (plus schemas when available).
|
|
52
|
+
- Query (GET) inputs are currently represented as a JSON request body when an input schema exists.
|
|
53
|
+
- Errors are not yet expanded into OpenAPI responses; that will be added when we standardize error envelopes.`
|
|
54
|
+
}];
|
|
55
|
+
registerDocBlocks(tech_contracts_openapi_export_DocBlocks);
|
|
56
|
+
|
|
57
|
+
//#endregion
|
|
58
|
+
//# sourceMappingURL=openapi-export.docblock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi-export.docblock.js","names":[],"sources":["../../../../../../../../../libs/contracts/dist/docs/tech/contracts/openapi-export.docblock.js"],"sourcesContent":["import { registerDocBlocks } from \"../../registry.js\";\n\n//#region src/docs/tech/contracts/openapi-export.docblock.ts\nconst tech_contracts_openapi_export_DocBlocks = [{\n\tid: \"docs.tech.contracts.openapi-export\",\n\ttitle: \"OpenAPI export (OpenAPI 3.1) from SpecRegistry\",\n\tsummary: \"Generate a deterministic OpenAPI document from a SpecRegistry using jsonSchemaForSpec + REST transport metadata.\",\n\tkind: \"reference\",\n\tvisibility: \"public\",\n\troute: \"/docs/tech/contracts/openapi-export\",\n\ttags: [\n\t\t\"contracts\",\n\t\t\"openapi\",\n\t\t\"rest\"\n\t],\n\tbody: `## OpenAPI export (OpenAPI 3.1) from SpecRegistry\n\n### Purpose\n\nContractSpec specs can be exported into an **OpenAPI 3.1** document for tooling (SDK generation, docs, gateways).\n\nThe export is **spec-first**:\n\n- Uses \\`jsonSchemaForSpec(spec)\\` for input/output JSON Schema (from SchemaModel → zod → JSON Schema)\n- Uses \\`spec.transport.rest.method/path\\` when present\n- Falls back to deterministic defaults:\n - Method: \\`POST\\` for commands, \\`GET\\` for queries\n - Path: \\`defaultRestPath(name, version)\\` → \\`/<dot/name>/v<version>\\`\n\n### Library API\n\n- Function: \\`openApiForRegistry(registry, options?)\\`\n- Location: \\`@lssm/lib.contracts/openapi\\`\n\n### CLI\n\nExport OpenAPI from a registry module:\n\n\\`\\`\\`bash\ncontractspec openapi --registry ./src/registry.ts --out ./openapi.json\n\\`\\`\\`\n\nThe registry module must export one of:\n\n- \\`registry: SpecRegistry\\`\n- \\`default(): SpecRegistry | Promise<SpecRegistry>\\`\n- \\`createRegistry(): SpecRegistry | Promise<SpecRegistry>\\`\n\n### Notes / limitations (current)\n\n- Responses are generated as a basic \\`200\\` response (plus schemas when available).\n- Query (GET) inputs are currently represented as a JSON request body when an input schema exists.\n- Errors are not yet expanded into OpenAPI responses; that will be added when we standardize error envelopes.`\n}];\nregisterDocBlocks(tech_contracts_openapi_export_DocBlocks);\n\n//#endregion\nexport { tech_contracts_openapi_export_DocBlocks };\n//# sourceMappingURL=openapi-export.docblock.js.map"],"mappings":";;;AAGA,MAAM,0CAA0C,CAAC;CAChD,IAAI;CACJ,OAAO;CACP,SAAS;CACT,MAAM;CACN,YAAY;CACZ,OAAO;CACP,MAAM;EACL;EACA;EACA;EACA;CACD,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsCN,CAAC;AACF,kBAAkB,wCAAwC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { registerDocBlocks } from "../registry.js";
|
|
2
|
+
|
|
3
|
+
//#region ../../libs/contracts/dist/docs/tech/lifecycle-stage-system.docblock.js
|
|
4
|
+
const tech_lifecycle_stage_system_DocBlocks = [{
|
|
5
|
+
id: "docs.tech.lifecycle-stage-system",
|
|
6
|
+
title: "ContractSpec Lifecycle Stage System – Technical Design",
|
|
7
|
+
summary: "This document describes how ContractSpec implements lifecycle detection and guidance. It covers architecture, module boundaries, scoring heuristics, and integration points so libraries, modules, bundles, and Studio surfaces stay synchronized.",
|
|
8
|
+
kind: "reference",
|
|
9
|
+
visibility: "public",
|
|
10
|
+
route: "/docs/tech/lifecycle-stage-system",
|
|
11
|
+
tags: ["tech", "lifecycle-stage-system"],
|
|
12
|
+
body: "## ContractSpec Lifecycle Stage System – Technical Design\n\nThis document describes how ContractSpec implements lifecycle detection and guidance. It covers architecture, module boundaries, scoring heuristics, and integration points so libraries, modules, bundles, and Studio surfaces stay synchronized.\n\n---\n\n### 1. Architecture Overview\n\n```\n┌──────────────────────┐\n│ @lssm/lib.lifecycle │ Types, enums, helpers (pure data)\n└───────────┬──────────┘\n │\n┌───────────▼──────────┐ ┌───────────────────────────┐\n│ modules/lifecycle- │ │ modules/lifecycle-advisor │\n│ core (detection) │ │ (guidance & ceremonies) │\n└───────────┬──────────┘ └───────────┬───────────────┘\n │ │\n ├────────────┬──────────────┤\n ▼ ▼ ▼\n Adapters: analytics, intent, questionnaires\n │\n┌───────────▼──────────┐\n│ bundles/lifecycle- │ Managed service for Studio\n│ managed │ (REST handlers, AI agent) │\n└───────────┬──────────┘\n │\n ContractSpec Studio surfaces\n (web/mobile APIs, CLI, docs)\n```\n\n- **Libraries** provide shared vocabulary.\n- **Modules** encapsulate logic, accepting adapters to avoid environment-specific code.\n- **Bundles** compose modules, register agents/events, and expose APIs for Studio.\n- **Apps** (web-landing, future Studio views) consume bundle APIs; they do not reimplement logic. For web-landing we now resolve `@lssm/bundle.contractspec-studio` and `@lssm/lib.database-contractspec-studio` directly from their `packages/.../src` folders via `tsconfig` path aliases so Prisma stays on the server build and Turbopack no longer pulls the prebundled `dist` artifacts into client chunks.\n\n---\n\n### 2. Core Library (`@lssm/lib.lifecycle`)\n\n- Stage enum (0–6) with metadata (`question`, `signals`, `traps`).\n- Axes types (`ProductPhase`, `CompanyPhase`, `CapitalPhase`).\n- `LifecycleSignal` (source, metric, value, timestamp).\n- `LifecycleMetricSnapshot` (aggregated numbers).\n- `LifecycleMilestone`, `LifecycleAction`, `LifecycleAssessment` interfaces.\n- Utility helpers:\n - `formatStageSummary(stage, assessment)`\n - `rankStageCandidates(scores)`\n\nThe library exports **no runtime dependencies** so it can be imported from apps, modules, and bundles alike.\n\n---\n\n### 3. Lifecycle Core Module\n\n**Location:** `packages/modules/lifecycle-core/`\n\n#### Components\n1. **StageSignalCollector**\n - Accepts adapter interfaces:\n - `AnalyticsAdapter` (pulls metrics from `@lssm/lib.analytics` or fixture streams).\n - `IntentAdapter` (hooks into `@lssm/lib.observability` intent detectors or logs).\n - `QuestionnaireAdapter` (loads JSON questionnaires and responses).\n - Produces normalized `LifecycleSignal[]`.\n\n2. **StageScorer**\n - Weighted scoring model:\n - Base weight per stage (reflecting expected maturity).\n - Feature weights (retention, revenue, team size, qualitative feedback).\n - Confidence computed via variance of contributing signals.\n - Supports pluggable scoring matrices via JSON config.\n - Accepts sparse metric snapshots; the orchestrator sanitizes metrics to numeric-only records before persisting assessments so downstream analytics stay consistent.\n\n3. **LifecycleOrchestrator**\n - Coordinates collectors + scorer.\n - Returns `LifecycleAssessment` with:\n - `stage`, `confidence`, `axisSnapshot`, `signalsUsed`.\n - Recommended focus areas (high-level categories only).\n - Emits events (internally) when stage confidence crosses thresholds (consumed later by bundle).\n\n4. **LifecycleMilestonePlanner**\n - Loads `milestones-catalog.json` (no DB).\n - Filters upcoming milestones per stage + axis.\n - Tracks completion using provided IDs (caller persists).\n\n#### Data Files\n- `configs/stage-weights.json`\n- `configs/milestones-catalog.json`\n- `questionnaires/stage-readiness.json`\n\n#### Extension Hooks\n- All adapters exported as TypeScript interfaces.\n- Implementations for analytics/intent can live in bundles or apps without modifying module code.\n\n---\n\n### 4. Lifecycle Advisor Module\n\n**Location:** `packages/modules/lifecycle-advisor/`\n\n#### Components\n1. **LifecycleRecommendationEngine**\n - Consumes `LifecycleAssessment`.\n - Maps gaps to `LifecycleAction[]` using rule tables (`stage-playbooks.ts`).\n - Supports override hooks for customer-specific rules.\n\n2. **ContractSpecLibraryRecommender**\n - Maintains mapping from stage → recommended libraries/modules/bundles.\n - Returns prioritized list with rationale and adoption prerequisites.\n\n3. **LifecycleCeremonyDesigner**\n - Provides textual/structural data for ceremonies (title, copy, animation cues, soundtrack references).\n - Ensures low-tech friendly instructions (clear copy, undo guidance).\n\n4. **AI Hooks**\n - Defines prompt templates and tool manifests for lifecycle advisor agents (consumed by bundles).\n - Keeps actual LLM integration outside module.\n\n---\n\n### 5. Managed Bundle (`lifecycle-managed`)\n\n**Responsibilities**\n- Wire modules together.\n- Provide HTTP/GraphQL handlers (exact transport optional).\n- Register LifecycleAdvisorAgent via `@lssm/lib.ai-agent`.\n- LifecycleAdvisorAgent meta: domain `operations`, owners `team-lifecycle`, stability `experimental`, tags `guide/lifecycle/ops` so ops tooling can route incidents quickly.\n- Emit lifecycle events through `@lssm/lib.bus` + `@lssm/lib.analytics`.\n- Integrate with `contractspec-studio` packages:\n - Use Studio contracts for authentication/tenant context (without accessing tenant DBs).\n - Store assessments in Studio-managed storage abstractions (in-memory or file-based for now).\n\n**APIs**\n- `POST /lifecycle/assessments`: Accepts metrics + optional questionnaire answers. Returns `LifecycleAssessment`.\n- `GET /lifecycle/playbooks/:stage`: Returns stage playbook + ceremonies.\n- `POST /lifecycle/advise`: Invokes LifecycleAdvisorAgent with context.\n\n**Events**\n- `LifecycleAssessmentCreated`\n- `LifecycleStageChanged`\n- `LifecycleGuidanceConsumed`\n\n---\n\n### 6. Library Enhancements\n\n| Library | Enhancement |\n| --- | --- |\n| `@lssm/lib.analytics` | Lifecycle metric collectors, helper to emit stage events, adapter implementation used by `StageSignalCollector`. |\n| `@lssm/lib.evolution` | Accepts `LifecycleContext` when ranking spec anomalies/suggestions. |\n| `@lssm/lib.growth` | Stage-specific experiment templates + guardrails referencing lifecycle enums. |\n| `@lssm/lib.observability` | Lifecycle KPI pipeline definitions (drift detection, regression alerts). |\n\nEach enhancement must import stage types from `@lssm/lib.lifecycle`.\n\n---\n\n### 7. Feature Flags & Progressive Delivery\n\n- Add new flags in progressive-delivery library:\n - `LIFECYCLE_DETECTION_ALPHA`\n - `LIFECYCLE_ADVISOR_ALPHA`\n - `LIFECYCLE_MANAGED_SERVICE`\n- Bundles/modules should check flags before enabling workflows.\n- Flags referenced in docs + Studio UI to avoid accidental exposure.\n\n---\n\n### 8. Analytics & Telemetry\n\n- Events defined in analytics library; consumed by bundle/app:\n - `lifecycle_assessment_run`\n - `lifecycle_stage_changed`\n - `lifecycle_guidance_consumed`\n- Observability pipeline includes:\n - Composite lifecycle health metric (weighted sum of KPIs).\n - Drift detection comparing stage predictions over time.\n - Alert manager recipes for regression (e.g., PMF drop).\n\n---\n\n### 9. Testing Strategy\n\n1. **Unit**\n - StageScorer weight matrix.\n - RecommendationEngine mapping.\n - Library recommender stage coverage.\n\n2. **Contract**\n - Adapters: ensure mock adapters satisfy interfaces.\n - Bundles: ensure HTTP handlers respect request/response contracts even without persistence.\n\n3. **Integration**\n - CLI example runs detection + guidance end-to-end on fixture data.\n - Dashboard example renders assessments, verifying JSON structures remain stable.\n\n---\n\n### 10. Implementation Checklist\n\n- [ ] Documentation (product, tech, ops, user).\n- [ ] Library creation (`@lssm/lib.lifecycle`).\n- [ ] Modules (`lifecycle-core`, `lifecycle-advisor`).\n- [ ] Bundle (`lifecycle-managed`) + Studio wiring.\n- [ ] Library enhancements (analytics/evolution/growth/observability).\n- [ ] Examples (CLI + dashboard).\n- [ ] Feature flags + telemetry.\n- [ ] Automated tests + fixtures.\n\nKeep this document in sync as modules evolve. When adding new stages or axes, update `@lssm/lib.lifecycle` first, then cascade to adapters, then refresh docs + Studio copy.*** End Patch*** End Patch\n\n\n"
|
|
13
|
+
}];
|
|
14
|
+
registerDocBlocks(tech_lifecycle_stage_system_DocBlocks);
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
//# sourceMappingURL=lifecycle-stage-system.docblock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycle-stage-system.docblock.js","names":[],"sources":["../../../../../../../../libs/contracts/dist/docs/tech/lifecycle-stage-system.docblock.js"],"sourcesContent":["import { registerDocBlocks } from \"../registry.js\";\n\n//#region src/docs/tech/lifecycle-stage-system.docblock.ts\nconst tech_lifecycle_stage_system_DocBlocks = [{\n\tid: \"docs.tech.lifecycle-stage-system\",\n\ttitle: \"ContractSpec Lifecycle Stage System – Technical Design\",\n\tsummary: \"This document describes how ContractSpec implements lifecycle detection and guidance. It covers architecture, module boundaries, scoring heuristics, and integration points so libraries, modules, bundles, and Studio surfaces stay synchronized.\",\n\tkind: \"reference\",\n\tvisibility: \"public\",\n\troute: \"/docs/tech/lifecycle-stage-system\",\n\ttags: [\"tech\", \"lifecycle-stage-system\"],\n\tbody: \"## ContractSpec Lifecycle Stage System – Technical Design\\n\\nThis document describes how ContractSpec implements lifecycle detection and guidance. It covers architecture, module boundaries, scoring heuristics, and integration points so libraries, modules, bundles, and Studio surfaces stay synchronized.\\n\\n---\\n\\n### 1. Architecture Overview\\n\\n```\\n┌──────────────────────┐\\n│ @lssm/lib.lifecycle │ Types, enums, helpers (pure data)\\n└───────────┬──────────┘\\n │\\n┌───────────▼──────────┐ ┌───────────────────────────┐\\n│ modules/lifecycle- │ │ modules/lifecycle-advisor │\\n│ core (detection) │ │ (guidance & ceremonies) │\\n└───────────┬──────────┘ └───────────┬───────────────┘\\n │ │\\n ├────────────┬──────────────┤\\n ▼ ▼ ▼\\n Adapters: analytics, intent, questionnaires\\n │\\n┌───────────▼──────────┐\\n│ bundles/lifecycle- │ Managed service for Studio\\n│ managed │ (REST handlers, AI agent) │\\n└───────────┬──────────┘\\n │\\n ContractSpec Studio surfaces\\n (web/mobile APIs, CLI, docs)\\n```\\n\\n- **Libraries** provide shared vocabulary.\\n- **Modules** encapsulate logic, accepting adapters to avoid environment-specific code.\\n- **Bundles** compose modules, register agents/events, and expose APIs for Studio.\\n- **Apps** (web-landing, future Studio views) consume bundle APIs; they do not reimplement logic. For web-landing we now resolve `@lssm/bundle.contractspec-studio` and `@lssm/lib.database-contractspec-studio` directly from their `packages/.../src` folders via `tsconfig` path aliases so Prisma stays on the server build and Turbopack no longer pulls the prebundled `dist` artifacts into client chunks.\\n\\n---\\n\\n### 2. Core Library (`@lssm/lib.lifecycle`)\\n\\n- Stage enum (0–6) with metadata (`question`, `signals`, `traps`).\\n- Axes types (`ProductPhase`, `CompanyPhase`, `CapitalPhase`).\\n- `LifecycleSignal` (source, metric, value, timestamp).\\n- `LifecycleMetricSnapshot` (aggregated numbers).\\n- `LifecycleMilestone`, `LifecycleAction`, `LifecycleAssessment` interfaces.\\n- Utility helpers:\\n - `formatStageSummary(stage, assessment)`\\n - `rankStageCandidates(scores)`\\n\\nThe library exports **no runtime dependencies** so it can be imported from apps, modules, and bundles alike.\\n\\n---\\n\\n### 3. Lifecycle Core Module\\n\\n**Location:** `packages/modules/lifecycle-core/`\\n\\n#### Components\\n1. **StageSignalCollector**\\n - Accepts adapter interfaces:\\n - `AnalyticsAdapter` (pulls metrics from `@lssm/lib.analytics` or fixture streams).\\n - `IntentAdapter` (hooks into `@lssm/lib.observability` intent detectors or logs).\\n - `QuestionnaireAdapter` (loads JSON questionnaires and responses).\\n - Produces normalized `LifecycleSignal[]`.\\n\\n2. **StageScorer**\\n - Weighted scoring model:\\n - Base weight per stage (reflecting expected maturity).\\n - Feature weights (retention, revenue, team size, qualitative feedback).\\n - Confidence computed via variance of contributing signals.\\n - Supports pluggable scoring matrices via JSON config.\\n - Accepts sparse metric snapshots; the orchestrator sanitizes metrics to numeric-only records before persisting assessments so downstream analytics stay consistent.\\n\\n3. **LifecycleOrchestrator**\\n - Coordinates collectors + scorer.\\n - Returns `LifecycleAssessment` with:\\n - `stage`, `confidence`, `axisSnapshot`, `signalsUsed`.\\n - Recommended focus areas (high-level categories only).\\n - Emits events (internally) when stage confidence crosses thresholds (consumed later by bundle).\\n\\n4. **LifecycleMilestonePlanner**\\n - Loads `milestones-catalog.json` (no DB).\\n - Filters upcoming milestones per stage + axis.\\n - Tracks completion using provided IDs (caller persists).\\n\\n#### Data Files\\n- `configs/stage-weights.json`\\n- `configs/milestones-catalog.json`\\n- `questionnaires/stage-readiness.json`\\n\\n#### Extension Hooks\\n- All adapters exported as TypeScript interfaces.\\n- Implementations for analytics/intent can live in bundles or apps without modifying module code.\\n\\n---\\n\\n### 4. Lifecycle Advisor Module\\n\\n**Location:** `packages/modules/lifecycle-advisor/`\\n\\n#### Components\\n1. **LifecycleRecommendationEngine**\\n - Consumes `LifecycleAssessment`.\\n - Maps gaps to `LifecycleAction[]` using rule tables (`stage-playbooks.ts`).\\n - Supports override hooks for customer-specific rules.\\n\\n2. **ContractSpecLibraryRecommender**\\n - Maintains mapping from stage → recommended libraries/modules/bundles.\\n - Returns prioritized list with rationale and adoption prerequisites.\\n\\n3. **LifecycleCeremonyDesigner**\\n - Provides textual/structural data for ceremonies (title, copy, animation cues, soundtrack references).\\n - Ensures low-tech friendly instructions (clear copy, undo guidance).\\n\\n4. **AI Hooks**\\n - Defines prompt templates and tool manifests for lifecycle advisor agents (consumed by bundles).\\n - Keeps actual LLM integration outside module.\\n\\n---\\n\\n### 5. Managed Bundle (`lifecycle-managed`)\\n\\n**Responsibilities**\\n- Wire modules together.\\n- Provide HTTP/GraphQL handlers (exact transport optional).\\n- Register LifecycleAdvisorAgent via `@lssm/lib.ai-agent`.\\n- LifecycleAdvisorAgent meta: domain `operations`, owners `team-lifecycle`, stability `experimental`, tags `guide/lifecycle/ops` so ops tooling can route incidents quickly.\\n- Emit lifecycle events through `@lssm/lib.bus` + `@lssm/lib.analytics`.\\n- Integrate with `contractspec-studio` packages:\\n - Use Studio contracts for authentication/tenant context (without accessing tenant DBs).\\n - Store assessments in Studio-managed storage abstractions (in-memory or file-based for now).\\n\\n**APIs**\\n- `POST /lifecycle/assessments`: Accepts metrics + optional questionnaire answers. Returns `LifecycleAssessment`.\\n- `GET /lifecycle/playbooks/:stage`: Returns stage playbook + ceremonies.\\n- `POST /lifecycle/advise`: Invokes LifecycleAdvisorAgent with context.\\n\\n**Events**\\n- `LifecycleAssessmentCreated`\\n- `LifecycleStageChanged`\\n- `LifecycleGuidanceConsumed`\\n\\n---\\n\\n### 6. Library Enhancements\\n\\n| Library | Enhancement |\\n| --- | --- |\\n| `@lssm/lib.analytics` | Lifecycle metric collectors, helper to emit stage events, adapter implementation used by `StageSignalCollector`. |\\n| `@lssm/lib.evolution` | Accepts `LifecycleContext` when ranking spec anomalies/suggestions. |\\n| `@lssm/lib.growth` | Stage-specific experiment templates + guardrails referencing lifecycle enums. |\\n| `@lssm/lib.observability` | Lifecycle KPI pipeline definitions (drift detection, regression alerts). |\\n\\nEach enhancement must import stage types from `@lssm/lib.lifecycle`.\\n\\n---\\n\\n### 7. Feature Flags & Progressive Delivery\\n\\n- Add new flags in progressive-delivery library:\\n - `LIFECYCLE_DETECTION_ALPHA`\\n - `LIFECYCLE_ADVISOR_ALPHA`\\n - `LIFECYCLE_MANAGED_SERVICE`\\n- Bundles/modules should check flags before enabling workflows.\\n- Flags referenced in docs + Studio UI to avoid accidental exposure.\\n\\n---\\n\\n### 8. Analytics & Telemetry\\n\\n- Events defined in analytics library; consumed by bundle/app:\\n - `lifecycle_assessment_run`\\n - `lifecycle_stage_changed`\\n - `lifecycle_guidance_consumed`\\n- Observability pipeline includes:\\n - Composite lifecycle health metric (weighted sum of KPIs).\\n - Drift detection comparing stage predictions over time.\\n - Alert manager recipes for regression (e.g., PMF drop).\\n\\n---\\n\\n### 9. Testing Strategy\\n\\n1. **Unit**\\n - StageScorer weight matrix.\\n - RecommendationEngine mapping.\\n - Library recommender stage coverage.\\n\\n2. **Contract**\\n - Adapters: ensure mock adapters satisfy interfaces.\\n - Bundles: ensure HTTP handlers respect request/response contracts even without persistence.\\n\\n3. **Integration**\\n - CLI example runs detection + guidance end-to-end on fixture data.\\n - Dashboard example renders assessments, verifying JSON structures remain stable.\\n\\n---\\n\\n### 10. Implementation Checklist\\n\\n- [ ] Documentation (product, tech, ops, user).\\n- [ ] Library creation (`@lssm/lib.lifecycle`).\\n- [ ] Modules (`lifecycle-core`, `lifecycle-advisor`).\\n- [ ] Bundle (`lifecycle-managed`) + Studio wiring.\\n- [ ] Library enhancements (analytics/evolution/growth/observability).\\n- [ ] Examples (CLI + dashboard).\\n- [ ] Feature flags + telemetry.\\n- [ ] Automated tests + fixtures.\\n\\nKeep this document in sync as modules evolve. When adding new stages or axes, update `@lssm/lib.lifecycle` first, then cascade to adapters, then refresh docs + Studio copy.*** End Patch*** End Patch\\n\\n\\n\"\n}];\nregisterDocBlocks(tech_lifecycle_stage_system_DocBlocks);\n\n//#endregion\nexport { tech_lifecycle_stage_system_DocBlocks };\n//# sourceMappingURL=lifecycle-stage-system.docblock.js.map"],"mappings":";;;AAGA,MAAM,wCAAwC,CAAC;CAC9C,IAAI;CACJ,OAAO;CACP,SAAS;CACT,MAAM;CACN,YAAY;CACZ,OAAO;CACP,MAAM,CAAC,QAAQ,yBAAyB;CACxC,MAAM;CACN,CAAC;AACF,kBAAkB,sCAAsC"}
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
import { registerDocBlocks } from "../../registry.js";
|
|
2
|
+
|
|
3
|
+
//#region ../../libs/contracts/dist/docs/tech/llm/llm-integration.docblock.js
|
|
4
|
+
const tech_llm_integration_DocBlocks = [
|
|
5
|
+
{
|
|
6
|
+
id: "docs.tech.llm.overview",
|
|
7
|
+
title: "LLM Integration Overview",
|
|
8
|
+
summary: "Export specs to LLM-friendly formats, generate implementation guides, and verify implementations.",
|
|
9
|
+
kind: "reference",
|
|
10
|
+
visibility: "public",
|
|
11
|
+
route: "/docs/tech/llm/overview",
|
|
12
|
+
tags: [
|
|
13
|
+
"llm",
|
|
14
|
+
"ai",
|
|
15
|
+
"export",
|
|
16
|
+
"guide",
|
|
17
|
+
"verify"
|
|
18
|
+
],
|
|
19
|
+
body: `# LLM Integration
|
|
20
|
+
|
|
21
|
+
ContractSpec provides first-class LLM integration to bridge specifications and AI coding agents.
|
|
22
|
+
|
|
23
|
+
## Core Features
|
|
24
|
+
|
|
25
|
+
### 1. Multi-Format Export
|
|
26
|
+
|
|
27
|
+
Export specs to markdown in formats optimized for LLM consumption:
|
|
28
|
+
|
|
29
|
+
- **Context format**: Summary for understanding (goal, context, acceptance criteria)
|
|
30
|
+
- **Full format**: Complete spec with all details (I/O schemas, policy, events)
|
|
31
|
+
- **Prompt format**: Actionable prompt with implementation instructions
|
|
32
|
+
|
|
33
|
+
### 2. Implementation Guidance
|
|
34
|
+
|
|
35
|
+
Generate agent-specific implementation plans:
|
|
36
|
+
|
|
37
|
+
- **Claude Code**: Extended thinking mode with structured prompts
|
|
38
|
+
- **Cursor CLI**: Background/composer mode with .mdc rules generation
|
|
39
|
+
- **Generic MCP**: Standard format for any MCP-compatible agent
|
|
40
|
+
|
|
41
|
+
### 3. Tiered Verification
|
|
42
|
+
|
|
43
|
+
Verify implementations against specs:
|
|
44
|
+
|
|
45
|
+
- **Tier 1 (Structure)**: Types, exports, imports validation
|
|
46
|
+
- **Tier 2 (Behavior)**: Scenario coverage, error handling, events
|
|
47
|
+
- **Tier 3 (AI Review)**: Semantic compliance analysis via LLM
|
|
48
|
+
|
|
49
|
+
## Access Points
|
|
50
|
+
|
|
51
|
+
| Surface | Commands/Tools |
|
|
52
|
+
|---------|---------------|
|
|
53
|
+
| CLI | \`contractspec llm export\`, \`guide\`, \`verify\`, \`copy\` |
|
|
54
|
+
| MCP | \`llm.export\`, \`llm.guide\`, \`llm.verify\` tools |
|
|
55
|
+
| VSCode | Export to LLM, Generate Guide, Verify, Copy commands |
|
|
56
|
+
|
|
57
|
+
## Quick Start
|
|
58
|
+
|
|
59
|
+
### CLI Usage
|
|
60
|
+
|
|
61
|
+
\`\`\`bash
|
|
62
|
+
# Export spec as markdown
|
|
63
|
+
contractspec llm export path/to/my.spec.ts --format full
|
|
64
|
+
|
|
65
|
+
# Generate implementation guide
|
|
66
|
+
contractspec llm guide path/to/my.spec.ts --agent claude-code
|
|
67
|
+
|
|
68
|
+
# Verify implementation
|
|
69
|
+
contractspec llm verify path/to/my.spec.ts path/to/impl.ts --tier 2
|
|
70
|
+
|
|
71
|
+
# Copy spec to clipboard
|
|
72
|
+
contractspec llm copy path/to/my.spec.ts --format context
|
|
73
|
+
\`\`\`
|
|
74
|
+
|
|
75
|
+
### MCP Usage
|
|
76
|
+
|
|
77
|
+
\`\`\`
|
|
78
|
+
# Export spec
|
|
79
|
+
llm.export { specPath: "path/to/my.spec.ts", format: "full" }
|
|
80
|
+
|
|
81
|
+
# Generate guide
|
|
82
|
+
llm.guide { specPath: "path/to/my.spec.ts", agent: "cursor-cli" }
|
|
83
|
+
|
|
84
|
+
# Verify implementation
|
|
85
|
+
llm.verify { specPath: "path/to/my.spec.ts", implementationPath: "path/to/impl.ts", tier: "2" }
|
|
86
|
+
\`\`\`
|
|
87
|
+
|
|
88
|
+
### Programmatic Usage
|
|
89
|
+
|
|
90
|
+
\`\`\`typescript
|
|
91
|
+
import { specToFullMarkdown, specToAgentPrompt } from '@lssm/lib.contracts/llm';
|
|
92
|
+
import { createAgentGuideService, createVerifyService } from '@lssm/bundle.contractspec-workspace';
|
|
93
|
+
|
|
94
|
+
// Export
|
|
95
|
+
const markdown = specToFullMarkdown(mySpec);
|
|
96
|
+
|
|
97
|
+
// Generate guide
|
|
98
|
+
const guideService = createAgentGuideService({ defaultAgent: 'claude-code' });
|
|
99
|
+
const guide = guideService.generateGuide(mySpec);
|
|
100
|
+
|
|
101
|
+
// Verify
|
|
102
|
+
const verifyService = createVerifyService();
|
|
103
|
+
const result = await verifyService.verify(mySpec, implementationCode, {
|
|
104
|
+
tiers: ['structure', 'behavior']
|
|
105
|
+
});
|
|
106
|
+
\`\`\`
|
|
107
|
+
`
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
id: "docs.tech.llm.export-formats",
|
|
111
|
+
title: "LLM Export Formats",
|
|
112
|
+
summary: "Detailed explanation of the three export formats for LLM consumption.",
|
|
113
|
+
kind: "reference",
|
|
114
|
+
visibility: "public",
|
|
115
|
+
route: "/docs/tech/llm/export-formats",
|
|
116
|
+
tags: [
|
|
117
|
+
"llm",
|
|
118
|
+
"export",
|
|
119
|
+
"markdown"
|
|
120
|
+
],
|
|
121
|
+
body: `# LLM Export Formats
|
|
122
|
+
|
|
123
|
+
ContractSpec provides three export formats optimized for different LLM use cases.
|
|
124
|
+
|
|
125
|
+
## Context Format
|
|
126
|
+
|
|
127
|
+
Best for: Understanding what a spec does, providing background to LLMs.
|
|
128
|
+
|
|
129
|
+
Includes:
|
|
130
|
+
- Spec name, version, type
|
|
131
|
+
- Goal and context
|
|
132
|
+
- Description
|
|
133
|
+
- Acceptance scenarios
|
|
134
|
+
|
|
135
|
+
Example:
|
|
136
|
+
|
|
137
|
+
\`\`\`markdown
|
|
138
|
+
# users.createUser (v1)
|
|
139
|
+
|
|
140
|
+
> Create a new user account with email verification.
|
|
141
|
+
|
|
142
|
+
**Type:** command | **Stability:** stable
|
|
143
|
+
|
|
144
|
+
## Goal
|
|
145
|
+
Create a new user in the system and trigger email verification.
|
|
146
|
+
|
|
147
|
+
## Context
|
|
148
|
+
Part of the user onboarding flow. Called after signup form submission.
|
|
149
|
+
|
|
150
|
+
## Acceptance Criteria
|
|
151
|
+
### Happy path
|
|
152
|
+
**Given:** Valid email and password
|
|
153
|
+
**When:** User submits registration
|
|
154
|
+
**Then:** Account is created, verification email is sent
|
|
155
|
+
\`\`\`
|
|
156
|
+
|
|
157
|
+
## Full Format
|
|
158
|
+
|
|
159
|
+
Best for: Complete documentation, implementation reference.
|
|
160
|
+
|
|
161
|
+
Includes everything:
|
|
162
|
+
- All metadata
|
|
163
|
+
- JSON schemas for I/O
|
|
164
|
+
- Error definitions
|
|
165
|
+
- Policy (auth, rate limits, PII)
|
|
166
|
+
- Events emitted
|
|
167
|
+
- Examples
|
|
168
|
+
- Transport configuration
|
|
169
|
+
|
|
170
|
+
## Prompt Format
|
|
171
|
+
|
|
172
|
+
Best for: Feeding directly to coding agents.
|
|
173
|
+
|
|
174
|
+
Includes:
|
|
175
|
+
- Task header with clear instructions
|
|
176
|
+
- Full spec context
|
|
177
|
+
- Implementation requirements
|
|
178
|
+
- Task-specific guidance (implement/test/refactor/review)
|
|
179
|
+
- Expected output format
|
|
180
|
+
|
|
181
|
+
The prompt format adapts based on task type:
|
|
182
|
+
- **implement**: Full implementation with tests
|
|
183
|
+
- **test**: Test generation for existing code
|
|
184
|
+
- **refactor**: Refactoring while maintaining behavior
|
|
185
|
+
- **review**: Code review against spec
|
|
186
|
+
`
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
id: "docs.tech.llm.agent-adapters",
|
|
190
|
+
title: "Agent Adapters",
|
|
191
|
+
summary: "Adapters for different AI coding agents (Claude, Cursor, MCP).",
|
|
192
|
+
kind: "reference",
|
|
193
|
+
visibility: "public",
|
|
194
|
+
route: "/docs/tech/llm/agent-adapters",
|
|
195
|
+
tags: [
|
|
196
|
+
"llm",
|
|
197
|
+
"agents",
|
|
198
|
+
"claude",
|
|
199
|
+
"cursor",
|
|
200
|
+
"mcp"
|
|
201
|
+
],
|
|
202
|
+
body: `# Agent Adapters
|
|
203
|
+
|
|
204
|
+
ContractSpec provides specialized adapters for different AI coding agents.
|
|
205
|
+
|
|
206
|
+
## Claude Code Adapter
|
|
207
|
+
|
|
208
|
+
Optimized for Anthropic Claude's extended thinking and code generation.
|
|
209
|
+
|
|
210
|
+
Features:
|
|
211
|
+
- Structured markdown with clear sections
|
|
212
|
+
- Checklists for steps and verification
|
|
213
|
+
- Icons for file operations (📝 create, ✏️ modify)
|
|
214
|
+
- System prompt for ContractSpec context
|
|
215
|
+
|
|
216
|
+
Usage:
|
|
217
|
+
\`\`\`typescript
|
|
218
|
+
const guideService = createAgentGuideService({ defaultAgent: 'claude-code' });
|
|
219
|
+
const result = guideService.generateGuide(spec, { agent: 'claude-code' });
|
|
220
|
+
// result.prompt.systemPrompt - Claude system context
|
|
221
|
+
// result.prompt.taskPrompt - Task-specific instructions
|
|
222
|
+
\`\`\`
|
|
223
|
+
|
|
224
|
+
## Cursor CLI Adapter
|
|
225
|
+
|
|
226
|
+
Optimized for Cursor's background/composer mode.
|
|
227
|
+
|
|
228
|
+
Features:
|
|
229
|
+
- Compact format for context efficiency
|
|
230
|
+
- .mdc cursor rules generation
|
|
231
|
+
- Integration with Cursor's file system
|
|
232
|
+
- Concise step lists
|
|
233
|
+
|
|
234
|
+
Generate Cursor Rules:
|
|
235
|
+
\`\`\`typescript
|
|
236
|
+
const cursorRules = guideService.generateAgentConfig(spec, 'cursor-cli');
|
|
237
|
+
// Save to .cursor/rules/my-spec.mdc
|
|
238
|
+
\`\`\`
|
|
239
|
+
|
|
240
|
+
## Generic MCP Adapter
|
|
241
|
+
|
|
242
|
+
Works with any MCP-compatible agent (Cline, Aider, etc.).
|
|
243
|
+
|
|
244
|
+
Features:
|
|
245
|
+
- Standard markdown format
|
|
246
|
+
- Table-based metadata
|
|
247
|
+
- JSON resource format support
|
|
248
|
+
- Prompt message format
|
|
249
|
+
|
|
250
|
+
The generic adapter is the default and works across all agents.
|
|
251
|
+
|
|
252
|
+
## Choosing an Adapter
|
|
253
|
+
|
|
254
|
+
| Agent | Best For | Key Features |
|
|
255
|
+
|-------|----------|--------------|
|
|
256
|
+
| Claude Code | Complex implementations | Extended thinking, detailed steps |
|
|
257
|
+
| Cursor CLI | IDE-integrated work | Cursor rules, compact format |
|
|
258
|
+
| Generic MCP | Any MCP agent | Universal compatibility |
|
|
259
|
+
`
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
id: "docs.tech.llm.verification",
|
|
263
|
+
title: "Implementation Verification",
|
|
264
|
+
summary: "Tiered verification of implementations against specifications.",
|
|
265
|
+
kind: "reference",
|
|
266
|
+
visibility: "public",
|
|
267
|
+
route: "/docs/tech/llm/verification",
|
|
268
|
+
tags: [
|
|
269
|
+
"llm",
|
|
270
|
+
"verify",
|
|
271
|
+
"validation",
|
|
272
|
+
"testing"
|
|
273
|
+
],
|
|
274
|
+
body: `# Implementation Verification
|
|
275
|
+
|
|
276
|
+
ContractSpec provides tiered verification to check if implementations comply with specs.
|
|
277
|
+
|
|
278
|
+
## Verification Tiers
|
|
279
|
+
|
|
280
|
+
### Tier 1: Structure (Fast)
|
|
281
|
+
|
|
282
|
+
Checks TypeScript structure against spec requirements:
|
|
283
|
+
|
|
284
|
+
| Check | What it validates |
|
|
285
|
+
|-------|------------------|
|
|
286
|
+
| Handler export | Function is properly exported |
|
|
287
|
+
| Contracts import | Imports from @lssm/lib.contracts |
|
|
288
|
+
| Schema import | Imports from @lssm/lib.schema |
|
|
289
|
+
| No \`any\` type | TypeScript strict compliance |
|
|
290
|
+
| Error handling | Error codes are referenced |
|
|
291
|
+
| Event emission | Event patterns exist |
|
|
292
|
+
| Input validation | Validation patterns used |
|
|
293
|
+
| Async patterns | Async/await for commands |
|
|
294
|
+
|
|
295
|
+
### Tier 2: Behavior (Comprehensive)
|
|
296
|
+
|
|
297
|
+
Checks implementation coverage of spec behaviors:
|
|
298
|
+
|
|
299
|
+
| Check | What it validates |
|
|
300
|
+
|-------|------------------|
|
|
301
|
+
| Scenario coverage | Acceptance scenarios implemented |
|
|
302
|
+
| Example coverage | Example I/O values referenced |
|
|
303
|
+
| Error cases | All error conditions handled |
|
|
304
|
+
| Event conditions | Events emitted correctly |
|
|
305
|
+
| Idempotency | Idempotent patterns (if required) |
|
|
306
|
+
|
|
307
|
+
### Tier 3: AI Review (Deep)
|
|
308
|
+
|
|
309
|
+
Uses LLM for semantic analysis:
|
|
310
|
+
|
|
311
|
+
- Does the implementation fulfill the spec's intent?
|
|
312
|
+
- Are edge cases properly handled?
|
|
313
|
+
- Is the code quality acceptable?
|
|
314
|
+
- Are there any subtle violations?
|
|
315
|
+
|
|
316
|
+
Requires AI API key configuration.
|
|
317
|
+
|
|
318
|
+
## Running Verification
|
|
319
|
+
|
|
320
|
+
\`\`\`typescript
|
|
321
|
+
const verifyService = createVerifyService({
|
|
322
|
+
aiApiKey: process.env.ANTHROPIC_API_KEY, // Optional, for Tier 3
|
|
323
|
+
aiProvider: 'anthropic',
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
const result = await verifyService.verify(spec, implementationCode, {
|
|
327
|
+
tiers: ['structure', 'behavior'],
|
|
328
|
+
failFast: false,
|
|
329
|
+
includeSuggestions: true,
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
console.log(result.passed); // true/false
|
|
333
|
+
console.log(result.score); // 0-100
|
|
334
|
+
console.log(result.summary); // Human-readable summary
|
|
335
|
+
\`\`\`
|
|
336
|
+
|
|
337
|
+
## Verification Report
|
|
338
|
+
|
|
339
|
+
The report includes:
|
|
340
|
+
|
|
341
|
+
- **passed**: Overall compliance
|
|
342
|
+
- **score**: 0-100 score
|
|
343
|
+
- **issues**: Array of problems found
|
|
344
|
+
- **suggestions**: Recommended fixes
|
|
345
|
+
- **coverage**: Metrics on scenario/error/field coverage
|
|
346
|
+
|
|
347
|
+
Each issue has:
|
|
348
|
+
- **severity**: error, warning, or info
|
|
349
|
+
- **category**: type, export, import, scenario, error_handling, semantic
|
|
350
|
+
- **message**: Description of the issue
|
|
351
|
+
- **suggestion**: How to fix it
|
|
352
|
+
`
|
|
353
|
+
}
|
|
354
|
+
];
|
|
355
|
+
registerDocBlocks(tech_llm_integration_DocBlocks);
|
|
356
|
+
|
|
357
|
+
//#endregion
|
|
358
|
+
//# sourceMappingURL=llm-integration.docblock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-integration.docblock.js","names":[],"sources":["../../../../../../../../../libs/contracts/dist/docs/tech/llm/llm-integration.docblock.js"],"sourcesContent":["import { registerDocBlocks } from \"../../registry.js\";\n\n//#region src/docs/tech/llm/llm-integration.docblock.ts\nconst tech_llm_integration_DocBlocks = [\n\t{\n\t\tid: \"docs.tech.llm.overview\",\n\t\ttitle: \"LLM Integration Overview\",\n\t\tsummary: \"Export specs to LLM-friendly formats, generate implementation guides, and verify implementations.\",\n\t\tkind: \"reference\",\n\t\tvisibility: \"public\",\n\t\troute: \"/docs/tech/llm/overview\",\n\t\ttags: [\n\t\t\t\"llm\",\n\t\t\t\"ai\",\n\t\t\t\"export\",\n\t\t\t\"guide\",\n\t\t\t\"verify\"\n\t\t],\n\t\tbody: `# LLM Integration\n\nContractSpec provides first-class LLM integration to bridge specifications and AI coding agents.\n\n## Core Features\n\n### 1. Multi-Format Export\n\nExport specs to markdown in formats optimized for LLM consumption:\n\n- **Context format**: Summary for understanding (goal, context, acceptance criteria)\n- **Full format**: Complete spec with all details (I/O schemas, policy, events)\n- **Prompt format**: Actionable prompt with implementation instructions\n\n### 2. Implementation Guidance\n\nGenerate agent-specific implementation plans:\n\n- **Claude Code**: Extended thinking mode with structured prompts\n- **Cursor CLI**: Background/composer mode with .mdc rules generation\n- **Generic MCP**: Standard format for any MCP-compatible agent\n\n### 3. Tiered Verification\n\nVerify implementations against specs:\n\n- **Tier 1 (Structure)**: Types, exports, imports validation\n- **Tier 2 (Behavior)**: Scenario coverage, error handling, events\n- **Tier 3 (AI Review)**: Semantic compliance analysis via LLM\n\n## Access Points\n\n| Surface | Commands/Tools |\n|---------|---------------|\n| CLI | \\`contractspec llm export\\`, \\`guide\\`, \\`verify\\`, \\`copy\\` |\n| MCP | \\`llm.export\\`, \\`llm.guide\\`, \\`llm.verify\\` tools |\n| VSCode | Export to LLM, Generate Guide, Verify, Copy commands |\n\n## Quick Start\n\n### CLI Usage\n\n\\`\\`\\`bash\n# Export spec as markdown\ncontractspec llm export path/to/my.spec.ts --format full\n\n# Generate implementation guide\ncontractspec llm guide path/to/my.spec.ts --agent claude-code\n\n# Verify implementation\ncontractspec llm verify path/to/my.spec.ts path/to/impl.ts --tier 2\n\n# Copy spec to clipboard\ncontractspec llm copy path/to/my.spec.ts --format context\n\\`\\`\\`\n\n### MCP Usage\n\n\\`\\`\\`\n# Export spec\nllm.export { specPath: \"path/to/my.spec.ts\", format: \"full\" }\n\n# Generate guide\nllm.guide { specPath: \"path/to/my.spec.ts\", agent: \"cursor-cli\" }\n\n# Verify implementation\nllm.verify { specPath: \"path/to/my.spec.ts\", implementationPath: \"path/to/impl.ts\", tier: \"2\" }\n\\`\\`\\`\n\n### Programmatic Usage\n\n\\`\\`\\`typescript\nimport { specToFullMarkdown, specToAgentPrompt } from '@lssm/lib.contracts/llm';\nimport { createAgentGuideService, createVerifyService } from '@lssm/bundle.contractspec-workspace';\n\n// Export\nconst markdown = specToFullMarkdown(mySpec);\n\n// Generate guide\nconst guideService = createAgentGuideService({ defaultAgent: 'claude-code' });\nconst guide = guideService.generateGuide(mySpec);\n\n// Verify\nconst verifyService = createVerifyService();\nconst result = await verifyService.verify(mySpec, implementationCode, {\n tiers: ['structure', 'behavior']\n});\n\\`\\`\\`\n`\n\t},\n\t{\n\t\tid: \"docs.tech.llm.export-formats\",\n\t\ttitle: \"LLM Export Formats\",\n\t\tsummary: \"Detailed explanation of the three export formats for LLM consumption.\",\n\t\tkind: \"reference\",\n\t\tvisibility: \"public\",\n\t\troute: \"/docs/tech/llm/export-formats\",\n\t\ttags: [\n\t\t\t\"llm\",\n\t\t\t\"export\",\n\t\t\t\"markdown\"\n\t\t],\n\t\tbody: `# LLM Export Formats\n\nContractSpec provides three export formats optimized for different LLM use cases.\n\n## Context Format\n\nBest for: Understanding what a spec does, providing background to LLMs.\n\nIncludes:\n- Spec name, version, type\n- Goal and context\n- Description\n- Acceptance scenarios\n\nExample:\n\n\\`\\`\\`markdown\n# users.createUser (v1)\n\n> Create a new user account with email verification.\n\n**Type:** command | **Stability:** stable\n\n## Goal\nCreate a new user in the system and trigger email verification.\n\n## Context\nPart of the user onboarding flow. Called after signup form submission.\n\n## Acceptance Criteria\n### Happy path\n**Given:** Valid email and password\n**When:** User submits registration\n**Then:** Account is created, verification email is sent\n\\`\\`\\`\n\n## Full Format\n\nBest for: Complete documentation, implementation reference.\n\nIncludes everything:\n- All metadata\n- JSON schemas for I/O\n- Error definitions\n- Policy (auth, rate limits, PII)\n- Events emitted\n- Examples\n- Transport configuration\n\n## Prompt Format\n\nBest for: Feeding directly to coding agents.\n\nIncludes:\n- Task header with clear instructions\n- Full spec context\n- Implementation requirements\n- Task-specific guidance (implement/test/refactor/review)\n- Expected output format\n\nThe prompt format adapts based on task type:\n- **implement**: Full implementation with tests\n- **test**: Test generation for existing code\n- **refactor**: Refactoring while maintaining behavior\n- **review**: Code review against spec\n`\n\t},\n\t{\n\t\tid: \"docs.tech.llm.agent-adapters\",\n\t\ttitle: \"Agent Adapters\",\n\t\tsummary: \"Adapters for different AI coding agents (Claude, Cursor, MCP).\",\n\t\tkind: \"reference\",\n\t\tvisibility: \"public\",\n\t\troute: \"/docs/tech/llm/agent-adapters\",\n\t\ttags: [\n\t\t\t\"llm\",\n\t\t\t\"agents\",\n\t\t\t\"claude\",\n\t\t\t\"cursor\",\n\t\t\t\"mcp\"\n\t\t],\n\t\tbody: `# Agent Adapters\n\nContractSpec provides specialized adapters for different AI coding agents.\n\n## Claude Code Adapter\n\nOptimized for Anthropic Claude's extended thinking and code generation.\n\nFeatures:\n- Structured markdown with clear sections\n- Checklists for steps and verification\n- Icons for file operations (📝 create, ✏️ modify)\n- System prompt for ContractSpec context\n\nUsage:\n\\`\\`\\`typescript\nconst guideService = createAgentGuideService({ defaultAgent: 'claude-code' });\nconst result = guideService.generateGuide(spec, { agent: 'claude-code' });\n// result.prompt.systemPrompt - Claude system context\n// result.prompt.taskPrompt - Task-specific instructions\n\\`\\`\\`\n\n## Cursor CLI Adapter\n\nOptimized for Cursor's background/composer mode.\n\nFeatures:\n- Compact format for context efficiency\n- .mdc cursor rules generation\n- Integration with Cursor's file system\n- Concise step lists\n\nGenerate Cursor Rules:\n\\`\\`\\`typescript\nconst cursorRules = guideService.generateAgentConfig(spec, 'cursor-cli');\n// Save to .cursor/rules/my-spec.mdc\n\\`\\`\\`\n\n## Generic MCP Adapter\n\nWorks with any MCP-compatible agent (Cline, Aider, etc.).\n\nFeatures:\n- Standard markdown format\n- Table-based metadata\n- JSON resource format support\n- Prompt message format\n\nThe generic adapter is the default and works across all agents.\n\n## Choosing an Adapter\n\n| Agent | Best For | Key Features |\n|-------|----------|--------------|\n| Claude Code | Complex implementations | Extended thinking, detailed steps |\n| Cursor CLI | IDE-integrated work | Cursor rules, compact format |\n| Generic MCP | Any MCP agent | Universal compatibility |\n`\n\t},\n\t{\n\t\tid: \"docs.tech.llm.verification\",\n\t\ttitle: \"Implementation Verification\",\n\t\tsummary: \"Tiered verification of implementations against specifications.\",\n\t\tkind: \"reference\",\n\t\tvisibility: \"public\",\n\t\troute: \"/docs/tech/llm/verification\",\n\t\ttags: [\n\t\t\t\"llm\",\n\t\t\t\"verify\",\n\t\t\t\"validation\",\n\t\t\t\"testing\"\n\t\t],\n\t\tbody: `# Implementation Verification\n\nContractSpec provides tiered verification to check if implementations comply with specs.\n\n## Verification Tiers\n\n### Tier 1: Structure (Fast)\n\nChecks TypeScript structure against spec requirements:\n\n| Check | What it validates |\n|-------|------------------|\n| Handler export | Function is properly exported |\n| Contracts import | Imports from @lssm/lib.contracts |\n| Schema import | Imports from @lssm/lib.schema |\n| No \\`any\\` type | TypeScript strict compliance |\n| Error handling | Error codes are referenced |\n| Event emission | Event patterns exist |\n| Input validation | Validation patterns used |\n| Async patterns | Async/await for commands |\n\n### Tier 2: Behavior (Comprehensive)\n\nChecks implementation coverage of spec behaviors:\n\n| Check | What it validates |\n|-------|------------------|\n| Scenario coverage | Acceptance scenarios implemented |\n| Example coverage | Example I/O values referenced |\n| Error cases | All error conditions handled |\n| Event conditions | Events emitted correctly |\n| Idempotency | Idempotent patterns (if required) |\n\n### Tier 3: AI Review (Deep)\n\nUses LLM for semantic analysis:\n\n- Does the implementation fulfill the spec's intent?\n- Are edge cases properly handled?\n- Is the code quality acceptable?\n- Are there any subtle violations?\n\nRequires AI API key configuration.\n\n## Running Verification\n\n\\`\\`\\`typescript\nconst verifyService = createVerifyService({\n aiApiKey: process.env.ANTHROPIC_API_KEY, // Optional, for Tier 3\n aiProvider: 'anthropic',\n});\n\nconst result = await verifyService.verify(spec, implementationCode, {\n tiers: ['structure', 'behavior'],\n failFast: false,\n includeSuggestions: true,\n});\n\nconsole.log(result.passed); // true/false\nconsole.log(result.score); // 0-100\nconsole.log(result.summary); // Human-readable summary\n\\`\\`\\`\n\n## Verification Report\n\nThe report includes:\n\n- **passed**: Overall compliance\n- **score**: 0-100 score\n- **issues**: Array of problems found\n- **suggestions**: Recommended fixes\n- **coverage**: Metrics on scenario/error/field coverage\n\nEach issue has:\n- **severity**: error, warning, or info\n- **category**: type, export, import, scenario, error_handling, semantic\n- **message**: Description of the issue\n- **suggestion**: How to fix it\n`\n\t}\n];\nregisterDocBlocks(tech_llm_integration_DocBlocks);\n\n//#endregion\nexport { tech_llm_integration_DocBlocks };\n//# sourceMappingURL=llm-integration.docblock.js.map"],"mappings":";;;AAGA,MAAM,iCAAiC;CACtC;EACC,IAAI;EACJ,OAAO;EACP,SAAS;EACT,MAAM;EACN,YAAY;EACZ,OAAO;EACP,MAAM;GACL;GACA;GACA;GACA;GACA;GACA;EACD,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyFN;CACD;EACC,IAAI;EACJ,OAAO;EACP,SAAS;EACT,MAAM;EACN,YAAY;EACZ,OAAO;EACP,MAAM;GACL;GACA;GACA;GACA;EACD,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkEN;CACD;EACC,IAAI;EACJ,OAAO;EACP,SAAS;EACT,MAAM;EACN,YAAY;EACZ,OAAO;EACP,MAAM;GACL;GACA;GACA;GACA;GACA;GACA;EACD,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0DN;CACD;EACC,IAAI;EACJ,OAAO;EACP,SAAS;EACT,MAAM;EACN,YAAY;EACZ,OAAO;EACP,MAAM;GACL;GACA;GACA;GACA;GACA;EACD,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+EN;CACD;AACD,kBAAkB,+BAA+B"}
|