@a-company/paradigm 5.37.4 → 5.37.7
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/ambient-76YMUA5Q.js +2 -0
- package/dist/ambient-WTLYUAQM.js +35 -0
- package/dist/{chunk-FILLU77P.js → chunk-3TR6LLXP.js} +2 -2
- package/dist/{chunk-WN74JUZA.js → chunk-3VF3CMCF.js} +40 -40
- package/dist/{chunk-22ISTMKI.js → chunk-46ZCEIF6.js} +1 -1
- package/dist/chunk-AGFPVSX5.js +14 -0
- package/dist/{chunk-4Q7XYPL4.js → chunk-BOYQAMGC.js} +3 -3
- package/dist/{chunk-D6ZXAI26.js → chunk-CHVQNRRT.js} +60 -20
- package/dist/{chunk-JOHAOLEC.js → chunk-G7XFK2GI.js} +4 -4
- package/dist/chunk-MQIG6SMF.js +3 -0
- package/dist/chunk-NEJ4ZLCY.js +14 -0
- package/dist/chunk-RLCH7DXQ.js +4 -0
- package/dist/{chunk-SXO7NC6A.js → chunk-SI6SV76D.js} +108 -23
- package/dist/{compliance-BPGQMQAX.js → compliance-WJINB5DM.js} +1 -1
- package/dist/doctor-QJ47XAUP.js +2 -0
- package/dist/{hooks-BNWRGACA.js → hooks-IG2GOAHP.js} +1 -1
- package/dist/index.js +4 -4
- package/dist/{init-EHVSM7YY.js → init-HIBRSVUB.js} +1 -1
- package/dist/mcp.js +1 -1
- package/dist/{migrate-YQG2FG3J.js → migrate-IBDE7VK4.js} +1 -1
- package/dist/{nomination-engine-KNSOAT4W.js → nomination-engine-EALA5MGI.js} +1 -1
- package/dist/notebook-loader-PXNRBBXD.js +2 -0
- package/dist/{promote-NJQDZBZA.js → promote-KU2ECEXX.js} +1 -1
- package/dist/reindex-FO5VMZVQ.js +2 -0
- package/dist/session-tracker-MWJAJA6Z.js +2 -0
- package/dist/session-work-log-PAKXOFGL.js +2 -0
- package/dist/session-work-log-ZP45TREI.js +2 -0
- package/dist/{setup-KPIMRZ4Q.js → setup-6SRJHDA7.js} +1 -1
- package/dist/{shift-RRNL6E4O.js → shift-CZMQWZWP.js} +2 -2
- package/dist/{switch-CTW4PDGI.js → switch-RXEXXIN7.js} +1 -1
- package/dist/tools-BZUAEUSQ.js +2 -0
- package/package.json +1 -1
- package/dist/ambient-GJAEXF7B.js +0 -35
- package/dist/chunk-4SCKMGTB.js +0 -9
- package/dist/chunk-UNHTQLYO.js +0 -9
- package/dist/chunk-UPFCBVXY.js +0 -3
- package/dist/chunk-VG7FN2TU.js +0 -4
- package/dist/doctor-G37LCXG5.js +0 -2
- package/dist/notebook-loader-CENTDDUJ.js +0 -2
- package/dist/reindex-O3WUCEE2.js +0 -2
- package/dist/session-tracker-D2CH7RJF.js +0 -2
- package/dist/session-work-log-BX434ZLK.js +0 -2
- package/dist/session-work-log-NQA7WJEC.js +0 -2
- package/dist/tools-ZHOHGFXD.js +0 -2
|
@@ -12,7 +12,7 @@ ${s}
|
|
|
12
12
|
`));return}let p=[];if(n.client)if(n.client==="all")p=c;else {let o=g.find(f=>f.id===n.client);if(!o){console.log(e.red(`Unknown client: ${n.client}`)),console.log(e.gray(`Available: ${g.map(f=>f.id).join(", ")}
|
|
13
13
|
`));return}o.detected||(console.log(e.yellow(`${o.name} not detected on this system.`)),console.log(e.gray(`Proceeding anyway...
|
|
14
14
|
`))),p=[o];}else if(c.length===1)p=c;else {console.log(e.cyan(`Multiple clients detected. Specify which to configure:
|
|
15
|
-
`)),console.log(e.white(" paradigm mcp setup --client=cursor")),console.log(e.white(" paradigm mcp setup --client=claude-desktop")),console.log(e.white(" paradigm mcp setup --client=all")),console.log();return}for(let o of p){t.start(`Configuring ${o.name}...`);let f=a$1.operation(`mcp-setup-${o.id}`).start("Configuring MCP",{client:o.id}),u=R(o,s,r),d=O(o,u,n.force||false);d.success?(t.succeed(`${o.name} configured`),f.success("MCP configured",{client:o.id,path:o.configPath}),console.log(e.gray(` \u2192 ${o.configPath}`)),o.configType==="project"&&n.gitignore!==false&&F(o.configPath)&&(console.log(e.gray(" \u2192 Added to .gitignore")),a$1.component("gitignore").debug("Added MCP config to .gitignore",{path:o.configPath}))):(t.fail(`Failed to configure ${o.name}: ${d.message}`),f.error("MCP configuration failed",{client:o.id,message:d.message}));}if(console.log(e.green(`
|
|
15
|
+
`)),console.log(e.white(" paradigm mcp setup --client=cursor")),console.log(e.white(" paradigm mcp setup --client=claude-desktop")),console.log(e.white(" paradigm mcp setup --client=all")),console.log();return}for(let o of p){t.start(`Configuring ${o.name}...`);let f=a$1.operation(`mcp-setup-${o.id}`).start("Configuring MCP",{client:o.id}),u=R(o,s,r),d=O(o,u,n.force||false);d.success?(t.succeed(`${o.name} configured`),f.success("MCP configured",{client:o.id,path:o.configPath}),console.log(e.gray(` \u2192 ${o.configPath}`)),o.configType==="project"&&n.gitignore!==false&&F(o.configPath)&&(console.log(e.gray(" \u2192 Added to .gitignore")),a$1.component("gitignore").debug("Added MCP config to .gitignore",{path:o.configPath}))):(t.fail(`Failed to configure ${o.name}: ${d.message}`),console.log(e.gray(" Troubleshooting: .paradigm/docs/troubleshooting.md")),f.error("MCP configuration failed",{client:o.id,message:d.message}));}if(console.log(e.green(`
|
|
16
16
|
\u2713 MCP setup complete!
|
|
17
17
|
`)),console.log(e.cyan("Next steps:")),[...new Set(p.map(o=>o.instructions))].forEach(o=>{console.log(e.gray(` \u2022 ${o}`));}),console.log(e.gray(`
|
|
18
18
|
Then try asking your AI:`)),console.log(e.white(` "What features are in the ${r} project?"`)),console.log(e.white(' "What would break if I changed @feature-name?"')),console.log(),n.json){let o={project:r,path:s,configured:p.map(f=>({client:f.id,name:f.name,configPath:f.configPath,configType:f.configType}))};console.log(JSON.stringify(o,null,2));}}async function z(n){console.log(e.blue(`
|
|
@@ -0,0 +1,14 @@
|
|
|
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",v=200,g=".paradigm/events/notebook-refs.jsonl";function x(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(a=>a.trim()).length>=v)return;let f=JSON.stringify(n)+`
|
|
4
|
+
`;e.appendFileSync(t,f,"utf8"),n.type==="user-verdict"&&n.agent&&n.symbols?.length&&import('./agent-loader-RIVI6QPP.js').then(({loadAgentProfile:c,saveAgentProfile:s})=>{try{let a=c(i,n.agent);if(a?.expertise){let u=n.verdict==="accepted"?.03:n.verdict==="dismissed"?-.02:n.verdict==="revised"?-.01:0;if(u!==0){for(let S of n.symbols){let l=a.expertise.find(h=>h.symbol===S);l&&(l.confidence=Math.max(0,Math.min(1,l.confidence+u)),l.sessions=(l.sessions||0)+1,l.lastTouch=new Date().toISOString());}s(n.agent,a,"global");}}}catch{}}).catch(()=>{});}catch{}}function m(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 C(i){try{let n=o.join(i,y);e.existsSync(n)&&e.writeFileSync(n,"","utf8");}catch{}}function I(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 N(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 M(i,n){try{let t=o.join(i,p);if(!e.existsSync(t))return;let r=new Set(n),c=e.readFileSync(t,"utf8").trim().split(`
|
|
8
|
+
`).filter(s=>s.trim()).map(s=>{try{let a=JSON.parse(s);return a.nominationId&&r.has(a.nominationId)?JSON.stringify({...a,consumed:!0}):s}catch{return s}});e.writeFileSync(t,c.join(`
|
|
9
|
+
`)+`
|
|
10
|
+
`,"utf8");}catch{}}function O(i){let n=m(i),t=new Set;for(let r of n)r.agent&&t.add(r.agent);return Array.from(t)}function k(i,n){return m(i).filter(t=>t.agent===n)}function A(i,n){let t=k(i,n),r=t.filter(s=>s.type==="agent-contribution"),f=t.filter(s=>s.type==="user-verdict"),c=[];for(let s of r)c.push({contribution:s});for(let s of f){let a=c.find(u=>!u.verdict&&u.contribution);a?a.verdict=s:c.push({verdict:s});}return c}function P(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},c=JSON.stringify(f)+`
|
|
11
|
+
`;e.appendFileSync(t,c,"utf8");}catch{}}function b(i){try{let n=o.join(i,d);return e.existsSync(n)?e.readFileSync(n,"utf8").trim().split(`
|
|
12
|
+
`).filter(t=>t.trim()).map(t=>{try{return JSON.parse(t)}catch{return null}}).filter(t=>t!==null&&t.type==="activity"):[]}catch{return []}}function F(i){let n=b(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,g),c=o.dirname(f);e.existsSync(c)||e.mkdirSync(c,{recursive:!0});let s={timestamp:new Date().toISOString(),type:"notebook-reference",agentId:n,notebookEntryIds:t,...r?{orchestrationId:r}:{}},a=JSON.stringify(s)+`
|
|
13
|
+
`;e.appendFileSync(f,a,"utf8");}catch{}}function E(i){try{let n=o.join(i,g);return e.existsSync(n)?e.readFileSync(n,"utf8").trim().split(`
|
|
14
|
+
`).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 E(i).length}export{x as a,m as b,C as c,I as d,N as e,M as f,O as g,k as h,A as i,P as j,F as k,B as l,W as m,E as n,j as o};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {c,b as b$1}from'./chunk-3KVVC4WV.js';import {z as z$1,i,c as c$1,f,j}from'./chunk-74SGKSRQ.js';import {g as g$1,f as f$1}from'./chunk-QGZRM6ZB.js';import {g as g$2
|
|
2
|
+
import {c,b as b$1}from'./chunk-3KVVC4WV.js';import {z as z$1,i,c as c$1,f,j}from'./chunk-74SGKSRQ.js';import {g as g$1,f as f$1}from'./chunk-QGZRM6ZB.js';import {h,g as g$2}from'./chunk-RLCH7DXQ.js';import {b,a,d as d$1}from'./chunk-5TAVYPOV.js';import*as d from'fs';import*as g from'path';import*as W from'js-yaml';import*as T from'os';function Y(e){return g.join(e,G,at)}function ct(){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:ct(),timestamp:new Date().toISOString(),...t};_.push(n),_.length>v&&(_=_.slice(-v));try{let r=g.join(e,G);d.mkdirSync(r,{recursive:!0});let o=Y(e);d.appendFileSync(o,JSON.stringify(n)+`
|
|
3
3
|
`,"utf8"),lt(o);}catch{}return n}function lt(e){try{if(d.statSync(e).size>512*1024){let r=d.readFileSync(e,"utf8").trim().split(`
|
|
4
4
|
`);if(r.length>v){let o=r.slice(-v);d.writeFileSync(e,o.join(`
|
|
5
5
|
`)+`
|
|
6
6
|
`,"utf8");}}}catch{}}function $t(e,t){let n=ft(e);return t?.type&&(n=n.filter(r=>r.type===t.type)),t?.source&&(n=n.filter(r=>r.source===t.source)),t?.symbol&&(n=n.filter(r=>r.symbols?.includes(t.symbol))),t?.agent&&(n=n.filter(r=>r.agent===t.agent)),t?.since&&(n=n.filter(r=>r.timestamp>=t.since)),n.sort((r,o)=>o.timestamp.localeCompare(r.timestamp)),t?.limit&&(n=n.slice(0,t.limit)),n}function ft(e){let t=Y(e);if(!d.existsSync(t))return [..._];try{return d.readFileSync(t,"utf8").trim().split(`
|
|
7
|
-
`).filter(o=>o.trim()).map(o=>{try{return JSON.parse(o)}catch{return null}}).filter(o=>o!==null)}catch{return [..._]}}function H(e,t,n){let r=0,o=0,i=0,a=0;if(n.symbols?.length&&e.symbols?.length)for(let l of n.symbols)for(let s of e.symbols)B(l,s)&&(r=Math.max(r,1));if(n.paths?.length&&e.path){for(let l of n.paths)if(B(l,e.path)){o=1;break}}if(n.concepts?.length){let l=[e.context||"",...e.keywords||[],e.type].join(" ").toLowerCase(),s=0;for(let m of n.concepts)l.includes(m.toLowerCase())&&s++;n.concepts.length>0&&(i=s/n.concepts.length);}if(n.signals?.length){for(let l of n.signals)if(l.type===e.type){a=1;break}}let u=[r,o,i,a].sort((l,s)=>s-l),c=u[0]*.5+u[1]*.2+u[2]*.15+u[3]*.15,f=n.threshold??.6;return {agentId:t,score:c,breakdown:{symbolMatch:r,pathMatch:o,conceptMatch:i,signalMatch:a},shouldNominate:c>=f,quietReason:c<f?"below-threshold":void 0}}function B(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 G,at,v,_,z=b(()=>{G=".paradigm/events",at="stream.jsonl",v=1e3,_=[];});function O(e){let t=g.join(e,dt);if(!d.existsSync(t))return {...b$1};try{let n=d.readFileSync(t,"utf8"),r=W.load(n);return ut(b$1,r)}catch{return {...b$1}}}function ut(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((r,o,i)=>i.indexOf(r)===o)}),t.streams){n.streams={...e.streams};for(let r of ["work_log","learning_journal","team_decisions"])t.streams[r]&&(n.streams[r]={...e.streams?.[r],...t.streams[r],deny_content:[...e.streams?.[r]?.deny_content||[],...t.streams[r]?.deny_content||[]].filter((o,i,a)=>a.indexOf(o)===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 C(e,t,n){return n&&e.agent_overrides?.[n]?.observation&&e.agent_overrides[n].observation.deny?.some(o=>R(o,t))||e.observation?.deny?.some(r=>R(r,t))?false:e.observation?.allow?.length?e.observation.allow.some(r=>R(r,t)):true}function Ct(e,t,n){let r=t.streams?.[n];if(!r)return {filtered:e,redacted:[]};let o=[],i=e;if(r.redaction)for(let a of r.redaction)try{let u=new RegExp(a.pattern,"gi"),c=i.match(u);c&&(o.push(...c),i=i.replace(u,a.replacement||"[REDACTED]"));}catch{}return {filtered:i,redacted:o}}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 dt,X=b(()=>{c();dt=".paradigm/data-policy.yaml";});function wt(){let e=Date.now(),t=Math.floor(Math.random()*9999).toString().padStart(4,"0");return `nom-${e}-${t}`}function _t(){let e=Date.now(),t=Math.floor(Math.random()*9999).toString().padStart(4,"0");return `dbt-${e}-${t}`}function Q(e,t){let n=i(e),r=O(e),o=[];for(let f of n){if(!f.attention||!c$1(f.id,e)||t.path&&!C(r,t.path,f.id))continue;let l=H(t,f.id,f.attention);l.shouldNominate&&o.push({profile:f,score:l});}if(o.length===0)return {nominations:[],debates:[]};let i$1=P(e,{since:new Date(Date.now()-3e4).toISOString()}),a=o.filter(({profile:f})=>!i$1.find(s=>s.agent===f.id&&s.brief===K(f,t,{...o.find(m=>m.profile.id===f.id).score})));if(a.length===0)return {nominations:[],debates:[]};let u=a.map(({profile:f,score:l})=>{let s=Et(t,l),m=Nt(f,t);return {id:wt(),agent:f.id,relevance:l.score,urgency:s,type:m,brief:K(f,t,l),triggered_by:[t.id],timestamp:new Date().toISOString(),surfaced:false}});xt(e,u);let c=kt(e,u);return c.length>0&&vt(e,c),{nominations:u,debates:c}}function Et(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 Nt(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 K(e,t,n){let r=e.role||e.id;switch(t.type){case "gate-checked":return `${r}: Gate check on ${t.symbols?.join(", ")||"route"} \u2014 verify gate coverage is complete`;case "file-modified":return `${r}: ${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 `${r}: Compliance violation detected \u2014 ${t.context||"check .purpose and portal.yaml coverage"}`;case "route-created":return `${r}: New route ${t.symbols?.join(", ")||""} \u2014 ${e.id==="security"?"needs gate assignment in portal.yaml":"review route structure"}`;case "gate-added":return `${r}: Gate ${t.symbols?.join(", ")||""} added \u2014 ${e.id==="security"?"verify enforcement points":"check downstream impact"}`;case "decision-made":return `${r}: Decision recorded \u2014 ${t.context?.slice(0,80)||"review for alignment with project patterns"}`;case "work-completed":return `${r}: Work completed on ${t.symbols?.join(", ")||t.context?.slice(0,40)||"task"} \u2014 review outcome`;case "error-encountered":return `${r}: Error detected \u2014 ${t.context?.slice(0,80)||"investigate root cause"}`;default:{let o=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 `${r}: ${o}`}}}function kt(e,t){if(t.length<2)return [];let n=[],r=new Map;for(let o of t)for(let i of o.triggered_by){let a=r.get(i)||[];a.push(o),r.set(i,a);}for(let[o,i]of r){if(i.length<2||new Set(i.map(f=>f.agent)).size<2)continue;let u=new Set(i.map(f=>f.type)),c=u.size>1&&u.has("warning")&&u.has("suggestion");n.push({id:_t(),topic:`Multiple agents responded to event ${o}`,nominations:i.map(f=>f.id),type:c?"conflicting":"complementary",overlap_events:[o]});}return n}function M(e){return g.join(e,S,mt)}function I(e){return g.join(e,S,gt)}function xt(e,t){try{let n=g.join(e,S);d.mkdirSync(n,{recursive:!0});let r=M(e),o=t.map(a=>JSON.stringify(a)).join(`
|
|
7
|
+
`).filter(o=>o.trim()).map(o=>{try{return JSON.parse(o)}catch{return null}}).filter(o=>o!==null)}catch{return [..._]}}function H(e,t,n){let r=0,o=0,i=0,a=0;if(n.symbols?.length&&e.symbols?.length)for(let l of n.symbols)for(let s of e.symbols)B(l,s)&&(r=Math.max(r,1));if(n.paths?.length&&e.path){for(let l of n.paths)if(B(l,e.path)){o=1;break}}if(n.concepts?.length){let l=[e.context||"",...e.keywords||[],e.type||""].join(" ").toLowerCase(),s=0;for(let m of n.concepts)m&&l.includes(m.toLowerCase())&&s++;n.concepts.length>0&&(i=s/n.concepts.length);}if(n.signals?.length){for(let l of n.signals)if(l.type===e.type){a=1;break}}let u=[r,o,i,a].sort((l,s)=>s-l),c=u[0]*.5+u[1]*.2+u[2]*.15+u[3]*.15,f=n.threshold??.6;return {agentId:t,score:c,breakdown:{symbolMatch:r,pathMatch:o,conceptMatch:i,signalMatch:a},shouldNominate:c>=f,quietReason:c<f?"below-threshold":void 0}}function B(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 G,at,v,_,z=b(()=>{G=".paradigm/events",at="stream.jsonl",v=1e3,_=[];});function O(e){let t=g.join(e,dt);if(!d.existsSync(t))return {...b$1};try{let n=d.readFileSync(t,"utf8"),r=W.load(n);return ut(b$1,r)}catch{return {...b$1}}}function ut(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((r,o,i)=>i.indexOf(r)===o)}),t.streams){n.streams={...e.streams};for(let r of ["work_log","learning_journal","team_decisions"])t.streams[r]&&(n.streams[r]={...e.streams?.[r],...t.streams[r],deny_content:[...e.streams?.[r]?.deny_content||[],...t.streams[r]?.deny_content||[]].filter((o,i,a)=>a.indexOf(o)===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 C(e,t,n){return n&&e.agent_overrides?.[n]?.observation&&e.agent_overrides[n].observation.deny?.some(o=>R(o,t))||e.observation?.deny?.some(r=>R(r,t))?false:e.observation?.allow?.length?e.observation.allow.some(r=>R(r,t)):true}function Ct(e,t,n){let r=t.streams?.[n];if(!r)return {filtered:e,redacted:[]};let o=[],i=e;if(r.redaction)for(let a of r.redaction)try{let u=new RegExp(a.pattern,"gi"),c=i.match(u);c&&(o.push(...c),i=i.replace(u,a.replacement||"[REDACTED]"));}catch{}return {filtered:i,redacted:o}}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 dt,X=b(()=>{c();dt=".paradigm/data-policy.yaml";});function wt(){let e=Date.now(),t=Math.floor(Math.random()*9999).toString().padStart(4,"0");return `nom-${e}-${t}`}function _t(){let e=Date.now(),t=Math.floor(Math.random()*9999).toString().padStart(4,"0");return `dbt-${e}-${t}`}function Q(e,t){let n=i(e),r=O(e),o=[];for(let f of n){if(!f.attention||!c$1(f.id,e)||t.path&&!C(r,t.path,f.id))continue;let l=H(t,f.id,f.attention);l.shouldNominate&&o.push({profile:f,score:l});}if(o.length===0)return {nominations:[],debates:[]};let i$1=P(e,{since:new Date(Date.now()-3e4).toISOString()}),a=o.filter(({profile:f})=>!i$1.find(s=>s.agent===f.id&&s.brief===K(f,t,{...o.find(m=>m.profile.id===f.id).score})));if(a.length===0)return {nominations:[],debates:[]};let u=a.map(({profile:f,score:l})=>{let s=Et(t,l),m=Nt(f,t);return {id:wt(),agent:f.id,relevance:l.score,urgency:s,type:m,brief:K(f,t,l),triggered_by:[t.id],timestamp:new Date().toISOString(),surfaced:false}});xt(e,u);let c=kt(e,u);return c.length>0&&vt(e,c),{nominations:u,debates:c}}function Et(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 Nt(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 K(e,t,n){let r=e.role||e.id;switch(t.type){case "gate-checked":return `${r}: Gate check on ${t.symbols?.join(", ")||"route"} \u2014 verify gate coverage is complete`;case "file-modified":return `${r}: ${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 `${r}: Compliance violation detected \u2014 ${t.context||"check .purpose and portal.yaml coverage"}`;case "route-created":return `${r}: New route ${t.symbols?.join(", ")||""} \u2014 ${e.id==="security"?"needs gate assignment in portal.yaml":"review route structure"}`;case "gate-added":return `${r}: Gate ${t.symbols?.join(", ")||""} added \u2014 ${e.id==="security"?"verify enforcement points":"check downstream impact"}`;case "decision-made":return `${r}: Decision recorded \u2014 ${t.context?.slice(0,80)||"review for alignment with project patterns"}`;case "work-completed":return `${r}: Work completed on ${t.symbols?.join(", ")||t.context?.slice(0,40)||"task"} \u2014 review outcome`;case "error-encountered":return `${r}: Error detected \u2014 ${t.context?.slice(0,80)||"investigate root cause"}`;default:{let o=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 `${r}: ${o}`}}}function kt(e,t){if(t.length<2)return [];let n=[],r=new Map;for(let o of t)for(let i of o.triggered_by){let a=r.get(i)||[];a.push(o),r.set(i,a);}for(let[o,i]of r){if(i.length<2||new Set(i.map(f=>f.agent)).size<2)continue;let u=new Set(i.map(f=>f.type)),c=u.size>1&&u.has("warning")&&u.has("suggestion");n.push({id:_t(),topic:`Multiple agents responded to event ${o}`,nominations:i.map(f=>f.id),type:c?"conflicting":"complementary",overlap_events:[o]});}return n}function M(e){return g.join(e,S,mt)}function I(e){return g.join(e,S,gt)}function xt(e,t){try{let n=g.join(e,S);d.mkdirSync(n,{recursive:!0});let r=M(e),o=t.map(a=>JSON.stringify(a)).join(`
|
|
8
8
|
`)+`
|
|
9
9
|
`;d.appendFileSync(r,o,"utf8"),Z(r,pt);let{nominationTtlDays:i}=A(e);tt(r,i*24*60*60*1e3);}catch{}}function vt(e,t){try{let n=g.join(e,S);d.mkdirSync(n,{recursive:!0});let r=I(e),o=t.map(a=>JSON.stringify(a)).join(`
|
|
10
10
|
`)+`
|
|
@@ -23,7 +23,7 @@ import {c,b as b$1}from'./chunk-3KVVC4WV.js';import {z as z$1,i,c as c$1,f,j}fro
|
|
|
23
23
|
`),u=!1,c=a.map(f=>{try{let l=JSON.parse(f);if(l.id===t){l.resolution={chosen:n,reason:r,resolved_by:"human",resolved_at:new Date().toISOString()},u=!0;let s=l.nominations.filter(m=>m!==n);for(let m of s){let p=P(e).find(h=>h.id===m);p&&E(e,{type:"work-completed",source:"agent-action",agent:p.agent,context:`Debate ${t} resolved \u2014 nomination ${m} not chosen`,data:{debate_id:t,chosen:n,reason:r}});}return JSON.stringify(l)}return f}catch{return f}});return u&&d.writeFileSync(o,c.join(`
|
|
24
24
|
`)+`
|
|
25
25
|
`,"utf8"),u}catch{return false}}function Gt(e){let t=g.join(e,S,".last-processed"),n="";try{d.existsSync(t)&&(n=d.readFileSync(t,"utf8").trim());}catch{}let r=g.join(e,S,"stream.jsonl");if(!d.existsSync(r))return {processed:0,nominations:[]};let o=[];try{o=d.readFileSync(r,"utf8").trim().split(`
|
|
26
|
-
`).filter(s=>s.trim()).map(s=>{try{return JSON.parse(s)}catch{return null}}).filter(s=>s!==null);}catch{return {processed:0,nominations:[]}}let i=0;if(n){let l=o.findIndex(s=>s.id===n);l>=0&&(i=l+1);}let a=o.slice(i);if(a.length===0)return {processed:0,nominations:[]};let u=[],c=a.slice(0,50);for(let l of c){let{nominations:s}=Q(e,l);u.push(...s);}let f=c[c.length-1];try{d.mkdirSync(g.join(e,S),{recursive:!0}),d.writeFileSync(t,f.id,"utf8");}catch{}return {processed:c.length,nominations:u}}function Yt(e,t,n){let r=O(e);if(t.path&&!C(r,t.path))return {event:E(e,t),nominations:[],debates:[]};let o=E(e,t);if(n?.skipNominations)return {event:o,nominations:[],debates:[]};let{nominations:i,debates:a}=Q(e,o);return i.length>0&&Tt(e,i),{event:o,nominations:i,debates:a}}function Ht(e,t){let n=f(e,t);if(!n?.attention)return {adjusted:false,oldThreshold:.6,newThreshold:.6,reason:"No attention config"};let r=n.attention.threshold??.6,{nominationTtlDays:o}=A(e),i=o*24*60*60*1e3,c=P(e,{agent:t}).filter(b=>b.engaged||Date.now()-new Date(b.timestamp).getTime()<i).filter(b=>b.engaged);if(c.length<5)return {adjusted:false,oldThreshold:r,newThreshold:r,reason:`Insufficient data (${c.length}/5 engaged nominations)`};let f$1=c.filter(b=>b.response==="accepted").length,l=c.filter(b=>b.response==="dismissed").length,s=f$1/c.length,m=l/c.length,p=r,h="No adjustment needed";if(m>.6?(p=Math.min(.95,r+.05),h=`High dismiss rate (${(m*100).toFixed(0)}%) \u2014 raising threshold to reduce noise`):s>.8&&(p=Math.max(.2,r-.05),h=`High accept rate (${(s*100).toFixed(0)}%) \u2014 lowering threshold to contribute more`),p===r)return {adjusted:false,oldThreshold:r,newThreshold:p,reason:h};n.attention.threshold=p;let w=g.join(e,".paradigm/agents",`${t}.agent`),N=d.existsSync(w)?"project":"global";return j(t,n,N,e),E(e,{type:"work-completed",source:"agent-action",agent:t,context:`Attention threshold adjusted: ${r.toFixed(2)} \u2192 ${p.toFixed(2)} (${h})`,data:{old_threshold:r,new_threshold:p,accept_rate:s,dismiss_rate:m}}),{adjusted:true,oldThreshold:r,newThreshold:p,reason:h}}function jt(e,t){let{nominationTtlDays:n}=A(e),r=n*24*60*60*1e3,i=P(e,{agent:t}).filter(s=>s.engaged||Date.now()-new Date(s.timestamp).getTime()<r),a=i.filter(s=>s.response==="accepted").length,u=i.filter(s=>s.response==="dismissed").length,c=i.filter(s=>s.response==="deferred").length,f=i.filter(s=>!s.engaged).length,l=a+u+c;return {total:i.length,accepted:a,dismissed:u,deferred:c,pending:f,acceptRate:l>0?a/l:0}}function zt(e){let n=i(e).filter(s=>c$1(s.id,e)).map(s=>{let m=jt(e,s.id),p=0;try{let h=g.join(T.homedir(),".paradigm","notebooks",s.id);d.existsSync(h)&&(p=d.readdirSync(h).filter(w=>w.endsWith(".yaml")).length);}catch{}return {id:s.id,acceptRate:m.acceptRate,threshold:s.attention?.threshold??.5,expertiseCount:(s.expertise||[]).length,notebookCount:p,transferableCount:(s.transferable||[]).length,totalNominations:m.total}}),r=n.length||1,o=n.reduce((s,m)=>s+m.acceptRate,0)/r,i$1=n.reduce((s,m)=>s+m.threshold,0)/r,a=n.reduce((s,m)=>s+m.expertiseCount,0),u=n.reduce((s,m)=>s+m.notebookCount,0),c=n.reduce((s,m)=>s+m.transferableCount,0),f=n.reduce((s,m)=>s+m.totalNominations,0),l;return f<10?l="cold-start":o<.5?l="accumulating":o<.7?l="calibrating":l="mature",{agents:n,aggregate:{avgAcceptRate:o,avgThreshold:i$1,totalExpertise:a,totalNotebooks:u,totalTransferable:c},healthStatus:l}}function Tt(e,t){if(t.length===0)return;let n=g.join(T.homedir(),".paradigm","score","outbox");if(d.existsSync(n))try{let r=g.join(n,`nom-${Date.now()}.json`),o={type:"nomination_forward",nominations:t.map(i=>({...i})),origin:At(e),timestamp:new Date().toISOString()};d.writeFileSync(r,JSON.stringify(o),"utf8");}catch{}}function At(e){try{let t=g.join(e,".paradigm","config.yaml");if(d.existsSync(t)){let r=d.readFileSync(t,"utf8").match(/project:\s*(.+)/);if(r)return r[1].trim()}}catch{}return g.basename(e)}function Vt(e,t){let n,r;try{let c=(g$1(),d$1(f$1)),f=(
|
|
26
|
+
`).filter(s=>s.trim()).map(s=>{try{return JSON.parse(s)}catch{return null}}).filter(s=>s!==null);}catch{return {processed:0,nominations:[]}}let i=0;if(n){let l=o.findIndex(s=>s.id===n);l>=0&&(i=l+1);}let a=o.slice(i);if(a.length===0)return {processed:0,nominations:[]};let u=[],c=a.slice(0,50);for(let l of c){let{nominations:s}=Q(e,l);u.push(...s);}let f=c[c.length-1];try{d.mkdirSync(g.join(e,S),{recursive:!0}),d.writeFileSync(t,f.id,"utf8");}catch{}return {processed:c.length,nominations:u}}function Yt(e,t,n){let r=O(e);if(t.path&&!C(r,t.path))return {event:E(e,t),nominations:[],debates:[]};let o=E(e,t);if(n?.skipNominations)return {event:o,nominations:[],debates:[]};let{nominations:i,debates:a}=Q(e,o);return i.length>0&&Tt(e,i),{event:o,nominations:i,debates:a}}function Ht(e,t){let n=f(e,t);if(!n?.attention)return {adjusted:false,oldThreshold:.6,newThreshold:.6,reason:"No attention config"};let r=n.attention.threshold??.6,{nominationTtlDays:o}=A(e),i=o*24*60*60*1e3,c=P(e,{agent:t}).filter(b=>b.engaged||Date.now()-new Date(b.timestamp).getTime()<i).filter(b=>b.engaged);if(c.length<5)return {adjusted:false,oldThreshold:r,newThreshold:r,reason:`Insufficient data (${c.length}/5 engaged nominations)`};let f$1=c.filter(b=>b.response==="accepted").length,l=c.filter(b=>b.response==="dismissed").length,s=f$1/c.length,m=l/c.length,p=r,h="No adjustment needed";if(m>.6?(p=Math.min(.95,r+.05),h=`High dismiss rate (${(m*100).toFixed(0)}%) \u2014 raising threshold to reduce noise`):s>.8&&(p=Math.max(.2,r-.05),h=`High accept rate (${(s*100).toFixed(0)}%) \u2014 lowering threshold to contribute more`),p===r)return {adjusted:false,oldThreshold:r,newThreshold:p,reason:h};n.attention.threshold=p;let w=g.join(e,".paradigm/agents",`${t}.agent`),N=d.existsSync(w)?"project":"global";return j(t,n,N,e),E(e,{type:"work-completed",source:"agent-action",agent:t,context:`Attention threshold adjusted: ${r.toFixed(2)} \u2192 ${p.toFixed(2)} (${h})`,data:{old_threshold:r,new_threshold:p,accept_rate:s,dismiss_rate:m}}),{adjusted:true,oldThreshold:r,newThreshold:p,reason:h}}function jt(e,t){let{nominationTtlDays:n}=A(e),r=n*24*60*60*1e3,i=P(e,{agent:t}).filter(s=>s.engaged||Date.now()-new Date(s.timestamp).getTime()<r),a=i.filter(s=>s.response==="accepted").length,u=i.filter(s=>s.response==="dismissed").length,c=i.filter(s=>s.response==="deferred").length,f=i.filter(s=>!s.engaged).length,l=a+u+c;return {total:i.length,accepted:a,dismissed:u,deferred:c,pending:f,acceptRate:l>0?a/l:0}}function zt(e){let n=i(e).filter(s=>c$1(s.id,e)).map(s=>{let m=jt(e,s.id),p=0;try{let h=g.join(T.homedir(),".paradigm","notebooks",s.id);d.existsSync(h)&&(p=d.readdirSync(h).filter(w=>w.endsWith(".yaml")).length);}catch{}return {id:s.id,acceptRate:m.acceptRate,threshold:s.attention?.threshold??.5,expertiseCount:(s.expertise||[]).length,notebookCount:p,transferableCount:(s.transferable||[]).length,totalNominations:m.total}}),r=n.length||1,o=n.reduce((s,m)=>s+m.acceptRate,0)/r,i$1=n.reduce((s,m)=>s+m.threshold,0)/r,a=n.reduce((s,m)=>s+m.expertiseCount,0),u=n.reduce((s,m)=>s+m.notebookCount,0),c=n.reduce((s,m)=>s+m.transferableCount,0),f=n.reduce((s,m)=>s+m.totalNominations,0),l;return f<10?l="cold-start":o<.5?l="accumulating":o<.7?l="calibrating":l="mature",{agents:n,aggregate:{avgAcceptRate:o,avgThreshold:i$1,totalExpertise:a,totalNotebooks:u,totalTransferable:c},healthStatus:l}}function Tt(e,t){if(t.length===0)return;let n=g.join(T.homedir(),".paradigm","score","outbox");if(d.existsSync(n))try{let r=g.join(n,`nom-${Date.now()}.json`),o={type:"nomination_forward",nominations:t.map(i=>({...i})),origin:At(e),timestamp:new Date().toISOString()};d.writeFileSync(r,JSON.stringify(o),"utf8");}catch{}}function At(e){try{let t=g.join(e,".paradigm","config.yaml");if(d.existsSync(t)){let r=d.readFileSync(t,"utf8").match(/project:\s*(.+)/);if(r)return r[1].trim()}}catch{}return g.basename(e)}function Vt(e,t){let n,r;try{let c=(g$1(),d$1(f$1)),f=(h(),d$1(g$2));n=c.loadJournalEntries,r=f.addNotebookEntry;}catch{return {promoted:0,entries:[]}}let o=n(t,{trigger:"pattern_discovered",limit:100}),i=n(t,{trigger:"human_feedback",limit:100}),a=[...o,...i],u=[];for(let c of a)if(!c.promoted_to_notebook&&!((c.confidence_after??0)<.8))try{let{entry:f}=r(t,{context:c.pattern?.applies_when||c.insight.slice(0,80),snippet:c.pattern?.correct_approach||c.insight,concepts:c.tags||[c.pattern?.id||"learned-pattern"],provenance:{source:"lore",loreEntryId:c.id,createdBy:t}},"global",e);u.push({journalId:c.id,notebookId:f.id});try{let l=g.join(T.homedir(),".paradigm","agents",t,"journal");if(d.existsSync(l)){let s=d.readdirSync(l).filter(m=>m.endsWith(".yaml"));for(let m of s){let p=g.join(l,m),h=d.readFileSync(p,"utf8");if(h.includes(c.id)){let w=h.replace(/promoted_to_notebook:.*$/m,`promoted_to_notebook: "${f.id}"`);if(w===h){let N=h.trimEnd().split(`
|
|
27
27
|
`);N.push(`promoted_to_notebook: "${f.id}"`),d.writeFileSync(p,N.join(`
|
|
28
28
|
`)+`
|
|
29
29
|
`,"utf8");}else d.writeFileSync(p,w,"utf8");break}}}}catch{}}catch{}return {promoted:u.length,entries:u}}function Wt(e){let t=g.join(e,Pt),n={default_min_urgency:"low",enable_debates:true};if(!d.existsSync(t))return n;try{let r=a("js-yaml"),o=d.readFileSync(t,"utf8"),i=r.load(o);return {...n,...i}}catch{return n}}function Xt(e,t){let n={critical:0,high:1,medium:2,low:3},r=n[t.default_min_urgency||"low"]??3;return e.filter(o=>{let i=n[o.urgency]??3;if(t.preferences){let a=t.preferences.find(u=>u.agent===o.agent);if(a){if(a.always_show)return true;if(a.mute_unless?.length&&!a.mute_unless.some(c=>o.urgency===c||o.type===c))return false;if(a.min_urgency){let u=n[a.min_urgency]??3;return i<=u}}}return i<=r})}var S,mt,gt,pt,ht,yt,bt,St,Pt,Dt=b(()=>{z();X();z$1();S=".paradigm/events",mt="nominations.jsonl",gt="debates.jsonl",pt=500,ht=200,yt=7,bt=14,St=100;Pt=".paradigm/surfacing.yaml";});export{$t as a,z as b,O as c,Ct as d,X as e,Q as f,kt as g,xt as h,P as i,Ut as j,qt as k,Bt as l,Gt as m,Yt as n,Ht as o,jt as p,zt as q,Tt as r,Vt as s,Wt as t,Xt as u,Dt as v};
|
|
@@ -1,12 +1,52 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {b}from'./chunk-LBQBWIEX.js';import {a as a$2,g as g$1,h,d as d$1,f}from'./chunk-UIKLE3WD.js';import {g}from'./chunk-T6IDXUUA.js';import {c}from'./chunk-JIXHEBGK.js';import {c as c$1,d,e}from'./chunk-DOCDDDTD.js';import {a as a$1}from'./chunk-LKAT7IAK.js';import*as
|
|
3
|
-
`).length}catch{return 0}}function
|
|
4
|
-
`)}function G(){let s=fileURLToPath(import.meta.url),
|
|
2
|
+
import {b as b$1}from'./chunk-LBQBWIEX.js';import {a as a$2,g as g$1,h,d as d$1,f}from'./chunk-UIKLE3WD.js';import {g}from'./chunk-T6IDXUUA.js';import {c}from'./chunk-JIXHEBGK.js';import {c as c$1,d,e}from'./chunk-DOCDDDTD.js';import {a as a$1}from'./chunk-LKAT7IAK.js';import*as i from'fs';import*as a from'path';import {fileURLToPath}from'url';import t from'chalk';import q from'ora';function b(s){try{return i.readFileSync(s,"utf8").split(`
|
|
3
|
+
`).length}catch{return 0}}function _(s){let o=g$1(s);if(o&&f[o])return f[o].name;let e=a$2(s);if(e!=="backend")return e.charAt(0).toUpperCase()+e.slice(1)}function U(s){let o=[],e=0,n={name:"cursor",displayName:"Cursor"},g=a.join(s,".cursorrules"),r=a.join(s,".cursor","rules");if(i.existsSync(g)){let l=b(g);n.legacy={path:".cursorrules",lines:l,type:"legacy"},e+=l;}if(i.existsSync(r)){let l=i.readdirSync(r).filter(m=>m.endsWith(".mdc"));l.length>0&&(n.modern=l.map(m=>{let x=a.join(r,m),j=b(x);return e+=j,{path:`.cursor/rules/${m}`,lines:j,type:"modern"}}));}(n.legacy||n.modern)&&o.push(n);let u={name:"copilot",displayName:"GitHub Copilot"},c=a.join(s,".github","copilot-instructions.md"),f=a.join(s,".github","instructions");if(i.existsSync(c)){let l=b(c);u.legacy={path:".github/copilot-instructions.md",lines:l,type:"legacy"},e+=l;}if(i.existsSync(f)){let l=i.readdirSync(f).filter(m=>m.endsWith(".md"));l.length>0&&(u.modern=l.map(m=>{let x=a.join(f,m),j=b(x);return e+=j,{path:`.github/instructions/${m}`,lines:j,type:"modern"}}));}(u.legacy||u.modern)&&o.push(u);let h=a.join(s,".windsurfrules");if(i.existsSync(h)){let l=b(h);o.push({name:"windsurf",displayName:"Windsurf",legacy:{path:".windsurfrules",lines:l,type:"legacy"}}),e+=l;}let w=a.join(s,"CLAUDE.md");if(i.existsSync(w)){let l=b(w);o.push({name:"claude",displayName:"Claude",legacy:{path:"CLAUDE.md",lines:l,type:"legacy"}}),e+=l;}let p=a.join(s,"AGENTS.md");if(i.existsSync(p)){let l=b(p);o.push({name:"agents",displayName:"AGENTS.md",legacy:{path:"AGENTS.md",lines:l,type:"legacy"}}),e+=l;}let y=a$2(s),d=g$1(s);return {ides:o,hasExisting:o.length>0,totalLines:e,projectType:_(s),discipline:y!=="backend"?y:void 0,stack:d||void 0}}function O(s,o){let e=[];e.push("# Migrate IDE Instructions to Paradigm Format"),e.push(""),e.push("## Overview"),e.push(""),e.push(`Migrate existing IDE instruction files for **${o}** to Paradigm's managed, scoped format.`),e.push(""),e.push("## Source Files Found"),e.push("");for(let n of s.ides)if(n.legacy&&e.push(`- \`${n.legacy.path}\` (${n.legacy.lines} lines) - ${n.displayName} ${n.legacy.type} format`),n.modern)for(let g of n.modern)e.push(`- \`${g.path}\` (${g.lines} lines) - ${n.displayName} modern format`);return e.push(""),s.ides.some(n=>n.name==="cursor")&&(e.push("## Cursor Migration \u2192 `.cursor/rules/*.mdc`"),e.push(""),e.push("Split the existing `.cursorrules` into scoped `.mdc` files with YAML frontmatter:"),e.push(""),e.push("### File Structure"),e.push(""),e.push("```"),e.push(".cursor/rules/"),e.push("\u251C\u2500\u2500 project-core.mdc # Always applies - project overview, architecture"),e.push("\u251C\u2500\u2500 code-style.mdc # globs: **/*.{ts,tsx,js,jsx} - naming, formatting"),e.push("\u251C\u2500\u2500 components.mdc # globs: **/components/**/* - component patterns"),e.push("\u251C\u2500\u2500 api-patterns.mdc # globs: **/api/**/* - API conventions"),e.push("\u251C\u2500\u2500 testing.mdc # globs: **/*.test.* - testing guidelines"),e.push("\u2514\u2500\u2500 custom.mdc # Any project-specific rules"),e.push("```"),e.push(""),e.push("### Frontmatter Format"),e.push(""),e.push("```yaml"),e.push("---"),e.push("description: Brief description of what these rules cover"),e.push('globs: "**/*.ts" # File pattern (OR use alwaysApply)'),e.push("alwaysApply: true # Apply to all files (OR use globs)"),e.push("---"),e.push("```"),e.push("")),s.ides.some(n=>n.name==="copilot")&&(e.push("## Copilot Migration \u2192 `.github/instructions/*.instructions.md`"),e.push(""),e.push("Split into scoped instruction files with `applyTo` frontmatter:"),e.push(""),e.push("### File Structure"),e.push(""),e.push("```"),e.push(".github/"),e.push("\u251C\u2500\u2500 copilot-instructions.md # Always applies - core rules"),e.push("\u2514\u2500\u2500 instructions/"),e.push(" \u251C\u2500\u2500 typescript.instructions.md # applyTo: **/*.ts"),e.push(" \u251C\u2500\u2500 react.instructions.md # applyTo: **/*.tsx"),e.push(" \u251C\u2500\u2500 api.instructions.md # applyTo: **/api/**"),e.push(" \u2514\u2500\u2500 testing.instructions.md # applyTo: **/*.test.*"),e.push("```"),e.push(""),e.push("### Frontmatter Format"),e.push(""),e.push("```yaml"),e.push("---"),e.push('applyTo: "**/*.ts"'),e.push("---"),e.push("```"),e.push("")),e.push("## Migration Steps"),e.push(""),e.push("1. **Read each source file** and identify logical sections:"),e.push(" - Project overview / architecture"),e.push(" - Code style / naming conventions"),e.push(" - Language-specific patterns"),e.push(" - Framework-specific rules"),e.push(" - Testing guidelines"),e.push(" - API patterns"),e.push(""),e.push("2. **Create scoped target files** with appropriate frontmatter"),e.push(""),e.push("3. **Backup originals** by renaming to `.bak`:"),e.push(" - `.cursorrules` \u2192 `.cursorrules.bak`"),e.push(" - `.github/copilot-instructions.md` \u2192 `.github/copilot-instructions.md.bak`"),e.push(""),e.push("4. **Verify** the migration by checking that rules apply correctly"),e.push(""),e.push("## Tips"),e.push(""),e.push("- **Prefer specific globs** over `alwaysApply` when possible"),e.push("- **Keep files focused** - one concern per file"),e.push("- **Use descriptive names** that indicate the scope"),e.push("- **Paradigm will generate its own rules** - keep custom rules separate"),e.push("- After migration, run `paradigm sync` to add Paradigm-managed rules"),e.push(""),e.push("---"),e.push(""),e.push("*Generated by `paradigm init --migrate`*"),e.join(`
|
|
4
|
+
`)}function G(){let s=fileURLToPath(import.meta.url),o=a.dirname(s),e=[a.join(o,"..","..","templates","paradigm"),a.join(o,"..","templates","paradigm"),a.join(o,"..","..","src","templates","paradigm")];for(let n of e)if(i.existsSync(n))return n;return a.join(o,"..","templates","paradigm")}var A={directories:["prompts"],files:["echoes.yaml","docs/commands.md","docs/queries.md","specs/disciplines.md","specs/scan.md","specs/context-tracking.md"]};function z(s){for(let o of A.directories)if(s===o||s.startsWith(o+"/"))return true;return !!A.files.includes(s)}function N(s,o,e,n=""){i.existsSync(o)||i.mkdirSync(o,{recursive:true});let g=i.readdirSync(s,{withFileTypes:true});for(let r of g){let u=a.join(s,r.name),c=a.join(o,r.name),f=n?`${n}/${r.name}`:r.name;if(!z(f))if(r.isDirectory())N(u,c,e,f);else {let h=i.readFileSync(u,"utf8");h=h.replace(/\{\{PROJECT_NAME\}\}/g,e),i.writeFileSync(c,h,"utf8");}}}function M(s,o){if(console.log(t.blue(`
|
|
5
5
|
\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510`)),console.log(t.blue("\u2502")+t.white.bold(" Welcome to Paradigm ")+t.blue("\u2502")),console.log(t.blue("\u2502")+t.gray(" Let's set up your project ")+t.blue("\u2502")),console.log(t.blue(`\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518
|
|
6
|
-
`)),console.log(t.white(" \u{1F4C1} Project: ")+t.cyan(
|
|
7
|
-
`));for(let e of s.ides)if(e.legacy&&console.log(t.green(" \u2713 ")+t.white(e.legacy.path)+t.gray(` (${e.legacy.lines} lines)`)),e.modern)for(let n of e.modern)console.log(t.green(" \u2713 ")+t.white(n.path)+t.gray(` (${n.lines} lines)`));console.log(""),console.log(t.gray(` Total: ${s.totalLines} lines of existing instructions`));}else console.log(t.gray(" \u{1F4C4} No existing IDE instructions found"));console.log(""),console.log(t.gray(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),console.log("");}function B(s,
|
|
6
|
+
`)),console.log(t.white(" \u{1F4C1} Project: ")+t.cyan(o)+(s.projectType?t.gray(` (${s.projectType} detected)`):"")),s.discipline&&console.log(t.white(" \u{1F3AF} Discipline: ")+t.cyan(s.discipline)+(s.stack?t.gray(` \u2192 stack: ${s.stack}`):"")),console.log(""),s.hasExisting){console.log(t.white(` \u{1F4C4} Found existing IDE instructions:
|
|
7
|
+
`));for(let e of s.ides)if(e.legacy&&console.log(t.green(" \u2713 ")+t.white(e.legacy.path)+t.gray(` (${e.legacy.lines} lines)`)),e.modern)for(let n of e.modern)console.log(t.green(" \u2713 ")+t.white(n.path)+t.gray(` (${n.lines} lines)`));console.log(""),console.log(t.gray(` Total: ${s.totalLines} lines of existing instructions`));}else console.log(t.gray(" \u{1F4C4} No existing IDE instructions found"));console.log(""),console.log(t.gray(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),console.log("");}function B(s,o){let n={cursor:".cursor/rules/",copilot:".github/instructions/",windsurf:".windsurfrules",claude:"CLAUDE.md"}[s]||".cursor/rules/";console.log(t.blue(`
|
|
8
8
|
\u2728 Paradigm initialized!
|
|
9
|
-
`)),console.log(t.white(" Created:")),console.log(t.gray(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),console.log(t.white(" \u{1F4C1} .paradigm/")),console.log(t.gray(" \u251C\u2500\u2500 config.yaml Configuration")),console.log(t.gray(" \u251C\u2500\u2500 specs/ Logger, symbols, context")),console.log(t.gray(" \u2514\u2500\u2500 docs/ Patterns, troubleshooting")),console.log(t.white(" \u{1F4C4} .premise Project overview")),console.log(t.white(" \u{1F4C4} .purpose Feature context")),console.log(t.white(` \u{1F4C4} ${n.padEnd(20)} IDE instructions`)),console.log(""),console.log(t.gray(" Reference content (prompts, commands, etc.) available via MCP")),
|
|
9
|
+
`)),console.log(t.white(" Created:")),console.log(t.gray(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),console.log(t.white(" \u{1F4C1} .paradigm/")),console.log(t.gray(" \u251C\u2500\u2500 config.yaml Configuration")),console.log(t.gray(" \u251C\u2500\u2500 specs/ Logger, symbols, context")),console.log(t.gray(" \u2514\u2500\u2500 docs/ Patterns, troubleshooting")),console.log(t.white(" \u{1F4C4} .premise Project overview")),console.log(t.white(" \u{1F4C4} .purpose Feature context")),console.log(t.white(` \u{1F4C4} ${n.padEnd(20)} IDE instructions`)),console.log(""),console.log(t.gray(" Reference content (prompts, commands, etc.) available via MCP")),o.hasExisting&&(console.log(""),console.log(t.yellow(" \u26A0 Your existing IDE files were preserved.")),console.log(t.gray(" Run `paradigm init --migrate` to get a migration prompt."))),console.log(""),console.log(t.white(" Next steps:")),console.log(t.gray(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),console.log(t.white(" 1. ")+t.gray("Review ")+t.cyan(".paradigm/config.yaml")),console.log(t.white(" 2. ")+t.gray("Edit ")+t.cyan(".purpose")+t.gray(" to define your features")),console.log(t.white(" 3. ")+t.gray("Run ")+t.cyan("paradigm beacon")+t.gray(" to generate AI context")),console.log(t.white(" 4. ")+t.gray("Run ")+t.cyan("paradigm doctor")+t.gray(" to verify setup")),console.log(t.white(" 5. ")+t.gray("Run ")+t.cyan("paradigm visualize")+t.gray(" to see your project")),console.log(""),console.log(t.gray(" Maintenance cost: ~5 min per feature to update .purpose files.")),console.log(t.gray(" What you get: agents with accurate context, ripple analysis, and")),console.log(t.gray(" drift detection \u2014 without re-explaining your project every session.")),console.log("");}function V(s,o,e,n){let g=a.join(s,".paradigm","init-report.md"),r=new Date().toISOString().split("T")[0],u=[];try{let h=i.readdirSync(s,{withFileTypes:!0});for(let p of h)p.name===".purpose"&&u.push(".purpose");let w=a.join(s,".paradigm");i.existsSync(w)&&u.push(".paradigm/ (config, specs, docs)");}catch{}let c=n.hasExisting?"\n> **Note:** Existing IDE files were preserved. Run `paradigm init --migrate` to convert them.\n":"",f=`# Paradigm Init Report \u2014 ${o}
|
|
10
|
+
|
|
11
|
+
**Date:** ${r}
|
|
12
|
+
**IDE:** ${e}
|
|
13
|
+
|
|
14
|
+
${c}
|
|
15
|
+
## What Was Created
|
|
16
|
+
|
|
17
|
+
- \`.paradigm/config.yaml\` \u2014 project configuration
|
|
18
|
+
- \`.paradigm/specs/\` \u2014 symbol and logger specifications
|
|
19
|
+
- \`.paradigm/docs/\` \u2014 command reference and troubleshooting
|
|
20
|
+
- \`.premise\` \u2014 project overview (edit to describe your project)
|
|
21
|
+
- \`.purpose\` \u2014 root feature context (edit to register your components)
|
|
22
|
+
- IDE instructions for **${e}**
|
|
23
|
+
|
|
24
|
+
## What You Get
|
|
25
|
+
|
|
26
|
+
| Tool | What it does |
|
|
27
|
+
|------|-------------|
|
|
28
|
+
| \`paradigm_navigate\` | Orients agents to your project structure |
|
|
29
|
+
| \`paradigm_ripple\` | Shows what breaks when you change a symbol |
|
|
30
|
+
| \`paradigm_status\` | Health check for context coverage |
|
|
31
|
+
| \`paradigm_aspect_check\` | Detects undocumented side effects |
|
|
32
|
+
| 30+ more | Full list: \`paradigm docs\` |
|
|
33
|
+
|
|
34
|
+
## Maintenance Contract
|
|
35
|
+
|
|
36
|
+
Each new feature costs ~5 minutes of \`.purpose\` file maintenance.
|
|
37
|
+
What you get: agents with accurate context, ripple analysis, and drift detection \u2014 without re-explaining your project every session.
|
|
38
|
+
|
|
39
|
+
## Next Steps
|
|
40
|
+
|
|
41
|
+
1. Edit \`.purpose\` \u2014 add your first component
|
|
42
|
+
2. Run \`paradigm scan\` \u2014 build the symbol index
|
|
43
|
+
3. Run \`paradigm beacon\` \u2014 generate AI orientation context
|
|
44
|
+
4. Run \`paradigm doctor\` \u2014 verify setup
|
|
45
|
+
5. Start a Claude Code session \u2014 the MCP tools and hooks are ready
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
*Generated by \`paradigm init\` \xB7 ${r}*
|
|
49
|
+
`;try{i.writeFileSync(g,f,"utf8"),console.log(t.gray(" Report: .paradigm/init-report.md"));}catch{}}async function oe(s){let o=process.cwd(),e$1=s.name||a.basename(o),n=q(),g$1=a$1.command("init").start("Initializing Paradigm",{project:e$1,quick:!!s.quick}),r=U(o);if(a$1.operation("detect-ide").debug("IDE detection complete",{hasExisting:r.hasExisting}),s.migrate){if(!r.hasExisting){console.log(t.yellow(`
|
|
10
50
|
No existing IDE instruction files found.
|
|
11
51
|
`)),console.log(t.gray(" Run `paradigm init` to create a fresh setup.\n"));return}console.log(t.blue(`
|
|
12
52
|
Migration Prompt
|
|
@@ -14,30 +54,30 @@ import {b}from'./chunk-LBQBWIEX.js';import {a as a$2,g as g$1,h,d as d$1,f}from'
|
|
|
14
54
|
`)),console.log(t.gray(` \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
|
|
15
55
|
`)),console.log(O(r,e$1)),console.log(t.gray(`
|
|
16
56
|
\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
|
|
17
|
-
`));return}if(s.dryRun){
|
|
18
|
-
`));return}s.quick||(
|
|
57
|
+
`));return}if(s.dryRun){M(r,e$1),console.log(t.white(" Would create (dry run):")),console.log(t.gray(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),console.log(t.cyan(" \u{1F4C1} .paradigm/")),console.log(t.cyan(" \u251C\u2500\u2500 config.yaml")),console.log(t.cyan(" \u251C\u2500\u2500 specs/")),console.log(t.cyan(" \u2514\u2500\u2500 docs/")),console.log(t.cyan(" \u{1F4C4} .premise")),console.log(t.cyan(" \u{1F4C4} .purpose")),console.log(t.cyan(" \u{1F4C1} .cursor/rules/*.mdc")),console.log(""),console.log(t.gray(" Reference content (prompts, commands, etc.) served via MCP")),console.log(t.gray(` Run without --dry-run to create these files.
|
|
58
|
+
`));return}s.quick||(M(r,e$1),r.hasExisting&&!s.force&&(console.log(t.white(` What would you like to do?
|
|
19
59
|
`)),console.log(t.cyan(" paradigm init --migrate")),console.log(t.gray(` Get an AI-ready prompt to convert your existing rules
|
|
20
60
|
`)),console.log(t.cyan(" paradigm init --force")),console.log(t.gray(` Create .paradigm/ alongside existing files
|
|
21
61
|
`)),console.log(t.cyan(" paradigm init --dry-run")),console.log(t.gray(` Preview what would be created
|
|
22
|
-
`))));let u=G(),
|
|
23
|
-
`));return}}n.start("Creating .paradigm/ directory...");try{
|
|
62
|
+
`))));let u=G(),c$2=a.join(o,".paradigm");if(i.existsSync(c$2)){let d=i.statSync(c$2);if(d.isFile()){if(!s.force){console.log(t.yellow(" \u26A0 Legacy .paradigm file found.")),console.log(t.gray(" Run `paradigm upgrade --all` to migrate.\n"));return}i.unlinkSync(c$2);}else if(d.isDirectory()&&!s.force){console.log(t.yellow(` \u26A0 .paradigm/ already exists (use --force to overwrite)
|
|
63
|
+
`));return}}n.start("Creating .paradigm/ directory...");try{i.existsSync(c$2)||i.mkdirSync(c$2,{recursive:!0}),i.existsSync(u)?(N(u,c$2,e$1),i.existsSync(a.join(c$2,"fixtures.yaml"))||L(c$2),Y(c$2,o,s.stack),n.succeed(t.green(".paradigm/ created"))):(n.warn(t.yellow("Templates not found, creating minimal structure")),H(c$2,e$1));}catch(d){n.fail(t.red(`Failed: ${d.message}`));return}let f=a.join(o,".premise");(!i.existsSync(f)||s.force)&&(n.start("Creating .premise..."),i.writeFileSync(f,g(e$1)),n.succeed(t.green(".premise created")));let h=a.join(o,".purpose");(!i.existsSync(h)||s.force)&&(n.start("Creating .purpose..."),i.writeFileSync(h,c()),n.succeed(t.green(".purpose created")));let w=a.join(o,"portal.yaml");i.existsSync(w)||(console.log(t.gray(" \u25CB No portal.yaml (optional - create manually if you need gate/auth definitions)")),console.log(t.gray(" See: https://github.com/a-company/paradigm/blob/main/docs/guides/portals.md")));let p;s.ide?p=["cursor","copilot","windsurf","claude"].includes(s.ide.toLowerCase())?s.ide.toLowerCase():"cursor":(n.start("Detecting IDE..."),p=c$1(o).detected||"cursor",n.succeed(`Using ${t.cyan(p)}`));let y=d(o);if(y){n.start("Generating IDE instructions...");let d=e(o,p,y,true);d.success?n.succeed(t.green(d.message||"IDE instructions generated")):n.warn(t.yellow(d.message));}if(!s.quick){n.start("Creating scan index for MCP tools...");try{await b$1(o,{quiet:!0}),n.succeed(t.green("Scan index created"));}catch(d){n.warn(t.yellow("Could not create scan index: "+d.message)),console.log(t.gray(" Run `paradigm scan` manually after adding .purpose files"));}}B(p,r),V(o,e$1,p,r),g$1.success("Paradigm initialized",{project:e$1,ide:p});}function Y(s,o,e){let n=a.join(s,"config.yaml");if(!i.existsSync(n))return;let g=a$2(o);if(g==="auto")return;let r=i.readFileSync(n,"utf8");r=r.replace(/^discipline:\s*auto\b.*$/m,`discipline: ${g}`);let u=e||g$1(o),c=u?h(u):d$1(g);if(!c){let y=function(){let d=Object.entries(p.symbolMapping).map(([m,x])=>` "${m}": "${x}"`).join(`
|
|
24
64
|
`);r=r.replace(/ symbol-mapping:\n(?:(?: .*| *)\n)*/,` symbol-mapping:
|
|
25
|
-
${
|
|
26
|
-
`);let
|
|
65
|
+
${d}
|
|
66
|
+
`);let l=p.purposeRequired.map(m=>` - pattern: "${m.pattern}"
|
|
27
67
|
depth: ${m.depth}`).join(`
|
|
28
68
|
`);r=r.replace(/purpose-required:\n(?: - pattern:.*\n depth:.*\n)*/,`purpose-required:
|
|
29
|
-
${
|
|
30
|
-
`),
|
|
31
|
-
stack: ${u}`));let f=Object.entries(
|
|
69
|
+
${l}
|
|
70
|
+
`),i.writeFileSync(n,r,"utf8");};let p=d$1(g);y();return}u&&(r=r.replace(/^(discipline:\s*.+)$/m,`$1
|
|
71
|
+
stack: ${u}`));let f=Object.entries(c.symbolMapping).map(([p,y])=>` "${p}": "${y}"`).join(`
|
|
32
72
|
`);r=r.replace(/ symbol-mapping:\n(?:(?: .*| *)\n)*/,` symbol-mapping:
|
|
33
73
|
${f}
|
|
34
|
-
`);let h$1=
|
|
74
|
+
`);let h$1=c.purposeRequired.map(p=>` - pattern: "${p.pattern}"
|
|
35
75
|
depth: ${p.depth}`).join(`
|
|
36
76
|
`);r=r.replace(/purpose-required:\n(?: - pattern:.*\n depth:.*\n)*/,`purpose-required:
|
|
37
77
|
${h$1}
|
|
38
|
-
`),
|
|
78
|
+
`),i.writeFileSync(n,r,"utf8");}function H(s,o){i.mkdirSync(a.join(s,"specs"),{recursive:true}),i.mkdirSync(a.join(s,"docs"),{recursive:true}),i.mkdirSync(a.join(s,"tasks"),{recursive:true}),i.mkdirSync(a.join(s,"lore"),{recursive:true});let e=`# Paradigm Configuration
|
|
39
79
|
version: "1.0"
|
|
40
|
-
project: "${
|
|
80
|
+
project: "${o}"
|
|
41
81
|
|
|
42
82
|
agent-guidelines:
|
|
43
83
|
overview: |
|
|
@@ -85,7 +125,7 @@ conventions:
|
|
|
85
125
|
- "Reference related items using symbol prefixes (# $ ^ ! ~)"
|
|
86
126
|
- "Update .purpose files when changing feature behavior"
|
|
87
127
|
- "ALWAYS use Paradigm logger, NEVER raw console.log/print"
|
|
88
|
-
`;
|
|
128
|
+
`;i.writeFileSync(a.join(s,"config.yaml"),e,"utf8"),L(s);}function L(s){i.writeFileSync(a.join(s,"fixtures.yaml"),`# Test Fixtures for Flow Validation
|
|
89
129
|
# Use with paradigm_test_fixtures MCP tool
|
|
90
130
|
version: "1.0"
|
|
91
131
|
|
|
@@ -131,4 +171,4 @@ payloads:
|
|
|
131
171
|
updateTask:
|
|
132
172
|
title: "Updated Task"
|
|
133
173
|
status: "in-progress"
|
|
134
|
-
`,"utf8");}export{
|
|
174
|
+
`,"utf8");}export{oe as a};
|
|
@@ -3,9 +3,9 @@ import {c,a as a$1}from'./chunk-DOCDDDTD.js';import {e as e$1}from'./chunk-JQKKV
|
|
|
3
3
|
\u{1FA7A} Paradigm Doctor
|
|
4
4
|
`)),console.log(N?l.gray(`Running context audit checks...
|
|
5
5
|
`):l.gray(`Checking Paradigm setup...
|
|
6
|
-
`)));let I=a.command("doctor").start("Running health checks");if(!N){let E=function(t){let a=[];try{let n=e.readdirSync(t,{withFileTypes:!0});for(let r of n){if(r.name==="node_modules"||r.name==="dist"||r.name===".git")continue;let f=i.join(t,r.name);r.isDirectory()?a.push(...E(f)):r.name===".purpose"&&a.push(f);}}catch{}return a};let o=i.join(p,".paradigm");if(e.existsSync(o))if(e.statSync(o).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 a=i.join(o,"config.yaml");if(e.existsSync(a))try{let g=e.readFileSync(a,"utf8");e$1(g),s.push({name:".paradigm/config.yaml",status:"ok",message:"Valid YAML"});}catch(g){s.push({name:".paradigm/config.yaml",status:"error",message:`Invalid YAML: ${g.message}`,fix:"Check YAML syntax"});}else s.push({name:".paradigm/config.yaml",status:"missing",message:"Config file not found",fix:"paradigm init --force"});let n=["logger.md","scan.md","symbols.md"],r=i.join(o,"specs");if(e.existsSync(r))for(let g of n){let x=i.join(r,g);e.existsSync(x)?s.push({name:`.paradigm/specs/${g}`,status:"ok",message:"Present"}):s.push({name:`.paradigm/specs/${g}`,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 f=i.join(o,"docs");e.existsSync(f)?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 h=i.join(o,"prompts");e.existsSync(h)?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 u=["specs","implementation-guides","prompts","decisions"],d=[];for(let g of u){let x=i.join(o,g);if(e.existsSync(x)&&e.statSync(x).isDirectory()){let k=i.join(x,".index.yaml");e.existsSync(k)||d.push(`.paradigm/${g}/`);}}d.length>0?s.push({name:"Docs-class indexes",status:"warn",message:`${d.length} director${d.length===1?"y":"ies"} missing .index.yaml: ${d.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(o,"scan-index.json"),F=i.join(p,".paradigm-scan-index.json");if(e.existsSync(y)){let g=e.statSync(y),x=Date.now()-g.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 e.existsSync(F)?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 m=c(p);if(m.detected){let t=a$1(m.detected);if(t){let a=i.join(p,t.outputPath);e.existsSync(a)?s.push({name:t.outputPath,status:"ok",message:`Present (${m.detected})`}):s.push({name:t.outputPath,status:"missing",message:`Not generated for ${m.detected}`,fix:"paradigm sync"});}}let c$1=i.join(p,".premise");e.existsSync(c$1)?s.push({name:".premise",status:"ok",message:"Present"}):s.push({name:".premise",status:"missing",message:"Not found (optional)"});let v=i.join(p,".purpose");e.existsSync(v)?s.push({name:".purpose",status:"ok",message:"Present"}):s.push({name:".purpose",status:"warn",message:"Root .purpose not found",fix:"paradigm init"});let A=i.join(p,".paradigm","config.yaml");if(e.existsSync(A))try{let t=e.readFileSync(A,"utf8"),n=S.load(t)?.["purpose-required"];if(n&&Array.isArray(n)){let r=[];for(let f of n){if(!f.pattern)continue;let{glob:h}=await import('glob'),u=await h(f.pattern,{cwd:p,nodir:!1});for(let d of u){let y=i.join(p,d);try{e.statSync(y).isDirectory()&&!e.existsSync(i.join(y,".purpose"))&&r.push(d);}catch{}}}r.length>0?s.push({name:"Purpose-required",status:"warn",message:`${r.length} director${r.length===1?"y":"ies"} missing .purpose: ${r.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 q=/\[NEEDS CLARIFICATION:\s*[^\]]+\]/gi,R=0,Y=E(p);for(let t of Y)try{let n=e.readFileSync(t,"utf8").match(q);n&&(R+=n.length);}catch{}R>0?s.push({name:"Clarification markers",status:"warn",message:`${R} [NEEDS CLARIFICATION] marker${R>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 L=i.join(p,"portal.yaml");if(e.existsSync(L))try{let t=e.readFileSync(L,"utf8"),a=S.load(t);if(a?.version&&a?.gates){let n=Object.keys(a.gates||{}).length,r=Object.keys(a.routes||{}).length;s.push({name:"portal.yaml",status:"ok",message:`Valid (${n} gates, ${r} 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(t){s.push({name:"portal.yaml",status:"error",message:`Invalid YAML: ${t.message}`,fix:"Check YAML syntax in portal.yaml"});}if(e.existsSync(L))try{let{checkPortalCompliance:t,getComplianceSummary:a}=await import('./portal-compliance-4MG5F2GI.js'),n=await t(p),r=a(n);s.push({name:"Portal compliance",status:r.status,message:r.message,fix:r.status!=="ok"?"paradigm portal check":void 0});}catch{}let U=i.join(p,".paradigm","flows.yaml");if(e.existsSync(U))try{let t=e.readFileSync(U,"utf8"),a=S.load(t);if(a?.version&&a?.flows){let n=Object.keys(a.flows||{}).length,r=Object.entries(a.flows||{}).filter(([,f])=>!f?.steps||(f.steps?.length??0)===0);r.length>0?s.push({name:".paradigm/flows.yaml",status:"warn",message:`${n} flows defined, ${r.length} have no steps`,fix:"Add steps to empty flow definitions"}):s.push({name:".paradigm/flows.yaml",status:"ok",message:`Valid (${n} 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(t){s.push({name:".paradigm/flows.yaml",status:"error",message:`Invalid YAML: ${t.message}`,fix:"Check YAML syntax in flows.yaml"});}let H=i.join(p,".paradigm","lore");if(e.existsSync(H))try{let t=e.readdirSync(H).filter(a=>a.endsWith(".yaml"));t.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:`${t.length} lore file${t.length>1?"s":""}`});}catch{s.push({name:"Lore entries",status:"warn",message:"Could not read lore directory"});}let G=i.join(p,".paradigm","university");if(e.existsSync(G))try{let t=i.join(G,"content"),a=0,n=0;if(e.existsSync(t))for(let r of ["notes","policies","quizzes","paths"]){let f=i.join(t,r);e.existsSync(f)&&(a+=e.readdirSync(f).filter(h=>h.endsWith(".md")||h.endsWith(".yaml")).length);}if(a===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 r=i.join(t,"quizzes");if(e.existsSync(r))for(let h of e.readdirSync(r).filter(u=>u.endsWith(".yaml")))try{let u=S.load(e.readFileSync(i.join(r,h),"utf8"));if(u?.questions)for(let d of u.questions)d.choices&&d.correct&&!(d.correct in d.choices)&&n++;}catch{}let f=i.join(t,"paths");if(e.existsSync(f))for(let h of e.readdirSync(f).filter(u=>u.endsWith(".yaml")))try{let u=S.load(e.readFileSync(i.join(f,h),"utf8"));if(u?.steps){for(let d of u.steps)if(d.content&&!d.content.startsWith("plsat:")){let y=!1;for(let F of ["notes","policies","quizzes","paths"]){let g=i.join(t,F);if(e.existsSync(g)&&e.readdirSync(g).some(k=>k.startsWith(d.content))){y=!0;break}}y||n++;}}}catch{}n>0?s.push({name:"University content",status:"warn",message:`${a} items, ${n} issue${n>1?"s":""}`,fix:"Run: paradigm university validate --deep"}):s.push({name:"University content",status:"ok",message:`${a} content item${a>1?"s":""}`});}}catch{s.push({name:"University content",status:"warn",message:"Could not read university directory"});}let _=i.join(p,".claude","hooks.json"),ss=i.join(p,"plugins","paradigm","hooks.json");if(e.existsSync(_)){let t=e.statSync(_),a=Date.now()-t.mtime.getTime(),n=Math.floor(a/(1e3*60*60*24));n>30?s.push({name:"Claude Code hooks",status:"warn",message:`Hooks are ${n} days old \u2014 may be outdated`,fix:"paradigm hooks install"}):s.push({name:"Claude Code hooks",status:"ok",message:n>0?`${n} days old`:"Fresh"});}else e.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(e.existsSync(V))try{let t=e.readFileSync(V,"utf8"),a=S.load(t);if(a?.version&&Array.isArray(a?.habits)){let n=a.habits.filter(r=>r.enabled!==!1).length;s.push({name:"Habits config",status:"ok",message:`Valid (${n}/${a.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(t){s.push({name:"Habits config",status:"error",message:`Invalid YAML: ${t.message}`,fix:"Check YAML syntax in habits.yaml"});}let J=i.join(p,"AGENTS.md");if(e.existsSync(J)){let t=e.statSync(J),a=Date.now()-t.mtime.getTime(),n=Math.floor(a/(1e3*60*60*24));n>60?s.push({name:"AGENTS.md",status:"warn",message:`${n} days since last update \u2014 may be stale`,fix:"paradigm sync"}):s.push({name:"AGENTS.md",status:"ok",message:n>0?`Updated ${n} days ago`:"Fresh"});}}let W=0,z=0,$=0;for(let o of s){let m,c;switch(o.status){case "ok":m="\u2713",c=l.green;break;case "warn":m="\u26A0",c=l.yellow,z++;break;case "error":m="\u2717",c=l.red,W++;break;case "missing":m="\u25CB",c=l.gray,$++;break}if(!w){let v=o.name.padEnd(30);console.log(` ${c(m)} ${v} ${c(o.message)}`),o.fix&&console.log(l.gray(` \u2514\u2500 Fix: ${o.fix}`));}}let{runContextAudit:Z}=await import('./context-audit-XRPT3OU2.js'),M=await Z(p,{quiet:w}),O=0,T=0,C=0;!w&&M.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 o of M){let m,c;switch(o.status){case "ok":m="\u2713",c=l.green;break;case "warn":m="\u26A0",c=l.yellow,T++;break;case "error":m="\u2717",c=l.red,O++;break;case "advisory":m="\u2139",c=l.cyan,C++;break}if(!w){let v=o.check.padEnd(30);if(console.log(` ${c(m)} ${v} ${c(o.message)}`),o.details&&o.details.length>0){let A=o.details.slice(0,5);for(let q of A)console.log(l.gray(` \u2502 ${q}`));o.details.length>5&&console.log(l.gray(` \u2502 ... and ${o.details.length-5} more`));}o.fix&&console.log(l.gray(` \u2514\u2500 Fix: ${o.fix}`));}}let b=W+O,j=z+T,D=b+j+$===0;if(!w)if(console.log(""),D)console.log(l.green(`\u2728 All checks passed!
|
|
7
|
-
`));else {let o=[];
|
|
8
|
-
`),console.log(l.gray(
|
|
6
|
+
`)));let I=a.command("doctor").start("Running health checks");if(!N){let E=function(t){let a=[];try{let n=e.readdirSync(t,{withFileTypes:!0});for(let r of n){if(r.name==="node_modules"||r.name==="dist"||r.name===".git")continue;let f=i.join(t,r.name);r.isDirectory()?a.push(...E(f)):r.name===".purpose"&&a.push(f);}}catch{}return a};let o=i.join(p,".paradigm");if(e.existsSync(o))if(e.statSync(o).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 a=i.join(o,"config.yaml");if(e.existsSync(a))try{let g=e.readFileSync(a,"utf8");e$1(g),s.push({name:".paradigm/config.yaml",status:"ok",message:"Valid YAML"});}catch(g){s.push({name:".paradigm/config.yaml",status:"error",message:`Invalid YAML: ${g.message}`,fix:"Check YAML syntax"});}else s.push({name:".paradigm/config.yaml",status:"missing",message:"Config file not found",fix:"paradigm init --force"});let n=["logger.md","scan.md","symbols.md"],r=i.join(o,"specs");if(e.existsSync(r))for(let g of n){let x=i.join(r,g);e.existsSync(x)?s.push({name:`.paradigm/specs/${g}`,status:"ok",message:"Present"}):s.push({name:`.paradigm/specs/${g}`,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 f=i.join(o,"docs");e.existsSync(f)?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 h=i.join(o,"prompts");e.existsSync(h)?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 u=["specs","implementation-guides","prompts","decisions"],d=[];for(let g of u){let x=i.join(o,g);if(e.existsSync(x)&&e.statSync(x).isDirectory()){let k=i.join(x,".index.yaml");e.existsSync(k)||d.push(`.paradigm/${g}/`);}}d.length>0?s.push({name:"Docs-class indexes",status:"warn",message:`${d.length} director${d.length===1?"y":"ies"} missing .index.yaml: ${d.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(o,"scan-index.json"),F=i.join(p,".paradigm-scan-index.json");if(e.existsSync(y)){let g=e.statSync(y),x=Date.now()-g.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 e.existsSync(F)?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 m=c(p);if(m.detected){let t=a$1(m.detected);if(t){let a=i.join(p,t.outputPath);e.existsSync(a)?s.push({name:t.outputPath,status:"ok",message:`Present (${m.detected})`}):s.push({name:t.outputPath,status:"missing",message:`Not generated for ${m.detected}`,fix:"paradigm sync"});}}let c$1=i.join(p,".premise");e.existsSync(c$1)?s.push({name:".premise",status:"ok",message:"Present"}):s.push({name:".premise",status:"missing",message:"Not found (optional)"});let v=i.join(p,".purpose");e.existsSync(v)?s.push({name:".purpose",status:"ok",message:"Present"}):s.push({name:".purpose",status:"warn",message:"Root .purpose not found",fix:"paradigm init"});let A=i.join(p,".paradigm","config.yaml");if(e.existsSync(A))try{let t=e.readFileSync(A,"utf8"),n=S.load(t)?.["purpose-required"];if(n&&Array.isArray(n)){let r=[];for(let f of n){if(!f.pattern)continue;let{glob:h}=await import('glob'),u=await h(f.pattern,{cwd:p,nodir:!1});for(let d of u){let y=i.join(p,d);try{e.statSync(y).isDirectory()&&!e.existsSync(i.join(y,".purpose"))&&r.push(d);}catch{}}}r.length>0?s.push({name:"Purpose-required",status:"warn",message:`${r.length} director${r.length===1?"y":"ies"} missing .purpose: ${r.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 q=/\[NEEDS CLARIFICATION:\s*[^\]]+\]/gi,R=0,Y=E(p);for(let t of Y)try{let n=e.readFileSync(t,"utf8").match(q);n&&(R+=n.length);}catch{}R>0?s.push({name:"Clarification markers",status:"warn",message:`${R} [NEEDS CLARIFICATION] marker${R>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 L=i.join(p,"portal.yaml");if(e.existsSync(L))try{let t=e.readFileSync(L,"utf8"),a=S.load(t);if(a?.version&&a?.gates){let n=Object.keys(a.gates||{}).length,r=Object.keys(a.routes||{}).length;s.push({name:"portal.yaml",status:"ok",message:`Valid (${n} gates, ${r} 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(t){s.push({name:"portal.yaml",status:"error",message:`Invalid YAML: ${t.message}`,fix:"Check YAML syntax in portal.yaml"});}if(e.existsSync(L))try{let{checkPortalCompliance:t,getComplianceSummary:a}=await import('./portal-compliance-4MG5F2GI.js'),n=await t(p),r=a(n);s.push({name:"Portal compliance",status:r.status,message:r.message,fix:r.status!=="ok"?"paradigm portal check":void 0});}catch{}let U=i.join(p,".paradigm","flows.yaml");if(e.existsSync(U))try{let t=e.readFileSync(U,"utf8"),a=S.load(t);if(a?.version&&a?.flows){let n=Object.keys(a.flows||{}).length,r=Object.entries(a.flows||{}).filter(([,f])=>!f?.steps||(f.steps?.length??0)===0);r.length>0?s.push({name:".paradigm/flows.yaml",status:"warn",message:`${n} flows defined, ${r.length} have no steps`,fix:"Add steps to empty flow definitions"}):s.push({name:".paradigm/flows.yaml",status:"ok",message:`Valid (${n} 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(t){s.push({name:".paradigm/flows.yaml",status:"error",message:`Invalid YAML: ${t.message}`,fix:"Check YAML syntax in flows.yaml"});}let H=i.join(p,".paradigm","lore");if(e.existsSync(H))try{let t=e.readdirSync(H).filter(a=>a.endsWith(".yaml"));t.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:`${t.length} lore file${t.length>1?"s":""}`});}catch{s.push({name:"Lore entries",status:"warn",message:"Could not read lore directory"});}let G=i.join(p,".paradigm","university");if(e.existsSync(G))try{let t=i.join(G,"content"),a=0,n=0;if(e.existsSync(t))for(let r of ["notes","policies","quizzes","paths"]){let f=i.join(t,r);e.existsSync(f)&&(a+=e.readdirSync(f).filter(h=>h.endsWith(".md")||h.endsWith(".yaml")).length);}if(a===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 r=i.join(t,"quizzes");if(e.existsSync(r))for(let h of e.readdirSync(r).filter(u=>u.endsWith(".yaml")))try{let u=S.load(e.readFileSync(i.join(r,h),"utf8"));if(u?.questions)for(let d of u.questions)d.choices&&d.correct&&!(d.correct in d.choices)&&n++;}catch{}let f=i.join(t,"paths");if(e.existsSync(f))for(let h of e.readdirSync(f).filter(u=>u.endsWith(".yaml")))try{let u=S.load(e.readFileSync(i.join(f,h),"utf8"));if(u?.steps){for(let d of u.steps)if(d.content&&!d.content.startsWith("plsat:")){let y=!1;for(let F of ["notes","policies","quizzes","paths"]){let g=i.join(t,F);if(e.existsSync(g)&&e.readdirSync(g).some(k=>k.startsWith(d.content))){y=!0;break}}y||n++;}}}catch{}n>0?s.push({name:"University content",status:"warn",message:`${a} items, ${n} issue${n>1?"s":""}`,fix:"Run: paradigm university validate --deep"}):s.push({name:"University content",status:"ok",message:`${a} content item${a>1?"s":""}`});}}catch{s.push({name:"University content",status:"warn",message:"Could not read university directory"});}let _=i.join(p,".claude","hooks.json"),ss=i.join(p,"plugins","paradigm","hooks.json");if(e.existsSync(_)){let t=e.statSync(_),a=Date.now()-t.mtime.getTime(),n=Math.floor(a/(1e3*60*60*24));n>30?s.push({name:"Claude Code hooks",status:"warn",message:`Hooks are ${n} days old \u2014 may be outdated`,fix:"paradigm hooks install"}):s.push({name:"Claude Code hooks",status:"ok",message:n>0?`${n} days old`:"Fresh"});}else e.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(e.existsSync(V))try{let t=e.readFileSync(V,"utf8"),a=S.load(t);if(a?.version&&Array.isArray(a?.habits)){let n=a.habits.filter(r=>r.enabled!==!1).length;s.push({name:"Habits config",status:"ok",message:`Valid (${n}/${a.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(t){s.push({name:"Habits config",status:"error",message:`Invalid YAML: ${t.message}`,fix:"Check YAML syntax in habits.yaml"});}let J=i.join(p,"AGENTS.md");if(e.existsSync(J)){let t=e.statSync(J),a=Date.now()-t.mtime.getTime(),n=Math.floor(a/(1e3*60*60*24));n>60?s.push({name:"AGENTS.md",status:"warn",message:`${n} days since last update \u2014 may be stale`,fix:"paradigm sync"}):s.push({name:"AGENTS.md",status:"ok",message:n>0?`Updated ${n} days ago`:"Fresh"});}}let T=0,W=0,$=0;for(let o of s){let m,c;switch(o.status){case "ok":m="\u2713",c=l.green;break;case "warn":m="\u26A0",c=l.yellow,W++;break;case "error":m="\u2717",c=l.red,T++;break;case "missing":m="\u25CB",c=l.gray,$++;break}if(!w){let v=o.name.padEnd(30);console.log(` ${c(m)} ${v} ${c(o.message)}`),o.fix&&console.log(l.gray(` \u2514\u2500 Fix: ${o.fix}`));}}let{runContextAudit:Z}=await import('./context-audit-XRPT3OU2.js'),M=await Z(p,{quiet:w}),z=0,O=0,b=0;!w&&M.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 o of M){let m,c;switch(o.status){case "ok":m="\u2713",c=l.green;break;case "warn":m="\u26A0",c=l.yellow,O++;break;case "error":m="\u2717",c=l.red,z++;break;case "advisory":m="\u2139",c=l.cyan,b++;break}if(!w){let v=o.check.padEnd(30);if(console.log(` ${c(m)} ${v} ${c(o.message)}`),o.details&&o.details.length>0){let A=o.details.slice(0,5);for(let q of A)console.log(l.gray(` \u2502 ${q}`));o.details.length>5&&console.log(l.gray(` \u2502 ... and ${o.details.length-5} more`));}o.fix&&console.log(l.gray(` \u2514\u2500 Fix: ${o.fix}`));}}let C=T+z,j=W+O,D=C+j+$===0;if(!w)if(console.log(""),D)console.log(l.green(`\u2728 All checks passed!
|
|
7
|
+
`));else {let o=[];C>0&&o.push(l.red(`${C} error${C>1?"s":""}`)),j>0&&o.push(l.yellow(`${j} warning${j>1?"s":""}`)),$>0&&o.push(l.gray(`${$} missing`)),b>0&&o.push(l.cyan(`${b} advisor${b>1?"ies":"y"}`)),console.log(`${o.join(", ")} found.
|
|
8
|
+
`),console.log(l.gray("Run the suggested commands to fix issues.")),console.log(l.gray(`Troubleshooting guide: .paradigm/docs/troubleshooting.md
|
|
9
9
|
`));}if(!w&&P.explain&&!D)try{let{narrateAllGaps:o}=await import('./gap-narrator-NTXLUI7I.js'),m=[];for(let c of s)c.status!=="ok"&&(c.name===".purpose"||c.name.startsWith("Purpose-required")?m.push({type:"missing-purpose",target:c.name,severity:"improvement"}):c.name===".paradigm/scan-index.json"&&c.status==="warn"?m.push({type:"index-stale",target:c.name,severity:"improvement"}):c.name==="Portal compliance"?m.push({type:"portal-mismatch",target:c.name,severity:c.status==="error"?"blocking":"improvement"}):c.name==="Clarification markers"&&m.push({type:"missing-description",target:c.name,severity:"improvement"}));if(m.length>0){let c=o(m);console.log(l.blue(`
|
|
10
10
|
Gap Narrations (--explain)
|
|
11
|
-
`)),console.log(l.gray(c.narrative)),console.log("");}}catch{}return D?I.success("All health checks passed",{total:s.length+M.length}):I.error("Health checks found issues",{errors:
|
|
11
|
+
`)),console.log(l.gray(c.narrative)),console.log("");}}catch{}return D?I.success("All health checks passed",{total:s.length+M.length}):I.error("Health checks found issues",{errors:C,warnings:j,missing:$,advisories:b}),D}export{rs as a};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {b as b$1,a as a$1}from'./chunk-EK4ZRIFJ.js';import {q as q$1,p}from'./chunk-NEJ4ZLCY.js';import {d}from'./chunk-5TAVYPOV.js';import*as r from'fs';import*as a from'path';import*as x from'os';import*as T from'crypto';import*as h from'js-yaml';function w(){let n=a.join(x.homedir(),".paradigm");return r.existsSync(n)||r.mkdirSync(n,{recursive:true}),n}function M(n){let s=a.resolve(n);return T.createHash("sha256").update(s).digest("hex").slice(0,12)}function f(n){let s=M(n),e=a.join(w(),"sessions",s);r.existsSync(e)||r.mkdirSync(e,{recursive:true});let t=a.join(e,"pending-handoffs");return r.existsSync(t)||r.mkdirSync(t,{recursive:true}),e}function S(n){let s=f(n),e=a.join(s,"_project-meta.json"),o={name:a.basename(a.resolve(n)),path:a.resolve(n),lastSeen:new Date().toISOString()};r.writeFileSync(e,JSON.stringify(o,null,2));}function O(n,s){let e=f(n),t=a.join(e,"pending-handoffs",`${s.id}.json`);r.writeFileSync(t,JSON.stringify(s,null,2));}function A(n){let s=f(n),e=a.join(s,"pending-handoffs");if(!r.existsSync(e))return [];let t=[];try{let o=r.readdirSync(e);for(let l of o)if(l.endsWith(".json"))try{let u=r.readFileSync(a.join(e,l),"utf8"),m=JSON.parse(u);m.status==="pending"&&t.push(m);}catch{}}catch{}return t.sort((o,l)=>new Date(o.timestamp).getTime()-new Date(l.timestamp).getTime()),t}function W(n,s){let e=f(n),t=a.join(e,"pending-handoffs",`${s}.json`);if(r.existsSync(t))try{let o=r.readFileSync(t,"utf8"),l=JSON.parse(o);l.status="delivered",r.writeFileSync(t,JSON.stringify(l,null,2));}catch{}}function y(){let n=a.join(w(),"wisdom");return r.existsSync(n)||r.mkdirSync(n,{recursive:true}),n}function H(){let n=a.join(y(),"antipatterns.yaml");if(!r.existsSync(n))return [];try{let s=r.readFileSync(n,"utf8");return h.load(s)?.antipatterns||[]}catch{return []}}function L(){let n=a.join(y(),"decisions");if(!r.existsSync(n))return [];let s=[];try{let e=r.readdirSync(n);for(let t of e)if(!(!t.endsWith(".yaml")&&!t.endsWith(".yml")))try{let o=r.readFileSync(a.join(n,t),"utf8"),l=h.load(o);s.push(l);}catch{}}catch{}return s.sort((e,t)=>e.id.localeCompare(t.id)),s}function _(){let n=a.join(y(),"preferences.yaml");if(!r.existsSync(n))return null;try{let s=r.readFileSync(n,"utf8");return h.load(s)}catch{return null}}function J(n){let s=a.join(y(),"antipatterns.yaml"),e={version:"1.0",antipatterns:[]};if(r.existsSync(s))try{let t=r.readFileSync(s,"utf8");e=h.load(t),e.antipatterns||(e.antipatterns=[]);}catch{}e.antipatterns.push({...n,added:new Date().toISOString()}),r.writeFileSync(s,h.dump(e,{lineWidth:-1}));}function U(n){let s=a.join(y(),"decisions");r.existsSync(s)||r.mkdirSync(s,{recursive:true});let e=n.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""),t=`${n.id}-${e}.yaml`,o=a.join(s,t);r.writeFileSync(o,h.dump(n,{lineWidth:-1}));}b$1();var k={"claude-opus-4":{input:15,output:75,name:"Claude Opus 4"},"claude-sonnet-4":{input:3,output:15,name:"Claude Sonnet 4"},"claude-haiku-3.5":{input:.8,output:4,name:"Claude Haiku 3.5"}},j=50,P=".paradigm/session-breadcrumbs.json",I=".paradigm/session-checkpoint.json",E=10080*60*1e3,C=class{session;rootDir=null;_recovered=false;lastLoreEntryId=null;constructor(){this.session=this.createNewSession();}setRootDir(s){this.rootDir=s;try{let{clearSessionWorkLog:e}=(q$1(),d(p));e(s);}catch{}}createNewSession(){return {sessionId:`s${Date.now().toString(36)}`,startTime:Date.now(),lastActivity:Date.now(),model:"claude-sonnet-4",resourceReads:[],toolCalls:[],breadcrumbs:[],totals:{resourceReadCount:0,toolCallCount:0,totalBytes:0,totalTokens:0,estimatedCostUsd:0}}}addBreadcrumb(s,e,t={}){this.session.breadcrumbs.push({timestamp:Date.now(),action:s,tool:t.tool,symbol:t.symbol,summary:e}),this.session.breadcrumbs.length>j&&(this.session.breadcrumbs=this.session.breadcrumbs.slice(-j)),this.persistBreadcrumbs();}getBreadcrumbs(s=20){return this.session.breadcrumbs.slice(-s)}persistBreadcrumbs(){if(!this.rootDir)return;let s={sessionId:this.session.sessionId,startTime:this.session.startTime,lastActivity:this.session.lastActivity,breadcrumbs:this.session.breadcrumbs,symbolsModified:this.extractSymbolsFromBreadcrumbs(),filesExplored:this.extractFilesFromBreadcrumbs()},e;try{e=JSON.stringify(s,null,2);}catch(t){a$1.component("#session-tracker").error("persistBreadcrumbs: JSON.stringify failed",{error:t.message});return}try{let t=a.join(this.rootDir,P),o=a.dirname(t);r.existsSync(o)||r.mkdirSync(o,{recursive:!0}),r.writeFileSync(t,e);}catch(t){a$1.component("#session-tracker").error("persistBreadcrumbs: local write failed",{error:t.message});}try{let t=f(this.rootDir);r.writeFileSync(a.join(t,"breadcrumbs.json"),e),S(this.rootDir);}catch(t){a$1.component("#session-tracker").error("persistBreadcrumbs: global write failed",{error:t.message});}}loadPreviousSession(){if(!this.rootDir)return null;try{let s=f(this.rootDir),e=a.join(s,"breadcrumbs.json");if(r.existsSync(e)){let t=r.readFileSync(e,"utf8");return JSON.parse(t)}}catch{}try{let s=a.join(this.rootDir,P);if(!r.existsSync(s))return null;let e=r.readFileSync(s,"utf8");return JSON.parse(e)}catch{return null}}saveCheckpoint(s){let e={phase:s.phase,context:s.context,timestamp:Date.now(),sessionId:this.session.sessionId,externalId:s.externalId,plan:s.plan,modifiedFiles:s.modifiedFiles,symbolsTouched:s.symbolsTouched,decisions:s.decisions,recentBreadcrumbs:this.session.breadcrumbs.slice(-10)},t=this.persistCheckpoint(e);return {checkpoint:e,persisted:t}}loadCheckpoint(){if(!this.rootDir)return null;let s=null;try{let e=f(this.rootDir),t=a.join(e,"checkpoint.json");if(r.existsSync(t)){let o=r.readFileSync(t,"utf8");s=JSON.parse(o);}}catch{}if(!s)try{let e=a.join(this.rootDir,I);if(r.existsSync(e)){let t=r.readFileSync(e,"utf8");s=JSON.parse(t);}}catch{}if(s&&Date.now()-s.timestamp>E)return null;if(s)for(let e of ["modifiedFiles","symbolsTouched","decisions"]){let t=s[e];if(typeof t=="string")try{s[e]=JSON.parse(t);}catch{s[e]=[];}}return s}persistCheckpoint(s){let e={local:false,global:false};if(!this.rootDir)return a$1.component("#session-tracker").warn("persistCheckpoint: rootDir not set, skipping write"),e;let t;try{t=JSON.stringify(s,null,2);}catch(o){return a$1.component("#session-tracker").error("persistCheckpoint: JSON.stringify failed",{error:o.message}),e}try{let o=a.join(this.rootDir,I),l=a.dirname(o);r.existsSync(l)||r.mkdirSync(l,{recursive:!0}),r.writeFileSync(o,t),e.local=!0;}catch(o){a$1.component("#session-tracker").error("persistCheckpoint: local write failed",{error:o.message});}try{let o=f(this.rootDir);r.writeFileSync(a.join(o,"checkpoint.json"),t),S(this.rootDir),e.global=!0;}catch(o){a$1.component("#session-tracker").error("persistCheckpoint: global write failed",{error:o.message});}return e}setLastLoreEntryId(s){this.lastLoreEntryId=s;}getLastLoreEntryId(){return this.lastLoreEntryId}hasRecoveredThisSession(){return this._recovered}markRecovered(){this._recovered=true;}extractSymbolsFromBreadcrumbs(){let s=new Set;for(let e of this.session.breadcrumbs)e.symbol&&s.add(e.symbol);return Array.from(s)}extractFilesFromBreadcrumbs(){let s=new Set;for(let e of this.session.breadcrumbs){let t=e.summary.match(/\b[\w./]+\.(ts|js|tsx|jsx|py|go|rs|yaml|json|md)\b/g);if(t)for(let o of t)s.add(o);}return Array.from(s)}estimateTokens(s){let e=typeof s=="number"?s:s.length;return Math.ceil(e/3.5)}calculateCost(s,e=true){let t=k[this.session.model],o=e?t.output:t.input;return s/1e6*o}setModel(s){this.session.model=s,this.recalculateTotals();}getModel(){return this.session.model}trackResourceRead(s,e){let t=this.extractResourceType(s),o=this.estimateTokens(e);this.session.resourceReads.push({timestamp:Date.now(),resourceType:t,uri:s,bytes:e,tokens:o}),this.session.lastActivity=Date.now(),this.updateTotals(e,o);}trackToolCall(s,e){let t=this.estimateTokens(e);this.session.toolCalls.push({timestamp:Date.now(),toolName:s,responseBytes:e,responseTokens:t}),this.session.lastActivity=Date.now(),this.updateTotals(e,t);}updateTotals(s,e){this.session.totals.resourceReadCount=this.session.resourceReads.length,this.session.totals.toolCallCount=this.session.toolCalls.length,this.session.totals.totalBytes+=s,this.session.totals.totalTokens+=e,this.session.totals.estimatedCostUsd=this.calculateCost(this.session.totals.totalTokens);}recalculateTotals(){this.session.totals.estimatedCostUsd=this.calculateCost(this.session.totals.totalTokens);}extractResourceType(s){return s.replace("paradigm://","").split("/")[0]||"unknown"}getStats(){return {...this.session}}getCostBreakdown(){let s={},e=0,t=0;for(let i of this.session.resourceReads)s[i.resourceType]||(s[i.resourceType]={count:0,bytes:0,tokens:0}),s[i.resourceType].count++,s[i.resourceType].bytes+=i.bytes,s[i.resourceType].tokens+=i.tokens,e+=i.bytes,t+=i.tokens;let o={},l=0,u=0;for(let i of this.session.toolCalls)o[i.toolName]||(o[i.toolName]={count:0,bytes:0,tokens:0}),o[i.toolName].count++,o[i.toolName].bytes+=i.responseBytes,o[i.toolName].tokens+=i.responseTokens,l+=i.responseBytes,u+=i.responseTokens;let m=t+u,g=this.calculateCost(m);return {model:k[this.session.model].name,modelId:this.session.model,pricing:k[this.session.model],resources:{count:this.session.resourceReads.length,bytes:e,tokens:t,costUsd:this.calculateCost(t),byType:s},tools:{count:this.session.toolCalls.length,bytes:l,tokens:u,costUsd:this.calculateCost(u),byName:o},total:{tokens:m,costUsd:g}}}getHandoffRecommendation(s=2e5,e){let t=this.session.totals.totalTokens,o=t*4,l=e||t+o,u=Math.round(l/s*100),m,g;u>=85?(m="handoff-urgent",g="Context is nearly full. Initiate handoff immediately to preserve session continuity."):u>=70?(m="handoff-recommended",g="Context usage is high. Consider initiating handoff soon to ensure smooth transition."):u>=50?(m="consider-handoff",g="Context usage is moderate. Plan a good stopping point for potential handoff."):(m="continue",g="Context usage is healthy. Continue working.");let i=[],v=Math.round((Date.now()-this.session.startTime)/6e4),D=this.session.toolCalls.length+this.session.resourceReads.length;return D>50&&i.push(`High number of MCP interactions (${D})`),v>30&&i.push(`Session duration >30 min (${v} min)`),this.session.totals.totalBytes>5e5&&i.push(`Large data volume (${Math.round(this.session.totals.totalBytes/1024)}KB)`),{recommendation:m,message:g,usagePercent:u,signals:i}}getDurationMinutes(){return Math.round((Date.now()-this.session.startTime)/6e4)}reset(){this.session=this.createNewSession(),this._recovered=false,this.lastLoreEntryId=null;}},b=null;function X(){return b||(b=new C),b}function q(){b&&b.reset();}
|
|
3
|
+
export{O as a,A as b,W as c,H as d,L as e,_ as f,J as g,U as h,k as i,X as j,q as k};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {c,b}from'./chunk-5TAVYPOV.js';import*as e from'fs';import*as o from'path';var D={};c(D,{appendSessionWorkEntry:()=>C,appendVerdictEntry:()=>N,clearActivityMetrics:()=>j,clearSessionWorkLog:()=>I,countNotebookReferences:()=>w,getAgentEntries:()=>S,getAgentVerdicts:()=>P,getContributingAgents:()=>A,getNotebookReferences:()=>h,getSessionActivitySummary:()=>W,markVerdictsConsumed:()=>O,readPendingVerdicts:()=>M,readSessionWorkLog:()=>g,recordActivityMetric:()=>F,recordNotebookReference:()=>R});function C(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(a=>a.trim()).length>=x)return;let f=JSON.stringify(n)+`
|
|
4
|
+
`;e.appendFileSync(t,f,"utf8"),n.type==="user-verdict"&&n.agent&&n.symbols?.length&&import('./agent-loader-RJRVO5GQ.js').then(({loadAgentProfile:c,saveAgentProfile:s})=>{try{let a=c(i,n.agent);if(a?.expertise){let u=n.verdict==="accepted"?.03:n.verdict==="dismissed"?-.02:n.verdict==="revised"?-.01:0;if(u!==0){for(let v of n.symbols){let l=a.expertise.find(k=>k.symbol===v);l&&(l.confidence=Math.max(0,Math.min(1,l.confidence+u)),l.sessions=(l.sessions||0)+1,l.lastTouch=new Date().toISOString());}s(n.agent,a,"global");}}}catch{}}).catch(()=>{});}catch{}}function g(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 I(i){try{let n=o.join(i,y);e.existsSync(n)&&e.writeFileSync(n,"","utf8");}catch{}}function N(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 M(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 O(i,n){try{let t=o.join(i,p);if(!e.existsSync(t))return;let r=new Set(n),c=e.readFileSync(t,"utf8").trim().split(`
|
|
8
|
+
`).filter(s=>s.trim()).map(s=>{try{let a=JSON.parse(s);return a.nominationId&&r.has(a.nominationId)?JSON.stringify({...a,consumed:!0}):s}catch{return s}});e.writeFileSync(t,c.join(`
|
|
9
|
+
`)+`
|
|
10
|
+
`,"utf8");}catch{}}function A(i){let n=g(i),t=new Set;for(let r of n)r.agent&&t.add(r.agent);return Array.from(t)}function S(i,n){return g(i).filter(t=>t.agent===n)}function P(i,n){let t=S(i,n),r=t.filter(s=>s.type==="agent-contribution"),f=t.filter(s=>s.type==="user-verdict"),c=[];for(let s of r)c.push({contribution:s});for(let s of f){let a=c.find(u=>!u.verdict&&u.contribution);a?a.verdict=s:c.push({verdict:s});}return c}function F(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},c=JSON.stringify(f)+`
|
|
11
|
+
`;e.appendFileSync(t,c,"utf8");}catch{}}function B(i){try{let n=o.join(i,d);return e.existsSync(n)?e.readFileSync(n,"utf8").trim().split(`
|
|
12
|
+
`).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=B(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 j(i){try{let n=o.join(i,d);e.existsSync(n)&&e.writeFileSync(n,"","utf8");}catch{}}function R(i,n,t,r){try{if(t.length===0)return;let f=o.join(i,m),c=o.dirname(f);e.existsSync(c)||e.mkdirSync(c,{recursive:!0});let s={timestamp:new Date().toISOString(),type:"notebook-reference",agentId:n,notebookEntryIds:t,...r?{orchestrationId:r}:{}},a=JSON.stringify(s)+`
|
|
13
|
+
`;e.appendFileSync(f,a,"utf8");}catch{}}function h(i){try{let n=o.join(i,m);return e.existsSync(n)?e.readFileSync(n,"utf8").trim().split(`
|
|
14
|
+
`).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 w(i){return h(i).length}var y,d,p,x,m,J=b(()=>{y=".paradigm/events/session-log.jsonl",d=".paradigm/events/session-metrics.jsonl",p=".paradigm/events/verdicts.jsonl",x=200,m=".paradigm/events/notebook-refs.jsonl";});export{C as a,g as b,I as c,N as d,M as e,O as f,A as g,S as h,P as i,F as j,W as k,j as l,R as m,h as n,w as o,D as p,J as q};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {c,b}from'./chunk-5TAVYPOV.js';import*as i from'fs';import*as l from'path';import*as k from'os';import*as g from'js-yaml';var $={};c($,{addNotebookEntry:()=>N,classifyNotebookScope:()=>w,incrementApplied:()=>P,loadNotebookEntries:()=>S,promoteFromLore:()=>_,searchNotebooks:()=>O});function S(e,t,n){let r=new Map,a=l.join(u,e);h(a,r);let o=l.join(t,d,e);h(o,r);let c=Array.from(r.values());if(n?.concepts&&n.concepts.length>0){let p=new Set(n.concepts.map(s=>s.toLowerCase()));c=c.filter(s=>s.concepts.some(f=>p.has(f.toLowerCase())));}if(n?.tags&&n.tags.length>0){let p=new Set(n.tags.map(s=>s.toLowerCase()));c=c.filter(s=>s.tags.some(f=>p.has(f.toLowerCase())));}return c.sort((p,s)=>s.appliedCount-p.appliedCount)}function h(e,t){if(i.existsSync(e))try{let n=i.readdirSync(e).filter(r=>r.startsWith(L)&&r.endsWith(y));for(let r of n)try{let a=i.readFileSync(l.join(e,r),"utf-8"),o=g.load(a);o?.id&&t.set(o.id,o);}catch{}}catch{}}function O(e,t,n){let r=S(e,n),a=t.toLowerCase();return r.filter(o=>o.context.toLowerCase().includes(a)||o.snippet.toLowerCase().includes(a)||o.concepts.some(c=>c.toLowerCase().includes(a))||o.tags.some(c=>c.toLowerCase().includes(a)))}function w(e){let t=[e.context,e.snippet,...e.concepts,...e.tags].join(" ").toLowerCase();return ["paradigm","mcp_","mcp tool",".paradigm/","lore entry","lore record","aspect","^gate","portal.yaml",".purpose","sentinel","symphony","ambient nomination","paradigm_"," pan ","agent notebook","concept anchor","symbol system","work log","knowledge stream","nevr.land","neverland"].some(r=>t.includes(r))?"platform-specific":/[#$^!~][a-z][a-z0-9-]{2,}/.test(t)||/\/[a-z0-9_-]{2,}\/[a-z0-9_-]/.test(t)?"project-specific":"generalizable"}function N(e,t,n,r){let a=new Date().toISOString(),o=(t.concepts[0]||t.context.split(" ").slice(0,4).join(" ")||"entry").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,40),p=`nb-${e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}-${o}`,s=t.scope??w({context:t.context,snippet:t.snippet,concepts:t.concepts,tags:t.tags}),f={...t,id:p,scope:s,publishable:t.publishable??true,appliedCount:0,created:a,updated:a},m=n==="global"?l.join(u,e):l.join(r||process.cwd(),d,e);i.existsSync(m)||i.mkdirSync(m,{recursive:true});let E=`${p}${y}`,b=l.join(m,E),C=g.dump(f,{lineWidth:120,noRefs:true,sortKeys:false});return i.writeFileSync(b,C,"utf-8"),{entry:f,filePath:b}}async function _(e,t,n,r="global"){let{loadLoreEntry:a}=await import('./lore-loader-RVQI5GXL.js'),o=await a(n,t);if(!o)return null;let c=[];if(o.symbols_touched)for(let f of o.symbols_touched){let m=f.replace(/^[#$^!~]/,"").toLowerCase();c.push(m);}let p=o.summary||"";o.body&&(p+=`
|
|
3
|
+
|
|
4
|
+
`+o.body);let s={source:"lore",loreEntryId:t,originProject:l.basename(n),createdBy:e};return N(e,{context:o.title||`Promoted from ${t}`,snippet:p,provenance:s,confidence:o.confidence??.7,concepts:c,tags:o.tags||[]},r,n)}function P(e,t,n){let r=l.join(n,d,e),a=l.join(u,e);for(let o of [r,a]){let c=l.join(o,`${t}${y}`);if(i.existsSync(c))try{let p=i.readFileSync(c,"utf-8"),s=g.load(p);if(s)return s.appliedCount=(s.appliedCount||0)+1,s.updated=new Date().toISOString(),i.writeFileSync(c,g.dump(s,{lineWidth:120,noRefs:!0,sortKeys:!1}),"utf-8"),!0}catch{}}return false}var u,d,L,y,v=b(()=>{u=l.join(k.homedir(),".paradigm","notebooks"),d=".paradigm/notebooks",L="nb-",y=".yaml";});export{S as a,O as b,w as c,N as d,_ as e,P as f,$ as g,v as h};
|