@a-company/paradigm 7.3.0 → 7.5.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 (115) hide show
  1. package/dist/{accept-orchestration-JA3A3TSU.js → accept-orchestration-NFNY5A4Q.js} +1 -1
  2. package/dist/{aggregate-H7SB2UYT.js → aggregate-647KIGV6.js} +1 -1
  3. package/dist/ambient-5TA5CD7Z.js +2 -0
  4. package/dist/{ambient-TFLZFV5Y.js → ambient-N24SR3BC.js} +1 -1
  5. package/dist/ambient-W3SPKLKC.js +2 -0
  6. package/dist/{arch-loader-YVOS3QRY.js → arch-loader-6TDQOSUE.js} +1 -1
  7. package/dist/arch-loader-NAGXLWUQ.js +2 -0
  8. package/dist/{beacon-WVN264OT.js → beacon-4XQSMTNN.js} +1 -1
  9. package/dist/captain-2MEKZKJS.js +2 -0
  10. package/dist/captain-V5XPN4UP.js +2 -0
  11. package/dist/{chunk-IBKCMLOW.js → chunk-43H6PB2A.js} +27 -27
  12. package/dist/chunk-54C2PETP.js +12 -0
  13. package/dist/{chunk-RGSFU2YW.js → chunk-5LIE2QMS.js} +1 -1
  14. package/dist/{chunk-ACJWUOMA.js → chunk-74NGU6YN.js} +1 -1
  15. package/dist/chunk-ABHILQLA.js +42 -0
  16. package/dist/{chunk-VR2LLUYE.js → chunk-AMZ3ESAK.js} +2 -2
  17. package/dist/chunk-BTMT4K73.js +93 -0
  18. package/dist/{chunk-MBKTVQS2.js → chunk-BXKFSYIN.js} +1 -1
  19. package/dist/chunk-CHFY3JSF.js +504 -0
  20. package/dist/chunk-D2T5AV5N.js +504 -0
  21. package/dist/{chunk-6VZSOQ7Y.js → chunk-DQ4MMMTP.js} +1 -1
  22. package/dist/chunk-F3OBFUOE.js +2 -0
  23. package/dist/chunk-GADXREYG.js +18 -0
  24. package/dist/{chunk-A5EEY6NO.js → chunk-HGT7RNOL.js} +1 -1
  25. package/dist/chunk-HLPYCWE5.js +6 -0
  26. package/dist/chunk-IGB2CIMK.js +93 -0
  27. package/dist/{chunk-27EK3OQZ.js → chunk-JJ3AUHQU.js} +1 -1
  28. package/dist/chunk-JOHPASZG.js +4 -0
  29. package/dist/{chunk-7BZPDOOQ.js → chunk-JOWT6J4C.js} +4 -4
  30. package/dist/chunk-L4MKNG56.js +42 -0
  31. package/dist/chunk-PRZZL57E.js +7 -0
  32. package/dist/{chunk-SD3KVW5Q.js → chunk-QBIME67A.js} +1 -1
  33. package/dist/{chunk-KA6QEI3C.js → chunk-QTMJVEEW.js} +1 -1
  34. package/dist/chunk-SGLIPRIC.js +3 -0
  35. package/dist/chunk-SOVBBLFK.js +6 -0
  36. package/dist/{chunk-VKVVIN6J.js → chunk-SPU3R5GW.js} +4 -4
  37. package/dist/{chunk-YNFF7XHV.js → chunk-T577TTVG.js} +2 -2
  38. package/dist/{chunk-3F4QP2Z5.js → chunk-VHVUJGZ2.js} +2 -2
  39. package/dist/chunk-WUSTIEYA.js +4 -0
  40. package/dist/{commands-4ENQMHFO.js → commands-RSHKXKXN.js} +1 -1
  41. package/dist/{compliance-3M6COUCO.js → compliance-EFNXWHDL.js} +1 -1
  42. package/dist/{constellation-TIKNCZWR.js → constellation-26225R5K.js} +1 -1
  43. package/dist/{diff-NZSJW3V3.js → diff-G52RYZNF.js} +1 -1
  44. package/dist/dist-N4NYCS3D.js +2 -0
  45. package/dist/dist-O7KGTIYK.js +4 -0
  46. package/dist/{docs-DWU3T2BV.js → docs-2O7HUSBX.js} +1 -1
  47. package/dist/doctor-KGQXLGOQ.js +2 -0
  48. package/dist/graph-slice-2WECDOEN.js +2 -0
  49. package/dist/index.js +5 -5
  50. package/dist/{init-QPMLEQWQ.js → init-JGYCABZZ.js} +1 -1
  51. package/dist/{integrity-FRGF5BFS.js → integrity-YUCXTQX3.js} +1 -1
  52. package/dist/mcp.js +2 -2
  53. package/dist/nomination-engine-3EYXJOZZ.js +2 -0
  54. package/dist/nomination-engine-BUPERVPR.js +2 -0
  55. package/dist/notebook-loader-QM4KUT4R.js +2 -0
  56. package/dist/{orchestrate-C7SI4J7C.js → orchestrate-RIKQB2DV.js} +1 -1
  57. package/dist/{orchestration-S2ESNKSA.js → orchestration-GFNPCEUU.js} +1 -1
  58. package/dist/orchestration-I62QXOWV.js +2 -0
  59. package/dist/{platform-server-IOWHNS7Q.js → platform-server-AAEDDBS3.js} +2 -2
  60. package/dist/{probe-G3TKOJYW.js → probe-GD3VDWGT.js} +1 -1
  61. package/dist/reindex-FNL4QRUZ.js +2 -0
  62. package/dist/reindex-N4NTDLJY.js +2 -0
  63. package/dist/{review-WHRNLW2W.js → review-YG4LWV22.js} +1 -1
  64. package/dist/{ripple-B6U7263T.js → ripple-S6VBP5C6.js} +1 -1
  65. package/dist/sentinel.js +1 -1
  66. package/dist/{serve-PWAFVYYC.js → serve-NPRYOGQX.js} +1 -1
  67. package/dist/session-tracker-HYN6ZYPH.js +2 -0
  68. package/dist/{session-work-log-T2IE4Y4T.js → session-work-log-KZX4PGUL.js} +1 -1
  69. package/dist/{setup-L5OP24US.js → setup-GPOTHS3N.js} +1 -1
  70. package/dist/{shift-HGXZ5THV.js → shift-ZIJTQ5SW.js} +2 -2
  71. package/dist/{snapshot-MT5L6XE4.js → snapshot-2ARNF3U2.js} +1 -1
  72. package/dist/{status-4QGKLOP6.js → status-NTWWESOR.js} +1 -1
  73. package/dist/{summary-6QNVQZJV.js → summary-4QXYLXAB.js} +1 -1
  74. package/dist/{sync-layer-C2PF273N.js → sync-layer-Z266WBWF.js} +1 -1
  75. package/dist/{task-PRLQ4VPK.js → task-6F527BNU.js} +1 -1
  76. package/dist/{task-loader-EIXPKHA3.js → task-loader-75NBBLRQ.js} +1 -1
  77. package/dist/{task-loader-LFEE6OU7.js → task-loader-INPLZRG5.js} +1 -1
  78. package/dist/{task-settlement-ZXOY4YGX.js → task-settlement-3ROAHAND.js} +2 -2
  79. package/dist/{task-settlement-A2T6EACG.js → task-settlement-F7CIKUG3.js} +2 -2
  80. package/dist/{team-KP4HMUB5.js → team-PFJTOCPM.js} +1 -1
  81. package/dist/tools-MAH6K5UL.js +142 -0
  82. package/dist/tools-Z354SXGS.js +2 -0
  83. package/dist/{workspace-4D4TQ637.js → workspace-HADUT5XT.js} +1 -1
  84. package/package.json +2 -1
  85. package/dist/ambient-OW5M5LVN.js +0 -2
  86. package/dist/ambient-VCTUHHIG.js +0 -2
  87. package/dist/arch-loader-G3AAM4E2.js +0 -2
  88. package/dist/captain-ILBN2IKJ.js +0 -2
  89. package/dist/captain-J4FZ5PRU.js +0 -2
  90. package/dist/chunk-33ERV2MW.js +0 -18
  91. package/dist/chunk-5VR7FKS5.js +0 -93
  92. package/dist/chunk-7HUPVOAY.js +0 -504
  93. package/dist/chunk-D6BSCELB.js +0 -2
  94. package/dist/chunk-FG3M6VVO.js +0 -30
  95. package/dist/chunk-HSY75GRR.js +0 -6
  96. package/dist/chunk-KAUGQMXU.js +0 -4
  97. package/dist/chunk-L3AOKDMU.js +0 -93
  98. package/dist/chunk-O4ADSTSY.js +0 -504
  99. package/dist/chunk-RVXQNS6K.js +0 -30
  100. package/dist/chunk-TMDPDIWA.js +0 -3
  101. package/dist/chunk-XBK244QR.js +0 -6
  102. package/dist/chunk-Y76OIMDO.js +0 -7
  103. package/dist/chunk-ZSWXLFN7.js +0 -12
  104. package/dist/dist-PW5YPGFF.js +0 -2
  105. package/dist/dist-RXYJK7AZ.js +0 -2
  106. package/dist/doctor-CBZYYQQH.js +0 -2
  107. package/dist/nomination-engine-EFXDEPZN.js +0 -2
  108. package/dist/nomination-engine-YRHZZZUN.js +0 -2
  109. package/dist/notebook-loader-TZVIMNDJ.js +0 -2
  110. package/dist/orchestration-4MJKBSGM.js +0 -2
  111. package/dist/reindex-G2JLIGOQ.js +0 -2
  112. package/dist/reindex-JR3PXYQE.js +0 -2
  113. package/dist/session-tracker-BZ7FU4AT.js +0 -2
  114. package/dist/tools-NOMEIBS7.js +0 -2
  115. package/dist/tools-YW3Q27UI.js +0 -142
@@ -1,30 +0,0 @@
1
- #!/usr/bin/env node
2
- import {c,b as b$2}from'./chunk-3KVVC4WV.js';import {j,a as a$1,d,g as g$1}from'./chunk-KAUGQMXU.js';import {z,i,c as c$1,f as f$1,j as j$1}from'./chunk-KAFQA7HV.js';import {b as b$1,a as a$2}from'./chunk-EK4ZRIFJ.js';import {f,b as b$3}from'./chunk-ECO3LHCE.js';import {b,a}from'./chunk-5TAVYPOV.js';import*as l from'fs';import*as g from'path';import*as nt from'js-yaml';import*as T from'os';function Q(e){return g.join(e,K,ut)}function gt(){let e=Date.now(),t=Math.floor(Math.random()*9999).toString().padStart(4,"0");return `ev-${e}-${t}`}function E(e,t){let n={id:gt(),timestamp:new Date().toISOString(),...t};_.push(n),_.length>k&&(_=_.slice(-k));try{let o=g.join(e,K);l.mkdirSync(o,{recursive:!0});let r=Q(e);l.appendFileSync(r,JSON.stringify(n)+`
3
- `,"utf8"),pt(r);}catch{}return n}function pt(e){try{if(l.statSync(e).size>512*1024){let o=l.readFileSync(e,"utf8").trim().split(`
4
- `);if(o.length>k){let r=o.slice(-k);l.writeFileSync(e,r.join(`
5
- `)+`
6
- `,"utf8");}}}catch{}}function Lt(e,t){let n=ht(e);return t?.type&&(n=n.filter(o=>o.type===t.type)),t?.source&&(n=n.filter(o=>o.source===t.source)),t?.symbol&&(n=n.filter(o=>o.symbols?.includes(t.symbol))),t?.agent&&(n=n.filter(o=>o.agent===t.agent)),t?.since&&(n=n.filter(o=>o.timestamp>=t.since)),n.sort((o,r)=>r.timestamp.localeCompare(o.timestamp)),t?.limit&&(n=n.slice(0,t.limit)),n}function ht(e){let t=Q(e);if(!l.existsSync(t))return [..._];try{return l.readFileSync(t,"utf8").trim().split(`
7
- `).filter(r=>r.trim()).map(r=>{try{return JSON.parse(r)}catch{return null}}).filter(r=>r!==null)}catch{return [..._]}}function Z(e,t,n){let o=0,r=0,i=0,s=0;if(n.symbols?.length&&e.symbols?.length)for(let c of n.symbols)for(let a of e.symbols)X(c,a)&&(o=Math.max(o,1));if(n.paths?.length&&e.path){for(let c of n.paths)if(X(c,e.path)){r=1;break}}if(n.concepts?.length){let c=[e.context||"",...e.keywords||[],e.type||""].join(" ").toLowerCase(),a=0;for(let u of n.concepts)u&&c.includes(u.toLowerCase())&&a++;n.concepts.length>0&&(i=a/n.concepts.length);}if(n.signals?.length){for(let c of n.signals)if(c.type===e.type){s=1;break}}let f=[o,r,i,s].sort((c,a)=>a-c),d=f[0]*.5+f[1]*.2+f[2]*.15+f[3]*.15,m=n.threshold??.6;return {agentId:t,score:d,breakdown:{symbolMatch:o,pathMatch:r,conceptMatch:i,signalMatch:s},shouldNominate:d>=m,quietReason:d<m?"below-threshold":void 0}}function X(e,t){if(e===t)return true;let n=e.replace(/\*\*/g,"\xA7\xA7").replace(/\*/g,"[^/]*").replace(/§§/g,".*");try{return new RegExp(`^${n}$`).test(t)}catch{return false}}var K,ut,k,_,tt=b(()=>{K=".paradigm/events",ut="stream.jsonl",k=1e3,_=[];});function C(e){let t=g.join(e,yt);if(!l.existsSync(t))return {...b$2};try{let n=l.readFileSync(t,"utf8"),o=nt.load(n);return bt(b$2,o)}catch{return {...b$2}}}function bt(e,t){let n={...e};if(t.version&&(n.version=t.version),t.default_ring&&(n.default_ring=t.default_ring),t.observation&&(n.observation={allow:t.observation.allow||e.observation?.allow,deny:[...e.observation?.deny||[],...t.observation.deny||[]].filter((o,r,i)=>i.indexOf(o)===r)}),t.streams){n.streams={...e.streams};for(let o of ["work_log","learning_journal","team_decisions"])t.streams[o]&&(n.streams[o]={...e.streams?.[o],...t.streams[o],deny_content:[...e.streams?.[o]?.deny_content||[],...t.streams[o]?.deny_content||[]].filter((r,i,s)=>s.indexOf(r)===i)});}return t.upstream&&(n.upstream={...e.upstream,...t.upstream}),t.network&&(n.network={...e.network,...t.network}),t.agent_overrides&&(n.agent_overrides={...e.agent_overrides,...t.agent_overrides}),t.deployment&&(n.deployment={...e.deployment,...t.deployment}),n}function M(e,t,n){return n&&e.agent_overrides?.[n]?.observation&&e.agent_overrides[n].observation.deny?.some(r=>R(r,t))||e.observation?.deny?.some(o=>R(o,t))?false:e.observation?.allow?.length?e.observation.allow.some(o=>R(o,t)):true}function Gt(e,t,n){let o=t.streams?.[n];if(!o)return {filtered:e,redacted:[]};let r=[],i=e;if(o.redaction)for(let s of o.redaction)try{let f=new RegExp(s.pattern,"gi"),d=i.match(f);d&&(r.push(...d),i=i.replace(f,s.replacement||"[REDACTED]"));}catch{}return {filtered:i,redacted:r}}function R(e,t){if(e===t)return true;let n=e.replace(/\*\*/g,"\xA7\xA7").replace(/\*/g,"[^/]*").replace(/§§/g,".*");try{return new RegExp(`^${n}$`).test(t)}catch{return false}}var yt,ot=b(()=>{c();yt=".paradigm/data-policy.yaml";});function kt(){let e=Date.now(),t=Math.floor(Math.random()*9999).toString().padStart(4,"0");return `nom-${e}-${t}`}function jt(){let e=Date.now(),t=Math.floor(Math.random()*9999).toString().padStart(4,"0");return `dbt-${e}-${t}`}function st(e,t){let n=i(e),o=C(e),r=[];for(let m of n){if(!m.attention||!c$1(m.id,e)||t.path&&!M(o,t.path,m.id))continue;let c=Z(t,m.id,m.attention);c.shouldNominate&&r.push({profile:m,score:c});}if(r.length===0)return {nominations:[],debates:[]};let i$1=A(e,{since:new Date(Date.now()-3e4).toISOString()}),s=r.filter(({profile:m})=>!i$1.find(a=>a.agent===m.id&&a.brief===rt(m,t,{...r.find(u=>u.profile.id===m.id).score})));if(s.length===0)return {nominations:[],debates:[]};let f=s.map(({profile:m,score:c})=>{let a=Tt(t,c),u=Pt(m,t);return {id:kt(),agent:m.id,relevance:c.score,urgency:a,type:u,brief:rt(m,t,c),triggered_by:[t.id],timestamp:new Date().toISOString(),surfaced:false}});Dt(e,f);let d=At(e,f);return d.length>0&&Ft(e,d),{nominations:f,debates:d}}function Tt(e,t){return e.severity==="critical"?"critical":e.severity==="error"||e.type==="compliance-violation"||e.type==="error-encountered"?"high":e.type==="gate-added"||e.type==="route-created"||t.score>=.9?"medium":"low"}function Pt(e,t){let n=e.collaboration?.stance;return t.type==="compliance-violation"||t.type==="error-encountered"?"warning":t.type==="gate-added"||t.type==="route-created"?"observation":n==="advisory"||n==="lead"?"suggestion":"observation"}function rt(e,t,n){let o=e.role||e.id;switch(t.type){case "gate-checked":return `${o}: Gate check on ${t.symbols?.join(", ")||"route"} \u2014 verify gate coverage is complete`;case "file-modified":return `${o}: ${t.path||"File"} modified \u2014 review for ${e.id==="security"?"security implications":e.id==="tester"?"test coverage":e.id==="reviewer"?"code quality":"consistency"}`;case "compliance-violation":return `${o}: Compliance violation detected \u2014 ${t.context||"check .purpose and portal.yaml coverage"}`;case "route-created":return `${o}: New route ${t.symbols?.join(", ")||""} \u2014 ${e.id==="security"?"needs gate assignment in portal.yaml":"review route structure"}`;case "gate-added":return `${o}: Gate ${t.symbols?.join(", ")||""} added \u2014 ${e.id==="security"?"verify enforcement points":"check downstream impact"}`;case "decision-made":return `${o}: Decision recorded \u2014 ${t.context?.slice(0,80)||"review for alignment with project patterns"}`;case "work-completed":return `${o}: Work completed on ${t.symbols?.join(", ")||t.context?.slice(0,40)||"task"} \u2014 review outcome`;case "error-encountered":return `${o}: Error detected \u2014 ${t.context?.slice(0,80)||"investigate root cause"}`;default:{let r=n.breakdown.symbolMatch>0?`symbol match on ${t.symbols?.join(", ")||"unknown"}`:n.breakdown.pathMatch>0?`path ${t.path||"unknown"}`:t.context?.slice(0,60)||t.type;return `${o}: ${r}`}}}function At(e,t){if(t.length<2)return [];let n=[],o=new Map;for(let r of t)for(let i of r.triggered_by){let s=o.get(i)||[];s.push(r),o.set(i,s);}for(let[r,i]of o){if(i.length<2||new Set(i.map(m=>m.agent)).size<2)continue;let f=new Set(i.map(m=>m.type)),d=f.size>1&&f.has("warning")&&f.has("suggestion");n.push({id:jt(),topic:`Multiple agents responded to event ${r}`,nominations:i.map(m=>m.id),type:d?"conflicting":"complementary",overlap_events:[r]});}return n}function I(e){return g.join(e,S,St)}function L(e){return g.join(e,S,_t)}function Dt(e,t){try{let n=g.join(e,S);l.mkdirSync(n,{recursive:!0});let o=I(e),r=t.map(s=>JSON.stringify(s)).join(`
8
- `)+`
9
- `;l.appendFileSync(o,r,"utf8"),J(o,it);let{nominationTtlDays:i}=P(e);at(o,i*24*60*60*1e3);}catch{}}function Ft(e,t){try{let n=g.join(e,S);l.mkdirSync(n,{recursive:!0});let o=L(e),r=t.map(s=>JSON.stringify(s)).join(`
10
- `)+`
11
- `;l.appendFileSync(o,r,"utf8"),J(o,Et);let{debateTtlDays:i}=P(e);at(o,i*24*60*60*1e3);}catch{}}function $t(e,t){try{let n=g.join(e,S);l.mkdirSync(n,{recursive:!0});let o=g.join(n,wt);l.appendFileSync(o,JSON.stringify(t)+`
12
- `,"utf8"),J(o,it);}catch(n){a$2.component("#promotion-decisions").warn("failed to record promotion decision",{agent:t.agent,error:n instanceof Error?n.message:String(n)});}}function J(e,t){try{let o=l.readFileSync(e,"utf8").trim().split(`
13
- `).filter(r=>r.trim());if(o.length>t){let r=o.slice(-t);l.writeFileSync(e,r.join(`
14
- `)+`
15
- `,"utf8");}}catch{}}function P(e){let t={nominationTtlDays:Nt,debateTtlDays:vt};try{let n=g.join(e,".paradigm","config.yaml");if(!l.existsSync(n))return t;let o=a("js-yaml"),r=l.readFileSync(n,"utf8"),s=o.load(r)?.ambient;return s?{nominationTtlDays:typeof s["nomination-ttl-days"]=="number"?s["nomination-ttl-days"]:t.nominationTtlDays,debateTtlDays:typeof s["debate-ttl-days"]=="number"?s["debate-ttl-days"]:t.debateTtlDays}:t}catch{return t}}function at(e,t){try{if(!l.existsSync(e))return;let o=l.readFileSync(e,"utf8").trim().split(`
16
- `).filter(s=>s.trim());if(o.length<=xt)return;let r=Date.now()-t,i=o.filter(s=>{try{let f=JSON.parse(s);return (f.timestamp?new Date(f.timestamp).getTime():Date.now())>=r}catch{return !0}});i.length<o.length&&l.writeFileSync(e,i.join(`
17
- `)+`
18
- `,"utf8");}catch{}}function A(e,t){let n=I(e);if(!l.existsSync(n))return [];try{let r=l.readFileSync(n,"utf8").trim().split(`
19
- `).filter(i=>i.trim()).map(i=>{try{return JSON.parse(i)}catch{return null}}).filter(i=>i!==null);return t?.agent&&(r=r.filter(i=>i.agent===t.agent)),t?.urgency&&(r=r.filter(i=>i.urgency===t.urgency)),t?.surfaced!==void 0&&(r=r.filter(i=>i.surfaced===t.surfaced)),t?.pending_only&&(r=r.filter(i=>!i.engaged)),t?.since&&(r=r.filter(i=>i.timestamp>=t.since)),r.sort((i,s)=>s.timestamp.localeCompare(i.timestamp)),t?.limit&&(r=r.slice(0,t.limit)),r}catch{return []}}function Kt(e){let t=L(e);if(!l.existsSync(t))return [];try{return l.readFileSync(t,"utf8").trim().split(`
20
- `).filter(o=>o.trim()).map(o=>{try{return JSON.parse(o)}catch{return null}}).filter(o=>o!==null)}catch{return []}}function Qt(e,t,n,o){let r=I(e);if(!l.existsSync(r))return false;try{let s=l.readFileSync(r,"utf8").trim().split(`
21
- `),f=!1,d=s.map(m=>{try{let c=JSON.parse(m);return c.id===t?(c.engaged=!0,c.response=n,o&&(c.reason=o),f=!0,JSON.stringify(c)):m}catch{return m}});if(f&&(l.writeFileSync(r,d.join(`
22
- `)+`
23
- `,"utf8"),n==="accepted"||n==="dismissed")){let m=JSON.parse(s.find(a=>{try{return JSON.parse(a).id===t}catch{return !1}}));i(e).find(a=>a.id===m.agent)?.learning?.intrinsic?.feedback?.after_recommendation&&E(e,{type:"work-completed",source:"agent-action",agent:m.agent,context:`Nomination ${t} ${n} \u2014 feedback for learning`,data:{nomination_id:t,response:n}});}return f}catch{return false}}function Zt(e,t,n,o){let r=L(e);if(!l.existsSync(r))return false;try{let s=l.readFileSync(r,"utf8").trim().split(`
24
- `),f=!1,d=s.map(m=>{try{let c=JSON.parse(m);if(c.id===t){c.resolution={chosen:n,reason:o,resolved_by:"human",resolved_at:new Date().toISOString()},f=!0;let a=c.nominations.filter(u=>u!==n);for(let u of a){let p=A(e).find(b=>b.id===u);p&&E(e,{type:"work-completed",source:"agent-action",agent:p.agent,context:`Debate ${t} resolved \u2014 nomination ${u} not chosen`,data:{debate_id:t,chosen:n,reason:o}});}return JSON.stringify(c)}return m}catch{return m}});return f&&l.writeFileSync(r,d.join(`
25
- `)+`
26
- `,"utf8"),f}catch{return false}}function te(e){let t=g.join(e,S,".last-processed"),n="";try{l.existsSync(t)&&(n=l.readFileSync(t,"utf8").trim());}catch{}let o=g.join(e,S,"stream.jsonl");if(!l.existsSync(o))return {processed:0,nominations:[]};let r=[];try{r=l.readFileSync(o,"utf8").trim().split(`
27
- `).filter(a=>a.trim()).map(a=>{try{return JSON.parse(a)}catch{return null}}).filter(a=>a!==null);}catch{return {processed:0,nominations:[]}}let i=0;if(n){let c=r.findIndex(a=>a.id===n);c>=0&&(i=c+1);}let s=r.slice(i);if(s.length===0)return {processed:0,nominations:[]};let f=[],d=s.slice(0,50);for(let c of d){let{nominations:a}=st(e,c);f.push(...a);}let m=d[d.length-1];try{l.mkdirSync(g.join(e,S),{recursive:!0}),l.writeFileSync(t,m.id,"utf8");}catch{}return {processed:d.length,nominations:f}}function ee(e,t,n){let o=C(e);if(t.path&&!M(o,t.path))return {event:E(e,t),nominations:[],debates:[]};let r=E(e,t);if(n?.skipNominations)return {event:r,nominations:[],debates:[]};let{nominations:i,debates:s}=st(e,r);return i.length>0&&Rt(e,i),{event:r,nominations:i,debates:s}}function ne(e,t){let n=f$1(e,t);if(!n?.attention)return {adjusted:false,oldThreshold:.6,newThreshold:.6,reason:"No attention config"};let o=n.attention.threshold??.6,{nominationTtlDays:r}=P(e),i=r*24*60*60*1e3,d=A(e,{agent:t}).filter(h=>h.engaged||Date.now()-new Date(h.timestamp).getTime()<i).filter(h=>h.engaged);if(d.length<5)return {adjusted:false,oldThreshold:o,newThreshold:o,reason:`Insufficient data (${d.length}/5 engaged nominations)`};let m=d.filter(h=>h.response==="accepted").length,c=d.filter(h=>h.response==="dismissed").length,a=m/d.length,u=c/d.length,p=o,b="No adjustment needed";if(u>.6?(p=Math.min(.95,o+.05),b=`High dismiss rate (${(u*100).toFixed(0)}%) \u2014 raising threshold to reduce noise`):a>.8&&(p=Math.max(.2,o-.05),b=`High accept rate (${(a*100).toFixed(0)}%) \u2014 lowering threshold to contribute more`),p===o)return {adjusted:false,oldThreshold:o,newThreshold:p,reason:b};n.attention.threshold=p;let w=g.join(e,".paradigm/agents",`${t}.agent`),N=l.existsSync(w)?"project":"global";return j$1(t,n,N,e),E(e,{type:"work-completed",source:"agent-action",agent:t,context:`Attention threshold adjusted: ${o.toFixed(2)} \u2192 ${p.toFixed(2)} (${b})`,data:{old_threshold:o,new_threshold:p,accept_rate:a,dismiss_rate:u}}),{adjusted:true,oldThreshold:o,newThreshold:p,reason:b}}function Ot(e,t){let{nominationTtlDays:n}=P(e),o=n*24*60*60*1e3,i=A(e,{agent:t}).filter(a=>a.engaged||Date.now()-new Date(a.timestamp).getTime()<o),s=i.filter(a=>a.response==="accepted").length,f=i.filter(a=>a.response==="dismissed").length,d=i.filter(a=>a.response==="deferred").length,m=i.filter(a=>!a.engaged).length,c=s+f+d;return {total:i.length,accepted:s,dismissed:f,deferred:d,pending:m,acceptRate:c>0?s/c:0}}function oe(e){let n=i(e).filter(a=>c$1(a.id,e)).map(a=>{let u=Ot(e,a.id),p=0;try{let b=g.join(T.homedir(),".paradigm","notebooks",a.id);l.existsSync(b)&&(p=l.readdirSync(b).filter(w=>w.endsWith(".yaml")).length);}catch{}return {id:a.id,acceptRate:u.acceptRate,threshold:a.attention?.threshold??.5,expertiseCount:(a.expertise||[]).length,notebookCount:p,transferableCount:(a.transferable||[]).length,totalNominations:u.total}}),o=n.length||1,r=n.reduce((a,u)=>a+u.acceptRate,0)/o,i$1=n.reduce((a,u)=>a+u.threshold,0)/o,s=n.reduce((a,u)=>a+u.expertiseCount,0),f=n.reduce((a,u)=>a+u.notebookCount,0),d=n.reduce((a,u)=>a+u.transferableCount,0),m=n.reduce((a,u)=>a+u.totalNominations,0),c;return m<10?c="cold-start":r<.5?c="accumulating":r<.7?c="calibrating":c="mature",{agents:n,aggregate:{avgAcceptRate:r,avgThreshold:i$1,totalExpertise:s,totalNotebooks:f,totalTransferable:d},healthStatus:c}}function Rt(e,t){if(t.length===0)return;let n=g.join(T.homedir(),".paradigm","score","outbox");if(l.existsSync(n))try{let o=g.join(n,`nom-${Date.now()}.json`),r={type:"nomination_forward",nominations:t.map(i=>({...i})),origin:Ct(e),timestamp:new Date().toISOString()};l.writeFileSync(o,JSON.stringify(r),"utf8");}catch{}}function Ct(e){try{let t=g.join(e,".paradigm","config.yaml");if(l.existsSync(t)){let o=l.readFileSync(t,"utf8").match(/project:\s*(.+)/);if(o)return o[1].trim()}}catch{}return g.basename(e)}function re(e,t){let n=b$3(t,{trigger:"pattern_discovered",limit:100}),o=b$3(t,{trigger:"human_feedback",limit:100}),r=[...n,...o],i=[];for(let s of r){if(s.promoted_to_notebook)continue;let f=(s.tags||[s.pattern?.id||"learned-pattern"]).map(a$1).filter(Boolean),d$1=s.confidence_after??0,m=d$1>=.8,c=.5,a=false;try{let u=d(t,f,e);c=u.value,a=u.found;}catch{}if($t(e,{ts:new Date().toISOString(),agent:t,concepts:f,before:c,after:d$1,delta:d$1-c,promoted:m,priorFound:a,gate:"absolute-0.8"}),!((s.confidence_after??0)<.8))try{let{entry:u}=g$1(t,{context:s.pattern?.applies_when||s.insight.slice(0,80),snippet:s.pattern?.correct_approach||s.insight,confidence:s.confidence_after??.5,concepts:f,tags:s.tags??[],provenance:{source:"lore",loreEntryId:s.id,createdBy:t}},"global",e);i.push({journalId:s.id,notebookId:u.id});try{let p=g.join(T.homedir(),".paradigm","agents",t,"journal");if(l.existsSync(p)){let b=l.readdirSync(p).filter(w=>w.endsWith(".yaml"));for(let w of b){let N=g.join(p,w),h=l.readFileSync(N,"utf8");if(h.includes(s.id)){let U=h.replace(/promoted_to_notebook:.*$/m,`promoted_to_notebook: "${u.id}"`);if(U===h){let B=h.trimEnd().split(`
28
- `);B.push(`promoted_to_notebook: "${u.id}"`),l.writeFileSync(N,B.join(`
29
- `)+`
30
- `,"utf8");}else l.writeFileSync(N,U,"utf8");break}}}}catch{}}catch(u){console.error("PROMOTE_THREW",u.message);}}return {promoted:i.length,entries:i}}function ie(e){let t=g.join(e,Mt),n={default_min_urgency:"low",enable_debates:true};if(!l.existsSync(t))return n;try{let o=a("js-yaml"),r=l.readFileSync(t,"utf8"),i=o.load(r);return {...n,...i}}catch{return n}}function se(e,t){let n={critical:0,high:1,medium:2,low:3},o=n[t.default_min_urgency||"low"]??3;return e.filter(r=>{let i=n[r.urgency]??3;if(t.preferences){let s=t.preferences.find(f=>f.agent===r.agent);if(s){if(s.always_show)return true;if(s.mute_unless?.length&&!s.mute_unless.some(d=>r.urgency===d||r.type===d))return false;if(s.min_urgency){let f=n[s.min_urgency]??3;return i<=f}}}return i<=o})}var S,St,wt,_t,it,Et,Nt,vt,xt,Mt,It=b(()=>{tt();ot();z();f();j();b$1();S=".paradigm/events",St="nominations.jsonl",wt="promotion-decisions.jsonl",_t="debates.jsonl",it=500,Et=200,Nt=7,vt=14,xt=100;Mt=".paradigm/surfacing.yaml";});export{Lt as a,tt as b,C as c,Gt as d,ot as e,st as f,At as g,Dt as h,A as i,Kt as j,Qt as k,Zt as l,te as m,ee as n,ne as o,Ot as p,oe as q,Rt as r,re as s,ie as t,se as u,It as v};
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- import*as P from'fs';import*as z from'js-yaml';import {z as z$1}from'zod';import*as b from'path';import {glob}from'glob';var T=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(),Y=T.extend({id:z$1.string()}),de=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()}),me=z$1.union([de,z$1.string().transform(t=>({description:t}))]),he=z$1.object({from:z$1.string(),to:z$1.string(),type:z$1.string(),description:z$1.string().optional()}),ge=z$1.union([he,z$1.string()]),ye=z$1.object({component:z$1.string(),action:z$1.string(),description:z$1.string().optional()}),N=z$1.union([ye,z$1.string()]),$e=z$1.object({name:z$1.string(),description:z$1.string().optional(),steps:z$1.array(N)}),we=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(N).optional()}),be=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()}),Se=z$1.object({description:z$1.string().optional(),default:z$1.unknown().optional(),type:z$1.string().optional()}),ve=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()}),xe=z$1.object({target:z$1.string(),type:z$1.string(),path:z$1.string()}),Pe=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(Y),z$1.record(T)]).optional(),components:z$1.union([z$1.array(Y),z$1.record(T)]).optional(),gates:z$1.record(be).optional(),states:z$1.record(Se).optional(),signals:z$1.record(me).optional(),aspects:z$1.record(ve).optional(),relationships:z$1.array(ge).optional(),flows:z$1.union([z$1.array($e),z$1.record(we)]).optional(),references:z$1.array(xe).optional()});function ke(t){let s=je(t);return {data:s.data,errors:s.errors}}function je(t){let s=[],e=[],o;try{o=P.readFileSync(t,"utf8");}catch(c){let p=`Cannot read file: ${c.message}`;return s.push(p),e.push({message:p,type:"file"}),{data:null,errors:s,detailedErrors:e,rawContent:void 0,isYamlValid:false}}let a=o.replace(/^([#~!$^][\w-]+):/gm,'"$1":').replace(/^(\s*-\s+)([!#][\w-]+)$/gm,'$1"$2"'),i=null;try{i=z.load(a);}catch(c){let p=c,f=p.mark?.line?p.mark.line+1:void 0,u=`YAML syntax error: ${p.reason||c.message}`;return s.push(`${u}${f?` (line ${f})`:""}`),e.push({message:u,line:f,type:"yaml"}),{data:null,errors:s,detailedErrors:e,rawContent:o,isYamlValid:false}}if(i==null)return {data:{},errors:[],detailedErrors:[],rawContent:o,isYamlValid:true};if(typeof i=="object"&&i!==null){let c=i,p={"#":"components",$:"flows","^":"gates","!":"signals","~":"aspects"};for(let f of Object.keys(c)){let u=f[0],d=p[u];if(!d||f.length<2)continue;let g=f.slice(1),y=c[f];if(typeof y!="object"||y===null)continue;let S=c[d]||{};d in c||(c[d]=S),g in S||(S[g]=y),delete c[f];}}let r=Pe.safeParse(i);if(!r.success){for(let c of r.error.issues){let p=c.path.join("."),f=c.message;s.push(`Schema error at ${p||"/"}: ${f}`),e.push({message:f,path:p||"/",type:"schema"});}return {data:i,errors:s,detailedErrors:e,rawContent:o,isYamlValid:true}}return {data:r.data,errors:[],detailedErrors:[],rawContent:o,isYamlValid:true}}function He(t){return z.dump(t,{indent:2,lineWidth:-1,noRefs:true,sortKeys:false})}function D(t){return t?Array.isArray(t)?t.map(s=>[s.id,s]):Object.entries(t):[]}async function Ae(t){let s=b.resolve(t);return (await glob("**/.purpose",{cwd:s,absolute:true,ignore:["**/node_modules/**","**/dist/**","**/.git/**"]})).sort((o,a)=>{let i=o.split(b.sep).length,r=a.split(b.sep).length;return i-r})}async function K(t){let s=await Ae(t),e=[];for(let o of s){let{data:a,errors:i}=ke(o);a&&(e.push({filePath:o,data:a}),i.length>0&&console.warn(`Warnings parsing ${o}:`,i));}return e}function U(t){let s=new Map;for(let{filePath:e,data:o}of t){let a=D(o.features);for(let[i,r]of a)s.set(i,{item:r,filePath:e});}return s}function q(t){let s=new Map;for(let{filePath:e,data:o}of t){let a=D(o.components);for(let[i,r]of a)s.set(i,{item:r,filePath:e});}return s}function Z(t){let s=new Map;for(let{filePath:e,data:o}of t)if(o.gates)for(let[a,i]of Object.entries(o.gates))s.set(a,{item:i,filePath:e});return s}function X(t){let s=new Map;for(let{filePath:e,data:o}of t)if(o.states)for(let[a,i]of Object.entries(o.states))s.set(a,{item:i,filePath:e});return s}function H(t){let s=new Map;for(let{filePath:e,data:o}of t)if(o.flows)if(Array.isArray(o.flows))for(let a of o.flows)s.set(a.name,{item:{id:a.name,description:a.description,steps:a.steps},filePath:e});else for(let[a,i]of Object.entries(o.flows))s.set(a,{item:{id:a,description:i.description,gates:i.gates,signals:i.signals,components:i.components,steps:i.steps},filePath:e});return s}function J(t){let s=new Map;for(let{filePath:e,data:o}of t)if(o.signals)for(let[a,i]of Object.entries(o.signals))s.set(a,{item:i,filePath:e});return s}function Q(t){let s=new Map;for(let{filePath:e,data:o}of t)if(o.aspects)for(let[a,i]of Object.entries(o.aspects))s.set(a,{item:i,filePath:e});return s}function ee(t){let s=[],e=new Set;for(let{filePath:o,data:a}of t){let i=D(a.features);for(let[c,p]of i)B(`#${c}`,p,o,s,e);let r=D(a.components);for(let[c,p]of r)B(`#${c}`,p,o,s,e);}return s}function B(t,s,e,o,a){if(s.flows)for(let i of s.flows){let r=i.startsWith("$")?i:`$${i}`;a.has(r)||(a.add(r),o.push({symbol:r,type:"flow",sourceSymbol:t,filePath:e}));}if(s.gates)for(let i of s.gates){let r=i.startsWith("^")?i:`^${i}`;a.has(r)||(a.add(r),o.push({symbol:r,type:"gate",sourceSymbol:t,filePath:e}));}if(s.signals)for(let i of s.signals){let r=i.startsWith("!")?i:`!${i}`;a.has(r)||(a.add(r),o.push({symbol:r,type:"signal",sourceSymbol:t,filePath:e}));}if(s.states)for(let i of s.states){let r=i.startsWith("#")?i:i.startsWith("%")?`#${i.slice(1)}`:`#${i}`;a.has(r)||(a.add(r),o.push({symbol:r,type:"component",sourceSymbol:t,filePath:e}));}if(s.components)for(let i of s.components){let r=i.startsWith("#")?i:`#${i}`;a.has(r)||(a.add(r),o.push({symbol:r,type:"component",sourceSymbol:t,filePath:e}));}if(s.aspects)for(let i of s.aspects){let r=i.startsWith("~")?i:`~${i}`;a.has(r)||(a.add(r),o.push({symbol:r,type:"aspect",sourceSymbol:t,filePath:e}));}if(s.description){let i=De(s.description);for(let{symbol:r,type:c}of i)a.has(r)||(a.add(r),o.push({symbol:r,type:c,sourceSymbol:t,filePath:e}));}}var Ie=new Set(["$lib","$env","$app","$service-worker","$virtual","$schema","$ref","$id","$type"]);function De(t){let s=[],e=/([$^!#~%])([a-zA-Z][a-zA-Z0-9._-]*)/g,o;for(;(o=e.exec(t))!==null;){let a=o[1],i=o[2],r,c;switch(a){case "#":c="component",r=`#${i}`;break;case "$":c="flow",r=`$${i}`;break;case "^":c="gate",r=`^${i}`;break;case "!":c="signal",r=`!${i}`;break;case "~":c="aspect",r=`~${i}`;break;case "%":c="component",r=`#${i}`;break;default:continue}Ie.has(r)||s.push({symbol:r,type:c});}return s}function k(t){return t?Array.isArray(t)?t.map(s=>[s.id,s]):Object.entries(t):[]}function F(t){return t?Array.isArray(t)?t.map(s=>s.id):Object.keys(t):[]}function Qe(t,s){let e=[],o=s?`${s}: `:"",a=k(t.features);for(let[r,c]of a)V(r,c,"feature",o,e);let i=k(t.components);for(let[r,c]of i)V(r,c,"component",o,e);if(t.relationships){let r=new Set([...F(t.features),...F(t.components)]);for(let c of t.relationships){if(typeof c=="string"||!c||!c.from||!c.to)continue;let p=c.from.replace(/^[@#$%~^!?]/,"");!r.has(p)&&!c.from.includes(".")&&e.push({type:"warning",message:`${o}Relationship references unknown source: "${c.from}"`,path:"relationships"});let f=c.to.replace(/^[@#$%~^!?]/,"");!r.has(f)&&!c.to.includes(".")&&e.push({type:"warning",message:`${o}Relationship references unknown target: "${c.to}"`,path:"relationships"});}}if(t.flows){let r=new Set(F(t.components));if(Array.isArray(t.flows)){for(let c of t.flows)if(!(!c||typeof c!="object")&&(c.name||e.push({type:"error",message:`${o}Flow missing required "name" field`,path:"flows"}),c.steps&&Array.isArray(c.steps)))for(let p of c.steps){if(typeof p=="string"||!p||!p.component)continue;let f=p.component.replace(/^#/,"");r.has(f)||e.push({type:"warning",message:`${o}Flow "${c.name}" references unknown component: "${p.component}"`,path:`flows.${c.name}`});}}else for(let[c,p]of Object.entries(t.flows))if(!(!p||typeof p!="object")&&p.steps&&Array.isArray(p.steps))for(let f of p.steps){if(typeof f=="string"||!f||!f.component)continue;let u=f.component.replace(/^#/,"");r.has(u)||e.push({type:"warning",message:`${o}Flow "${c}" references unknown component: "${f.component}"`,path:`flows.${c}`});}}return {valid:e.filter(r=>r.type==="error").length===0,issues:e}}function V(t,s,e,o,a){let i=`${e}s.${t}`;if(/^[a-zA-Z][a-zA-Z0-9-]*$/.test(t)||a.push({type:"warning",message:`${o}${e} ID "${t}" should use alphanumeric characters and hyphens`,path:i}),(!s.description||s.description.trim()==="")&&a.push({type:"warning",message:`${o}${e} "${t}" has no description`,path:i}),s.endpoints)for(let r of s.endpoints)/^(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS)\s+\//.test(r)||a.push({type:"warning",message:`${o}Endpoint "${r}" in ${e} "${t}" may not be in standard format (e.g., "GET /api/users")`,path:`${i}.endpoints`});}function et(t){let s=[],e=new Set;for(let{data:o}of t){let a=k(o.components);for(let[r]of a)e.add(`#${r}`),e.add(r);let i=k(o.features);for(let[r]of i)e.add(`#${r}`),e.add(r);if(o.gates)for(let r of Object.keys(o.gates))e.add(`^${r}`),e.add(r);if(o.signals)for(let r of Object.keys(o.signals))e.add(`!${r}`),e.add(r);if(o.flows)if(Array.isArray(o.flows))for(let r of o.flows)r?.name&&(e.add(`$${r.name}`),e.add(r.name));else for(let r of Object.keys(o.flows))e.add(`$${r}`),e.add(r);if(o.aspects)for(let r of Object.keys(o.aspects))e.add(`~${r}`),e.add(r);if(o.states)for(let r of Object.keys(o.states))e.add(`#${r}`),e.add(r);}for(let{filePath:o,data:a}of t){let i=o?`${o}: `:"",r=[...k(a.components),...k(a.features)];for(let[c,p]of r){if(p.parent){let u=p.parent.replace(/^["']|["']$/g,""),d=u.replace(/^[#$^!~@%?&]/,"");!e.has(u)&&!e.has(d)&&s.push({type:"warning",message:`${i}Component "${c}" references parent "${u}" which is not defined in any .purpose file`,path:`components.${c}.parent`});}let f=[{field:"gates",refs:p.gates},{field:"signals",refs:p.signals},{field:"flows",refs:p.flows},{field:"components",refs:p.components},{field:"aspects",refs:p.aspects}];for(let{field:u,refs:d}of f)if(d)for(let g of d){let y=g.replace(/^[#$^!~@%?&]/,"");!e.has(g)&&!e.has(y)&&s.push({type:"warning",message:`${i}Symbol "${c}" references ${u} "${g}" which is not defined`,path:`components.${c}.${u}`});}}if(a.flows){if(Array.isArray(a.flows)){for(let c of a.flows)if(c?.steps)for(let p of c.steps){if(typeof p=="string"||!p?.component)continue;let f=p.component.replace(/^#/,"");!e.has(p.component)&&!e.has(f)&&s.push({type:"warning",message:`${i}Flow "${c.name}" step references "${p.component}" which is not defined`,path:`flows.${c.name}.steps`});}}else for(let[c,p]of Object.entries(a.flows))if(p?.steps)for(let f of p.steps){if(typeof f=="string"||!f?.component)continue;let u=f.component.replace(/^#/,"");!e.has(f.component)&&!e.has(u)&&s.push({type:"warning",message:`${i}Flow "${c}" step references "${f.component}" which is not defined`,path:`flows.${c}.steps`});}}}return {valid:s.filter(o=>o.type==="error").length===0,issues:s}}var ze={visualizerPort:42195,watcherPort:42196,autoConnect:true};async function R(t){let s=b.resolve(t),e=b.dirname(s);if(!P.existsSync(s))throw new Error(`Gate config not found: ${s}`);let o=P.readFileSync(s,"utf8"),a=z.load(o);if(!a.version)throw new Error('Gate config missing required "version" field');let i=[],r=a,c=a.gates||r.portals;if(c)for(let[f,u]of Object.entries(c)){let d=f.startsWith("^")?f.slice(1):f;i.push(L(d,u));}if(a.include)for(let f of a.include){let u=b.join(e,f),d=await glob(u.replace(/\\/g,"/"));for(let g of d){let y=await Oe(g);i.push(...y);}}let p=[];if(a.flows)for(let[f,u]of Object.entries(a.flows))p.push(Fe(f,u));return {version:a.version,gates:i,flows:p,settings:{dev:{...ze,...a.settings?.dev}}}}async function Oe(t){let s=P.readFileSync(t,"utf8"),e=z.load(s);if(e.id){let o=e.id,a=o.startsWith("^")?o.slice(1):o;return [L(a,e)]}if(e.gates){let o=[];for(let[a,i]of Object.entries(e.gates)){let r=a.startsWith("^")?a.slice(1):a;o.push(L(r,i));}return o}return []}function L(t,s){let e=[];if(s.locks)for(let a of s.locks)e.push(Re(a));let o=[];if(s.prizes)for(let a of s.prizes)o.push(Ee(a));return {id:t,description:s.description,locks:e,prizes:o,position:s.position}}function Re(t){let s=t,e=[];if(s.keys){for(let o of s.keys)if(typeof o=="string")e.push({expression:o});else if(o.expression){let a=o;e.push({expression:a.expression,description:a.description});}}return {id:s.id,description:s.description,keys:e,mode:s.mode||"all"}}function Ee(t){let s=t;return {id:s.id,oneTime:s.oneTime??false,metadata:s.metadata}}function Fe(t,s){return {id:t,description:s.description,gates:s.gates||[],forkable:s.forkable}}async function se(t){let s=b.resolve(t);return await glob("**/portal.yaml",{cwd:s,absolute:true,ignore:["**/node_modules/**","**/dist/**","**/.git/**"]})}function ot(t){if(t instanceof z.YAMLException){let s=(t.reason||"").toLowerCase();return s.includes("duplicated mapping key")||s.includes("duplicate mapping key")?{errorClass:"duplicate-key",detail:"duplicate mapping key"}:["unexpected","expected","bad indentation","mapping values","cannot read a block mapping entry","end of the stream","while scanning","while parsing"].some(o=>s.includes(o))?{errorClass:"syntax",detail:"yaml syntax error"}:{errorClass:"other",detail:"yaml parse error"}}return {errorClass:"other",detail:"yaml parse error"}}var Te=z$1.object({x:z$1.number(),y:z$1.number()}),Le=z$1.object({x:z$1.number(),y:z$1.number(),zoom:z$1.number()}),ne=z$1.object({path:z$1.string(),include:z$1.array(z$1.string()).optional(),exclude:z$1.array(z$1.string()).optional()}),ae=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:Te,tags:z$1.array(z$1.string()).optional(),created:z$1.string(),modified:z$1.string().optional()}),ie=z$1.object({from:z$1.string(),to:z$1.string(),label:z$1.string().optional(),type:z$1.string().optional()}),Me=z$1.object({id:z$1.string(),name:z$1.string(),nodes:z$1.array(z$1.string()),color:z$1.string().optional()}),ce=z$1.object({viewport:Le,groups:z$1.array(Me).optional()}),Ge=z$1.object({nodes:z$1.array(ae),connections:z$1.array(ie),layout:ce}),We=z$1.object({id:z$1.string(),name:z$1.string(),timestamp:z$1.string(),description:z$1.string().optional(),state:Ge});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(ne).optional(),portal:z$1.array(ne).optional()}),nodes:z$1.array(ae),connections:z$1.array(ie),layout:ce,snapshots:z$1.array(We).optional()});async function Ye(t,s){let e=[],o=[],a=[],i=[];if(t.sources.purpose)for(let p of t.sources.purpose){let f=b.resolve(s,p.path);try{let u=await K(f);a.push(...u.map(m=>m.filePath));let d=U(u);for(let[m,{item:h,filePath:$}]of d){let C=["feature",...h.tags||[]];e.push(w({id:`purpose-feature-${m}`,symbol:`#${m}`,type:"component",source:"purpose",filePath:$,data:h,description:h.description,tags:C,componentType:h.type,parentSymbol:h.parent,anchors:h.anchors?.map(ue=>M(ue))}));}let g=q(u);for(let[m,{item:h,filePath:$}]of g)e.push(w({id:`purpose-component-${m}`,symbol:`#${m}`,type:"component",source:"purpose",filePath:$,data:h,description:h.description,tags:h.tags,componentType:h.type,parentSymbol:h.parent,anchors:h.anchors?.map(C=>M(C))}));let y=Z(u);for(let[m,{item:h,filePath:$}]of y)e.push(w({id:`purpose-gate-${m}`,symbol:`^${m}`,type:"gate",source:"purpose",filePath:$,data:h,description:h.description}));let S=X(u);for(let[m,{item:h,filePath:$}]of S)e.push(w({id:`purpose-state-${m}`,symbol:`#${m}`,type:"component",source:"purpose",filePath:$,data:h,description:h.description,tags:["state"]}));let G=H(u);for(let[m,{item:h,filePath:$}]of G)e.push(w({id:`purpose-flow-${m}`,symbol:`$${m}`,type:"flow",source:"purpose",filePath:$,data:h,description:h.description}));let pe=J(u);for(let[m,{item:h,filePath:$}]of pe)e.push(w({id:`purpose-signal-${m}`,symbol:`!${m}`,type:"signal",source:"purpose",filePath:$,data:h,description:h.description}));let fe=Q(u);for(let[m,{item:h,filePath:$}]of fe)e.push(w({id:`purpose-aspect-${m}`,symbol:`~${m}`,type:"aspect",source:"purpose",filePath:$,data:h,description:h.description,anchors:h.anchors?.map(C=>M(C)),appliesTo:h["applies-to"],tags:h.tags,enforcement:h.enforcement}));let le=ee(u),W=new Set(e.map(m=>m.symbol));for(let m of le)W.has(m.symbol)||(W.add(m.symbol),e.push(w({id:`purpose-ref-${m.type}-${m.symbol.slice(1)}`,symbol:m.symbol,type:m.type,source:"purpose",filePath:m.filePath,data:{referencedFrom:m.sourceSymbol},description:`Referenced from ${m.sourceSymbol}`})));}catch(u){o.push({source:"purpose",filePath:f,message:u.message});}}if(t.sources.portal)for(let p of t.sources.portal){let f=b.resolve(s,p.path);try{let u;if(f.endsWith(".yaml")||f.endsWith(".yml"))u=await R(f),i.push(f);else {let d=await se(f);if(i.push(...d),d.length>0){u=await R(d[0]);for(let g=1;g<d.length;g++){let y=await R(d[g]);u.gates.push(...y.gates),u.flows.push(...y.flows);}}else continue}for(let d of u.gates){e.push(Be(d,f));for(let g of d.prizes)e.push(w({id:`gate-signal-${d.id}-${g.id}`,symbol:`!${g.id}`,type:"signal",source:"portal",filePath:f,data:g,description:`Signal from gate ${d.id}`}));}for(let d of u.flows)e.push(Ve(d,f));}catch(u){o.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=e.find(d=>d.symbol===p.symbol);if(u){u.position=p.position,u.tags=p.tags;continue}}e.push(w({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}));}Ne(e);let r=new Map;for(let p of e){let f=r.get(p.symbol)||[];f.includes(p.filePath)||f.push(p.filePath),r.set(p.symbol,f);}let c=[];for(let[p,f]of r)f.length>1&&c.push({symbol:p,files:f});return {symbols:e,purposeFiles:a,portalFiles:i,errors:o,timestamp:Date.now(),...c.length>0?{duplicateSymbols:c}:{}}}function w(t){return {...t,data:t.data??null,references:t.references??[],referencedBy:t.referencedBy??[]}}function Be(t,s){let e=t.id.startsWith("^")?t.id.slice(1):t.id;return w({id:`gate-${e}`,symbol:`^${e}`,type:"gate",source:"portal",filePath:s,data:t,description:t.description,position:t.position})}function Ve(t,s){return w({id:`gate-flow-${t.id}`,symbol:`$${t.id}`,type:"flow",source:"portal",filePath:s,data:t,description:t.description})}function M(t){let s=t.lastIndexOf(":");if(s===-1||s===t.length-1)return {path:t,lines:0,raw:t};let e=t.slice(s+1),o=t.slice(0,s);if(!/^[\d,\- ]+$/.test(e))return {path:t,lines:0,raw:t};if(e.includes("-")){let[a,i]=e.split("-").map(Number);return {path:o,lines:[a,i],raw:t}}else if(e.includes(",")){let a=e.split(",").map(Number);return {path:o,lines:a,raw:t}}else return {path:o,lines:Number(e),raw:t}}var _e=new Set(["$lib","$env","$app","$service-worker","$virtual","$schema","$ref","$id","$type"]);function Ne(t){let s=new Map(t.map(e=>[e.symbol,e]));for(let e of t){let o=JSON.stringify(e.data),a=/(?:\?[@#$%~^!]|[@#$%~^!?])[a-zA-Z][\w-]*/g,i=(o.match(a)||[]).filter(r=>!_e.has(r));for(let r of i)if(r!==e.symbol&&s.has(r)){e.references.includes(r)||e.references.push(r);let c=s.get(r);c&&!c.referencedBy.includes(e.symbol)&&c.referencedBy.push(e.symbol);}}}async function pt(t){let s={metadata:{name:b.basename(t),created:new Date().toISOString(),modified:new Date().toISOString()},sources:{purpose:[{path:"./"}],portal:[{path:"./"}]},nodes:[]};return Ye(s,t)}function Ke(){return {entries:new Map,byType:new Map,bySource:new Map,timestamp:0}}function ft(t){let s=Ke();s.timestamp=t.timestamp;for(let e of t.symbols)s.entries.set(e.id,e),s.byType.has(e.type)||s.byType.set(e.type,[]),s.byType.get(e.type).push(e),s.bySource.has(e.source)||s.bySource.set(e.source,[]),s.bySource.get(e.source).push(e);return s}function E(t,s){for(let e of t.entries.values())if(e.symbol===s)return e}function Ue(t,s){return t.byType.get(s)||[]}function lt(t,s){let e=s.toLowerCase(),o=[];for(let a of t.entries.values()){if(a.symbol.toLowerCase().includes(e)){o.push(a);continue}if(a.description?.toLowerCase().includes(e)){o.push(a);continue}if(a.tags?.some(i=>i.toLowerCase().includes(e))){o.push(a);continue}if(a.componentType?.toLowerCase().includes(e)){o.push(a);continue}}return o}function ut(t,s){let e=E(t,s);return e?e.referencedBy.map(o=>E(t,o)).filter(o=>o!==void 0):[]}function dt(t,s){let e=E(t,s);return e?e.references.map(o=>E(t,o)).filter(o=>o!==void 0):[]}function mt(t){let s={component:0,flow:0,gate:0,signal:0,aspect:0};for(let[e,o]of t.byType)e in s&&(s[e]=o.length);return s}function ht(t){return Array.from(t.entries.values())}function qe(t,s,e){if(b.isAbsolute(t))return {resolvedPath:t,baseUsed:"absolute",exists:P.existsSync(t)};let o=b.join(e,t);if(P.existsSync(o))return {resolvedPath:o,baseUsed:"project-root",exists:true};let a=b.resolve(s,t);return P.existsSync(a)?{resolvedPath:a,baseUsed:"purpose-dir",exists:true}:{resolvedPath:o,baseUsed:"project-root",exists:false}}function gt(t,s,e){if(b.isAbsolute(t)){let i=P.existsSync(t);return {rootResolves:i,purposeResolves:i,mismatch:false}}let o=P.existsSync(b.join(e,t)),a=P.existsSync(b.resolve(s,t));return {rootResolves:o,purposeResolves:a,mismatch:o!==a}}function Ze(t,s){return t.includes("*")?new RegExp("^"+t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\\\*/g,".*")+"$").test(s):t===s}function yt(t,s,e){let o=[],a=Ue(t,"aspect"),i=new Set;for(let r of a){let c=r.appliesTo||[];if(c.length!==0)for(let p of c)for(let f of s){if(!Ze(p,f))continue;let u=r.anchors||[];if(u.length===0){let d=`${r.symbol}::__no-anchors__`;i.has(d)||(i.add(d),o.push({aspectSymbol:r.symbol,anchorRaw:null,kind:"no-anchors"}));}else {let d=r.filePath?b.isAbsolute(r.filePath)?r.filePath:b.resolve(e,r.filePath):e,g=r.filePath?b.dirname(d):e;for(let y of u){let S=`${r.symbol}::${y.raw}`;if(i.has(S))continue;qe(y.path,g,e).exists||(i.add(S),o.push({aspectSymbol:r.symbol,anchorRaw:y.raw,kind:"missing-file"}));}}}}return o}
3
- export{ke as a,je as b,He as c,Ae as d,Qe as e,et as f,R as g,ot as h,pt as i,ft as j,E as k,Ue as l,lt as m,ut as n,dt as o,mt as p,ht as q,qe as r,gt as s,yt as t};
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env node
2
- import {v as v$1,b,q,p,o,s as s$1,i,k,l,a,m,t,u,j as j$1}from'./chunk-FG3M6VVO.js';import {e}from'./chunk-Q527BPUF.js';import {s,e as e$1,g,b as b$2,f as f$2,h}from'./chunk-33ERV2MW.js';import {z,f as f$1,p as p$1}from'./chunk-KAFQA7HV.js';import {f,b as b$1,a as a$1}from'./chunk-ECO3LHCE.js';import*as v from'fs';import*as j from'path';v$1();b();z();f();s();function be(){return [{name:"paradigm_ambient_nominations",description:"Get pending agent nominations \u2014 agents that self-nominated contributions based on recent events. Filters by urgency, agent, pending status. Marks returned nominations as surfaced. ~200 tokens.",inputSchema:{type:"object",properties:{urgency:{type:"string",enum:["critical","high","medium","low"],description:"Filter by urgency level"},agent:{type:"string",description:"Filter by agent ID"},pending_only:{type:"boolean",description:"Only show un-engaged nominations (default: true)"},include_debates:{type:"boolean",description:"Include debate groupings (default: false)"},limit:{type:"number",description:"Max nominations to return (default: 20)"}}},annotations:{readOnlyHint:false,destructiveHint:false}},{name:"paradigm_ambient_events",description:"Query the ambient event stream \u2014 recent tool calls, file edits, gate checks, and other project activity. Filters by type, source, symbol, agent, time window. ~200 tokens.",inputSchema:{type:"object",properties:{type:{type:"string",description:'Event type filter (e.g., "file-modified", "gate-checked", "decision-made")'},source:{type:"string",description:'Event source filter (e.g., "mcp-tool-call", "post-write-hook")'},symbol:{type:"string",description:"Filter events referencing this symbol"},agent:{type:"string",description:"Filter events from this agent"},since:{type:"string",description:'Relative time filter (e.g., "1h", "30m", "2d") or ISO timestamp'},limit:{type:"number",description:"Max events to return (default: 50)"}}},annotations:{readOnlyHint:true,destructiveHint:false}},{name:"paradigm_ambient_engage",description:"Accept, dismiss, or defer a nomination. Optionally resolves a debate by choosing this nomination over others. ~50 tokens.",inputSchema:{type:"object",properties:{nomination_id:{type:"string",description:"Nomination ID to engage with"},response:{type:"string",enum:["accepted","dismissed","deferred"],description:"How to respond"},resolve_debate:{type:"string",description:"Optional debate ID to resolve by choosing this nomination"},reason:{type:"string",description:"Reason for response \u2014 stored on nomination for learning feedback. Especially valuable for dismissals."}},required:["nomination_id","response"]},annotations:{readOnlyHint:false,destructiveHint:false}},{name:"paradigm_context_compose",description:"Compose full agent session context: profile enrichment + recent decisions + transferable journal entries + pending nominations. Returns a markdown context block for prompt injection. ~300 tokens.",inputSchema:{type:"object",properties:{agent:{type:"string",description:"Agent ID to compose context for"},symbols:{type:"array",items:{type:"string"},description:"Relevant symbols for expertise filtering"},include_nominations:{type:"boolean",description:"Include pending nominations (default: true)"},include_decisions:{type:"boolean",description:"Include recent team decisions (default: true)"},include_journal:{type:"boolean",description:"Include transferable journal entries (default: true)"},max_decisions:{type:"number",description:"Max decisions to include (default: 5)"},max_journal:{type:"number",description:"Max journal entries to include (default: 5)"}},required:["agent"]},annotations:{readOnlyHint:true,destructiveHint:false}},{name:"paradigm_ambient_promote",description:"Auto-promote high-confidence pattern discoveries from an agent's learning journal to its notebook. Promotes entries with trigger=pattern_discovered and confidence_after >= 0.8. ~100 tokens.",inputSchema:{type:"object",properties:{agent:{type:"string",description:"Agent ID whose journal to scan"}},required:["agent"]},annotations:{readOnlyHint:false,destructiveHint:false}},{name:"paradigm_ambient_learn",description:"Analyze an agent's nomination acceptance/dismissal history and adjust its attention threshold. If >60% dismissed \u2192 raise threshold (less noise). If >80% accepted \u2192 lower threshold (contribute more). Also returns engagement stats. ~100 tokens.",inputSchema:{type:"object",properties:{agent:{type:"string",description:"Agent ID to analyze and adjust"},dry_run:{type:"boolean",description:"If true, return stats without adjusting (default: false)"}},required:["agent"]},annotations:{readOnlyHint:false,destructiveHint:false}},{name:"paradigm_ambient_health",description:"Agent learning health metrics \u2014 aggregate learning quality across all agents: nomination acceptance rates, threshold drift, notebook counts, expertise growth, and overall health status (cold-start \u2192 accumulating \u2192 calibrating \u2192 mature).",inputSchema:{type:"object",properties:{}},annotations:{readOnlyHint:true,destructiveHint:false}},{name:"paradigm_ambient_learn_postflight",description:"Postflight learning pass \u2014 converts session work log verdicts into agent journal entries. Reads accepted/dismissed/revised verdicts from the session log, creates journal entries for each agent, then auto-promotes high-confidence entries to notebooks. Typically called at session end by the stop hook. ~200 tokens.",inputSchema:{type:"object",properties:{session_id:{type:"string",description:"Session ID (default: current session)"},dry_run:{type:"boolean",description:"If true, show what would be written without writing (default: false)"}}},annotations:{readOnlyHint:false,destructiveHint:false}}]}function re(s){let e=Date.now(),t=s.match(/^(\d+)(m|h|d)$/);if(t){let r=parseInt(t[1],10),i=t[2],l=i==="m"?r*6e4:i==="h"?r*36e5:r*864e5;return new Date(e-l).toISOString()}return s}async function ve(s,e$1,t$1){let r=i=>JSON.stringify(i,null,2);switch(s){case "paradigm_ambient_nominations":{m(t$1.rootDir);let l=e$1.pending_only!==false,d=e$1.limit||20,o=i(t$1.rootDir,{agent:e$1.agent,urgency:e$1.urgency,pending_only:l,limit:d+20}),b=t(t$1.rootDir);o=u(o,b).slice(0,d);let y=j.join(t$1.rootDir,".paradigm/events/nominations.jsonl");if(v.existsSync(y))try{let a=v.readFileSync(y,"utf8"),c=new Set(o.map(m=>m.id)),g=a.trim().split(`
3
- `).map(m=>{try{let f=JSON.parse(m);return c.has(f.id)?(f.surfaced=!0,JSON.stringify(f)):m}catch{return m}});v.writeFileSync(y,g.join(`
4
- `)+`
5
- `,"utf8");}catch{}let h={count:o.length,nominations:o.map(a=>({id:a.id,agent:a.agent,urgency:a.urgency,type:a.type,brief:a.brief,relevance:a.relevance,timestamp:a.timestamp,engaged:a.engaged,response:a.response}))};if(e$1.include_debates){let c=j$1(t$1.rootDir).filter(g=>!g.resolution);h.debates=c.map(g=>({id:g.id,topic:g.topic,type:g.type,nominations:g.nominations})),h.debate_count=c.length;}return {text:r(h),handled:true}}case "paradigm_ambient_events":{let i=e$1.since?re(e$1.since):void 0,l=e$1.limit||50,d=a(t$1.rootDir,{type:e$1.type,source:e$1.source,symbol:e$1.symbol,agent:e$1.agent,since:i,limit:l});return {text:r({count:d.length,events:d.map(o=>({id:o.id,type:o.type,source:o.source,timestamp:o.timestamp,path:o.path,symbols:o.symbols,context:o.context,agent:o.agent,tool:o.tool,severity:o.severity}))}),handled:true}}case "paradigm_ambient_engage":{let i$1=e$1.nomination_id,l$1=e$1.response,d=e$1.reason,o=k(t$1.rootDir,i$1,l$1,d);if(o)try{let{appendSessionWorkEntry:y,appendVerdictEntry:h}=await import('./session-work-log-T2IE4Y4T.js'),c=i(t$1.rootDir,{limit:500}).find(m=>m.id===i$1),g={timestamp:new Date().toISOString(),type:"user-verdict",agent:c?.agent,nominationId:i$1,verdict:l$1,reason:d};y(t$1.rootDir,g),h(t$1.rootDir,g);}catch{}let b=false;return e$1.resolve_debate&&o&&(b=l(t$1.rootDir,e$1.resolve_debate,i$1,e$1.reason)),{text:r({engaged:o,nomination_id:i$1,response:l$1,debate_resolved:b||void 0}),handled:true}}case "paradigm_context_compose":{let i$1=e$1.agent,l=e$1.symbols||[],d=e$1.include_nominations!==false,o=e$1.include_decisions!==false,b=e$1.include_journal!==false,y=e$1.max_decisions||5,h=e$1.max_journal||5,a=f$1(t$1.rootDir,i$1);if(!a)return {text:r({error:`Agent profile not found: ${i$1}`}),handled:true};let c=[],g=p$1(a,l);if(g.trim()&&c.push(g),o){let m=e(t$1.rootDir,{status:"active",limit:y});if(m.length>0){c.push("## Recent Team Decisions");for(let f of m)c.push(`- **${f.title}**: ${f.decision.slice(0,150)}${f.decision.length>150?"...":""}`);c.push("");}}if(b){let m=b$1(i$1,{transferable:true,limit:h});if(m.length>0){c.push("## Transferable Insights");for(let f of m)c.push(`- [${f.trigger}] ${f.insight.slice(0,150)}${f.insight.length>150?"...":""}`);c.push("");}}if(d){let m=i(t$1.rootDir,{pending_only:true,limit:10});if(m.length>0){c.push("## Pending Nominations");for(let f of m)c.push(`- [${f.urgency}] ${f.brief}`);c.push("");}}return {text:r({agent:i$1,context:c.join(`
6
- `),sections_included:{profile:true,decisions:o,journal:b,nominations:d}}),handled:true}}case "paradigm_ambient_promote":{let i=e$1.agent,l=s$1(t$1.rootDir,i);return {text:r({agent:i,promoted:l.promoted,entries:l.entries}),handled:true}}case "paradigm_ambient_learn":{let i=e$1.agent,l=e$1.dry_run===true,d=p(t$1.rootDir,i);if(l)return {text:r({agent:i,dry_run:true,stats:d,note:d.total<5?"Insufficient data for threshold adjustment (need 5+ engaged nominations)":`Accept rate: ${(d.acceptRate*100).toFixed(0)}% \u2014 ${d.acceptRate>.8?"would lower threshold":d.acceptRate<.4?"would raise threshold":"no adjustment needed"}`}),handled:true};let o$1=o(t$1.rootDir,i);return {text:r({agent:i,...o$1,stats:d}),handled:true}}case "paradigm_ambient_health":case "paradigm_ambient_neverland":{let i=q(t$1.rootDir);return {text:r(i),handled:true}}case "paradigm_ambient_learn_postflight":return {text:r(await de(t$1.rootDir,e$1)),handled:true};default:return {text:`Unknown ambient tool: ${s}`,handled:false}}}var ae={accepted:"human_feedback",dismissed:"confidence_miss",revised:"correction_received"};function ce(s){try{let e=j.join(s,".paradigm","config.yaml");if(v.existsSync(e)){let r=v.readFileSync(e,"utf8").match(/project:\s*["']?([^"'\n]+)["']?/);if(r)return r[1].trim()}}catch{}return j.basename(s)}async function de(s,e={}){let t=e.dry_run===true,r=ce(s),i=e$1(s).filter(n=>n.verdict&&n.agent),l=g(s).filter(n=>n.agent&&n.corrections.length>0),d=b$2(s);if(i.length===0&&l.length===0)return {sessionEntries:d.length,agentsProcessed:[],journalsWritten:0,journalsByAgent:{},promoted:0,promotedByAgent:{},dryRun:t,details:[]};let o=new Map;for(let n of i){let u=n.agent;o.has(u)||o.set(u,[]),o.get(u).push(n);}let b=d.filter(n=>n.type==="agent-contribution"),y=new Map;for(let n of b)n.agent&&(y.has(n.agent)||y.set(n.agent,[]),y.get(n.agent).push(n));let h$1=[],a={},c=0;for(let[n,u]of o){a[n]=0;let _=u.filter(p=>p.verdict==="accepted").length;u.filter(p=>p.verdict==="dismissed").length;u.filter(p=>p.verdict==="revised").length;let R=u.length,K=R>0?_/R:0;for(let p of u){let I=ae[p.verdict];if(!I)continue;let X=y.get(n)?.shift(),A=le(p,X,{acceptRate:K,total:R,accepted:_}),Y=typeof p.confidence=="number"?p.confidence:p.verdict==="accepted"?.85:p.verdict==="revised"?.6:.4,Z={agent:n,verdict:p.verdict,trigger:I,insight:A,symbols:p.symbols};if(h$1.push(Z),t)a[n]++,c++;else try{a$1(n,{trigger:I,insight:A,confidence_before:p.verdict==="accepted"?.7:.8,confidence_after:Y,project:r,transferable:p.verdict==="dismissed",tags:["postflight",`verdict:${p.verdict}`,...(p.symbols||[]).map(ee=>`symbol:${ee}`)]}),a[n]++,c++;}catch{}}}let g$1=new Set;for(let n of l){let u=n.agent;g$1.add(u),a[u]===void 0&&(a[u]=0);let _=`Self-revision during iteration round ${n.round}: ${n.corrections.join("; ")}`;if(h$1.push({agent:u,verdict:"iteration-revision",trigger:"self_reflection",insight:_,symbols:n.symbols}),t)a[u]++,c++;else try{a$1(u,{trigger:"self_reflection",insight:_,confidence_before:.6,confidence_after:typeof n.confidence=="number"?n.confidence:.75,project:r,transferable:!1,tags:["postflight","iteration-revision",`round:${n.round}`,...(n.symbols||[]).map($=>`symbol:${$}`)]}),a[u]++,c++;}catch{}}let m={},f=0,k=new Set([...o.keys(),...g$1]);if(!t)for(let n of k)try{let u=s$1(s,n);u.promoted>0&&(m[n]=u.promoted,f+=u.promoted);}catch{}return !t&&i.length>0&&f$2(s,i.map(n=>n.nominationId).filter(Boolean)),!t&&l.length>0&&h(s,l.map(n=>n.id)),{sessionEntries:d.length,agentsProcessed:Array.from(k),journalsWritten:c,journalsByAgent:a,promoted:f,promotedByAgent:m,dryRun:t,details:h$1}}function le(s,e,t){let r=s.symbols?.length?` (symbols: ${s.symbols.join(", ")})`:"",i=s.reason?` Reason: ${s.reason}.`:"";switch(s.verdict){case "accepted":return `Contribution accepted by user${r}.${i}`+(e?.contribution?` Original: "${e.contribution.slice(0,120)}".`:"")+` Session accept rate: ${(t.acceptRate*100).toFixed(0)}% (${t.accepted}/${t.total}).`;case "dismissed":return `Contribution dismissed by user${r}.${i}`+(e?.contribution?` Rejected contribution: "${e.contribution.slice(0,120)}".`:"")+` Learn from this dismissal to improve future nominations. Session accept rate: ${(t.acceptRate*100).toFixed(0)}% (${t.accepted}/${t.total}).`;case "revised":return `Contribution revised by user${r}.${i}`+(s.revisionDelta?` Delta: "${s.revisionDelta.slice(0,120)}".`:"")+(e?.contribution?` Original: "${e.contribution.slice(0,120)}".`:"")+` Partial credit \u2014 close but not accurate enough. Session accept rate: ${(t.acceptRate*100).toFixed(0)}% (${t.accepted}/${t.total}).`;default:return `Unknown verdict "${s.verdict}"${r}.${i}`}}export{be as a,ve as b,de as c};
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env node
2
- import {a,b}from'./chunk-4TXOVRWD.js';import {b as b$1}from'./chunk-VCKKJDLP.js';import {m}from'./chunk-D6BSCELB.js';import*as u from'fs';import*as p from'path';import*as $ from'js-yaml';import g from'chalk';import q from'ora';var _={"@":{category:"features",prefix:"@"},"#":{category:"components",prefix:"#"},"^":{category:"gates",prefix:"^"},$:{category:"flows",prefix:"$"},"&":{category:"integrations",prefix:"&"},"!":{category:"signals",prefix:"!"},"%":{category:"state",prefix:"%"}},N={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/"]},z={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"]},G={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*"]};async function A(o,t,n={}){let r=n.quiet?null:q();r?.start("Generating navigator.yaml...");let s=M(o),e=L(o),c=H(o),i=U(t.symbols,t.purposeFiles),f={version:"1.0",generated:new Date().toISOString(),structure:s,key_files:e,skip_patterns:c,symbols:i},a=p.join(o,".paradigm"),l=p.join(a,"navigator.yaml");u.existsSync(a)||u.mkdirSync(a,{recursive:true}),u.writeFileSync(l,$.dump(f,{indent:2,lineWidth:120,noRefs:true,sortKeys:false}),"utf8"),r?.succeed(g.green("Navigator generated")),n.quiet||(console.log(g.gray(` Output: ${l}`)),console.log(g.gray(` Structure categories: ${Object.keys(s).length}`)),console.log(g.gray(` Symbol mappings: ${Object.keys(i).length}`)),console.log());}function M(o){let t={};for(let[n,r]of Object.entries(N)){let s=r.filter(e=>{let c=p.join(o,e);return u.existsSync(c)});if(s.length>0){let e=Object.values(_).find(c=>c.category===n);t[n]={paths:s,symbol:e?.prefix||"@"};}}return t}function L(o){let t={};for(let[n,r]of Object.entries(z)){let s=r.filter(e=>{let c=p.join(o,e);return u.existsSync(c)});s.length>0&&(t[n]=s);}return t.config||(t.config=[]),t.entry||(t.entry=[]),t.types||(t.types=[]),t}function H(o){let t={...G},n=p.join(o,".gitignore");if(u.existsSync(n))try{let s=u.readFileSync(n,"utf8").split(`
3
- `).map(e=>e.trim()).filter(e=>e&&!e.startsWith("#")).filter(e=>e.endsWith("/")||e.includes("*")||["node_modules","dist","build",".cache"].some(c=>e.includes(c))).slice(0,20);for(let e of s)t.always.includes(e)||t.always.push(e);}catch{}return t}function U(o,t,n){let r={},s=new Map;for(let e of t){let c=p.dirname(e);s.set(e,c);}for(let e of o){let i=`${W(e.type)}${e.id}`;if(e.path)r[i]=e.path;else if(e.directory)r[i]=e.directory;else {let f=t.find(a=>{let l=p.dirname(a),y=e.id.toLowerCase();return l.toLowerCase().includes(y)});f&&(r[i]=p.dirname(f)+"/");}}return r}function W(o){switch(o){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 "~";default:return "@"}}function P(o){return $.load(o)}async function ce(o,t){let n=o?p.resolve(o):process.cwd(),r=p.basename(n),s=q(),e=p.join(n,".paradigm"),c=u.existsSync(e)&&u.statSync(e).isFile(),i;t.output?i=p.resolve(t.output):c?i=p.join(n,".paradigm-scan-index.json"):(i=p.join(n,".paradigm","scan-index.json"),u.existsSync(p.dirname(i))||u.mkdirSync(p.dirname(i),{recursive:true})),t.quiet||console.log(g.blue(`
4
- \u{1F52D} Generating Paradigm Scan Index
5
- `));let f,a$1,l,y=[p.join(n,".paradigm"),p.join(n,".paradigm","config.yaml")];for(let h of y)if(u.existsSync(h)&&u.statSync(h).isFile())try{let m=u.readFileSync(h,"utf8"),F=P(m);f=F.scan,a$1=F.graph,l=F.context?.tiers;break}catch{}s.start("Aggregating symbols from purpose and portal files...");let d;try{d=await m(n);}catch(h){s.fail(g.red("Failed to aggregate symbols")),console.error(g.gray(h.message)),process.exit(1);}if(s.succeed(`Found ${d.symbols.length} symbols`),!t.quiet){let h={components:d.symbols.filter(m=>m.type==="component").length,flows:d.symbols.filter(m=>m.type==="flow").length,gates:d.symbols.filter(m=>m.type==="gate").length,signals:d.symbols.filter(m=>m.type==="signal").length,aspects:d.symbols.filter(m=>m.type==="aspect").length};console.log(g.gray(" Breakdown:"));for(let[m,S]of Object.entries(h))S>0&&console.log(g.gray(` ${m}: ${S}`));console.log();}s.start("Generating scan index...");let b$2=a({symbols:d.symbols,purposeFiles:d.purposeFiles,portalFiles:d.portalFiles},{projectName:r,visualTagMappings:f?.visualTagMappings,screenDefinitions:f?.screens});K(b$2,{hot:l?.["hot-threshold"],warm:l?.["warm-threshold"]});try{u.writeFileSync(i,b(b$2),"utf8"),s.succeed(g.green("Scan index generated"));}catch(h){s.fail(g.red("Failed to write scan index")),console.error(g.gray(h.message)),process.exit(1);}await A(n,d,{quiet:t.quiet});let j=await Y(n,d.purposeFiles,{quiet:t.quiet});if(j&&Object.keys(j.flows).length>0){let h=p.join(n,".paradigm","flow-index.json");u.writeFileSync(h,JSON.stringify(j,null,2),"utf8"),t.quiet||s.succeed(g.green(`Flow index generated (${Object.keys(j.flows).length} flows)`));}if(a$1?.["auto-generate"]!==false)try{let h=b$1(n),m=p.join(n,".paradigm","graphs");u.existsSync(m)||u.mkdirSync(m,{recursive:!0});let S=p.join(m,"auto.graph.json");u.writeFileSync(S,JSON.stringify(h,null,2),"utf8"),t.quiet||s.succeed(g.green(`Symbol graph updated (${h.nodes.length} nodes)`));}catch{t.quiet||s.warn(g.yellow("Could not auto-generate symbol graph"));}return t.quiet||(console.log(g.gray(`
6
- Output: ${i}`)),console.log(g.gray(` Components: ${Object.keys(b$2.components).length}`)),console.log(g.gray(` Features: ${Object.keys(b$2.features).length}`)),console.log(g.gray(` Flows: ${Object.keys(b$2.flows).length}`)),console.log(g.gray(` State: ${Object.keys(b$2.state).length}`)),console.log(g.gray(` Gates: ${Object.keys(b$2.gates).length}`)),console.log(g.gray(` Signals: ${Object.keys(b$2.signals).length}`)),console.log(),console.log(g.blue('\u2728 Scan index ready for "paradigm probe" queries')),console.log(g.gray(` Attach an image and say "paradigm probe" to map UI to code
7
- `))),b$2}function K(o,t){let n=t?.hot??15,r=t?.warm??5,s=new Map,e=["components","flows","gates","signals","aspects","features","state"];for(let c of e){let i=o[c];if(i)for(let[,f]of Object.entries(i)){let a=f.related;if(a)for(let l of a){let y=l.replace(/^[#$^!~]/,"");s.set(y,(s.get(y)||0)+1);}}}for(let c of e){let i=o[c];if(i)for(let[f,a]of Object.entries(i)){let l=s.get(f)||0,d=(a.visualTags||[]).length,b=l*3+d;a.tier=b>n?"hot":b>r?"warm":"cold";}}}async function Y(o,t,n){let r={},s={};for(let e of t)try{let c=u.readFileSync(e,"utf8"),i=$.load(c);if(!i?.flows)continue;if(Array.isArray(i.flows))for(let f of i.flows){let a=f;if(!a.name)continue;let l=`$${a.name}`,y=T(a.steps);if(y.length>0){let d={id:l,description:a.description||"",steps:y,definedIn:p.relative(o,e)};r[l]=d,D(l,y,s);}}else for(let[f,a]of Object.entries(i.flows)){let l=f.startsWith("$")?f:`$${f}`,y=T(a.steps);if(y.length>0){let d={id:l,description:a.description||"",trigger:a.trigger,steps:y,validation:a.validation,definedIn:p.relative(o,e)};r[l]=d,D(l,y,s);}}}catch(c){n.quiet||console.warn(g.yellow(` Warning: Could not parse flows from ${e}: ${c.message}`));}return Object.keys(r).length===0?null:{version:"1.0",generatedAt:new Date().toISOString(),flows:r,symbolToFlows:s}}function T(o){if(!o||!Array.isArray(o))return [];let t=[];for(let n=0;n<o.length;n++){let r=o[n];if(typeof r=="object"&&r!==null){let s=r,e=s.action||s.description||s.component||"";e&&t.push({id:s.id||`step-${n+1}`,action:e,symbol:s.symbol||s.component,expect:s.expect});}}return t}function D(o,t,n){for(let r of t)r.symbol&&(n[r.symbol]||(n[r.symbol]=[]),n[r.symbol].includes(o)||n[r.symbol].push(o));}export{A as a,ce as b,Y as c};
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env node
2
- import {c,a as a$1}from'./chunk-YNDPSWOE.js';import {e}from'./chunk-VIG5LSGZ.js';import {a}from'./chunk-LKAT7IAK.js';import*as t from'fs';import*as i from'path';import*as w from'js-yaml';import l from'chalk';async function rs(P={}){let p=P.rootDir||process.cwd(),s=[],$=P.quiet,E=P.context;$||(console.log(l.blue(`
3
- \u{1FA7A} Paradigm Doctor
4
- `)),console.log(E?l.gray(`Running context audit checks...
5
- `):l.gray(`Checking Paradigm setup...
6
- `)));let q=a.command("doctor").start("Running health checks");if(!E){let N=function(a){let e=[];try{let o=t.readdirSync(a,{withFileTypes:!0});for(let n of o){if(n.name==="node_modules"||n.name==="dist"||n.name===".git")continue;let d=i.join(a,n.name);n.isDirectory()?e.push(...N(d)):n.name===".purpose"&&e.push(d);}}catch{}return e};let r=i.join(p,".paradigm");if(t.existsSync(r))if(t.statSync(r).isFile())s.push({name:".paradigm",status:"warn",message:"Legacy file format (should be directory)",fix:"paradigm upgrade --all"});else {s.push({name:".paradigm/",status:"ok",message:"Directory exists"});let e$1=i.join(r,"config.yaml");if(t.existsSync(e$1))try{let f=t.readFileSync(e$1,"utf8");e(f),s.push({name:".paradigm/config.yaml",status:"ok",message:"Valid YAML"});}catch(f){s.push({name:".paradigm/config.yaml",status:"error",message:`Invalid YAML: ${f.message}`,fix:"Check YAML syntax"});}else s.push({name:".paradigm/config.yaml",status:"missing",message:"Config file not found",fix:"paradigm init --force"});let o=["logger.md","probe.md","symbols.md"],n=i.join(r,"specs");if(t.existsSync(n))for(let f of o){let x=i.join(n,f);t.existsSync(x)?s.push({name:`.paradigm/specs/${f}`,status:"ok",message:"Present"}):s.push({name:`.paradigm/specs/${f}`,status:"missing",message:"Spec file not found",fix:"paradigm upgrade --all"});}else s.push({name:".paradigm/specs/",status:"missing",message:"Specs directory not found",fix:"paradigm upgrade --all"});let d=i.join(r,"docs");t.existsSync(d)?s.push({name:".paradigm/docs/",status:"ok",message:"Directory exists"}):s.push({name:".paradigm/docs/",status:"missing",message:"Docs directory not found",fix:"paradigm upgrade --all"});let u=i.join(r,"prompts");t.existsSync(u)?s.push({name:".paradigm/prompts/",status:"ok",message:"Directory exists"}):s.push({name:".paradigm/prompts/",status:"missing",message:"Prompts directory not found",fix:"paradigm upgrade --all"});let h=["specs","implementation-guides","prompts","decisions"],m=[];for(let f of h){let x=i.join(r,f);if(t.existsSync(x)&&t.statSync(x).isDirectory()){let k=i.join(x,".index.yaml");t.existsSync(k)||m.push(`.paradigm/${f}/`);}}m.length>0?s.push({name:"Docs-class indexes",status:"warn",message:`${m.length} director${m.length===1?"y":"ies"} missing .index.yaml: ${m.join(", ")}`,fix:"paradigm docs scaffold"}):s.push({name:"Docs-class indexes",status:"ok",message:"All docs-class directories have .index.yaml"});let y=i.join(r,"scan-index.json"),b=i.join(p,".paradigm-scan-index.json");if(t.existsSync(y)){let f=t.statSync(y),x=Date.now()-f.mtime.getTime(),k=Math.floor(x/(1e3*60*60));k>24?s.push({name:".paradigm/scan-index.json",status:"warn",message:`Stale (${k} hours old)`,fix:"paradigm index"}):s.push({name:".paradigm/scan-index.json",status:"ok",message:k>0?`${k} hours old`:"Fresh"});}else t.existsSync(b)?s.push({name:"scan-index",status:"warn",message:"Using legacy location",fix:"paradigm index"}):s.push({name:".paradigm/scan-index.json",status:"missing",message:"Not generated",fix:"paradigm index"});}else s.push({name:".paradigm/",status:"missing",message:"Not initialized",fix:"paradigm init"});let g=c(p);if(g.detected){let a=a$1(g.detected);if(a){let e=i.join(p,a.outputPath);t.existsSync(e)?s.push({name:a.outputPath,status:"ok",message:`Present (${g.detected})`}):s.push({name:a.outputPath,status:"missing",message:`Not generated for ${g.detected}`,fix:"paradigm sync"});}}let c$1=i.join(p,".premise");t.existsSync(c$1)?s.push({name:".premise",status:"ok",message:"Present"}):s.push({name:".premise",status:"missing",message:"Not found (optional)"});let A=i.join(p,".purpose");t.existsSync(A)?s.push({name:".purpose",status:"ok",message:"Present"}):s.push({name:".purpose",status:"warn",message:"Root .purpose not found",fix:"paradigm init"});let R=i.join(p,".paradigm","config.yaml");if(t.existsSync(R))try{let a=t.readFileSync(R,"utf8"),o=w.load(a)?.["purpose-required"];if(o&&Array.isArray(o)){let n=[];for(let d of o){if(!d.pattern)continue;let{glob:u}=await import('glob'),h=await u(d.pattern,{cwd:p,nodir:!1});for(let m of h){let y=i.join(p,m);try{t.statSync(y).isDirectory()&&!t.existsSync(i.join(y,".purpose"))&&n.push(m);}catch{}}}n.length>0?s.push({name:"Purpose-required",status:"warn",message:`${n.length} director${n.length===1?"y":"ies"} missing .purpose: ${n.join(", ")}`,fix:"Create .purpose files with paradigm_purpose_init + paradigm_purpose_add_component"}):s.push({name:"Purpose-required",status:"ok",message:"All required directories have .purpose files"});}}catch{}let M=/\[NEEDS CLARIFICATION:\s*[^\]]+\]/gi,F=0,Y=N(p);for(let a of Y)try{let o=t.readFileSync(a,"utf8").match(M);o&&(F+=o.length);}catch{}F>0?s.push({name:"Clarification markers",status:"warn",message:`${F} [NEEDS CLARIFICATION] marker${F>1?"s":""} found in .purpose files`,fix:"Resolve open clarification markers before shipping"}):Y.length>0&&s.push({name:"Clarification markers",status:"ok",message:"No unresolved markers"});let I=i.join(p,"portal.yaml");if(t.existsSync(I))try{let a=t.readFileSync(I,"utf8"),e=w.load(a);if(e?.version&&e?.gates){let o=Object.keys(e.gates||{}).length,n=Object.keys(e.routes||{}).length;s.push({name:"portal.yaml",status:"ok",message:`Valid (${o} gates, ${n} routes)`});}else s.push({name:"portal.yaml",status:"warn",message:"Missing version or gates section",fix:'Add version: "1.0" and gates: {} to portal.yaml'});}catch(a){s.push({name:"portal.yaml",status:"error",message:`Invalid YAML: ${a.message}`,fix:"Check YAML syntax in portal.yaml"});}if(t.existsSync(I))try{let{checkPortalCompliance:a,getComplianceSummary:e}=await import('./portal-compliance-JONQ4SOP.js'),o=await a(p),n=e(o);s.push({name:"Portal compliance",status:n.status,message:n.message,fix:n.status!=="ok"?"paradigm portal check":void 0});}catch{}{let a=i.join(p,".paradigm","scan-index.json"),e=i.join(p,".paradigm","roster.yaml");try{if(t.existsSync(a)){let o=t.readFileSync(a,"utf8"),n=JSON.parse(o),d=Object.keys(n.components??{}).length,u=Object.keys(n.aspects??{}).length;if(d>0){let h=!1;if(t.existsSync(e))try{let y=w.load(t.readFileSync(e,"utf8"));h=Array.isArray(y?.active)&&y.active.includes("compliance");}catch{}let m=`${d}:${u} components:aspects`;h?s.push({name:"Aspect coverage",status:"ok",message:`${m} (claimant: rune)`}):u===0?s.push({name:"Aspect coverage",status:"info",message:`${m} ${l.dim("(no aspects defined)")}`}):s.push({name:"Aspect coverage",status:"info",message:`${m} ${l.dim("(no claimant active)")}`});}}}catch{}}let H=i.join(p,".paradigm","flows.yaml");if(t.existsSync(H))try{let a=t.readFileSync(H,"utf8"),e=w.load(a);if(e?.version&&e?.flows){let o=Object.keys(e.flows||{}).length,n=Object.entries(e.flows||{}).filter(([,d])=>!d?.steps||(d.steps?.length??0)===0);n.length>0?s.push({name:".paradigm/flows.yaml",status:"warn",message:`${o} flows defined, ${n.length} have no steps`,fix:"Add steps to empty flow definitions"}):s.push({name:".paradigm/flows.yaml",status:"ok",message:`Valid (${o} flows)`});}else s.push({name:".paradigm/flows.yaml",status:"warn",message:"Missing version or flows section",fix:'Ensure flows.yaml has version: "1.0" and flows: {}'});}catch(a){s.push({name:".paradigm/flows.yaml",status:"error",message:`Invalid YAML: ${a.message}`,fix:"Check YAML syntax in flows.yaml"});}let U=i.join(p,".paradigm","lore");if(t.existsSync(U))try{let a=t.readdirSync(U).filter(e=>e.endsWith(".yaml"));a.length===0?s.push({name:"Lore entries",status:"warn",message:"Lore directory exists but no entries found",fix:"Record a lore entry: paradigm lore record"}):s.push({name:"Lore entries",status:"ok",message:`${a.length} lore file${a.length>1?"s":""}`});}catch{s.push({name:"Lore entries",status:"warn",message:"Could not read lore directory"});}let _=i.join(p,".paradigm","university");if(t.existsSync(_))try{let a=i.join(_,"content"),e=0,o=0;if(t.existsSync(a))for(let n of ["notes","policies","quizzes","paths"]){let d=i.join(a,n);t.existsSync(d)&&(e+=t.readdirSync(d).filter(u=>u.endsWith(".md")||u.endsWith(".yaml")).length);}if(e===0)s.push({name:"University content",status:"warn",message:"University directory exists but no content found",fix:'Add content: paradigm university add note --title "Getting Started"'});else {let n=i.join(a,"quizzes");if(t.existsSync(n))for(let u of t.readdirSync(n).filter(h=>h.endsWith(".yaml")))try{let h=w.load(t.readFileSync(i.join(n,u),"utf8"));if(h?.questions)for(let m of h.questions)m.choices&&m.correct&&!(m.correct in m.choices)&&o++;}catch{}let d=i.join(a,"paths");if(t.existsSync(d))for(let u of t.readdirSync(d).filter(h=>h.endsWith(".yaml")))try{let h=w.load(t.readFileSync(i.join(d,u),"utf8"));if(h?.steps){for(let m of h.steps)if(m.content&&!m.content.startsWith("plsat:")){let y=!1;for(let b of ["notes","policies","quizzes","paths"]){let f=i.join(a,b);if(t.existsSync(f)&&t.readdirSync(f).some(k=>k.startsWith(m.content))){y=!0;break}}y||o++;}}}catch{}o>0?s.push({name:"University content",status:"warn",message:`${e} items, ${o} issue${o>1?"s":""}`,fix:"Run: paradigm university validate --deep"}):s.push({name:"University content",status:"ok",message:`${e} content item${e>1?"s":""}`});}}catch{s.push({name:"University content",status:"warn",message:"Could not read university directory"});}let G=i.join(p,".claude","hooks.json"),ss=i.join(p,"plugins","paradigm","hooks.json");if(t.existsSync(G)){let a=t.statSync(G),e=Date.now()-a.mtime.getTime(),o=Math.floor(e/(1e3*60*60*24));o>30?s.push({name:"Claude Code hooks",status:"warn",message:`Hooks are ${o} days old \u2014 may be outdated`,fix:"paradigm hooks install"}):s.push({name:"Claude Code hooks",status:"ok",message:o>0?`${o} days old`:"Fresh"});}else t.existsSync(ss)?s.push({name:"Claude Code hooks",status:"ok",message:"Using plugin hooks"}):s.push({name:"Claude Code hooks",status:"missing",message:"No hooks installed",fix:"paradigm hooks install"});let V=i.join(p,".paradigm","habits.yaml");if(t.existsSync(V))try{let a=t.readFileSync(V,"utf8"),e=w.load(a);if(e?.version&&Array.isArray(e?.habits)){let o=e.habits.filter(n=>n.enabled!==!1).length;s.push({name:"Habits config",status:"ok",message:`Valid (${o}/${e.habits.length} enabled)`});}else s.push({name:"Habits config",status:"warn",message:"Missing version or habits array",fix:"Regenerate habits.yaml with paradigm habits init"});}catch(a){s.push({name:"Habits config",status:"error",message:`Invalid YAML: ${a.message}`,fix:"Check YAML syntax in habits.yaml"});}let J=i.join(p,"AGENTS.md");if(t.existsSync(J)){let a=t.statSync(J),e=Date.now()-a.mtime.getTime(),o=Math.floor(e/(1e3*60*60*24));o>60?s.push({name:"AGENTS.md",status:"warn",message:`${o} days since last update \u2014 may be stale`,fix:"paradigm sync"}):s.push({name:"AGENTS.md",status:"ok",message:o>0?`Updated ${o} days ago`:"Fresh"});}try{let{summarizeTeamFunnel:a}=await import('./team-funnel-RAJ6EDG3.js'),e=a(p,30);if(e.orchestrated+e.soloDeclared+e.bypasses>0||e.eligible>0){let n=e.invocationRate!==null?`${Math.round(e.invocationRate*100)}%`:"n/a",d=e.legibleRate!==null?`${Math.round(e.legibleRate*100)}%`:"n/a",u=Object.entries(e.soloByReason).map(([h,m])=>`${h}:${m}`).join(" ");s.push({name:"Team funnel (30d)",status:e.bypasses>e.orchestrated?"warn":"info",message:`eligible ${e.eligible} \xB7 orchestrated ${e.orchestrated} \xB7 solo ${e.soloDeclared}${u?` (${u})`:""} \xB7 bypass ${e.bypasses} \xB7 invocation ${n} \xB7 legible ${d}`,...e.bypasses>e.orchestrated?{fix:"Orchestrate eligible tasks (paradigm_orchestrate_inline) or declare `paradigm solo <reason>`"}:{}});}}catch{}try{let a=i.join(p,".paradigm","events","settlement-liveness.jsonl");if(t.existsSync(a)){let o=t.readFileSync(a,"utf8").trim().split(`
7
- `).filter(n=>n.trim()).map(n=>{try{return JSON.parse(n)}catch{return null}}).filter(n=>n!==null);if(o.length===0)s.push({name:"Learning-loop liveness",status:"info",message:"No settlements recorded yet (probe writes on each task-DAG settlement)"});else {let n=o.slice(-20),d=o.slice(-5),u=n.filter(f=>f.chainLive===!1),h=d.filter(f=>f.chainLive===!1),m=u.length>0?u[u.length-1]:void 0,y=m?.stages?Object.entries(m.stages).filter(([,f])=>f==="threw").map(([f])=>f):[],b=y.length>0?` (stage: ${y.join(", ")})`:"";h.length>=3?s.push({name:"Learning-loop liveness",status:"error",message:`DEAD CHAIN: ${h.length}/5 recent settlements severed${b} \u2014 the learning loop is not closing`,fix:"A settlement-chain stage is throwing. Inspect .paradigm/events/settlement-liveness.jsonl and the named stage."}):u.length>0?s.push({name:"Learning-loop liveness",status:"warn",message:`${u.length}/${n.length} recent settlements had a severed chain${b}`,fix:"Inspect the named stage in .paradigm/events/settlement-liveness.jsonl."}):s.push({name:"Learning-loop liveness",status:"ok",message:`${n.length} recent settlements, chain live`});}}}catch{}}let O=0,T=0,v=0;for(let r of s){let g,c;switch(r.status){case "ok":g="\u2713",c=l.green;break;case "warn":g="\u26A0",c=l.yellow,T++;break;case "error":g="\u2717",c=l.red,O++;break;case "missing":g="\u25CB",c=l.gray,v++;break;case "info":g="\u2802",c=l.gray;break}if(!$){let A=r.name.padEnd(30);console.log(` ${c(g)} ${A} ${c(r.message)}`),r.fix&&console.log(l.gray(` \u2514\u2500 Fix: ${r.fix}`));}}let{runContextAudit:Z}=await import('./context-audit-JVCA6GSV.js'),L=await Z(p,{quiet:$}),z=0,W=0,S=0;!$&&L.length>0&&(console.log(""),console.log(l.blue(" Context Audit")),console.log(l.gray(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")));for(let r of L){let g,c;switch(r.status){case "ok":g="\u2713",c=l.green;break;case "warn":g="\u26A0",c=l.yellow,W++;break;case "error":g="\u2717",c=l.red,z++;break;case "advisory":g="\u2139",c=l.cyan,S++;break}if(!$){let A=r.check.padEnd(30);if(console.log(` ${c(g)} ${A} ${c(r.message)}`),r.details&&r.details.length>0){let R=r.details.slice(0,5);for(let M of R)console.log(l.gray(` \u2502 ${M}`));r.details.length>5&&console.log(l.gray(` \u2502 ... and ${r.details.length-5} more`));}r.fix&&console.log(l.gray(` \u2514\u2500 Fix: ${r.fix}`));}}let j=O+z,C=T+W,D=j+C+v===0;if(!$)if(console.log(""),D)console.log(l.green(`\u2728 All checks passed!
8
- `));else {let r=[];j>0&&r.push(l.red(`${j} error${j>1?"s":""}`)),C>0&&r.push(l.yellow(`${C} warning${C>1?"s":""}`)),v>0&&r.push(l.gray(`${v} missing`)),S>0&&r.push(l.cyan(`${S} advisor${S>1?"ies":"y"}`)),console.log(`${r.join(", ")} found.
9
- `),console.log(l.gray("Run the suggested commands to fix issues.")),console.log(l.gray(`Troubleshooting guide: .paradigm/docs/troubleshooting.md
10
- `));}if(!$&&P.explain&&!D)try{let{narrateAllGaps:r}=await import('./gap-narrator-NTXLUI7I.js'),g=[];for(let c of s)c.status!=="ok"&&(c.name===".purpose"||c.name.startsWith("Purpose-required")?g.push({type:"missing-purpose",target:c.name,severity:"improvement"}):c.name===".paradigm/scan-index.json"&&c.status==="warn"?g.push({type:"index-stale",target:c.name,severity:"improvement"}):c.name==="Portal compliance"?g.push({type:"portal-mismatch",target:c.name,severity:c.status==="error"?"blocking":"improvement"}):c.name==="Clarification markers"&&g.push({type:"missing-description",target:c.name,severity:"improvement"}));if(g.length>0){let c=r(g);console.log(l.blue(`
11
- Gap Narrations (--explain)
12
- `)),console.log(l.gray(c.narrative)),console.log("");}}catch{}D?q.success("All health checks passed",{total:s.length+L.length}):q.error("Health checks found issues",{errors:j,warnings:C,missing:v,advisories:S});try{let{captureSnapshot:r}=await import('./metrics-UESGUHTA.js');r(p);}catch{}return D}export{rs as a};
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export{b as PREFIX_TO_TYPE,a as SYMBOL_PREFIXES,j as addConnection,h as addPremiseNode,m as aggregateFromDirectory,l as aggregateFromPremise,o as buildSymbolIndex,J as checkAspectAnchors,e as createEmptyPremiseFile,k as createSnapshot,n as createSymbolIndex,E as createSymbolString,I as detectAnchorBaseMismatch,v as getAllComponentTypes,C as getAllSymbols,A as getAllTags,G as getAutocompleteSuggestions,w as getChildComponents,u as getComponentsByType,g as getDefaultPremiseContent,y as getReferencesFrom,x as getReferencesTo,p as getSymbol,q as getSymbolById,B as getSymbolCounts,s as getSymbolsBySource,z as getSymbolsByTag,r as getSymbolsByType,F as isValidSymbol,d as parsePremiseContent,c as parsePremiseFile,D as parseSymbol,H as resolveAnchorPath,t as searchSymbols,f as serializePremiseFile,i as updateNodePosition}from'./chunk-D6BSCELB.js';import'./chunk-K6TLYNRQ.js';import'./chunk-ZJQY5PPP.js';import'./chunk-5TAVYPOV.js';
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import*as P from'fs';import*as z from'js-yaml';import {z as z$1}from'zod';import*as b from'path';import {glob}from'glob';var F=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(),Y=F.extend({id:z$1.string()}),de=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()}),me=z$1.union([de,z$1.string().transform(e=>({description:e}))]),he=z$1.object({from:z$1.string(),to:z$1.string(),type:z$1.string(),description:z$1.string().optional()}),ge=z$1.union([he,z$1.string()]),ye=z$1.object({component:z$1.string(),action:z$1.string(),description:z$1.string().optional()}),_=z$1.union([ye,z$1.string()]),$e=z$1.object({name:z$1.string(),description:z$1.string().optional(),steps:z$1.array(_)}),we=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(_).optional()}),be=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()}),Se=z$1.object({description:z$1.string().optional(),default:z$1.unknown().optional(),type:z$1.string().optional()}),ve=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()}),xe=z$1.object({target:z$1.string(),type:z$1.string(),path:z$1.string()}),Pe=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(Y),z$1.record(F)]).optional(),components:z$1.union([z$1.array(Y),z$1.record(F)]).optional(),gates:z$1.record(be).optional(),states:z$1.record(Se).optional(),signals:z$1.record(me).optional(),aspects:z$1.record(ve).optional(),relationships:z$1.array(ge).optional(),flows:z$1.union([z$1.array($e),z$1.record(we)]).optional(),references:z$1.array(xe).optional()});function ke(e){let t=je(e);return {data:t.data,errors:t.errors}}function je(e){let t=[],s=[],o;try{o=P.readFileSync(e,"utf8");}catch(l){let p=`Cannot read file: ${l.message}`;return t.push(p),s.push({message:p,type:"file"}),{data:null,errors:t,detailedErrors:s,rawContent:void 0,isYamlValid:false}}let r=o.replace(/^([#~!$^][\w-]+):/gm,'"$1":').replace(/^(\s*-\s+)([!#][\w-]+)$/gm,'$1"$2"'),a=null;try{a=z.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 t.push(`${u}${f?` (line ${f})`:""}`),s.push({message:u,line:f,type:"yaml"}),{data:null,errors:t,detailedErrors:s,rawContent:o,isYamlValid:false}}if(a==null)return {data:{},errors:[],detailedErrors:[],rawContent:o,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],h=p[u];if(!h||f.length<2)continue;let g=f.slice(1),y=l[f];if(typeof y!="object"||y===null)continue;let S=l[h]||{};h in l||(l[h]=S),g in S||(S[g]=y),delete l[f];}}let i=Pe.safeParse(a);if(!i.success){for(let l of i.error.issues){let p=l.path.join("."),f=l.message;t.push(`Schema error at ${p||"/"}: ${f}`),s.push({message:f,path:p||"/",type:"schema"});}return {data:a,errors:t,detailedErrors:s,rawContent:o,isYamlValid:true}}return {data:i.data,errors:[],detailedErrors:[],rawContent:o,isYamlValid:true}}function D(e){return e?Array.isArray(e)?e.map(t=>[t.id,t]):Object.entries(e):[]}async function Ae(e){let t=b.resolve(e);return (await glob("**/.purpose",{cwd:t,absolute:true,ignore:["**/node_modules/**","**/dist/**","**/.git/**"]})).sort((o,r)=>{let a=o.split(b.sep).length,i=r.split(b.sep).length;return a-i})}async function N(e){let t=await Ae(e),s=[];for(let o of t){let{data:r,errors:a}=ke(o);r&&(s.push({filePath:o,data:r}),a.length>0&&console.warn(`Warnings parsing ${o}:`,a));}return s}function K(e){let t=new Map;for(let{filePath:s,data:o}of e){let r=D(o.features);for(let[a,i]of r)t.set(a,{item:i,filePath:s});}return t}function U(e){let t=new Map;for(let{filePath:s,data:o}of e){let r=D(o.components);for(let[a,i]of r)t.set(a,{item:i,filePath:s});}return t}function q(e){let t=new Map;for(let{filePath:s,data:o}of e)if(o.gates)for(let[r,a]of Object.entries(o.gates))t.set(r,{item:a,filePath:s});return t}function Z(e){let t=new Map;for(let{filePath:s,data:o}of e)if(o.states)for(let[r,a]of Object.entries(o.states))t.set(r,{item:a,filePath:s});return t}function X(e){let t=new Map;for(let{filePath:s,data:o}of e)if(o.flows)if(Array.isArray(o.flows))for(let r of o.flows)t.set(r.name,{item:{id:r.name,description:r.description,steps:r.steps},filePath:s});else for(let[r,a]of Object.entries(o.flows))t.set(r,{item:{id:r,description:a.description,gates:a.gates,signals:a.signals,components:a.components,steps:a.steps},filePath:s});return t}function H(e){let t=new Map;for(let{filePath:s,data:o}of e)if(o.signals)for(let[r,a]of Object.entries(o.signals))t.set(r,{item:a,filePath:s});return t}function J(e){let t=new Map;for(let{filePath:s,data:o}of e)if(o.aspects)for(let[r,a]of Object.entries(o.aspects))t.set(r,{item:a,filePath:s});return t}function Q(e){let t=[],s=new Set;for(let{filePath:o,data:r}of e){let a=D(r.features);for(let[l,p]of a)B(`#${l}`,p,o,t,s);let i=D(r.components);for(let[l,p]of i)B(`#${l}`,p,o,t,s);}return t}function B(e,t,s,o,r){if(t.flows)for(let a of t.flows){let i=a.startsWith("$")?a:`$${a}`;r.has(i)||(r.add(i),o.push({symbol:i,type:"flow",sourceSymbol:e,filePath:s}));}if(t.gates)for(let a of t.gates){let i=a.startsWith("^")?a:`^${a}`;r.has(i)||(r.add(i),o.push({symbol:i,type:"gate",sourceSymbol:e,filePath:s}));}if(t.signals)for(let a of t.signals){let i=a.startsWith("!")?a:`!${a}`;r.has(i)||(r.add(i),o.push({symbol:i,type:"signal",sourceSymbol:e,filePath:s}));}if(t.states)for(let a of t.states){let i=a.startsWith("#")?a:a.startsWith("%")?`#${a.slice(1)}`:`#${a}`;r.has(i)||(r.add(i),o.push({symbol:i,type:"component",sourceSymbol:e,filePath:s}));}if(t.components)for(let a of t.components){let i=a.startsWith("#")?a:`#${a}`;r.has(i)||(r.add(i),o.push({symbol:i,type:"component",sourceSymbol:e,filePath:s}));}if(t.aspects)for(let a of t.aspects){let i=a.startsWith("~")?a:`~${a}`;r.has(i)||(r.add(i),o.push({symbol:i,type:"aspect",sourceSymbol:e,filePath:s}));}if(t.description){let a=De(t.description);for(let{symbol:i,type:l}of a)r.has(i)||(r.add(i),o.push({symbol:i,type:l,sourceSymbol:e,filePath:s}));}}var Ie=new Set(["$lib","$env","$app","$service-worker","$virtual","$schema","$ref","$id","$type"]);function De(e){let t=[],s=/([$^!#~%])([a-zA-Z][a-zA-Z0-9._-]*)/g,o;for(;(o=s.exec(e))!==null;){let r=o[1],a=o[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}Ie.has(i)||t.push({symbol:i,type:l});}return t}var ze={visualizerPort:42195,watcherPort:42196,autoConnect:true};async function O(e){let t=b.resolve(e),s=b.dirname(t);if(!P.existsSync(t))throw new Error(`Gate config not found: ${t}`);let o=P.readFileSync(t,"utf8"),r=z.load(o);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)){let h=f.startsWith("^")?f.slice(1):f;a.push(L(h,u));}if(r.include)for(let f of r.include){let u=b.join(s,f),h=await glob(u.replace(/\\/g,"/"));for(let g of h){let y=await Oe(g);a.push(...y);}}let p=[];if(r.flows)for(let[f,u]of Object.entries(r.flows))p.push(Fe(f,u));return {version:r.version,gates:a,flows:p,settings:{dev:{...ze,...r.settings?.dev}}}}async function Oe(e){let t=P.readFileSync(e,"utf8"),s=z.load(t);if(s.id){let o=s.id,r=o.startsWith("^")?o.slice(1):o;return [L(r,s)]}if(s.gates){let o=[];for(let[r,a]of Object.entries(s.gates)){let i=r.startsWith("^")?r.slice(1):r;o.push(L(i,a));}return o}return []}function L(e,t){let s=[];if(t.locks)for(let r of t.locks)s.push(Re(r));let o=[];if(t.prizes)for(let r of t.prizes)o.push(Ee(r));return {id:e,description:t.description,locks:s,prizes:o,position:t.position}}function Re(e){let t=e,s=[];if(t.keys){for(let o of t.keys)if(typeof o=="string")s.push({expression:o});else if(o.expression){let r=o;s.push({expression:r.expression,description:r.description});}}return {id:t.id,description:t.description,keys:s,mode:t.mode||"all"}}function Ee(e){let t=e;return {id:t.id,oneTime:t.oneTime??false,metadata:t.metadata}}function Fe(e,t){return {id:e,description:t.description,gates:t.gates||[],forkable:t.forkable}}async function te(e){let t=b.resolve(e);return await glob("**/portal.yaml",{cwd:t,absolute:true,ignore:["**/node_modules/**","**/dist/**","**/.git/**"]})}var Le={component:"#",flow:"$",gate:"^",signal:"!",aspect:"~"},Me={"#":"component",$:"flow","^":"gate","!":"signal","~":"aspect"},Ge=["#","$","^","!","~"];function We(e){return Ge.includes(e)}var Ye=z$1.object({x:z$1.number(),y:z$1.number()}),Be=z$1.object({x:z$1.number(),y:z$1.number(),zoom:z$1.number()}),se=z$1.object({path:z$1.string(),include:z$1.array(z$1.string()).optional(),exclude:z$1.array(z$1.string()).optional()}),ne=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:Ye,tags:z$1.array(z$1.string()).optional(),created:z$1.string(),modified:z$1.string().optional()}),re=z$1.object({from:z$1.string(),to:z$1.string(),label:z$1.string().optional(),type:z$1.string().optional()}),Ve=z$1.object({id:z$1.string(),name:z$1.string(),nodes:z$1.array(z$1.string()),color:z$1.string().optional()}),ae=z$1.object({viewport:Be,groups:z$1.array(Ve).optional()}),_e=z$1.object({nodes:z$1.array(ne),connections:z$1.array(re),layout:ae}),Ne=z$1.object({id:z$1.string(),name:z$1.string(),timestamp:z$1.string(),description:z$1.string().optional(),state:_e}),Ke=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(se).optional(),portal:z$1.array(se).optional()}),nodes:z$1.array(ne),connections:z$1.array(re),layout:ae,snapshots:z$1.array(Ne).optional()});function ft(e){let t=[],s;try{s=P.readFileSync(e,"utf8");}catch(o){return t.push(`Cannot read file: ${o.message}`),{data:null,errors:t,rawContent:void 0}}return Ue(s)}function Ue(e){let t=[],s=null;try{s=z.load(e);}catch(r){let a=r,i=a.mark?.line?a.mark.line+1:void 0;return t.push(`YAML syntax error: ${a.reason||r.message}${i?` (line ${i})`:""}`),{data:null,errors:t,rawContent:e}}if(s==null)return {data:ie(),errors:[],rawContent:e};let o=Ke.safeParse(s);if(!o.success){for(let r of o.error.issues){let a=r.path.join(".");t.push(`Schema error at ${a||"/"}: ${r.message}`);}return {data:s,errors:t,rawContent:e}}return {data:o.data,errors:[],rawContent:e}}function ie(e="Untitled"){let t=new Date().toISOString();return {version:"1.0.0",metadata:{name:e,created:t,modified:t},sources:{purpose:[{path:"./"}],portal:[{path:"./portal.yaml"}]},nodes:[],connections:[],layout:{viewport:{x:0,y:0,zoom:1}}}}function qe(e){return e.metadata.modified=new Date().toISOString(),z.dump(e,{indent:2,lineWidth:-1,noRefs:true,sortKeys:false})}function lt(e="My Project"){return qe(ie(e))}function ut(e,t){return {...e,nodes:[...e.nodes,t],metadata:{...e.metadata,modified:new Date().toISOString()}}}function dt(e,t,s){return {...e,nodes:e.nodes.map(o=>o.id===t?{...o,position:s,modified:new Date().toISOString()}:o),metadata:{...e.metadata,modified:new Date().toISOString()}}}function mt(e,t){return e.connections.some(o=>o.from===t.from&&o.to===t.to)?e:{...e,connections:[...e.connections,t],metadata:{...e.metadata,modified:new Date().toISOString()}}}function ht(e,t,s){let o={id:`snap-${Date.now()}`,name:t,timestamp:new Date().toISOString(),description:s,state:{nodes:[...e.nodes],connections:[...e.connections],layout:{...e.layout}}};return {...e,snapshots:[...e.snapshots||[],o],metadata:{...e.metadata,modified:new Date().toISOString()}}}async function Ze(e,t){let s=[],o=[],r=[],a=[];if(e.sources.purpose)for(let p of e.sources.purpose){let f=b.resolve(t,p.path);try{let u=await N(f);r.push(...u.map(d=>d.filePath));let h=K(u);for(let[d,{item:m,filePath:$}]of h){let j=["feature",...m.tags||[]];s.push(w({id:`purpose-feature-${d}`,symbol:`#${d}`,type:"component",source:"purpose",filePath:$,data:m,description:m.description,tags:j,componentType:m.type,parentSymbol:m.parent,anchors:m.anchors?.map(ue=>M(ue))}));}let g=U(u);for(let[d,{item:m,filePath:$}]of g)s.push(w({id:`purpose-component-${d}`,symbol:`#${d}`,type:"component",source:"purpose",filePath:$,data:m,description:m.description,tags:m.tags,componentType:m.type,parentSymbol:m.parent,anchors:m.anchors?.map(j=>M(j))}));let y=q(u);for(let[d,{item:m,filePath:$}]of y)s.push(w({id:`purpose-gate-${d}`,symbol:`^${d}`,type:"gate",source:"purpose",filePath:$,data:m,description:m.description}));let S=Z(u);for(let[d,{item:m,filePath:$}]of S)s.push(w({id:`purpose-state-${d}`,symbol:`#${d}`,type:"component",source:"purpose",filePath:$,data:m,description:m.description,tags:["state"]}));let G=X(u);for(let[d,{item:m,filePath:$}]of G)s.push(w({id:`purpose-flow-${d}`,symbol:`$${d}`,type:"flow",source:"purpose",filePath:$,data:m,description:m.description}));let pe=H(u);for(let[d,{item:m,filePath:$}]of pe)s.push(w({id:`purpose-signal-${d}`,symbol:`!${d}`,type:"signal",source:"purpose",filePath:$,data:m,description:m.description}));let fe=J(u);for(let[d,{item:m,filePath:$}]of fe)s.push(w({id:`purpose-aspect-${d}`,symbol:`~${d}`,type:"aspect",source:"purpose",filePath:$,data:m,description:m.description,anchors:m.anchors?.map(j=>M(j)),appliesTo:m["applies-to"],tags:m.tags,enforcement:m.enforcement}));let le=Q(u),W=new Set(s.map(d=>d.symbol));for(let d of le)W.has(d.symbol)||(W.add(d.symbol),s.push(w({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){o.push({source:"purpose",filePath:f,message:u.message});}}if(e.sources.portal)for(let p of e.sources.portal){let f=b.resolve(t,p.path);try{let u;if(f.endsWith(".yaml")||f.endsWith(".yml"))u=await O(f),a.push(f);else {let h=await te(f);if(a.push(...h),h.length>0){u=await O(h[0]);for(let g=1;g<h.length;g++){let y=await O(h[g]);u.gates.push(...y.gates),u.flows.push(...y.flows);}}else continue}for(let h of u.gates){s.push(Xe(h,f));for(let g of h.prizes)s.push(w({id:`gate-signal-${h.id}-${g.id}`,symbol:`!${g.id}`,type:"signal",source:"portal",filePath:f,data:g,description:`Signal from gate ${h.id}`}));}for(let h of u.flows)s.push(He(h,f));}catch(u){o.push({source:"portal",filePath:f,message:u.message});}}for(let p of e.nodes){let f=p.tags?.includes("idea");if(!p.content&&!f){let u=s.find(h=>h.symbol===p.symbol);if(u){u.position=p.position,u.tags=p.tags;continue}}s.push(w({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}));}Qe(s);let i=new Map;for(let p of s){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:s,purposeFiles:r,portalFiles:a,errors:o,timestamp:Date.now(),...l.length>0?{duplicateSymbols:l}:{}}}function w(e){return {...e,data:e.data??null,references:e.references??[],referencedBy:e.referencedBy??[]}}function Xe(e,t){let s=e.id.startsWith("^")?e.id.slice(1):e.id;return w({id:`gate-${s}`,symbol:`^${s}`,type:"gate",source:"portal",filePath:t,data:e,description:e.description,position:e.position})}function He(e,t){return w({id:`gate-flow-${e.id}`,symbol:`$${e.id}`,type:"flow",source:"portal",filePath:t,data:e,description:e.description})}function M(e){let t=e.lastIndexOf(":");if(t===-1||t===e.length-1)return {path:e,lines:0,raw:e};let s=e.slice(t+1),o=e.slice(0,t);if(!/^[\d,\- ]+$/.test(s))return {path:e,lines:0,raw:e};if(s.includes("-")){let[r,a]=s.split("-").map(Number);return {path:o,lines:[r,a],raw:e}}else if(s.includes(",")){let r=s.split(",").map(Number);return {path:o,lines:r,raw:e}}else return {path:o,lines:Number(s),raw:e}}var Je=new Set(["$lib","$env","$app","$service-worker","$virtual","$schema","$ref","$id","$type"]);function Qe(e){let t=new Map(e.map(s=>[s.symbol,s]));for(let s of e){let o=JSON.stringify(s.data),r=/(?:\?[@#$%~^!]|[@#$%~^!?])[a-zA-Z][\w-]*/g,a=(o.match(r)||[]).filter(i=>!Je.has(i));for(let i of a)if(i!==s.symbol&&t.has(i)){s.references.includes(i)||s.references.push(i);let l=t.get(i);l&&!l.referencedBy.includes(s.symbol)&&l.referencedBy.push(s.symbol);}}}async function $t(e){let t={metadata:{name:b.basename(e),created:new Date().toISOString(),modified:new Date().toISOString()},sources:{purpose:[{path:"./"}],portal:[{path:"./"}]},nodes:[]};return Ze(t,e)}function et(){return {entries:new Map,byType:new Map,bySource:new Map,timestamp:0}}function wt(e){let t=et();t.timestamp=e.timestamp;for(let s of e.symbols)t.entries.set(s.id,s),t.byType.has(s.type)||t.byType.set(s.type,[]),t.byType.get(s.type).push(s),t.bySource.has(s.source)||t.bySource.set(s.source,[]),t.bySource.get(s.source).push(s);return t}function R(e,t){for(let s of e.entries.values())if(s.symbol===t)return s}function bt(e,t){return e.entries.get(t)}function I(e,t){return e.byType.get(t)||[]}function St(e,t){return e.bySource.get(t)||[]}function tt(e,t){let s=t.toLowerCase(),o=[];for(let r of e.entries.values()){if(r.symbol.toLowerCase().includes(s)){o.push(r);continue}if(r.description?.toLowerCase().includes(s)){o.push(r);continue}if(r.tags?.some(a=>a.toLowerCase().includes(s))){o.push(r);continue}if(r.componentType?.toLowerCase().includes(s)){o.push(r);continue}}return o}function vt(e,t){return I(e,"component").filter(o=>o.componentType===t)}function xt(e){let t=new Set,s=I(e,"component");for(let o of s)o.componentType&&t.add(o.componentType);return Array.from(t).sort()}function Pt(e,t){return I(e,"component").filter(o=>o.parentSymbol===t)}function kt(e,t){let s=R(e,t);return s?s.referencedBy.map(o=>R(e,o)).filter(o=>o!==void 0):[]}function jt(e,t){let s=R(e,t);return s?s.references.map(o=>R(e,o)).filter(o=>o!==void 0):[]}function Ct(e,t){let s=[];for(let o of e.entries.values())o.tags?.includes(t)&&s.push(o);return s}function At(e){let t=new Set;for(let s of e.entries.values())for(let o of s.tags||[])t.add(o);return Array.from(t).sort()}function It(e){let t={component:0,flow:0,gate:0,signal:0,aspect:0};for(let[s,o]of e.byType)s in t&&(t[s]=o.length);return t}function Dt(e){return Array.from(e.entries.values())}function ce(e){if(e.length<2)return null;let t=e[0],s=e.slice(1);return We(t)?{type:Me[t],name:s}:null}function zt(e,t){return `${Le[e]}${t}`}function Ot(e){return ce(e)!==null}function Rt(e,t,s=10){let o=t.toLowerCase(),r=ce(t);return r?I(e,r.type).filter(i=>i.symbol.toLowerCase().includes(o)).slice(0,s):tt(e,t).slice(0,s)}function st(e,t,s){if(b.isAbsolute(e))return {resolvedPath:e,baseUsed:"absolute",exists:P.existsSync(e)};let o=b.join(s,e);if(P.existsSync(o))return {resolvedPath:o,baseUsed:"project-root",exists:true};let r=b.resolve(t,e);return P.existsSync(r)?{resolvedPath:r,baseUsed:"purpose-dir",exists:true}:{resolvedPath:o,baseUsed:"project-root",exists:false}}function Et(e,t,s){if(b.isAbsolute(e)){let a=P.existsSync(e);return {rootResolves:a,purposeResolves:a,mismatch:false}}let o=P.existsSync(b.join(s,e)),r=P.existsSync(b.resolve(t,e));return {rootResolves:o,purposeResolves:r,mismatch:o!==r}}function ot(e,t){return e.includes("*")?new RegExp("^"+e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\\\*/g,".*")+"$").test(t):e===t}function Ft(e,t,s){let o=[],r=I(e,"aspect"),a=new Set;for(let i of r){let l=i.appliesTo||[];if(l.length!==0)for(let p of l)for(let f of t){if(!ot(p,f))continue;let u=i.anchors||[];if(u.length===0){let h=`${i.symbol}::__no-anchors__`;a.has(h)||(a.add(h),o.push({aspectSymbol:i.symbol,anchorRaw:null,kind:"no-anchors"}));}else {let h=i.filePath?b.isAbsolute(i.filePath)?i.filePath:b.resolve(s,i.filePath):s,g=i.filePath?b.dirname(h):s;for(let y of u){let S=`${i.symbol}::${y.raw}`;if(a.has(S))continue;st(y.path,g,s).exists||(a.add(S),o.push({aspectSymbol:i.symbol,anchorRaw:y.raw,kind:"missing-file"}));}}}}return o}export{Me as PREFIX_TO_TYPE,Le as SYMBOL_PREFIXES,mt as addConnection,ut as addPremiseNode,$t as aggregateFromDirectory,Ze as aggregateFromPremise,wt as buildSymbolIndex,Ft as checkAspectAnchors,ie as createEmptyPremiseFile,ht as createSnapshot,et as createSymbolIndex,zt as createSymbolString,Et as detectAnchorBaseMismatch,xt as getAllComponentTypes,Dt as getAllSymbols,At as getAllTags,Rt as getAutocompleteSuggestions,Pt as getChildComponents,vt as getComponentsByType,lt as getDefaultPremiseContent,jt as getReferencesFrom,kt as getReferencesTo,R as getSymbol,bt as getSymbolById,It as getSymbolCounts,St as getSymbolsBySource,Ct as getSymbolsByTag,I as getSymbolsByType,Ot as isValidSymbol,Ue as parsePremiseContent,ft as parsePremiseFile,ce as parseSymbol,st as resolveAnchorPath,tt as searchSymbols,qe as serializePremiseFile,dt as updateNodePosition};
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export{a as doctorCommand}from'./chunk-ZSWXLFN7.js';import'./chunk-YNDPSWOE.js';import'./chunk-VIG5LSGZ.js';import'./chunk-LKAT7IAK.js';import'./chunk-5TAVYPOV.js';
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import {v}from'./chunk-FG3M6VVO.js';export{o as adjustAttentionFromFeedback,u as applySurfacingRules,s as autoPromoteJournalEntries,g as detectDebates,n as emitAndProcess,k as engageNomination,r as forwardNominationsToRelay,q as getNeverlandMetrics,p as getNominationStats,j as loadDebates,i as loadNominations,t as loadSurfacingConfig,h as persistNominations,f as processEvent,m as processPendingEvents,l as resolveDebate}from'./chunk-FG3M6VVO.js';import'./chunk-3KVVC4WV.js';import'./chunk-KAUGQMXU.js';import'./chunk-KAFQA7HV.js';import'./chunk-EK4ZRIFJ.js';import'./chunk-ECO3LHCE.js';import'./chunk-5TAVYPOV.js';v();
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import {v}from'./chunk-RVXQNS6K.js';export{o as adjustAttentionFromFeedback,u as applySurfacingRules,s as autoPromoteJournalEntries,g as detectDebates,n as emitAndProcess,k as engageNomination,r as forwardNominationsToRelay,q as getNeverlandMetrics,p as getNominationStats,j as loadDebates,i as loadNominations,t as loadSurfacingConfig,h as persistNominations,f as processEvent,m as processPendingEvents,l as resolveDebate}from'./chunk-RVXQNS6K.js';import'./chunk-3KVVC4WV.js';import'./chunk-KAUGQMXU.js';import'./chunk-KAFQA7HV.js';import'./chunk-EK4ZRIFJ.js';import'./chunk-ECO3LHCE.js';import'./chunk-5TAVYPOV.js';v();
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import {j}from'./chunk-KAUGQMXU.js';export{c as DEFAULT_PRIOR,g as addNotebookEntry,f as classifyNotebookScope,i as incrementApplied,b as loadNotebookEntries,a as normalizeConcept,d as notebookPrior,h as promoteFromLore,e as searchNotebooks}from'./chunk-KAUGQMXU.js';import'./chunk-5TAVYPOV.js';j();
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export{d as TASK_TYPE_FAMILIES,e as assembleCalibrationGrid,h as classifyTaskLocal,k as emitTaskDag,c as estimateForTask,f as getOrchestrationToolsList,g as handleOrchestrationTool,j as loadAgentsManifest,a as loadLearnedTokenTable,l as planBuilderStages,b as resolveAgentEstimate,i as suggestAgentsForTask}from'./chunk-O4ADSTSY.js';import'./chunk-7BZPDOOQ.js';import'./chunk-4QADCWPU.js';import'./chunk-NKYNHSA5.js';import'./chunk-VR2LLUYE.js';import'./chunk-M7JHVVDW.js';import'./chunk-ACJWUOMA.js';import'./chunk-A5EEY6NO.js';import'./chunk-Q527BPUF.js';import'./chunk-33ERV2MW.js';import'./chunk-VOPJ47QY.js';import'./chunk-GRZQIKST.js';import'./chunk-KAFQA7HV.js';import'./chunk-EK4ZRIFJ.js';import'./chunk-D6BSCELB.js';import'./chunk-K6TLYNRQ.js';import'./chunk-ZJQY5PPP.js';import'./chunk-5TAVYPOV.js';
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export{n as getReindexToolsList,o as handleReindexTool,p as rebuildStaticFiles}from'./chunk-5VR7FKS5.js';import'./chunk-3F4QP2Z5.js';import'./chunk-M4UMM6DC.js';import'./chunk-TMDPDIWA.js';import'./chunk-GRZQIKST.js';import'./chunk-ACJWUOMA.js';import'./chunk-33ERV2MW.js';import'./chunk-EK4ZRIFJ.js';import'./chunk-5TAVYPOV.js';
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export{n as getReindexToolsList,o as handleReindexTool,p as rebuildStaticFiles}from'./chunk-L3AOKDMU.js';import'./chunk-VR2LLUYE.js';import'./chunk-M7JHVVDW.js';import'./chunk-ACJWUOMA.js';import'./chunk-M4UMM6DC.js';import'./chunk-33ERV2MW.js';import'./chunk-GRZQIKST.js';import'./chunk-EK4ZRIFJ.js';import'./chunk-4TXOVRWD.js';import'./chunk-D6BSCELB.js';import'./chunk-K6TLYNRQ.js';import'./chunk-ZJQY5PPP.js';import'./chunk-5TAVYPOV.js';
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export{i as MODEL_PRICING,j as getSessionTracker,k as resetSessionTracker}from'./chunk-ACJWUOMA.js';import'./chunk-33ERV2MW.js';import'./chunk-EK4ZRIFJ.js';import'./chunk-5TAVYPOV.js';
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export{b as registerTools}from'./chunk-IBKCMLOW.js';import'./chunk-4UJ4NIEQ.js';import'./chunk-XROULIQN.js';import'./chunk-ZUAUFZRJ.js';import'./chunk-7HUPVOAY.js';import'./chunk-VKVVIN6J.js';import'./chunk-5VR7FKS5.js';import'./chunk-3F4QP2Z5.js';import'./chunk-M4UMM6DC.js';import'./chunk-B5KLSBOZ.js';import'./chunk-HSY75GRR.js';import'./chunk-RVXQNS6K.js';import'./chunk-3KVVC4WV.js';import'./chunk-KAUGQMXU.js';import'./chunk-Q527BPUF.js';import'./chunk-VOPJ47QY.js';import'./chunk-RGSFU2YW.js';import'./chunk-TMDPDIWA.js';import'./chunk-KLBH26PA.js';import'./chunk-GRZQIKST.js';import'./chunk-KAFQA7HV.js';import'./chunk-ACJWUOMA.js';import'./chunk-33ERV2MW.js';import'./chunk-SD3KVW5Q.js';import'./chunk-EK4ZRIFJ.js';import'./chunk-JNSJVCTU.js';import'./chunk-ECO3LHCE.js';import'./chunk-5TAVYPOV.js';