@a-company/paradigm 6.6.6 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{accept-orchestration-JHDCVHB2.js → accept-orchestration-WMGFGYDK.js} +1 -1
- package/dist/{agent-loader-VGBPL3TH.js → agent-loader-Z753DQWH.js} +1 -1
- package/dist/{agents-suggest-IKY6VD2R.js → agents-suggest-WZEGQT5E.js} +1 -1
- package/dist/{ambient-FNNFB4AP.js → ambient-HAXPDIWK.js} +1 -1
- package/dist/ambient-OW5M5LVN.js +2 -0
- package/dist/ambient-QB7V4TBR.js +6 -0
- package/dist/calibrate-PHVP7RPH.js +4 -0
- package/dist/captain-3COP6YTD.js +2 -0
- package/dist/chunk-33ERV2MW.js +18 -0
- package/dist/chunk-4CGPLLWQ.js +30 -0
- package/dist/chunk-6HVOZANP.js +4 -0
- package/dist/chunk-ACJWUOMA.js +3 -0
- package/dist/chunk-B5KLSBOZ.js +2 -0
- package/dist/chunk-CHSU6LTR.js +2 -0
- package/dist/chunk-DLMDHS2X.js +10 -0
- package/dist/chunk-ECO3LHCE.js +2 -0
- package/dist/chunk-EG22HDXI.js +33 -0
- package/dist/{chunk-5RFISGUW.js → chunk-G6DK3ND3.js} +250 -25
- package/dist/{chunk-GD4F2HC6.js → chunk-H55W26AR.js} +1 -1
- package/dist/chunk-HSY75GRR.js +6 -0
- package/dist/chunk-KAUGQMXU.js +4 -0
- package/dist/chunk-KP5VOYAH.js +20 -0
- package/dist/chunk-OIYJUU6T.js +25 -0
- package/dist/chunk-RDWWSQGH.js +142 -0
- package/dist/chunk-RVXQNS6K.js +30 -0
- package/dist/chunk-VPNJL4LS.js +93 -0
- package/dist/{chunk-XKNJSPB5.js → chunk-W4BW7GXA.js} +1 -1
- package/dist/chunk-XPPFILCM.js +2 -0
- package/dist/chunk-YCDOA5IQ.js +18 -0
- package/dist/chunk-YQK3XU63.js +504 -0
- package/dist/{chunk-TQOT2LBO.js → chunk-YXLGVOZO.js} +1 -1
- package/dist/chunk-ZSWXLFN7.js +12 -0
- package/dist/{compliance-J3VOV445.js → compliance-4P3EE5OA.js} +1 -1
- package/dist/{diff-ANKTFDRA.js → diff-VBVIUNL5.js} +1 -1
- package/dist/{docs-TSAAS4W3.js → docs-NTP6UENF.js} +1 -1
- package/dist/doctor-CBZYYQQH.js +2 -0
- package/dist/{hooks-45WDP6QS.js → hooks-AXBWYJ5V.js} +1 -1
- package/dist/index.js +6 -6
- package/dist/journal-loader-CNNA4EAU.js +2 -0
- package/dist/lore-loader-HAZ5FRLP.js +2 -0
- package/dist/mcp.js +3 -3
- package/dist/{migrate-R64OQGSM.js → migrate-5M4KUQ2L.js} +1 -1
- package/dist/nomination-engine-ORHH4L2W.js +2 -0
- package/dist/{nomination-engine-NCLTGMAK.js → nomination-engine-YRHZZZUN.js} +1 -1
- package/dist/notebook-loader-TZVIMNDJ.js +2 -0
- package/dist/orchestrate-MLUGQOEJ.js +8 -0
- package/dist/orchestration-O2OVPTIZ.js +2 -0
- package/dist/{platform-server-ANOALDPL.js → platform-server-Y6TLEXR2.js} +1 -1
- package/dist/propose-block-ZEMEWJQF.js +2 -0
- package/dist/{providers-TBPOE4DI.js → providers-5EHD45C6.js} +1 -1
- package/dist/reindex-ZLDQBFUR.js +2 -0
- package/dist/{serve-3FMUWW5K.js → serve-XZ6GBUS3.js} +1 -1
- package/dist/session-tracker-BZ7FU4AT.js +2 -0
- package/dist/session-work-log-FF7CKMWP.js +2 -0
- package/dist/session-work-log-T2IE4Y4T.js +2 -0
- package/dist/{shift-TNA2E5O7.js → shift-PM4GI736.js} +2 -2
- package/dist/solo-OWR3MX74.js +3 -0
- package/dist/{spawn-KKDDR6UR.js → spawn-PHA2SVQ3.js} +1 -1
- package/dist/{symphony-G6IENE4K.js → symphony-CFAYJGLF.js} +1 -1
- package/dist/{symphony-7INZR43F.js → symphony-L56O5ZG3.js} +3 -3
- package/dist/{symphony-relay-2RHG25Z4.js → symphony-relay-Y2UR3YNR.js} +1 -1
- package/dist/task-loader-H7HQAYGL.js +2 -0
- package/dist/task-loader-YZME4RKE.js +2 -0
- package/dist/task-settlement-HINBVZBE.js +3 -0
- package/dist/task-settlement-XC6E6JNT.js +3 -0
- package/dist/team-25LK6CWM.js +2 -0
- package/dist/team-funnel-RAJ6EDG3.js +2 -0
- package/dist/tools-GAU5WOEI.js +2 -0
- package/dist/university-content/notes/N-para-801-cid-becomes-real.md +60 -0
- package/dist/university-content/notes/N-para-801-falsifiable-self-improvement.md +66 -0
- package/dist/university-content/notes/N-para-801-honest-routing-and-the-method.md +57 -0
- package/dist/university-content/notes/N-para-801-orchestration-emits-dag.md +60 -0
- package/dist/university-content/notes/N-para-801-settlement-closes-the-loop.md +64 -0
- package/dist/university-content/notes/N-para-801-the-task-dag.md +93 -0
- package/dist/university-content/paths/LP-para-801.yaml +43 -0
- package/dist/university-content/quizzes/Q-para-801-cid-becomes-real.yaml +54 -0
- package/dist/university-content/quizzes/Q-para-801-falsifiable-self-improvement.yaml +54 -0
- package/dist/university-content/quizzes/Q-para-801-honest-routing-and-the-method.yaml +54 -0
- package/dist/university-content/quizzes/Q-para-801-orchestration-emits-dag.yaml +54 -0
- package/dist/university-content/quizzes/Q-para-801-settlement-closes-the-loop.yaml +54 -0
- package/dist/university-content/quizzes/Q-para-801-the-task-dag.yaml +54 -0
- package/dist/university-ui/assets/{index-DrtbBC21.js → index-AbTjHBCf.js} +2 -2
- package/dist/university-ui/assets/{index-DrtbBC21.js.map → index-AbTjHBCf.js.map} +1 -1
- package/dist/university-ui/index.html +1 -1
- package/dist/work-log-loader-CRVTOMVB.js +2 -0
- package/package.json +1 -1
- package/dist/ambient-AI42BOM5.js +0 -35
- package/dist/chunk-3OXR6F65.js +0 -666
- package/dist/chunk-4N56FRNE.js +0 -29
- package/dist/chunk-6QXBXZF6.js +0 -3
- package/dist/chunk-AMLD7IYC.js +0 -10
- package/dist/chunk-DVZWCXB6.js +0 -2
- package/dist/chunk-F6E3HW45.js +0 -14
- package/dist/chunk-K7X3Z3GL.js +0 -4
- package/dist/chunk-LAYBUKMB.js +0 -14
- package/dist/chunk-MU5YWTNE.js +0 -24
- package/dist/chunk-PMKZMCTS.js +0 -111
- package/dist/chunk-QGZRM6ZB.js +0 -2
- package/dist/chunk-XQLO5URP.js +0 -11
- package/dist/doctor-L5XZENCF.js +0 -2
- package/dist/journal-loader-GLH7XFTK.js +0 -2
- package/dist/lore-loader-D2ISOASW.js +0 -2
- package/dist/notebook-loader-3J2OFMS3.js +0 -2
- package/dist/orchestrate-UG5QXNAU.js +0 -8
- package/dist/reindex-PTIQ2UGY.js +0 -2
- package/dist/session-tracker-HHNY6J4I.js +0 -2
- package/dist/session-work-log-MEJ33TYD.js +0 -2
- package/dist/session-work-log-ZVVJGO7X.js +0 -2
- package/dist/task-loader-NZFDTUQ5.js +0 -2
- package/dist/team-PEGP6F7S.js +0 -2
- package/dist/tools-PUSDXUYE.js +0 -2
- /package/dist/{chunk-HXGYVS2N.js → chunk-ECLUYHAR.js} +0 -0
- /package/dist/{chunk-CVPKQ3JH.js → chunk-HE2NA5QF.js} +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
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};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {a,O,j as j$2,M as M$1,B}from'./chunk-KP5VOYAH.js';import {a as a$1,b as b$3,c as c$1}from'./chunk-M4UMM6DC.js';import {r,i,a as a$2,f}from'./chunk-TMDPDIWA.js';import {j as j$1,b as b$2,a as a$4}from'./chunk-GRZQIKST.js';import {b as b$1,a as a$3}from'./chunk-EK4ZRIFJ.js';import {c,b,d}from'./chunk-5TAVYPOV.js';import*as S from'fs';import*as T from'path';import*as j from'crypto';import {execSync}from'child_process';import*as C from'js-yaml';import*as Y from'os';import ht from'sql.js';var ve={};c(ve,{contentSearch:()=>gt,detectFileRename:()=>Ae,generateFingerprint:()=>xe,levenshteinDistance:()=>Ie,levenshteinSimilarity:()=>se,searchSiblingFiles:()=>Ce,slidingWindowSearch:()=>V});function xe(e){let t=e.split(`
|
|
3
|
+
`).filter(n=>n.trim()!=="");return {firstLine:q(t[0]||""),lastLine:q(t[t.length-1]||""),lineCount:t.length,structuralHash:Le(t)}}function Le(e){let t=e.map(n=>n.trim()).filter(n=>Re.test(n)).map(n=>{let s=n.match(Re);return s?s[1].trim():""}).join("|");return j.createHash("sha256").update(t).digest("hex").slice(0,16)}function q(e){return e.trim().replace(/\s+/g," ").toLowerCase()}function Ie(e,t){if(e===t)return 0;if(e.length===0)return t.length;if(t.length===0)return e.length;e.length>t.length&&([e,t]=[t,e]);let n=e.length,s=t.length;if(n>5e3||s>5e3)return Math.abs(n-s);let r=new Array(n+1),i=new Array(n+1);for(let a=0;a<=n;a++)r[a]=a;for(let a=1;a<=s;a++){i[0]=a;for(let c=1;c<=n;c++){let o=e[c-1]===t[a-1]?0:1;i[c]=Math.min(r[c]+1,i[c-1]+1,r[c-1]+o);}[r,i]=[i,r];}return r[n]}function se(e,t){if(e.length===0&&t.length===0)return 1;let n=Math.max(e.length,t.length);return 1-Ie(e,t)/n}function V(e,t,n,s=3){let{lineCount:r}=t,i=Math.max(1,Math.floor(r*.8)),a=Math.ceil(r*1.2),c=[],o=ne(n);for(let l of [r,i,a])if(!(l>e.length))for(let d=0;d<=e.length-l;d++){let p=e.slice(d,d+l),y=ft(p,t,o);if(y>=.5){let m=p.join(`
|
|
4
|
+
`);c.push({windowStart:d+1,windowEnd:d+l,similarity:se(ne(m),o),score:y});}}let u=new Map;for(let l of c){let d=u.get(l.windowStart);(!d||l.score>d.score)&&u.set(l.windowStart,l);}return Array.from(u.values()).sort((l,d)=>d.score-l.score).slice(0,s)}function ft(e,t,n){let s=e.filter(p=>p.trim()!=="");if(s.length===0)return 0;let r=0,i=q(s[0]),a=q(s[s.length-1]),c=0;i===t.firstLine&&(c+=.5),a===t.lastLine&&(c+=.5),r+=c*lt,Le(s)===t.structuralHash&&(r+=ut);let u=s.join(`
|
|
5
|
+
`),l=se(ne(u),n);l>=.8&&(r+=(l-.8)/.2*dt);let d=s.length/t.lineCount;if(d>=.8&&d<=1.2){let p=1-Math.abs(1-d)/.2;r+=p*pt;}return r}function ne(e){return e.split(`
|
|
6
|
+
`).map(t=>t.trim()).filter(t=>t!=="").join(`
|
|
7
|
+
`)}function Ae(e,t){try{let n=execSync(`git log --follow --diff-filter=R --name-status --format="" -- "${t}"`,{cwd:e,encoding:"utf8",timeout:5e3}).trim();if(!n)return null;let s=n.split(`
|
|
8
|
+
`);for(let r of s){let i=r.split(" ");if(i.length>=3&&i[0].startsWith("R"))return i[2]}return null}catch{return null}}function Ce(e,t,n,s,r=10){let i=T.isAbsolute(t)?t:T.join(e,t);if(!S.existsSync(i))return [];let a=[];try{let c=S.readdirSync(i).filter(o=>!o.startsWith(".")&&S.statSync(T.join(i,o)).isFile()).slice(0,r);for(let o of c)try{let l=S.readFileSync(T.join(i,o),"utf8").split(`
|
|
9
|
+
`),d=V(l,n,s,1);if(d.length>0&&d[0].score>=.7){let p=T.relative(e,T.join(i,o));a.push({file:p,score:d[0].score,start:d[0].windowStart,end:d[0].windowEnd});}}catch{}}catch{return []}return a.sort((c,o)=>o.score-c.score)}function gt(e,t,n,s=true){let r=xe(n),i=T.isAbsolute(t)?t:T.join(e,t);if(S.existsSync(i)){let l=S.readFileSync(i,"utf8").split(`
|
|
10
|
+
`),d=V(l,r,n);if(d.length>0){let p=d[0];return {found:p.score>=.7,score:p.score,suggestedStart:p.windowStart,suggestedEnd:p.windowEnd,similarity:p.similarity}}}let a=Ae(e,t);if(a){let u=T.join(e,a);if(S.existsSync(u)){let d=S.readFileSync(u,"utf8").split(`
|
|
11
|
+
`),p=V(d,r,n);if(p.length>0&&p[0].score>=.7)return {found:true,score:p[0].score,suggestedStart:p[0].windowStart,suggestedEnd:p[0].windowEnd,suggestedPath:a,similarity:p[0].similarity}}}let c=T.dirname(t),o=Ce(e,c,r,n);if(o.length>0&&o[0].score>=.7){let u=o[0];return {found:true,score:u.score,suggestedStart:u.start,suggestedEnd:u.end,suggestedPath:u.file!==t?u.file:void 0,similarity:u.score}}return {found:false,score:0}}var Re,lt,ut,dt,pt,Ne=b(()=>{Re=/^\s*(function |class |if |else |for |while |switch |case |return |export |import |const |let |var |async |await |try |catch |throw |struct |enum |protocol |guard |def |fn )/;lt=.4,ut=.3,dt=.2,pt=.1;});var Ye="0.1.0",qe="1.0.0";function ee(e,t){let n={$meta:Ve(t.projectName,e),components:{},features:{},flows:{},state:{},gates:{},signals:{},aspects:{},screens:{},symbolMap:{}};for(let r of e.symbols)Ke(r,n,t);if(t.screenDefinitions)for(let[r,i]of Object.entries(t.screenDefinitions))n.screens[r]||(n.screens[r]={id:r,name:M(r),route:i.route,path:"",components:i.components,features:i.features});let s={};for(let r of Object.values(n.components))r.componentType&&(s[r.componentType]=(s[r.componentType]||0)+1);for(let r of Object.values(n.features))r.componentType&&(s[r.componentType]=(s[r.componentType]||0)+1);return Object.keys(s).length>0&&(n.$meta.componentTypes=s),rt(n),n}function Ve(e,t){return {version:qe,project:e,generatedAt:new Date().toISOString(),paradigmVersion:Ye,sources:{purposeFiles:t.purposeFiles.length,portalFiles:t.portalFiles.length,premiseFiles:t.symbols.filter(n=>n.source==="premise").length>0?1:0}}}function Ke(e,t,n){let{type:s}=e;switch(s){case "component":Je(e,t,n);break;case "feature":Qe(e,t,n);break;case "flow":Ze(e,t);break;case "state":et(e,t);break;case "gate":tt(e,t);break;case "signal":nt(e,t);break;case "aspect":st(e,t);break;}}function Je(e,t,n){let s=W(e.symbol),r=Se(s,e.data,n.visualTagMappings),i={id:s,name:M(s),symbol:e.symbol,category:"components",path:e.filePath,description:e.description,visualTags:r,related:e.references,componentType:e.componentType,parent:e.parentSymbol};t.components[s]=i,t.symbolMap[e.symbol]={category:"components",id:s};}function Qe(e,t,n){let s=W(e.symbol),r=Se(s,e.data,n.visualTagMappings),i={id:s,name:M(s),symbol:e.symbol,category:"features",path:e.filePath,description:e.description,visualTags:r,related:e.references,componentType:e.componentType,parent:e.parentSymbol};t.features[s]=i,t.symbolMap[e.symbol]={category:"features",id:s};}function Ze(e,t){let n=W(e.symbol),s=e.data,r=[];if(s?.steps)for(let a=0;a<s.steps.length;a++){let c=s.steps[a];r.push({id:`${n}-step-${a}`,name:c.action||`Step ${a+1}`,target:c.component,description:c.description,order:a});}let i={id:n,name:M(n),symbol:e.symbol,path:e.filePath,description:e.description,steps:r};t.flows[n]=i,t.symbolMap[e.symbol]={category:"flows",id:n};}function et(e,t){let n=W(e.symbol),s={id:n,name:M(n),symbol:e.symbol,path:e.filePath,description:e.description,consumers:e.referencedBy};t.state[n]=s,t.symbolMap[e.symbol]={category:"state",id:n};}function tt(e,t){let n=W(e.symbol),s={id:n,name:M(n),symbol:e.symbol,category:"gates",path:e.filePath,description:e.description,related:e.references};t.gates[n]=s,t.symbolMap[e.symbol]={category:"gates",id:n};}function nt(e,t){let n=W(e.symbol),s={id:n,name:M(n),symbol:e.symbol,category:"signals",path:e.filePath,description:e.description,related:e.references};t.signals[n]=s,t.symbolMap[e.symbol]={category:"signals",id:n};}function st(e,t){let n=W(e.symbol),s={id:n,name:M(n),symbol:e.symbol,category:"aspects",path:e.filePath,description:e.description,related:e.references};t.aspects[n]=s,t.symbolMap[e.symbol]={category:"aspects",id:n};}function rt(e){for(let t of Object.values(e.screens))if(t.components)for(let n of t.components){let s=e.components[n];s&&(s.screens=s.screens||[],s.screens.includes(t.id)||s.screens.push(t.id));}}function W(e){return e.slice(1)}function M(e){return e.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function Se(e,t,n){let s=[];if(n?.[e])return n[e];let r=[[/button/i,"button"],[/btn/i,"button"],[/form/i,"form"],[/input/i,"input"],[/field/i,"input"],[/select/i,"input"],[/card/i,"card"],[/list/i,"list"],[/table/i,"list"],[/modal/i,"modal"],[/dialog/i,"modal"],[/drawer/i,"modal"],[/nav/i,"nav"],[/menu/i,"menu"],[/dropdown/i,"menu"],[/header/i,"header"],[/footer/i,"footer"],[/sidebar/i,"sidebar"],[/hero/i,"hero"],[/grid/i,"grid"],[/chart/i,"chart"],[/graph/i,"chart"],[/icon/i,"icon"],[/image/i,"image"],[/avatar/i,"avatar"],[/badge/i,"badge"],[/tag/i,"badge"],[/tab/i,"tab"],[/accordion/i,"accordion"],[/toast/i,"toast"],[/notification/i,"toast"],[/alert/i,"toast"],[/spinner/i,"spinner"],[/loader/i,"spinner"],[/loading/i,"spinner"],[/skeleton/i,"skeleton"]];for(let[i,a]of r)i.test(e)&&s.push(a);return s}function te(e){return JSON.stringify(e,null,2)}var ot=300*1e3,$=null;function be(){$=null;}function N(e,t){return S.existsSync(T.join(e,t))}function P(e,t){return S.existsSync(T.join(e,t))}function it(e,t,n){let s=e;try{if(!S.existsSync(s))return !1;let r=S.readdirSync(s,{withFileTypes:!0});for(let i of r){if(i.isFile()&&i.name.endsWith(t))return !0;if(i.isDirectory())try{if(S.readdirSync(T.join(s,i.name)).some(c=>c.endsWith(t)))return !0}catch{}}}catch{}return false}var at={wisdom:e=>N(e,".paradigm/wisdom"),history:e=>N(e,".paradigm/history"),lore:e=>N(e,".paradigm/lore"),habits:e=>P(e,".paradigm/habits.yaml"),sentinel:e=>{try{let t=T.join(e,".paradigm","config.yaml");return S.existsSync(t)?S.readFileSync(t,"utf-8").includes("sentinel"):!1}catch{return false}},flows:e=>P(e,".paradigm/flow-index.json")||P(e,".paradigm/flows.yaml"),fixtures:e=>P(e,".paradigm/fixtures.yaml"),orchestration:e=>P(e,".paradigm/agents.yaml"),tasks:e=>N(e,".paradigm/tasks"),assessment:e=>N(e,".paradigm/lore"),personas:e=>it(e,".persona"),protocols:e=>N(e,".paradigm/protocols"),symphony:()=>{let e=T.join(Y.homedir(),".paradigm","score");return S.existsSync(e)},university:e=>N(e,".paradigm/university"),agents:e=>{let t=T.join(Y.homedir(),".paradigm","agents");return N(e,".paradigm/agents")||S.existsSync(t)},"aspect-graph":e=>P(e,".paradigm/aspect-graph.db"),pan:e=>P(e,".pan")||P(e,"nevr.yaml"),notebooks:e=>{let t=T.join(Y.homedir(),".paradigm","notebooks");return N(e,".paradigm/notebooks")||S.existsSync(t)}},we=class{modules=new Map;activatedAdvanced=new Set;rootDir;constructor(t){this.rootDir=t;}register(t){this.modules.set(t.key,t);}registerAll(t){for(let n of t)this.register(n);}detectActiveFeatures(){if($&&Date.now()-$.timestamp<ot)return $.features;let t=new Set;for(let[n,s]of this.modules){if(s.tier==="core"){t.add(n);continue}if(s.tier==="advanced"){this.activatedAdvanced.has(n)&&t.add(n);continue}let r=s.detect||at[n];if(r)try{r(this.rootDir)&&t.add(n);}catch{}else t.add(n);}return $={features:t,timestamp:Date.now()},t}getActiveTools(){let t=this.detectActiveFeatures(),n=[];for(let[s,r]of this.modules)t.has(s)&&n.push(...r.getToolsList());return n}activateAdvanced(t){let n=this.modules.get(t);return !n||n.tier!=="advanced"?null:(this.activatedAdvanced.add(t),n.getToolsList())}getAvailableAdvanced(){let t=[];for(let[n,s]of this.modules)s.tier==="advanced"&&!this.activatedAdvanced.has(n)&&t.push({key:n,toolCount:s.getToolsList().length});return t}async dispatch(t,n,s,r){let i=this.detectActiveFeatures();for(let[a,c]of this.modules)if(i.has(a))try{let o=await c.handleTool(t,n,s,r);if(o.handled)return o}catch(o){return {handled:true,text:JSON.stringify({error:`Tool handler error in module "${a}"`,message:o.message},null,2)}}return null}get size(){return this.modules.size}getRegistryInfo(){let t=this.detectActiveFeatures(),n={core:0,feature:0,advanced:0};for(let s of this.modules.values())n[s.tier]++;return {total:this.modules.size,byTier:n,activeFeatures:[...t],availableAdvanced:[...this.modules.entries()].filter(([s,r])=>r.tier==="advanced"&&!this.activatedAdvanced.has(s)).map(([s])=>s)}}};var re=null;async function mt(){return re||(re=await ht()),re}var yt=[`CREATE TABLE IF NOT EXISTS aspects (
|
|
12
|
+
id TEXT PRIMARY KEY,
|
|
13
|
+
description TEXT NOT NULL,
|
|
14
|
+
category TEXT DEFAULT 'rule',
|
|
15
|
+
severity TEXT DEFAULT 'medium',
|
|
16
|
+
value TEXT,
|
|
17
|
+
enforcement TEXT,
|
|
18
|
+
defined_in TEXT NOT NULL,
|
|
19
|
+
tags TEXT,
|
|
20
|
+
created_at TEXT NOT NULL,
|
|
21
|
+
updated_at TEXT NOT NULL
|
|
22
|
+
)`,`CREATE TABLE IF NOT EXISTS anchors (
|
|
23
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
24
|
+
aspect_id TEXT NOT NULL REFERENCES aspects(id) ON DELETE CASCADE,
|
|
25
|
+
file_path TEXT NOT NULL,
|
|
26
|
+
start_line INTEGER NOT NULL,
|
|
27
|
+
end_line INTEGER NOT NULL,
|
|
28
|
+
content_hash TEXT,
|
|
29
|
+
normalized_hash TEXT,
|
|
30
|
+
materialized_at_commit TEXT,
|
|
31
|
+
last_verified TEXT,
|
|
32
|
+
drifted INTEGER DEFAULT 0
|
|
33
|
+
)`,"CREATE INDEX IF NOT EXISTS idx_anchors_file ON anchors(file_path)","CREATE INDEX IF NOT EXISTS idx_anchors_aspect ON anchors(aspect_id)",`CREATE TABLE IF NOT EXISTS edges (
|
|
34
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
35
|
+
source TEXT NOT NULL,
|
|
36
|
+
target TEXT NOT NULL,
|
|
37
|
+
relation TEXT NOT NULL,
|
|
38
|
+
weight REAL DEFAULT 1.0,
|
|
39
|
+
origin TEXT DEFAULT 'explicit',
|
|
40
|
+
created_at TEXT NOT NULL
|
|
41
|
+
)`,"CREATE INDEX IF NOT EXISTS idx_edges_source ON edges(source)","CREATE INDEX IF NOT EXISTS idx_edges_target ON edges(target)",`CREATE TABLE IF NOT EXISTS lore_links (
|
|
42
|
+
aspect_id TEXT NOT NULL,
|
|
43
|
+
lore_id TEXT NOT NULL,
|
|
44
|
+
PRIMARY KEY (aspect_id, lore_id)
|
|
45
|
+
)`,`CREATE TABLE IF NOT EXISTS search_log (
|
|
46
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
47
|
+
query TEXT NOT NULL,
|
|
48
|
+
results_returned TEXT NOT NULL,
|
|
49
|
+
selected_result TEXT,
|
|
50
|
+
timestamp TEXT NOT NULL
|
|
51
|
+
)`,"CREATE INDEX IF NOT EXISTS idx_search_query ON search_log(query)",`CREATE TABLE IF NOT EXISTS search_weights (
|
|
52
|
+
query_normalized TEXT NOT NULL,
|
|
53
|
+
aspect_id TEXT NOT NULL,
|
|
54
|
+
weight REAL DEFAULT 1.0,
|
|
55
|
+
hit_count INTEGER DEFAULT 1,
|
|
56
|
+
last_hit TEXT NOT NULL,
|
|
57
|
+
PRIMARY KEY (query_normalized, aspect_id)
|
|
58
|
+
)`,`CREATE TABLE IF NOT EXISTS heatmap (
|
|
59
|
+
aspect_id TEXT NOT NULL,
|
|
60
|
+
access_type TEXT NOT NULL,
|
|
61
|
+
count INTEGER DEFAULT 0,
|
|
62
|
+
last_accessed TEXT NOT NULL,
|
|
63
|
+
PRIMARY KEY (aspect_id, access_type)
|
|
64
|
+
)`],Et=["ALTER TABLE anchors ADD COLUMN original_content TEXT",`CREATE TABLE IF NOT EXISTS anchor_history (
|
|
65
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
66
|
+
anchor_id INTEGER NOT NULL,
|
|
67
|
+
action TEXT NOT NULL,
|
|
68
|
+
old_start INTEGER,
|
|
69
|
+
old_end INTEGER,
|
|
70
|
+
new_start INTEGER,
|
|
71
|
+
new_end INTEGER,
|
|
72
|
+
old_path TEXT,
|
|
73
|
+
new_path TEXT,
|
|
74
|
+
confidence REAL,
|
|
75
|
+
commit_hash TEXT,
|
|
76
|
+
healed_at TEXT NOT NULL
|
|
77
|
+
)`],Tt="CREATE VIRTUAL TABLE IF NOT EXISTS aspects_fts USING fts5(id, description, enforcement, tags)";function A(e,t,n){let s=e.prepare(t);n&&n.length>0&&s.bind(n);let r=[];for(;s.step();)r.push(s.getAsObject());return s.free(),r}function St(e,t,n){let s=e.prepare(t);n&&n.length>0&&s.bind(n);let r=null;return s.step()&&(r=s.getAsObject()),s.free(),r}async function Fe(e){let t=await mt(),n=T.join(e,".paradigm"),s=T.join(n,"aspect-graph.db"),r;if(S.existsSync(s)){let i=S.readFileSync(s);r=new t.Database(i);}else S.existsSync(n)||S.mkdirSync(n,{recursive:true}),r=new t.Database;for(let i of yt)r.run(i);try{r.run(Tt);}catch{}for(let i of Et)try{r.run(i);}catch{}return r}function ke(e,t){if(t){let n=T.join(t,".paradigm");S.existsSync(n)||S.mkdirSync(n,{recursive:true});let s=T.join(n,"aspect-graph.db"),r=e.export();S.writeFileSync(s,Buffer.from(r));}e.close();}function Me(e,t,n){let s=t.filter(a=>a.type==="aspect"),r=new Date().toISOString(),i=null;try{i=execSync("git rev-parse HEAD",{cwd:n,encoding:"utf8"}).trim();}catch{}e.run("DELETE FROM anchors"),e.run("DELETE FROM edges"),e.run("DELETE FROM aspects");try{e.run("DELETE FROM aspects_fts");}catch{}for(let a of s){let c=a.data??{},o=_t(c,a),u=xt(c,a),l=c.value!=null?String(c.value):null,d=a.enforcement??(c.enforcement!=null?String(c.enforcement):null),p=a.tags?JSON.stringify(a.tags):null;if(e.run(`INSERT INTO aspects (id, description, category, severity, value, enforcement, defined_in, tags, created_at, updated_at)
|
|
78
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,[a.symbol,a.description??"",o,u,l,d,a.filePath,p,a.created??r,a.modified??r]),a.anchors)for(let m of a.anchors){let{startLine:R,endLine:v}=Pe(m),L=Rt();e.run(`INSERT INTO anchors (aspect_id, file_path, start_line, end_line, content_hash, normalized_hash, materialized_at_commit, last_verified, original_content)
|
|
79
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,[a.symbol,m.path,R,v,L.exact,L.normalized,i,r,L.normalizedContent]);}let y=c.edges;if(Array.isArray(y))for(let m of y)e.run(`INSERT INTO edges (source, target, relation, weight, origin, created_at)
|
|
80
|
+
VALUES (?, ?, ?, ?, ?, ?)`,[m.source??a.symbol,m.target??"",m.relation??"related-to",m.weight??1,m.origin??"explicit",r]);if(a.appliesTo)for(let m of a.appliesTo)e.run(`INSERT INTO edges (source, target, relation, weight, origin, created_at)
|
|
81
|
+
VALUES (?, ?, ?, ?, ?, ?)`,[a.symbol,m,"related-to",.5,"inferred",r]);try{e.run(`INSERT INTO aspects_fts (id, description, enforcement, tags)
|
|
82
|
+
VALUES (?, ?, ?, ?)`,[a.symbol,a.description??"",d??"",p??""]);}catch{}}}function cn(e,t){return St(e,"SELECT * FROM aspects WHERE id = ?",[t])}function ln(e,t){return A(e,"SELECT * FROM anchors WHERE aspect_id = ?",[t])}function un(e,t){return A(e,"SELECT * FROM edges WHERE source = ?",[t])}function dn(e,t){return A(e,"SELECT * FROM edges WHERE target = ?",[t])}function pn(e,t){return A(e,"SELECT * FROM edges WHERE source = ? OR target = ?",[t,t])}function fn(e,t,n){let s=new Date().toISOString();e.run(`INSERT INTO heatmap (aspect_id, access_type, count, last_accessed)
|
|
83
|
+
VALUES (?, ?, 1, ?)
|
|
84
|
+
ON CONFLICT(aspect_id, access_type)
|
|
85
|
+
DO UPDATE SET count = count + 1, last_accessed = ?`,[t,n,s,s]);}function gn(e,t=20,n){return n?A(e,"SELECT * FROM heatmap WHERE access_type = ? ORDER BY count DESC LIMIT ?",[n,t]):A(e,"SELECT * FROM heatmap ORDER BY count DESC LIMIT ?",[t])}function hn(e,t,n,s=true,r$1=.7,i=.85){let a=n?A(e,"SELECT * FROM anchors WHERE aspect_id = ?",[n]):A(e,"SELECT * FROM anchors"),c=[];for(let o of a){let l=A(e,"SELECT defined_in FROM aspects WHERE id = ?",[o.aspect_id])[0]?.defined_in,d$1=l?T.dirname(T.isAbsolute(l)?l:T.resolve(t,l)):t,p=r(o.file_path,d$1,t),y=p.resolvedPath;if(!p.exists){c.push({aspectId:o.aspect_id,path:o.file_path,startLine:o.start_line,endLine:o.end_line,status:"missing",resolvedBy:"none",exists:false,drifted:true});continue}try{let R=S.readFileSync(y,"utf8").split(`
|
|
86
|
+
`),v=Math.max(0,o.start_line-1),L=Math.min(R.length,o.end_line),D=R.slice(v,L).join(`
|
|
87
|
+
`),U=j.createHash("sha256").update(D).digest("hex");if(o.content_hash!=null&&U===o.content_hash){c.push({aspectId:o.aspect_id,path:o.file_path,startLine:o.start_line,endLine:o.end_line,status:"clean",resolvedBy:"exact-hash",exists:!0,drifted:!1}),o.drifted===1&&e.run("UPDATE anchors SET drifted = 0 WHERE id = ?",[o.id]);continue}let X=j.createHash("sha256").update(ie(D)).digest("hex");if(o.normalized_hash!=null&&X===o.normalized_hash){e.run("UPDATE anchors SET content_hash = ?, drifted = 0 WHERE id = ?",[U,o.id]),c.push({aspectId:o.aspect_id,path:o.file_path,startLine:o.start_line,endLine:o.end_line,status:"cosmetic",resolvedBy:"normalized-hash",exists:!0,drifted:!1});continue}if(o.content_hash==null&&o.normalized_hash==null){e.run("UPDATE anchors SET content_hash = ?, normalized_hash = ?, drifted = 0 WHERE id = ?",[U,X,o.id]),c.push({aspectId:o.aspect_id,path:o.file_path,startLine:o.start_line,endLine:o.end_line,status:"clean",resolvedBy:"exact-hash",exists:!0,drifted:!1});continue}let H=!1;if(o.materialized_at_commit){let h=bt(t,o.file_path,o.materialized_at_commit,o.start_line,o.end_line);if(h){let g=Math.max(0,h.currentStart-1),f=Math.min(R.length,h.currentEnd),E=R.slice(g,f).join(`
|
|
88
|
+
`),F=j.createHash("sha256").update(E).digest("hex");if(o.content_hash!=null&&F===o.content_hash){let k=s;if(k){e.run("UPDATE anchors SET start_line = ?, end_line = ?, drifted = 0 WHERE id = ?",[h.currentStart,h.currentEnd,o.id]);let z=A(e,"SELECT defined_in FROM aspects WHERE id = ?",[o.aspect_id]);z.length>0&&oe(t,z[0].defined_in,o.file_path,o.start_line,o.end_line,h.currentStart,h.currentEnd);}c.push({aspectId:o.aspect_id,path:o.file_path,startLine:k?h.currentStart:o.start_line,endLine:k?h.currentEnd:o.end_line,status:"shifted",resolvedBy:"git-line-mapping",exists:!0,drifted:!1,suggestedStart:h.currentStart,suggestedEnd:h.currentEnd,autoHealed:k}),H=!0;}else {let k=j.createHash("sha256").update(ie(E)).digest("hex");if(o.normalized_hash!=null&&k===o.normalized_hash){if(s){let z=j.createHash("sha256").update(E).digest("hex");e.run("UPDATE anchors SET start_line = ?, end_line = ?, content_hash = ?, drifted = 0 WHERE id = ?",[h.currentStart,h.currentEnd,z,o.id]);let B=A(e,"SELECT defined_in FROM aspects WHERE id = ?",[o.aspect_id]);B.length>0&&oe(t,B[0].defined_in,o.file_path,o.start_line,o.end_line,h.currentStart,h.currentEnd);}c.push({aspectId:o.aspect_id,path:o.file_path,startLine:s?h.currentStart:o.start_line,endLine:s?h.currentEnd:o.end_line,status:"shifted",resolvedBy:"git-line-mapping",exists:!0,drifted:!1,suggestedStart:h.currentStart,suggestedEnd:h.currentEnd,autoHealed:s}),H=!0;}}}}if(H)continue;if(o.original_content){let{contentSearch:h}=(Ne(),d(ve)),g=h(t,o.file_path,o.original_content,s);if(g.found&&g.score>=r$1){if(s&&g.score>=i&&!g.suggestedPath&&g.suggestedStart&&g.suggestedEnd){e.run("UPDATE anchors SET start_line = ?, end_line = ?, drifted = 0 WHERE id = ?",[g.suggestedStart,g.suggestedEnd,o.id]);try{e.run(`INSERT INTO anchor_history (anchor_id, action, old_start, old_end, new_start, new_end, confidence, healed_at)
|
|
89
|
+
VALUES (?, 'relocated', ?, ?, ?, ?, ?, ?)`,[o.id,o.start_line,o.end_line,g.suggestedStart,g.suggestedEnd,g.score,new Date().toISOString()]);}catch{}let E=A(e,"SELECT defined_in FROM aspects WHERE id = ?",[o.aspect_id]);E.length>0&&oe(t,E[0].defined_in,o.file_path,o.start_line,o.end_line,g.suggestedStart,g.suggestedEnd),c.push({aspectId:o.aspect_id,path:o.file_path,startLine:g.suggestedStart,endLine:g.suggestedEnd,status:"relocated",resolvedBy:"content-search",exists:!0,similarity:g.similarity,suggestedStart:g.suggestedStart,suggestedEnd:g.suggestedEnd,autoHealed:!0,drifted:!1});continue}c.push({aspectId:o.aspect_id,path:g.suggestedPath||o.file_path,startLine:o.start_line,endLine:o.end_line,status:"relocated",resolvedBy:"content-search",exists:!0,similarity:g.similarity,suggestedStart:g.suggestedStart,suggestedEnd:g.suggestedEnd,autoHealed:!1,drifted:!0});continue}}e.run("UPDATE anchors SET drifted = 1 WHERE id = ?",[o.id]),c.push({aspectId:o.aspect_id,path:o.file_path,startLine:o.start_line,endLine:o.end_line,status:"modified",resolvedBy:"none",exists:!0,currentContent:D,drifted:!0});}catch{c.push({aspectId:o.aspect_id,path:o.file_path,startLine:o.start_line,endLine:o.end_line,status:"modified",resolvedBy:"none",exists:true,drifted:true});}}return c}function Pe(e){let{lines:t}=e;return typeof t=="number"?{startLine:t,endLine:t}:Array.isArray(t)?t.length===2?{startLine:t[0],endLine:t[1]}:{startLine:Math.min(...t),endLine:Math.max(...t)}:{startLine:1,endLine:1}}function wt(e){let t=[],n=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/gm,s;for(;(s=n.exec(e))!==null;)t.push({oldStart:parseInt(s[1],10),oldCount:s[2]!==void 0?parseInt(s[2],10):1,newStart:parseInt(s[3],10),newCount:s[4]!==void 0?parseInt(s[4],10):1});return t}function bt(e,t,n,s,r){let i;try{i=execSync(`git diff ${n}..HEAD --unified=0 -- "${t}"`,{cwd:e,encoding:"utf8",timeout:5e3});}catch{return null}if(!i.trim())return {originalStart:s,originalEnd:r,currentStart:s,currentEnd:r};let a=wt(i),c=0;for(let o of a){if(o.oldStart+o.oldCount<=s){c+=o.newCount-o.oldCount;continue}if(o.oldStart<r)return null;break}return c===0?null:{originalStart:s,originalEnd:r,currentStart:s+c,currentEnd:r+c}}function oe(e,t,n,s,r,i,a){let c=T.isAbsolute(t)?t:T.join(e,t);if(!S.existsSync(c))return false;try{let o=S.readFileSync(c,"utf8"),u=s===r?`${n}:${s}`:`${n}:${s}-${r}`,l=i===a?`${n}:${i}`:`${n}:${i}-${a}`;if(!o.includes(u))return !1;let d=o.replace(u,l);return S.writeFileSync(c,d,"utf8"),!0}catch{return false}}function ie(e){return e.split(`
|
|
90
|
+
`).map(t=>t.trimEnd()).filter(t=>t.trim()!=="").map(t=>t.replace(/\s+/g," ")).join(`
|
|
91
|
+
`)}function Rt(e,t,n){return {exact:null,normalized:null,normalizedContent:null};}function _t(e,t){if(typeof e.category=="string")return e.category;let n=(t.description??"").toLowerCase();return /\b(must|require|always)\b/.test(n)?"rule":/\b(decided|chose)\b/.test(n)?"decision":/\b(limit|cannot)\b/.test(n)?"constraint":/\b(set to|configured|value)\b/.test(n)?"configuration":"rule"}function xt(e,t){if(typeof e.severity=="string")return e.severity;let n=t.tags??[];return n.includes("critical")?"critical":n.includes("security")||n.includes("compliance")?"high":"medium"}j$1();var Lt=/L-\d{4}-\d{2}-\d{2}-\d{3}/g;async function je(e,t){e.run("DELETE FROM lore_links");let n=await a$4(t);if(n.length===0)return 0;let s=It(n),r=new Map;for(let u of n)r.set(u.id,u);let i=new Set,a=e.exec("SELECT id, enforcement FROM aspects");if(a.length>0){let{columns:u,values:l}=a[0],d=u.indexOf("id"),p=u.indexOf("enforcement");for(let y of l){let m=String(y[d]),R=y[p];if(R&&typeof R=="string"){let v=R.match(Lt);if(v)for(let L of v)r.has(L)&&i.add(`${m}\0${L}`);}}}let c=e.exec("SELECT source, target FROM edges");if(c.length>0&&a.length>0){let u=At(e,c);for(let[l,d]of u)for(let p of d){let y=s.get(p);if(y)for(let m of y)i.add(`${l}\0${m}`);}}if(i.size===0)return 0;let o=e.prepare("INSERT OR IGNORE INTO lore_links (aspect_id, lore_id) VALUES (?, ?)");try{for(let u of i){let[l,d]=u.split("\0");o.bind([l,d]),o.step(),o.reset();}}finally{o.free();}return i.size}async function En(e,t,n){let s=e.exec("SELECT lore_id FROM lore_links WHERE aspect_id = ?",[n]);if(s.length===0||s[0].values.length===0)return [];let r=s[0].values.map(i=>String(i[0]));return Ct(t,r)}async function De(e,t){let n=await a$4(t);if(n.length===0)return 0;let s=e.exec("SELECT id FROM aspects"),r=new Set;if(s.length>0)for(let o of s[0].values)r.add(String(o[0]));if(r.size<2)return 0;let i=new Date().toISOString(),a=0,c=e.prepare(`INSERT OR IGNORE INTO edges (source, target, relation, weight, origin, created_at)
|
|
92
|
+
VALUES (?, ?, 'related-to', 0.3, 'learned', ?)`);try{for(let o of n){if(!o.symbols_touched||o.symbols_touched.length<2)continue;let u=[];for(let l of o.symbols_touched){let d=l.startsWith("~")?l.slice(1):l;r.has(d)&&u.push(d);}for(let l=0;l<u.length;l++)for(let d=l+1;d<u.length;d++){let[p,y]=u[l]<u[d]?[u[l],u[d]]:[u[d],u[l]];c.bind([p,y,i]),c.step(),c.reset(),a++;}}}finally{c.free();}return a}function It(e){let t=new Map;for(let n of e)if(n.symbols_touched)for(let s of n.symbols_touched){let r=t.get(s);r||(r=new Set,t.set(s,r)),r.add(n.id);}return t}function At(e,t){let n=e.exec("SELECT id FROM aspects"),s=new Set;if(n.length>0)for(let u of n[0].values)s.add(String(u[0]));let r=new Map;if(t.length===0)return r;let{columns:i,values:a}=t[0],c=i.indexOf("source"),o=i.indexOf("target");for(let u of a){let l=String(u[c]),d=String(u[o]);if(s.has(l)){let p=r.get(l);p||(p=new Set,r.set(l,p)),p.add(d),p.add(`~${l}`);}if(s.has(d)){let p=r.get(d);p||(p=new Set,r.set(d,p)),p.add(l),p.add(`~${d}`);}}return r}async function Ct(e,t){let n=new Set,s=[];for(let r of t){if(n.has(r))continue;n.add(r);let i=await b$2(e,r);i&&s.push(vt(i));}return s}function vt(e){return {id:e.id,title:e.title,summary:e.summary,timestamp:e.timestamp,symbolsTouched:e.symbols_touched}}var Nt="PARADIGM_STRICT";function K(){let e=process.env[Nt];if(e===void 0||e==="")return false;let t=e.toLowerCase();return t==="1"||t==="true"||t==="yes"||t==="on"}var Ue=new Set(["duplicate-key-detected"]);function Ot(e){let t=e.trim();if(t.includes("/")||t.includes("\\")){let n=t.split(/[/\\]/);t=n[n.length-1]||"unknown";}return t.length>40&&(t=t.slice(0,40)),t||"unknown"}var J=class{transforms=new Map;record(t,n,s=1){let r=Ot(n),i=`${t}::${r}`,a=this.transforms.get(i);a?a.count+=s:this.transforms.set(i,{kind:t,surface:r,count:s});}report(){let t=Array.from(this.transforms.values()).sort((s,r)=>s.kind!==r.kind?s.kind.localeCompare(r.kind):s.surface.localeCompare(r.surface)),n=t.filter(s=>Ue.has(s.kind)).reduce((s,r)=>s+r.count,0);return {reindex_ts:new Date().toISOString(),transformations:t,lossy_count:n,strict_mode:K()}}hasLossy(){for(let t of this.transforms.values())if(Ue.has(t.kind))return true;return false}totalCount(){let t=0;for(let n of this.transforms.values())t+=n.count;return t}};b$1();var Ft={"@":{category:"features",prefix:"@"},"#":{category:"components",prefix:"#"},"^":{category:"gates",prefix:"^"},$:{category:"flows",prefix:"$"},"&":{category:"integrations",prefix:"&"},"!":{category:"signals",prefix:"!"},"%":{category:"state",prefix:"%"}},kt={features:["src/features/","features/","app/","src/app/","src/modules/","modules/"],components:["src/components/","components/","src/lib/","lib/","src/ui/","ui/"],gates:["middleware/","src/middleware/","auth/","src/auth/","guards/","src/guards/"],flows:["flows/","src/flows/","workflows/","src/workflows/","sagas/","src/sagas/"],integrations:["integrations/","src/integrations/","external/","src/external/","vendors/"],signals:["events/","src/events/","handlers/","src/handlers/"],state:["stores/","src/stores/","state/","src/state/","reducers/","src/reducers/"]},Mt={config:[".paradigm/config.yaml","package.json","tsconfig.json",".env.example"],entry:["src/index.ts","src/index.tsx","src/main.ts","src/main.tsx","index.ts","main.ts","src/app.ts","src/app.tsx"],types:["src/types/","types/","src/types.ts","types.ts"]},ae={always:["node_modules/","dist/","build/",".git/",".next/",".nuxt/",".cache/","*.lock","*.log"],unless_testing:["**/*.test.ts","**/*.test.tsx","**/*.spec.ts","**/*.spec.tsx","__tests__/","test/","tests/"],unless_docs:["docs/","*.md","README*","CHANGELOG*"]};function Dn(){return [{name:"paradigm_reindex",description:"Rebuild scan-index.json, navigator.yaml, and flow-index.json from .purpose files. Call after modifying paradigm files or at the end of a work session to ensure static index files are fresh. Returns counts of indexed symbols, files processed, and any errors. ~150 tokens.",inputSchema:{type:"object",properties:{}},annotations:{readOnlyHint:false,destructiveHint:true},aliases:["rebuild","refresh","rescan","regenerate index","update index"]}]}async function Un(e,t,n,s){if(e!=="paradigm_reindex")return {handled:false,text:""};try{let r=await Pt(n.rootDir,n);await s(),a.clear(),be();let i=(r.integrityReport?.brokenReferences?.length||0)+(r.integrityReport?.duplicateSymbols?.length||0)+(r.componentAnchorIssues||0)+(r.crossFileIssues||0),a$1={success:!0,symbolCount:r.symbolCount,breakdown:r.breakdown,flowCount:r.flowCount,filesWritten:r.filesWritten.length,...r.aspectGraphStats?{aspects:r.aspectGraphStats.aspects,loreLinks:r.aspectGraphStats.loreLinks}:{},...r.protocolHealth?{protocols:r.protocolHealth.total,staleProtocols:r.protocolHealth.stale}:{},...i>0?{issues:i}:{}};r.consistency&&(a$1.consistency=r.consistency);let c=JSON.stringify(a$1,null,2);return O(c.length,e),{handled:!0,text:c}}catch(r){let i=JSON.stringify({error:r.message},null,2);return O(i.length,e),{handled:true,text:i}}}async function Pt(e,t){let n=[],s=new J,r;t?r=t.aggregation:r=await i(e);let i$1=t?.projectName||T.basename(e),a=T.join(e,".paradigm");S.existsSync(a)||S.mkdirSync(a,{recursive:true}),jt(e,s),Dt(r.purposeFiles,s);let c=ee({symbols:r.symbols,purposeFiles:r.purposeFiles,portalFiles:r.portalFiles},{projectName:i$1}),o=T.join(a,"scan-index.json");S.writeFileSync(o,te(c),"utf8"),n.push(".paradigm/scan-index.json");let u=Ut(e,r),l=T.join(a,"navigator.yaml");S.writeFileSync(l,C.dump(u,{indent:2,lineWidth:120,noRefs:true,sortKeys:false}),"utf8"),n.push(".paradigm/navigator.yaml");let d=Bt(e,r.purposeFiles),p=0;if(d&&Object.keys(d.flows).length>0){let f=T.join(a,"flow-index.json");S.writeFileSync(f,JSON.stringify(d,null,2),"utf8"),n.push(".paradigm/flow-index.json"),p=Object.keys(d.flows).length;}let y;try{let f=await Fe(e);Me(f,r.symbols,e);let E=await je(f,e),F=await De(f,e),k=f.exec("SELECT COUNT(*) FROM aspects")[0]?.values[0]?.[0]??0,z=f.exec("SELECT COUNT(*) FROM anchors")[0]?.values[0]?.[0]??0,B=f.exec("SELECT COUNT(*) FROM edges")[0]?.values[0]?.[0]??0;ke(f,e),n.push(".paradigm/aspect-graph.db"),y={aspects:k,anchors:z,edges:B,loreLinks:E};}catch{}let m=0;try{let f=await j$2(e);m=Object.keys(f.personas).length,m>0&&n.push(".paradigm/personas/index.yaml");}catch{}let R;try{let f=await M$1(e);f.health.total>0&&(R=f.health,n.push(".paradigm/protocols/index.yaml"));}catch{}let v;try{let f=T.join(e,".paradigm","university");if(S.existsSync(f)){let E=B(e);(E.totalContent>0||E.diplomaCount>0)&&(v={totalContent:E.totalContent,diplomaCount:E.diplomaCount},n.push(".paradigm/university/index.yaml"));}}catch{}let L;try{L=a$1(r,e);}catch{}let D;try{let f=b$3(r.symbols,e),E=f.missing+f.outOfBounds;E>0&&(D=E);}catch{}let U;try{U=c$1(r.purposeFiles,e);}catch{}let X;try{let f$1=[];for(let E of r.purposeFiles){let F=a$2(E);F.data&&f$1.push({filePath:E,data:F.data});}if(f$1.length>0){let F=f(f$1).issues.length;F>0&&(X=F);}}catch{}let H={};for(let f of r.symbols)H[f.type]=(H[f.type]||0)+1;let h={};for(let f of r.symbols)f.type==="component"&&f.componentType&&(h[f.componentType]=(h[f.componentType]||0)+1);let g=s.report();try{let f=T.join(a,"manifest.consistency.json");S.writeFileSync(f,JSON.stringify(g,null,2),"utf-8"),n.push(".paradigm/manifest.consistency.json");}catch{a$3.component("#reindex").warn("failed to write consistency manifest",{stage:"manifest-write"});}if(K()&&s.hasLossy())throw new Error(`reindex aborted: ${g.lossy_count} lossy transformation(s) detected under PARADIGM_STRICT=1. See .paradigm/manifest.consistency.json.`);return {action:"reindex",filesWritten:n,symbolCount:r.symbols.length,breakdown:H,flowCount:p,aspectGraphStats:y,personaCount:m,protocolHealth:R,consistency:g,...Object.keys(h).length>0?{componentTypeBreakdown:h}:{},...v?{universityStats:v}:{},...L?{integrityReport:L}:{},...D!==void 0?{componentAnchorIssues:D}:{},...U?{purposeHealth:U}:{},...X!==void 0?{crossFileIssues:X}:{}}}function jt(e,t){let n=T.join(e,"portal.yaml");if(!S.existsSync(n))return;let s;try{s=S.readFileSync(n,"utf-8");}catch{return}try{C.load(s);}catch(o){(o?.reason?.toLowerCase()||"").includes("duplicate")&&t.record("duplicate-key-detected","portal.yaml");return}let r;try{r=C.load(s,{schema:C.FAILSAFE_SCHEMA});}catch{return}if(!r||typeof r!="object")return;let i=r,a=i.gates;if(a&&typeof a=="object"&&!Array.isArray(a)){let o=0;for(let u of Object.keys(a))u.startsWith("^")&&o++;o>0&&t.record("prefix-stripped","portal.yaml",o);}else Array.isArray(a)&&a.length>0&&t.record("array-coerced","portal.yaml");let c=i.routes;Array.isArray(c)&&c.length>0&&t.record("array-coerced","portal.yaml"),i.version||t.record("default-applied","portal.yaml");}function Dt(e,t){for(let n of e){let s;try{s=S.readFileSync(n,"utf-8");}catch{continue}try{C.load(s);}catch(l){(l?.reason?.toLowerCase()||"").includes("duplicate")&&t.record("duplicate-key-detected","purpose.yaml");continue}let r;try{r=C.load(s,{schema:C.FAILSAFE_SCHEMA});}catch{continue}if(!r||typeof r!="object")continue;let i=r,a=["components","features","gates","signals","aspects","states"],c=0;for(let l of a)Array.isArray(i[l])&&c++;c>0&&t.record("array-coerced","purpose.yaml",c);let o=(l,d)=>{if(!l||typeof l!="object"||Array.isArray(l))return 0;let p=0;for(let y of Object.keys(l))y.startsWith(d)&&p++;return p},u=o(i.gates,"^")+o(i.signals,"!")+o(i.aspects,"~")+o(i.components,"#")+o(i.features,"#");u>0&&t.record("prefix-stripped","purpose.yaml",u);}}function Ut(e,t){let n={};for(let s of t.symbols)if(s.type==="component"&&s.componentType){let r=s.componentType;n[r]||(n[r]=[]),n[r].push(s.symbol);}return {version:"1.0",generated:new Date().toISOString(),structure:Ht(e),key_files:Wt(e),skip_patterns:Xt(e),symbols:$t(t.symbols,t.purposeFiles),...Object.keys(n).length>0?{symbolsByComponentType:n}:{}}}function Ht(e){let t={};for(let[n,s]of Object.entries(kt)){let r=s.filter(i=>S.existsSync(T.join(e,i)));if(r.length>0){let i=Object.values(Ft).find(a=>a.category===n);t[n]={paths:r,symbol:i?.prefix||"@"};}}return t}function Wt(e){let t={};for(let[n,s]of Object.entries(Mt)){let r=s.filter(i=>S.existsSync(T.join(e,i)));r.length>0&&(t[n]=r);}return t.config||(t.config=[]),t.entry||(t.entry=[]),t.types||(t.types=[]),t}function Xt(e){let t={always:[...ae.always],unless_testing:[...ae.unless_testing],unless_docs:[...ae.unless_docs]},n=T.join(e,".gitignore");if(S.existsSync(n))try{let r=S.readFileSync(n,"utf8").split(`
|
|
93
|
+
`).map(i=>i.trim()).filter(i=>i&&!i.startsWith("#")).filter(i=>i.endsWith("/")||i.includes("*")||["node_modules","dist","build",".cache"].some(a=>i.includes(a))).slice(0,20);for(let i of r)t.always.includes(i)||t.always.push(i);}catch{}return t}function zt(e){switch(e){case "feature":return "@";case "component":return "#";case "gate":return "^";case "flow":return "$";case "integration":return "&";case "signal":return "!";case "state":return "%";case "idea":return "?";case "deprecated":return "~";case "aspect":return "~";default:return "@"}}function $t(e,t,n){let s={};for(let r of e){let a=`${zt(r.type)}${r.id}`;if(r.filePath)s[a]=r.filePath;else {let c=t.find(o=>T.dirname(o).toLowerCase().includes(r.id.toLowerCase()));c&&(s[a]=T.dirname(c)+"/");}}return s}function Bt(e,t){let n={},s={};for(let r of t)try{let i=S.readFileSync(r,"utf8"),a=C.load(i);if(!a?.flows)continue;if(Array.isArray(a.flows))for(let c of a.flows){let o=c;if(!o.name)continue;let u=`$${o.name}`,l=He(o.steps);l.length>0&&(n[u]={id:u,description:o.description||"",steps:l,definedIn:T.relative(e,r)},We(u,l,s));}else for(let[c,o]of Object.entries(a.flows)){let u=c.startsWith("$")?c:`$${c}`,l=He(o.steps);l.length>0&&(n[u]={id:u,description:o.description||"",trigger:o.trigger,steps:l,validation:o.validation,definedIn:T.relative(e,r)},We(u,l,s));}}catch{}return Object.keys(n).length===0?null:{version:"1.0",generatedAt:new Date().toISOString(),flows:n,symbolToFlows:s}}function He(e){if(!e||!Array.isArray(e))return [];let t=[];for(let n=0;n<e.length;n++){let s=e[n];if(typeof s=="object"&&s!==null){let r=s,i=r.action||r.description||r.component||"";i&&t.push({id:r.id||`step-${n+1}`,action:i,symbol:r.symbol||r.component,expect:r.expect});}}return t}function We(e,t,n){for(let s of t)s.symbol&&(n[s.symbol]||(n[s.symbol]=[]),n[s.symbol].includes(e)||n[s.symbol].push(e));}export{we as a,K as b,Fe as c,ke as d,cn as e,ln as f,un as g,dn as h,pn as i,fn as j,gn as k,hn as l,En as m,Dn as n,Un as o,Pt as p};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {b}from'./chunk-
|
|
2
|
+
import {b}from'./chunk-EG22HDXI.js';import {e,f,c,d,l,h,g,k,i,m as m$1,o,n,j,b as b$1,a as a$1}from'./chunk-YXLGVOZO.js';import {a}from'./chunk-Y4XFVDZC.js';import*as $ from'fs';import*as m from'path';import e$1 from'chalk';import E from'prompts';function F(){return process.env.CLAUDE_CODE==="1"||process.env.TERM_PROGRAM==="claude"?false:!!(process.env.TERM_PROGRAM==="cursor"||process.env.CURSOR_SESSION||process.env.CURSOR_TRACE_ID||process.env.VSCODE_CWD&&process.env.VSCODE_CWD.toLowerCase().includes("cursor")||process.env.VSCODE_NLS_CONFIG&&process.env.VSCODE_NLS_CONFIG.toLowerCase().includes("cursor")||process.env.TERM_PROGRAM==="vscode"&&process.env.VSCODE_GIT_ASKPASS_NODE?.toLowerCase().includes("cursor")||process.stdin.isTTY)}async function T(g){let n=new a(g),c=await n.discover();console.log(e$1.cyan(`
|
|
3
3
|
Configure Agent Models
|
|
4
4
|
`)),console.log(e$1.gray(` Environment: ${c.source}`)),console.log(e$1.gray(` Available: ${c.models.length} models
|
|
5
5
|
`));let i={},o=n.groupByTier(c.models),a$2=t=>{let r=a$1[t],s=r.tier==="high"?o.high:r.tier==="medium"?o.medium:o.low,l=[];for(let f of s){let P=l.length===0;l.push({title:P?`${f.name} (recommended)`:f.name,value:f.id,description:`${f.provider} - ${r.tier} tier`});}let u=o.high.filter(f=>!s.includes(f)),y=o.medium.filter(f=>!s.includes(f)),v=o.low.filter(f=>!s.includes(f));for(let f of u)l.push({title:f.name,value:f.id,description:`${f.provider} - high tier`});for(let f of y)l.push({title:f.name,value:f.id,description:`${f.provider} - medium tier`});for(let f of v)l.push({title:f.name,value:f.id,description:`${f.provider} - low tier`});return l};for(let t of ["architect","builder","tester","reviewer","security"]){let r=a$1[t],s=t.charAt(0).toUpperCase()+t.slice(1),l=a$2(t),u=await E({type:"select",name:"model",message:`${s} (${r.description})`,choices:l,initial:0},{onCancel:()=>{console.log(e$1.yellow(`
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {a}from'./chunk-MBPLJKE5.js';import*as r from'fs';import*as o from'path';import*as f from'js-yaml';var m=".paradigm/tasks",T="entries",R="index.yaml";function k(e){if(e&&e.session_link&&!e.external_ref){let t=e.session_link,n=t.toLowerCase(),s;n.includes("github")?s="github":n.includes("session")?s="session":s="url",e.external_ref={kind:s,ref:t},delete e.session_link;}return e}function F(e,t){let n=o.join(e,m,T,t);if(!r.existsSync(n))return `T-${t}-001`;let s=r.readdirSync(n).filter(i=>i.startsWith("T-")&&i.endsWith(".yaml")).map(i=>{let l=i.match(/T-\d{4}-\d{2}-\d{2}-(\d+)\.yaml/);return l?parseInt(l[1],10):0}),a=s.length>0?Math.max(...s)+1:1;return `T-${t}-${String(a).padStart(3,"0")}`}function j(e,t){return e===t?true:({open:["in-progress","done","shelved"],"in-progress":["done","open","shelved"],shelved:["open"],done:[]}[e]??[]).includes(t)}var _={high:0,medium:1,low:2},O=["open","in-progress"];function E(e,t){return t==="all"?true:t==="active"?O.includes(e.status):e.status===t}function b(e){let t=e.created?new Date(e.created).getTime():NaN;if(!Number.isNaN(t))return t;let n=e.id?.match(/^T-(\d{4}-\d{2}-\d{2})-/);if(n){let s=new Date(n[1]).getTime();if(!Number.isNaN(s))return s}return 0}function N(e,t){let n=e;return t.status&&t.status!=="all"&&(n=n.filter(s=>E(s,t.status))),t.priority&&(n=n.filter(s=>s.priority===t.priority)),t.tag&&(n=n.filter(s=>s.tags.includes(t.tag))),n.sort((s,a)=>{let i=(_[s.priority]??1)-(_[a.priority]??1);return i!==0?i:b(a)-b(s)}),t.limit&&(n=n.slice(0,t.limit)),n}async function C(e,t){let n=o.join(e,m,T);if(!r.existsSync(n))return [];let s={status:"open",limit:20,...t},a=[],i=r.readdirSync(n).filter(l=>/^\d{4}-\d{2}-\d{2}$/.test(l)).sort().reverse();for(let l of i){let g=o.join(n,l),d=r.readdirSync(g).filter(c=>c.endsWith(".yaml")).sort();for(let c of d)try{let u=r.readFileSync(o.join(g,c),"utf8"),h=k(f.load(u));a.push(h);}catch{}}return N(a,s)}async function D(e,t){let n=t.match(/^T-(\d{4}-\d{2}-\d{2})-/);if(n){let a=o.join(e,m,T,n[1],`${t}.yaml`);if(r.existsSync(a))try{return k(f.load(r.readFileSync(a,"utf8")))}catch{return null}}return (await C(e,{status:"all",limit:9999})).find(a=>a.id===t)||null}async function K(e,t){let n=new Date,s=n.toISOString().slice(0,10),a=o.join(e,m,T,s);r.mkdirSync(a,{recursive:true});let i=F(e,s),l={id:i,blurb:t.blurb,priority:t.priority||"medium",status:"open",tags:t.tags||[],created:n.toISOString(),related_lore:t.related_lore,claimant:t.claimant,parentTaskId:t.parentTaskId,dependsOn:t.dependsOn,stage:t.stage,external_ref:t.external_ref,session_link:t.session_link};return k(l),r.writeFileSync(o.join(a,`${i}.yaml`),f.dump(w(l),{lineWidth:-1,noRefs:true})),await v(e),i}async function I(e,t,n){let s=await D(e,t);if(!s)return false;let a$1=s.created.slice(0,10),i=o.join(e,m,T,a$1,`${t}.yaml`);if(!r.existsSync(i))return false;let{id:l,created:g,...d}=n;if(d.status!==void 0&&d.status!==s.status){if(!j(s.status,d.status))return a.component("#task-loader").warn("Illegal task status transition rejected",{taskId:t,from:s.status,to:d.status}),false;d.status==="in-progress"&&!s.started_at&&d.started_at===void 0&&(d.started_at=new Date().toISOString());}let c={...s,...d};if(r.writeFileSync(i,f.dump(w(c),{lineWidth:-1,noRefs:true})),await v(e),$(c.status)&&c.parentTaskId)try{let{settleParentIfComplete:u}=await import('./task-settlement-XC6E6JNT.js');await u(e,c.parentTaskId,c.id);}catch(u){a.component("#task-loader").warn("Settlement after updateTask failed (non-fatal)",{taskId:t,parentTaskId:c.parentTaskId,error:u instanceof Error?u.message:String(u)});}return true}function $(e){return e==="done"||e==="shelved"}async function A(e,t){return I(e,t,{status:"done",completed:new Date().toISOString()})}async function L(e,t){return I(e,t,{status:"shelved",shelved:new Date().toISOString()})}async function v(e){let t=o.join(e,m,T),n=o.join(e,m),s=0,a=0,i=0,l=0,g=0,d=[];if(r.existsSync(t)){let u=r.readdirSync(t).filter(h=>/^\d{4}-\d{2}-\d{2}$/.test(h));for(let h of u){let x=o.join(t,h),P=r.readdirSync(x).filter(y=>y.endsWith(".yaml"));for(let y of P)try{let p=k(f.load(r.readFileSync(o.join(x,y),"utf8")));s++,p.status==="open"?a++:p.status==="in-progress"?i++:p.status==="done"?l++:p.status==="shelved"&&g++,!p.parentTaskId&&p.id&&d.push(p.id);}catch{}}}let c={version:"1.1",total:s,open:a,in_progress:i,done:l,shelved:g,roots:d,last_updated:new Date().toISOString()};return r.mkdirSync(n,{recursive:true}),r.writeFileSync(o.join(n,R),f.dump(c,{lineWidth:-1,noRefs:true})),c}function w(e){let t={};for(let[n,s]of Object.entries(e))s!==void 0&&(t[n]=s);return t}export{k as a,j as b,C as c,D as d,K as e,I as f,A as g,L as h,v as i};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import*as e from'fs';import*as o from'path';var y=".paradigm/events/session-log.jsonl",d=".paradigm/events/session-metrics.jsonl",p=".paradigm/events/verdicts.jsonl",g=".paradigm/events/iteration-revisions.jsonl",b=200,m=".paradigm/events/notebook-refs.jsonl";function I(i,n){try{let t=o.join(i,y),r=o.dirname(t);if(e.existsSync(r)||e.mkdirSync(r,{recursive:!0}),e.existsSync(t)&&e.readFileSync(t,"utf8").trim().split(`
|
|
3
|
+
`).filter(c=>c.trim()).length>=b)return;let f=JSON.stringify(n)+`
|
|
4
|
+
`;e.appendFileSync(t,f,"utf8"),n.type==="user-verdict"&&n.agent&&n.symbols?.length&&import('./agent-loader-Z753DQWH.js').then(({loadAgentProfile:a,saveAgentProfile:s})=>{try{let c=a(i,n.agent);if(c?.expertise){let l=n.verdict==="accepted"?.03:n.verdict==="dismissed"?-.02:n.verdict==="revised"?-.01:0;if(l!==0){for(let h of n.symbols){let u=c.expertise.find(v=>v.symbol===h);u&&(u.confidence=Math.max(0,Math.min(1,u.confidence+l)),u.sessions=(u.sessions||0)+1,u.lastTouch=new Date().toISOString());}s(n.agent,c,"global");}}}catch{}}).catch(()=>{});}catch{}}function S(i){try{let n=o.join(i,y);return e.existsSync(n)?e.readFileSync(n,"utf8").trim().split(`
|
|
5
|
+
`).filter(t=>t.trim()).map(t=>{try{return JSON.parse(t)}catch{return null}}).filter(t=>t!==null):[]}catch{return []}}function N(i){try{let n=o.join(i,y);e.existsSync(n)&&e.writeFileSync(n,"","utf8");}catch{}}function C(i,n){try{let t=o.join(i,p),r=o.dirname(t);e.existsSync(r)||e.mkdirSync(r,{recursive:!0}),e.appendFileSync(t,JSON.stringify(n)+`
|
|
6
|
+
`,"utf8");}catch{}}function O(i){try{let n=o.join(i,p);return e.existsSync(n)?e.readFileSync(n,"utf8").trim().split(`
|
|
7
|
+
`).filter(t=>t.trim()).map(t=>{try{return JSON.parse(t)}catch{return null}}).filter(t=>t!==null&&!t.consumed):[]}catch{return []}}function R(i,n){try{let t=o.join(i,p);if(!e.existsSync(t))return;let r=new Set(n),a=e.readFileSync(t,"utf8").trim().split(`
|
|
8
|
+
`).filter(s=>s.trim()).map(s=>{try{let c=JSON.parse(s);return c.nominationId&&r.has(c.nominationId)?JSON.stringify({...c,consumed:!0}):s}catch{return s}});e.writeFileSync(t,a.join(`
|
|
9
|
+
`)+`
|
|
10
|
+
`,"utf8");}catch{}}function P(i){try{let n=o.join(i,g);return e.existsSync(n)?e.readFileSync(n,"utf8").trim().split(`
|
|
11
|
+
`).filter(t=>t.trim()).map(t=>{try{return JSON.parse(t)}catch{return null}}).filter(t=>t!==null&&t.type==="iteration-revision"&&!t.consumed):[]}catch{return []}}function F(i,n){try{let t=o.join(i,g);if(!e.existsSync(t))return;let r=new Set(n),a=e.readFileSync(t,"utf8").trim().split(`
|
|
12
|
+
`).filter(s=>s.trim()).map(s=>{try{let c=JSON.parse(s);return c.id&&r.has(c.id)?JSON.stringify({...c,consumed:!0}):s}catch{return s}});e.writeFileSync(t,a.join(`
|
|
13
|
+
`)+`
|
|
14
|
+
`,"utf8");}catch{}}function A(i){let n=S(i),t=new Set;for(let r of n)r.agent&&t.add(r.agent);return Array.from(t)}function k(i,n){return S(i).filter(t=>t.agent===n)}function M(i,n){let t=k(i,n),r=t.filter(s=>s.type==="agent-contribution"),f=t.filter(s=>s.type==="user-verdict"),a=[];for(let s of r)a.push({contribution:s});for(let s of f){let c=a.find(l=>!l.verdict&&l.contribution);c?c.verdict=s:a.push({verdict:s});}return a}function j(i,n){try{let t=o.join(i,d),r=o.dirname(t);e.existsSync(r)||e.mkdirSync(r,{recursive:!0});let f={timestamp:new Date().toISOString(),type:"activity",...n},a=JSON.stringify(f)+`
|
|
15
|
+
`;e.appendFileSync(t,a,"utf8");}catch{}}function E(i){try{let n=o.join(i,d);return e.existsSync(n)?e.readFileSync(n,"utf8").trim().split(`
|
|
16
|
+
`).filter(t=>t.trim()).map(t=>{try{return JSON.parse(t)}catch{return null}}).filter(t=>t!==null&&t.type==="activity"):[]}catch{return []}}function w(i){let n=E(i),t={toolCallCount:0,responsePayloadBytes:0,sessionDurationMs:0,agentBreakdown:{}};for(let r of n)if(r.toolCallCount!=null&&(t.toolCallCount+=r.toolCallCount),r.responsePayloadBytes!=null&&(t.responsePayloadBytes+=r.responsePayloadBytes),r.sessionDurationMs!=null&&(t.sessionDurationMs=Math.max(t.sessionDurationMs,r.sessionDurationMs)),r.agentId){t.agentBreakdown[r.agentId]||(t.agentBreakdown[r.agentId]={toolCalls:0,payloadBytes:0});let f=t.agentBreakdown[r.agentId];r.toolCallCount!=null&&(f.toolCalls+=r.toolCallCount),r.responsePayloadBytes!=null&&(f.payloadBytes+=r.responsePayloadBytes);}return t}function B(i){try{let n=o.join(i,d);e.existsSync(n)&&e.writeFileSync(n,"","utf8");}catch{}}function W(i,n,t,r){try{if(t.length===0)return;let f=o.join(i,m),a=o.dirname(f);e.existsSync(a)||e.mkdirSync(a,{recursive:!0});let s={timestamp:new Date().toISOString(),type:"notebook-reference",agentId:n,notebookEntryIds:t,...r?{orchestrationId:r}:{}},c=JSON.stringify(s)+`
|
|
17
|
+
`;e.appendFileSync(f,c,"utf8");}catch{}}function x(i){try{let n=o.join(i,m);return e.existsSync(n)?e.readFileSync(n,"utf8").trim().split(`
|
|
18
|
+
`).filter(t=>t.trim()).map(t=>{try{return JSON.parse(t)}catch{return null}}).filter(t=>t!==null&&t.type==="notebook-reference"):[]}catch{return []}}function J(i){return x(i).length}export{I as a,S as b,N as c,C as d,O as e,R as f,P as g,F as h,A as i,k as j,M as k,j as l,w as m,B as n,W as o,x as p,J as q};
|