@a-company/paradigm 5.21.2 → 5.23.0
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/dist/{ambient-HYZR42NX.js → ambient-WEPHBAJD.js} +1 -1
- package/dist/chunk-27FBCZX6.js +2 -0
- package/dist/chunk-4DVT5IEY.js +2 -0
- package/dist/{chunk-UONPO7SC.js → chunk-CSXVL2U7.js} +1 -1
- package/dist/{chunk-SWFC4HD7.js → chunk-FSOI3CCD.js} +305 -125
- package/dist/{chunk-ET5XJTSX.js → chunk-RMOALQJN.js} +1 -1
- package/dist/{compliance-33HC4D5Z.js → compliance-TSXLXADI.js} +2 -2
- package/dist/{config-schema-HR7LDEQ6.js → config-schema-GUQY2QN7.js} +1 -1
- package/dist/{context-audit-RSSRX6XC.js → context-audit-XRPT3OU2.js} +1 -1
- package/dist/doctor-HMQBF2WK.js +2 -0
- package/dist/enforcement-MKFUH4TE.js +2 -0
- package/dist/enforcement-TJOXPSTJ.js +2 -0
- package/dist/{habits-4J2KRYUL.js → habits-LX5IWCZM.js} +1 -1
- package/dist/{hooks-JQKA3TUG.js → hooks-E7HQQ57M.js} +1 -1
- package/dist/index.js +7 -7
- package/dist/mcp.js +76 -53
- package/dist/{migrate-ZLITTMVW.js → migrate-WT56YYAM.js} +1 -1
- package/dist/{project-type-SURTOIG7.js → project-type-4Y6CESWP.js} +1 -1
- package/dist/{roster-FLRZ5J42.js → roster-K2QILE7K.js} +1 -1
- package/dist/shift-TDOYQKR4.js +11 -0
- package/package.json +1 -1
- package/dist/chunk-AGVAHVUA.js +0 -2
- package/dist/doctor-PA7EAJO2.js +0 -2
- package/dist/shift-QZC77Y5O.js +0 -11
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import {b as b$2}from'./chunk-PUBB7LIT.js';import {f as f$1,n,g,h}from'./chunk-2QO33NYK.js';import {c,b as b$1,d,a}from'./chunk-5TAVYPOV.js';import*as f from'fs';import*as b from'path';import*as P from'js-yaml';import*as Q from'os';var vt={};c(vt,{getJournalStats:()=>ne,loadAllJournalEntries:()=>ee,loadJournalEntries:()=>O,loadJournalEntry:()=>te,recordJournalEntry:()=>z});function G(n){let t=process.env.HOME||process.env.USERPROFILE||"";return b.join(t,".paradigm","agents",n,"journal")}function Zt(){let n=new Date,t=n.toISOString().slice(0,10),e=n.toISOString().slice(11,19).replace(/:/g,""),o=String(Math.floor(Math.random()*999)+1).padStart(3,"0");return `LJ-${t}-${e}-${o}`}function z(n,t){let e=new Date,o=Zt(),i={id:o,agent:n,timestamp:e.toISOString(),...t},r=G(n);f.mkdirSync(r,{recursive:true});let s=b.join(r,`${o}.yaml`);return f.writeFileSync(s,P.dump(i,{lineWidth:120,noRefs:true}),"utf8"),i}function O(n,t){let e=G(n);if(!f.existsSync(e))return [];let o=[],i=f.readdirSync(e).filter(s=>s.endsWith(".yaml"));for(let s of i)try{let a=f.readFileSync(b.join(e,s),"utf8"),c=P.load(a);c&&c.id&&o.push(c);}catch{}let r=o;return t?.trigger&&(r=r.filter(s=>s.trigger===t.trigger)),t?.project&&(r=r.filter(s=>s.project===t.project)),t?.transferable!==void 0&&(r=r.filter(s=>s.transferable===t.transferable)),t?.tag&&(r=r.filter(s=>s.tags?.some(a=>a.startsWith(t.tag)))),t?.dateFrom&&(r=r.filter(s=>s.timestamp>=t.dateFrom)),t?.dateTo&&(r=r.filter(s=>s.timestamp<=t.dateTo)),r.sort((s,a)=>a.timestamp.localeCompare(s.timestamp)),t?.limit&&(r=r.slice(0,t.limit)),r}function te(n,t){let e=G(n),o=b.join(e,`${t}.yaml`);if(!f.existsSync(o))return null;let i=f.readFileSync(o,"utf8");return P.load(i)}function ee(n){let t=process.env.HOME||process.env.USERPROFILE||"",e=b.join(t,".paradigm","agents");if(!f.existsSync(e))return [];let o=[],i=f.readdirSync(e,{withFileTypes:true}).filter(r=>r.isDirectory());for(let r of i){if(n?.agent&&r.name!==n.agent)continue;let s=O(r.name,n);o.push(...s);}return o.sort((r,s)=>s.timestamp.localeCompare(r.timestamp)),n?.limit?o.slice(0,n.limit):o}function ne(n){let t=O(n),e={},o={},i=0;for(let r of t)e[r.trigger]=(e[r.trigger]||0)+1,o[r.project]=(o[r.project]||0)+1,r.transferable&&i++;return {total:t.length,byTrigger:e,byProject:o,transferableCount:i,recentInsights:t.slice(0,5).map(r=>({id:r.id,trigger:r.trigger,insight:r.insight.slice(0,200),timestamp:r.timestamp}))}}var K=b$1(()=>{});var Dt={};c(Dt,{addNotebookEntry:()=>xt,incrementApplied:()=>se,loadNotebookEntries:()=>Et,promoteFromLore:()=>ie,searchNotebooks:()=>re});function Et(n,t,e){let o=new Map,i=b.join(V,n);jt(i,o);let r=b.join(t,Y,n);jt(r,o);let s=Array.from(o.values());if(e?.concepts&&e.concepts.length>0){let a=new Set(e.concepts.map(c=>c.toLowerCase()));s=s.filter(c=>c.concepts.some(d=>a.has(d.toLowerCase())));}if(e?.tags&&e.tags.length>0){let a=new Set(e.tags.map(c=>c.toLowerCase()));s=s.filter(c=>c.tags.some(d=>a.has(d.toLowerCase())));}return s.sort((a,c)=>c.appliedCount-a.appliedCount)}function jt(n,t){if(f.existsSync(n))try{let e=f.readdirSync(n).filter(o=>o.startsWith(oe)&&o.endsWith(X));for(let o of e)try{let i=f.readFileSync(b.join(n,o),"utf-8"),r=P.load(i);r?.id&&t.set(r.id,r);}catch{}}catch{}}function re(n,t,e){let o=Et(n,e),i=t.toLowerCase();return o.filter(r=>r.context.toLowerCase().includes(i)||r.snippet.toLowerCase().includes(i)||r.concepts.some(s=>s.toLowerCase().includes(i))||r.tags.some(s=>s.toLowerCase().includes(i)))}function xt(n,t,e,o){let i=new Date().toISOString(),r=(t.concepts[0]||"entry").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""),s=Date.now().toString(36),a=`nb-${r}-${s}`,c={...t,id:a,appliedCount:0,created:i,updated:i},d=e==="global"?b.join(V,n):b.join(o||process.cwd(),Y,n);f.existsSync(d)||f.mkdirSync(d,{recursive:true});let u=`${a}${X}`,l=b.join(d,u),m=P.dump(c,{lineWidth:120,noRefs:true,sortKeys:false});return f.writeFileSync(l,m,"utf-8"),{entry:c,filePath:l}}async function ie(n,t,e,o="global"){let{loadLoreEntry:i}=await import('./lore-loader-XY5MZRR2.js'),r=await i(e,t);if(!r)return null;let s=[];if(r.symbols_touched)for(let d of r.symbols_touched){let u=d.replace(/^[#$^!~]/,"").toLowerCase();s.push(u);}let a=r.summary||"";r.body&&(a+=`
|
|
3
3
|
|
|
4
4
|
`+r.body);let c={source:"lore",loreEntryId:t,originProject:b.basename(e),createdBy:n};return xt(n,{context:r.title||`Promoted from ${t}`,snippet:a,provenance:c,confidence:r.confidence??.7,concepts:s,tags:r.tags||[]},o,e)}function se(n,t,e){let o=b.join(e,Y,n),i=b.join(V,n);for(let r of [o,i]){let s=b.join(r,`${t}${X}`);if(f.existsSync(s))try{let a=f.readFileSync(s,"utf-8"),c=P.load(a);if(c)return c.appliedCount=(c.appliedCount||0)+1,c.updated=new Date().toISOString(),f.writeFileSync(s,P.dump(c,{lineWidth:120,noRefs:!0,sortKeys:!1}),"utf-8"),!0}catch{}}return false}var V,Y,oe,X,Rt=b$1(()=>{V=b.join(Q.homedir(),".paradigm","notebooks"),Y=".paradigm/notebooks",oe="nb-",X=".yaml";});var ft=".paradigm/events",zt="stream.jsonl",I=1e3,N=[];function gt(n){return b.join(n,ft,zt)}function Kt(){let n=Date.now(),t=Math.floor(Math.random()*9999).toString().padStart(4,"0");return `ev-${n}-${t}`}function J(n,t){let e={id:Kt(),timestamp:new Date().toISOString(),...t};N.push(e),N.length>I&&(N=N.slice(-I));try{let o=b.join(n,ft);f.mkdirSync(o,{recursive:!0});let i=gt(n);f.appendFileSync(i,JSON.stringify(e)+`
|
|
5
5
|
`,"utf8"),Vt(i);}catch{}return e}function Vt(n){try{if(f.statSync(n).size>512*1024){let o=f.readFileSync(n,"utf8").trim().split(`
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import*as i from'fs';import*as m from'path';import*as f from'js-yaml';var s=["purpose-coverage","purpose-exists","portal-gates","aspect-anchors","purpose-freshness","aspect-advisory","lore-required","habits-blocking","purpose-required-patterns","drift-detection","portal-compliance","graduation-tracking","orchestration-required"];var A={"purpose-coverage":"block","purpose-exists":"block","portal-gates":"block","aspect-anchors":"block","purpose-freshness":"warn","aspect-advisory":"warn","lore-required":"block","habits-blocking":"block","purpose-required-patterns":"block","drift-detection":"block","portal-compliance":"block","graduation-tracking":"warn","orchestration-required":"block"},O={"purpose-coverage":"block","purpose-exists":"warn","portal-gates":"warn","aspect-anchors":"warn","purpose-freshness":"warn","aspect-advisory":"off","lore-required":"warn","habits-blocking":"block","purpose-required-patterns":"warn","drift-detection":"warn","portal-compliance":"warn","graduation-tracking":"off","orchestration-required":"warn"},P={"purpose-coverage":"warn","purpose-exists":"off","portal-gates":"off","aspect-anchors":"off","purpose-freshness":"off","aspect-advisory":"off","lore-required":"off","habits-blocking":"warn","purpose-required-patterns":"off","drift-detection":"off","portal-compliance":"off","graduation-tracking":"off","orchestration-required":"off"},x={strict:A,balanced:O,minimal:P};function p(e){return {...x[e]}}function V(e,t){return x[e][t]}function b(e){return s.includes(e)}function E(e){return e==="block"||e==="warn"||e==="off"}function S(e){return e==="strict"||e==="balanced"||e==="minimal"}var L="balanced",j={threshold:3,detection:"git-diff",exempt:["*.md","*.yaml","*.yml",".purpose"]};function T(e){let t=m.join(e,".paradigm","config.yaml");if(!i.existsSync(t))return h();try{let n=i.readFileSync(t,"utf8"),r=f.load(n);if(!r||typeof r!="object")return h();let o=r.enforcement;if(!o||typeof o!="object")return h();let y=o.level,q=typeof y=="string"&&S(y)?y:L,v=o.checks,w={};if(v&&typeof v=="object")for(let[l,C]of Object.entries(v))b(l)&&typeof C=="string"&&E(C)&&(w[l]=C);let c=o.orchestration,d={...j};return c&&typeof c=="object"&&(typeof c.threshold=="number"&&(d.threshold=c.threshold),typeof c.detection=="string"&&(d.detection=c.detection),Array.isArray(c.exempt)&&(d.exempt=c.exempt.filter(l=>typeof l=="string"))),{level:q,checks:w,orchestration:d}}catch{return h()}}function h(){return {level:L,checks:{},orchestration:{...j}}}function _(e,t){let n=e.checks[t];return n!==void 0?n:p(e.level)[t]}function D(e){let t=p(e.level);for(let n of s){let r=e.checks[n];r!==void 0&&(t[n]=r);}return t}function k(e){let t=m.join(e,".paradigm","config.yaml");if(!i.existsSync(t))throw new Error(`Config not found: ${t}`);let n=i.readFileSync(t,"utf8"),r=f.load(n);if(!r||typeof r!="object")throw new Error("Config is not a valid YAML object");return [r,n]}function a(e,t){let n=m.join(e,".paradigm","config.yaml"),r=f.dump(t,{lineWidth:-1,noRefs:true,sortKeys:false,quotingType:"'"});i.writeFileSync(n,r,"utf8");}function g(e){return (!e.enforcement||typeof e.enforcement!="object")&&(e.enforcement={level:"balanced",checks:{}}),e.enforcement}function F(e,t){let[n]=k(e),r=g(n);r.level=t,a(e,n);}function H(e,t,n){let[r]=k(e),o=g(r);(!o.checks||typeof o.checks!="object")&&(o.checks={}),o.checks[t]=n,a(e,r);}function K(e,t){let[n]=k(e),r=g(n);r.checks&&typeof r.checks=="object"&&delete r.checks[t],a(e,n);}function M(e){let[t]=k(e),n=g(t);n.checks={},a(e,t);}function N(e){let t=m.join(e,".paradigm","config.yaml");if(!i.existsSync(t))return false;try{let n=i.readFileSync(t,"utf8"),r=f.load(n);return !r||typeof r!="object"||r.enforcement?!1:(r.enforcement={level:"balanced",checks:{},orchestration:{threshold:3,detection:"git-diff",exempt:["*.md","*.yaml","*.yml",".purpose"]}},a(e,r),!0)}catch{return false}}export{s as a,p as b,V as c,b as d,E as e,S as f,T as g,_ as h,D as i,F as j,H as k,K as l,M as m,N as n};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import*as a from'fs';import*as c from'path';import {Glob}from'glob';function s(t){let e=r=>{if(r.includes("*"))try{return new Glob(r,{cwd:t,nodir:!0}).walkSync().length>0}catch{return false}return a.existsSync(c.join(t,r))};return e("project.godot")||e("Assets/ProjectSettings")?"game":e("Package.swift")&&!e("package.json")?e("Sources/*/App")||e("**/AppDelegate.swift")?"macos-app":"ios-app":e("pubspec.yaml")?"flutter-app":e("supabase")&&(e("next.config.*")||e("vite.config.*"))?"saas-web-app":e("next.config.*")||e("vite.config.*")||e("nuxt.config.*")?"web-app":e("Dockerfile")||e("prisma")||e("drizzle.config.*")?"backend-api":e("Cargo.toml")?"rust-project":e("pyproject.toml")||e("setup.py")||e("requirements.txt")?"python-project":"generic"}var n={"saas-web-app":["advocate","architect","builder","reviewer","tester","security","documentor","designer","copywriter","performance","devops","dba","e2e","dx","seo","pm","product","sales","legal","a11y","qa","debugger","release","narrator"],"web-app":["advocate","architect","builder","reviewer","tester","security","documentor","designer","copywriter","performance","devops","e2e","seo","a11y","qa","debugger"],"backend-api":["advocate","architect","builder","reviewer","tester","security","documentor","devops","dba","performance","dx","qa","debugger","release"],"ios-app":["advocate","architect","builder","reviewer","tester","security","documentor","designer","mobile","performance","a11y","qa","debugger"],"macos-app":["advocate","architect","builder","reviewer","tester","security","documentor","designer","performance","qa","debugger"],"flutter-app":["advocate","architect","builder","reviewer","tester","security","documentor","designer","mobile","performance","a11y","debugger"],game:["advocate","architect","builder","reviewer","tester","documentor","gamedev","3d","audio","designer","performance","debugger"],"rust-project":["advocate","architect","builder","reviewer","tester","security","documentor","performance","debugger","qa"],"python-project":["advocate","architect","builder","reviewer","tester","security","documentor","performance","debugger","qa"],generic:["advocate","architect","builder","reviewer","tester","security","documentor","debugger","qa"]};export{s as a,n as b};
|
|
@@ -3,7 +3,7 @@ import {c as c$1,a as a$1}from'./chunk-HMQ5BHP2.js';import {e as e$1}from'./chun
|
|
|
3
3
|
\u{1FA7A} Paradigm Doctor
|
|
4
4
|
`)),console.log(q?c.gray(`Running context audit checks...
|
|
5
5
|
`):c.gray(`Checking Paradigm setup...
|
|
6
|
-
`)));let L=a.command("doctor").start("Running health checks");if(!q){let M=function(t){let a=[];try{let n=e.readdirSync(t,{withFileTypes:!0});for(let o of n){if(o.name==="node_modules"||o.name==="dist"||o.name===".git")continue;let m=i.join(t,o.name);o.isDirectory()?a.push(...M(m)):o.name===".purpose"&&a.push(m);}}catch{}return a};let r=i.join(l,".paradigm");if(e.existsSync(r))if(e.statSync(r).isFile())s.push({name:".paradigm",status:"warn",message:"Legacy file format (should be directory)",fix:"paradigm upgrade --all"});else {s.push({name:".paradigm/",status:"ok",message:"Directory exists"});let a=i.join(r,"config.yaml");if(e.existsSync(a))try{let d=e.readFileSync(a,"utf8");e$1(d),s.push({name:".paradigm/config.yaml",status:"ok",message:"Valid YAML"});}catch(d){s.push({name:".paradigm/config.yaml",status:"error",message:`Invalid YAML: ${d.message}`,fix:"Check YAML syntax"});}else s.push({name:".paradigm/config.yaml",status:"missing",message:"Config file not found",fix:"paradigm init --force"});let n=["logger.md","scan.md","symbols.md"],o=i.join(r,"specs");if(e.existsSync(o))for(let d of n){let w=i.join(o,d);e.existsSync(w)?s.push({name:`.paradigm/specs/${d}`,status:"ok",message:"Present"}):s.push({name:`.paradigm/specs/${d}`,status:"missing",message:"Spec file not found",fix:"paradigm upgrade --all"});}else s.push({name:".paradigm/specs/",status:"missing",message:"Specs directory not found",fix:"paradigm upgrade --all"});let m=i.join(r,"docs");e.existsSync(m)?s.push({name:".paradigm/docs/",status:"ok",message:"Directory exists"}):s.push({name:".paradigm/docs/",status:"missing",message:"Docs directory not found",fix:"paradigm upgrade --all"});let h=i.join(r,"prompts");e.existsSync(h)?s.push({name:".paradigm/prompts/",status:"ok",message:"Directory exists"}):s.push({name:".paradigm/prompts/",status:"missing",message:"Prompts directory not found",fix:"paradigm upgrade --all"});let u=i.join(r,"scan-index.json"),g=i.join(l,".paradigm-scan-index.json");if(e.existsSync(u)){let d=e.statSync(u),w=Date.now()-d.mtime.getTime(),y=Math.floor(w/(1e3*60*60));y>24?s.push({name:".paradigm/scan-index.json",status:"warn",message:`Stale (${y} hours old)`,fix:"paradigm index"}):s.push({name:".paradigm/scan-index.json",status:"ok",message:y>0?`${y} hours old`:"Fresh"});}else e.existsSync(g)?s.push({name:"scan-index",status:"warn",message:"Using legacy location",fix:"paradigm index"}):s.push({name:".paradigm/scan-index.json",status:"missing",message:"Not generated",fix:"paradigm index"});}else s.push({name:".paradigm/",status:"missing",message:"Not initialized",fix:"paradigm init"});let f=c$1(l);if(f.detected){let t=a$1(f.detected);if(t){let a=i.join(l,t.outputPath);e.existsSync(a)?s.push({name:t.outputPath,status:"ok",message:`Present (${f.detected})`}):s.push({name:t.outputPath,status:"missing",message:`Not generated for ${f.detected}`,fix:"paradigm sync"});}}let p=i.join(l,".premise");e.existsSync(p)?s.push({name:".premise",status:"ok",message:"Present"}):s.push({name:".premise",status:"missing",message:"Not found (optional)"});let j=i.join(l,".purpose");e.existsSync(j)?s.push({name:".purpose",status:"ok",message:"Present"}):s.push({name:".purpose",status:"warn",message:"Root .purpose not found",fix:"paradigm init"});let P=i.join(l,".paradigm","config.yaml");if(e.existsSync(P))try{let t=e.readFileSync(P,"utf8"),n=x.load(t)?.["purpose-required"];if(n&&Array.isArray(n)){let o=[];for(let m of n){if(!m.pattern)continue;let{glob:h}=await import('glob'),u=await h(m.pattern,{cwd:l,nodir:!1});for(let g of u){let d=i.join(l,g);try{e.statSync(d).isDirectory()&&!e.existsSync(i.join(d,".purpose"))&&o.push(g);}catch{}}}o.length>0?s.push({name:"Purpose-required",status:"warn",message:`${o.length} director${o.length===1?"y":"ies"} missing .purpose: ${o.join(", ")}`,fix:"Create .purpose files with paradigm_purpose_init + paradigm_purpose_add_component"}):s.push({name:"Purpose-required",status:"ok",message:"All required directories have .purpose files"});}}catch{}let F=/\[NEEDS CLARIFICATION:\s*[^\]]+\]/gi,v=0,T=M(l);for(let t of T)try{let n=e.readFileSync(t,"utf8").match(F);n&&(v+=n.length);}catch{}v>0?s.push({name:"Clarification markers",status:"warn",message:`${v} [NEEDS CLARIFICATION] marker${v>1?"s":""} found in .purpose files`,fix:"Resolve open clarification markers before shipping"}):T.length>0&&s.push({name:"Clarification markers",status:"ok",message:"No unresolved markers"});let E=i.join(l,"portal.yaml");if(e.existsSync(E))try{let t=e.readFileSync(E,"utf8"),a=x.load(t);if(a?.version&&a?.gates){let n=Object.keys(a.gates||{}).length,o=Object.keys(a.routes||{}).length;s.push({name:"portal.yaml",status:"ok",message:`Valid (${n} gates, ${o} routes)`});}else s.push({name:"portal.yaml",status:"warn",message:"Missing version or gates section",fix:'Add version: "1.0" and gates: {} to portal.yaml'});}catch(t){s.push({name:"portal.yaml",status:"error",message:`Invalid YAML: ${t.message}`,fix:"Check YAML syntax in portal.yaml"});}if(e.existsSync(E))try{let{checkPortalCompliance:t,getComplianceSummary:a}=await import('./portal-compliance-4MG5F2GI.js'),n=await t(l),o=a(n);s.push({name:"Portal compliance",status:o.status,message:o.message,fix:o.status!=="ok"?"paradigm portal check":void 0});}catch{}let W=i.join(l,".paradigm","flows.yaml");if(e.existsSync(W))try{let t=e.readFileSync(W,"utf8"),a=x.load(t);if(a?.version&&a?.flows){let n=Object.keys(a.flows||{}).length,o=Object.entries(a.flows||{}).filter(([,m])=>!m?.steps||(m.steps?.length??0)===0);o.length>0?s.push({name:".paradigm/flows.yaml",status:"warn",message:`${n} flows defined, ${o.length} have no steps`,fix:"Add steps to empty flow definitions"}):s.push({name:".paradigm/flows.yaml",status:"ok",message:`Valid (${n} flows)`});}else s.push({name:".paradigm/flows.yaml",status:"warn",message:"Missing version or flows section",fix:'Ensure flows.yaml has version: "1.0" and flows: {}'});}catch(t){s.push({name:".paradigm/flows.yaml",status:"error",message:`Invalid YAML: ${t.message}`,fix:"Check YAML syntax in flows.yaml"});}let Y=i.join(l,".paradigm","lore");if(e.existsSync(Y))try{let t=e.readdirSync(Y).filter(a=>a.endsWith(".yaml"));t.length===0?s.push({name:"Lore entries",status:"warn",message:"Lore directory exists but no entries found",fix:"Record a lore entry: paradigm lore record"}):s.push({name:"Lore entries",status:"ok",message:`${t.length} lore file${t.length>1?"s":""}`});}catch{s.push({name:"Lore entries",status:"warn",message:"Could not read lore directory"});}let U=i.join(l,".paradigm","university");if(e.existsSync(U))try{let t=i.join(U,"content"),a=0,n=0;if(e.existsSync(t))for(let o of ["notes","policies","quizzes","paths"]){let m=i.join(t,o);e.existsSync(m)&&(a+=e.readdirSync(m).filter(h=>h.endsWith(".md")||h.endsWith(".yaml")).length);}if(a===0)s.push({name:"University content",status:"warn",message:"University directory exists but no content found",fix:'Add content: paradigm university add note --title "Getting Started"'});else {let o=i.join(t,"quizzes");if(e.existsSync(o))for(let h of e.readdirSync(o).filter(u=>u.endsWith(".yaml")))try{let u=x.load(e.readFileSync(i.join(o,h),"utf8"));if(u?.questions)for(let g of u.questions)g.choices&&g.correct&&!(g.correct in g.choices)&&n++;}catch{}let m=i.join(t,"paths");if(e.existsSync(m))for(let h of e.readdirSync(m).filter(u=>u.endsWith(".yaml")))try{let u=x.load(e.readFileSync(i.join(m,h),"utf8"));if(u?.steps){for(let g of u.steps)if(g.content&&!g.content.startsWith("plsat:")){let d=!1;for(let w of ["notes","policies","quizzes","paths"]){let y=i.join(t,w);if(e.existsSync(y)&&e.readdirSync(y).some(Z=>Z.startsWith(g.content))){d=!0;break}}d||n++;}}}catch{}n>0?s.push({name:"University content",status:"warn",message:`${a} items, ${n} issue${n>1?"s":""}`,fix:"Run: paradigm university validate --deep"}):s.push({name:"University content",status:"ok",message:`${a} content item${a>1?"s":""}`});}}catch{s.push({name:"University content",status:"warn",message:"Could not read university directory"});}let H=i.join(l,".claude","hooks.json"),X=i.join(l,"plugins","paradigm","hooks.json");if(e.existsSync(H)){let t=e.statSync(H),a=Date.now()-t.mtime.getTime(),n=Math.floor(a/(1e3*60*60*24));n>30?s.push({name:"Claude Code hooks",status:"warn",message:`Hooks are ${n} days old \u2014 may be outdated`,fix:"paradigm hooks install"}):s.push({name:"Claude Code hooks",status:"ok",message:n>0?`${n} days old`:"Fresh"});}else e.existsSync(X)?s.push({name:"Claude Code hooks",status:"ok",message:"Using plugin hooks"}):s.push({name:"Claude Code hooks",status:"missing",message:"No hooks installed",fix:"paradigm hooks install"});let _=i.join(l,".paradigm","habits.yaml");if(e.existsSync(_))try{let t=e.readFileSync(_,"utf8"),a=x.load(t);if(a?.version&&Array.isArray(a?.habits)){let n=a.habits.filter(o=>o.enabled!==!1).length;s.push({name:"Habits config",status:"ok",message:`Valid (${n}/${a.habits.length} enabled)`});}else s.push({name:"Habits config",status:"warn",message:"Missing version or habits array",fix:"Regenerate habits.yaml with paradigm habits init"});}catch(t){s.push({name:"Habits config",status:"error",message:`Invalid YAML: ${t.message}`,fix:"Check YAML syntax in habits.yaml"});}let G=i.join(l,"AGENTS.md");if(e.existsSync(G)){let t=e.statSync(G),a=Date.now()-t.mtime.getTime(),n=Math.floor(a/(1e3*60*60*24));n>60?s.push({name:"AGENTS.md",status:"warn",message:`${n} days since last update \u2014 may be stale`,fix:"paradigm sync"}):s.push({name:"AGENTS.md",status:"ok",message:n>0?`Updated ${n} days ago`:"Fresh"});}}let I=0,N=0,S=0;for(let r of s){let f,p;switch(r.status){case "ok":f="\u2713",p=c.green;break;case "warn":f="\u26A0",p=c.yellow,N++;break;case "error":f="\u2717",p=c.red,I++;break;case "missing":f="\u25CB",p=c.gray,S++;break}if(!k){let j=r.name.padEnd(30);console.log(` ${p(f)} ${j} ${p(r.message)}`),r.fix&&console.log(c.gray(` \u2514\u2500 Fix: ${r.fix}`));}}let{runContextAudit:Q}=await import('./context-audit-RSSRX6XC.js'),D=await Q(l,{quiet:k}),z=0,O=0,$=0;!k&&D.length>0&&(console.log(""),console.log(c.blue(" Context Audit")),console.log(c.gray(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")));for(let r of D){let f,p;switch(r.status){case "ok":f="\u2713",p=c.green;break;case "warn":f="\u26A0",p=c.yellow,O++;break;case "error":f="\u2717",p=c.red,z++;break;case "advisory":f="\u2139",p=c.cyan,$++;break}if(!k){let j=r.check.padEnd(30);if(console.log(` ${p(f)} ${j} ${p(r.message)}`),r.details&&r.details.length>0){let P=r.details.slice(0,5);for(let F of P)console.log(c.gray(` \u2502 ${F}`));r.details.length>5&&console.log(c.gray(` \u2502 ... and ${r.details.length-5} more`));}r.fix&&console.log(c.gray(` \u2514\u2500 Fix: ${r.fix}`));}}let C=I+z,b=N+O,R=C+b+S===0;if(!k)if(console.log(""),R)console.log(c.green(`\u2728 All checks passed!
|
|
6
|
+
`)));let L=a.command("doctor").start("Running health checks");if(!q){let M=function(t){let a=[];try{let n=e.readdirSync(t,{withFileTypes:!0});for(let o of n){if(o.name==="node_modules"||o.name==="dist"||o.name===".git")continue;let m=i.join(t,o.name);o.isDirectory()?a.push(...M(m)):o.name===".purpose"&&a.push(m);}}catch{}return a};let r=i.join(l,".paradigm");if(e.existsSync(r))if(e.statSync(r).isFile())s.push({name:".paradigm",status:"warn",message:"Legacy file format (should be directory)",fix:"paradigm upgrade --all"});else {s.push({name:".paradigm/",status:"ok",message:"Directory exists"});let a=i.join(r,"config.yaml");if(e.existsSync(a))try{let d=e.readFileSync(a,"utf8");e$1(d),s.push({name:".paradigm/config.yaml",status:"ok",message:"Valid YAML"});}catch(d){s.push({name:".paradigm/config.yaml",status:"error",message:`Invalid YAML: ${d.message}`,fix:"Check YAML syntax"});}else s.push({name:".paradigm/config.yaml",status:"missing",message:"Config file not found",fix:"paradigm init --force"});let n=["logger.md","scan.md","symbols.md"],o=i.join(r,"specs");if(e.existsSync(o))for(let d of n){let w=i.join(o,d);e.existsSync(w)?s.push({name:`.paradigm/specs/${d}`,status:"ok",message:"Present"}):s.push({name:`.paradigm/specs/${d}`,status:"missing",message:"Spec file not found",fix:"paradigm upgrade --all"});}else s.push({name:".paradigm/specs/",status:"missing",message:"Specs directory not found",fix:"paradigm upgrade --all"});let m=i.join(r,"docs");e.existsSync(m)?s.push({name:".paradigm/docs/",status:"ok",message:"Directory exists"}):s.push({name:".paradigm/docs/",status:"missing",message:"Docs directory not found",fix:"paradigm upgrade --all"});let h=i.join(r,"prompts");e.existsSync(h)?s.push({name:".paradigm/prompts/",status:"ok",message:"Directory exists"}):s.push({name:".paradigm/prompts/",status:"missing",message:"Prompts directory not found",fix:"paradigm upgrade --all"});let u=i.join(r,"scan-index.json"),g=i.join(l,".paradigm-scan-index.json");if(e.existsSync(u)){let d=e.statSync(u),w=Date.now()-d.mtime.getTime(),y=Math.floor(w/(1e3*60*60));y>24?s.push({name:".paradigm/scan-index.json",status:"warn",message:`Stale (${y} hours old)`,fix:"paradigm index"}):s.push({name:".paradigm/scan-index.json",status:"ok",message:y>0?`${y} hours old`:"Fresh"});}else e.existsSync(g)?s.push({name:"scan-index",status:"warn",message:"Using legacy location",fix:"paradigm index"}):s.push({name:".paradigm/scan-index.json",status:"missing",message:"Not generated",fix:"paradigm index"});}else s.push({name:".paradigm/",status:"missing",message:"Not initialized",fix:"paradigm init"});let f=c$1(l);if(f.detected){let t=a$1(f.detected);if(t){let a=i.join(l,t.outputPath);e.existsSync(a)?s.push({name:t.outputPath,status:"ok",message:`Present (${f.detected})`}):s.push({name:t.outputPath,status:"missing",message:`Not generated for ${f.detected}`,fix:"paradigm sync"});}}let p=i.join(l,".premise");e.existsSync(p)?s.push({name:".premise",status:"ok",message:"Present"}):s.push({name:".premise",status:"missing",message:"Not found (optional)"});let j=i.join(l,".purpose");e.existsSync(j)?s.push({name:".purpose",status:"ok",message:"Present"}):s.push({name:".purpose",status:"warn",message:"Root .purpose not found",fix:"paradigm init"});let P=i.join(l,".paradigm","config.yaml");if(e.existsSync(P))try{let t=e.readFileSync(P,"utf8"),n=x.load(t)?.["purpose-required"];if(n&&Array.isArray(n)){let o=[];for(let m of n){if(!m.pattern)continue;let{glob:h}=await import('glob'),u=await h(m.pattern,{cwd:l,nodir:!1});for(let g of u){let d=i.join(l,g);try{e.statSync(d).isDirectory()&&!e.existsSync(i.join(d,".purpose"))&&o.push(g);}catch{}}}o.length>0?s.push({name:"Purpose-required",status:"warn",message:`${o.length} director${o.length===1?"y":"ies"} missing .purpose: ${o.join(", ")}`,fix:"Create .purpose files with paradigm_purpose_init + paradigm_purpose_add_component"}):s.push({name:"Purpose-required",status:"ok",message:"All required directories have .purpose files"});}}catch{}let F=/\[NEEDS CLARIFICATION:\s*[^\]]+\]/gi,v=0,T=M(l);for(let t of T)try{let n=e.readFileSync(t,"utf8").match(F);n&&(v+=n.length);}catch{}v>0?s.push({name:"Clarification markers",status:"warn",message:`${v} [NEEDS CLARIFICATION] marker${v>1?"s":""} found in .purpose files`,fix:"Resolve open clarification markers before shipping"}):T.length>0&&s.push({name:"Clarification markers",status:"ok",message:"No unresolved markers"});let E=i.join(l,"portal.yaml");if(e.existsSync(E))try{let t=e.readFileSync(E,"utf8"),a=x.load(t);if(a?.version&&a?.gates){let n=Object.keys(a.gates||{}).length,o=Object.keys(a.routes||{}).length;s.push({name:"portal.yaml",status:"ok",message:`Valid (${n} gates, ${o} routes)`});}else s.push({name:"portal.yaml",status:"warn",message:"Missing version or gates section",fix:'Add version: "1.0" and gates: {} to portal.yaml'});}catch(t){s.push({name:"portal.yaml",status:"error",message:`Invalid YAML: ${t.message}`,fix:"Check YAML syntax in portal.yaml"});}if(e.existsSync(E))try{let{checkPortalCompliance:t,getComplianceSummary:a}=await import('./portal-compliance-4MG5F2GI.js'),n=await t(l),o=a(n);s.push({name:"Portal compliance",status:o.status,message:o.message,fix:o.status!=="ok"?"paradigm portal check":void 0});}catch{}let W=i.join(l,".paradigm","flows.yaml");if(e.existsSync(W))try{let t=e.readFileSync(W,"utf8"),a=x.load(t);if(a?.version&&a?.flows){let n=Object.keys(a.flows||{}).length,o=Object.entries(a.flows||{}).filter(([,m])=>!m?.steps||(m.steps?.length??0)===0);o.length>0?s.push({name:".paradigm/flows.yaml",status:"warn",message:`${n} flows defined, ${o.length} have no steps`,fix:"Add steps to empty flow definitions"}):s.push({name:".paradigm/flows.yaml",status:"ok",message:`Valid (${n} flows)`});}else s.push({name:".paradigm/flows.yaml",status:"warn",message:"Missing version or flows section",fix:'Ensure flows.yaml has version: "1.0" and flows: {}'});}catch(t){s.push({name:".paradigm/flows.yaml",status:"error",message:`Invalid YAML: ${t.message}`,fix:"Check YAML syntax in flows.yaml"});}let Y=i.join(l,".paradigm","lore");if(e.existsSync(Y))try{let t=e.readdirSync(Y).filter(a=>a.endsWith(".yaml"));t.length===0?s.push({name:"Lore entries",status:"warn",message:"Lore directory exists but no entries found",fix:"Record a lore entry: paradigm lore record"}):s.push({name:"Lore entries",status:"ok",message:`${t.length} lore file${t.length>1?"s":""}`});}catch{s.push({name:"Lore entries",status:"warn",message:"Could not read lore directory"});}let U=i.join(l,".paradigm","university");if(e.existsSync(U))try{let t=i.join(U,"content"),a=0,n=0;if(e.existsSync(t))for(let o of ["notes","policies","quizzes","paths"]){let m=i.join(t,o);e.existsSync(m)&&(a+=e.readdirSync(m).filter(h=>h.endsWith(".md")||h.endsWith(".yaml")).length);}if(a===0)s.push({name:"University content",status:"warn",message:"University directory exists but no content found",fix:'Add content: paradigm university add note --title "Getting Started"'});else {let o=i.join(t,"quizzes");if(e.existsSync(o))for(let h of e.readdirSync(o).filter(u=>u.endsWith(".yaml")))try{let u=x.load(e.readFileSync(i.join(o,h),"utf8"));if(u?.questions)for(let g of u.questions)g.choices&&g.correct&&!(g.correct in g.choices)&&n++;}catch{}let m=i.join(t,"paths");if(e.existsSync(m))for(let h of e.readdirSync(m).filter(u=>u.endsWith(".yaml")))try{let u=x.load(e.readFileSync(i.join(m,h),"utf8"));if(u?.steps){for(let g of u.steps)if(g.content&&!g.content.startsWith("plsat:")){let d=!1;for(let w of ["notes","policies","quizzes","paths"]){let y=i.join(t,w);if(e.existsSync(y)&&e.readdirSync(y).some(Z=>Z.startsWith(g.content))){d=!0;break}}d||n++;}}}catch{}n>0?s.push({name:"University content",status:"warn",message:`${a} items, ${n} issue${n>1?"s":""}`,fix:"Run: paradigm university validate --deep"}):s.push({name:"University content",status:"ok",message:`${a} content item${a>1?"s":""}`});}}catch{s.push({name:"University content",status:"warn",message:"Could not read university directory"});}let H=i.join(l,".claude","hooks.json"),X=i.join(l,"plugins","paradigm","hooks.json");if(e.existsSync(H)){let t=e.statSync(H),a=Date.now()-t.mtime.getTime(),n=Math.floor(a/(1e3*60*60*24));n>30?s.push({name:"Claude Code hooks",status:"warn",message:`Hooks are ${n} days old \u2014 may be outdated`,fix:"paradigm hooks install"}):s.push({name:"Claude Code hooks",status:"ok",message:n>0?`${n} days old`:"Fresh"});}else e.existsSync(X)?s.push({name:"Claude Code hooks",status:"ok",message:"Using plugin hooks"}):s.push({name:"Claude Code hooks",status:"missing",message:"No hooks installed",fix:"paradigm hooks install"});let _=i.join(l,".paradigm","habits.yaml");if(e.existsSync(_))try{let t=e.readFileSync(_,"utf8"),a=x.load(t);if(a?.version&&Array.isArray(a?.habits)){let n=a.habits.filter(o=>o.enabled!==!1).length;s.push({name:"Habits config",status:"ok",message:`Valid (${n}/${a.habits.length} enabled)`});}else s.push({name:"Habits config",status:"warn",message:"Missing version or habits array",fix:"Regenerate habits.yaml with paradigm habits init"});}catch(t){s.push({name:"Habits config",status:"error",message:`Invalid YAML: ${t.message}`,fix:"Check YAML syntax in habits.yaml"});}let G=i.join(l,"AGENTS.md");if(e.existsSync(G)){let t=e.statSync(G),a=Date.now()-t.mtime.getTime(),n=Math.floor(a/(1e3*60*60*24));n>60?s.push({name:"AGENTS.md",status:"warn",message:`${n} days since last update \u2014 may be stale`,fix:"paradigm sync"}):s.push({name:"AGENTS.md",status:"ok",message:n>0?`Updated ${n} days ago`:"Fresh"});}}let I=0,N=0,S=0;for(let r of s){let f,p;switch(r.status){case "ok":f="\u2713",p=c.green;break;case "warn":f="\u26A0",p=c.yellow,N++;break;case "error":f="\u2717",p=c.red,I++;break;case "missing":f="\u25CB",p=c.gray,S++;break}if(!k){let j=r.name.padEnd(30);console.log(` ${p(f)} ${j} ${p(r.message)}`),r.fix&&console.log(c.gray(` \u2514\u2500 Fix: ${r.fix}`));}}let{runContextAudit:Q}=await import('./context-audit-XRPT3OU2.js'),D=await Q(l,{quiet:k}),z=0,O=0,$=0;!k&&D.length>0&&(console.log(""),console.log(c.blue(" Context Audit")),console.log(c.gray(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")));for(let r of D){let f,p;switch(r.status){case "ok":f="\u2713",p=c.green;break;case "warn":f="\u26A0",p=c.yellow,O++;break;case "error":f="\u2717",p=c.red,z++;break;case "advisory":f="\u2139",p=c.cyan,$++;break}if(!k){let j=r.check.padEnd(30);if(console.log(` ${p(f)} ${j} ${p(r.message)}`),r.details&&r.details.length>0){let P=r.details.slice(0,5);for(let F of P)console.log(c.gray(` \u2502 ${F}`));r.details.length>5&&console.log(c.gray(` \u2502 ... and ${r.details.length-5} more`));}r.fix&&console.log(c.gray(` \u2514\u2500 Fix: ${r.fix}`));}}let C=I+z,b=N+O,R=C+b+S===0;if(!k)if(console.log(""),R)console.log(c.green(`\u2728 All checks passed!
|
|
7
7
|
`));else {let r=[];C>0&&r.push(c.red(`${C} error${C>1?"s":""}`)),b>0&&r.push(c.yellow(`${b} warning${b>1?"s":""}`)),S>0&&r.push(c.gray(`${S} missing`)),$>0&&r.push(c.cyan(`${$} advisor${$>1?"ies":"y"}`)),console.log(`${r.join(", ")} found.
|
|
8
8
|
`),console.log(c.gray(`Run the suggested commands to fix issues.
|
|
9
9
|
`));}return R?L.success("All health checks passed",{total:s.length+D.length}):L.error("Health checks found issues",{errors:C,warnings:b,missing:S,advisories:$}),R}export{rs as a};
|