@a-company/paradigm 6.2.0 → 6.3.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/arch-loader-T3TARMSO.js +2 -0
- package/dist/chunk-32XL3FIQ.js +2 -0
- package/dist/chunk-ARLB6YYW.js +3 -0
- package/dist/chunk-EMGJWT7D.js +111 -0
- package/dist/chunk-SRWROALW.js +666 -0
- package/dist/chunk-SU5F5D4I.js +3 -0
- package/dist/{enforcement-46XWPNSA.js → enforcement-FXO6IYYE.js} +1 -1
- package/dist/{enforcement-BEGPQIUN.js → enforcement-VRE3WZOI.js} +1 -1
- package/dist/index.js +2 -2
- package/dist/mcp.js +3 -52
- package/dist/reindex-PJVOMN57.js +2 -0
- package/dist/rune-promotion-3JQ5LMWK.js +3 -0
- package/dist/{shift-3ATE2ONQ.js → shift-6Y3KQP62.js} +2 -2
- package/dist/tools-2XPMZZBT.js +2 -0
- package/dist/university-content/notes/N-para-001-shift-setup.md +2 -2
- package/dist/university-content/notes/N-para-301-enforcement-levels.md +18 -11
- package/dist/university-content/notes/N-para-301-paradigm-shift.md +2 -2
- package/dist/university-content/notes/N-para-301-rune-promotion.md +69 -0
- package/dist/university-content/notes/N-para-501-hook-enforcement.md +3 -1
- package/dist/university-content/notes/N-para-701-orchestration-enforcement.md +10 -1
- package/dist/university-content/quizzes/Q-para-301-enforcement-levels.yaml +21 -1
- package/dist/university-content/quizzes/Q-para-701-orchestration-enforcement.yaml +11 -1
- package/dist/university-ui/assets/{index-CkgaxOXi.js → index-SNyIB61M.js} +2 -2
- package/dist/university-ui/assets/{index-CkgaxOXi.js.map → index-SNyIB61M.js.map} +1 -1
- package/dist/university-ui/index.html +1 -1
- package/package.json +1 -1
- package/dist/chunk-K7EQHFZP.js +0 -111
- package/dist/chunk-KYA4TP26.js +0 -2
- package/dist/chunk-UMC4RC66.js +0 -636
- package/dist/reindex-GSRV4MQO.js +0 -2
- package/dist/tools-F34P22PW.js +0 -2
|
@@ -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 O={"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"},A={"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"},V={"purpose-coverage":"off","purpose-exists":"off","portal-gates":"off","aspect-anchors":"off","purpose-freshness":"off","aspect-advisory":"off","lore-required":"off","habits-blocking":"off","purpose-required-patterns":"off","drift-detection":"off","portal-compliance":"off","graduation-tracking":"off","orchestration-required":"off"},x={strict:O,balanced:A,minimal:P,none:V};function l(e){return {...x[e]}}function T(e,r){return x[e][r]}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"||e==="none"}var L="none",j={threshold:3,detection:"git-diff",exempt:["*.md","*.yaml","*.yml",".purpose"]};function _(e){let r=m.join(e,".paradigm","config.yaml");if(!i.existsSync(r))return h();try{let o=i.readFileSync(r,"utf8"),t=f.load(o);if(!t||typeof t!="object")return h();let n=t.enforcement;if(!n||typeof n!="object")return h();let y=n.level,q=typeof y=="string"&&S(y)?y:L,v=n.checks,w={};if(v&&typeof v=="object")for(let[d,C]of Object.entries(v))b(d)&&typeof C=="string"&&E(C)&&(w[d]=C);let c=n.orchestration,p={...j};return c&&typeof c=="object"&&(typeof c.threshold=="number"&&(p.threshold=c.threshold),typeof c.detection=="string"&&(p.detection=c.detection),Array.isArray(c.exempt)&&(p.exempt=c.exempt.filter(d=>typeof d=="string"))),{level:q,checks:w,orchestration:p}}catch{return h()}}function h(){return {level:L,checks:{},orchestration:{...j}}}function D(e,r){let o=e.checks[r];return o!==void 0?o:l(e.level)[r]}function F(e){let r=l(e.level);for(let o of s){let t=e.checks[o];t!==void 0&&(r[o]=t);}return r}function k(e){let r=m.join(e,".paradigm","config.yaml");if(!i.existsSync(r))throw new Error(`Config not found: ${r}`);let o=i.readFileSync(r,"utf8"),t=f.load(o);if(!t||typeof t!="object")throw new Error("Config is not a valid YAML object");return [t,o]}function a(e,r){let o=m.join(e,".paradigm","config.yaml"),t=f.dump(r,{lineWidth:-1,noRefs:true,sortKeys:false,quotingType:"'"});i.writeFileSync(o,t,"utf8");}function g(e){return (!e.enforcement||typeof e.enforcement!="object")&&(e.enforcement={level:"none",checks:{}}),e.enforcement}function H(e,r){let[o]=k(e),t=g(o);t.level=r,a(e,o);}function K(e,r,o){let[t]=k(e),n=g(t);(!n.checks||typeof n.checks!="object")&&(n.checks={}),n.checks[r]=o,a(e,t);}function N(e,r){let[o]=k(e),t=g(o);t.checks&&typeof t.checks=="object"&&delete t.checks[r],a(e,o);}function M(e){let[r]=k(e),o=g(r);o.checks={},a(e,r);}function U(e){let r=m.join(e,".paradigm","config.yaml");if(!i.existsSync(r))return false;try{let o=i.readFileSync(r,"utf8"),t=f.load(o);return !t||typeof t!="object"||t.enforcement?!1:(t.enforcement={level:"none",checks:{},orchestration:{threshold:3,detection:"git-diff",exempt:["*.md","*.yaml","*.yml",".purpose"]}},a(e,t),!0)}catch{return false}}export{s as a,l as b,T as c,b as d,E as e,S as f,_ as g,D as h,F as i,H as j,K as k,N as l,M as m,U as n};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {l}from'./chunk-SU5F5D4I.js';import {b as b$1,a}from'./chunk-EK4ZRIFJ.js';import*as i from'fs';import*as c from'path';import*as f from'js-yaml';b$1();var g=".paradigm/arch.yaml";function u(e){let n=c.join(e,g);if(!i.existsSync(n))return null;try{let t=i.readFileSync(n,"utf8");return f.load(t)}catch{return null}}function S(e,n){let t=c.join(e,g),r=c.dirname(t);i.existsSync(r)||i.mkdirSync(r,{recursive:true}),i.writeFileSync(t,f.dump(n,{lineWidth:-1,noRefs:true}),"utf8");}function b(e,n){let t=u(e);if(!t)return {unassigned:[],missing_purpose:[]};let r=new Set;for(let o of t.tiers)for(let p of o.components)r.add(p);let s=new Set;try{let o=l(n.index,"component");for(let p of o)s.add(p.symbol);}catch(o){a.component("#arch-loader").warn("Could not load symbol index for drift check",{error:String(o)});}let a$1=Array.from(s).filter(o=>!r.has(o)),h=Array.from(r).filter(o=>!s.has(o));return {unassigned:a$1,missing_purpose:h}}function k(e){let n=r=>r.replace(/[^a-zA-Z0-9_-]/g,"-"),t=["graph TD"];for(let r of e.tiers){let s=n(r.id);t.push(` ${s}["${r.label}\\n(${r.responsibility})"]`);}for(let r of e.links){let s=n(r.from),a=n(r.to);r.via?t.push(` ${s} -->|"${r.via}"| ${a}`):t.push(` ${s} --> ${a}`);}return t.join(`
|
|
3
|
+
`)}export{g as a,u as b,S as c,b as d,k as e};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {i,a as a$3,f,h as h$1}from'./chunk-SU5F5D4I.js';import {a as a$2,b as b$4,c as c$2}from'./chunk-M4UMM6DC.js';import {j,b as b$3,a as a$4}from'./chunk-GRZQIKST.js';import {j as j$1,a,c as c$1,b as b$2,k}from'./chunk-6QXBXZF6.js';import {b as b$1,a as a$1}from'./chunk-EK4ZRIFJ.js';import {c,b,d}from'./chunk-5TAVYPOV.js';import*as h from'fs';import*as x from'path';import*as te from'crypto';import {execSync}from'child_process';import*as N from'js-yaml';import*as Se from'os';import In from'sql.js';var bt={};c(bt,{contentSearch:()=>Rn,detectFileRename:()=>yt,generateFingerprint:()=>mt,levenshteinDistance:()=>ht,levenshteinSimilarity:()=>Fe,searchSiblingFiles:()=>St,slidingWindowSearch:()=>we});function mt(t){let e=t.split(`
|
|
3
|
+
`).filter(r=>r.trim()!=="");return {firstLine:be(e[0]||""),lastLine:be(e[e.length-1]||""),lineCount:e.length,structuralHash:gt(e)}}function gt(t){let e=t.map(r=>r.trim()).filter(r=>ft.test(r)).map(r=>{let n=r.match(ft);return n?n[1].trim():""}).join("|");return te.createHash("sha256").update(e).digest("hex").slice(0,16)}function be(t){return t.trim().replace(/\s+/g," ").toLowerCase()}function ht(t,e){if(t===e)return 0;if(t.length===0)return e.length;if(e.length===0)return t.length;t.length>e.length&&([t,e]=[e,t]);let r=t.length,n=e.length;if(r>5e3||n>5e3)return Math.abs(r-n);let s=new Array(r+1),o=new Array(r+1);for(let i=0;i<=r;i++)s[i]=i;for(let i=1;i<=n;i++){o[0]=i;for(let a=1;a<=r;a++){let c=t[a-1]===e[i-1]?0:1;o[a]=Math.min(s[a]+1,o[a-1]+1,s[a-1]+c);}[s,o]=[o,s];}return s[r]}function Fe(t,e){if(t.length===0&&e.length===0)return 1;let r=Math.max(t.length,e.length);return 1-ht(t,e)/r}function we(t,e,r,n=3){let{lineCount:s}=e,o=Math.max(1,Math.floor(s*.8)),i=Math.ceil(s*1.2),a=[],c=Oe(r);for(let u of [s,o,i])if(!(u>t.length))for(let d=0;d<=t.length-u;d++){let f=t.slice(d,d+u),m=kn(f,e,c);if(m>=.5){let p=f.join(`
|
|
4
|
+
`);a.push({windowStart:d+1,windowEnd:d+u,similarity:Fe(Oe(p),c),score:m});}}let l=new Map;for(let u of a){let d=l.get(u.windowStart);(!d||u.score>d.score)&&l.set(u.windowStart,u);}return Array.from(l.values()).sort((u,d)=>d.score-u.score).slice(0,n)}function kn(t,e,r){let n=t.filter(f=>f.trim()!=="");if(n.length===0)return 0;let s=0,o=be(n[0]),i=be(n[n.length-1]),a=0;o===e.firstLine&&(a+=.5),i===e.lastLine&&(a+=.5),s+=a*En,gt(n)===e.structuralHash&&(s+=Tn);let l=n.join(`
|
|
5
|
+
`),u=Fe(Oe(l),r);u>=.8&&(s+=(u-.8)/.2*vn);let d=n.length/e.lineCount;if(d>=.8&&d<=1.2){let f=1-Math.abs(1-d)/.2;s+=f*_n;}return s}function Oe(t){return t.split(`
|
|
6
|
+
`).map(e=>e.trim()).filter(e=>e!=="").join(`
|
|
7
|
+
`)}function yt(t,e){try{let r=execSync(`git log --follow --diff-filter=R --name-status --format="" -- "${e}"`,{cwd:t,encoding:"utf8",timeout:5e3}).trim();if(!r)return null;let n=r.split(`
|
|
8
|
+
`);for(let s of n){let o=s.split(" ");if(o.length>=3&&o[0].startsWith("R"))return o[2]}return null}catch{return null}}function St(t,e,r,n,s=10){let o=x.isAbsolute(e)?e:x.join(t,e);if(!h.existsSync(o))return [];let i=[];try{let a=h.readdirSync(o).filter(c=>!c.startsWith(".")&&h.statSync(x.join(o,c)).isFile()).slice(0,s);for(let c of a)try{let u=h.readFileSync(x.join(o,c),"utf8").split(`
|
|
9
|
+
`),d=we(u,r,n,1);if(d.length>0&&d[0].score>=.7){let f=x.relative(t,x.join(o,c));i.push({file:f,score:d[0].score,start:d[0].windowStart,end:d[0].windowEnd});}}catch{}}catch{return []}return i.sort((a,c)=>c.score-a.score)}function Rn(t,e,r,n=true){let s=mt(r),o=x.isAbsolute(e)?e:x.join(t,e);if(h.existsSync(o)){let u=h.readFileSync(o,"utf8").split(`
|
|
10
|
+
`),d=we(u,s,r);if(d.length>0){let f=d[0];return {found:f.score>=.7,score:f.score,suggestedStart:f.windowStart,suggestedEnd:f.windowEnd,similarity:f.similarity}}}let i=yt(t,e);if(i){let l=x.join(t,i);if(h.existsSync(l)){let d=h.readFileSync(l,"utf8").split(`
|
|
11
|
+
`),f=we(d,s,r);if(f.length>0&&f[0].score>=.7)return {found:true,score:f[0].score,suggestedStart:f[0].windowStart,suggestedEnd:f[0].windowEnd,suggestedPath:i,similarity:f[0].similarity}}}let a=x.dirname(e),c=St(t,a,s,r);if(c.length>0&&c[0].score>=.7){let l=c[0];return {found:true,score:l.score,suggestedStart:l.start,suggestedEnd:l.end,suggestedPath:l.file!==e?l.file:void 0,similarity:l.score}}return {found:false,score:0}}var ft,En,Tn,vn,_n,wt=b(()=>{ft=/^\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 )/;En=.4,Tn=.3,vn=.2,_n=.1;});var sn="0.1.0",rn="1.0.0";function Pe(t,e){let r={$meta:on(e.projectName,t),components:{},features:{},flows:{},state:{},gates:{},signals:{},aspects:{},screens:{},symbolMap:{}};for(let s of t.symbols)an(s,r,e);if(e.screenDefinitions)for(let[s,o]of Object.entries(e.screenDefinitions))r.screens[s]||(r.screens[s]={id:s,name:Z(s),route:o.route,path:"",components:o.components,features:o.features});let n={};for(let s of Object.values(r.components))s.componentType&&(n[s.componentType]=(n[s.componentType]||0)+1);for(let s of Object.values(r.features))s.componentType&&(n[s.componentType]=(n[s.componentType]||0)+1);return Object.keys(n).length>0&&(r.$meta.componentTypes=n),gn(r),r}function on(t,e){return {version:rn,project:t,generatedAt:new Date().toISOString(),paradigmVersion:sn,sources:{purposeFiles:e.purposeFiles.length,portalFiles:e.portalFiles.length,premiseFiles:e.symbols.filter(r=>r.source==="premise").length>0?1:0}}}function an(t,e,r){let{type:n}=t;switch(n){case "component":cn(t,e,r);break;case "feature":ln(t,e,r);break;case "flow":dn(t,e);break;case "state":un(t,e);break;case "gate":fn(t,e);break;case "signal":pn(t,e);break;case "aspect":mn(t,e);break;}}function cn(t,e,r){let n=re(t.symbol),s=at(n,t.data,r.visualTagMappings),o={id:n,name:Z(n),symbol:t.symbol,category:"components",path:t.filePath,description:t.description,visualTags:s,related:t.references,componentType:t.componentType,parent:t.parentSymbol};e.components[n]=o,e.symbolMap[t.symbol]={category:"components",id:n};}function ln(t,e,r){let n=re(t.symbol),s=at(n,t.data,r.visualTagMappings),o={id:n,name:Z(n),symbol:t.symbol,category:"features",path:t.filePath,description:t.description,visualTags:s,related:t.references,componentType:t.componentType,parent:t.parentSymbol};e.features[n]=o,e.symbolMap[t.symbol]={category:"features",id:n};}function dn(t,e){let r=re(t.symbol),n=t.data,s=[];if(n?.steps)for(let i=0;i<n.steps.length;i++){let a=n.steps[i];s.push({id:`${r}-step-${i}`,name:a.action||`Step ${i+1}`,target:a.component,description:a.description,order:i});}let o={id:r,name:Z(r),symbol:t.symbol,path:t.filePath,description:t.description,steps:s};e.flows[r]=o,e.symbolMap[t.symbol]={category:"flows",id:r};}function un(t,e){let r=re(t.symbol),n={id:r,name:Z(r),symbol:t.symbol,path:t.filePath,description:t.description,consumers:t.referencedBy};e.state[r]=n,e.symbolMap[t.symbol]={category:"state",id:r};}function fn(t,e){let r=re(t.symbol),n={id:r,name:Z(r),symbol:t.symbol,category:"gates",path:t.filePath,description:t.description,related:t.references};e.gates[r]=n,e.symbolMap[t.symbol]={category:"gates",id:r};}function pn(t,e){let r=re(t.symbol),n={id:r,name:Z(r),symbol:t.symbol,category:"signals",path:t.filePath,description:t.description,related:t.references};e.signals[r]=n,e.symbolMap[t.symbol]={category:"signals",id:r};}function mn(t,e){let r=re(t.symbol),n={id:r,name:Z(r),symbol:t.symbol,category:"aspects",path:t.filePath,description:t.description,related:t.references};e.aspects[r]=n,e.symbolMap[t.symbol]={category:"aspects",id:r};}function gn(t){for(let e of Object.values(t.screens))if(e.components)for(let r of e.components){let n=t.components[r];n&&(n.screens=n.screens||[],n.screens.includes(e.id)||n.screens.push(e.id));}}function re(t){return t.slice(1)}function Z(t){return t.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function at(t,e,r){let n=[];if(r?.[t])return r[t];let s=[[/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[o,i]of s)o.test(t)&&n.push(i);return n}function Ce(t){return JSON.stringify(t,null,2)}function Ae(t,e="unknown"){j$1().trackToolCall(e,t);}function Gs(t,e="paradigm://unknown"){j$1().trackResourceRead(e,t);}function hn(){k();}function yn(t,e){switch(t){case "paradigm_search":return {summary:`Searched for "${e.query}"${e.type?` (type: ${e.type})`:""}`,symbol:e.query};case "paradigm_ripple":return {summary:`Ripple analysis on ${e.symbol}${e.depth?` (depth: ${e.depth})`:""}`,symbol:e.symbol};case "paradigm_related":return {summary:`Checked relations for ${e.symbol}`,symbol:e.symbol};case "paradigm_status":return {summary:"Checked project status"};case "paradigm_navigate":{let r=e.intent,n=e.target,s=e.task;return r==="context"&&s?{summary:`Navigate context: "${s}"`}:n?{summary:`Navigate ${r||"find"}: ${n}`,symbol:n}:{summary:`Navigate (${r||"unknown"})`}}case "paradigm_gates_for_route":return {summary:`Gate suggestions for ${e.method||"GET"} ${e.route}`};case "paradigm_wisdom_context":return {summary:`Checked wisdom for ${Array.isArray(e.symbols)?e.symbols.join(", "):"symbols"}`,symbol:Array.isArray(e.symbols)?e.symbols[0]:void 0};case "paradigm_history_context":return {summary:`Checked history for ${Array.isArray(e.symbols)?e.symbols.join(", "):"symbols"}`,symbol:Array.isArray(e.symbols)?e.symbols[0]:void 0};case "paradigm_history_record":return {summary:`Recorded ${e.type}: ${(e.description||"").slice(0,60)}`,symbol:Array.isArray(e.symbols)?e.symbols[0]:void 0};case "paradigm_history_fragility":return {summary:`Checked fragility for ${Array.isArray(e.symbols)?e.symbols.join(", "):"symbols"}`,symbol:Array.isArray(e.symbols)?e.symbols[0]:void 0};case "paradigm_flows_affected":return {summary:`Checked flows affected by ${e.symbol}`,symbol:e.symbol};case "paradigm_reindex":return {summary:"Rebuilt static index files"};case "paradigm_session_checkpoint":return {summary:`Checkpoint: phase=${e.phase}, ${(e.context||"").slice(0,60)}`};case "paradigm_task_create":return {summary:`Created task: "${(e.blurb||"").slice(0,60)}"`};case "paradigm_task_done":return {summary:`Completed task ${e.id}`};case "paradigm_task_shelve":return {summary:`Shelved task ${e.id}`};case "paradigm_task_list":return {summary:`Listed tasks (status: ${e.status||"open"})`};case "paradigm_task_update":return {summary:`Updated task ${e.id}`};case "paradigm_assessment_record":return {summary:`Assessment: ${(e.title||"").slice(0,60)} \u2192 ${e.arc_id}`,symbol:Array.isArray(e.symbols)?e.symbols[0]:void 0};case "paradigm_assessment_list":return {summary:e.arc_id?`Listed entries in ${e.arc_id}`:"Listed assessment arcs"};case "paradigm_assessment_search":return {summary:`Searched assessments${e.symbol?` for ${e.symbol}`:""}`,symbol:e.symbol};case "paradigm_assessment_arc_create":return {summary:`Created arc: ${e.id}`};case "paradigm_assessment_arc_close":return {summary:`Closed arc: ${e.arc_id}`};default:{let r=t.replace(/^paradigm_/,""),n=Object.values(e).find(s=>typeof s=="string"&&s.length>0);return {summary:n?`${r}: ${n.slice(0,60)}`:r,symbol:e.symbol||void 0}}}}function Bs(t,e){let r=j$1(),{summary:n,symbol:s}=yn(t,e);r.addBreadcrumb("tool-call",n,{tool:t,symbol:s});}function Xs(){return [{name:"paradigm_session_health",description:"Check if context handoff is recommended based on session activity. Call this periodically during long sessions. Returns usage percentage and recommendation (continue, consider-handoff, handoff-recommended, handoff-urgent). ~100 tokens.",inputSchema:{type:"object",properties:{estimatedTotalTokens:{type:"number",description:"Optional: Your estimate of total conversation tokens (if available)"},contextWindowSize:{type:"number",description:"Context window size in tokens (default: 200000)"}}},annotations:{readOnlyHint:true,destructiveHint:false}},{name:"paradigm_context_check",description:"DEPRECATED: renamed to paradigm_session_health. This alias will be removed in a future version.",inputSchema:{type:"object",properties:{}},annotations:{readOnlyHint:true,destructiveHint:false}},{name:"paradigm_handoff_prepare",description:"Prepare a handoff summary. Generates a structured handoff file with markdown summary and recovery instructions. Returns structured markdown with summary, modified files, and next steps. ~300 tokens.",inputSchema:{type:"object",properties:{summary:{type:"string",description:"Brief summary of work done in this session"},nextSteps:{type:"array",items:{type:"string"},description:"List of next steps for the continuing session"},agent:{type:"string",description:'Target agent role (e.g., "builder", "architect")'},modifiedFiles:{type:"array",items:{type:"string"},description:"List of files modified in this session"},symbolsTouched:{type:"array",items:{type:"string"},description:"List of symbols (@feature, #component, etc.) touched"},openQuestions:{type:"array",items:{type:"string"},description:"Unresolved questions or decisions needed"}},required:["summary"]},annotations:{readOnlyHint:false,destructiveHint:false}},{name:"paradigm_session_stats",description:"Get current session statistics (MCP interactions, estimated tokens). Returns tool call count, estimated tokens used, and cost breakdown. ~100 tokens.",inputSchema:{type:"object",properties:{}},annotations:{readOnlyHint:true,destructiveHint:false}},{name:"paradigm_session_recover",description:"Load previous session breadcrumbs for continuity. Call this at the start of a new session to understand what was done before. Returns symbols modified, files explored, recent actions, and suggestions for continuity. ~200 tokens. NOTE: Recovery data is automatically surfaced as a preamble on the first tool call of each session \u2014 explicit calls are retained for direct inspection or forcing a second recovery pass.",inputSchema:{type:"object",properties:{}},annotations:{readOnlyHint:true,destructiveHint:false},aliases:["resume","pick up","continue","what was I doing","last session","recover"]},{name:"paradigm_session_checkpoint",description:"Save a cognitive-transition checkpoint for crash recovery. Call when transitioning between phases (planning \u2192 implementing \u2192 validating \u2192 complete). ~100 tokens.",inputSchema:{type:"object",properties:{phase:{type:"string",enum:["planning","implementing","validating","complete"],description:"Current workflow phase"},context:{type:"string",description:"What's top-of-mind right now (1-3 sentences)"},externalId:{type:"string",description:'Optional: deterministic ID from external source for automatic session recovery (e.g. "linear:PROJ-123", "github:owner/repo#42")'},plan:{type:"string",description:"Optional: the current plan or approach"},modifiedFiles:{type:"array",items:{type:"string"},description:"Optional: files modified so far"},symbolsTouched:{type:"array",items:{type:"string"},description:"Optional: symbols touched so far"},decisions:{type:"array",items:{type:"string"},description:"Optional: key decisions made so far"}},required:["phase","context"]},annotations:{readOnlyHint:false,destructiveHint:false}}]}async function qs(t,e,r){let n=j$1();if(t==="paradigm_session_health"||t==="paradigm_context_check"){let s=e.contextWindowSize||2e5,o=e.estimatedTotalTokens,i=n.getStats(),{recommendation:a,message:c,usagePercent:l,signals:u}=n.getHandoffRecommendation(s,o),d=n.getDurationMinutes();return {handled:true,text:JSON.stringify({recommendation:a,message:c,stats:{sessionDurationMinutes:d,mcpToolCalls:i.totals.toolCallCount,mcpResourceReads:i.totals.resourceReadCount,estimatedMcpTokens:i.totals.totalTokens,estimatedTotalTokens:o||Math.round(i.totals.totalTokens*5),contextWindowSize:s,usagePercent:l},signals:u,action:a==="continue"?null:"Call paradigm_handoff_prepare to create handoff file"},null,2)}}if(t==="paradigm_handoff_prepare"){let s=e.summary,o=e.nextSteps||[],i=e.agent||"builder",a$1=e.modifiedFiles||[],c=e.symbolsTouched||[],l=e.openQuestions||[],u=n.getStats(),d=n.getCostBreakdown(),f=`h${Date.now().toString(36)}`,m=new Date().toISOString(),p={id:f,timestamp:m,from:"current-session",to:i,summary:s,nextSteps:o,modifiedFiles:a$1,symbolsTouched:c,openQuestions:l,sessionStats:{duration:n.getDurationMinutes(),mcpCalls:u.totals.toolCallCount+u.totals.resourceReadCount,estimatedTokens:u.totals.totalTokens,estimatedCostUsd:d.total.costUsd,model:d.model},status:"pending"},g=false;try{a(r.rootDir,p),g=!0;}catch{}let y=`# Handoff: ${m}
|
|
12
|
+
|
|
13
|
+
## Session Summary
|
|
14
|
+
${s}
|
|
15
|
+
|
|
16
|
+
## Next Steps
|
|
17
|
+
${o.map((b,P)=>`${P+1}. ${b}`).join(`
|
|
18
|
+
`)||"(none specified)"}
|
|
19
|
+
|
|
20
|
+
## Key Context
|
|
21
|
+
- Modified files: ${a$1.length>0?a$1.join(", "):"(not specified)"}
|
|
22
|
+
- Symbols touched: ${c.length>0?c.join(", "):"(not specified)"}
|
|
23
|
+
- Open questions: ${l.length>0?l.join(", "):"(none)"}
|
|
24
|
+
`;return hn(),{handled:true,text:JSON.stringify({handoff:p,markdownSummary:y,persisted:g,recovery:"The next session will automatically receive this handoff via paradigm_session_recover."},null,2)}}if(t==="paradigm_session_stats"){let s=n.getStats(),o=n.getCostBreakdown(),i=n.getDurationMinutes();return {handled:true,text:JSON.stringify({session:{startTime:new Date(s.startTime).toISOString(),durationMinutes:i,lastActivity:new Date(s.lastActivity).toISOString()},model:{name:o.model,id:o.modelId,pricing:{inputPerMillion:`$${o.pricing.input.toFixed(2)}`,outputPerMillion:`$${o.pricing.output.toFixed(2)}`}},interactions:{toolCalls:s.totals.toolCallCount,resourceReads:s.totals.resourceReadCount,totalInteractions:s.totals.toolCallCount+s.totals.resourceReadCount},tokens:{total:s.totals.totalTokens,byCategory:{resources:o.resources.tokens,tools:o.tools.tokens}},cost:{totalUsd:`$${o.total.costUsd.toFixed(4)}`,breakdown:{resources:`$${o.resources.costUsd.toFixed(4)}`,tools:`$${o.tools.costUsd.toFixed(4)}`},note:"Cost is for MCP output tokens only (responses sent to model)"},details:{resourcesByType:o.resources.byType,toolsByName:o.tools.byName}},null,2)}}if(t==="paradigm_session_recover"){let{checkpoint:s,pendingHandoffs:o,previousSession:i}=ct(r.rootDir);if(!i&&o.length===0&&!s)return {handled:true,text:JSON.stringify({found:false,message:"No previous session breadcrumbs, checkpoints, or pending handoffs found.",tip:"Breadcrumbs persist to ~/.paradigm/sessions/ and handoffs persist via paradigm_handoff_prepare. Checkpoints persist via paradigm_session_checkpoint."},null,2)};let a={found:true};if(s){let l=Date.now()-s.timestamp,u=Math.round(l/6e4),d=Math.round(l/36e5);a.checkpoint={phase:s.phase,context:s.context,age:d>1?`${d} hours ago`:`${u} minutes ago`,timestamp:new Date(s.timestamp).toISOString(),sessionId:s.sessionId,plan:s.plan,modifiedFiles:s.modifiedFiles,symbolsTouched:s.symbolsTouched,decisions:s.decisions,recentBreadcrumbs:s.recentBreadcrumbs?.map(f=>({time:new Date(f.timestamp).toISOString(),action:f.action,tool:f.tool,symbol:f.symbol,summary:f.summary}))};}if(i){let l=Date.now()-i.lastActivity,u=Math.round(l/6e4),d=Math.round(l/36e5),m=i.breadcrumbs.slice(-10).map(p=>({time:new Date(p.timestamp).toISOString(),action:p.action,tool:p.tool,symbol:p.symbol,summary:p.summary}));a.previousSession={sessionId:i.sessionId,startTime:new Date(i.startTime).toISOString(),lastActivity:new Date(i.lastActivity).toISOString(),age:d>1?`${d} hours ago`:`${u} minutes ago`},a.context={symbolsModified:i.symbolsModified,filesExplored:i.filesExplored},a.recentActions=m;}if(o.length>0){a.pendingHandoffs=o.map(l=>({id:l.id,timestamp:l.timestamp,from:l.from,to:l.to,summary:l.summary,nextSteps:l.nextSteps,modifiedFiles:l.modifiedFiles,symbolsTouched:l.symbolsTouched,openQuestions:l.openQuestions}));for(let l of o)try{c$1(r.rootDir,l.id);}catch{}}let c="Continue where the previous session left off.";if(s)c=`Previous session was in "${s.phase}" phase: ${s.context}`,s.decisions?.length&&(c+=` Key decisions: ${s.decisions.slice(0,2).join("; ")}`);else if(o.length>0){let l=o[o.length-1];c=`Handoff received: "${l.summary}". `,l.nextSteps.length>0&&(c+=`Start with: ${l.nextSteps[0]}`);}else if(i){let l=i.breadcrumbs.slice(-10);if(l.length>0){let u=l[l.length-1];u.symbol&&(c=`Last work involved ${u.symbol}. Consider checking its current state with paradigm_ripple.`);}}return a.suggestion=c,a.agentInstruction="Present a brief summary of the previous session, then ask the user what they would like to do: (1) Continue \u2014 pick up where the last session left off, (2) Discard \u2014 ignore the previous session and start fresh, or (3) let them describe what they want to work on instead. Do NOT automatically continue without asking.",n.markRecovered(),{handled:true,text:JSON.stringify(a,null,2)}}if(t==="paradigm_session_checkpoint"){n.setRootDir(r.rootDir);let s=e.phase,o=e.context,i=e.externalId,a=e.plan,c=e.modifiedFiles,l=e.symbolsTouched,u=e.decisions,{checkpoint:d,persisted:f}=n.saveCheckpoint({phase:s,context:o,externalId:i,plan:a,modifiedFiles:c,symbolsTouched:l,decisions:u}),m=f.local||f.global;return {handled:true,text:JSON.stringify({saved:m,persisted:f,checkpoint:{phase:d.phase,context:d.context,sessionId:d.sessionId,...d.externalId?{externalId:d.externalId}:{},timestamp:new Date(d.timestamp).toISOString(),modifiedFiles:d.modifiedFiles?.length||0,symbolsTouched:d.symbolsTouched?.length||0,decisions:d.decisions?.length||0,recentBreadcrumbs:d.recentBreadcrumbs?.length||0},...m?{note:"Checkpoint saved. Recovery data will be auto-surfaced on the first tool call of the next session."}:{warning:"Checkpoint was NOT persisted to disk. Both local and global writes failed. Check MCP server stderr for details."}},null,2)}}return {handled:false,text:""}}function ct(t){let e=j$1();e.setRootDir(t);let r=e.loadCheckpoint(),n=e.loadPreviousSession(),s=[];try{s=b$2(t);}catch{}return {checkpoint:r,pendingHandoffs:s,previousSession:n}}async function Vs(t){let{checkpoint:e,pendingHandoffs:r}=ct(t);if(!e&&r.length===0)return null;let n=[];if(n.push("--- SESSION RECOVERY ---"),e){let s=Date.now()-e.timestamp,o=Math.round(s/6e4),i=Math.round(s/36e5),a=i>1?`${i}h ago`:`${o}m ago`;n.push(`Previous session was in "${e.phase}" phase (${a}): ${e.context}`),e.modifiedFiles?.length&&n.push(`Modified files: ${e.modifiedFiles.join(", ")}`),e.symbolsTouched?.length&&n.push(`Symbols: ${e.symbolsTouched.join(", ")}`),e.decisions?.length&&n.push(`Decisions: ${e.decisions.join("; ")}`),e.plan&&n.push(`Plan: ${e.plan.slice(0,200)}`);}if(r.length>0){let s=r[r.length-1];n.push(`Pending handoff: "${s.summary}"`),s.nextSteps.length>0&&n.push(`Next steps: ${s.nextSteps.slice(0,3).join(", ")}`);}try{let{loadTasks:s}=await import('./task-loader-NZFDTUQ5.js'),o=await s(t,{status:"open",limit:5});if(o.length>0){n.push(""),n.push("Open tasks:");for(let i of o){let a=i.tags.length>0?` [${i.tags.join(", ")}]`:"";n.push(` [${i.priority}] ${i.id}: ${i.blurb}${a}`);}}}catch{}try{let{loadLoreEntries:s}=await import('./lore-loader-PXFKMKAN.js'),i=(await s(t,{limit:10})).filter(a=>a.tags?.some(c=>c.startsWith("arc:")));if(i.length>0){let a=new Map;for(let u of i){let d=u.tags?.find(f=>f.startsWith("arc:"))||"";a.set(d,(a.get(d)||0)+1);}let c=e?.symbolsTouched||[];if((c.length>0?i.filter(u=>u.symbols_touched?.some(d=>c.includes(d))):i.slice(0,3)).length>0||a.size>0){n.push(""),n.push("Active lore arcs:");for(let[u,d]of a)n.push(` ${u} (${d} entries)`);}}}catch{}try{let{loadNominations:s}=await import('./nomination-engine-NCLTGMAK.js'),o=s(t,{pending_only:!0}).filter(i=>i.urgency==="critical"||i.urgency==="high");if(o.length>0){n.push(""),n.push("Ambient nominations (urgent):");for(let i of o.slice(0,5))n.push(` [${i.urgency}] ${i.brief}`);o.length>5&&n.push(` ... and ${o.length-5} more. Use paradigm_ambient_nominations to see all.`);}}catch{}return n.push(""),n.push("IMPORTANT: Present a brief summary of this recovery data to the user, then ask what they would like to do: (1) Continue \u2014 pick up where the last session left off, (2) Discard \u2014 ignore the previous session and start fresh, or (3) let them describe what they want to work on instead. Do NOT automatically continue without asking."),n.push("---"),n.join(`
|
|
25
|
+
`)}var Le=class{cache=new Map;ttlMs;constructor(e=3e4){this.ttlMs=e;}async getOrCompute(e,r){let n=this.cache.get(e);if(n&&Date.now()-n.createdAt<this.ttlMs)return n.data;let s=await r();return this.cache.set(e,{data:s,createdAt:Date.now()}),s}invalidate(e){this.cache.delete(e);}invalidatePrefix(e){for(let r of this.cache.keys())r.startsWith(e)&&this.cache.delete(r);}clear(){this.cache.clear();}stats(){return {size:this.cache.size,ttlMs:this.ttlMs}}},lt=new Le(3e4);var Sn=300*1e3,pe=null;function ut(){pe=null;}function B(t,e){return h.existsSync(x.join(t,e))}function ee(t,e){return h.existsSync(x.join(t,e))}function bn(t,e,r){let n=t;try{if(!h.existsSync(n))return !1;let s=h.readdirSync(n,{withFileTypes:!0});for(let o of s){if(o.isFile()&&o.name.endsWith(e))return !0;if(o.isDirectory())try{if(h.readdirSync(x.join(n,o.name)).some(a=>a.endsWith(e)))return !0}catch{}}}catch{}return false}var wn={wisdom:t=>B(t,".paradigm/wisdom"),history:t=>B(t,".paradigm/history"),lore:t=>B(t,".paradigm/lore"),habits:t=>ee(t,".paradigm/habits.yaml"),sentinel:t=>{try{let e=x.join(t,".paradigm","config.yaml");return h.existsSync(e)?h.readFileSync(e,"utf-8").includes("sentinel"):!1}catch{return false}},flows:t=>ee(t,".paradigm/flow-index.json")||ee(t,".paradigm/flows.yaml"),fixtures:t=>ee(t,".paradigm/fixtures.yaml"),orchestration:t=>ee(t,".paradigm/agents.yaml"),tasks:t=>B(t,".paradigm/tasks"),assessment:t=>B(t,".paradigm/lore"),personas:t=>bn(t,".persona"),protocols:t=>B(t,".paradigm/protocols"),symphony:()=>{let t=x.join(Se.homedir(),".paradigm","score");return h.existsSync(t)},university:t=>B(t,".paradigm/university"),agents:t=>{let e=x.join(Se.homedir(),".paradigm","agents");return B(t,".paradigm/agents")||h.existsSync(e)},"aspect-graph":t=>ee(t,".paradigm/aspect-graph.db"),pan:t=>ee(t,".pan")||ee(t,"nevr.yaml"),notebooks:t=>{let e=x.join(Se.homedir(),".paradigm","notebooks");return B(t,".paradigm/notebooks")||h.existsSync(e)}},dt=class{modules=new Map;activatedAdvanced=new Set;rootDir;constructor(e){this.rootDir=e;}register(e){this.modules.set(e.key,e);}registerAll(e){for(let r of e)this.register(r);}detectActiveFeatures(){if(pe&&Date.now()-pe.timestamp<Sn)return pe.features;let e=new Set;for(let[r,n]of this.modules){if(n.tier==="core"){e.add(r);continue}if(n.tier==="advanced"){this.activatedAdvanced.has(r)&&e.add(r);continue}let s=n.detect||wn[r];if(s)try{s(this.rootDir)&&e.add(r);}catch{}else e.add(r);}return pe={features:e,timestamp:Date.now()},e}getActiveTools(){let e=this.detectActiveFeatures(),r=[];for(let[n,s]of this.modules)e.has(n)&&r.push(...s.getToolsList());return r}activateAdvanced(e){let r=this.modules.get(e);return !r||r.tier!=="advanced"?null:(this.activatedAdvanced.add(e),r.getToolsList())}getAvailableAdvanced(){let e=[];for(let[r,n]of this.modules)n.tier==="advanced"&&!this.activatedAdvanced.has(r)&&e.push({key:r,toolCount:n.getToolsList().length});return e}async dispatch(e,r,n,s){let o=this.detectActiveFeatures();for(let[i,a]of this.modules)if(o.has(i))try{let c=await a.handleTool(e,r,n,s);if(c.handled)return c}catch(c){return {handled:true,text:JSON.stringify({error:`Tool handler error in module "${i}"`,message:c.message},null,2)}}return null}get size(){return this.modules.size}getRegistryInfo(){let e=this.detectActiveFeatures(),r={core:0,feature:0,advanced:0};for(let n of this.modules.values())r[n.tier]++;return {total:this.modules.size,byTier:r,activeFeatures:[...e],availableAdvanced:[...this.modules.entries()].filter(([n,s])=>s.tier==="advanced"&&!this.activatedAdvanced.has(n)).map(([n])=>n)}}};function je(t,e,r){if(x.isAbsolute(t))return {resolvedPath:t,baseUsed:"absolute",exists:h.existsSync(t)};let n=x.join(r,t);if(h.existsSync(n))return {resolvedPath:n,baseUsed:"project-root",exists:true};let s=x.resolve(e,t);return h.existsSync(s)?{resolvedPath:s,baseUsed:"purpose-dir",exists:true}:{resolvedPath:n,baseUsed:"project-root",exists:false}}function Qs(t,e,r){if(x.isAbsolute(t)){let o=h.existsSync(t);return {rootResolves:o,purposeResolves:o,mismatch:false}}let n=h.existsSync(x.join(r,t)),s=h.existsSync(x.resolve(e,t));return {rootResolves:n,purposeResolves:s,mismatch:n!==s}}var Ne=null;async function Pn(){return Ne||(Ne=await In()),Ne}var Cn=[`CREATE TABLE IF NOT EXISTS aspects (
|
|
26
|
+
id TEXT PRIMARY KEY,
|
|
27
|
+
description TEXT NOT NULL,
|
|
28
|
+
category TEXT DEFAULT 'rule',
|
|
29
|
+
severity TEXT DEFAULT 'medium',
|
|
30
|
+
value TEXT,
|
|
31
|
+
enforcement TEXT,
|
|
32
|
+
defined_in TEXT NOT NULL,
|
|
33
|
+
tags TEXT,
|
|
34
|
+
created_at TEXT NOT NULL,
|
|
35
|
+
updated_at TEXT NOT NULL
|
|
36
|
+
)`,`CREATE TABLE IF NOT EXISTS anchors (
|
|
37
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
38
|
+
aspect_id TEXT NOT NULL REFERENCES aspects(id) ON DELETE CASCADE,
|
|
39
|
+
file_path TEXT NOT NULL,
|
|
40
|
+
start_line INTEGER NOT NULL,
|
|
41
|
+
end_line INTEGER NOT NULL,
|
|
42
|
+
content_hash TEXT,
|
|
43
|
+
normalized_hash TEXT,
|
|
44
|
+
materialized_at_commit TEXT,
|
|
45
|
+
last_verified TEXT,
|
|
46
|
+
drifted INTEGER DEFAULT 0
|
|
47
|
+
)`,"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 (
|
|
48
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
49
|
+
source TEXT NOT NULL,
|
|
50
|
+
target TEXT NOT NULL,
|
|
51
|
+
relation TEXT NOT NULL,
|
|
52
|
+
weight REAL DEFAULT 1.0,
|
|
53
|
+
origin TEXT DEFAULT 'explicit',
|
|
54
|
+
created_at TEXT NOT NULL
|
|
55
|
+
)`,"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 (
|
|
56
|
+
aspect_id TEXT NOT NULL,
|
|
57
|
+
lore_id TEXT NOT NULL,
|
|
58
|
+
PRIMARY KEY (aspect_id, lore_id)
|
|
59
|
+
)`,`CREATE TABLE IF NOT EXISTS search_log (
|
|
60
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
61
|
+
query TEXT NOT NULL,
|
|
62
|
+
results_returned TEXT NOT NULL,
|
|
63
|
+
selected_result TEXT,
|
|
64
|
+
timestamp TEXT NOT NULL
|
|
65
|
+
)`,"CREATE INDEX IF NOT EXISTS idx_search_query ON search_log(query)",`CREATE TABLE IF NOT EXISTS search_weights (
|
|
66
|
+
query_normalized TEXT NOT NULL,
|
|
67
|
+
aspect_id TEXT NOT NULL,
|
|
68
|
+
weight REAL DEFAULT 1.0,
|
|
69
|
+
hit_count INTEGER DEFAULT 1,
|
|
70
|
+
last_hit TEXT NOT NULL,
|
|
71
|
+
PRIMARY KEY (query_normalized, aspect_id)
|
|
72
|
+
)`,`CREATE TABLE IF NOT EXISTS heatmap (
|
|
73
|
+
aspect_id TEXT NOT NULL,
|
|
74
|
+
access_type TEXT NOT NULL,
|
|
75
|
+
count INTEGER DEFAULT 0,
|
|
76
|
+
last_accessed TEXT NOT NULL,
|
|
77
|
+
PRIMARY KEY (aspect_id, access_type)
|
|
78
|
+
)`],An=["ALTER TABLE anchors ADD COLUMN original_content TEXT",`CREATE TABLE IF NOT EXISTS anchor_history (
|
|
79
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
80
|
+
anchor_id INTEGER NOT NULL,
|
|
81
|
+
action TEXT NOT NULL,
|
|
82
|
+
old_start INTEGER,
|
|
83
|
+
old_end INTEGER,
|
|
84
|
+
new_start INTEGER,
|
|
85
|
+
new_end INTEGER,
|
|
86
|
+
old_path TEXT,
|
|
87
|
+
new_path TEXT,
|
|
88
|
+
confidence REAL,
|
|
89
|
+
commit_hash TEXT,
|
|
90
|
+
healed_at TEXT NOT NULL
|
|
91
|
+
)`],Ln="CREATE VIRTUAL TABLE IF NOT EXISTS aspects_fts USING fts5(id, description, enforcement, tags)";function H(t,e,r){let n=t.prepare(e);r&&r.length>0&&n.bind(r);let s=[];for(;n.step();)s.push(n.getAsObject());return n.free(),s}function jn(t,e,r){let n=t.prepare(e);r&&r.length>0&&n.bind(r);let s=null;return n.step()&&(s=n.getAsObject()),n.free(),s}async function Et(t){let e=await Pn(),r=x.join(t,".paradigm"),n=x.join(r,"aspect-graph.db"),s;if(h.existsSync(n)){let o=h.readFileSync(n);s=new e.Database(o);}else h.existsSync(r)||h.mkdirSync(r,{recursive:true}),s=new e.Database;for(let o of Cn)s.run(o);try{s.run(Ln);}catch{}for(let o of An)try{s.run(o);}catch{}return s}function Tt(t,e){if(e){let r=x.join(e,".paradigm");h.existsSync(r)||h.mkdirSync(r,{recursive:true});let n=x.join(r,"aspect-graph.db"),s=t.export();h.writeFileSync(n,Buffer.from(s));}t.close();}function vt(t,e,r){let n=e.filter(i=>i.type==="aspect"),s=new Date().toISOString(),o=null;try{o=execSync("git rev-parse HEAD",{cwd:r,encoding:"utf8"}).trim();}catch{}t.run("DELETE FROM anchors"),t.run("DELETE FROM edges"),t.run("DELETE FROM aspects");try{t.run("DELETE FROM aspects_fts");}catch{}for(let i of n){let a=i.data??{},c=$n(a,i),l=Mn(a,i),u=a.value!=null?String(a.value):null,d=i.enforcement??(a.enforcement!=null?String(a.enforcement):null),f=i.tags?JSON.stringify(i.tags):null;if(t.run(`INSERT INTO aspects (id, description, category, severity, value, enforcement, defined_in, tags, created_at, updated_at)
|
|
92
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,[i.symbol,i.description??"",c,l,u,d,i.filePath,f,i.created??s,i.modified??s]),i.anchors)for(let p of i.anchors){let{startLine:g,endLine:y}=_t(p),b=Nn();t.run(`INSERT INTO anchors (aspect_id, file_path, start_line, end_line, content_hash, normalized_hash, materialized_at_commit, last_verified, original_content)
|
|
93
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,[i.symbol,p.path,g,y,b.exact,b.normalized,o,s,b.normalizedContent]);}let m=a.edges;if(Array.isArray(m))for(let p of m)t.run(`INSERT INTO edges (source, target, relation, weight, origin, created_at)
|
|
94
|
+
VALUES (?, ?, ?, ?, ?, ?)`,[p.source??i.symbol,p.target??"",p.relation??"related-to",p.weight??1,p.origin??"explicit",s]);if(i.appliesTo)for(let p of i.appliesTo)t.run(`INSERT INTO edges (source, target, relation, weight, origin, created_at)
|
|
95
|
+
VALUES (?, ?, ?, ?, ?, ?)`,[i.symbol,p,"related-to",.5,"inferred",s]);try{t.run(`INSERT INTO aspects_fts (id, description, enforcement, tags)
|
|
96
|
+
VALUES (?, ?, ?, ?)`,[i.symbol,i.description??"",d??"",f??""]);}catch{}}}function rr(t,e){return jn(t,"SELECT * FROM aspects WHERE id = ?",[e])}function or(t,e){return H(t,"SELECT * FROM anchors WHERE aspect_id = ?",[e])}function ir(t,e){return H(t,"SELECT * FROM edges WHERE source = ?",[e])}function ar(t,e){return H(t,"SELECT * FROM edges WHERE target = ?",[e])}function cr(t,e){return H(t,"SELECT * FROM edges WHERE source = ? OR target = ?",[e,e])}function lr(t,e,r){let n=new Date().toISOString();t.run(`INSERT INTO heatmap (aspect_id, access_type, count, last_accessed)
|
|
97
|
+
VALUES (?, ?, 1, ?)
|
|
98
|
+
ON CONFLICT(aspect_id, access_type)
|
|
99
|
+
DO UPDATE SET count = count + 1, last_accessed = ?`,[e,r,n,n]);}function dr(t,e=20,r){return r?H(t,"SELECT * FROM heatmap WHERE access_type = ? ORDER BY count DESC LIMIT ?",[r,e]):H(t,"SELECT * FROM heatmap ORDER BY count DESC LIMIT ?",[e])}function ur(t,e,r,n=true,s=.7,o=.85){let i=r?H(t,"SELECT * FROM anchors WHERE aspect_id = ?",[r]):H(t,"SELECT * FROM anchors"),a=[];for(let c of i){let u=H(t,"SELECT defined_in FROM aspects WHERE id = ?",[c.aspect_id])[0]?.defined_in,d$1=u?x.dirname(x.isAbsolute(u)?u:x.resolve(e,u)):e,f=je(c.file_path,d$1,e),m=f.resolvedPath;if(!f.exists){a.push({aspectId:c.aspect_id,path:c.file_path,startLine:c.start_line,endLine:c.end_line,status:"missing",resolvedBy:"none",exists:false,drifted:true});continue}try{let g=h.readFileSync(m,"utf8").split(`
|
|
100
|
+
`),y=Math.max(0,c.start_line-1),b=Math.min(g.length,c.end_line),P=g.slice(y,b).join(`
|
|
101
|
+
`),$=te.createHash("sha256").update(P).digest("hex");if(c.content_hash!=null&&$===c.content_hash){a.push({aspectId:c.aspect_id,path:c.file_path,startLine:c.start_line,endLine:c.end_line,status:"clean",resolvedBy:"exact-hash",exists:!0,drifted:!1}),c.drifted===1&&t.run("UPDATE anchors SET drifted = 0 WHERE id = ?",[c.id]);continue}let Y=te.createHash("sha256").update(Me(P)).digest("hex");if(c.normalized_hash!=null&&Y===c.normalized_hash){t.run("UPDATE anchors SET content_hash = ?, drifted = 0 WHERE id = ?",[$,c.id]),a.push({aspectId:c.aspect_id,path:c.file_path,startLine:c.start_line,endLine:c.end_line,status:"cosmetic",resolvedBy:"normalized-hash",exists:!0,drifted:!1});continue}if(c.content_hash==null&&c.normalized_hash==null){t.run("UPDATE anchors SET content_hash = ?, normalized_hash = ?, drifted = 0 WHERE id = ?",[$,Y,c.id]),a.push({aspectId:c.aspect_id,path:c.file_path,startLine:c.start_line,endLine:c.end_line,status:"clean",resolvedBy:"exact-hash",exists:!0,drifted:!1});continue}let se=!1;if(c.materialized_at_commit){let v=Fn(e,c.file_path,c.materialized_at_commit,c.start_line,c.end_line);if(v){let E=Math.max(0,v.currentStart-1),S=Math.min(g.length,v.currentEnd),I=g.slice(E,S).join(`
|
|
102
|
+
`),K=te.createHash("sha256").update(I).digest("hex");if(c.content_hash!=null&&K===c.content_hash){let Q=n;if(Q){t.run("UPDATE anchors SET start_line = ?, end_line = ?, drifted = 0 WHERE id = ?",[v.currentStart,v.currentEnd,c.id]);let ae=H(t,"SELECT defined_in FROM aspects WHERE id = ?",[c.aspect_id]);ae.length>0&&$e(e,ae[0].defined_in,c.file_path,c.start_line,c.end_line,v.currentStart,v.currentEnd);}a.push({aspectId:c.aspect_id,path:c.file_path,startLine:Q?v.currentStart:c.start_line,endLine:Q?v.currentEnd:c.end_line,status:"shifted",resolvedBy:"git-line-mapping",exists:!0,drifted:!1,suggestedStart:v.currentStart,suggestedEnd:v.currentEnd,autoHealed:Q}),se=!0;}else {let Q=te.createHash("sha256").update(Me(I)).digest("hex");if(c.normalized_hash!=null&&Q===c.normalized_hash){if(n){let ae=te.createHash("sha256").update(I).digest("hex");t.run("UPDATE anchors SET start_line = ?, end_line = ?, content_hash = ?, drifted = 0 WHERE id = ?",[v.currentStart,v.currentEnd,ae,c.id]);let ye=H(t,"SELECT defined_in FROM aspects WHERE id = ?",[c.aspect_id]);ye.length>0&&$e(e,ye[0].defined_in,c.file_path,c.start_line,c.end_line,v.currentStart,v.currentEnd);}a.push({aspectId:c.aspect_id,path:c.file_path,startLine:n?v.currentStart:c.start_line,endLine:n?v.currentEnd:c.end_line,status:"shifted",resolvedBy:"git-line-mapping",exists:!0,drifted:!1,suggestedStart:v.currentStart,suggestedEnd:v.currentEnd,autoHealed:n}),se=!0;}}}}if(se)continue;if(c.original_content){let{contentSearch:v}=(wt(),d(bt)),E=v(e,c.file_path,c.original_content,n);if(E.found&&E.score>=s){if(n&&E.score>=o&&!E.suggestedPath&&E.suggestedStart&&E.suggestedEnd){t.run("UPDATE anchors SET start_line = ?, end_line = ?, drifted = 0 WHERE id = ?",[E.suggestedStart,E.suggestedEnd,c.id]);try{t.run(`INSERT INTO anchor_history (anchor_id, action, old_start, old_end, new_start, new_end, confidence, healed_at)
|
|
103
|
+
VALUES (?, 'relocated', ?, ?, ?, ?, ?, ?)`,[c.id,c.start_line,c.end_line,E.suggestedStart,E.suggestedEnd,E.score,new Date().toISOString()]);}catch{}let I=H(t,"SELECT defined_in FROM aspects WHERE id = ?",[c.aspect_id]);I.length>0&&$e(e,I[0].defined_in,c.file_path,c.start_line,c.end_line,E.suggestedStart,E.suggestedEnd),a.push({aspectId:c.aspect_id,path:c.file_path,startLine:E.suggestedStart,endLine:E.suggestedEnd,status:"relocated",resolvedBy:"content-search",exists:!0,similarity:E.similarity,suggestedStart:E.suggestedStart,suggestedEnd:E.suggestedEnd,autoHealed:!0,drifted:!1});continue}a.push({aspectId:c.aspect_id,path:E.suggestedPath||c.file_path,startLine:c.start_line,endLine:c.end_line,status:"relocated",resolvedBy:"content-search",exists:!0,similarity:E.similarity,suggestedStart:E.suggestedStart,suggestedEnd:E.suggestedEnd,autoHealed:!1,drifted:!0});continue}}t.run("UPDATE anchors SET drifted = 1 WHERE id = ?",[c.id]),a.push({aspectId:c.aspect_id,path:c.file_path,startLine:c.start_line,endLine:c.end_line,status:"modified",resolvedBy:"none",exists:!0,currentContent:P,drifted:!0});}catch{a.push({aspectId:c.aspect_id,path:c.file_path,startLine:c.start_line,endLine:c.end_line,status:"modified",resolvedBy:"none",exists:true,drifted:true});}}return a}function _t(t){let{lines:e}=t;return typeof e=="number"?{startLine:e,endLine:e}:Array.isArray(e)?e.length===2?{startLine:e[0],endLine:e[1]}:{startLine:Math.min(...e),endLine:Math.max(...e)}:{startLine:1,endLine:1}}function On(t){let e=[],r=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/gm,n;for(;(n=r.exec(t))!==null;)e.push({oldStart:parseInt(n[1],10),oldCount:n[2]!==void 0?parseInt(n[2],10):1,newStart:parseInt(n[3],10),newCount:n[4]!==void 0?parseInt(n[4],10):1});return e}function Fn(t,e,r,n,s){let o;try{o=execSync(`git diff ${r}..HEAD --unified=0 -- "${e}"`,{cwd:t,encoding:"utf8",timeout:5e3});}catch{return null}if(!o.trim())return {originalStart:n,originalEnd:s,currentStart:n,currentEnd:s};let i=On(o),a=0;for(let c of i){if(c.oldStart+c.oldCount<=n){a+=c.newCount-c.oldCount;continue}if(c.oldStart<s)return null;break}return a===0?null:{originalStart:n,originalEnd:s,currentStart:n+a,currentEnd:s+a}}function $e(t,e,r,n,s,o,i){let a=x.isAbsolute(e)?e:x.join(t,e);if(!h.existsSync(a))return false;try{let c=h.readFileSync(a,"utf8"),l=n===s?`${r}:${n}`:`${r}:${n}-${s}`,u=o===i?`${r}:${o}`:`${r}:${o}-${i}`;if(!c.includes(l))return !1;let d=c.replace(l,u);return h.writeFileSync(a,d,"utf8"),!0}catch{return false}}function Me(t){return t.split(`
|
|
104
|
+
`).map(e=>e.trimEnd()).filter(e=>e.trim()!=="").map(e=>e.replace(/\s+/g," ")).join(`
|
|
105
|
+
`)}function Nn(t,e,r){return {exact:null,normalized:null,normalizedContent:null};}function $n(t,e){if(typeof t.category=="string")return t.category;let r=(e.description??"").toLowerCase();return /\b(must|require|always)\b/.test(r)?"rule":/\b(decided|chose)\b/.test(r)?"decision":/\b(limit|cannot)\b/.test(r)?"constraint":/\b(set to|configured|value)\b/.test(r)?"configuration":"rule"}function Mn(t,e){if(typeof t.severity=="string")return t.severity;let r=e.tags??[];return r.includes("critical")?"critical":r.includes("security")||r.includes("compliance")?"high":"medium"}j();var Dn=/L-\d{4}-\d{2}-\d{2}-\d{3}/g;async function kt(t,e){t.run("DELETE FROM lore_links");let r=await a$4(e);if(r.length===0)return 0;let n=Un(r),s=new Map;for(let l of r)s.set(l.id,l);let o=new Set,i=t.exec("SELECT id, enforcement FROM aspects");if(i.length>0){let{columns:l,values:u}=i[0],d=l.indexOf("id"),f=l.indexOf("enforcement");for(let m of u){let p=String(m[d]),g=m[f];if(g&&typeof g=="string"){let y=g.match(Dn);if(y)for(let b of y)s.has(b)&&o.add(`${p}\0${b}`);}}}let a=t.exec("SELECT source, target FROM edges");if(a.length>0&&i.length>0){let l=Hn(t,a);for(let[u,d]of l)for(let f of d){let m=n.get(f);if(m)for(let p of m)o.add(`${u}\0${p}`);}}if(o.size===0)return 0;let c=t.prepare("INSERT OR IGNORE INTO lore_links (aspect_id, lore_id) VALUES (?, ?)");try{for(let l of o){let[u,d]=l.split("\0");c.bind([u,d]),c.step(),c.reset();}}finally{c.free();}return o.size}async function mr(t,e,r){let n=t.exec("SELECT lore_id FROM lore_links WHERE aspect_id = ?",[r]);if(n.length===0||n[0].values.length===0)return [];let s=n[0].values.map(o=>String(o[0]));return zn(e,s)}async function Rt(t,e){let r=await a$4(e);if(r.length===0)return 0;let n=t.exec("SELECT id FROM aspects"),s=new Set;if(n.length>0)for(let c of n[0].values)s.add(String(c[0]));if(s.size<2)return 0;let o=new Date().toISOString(),i=0,a=t.prepare(`INSERT OR IGNORE INTO edges (source, target, relation, weight, origin, created_at)
|
|
106
|
+
VALUES (?, ?, 'related-to', 0.3, 'learned', ?)`);try{for(let c of r){if(!c.symbols_touched||c.symbols_touched.length<2)continue;let l=[];for(let u of c.symbols_touched){let d=u.startsWith("~")?u.slice(1):u;s.has(d)&&l.push(d);}for(let u=0;u<l.length;u++)for(let d=u+1;d<l.length;d++){let[f,m]=l[u]<l[d]?[l[u],l[d]]:[l[d],l[u]];a.bind([f,m,o]),a.step(),a.reset(),i++;}}}finally{a.free();}return i}function Un(t){let e=new Map;for(let r of t)if(r.symbols_touched)for(let n of r.symbols_touched){let s=e.get(n);s||(s=new Set,e.set(n,s)),s.add(r.id);}return e}function Hn(t,e){let r=t.exec("SELECT id FROM aspects"),n=new Set;if(r.length>0)for(let l of r[0].values)n.add(String(l[0]));let s=new Map;if(e.length===0)return s;let{columns:o,values:i}=e[0],a=o.indexOf("source"),c=o.indexOf("target");for(let l of i){let u=String(l[a]),d=String(l[c]);if(n.has(u)){let f=s.get(u);f||(f=new Set,s.set(u,f)),f.add(d),f.add(`~${u}`);}if(n.has(d)){let f=s.get(d);f||(f=new Set,s.set(d,f)),f.add(u),f.add(`~${d}`);}}return s}async function zn(t,e){let r=new Set,n=[];for(let s of e){if(r.has(s))continue;r.add(s);let o=await b$3(t,s);o&&n.push(Wn(o));}return n}function Wn(t){return {id:t.id,title:t.title,summary:t.summary,timestamp:t.timestamp,symbolsTouched:t.symbols_touched}}var le=".paradigm/personas",Gn="index.yaml";async function me(t,e){let r=x.join(t,le);if(!h.existsSync(r))return [];let n=h.readdirSync(r).filter(o=>o.endsWith(".persona")),s=[];for(let o of n)try{let i=h.readFileSync(x.join(r,o),"utf8"),a=N.load(i);a&&a.id&&s.push(a);}catch{}return Bn(s,e)}async function ge(t,e){let r=x.join(t,le,`${e}.persona`);if(!h.existsSync(r))return null;try{return N.load(h.readFileSync(r,"utf8"))}catch{return null}}function Bn(t,e){if(!e)return t;let r=t;return e.tag&&(r=r.filter(n=>n.tags?.includes(e.tag))),e.trigger_type&&(r=r.filter(n=>n.trigger.type===e.trigger_type)),e.gate&&(r=r.filter(n=>n.journey.some(s=>s.gates.includes(e.gate)))),e.flow&&(r=r.filter(n=>n.journey.some(s=>s.flow===e.flow))),e.limit&&(r=r.slice(0,e.limit)),r}async function hr(t,e){let r=x.join(t,le);h.mkdirSync(r,{recursive:true});let n=x.join(r,`${e.id}.persona`);if(h.existsSync(n))throw new Error(`Persona ${e.id} already exists`);let s=new Date().toISOString(),o={version:"1.0",id:e.id,name:e.name,description:e.description,traits:e.traits,trigger:e.trigger,fixtures:e.fixtures,tags:e.tags||[],journey:e.journey||[],created:s,updated:s};return h.writeFileSync(n,N.dump(o,{indent:2,lineWidth:120,noRefs:true,sortKeys:false})),await he(t),e.id}async function It(t,e,r){let n=await ge(t,e);if(!n)return false;let s=x.join(t,le,`${e}.persona`),o={...n,...r,id:n.id,version:n.version,created:n.created,updated:new Date().toISOString()};return h.writeFileSync(s,N.dump(o,{indent:2,lineWidth:120,noRefs:true,sortKeys:false})),await he(t),true}async function yr(t,e){let r=x.join(t,le,`${e}.persona`);if(!h.existsSync(r))return {deleted:false,warnings:[]};let n=[],s=await me(t);for(let o of s)if(o.id!==e){o.trigger.spawned_by?.startsWith(e+".")&&n.push(`Persona ${o.id} is spawned by ${e} \u2014 it will become orphaned`);for(let i of o.journey)i.spawns?.some(a=>a.persona===e)&&n.push(`Persona ${o.id} step ${i.id} spawns ${e} \u2014 spawn will break`);}return h.unlinkSync(r),await he(t),{deleted:true,warnings:n}}async function Sr(t,e,r,n){let s=await ge(t,e);if(!s)return false;if(s.journey.some(o=>o.id===r.id))throw new Error(`Step ${r.id} already exists in persona ${e}`);if(n){let o=s.journey.findIndex(i=>i.id===n);if(o===-1)throw new Error(`Step ${n} not found in persona ${e}`);s.journey.splice(o+1,0,r);}else s.journey.push(r);return It(t,e,{journey:s.journey})}async function br(t,e,r){let n=await ge(t,e);if(!n)return {removed:false,warnings:[]};let s=n.journey.findIndex(a=>a.id===r);if(s===-1)return {removed:false,warnings:[]};let o=n.journey[s],i=[];if(o.produces)for(let a of Object.keys(o.produces)){let c=`{{produces.${a}}}`;for(let l=s+1;l<n.journey.length;l++){let u=n.journey[l];JSON.stringify(u).includes(c)&&i.push(`Step ${u.id} consumes {{produces.${a}}} from this step`);}}if(o.spawns&&o.spawns.length>0)for(let a of o.spawns)i.push(`Step spawns persona ${a.persona} \u2014 spawn chain will break`);return n.journey.splice(s,1),await It(t,e,{journey:n.journey}),{removed:true,warnings:i}}var Xn=/^[a-z][a-z0-9-]*$/,qn=/^[a-z][a-z0-9-]*$/,Vn=/^(GET|POST|PUT|PATCH|DELETE)\s+\//;async function wr(t,e,r=false){let n=[],s=[];Xn.test(e.id)||n.push({type:"invalid-id",detail:`ID "${e.id}" must match /^[a-z][a-z0-9-]*$/`}),(!e.name||e.name.trim()==="")&&n.push({type:"missing-name",detail:"Name is required"}),(!e.trigger||!e.trigger.type)&&n.push({type:"missing-trigger",detail:"Trigger with type is required"}),e.trigger.type!=="root"&&!e.trigger.spawned_by&&n.push({type:"missing-spawned-by",detail:`Non-root trigger type "${e.trigger.type}" requires spawned_by`}),(!e.journey||e.journey.length===0)&&n.push({type:"empty-journey",detail:"Journey must have at least one step"});let o=new Set,i=new Set;for(let a of e.journey){qn.test(a.id)||n.push({type:"invalid-step-id",step:a.id,detail:"Step ID must match /^[a-z][a-z0-9-]*$/"}),o.has(a.id)&&n.push({type:"duplicate-step-id",step:a.id,detail:`Duplicate step ID "${a.id}"`}),o.add(a.id),Vn.test(a.route)||n.push({type:"invalid-route",step:a.id,route:a.route,detail:'Route must match "METHOD /path" (e.g., "POST /api/auth/signup")'}),(!a.gates||a.gates.length===0)&&n.push({type:"missing-gates",step:a.id,detail:"Step must have at least one gate"}),(!a.expect||a.expect.status===void 0)&&n.push({type:"missing-expect",step:a.id,detail:"Step must have expect with status"});let l=JSON.stringify(a).match(/\{\{produces\.([^}]+)\}\}/g)||[];for(let u of l){let d=u.replace("{{produces.","").replace("}}","");i.has(d)||n.push({type:"unresolved-produces",step:a.id,key:d,detail:`{{produces.${d}}} used but not produced by a prior step`});}if(a.produces)for(let u of Object.keys(a.produces))i.add(u);}if(r){let a=x.join(t,"portal.yaml"),c=[],l=[];if(h.existsSync(a))try{let d=N.load(h.readFileSync(a,"utf8"));d.gates&&typeof d.gates=="object"&&(c=Object.keys(d.gates)),d.routes&&typeof d.routes=="object"&&(l=Object.keys(d.routes));}catch{}for(let d of e.journey)for(let f of d.gates)c.length>0&&!c.includes(f)&&n.push({type:"gate-not-found",step:d.id,gate:f,detail:`Gate ${f} not defined in portal.yaml`});for(let d of e.journey)if(l.length>0){let f=d.route;l.some(p=>De(p,f))||s.push({type:"route-not-in-portal",detail:`Route "${f}" (step ${d.id}) not found in portal.yaml`});}for(let d of e.journey)if(d.spawns)for(let f of d.spawns)await ge(t,f.persona)||n.push({type:"spawn-target-missing",step:d.id,detail:`Spawn target persona "${f.persona}" does not exist`});let u=await Jn(t,e.id);if(u&&n.push({type:"spawn-cycle",detail:`Circular spawn dependency: ${u.join(" \u2192 ")}`}),l.length>0||c.length>0){let d=await me(t),f=new Set,m=new Set;for(let b of d)for(let P of b.journey){for(let $ of P.gates)f.add($);m.add(P.route);}let p=[],g=x.join(t,".paradigm","flow-index.json");if(h.existsSync(g))try{let b=JSON.parse(h.readFileSync(g,"utf8"));p=Object.keys(b.flows||{});}catch{}let y=new Set;for(let b of d)for(let P of b.journey)P.flow&&y.add(P.flow);return {persona:e.id,valid:n.length===0,errors:n,warnings:s,coverage:{routes:{covered:m.size,total:l.length,uncovered:l.filter(b=>!m.has(b))},gates:{covered:f.size,total:c.length,uncovered:c.filter(b=>!f.has(b))},flows:{covered:y.size,total:p.length,uncovered:p.filter(b=>!y.has(b))}}}}}return {persona:e.id,valid:n.length===0,errors:n,warnings:s}}function De(t,e){let r=n=>n.replace(/:[a-zA-Z_]+/g,":param").replace(/\{\{[^}]+\}\}/g,":param");return r(t)===r(e)}async function Jn(t,e){let r=new Set,n=[];async function s(o){if(r.has(o)){let a=n.indexOf(o);return a!==-1?[...n.slice(a),o]:null}r.add(o),n.push(o);let i=await ge(t,o);if(i){for(let a of i.journey)if(a.spawns)for(let c of a.spawns){let l=await s(c.persona);if(l)return l}}return n.pop(),null}return s(e)}async function he(t){let e=x.join(t,le);h.mkdirSync(e,{recursive:true});let r=await me(t),n={},s={},o={};for(let d of r){let f=new Set,m=new Set,p=[],g=new Set;for(let y of d.journey){for(let b of y.gates)f.add(b);if(y.flow&&m.add(y.flow),p.push(y.route),y.spawns)for(let b of y.spawns)g.add(b.persona);}n[d.id]={name:d.name,trigger:d.trigger.type,spawned_by:d.trigger.spawned_by,steps:d.journey.length,gates:[...f],flows:[...m],routes:p,spawns:[...g],tags:d.tags||[]};for(let y of f)s[y]||(s[y]=[]),s[y].push(d.id);for(let y of p)o[y]||(o[y]=[]),o[y].push(d.id);}let i=[],a=x.join(t,"portal.yaml");if(h.existsSync(a))try{let d=N.load(h.readFileSync(a,"utf8"));d.routes&&typeof d.routes=="object"&&(i=Object.keys(d.routes).filter(m=>!Object.keys(o).some(p=>De(m,p))));}catch{}let c={},l=x.join(e,"chains");if(h.existsSync(l)){let d=h.readdirSync(l).filter(f=>f.endsWith(".yaml"));for(let f of d)try{let m=h.readFileSync(x.join(l,f),"utf8"),p=N.load(m);if(p&&p.id){let g=p.order.map(P=>P.persona),y=0,b=new Set;for(let P of g){let $=n[P];if($){y+=$.steps;for(let Y of $.gates)b.add(Y);}}c[p.id]={description:p.description||"",order:g,total_steps:y,total_gates:b.size};}}catch{}}let u={version:"1.0",generated:new Date().toISOString(),personas:n,chains:c,gate_coverage:s,route_coverage:o,uncovered_routes:i};return h.writeFileSync(x.join(e,Gn),N.dump(u,{indent:2,lineWidth:120,noRefs:true,sortKeys:false})),u}async function xr(t){let e=await me(t),r=new Set,n=new Set,s=new Set;for(let u of e)for(let d of u.journey){for(let f of d.gates)r.add(f);n.add(d.route),d.flow&&s.add(d.flow);}let o=[],i=[],a=x.join(t,"portal.yaml");if(h.existsSync(a))try{let u=N.load(h.readFileSync(a,"utf8"));u.gates&&typeof u.gates=="object"&&(o=Object.keys(u.gates)),u.routes&&typeof u.routes=="object"&&(i=Object.keys(u.routes));}catch{}let c=[],l=x.join(t,".paradigm","flow-index.json");if(h.existsSync(l))try{let u=JSON.parse(h.readFileSync(l,"utf8"));c=Object.keys(u.flows||{});}catch{}return {routes:{covered:n.size,total:i.length,uncovered:i.filter(u=>!Array.from(n).some(d=>De(u,d)))},gates:{covered:r.size,total:o.length,uncovered:o.filter(u=>!r.has(u))},flows:{covered:s.size,total:c.length,uncovered:c.filter(u=>!s.has(u))},personas:e.length}}async function Er(t,e){let r=await me(t),n=[];for(let s of r){let o=[],i=[];for(let a of s.journey)if((a.gates.includes(e)||a.flow===e||a.route===e||a.signals?.includes(e))&&(o.push(a.id),a.spawns))for(let l of a.spawns)i.push(l.persona);o.length>0&&n.push({persona:s.id,steps:o,spawns_blocked:i});}return n}function Yn(t,e){let r=e.split(/[.\[\]]+/).filter(Boolean),n=t;for(let s of r){if(n==null||typeof n!="object")return;n=n[s];}return n}function Kn(t,e){let r=[];if(e.status!==t.expect.status&&r.push({type:"status",field:"status",expected:t.expect.status,actual:e.status,message:`Step ${t.id}: status is ${e.status}, expected ${t.expect.status}`}),t.expect.body?.has){let n=e.body;for(let s of t.expect.body.has)(!n||typeof n!="object"||!(s in n))&&r.push({type:"body.has",field:s,expected:true,actual:false,message:`Step ${t.id}: body missing key '${s}'`});}if(t.expect.body?.match){let n=e.body;for(let[s,o]of Object.entries(t.expect.body.match)){let i=n?Yn(n,s):void 0;JSON.stringify(i)!==JSON.stringify(o)&&r.push({type:"body.match",field:s,expected:o,actual:i??null,message:`Step ${t.id}: '${s}' is ${JSON.stringify(i??null)}, expected ${JSON.stringify(o)}`});}}if(t.signals&&t.signals.length>0){let n=e.signals_fired||[];for(let s of t.signals)n.includes(s)||r.push({type:"signal",field:"signals_fired",expected:s,actual:n,message:`Step ${t.id}: signal '${s}' was not fired`});}if(t.gates.length>0&&e.gates_traversed)for(let n of t.gates)e.gates_traversed.includes(n)||r.push({type:"gate",field:"gates_traversed",expected:n,actual:e.gates_traversed,message:`Step ${t.id}: gate '${n}' was not traversed`});return r}async function Tr(t,e={}){let r=[];try{let{SentinelStorage:a}=await import('./dist-W3XCATBJ.js'),c=new a,u=(c.queryEvents?.({schemaId:"paradigm-personas",eventType:"persona.step.complete",scopeValue:t.id,limit:500})||[]).filter(p=>{let g=JSON.parse(p.data_json||"{}");return !(e.run_id&&g.run_id!==e.run_id||e.chain_id&&g.chain_id!==e.chain_id||e.environment&&g.environment!==e.environment)}),f=(c.queryEvents?.({schemaId:"paradigm-personas",eventType:"persona.step.fail",scopeValue:t.id,limit:500})||[]).filter(p=>{let g=JSON.parse(p.data_json||"{}");return !(e.run_id&&g.run_id!==e.run_id||e.chain_id&&g.chain_id!==e.chain_id||e.environment&&g.environment!==e.environment)}),m=new Map;for(let p of [...u,...f]){let g=JSON.parse(p.data_json||"{}");g.step_id&&m.set(g.step_id,g);}for(let p of t.journey){let g=m.get(p.id);if(!g){r.push({step_id:p.id,matched:!1,assertions:[],message:`No Sentinel event found for step '${p.id}' \u2014 step was never exercised`});continue}let y=Kn(p,{status:g.status,body:g.body,gates_traversed:g.gates_traversed,signals_fired:g.signals_fired});r.push({step_id:p.id,matched:!0,passed:y.length===0,assertions:y});}}catch{for(let a of t.journey)r.push({step_id:a.id,matched:false,assertions:[],message:"Sentinel unavailable \u2014 cannot validate events"});}let n=r.filter(a=>a.matched).length,s=r.filter(a=>a.passed).length,o=r.filter(a=>a.matched&&!a.passed).length,i=r.reduce((a,c)=>a+c.assertions.length,0);return {run_id:e.run_id,environment:e.environment,steps:r,summary:{total_steps:t.journey.length,matched:n,unmatched:t.journey.length-n,passed:s,failed:o,assertion_failures:i}}}var ie=".paradigm/protocols",Pt="index.yaml";async function Ue(t){let e=x.join(t,ie);if(!h.existsSync(e))return [];let r=h.readdirSync(e).filter(s=>s.endsWith(".protocol")).sort(),n=[];for(let s of r)try{let o=h.readFileSync(x.join(e,s),"utf8"),i=N.load(o);i?.id&&i?.name&&n.push(i);}catch{}return n}async function Qn(t,e){let r=e.replace(/^P-/,""),n=x.join(t,ie,`${r}.protocol`);if(h.existsSync(n))try{let o=h.readFileSync(n,"utf8");return N.load(o)}catch{return null}return (await Ue(t)).find(o=>o.id===e)||null}async function _r(t){let e=x.join(t,ie,Pt);if(!h.existsSync(e))return null;try{let r=h.readFileSync(e,"utf8");return N.load(r)}catch{return null}}async function kr(t,e,r=3){let n=await Ue(t);if(n.length===0)return [];let s=es(e);if(s.length===0)return [];let o=[];for(let i of n){let a=0;for(let u of i.trigger){let d=u.toLowerCase();for(let f of s)d.includes(f)&&(a+=3);}for(let u of i.tags){let d=u.toLowerCase();for(let f of s)(d.includes(f)||f.includes(d))&&(a+=2);}let c=i.name.toLowerCase(),l=i.description.toLowerCase();for(let u of s)c.includes(u)&&(a+=1),l.includes(u)&&(a+=1);for(let u of i.steps)if(u.notes){let d=u.notes.toLowerCase();for(let f of s)d.includes(f)&&(a+=.5);}a>0&&o.push({protocol:i,score:a});}return o.sort((i,a)=>a.score-i.score),o.slice(0,r)}async function Rr(t,e){let r=x.join(t,ie);h.existsSync(r)||h.mkdirSync(r,{recursive:true});let n=ns(e.name),s=`P-${n}`,o=new Date().toISOString(),i={id:s,name:e.name,description:e.description,trigger:e.trigger,tags:e.tags,symbols:e.symbols||[],exemplar:e.exemplar,steps:e.steps,recorded_from:e.recorded_from,recorded_at:o,last_verified:o,verified_by:e.verified_by||"claude-opus-4-6",status:"current"},a=x.join(r,`${n}.protocol`);return h.writeFileSync(a,N.dump(i,{lineWidth:-1,noRefs:true}),"utf8"),s}async function Ir(t,e,r,n=false){let s=await Qn(t,e);if(!s)return false;r.name!==void 0&&(s.name=r.name),r.description!==void 0&&(s.description=r.description),r.trigger!==void 0&&(s.trigger=r.trigger),r.tags!==void 0&&(s.tags=r.tags),r.symbols!==void 0&&(s.symbols=r.symbols),r.exemplar!==void 0&&(s.exemplar=r.exemplar),r.steps!==void 0&&(s.steps=r.steps),r.status!==void 0&&(s.status=r.status),r.verified_by!==void 0&&(s.verified_by=r.verified_by),n&&(s.last_verified=new Date().toISOString(),s.verified_by=r.verified_by||"claude-opus-4-6");let o=e.replace(/^P-/,""),i=x.join(t,ie,`${o}.protocol`);return h.writeFileSync(i,N.dump(s,{lineWidth:-1,noRefs:true}),"utf8"),true}function Zn(t,e){let r=[],n="current";if(e.exemplar){let s=x.join(t,e.exemplar);h.existsSync(s)?h.statSync(s).mtime.toISOString()>e.last_verified&&(r.push(`Exemplar modified since last verified: ${e.exemplar}`),n!=="broken"&&(n="stale")):(r.push(`Exemplar missing: ${e.exemplar}`),n="broken");}for(let s of e.steps){if(s.template_from){let o=x.join(t,s.template_from);h.existsSync(o)||(r.push(`Template file missing: ${s.template_from}`),n="broken");}if(s.action==="modify"&&s.target){let o=x.join(t,s.target);!s.target.includes("{")&&!h.existsSync(o)&&(r.push(`Modify target missing: ${s.target}`),n="broken");}}return {status:n,issues:r}}async function Ct(t){let e=await Ue(t),r=[],n=0,s=0,o=0;for(let c of e){let l=Zn(t,c);if(c.status!==l.status){c.status=l.status;let u=c.id.replace(/^P-/,""),d=x.join(t,ie,`${u}.protocol`);h.existsSync(d)&&h.writeFileSync(d,N.dump(c,{lineWidth:-1,noRefs:true}),"utf8");}switch(l.status){case "current":n++;break;case "stale":s++;break;case "broken":o++;break}r.push({id:c.id,name:c.name,status:l.status,last_verified:c.last_verified,trigger:c.trigger,tags:c.tags});}let i={version:"1.0",generated:new Date().toISOString(),protocols:r,health:{total:e.length,current:n,stale:s,broken:o}},a=x.join(t,ie);if(e.length>0){h.existsSync(a)||h.mkdirSync(a,{recursive:true});let c=x.join(a,Pt);h.writeFileSync(c,N.dump(i,{lineWidth:-1,noRefs:true}),"utf8");}return i}function Pr(t,e,r){if(!e||e.length<2)return null;let n={};for(let s of e){let o=x.dirname(s);n[o]||(n[o]=[]),n[o].push(s);}for(let[s,o]of Object.entries(n)){if(o.length<2)continue;let i=x.join(t,s);if(!h.existsSync(i))continue;let c=h.readdirSync(i).filter(l=>{let u=x.extname(l);return [".ts",".tsx",".js",".jsx",".rs",".py"].includes(u)}).filter(l=>!o.some(u=>x.basename(u)===l));if(c.length>0){let l=x.join(s,c[0]),u=[...o.map(d=>({action:"create",target:d})),...r.map(d=>({action:"modify",target:d}))];return {hint:`This session created ${o.length} new files in ${s}/ following existing patterns. Consider recording a protocol.`,draft:{name:`Add a ${x.basename(s).replace(/s$/,"")}`,exemplar:l,steps:u}}}}return null}function es(t){return t.toLowerCase().replace(/[^a-z0-9\s-]/g," ").split(/\s+/).filter(e=>e.length>1).filter(e=>!ts.has(e))}var ts=new Set(["a","an","the","is","are","was","were","be","been","to","of","in","for","on","with","at","by","from","it","this","that","and","or","but","if","then","so","as","do","does","did","will","would","can","could","should","may","might","must","shall","i","me","my","we","our","you","your","he","she","how","what","when","where","which","who","whom"]);function ns(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}var J="pack.yaml";var ss="PARADIGM_STRICT";function de(){let t=process.env[ss];if(t===void 0||t==="")return false;let e=t.toLowerCase();return e==="1"||e==="true"||e==="yes"||e==="on"}function rs(t){return h$1(t)}function jt(t,e){if(!h.existsSync(t))return {status:"missing"};let r;try{r=h.readFileSync(t,"utf-8");}catch{return He({status:"unparseable",errorClass:"other",detail:"file read error"},e)}let n;try{n=N.load(r);}catch(s){let{errorClass:o,detail:i}=rs(s);return He({status:"unparseable",errorClass:o,detail:i},e)}if(e?.schema){let s=e.schema.safeParse(n);if(!s.success){let o={status:"invalid",errorClass:"schema",detail:`schema validation failed (${s.error.issues.length} issue(s))`};return He(o,e)}return {status:"ok",data:s.data}}return {status:"ok",data:n}}function He(t,e){if(!(e?.strict??de())||t.status==="ok"||t.status==="missing")return t;throw new Error(`yaml load failed under PARADIGM_STRICT=1 (${t.errorClass}: ${t.detail})`)}b$1();var Ot="@a-company/university",Ft=".paradigm/university",Nt=".paradigm/cache/packs.json",F=class extends Error{constructor(r,n){super(`pack-load failed (${r}: ${n})`);this.errorClass=r;this.detail=n;this.name="PackLoadError";}},os=["id","name","version","schema_version","tenant_kind"],is=new Set(["first-party","project","external"]);function ue(t){let e=x.join(t,J),r=jt(e);switch(r.status){case "missing":throw new F("missing-manifest",`no ${J} at pack root`);case "unparseable":throw new F("manifest-unparseable",r.detail);case "invalid":throw new F("manifest-invalid",r.detail);case "ok":{let n=r.data;if(!n||typeof n!="object")throw new F("manifest-invalid","manifest is not an object");for(let s of os){let o=n[s];if(o==null||o==="")throw new F("missing-required-field",`required field ${String(s)} is missing or empty`)}if(!is.has(String(n.tenant_kind)))throw new F("missing-required-field","tenant_kind must be one of first-party|project|external");return n}}}function $t(t){let e=ls(t);if(e)return e;let r=[],n=x.join(t,"node_modules",Ot);if(h.existsSync(x.join(n,J)))try{let o=ue(n);r.push({manifest:o,rootDir:n,source:"first-party"});}catch(o){a$1.component("#pack-loader").warn("first-party pack manifest invalid",{errorClass:o instanceof F?o.errorClass:"other"});}for(let o of as(t))try{let i=ue(o);r.push({manifest:i,rootDir:o,source:"npm"});}catch(i){a$1.component("#pack-loader").warn("npm pack manifest invalid",{errorClass:i instanceof F?i.errorClass:"other"});}let s=x.join(t,Ft);if(h.existsSync(s)&&h.statSync(s).isDirectory()){let o=x.join(s,J),i;if(h.existsSync(o))try{i=ue(s),r.push({manifest:i,rootDir:s,source:"local"});}catch(c){a$1.component("#pack-loader").warn("local pack manifest invalid",{errorClass:c instanceof F?c.errorClass:"other"});}let a=i?.id??"project";for(let c of cs(s))try{let l=ue(c);r.push({manifest:l,rootDir:c,source:"local",parentPackId:a});}catch(l){a$1.component("#pack-loader").warn("discipline sub-pack manifest invalid",{errorClass:l instanceof F?l.errorClass:"other"});}}return ds(t,r),r}function as(t){let e=x.join(t,"package.json");if(!h.existsSync(e))return [];let r;try{r=JSON.parse(h.readFileSync(e,"utf8"));}catch{return []}let n=new Set([...Object.keys(r.dependencies||{}),...Object.keys(r.devDependencies||{}),...Object.keys(r.peerDependencies||{})]);if(n.size===0)return [];let s=x.join(t,"node_modules");if(!h.existsSync(s))return [];let o=[];for(let i of n){if(i===Ot)continue;let a=x.join(s,i,"package.json");if(!h.existsSync(a))continue;let c;try{c=JSON.parse(h.readFileSync(a,"utf8"));}catch{continue}let l=c.paradigm?.universityPack;if(typeof l!="string"||l.length===0)continue;let u=x.resolve(x.dirname(a),l);h.existsSync(x.join(u,J))&&o.push(u);}return o}function cs(t){let e=[],r;try{r=h.readdirSync(t,{withFileTypes:!0});}catch{return e}for(let n of r){if(!n.isDirectory()||n.name.startsWith("."))continue;let s=x.join(t,n.name);h.existsSync(x.join(s,J))&&e.push(s);}return e}function Dr(t,e){if(typeof t!="string"||t.length===0)throw new Error("resolveEntryAddress: address must be a non-empty string");let r=t.indexOf(":");if(r!==-1){let s=t.slice(0,r),o=t.slice(r+1);if(!s||!o)throw new Error("resolveEntryAddress: malformed <pack-id>:<entry-id> address");return {packId:s,entryId:o}}let n=t;if(e.candidatePacks&&e.entryExistsIn){let s=e.candidatePacks.filter(o=>e.entryExistsIn(o,n));if(s.length>1){let o=s.map(i=>`${i}:${n}`).join(", ");throw new Error(`resolveEntryAddress: bare entry id "${n}" is ambiguous across packs. Candidates: ${o}`)}if(s.length===1)return {packId:s[0],entryId:n}}return {packId:e.activePack,entryId:n}}function Mt(t){try{return h.statSync(x.join(t,"node_modules")).mtime.getTime()}catch{return}}function Dt(t){try{return h.statSync(x.join(t,Ft)).mtime.getTime()}catch{return}}function ls(t){let e=x.join(t,Nt);if(!h.existsSync(e))return null;let r;try{r=JSON.parse(h.readFileSync(e,"utf8"));}catch{return null}if(r.version!==1||!Array.isArray(r.packs))return null;let n=Mt(t),s=Dt(t);return r.node_modules_mtime_ms!==n||r.local_university_mtime_ms!==s?null:r.packs.map(o=>({manifest:o.manifest,rootDir:o.rootDir,source:o.source,...o.parentPackId?{parentPackId:o.parentPackId}:{}}))}function ds(t,e){let r=x.join(t,Nt);try{h.mkdirSync(x.dirname(r),{recursive:!0});let n={version:1,node_modules_mtime_ms:Mt(t),local_university_mtime_ms:Dt(t),packs:e.map(s=>({manifest:s.manifest,rootDir:s.rootDir,source:s.source,...s.parentPackId?{parentPackId:s.parentPackId}:{}}))};h.writeFileSync(r,JSON.stringify(n,null,2),"utf8");}catch{}}b$1();var fe=".paradigm/university",ne="content",We="notes",Ee="policies",Te="quizzes",ve="paths",Ut="diplomas",Ht="index.yaml",us="config.yaml";function Ge(t){let e=x.join(t,fe);if(h.existsSync(e))return e;try{let n=$t(t).find(s=>s.manifest.tenant_kind==="first-party");if(n)return n.rootDir}catch{}return e}function zt(t){if(!h.existsSync(t))return null;let e=x.join(t,J);if(h.existsSync(e))try{return ue(t)}catch(n){a$1.component("#university-loader").warn("pack manifest invalid, using implicit manifest",{errorClass:n instanceof F?n.errorClass:"other"});}let r=x.basename(t)||"project";return {id:r,name:r,version:"0.0.0",schema_version:"1",tenant_kind:"project",description:"Implicit project pack (pack.yaml not present \u2014 v5 layout)",origin_hint:"authored"}}function fs(t,e,r){return e?{...t,...t.pack_id?{}:{pack_id:e.id},...t.discipline||!r?{}:{discipline:r}}:t}var Wt={name:"Project University",tagline:"Learn the codebase",institution:"Paradigm"},Gt={primary:"#6366f1",secondary:"#8b5cf6",accent:"#f59e0b",background:"#0f172a",surface:"#1e293b",text:"#f8fafc",textMuted:"#94a3b8",success:"#22c55e",error:"#ef4444",font:"Inter, system-ui, sans-serif"},ze={branding:Wt,theme:Gt,content:{categories:[],defaultDifficulty:"beginner",requireApproval:false},diplomas:{includeGlobalPLSAT:true,customCertStyle:null}};function Be(t){let e=x.join(t,fe,us);if(!h.existsSync(e))return {...ze};try{let r=h.readFileSync(e,"utf8"),n=N.load(r);return n?{branding:{...Wt,...n.branding||{}},theme:{...Gt,...n.theme||{}},content:{categories:n.content?.categories||[],defaultDifficulty:n.content?.defaultDifficulty||"beginner",requireApproval:n.content?.requireApproval??!1,defaultCategory:n.content?.defaultCategory},diplomas:{includeGlobalPLSAT:n.diplomas?.includeGlobalPLSAT??!0,customCertStyle:n.diplomas?.customCertStyle??null}}:{...ze}}catch{return {...ze}}}function _e(t){let e=x.join(t,fe,Ht);if(!h.existsSync(e))return null;try{let r=h.readFileSync(e,"utf8");return N.load(r)}catch{return null}}function Bt(t){let e=t.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);if(!e)return null;try{return {frontmatter:N.load(e[1]),body:e[2].trim()}}catch{return null}}function ps(t,e){return `---
|
|
107
|
+
${N.dump(t,{lineWidth:-1,noRefs:true,sortKeys:false})}---
|
|
108
|
+
|
|
109
|
+
${e}
|
|
110
|
+
`}function Gr(t,e,r){let n=qe(t,e,".md",r);if(!n)return null;try{let s=h.readFileSync(n,"utf8"),o=Bt(s);if(!o)return null;let i=o.frontmatter;return {frontmatter:ys(i),body:o.body}}catch{return null}}function Br(t,e,r,n){let s=e.type==="policy"?Ee:We,o=n??Ge(t),i=x.join(o,ne,s);h.mkdirSync(i,{recursive:true});let a=zt(o),c=fs(e,a),l=x.join(i,`${c.id}.md`),u=ps(c,r);return h.writeFileSync(l,u,"utf8"),l}function ms(t,e,r){let n=qe(t,e,".yaml",r);if(!n)return null;try{let s=h.readFileSync(n,"utf8"),o=N.load(s);return !o||!o.id?null:Ss(o)}catch{return null}}function Xr(t,e,r){let n=r??Ge(t),s=x.join(n,ne,Te);h.mkdirSync(s,{recursive:true});let o=zt(n),i={...e,...e.pack_id||!o?{}:{pack_id:o.id}},a=x.join(s,`${i.id}.yaml`);return h.writeFileSync(a,N.dump(i,{lineWidth:-1,noRefs:true}),"utf8"),a}function Xt(t,e,r){let n=qe(t,e,".yaml",r);if(!n)return null;try{let s=h.readFileSync(n,"utf8"),o=N.load(s);return !o||!o.id?null:o}catch{return null}}function qr(t,e,r){let n=r??Ge(t),s=x.join(n,ne,ve);h.mkdirSync(s,{recursive:true});let o=x.join(s,`${e.id}.yaml`);return h.writeFileSync(o,N.dump(e,{lineWidth:-1,noRefs:true}),"utf8"),o}function qt(t,e){let r=x.join(t,fe,Ut);if(!h.existsSync(r))return [];let n=[];try{let s=h.readdirSync(r).filter(o=>o.endsWith(".yaml"));for(let o of s)try{let i=h.readFileSync(x.join(r,o),"utf8"),a=N.load(i);if(!a||!a.id||e?.student&&a.student!==e.student||e?.type&&a.type!==e.type)continue;n.push(a);}catch{}}catch{}return n.sort((s,o)=>o.earnedAt.localeCompare(s.earnedAt))}function Vr(t,e){let r=_e(t);if(!r)return [];let n=[...r.entries];if(e.type&&(n=n.filter(o=>o.type===e.type)),e.tag&&(n=n.filter(o=>o.tags.some(i=>i.startsWith(e.tag)))),e.difficulty&&(n=n.filter(o=>o.difficulty===e.difficulty)),e.symbol&&(n=n.filter(o=>o.symbols.some(i=>i===e.symbol))),e.author&&(n=n.filter(o=>o.author===e.author)),e.query){let o=e.query.toLowerCase();n=n.filter(i=>i.title.toLowerCase().includes(o)||i.id.toLowerCase().includes(o)||i.tags.some(a=>a.toLowerCase().includes(o)));}if(e.category&&(n=n.filter(o=>o.category===e.category)),e.track){let o=Be(t),i=new Map;for(let a of o.content.categories)i.set(a.id,a.track||"core");n=n.filter(a=>(a.category&&i.get(a.category)||"core")===e.track);}let s=e.limit||20;return n.slice(0,s)}function Xe(t){let e=x.join(t,fe),r=x.join(e,ne),n=[];for(let u of [We,Ee]){let d=x.join(r,u);if(h.existsSync(d))try{for(let f of h.readdirSync(d).filter(m=>m.endsWith(".md")))try{let m=h.readFileSync(x.join(d,f),"utf8"),p=Bt(m);if(!p)continue;let g=p.frontmatter;n.push({id:g.id||f.replace(".md",""),title:g.title||f,type:g.type||(u===Ee?"policy":"note"),author:g.author||"unknown",created:g.created||"",updated:g.updated||"",tags:Array.isArray(g.tags)?g.tags:[],symbols:Array.isArray(g.symbols)?g.symbols:[],difficulty:g.difficulty||"beginner",file:`${ne}/${u}/${f}`,...g.category?{category:g.category}:{}});}catch{}}catch{}}let s=x.join(r,Te);if(h.existsSync(s))try{for(let u of h.readdirSync(s).filter(d=>d.endsWith(".yaml")))try{let d=h.readFileSync(x.join(s,u),"utf8"),f=N.load(d);if(!f||!f.id)continue;n.push({id:f.id,title:f.title||u,type:"quiz",author:f.author||"unknown",created:f.created||"",updated:f.updated||"",tags:f.tags||[],symbols:f.symbols||[],difficulty:f.difficulty||"beginner",file:`${ne}/${Te}/${u}`,...f.category?{category:f.category}:{}});}catch{}}catch{}let o=x.join(r,ve);if(h.existsSync(o))try{for(let u of h.readdirSync(o).filter(d=>d.endsWith(".yaml")))try{let d=h.readFileSync(x.join(o,u),"utf8"),f=N.load(d);if(!f||!f.id)continue;n.push({id:f.id,title:f.title||u,type:"path",author:f.author||"unknown",created:f.created||"",updated:f.updated||"",tags:f.tags||[],symbols:[],file:`${ne}/${ve}/${u}`,...f.category?{category:f.category}:{}});}catch{}}catch{}let i=0,a=x.join(e,Ut);if(h.existsSync(a))try{i=h.readdirSync(a).filter(u=>u.endsWith(".yaml")).length;}catch{}let c={version:"1.0",generatedAt:new Date().toISOString(),totalContent:n.length,entries:n,diplomaCount:i};h.mkdirSync(e,{recursive:true});let l=x.join(e,Ht);return h.writeFileSync(l,N.dump(c,{lineWidth:-1,noRefs:true}),"utf8"),c}function Jr(t,e){let r=_e(t)||Xe(t),n=[],s=r.entries;e?.id&&(s=s.filter(l=>l.id===e.id));let o=null;e?.deep&&(o=Vt(t));let i=new Set(r.entries.map(l=>l.id));for(let l of s){if(l.title||n.push({contentId:l.id,severity:"error",check:"missing-title",message:"Content is missing a title",fix:"Add a title field to the content frontmatter"}),l.type==="quiz"&&gs(t,l.id,n),l.type==="path"&&hs(t,l.id,i,n),o&&l.symbols.length>0){Be(t).content.categories.find(m=>m.id===l.category)?.validationStrictness==="relaxed";for(let m of l.symbols)o.has(m)||n.push({contentId:l.id,severity:"warning",check:"broken-symbol-ref",message:`Symbol "${m}" not found in scan-index`,fix:`Remove or update the symbol reference in ${l.id}`});}e?.deep&&l.symbols.length>0&&l.updated&&ws(t,l,n);}let a=qt(t);for(let l of a)if(l.total>0&&l.percentage!==Math.round(l.score/l.total*1e4)/100){let u=Math.round(l.score/l.total*1e4)/100;Math.abs(l.percentage-u)>.1&&n.push({contentId:l.id,severity:"warning",check:"diploma-score-mismatch",message:`Diploma percentage ${l.percentage} doesn't match score ${l.score}/${l.total} (expected ${u})`});}let c=bs(t,r);return {status:n.some(l=>l.severity==="error")?"errors":n.length>0?"warnings":"healthy",totalContent:r.totalContent,checked:s.length,issues:n,symbolCoverage:c}}function gs(t,e,r){let n=ms(t,e);if(!n){r.push({contentId:e,severity:"error",check:"unreadable-quiz",message:"Quiz file could not be parsed"});return}(!n.passThreshold||n.passThreshold<0||n.passThreshold>1)&&r.push({contentId:e,severity:"warning",check:"invalid-pass-threshold",message:`passThreshold should be between 0 and 1, got ${n.passThreshold}`,fix:"Set passThreshold to a value between 0.0 and 1.0"});for(let s of n.questions){if(!s.choices||typeof s.choices!="object"){r.push({contentId:e,severity:"error",check:"invalid-quiz-choices",message:`Question ${s.id} has no choices defined`});continue}(!s.correct||!(s.correct in s.choices))&&r.push({contentId:e,severity:"error",check:"invalid-quiz-answer",message:`Question ${s.id}: correct answer "${s.correct}" not found in choices [${Object.keys(s.choices).join(", ")}]`,fix:`Set correct to one of: ${Object.keys(s.choices).join(", ")}`});}}function hs(t,e,r,n){let s=Xt(t,e);if(!s){n.push({contentId:e,severity:"error",check:"unreadable-path",message:"Learning path file could not be parsed"});return}for(let o of s.steps)o.content.startsWith("plsat:")||r.has(o.content)||n.push({contentId:e,severity:"error",check:"broken-path-step",message:`Learning path step references "${o.content}" which doesn't exist`,fix:`Create content with id "${o.content}" or remove this step`});}function Yr(t,e){let r=_e(t);if(!r)return [];let n=[];for(let s of r.entries)if(s.symbols.includes(e)){let o=Jt(t,s,e);n.push({id:s.id,title:s.title,type:s.type,stale:o});}return n}function Kr(t,e){let r=_e(t);if(!r)return {paths:[],suggestedContent:[],extracurricular:[],diplomaCount:0,totalContent:0};let n=Be(t),s=new Set;for(let f of n.content.categories)f.excludeFromOnboarding&&s.add(f.id);let o=r.entries.filter(f=>!f.category||!s.has(f.category)),i=r.entries.filter(f=>f.category&&s.has(f.category)),a=o.filter(f=>f.type==="path"),c=e?qt(t,{student:e}):[],l=new Set(c.map(f=>f.source)),u=a.map(f=>{let m=Xt(t,f.id);return {id:f.id,title:f.title,steps:m?.steps.length||0,completed:l.has(f.id)}}),d=o.filter(f=>f.type!=="path"&&(f.difficulty==="beginner"||f.tags.includes("onboarding"))).slice(0,10);return {paths:u,suggestedContent:d,extracurricular:i,diplomaCount:c.length,totalContent:r.totalContent}}function qe(t,e,r,n){let s=n??x.join(t,fe),o=x.join(s,ne);for(let i of [We,Ee,Te,ve]){let a=x.join(o,i,`${e}${r}`);if(h.existsSync(a))return a}return null}function ys(t){return {id:t.id||"",title:t.title||"",type:t.type||"note",author:t.author||"unknown",created:t.created||"",updated:t.updated||"",tags:Array.isArray(t.tags)?t.tags:[],symbols:Array.isArray(t.symbols)?t.symbols:[],difficulty:t.difficulty||"beginner",estimatedMinutes:t.estimatedMinutes,prerequisites:Array.isArray(t.prerequisites)?t.prerequisites:[],...t.category?{category:t.category}:{},...t.origin?{origin:t.origin}:{},...t.source?{source:t.source}:{},...t.pack_id?{pack_id:t.pack_id}:{},...t.discipline?{discipline:t.discipline}:{}}}function Ss(t){return {...t,tags:t.tags||[],symbols:t.symbols||[],difficulty:t.difficulty||"beginner",passThreshold:t.passThreshold??.7,questions:t.questions||[]}}function Vt(t){let e=new Set,r=x.join(t,".paradigm","scan-index.json");if(!h.existsSync(r))return e;try{let n=h.readFileSync(r,"utf8"),s=JSON.parse(n);if(s.symbols&&Array.isArray(s.symbols))for(let o of s.symbols)o.symbol&&e.add(o.symbol);}catch{}return e}function bs(t,e){let r=Vt(t),n=new Set;for(let o of e.entries)for(let i of o.symbols)r.has(i)&&n.add(i);let s=r.size;return {totalSymbols:s,coveredByContent:n.size,percentage:s>0?Math.round(n.size/s*100):0}}function Jt(t,e,r){if(!e.updated)return false;let n=new Date(e.updated).getTime();if(isNaN(n))return false;let s=x.join(t,".paradigm","scan-index.json");if(!h.existsSync(s))return false;try{let o=h.readFileSync(s,"utf8"),i=JSON.parse(o);if(i.symbols&&Array.isArray(i.symbols)){for(let a of i.symbols)if(a.symbol===r&&a.filePath){let c=x.join(t,a.filePath);if(h.existsSync(c)&&h.statSync(c).mtime.getTime()>n)return !0}}}catch{}return false}function ws(t,e,r){for(let n of e.symbols)if(Jt(t,e,n)){r.push({contentId:e.id,severity:"warning",check:"stale-content",message:`Content may be stale: symbol "${n}" was updated after content was last modified`,fix:`Review and update ${e.id} to reflect changes to ${n}`});break}}var Yt=new Set(["duplicate-key-detected"]);function xs(t){let e=t.trim();if(e.includes("/")||e.includes("\\")){let r=e.split(/[/\\]/);e=r[r.length-1]||"unknown";}return e.length>40&&(e=e.slice(0,40)),e||"unknown"}var ke=class{transforms=new Map;record(e,r,n=1){let s=xs(r),o=`${e}::${s}`,i=this.transforms.get(o);i?i.count+=n:this.transforms.set(o,{kind:e,surface:s,count:n});}report(){let e=Array.from(this.transforms.values()).sort((n,s)=>n.kind!==s.kind?n.kind.localeCompare(s.kind):n.surface.localeCompare(s.surface)),r=e.filter(n=>Yt.has(n.kind)).reduce((n,s)=>n+s.count,0);return {reindex_ts:new Date().toISOString(),transformations:e,lossy_count:r,strict_mode:de()}}hasLossy(){for(let e of this.transforms.values())if(Yt.has(e.kind))return true;return false}totalCount(){let e=0;for(let r of this.transforms.values())e+=r.count;return e}};b$1();var Es={"@":{category:"features",prefix:"@"},"#":{category:"components",prefix:"#"},"^":{category:"gates",prefix:"^"},$:{category:"flows",prefix:"$"},"&":{category:"integrations",prefix:"&"},"!":{category:"signals",prefix:"!"},"%":{category:"state",prefix:"%"}},Ts={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/"]},vs={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"]},Ve={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 yo(){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 So(t,e,r,n){if(t!=="paradigm_reindex")return {handled:false,text:""};try{let s=await _s(r.rootDir,r);await n(),lt.clear(),ut();let o=(s.integrityReport?.brokenReferences?.length||0)+(s.integrityReport?.duplicateSymbols?.length||0)+(s.componentAnchorIssues||0)+(s.crossFileIssues||0),i={success:!0,symbolCount:s.symbolCount,breakdown:s.breakdown,flowCount:s.flowCount,filesWritten:s.filesWritten.length,...s.aspectGraphStats?{aspects:s.aspectGraphStats.aspects,loreLinks:s.aspectGraphStats.loreLinks}:{},...s.protocolHealth?{protocols:s.protocolHealth.total,staleProtocols:s.protocolHealth.stale}:{},...o>0?{issues:o}:{}};s.consistency&&(i.consistency=s.consistency);let a=JSON.stringify(i,null,2);return Ae(a.length,t),{handled:!0,text:a}}catch(s){let o=JSON.stringify({error:s.message},null,2);return Ae(o.length,t),{handled:true,text:o}}}async function _s(t,e){let r=[],n=new ke,s;e?s=e.aggregation:s=await i(t);let o=e?.projectName||x.basename(t),i$1=x.join(t,".paradigm");h.existsSync(i$1)||h.mkdirSync(i$1,{recursive:true}),ks(t,n),Rs(s.purposeFiles,n);let a=Pe({symbols:s.symbols,purposeFiles:s.purposeFiles,portalFiles:s.portalFiles},{projectName:o}),c=x.join(i$1,"scan-index.json");h.writeFileSync(c,Ce(a),"utf8"),r.push(".paradigm/scan-index.json");let l=Is(t,s),u=x.join(i$1,"navigator.yaml");h.writeFileSync(u,N.dump(l,{indent:2,lineWidth:120,noRefs:true,sortKeys:false}),"utf8"),r.push(".paradigm/navigator.yaml");let d=Os(t,s.purposeFiles),f$1=0;if(d&&Object.keys(d.flows).length>0){let S=x.join(i$1,"flow-index.json");h.writeFileSync(S,JSON.stringify(d,null,2),"utf8"),r.push(".paradigm/flow-index.json"),f$1=Object.keys(d.flows).length;}let m;try{let S=await Et(t);vt(S,s.symbols,t);let I=await kt(S,t),K=await Rt(S,t),Q=S.exec("SELECT COUNT(*) FROM aspects")[0]?.values[0]?.[0]??0,ae=S.exec("SELECT COUNT(*) FROM anchors")[0]?.values[0]?.[0]??0,ye=S.exec("SELECT COUNT(*) FROM edges")[0]?.values[0]?.[0]??0;Tt(S,t),r.push(".paradigm/aspect-graph.db"),m={aspects:Q,anchors:ae,edges:ye,loreLinks:I};}catch{}let p=0;try{let S=await he(t);p=Object.keys(S.personas).length,p>0&&r.push(".paradigm/personas/index.yaml");}catch{}let g;try{let S=await Ct(t);S.health.total>0&&(g=S.health,r.push(".paradigm/protocols/index.yaml"));}catch{}let y;try{let S=x.join(t,".paradigm","university");if(h.existsSync(S)){let I=Xe(t);(I.totalContent>0||I.diplomaCount>0)&&(y={totalContent:I.totalContent,diplomaCount:I.diplomaCount},r.push(".paradigm/university/index.yaml"));}}catch{}let b;try{b=a$2(s,t);}catch{}let P;try{let S=b$4(s.symbols,t),I=S.missing+S.outOfBounds;I>0&&(P=I);}catch{}let $;try{$=c$2(s.purposeFiles,t);}catch{}let Y;try{let S=[];for(let I of s.purposeFiles){let K=a$3(I);K.data&&S.push({filePath:I,data:K.data});}if(S.length>0){let K=f(S).issues.length;K>0&&(Y=K);}}catch{}let se={};for(let S of s.symbols)se[S.type]=(se[S.type]||0)+1;let v={};for(let S of s.symbols)S.type==="component"&&S.componentType&&(v[S.componentType]=(v[S.componentType]||0)+1);let E=n.report();try{let S=x.join(i$1,"manifest.consistency.json");h.writeFileSync(S,JSON.stringify(E,null,2),"utf-8"),r.push(".paradigm/manifest.consistency.json");}catch{a$1.component("#reindex").warn("failed to write consistency manifest",{stage:"manifest-write"});}if(de()&&n.hasLossy())throw new Error(`reindex aborted: ${E.lossy_count} lossy transformation(s) detected under PARADIGM_STRICT=1. See .paradigm/manifest.consistency.json.`);return {action:"reindex",filesWritten:r,symbolCount:s.symbols.length,breakdown:se,flowCount:f$1,aspectGraphStats:m,personaCount:p,protocolHealth:g,consistency:E,...Object.keys(v).length>0?{componentTypeBreakdown:v}:{},...y?{universityStats:y}:{},...b?{integrityReport:b}:{},...P!==void 0?{componentAnchorIssues:P}:{},...$?{purposeHealth:$}:{},...Y!==void 0?{crossFileIssues:Y}:{}}}function ks(t,e){let r=x.join(t,"portal.yaml");if(!h.existsSync(r))return;let n;try{n=h.readFileSync(r,"utf-8");}catch{return}try{N.load(n);}catch(c){(c?.reason?.toLowerCase()||"").includes("duplicate")&&e.record("duplicate-key-detected","portal.yaml");return}let s;try{s=N.load(n,{schema:N.FAILSAFE_SCHEMA});}catch{return}if(!s||typeof s!="object")return;let o=s,i=o.gates;if(i&&typeof i=="object"&&!Array.isArray(i)){let c=0;for(let l of Object.keys(i))l.startsWith("^")&&c++;c>0&&e.record("prefix-stripped","portal.yaml",c);}else Array.isArray(i)&&i.length>0&&e.record("array-coerced","portal.yaml");let a=o.routes;Array.isArray(a)&&a.length>0&&e.record("array-coerced","portal.yaml"),o.version||e.record("default-applied","portal.yaml");}function Rs(t,e){for(let r of t){let n;try{n=h.readFileSync(r,"utf-8");}catch{continue}try{N.load(n);}catch(u){(u?.reason?.toLowerCase()||"").includes("duplicate")&&e.record("duplicate-key-detected","purpose.yaml");continue}let s;try{s=N.load(n,{schema:N.FAILSAFE_SCHEMA});}catch{continue}if(!s||typeof s!="object")continue;let o=s,i=["components","features","gates","signals","aspects","states"],a=0;for(let u of i)Array.isArray(o[u])&&a++;a>0&&e.record("array-coerced","purpose.yaml",a);let c=(u,d)=>{if(!u||typeof u!="object"||Array.isArray(u))return 0;let f=0;for(let m of Object.keys(u))m.startsWith(d)&&f++;return f},l=c(o.gates,"^")+c(o.signals,"!")+c(o.aspects,"~")+c(o.components,"#")+c(o.features,"#");l>0&&e.record("prefix-stripped","purpose.yaml",l);}}function Is(t,e){let r={};for(let n of e.symbols)if(n.type==="component"&&n.componentType){let s=n.componentType;r[s]||(r[s]=[]),r[s].push(n.symbol);}return {version:"1.0",generated:new Date().toISOString(),structure:Ps(t),key_files:Cs(t),skip_patterns:As(t),symbols:js(e.symbols,e.purposeFiles),...Object.keys(r).length>0?{symbolsByComponentType:r}:{}}}function Ps(t){let e={};for(let[r,n]of Object.entries(Ts)){let s=n.filter(o=>h.existsSync(x.join(t,o)));if(s.length>0){let o=Object.values(Es).find(i=>i.category===r);e[r]={paths:s,symbol:o?.prefix||"@"};}}return e}function Cs(t){let e={};for(let[r,n]of Object.entries(vs)){let s=n.filter(o=>h.existsSync(x.join(t,o)));s.length>0&&(e[r]=s);}return e.config||(e.config=[]),e.entry||(e.entry=[]),e.types||(e.types=[]),e}function As(t){let e={always:[...Ve.always],unless_testing:[...Ve.unless_testing],unless_docs:[...Ve.unless_docs]},r=x.join(t,".gitignore");if(h.existsSync(r))try{let s=h.readFileSync(r,"utf8").split(`
|
|
111
|
+
`).map(o=>o.trim()).filter(o=>o&&!o.startsWith("#")).filter(o=>o.endsWith("/")||o.includes("*")||["node_modules","dist","build",".cache"].some(i=>o.includes(i))).slice(0,20);for(let o of s)e.always.includes(o)||e.always.push(o);}catch{}return e}function Ls(t){switch(t){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 js(t,e,r){let n={};for(let s of t){let i=`${Ls(s.type)}${s.id}`;if(s.filePath)n[i]=s.filePath;else {let a=e.find(c=>x.dirname(c).toLowerCase().includes(s.id.toLowerCase()));a&&(n[i]=x.dirname(a)+"/");}}return n}function Os(t,e){let r={},n={};for(let s of e)try{let o=h.readFileSync(s,"utf8"),i=N.load(o);if(!i?.flows)continue;if(Array.isArray(i.flows))for(let a of i.flows){let c=a;if(!c.name)continue;let l=`$${c.name}`,u=Kt(c.steps);u.length>0&&(r[l]={id:l,description:c.description||"",steps:u,definedIn:x.relative(t,s)},Qt(l,u,n));}else for(let[a,c]of Object.entries(i.flows)){let l=a.startsWith("$")?a:`$${a}`,u=Kt(c.steps);u.length>0&&(r[l]={id:l,description:c.description||"",trigger:c.trigger,steps:u,validation:c.validation,definedIn:x.relative(t,s)},Qt(l,u,n));}}catch{}return Object.keys(r).length===0?null:{version:"1.0",generatedAt:new Date().toISOString(),flows:r,symbolToFlows:n}}function Kt(t){if(!t||!Array.isArray(t))return [];let e=[];for(let r=0;r<t.length;r++){let n=t[r];if(typeof n=="object"&&n!==null){let s=n,o=s.action||s.description||s.component||"";o&&e.push({id:s.id||`step-${r+1}`,action:o,symbol:s.symbol||s.component,expect:s.expect});}}return e}function Qt(t,e,r){for(let n of e)n.symbol&&(r[n.symbol]||(r[n.symbol]=[]),r[n.symbol].includes(t)||r[n.symbol].push(t));}export{cr as $,Gr as A,Br as B,ms as C,Xr as D,Xt as E,qr as F,Vr as G,Xe as H,Jr as I,Yr as J,Kr as K,Ue as L,Qn as M,_r as N,kr as O,Rr as P,Ir as Q,Zn as R,Pr as S,je as T,Qs as U,Et as V,Tt as W,rr as X,or as Y,ir as Z,ar as _,Ae as a,lr as aa,Gs as b,dr as ba,Bs as c,ur as ca,Xs as d,mr as da,qs as e,yo as ea,Vs as f,So as fa,dt as g,_s as ga,lt as h,me as i,ge as j,hr as k,It as l,yr as m,Sr as n,br as o,wr as p,xr as q,Er as r,Tr as s,de as t,jt as u,$t as v,Dr as w,Ge as x,zt as y,Be as z};
|