@lssm/bundle.contractspec-workspace 0.0.0-canary-20251216035145 → 0.0.0-canary-20251216062412

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{access as e,mkdir as t,readFile as n,rm as r,stat as i,writeFile as a}from"node:fs/promises";import{basename as o,dirname as s,isAbsolute as c,join as l,relative as u,resolve as d}from"node:path";import{glob as f}from"glob";const p=[`**/*.contracts.ts`,`**/*.event.ts`,`**/*.presentation.ts`,`**/*.feature.ts`,`**/*.capability.ts`,`**/*.workflow.ts`,`**/*.data-view.ts`,`**/*.form.ts`,`**/*.migration.ts`,`**/*.telemetry.ts`,`**/*.experiment.ts`,`**/*.app-config.ts`,`**/*.integration.ts`,`**/*.knowledge.ts`,`**/*.policy.ts`,`**/*.test-spec.ts`],m=[`node_modules/**`,`dist/**`,`.turbo/**`];function h(h){let g=h??process.cwd();return{async exists(t){try{return await e(_(t)),!0}catch{return!1}},async readFile(e){return n(_(e),`utf-8`)},async writeFile(e,n){let r=_(e);await t(s(r),{recursive:!0}),await a(r,n,`utf-8`)},async remove(e){await r(_(e),{recursive:!0,force:!0})},async stat(e){let t=await i(_(e));return{size:t.size,isFile:t.isFile(),isDirectory:t.isDirectory(),mtime:t.mtime}},async mkdir(e){await t(_(e),{recursive:!0})},async glob(e){let t=e.patterns??(e.pattern?[e.pattern]:p),n=e.ignore??m,r=e.cwd??g,i=e.absolute??!0,a=[];for(let e of t){let t=await f(e,{cwd:r,ignore:n,absolute:i});a.push(...t)}return Array.from(new Set(a)).sort((e,t)=>e.localeCompare(t))},resolve(...e){let[t,...n]=e;return t?d(g,t,...n):g},dirname(e){return s(e)},basename(e){return o(e)},join(...e){return l(...e)},relative(e,t){return u(e,t)}};function _(e){return c(e)?e:d(g,e)}}export{h as createNodeFsAdapter};
1
+ import{access as e,mkdir as t,readFile as n,rm as r,stat as i,writeFile as a}from"node:fs/promises";import{basename as o,dirname as s,isAbsolute as c,join as l,relative as u,resolve as d}from"node:path";import{glob as f}from"glob";const p=[`**/*.contracts.ts`,`**/*.event.ts`,`**/*.presentation.ts`,`**/*.feature.ts`,`**/*.capability.ts`,`**/*.workflow.ts`,`**/*.data-view.ts`,`**/*.form.ts`,`**/*.migration.ts`,`**/*.telemetry.ts`,`**/*.experiment.ts`,`**/*.app-config.ts`,`**/*.integration.ts`,`**/*.knowledge.ts`,`**/*.policy.ts`,`**/*.test-spec.ts`,`**/contracts/*.ts`,`**/contracts/index.ts`,`**/events.ts`,`**/presentations.ts`,`**/events/index.ts`,`**/presentations/index.ts`],m=[`node_modules/**`,`dist/**`,`.turbo/**`];function h(h){let g=h??process.cwd();return{async exists(t){try{return await e(_(t)),!0}catch{return!1}},async readFile(e){return n(_(e),`utf-8`)},async writeFile(e,n){let r=_(e);await t(s(r),{recursive:!0}),await a(r,n,`utf-8`)},async remove(e){await r(_(e),{recursive:!0,force:!0})},async stat(e){let t=await i(_(e));return{size:t.size,isFile:t.isFile(),isDirectory:t.isDirectory(),mtime:t.mtime}},async mkdir(e){await t(_(e),{recursive:!0})},async glob(e){let t=e.patterns??(e.pattern?[e.pattern]:p),n=e.ignore??m,r=e.cwd??g,i=e.absolute??!0,a=[];for(let e of t){let t=await f(e,{cwd:r,ignore:n,absolute:i});a.push(...t)}return Array.from(new Set(a)).sort((e,t)=>e.localeCompare(t))},resolve(...e){let[t,...n]=e;return t?d(g,t,...n):g},dirname(e){return s(e)},basename(e){return o(e)},join(...e){return l(...e)},relative(e,t){return u(e,t)}};function _(e){return c(e)?e:d(g,e)}}export{h as createNodeFsAdapter};
@@ -0,0 +1 @@
1
+ import{__export as e}from"../_virtual/rolldown_runtime.js";import{formatAsSarif as t,sarifToJson as n}from"./sarif.js";import{formatAsJson as r,formatAsJsonCompact as i,formatAsJsonFull as a}from"./json.js";import{formatAsText as o,formatAsTextLines as s}from"./text.js";var c=e({formatAsJson:()=>r,formatAsJsonCompact:()=>i,formatAsJsonFull:()=>a,formatAsSarif:()=>t,formatAsText:()=>o,formatAsTextLines:()=>s,sarifToJson:()=>n});export{c as formatters_exports};
@@ -0,0 +1 @@
1
+ function e(e){return{success:e.success,errors:e.totalErrors,warnings:e.totalWarnings,duration:e.durationMs,timestamp:e.timestamp,commit:e.commitSha,branch:e.branch,issues:e.issues.map(e=>({rule:e.ruleId,severity:e.severity,message:e.message,file:e.file,line:e.line}))}}function t(e){return{success:e.success,summary:{totalErrors:e.totalErrors,totalWarnings:e.totalWarnings,totalNotes:e.totalNotes,durationMs:e.durationMs,timestamp:e.timestamp,commitSha:e.commitSha,branch:e.branch},categories:e.categories.map(e=>({category:e.category,label:e.label,passed:e.passed,errors:e.errors,warnings:e.warnings,notes:e.notes,durationMs:e.durationMs})),issues:e.issues.map(e=>({ruleId:e.ruleId,severity:e.severity,message:e.message,category:e.category,file:e.file,line:e.line,column:e.column,endLine:e.endLine,endColumn:e.endColumn,context:e.context}))}}function n(n,r={}){let{pretty:i=!0,includeDetails:a=!0}=r,o=a?t(n):e(n);return i?JSON.stringify(o,null,2):JSON.stringify(o)}export{n as formatAsJson,e as formatAsJsonCompact,t as formatAsJsonFull};
@@ -0,0 +1 @@
1
+ const e={"spec-structure-error":{name:`Spec Structure Error`,description:`Contract specification is missing required structure elements`},"spec-structure-warning":{name:`Spec Structure Warning`,description:`Contract specification has recommended but missing elements`},"integrity-orphaned":{name:`Orphaned Spec`,description:`Contract specification is not linked to any feature`},"integrity-unresolved-ref":{name:`Unresolved Reference`,description:`Contract specification references a non-existent spec`},"integrity-missing-feature":{name:`Missing Feature`,description:`Feature referenced by spec does not exist`},"integrity-broken-link":{name:`Broken Link`,description:`Link between specs is broken`},"deps-circular":{name:`Circular Dependency`,description:`Circular dependency detected between contracts`},"deps-missing":{name:`Missing Dependency`,description:`Contract depends on a non-existent contract`},"handler-missing":{name:`Missing Handler`,description:`Handler implementation file does not exist for this contract`},"handler-warning":{name:`Handler Warning`,description:`Handler implementation has potential issues`},"test-missing":{name:`Missing Test`,description:`Test file does not exist for this contract`},"test-warning":{name:`Test Warning`,description:`Test implementation has potential issues`}};function t(t,a={}){let{toolName:o=`ContractSpec`,toolVersion:s=`1.0.0`,toolUri:c=`https://contractspec.dev`,repositoryUri:l,workingDirectory:u}=a,d=new Map,f=new Map;for(let r of t.issues)if(!d.has(r.ruleId)){let t=e[r.ruleId]??{name:r.ruleId,description:`Rule: ${r.ruleId}`},i={id:r.ruleId,name:t.name,shortDescription:{text:t.description},defaultConfiguration:{level:n(r.severity)}};t.helpUri&&(i.helpUri=t.helpUri),f.set(r.ruleId,d.size),d.set(r.ruleId,i)}let p=t.issues.map(e=>{let t={ruleId:e.ruleId,ruleIndex:f.get(e.ruleId)??0,level:n(e.severity),message:{text:e.message}};if(e.file){let n={physicalLocation:{artifactLocation:{uri:r(e.file),uriBaseId:`%SRCROOT%`}}};e.line!==void 0&&(n.physicalLocation.region={startLine:e.line,startColumn:e.column??1,endLine:e.endLine??e.line,endColumn:e.endColumn}),t.locations=[n]}return t.partialFingerprints={primaryLocationLineHash:i(e)},t}),m=[];(l||t.commitSha||t.branch)&&m.push({repositoryUri:l,revisionId:t.commitSha,branch:t.branch});let h={tool:{driver:{name:o,version:s,informationUri:c,rules:Array.from(d.values())}},results:p,invocations:[{executionSuccessful:t.success,endTimeUtc:t.timestamp,...u&&{workingDirectory:{uri:u}}}]};return m.length>0&&(h.versionControlProvenance=m),{$schema:`https://json.schemastore.org/sarif-2.1.0.json`,version:`2.1.0`,runs:[h]}}function n(e){switch(e){case`error`:return`error`;case`warning`:return`warning`;case`note`:return`note`;default:return`warning`}}function r(e){return e.replace(/^\.\//,``).replace(/\\/g,`/`)}function i(e){let t=[e.ruleId,e.file??``,e.message];return Buffer.from(t.join(`|`)).toString(`base64`).slice(0,16)}function a(e){return JSON.stringify(e,null,2)}export{t as formatAsSarif,a as sarifToJson};
@@ -0,0 +1,2 @@
1
+ function e(e,t={}){let a=[],{verbose:o=!1,showTiming:s=!0,groupByFile:c=!1}=t;if(a.push({text:``,style:`normal`}),a.push({text:`📋 ContractSpec CI Check Results`,style:`bold`}),a.push({text:``,style:`normal`}),e.commitSha||e.branch){let t=[e.branch?`branch: ${e.branch}`:null,e.commitSha?`commit: ${e.commitSha.slice(0,7)}`:null].filter(Boolean).join(`, `);a.push({text:`Git: ${t}`,style:`muted`})}a.push({text:``,style:`normal`}),a.push({text:`Check Results:`,style:`bold`});for(let t of e.categories){let e=t.passed?`✓`:`✗`,r=t.passed?`success`:`error`,i=n(t),o=s?` (${t.durationMs}ms)`:``;a.push({text:` ${e} ${t.label}: ${i}${o}`,style:r})}if(e.issues.length>0)if(a.push({text:``,style:`normal`}),a.push({text:`Issues:`,style:`bold`}),c){let t=i(e.issues);for(let[e,n]of t){a.push({text:``,style:`normal`}),a.push({text:` ${e||`(no file)`}`,style:`bold`,indent:1});for(let e of n)a.push(...r(e,o,2))}}else{let t=e.issues.filter(e=>e.severity===`error`),n=e.issues.filter(e=>e.severity===`warning`),i=e.issues.filter(e=>e.severity===`note`);if(t.length>0){a.push({text:``,style:`normal`}),a.push({text:` Errors:`,style:`error`,indent:1});for(let e of t)a.push(...r(e,o,2))}if(n.length>0){a.push({text:``,style:`normal`}),a.push({text:` Warnings:`,style:`warning`,indent:1});for(let e of n)a.push(...r(e,o,2))}if(i.length>0&&o){a.push({text:``,style:`normal`}),a.push({text:` Notes:`,style:`muted`,indent:1});for(let e of i)a.push(...r(e,o,2))}}a.push({text:``,style:`normal`}),a.push({text:`─`.repeat(50),style:`muted`});let l=[e.totalErrors>0?`${e.totalErrors} error(s)`:null,e.totalWarnings>0?`${e.totalWarnings} warning(s)`:null,e.totalNotes>0&&o?`${e.totalNotes} note(s)`:null].filter(Boolean);return l.length>0&&a.push({text:`Found: ${l.join(`, `)}`,style:e.success?`warning`:`error`}),s&&a.push({text:`Duration: ${e.durationMs}ms`,style:`muted`}),a.push({text:``,style:`normal`}),e.success?a.push({text:`✅ All CI checks passed!`,style:`success`}):a.push({text:`❌ CI checks failed`,style:`error`}),a.push({text:``,style:`normal`}),a}function t(t,n={}){return e(t,n).map(e=>` `.repeat(e.indent??0)+e.text).join(`
2
+ `)}function n(e){let t=[];return e.errors>0&&t.push(`${e.errors} error(s)`),e.warnings>0&&t.push(`${e.warnings} warning(s)`),t.length===0?`passed`:t.join(`, `)}function r(e,t,n){let r=[],i=e.severity===`error`?`✗`:e.severity===`warning`?`⚠`:`○`,a=e.severity===`error`?`error`:e.severity===`warning`?`warning`:`muted`,o=`${i} ${e.message}`;if(e.file){let t=e.line?`:${e.line}`:``;o+=` (${e.file}${t})`}if(r.push({text:o,style:a,indent:n}),t&&e.context){let t=JSON.stringify(e.context);t!==`{}`&&r.push({text:`Context: ${t}`,style:`muted`,indent:n+1})}return r}function i(e){let t=new Map;for(let n of e){let e=n.file??``;t.has(e)||t.set(e,[]);let r=t.get(e);r&&r.push(n)}return new Map([...t.entries()].sort(([e],[t])=>e.localeCompare(t)))}export{t as formatAsText,e as formatAsTextLines};
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{createNodeFsAdapter as e}from"./adapters/fs.js";import{createNodeGitAdapter as t}from"./adapters/git.js";import{createNodeWatcherAdapter as n}from"./adapters/watcher.js";import{createNodeAiAdapter as r}from"./adapters/ai.js";import{createConsoleLoggerAdapter as i,createNoopLoggerAdapter as a}from"./adapters/logger.js";import{createNodeAdapters as o}from"./adapters/factory.js";import{detectPackageManager as s,findPackageRoot as c,findWorkspaceRoot as l,getExecCommand as u,getInstallCommand as d,getPackageName as f,getRunCommand as p,getWorkspaceInfo as m,getWorkspacePackages as h,isMonorepo as g}from"./adapters/workspace.js";import"./adapters/index.js";import{validateSpec as _,validateSpecs as v}from"./services/validate.js";import{validateImplementationFiles as y}from"./services/validate-implementation.js";import{compareSpecs as b}from"./services/diff.js";import{analyzeDeps as x,exportGraphAsDot as S,getContractNode as C,getGraphStats as w}from"./services/deps.js";import{groupSpecsByType as T,listSpecs as E}from"./services/list.js";import{getApiKey as D,loadWorkspaceConfig as O,mergeWorkspaceConfig as k}from"./services/config.js";import{buildSpec as A}from"./services/build.js";import{exportOpenApi as j}from"./services/openapi.js";import{RegistryClient as M,addToRegistry as N,listFromRegistry as P,resolveRegistryUrl as F,searchRegistry as I}from"./services/registry.js";import{syncSpecs as L}from"./services/sync.js";import{watchSpecs as R}from"./services/watch.js";import{cleanArtifacts as z}from"./services/clean.js";import{runTests as B}from"./services/test.js";import{createRegeneratorService as V}from"./services/regenerator.js";import{findAllConfigFiles as H,formatWorkspaceInfo as U,getExtendedWorkspaceInfo as W,mergeMonorepoConfigs as G}from"./services/workspace-info.js";import{analyzeIntegrity as K,filterIssuesBySeverity as q,filterIssuesByType as J,getAllSpecs as Y}from"./services/integrity.js";import{generateMermaidDiagram as X}from"./services/integrity-diagram.js";import{ALL_SETUP_TARGETS as Z,SETUP_TARGET_LABELS as Q}from"./services/setup/types.js";import{generateAgentsMd as $,generateClaudeMcpConfig as ee,generateContractsrcConfig as te,generateCursorMcpConfig as ne,generateCursorRules as re,generateVscodeSettings as ie,getClaudeDesktopConfigPath as ae}from"./services/setup/config-generators.js";import{deepMergeOverwrite as oe,deepMergePreserve as se,formatJson as ce,safeParseJson as le}from"./services/setup/file-merger.js";import{runSetup as ue}from"./services/setup/setup-service.js";import{ALL_CHECK_CATEGORIES as de,CHECK_CATEGORY_LABELS as fe}from"./services/doctor/types.js";import{formatCheckResult as pe,formatDoctorSummary as me,runDoctor as he}from"./services/doctor/doctor-service.js";import"./services/index.js";import{templates_exports as ge}from"./templates/index.js";import{ai_exports as _e}from"./ai/index.js";export*from"@lssm/module.contractspec-workspace";export{de as ALL_CHECK_CATEGORIES,Z as ALL_SETUP_TARGETS,fe as CHECK_CATEGORY_LABELS,M as RegistryClient,Q as SETUP_TARGET_LABELS,N as addToRegistry,_e as ai,x as analyzeDeps,K as analyzeIntegrity,A as buildSpec,z as cleanArtifacts,b as compareSpecs,i as createConsoleLoggerAdapter,o as createNodeAdapters,r as createNodeAiAdapter,e as createNodeFsAdapter,t as createNodeGitAdapter,n as createNodeWatcherAdapter,a as createNoopLoggerAdapter,V as createRegeneratorService,oe as deepMergeOverwrite,se as deepMergePreserve,s as detectPackageManager,S as exportGraphAsDot,j as exportOpenApi,q as filterIssuesBySeverity,J as filterIssuesByType,H as findAllConfigFiles,c as findPackageRoot,l as findWorkspaceRoot,pe as formatCheckResult,me as formatDoctorSummary,ce as formatJson,U as formatWorkspaceInfo,$ as generateAgentsMd,ee as generateClaudeMcpConfig,te as generateContractsrcConfig,ne as generateCursorMcpConfig,re as generateCursorRules,X as generateMermaidDiagram,ie as generateVscodeSettings,Y as getAllSpecs,D as getApiKey,ae as getClaudeDesktopConfigPath,C as getContractNode,u as getExecCommand,W as getExtendedWorkspaceInfo,w as getGraphStats,d as getInstallCommand,f as getPackageName,p as getRunCommand,m as getWorkspaceInfo,h as getWorkspacePackages,T as groupSpecsByType,g as isMonorepo,P as listFromRegistry,E as listSpecs,O as loadWorkspaceConfig,G as mergeMonorepoConfigs,k as mergeWorkspaceConfig,F as resolveRegistryUrl,he as runDoctor,ue as runSetup,B as runTests,le as safeParseJson,I as searchRegistry,L as syncSpecs,ge as templates,y as validateImplementationFiles,_ as validateSpec,v as validateSpecs,R as watchSpecs};
1
+ import{createNodeFsAdapter as e}from"./adapters/fs.js";import{createNodeGitAdapter as t}from"./adapters/git.js";import{createNodeWatcherAdapter as n}from"./adapters/watcher.js";import{createNodeAiAdapter as r}from"./adapters/ai.js";import{createConsoleLoggerAdapter as i,createNoopLoggerAdapter as a}from"./adapters/logger.js";import{createNodeAdapters as o}from"./adapters/factory.js";import{detectPackageManager as s,findPackageRoot as c,findWorkspaceRoot as l,getExecCommand as u,getInstallCommand as d,getPackageName as f,getRunCommand as p,getWorkspaceInfo as m,getWorkspacePackages as h,isMonorepo as g}from"./adapters/workspace.js";import"./adapters/index.js";import{validateSpec as _,validateSpecs as v}from"./services/validate.js";import{validateImplementationFiles as y}from"./services/validate-implementation.js";import{compareSpecs as b}from"./services/diff.js";import{analyzeDeps as x,exportGraphAsDot as S,getContractNode as C,getGraphStats as w}from"./services/deps.js";import{groupSpecsByType as T,listSpecs as E}from"./services/list.js";import{getApiKey as D,loadWorkspaceConfig as O,mergeWorkspaceConfig as k}from"./services/config.js";import{buildSpec as A}from"./services/build.js";import{exportOpenApi as j}from"./services/openapi.js";import{RegistryClient as M,addToRegistry as N,listFromRegistry as P,resolveRegistryUrl as F,searchRegistry as I}from"./services/registry.js";import{syncSpecs as L}from"./services/sync.js";import{watchSpecs as R}from"./services/watch.js";import{cleanArtifacts as z}from"./services/clean.js";import{runTests as B}from"./services/test.js";import{createRegeneratorService as V}from"./services/regenerator.js";import{findAllConfigFiles as H,formatWorkspaceInfo as U,getExtendedWorkspaceInfo as W,mergeMonorepoConfigs as G}from"./services/workspace-info.js";import{analyzeIntegrity as K,filterIssuesBySeverity as q,filterIssuesByType as J,getAllSpecs as Y}from"./services/integrity.js";import{generateMermaidDiagram as X}from"./services/integrity-diagram.js";import{ALL_SETUP_TARGETS as Z,SETUP_TARGET_LABELS as Q}from"./services/setup/types.js";import{generateAgentsMd as $,generateClaudeMcpConfig as ee,generateContractsrcConfig as te,generateCursorMcpConfig as ne,generateCursorRules as re,generateVscodeSettings as ie,getClaudeDesktopConfigPath as ae}from"./services/setup/config-generators.js";import{deepMergeOverwrite as oe,deepMergePreserve as se,formatJson as ce,safeParseJson as le}from"./services/setup/file-merger.js";import{runSetup as ue}from"./services/setup/setup-service.js";import{ALL_CHECK_CATEGORIES as de,CHECK_CATEGORY_LABELS as fe}from"./services/doctor/types.js";import{formatCheckResult as pe,formatDoctorSummary as me,runDoctor as he}from"./services/doctor/doctor-service.js";import{ALL_CI_CHECK_CATEGORIES as ge,CI_CHECK_CATEGORY_LABELS as _e}from"./services/ci-check/types.js";import{runCIChecks as ve}from"./services/ci-check/ci-check-service.js";import{ClaudeCodeAdapter as ye,claudeCodeAdapter as be}from"./services/agent-guide/adapters/claude-code.js";import{CursorCLIAdapter as xe,cursorCLIAdapter as Se}from"./services/agent-guide/adapters/cursor-cli.js";import{GenericMCPAdapter as Ce,genericMCPAdapter as we}from"./services/agent-guide/adapters/generic-mcp.js";import{agentAdapters as Te,getAgentAdapter as Ee,listAgentTypes as De}from"./services/agent-guide/adapters/index.js";import{AgentGuideService as Oe,agentGuideService as ke,createAgentGuideService as Ae}from"./services/agent-guide/agent-guide-service.js";import{verifyStructure as je}from"./services/verify/structure-verifier.js";import{verifyBehavior as Me}from"./services/verify/behavior-verifier.js";import{createQuickAIReview as Ne,verifyWithAI as Pe}from"./services/verify/ai-verifier.js";import{VerifyService as Fe,createVerifyService as Ie,verifyService as Le}from"./services/verify/verify-service.js";import"./services/index.js";import{formatters_exports as Re}from"./formatters/index.js";import{templates_exports as ze}from"./templates/index.js";import{ai_exports as Be}from"./ai/index.js";export*from"@lssm/module.contractspec-workspace";export{de as ALL_CHECK_CATEGORIES,ge as ALL_CI_CHECK_CATEGORIES,Z as ALL_SETUP_TARGETS,Oe as AgentGuideService,fe as CHECK_CATEGORY_LABELS,_e as CI_CHECK_CATEGORY_LABELS,ye as ClaudeCodeAdapter,xe as CursorCLIAdapter,Ce as GenericMCPAdapter,M as RegistryClient,Q as SETUP_TARGET_LABELS,Fe as VerifyService,N as addToRegistry,Te as agentAdapters,ke as agentGuideService,Be as ai,x as analyzeDeps,K as analyzeIntegrity,A as buildSpec,be as claudeCodeAdapter,z as cleanArtifacts,b as compareSpecs,Ae as createAgentGuideService,i as createConsoleLoggerAdapter,o as createNodeAdapters,r as createNodeAiAdapter,e as createNodeFsAdapter,t as createNodeGitAdapter,n as createNodeWatcherAdapter,a as createNoopLoggerAdapter,Ne as createQuickAIReview,V as createRegeneratorService,Ie as createVerifyService,Se as cursorCLIAdapter,oe as deepMergeOverwrite,se as deepMergePreserve,s as detectPackageManager,S as exportGraphAsDot,j as exportOpenApi,q as filterIssuesBySeverity,J as filterIssuesByType,H as findAllConfigFiles,c as findPackageRoot,l as findWorkspaceRoot,pe as formatCheckResult,me as formatDoctorSummary,ce as formatJson,U as formatWorkspaceInfo,Re as formatters,$ as generateAgentsMd,ee as generateClaudeMcpConfig,te as generateContractsrcConfig,ne as generateCursorMcpConfig,re as generateCursorRules,X as generateMermaidDiagram,ie as generateVscodeSettings,we as genericMCPAdapter,Ee as getAgentAdapter,Y as getAllSpecs,D as getApiKey,ae as getClaudeDesktopConfigPath,C as getContractNode,u as getExecCommand,W as getExtendedWorkspaceInfo,w as getGraphStats,d as getInstallCommand,f as getPackageName,p as getRunCommand,m as getWorkspaceInfo,h as getWorkspacePackages,T as groupSpecsByType,g as isMonorepo,De as listAgentTypes,P as listFromRegistry,E as listSpecs,O as loadWorkspaceConfig,G as mergeMonorepoConfigs,k as mergeWorkspaceConfig,F as resolveRegistryUrl,ve as runCIChecks,he as runDoctor,ue as runSetup,B as runTests,le as safeParseJson,I as searchRegistry,L as syncSpecs,ze as templates,y as validateImplementationFiles,_ as validateSpec,v as validateSpecs,Me as verifyBehavior,Le as verifyService,je as verifyStructure,Pe as verifyWithAI,R as watchSpecs};
@@ -0,0 +1,3 @@
1
+ import{AGENT_SYSTEM_PROMPTS as e}from"@lssm/lib.contracts/llm";var t=class{agentType=`claude-code`;formatPlan(t){let n=[];if(n.push(`# Implement: ${t.target.name}.v${t.target.version}`),n.push(``),n.push(`## Context`),n.push(``),n.push(`**Goal:** ${t.context.goal}`),n.push(``),n.push(`**Description:** ${t.context.description}`),n.push(``),t.context.background&&(n.push(`**Background:**`),n.push(t.context.background),n.push(``)),n.push(`## Specification`),n.push(``),n.push(t.specMarkdown),n.push(``),t.fileStructure.length>0){n.push(`## Files to Create/Modify`),n.push(``);for(let e of t.fileStructure){let t=e.type===`create`?`📝`:`âœī¸`;n.push(`${t} \`${e.path}\``),n.push(` ${e.purpose}`),n.push(``)}}n.push(`## Implementation Steps`),n.push(``);for(let e of t.steps){n.push(`### ${e.order}. ${e.title}`),n.push(``),n.push(e.description),n.push(``),n.push(`**Acceptance Criteria:**`);for(let t of e.acceptanceCriteria)n.push(`- [ ] ${t}`);n.push(``)}if(t.constraints.policy.length>0||t.constraints.security.length>0||t.constraints.pii.length>0){if(n.push(`## Constraints`),n.push(``),t.constraints.policy.length>0){n.push(`### Policy`);for(let e of t.constraints.policy)n.push(`- ${e}`);n.push(``)}if(t.constraints.security.length>0){n.push(`### Security`);for(let e of t.constraints.security)n.push(`- âš ī¸ ${e}`);n.push(``)}if(t.constraints.pii.length>0){n.push(`### PII Handling`),n.push(`The following fields contain personally identifiable information:`);for(let e of t.constraints.pii)n.push(`- \`${e}\``);n.push(``)}}n.push(`## Verification Checklist`),n.push(``),n.push(`Before submitting, verify:`);for(let e of t.verificationChecklist)n.push(`- [ ] ${e}`);return n.push(``),n.push(`## Instructions`),n.push(``),n.push(`1. Implement each step in order`),n.push("2. Use TypeScript with strict typing (no `any`)"),n.push(`3. Include JSDoc comments for public APIs`),n.push(`4. Handle all error cases defined in the spec`),n.push(`5. Emit events as specified`),n.push(`6. Mark checklist items as you complete them`),n.push(``),{agent:`claude-code`,systemPrompt:e[`claude-code`],taskPrompt:n.join(`
2
+ `)}}generateConfig(e){let t=[];return t.push(`# ContractSpec Implementation Context`),t.push(``),t.push(`This codebase uses ContractSpec for spec-first development.`),t.push(``),t.push(`## Spec Details`),t.push(``),t.push(`- **Name:** ${e.meta.name}`),t.push(`- **Version:** ${e.meta.version}`),t.push(`- **Kind:** ${e.meta.kind}`),t.push(`- **Stability:** ${e.meta.stability}`),t.push(``),t.push(`## Implementation Requirements`),t.push(``),t.push(`1. Match input/output types exactly`),t.push(`2. Handle all defined error cases`),t.push(`3. Emit events as specified`),t.push(`4. Respect policy constraints`),t.push(``),t.join(`
3
+ `)}parseOutput(e){let t=e.match(/```(?:typescript|ts|tsx)?\n([\s\S]*?)\n```/);if(t?.[1])return{code:t[1]};let n=[];for(let t of[/error:\s*(.+)/gi,/failed:\s*(.+)/gi,/cannot\s+(.+)/gi]){let r=e.matchAll(t);for(let e of r)e[1]&&n.push(e[1])}return n.length>0?{errors:n}:{code:e}}};const n=new t;export{t as ClaudeCodeAdapter,n as claudeCodeAdapter};
@@ -0,0 +1,3 @@
1
+ import{AGENT_SYSTEM_PROMPTS as e,specToFullMarkdown as t}from"@lssm/lib.contracts/llm";var n=class{agentType=`cursor-cli`;formatPlan(t){let n=[];if(n.push(`# ${t.target.name}.v${t.target.version}`),n.push(``),n.push(`> ${t.context.goal}`),n.push(``),t.fileStructure.length>0){n.push(`## Files`),n.push(``);for(let e of t.fileStructure)n.push(`- ${e.type}: \`${e.path}\` - ${e.purpose}`);n.push(``)}n.push(`## Spec`),n.push(``),n.push(t.specMarkdown),n.push(``),n.push(`## Steps`),n.push(``);for(let e of t.steps)n.push(`${e.order}. **${e.title}**: ${e.description}`);n.push(``);let r=[...t.constraints.policy,...t.constraints.security.map(e=>`âš ī¸ ${e}`)];if(r.length>0){n.push(`## Constraints`),n.push(``);for(let e of r)n.push(`- ${e}`);n.push(``)}return t.constraints.pii.length>0&&(n.push(`## PII Fields`),n.push(``),n.push(`Handle carefully: ${t.constraints.pii.map(e=>`\`${e}\``).join(`, `)}`),n.push(``)),{agent:`cursor-cli`,systemPrompt:e[`cursor-cli`],taskPrompt:n.join(`
2
+ `)}}generateConfig(e){let t=e.meta,n=[];if(n.push(`---`),n.push(`description: Implementation rules for ${t.name}.v${t.version}`),n.push(`globs: ["**/${t.name.replace(/\./g,`/`)}/**"]`),n.push(`alwaysApply: false`),n.push(`---`),n.push(``),n.push(`# ${t.name} Implementation Rules`),n.push(``),n.push(`This ${t.kind} operation must follow the ContractSpec specification.`),n.push(``),n.push(`## Goal`),n.push(``),n.push(t.goal),n.push(``),n.push(`## Requirements`),n.push(``),n.push(`1. Input/output types MUST match the spec schema exactly`),n.push(`2. All error cases MUST be handled`),e.sideEffects?.emits?.length&&n.push(`3. Events MUST be emitted as specified`),n.push(`4. Auth level: ${e.policy.auth}`),e.policy.idempotent!==void 0&&n.push(`5. Idempotency: ${e.policy.idempotent}`),n.push(``),e.io.errors&&Object.keys(e.io.errors).length>0){n.push(`## Error Cases`),n.push(``);for(let[t,r]of Object.entries(e.io.errors))n.push(`- \`${t}\` (HTTP ${r.http??400}): ${r.when}`);n.push(``)}if(e.sideEffects?.emits?.length){n.push(`## Events to Emit`),n.push(``);for(let t of e.sideEffects.emits)`ref`in t?n.push(`- \`${t.ref.name}.v${t.ref.version}\`: ${t.when}`):n.push(`- \`${t.name}.v${t.version}\`: ${t.when}`);n.push(``)}if(e.policy.pii?.length){n.push(`## PII Handling`),n.push(``),n.push(`These fields contain PII and must be handled with care:`);for(let t of e.policy.pii)n.push(`- \`${t}\``);n.push(``)}if(e.acceptance?.scenarios?.length){n.push(`## Acceptance Scenarios`),n.push(``);for(let t of e.acceptance.scenarios)n.push(`### ${t.name}`),n.push(`- Given: ${t.given.join(`; `)}`),n.push(`- When: ${t.when.join(`; `)}`),n.push(`- Then: ${t.then.join(`; `)}`),n.push(``)}return n.join(`
3
+ `)}getCursorRulesPath(e){return`.cursor/rules/${e.meta.name.replace(/\./g,`-`)}.mdc`}parseOutput(e){let t=e.match(/```(?:typescript|ts|tsx|javascript|js)?\n([\s\S]*?)\n```/);return t?.[1]?{code:t[1]}:{code:e}}};const r=new n;export{n as CursorCLIAdapter,r as cursorCLIAdapter};
@@ -0,0 +1,3 @@
1
+ import{AGENT_SYSTEM_PROMPTS as e}from"@lssm/lib.contracts/llm";var t=class{agentType=`generic-mcp`;formatPlan(t){let n=[];if(n.push(`# Implementation Task: ${t.target.name}.v${t.target.version}`),n.push(``),n.push(`## Task`),n.push(``),n.push(`Implement the ${t.target.type} \`${t.target.name}\` version ${t.target.version}.`),n.push(``),n.push(`## Context`),n.push(``),n.push(`**Goal:** ${t.context.goal}`),n.push(``),n.push(`**Description:** ${t.context.description}`),n.push(``),t.context.background&&(n.push(`**Background:**`),n.push(``),n.push(t.context.background),n.push(``)),n.push(`## Specification`),n.push(``),n.push(t.specMarkdown),n.push(``),t.fileStructure.length>0){n.push(`## Files`),n.push(``),n.push(`| Path | Action | Purpose |`),n.push(`|------|--------|---------|`);for(let e of t.fileStructure)n.push(`| \`${e.path}\` | ${e.type} | ${e.purpose} |`);n.push(``)}n.push(`## Implementation Steps`),n.push(``);for(let e of t.steps)if(n.push(`### Step ${e.order}: ${e.title}`),n.push(``),n.push(e.description),n.push(``),e.acceptanceCriteria.length>0){n.push(`**Acceptance Criteria:**`),n.push(``);for(let t of e.acceptanceCriteria)n.push(`- ${t}`);n.push(``)}if(n.push(`## Constraints`),n.push(``),t.constraints.policy.length>0){n.push(`**Policy:**`);for(let e of t.constraints.policy)n.push(`- ${e}`);n.push(``)}if(t.constraints.security.length>0){n.push(`**Security:**`);for(let e of t.constraints.security)n.push(`- ${e}`);n.push(``)}if(t.constraints.pii.length>0){n.push(`**PII Fields (handle with care):**`);for(let e of t.constraints.pii)n.push(`- \`${e}\``);n.push(``)}n.push(`## Verification`),n.push(``),n.push(`After implementation, verify:`),n.push(``);for(let e of t.verificationChecklist)n.push(`- [ ] ${e}`);return n.push(``),{agent:`generic-mcp`,systemPrompt:e[`generic-mcp`],taskPrompt:n.join(`
2
+ `)}}formatAsResource(e){return{uri:`spec://${e.target.name}/v${e.target.version}/plan`,mimeType:`application/json`,data:JSON.stringify({target:e.target,context:e.context,fileStructure:e.fileStructure,steps:e.steps,constraints:e.constraints,verificationChecklist:e.verificationChecklist},null,2)}}formatAsPromptMessage(e){return{role:`user`,content:{type:`text`,text:this.formatPlan(e).taskPrompt}}}generateConfig(e){let t=e.meta,n=[];return n.push(`# ${t.name} v${t.version}`),n.push(``),n.push(`**Type:** ${t.kind}`),n.push(`**Stability:** ${t.stability}`),n.push(``),n.push(`## Goal`),n.push(``),n.push(t.goal),n.push(``),n.push(`## Description`),n.push(``),n.push(t.description),n.push(``),n.join(`
3
+ `)}parseOutput(e){let t=e.match(/```(?:typescript|ts|tsx|javascript|js|python|go|rust)?\n([\s\S]*?)\n```/);if(t?.[1])return{code:t[1]};try{let t=JSON.parse(e);if(typeof t.code==`string`)return{code:t.code};if(typeof t.errors==`object`)return{errors:Array.isArray(t.errors)?t.errors:[String(t.errors)]}}catch{}return{code:e}}};const n=new t;export{t as GenericMCPAdapter,n as genericMCPAdapter};
@@ -0,0 +1 @@
1
+ import{ClaudeCodeAdapter as e,claudeCodeAdapter as t}from"./claude-code.js";import{CursorCLIAdapter as n,cursorCLIAdapter as r}from"./cursor-cli.js";import{GenericMCPAdapter as i,genericMCPAdapter as a}from"./generic-mcp.js";const o={"claude-code":t,"cursor-cli":r,"generic-mcp":a};function s(e){let t=o[e];if(!t)throw Error(`Unknown agent type: ${e}`);return t}function c(){return Object.keys(o)}export{o as agentAdapters,s as getAgentAdapter,c as listAgentTypes};
@@ -0,0 +1 @@
1
+ import{getAgentAdapter as e,listAgentTypes as t}from"./adapters/index.js";import{featureToMarkdown as n,generateImplementationPlan as r,specToAgentPrompt as i,specToFullMarkdown as a}from"@lssm/lib.contracts/llm";const o={defaultAgent:`generic-mcp`,verbose:!1};var s=class{config;constructor(e={}){this.config={...o,...e}}generateGuide(t,n={}){let i=e(n.agent??this.config.defaultAgent),o=r(t,{projectRoot:this.config.projectRoot,existingFiles:n.targetPath?[n.targetPath]:void 0});return{plan:o,prompt:i.formatPlan(o),markdown:a(t)}}generateFeatureGuide(t,i,a={}){let o=e(a.agent??this.config.defaultAgent),s=t.operations?.[0],c=s?i.specs?.getSpec(s.name,s.version):void 0,l;c?(l=r(c,{projectRoot:this.config.projectRoot}),l.target={type:`feature`,name:t.meta.key,version:1},l.context.goal=t.meta.description??l.context.goal):l={target:{type:`feature`,name:t.meta.key,version:1},context:{goal:t.meta.description??`Implement feature ${t.meta.key}`,description:t.meta.title??t.meta.key,background:``},specMarkdown:n(t,i),fileStructure:[],steps:[{order:1,title:`Implement Feature`,description:`Implement the ${t.meta.key} feature`,acceptanceCriteria:[]}],constraints:{policy:[],security:[],pii:[]},verificationChecklist:[]},l.specMarkdown=n(t,i,{format:`full`,includeRelatedSpecs:!0,includeRelatedEvents:!0,includeRelatedPresentations:!0}),t.operations?.length&&(l.steps=t.operations.map((e,t)=>({order:t+1,title:`Implement ${e.name}`,description:`Implement operation ${e.name}.v${e.version}`,acceptanceCriteria:[`Operation ${e.name} works as specified`]})));let u=o.formatPlan(l),d=n(t,i);return{plan:l,prompt:u,markdown:d}}generateAgentConfig(t,n){return e(n??this.config.defaultAgent).generateConfig?.(t)}exportForAgent(e,t,n=`implement`,r){return i(e,{taskType:n,existingCode:r})}listAgentTypes(){return t()}getDefaultAgent(){return this.config.defaultAgent}configure(e){this.config={...this.config,...e}}};function c(e){return new s(e)}const l=new s;export{s as AgentGuideService,l as agentGuideService,c as createAgentGuideService};
@@ -0,0 +1 @@
1
+ import{ClaudeCodeAdapter as e,claudeCodeAdapter as t}from"./adapters/claude-code.js";import{CursorCLIAdapter as n,cursorCLIAdapter as r}from"./adapters/cursor-cli.js";import{GenericMCPAdapter as i,genericMCPAdapter as a}from"./adapters/generic-mcp.js";import{agentAdapters as o,getAgentAdapter as s,listAgentTypes as c}from"./adapters/index.js";import{AgentGuideService as l,agentGuideService as u,createAgentGuideService as d}from"./agent-guide-service.js";
@@ -0,0 +1 @@
1
+ import{validateImplementationFiles as e}from"../validate-implementation.js";import{analyzeDeps as t}from"../deps.js";import{loadWorkspaceConfig as n}from"../config.js";import{analyzeIntegrity as r}from"../integrity.js";import{runDoctor as i}from"../doctor/doctor-service.js";import{isFeatureFile as a,validateSpecStructure as o}from"@lssm/module.contractspec-workspace";async function s(e,t={}){let n=Date.now(),{fs:r,logger:i}=e,o=[],s=[],_=c(t);i.info(`Starting CI checks...`,{checks:_});let v=(await r.glob({pattern:t.pattern})).filter(e=>!a(e)&&!e.includes(`.test.`)&&!e.includes(`.spec.`));if(_.includes(`structure`)){let t=Date.now(),n=await l(e,v);o.push(...n),s.push(h(`structure`,n,Date.now()-t))}if(_.includes(`integrity`)){let n=Date.now(),r=await u(e,t);o.push(...r),s.push(h(`integrity`,r,Date.now()-n))}if(_.includes(`deps`)){let n=Date.now(),r=await d(e,t);o.push(...r),s.push(h(`deps`,r,Date.now()-n))}if(_.includes(`doctor`)){let n=Date.now(),r=await f(e,t);o.push(...r),s.push(h(`doctor`,r,Date.now()-n))}if(_.includes(`handlers`)||t.checkHandlers){let t=Date.now(),n=await p(e,v);o.push(...n),s.push(h(`handlers`,n,Date.now()-t))}if(_.includes(`tests`)||t.checkTests){let t=Date.now(),n=await m(e,v);o.push(...n),s.push(h(`tests`,n,Date.now()-t))}let y=o.filter(e=>e.severity===`error`).length,b=o.filter(e=>e.severity===`warning`).length,x=o.filter(e=>e.severity===`note`).length,S=t.failOnWarnings?y===0&&b===0:y===0,C=await g(r),w={success:S,totalErrors:y,totalWarnings:b,totalNotes:x,issues:o,categories:s,durationMs:Date.now()-n,timestamp:new Date().toISOString(),...C};return i.info(`CI checks complete`,{success:S,errors:y,warnings:b,durationMs:w.durationMs}),w}function c(e){let t=[`structure`,`integrity`,`deps`,`doctor`];return e.checkHandlers&&t.push(`handlers`),e.checkTests&&t.push(`tests`),e.checks&&e.checks.length>0?e.checks:e.skip&&e.skip.length>0?t.filter(t=>!e.skip?.includes(t)):t}async function l(e,t){let{fs:n}=e,r=[];for(let e of t){let t=o(await n.readFile(e),n.basename(e));for(let n of t.errors)r.push({ruleId:`spec-structure-error`,severity:`error`,message:n,category:`structure`,file:e});for(let n of t.warnings)r.push({ruleId:`spec-structure-warning`,severity:`warning`,message:n,category:`structure`,file:e})}return r}async function u(e,t){let n=[],i=await r(e,{pattern:t.pattern,all:!0});for(let e of i.issues)n.push({ruleId:`integrity-${e.type}`,severity:e.severity===`error`?`error`:`warning`,message:e.message,category:`integrity`,file:e.file,context:{specName:e.specName,specType:e.specType,featureKey:e.featureKey,ref:e.ref}});return n}async function d(e,n){let r=[],i=await t(e,{pattern:n.pattern});for(let e of i.cycles)r.push({ruleId:`deps-circular`,severity:`error`,message:`Circular dependency detected: ${e.join(` → `)}`,category:`deps`,context:{cycle:e}});for(let e of i.missing)for(let t of e.missing)r.push({ruleId:`deps-missing`,severity:`error`,message:`Missing dependency: ${e.contract} requires ${t}`,category:`deps`,context:{contract:e.contract,missing:t}});return r}async function f(e,t){let n=[],r=await i(e,{workspaceRoot:t.workspaceRoot??process.cwd(),skipAi:!0,categories:[`cli`,`config`,`deps`,`workspace`]});for(let e of r.checks)e.status===`fail`?n.push({ruleId:`doctor-${e.category}-${e.name.toLowerCase().replace(/\s+/g,`-`)}`,severity:`error`,message:`${e.name}: ${e.message}`,category:`doctor`,context:{details:e.details}}):e.status===`warn`&&n.push({ruleId:`doctor-${e.category}-${e.name.toLowerCase().replace(/\s+/g,`-`)}`,severity:`warning`,message:`${e.name}: ${e.message}`,category:`doctor`,context:{details:e.details}});return n}async function p(t,r){let{fs:i}=t,a=[],o=await n(i);for(let t of r){if(!t.includes(`.contracts.`))continue;let n=await e(t,{fs:i},o,{checkHandlers:!0,outputDir:o.outputDir});for(let e of n.errors)a.push({ruleId:`handler-missing`,severity:`warning`,message:e,category:`handlers`,file:t});for(let e of n.warnings)a.push({ruleId:`handler-warning`,severity:`warning`,message:e,category:`handlers`,file:t})}return a}async function m(t,r){let{fs:i}=t,a=[],o=await n(i);for(let t of r){if(!t.includes(`.contracts.`))continue;let n=await e(t,{fs:i},o,{checkTests:!0,outputDir:o.outputDir});for(let e of n.errors)a.push({ruleId:`test-missing`,severity:`warning`,message:e,category:`tests`,file:t});for(let e of n.warnings)a.push({ruleId:`test-warning`,severity:`warning`,message:e,category:`tests`,file:t})}return a}function h(e,t,n){let r={structure:`Spec Structure Validation`,integrity:`Contract Integrity Analysis`,deps:`Dependency Analysis`,doctor:`Installation Health`,handlers:`Handler Implementation`,tests:`Test Coverage`},i=t.filter(e=>e.severity===`error`).length,a=t.filter(e=>e.severity===`warning`).length,o=t.filter(e=>e.severity===`note`).length;return{category:e,label:r[e],errors:i,warnings:a,notes:o,passed:i===0,durationMs:n}}async function g(e){try{let t=`.git/HEAD`;if(!await e.exists(t))return{};let n=await e.readFile(t),r=n.match(/^ref: (.+)$/m);if(r){let t=r[1]?.replace(`refs/heads/`,``),n=`.git/${r[1]}`;return await e.exists(n)?{commitSha:(await e.readFile(n)).trim(),branch:t}:{branch:t}}return{commitSha:n.trim()}}catch{return{}}}export{s as runCIChecks};
@@ -0,0 +1 @@
1
+ import{ALL_CI_CHECK_CATEGORIES as e,CI_CHECK_CATEGORY_LABELS as t}from"./types.js";import{runCIChecks as n}from"./ci-check-service.js";
@@ -0,0 +1 @@
1
+ const e=[`structure`,`integrity`,`deps`,`doctor`,`handlers`,`tests`],t={structure:`Spec Structure Validation`,integrity:`Contract Integrity Analysis`,deps:`Dependency Analysis`,doctor:`Installation Health`,handlers:`Handler Implementation`,tests:`Test Coverage`};export{e as ALL_CI_CHECK_CATEGORIES,t as CI_CHECK_CATEGORY_LABELS};
@@ -1 +1 @@
1
- import{detectPackageManager as e,findPackageRoot as t,findWorkspaceRoot as n,getWorkspaceInfo as r}from"../adapters/workspace.js";import{validateSpec as i,validateSpecs as a}from"./validate.js";import{validateImplementationFiles as o}from"./validate-implementation.js";import{compareSpecs as s}from"./diff.js";import{analyzeDeps as c,exportGraphAsDot as l,getContractNode as u,getGraphStats as d}from"./deps.js";import{groupSpecsByType as f,listSpecs as p}from"./list.js";import{getApiKey as m,loadWorkspaceConfig as h,mergeWorkspaceConfig as g}from"./config.js";import{buildSpec as _}from"./build.js";import{exportOpenApi as v}from"./openapi.js";import{RegistryClient as y,addToRegistry as b,listFromRegistry as x,resolveRegistryUrl as S,searchRegistry as C}from"./registry.js";import{syncSpecs as w}from"./sync.js";import{watchSpecs as T}from"./watch.js";import{cleanArtifacts as E}from"./clean.js";import{runTests as D}from"./test.js";import{createRegeneratorService as O}from"./regenerator.js";import{findAllConfigFiles as k,formatWorkspaceInfo as A,getExtendedWorkspaceInfo as j,mergeMonorepoConfigs as M}from"./workspace-info.js";import{analyzeIntegrity as N,filterIssuesBySeverity as P,filterIssuesByType as F,getAllSpecs as I}from"./integrity.js";import{generateMermaidDiagram as L}from"./integrity-diagram.js";import{ALL_SETUP_TARGETS as R,SETUP_TARGET_LABELS as z}from"./setup/types.js";import{generateAgentsMd as B,generateClaudeMcpConfig as V,generateContractsrcConfig as H,generateCursorMcpConfig as U,generateCursorRules as W,generateVscodeSettings as G,getClaudeDesktopConfigPath as K}from"./setup/config-generators.js";import{deepMergeOverwrite as q,deepMergePreserve as J,formatJson as Y,safeParseJson as X}from"./setup/file-merger.js";import{runSetup as Z}from"./setup/setup-service.js";import"./setup/index.js";import{ALL_CHECK_CATEGORIES as Q,CHECK_CATEGORY_LABELS as $}from"./doctor/types.js";import{formatCheckResult as ee,formatDoctorSummary as te,runDoctor as ne}from"./doctor/doctor-service.js";import"./doctor/index.js";
1
+ import{detectPackageManager as e,findPackageRoot as t,findWorkspaceRoot as n,getWorkspaceInfo as r}from"../adapters/workspace.js";import{validateSpec as i,validateSpecs as a}from"./validate.js";import{validateImplementationFiles as o}from"./validate-implementation.js";import{compareSpecs as s}from"./diff.js";import{analyzeDeps as c,exportGraphAsDot as l,getContractNode as u,getGraphStats as d}from"./deps.js";import{groupSpecsByType as f,listSpecs as p}from"./list.js";import{getApiKey as m,loadWorkspaceConfig as h,mergeWorkspaceConfig as g}from"./config.js";import{buildSpec as _}from"./build.js";import{exportOpenApi as v}from"./openapi.js";import{RegistryClient as y,addToRegistry as b,listFromRegistry as x,resolveRegistryUrl as S,searchRegistry as C}from"./registry.js";import{syncSpecs as w}from"./sync.js";import{watchSpecs as T}from"./watch.js";import{cleanArtifacts as E}from"./clean.js";import{runTests as D}from"./test.js";import{createRegeneratorService as O}from"./regenerator.js";import{findAllConfigFiles as k,formatWorkspaceInfo as A,getExtendedWorkspaceInfo as j,mergeMonorepoConfigs as M}from"./workspace-info.js";import{analyzeIntegrity as N,filterIssuesBySeverity as P,filterIssuesByType as F,getAllSpecs as I}from"./integrity.js";import{generateMermaidDiagram as L}from"./integrity-diagram.js";import{ALL_SETUP_TARGETS as R,SETUP_TARGET_LABELS as z}from"./setup/types.js";import{generateAgentsMd as B,generateClaudeMcpConfig as V,generateContractsrcConfig as H,generateCursorMcpConfig as U,generateCursorRules as W,generateVscodeSettings as G,getClaudeDesktopConfigPath as K}from"./setup/config-generators.js";import{deepMergeOverwrite as q,deepMergePreserve as J,formatJson as Y,safeParseJson as X}from"./setup/file-merger.js";import{runSetup as Z}from"./setup/setup-service.js";import"./setup/index.js";import{ALL_CHECK_CATEGORIES as Q,CHECK_CATEGORY_LABELS as $}from"./doctor/types.js";import{formatCheckResult as ee,formatDoctorSummary as te,runDoctor as ne}from"./doctor/doctor-service.js";import"./doctor/index.js";import{ALL_CI_CHECK_CATEGORIES as re,CI_CHECK_CATEGORY_LABELS as ie}from"./ci-check/types.js";import{runCIChecks as ae}from"./ci-check/ci-check-service.js";import"./ci-check/index.js";import{ClaudeCodeAdapter as oe,claudeCodeAdapter as se}from"./agent-guide/adapters/claude-code.js";import{CursorCLIAdapter as ce,cursorCLIAdapter as le}from"./agent-guide/adapters/cursor-cli.js";import{GenericMCPAdapter as ue,genericMCPAdapter as de}from"./agent-guide/adapters/generic-mcp.js";import{agentAdapters as fe,getAgentAdapter as pe,listAgentTypes as me}from"./agent-guide/adapters/index.js";import{AgentGuideService as he,agentGuideService as ge,createAgentGuideService as _e}from"./agent-guide/agent-guide-service.js";import"./agent-guide/index.js";import{verifyStructure as ve}from"./verify/structure-verifier.js";import{verifyBehavior as ye}from"./verify/behavior-verifier.js";import{createQuickAIReview as be,verifyWithAI as xe}from"./verify/ai-verifier.js";import{VerifyService as Se,createVerifyService as Ce,verifyService as we}from"./verify/verify-service.js";import"./verify/index.js";
@@ -1 +1 @@
1
- import{isFeatureFile as e,scanFeatureSource as t,scanSpecSource as n}from"@lssm/module.contractspec-workspace";function r(e,t){return`${e}.v${t}`}function i(){return{operations:new Map,events:new Map,presentations:new Map,capabilities:new Map,workflows:new Map,dataViews:new Map,forms:new Map,migrations:new Map,experiments:new Map,integrations:new Map,knowledge:new Map,telemetry:new Map,appConfigs:new Map,policies:new Map,testSpecs:new Map}}function a(e,t){return{operation:e.operations,event:e.events,presentation:e.presentations,capability:e.capabilities,workflow:e.workflows,"data-view":e.dataViews,form:e.forms,migration:e.migrations,experiment:e.experiments,integration:e.integrations,knowledge:e.knowledge,telemetry:e.telemetry,"app-config":e.appConfigs,policy:e.policies,"test-spec":e.testSpecs}[t]}async function o(o,s={}){let{fs:c,logger:l}=o;l.info(`Starting integrity analysis...`,{options:s});let u=await c.glob({pattern:s.pattern}),d=i(),f=[],p=[];for(let i of u){let o=await c.readFile(i);if(e(i)){let e=t(o,i);f.push(e)}else{let e=n(o,i);if(e.specType!==`unknown`&&e.specType!==`feature`){let t=a(d,e.specType);if(t&&e.name&&e.version!==void 0){let n=r(e.name,e.version);t.set(n,{name:e.name,version:e.version,file:e.filePath,type:e.specType,stability:e.stability})}}}}let m=s.featureKey?f.filter(e=>e.key===s.featureKey):f,h=new Set;for(let e of m){for(let t of e.operations){let n=r(t.name,t.version);h.add(`operation:${n}`),d.operations.has(n)||p.push({severity:`error`,type:`unresolved-ref`,message:`Operation ${t.name}.v${t.version} not found`,file:e.filePath,featureKey:e.key,specType:`operation`,ref:t})}for(let t of e.events){let n=r(t.name,t.version);h.add(`event:${n}`),d.events.has(n)||p.push({severity:`error`,type:`unresolved-ref`,message:`Event ${t.name}.v${t.version} not found`,file:e.filePath,featureKey:e.key,specType:`event`,ref:t})}for(let t of e.presentations){let n=r(t.name,t.version);h.add(`presentation:${n}`),d.presentations.has(n)||p.push({severity:`error`,type:`unresolved-ref`,message:`Presentation ${t.name}.v${t.version} not found`,file:e.filePath,featureKey:e.key,specType:`presentation`,ref:t})}for(let t of e.experiments){let n=r(t.name,t.version);h.add(`experiment:${n}`),d.experiments.has(n)||p.push({severity:`error`,type:`unresolved-ref`,message:`Experiment ${t.name}.v${t.version} not found`,file:e.filePath,featureKey:e.key,specType:`experiment`,ref:t})}for(let t of e.capabilities.provides){let n=r(t.name,t.version);h.add(`capability:${n}`),d.capabilities.has(n)||p.push({severity:`warning`,type:`unresolved-ref`,message:`Provided capability ${t.name}.v${t.version} not found`,file:e.filePath,featureKey:e.key,specType:`capability`,ref:t})}for(let t of e.capabilities.requires){let e=r(t.name,t.version);h.add(`capability:${e}`)}for(let t of e.opToPresentationLinks){let n=r(t.op.name,t.op.version),i=r(t.pres.name,t.pres.version);d.operations.has(n)||p.push({severity:`error`,type:`broken-link`,message:`Linked operation ${t.op.name}.v${t.op.version} not found`,file:e.filePath,featureKey:e.key,specType:`operation`,ref:t.op}),d.presentations.has(i)||p.push({severity:`error`,type:`broken-link`,message:`Linked presentation ${t.pres.name}.v${t.pres.version} not found`,file:e.filePath,featureKey:e.key,specType:`presentation`,ref:t.pres})}}let g=[],_=[`operation`,`event`,`presentation`,`experiment`];for(let e of _){let t=a(d,e);if(t)for(let[n,r]of t)h.has(`${e}:${n}`)||(g.push(r),p.push({severity:`warning`,type:`orphaned`,message:`${e} ${r.name}.v${r.version} is not linked to any feature`,file:r.file,specName:r.name,specType:r.type}))}let v={};for(let e of _){let t=a(d,e);if(!t)continue;let n=t.size,r=0;for(let n of t.keys())h.has(`${e}:${n}`)&&r++;v[e]={total:n,covered:r,orphaned:n-r}}let y=Object.values(v).reduce((e,t)=>e+t.total,0),b=Object.values(v).reduce((e,t)=>e+t.covered,0),x={total:y,linkedToFeature:b,orphaned:y-b,byType:v},S=!p.some(e=>e.severity===`error`);return l.info(`Integrity analysis complete`,{features:f.length,totalSpecs:y,orphaned:g.length,issues:p.length,healthy:S}),{inventory:d,features:m,coverage:x,issues:p,orphanedSpecs:g,healthy:S}}function s(e){let t=[];for(let n of Object.values(e))for(let e of n.values())t.push(e);return t}function c(e,t){return e.filter(e=>e.type===t)}function l(e,t){return e.filter(e=>e.severity===t)}export{o as analyzeIntegrity,l as filterIssuesBySeverity,c as filterIssuesByType,s as getAllSpecs};
1
+ import{isFeatureFile as e,scanAllSpecsFromSource as t,scanFeatureSource as n}from"@lssm/module.contractspec-workspace";function r(e,t){return`${e}.v${t}`}function i(){return{operations:new Map,events:new Map,presentations:new Map,capabilities:new Map,workflows:new Map,dataViews:new Map,forms:new Map,migrations:new Map,experiments:new Map,integrations:new Map,knowledge:new Map,telemetry:new Map,appConfigs:new Map,policies:new Map,testSpecs:new Map}}function a(e,t){return{operation:e.operations,event:e.events,presentation:e.presentations,capability:e.capabilities,workflow:e.workflows,"data-view":e.dataViews,form:e.forms,migration:e.migrations,experiment:e.experiments,integration:e.integrations,knowledge:e.knowledge,telemetry:e.telemetry,"app-config":e.appConfigs,policy:e.policies,"test-spec":e.testSpecs}[t]}async function o(o,s={}){let{fs:c,logger:l}=o;l.info(`Starting integrity analysis...`,{options:s});let u=await c.glob({pattern:s.pattern}),d=i(),f=[],p=[];for(let i of u){let o=await c.readFile(i);if(e(i)){let e=n(o,i);f.push(e)}else{let e=t(o,i);for(let t of e)if(t.specType!==`unknown`&&t.specType!==`feature`){let e=a(d,t.specType);if(e&&t.name&&t.version!==void 0){let n=r(t.name,t.version);e.set(n,{name:t.name,version:t.version,file:t.filePath,type:t.specType,stability:t.stability})}}}}let m=s.featureKey?f.filter(e=>e.key===s.featureKey):f,h=new Set;for(let e of m){for(let t of e.operations){let n=r(t.name,t.version);h.add(`operation:${n}`),d.operations.has(n)||p.push({severity:`error`,type:`unresolved-ref`,message:`Operation ${t.name}.v${t.version} not found`,file:e.filePath,featureKey:e.key,specType:`operation`,ref:t})}for(let t of e.events){let n=r(t.name,t.version);h.add(`event:${n}`),d.events.has(n)||p.push({severity:`error`,type:`unresolved-ref`,message:`Event ${t.name}.v${t.version} not found`,file:e.filePath,featureKey:e.key,specType:`event`,ref:t})}for(let t of e.presentations){let n=r(t.name,t.version);h.add(`presentation:${n}`),d.presentations.has(n)||p.push({severity:`error`,type:`unresolved-ref`,message:`Presentation ${t.name}.v${t.version} not found`,file:e.filePath,featureKey:e.key,specType:`presentation`,ref:t})}for(let t of e.experiments){let n=r(t.name,t.version);h.add(`experiment:${n}`),d.experiments.has(n)||p.push({severity:`error`,type:`unresolved-ref`,message:`Experiment ${t.name}.v${t.version} not found`,file:e.filePath,featureKey:e.key,specType:`experiment`,ref:t})}for(let t of e.capabilities.provides){let n=r(t.name,t.version);h.add(`capability:${n}`),d.capabilities.has(n)||p.push({severity:`warning`,type:`unresolved-ref`,message:`Provided capability ${t.name}.v${t.version} not found`,file:e.filePath,featureKey:e.key,specType:`capability`,ref:t})}for(let t of e.capabilities.requires){let e=r(t.name,t.version);h.add(`capability:${e}`)}for(let t of e.opToPresentationLinks){let n=r(t.op.name,t.op.version),i=r(t.pres.name,t.pres.version);d.operations.has(n)||p.push({severity:`error`,type:`broken-link`,message:`Linked operation ${t.op.name}.v${t.op.version} not found`,file:e.filePath,featureKey:e.key,specType:`operation`,ref:t.op}),d.presentations.has(i)||p.push({severity:`error`,type:`broken-link`,message:`Linked presentation ${t.pres.name}.v${t.pres.version} not found`,file:e.filePath,featureKey:e.key,specType:`presentation`,ref:t.pres})}}let g=[],_=[`operation`,`event`,`presentation`,`experiment`];for(let e of _){let t=a(d,e);if(t)for(let[n,r]of t)h.has(`${e}:${n}`)||(g.push(r),p.push({severity:`warning`,type:`orphaned`,message:`${e} ${r.name}.v${r.version} is not linked to any feature`,file:r.file,specName:r.name,specType:r.type}))}let v={};for(let e of _){let t=a(d,e);if(!t)continue;let n=t.size,r=0;for(let n of t.keys())h.has(`${e}:${n}`)&&r++;v[e]={total:n,covered:r,orphaned:n-r}}let y=Object.values(v).reduce((e,t)=>e+t.total,0),b=Object.values(v).reduce((e,t)=>e+t.covered,0),x={total:y,linkedToFeature:b,orphaned:y-b,byType:v},S=!p.some(e=>e.severity===`error`);return l.info(`Integrity analysis complete`,{features:f.length,totalSpecs:y,orphaned:g.length,issues:p.length,healthy:S}),{inventory:d,features:m,coverage:x,issues:p,orphanedSpecs:g,healthy:S}}function s(e){let t=[];for(let n of Object.values(e))for(let e of n.values())t.push(e);return t}function c(e,t){return e.filter(e=>e.type===t)}function l(e,t){return e.filter(e=>e.severity===t)}export{o as analyzeIntegrity,l as filterIssuesBySeverity,c as filterIssuesByType,s as getAllSpecs};
@@ -0,0 +1,28 @@
1
+ import{generateVerificationPrompt as e,specToFullMarkdown as t}from"@lssm/lib.contracts/llm";function n(e){let t=e.match(/```json\n?([\s\S]*?)\n?```/);if(t?.[1])try{let n=JSON.parse(t[1]);return{compliant:n.passed??!1,confidence:(n.score??0)/100,findings:(n.issues??[]).map(e=>({category:String(e.category??`semantic`),severity:String(e.severity??`warning`),message:String(e.message??``),location:e.location?String(e.location):void 0,suggestion:e.suggestion?String(e.suggestion):void 0})),rawResponse:e}}catch{}let n=[],r=e.split(`
2
+ `),i=`info`;for(let e of r){let t=e.toLowerCase();t.includes(`error`)||t.includes(`critical`)?i=`error`:t.includes(`warning`)||t.includes(`should`)?i=`warning`:(t.includes(`info`)||t.includes(`note`))&&(i=`info`);let r=e.match(/^[-*â€ĸ]\s*(.+)$/),a=e.match(/^\d+\.\s*(.+)$/);if(r||a){let e=r?.[1]??a?.[1]??``;e.length>10&&n.push({category:`semantic`,severity:i,message:e})}}let a=n.some(e=>e.severity===`error`);return{compliant:!a,confidence:a?.3:n.length===0?.9:.7,findings:n,rawResponse:e}}async function r(e,t){if(!t.aiApiKey)return`\`\`\`json
3
+ {
4
+ "passed": true,
5
+ "score": 50,
6
+ "compliance": {
7
+ "inputTypes": { "match": true, "issues": [] },
8
+ "outputTypes": { "match": true, "issues": [] },
9
+ "errorHandling": { "coverage": "unknown", "missing": [] },
10
+ "eventEmission": { "correct": true, "issues": [] },
11
+ "policyCompliance": { "auth": true, "rateLimit": true, "pii": true }
12
+ },
13
+ "scenarios": [],
14
+ "issues": [
15
+ { "severity": "info", "category": "semantic", "message": "AI verification not available - configure AI API key for full analysis" }
16
+ ],
17
+ "summary": "AI verification skipped - no API key configured. Structure and behavior checks have been performed."
18
+ }
19
+ \`\`\``;try{let n=t.aiProvider??`anthropic`;if(n===`anthropic`){let{anthropic:t}=await import(`@ai-sdk/anthropic`),{generateText:n}=await import(`ai`);return(await n({model:t(`claude-3-5-sonnet-20241022`),prompt:e,system:`You are an expert code reviewer analyzing implementation compliance with specifications. Respond with structured JSON.`})).text}else if(n===`openai`){let{openai:t}=await import(`@ai-sdk/openai`),{generateText:n}=await import(`ai`);return(await n({model:t(`gpt-4o`),prompt:e,system:`You are an expert code reviewer analyzing implementation compliance with specifications. Respond with structured JSON.`})).text}throw Error(`Unknown AI provider: ${n}`)}catch(e){return`\`\`\`json
20
+ {
21
+ "passed": false,
22
+ "score": 0,
23
+ "issues": [
24
+ { "severity": "error", "category": "semantic", "message": "AI verification failed: ${e instanceof Error?e.message:`Unknown error`}" }
25
+ ],
26
+ "summary": "AI verification encountered an error"
27
+ }
28
+ \`\`\``}}async function i(t,i={}){let{spec:a,implementationCode:o,implementationPath:s}=t,c=Date.now(),l=n(await r(e(a,o).taskPrompt,i)),u=l.findings.map(e=>({severity:e.severity,category:`semantic`,message:e.message,location:e.location?{file:e.location}:s?{file:s}:void 0,suggestion:e.suggestion})),d=Math.round(l.confidence*100),f=l.compliant;return{tier:`ai_review`,passed:f,score:d,issues:u,suggestions:l.findings.filter(e=>e.suggestion).map(e=>e.suggestion),coverage:{scenarios:{total:0,covered:0},errors:{total:0,handled:0},fields:{total:1,implemented:f?1:0}},meta:{specName:a.meta.name,specVersion:a.meta.version,implementationPath:s??`unknown`,verifiedAt:new Date().toISOString(),duration:Date.now()-c}}}function a(e){let{spec:t,implementationCode:n,implementationPath:r}=e,i=Date.now(),a=[];n.includes(`console.log`)&&a.push({severity:`warning`,category:`semantic`,message:`Console.log statements found - consider using proper logging`,suggestion:`Use a structured logger instead of console.log`}),(n.includes(`// TODO`)||n.includes(`// FIXME`))&&a.push({severity:`info`,category:`semantic`,message:`TODO/FIXME comments found - implementation may be incomplete`,suggestion:`Address TODO items before finalizing implementation`}),t.policy.auth!==`anonymous`&&!n.includes(`auth`)&&a.push({severity:`warning`,category:`semantic`,message:`Spec requires ${t.policy.auth} auth but no auth check found`,suggestion:`Add authentication check at the handler entry point`});let o=a.filter(e=>e.severity===`error`).length===0?80:40,s=a.filter(e=>e.severity===`error`).length===0;return{tier:`ai_review`,passed:s,score:o,issues:a,suggestions:a.filter(e=>e.suggestion).map(e=>e.suggestion),coverage:{scenarios:{total:0,covered:0},errors:{total:0,handled:0},fields:{total:1,implemented:s?1:0}},meta:{specName:t.meta.name,specVersion:t.meta.version,implementationPath:r??`unknown`,verifiedAt:new Date().toISOString(),duration:Date.now()-i}}}export{a as createQuickAIReview,i as verifyWithAI};
@@ -0,0 +1 @@
1
+ import{isEmitDeclRef as e}from"@lssm/lib.contracts/spec";function t(e,t){let n=[...t.given,...t.when,...t.then].flatMap(e=>e.toLowerCase().split(/\s+/).filter(e=>e.length>3)),r=e.toLowerCase(),i=n.filter(e=>r.includes(e)),a=n.length>0?i.length/n.length:0,o=t.name.toLowerCase().replace(/\s+/g,``),s=r.includes(o)||r.includes(`test('${t.name.toLowerCase()}'`)||r.includes(`it('${t.name.toLowerCase()}'`)||r.includes(`describe('${t.name.toLowerCase()}'`),c=a>=.3||s;return{name:t.name,type:`scenario`,passed:c,expected:`Given: ${t.given.join(`; `)}; When: ${t.when.join(`; `)}; Then: ${t.then.join(`; `)}`,details:c?void 0:`Scenario keywords not found in implementation (${Math.round(a*100)}% coverage)`}}function n(e,t){let n=JSON.stringify(t.input),i=JSON.stringify(t.output),a=r(t.input),o=r(t.output),s=e.toLowerCase(),c=a.filter(e=>s.includes(e.toLowerCase())),l=o.filter(e=>s.includes(e.toLowerCase())),u=((a.length>0?c.length/a.length:1)+(o.length>0?l.length/o.length:1))/2,d=u>=.2;return{name:t.name,type:`example`,passed:d,expected:`Input: ${n.slice(0,100)}...; Output: ${i.slice(0,100)}...`,details:d?void 0:`Example values not found in implementation (${Math.round(u*100)}% coverage)`}}function r(e){let t=[];function n(e){typeof e==`string`&&e.length>2?t.push(e):Array.isArray(e)?e.forEach(n):e&&typeof e==`object`&&Object.values(e).forEach(n)}return n(e),t}function i(e,t,n){let r=e.includes(t),i=n.http?e.includes(String(n.http)):!0,a=n.when.toLowerCase().split(/\s+/).filter(e=>e.length>3),o=e.toLowerCase(),s=a.filter(e=>o.includes(e)),c=a.length>0?s.length/a.length:1,l=r&&(i||c>=.3);return{name:`Error: ${t}`,type:`error`,passed:l,expected:`When: ${n.when}; Return: ${t} (HTTP ${n.http??400})`,details:l?void 0:r?`Error condition not properly implemented`:`Error code '${t}' not found in implementation`}}function a(t,n){let r=n.sideEffects?.emits??[],i=[];for(let n of r){let r=e(n)?n.ref.name:n.name,a=n.when,o=a.toLowerCase().split(/\s+/).filter(e=>e.length>3),s=t.toLowerCase(),c=s.includes(r.toLowerCase()),l=o.filter(e=>s.includes(e)),u=o.length>0?l.length/o.length:1;i.push({name:`Event: ${r}`,type:`scenario`,passed:c&&u>=.3,expected:`Emit ${r} when: ${a}`,details:c?u<.3?`Event condition not properly implemented`:void 0:`Event '${r}' not found`})}return i}function o(e,t){if(t.policy.idempotent===void 0||!t.policy.idempotent)return null;let n=[`idempotency`,`idempotent`,`already exists`,`upsert`,`on conflict`,`if not exists`,`dedupe`,`duplicate`],r=e.toLowerCase(),i=n.some(e=>r.includes(e));return{name:`Idempotency`,type:`scenario`,passed:i,expected:`Operation should be idempotent (safe to retry)`,details:i?void 0:`No idempotency pattern found for idempotent operation`}}function s(e){let{spec:r,implementationCode:s,implementationPath:c}=e,l=Date.now(),u=[];for(let e of r.acceptance?.scenarios??[])u.push(t(s,e));for(let e of r.acceptance?.examples??[])u.push(n(s,e));for(let[e,t]of Object.entries(r.io.errors??{}))u.push(i(s,e,t));u.push(...a(s,r));let d=o(s,r);d&&u.push(d);let f=u.filter(e=>!e.passed).map(e=>({severity:e.type===`error`?`error`:`warning`,category:e.type===`scenario`||e.type===`example`?`scenario`:`error_handling`,message:e.details??`${e.type} not covered: ${e.name}`,location:c?{file:c}:void 0,suggestion:e.expected?`Expected: ${e.expected}`:void 0})),p=u.filter(e=>e.type===`scenario`),m=u.filter(e=>e.type===`error`),h=u.filter(e=>e.passed).length,g=u.length>0?Math.round(h/u.length*100):100;return{tier:`behavior`,passed:f.filter(e=>e.severity===`error`).length===0,score:g,issues:f,suggestions:u.filter(e=>!e.passed&&e.expected).map(e=>`${e.name}: ${e.expected}`),coverage:{scenarios:{total:p.length,covered:p.filter(e=>e.passed).length},errors:{total:m.length,handled:m.filter(e=>e.passed).length},fields:{total:u.length,implemented:h}},meta:{specName:r.meta.name,specVersion:r.meta.version,implementationPath:c??`unknown`,verifiedAt:new Date().toISOString(),duration:Date.now()-l}}}export{s as verifyBehavior};
@@ -0,0 +1 @@
1
+ import{verifyStructure as e}from"./structure-verifier.js";import{verifyBehavior as t}from"./behavior-verifier.js";import{createQuickAIReview as n,verifyWithAI as r}from"./ai-verifier.js";import{VerifyService as i,createVerifyService as a,verifyService as o}from"./verify-service.js";
@@ -0,0 +1,2 @@
1
+ import{isEmitDeclRef as e}from"@lssm/lib.contracts/spec";function t(e){let t=/export\s+(async\s+)?function\s+\w+/.test(e)||/export\s+const\s+\w+\s*=\s*(async\s*)?\(/.test(e)||/export\s+default\s+(async\s+)?function/.test(e)||/export\s+\{\s*\w+/.test(e);return{name:`handler_export`,passed:t,details:t?void 0:`No exported handler function found`,suggestion:`Export a function that handles the operation: export async function handle(...) { }`}}function n(e){let t=e.includes(`from '@lssm/lib.contracts'`)||e.includes(`from "@lssm/lib.contracts"`);return{name:`contracts_import`,passed:t,details:t?void 0:`Missing import from @lssm/lib.contracts`,suggestion:`Add: import { ... } from '@lssm/lib.contracts';`}}function r(e,t){if(!(t.io.input!==null||t.io.output!==null))return{name:`schema_import`,passed:!0};let n=e.includes(`from '@lssm/lib.schema'`)||e.includes(`from "@lssm/lib.schema"`);return{name:`schema_import`,passed:n,details:n?void 0:`Missing import from @lssm/lib.schema`,suggestion:`Add: import { ... } from '@lssm/lib.schema';`}}function i(e){let t=/:\s*any\b|as\s+any\b|<any>/,n=e.split(`
2
+ `),r=[];for(let e=0;e<n.length;e++){let i=n[e]??``;i.trim().startsWith(`//`)||i.trim().startsWith(`*`)||t.test(i)&&r.push(e+1)}return{name:`no_any_type`,passed:r.length===0,details:r.length>0?`Found 'any' type on lines: ${r.slice(0,5).join(`, `)}${r.length>5?`...`:``}`:void 0,suggestion:`Replace any with proper types from the spec schema`}}function a(e,t){let n=t.io.errors;if(!n||Object.keys(n).length===0)return{name:`error_handling`,passed:!0};let r=Object.keys(n),i=[];for(let t of r)e.includes(t)||i.push(t);return{name:`error_handling`,passed:i.length===0,details:i.length>0?`Missing error handling for: ${i.join(`, `)}`:void 0,suggestion:`Implement handlers for all error cases defined in the spec`}}function o(t,n){let r=n.sideEffects?.emits;if(!r||r.length===0)return{name:`event_emission`,passed:!0};let i=t.includes(`emit(`)||t.includes(`.emit(`)||t.includes(`publish(`)||t.includes(`.publish(`)||t.includes(`dispatchEvent`)||t.includes(`eventBus`),a=r.map(t=>e(t)?t.ref.name:t.name),o=a.filter(e=>t.includes(e));return{name:`event_emission`,passed:i&&o.length>0,details:i?o.length===0?`Events not referenced: ${a.join(`, `)}`:void 0:`No event emission pattern found`,suggestion:`Emit events as specified in sideEffects.emits`}}function s(e,t){if(!t.io.input)return{name:`input_validation`,passed:!0};let n=e.includes(`.parse(`)||e.includes(`.safeParse(`)||e.includes(`validate(`)||e.includes(`.validate(`)||e.includes(`schema.`)||e.includes(`zodSchema`)||e.includes(`.getZod()`);return{name:`input_validation`,passed:n,details:n?void 0:`No input validation pattern found`,suggestion:`Validate input using the schema: schema.parse(input) or schema.safeParse(input)`}}function c(e,t){let n=/export\s+(const\s+\w+\s*=\s*)?async/.test(e)||/async\s+function/.test(e);return t.meta.kind===`command`?{name:`async_patterns`,passed:n,details:n?void 0:`Handler should be async for command operations`,suggestion:`Make the handler function async: export async function handle(...)`}:{name:`async_patterns`,passed:!0}}function l(e){let{spec:l,implementationCode:u,implementationPath:d}=e,f=Date.now(),p=[t(u),n(u),r(u,l),i(u),a(u,l),o(u,l),s(u,l),c(u,l)],m=p.filter(e=>!e.passed).map(e=>({severity:e.name===`no_any_type`?`warning`:`error`,category:e.name.includes(`import`)?`import`:e.name.includes(`export`)?`export`:`type`,message:e.details??`Check failed: ${e.name}`,location:d?{file:d}:void 0,suggestion:e.suggestion})),h=p.filter(e=>e.passed).length,g=Math.round(h/p.length*100),_=m.filter(e=>e.severity===`error`).length===0,v=p.filter(e=>!e.passed&&e.suggestion).map(e=>e.suggestion),y=Object.keys(l.io.errors??{}).length;return{tier:`structure`,passed:_,score:g,issues:m,suggestions:v,coverage:{scenarios:{total:0,covered:0},errors:{total:y,handled:p.find(e=>e.name===`error_handling`)?.passed?y:0},fields:{total:p.length,implemented:h}},meta:{specName:l.meta.name,specVersion:l.meta.version,implementationPath:d??`unknown`,verifiedAt:new Date().toISOString(),duration:Date.now()-f}}}export{l as verifyStructure};
@@ -0,0 +1,3 @@
1
+ import{verifyStructure as e}from"./structure-verifier.js";import{verifyBehavior as t}from"./behavior-verifier.js";import{createQuickAIReview as n,verifyWithAI as r}from"./ai-verifier.js";const i={verbose:!1},a=[`structure`,`behavior`,`ai_review`];var o=class{config;constructor(e={}){this.config={...i,...e}}async verify(i,o,s={}){let c=Date.now(),l=new Map,u=[],d={spec:i,implementationCode:o},f=s.tiers??[`structure`,`behavior`];for(let i of a){if(!f.includes(i))continue;let a;switch(i){case`structure`:a=e(d);break;case`behavior`:a=t(d);break;case`ai_review`:a=this.config.aiApiKey?await r(d,this.config):n(d);break;default:continue}if(l.set(i,a),u.push(...a.issues),s.failFast&&!a.passed)break}let p=Array.from(l.values());return{passed:p.every(e=>e.passed),score:p.length>0?Math.round(p.reduce((e,t)=>e+t.score,0)/p.length):100,reports:l,allIssues:u,summary:this.generateSummary(p,u),duration:Date.now()-c}}verifyStructure(t,n,r){return e({spec:t,implementationCode:n,implementationPath:r})}verifyBehavior(e,n,r){return t({spec:e,implementationCode:n,implementationPath:r})}async verifyAI(e,t,i){let a={spec:e,implementationCode:t,implementationPath:i};return this.config.aiApiKey?r(a,this.config):n(a)}quickVerify(t,n){return e({spec:t,implementationCode:n})}generateSummary(e,t){let n=[],r=e.every(e=>e.passed),i=e.length>0?Math.round(e.reduce((e,t)=>e+t.score,0)/e.length):100;n.push(r?`✓ Verification passed`:`✗ Verification failed`),n.push(`Score: ${i}/100`),n.push(``);for(let t of e){let e=t.passed?`✓`:`✗`;n.push(`${e} ${t.tier}: ${t.score}/100`)}n.push(``);let a=t.filter(e=>e.severity===`error`),o=t.filter(e=>e.severity===`warning`),s=t.filter(e=>e.severity===`info`);return a.length>0&&n.push(`Errors: ${a.length}`),o.length>0&&n.push(`Warnings: ${o.length}`),s.length>0&&n.push(`Info: ${s.length}`),n.join(`
2
+ `)}formatAsMarkdown(e){let t=[];t.push(`# Verification Report`),t.push(``),t.push(`**Status:** ${e.passed?`✓ Passed`:`✗ Failed`}`),t.push(`**Score:** ${e.score}/100`),t.push(`**Duration:** ${e.duration}ms`),t.push(``);for(let[n,r]of e.reports){if(t.push(`## ${this.formatTierName(n)}`),t.push(``),t.push(`**Status:** ${r.passed?`✓ Passed`:`✗ Failed`}`),t.push(`**Score:** ${r.score}/100`),t.push(``),r.issues.length>0){t.push(`### Issues`),t.push(``);for(let e of r.issues){let n=e.severity===`error`?`❌`:e.severity===`warning`?`âš ī¸`:`â„šī¸`;t.push(`${n} **${e.category}**: ${e.message}`),e.suggestion&&t.push(` - Suggestion: ${e.suggestion}`)}t.push(``)}r.coverage.scenarios.total>0&&t.push(`**Scenarios:** ${r.coverage.scenarios.covered}/${r.coverage.scenarios.total}`),r.coverage.errors.total>0&&t.push(`**Errors handled:** ${r.coverage.errors.handled}/${r.coverage.errors.total}`),t.push(``)}let n=Array.from(e.reports.values()).flatMap(e=>e.suggestions);if(n.length>0){t.push(`## Suggestions`),t.push(``);for(let e of n.slice(0,10))t.push(`- ${e}`);n.length>10&&t.push(`- ... and ${n.length-10} more`),t.push(``)}return t.join(`
3
+ `)}formatTierName(e){switch(e){case`structure`:return`Tier 1: Structure`;case`behavior`:return`Tier 2: Behavior`;case`ai_review`:return`Tier 3: AI Review`;default:return e}}configure(e){this.config={...this.config,...e}}};function s(e){return new o(e)}const c=new o;export{o as VerifyService,s as createVerifyService,c as verifyService};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lssm/bundle.contractspec-workspace",
3
- "version": "0.0.0-canary-20251216035145",
3
+ "version": "0.0.0-canary-20251216062412",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",