@a-company/paradigm 6.6.3 → 7.0.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/{accept-orchestration-JHDCVHB2.js → accept-orchestration-YO2V2WYA.js} +1 -1
- package/dist/add-V6XR7DU5.js +12 -0
- package/dist/{agents-suggest-IKY6VD2R.js → agents-suggest-WZEGQT5E.js} +1 -1
- package/dist/ambient-7HBJHJL2.js +2 -0
- package/dist/{ambient-FNNFB4AP.js → ambient-OX7YJ4PJ.js} +1 -1
- package/dist/ambient-SST5CLEC.js +35 -0
- package/dist/captain-YUP3KVCA.js +2 -0
- package/dist/chunk-33ERV2MW.js +18 -0
- package/dist/chunk-3MZ4J2LF.js +2 -0
- package/dist/chunk-47YPID6H.js +142 -0
- package/dist/chunk-6AKNXD22.js +32 -0
- package/dist/chunk-6HVOZANP.js +4 -0
- package/dist/chunk-ACJWUOMA.js +3 -0
- package/dist/chunk-B5KLSBOZ.js +2 -0
- package/dist/chunk-DLMDHS2X.js +10 -0
- package/dist/chunk-EKNLG73M.js +6 -0
- package/dist/chunk-FRQRREJ6.js +29 -0
- package/dist/{chunk-5RFISGUW.js → chunk-G6DK3ND3.js} +250 -25
- package/dist/{chunk-XKNJSPB5.js → chunk-JCGCPAHF.js} +1 -1
- package/dist/chunk-K54L6CFR.js +25 -0
- package/dist/chunk-QBIQ2FYB.js +20 -0
- package/dist/chunk-QEQCPVF5.js +4 -0
- package/dist/chunk-ROU3F2HZ.js +6 -0
- package/dist/chunk-S4J337EQ.js +504 -0
- package/dist/chunk-V6MIKLMY.js +18 -0
- package/dist/chunk-WROJSWAO.js +93 -0
- package/dist/{chunk-TQOT2LBO.js → chunk-YXLGVOZO.js} +1 -1
- package/dist/chunk-ZSWXLFN7.js +12 -0
- package/dist/{compliance-J3VOV445.js → compliance-MLG4W6S4.js} +1 -1
- package/dist/{diff-ANKTFDRA.js → diff-MC6AXLKX.js} +1 -1
- package/dist/{docs-TSAAS4W3.js → docs-3YFNNZRV.js} +1 -1
- package/dist/doctor-CBZYYQQH.js +2 -0
- package/dist/{hooks-45WDP6QS.js → hooks-AXBWYJ5V.js} +1 -1
- package/dist/index.js +6 -6
- package/dist/list-NC3QGT75.js +12 -0
- package/dist/mcp.js +3 -3
- package/dist/{migrate-R64OQGSM.js → migrate-5M4KUQ2L.js} +1 -1
- package/dist/{nomination-engine-NCLTGMAK.js → nomination-engine-AQHU2KBU.js} +1 -1
- package/dist/notebook-loader-6DYFMNJ2.js +2 -0
- package/dist/orchestrate-GMYEBA5T.js +8 -0
- package/dist/orchestration-G5MAY6IA.js +2 -0
- package/dist/propose-block-ZEMEWJQF.js +2 -0
- package/dist/{providers-TBPOE4DI.js → providers-5EHD45C6.js} +1 -1
- package/dist/quiz-TNV6APBM.js +10 -0
- package/dist/reindex-XTRF23F7.js +2 -0
- package/dist/serve-2PKJP65E.js +12 -0
- package/dist/{serve-3FMUWW5K.js → serve-SMGWGJLM.js} +1 -1
- package/dist/server-4SYOUF6D.js +7 -0
- package/dist/session-tracker-BZ7FU4AT.js +2 -0
- package/dist/session-work-log-QXPAXY5K.js +2 -0
- package/dist/session-work-log-T2IE4Y4T.js +2 -0
- package/dist/{shift-TNA2E5O7.js → shift-JBCEDCGA.js} +2 -2
- package/dist/show-N5LGB5B2.js +7 -0
- package/dist/solo-OWR3MX74.js +3 -0
- package/dist/{spawn-KKDDR6UR.js → spawn-PHA2SVQ3.js} +1 -1
- package/dist/status-ENAI35NL.js +6 -0
- package/dist/task-loader-IGQQ6ZFL.js +2 -0
- package/dist/task-settlement-NW4XMJGJ.js +3 -0
- package/dist/{team-PEGP6F7S.js → team-J2YXPEGX.js} +1 -1
- package/dist/team-funnel-RAJ6EDG3.js +2 -0
- package/dist/tools-HNJ7D5IO.js +2 -0
- package/dist/university-content/notes/N-para-801-cid-becomes-real.md +60 -0
- package/dist/university-content/notes/N-para-801-falsifiable-self-improvement.md +66 -0
- package/dist/university-content/notes/N-para-801-honest-routing-and-the-method.md +57 -0
- package/dist/university-content/notes/N-para-801-orchestration-emits-dag.md +60 -0
- package/dist/university-content/notes/N-para-801-settlement-closes-the-loop.md +64 -0
- package/dist/university-content/notes/N-para-801-the-task-dag.md +93 -0
- package/dist/university-content/paths/LP-para-801.yaml +43 -0
- package/dist/university-content/quizzes/Q-para-801-cid-becomes-real.yaml +54 -0
- package/dist/university-content/quizzes/Q-para-801-falsifiable-self-improvement.yaml +54 -0
- package/dist/university-content/quizzes/Q-para-801-honest-routing-and-the-method.yaml +54 -0
- package/dist/university-content/quizzes/Q-para-801-orchestration-emits-dag.yaml +54 -0
- package/dist/university-content/quizzes/Q-para-801-settlement-closes-the-loop.yaml +54 -0
- package/dist/university-content/quizzes/Q-para-801-the-task-dag.yaml +54 -0
- package/dist/university-ui/assets/{index-BIQeax_b.js → index-B8hm_MdR.js} +2 -2
- package/dist/university-ui/assets/{index-BIQeax_b.js.map → index-B8hm_MdR.js.map} +1 -1
- package/dist/university-ui/index.html +1 -1
- package/dist/validate-IQG7DBFC.js +9 -0
- package/package.json +2 -1
- package/dist/add-CBDFTWST.js +0 -12
- package/dist/ambient-AI42BOM5.js +0 -35
- package/dist/chunk-4N56FRNE.js +0 -29
- package/dist/chunk-6QXBXZF6.js +0 -3
- package/dist/chunk-AMLD7IYC.js +0 -10
- package/dist/chunk-DVZWCXB6.js +0 -2
- package/dist/chunk-ERO4MJSH.js +0 -6
- package/dist/chunk-F6E3HW45.js +0 -14
- package/dist/chunk-FI66YM6G.js +0 -666
- package/dist/chunk-K7X3Z3GL.js +0 -4
- package/dist/chunk-LAYBUKMB.js +0 -14
- package/dist/chunk-MU5YWTNE.js +0 -24
- package/dist/chunk-P344HV6Z.js +0 -2
- package/dist/chunk-QALPEMCU.js +0 -111
- package/dist/chunk-XQLO5URP.js +0 -11
- package/dist/doctor-L5XZENCF.js +0 -2
- package/dist/list-AXKTBXKJ.js +0 -12
- package/dist/notebook-loader-3J2OFMS3.js +0 -2
- package/dist/orchestrate-UG5QXNAU.js +0 -8
- package/dist/quiz-G56CUN45.js +0 -10
- package/dist/reindex-F7BZCG4W.js +0 -2
- package/dist/serve-TJQ5BNKR.js +0 -12
- package/dist/server-QOCW5RU6.js +0 -7
- package/dist/session-tracker-HHNY6J4I.js +0 -2
- package/dist/session-work-log-MEJ33TYD.js +0 -2
- package/dist/session-work-log-ZVVJGO7X.js +0 -2
- package/dist/show-MTPEQFXK.js +0 -7
- package/dist/status-REA6HUXE.js +0 -6
- package/dist/task-loader-NZFDTUQ5.js +0 -2
- package/dist/tools-HQKF4Q3P.js +0 -2
- package/dist/validate-742XMB42.js +0 -9
- /package/dist/{chunk-HXGYVS2N.js → chunk-ECLUYHAR.js} +0 -0
- /package/dist/{platform-server-ANOALDPL.js → platform-server-WIBVYHIV.js} +0 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {a,O,j as j$2,M as M$1,B}from'./chunk-QBIQ2FYB.js';import {a as a$1,b as b$3,c as c$1}from'./chunk-M4UMM6DC.js';import {r,i,a as a$2,f}from'./chunk-TMDPDIWA.js';import {j as j$1,b as b$2,a as a$4}from'./chunk-GRZQIKST.js';import {b as b$1,a as a$3}from'./chunk-EK4ZRIFJ.js';import {c,b,d}from'./chunk-5TAVYPOV.js';import*as S from'fs';import*as T from'path';import*as j from'crypto';import {execSync}from'child_process';import*as C from'js-yaml';import*as Y from'os';import ht from'sql.js';var ve={};c(ve,{contentSearch:()=>gt,detectFileRename:()=>Ae,generateFingerprint:()=>xe,levenshteinDistance:()=>Ie,levenshteinSimilarity:()=>se,searchSiblingFiles:()=>Ce,slidingWindowSearch:()=>V});function xe(e){let t=e.split(`
|
|
3
|
+
`).filter(n=>n.trim()!=="");return {firstLine:q(t[0]||""),lastLine:q(t[t.length-1]||""),lineCount:t.length,structuralHash:Le(t)}}function Le(e){let t=e.map(n=>n.trim()).filter(n=>Re.test(n)).map(n=>{let s=n.match(Re);return s?s[1].trim():""}).join("|");return j.createHash("sha256").update(t).digest("hex").slice(0,16)}function q(e){return e.trim().replace(/\s+/g," ").toLowerCase()}function Ie(e,t){if(e===t)return 0;if(e.length===0)return t.length;if(t.length===0)return e.length;e.length>t.length&&([e,t]=[t,e]);let n=e.length,s=t.length;if(n>5e3||s>5e3)return Math.abs(n-s);let r=new Array(n+1),i=new Array(n+1);for(let a=0;a<=n;a++)r[a]=a;for(let a=1;a<=s;a++){i[0]=a;for(let c=1;c<=n;c++){let o=e[c-1]===t[a-1]?0:1;i[c]=Math.min(r[c]+1,i[c-1]+1,r[c-1]+o);}[r,i]=[i,r];}return r[n]}function se(e,t){if(e.length===0&&t.length===0)return 1;let n=Math.max(e.length,t.length);return 1-Ie(e,t)/n}function V(e,t,n,s=3){let{lineCount:r}=t,i=Math.max(1,Math.floor(r*.8)),a=Math.ceil(r*1.2),c=[],o=ne(n);for(let l of [r,i,a])if(!(l>e.length))for(let d=0;d<=e.length-l;d++){let p=e.slice(d,d+l),y=ft(p,t,o);if(y>=.5){let m=p.join(`
|
|
4
|
+
`);c.push({windowStart:d+1,windowEnd:d+l,similarity:se(ne(m),o),score:y});}}let u=new Map;for(let l of c){let d=u.get(l.windowStart);(!d||l.score>d.score)&&u.set(l.windowStart,l);}return Array.from(u.values()).sort((l,d)=>d.score-l.score).slice(0,s)}function ft(e,t,n){let s=e.filter(p=>p.trim()!=="");if(s.length===0)return 0;let r=0,i=q(s[0]),a=q(s[s.length-1]),c=0;i===t.firstLine&&(c+=.5),a===t.lastLine&&(c+=.5),r+=c*lt,Le(s)===t.structuralHash&&(r+=ut);let u=s.join(`
|
|
5
|
+
`),l=se(ne(u),n);l>=.8&&(r+=(l-.8)/.2*dt);let d=s.length/t.lineCount;if(d>=.8&&d<=1.2){let p=1-Math.abs(1-d)/.2;r+=p*pt;}return r}function ne(e){return e.split(`
|
|
6
|
+
`).map(t=>t.trim()).filter(t=>t!=="").join(`
|
|
7
|
+
`)}function Ae(e,t){try{let n=execSync(`git log --follow --diff-filter=R --name-status --format="" -- "${t}"`,{cwd:e,encoding:"utf8",timeout:5e3}).trim();if(!n)return null;let s=n.split(`
|
|
8
|
+
`);for(let r of s){let i=r.split(" ");if(i.length>=3&&i[0].startsWith("R"))return i[2]}return null}catch{return null}}function Ce(e,t,n,s,r=10){let i=T.isAbsolute(t)?t:T.join(e,t);if(!S.existsSync(i))return [];let a=[];try{let c=S.readdirSync(i).filter(o=>!o.startsWith(".")&&S.statSync(T.join(i,o)).isFile()).slice(0,r);for(let o of c)try{let l=S.readFileSync(T.join(i,o),"utf8").split(`
|
|
9
|
+
`),d=V(l,n,s,1);if(d.length>0&&d[0].score>=.7){let p=T.relative(e,T.join(i,o));a.push({file:p,score:d[0].score,start:d[0].windowStart,end:d[0].windowEnd});}}catch{}}catch{return []}return a.sort((c,o)=>o.score-c.score)}function gt(e,t,n,s=true){let r=xe(n),i=T.isAbsolute(t)?t:T.join(e,t);if(S.existsSync(i)){let l=S.readFileSync(i,"utf8").split(`
|
|
10
|
+
`),d=V(l,r,n);if(d.length>0){let p=d[0];return {found:p.score>=.7,score:p.score,suggestedStart:p.windowStart,suggestedEnd:p.windowEnd,similarity:p.similarity}}}let a=Ae(e,t);if(a){let u=T.join(e,a);if(S.existsSync(u)){let d=S.readFileSync(u,"utf8").split(`
|
|
11
|
+
`),p=V(d,r,n);if(p.length>0&&p[0].score>=.7)return {found:true,score:p[0].score,suggestedStart:p[0].windowStart,suggestedEnd:p[0].windowEnd,suggestedPath:a,similarity:p[0].similarity}}}let c=T.dirname(t),o=Ce(e,c,r,n);if(o.length>0&&o[0].score>=.7){let u=o[0];return {found:true,score:u.score,suggestedStart:u.start,suggestedEnd:u.end,suggestedPath:u.file!==t?u.file:void 0,similarity:u.score}}return {found:false,score:0}}var Re,lt,ut,dt,pt,Ne=b(()=>{Re=/^\s*(function |class |if |else |for |while |switch |case |return |export |import |const |let |var |async |await |try |catch |throw |struct |enum |protocol |guard |def |fn )/;lt=.4,ut=.3,dt=.2,pt=.1;});var Ye="0.1.0",qe="1.0.0";function ee(e,t){let n={$meta:Ve(t.projectName,e),components:{},features:{},flows:{},state:{},gates:{},signals:{},aspects:{},screens:{},symbolMap:{}};for(let r of e.symbols)Ke(r,n,t);if(t.screenDefinitions)for(let[r,i]of Object.entries(t.screenDefinitions))n.screens[r]||(n.screens[r]={id:r,name:M(r),route:i.route,path:"",components:i.components,features:i.features});let s={};for(let r of Object.values(n.components))r.componentType&&(s[r.componentType]=(s[r.componentType]||0)+1);for(let r of Object.values(n.features))r.componentType&&(s[r.componentType]=(s[r.componentType]||0)+1);return Object.keys(s).length>0&&(n.$meta.componentTypes=s),rt(n),n}function Ve(e,t){return {version:qe,project:e,generatedAt:new Date().toISOString(),paradigmVersion:Ye,sources:{purposeFiles:t.purposeFiles.length,portalFiles:t.portalFiles.length,premiseFiles:t.symbols.filter(n=>n.source==="premise").length>0?1:0}}}function Ke(e,t,n){let{type:s}=e;switch(s){case "component":Je(e,t,n);break;case "feature":Qe(e,t,n);break;case "flow":Ze(e,t);break;case "state":et(e,t);break;case "gate":tt(e,t);break;case "signal":nt(e,t);break;case "aspect":st(e,t);break;}}function Je(e,t,n){let s=W(e.symbol),r=Se(s,e.data,n.visualTagMappings),i={id:s,name:M(s),symbol:e.symbol,category:"components",path:e.filePath,description:e.description,visualTags:r,related:e.references,componentType:e.componentType,parent:e.parentSymbol};t.components[s]=i,t.symbolMap[e.symbol]={category:"components",id:s};}function Qe(e,t,n){let s=W(e.symbol),r=Se(s,e.data,n.visualTagMappings),i={id:s,name:M(s),symbol:e.symbol,category:"features",path:e.filePath,description:e.description,visualTags:r,related:e.references,componentType:e.componentType,parent:e.parentSymbol};t.features[s]=i,t.symbolMap[e.symbol]={category:"features",id:s};}function Ze(e,t){let n=W(e.symbol),s=e.data,r=[];if(s?.steps)for(let a=0;a<s.steps.length;a++){let c=s.steps[a];r.push({id:`${n}-step-${a}`,name:c.action||`Step ${a+1}`,target:c.component,description:c.description,order:a});}let i={id:n,name:M(n),symbol:e.symbol,path:e.filePath,description:e.description,steps:r};t.flows[n]=i,t.symbolMap[e.symbol]={category:"flows",id:n};}function et(e,t){let n=W(e.symbol),s={id:n,name:M(n),symbol:e.symbol,path:e.filePath,description:e.description,consumers:e.referencedBy};t.state[n]=s,t.symbolMap[e.symbol]={category:"state",id:n};}function tt(e,t){let n=W(e.symbol),s={id:n,name:M(n),symbol:e.symbol,category:"gates",path:e.filePath,description:e.description,related:e.references};t.gates[n]=s,t.symbolMap[e.symbol]={category:"gates",id:n};}function nt(e,t){let n=W(e.symbol),s={id:n,name:M(n),symbol:e.symbol,category:"signals",path:e.filePath,description:e.description,related:e.references};t.signals[n]=s,t.symbolMap[e.symbol]={category:"signals",id:n};}function st(e,t){let n=W(e.symbol),s={id:n,name:M(n),symbol:e.symbol,category:"aspects",path:e.filePath,description:e.description,related:e.references};t.aspects[n]=s,t.symbolMap[e.symbol]={category:"aspects",id:n};}function rt(e){for(let t of Object.values(e.screens))if(t.components)for(let n of t.components){let s=e.components[n];s&&(s.screens=s.screens||[],s.screens.includes(t.id)||s.screens.push(t.id));}}function W(e){return e.slice(1)}function M(e){return e.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function Se(e,t,n){let s=[];if(n?.[e])return n[e];let r=[[/button/i,"button"],[/btn/i,"button"],[/form/i,"form"],[/input/i,"input"],[/field/i,"input"],[/select/i,"input"],[/card/i,"card"],[/list/i,"list"],[/table/i,"list"],[/modal/i,"modal"],[/dialog/i,"modal"],[/drawer/i,"modal"],[/nav/i,"nav"],[/menu/i,"menu"],[/dropdown/i,"menu"],[/header/i,"header"],[/footer/i,"footer"],[/sidebar/i,"sidebar"],[/hero/i,"hero"],[/grid/i,"grid"],[/chart/i,"chart"],[/graph/i,"chart"],[/icon/i,"icon"],[/image/i,"image"],[/avatar/i,"avatar"],[/badge/i,"badge"],[/tag/i,"badge"],[/tab/i,"tab"],[/accordion/i,"accordion"],[/toast/i,"toast"],[/notification/i,"toast"],[/alert/i,"toast"],[/spinner/i,"spinner"],[/loader/i,"spinner"],[/loading/i,"spinner"],[/skeleton/i,"skeleton"]];for(let[i,a]of r)i.test(e)&&s.push(a);return s}function te(e){return JSON.stringify(e,null,2)}var ot=300*1e3,$=null;function be(){$=null;}function N(e,t){return S.existsSync(T.join(e,t))}function P(e,t){return S.existsSync(T.join(e,t))}function it(e,t,n){let s=e;try{if(!S.existsSync(s))return !1;let r=S.readdirSync(s,{withFileTypes:!0});for(let i of r){if(i.isFile()&&i.name.endsWith(t))return !0;if(i.isDirectory())try{if(S.readdirSync(T.join(s,i.name)).some(c=>c.endsWith(t)))return !0}catch{}}}catch{}return false}var at={wisdom:e=>N(e,".paradigm/wisdom"),history:e=>N(e,".paradigm/history"),lore:e=>N(e,".paradigm/lore"),habits:e=>P(e,".paradigm/habits.yaml"),sentinel:e=>{try{let t=T.join(e,".paradigm","config.yaml");return S.existsSync(t)?S.readFileSync(t,"utf-8").includes("sentinel"):!1}catch{return false}},flows:e=>P(e,".paradigm/flow-index.json")||P(e,".paradigm/flows.yaml"),fixtures:e=>P(e,".paradigm/fixtures.yaml"),orchestration:e=>P(e,".paradigm/agents.yaml"),tasks:e=>N(e,".paradigm/tasks"),assessment:e=>N(e,".paradigm/lore"),personas:e=>it(e,".persona"),protocols:e=>N(e,".paradigm/protocols"),symphony:()=>{let e=T.join(Y.homedir(),".paradigm","score");return S.existsSync(e)},university:e=>N(e,".paradigm/university"),agents:e=>{let t=T.join(Y.homedir(),".paradigm","agents");return N(e,".paradigm/agents")||S.existsSync(t)},"aspect-graph":e=>P(e,".paradigm/aspect-graph.db"),pan:e=>P(e,".pan")||P(e,"nevr.yaml"),notebooks:e=>{let t=T.join(Y.homedir(),".paradigm","notebooks");return N(e,".paradigm/notebooks")||S.existsSync(t)}},we=class{modules=new Map;activatedAdvanced=new Set;rootDir;constructor(t){this.rootDir=t;}register(t){this.modules.set(t.key,t);}registerAll(t){for(let n of t)this.register(n);}detectActiveFeatures(){if($&&Date.now()-$.timestamp<ot)return $.features;let t=new Set;for(let[n,s]of this.modules){if(s.tier==="core"){t.add(n);continue}if(s.tier==="advanced"){this.activatedAdvanced.has(n)&&t.add(n);continue}let r=s.detect||at[n];if(r)try{r(this.rootDir)&&t.add(n);}catch{}else t.add(n);}return $={features:t,timestamp:Date.now()},t}getActiveTools(){let t=this.detectActiveFeatures(),n=[];for(let[s,r]of this.modules)t.has(s)&&n.push(...r.getToolsList());return n}activateAdvanced(t){let n=this.modules.get(t);return !n||n.tier!=="advanced"?null:(this.activatedAdvanced.add(t),n.getToolsList())}getAvailableAdvanced(){let t=[];for(let[n,s]of this.modules)s.tier==="advanced"&&!this.activatedAdvanced.has(n)&&t.push({key:n,toolCount:s.getToolsList().length});return t}async dispatch(t,n,s,r){let i=this.detectActiveFeatures();for(let[a,c]of this.modules)if(i.has(a))try{let o=await c.handleTool(t,n,s,r);if(o.handled)return o}catch(o){return {handled:true,text:JSON.stringify({error:`Tool handler error in module "${a}"`,message:o.message},null,2)}}return null}get size(){return this.modules.size}getRegistryInfo(){let t=this.detectActiveFeatures(),n={core:0,feature:0,advanced:0};for(let s of this.modules.values())n[s.tier]++;return {total:this.modules.size,byTier:n,activeFeatures:[...t],availableAdvanced:[...this.modules.entries()].filter(([s,r])=>r.tier==="advanced"&&!this.activatedAdvanced.has(s)).map(([s])=>s)}}};var re=null;async function mt(){return re||(re=await ht()),re}var yt=[`CREATE TABLE IF NOT EXISTS aspects (
|
|
12
|
+
id TEXT PRIMARY KEY,
|
|
13
|
+
description TEXT NOT NULL,
|
|
14
|
+
category TEXT DEFAULT 'rule',
|
|
15
|
+
severity TEXT DEFAULT 'medium',
|
|
16
|
+
value TEXT,
|
|
17
|
+
enforcement TEXT,
|
|
18
|
+
defined_in TEXT NOT NULL,
|
|
19
|
+
tags TEXT,
|
|
20
|
+
created_at TEXT NOT NULL,
|
|
21
|
+
updated_at TEXT NOT NULL
|
|
22
|
+
)`,`CREATE TABLE IF NOT EXISTS anchors (
|
|
23
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
24
|
+
aspect_id TEXT NOT NULL REFERENCES aspects(id) ON DELETE CASCADE,
|
|
25
|
+
file_path TEXT NOT NULL,
|
|
26
|
+
start_line INTEGER NOT NULL,
|
|
27
|
+
end_line INTEGER NOT NULL,
|
|
28
|
+
content_hash TEXT,
|
|
29
|
+
normalized_hash TEXT,
|
|
30
|
+
materialized_at_commit TEXT,
|
|
31
|
+
last_verified TEXT,
|
|
32
|
+
drifted INTEGER DEFAULT 0
|
|
33
|
+
)`,"CREATE INDEX IF NOT EXISTS idx_anchors_file ON anchors(file_path)","CREATE INDEX IF NOT EXISTS idx_anchors_aspect ON anchors(aspect_id)",`CREATE TABLE IF NOT EXISTS edges (
|
|
34
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
35
|
+
source TEXT NOT NULL,
|
|
36
|
+
target TEXT NOT NULL,
|
|
37
|
+
relation TEXT NOT NULL,
|
|
38
|
+
weight REAL DEFAULT 1.0,
|
|
39
|
+
origin TEXT DEFAULT 'explicit',
|
|
40
|
+
created_at TEXT NOT NULL
|
|
41
|
+
)`,"CREATE INDEX IF NOT EXISTS idx_edges_source ON edges(source)","CREATE INDEX IF NOT EXISTS idx_edges_target ON edges(target)",`CREATE TABLE IF NOT EXISTS lore_links (
|
|
42
|
+
aspect_id TEXT NOT NULL,
|
|
43
|
+
lore_id TEXT NOT NULL,
|
|
44
|
+
PRIMARY KEY (aspect_id, lore_id)
|
|
45
|
+
)`,`CREATE TABLE IF NOT EXISTS search_log (
|
|
46
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
47
|
+
query TEXT NOT NULL,
|
|
48
|
+
results_returned TEXT NOT NULL,
|
|
49
|
+
selected_result TEXT,
|
|
50
|
+
timestamp TEXT NOT NULL
|
|
51
|
+
)`,"CREATE INDEX IF NOT EXISTS idx_search_query ON search_log(query)",`CREATE TABLE IF NOT EXISTS search_weights (
|
|
52
|
+
query_normalized TEXT NOT NULL,
|
|
53
|
+
aspect_id TEXT NOT NULL,
|
|
54
|
+
weight REAL DEFAULT 1.0,
|
|
55
|
+
hit_count INTEGER DEFAULT 1,
|
|
56
|
+
last_hit TEXT NOT NULL,
|
|
57
|
+
PRIMARY KEY (query_normalized, aspect_id)
|
|
58
|
+
)`,`CREATE TABLE IF NOT EXISTS heatmap (
|
|
59
|
+
aspect_id TEXT NOT NULL,
|
|
60
|
+
access_type TEXT NOT NULL,
|
|
61
|
+
count INTEGER DEFAULT 0,
|
|
62
|
+
last_accessed TEXT NOT NULL,
|
|
63
|
+
PRIMARY KEY (aspect_id, access_type)
|
|
64
|
+
)`],Et=["ALTER TABLE anchors ADD COLUMN original_content TEXT",`CREATE TABLE IF NOT EXISTS anchor_history (
|
|
65
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
66
|
+
anchor_id INTEGER NOT NULL,
|
|
67
|
+
action TEXT NOT NULL,
|
|
68
|
+
old_start INTEGER,
|
|
69
|
+
old_end INTEGER,
|
|
70
|
+
new_start INTEGER,
|
|
71
|
+
new_end INTEGER,
|
|
72
|
+
old_path TEXT,
|
|
73
|
+
new_path TEXT,
|
|
74
|
+
confidence REAL,
|
|
75
|
+
commit_hash TEXT,
|
|
76
|
+
healed_at TEXT NOT NULL
|
|
77
|
+
)`],Tt="CREATE VIRTUAL TABLE IF NOT EXISTS aspects_fts USING fts5(id, description, enforcement, tags)";function A(e,t,n){let s=e.prepare(t);n&&n.length>0&&s.bind(n);let r=[];for(;s.step();)r.push(s.getAsObject());return s.free(),r}function St(e,t,n){let s=e.prepare(t);n&&n.length>0&&s.bind(n);let r=null;return s.step()&&(r=s.getAsObject()),s.free(),r}async function Fe(e){let t=await mt(),n=T.join(e,".paradigm"),s=T.join(n,"aspect-graph.db"),r;if(S.existsSync(s)){let i=S.readFileSync(s);r=new t.Database(i);}else S.existsSync(n)||S.mkdirSync(n,{recursive:true}),r=new t.Database;for(let i of yt)r.run(i);try{r.run(Tt);}catch{}for(let i of Et)try{r.run(i);}catch{}return r}function ke(e,t){if(t){let n=T.join(t,".paradigm");S.existsSync(n)||S.mkdirSync(n,{recursive:true});let s=T.join(n,"aspect-graph.db"),r=e.export();S.writeFileSync(s,Buffer.from(r));}e.close();}function Me(e,t,n){let s=t.filter(a=>a.type==="aspect"),r=new Date().toISOString(),i=null;try{i=execSync("git rev-parse HEAD",{cwd:n,encoding:"utf8"}).trim();}catch{}e.run("DELETE FROM anchors"),e.run("DELETE FROM edges"),e.run("DELETE FROM aspects");try{e.run("DELETE FROM aspects_fts");}catch{}for(let a of s){let c=a.data??{},o=_t(c,a),u=xt(c,a),l=c.value!=null?String(c.value):null,d=a.enforcement??(c.enforcement!=null?String(c.enforcement):null),p=a.tags?JSON.stringify(a.tags):null;if(e.run(`INSERT INTO aspects (id, description, category, severity, value, enforcement, defined_in, tags, created_at, updated_at)
|
|
78
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,[a.symbol,a.description??"",o,u,l,d,a.filePath,p,a.created??r,a.modified??r]),a.anchors)for(let m of a.anchors){let{startLine:R,endLine:v}=Pe(m),L=Rt();e.run(`INSERT INTO anchors (aspect_id, file_path, start_line, end_line, content_hash, normalized_hash, materialized_at_commit, last_verified, original_content)
|
|
79
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,[a.symbol,m.path,R,v,L.exact,L.normalized,i,r,L.normalizedContent]);}let y=c.edges;if(Array.isArray(y))for(let m of y)e.run(`INSERT INTO edges (source, target, relation, weight, origin, created_at)
|
|
80
|
+
VALUES (?, ?, ?, ?, ?, ?)`,[m.source??a.symbol,m.target??"",m.relation??"related-to",m.weight??1,m.origin??"explicit",r]);if(a.appliesTo)for(let m of a.appliesTo)e.run(`INSERT INTO edges (source, target, relation, weight, origin, created_at)
|
|
81
|
+
VALUES (?, ?, ?, ?, ?, ?)`,[a.symbol,m,"related-to",.5,"inferred",r]);try{e.run(`INSERT INTO aspects_fts (id, description, enforcement, tags)
|
|
82
|
+
VALUES (?, ?, ?, ?)`,[a.symbol,a.description??"",d??"",p??""]);}catch{}}}function cn(e,t){return St(e,"SELECT * FROM aspects WHERE id = ?",[t])}function ln(e,t){return A(e,"SELECT * FROM anchors WHERE aspect_id = ?",[t])}function un(e,t){return A(e,"SELECT * FROM edges WHERE source = ?",[t])}function dn(e,t){return A(e,"SELECT * FROM edges WHERE target = ?",[t])}function pn(e,t){return A(e,"SELECT * FROM edges WHERE source = ? OR target = ?",[t,t])}function fn(e,t,n){let s=new Date().toISOString();e.run(`INSERT INTO heatmap (aspect_id, access_type, count, last_accessed)
|
|
83
|
+
VALUES (?, ?, 1, ?)
|
|
84
|
+
ON CONFLICT(aspect_id, access_type)
|
|
85
|
+
DO UPDATE SET count = count + 1, last_accessed = ?`,[t,n,s,s]);}function gn(e,t=20,n){return n?A(e,"SELECT * FROM heatmap WHERE access_type = ? ORDER BY count DESC LIMIT ?",[n,t]):A(e,"SELECT * FROM heatmap ORDER BY count DESC LIMIT ?",[t])}function hn(e,t,n,s=true,r$1=.7,i=.85){let a=n?A(e,"SELECT * FROM anchors WHERE aspect_id = ?",[n]):A(e,"SELECT * FROM anchors"),c=[];for(let o of a){let l=A(e,"SELECT defined_in FROM aspects WHERE id = ?",[o.aspect_id])[0]?.defined_in,d$1=l?T.dirname(T.isAbsolute(l)?l:T.resolve(t,l)):t,p=r(o.file_path,d$1,t),y=p.resolvedPath;if(!p.exists){c.push({aspectId:o.aspect_id,path:o.file_path,startLine:o.start_line,endLine:o.end_line,status:"missing",resolvedBy:"none",exists:false,drifted:true});continue}try{let R=S.readFileSync(y,"utf8").split(`
|
|
86
|
+
`),v=Math.max(0,o.start_line-1),L=Math.min(R.length,o.end_line),D=R.slice(v,L).join(`
|
|
87
|
+
`),U=j.createHash("sha256").update(D).digest("hex");if(o.content_hash!=null&&U===o.content_hash){c.push({aspectId:o.aspect_id,path:o.file_path,startLine:o.start_line,endLine:o.end_line,status:"clean",resolvedBy:"exact-hash",exists:!0,drifted:!1}),o.drifted===1&&e.run("UPDATE anchors SET drifted = 0 WHERE id = ?",[o.id]);continue}let X=j.createHash("sha256").update(ie(D)).digest("hex");if(o.normalized_hash!=null&&X===o.normalized_hash){e.run("UPDATE anchors SET content_hash = ?, drifted = 0 WHERE id = ?",[U,o.id]),c.push({aspectId:o.aspect_id,path:o.file_path,startLine:o.start_line,endLine:o.end_line,status:"cosmetic",resolvedBy:"normalized-hash",exists:!0,drifted:!1});continue}if(o.content_hash==null&&o.normalized_hash==null){e.run("UPDATE anchors SET content_hash = ?, normalized_hash = ?, drifted = 0 WHERE id = ?",[U,X,o.id]),c.push({aspectId:o.aspect_id,path:o.file_path,startLine:o.start_line,endLine:o.end_line,status:"clean",resolvedBy:"exact-hash",exists:!0,drifted:!1});continue}let H=!1;if(o.materialized_at_commit){let h=bt(t,o.file_path,o.materialized_at_commit,o.start_line,o.end_line);if(h){let g=Math.max(0,h.currentStart-1),f=Math.min(R.length,h.currentEnd),E=R.slice(g,f).join(`
|
|
88
|
+
`),F=j.createHash("sha256").update(E).digest("hex");if(o.content_hash!=null&&F===o.content_hash){let k=s;if(k){e.run("UPDATE anchors SET start_line = ?, end_line = ?, drifted = 0 WHERE id = ?",[h.currentStart,h.currentEnd,o.id]);let z=A(e,"SELECT defined_in FROM aspects WHERE id = ?",[o.aspect_id]);z.length>0&&oe(t,z[0].defined_in,o.file_path,o.start_line,o.end_line,h.currentStart,h.currentEnd);}c.push({aspectId:o.aspect_id,path:o.file_path,startLine:k?h.currentStart:o.start_line,endLine:k?h.currentEnd:o.end_line,status:"shifted",resolvedBy:"git-line-mapping",exists:!0,drifted:!1,suggestedStart:h.currentStart,suggestedEnd:h.currentEnd,autoHealed:k}),H=!0;}else {let k=j.createHash("sha256").update(ie(E)).digest("hex");if(o.normalized_hash!=null&&k===o.normalized_hash){if(s){let z=j.createHash("sha256").update(E).digest("hex");e.run("UPDATE anchors SET start_line = ?, end_line = ?, content_hash = ?, drifted = 0 WHERE id = ?",[h.currentStart,h.currentEnd,z,o.id]);let B=A(e,"SELECT defined_in FROM aspects WHERE id = ?",[o.aspect_id]);B.length>0&&oe(t,B[0].defined_in,o.file_path,o.start_line,o.end_line,h.currentStart,h.currentEnd);}c.push({aspectId:o.aspect_id,path:o.file_path,startLine:s?h.currentStart:o.start_line,endLine:s?h.currentEnd:o.end_line,status:"shifted",resolvedBy:"git-line-mapping",exists:!0,drifted:!1,suggestedStart:h.currentStart,suggestedEnd:h.currentEnd,autoHealed:s}),H=!0;}}}}if(H)continue;if(o.original_content){let{contentSearch:h}=(Ne(),d(ve)),g=h(t,o.file_path,o.original_content,s);if(g.found&&g.score>=r$1){if(s&&g.score>=i&&!g.suggestedPath&&g.suggestedStart&&g.suggestedEnd){e.run("UPDATE anchors SET start_line = ?, end_line = ?, drifted = 0 WHERE id = ?",[g.suggestedStart,g.suggestedEnd,o.id]);try{e.run(`INSERT INTO anchor_history (anchor_id, action, old_start, old_end, new_start, new_end, confidence, healed_at)
|
|
89
|
+
VALUES (?, 'relocated', ?, ?, ?, ?, ?, ?)`,[o.id,o.start_line,o.end_line,g.suggestedStart,g.suggestedEnd,g.score,new Date().toISOString()]);}catch{}let E=A(e,"SELECT defined_in FROM aspects WHERE id = ?",[o.aspect_id]);E.length>0&&oe(t,E[0].defined_in,o.file_path,o.start_line,o.end_line,g.suggestedStart,g.suggestedEnd),c.push({aspectId:o.aspect_id,path:o.file_path,startLine:g.suggestedStart,endLine:g.suggestedEnd,status:"relocated",resolvedBy:"content-search",exists:!0,similarity:g.similarity,suggestedStart:g.suggestedStart,suggestedEnd:g.suggestedEnd,autoHealed:!0,drifted:!1});continue}c.push({aspectId:o.aspect_id,path:g.suggestedPath||o.file_path,startLine:o.start_line,endLine:o.end_line,status:"relocated",resolvedBy:"content-search",exists:!0,similarity:g.similarity,suggestedStart:g.suggestedStart,suggestedEnd:g.suggestedEnd,autoHealed:!1,drifted:!0});continue}}e.run("UPDATE anchors SET drifted = 1 WHERE id = ?",[o.id]),c.push({aspectId:o.aspect_id,path:o.file_path,startLine:o.start_line,endLine:o.end_line,status:"modified",resolvedBy:"none",exists:!0,currentContent:D,drifted:!0});}catch{c.push({aspectId:o.aspect_id,path:o.file_path,startLine:o.start_line,endLine:o.end_line,status:"modified",resolvedBy:"none",exists:true,drifted:true});}}return c}function Pe(e){let{lines:t}=e;return typeof t=="number"?{startLine:t,endLine:t}:Array.isArray(t)?t.length===2?{startLine:t[0],endLine:t[1]}:{startLine:Math.min(...t),endLine:Math.max(...t)}:{startLine:1,endLine:1}}function wt(e){let t=[],n=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/gm,s;for(;(s=n.exec(e))!==null;)t.push({oldStart:parseInt(s[1],10),oldCount:s[2]!==void 0?parseInt(s[2],10):1,newStart:parseInt(s[3],10),newCount:s[4]!==void 0?parseInt(s[4],10):1});return t}function bt(e,t,n,s,r){let i;try{i=execSync(`git diff ${n}..HEAD --unified=0 -- "${t}"`,{cwd:e,encoding:"utf8",timeout:5e3});}catch{return null}if(!i.trim())return {originalStart:s,originalEnd:r,currentStart:s,currentEnd:r};let a=wt(i),c=0;for(let o of a){if(o.oldStart+o.oldCount<=s){c+=o.newCount-o.oldCount;continue}if(o.oldStart<r)return null;break}return c===0?null:{originalStart:s,originalEnd:r,currentStart:s+c,currentEnd:r+c}}function oe(e,t,n,s,r,i,a){let c=T.isAbsolute(t)?t:T.join(e,t);if(!S.existsSync(c))return false;try{let o=S.readFileSync(c,"utf8"),u=s===r?`${n}:${s}`:`${n}:${s}-${r}`,l=i===a?`${n}:${i}`:`${n}:${i}-${a}`;if(!o.includes(u))return !1;let d=o.replace(u,l);return S.writeFileSync(c,d,"utf8"),!0}catch{return false}}function ie(e){return e.split(`
|
|
90
|
+
`).map(t=>t.trimEnd()).filter(t=>t.trim()!=="").map(t=>t.replace(/\s+/g," ")).join(`
|
|
91
|
+
`)}function Rt(e,t,n){return {exact:null,normalized:null,normalizedContent:null};}function _t(e,t){if(typeof e.category=="string")return e.category;let n=(t.description??"").toLowerCase();return /\b(must|require|always)\b/.test(n)?"rule":/\b(decided|chose)\b/.test(n)?"decision":/\b(limit|cannot)\b/.test(n)?"constraint":/\b(set to|configured|value)\b/.test(n)?"configuration":"rule"}function xt(e,t){if(typeof e.severity=="string")return e.severity;let n=t.tags??[];return n.includes("critical")?"critical":n.includes("security")||n.includes("compliance")?"high":"medium"}j$1();var Lt=/L-\d{4}-\d{2}-\d{2}-\d{3}/g;async function je(e,t){e.run("DELETE FROM lore_links");let n=await a$4(t);if(n.length===0)return 0;let s=It(n),r=new Map;for(let u of n)r.set(u.id,u);let i=new Set,a=e.exec("SELECT id, enforcement FROM aspects");if(a.length>0){let{columns:u,values:l}=a[0],d=u.indexOf("id"),p=u.indexOf("enforcement");for(let y of l){let m=String(y[d]),R=y[p];if(R&&typeof R=="string"){let v=R.match(Lt);if(v)for(let L of v)r.has(L)&&i.add(`${m}\0${L}`);}}}let c=e.exec("SELECT source, target FROM edges");if(c.length>0&&a.length>0){let u=At(e,c);for(let[l,d]of u)for(let p of d){let y=s.get(p);if(y)for(let m of y)i.add(`${l}\0${m}`);}}if(i.size===0)return 0;let o=e.prepare("INSERT OR IGNORE INTO lore_links (aspect_id, lore_id) VALUES (?, ?)");try{for(let u of i){let[l,d]=u.split("\0");o.bind([l,d]),o.step(),o.reset();}}finally{o.free();}return i.size}async function En(e,t,n){let s=e.exec("SELECT lore_id FROM lore_links WHERE aspect_id = ?",[n]);if(s.length===0||s[0].values.length===0)return [];let r=s[0].values.map(i=>String(i[0]));return Ct(t,r)}async function De(e,t){let n=await a$4(t);if(n.length===0)return 0;let s=e.exec("SELECT id FROM aspects"),r=new Set;if(s.length>0)for(let o of s[0].values)r.add(String(o[0]));if(r.size<2)return 0;let i=new Date().toISOString(),a=0,c=e.prepare(`INSERT OR IGNORE INTO edges (source, target, relation, weight, origin, created_at)
|
|
92
|
+
VALUES (?, ?, 'related-to', 0.3, 'learned', ?)`);try{for(let o of n){if(!o.symbols_touched||o.symbols_touched.length<2)continue;let u=[];for(let l of o.symbols_touched){let d=l.startsWith("~")?l.slice(1):l;r.has(d)&&u.push(d);}for(let l=0;l<u.length;l++)for(let d=l+1;d<u.length;d++){let[p,y]=u[l]<u[d]?[u[l],u[d]]:[u[d],u[l]];c.bind([p,y,i]),c.step(),c.reset(),a++;}}}finally{c.free();}return a}function It(e){let t=new Map;for(let n of e)if(n.symbols_touched)for(let s of n.symbols_touched){let r=t.get(s);r||(r=new Set,t.set(s,r)),r.add(n.id);}return t}function At(e,t){let n=e.exec("SELECT id FROM aspects"),s=new Set;if(n.length>0)for(let u of n[0].values)s.add(String(u[0]));let r=new Map;if(t.length===0)return r;let{columns:i,values:a}=t[0],c=i.indexOf("source"),o=i.indexOf("target");for(let u of a){let l=String(u[c]),d=String(u[o]);if(s.has(l)){let p=r.get(l);p||(p=new Set,r.set(l,p)),p.add(d),p.add(`~${l}`);}if(s.has(d)){let p=r.get(d);p||(p=new Set,r.set(d,p)),p.add(l),p.add(`~${d}`);}}return r}async function Ct(e,t){let n=new Set,s=[];for(let r of t){if(n.has(r))continue;n.add(r);let i=await b$2(e,r);i&&s.push(vt(i));}return s}function vt(e){return {id:e.id,title:e.title,summary:e.summary,timestamp:e.timestamp,symbolsTouched:e.symbols_touched}}var Nt="PARADIGM_STRICT";function K(){let e=process.env[Nt];if(e===void 0||e==="")return false;let t=e.toLowerCase();return t==="1"||t==="true"||t==="yes"||t==="on"}var Ue=new Set(["duplicate-key-detected"]);function Ot(e){let t=e.trim();if(t.includes("/")||t.includes("\\")){let n=t.split(/[/\\]/);t=n[n.length-1]||"unknown";}return t.length>40&&(t=t.slice(0,40)),t||"unknown"}var J=class{transforms=new Map;record(t,n,s=1){let r=Ot(n),i=`${t}::${r}`,a=this.transforms.get(i);a?a.count+=s:this.transforms.set(i,{kind:t,surface:r,count:s});}report(){let t=Array.from(this.transforms.values()).sort((s,r)=>s.kind!==r.kind?s.kind.localeCompare(r.kind):s.surface.localeCompare(r.surface)),n=t.filter(s=>Ue.has(s.kind)).reduce((s,r)=>s+r.count,0);return {reindex_ts:new Date().toISOString(),transformations:t,lossy_count:n,strict_mode:K()}}hasLossy(){for(let t of this.transforms.values())if(Ue.has(t.kind))return true;return false}totalCount(){let t=0;for(let n of this.transforms.values())t+=n.count;return t}};b$1();var Ft={"@":{category:"features",prefix:"@"},"#":{category:"components",prefix:"#"},"^":{category:"gates",prefix:"^"},$:{category:"flows",prefix:"$"},"&":{category:"integrations",prefix:"&"},"!":{category:"signals",prefix:"!"},"%":{category:"state",prefix:"%"}},kt={features:["src/features/","features/","app/","src/app/","src/modules/","modules/"],components:["src/components/","components/","src/lib/","lib/","src/ui/","ui/"],gates:["middleware/","src/middleware/","auth/","src/auth/","guards/","src/guards/"],flows:["flows/","src/flows/","workflows/","src/workflows/","sagas/","src/sagas/"],integrations:["integrations/","src/integrations/","external/","src/external/","vendors/"],signals:["events/","src/events/","handlers/","src/handlers/"],state:["stores/","src/stores/","state/","src/state/","reducers/","src/reducers/"]},Mt={config:[".paradigm/config.yaml","package.json","tsconfig.json",".env.example"],entry:["src/index.ts","src/index.tsx","src/main.ts","src/main.tsx","index.ts","main.ts","src/app.ts","src/app.tsx"],types:["src/types/","types/","src/types.ts","types.ts"]},ae={always:["node_modules/","dist/","build/",".git/",".next/",".nuxt/",".cache/","*.lock","*.log"],unless_testing:["**/*.test.ts","**/*.test.tsx","**/*.spec.ts","**/*.spec.tsx","__tests__/","test/","tests/"],unless_docs:["docs/","*.md","README*","CHANGELOG*"]};function Dn(){return [{name:"paradigm_reindex",description:"Rebuild scan-index.json, navigator.yaml, and flow-index.json from .purpose files. Call after modifying paradigm files or at the end of a work session to ensure static index files are fresh. Returns counts of indexed symbols, files processed, and any errors. ~150 tokens.",inputSchema:{type:"object",properties:{}},annotations:{readOnlyHint:false,destructiveHint:true},aliases:["rebuild","refresh","rescan","regenerate index","update index"]}]}async function Un(e,t,n,s){if(e!=="paradigm_reindex")return {handled:false,text:""};try{let r=await Pt(n.rootDir,n);await s(),a.clear(),be();let i=(r.integrityReport?.brokenReferences?.length||0)+(r.integrityReport?.duplicateSymbols?.length||0)+(r.componentAnchorIssues||0)+(r.crossFileIssues||0),a$1={success:!0,symbolCount:r.symbolCount,breakdown:r.breakdown,flowCount:r.flowCount,filesWritten:r.filesWritten.length,...r.aspectGraphStats?{aspects:r.aspectGraphStats.aspects,loreLinks:r.aspectGraphStats.loreLinks}:{},...r.protocolHealth?{protocols:r.protocolHealth.total,staleProtocols:r.protocolHealth.stale}:{},...i>0?{issues:i}:{}};r.consistency&&(a$1.consistency=r.consistency);let c=JSON.stringify(a$1,null,2);return O(c.length,e),{handled:!0,text:c}}catch(r){let i=JSON.stringify({error:r.message},null,2);return O(i.length,e),{handled:true,text:i}}}async function Pt(e,t){let n=[],s=new J,r;t?r=t.aggregation:r=await i(e);let i$1=t?.projectName||T.basename(e),a=T.join(e,".paradigm");S.existsSync(a)||S.mkdirSync(a,{recursive:true}),jt(e,s),Dt(r.purposeFiles,s);let c=ee({symbols:r.symbols,purposeFiles:r.purposeFiles,portalFiles:r.portalFiles},{projectName:i$1}),o=T.join(a,"scan-index.json");S.writeFileSync(o,te(c),"utf8"),n.push(".paradigm/scan-index.json");let u=Ut(e,r),l=T.join(a,"navigator.yaml");S.writeFileSync(l,C.dump(u,{indent:2,lineWidth:120,noRefs:true,sortKeys:false}),"utf8"),n.push(".paradigm/navigator.yaml");let d=Bt(e,r.purposeFiles),p=0;if(d&&Object.keys(d.flows).length>0){let f=T.join(a,"flow-index.json");S.writeFileSync(f,JSON.stringify(d,null,2),"utf8"),n.push(".paradigm/flow-index.json"),p=Object.keys(d.flows).length;}let y;try{let f=await Fe(e);Me(f,r.symbols,e);let E=await je(f,e),F=await De(f,e),k=f.exec("SELECT COUNT(*) FROM aspects")[0]?.values[0]?.[0]??0,z=f.exec("SELECT COUNT(*) FROM anchors")[0]?.values[0]?.[0]??0,B=f.exec("SELECT COUNT(*) FROM edges")[0]?.values[0]?.[0]??0;ke(f,e),n.push(".paradigm/aspect-graph.db"),y={aspects:k,anchors:z,edges:B,loreLinks:E};}catch{}let m=0;try{let f=await j$2(e);m=Object.keys(f.personas).length,m>0&&n.push(".paradigm/personas/index.yaml");}catch{}let R;try{let f=await M$1(e);f.health.total>0&&(R=f.health,n.push(".paradigm/protocols/index.yaml"));}catch{}let v;try{let f=T.join(e,".paradigm","university");if(S.existsSync(f)){let E=B(e);(E.totalContent>0||E.diplomaCount>0)&&(v={totalContent:E.totalContent,diplomaCount:E.diplomaCount},n.push(".paradigm/university/index.yaml"));}}catch{}let L;try{L=a$1(r,e);}catch{}let D;try{let f=b$3(r.symbols,e),E=f.missing+f.outOfBounds;E>0&&(D=E);}catch{}let U;try{U=c$1(r.purposeFiles,e);}catch{}let X;try{let f$1=[];for(let E of r.purposeFiles){let F=a$2(E);F.data&&f$1.push({filePath:E,data:F.data});}if(f$1.length>0){let F=f(f$1).issues.length;F>0&&(X=F);}}catch{}let H={};for(let f of r.symbols)H[f.type]=(H[f.type]||0)+1;let h={};for(let f of r.symbols)f.type==="component"&&f.componentType&&(h[f.componentType]=(h[f.componentType]||0)+1);let g=s.report();try{let f=T.join(a,"manifest.consistency.json");S.writeFileSync(f,JSON.stringify(g,null,2),"utf-8"),n.push(".paradigm/manifest.consistency.json");}catch{a$3.component("#reindex").warn("failed to write consistency manifest",{stage:"manifest-write"});}if(K()&&s.hasLossy())throw new Error(`reindex aborted: ${g.lossy_count} lossy transformation(s) detected under PARADIGM_STRICT=1. See .paradigm/manifest.consistency.json.`);return {action:"reindex",filesWritten:n,symbolCount:r.symbols.length,breakdown:H,flowCount:p,aspectGraphStats:y,personaCount:m,protocolHealth:R,consistency:g,...Object.keys(h).length>0?{componentTypeBreakdown:h}:{},...v?{universityStats:v}:{},...L?{integrityReport:L}:{},...D!==void 0?{componentAnchorIssues:D}:{},...U?{purposeHealth:U}:{},...X!==void 0?{crossFileIssues:X}:{}}}function jt(e,t){let n=T.join(e,"portal.yaml");if(!S.existsSync(n))return;let s;try{s=S.readFileSync(n,"utf-8");}catch{return}try{C.load(s);}catch(o){(o?.reason?.toLowerCase()||"").includes("duplicate")&&t.record("duplicate-key-detected","portal.yaml");return}let r;try{r=C.load(s,{schema:C.FAILSAFE_SCHEMA});}catch{return}if(!r||typeof r!="object")return;let i=r,a=i.gates;if(a&&typeof a=="object"&&!Array.isArray(a)){let o=0;for(let u of Object.keys(a))u.startsWith("^")&&o++;o>0&&t.record("prefix-stripped","portal.yaml",o);}else Array.isArray(a)&&a.length>0&&t.record("array-coerced","portal.yaml");let c=i.routes;Array.isArray(c)&&c.length>0&&t.record("array-coerced","portal.yaml"),i.version||t.record("default-applied","portal.yaml");}function Dt(e,t){for(let n of e){let s;try{s=S.readFileSync(n,"utf-8");}catch{continue}try{C.load(s);}catch(l){(l?.reason?.toLowerCase()||"").includes("duplicate")&&t.record("duplicate-key-detected","purpose.yaml");continue}let r;try{r=C.load(s,{schema:C.FAILSAFE_SCHEMA});}catch{continue}if(!r||typeof r!="object")continue;let i=r,a=["components","features","gates","signals","aspects","states"],c=0;for(let l of a)Array.isArray(i[l])&&c++;c>0&&t.record("array-coerced","purpose.yaml",c);let o=(l,d)=>{if(!l||typeof l!="object"||Array.isArray(l))return 0;let p=0;for(let y of Object.keys(l))y.startsWith(d)&&p++;return p},u=o(i.gates,"^")+o(i.signals,"!")+o(i.aspects,"~")+o(i.components,"#")+o(i.features,"#");u>0&&t.record("prefix-stripped","purpose.yaml",u);}}function Ut(e,t){let n={};for(let s of t.symbols)if(s.type==="component"&&s.componentType){let r=s.componentType;n[r]||(n[r]=[]),n[r].push(s.symbol);}return {version:"1.0",generated:new Date().toISOString(),structure:Ht(e),key_files:Wt(e),skip_patterns:Xt(e),symbols:$t(t.symbols,t.purposeFiles),...Object.keys(n).length>0?{symbolsByComponentType:n}:{}}}function Ht(e){let t={};for(let[n,s]of Object.entries(kt)){let r=s.filter(i=>S.existsSync(T.join(e,i)));if(r.length>0){let i=Object.values(Ft).find(a=>a.category===n);t[n]={paths:r,symbol:i?.prefix||"@"};}}return t}function Wt(e){let t={};for(let[n,s]of Object.entries(Mt)){let r=s.filter(i=>S.existsSync(T.join(e,i)));r.length>0&&(t[n]=r);}return t.config||(t.config=[]),t.entry||(t.entry=[]),t.types||(t.types=[]),t}function Xt(e){let t={always:[...ae.always],unless_testing:[...ae.unless_testing],unless_docs:[...ae.unless_docs]},n=T.join(e,".gitignore");if(S.existsSync(n))try{let r=S.readFileSync(n,"utf8").split(`
|
|
93
|
+
`).map(i=>i.trim()).filter(i=>i&&!i.startsWith("#")).filter(i=>i.endsWith("/")||i.includes("*")||["node_modules","dist","build",".cache"].some(a=>i.includes(a))).slice(0,20);for(let i of r)t.always.includes(i)||t.always.push(i);}catch{}return t}function zt(e){switch(e){case "feature":return "@";case "component":return "#";case "gate":return "^";case "flow":return "$";case "integration":return "&";case "signal":return "!";case "state":return "%";case "idea":return "?";case "deprecated":return "~";case "aspect":return "~";default:return "@"}}function $t(e,t,n){let s={};for(let r of e){let a=`${zt(r.type)}${r.id}`;if(r.filePath)s[a]=r.filePath;else {let c=t.find(o=>T.dirname(o).toLowerCase().includes(r.id.toLowerCase()));c&&(s[a]=T.dirname(c)+"/");}}return s}function Bt(e,t){let n={},s={};for(let r of t)try{let i=S.readFileSync(r,"utf8"),a=C.load(i);if(!a?.flows)continue;if(Array.isArray(a.flows))for(let c of a.flows){let o=c;if(!o.name)continue;let u=`$${o.name}`,l=He(o.steps);l.length>0&&(n[u]={id:u,description:o.description||"",steps:l,definedIn:T.relative(e,r)},We(u,l,s));}else for(let[c,o]of Object.entries(a.flows)){let u=c.startsWith("$")?c:`$${c}`,l=He(o.steps);l.length>0&&(n[u]={id:u,description:o.description||"",trigger:o.trigger,steps:l,validation:o.validation,definedIn:T.relative(e,r)},We(u,l,s));}}catch{}return Object.keys(n).length===0?null:{version:"1.0",generatedAt:new Date().toISOString(),flows:n,symbolToFlows:s}}function He(e){if(!e||!Array.isArray(e))return [];let t=[];for(let n=0;n<e.length;n++){let s=e[n];if(typeof s=="object"&&s!==null){let r=s,i=r.action||r.description||r.component||"";i&&t.push({id:r.id||`step-${n+1}`,action:i,symbol:r.symbol||r.component,expect:r.expect});}}return t}function We(e,t,n){for(let s of t)s.symbol&&(n[s.symbol]||(n[s.symbol]=[]),n[s.symbol].includes(e)||n[s.symbol].push(e));}export{we as a,K as b,Fe as c,ke as d,cn as e,ln as f,un as g,dn as h,pn as i,fn as j,gn as k,hn as l,En as m,Dn as n,Un as o,Pt as p};
|
|
@@ -10,4 +10,4 @@ Hand back to Builder for fixes, or to Tester when approved.`,focus:{reads:["^gat
|
|
|
10
10
|
Run tests, check portal validations, verify health status.
|
|
11
11
|
Report issues back to Builder. Update health.yaml when verified.`,focus:{reads:["tests/**","portal.yaml","health.yaml","#components"],writes:["tests/**","health.yaml"]},triggers:[{type:"keyword",match:["test","verify","qa","validate"]},{type:"handoff",from:"reviewer"}],handoff_to:["builder","architect"],defaultModel:"haiku",context:{include:["tests/**","health.yaml","{feature}.purpose"],exclude:["src/**","specs/**","node_modules/**"]}},security:{role:`You audit for security issues, especially around ^gates.
|
|
12
12
|
Review auth flows, check for vulnerabilities.
|
|
13
|
-
Flag issues but do NOT implement fixes - hand to Builder for that.`,focus:{reads:["^gates","!signals","portal.yaml","src/**"],writes:["security/*.md"]},triggers:[{type:"keyword",match:["security","audit","vulnerability","auth"]}],handoff_to:["builder","architect"],defaultModel:"opus",context:{include:["portal.yaml","src/middleware/**","src/auth/**"],exclude:["src/routes/**","tests/**","node_modules/**"]}}};function d(e){return c.join(e,".paradigm")}function u(e){return c.join(d(e),"agents.yaml")}function x(e){return c.join(d(e),"team-state.yaml")}function g(e){return c.join(d(e),"handoffs")}function
|
|
13
|
+
Flag issues but do NOT implement fixes - hand to Builder for that.`,focus:{reads:["^gates","!signals","portal.yaml","src/**"],writes:["security/*.md"]},triggers:[{type:"keyword",match:["security","audit","vulnerability","auth"]}],handoff_to:["builder","architect"],defaultModel:"opus",context:{include:["portal.yaml","src/middleware/**","src/auth/**"],exclude:["src/routes/**","tests/**","node_modules/**"]}}};function d(e){return c.join(e,".paradigm")}function u(e){return c.join(d(e),"agents.yaml")}function x(e){return c.join(d(e),"team-state.yaml")}function g(e){return c.join(d(e),"handoffs")}function F(e){return s.existsSync(u(e))}function P(e){let t=u(e);if(!s.existsSync(t))return null;try{let n=s.readFileSync(t,"utf8");return a.load(n)}catch{return null}}function C(e,t){let n=u(e),r=d(e);s.existsSync(r)||s.mkdirSync(r,{recursive:true});let o={...t,agents:Object.fromEntries(Object.entries(t.agents).map(([f,b])=>{let{partners:l,...h}=b;return [f,l&&l.length>0?{...h,partners:l}:h]}))},i=a.dump(o,{lineWidth:-1,noRefs:true,quotingType:'"'});s.writeFileSync(n,i);}function p(e){let t=x(e);if(!s.existsSync(t))return {current:null,queue:[],recent:[],blocked:[]};try{let n=s.readFileSync(t,"utf8");return a.load(n)}catch{return {current:null,queue:[],recent:[],blocked:[]}}}function m(e,t){let n=x(e),r=d(e);s.existsSync(r)||s.mkdirSync(r,{recursive:true});let o=a.dump(t,{lineWidth:-1,noRefs:true,quotingType:'"'});s.writeFileSync(n,o);}function w(e,t){let n=c.join(g(e),`${t}.yaml`);if(!s.existsSync(n))return null;try{let r=s.readFileSync(n,"utf8");return a.load(r)}catch{return null}}function H(e,t){let n=g(e);s.existsSync(n)||s.mkdirSync(n,{recursive:true});let r=c.join(n,`${t.id}.yaml`),o=a.dump(t,{lineWidth:-1,noRefs:true,quotingType:'"'});s.writeFileSync(r,o);}function v(e){let t=g(e);if(!s.existsSync(t))return [];let n=s.readdirSync(t).filter(o=>o.endsWith(".yaml")),r=[];for(let o of n){let i=o.replace(".yaml",""),f=w(e,i);f&&r.push(f);}return r.sort((o,i)=>new Date(i.timestamp).getTime()-new Date(o.timestamp).getTime())}function O(e){return v(e).filter(t=>t.status==="pending")}function j(e="project",t){let n={};for(let[r,o]of Object.entries(y))if(n[r]={name:r,...o},t&&t[r]){let i=t[r].id.toLowerCase();i.includes("opus")||i.includes("gpt-4")&&!i.includes("mini")||i.includes("o1")&&!i.includes("mini")||i.includes("pro")&&!i.includes("mini")||i.includes("large")?n[r].defaultModel="opus":i.includes("haiku")||i.includes("mini")||i.includes("flash")||i.includes("small")?n[r].defaultModel="haiku":n[r].defaultModel="sonnet";}return {version:"1.0.0",team:{name:`${e}-team`,default_agent:"architect",require_handoff:false},agents:n}}function I(e,t){let n=p(e);n.recent.unshift({...t,timestamp:new Date().toISOString()}),n.recent=n.recent.slice(0,20),m(e,n);}function q(e,t,n){let r=p(e);r.current={agent:t,task:n,started:new Date().toISOString(),symbols_touched:[]},m(e,r);}function E(e){let t=p(e);t.current=null,m(e,t);}export{A as a,d as b,u as c,F as d,P as e,C as f,p as g,m as h,H as i,v as j,O as k,j as l,I as m,q as n,E as o};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {c,a as a$1}from'./chunk-YNDPSWOE.js';import {e}from'./chunk-VIG5LSGZ.js';import {a}from'./chunk-LKAT7IAK.js';import*as t from'fs';import*as i from'path';import*as w from'js-yaml';import l from'chalk';async function rs(P={}){let p=P.rootDir||process.cwd(),s=[],$=P.quiet,E=P.context;$||(console.log(l.blue(`
|
|
3
|
+
\u{1FA7A} Paradigm Doctor
|
|
4
|
+
`)),console.log(E?l.gray(`Running context audit checks...
|
|
5
|
+
`):l.gray(`Checking Paradigm setup...
|
|
6
|
+
`)));let q=a.command("doctor").start("Running health checks");if(!E){let N=function(a){let e=[];try{let o=t.readdirSync(a,{withFileTypes:!0});for(let n of o){if(n.name==="node_modules"||n.name==="dist"||n.name===".git")continue;let d=i.join(a,n.name);n.isDirectory()?e.push(...N(d)):n.name===".purpose"&&e.push(d);}}catch{}return e};let r=i.join(p,".paradigm");if(t.existsSync(r))if(t.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 e$1=i.join(r,"config.yaml");if(t.existsSync(e$1))try{let f=t.readFileSync(e$1,"utf8");e(f),s.push({name:".paradigm/config.yaml",status:"ok",message:"Valid YAML"});}catch(f){s.push({name:".paradigm/config.yaml",status:"error",message:`Invalid YAML: ${f.message}`,fix:"Check YAML syntax"});}else s.push({name:".paradigm/config.yaml",status:"missing",message:"Config file not found",fix:"paradigm init --force"});let o=["logger.md","probe.md","symbols.md"],n=i.join(r,"specs");if(t.existsSync(n))for(let f of o){let x=i.join(n,f);t.existsSync(x)?s.push({name:`.paradigm/specs/${f}`,status:"ok",message:"Present"}):s.push({name:`.paradigm/specs/${f}`,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 d=i.join(r,"docs");t.existsSync(d)?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 u=i.join(r,"prompts");t.existsSync(u)?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 h=["specs","implementation-guides","prompts","decisions"],m=[];for(let f of h){let x=i.join(r,f);if(t.existsSync(x)&&t.statSync(x).isDirectory()){let k=i.join(x,".index.yaml");t.existsSync(k)||m.push(`.paradigm/${f}/`);}}m.length>0?s.push({name:"Docs-class indexes",status:"warn",message:`${m.length} director${m.length===1?"y":"ies"} missing .index.yaml: ${m.join(", ")}`,fix:"paradigm docs scaffold"}):s.push({name:"Docs-class indexes",status:"ok",message:"All docs-class directories have .index.yaml"});let y=i.join(r,"scan-index.json"),b=i.join(p,".paradigm-scan-index.json");if(t.existsSync(y)){let f=t.statSync(y),x=Date.now()-f.mtime.getTime(),k=Math.floor(x/(1e3*60*60));k>24?s.push({name:".paradigm/scan-index.json",status:"warn",message:`Stale (${k} hours old)`,fix:"paradigm index"}):s.push({name:".paradigm/scan-index.json",status:"ok",message:k>0?`${k} hours old`:"Fresh"});}else t.existsSync(b)?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 g=c(p);if(g.detected){let a=a$1(g.detected);if(a){let e=i.join(p,a.outputPath);t.existsSync(e)?s.push({name:a.outputPath,status:"ok",message:`Present (${g.detected})`}):s.push({name:a.outputPath,status:"missing",message:`Not generated for ${g.detected}`,fix:"paradigm sync"});}}let c$1=i.join(p,".premise");t.existsSync(c$1)?s.push({name:".premise",status:"ok",message:"Present"}):s.push({name:".premise",status:"missing",message:"Not found (optional)"});let A=i.join(p,".purpose");t.existsSync(A)?s.push({name:".purpose",status:"ok",message:"Present"}):s.push({name:".purpose",status:"warn",message:"Root .purpose not found",fix:"paradigm init"});let R=i.join(p,".paradigm","config.yaml");if(t.existsSync(R))try{let a=t.readFileSync(R,"utf8"),o=w.load(a)?.["purpose-required"];if(o&&Array.isArray(o)){let n=[];for(let d of o){if(!d.pattern)continue;let{glob:u}=await import('glob'),h=await u(d.pattern,{cwd:p,nodir:!1});for(let m of h){let y=i.join(p,m);try{t.statSync(y).isDirectory()&&!t.existsSync(i.join(y,".purpose"))&&n.push(m);}catch{}}}n.length>0?s.push({name:"Purpose-required",status:"warn",message:`${n.length} director${n.length===1?"y":"ies"} missing .purpose: ${n.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 M=/\[NEEDS CLARIFICATION:\s*[^\]]+\]/gi,F=0,Y=N(p);for(let a of Y)try{let o=t.readFileSync(a,"utf8").match(M);o&&(F+=o.length);}catch{}F>0?s.push({name:"Clarification markers",status:"warn",message:`${F} [NEEDS CLARIFICATION] marker${F>1?"s":""} found in .purpose files`,fix:"Resolve open clarification markers before shipping"}):Y.length>0&&s.push({name:"Clarification markers",status:"ok",message:"No unresolved markers"});let I=i.join(p,"portal.yaml");if(t.existsSync(I))try{let a=t.readFileSync(I,"utf8"),e=w.load(a);if(e?.version&&e?.gates){let o=Object.keys(e.gates||{}).length,n=Object.keys(e.routes||{}).length;s.push({name:"portal.yaml",status:"ok",message:`Valid (${o} gates, ${n} 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(a){s.push({name:"portal.yaml",status:"error",message:`Invalid YAML: ${a.message}`,fix:"Check YAML syntax in portal.yaml"});}if(t.existsSync(I))try{let{checkPortalCompliance:a,getComplianceSummary:e}=await import('./portal-compliance-JONQ4SOP.js'),o=await a(p),n=e(o);s.push({name:"Portal compliance",status:n.status,message:n.message,fix:n.status!=="ok"?"paradigm portal check":void 0});}catch{}{let a=i.join(p,".paradigm","scan-index.json"),e=i.join(p,".paradigm","roster.yaml");try{if(t.existsSync(a)){let o=t.readFileSync(a,"utf8"),n=JSON.parse(o),d=Object.keys(n.components??{}).length,u=Object.keys(n.aspects??{}).length;if(d>0){let h=!1;if(t.existsSync(e))try{let y=w.load(t.readFileSync(e,"utf8"));h=Array.isArray(y?.active)&&y.active.includes("compliance");}catch{}let m=`${d}:${u} components:aspects`;h?s.push({name:"Aspect coverage",status:"ok",message:`${m} (claimant: rune)`}):u===0?s.push({name:"Aspect coverage",status:"info",message:`${m} ${l.dim("(no aspects defined)")}`}):s.push({name:"Aspect coverage",status:"info",message:`${m} ${l.dim("(no claimant active)")}`});}}}catch{}}let H=i.join(p,".paradigm","flows.yaml");if(t.existsSync(H))try{let a=t.readFileSync(H,"utf8"),e=w.load(a);if(e?.version&&e?.flows){let o=Object.keys(e.flows||{}).length,n=Object.entries(e.flows||{}).filter(([,d])=>!d?.steps||(d.steps?.length??0)===0);n.length>0?s.push({name:".paradigm/flows.yaml",status:"warn",message:`${o} flows defined, ${n.length} have no steps`,fix:"Add steps to empty flow definitions"}):s.push({name:".paradigm/flows.yaml",status:"ok",message:`Valid (${o} 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(a){s.push({name:".paradigm/flows.yaml",status:"error",message:`Invalid YAML: ${a.message}`,fix:"Check YAML syntax in flows.yaml"});}let U=i.join(p,".paradigm","lore");if(t.existsSync(U))try{let a=t.readdirSync(U).filter(e=>e.endsWith(".yaml"));a.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:`${a.length} lore file${a.length>1?"s":""}`});}catch{s.push({name:"Lore entries",status:"warn",message:"Could not read lore directory"});}let _=i.join(p,".paradigm","university");if(t.existsSync(_))try{let a=i.join(_,"content"),e=0,o=0;if(t.existsSync(a))for(let n of ["notes","policies","quizzes","paths"]){let d=i.join(a,n);t.existsSync(d)&&(e+=t.readdirSync(d).filter(u=>u.endsWith(".md")||u.endsWith(".yaml")).length);}if(e===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 n=i.join(a,"quizzes");if(t.existsSync(n))for(let u of t.readdirSync(n).filter(h=>h.endsWith(".yaml")))try{let h=w.load(t.readFileSync(i.join(n,u),"utf8"));if(h?.questions)for(let m of h.questions)m.choices&&m.correct&&!(m.correct in m.choices)&&o++;}catch{}let d=i.join(a,"paths");if(t.existsSync(d))for(let u of t.readdirSync(d).filter(h=>h.endsWith(".yaml")))try{let h=w.load(t.readFileSync(i.join(d,u),"utf8"));if(h?.steps){for(let m of h.steps)if(m.content&&!m.content.startsWith("plsat:")){let y=!1;for(let b of ["notes","policies","quizzes","paths"]){let f=i.join(a,b);if(t.existsSync(f)&&t.readdirSync(f).some(k=>k.startsWith(m.content))){y=!0;break}}y||o++;}}}catch{}o>0?s.push({name:"University content",status:"warn",message:`${e} items, ${o} issue${o>1?"s":""}`,fix:"Run: paradigm university validate --deep"}):s.push({name:"University content",status:"ok",message:`${e} content item${e>1?"s":""}`});}}catch{s.push({name:"University content",status:"warn",message:"Could not read university directory"});}let G=i.join(p,".claude","hooks.json"),ss=i.join(p,"plugins","paradigm","hooks.json");if(t.existsSync(G)){let a=t.statSync(G),e=Date.now()-a.mtime.getTime(),o=Math.floor(e/(1e3*60*60*24));o>30?s.push({name:"Claude Code hooks",status:"warn",message:`Hooks are ${o} days old \u2014 may be outdated`,fix:"paradigm hooks install"}):s.push({name:"Claude Code hooks",status:"ok",message:o>0?`${o} days old`:"Fresh"});}else t.existsSync(ss)?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 V=i.join(p,".paradigm","habits.yaml");if(t.existsSync(V))try{let a=t.readFileSync(V,"utf8"),e=w.load(a);if(e?.version&&Array.isArray(e?.habits)){let o=e.habits.filter(n=>n.enabled!==!1).length;s.push({name:"Habits config",status:"ok",message:`Valid (${o}/${e.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(a){s.push({name:"Habits config",status:"error",message:`Invalid YAML: ${a.message}`,fix:"Check YAML syntax in habits.yaml"});}let J=i.join(p,"AGENTS.md");if(t.existsSync(J)){let a=t.statSync(J),e=Date.now()-a.mtime.getTime(),o=Math.floor(e/(1e3*60*60*24));o>60?s.push({name:"AGENTS.md",status:"warn",message:`${o} days since last update \u2014 may be stale`,fix:"paradigm sync"}):s.push({name:"AGENTS.md",status:"ok",message:o>0?`Updated ${o} days ago`:"Fresh"});}try{let{summarizeTeamFunnel:a}=await import('./team-funnel-RAJ6EDG3.js'),e=a(p,30);if(e.orchestrated+e.soloDeclared+e.bypasses>0||e.eligible>0){let n=e.invocationRate!==null?`${Math.round(e.invocationRate*100)}%`:"n/a",d=e.legibleRate!==null?`${Math.round(e.legibleRate*100)}%`:"n/a",u=Object.entries(e.soloByReason).map(([h,m])=>`${h}:${m}`).join(" ");s.push({name:"Team funnel (30d)",status:e.bypasses>e.orchestrated?"warn":"info",message:`eligible ${e.eligible} \xB7 orchestrated ${e.orchestrated} \xB7 solo ${e.soloDeclared}${u?` (${u})`:""} \xB7 bypass ${e.bypasses} \xB7 invocation ${n} \xB7 legible ${d}`,...e.bypasses>e.orchestrated?{fix:"Orchestrate eligible tasks (paradigm_orchestrate_inline) or declare `paradigm solo <reason>`"}:{}});}}catch{}try{let a=i.join(p,".paradigm","events","settlement-liveness.jsonl");if(t.existsSync(a)){let o=t.readFileSync(a,"utf8").trim().split(`
|
|
7
|
+
`).filter(n=>n.trim()).map(n=>{try{return JSON.parse(n)}catch{return null}}).filter(n=>n!==null);if(o.length===0)s.push({name:"Learning-loop liveness",status:"info",message:"No settlements recorded yet (probe writes on each task-DAG settlement)"});else {let n=o.slice(-20),d=o.slice(-5),u=n.filter(f=>f.chainLive===!1),h=d.filter(f=>f.chainLive===!1),m=u.length>0?u[u.length-1]:void 0,y=m?.stages?Object.entries(m.stages).filter(([,f])=>f==="threw").map(([f])=>f):[],b=y.length>0?` (stage: ${y.join(", ")})`:"";h.length>=3?s.push({name:"Learning-loop liveness",status:"error",message:`DEAD CHAIN: ${h.length}/5 recent settlements severed${b} \u2014 the learning loop is not closing`,fix:"A settlement-chain stage is throwing. Inspect .paradigm/events/settlement-liveness.jsonl and the named stage."}):u.length>0?s.push({name:"Learning-loop liveness",status:"warn",message:`${u.length}/${n.length} recent settlements had a severed chain${b}`,fix:"Inspect the named stage in .paradigm/events/settlement-liveness.jsonl."}):s.push({name:"Learning-loop liveness",status:"ok",message:`${n.length} recent settlements, chain live`});}}}catch{}}let O=0,T=0,v=0;for(let r of s){let g,c;switch(r.status){case "ok":g="\u2713",c=l.green;break;case "warn":g="\u26A0",c=l.yellow,T++;break;case "error":g="\u2717",c=l.red,O++;break;case "missing":g="\u25CB",c=l.gray,v++;break;case "info":g="\u2802",c=l.gray;break}if(!$){let A=r.name.padEnd(30);console.log(` ${c(g)} ${A} ${c(r.message)}`),r.fix&&console.log(l.gray(` \u2514\u2500 Fix: ${r.fix}`));}}let{runContextAudit:Z}=await import('./context-audit-JVCA6GSV.js'),L=await Z(p,{quiet:$}),z=0,W=0,S=0;!$&&L.length>0&&(console.log(""),console.log(l.blue(" Context Audit")),console.log(l.gray(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")));for(let r of L){let g,c;switch(r.status){case "ok":g="\u2713",c=l.green;break;case "warn":g="\u26A0",c=l.yellow,W++;break;case "error":g="\u2717",c=l.red,z++;break;case "advisory":g="\u2139",c=l.cyan,S++;break}if(!$){let A=r.check.padEnd(30);if(console.log(` ${c(g)} ${A} ${c(r.message)}`),r.details&&r.details.length>0){let R=r.details.slice(0,5);for(let M of R)console.log(l.gray(` \u2502 ${M}`));r.details.length>5&&console.log(l.gray(` \u2502 ... and ${r.details.length-5} more`));}r.fix&&console.log(l.gray(` \u2514\u2500 Fix: ${r.fix}`));}}let j=O+z,C=T+W,D=j+C+v===0;if(!$)if(console.log(""),D)console.log(l.green(`\u2728 All checks passed!
|
|
8
|
+
`));else {let r=[];j>0&&r.push(l.red(`${j} error${j>1?"s":""}`)),C>0&&r.push(l.yellow(`${C} warning${C>1?"s":""}`)),v>0&&r.push(l.gray(`${v} missing`)),S>0&&r.push(l.cyan(`${S} advisor${S>1?"ies":"y"}`)),console.log(`${r.join(", ")} found.
|
|
9
|
+
`),console.log(l.gray("Run the suggested commands to fix issues.")),console.log(l.gray(`Troubleshooting guide: .paradigm/docs/troubleshooting.md
|
|
10
|
+
`));}if(!$&&P.explain&&!D)try{let{narrateAllGaps:r}=await import('./gap-narrator-NTXLUI7I.js'),g=[];for(let c of s)c.status!=="ok"&&(c.name===".purpose"||c.name.startsWith("Purpose-required")?g.push({type:"missing-purpose",target:c.name,severity:"improvement"}):c.name===".paradigm/scan-index.json"&&c.status==="warn"?g.push({type:"index-stale",target:c.name,severity:"improvement"}):c.name==="Portal compliance"?g.push({type:"portal-mismatch",target:c.name,severity:c.status==="error"?"blocking":"improvement"}):c.name==="Clarification markers"&&g.push({type:"missing-description",target:c.name,severity:"improvement"}));if(g.length>0){let c=r(g);console.log(l.blue(`
|
|
11
|
+
Gap Narrations (--explain)
|
|
12
|
+
`)),console.log(l.gray(c.narrative)),console.log("");}}catch{}D?q.success("All health checks passed",{total:s.length+L.length}):q.error("Health checks found issues",{errors:j,warnings:C,missing:v,advisories:S});try{let{captureSnapshot:r}=await import('./metrics-UESGUHTA.js');r(p);}catch{}return D}export{rs as a};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {a,e,d}from'./chunk-QO7YPQXC.js';import'./chunk-5TAVYPOV.js';import*as u from'fs';import*as m from'path';import {execSync}from'child_process';import n from'chalk';import*as w from'js-yaml';function $(s){return s.match(/(?:^|\s)((?:\/|\.\/|[a-zA-Z0-9_-]+\/)[^\s,;:'"]+\.[a-zA-Z]{1,10})\b/)?.[1]}async function R(s,a$1){try{let r=a(s),d$1=[];try{d$1=execSync("git diff --name-only HEAD",{cwd:s,encoding:"utf8",timeout:5e3}).trim().split(`
|
|
3
3
|
`).filter(Boolean);}catch{}let l;try{l=execSync("git status --porcelain",{cwd:s,encoding:"utf8",timeout:5e3}).trim()==="";}catch{}let c=m.join(s,"portal.yaml"),f=!1;if(u.existsSync(c))try{let t=u.readFileSync(c,"utf8"),e=w.load(t);f=e?.routes!=null&&Object.keys(e.routes).length>0;}catch{}let i=e({toolsCalled:[],filesModified:d$1,symbolsTouched:[],loreRecorded:!1,hasPortalRoutes:f,taskAddsRoutes:!1,gitClean:l}),o=d(r,a$1,i),g=0;if(o.evaluations.length>0)try{let t=m.join(s,".paradigm","sentinel");if(u.existsSync(t)){let{SentinelStorage:e}=await import('./dist-VGFSP3XM.js'),p=new e(t);for(let b of o.evaluations)p.recordPracticeEvent({habitId:b.habit.id,habitCategory:b.habit.category,result:b.result,engineer:"agent",sessionId:`cli-${Date.now().toString(36)}`,symbolsTouched:[],filesModified:d$1,notes:b.reason}),g++;}}catch{}let h=m.join(s,".paradigm",".habits-blocking");try{if(a$1==="on-stop"&&o.blocksCompletion){let t=o.evaluations.filter(e=>e.result==="skipped"&&e.habit.severity==="block").map(e=>`${e.habit.name}: ${e.reason}`);u.writeFileSync(h,t.join(`
|
|
4
|
-
`),"utf8");}else a$1==="on-stop"&&u.existsSync(h)&&u.unlinkSync(h);}catch{}return {trigger:a$1,evaluation:{total:o.summary.total,followed:o.summary.followed,skipped:o.summary.skipped,partial:o.summary.partial,blockingViolations:o.summary.blockingViolations,blocksCompletion:o.blocksCompletion},habits:o.evaluations.map(t=>({id:t.habit.id,name:t.habit.name,category:t.habit.category,severity:t.habit.severity,result:t.result,reason:t.reason,evidence:t.evidence})),recorded:g}}catch{return null}}async function P(s,a){let r=m.join(s,".paradigm","aspect-graph.db");if(!u.existsSync(r))return {driftedCount:0,healedCount:0,cleanCount:0,missingCount:0,details:[]};try{let{driftCheckCommand:d}=await import('./drift-ILZE5BFJ.js'),l="",c=console.log;console.log=f=>{l=f;};try{await d({json:!0,autoHeal:a});}finally{console.log=c;}return l?JSON.parse(l):null}catch{return null}}async function B(s){if(!u.existsSync(m.join(s,"portal.yaml")))return null;try{let{checkPortalCompliance:a}=await import('./portal-compliance-JONQ4SOP.js'),r=await a(s);return {status:r.status,declaredButUnusedCount:r.declaredButUnused.length,usedButUndeclaredCount:r.usedButUndeclared.length,properlyDeclaredCount:r.properlyDeclared.length,declaredButUnused:r.declaredButUnused,usedButUndeclared:r.usedButUndeclared,properlyDeclared:r.properlyDeclared,portalError:r.portalError,...r.nearMatches&&r.nearMatches.length>0?{suggestions:r.nearMatches.map(d=>({gate:d.gate,didYouMean:d.didYouMean,distance:d.distance}))}:{}}}catch{return null}}async function j(s){try{let{runPostflightLearning:a}=await import('./ambient-
|
|
4
|
+
`),"utf8");}else a$1==="on-stop"&&u.existsSync(h)&&u.unlinkSync(h);}catch{}return {trigger:a$1,evaluation:{total:o.summary.total,followed:o.summary.followed,skipped:o.summary.skipped,partial:o.summary.partial,blockingViolations:o.summary.blockingViolations,blocksCompletion:o.blocksCompletion},habits:o.evaluations.map(t=>({id:t.habit.id,name:t.habit.name,category:t.habit.category,severity:t.habit.severity,result:t.result,reason:t.reason,evidence:t.evidence})),recorded:g}}catch{return null}}async function P(s,a){let r=m.join(s,".paradigm","aspect-graph.db");if(!u.existsSync(r))return {driftedCount:0,healedCount:0,cleanCount:0,missingCount:0,details:[]};try{let{driftCheckCommand:d}=await import('./drift-ILZE5BFJ.js'),l="",c=console.log;console.log=f=>{l=f;};try{await d({json:!0,autoHeal:a});}finally{console.log=c;}return l?JSON.parse(l):null}catch{return null}}async function B(s){if(!u.existsSync(m.join(s,"portal.yaml")))return null;try{let{checkPortalCompliance:a}=await import('./portal-compliance-JONQ4SOP.js'),r=await a(s);return {status:r.status,declaredButUnusedCount:r.declaredButUnused.length,usedButUndeclaredCount:r.usedButUndeclared.length,properlyDeclaredCount:r.properlyDeclared.length,declaredButUnused:r.declaredButUnused,usedButUndeclared:r.usedButUndeclared,properlyDeclared:r.properlyDeclared,portalError:r.portalError,...r.nearMatches&&r.nearMatches.length>0?{suggestions:r.nearMatches.map(d=>({gate:d.gate,didYouMean:d.didYouMean,distance:d.distance}))}:{}}}catch{return null}}async function j(s){try{let{runPostflightLearning:a}=await import('./ambient-SST5CLEC.js');return await a(s)}catch{return null}}async function A(s){let a=process.cwd(),r=s.trigger||"on-stop",d=s.autoHeal!==false,l=[],c=[],f=await R(a,r),i=await P(a,d),o=await B(a);if(f?.evaluation.blocksCompletion){let t=f.habits.filter(e=>e.result==="skipped"&&e.severity==="block");for(let e of t){let p=`Blocking habit not satisfied: ${e.name} \u2014 ${e.reason}`;l.push(p),c.push({message:p,source:"habits",file:$(e.reason),severity:"blocking"});}}if(i&&i.driftedCount>0){let t=`${i.driftedCount} aspect anchor(s) have drifted (content genuinely changed). Run paradigm_aspect_check to review.`;l.push(t);for(let e of i.details.filter(p=>p.status==="drifted"))c.push({message:`Aspect ~${e.aspectId} drifted at lines ${e.startLine}-${e.endLine}`,source:"drift",file:e.path,severity:"advisory"});c.filter(e=>e.source==="drift").length===0&&c.push({message:t,source:"drift",severity:"advisory"});}if(o&&o.portalError?.kind==="unparseable"){let e=`portal.yaml unparseable: ${o.portalError.errorClass} \u2014 run 'paradigm doctor' for details`;l.push(e),c.push({message:e,source:"portal",file:"portal.yaml",severity:"blocking"});}else if(o&&o.usedButUndeclaredCount>0){let t=o.usedButUndeclared.filter(e=>e!=="__portal_unparseable__");if(t.length>0){let e=`${t.length} gate(s) used in code but not declared in portal.yaml: ${t.join(", ")}`;l.push(e);for(let p of t)c.push({message:`Gate ^${p} used in code but not declared in portal.yaml`,source:"portal",file:"portal.yaml",severity:"blocking"});}}let g=null;s.learn&&(g=await j(a));let h={habits:f,drift:i,portal:o,violations:l,structuredViolations:c,postflight:s.learn?g:void 0};if(s.json)console.log(JSON.stringify(h));else {if(console.log(n.magenta(`
|
|
5
5
|
Paradigm Compliance Check
|
|
6
6
|
`)),f){let{evaluation:t}=f,e=t.blocksCompletion?n.red:n.green;console.log(n.white(" Habits:")),console.log(` ${e(`${t.followed} followed, ${t.skipped} skipped, ${t.partial} partial`)}`),t.blockingViolations>0&&console.log(n.red(` ${t.blockingViolations} blocking violation(s)`)),console.log();}if(i&&(console.log(n.white(" Drift:")),i.healedCount>0&&console.log(n.green(` Auto-healed: ${i.healedCount} shifted anchor(s)`)),i.cleanCount>0&&console.log(n.green(` Clean: ${i.cleanCount} anchor(s)`)),i.driftedCount>0&&console.log(n.red(` Drifted: ${i.driftedCount} anchor(s)`)),i.missingCount>0&&console.log(n.yellow(` Missing: ${i.missingCount} anchor file(s)`)),console.log()),o){console.log(n.white(" Portal:"));let t=o.status==="compliant"?n.green:o.status==="warnings"?n.yellow:n.red;console.log(` Status: ${t(o.status)}`),o.usedButUndeclaredCount>0&&console.log(n.red(` ${o.usedButUndeclaredCount} undeclared gate(s)`)),console.log();}if(g){if(console.log(n.white(" Postflight Learning:")),g.journalsWritten>0){console.log(n.green(` Journals written: ${g.journalsWritten}`));for(let[t,e]of Object.entries(g.journalsByAgent))e>0&&console.log(n.gray(` ${t}: ${e} entries`));}else console.log(n.gray(" No verdicts to learn from"));g.promoted>0&&console.log(n.green(` Promoted to notebooks: ${g.promoted}`)),console.log();}if(l.length>0){console.log(n.red(` ${l.length} violation(s):`));for(let t of l)console.log(n.red(` - ${t}`));}else console.log(n.green(" All checks passed."));console.log();}l.length>0&&(process.exitCode=1);}export{A as complianceCheckCommand};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {b}from'./chunk-
|
|
2
|
+
import {b}from'./chunk-6AKNXD22.js';import'./chunk-DLMDHS2X.js';import'./chunk-FYDRENK7.js';import'./chunk-ECLUYHAR.js';import'./chunk-TYWB5IQJ.js';import'./chunk-YXLGVOZO.js';import'./chunk-EKZDFEJW.js';import'./chunk-LPBCQM5Y.js';import'./chunk-4GC35IFF.js';import'./chunk-JIXHEBGK.js';import'./chunk-ZJQY5PPP.js';import'./chunk-5TAVYPOV.js';import*as i from'fs';import*as a from'path';import o from'chalk';async function D(l,f,t){let d=f?a.resolve(f):process.cwd();if(!l){t.json?console.log(JSON.stringify({error:"Orchestration ID required"})):(console.log(o.red(`
|
|
3
3
|
Orchestration ID required.`)),console.log(o.gray(`Usage: paradigm team diff <orchestration-id>
|
|
4
4
|
`)));return}let e=new b(d).getOrchestration(l);if(!e){t.json?console.log(JSON.stringify({error:"Orchestration not found",id:l})):console.log(o.red(`
|
|
5
5
|
Orchestration not found: ${l}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {a,d,e,f,g,b}from'./chunk-BFD3GFRK.js';import'./chunk-5TAVYPOV.js';import n from'chalk';import*as t from'fs';import*as o from'path';import {fileURLToPath}from'url';async function C(c){let s=process.cwd(),e=parseInt(c.port||"3850",10),p=c.open!==false;console.log(n.cyan(`
|
|
3
3
|
Starting Paradigm Docs...
|
|
4
|
-
`));try{let{startPlatformServer:i}=await import('./platform-server-
|
|
4
|
+
`));try{let{startPlatformServer:i}=await import('./platform-server-WIBVYHIV.js');await i({projectDir:s,port:e,open:p,sections:["overview","docs"]}),console.log(n.green(` Docs running at ${n.bold(`http://localhost:${e}`)}`)),console.log(n.gray(` Press Ctrl+C to stop
|
|
5
5
|
`)),await new Promise(()=>{});}catch(i){i.code==="EADDRINUSE"?(console.error(n.red(`
|
|
6
6
|
Error: Port ${e} is already in use.`)),console.log(n.gray(` Try: paradigm docs serve --port ${e+1}
|
|
7
7
|
`))):console.error(n.red(`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
export{a as hooksInstallCommand,c as hooksStatusCommand,b as hooksUninstallCommand}from'./chunk-
|
|
2
|
+
export{a as hooksInstallCommand,c as hooksStatusCommand,b as hooksUninstallCommand}from'./chunk-G6DK3ND3.js';import'./chunk-5TAVYPOV.js';
|