@a-company/paradigm 5.37.11 → 5.38.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.
Files changed (64) hide show
  1. package/dist/{accept-orchestration-SBZVK3H4.js → accept-orchestration-OATWIRHP.js} +1 -1
  2. package/dist/{aggregate-W66DM3GA.js → aggregate-A5S5MTCC.js} +1 -1
  3. package/dist/{beacon-5QVYV5DF.js → beacon-QVUD3MGP.js} +1 -1
  4. package/dist/{chunk-SI6SV76D.js → chunk-3DZK54RU.js} +72 -19
  5. package/dist/{chunk-KFNHCQ4R.js → chunk-4L7665QV.js} +1 -1
  6. package/dist/chunk-4VKSEOXZ.js +6 -0
  7. package/dist/{chunk-CHVQNRRT.js → chunk-5QOCKWK5.js} +1 -1
  8. package/dist/chunk-HOBHJPTL.js +24 -0
  9. package/dist/{chunk-T6IDXUUA.js → chunk-LWAIVOSF.js} +1 -1
  10. package/dist/chunk-NQ47TA6C.js +111 -0
  11. package/dist/{chunk-G7XFK2GI.js → chunk-RBLK34IA.js} +1 -1
  12. package/dist/chunk-RN4VE6P3.js +521 -0
  13. package/dist/{chunk-SUU6M4JH.js → chunk-TOYQ2QCB.js} +1 -1
  14. package/dist/{chunk-LBQBWIEX.js → chunk-Y4P4SGZV.js} +1 -1
  15. package/dist/chunk-ZJQY5PPP.js +7 -0
  16. package/dist/{commands-LMUD5L6R.js → commands-ANRJNG2W.js} +1 -1
  17. package/dist/compliance-D7GD6ZYC.js +6 -0
  18. package/dist/{constellation-CG7C4WFE.js → constellation-NWLXYATA.js} +1 -1
  19. package/dist/{cost-IDNVMAEV.js → cost-24UZSS2P.js} +1 -1
  20. package/dist/{diff-JVEYCXUC.js → diff-YGHBIJY5.js} +1 -1
  21. package/dist/dist-JZZJLVMR.js +2 -0
  22. package/dist/{dist-3ZCH25SG.js → dist-OG6MM4VY.js} +1 -1
  23. package/dist/dist-SE67SOXB.js +2 -0
  24. package/dist/doctor-WMVULMQD.js +2 -0
  25. package/dist/{flow-POQP27WA.js → flow-FVZR3YJ4.js} +1 -1
  26. package/dist/{hooks-IG2GOAHP.js → hooks-TFMMMB2H.js} +1 -1
  27. package/dist/index.js +5 -5
  28. package/dist/init-XYB62Q3X.js +2 -0
  29. package/dist/{integrity-UYDOOJDP.js → integrity-ROO3G43N.js} +1 -1
  30. package/dist/mcp.js +18 -10
  31. package/dist/{migrate-IBDE7VK4.js → migrate-Z5UQN57G.js} +1 -1
  32. package/dist/{orchestrate-RCAMBOIB.js → orchestrate-M5PBZBJQ.js} +1 -1
  33. package/dist/portal-check-ZMLVBIGW.js +8 -0
  34. package/dist/portal-compliance-6YR27IQU.js +2 -0
  35. package/dist/{probe-B22G2JKF.js → probe-3FTG6LYO.js} +1 -1
  36. package/dist/{reindex-FO5VMZVQ.js → reindex-I6LPAKCC.js} +1 -1
  37. package/dist/{review-6UAH6V3R.js → review-VMSX2PKI.js} +1 -1
  38. package/dist/{ripple-ZGDITCGB.js → ripple-FNZI47SH.js} +1 -1
  39. package/dist/sentinel.js +1 -1
  40. package/dist/{setup-3F5IK7MO.js → setup-FEWSYS3Y.js} +2 -2
  41. package/dist/{shift-FDADESC4.js → shift-PC6C7NUX.js} +3 -3
  42. package/dist/{snapshot-L2G56RPL.js → snapshot-3IYB67D4.js} +1 -1
  43. package/dist/{status-77M3SDIF.js → status-DB3KNLW3.js} +1 -1
  44. package/dist/{summary-LXLHFRN7.js → summary-PYTEIJ4U.js} +1 -1
  45. package/dist/{team-NSP6PMPS.js → team-PDK64JXI.js} +1 -1
  46. package/dist/{test-BQJMS4Y2.js → test-WLEPZQFC.js} +1 -1
  47. package/dist/{tools-CERDNVCG.js → tools-5ITPEPSV.js} +1 -1
  48. package/dist/{validate-VZXTJHGO.js → validate-BB6LRWIY.js} +1 -1
  49. package/dist/workspace-VMSPYIBV.js +2 -0
  50. package/package.json +2 -1
  51. package/templates/paradigm/specs/symbols.md +4 -2
  52. package/dist/chunk-3TR6LLXP.js +0 -111
  53. package/dist/chunk-J6KWGCHN.js +0 -24
  54. package/dist/chunk-QT2LKB3P.js +0 -7
  55. package/dist/chunk-SHD27BQX.js +0 -6
  56. package/dist/chunk-YT52WLBF.js +0 -521
  57. package/dist/compliance-WJINB5DM.js +0 -6
  58. package/dist/dist-R3RWD35F.js +0 -2
  59. package/dist/dist-VXCZWVVJ.js +0 -2
  60. package/dist/doctor-QJ47XAUP.js +0 -2
  61. package/dist/init-HIBRSVUB.js +0 -2
  62. package/dist/portal-check-Z3OCQEQR.js +0 -8
  63. package/dist/portal-compliance-4MG5F2GI.js +0 -2
  64. package/dist/workspace-MKSQN7B2.js +0 -2
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env node
2
- import {a,e,d}from'./chunk-QO7YPQXC.js';import'./chunk-5TAVYPOV.js';import*as c from'fs';import*as p from'path';import {execSync}from'child_process';import n from'chalk';import*as w from'js-yaml';function R(s){return s.match(/(?:^|\s)((?:\/|\.\/|[a-zA-Z0-9_-]+\/)[^\s,;:'"]+\.[a-zA-Z]{1,10})\b/)?.[1]}async function $(s,l){try{let a$1=a(s),f=[];try{f=execSync("git diff --name-only HEAD",{cwd:s,encoding:"utf8",timeout:5e3}).trim().split(`
3
- `).filter(Boolean);}catch{}let i;try{i=execSync("git status --porcelain",{cwd:s,encoding:"utf8",timeout:5e3}).trim()==="";}catch{}let u=p.join(s,"portal.yaml"),g=!1;if(c.existsSync(u))try{let t=c.readFileSync(u,"utf8"),e=w.load(t);g=e?.routes!=null&&Object.keys(e.routes).length>0;}catch{}let r=e({toolsCalled:[],filesModified:f,symbolsTouched:[],loreRecorded:!1,hasPortalRoutes:g,taskAddsRoutes:!1,gitClean:i}),o=d(a$1,l,r),d$1=0;if(o.evaluations.length>0)try{let t=p.join(s,".paradigm","sentinel");if(c.existsSync(t)){let{SentinelStorage:e}=await import('./dist-VGFSP3XM.js'),m=new e(t);for(let b of o.evaluations)m.recordPracticeEvent({habitId:b.habit.id,habitCategory:b.habit.category,result:b.result,engineer:"agent",sessionId:`cli-${Date.now().toString(36)}`,symbolsTouched:[],filesModified:f,notes:b.reason}),d$1++;}}catch{}let h=p.join(s,".paradigm",".habits-blocking");try{if(l==="on-stop"&&o.blocksCompletion){let t=o.evaluations.filter(e=>e.result==="skipped"&&e.habit.severity==="block").map(e=>`${e.habit.name}: ${e.reason}`);c.writeFileSync(h,t.join(`
4
- `),"utf8");}else l==="on-stop"&&c.existsSync(h)&&c.unlinkSync(h);}catch{}return {trigger:l,evaluation:{total:o.summary.total,followed:o.summary.followed,skipped:o.summary.skipped,partial:o.summary.partial,blockingViolations:o.summary.blockingViolations,blocksCompletion:o.blocksCompletion},habits:o.evaluations.map(t=>({id:t.habit.id,name:t.habit.name,category:t.habit.category,severity:t.habit.severity,result:t.result,reason:t.reason,evidence:t.evidence})),recorded:d$1}}catch{return null}}async function P(s,l){let a=p.join(s,".paradigm","aspect-graph.db");if(!c.existsSync(a))return {driftedCount:0,healedCount:0,cleanCount:0,missingCount:0,details:[]};try{let{driftCheckCommand:f}=await import('./drift-ILZE5BFJ.js'),i="",u=console.log;console.log=g=>{i=g;};try{await f({json:!0,autoHeal:l});}finally{console.log=u;}return i?JSON.parse(i):null}catch{return null}}async function B(s){if(!c.existsSync(p.join(s,"portal.yaml")))return null;try{let{checkPortalCompliance:l}=await import('./portal-compliance-4MG5F2GI.js'),a=await l(s);return {status:a.status,declaredButUnusedCount:a.declaredButUnused.length,usedButUndeclaredCount:a.usedButUndeclared.length,properlyDeclaredCount:a.properlyDeclared.length,declaredButUnused:a.declaredButUnused,usedButUndeclared:a.usedButUndeclared,properlyDeclared:a.properlyDeclared}}catch{return null}}async function j(s){try{let{runPostflightLearning:l}=await import('./ambient-WTLYUAQM.js');return await l(s)}catch{return null}}async function A(s){let l=process.cwd(),a=s.trigger||"on-stop",f=s.autoHeal!==false,i=[],u=[],g=await $(l,a),r=await P(l,f),o=await B(l);if(g?.evaluation.blocksCompletion){let t=g.habits.filter(e=>e.result==="skipped"&&e.severity==="block");for(let e of t){let m=`Blocking habit not satisfied: ${e.name} \u2014 ${e.reason}`;i.push(m),u.push({message:m,source:"habits",file:R(e.reason),severity:"blocking"});}}if(r&&r.driftedCount>0){let t=`${r.driftedCount} aspect anchor(s) have drifted (content genuinely changed). Run paradigm_aspect_check to review.`;i.push(t);for(let e of r.details.filter(m=>m.status==="drifted"))u.push({message:`Aspect ~${e.aspectId} drifted at lines ${e.startLine}-${e.endLine}`,source:"drift",file:e.path,severity:"advisory"});u.filter(e=>e.source==="drift").length===0&&u.push({message:t,source:"drift",severity:"advisory"});}if(o&&o.usedButUndeclaredCount>0){let t=`${o.usedButUndeclaredCount} gate(s) used in code but not declared in portal.yaml: ${o.usedButUndeclared.join(", ")}`;i.push(t);for(let e of o.usedButUndeclared)u.push({message:`Gate ^${e} used in code but not declared in portal.yaml`,source:"portal",file:"portal.yaml",severity:"blocking"});}let d=null;s.learn&&(d=await j(l));let h={habits:g,drift:r,portal:o,violations:i,structuredViolations:u,postflight:s.learn?d:void 0};if(s.json)console.log(JSON.stringify(h));else {if(console.log(n.magenta(`
5
- Paradigm Compliance Check
6
- `)),g){let{evaluation:t}=g,e=t.blocksCompletion?n.red:n.green;console.log(n.white(" Habits:")),console.log(` ${e(`${t.followed} followed, ${t.skipped} skipped, ${t.partial} partial`)}`),t.blockingViolations>0&&console.log(n.red(` ${t.blockingViolations} blocking violation(s)`)),console.log();}if(r&&(console.log(n.white(" Drift:")),r.healedCount>0&&console.log(n.green(` Auto-healed: ${r.healedCount} shifted anchor(s)`)),r.cleanCount>0&&console.log(n.green(` Clean: ${r.cleanCount} anchor(s)`)),r.driftedCount>0&&console.log(n.red(` Drifted: ${r.driftedCount} anchor(s)`)),r.missingCount>0&&console.log(n.yellow(` Missing: ${r.missingCount} anchor file(s)`)),console.log()),o){console.log(n.white(" Portal:"));let t=o.status==="compliant"?n.green:o.status==="warnings"?n.yellow:n.red;console.log(` Status: ${t(o.status)}`),o.usedButUndeclaredCount>0&&console.log(n.red(` ${o.usedButUndeclaredCount} undeclared gate(s)`)),console.log();}if(d){if(console.log(n.white(" Postflight Learning:")),d.journalsWritten>0){console.log(n.green(` Journals written: ${d.journalsWritten}`));for(let[t,e]of Object.entries(d.journalsByAgent))e>0&&console.log(n.gray(` ${t}: ${e} entries`));}else console.log(n.gray(" No verdicts to learn from"));d.promoted>0&&console.log(n.green(` Promoted to notebooks: ${d.promoted}`)),console.log();}if(i.length>0){console.log(n.red(` ${i.length} violation(s):`));for(let t of i)console.log(n.red(` - ${t}`));}else console.log(n.green(" All checks passed."));console.log();}i.length>0&&(process.exitCode=1);}export{A as complianceCheckCommand};
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import*as x from'fs';import*as C from'js-yaml';import {z as z$1}from'zod';import*as S from'path';import {glob}from'glob';var O=z$1.object({description:z$1.string(),type:z$1.string().optional(),parent:z$1.string().optional(),anchors:z$1.array(z$1.string()).optional(),tags:z$1.array(z$1.string()).optional(),endpoints:z$1.array(z$1.string()).optional(),tests:z$1.array(z$1.string()).optional(),rules:z$1.record(z$1.unknown()).optional(),aspects:z$1.array(z$1.string()).optional(),flows:z$1.array(z$1.string()).optional(),gates:z$1.array(z$1.string()).optional(),signals:z$1.array(z$1.string()).optional(),states:z$1.array(z$1.string()).optional(),components:z$1.array(z$1.string()).optional(),location:z$1.string().optional(),locations:z$1.array(z$1.string()).optional(),uses:z$1.array(z$1.string()).optional(),"used-by":z$1.array(z$1.string()).optional(),"used-for":z$1.array(z$1.string()).optional(),exports:z$1.array(z$1.string()).optional(),status:z$1.string().optional(),properties:z$1.record(z$1.unknown()).optional(),handles:z$1.array(z$1.string()).optional()}).passthrough(),L=O.extend({id:z$1.string()}),fe=z$1.object({description:z$1.string().optional(),category:z$1.string().optional(),severity:z$1.enum(["info","warn","error"]).optional(),emitters:z$1.array(z$1.string()).optional(),related:z$1.array(z$1.string()).optional(),data:z$1.record(z$1.unknown()).optional()}),le=z$1.union([fe,z$1.string().transform(t=>({description:t}))]),ue=z$1.object({from:z$1.string(),to:z$1.string(),type:z$1.string(),description:z$1.string().optional()}),de=z$1.union([ue,z$1.string()]),me=z$1.object({component:z$1.string(),action:z$1.string(),description:z$1.string().optional()}),B=z$1.union([me,z$1.string()]),ge=z$1.object({name:z$1.string(),description:z$1.string().optional(),steps:z$1.array(B)}),he=z$1.object({description:z$1.string().optional(),gates:z$1.array(z$1.string()).optional(),signals:z$1.array(z$1.string()).optional(),components:z$1.array(z$1.string()).optional(),steps:z$1.array(B).optional()}),ye=z$1.object({description:z$1.string().optional(),requires:z$1.array(z$1.string()).optional(),keys:z$1.array(z$1.string()).optional(),signals:z$1.array(z$1.string()).optional()}),$e=z$1.object({description:z$1.string().optional(),default:z$1.unknown().optional(),type:z$1.string().optional()}),we=z$1.object({description:z$1.string().optional(),tags:z$1.array(z$1.string()).optional(),anchors:z$1.array(z$1.string()).optional(),"applies-to":z$1.array(z$1.string()).optional(),enforcement:z$1.string().optional()}),be=z$1.object({target:z$1.string(),type:z$1.string(),path:z$1.string()}),Se=z$1.object({version:z$1.string().optional(),description:z$1.string().optional(),apiSpec:z$1.string().optional(),context:z$1.array(z$1.string()).optional(),rules:z$1.record(z$1.unknown()).optional(),features:z$1.union([z$1.array(L),z$1.record(O)]).optional(),components:z$1.union([z$1.array(L),z$1.record(O)]).optional(),gates:z$1.record(ye).optional(),states:z$1.record($e).optional(),signals:z$1.record(le).optional(),aspects:z$1.record(we).optional(),relationships:z$1.array(de).optional(),flows:z$1.union([z$1.array(ge),z$1.record(he)]).optional(),references:z$1.array(be).optional()});function ve(t){let e=Pe(t);return {data:e.data,errors:e.errors}}function Pe(t){let e=[],o=[],n;try{n=x.readFileSync(t,"utf8");}catch(l){let p=`Cannot read file: ${l.message}`;return e.push(p),o.push({message:p,type:"file"}),{data:null,errors:e,detailedErrors:o,rawContent:void 0,isYamlValid:false}}let r=n.replace(/^([#~!$^][\w-]+):/gm,'"$1":').replace(/^(\s*-\s+)([!#][\w-]+)$/gm,'$1"$2"'),a=null;try{a=C.load(r);}catch(l){let p=l,f=p.mark?.line?p.mark.line+1:void 0,u=`YAML syntax error: ${p.reason||l.message}`;return e.push(`${u}${f?` (line ${f})`:""}`),o.push({message:u,line:f,type:"yaml"}),{data:null,errors:e,detailedErrors:o,rawContent:n,isYamlValid:false}}if(a==null)return {data:{},errors:[],detailedErrors:[],rawContent:n,isYamlValid:true};if(typeof a=="object"&&a!==null){let l=a,p={"#":"components",$:"flows","^":"gates","!":"signals","~":"aspects"};for(let f of Object.keys(l)){let u=f[0],g=p[u];if(!g||f.length<2)continue;let h=f.slice(1),w=l[f];if(typeof w!="object"||w===null)continue;let v=l[g]||{};g in l||(l[g]=v),h in v||(v[h]=w),delete l[f];}}let i=Se.safeParse(a);if(!i.success){for(let l of i.error.issues){let p=l.path.join("."),f=l.message;e.push(`Schema error at ${p||"/"}: ${f}`),o.push({message:f,path:p||"/",type:"schema"});}return {data:a,errors:e,detailedErrors:o,rawContent:n,isYamlValid:true}}return {data:i.data,errors:[],detailedErrors:[],rawContent:n,isYamlValid:true}}function k(t){return t?Array.isArray(t)?t.map(e=>[e.id,e]):Object.entries(t):[]}async function je(t){let e=S.resolve(t);return (await glob("**/.purpose",{cwd:e,absolute:true,ignore:["**/node_modules/**","**/dist/**","**/.git/**"]})).sort((n,r)=>{let a=n.split(S.sep).length,i=r.split(S.sep).length;return a-i})}async function V(t){let e=await je(t),o=[];for(let n of e){let{data:r,errors:a}=ve(n);r&&(o.push({filePath:n,data:r}),a.length>0&&console.warn(`Warnings parsing ${n}:`,a));}return o}function Y(t){let e=new Map;for(let{filePath:o,data:n}of t){let r=k(n.features);for(let[a,i]of r)e.set(a,{item:i,filePath:o});}return e}function W(t){let e=new Map;for(let{filePath:o,data:n}of t){let r=k(n.components);for(let[a,i]of r)e.set(a,{item:i,filePath:o});}return e}function _(t){let e=new Map;for(let{filePath:o,data:n}of t)if(n.gates)for(let[r,a]of Object.entries(n.gates))e.set(r,{item:a,filePath:o});return e}function N(t){let e=new Map;for(let{filePath:o,data:n}of t)if(n.states)for(let[r,a]of Object.entries(n.states))e.set(r,{item:a,filePath:o});return e}function K(t){let e=new Map;for(let{filePath:o,data:n}of t)if(n.flows)if(Array.isArray(n.flows))for(let r of n.flows)e.set(r.name,{item:{id:r.name,description:r.description,steps:r.steps},filePath:o});else for(let[r,a]of Object.entries(n.flows))e.set(r,{item:{id:r,description:a.description,gates:a.gates,signals:a.signals,components:a.components,steps:a.steps},filePath:o});return e}function q(t){let e=new Map;for(let{filePath:o,data:n}of t)if(n.signals)for(let[r,a]of Object.entries(n.signals))e.set(r,{item:a,filePath:o});return e}function Z(t){let e=new Map;for(let{filePath:o,data:n}of t)if(n.aspects)for(let[r,a]of Object.entries(n.aspects))e.set(r,{item:a,filePath:o});return e}function U(t){let e=[],o=new Set;for(let{filePath:n,data:r}of t){let a=k(r.features);for(let[l,p]of a)M(`#${l}`,p,n,e,o);let i=k(r.components);for(let[l,p]of i)M(`#${l}`,p,n,e,o);}return e}function M(t,e,o,n,r){if(e.flows)for(let a of e.flows){let i=a.startsWith("$")?a:`$${a}`;r.has(i)||(r.add(i),n.push({symbol:i,type:"flow",sourceSymbol:t,filePath:o}));}if(e.gates)for(let a of e.gates){let i=a.startsWith("^")?a:`^${a}`;r.has(i)||(r.add(i),n.push({symbol:i,type:"gate",sourceSymbol:t,filePath:o}));}if(e.signals)for(let a of e.signals){let i=a.startsWith("!")?a:`!${a}`;r.has(i)||(r.add(i),n.push({symbol:i,type:"signal",sourceSymbol:t,filePath:o}));}if(e.states)for(let a of e.states){let i=a.startsWith("#")?a:a.startsWith("%")?`#${a.slice(1)}`:`#${a}`;r.has(i)||(r.add(i),n.push({symbol:i,type:"component",sourceSymbol:t,filePath:o}));}if(e.components)for(let a of e.components){let i=a.startsWith("#")?a:`#${a}`;r.has(i)||(r.add(i),n.push({symbol:i,type:"component",sourceSymbol:t,filePath:o}));}if(e.aspects)for(let a of e.aspects){let i=a.startsWith("~")?a:`~${a}`;r.has(i)||(r.add(i),n.push({symbol:i,type:"aspect",sourceSymbol:t,filePath:o}));}if(e.description){let a=Ce(e.description);for(let{symbol:i,type:l}of a)r.has(i)||(r.add(i),n.push({symbol:i,type:l,sourceSymbol:t,filePath:o}));}}var ke=new Set(["$lib","$env","$app","$service-worker","$virtual","$schema","$ref","$id","$type"]);function Ce(t){let e=[],o=/([$^!#~%])([a-zA-Z][a-zA-Z0-9._-]*)/g,n;for(;(n=o.exec(t))!==null;){let r=n[1],a=n[2],i,l;switch(r){case "#":l="component",i=`#${a}`;break;case "$":l="flow",i=`$${a}`;break;case "^":l="gate",i=`^${a}`;break;case "!":l="signal",i=`!${a}`;break;case "~":l="aspect",i=`~${a}`;break;case "%":l="component",i=`#${a}`;break;default:continue}ke.has(i)||e.push({symbol:i,type:l});}return e}var Ie={visualizerPort:42195,watcherPort:42196,autoConnect:true};async function I(t){let e=S.resolve(t),o=S.dirname(e);if(!x.existsSync(e))throw new Error(`Gate config not found: ${e}`);let n=x.readFileSync(e,"utf8"),r=C.load(n);if(!r.version)throw new Error('Gate config missing required "version" field');let a=[],i=r,l=r.gates||i.portals;if(l)for(let[f,u]of Object.entries(l))a.push(F(f,u));if(r.include)for(let f of r.include){let u=S.join(o,f),g=await glob(u.replace(/\\/g,"/"));for(let h of g){let w=await Ae(h);a.push(...w);}}let p=[];if(r.flows)for(let[f,u]of Object.entries(r.flows))p.push(Oe(f,u));return {version:r.version,gates:a,flows:p,settings:{dev:{...Ie,...r.settings?.dev}}}}async function Ae(t){let e=x.readFileSync(t,"utf8"),o=C.load(e);if(o.id)return [F(o.id,o)];if(o.gates){let n=[];for(let[r,a]of Object.entries(o.gates))n.push(F(r,a));return n}return []}function F(t,e){let o=[];if(e.locks)for(let r of e.locks)o.push(De(r));let n=[];if(e.prizes)for(let r of e.prizes)n.push(ze(r));return {id:t,description:e.description,locks:o,prizes:n,position:e.position}}function De(t){let e=t,o=[];if(e.keys){for(let n of e.keys)if(typeof n=="string")o.push({expression:n});else if(n.expression){let r=n;o.push({expression:r.expression,description:r.description});}}return {id:e.id,description:e.description,keys:o,mode:e.mode||"all"}}function ze(t){let e=t;return {id:e.id,oneTime:e.oneTime??false,metadata:e.metadata}}function Oe(t,e){return {id:t,description:e.description,gates:e.gates||[],forkable:e.forkable}}async function H(t){let e=S.resolve(t);return await glob("**/portal.yaml",{cwd:e,absolute:true,ignore:["**/node_modules/**","**/dist/**","**/.git/**"]})}var Ee={component:"#",flow:"$",gate:"^",signal:"!",aspect:"~"},Fe={"#":"component",$:"flow","^":"gate","!":"signal","~":"aspect"},Te=["#","$","^","!","~"];function Re(t){return Te.includes(t)}var Le=z$1.object({x:z$1.number(),y:z$1.number()}),Me=z$1.object({x:z$1.number(),y:z$1.number(),zoom:z$1.number()}),J=z$1.object({path:z$1.string(),include:z$1.array(z$1.string()).optional(),exclude:z$1.array(z$1.string()).optional()}),ee=z$1.object({id:z$1.string(),symbol:z$1.string(),type:z$1.enum(["feature","component","flow","state","aspect","gate","signal","idea"]),content:z$1.string().optional(),position:Le,tags:z$1.array(z$1.string()).optional(),created:z$1.string(),modified:z$1.string().optional()}),te=z$1.object({from:z$1.string(),to:z$1.string(),label:z$1.string().optional(),type:z$1.string().optional()}),Ge=z$1.object({id:z$1.string(),name:z$1.string(),nodes:z$1.array(z$1.string()),color:z$1.string().optional()}),oe=z$1.object({viewport:Me,groups:z$1.array(Ge).optional()}),Be=z$1.object({nodes:z$1.array(ee),connections:z$1.array(te),layout:oe}),Ve=z$1.object({id:z$1.string(),name:z$1.string(),timestamp:z$1.string(),description:z$1.string().optional(),state:Be}),Ye=z$1.object({version:z$1.string(),metadata:z$1.object({name:z$1.string(),created:z$1.string(),modified:z$1.string()}),sources:z$1.object({purpose:z$1.array(J).optional(),portal:z$1.array(J).optional()}),nodes:z$1.array(ee),connections:z$1.array(te),layout:oe,snapshots:z$1.array(Ve).optional()});function nt(t){let e=[],o;try{o=x.readFileSync(t,"utf8");}catch(n){return e.push(`Cannot read file: ${n.message}`),{data:null,errors:e,rawContent:void 0}}return We(o)}function We(t){let e=[],o=null;try{o=C.load(t);}catch(r){let a=r,i=a.mark?.line?a.mark.line+1:void 0;return e.push(`YAML syntax error: ${a.reason||r.message}${i?` (line ${i})`:""}`),{data:null,errors:e,rawContent:t}}if(o==null)return {data:se(),errors:[],rawContent:t};let n=Ye.safeParse(o);if(!n.success){for(let r of n.error.issues){let a=r.path.join(".");e.push(`Schema error at ${a||"/"}: ${r.message}`);}return {data:o,errors:e,rawContent:t}}return {data:n.data,errors:[],rawContent:t}}function se(t="Untitled"){let e=new Date().toISOString();return {version:"1.0.0",metadata:{name:t,created:e,modified:e},sources:{purpose:[{path:"./"}],portal:[{path:"./portal.yaml"}]},nodes:[],connections:[],layout:{viewport:{x:0,y:0,zoom:1}}}}function _e(t){return t.metadata.modified=new Date().toISOString(),C.dump(t,{indent:2,lineWidth:-1,noRefs:true,sortKeys:false})}function rt(t="My Project"){return _e(se(t))}function at(t,e){return {...t,nodes:[...t.nodes,e],metadata:{...t.metadata,modified:new Date().toISOString()}}}function it(t,e,o){return {...t,nodes:t.nodes.map(n=>n.id===e?{...n,position:o,modified:new Date().toISOString()}:n),metadata:{...t.metadata,modified:new Date().toISOString()}}}function ct(t,e){return t.connections.some(n=>n.from===e.from&&n.to===e.to)?t:{...t,connections:[...t.connections,e],metadata:{...t.metadata,modified:new Date().toISOString()}}}function pt(t,e,o){let n={id:`snap-${Date.now()}`,name:e,timestamp:new Date().toISOString(),description:o,state:{nodes:[...t.nodes],connections:[...t.connections],layout:{...t.layout}}};return {...t,snapshots:[...t.snapshots||[],n],metadata:{...t.metadata,modified:new Date().toISOString()}}}async function Ne(t,e){let o=[],n=[],r=[],a=[];if(t.sources.purpose)for(let p of t.sources.purpose){let f=S.resolve(e,p.path);try{let u=await V(f);r.push(...u.map(d=>d.filePath));let g=Y(u);for(let[d,{item:m,filePath:y}]of g){let P=["feature",...m.tags||[]];o.push($({id:`purpose-feature-${d}`,symbol:`#${d}`,type:"component",source:"purpose",filePath:y,data:m,description:m.description,tags:P,componentType:m.type,parentSymbol:m.parent,anchors:m.anchors?.map(pe=>T(pe))}));}let h=W(u);for(let[d,{item:m,filePath:y}]of h)o.push($({id:`purpose-component-${d}`,symbol:`#${d}`,type:"component",source:"purpose",filePath:y,data:m,description:m.description,tags:m.tags,componentType:m.type,parentSymbol:m.parent,anchors:m.anchors?.map(P=>T(P))}));let w=_(u);for(let[d,{item:m,filePath:y}]of w)o.push($({id:`purpose-gate-${d}`,symbol:`^${d}`,type:"gate",source:"purpose",filePath:y,data:m,description:m.description}));let v=N(u);for(let[d,{item:m,filePath:y}]of v)o.push($({id:`purpose-state-${d}`,symbol:`#${d}`,type:"component",source:"purpose",filePath:y,data:m,description:m.description,tags:["state"]}));let re=K(u);for(let[d,{item:m,filePath:y}]of re)o.push($({id:`purpose-flow-${d}`,symbol:`$${d}`,type:"flow",source:"purpose",filePath:y,data:m,description:m.description}));let ae=q(u);for(let[d,{item:m,filePath:y}]of ae)o.push($({id:`purpose-signal-${d}`,symbol:`!${d}`,type:"signal",source:"purpose",filePath:y,data:m,description:m.description}));let ie=Z(u);for(let[d,{item:m,filePath:y}]of ie)o.push($({id:`purpose-aspect-${d}`,symbol:`~${d}`,type:"aspect",source:"purpose",filePath:y,data:m,description:m.description,anchors:m.anchors?.map(P=>T(P)),appliesTo:m["applies-to"],tags:m.tags,enforcement:m.enforcement}));let ce=U(u),R=new Set(o.map(d=>d.symbol));for(let d of ce)R.has(d.symbol)||(R.add(d.symbol),o.push($({id:`purpose-ref-${d.type}-${d.symbol.slice(1)}`,symbol:d.symbol,type:d.type,source:"purpose",filePath:d.filePath,data:{referencedFrom:d.sourceSymbol},description:`Referenced from ${d.sourceSymbol}`})));}catch(u){n.push({source:"purpose",filePath:f,message:u.message});}}if(t.sources.portal)for(let p of t.sources.portal){let f=S.resolve(e,p.path);try{let u;if(f.endsWith(".yaml")||f.endsWith(".yml"))u=await I(f),a.push(f);else {let g=await H(f);if(a.push(...g),g.length>0){u=await I(g[0]);for(let h=1;h<g.length;h++){let w=await I(g[h]);u.gates.push(...w.gates),u.flows.push(...w.flows);}}else continue}for(let g of u.gates){o.push(Ke(g,f));for(let h of g.prizes)o.push($({id:`gate-signal-${g.id}-${h.id}`,symbol:`!${h.id}`,type:"signal",source:"portal",filePath:f,data:h,description:`Signal from gate ${g.id}`}));}for(let g of u.flows)o.push(qe(g,f));}catch(u){n.push({source:"portal",filePath:f,message:u.message});}}for(let p of t.nodes){let f=p.tags?.includes("idea");if(!p.content&&!f){let u=o.find(g=>g.symbol===p.symbol);if(u){u.position=p.position,u.tags=p.tags;continue}}o.push($({id:p.id,symbol:p.symbol,type:p.type,source:"premise",filePath:".premise",data:p,description:p.content,position:p.position,tags:p.tags,created:p.created,modified:p.modified}));}Ue(o);let i=new Map;for(let p of o){let f=i.get(p.symbol)||[];f.includes(p.filePath)||f.push(p.filePath),i.set(p.symbol,f);}let l=[];for(let[p,f]of i)f.length>1&&l.push({symbol:p,files:f});return {symbols:o,purposeFiles:r,portalFiles:a,errors:n,timestamp:Date.now(),...l.length>0?{duplicateSymbols:l}:{}}}function $(t){return {...t,data:t.data??null,references:t.references??[],referencedBy:t.referencedBy??[]}}function Ke(t,e){return $({id:`gate-${t.id}`,symbol:`^${t.id}`,type:"gate",source:"portal",filePath:e,data:t,description:t.description,position:t.position})}function qe(t,e){return $({id:`gate-flow-${t.id}`,symbol:`$${t.id}`,type:"flow",source:"portal",filePath:e,data:t,description:t.description})}function T(t){let e=t.lastIndexOf(":");if(e===-1||e===t.length-1)return {path:t,lines:0,raw:t};let o=t.slice(e+1),n=t.slice(0,e);if(!/^[\d,\- ]+$/.test(o))return {path:t,lines:0,raw:t};if(o.includes("-")){let[r,a]=o.split("-").map(Number);return {path:n,lines:[r,a],raw:t}}else if(o.includes(",")){let r=o.split(",").map(Number);return {path:n,lines:r,raw:t}}else return {path:n,lines:Number(o),raw:t}}var Ze=new Set(["$lib","$env","$app","$service-worker","$virtual","$schema","$ref","$id","$type"]);function Ue(t){let e=new Map(t.map(o=>[o.symbol,o]));for(let o of t){let n=JSON.stringify(o.data),r=/(?:\?[@#$%~^!]|[@#$%~^!?])[a-zA-Z][\w-]*/g,a=(n.match(r)||[]).filter(i=>!Ze.has(i));for(let i of a)if(i!==o.symbol&&e.has(i)){o.references.includes(i)||o.references.push(i);let l=e.get(i);l&&!l.referencedBy.includes(o.symbol)&&l.referencedBy.push(o.symbol);}}}async function ut(t){let e={metadata:{name:S.basename(t),created:new Date().toISOString(),modified:new Date().toISOString()},sources:{purpose:[{path:"./"}],portal:[{path:"./"}]},nodes:[]};return Ne(e,t)}function Xe(){return {entries:new Map,byType:new Map,bySource:new Map,timestamp:0}}function dt(t){let e=Xe();e.timestamp=t.timestamp;for(let o of t.symbols)e.entries.set(o.id,o),e.byType.has(o.type)||e.byType.set(o.type,[]),e.byType.get(o.type).push(o),e.bySource.has(o.source)||e.bySource.set(o.source,[]),e.bySource.get(o.source).push(o);return e}function A(t,e){for(let o of t.entries.values())if(o.symbol===e)return o}function mt(t,e){return t.entries.get(e)}function z(t,e){return t.byType.get(e)||[]}function gt(t,e){return t.bySource.get(e)||[]}function He(t,e){let o=e.toLowerCase(),n=[];for(let r of t.entries.values()){if(r.symbol.toLowerCase().includes(o)){n.push(r);continue}if(r.description?.toLowerCase().includes(o)){n.push(r);continue}if(r.tags?.some(a=>a.toLowerCase().includes(o))){n.push(r);continue}if(r.componentType?.toLowerCase().includes(o)){n.push(r);continue}}return n}function ht(t,e){return z(t,"component").filter(n=>n.componentType===e)}function yt(t){let e=new Set,o=z(t,"component");for(let n of o)n.componentType&&e.add(n.componentType);return Array.from(e).sort()}function $t(t,e){return z(t,"component").filter(n=>n.parentSymbol===e)}function wt(t,e){let o=A(t,e);return o?o.referencedBy.map(n=>A(t,n)).filter(n=>n!==void 0):[]}function bt(t,e){let o=A(t,e);return o?o.references.map(n=>A(t,n)).filter(n=>n!==void 0):[]}function St(t,e){let o=[];for(let n of t.entries.values())n.tags?.includes(e)&&o.push(n);return o}function vt(t){let e=new Set;for(let o of t.entries.values())for(let n of o.tags||[])e.add(n);return Array.from(e).sort()}function Pt(t){let e={component:0,flow:0,gate:0,signal:0,aspect:0};for(let[o,n]of t.byType)o in e&&(e[o]=n.length);return e}function xt(t){return Array.from(t.entries.values())}function ne(t){if(t.length<2)return null;let e=t[0],o=t.slice(1);return Re(e)?{type:Fe[e],name:o}:null}function jt(t,e){return `${Ee[t]}${e}`}function kt(t){return ne(t)!==null}function Ct(t,e,o=10){let n=e.toLowerCase(),r=ne(e);return r?z(t,r.type).filter(i=>i.symbol.toLowerCase().includes(n)).slice(0,o):He(t,e).slice(0,o)}export{Fe as PREFIX_TO_TYPE,Ee as SYMBOL_PREFIXES,ct as addConnection,at as addPremiseNode,ut as aggregateFromDirectory,Ne as aggregateFromPremise,dt as buildSymbolIndex,se as createEmptyPremiseFile,pt as createSnapshot,Xe as createSymbolIndex,jt as createSymbolString,yt as getAllComponentTypes,xt as getAllSymbols,vt as getAllTags,Ct as getAutocompleteSuggestions,$t as getChildComponents,ht as getComponentsByType,rt as getDefaultPremiseContent,bt as getReferencesFrom,wt as getReferencesTo,A as getSymbol,mt as getSymbolById,Pt as getSymbolCounts,gt as getSymbolsBySource,St as getSymbolsByTag,z as getSymbolsByType,kt as isValidSymbol,We as parsePremiseContent,nt as parsePremiseFile,ne as parseSymbol,He as searchSymbols,_e as serializePremiseFile,it as updateNodePosition};
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export{e as findGateFiles,g as formatValidationResult,d as getDefaultGateConfig,a as parseGateConfig,b as parseGateFile,c as serializeGateConfig,f as validateGateConfig}from'./chunk-QT2LKB3P.js';import'./chunk-5TAVYPOV.js';
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export{a as doctorCommand}from'./chunk-G7XFK2GI.js';import'./chunk-DOCDDDTD.js';import'./chunk-JQKKVAAN.js';import'./chunk-LKAT7IAK.js';import'./chunk-5TAVYPOV.js';
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export{a as initCommand}from'./chunk-CHVQNRRT.js';import'./chunk-LBQBWIEX.js';import'./chunk-4TXOVRWD.js';import'./chunk-VCKKJDLP.js';import'./chunk-WR6D3SC6.js';import'./chunk-UIKLE3WD.js';import'./chunk-T6IDXUUA.js';import'./chunk-JIXHEBGK.js';import'./chunk-QT2LKB3P.js';import'./chunk-DOCDDDTD.js';import'./chunk-JQKKVAAN.js';import'./chunk-LKAT7IAK.js';import'./chunk-5TAVYPOV.js';
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env node
2
- import {d,e}from'./chunk-SHD27BQX.js';import'./chunk-5TAVYPOV.js';import n from'chalk';async function c(l){let s=process.cwd(),e$1=await d(s);if(l.json)console.log(JSON.stringify({status:e$1.status,declaredButUnusedCount:e$1.declaredButUnused.length,usedButUndeclaredCount:e$1.usedButUndeclared.length,properlyDeclaredCount:e$1.properlyDeclared.length,declaredButUnused:e$1.declaredButUnused,usedButUndeclared:e$1.usedButUndeclared,properlyDeclared:e$1.properlyDeclared}));else {let o=e(e$1);e$1.status==="compliant"?console.log(n.green(`
3
- ${o}
4
- `)):e$1.status==="warnings"?console.log(n.yellow(`
5
- ${o}
6
- `)):console.log(n.red(`
7
- ${o}
8
- `));}}export{c as portalCheckCommand};
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export{d as checkPortalCompliance,b as extractDeclaredGates,c as findGateReferences,e as formatComplianceReport,f as getComplianceSummary,a as loadPortalConfig}from'./chunk-SHD27BQX.js';import'./chunk-5TAVYPOV.js';
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export{d as detectProjectRole,a as workspaceInitCommand,c as workspaceReindexCommand,b as workspaceStatusCommand}from'./chunk-SUU6M4JH.js';import'./chunk-LBQBWIEX.js';import'./chunk-4TXOVRWD.js';import'./chunk-VCKKJDLP.js';import'./chunk-WR6D3SC6.js';import'./chunk-T6IDXUUA.js';import'./chunk-JIXHEBGK.js';import'./chunk-QT2LKB3P.js';import'./chunk-LKAT7IAK.js';import'./chunk-5TAVYPOV.js';