@a-company/paradigm 6.6.6 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{accept-orchestration-JHDCVHB2.js → accept-orchestration-YO2V2WYA.js} +1 -1
- package/dist/{agents-suggest-IKY6VD2R.js → agents-suggest-WZEGQT5E.js} +1 -1
- package/dist/ambient-7HBJHJL2.js +2 -0
- package/dist/{ambient-FNNFB4AP.js → ambient-OX7YJ4PJ.js} +1 -1
- package/dist/ambient-SST5CLEC.js +35 -0
- package/dist/captain-YUP3KVCA.js +2 -0
- package/dist/chunk-33ERV2MW.js +18 -0
- package/dist/chunk-3MZ4J2LF.js +2 -0
- package/dist/chunk-47YPID6H.js +142 -0
- package/dist/chunk-6AKNXD22.js +32 -0
- package/dist/chunk-6HVOZANP.js +4 -0
- package/dist/chunk-ACJWUOMA.js +3 -0
- package/dist/chunk-B5KLSBOZ.js +2 -0
- package/dist/chunk-DLMDHS2X.js +10 -0
- package/dist/chunk-FRQRREJ6.js +29 -0
- package/dist/{chunk-5RFISGUW.js → chunk-G6DK3ND3.js} +250 -25
- package/dist/{chunk-XKNJSPB5.js → chunk-JCGCPAHF.js} +1 -1
- package/dist/chunk-K54L6CFR.js +25 -0
- package/dist/chunk-QBIQ2FYB.js +20 -0
- package/dist/chunk-QEQCPVF5.js +4 -0
- package/dist/chunk-ROU3F2HZ.js +6 -0
- package/dist/chunk-S4J337EQ.js +504 -0
- package/dist/chunk-V6MIKLMY.js +18 -0
- package/dist/chunk-WROJSWAO.js +93 -0
- package/dist/{chunk-TQOT2LBO.js → chunk-YXLGVOZO.js} +1 -1
- package/dist/chunk-ZSWXLFN7.js +12 -0
- package/dist/{compliance-J3VOV445.js → compliance-MLG4W6S4.js} +1 -1
- package/dist/{diff-ANKTFDRA.js → diff-MC6AXLKX.js} +1 -1
- package/dist/{docs-TSAAS4W3.js → docs-3YFNNZRV.js} +1 -1
- package/dist/doctor-CBZYYQQH.js +2 -0
- package/dist/{hooks-45WDP6QS.js → hooks-AXBWYJ5V.js} +1 -1
- package/dist/index.js +4 -4
- package/dist/mcp.js +3 -3
- package/dist/{migrate-R64OQGSM.js → migrate-5M4KUQ2L.js} +1 -1
- package/dist/{nomination-engine-NCLTGMAK.js → nomination-engine-AQHU2KBU.js} +1 -1
- package/dist/notebook-loader-6DYFMNJ2.js +2 -0
- package/dist/orchestrate-GMYEBA5T.js +8 -0
- package/dist/orchestration-G5MAY6IA.js +2 -0
- package/dist/propose-block-ZEMEWJQF.js +2 -0
- package/dist/{providers-TBPOE4DI.js → providers-5EHD45C6.js} +1 -1
- package/dist/reindex-XTRF23F7.js +2 -0
- package/dist/{serve-3FMUWW5K.js → serve-SMGWGJLM.js} +1 -1
- package/dist/session-tracker-BZ7FU4AT.js +2 -0
- package/dist/session-work-log-QXPAXY5K.js +2 -0
- package/dist/session-work-log-T2IE4Y4T.js +2 -0
- package/dist/{shift-TNA2E5O7.js → shift-JBCEDCGA.js} +2 -2
- package/dist/solo-OWR3MX74.js +3 -0
- package/dist/{spawn-KKDDR6UR.js → spawn-PHA2SVQ3.js} +1 -1
- package/dist/task-loader-IGQQ6ZFL.js +2 -0
- package/dist/task-settlement-NW4XMJGJ.js +3 -0
- package/dist/{team-PEGP6F7S.js → team-J2YXPEGX.js} +1 -1
- package/dist/team-funnel-RAJ6EDG3.js +2 -0
- package/dist/tools-HNJ7D5IO.js +2 -0
- package/dist/university-content/notes/N-para-801-cid-becomes-real.md +60 -0
- package/dist/university-content/notes/N-para-801-falsifiable-self-improvement.md +66 -0
- package/dist/university-content/notes/N-para-801-honest-routing-and-the-method.md +57 -0
- package/dist/university-content/notes/N-para-801-orchestration-emits-dag.md +60 -0
- package/dist/university-content/notes/N-para-801-settlement-closes-the-loop.md +64 -0
- package/dist/university-content/notes/N-para-801-the-task-dag.md +93 -0
- package/dist/university-content/paths/LP-para-801.yaml +43 -0
- package/dist/university-content/quizzes/Q-para-801-cid-becomes-real.yaml +54 -0
- package/dist/university-content/quizzes/Q-para-801-falsifiable-self-improvement.yaml +54 -0
- package/dist/university-content/quizzes/Q-para-801-honest-routing-and-the-method.yaml +54 -0
- package/dist/university-content/quizzes/Q-para-801-orchestration-emits-dag.yaml +54 -0
- package/dist/university-content/quizzes/Q-para-801-settlement-closes-the-loop.yaml +54 -0
- package/dist/university-content/quizzes/Q-para-801-the-task-dag.yaml +54 -0
- package/dist/university-ui/assets/{index-DrtbBC21.js → index-B8hm_MdR.js} +2 -2
- package/dist/university-ui/assets/{index-DrtbBC21.js.map → index-B8hm_MdR.js.map} +1 -1
- package/dist/university-ui/index.html +1 -1
- package/package.json +1 -1
- package/dist/ambient-AI42BOM5.js +0 -35
- package/dist/chunk-3OXR6F65.js +0 -666
- package/dist/chunk-4N56FRNE.js +0 -29
- package/dist/chunk-6QXBXZF6.js +0 -3
- package/dist/chunk-AMLD7IYC.js +0 -10
- package/dist/chunk-DVZWCXB6.js +0 -2
- package/dist/chunk-F6E3HW45.js +0 -14
- package/dist/chunk-K7X3Z3GL.js +0 -4
- package/dist/chunk-LAYBUKMB.js +0 -14
- package/dist/chunk-MU5YWTNE.js +0 -24
- package/dist/chunk-PMKZMCTS.js +0 -111
- package/dist/chunk-XQLO5URP.js +0 -11
- package/dist/doctor-L5XZENCF.js +0 -2
- package/dist/notebook-loader-3J2OFMS3.js +0 -2
- package/dist/orchestrate-UG5QXNAU.js +0 -8
- package/dist/reindex-PTIQ2UGY.js +0 -2
- package/dist/session-tracker-HHNY6J4I.js +0 -2
- package/dist/session-work-log-MEJ33TYD.js +0 -2
- package/dist/session-work-log-ZVVJGO7X.js +0 -2
- package/dist/task-loader-NZFDTUQ5.js +0 -2
- package/dist/tools-PUSDXUYE.js +0 -2
- /package/dist/{chunk-HXGYVS2N.js → chunk-ECLUYHAR.js} +0 -0
- /package/dist/{platform-server-ANOALDPL.js → platform-server-WIBVYHIV.js} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {b}from'./chunk-
|
|
2
|
+
import {b}from'./chunk-6AKNXD22.js';import'./chunk-DLMDHS2X.js';import'./chunk-FYDRENK7.js';import'./chunk-ECLUYHAR.js';import'./chunk-TYWB5IQJ.js';import'./chunk-YXLGVOZO.js';import'./chunk-EKZDFEJW.js';import'./chunk-LPBCQM5Y.js';import'./chunk-4GC35IFF.js';import'./chunk-JIXHEBGK.js';import'./chunk-ZJQY5PPP.js';import'./chunk-5TAVYPOV.js';import*as g from'path';import e from'chalk';async function u(n,s,r){let a=s?g.resolve(s):process.cwd();if(!n){r.json?console.log(JSON.stringify({error:"Orchestration ID required"})):(console.log(e.red(`
|
|
3
3
|
Orchestration ID required.`)),console.log(e.gray(`Usage: paradigm team accept <orchestration-id>
|
|
4
4
|
`)));return}let l=new b(a),o=l.getOrchestration(n);if(!o){r.json?console.log(JSON.stringify({error:"Orchestration not found",id:n})):console.log(e.red(`
|
|
5
5
|
Orchestration not found: ${n}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {a}from'./chunk-TYWB5IQJ.js';import {e}from'./chunk-
|
|
2
|
+
import {a}from'./chunk-TYWB5IQJ.js';import {e}from'./chunk-YXLGVOZO.js';import'./chunk-5TAVYPOV.js';import o from'chalk';async function y(s,g){let r=process.cwd(),t=e(r);t||(g.json?console.log(JSON.stringify({error:"No agents.yaml found"})):console.log(o.red("\nNo agents.yaml found. Run `paradigm team init` first.\n")),process.exit(1));let e$1=a(s,t.agents);if(g.json){console.log(JSON.stringify({task:s,suggestions:e$1},null,2));return}if(console.log(o.cyan(`
|
|
3
3
|
Suggested agents for this task:
|
|
4
4
|
`)),console.log(o.gray(` Task: "${s}"
|
|
5
5
|
`)),e$1.length===0){console.log(o.yellow(` No agents matched. Consider using architect \u2192 builder flow.
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
export{a as getAmbientToolsList,b as handleAmbientTool,c as runPostflightLearning}from'./chunk-ROU3F2HZ.js';import'./chunk-FRQRREJ6.js';import'./chunk-3KVVC4WV.js';import'./chunk-QEQCPVF5.js';import'./chunk-Q527BPUF.js';import'./chunk-KAFQA7HV.js';import'./chunk-33ERV2MW.js';import'./chunk-EK4ZRIFJ.js';import'./chunk-QGZRM6ZB.js';import'./chunk-5TAVYPOV.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import'./chunk-5TAVYPOV.js';import*as s from'path';import t from'chalk';async function g(n){let e=n.project?s.resolve(n.project):process.cwd(),r=n.dryRun===true,{readPendingVerdicts:a}=await import('./session-work-log-
|
|
2
|
+
import'./chunk-5TAVYPOV.js';import*as s from'path';import t from'chalk';async function g(n){let e=n.project?s.resolve(n.project):process.cwd(),r=n.dryRun===true,{readPendingVerdicts:a}=await import('./session-work-log-QXPAXY5K.js'),i=a(e);if(i.length===0){console.log(t.dim("[paradigm] No pending verdicts \u2014 postflight skipped."));return}console.log(t.cyan(`[paradigm] Running postflight \u2014 ${i.length} pending verdict(s)${r?" (dry run)":""}...`));let{runPostflightLearning:l}=await import('./ambient-SST5CLEC.js'),o=await l(e,{dry_run:r});if(o.journalsWritten===0&&o.promoted===0){console.log(t.dim("[paradigm] Postflight complete \u2014 no new journals written."));return}console.log(t.green("[paradigm] Postflight complete:")),o.journalsWritten>0&&console.log(` ${t.bold(o.journalsWritten)} journal entries written across ${o.agentsProcessed.length} agent(s)`),o.promoted>0&&console.log(` ${t.bold(o.promoted)} entries auto-promoted to notebooks`);}export{g as ambientPostflightCommand};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {f,p as p$1,i,c as c$1,j}from'./chunk-GD4F2HC6.js';import {e,g,b as b$1,f as f$1,h}from'./chunk-V6MIKLMY.js';import {b as b$2}from'./chunk-7SWEOPWF.js';import'./chunk-MBPLJKE5.js';import {c,b,d,a}from'./chunk-5TAVYPOV.js';import*as p from'fs';import*as w from'path';import*as P from'js-yaml';import*as ot from'os';var Tt={};c(Tt,{getJournalStats:()=>ue,loadAllJournalEntries:()=>me,loadJournalEntries:()=>F,loadJournalEntry:()=>de,recordJournalEntry:()=>H});function Q(e){let t=process.env.HOME||process.env.USERPROFILE||"";return w.join(t,".paradigm","agents",e,"journal")}function le(){let e=new Date,t=e.toISOString().slice(0,10),n=e.toISOString().slice(11,19).replace(/:/g,""),o=String(Math.floor(Math.random()*999)+1).padStart(3,"0");return `LJ-${t}-${n}-${o}`}function H(e,t){let n=new Date,o=le(),r={id:o,agent:e,timestamp:n.toISOString(),...t},i=Q(e);p.mkdirSync(i,{recursive:true});let s=w.join(i,`${o}.yaml`);return p.writeFileSync(s,P.dump(r,{lineWidth:120,noRefs:true}),"utf8"),r}function F(e,t){let n=Q(e);if(!p.existsSync(n))return [];let o=[],r=p.readdirSync(n).filter(s=>s.endsWith(".yaml"));for(let s of r)try{let a=p.readFileSync(w.join(n,s),"utf8"),d=P.load(a);d&&d.id&&o.push(d);}catch{}let i=o;return t?.trigger&&(i=i.filter(s=>s.trigger===t.trigger)),t?.project&&(i=i.filter(s=>s.project===t.project)),t?.transferable!==void 0&&(i=i.filter(s=>s.transferable===t.transferable)),t?.tag&&(i=i.filter(s=>s.tags?.some(a=>a.startsWith(t.tag)))),t?.dateFrom&&(i=i.filter(s=>s.timestamp>=t.dateFrom)),t?.dateTo&&(i=i.filter(s=>s.timestamp<=t.dateTo)),i.sort((s,a)=>a.timestamp.localeCompare(s.timestamp)),t?.limit&&(i=i.slice(0,t.limit)),i}function de(e,t){let n=Q(e),o=w.join(n,`${t}.yaml`);if(!p.existsSync(o))return null;let r=p.readFileSync(o,"utf8");return P.load(r)}function me(e){let t=process.env.HOME||process.env.USERPROFILE||"",n=w.join(t,".paradigm","agents");if(!p.existsSync(n))return [];let o=[],r=p.readdirSync(n,{withFileTypes:true}).filter(i=>i.isDirectory());for(let i of r){if(e?.agent&&i.name!==e.agent)continue;let s=F(i.name,e);o.push(...s);}return o.sort((i,s)=>s.timestamp.localeCompare(i.timestamp)),e?.limit?o.slice(0,e.limit):o}function ue(e){let t=F(e),n={},o={},r=0;for(let i of t)n[i.trigger]=(n[i.trigger]||0)+1,o[i.project]=(o[i.project]||0)+1,i.transferable&&r++;return {total:t.length,byTrigger:n,byProject:o,transferableCount:r,recentInsights:t.slice(0,5).map(i=>({id:i.id,trigger:i.trigger,insight:i.insight.slice(0,200),timestamp:i.timestamp}))}}var Z=b(()=>{});var It={};c(It,{addNotebookEntry:()=>Ct,classifyNotebookScope:()=>Ft,incrementApplied:()=>ye,loadNotebookEntries:()=>Ot,normalizeConcept:()=>W,promoteFromLore:()=>ge,searchNotebooks:()=>pe});function W(e){if(!e)return "";let t=e.trim();return t=t.replace(/^symbol:/i,""),t=t.replace(/^[#$^!~@&%?]/,""),t.trim().toLowerCase()}function Ot(e,t,n){let o=new Map,r=w.join(tt,e);Pt(r,o);let i=w.join(t,et,e);Pt(i,o);let s=Array.from(o.values());if(n?.concepts&&n.concepts.length>0){let a=new Set(n.concepts.map(W));s=s.filter(d=>d.concepts.some(l=>a.has(W(l))));}if(n?.tags&&n.tags.length>0){let a=new Set(n.tags.map(d=>d.toLowerCase()));s=s.filter(d=>d.tags.some(l=>a.has(l.toLowerCase())));}return s.sort((a,d)=>d.appliedCount-a.appliedCount)}function Pt(e,t){if(p.existsSync(e))try{let n=p.readdirSync(e).filter(o=>o.startsWith(fe)&&o.endsWith(nt));for(let o of n)try{let r=p.readFileSync(w.join(e,o),"utf-8"),i=P.load(r);i?.id&&t.set(i.id,i);}catch{}}catch{}}function pe(e,t,n){let o=Ot(e,n),r=t.toLowerCase();return o.filter(i=>i.context.toLowerCase().includes(r)||i.snippet.toLowerCase().includes(r)||i.concepts.some(s=>s.toLowerCase().includes(r))||i.tags.some(s=>s.toLowerCase().includes(r)))}function Ft(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(o=>t.includes(o))?"platform-specific":/[#$^!~][a-z][a-z0-9-]{2,}/.test(t)||/\/[a-z0-9_-]{2,}\/[a-z0-9_-]/.test(t)?"project-specific":"generalizable"}function Ct(e,t,n,o){let r=new Date().toISOString(),i=(t.concepts[0]||t.context.split(" ").slice(0,4).join(" ")||"entry").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,40),a=`nb-${e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}-${i}`,d=t.scope??Ft({context:t.context,snippet:t.snippet,concepts:t.concepts,tags:t.tags}),l=Array.from(new Set((t.concepts||[]).map(W).filter(Boolean))),m={...t,concepts:l,id:a,scope:d,publishable:t.publishable??true,appliedCount:0,created:r,updated:r},c=n==="global"?w.join(tt,e):w.join(o||process.cwd(),et,e);p.existsSync(c)||p.mkdirSync(c,{recursive:true});let u=`${a}${nt}`,g=w.join(c,u),y=P.dump(m,{lineWidth:120,noRefs:true,sortKeys:false});return p.writeFileSync(g,y,"utf-8"),{entry:m,filePath:g}}async function ge(e,t,n,o="global"){let{loadLoreEntry:r}=await import('./lore-loader-D2ISOASW.js'),i=await r(n,t);if(!i)return null;let s=[];if(i.symbols_touched)for(let l of i.symbols_touched){let m=l.replace(/^[#$^!~]/,"").toLowerCase();s.push(m);}let a=i.summary||"";i.body&&(a+=`
|
|
3
|
+
|
|
4
|
+
`+i.body);let d={source:"lore",loreEntryId:t,originProject:w.basename(n),createdBy:e};return Ct(e,{context:i.title||`Promoted from ${t}`,snippet:a,provenance:d,confidence:i.confidence??.7,concepts:s,tags:i.tags||[]},o,n)}function ye(e,t,n){let o=w.join(n,et,e),r=w.join(tt,e);for(let i of [o,r]){let s=w.join(i,`${t}${nt}`);if(p.existsSync(s))try{let a=p.readFileSync(s,"utf-8"),d=P.load(a);if(d)return d.appliedCount=(d.appliedCount||0)+1,d.updated=new Date().toISOString(),p.writeFileSync(s,P.dump(d,{lineWidth:120,noRefs:!0,sortKeys:!1}),"utf-8"),!0}catch{}}return false}var tt,et,fe,nt,Jt=b(()=>{tt=w.join(ot.homedir(),".paradigm","notebooks"),et=".paradigm/notebooks",fe="nb-",nt=".yaml";});var jt=".paradigm/events",oe="stream.jsonl",L=1e3,R=[];function Et(e){return w.join(e,jt,oe)}function ie(){let e=Date.now(),t=Math.floor(Math.random()*9999).toString().padStart(4,"0");return `ev-${e}-${t}`}function U(e,t){let n={id:ie(),timestamp:new Date().toISOString(),...t};R.push(n),R.length>L&&(R=R.slice(-L));try{let o=w.join(e,jt);p.mkdirSync(o,{recursive:!0});let r=Et(e);p.appendFileSync(r,JSON.stringify(n)+`
|
|
5
|
+
`,"utf8"),re(r);}catch{}return n}function re(e){try{if(p.statSync(e).size>512*1024){let o=p.readFileSync(e,"utf8").trim().split(`
|
|
6
|
+
`);if(o.length>L){let r=o.slice(-L);p.writeFileSync(e,r.join(`
|
|
7
|
+
`)+`
|
|
8
|
+
`,"utf8");}}}catch{}}function kt(e,t){let n=se(e);return t?.type&&(n=n.filter(o=>o.type===t.type)),t?.source&&(n=n.filter(o=>o.source===t.source)),t?.symbol&&(n=n.filter(o=>o.symbols?.includes(t.symbol))),t?.agent&&(n=n.filter(o=>o.agent===t.agent)),t?.since&&(n=n.filter(o=>o.timestamp>=t.since)),n.sort((o,r)=>r.timestamp.localeCompare(o.timestamp)),t?.limit&&(n=n.slice(0,t.limit)),n}function se(e){let t=Et(e);if(!p.existsSync(t))return [...R];try{return p.readFileSync(t,"utf8").trim().split(`
|
|
9
|
+
`).filter(r=>r.trim()).map(r=>{try{return JSON.parse(r)}catch{return null}}).filter(r=>r!==null)}catch{return [...R]}}function xt(e,t,n){let o=0,r=0,i=0,s=0;if(n.symbols?.length&&e.symbols?.length)for(let m of n.symbols)for(let c of e.symbols)vt(m,c)&&(o=Math.max(o,1));if(n.paths?.length&&e.path){for(let m of n.paths)if(vt(m,e.path)){r=1;break}}if(n.concepts?.length){let m=[e.context||"",...e.keywords||[],e.type||""].join(" ").toLowerCase(),c=0;for(let u of n.concepts)u&&m.includes(u.toLowerCase())&&c++;n.concepts.length>0&&(i=c/n.concepts.length);}if(n.signals?.length){for(let m of n.signals)if(m.type===e.type){s=1;break}}let a=[o,r,i,s].sort((m,c)=>c-m),d=a[0]*.5+a[1]*.2+a[2]*.15+a[3]*.15,l=n.threshold??.6;return {agentId:t,score:d,breakdown:{symbolMatch:o,pathMatch:r,conceptMatch:i,signalMatch:s},shouldNominate:d>=l,quietReason:d<l?"below-threshold":void 0}}function vt(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 ae=".paradigm/data-policy.yaml";function $t(e){let t=w.join(e,ae);if(!p.existsSync(t))return {...b$2};try{let n=p.readFileSync(t,"utf8"),o=P.load(n);return ce(b$2,o)}catch{return {...b$2}}}function ce(e,t){let n={...e};if(t.version&&(n.version=t.version),t.default_ring&&(n.default_ring=t.default_ring),t.observation&&(n.observation={allow:t.observation.allow||e.observation?.allow,deny:[...e.observation?.deny||[],...t.observation.deny||[]].filter((o,r,i)=>i.indexOf(o)===r)}),t.streams){n.streams={...e.streams};for(let o of ["work_log","learning_journal","team_decisions"])t.streams[o]&&(n.streams[o]={...e.streams?.[o],...t.streams[o],deny_content:[...e.streams?.[o]?.deny_content||[],...t.streams[o]?.deny_content||[]].filter((r,i,s)=>s.indexOf(r)===i)});}return t.upstream&&(n.upstream={...e.upstream,...t.upstream}),t.network&&(n.network={...e.network,...t.network}),t.agent_overrides&&(n.agent_overrides={...e.agent_overrides,...t.agent_overrides}),t.deployment&&(n.deployment={...e.deployment,...t.deployment}),n}function Rt(e,t,n){return n&&e.agent_overrides?.[n]?.observation&&e.agent_overrides[n].observation.deny?.some(r=>Y(r,t))||e.observation?.deny?.some(o=>Y(o,t))?false:e.observation?.allow?.length?e.observation.allow.some(o=>Y(o,t)):true}function Y(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 $=".paradigm/events",he="nominations.jsonl",be="debates.jsonl",Se=500,we=200,_e=7,ve=14,je=100;function Ee(){let e=Date.now(),t=Math.floor(Math.random()*9999).toString().padStart(4,"0");return `nom-${e}-${t}`}function ke(){let e=Date.now(),t=Math.floor(Math.random()*9999).toString().padStart(4,"0");return `dbt-${e}-${t}`}function xe(e,t){let n=i(e),o=$t(e),r=[];for(let l of n){if(!l.attention||!c$1(l.id,e)||t.path&&!Rt(o,t.path,l.id))continue;let m=xt(t,l.id,l.attention);m.shouldNominate&&r.push({profile:l,score:m});}if(r.length===0)return {nominations:[],debates:[]};let i$1=k(e,{since:new Date(Date.now()-3e4).toISOString()}),s=r.filter(({profile:l})=>!i$1.find(c=>c.agent===l.id&&c.brief===Mt(l,t,{...r.find(u=>u.profile.id===l.id).score})));if(s.length===0)return {nominations:[],debates:[]};let a=s.map(({profile:l,score:m})=>{let c=De(t,m),u=Ne(l,t);return {id:Ee(),agent:l.id,relevance:m.score,urgency:c,type:u,brief:Mt(l,t,m),triggered_by:[t.id],timestamp:new Date().toISOString(),surfaced:false}});Re(e,a);let d=$e(e,a);return d.length>0&&Te(e,d),{nominations:a,debates:d}}function De(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 Ne(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 Mt(e,t,n){let o=e.role||e.id;switch(t.type){case "gate-checked":return `${o}: Gate check on ${t.symbols?.join(", ")||"route"} \u2014 verify gate coverage is complete`;case "file-modified":return `${o}: ${t.path||"File"} modified \u2014 review for ${e.id==="security"?"security implications":e.id==="tester"?"test coverage":e.id==="reviewer"?"code quality":"consistency"}`;case "compliance-violation":return `${o}: Compliance violation detected \u2014 ${t.context||"check .purpose and portal.yaml coverage"}`;case "route-created":return `${o}: New route ${t.symbols?.join(", ")||""} \u2014 ${e.id==="security"?"needs gate assignment in portal.yaml":"review route structure"}`;case "gate-added":return `${o}: Gate ${t.symbols?.join(", ")||""} added \u2014 ${e.id==="security"?"verify enforcement points":"check downstream impact"}`;case "decision-made":return `${o}: Decision recorded \u2014 ${t.context?.slice(0,80)||"review for alignment with project patterns"}`;case "work-completed":return `${o}: Work completed on ${t.symbols?.join(", ")||t.context?.slice(0,40)||"task"} \u2014 review outcome`;case "error-encountered":return `${o}: Error detected \u2014 ${t.context?.slice(0,80)||"investigate root cause"}`;default:{let r=n.breakdown.symbolMatch>0?`symbol match on ${t.symbols?.join(", ")||"unknown"}`:n.breakdown.pathMatch>0?`path ${t.path||"unknown"}`:t.context?.slice(0,60)||t.type;return `${o}: ${r}`}}}function $e(e,t){if(t.length<2)return [];let n=[],o=new Map;for(let r of t)for(let i of r.triggered_by){let s=o.get(i)||[];s.push(r),o.set(i,s);}for(let[r,i]of o){if(i.length<2||new Set(i.map(l=>l.agent)).size<2)continue;let a=new Set(i.map(l=>l.type)),d=a.size>1&&a.has("warning")&&a.has("suggestion");n.push({id:ke(),topic:`Multiple agents responded to event ${r}`,nominations:i.map(l=>l.id),type:d?"conflicting":"complementary",overlap_events:[r]});}return n}function it(e){return w.join(e,$,he)}function rt(e){return w.join(e,$,be)}function Re(e,t){try{let n=w.join(e,$);p.mkdirSync(n,{recursive:!0});let o=it(e),r=t.map(s=>JSON.stringify(s)).join(`
|
|
10
|
+
`)+`
|
|
11
|
+
`;p.appendFileSync(o,r,"utf8"),Lt(o,Se);let{nominationTtlDays:i}=z(e);Ut(o,i*24*60*60*1e3);}catch{}}function Te(e,t){try{let n=w.join(e,$);p.mkdirSync(n,{recursive:!0});let o=rt(e),r=t.map(s=>JSON.stringify(s)).join(`
|
|
12
|
+
`)+`
|
|
13
|
+
`;p.appendFileSync(o,r,"utf8"),Lt(o,we);let{debateTtlDays:i}=z(e);Ut(o,i*24*60*60*1e3);}catch{}}function Lt(e,t){try{let o=p.readFileSync(e,"utf8").trim().split(`
|
|
14
|
+
`).filter(r=>r.trim());if(o.length>t){let r=o.slice(-t);p.writeFileSync(e,r.join(`
|
|
15
|
+
`)+`
|
|
16
|
+
`,"utf8");}}catch{}}function z(e){let t={nominationTtlDays:_e,debateTtlDays:ve};try{let n=w.join(e,".paradigm","config.yaml");if(!p.existsSync(n))return t;let o=a("js-yaml"),r=p.readFileSync(n,"utf8"),s=o.load(r)?.ambient;return s?{nominationTtlDays:typeof s["nomination-ttl-days"]=="number"?s["nomination-ttl-days"]:t.nominationTtlDays,debateTtlDays:typeof s["debate-ttl-days"]=="number"?s["debate-ttl-days"]:t.debateTtlDays}:t}catch{return t}}function Ut(e,t){try{if(!p.existsSync(e))return;let o=p.readFileSync(e,"utf8").trim().split(`
|
|
17
|
+
`).filter(s=>s.trim());if(o.length<=je)return;let r=Date.now()-t,i=o.filter(s=>{try{let a=JSON.parse(s);return (a.timestamp?new Date(a.timestamp).getTime():Date.now())>=r}catch{return !0}});i.length<o.length&&p.writeFileSync(e,i.join(`
|
|
18
|
+
`)+`
|
|
19
|
+
`,"utf8");}catch{}}function k(e,t){let n=it(e);if(!p.existsSync(n))return [];try{let r=p.readFileSync(n,"utf8").trim().split(`
|
|
20
|
+
`).filter(i=>i.trim()).map(i=>{try{return JSON.parse(i)}catch{return null}}).filter(i=>i!==null);return t?.agent&&(r=r.filter(i=>i.agent===t.agent)),t?.urgency&&(r=r.filter(i=>i.urgency===t.urgency)),t?.surfaced!==void 0&&(r=r.filter(i=>i.surfaced===t.surfaced)),t?.pending_only&&(r=r.filter(i=>!i.engaged)),t?.since&&(r=r.filter(i=>i.timestamp>=t.since)),r.sort((i,s)=>s.timestamp.localeCompare(i.timestamp)),t?.limit&&(r=r.slice(0,t.limit)),r}catch{return []}}function Bt(e){let t=rt(e);if(!p.existsSync(t))return [];try{return p.readFileSync(t,"utf8").trim().split(`
|
|
21
|
+
`).filter(o=>o.trim()).map(o=>{try{return JSON.parse(o)}catch{return null}}).filter(o=>o!==null)}catch{return []}}function Ht(e,t,n,o){let r=it(e);if(!p.existsSync(r))return false;try{let s=p.readFileSync(r,"utf8").trim().split(`
|
|
22
|
+
`),a=!1,d=s.map(l=>{try{let m=JSON.parse(l);return m.id===t?(m.engaged=!0,m.response=n,o&&(m.reason=o),a=!0,JSON.stringify(m)):l}catch{return l}});if(a&&(p.writeFileSync(r,d.join(`
|
|
23
|
+
`)+`
|
|
24
|
+
`,"utf8"),n==="accepted"||n==="dismissed")){let l=JSON.parse(s.find(c=>{try{return JSON.parse(c).id===t}catch{return !1}}));i(e).find(c=>c.id===l.agent)?.learning?.intrinsic?.feedback?.after_recommendation&&U(e,{type:"work-completed",source:"agent-action",agent:l.agent,context:`Nomination ${t} ${n} \u2014 feedback for learning`,data:{nomination_id:t,response:n}});}return a}catch{return false}}function Wt(e,t,n,o){let r=rt(e);if(!p.existsSync(r))return false;try{let s=p.readFileSync(r,"utf8").trim().split(`
|
|
25
|
+
`),a=!1,d=s.map(l=>{try{let m=JSON.parse(l);if(m.id===t){m.resolution={chosen:n,reason:o,resolved_by:"human",resolved_at:new Date().toISOString()},a=!0;let c=m.nominations.filter(u=>u!==n);for(let u of c){let g=k(e).find(y=>y.id===u);g&&U(e,{type:"work-completed",source:"agent-action",agent:g.agent,context:`Debate ${t} resolved \u2014 nomination ${u} not chosen`,data:{debate_id:t,chosen:n,reason:o}});}return JSON.stringify(m)}return l}catch{return l}});return a&&p.writeFileSync(r,d.join(`
|
|
26
|
+
`)+`
|
|
27
|
+
`,"utf8"),a}catch{return false}}function zt(e){let t=w.join(e,$,".last-processed"),n="";try{p.existsSync(t)&&(n=p.readFileSync(t,"utf8").trim());}catch{}let o=w.join(e,$,"stream.jsonl");if(!p.existsSync(o))return {processed:0,nominations:[]};let r=[];try{r=p.readFileSync(o,"utf8").trim().split(`
|
|
28
|
+
`).filter(c=>c.trim()).map(c=>{try{return JSON.parse(c)}catch{return null}}).filter(c=>c!==null);}catch{return {processed:0,nominations:[]}}let i=0;if(n){let m=r.findIndex(c=>c.id===n);m>=0&&(i=m+1);}let s=r.slice(i);if(s.length===0)return {processed:0,nominations:[]};let a=[],d=s.slice(0,50);for(let m of d){let{nominations:c}=xe(e,m);a.push(...c);}let l=d[d.length-1];try{p.mkdirSync(w.join(e,$),{recursive:!0}),p.writeFileSync(t,l.id,"utf8");}catch{}return {processed:d.length,nominations:a}}function qt(e,t){let n=f(e,t);if(!n?.attention)return {adjusted:false,oldThreshold:.6,newThreshold:.6,reason:"No attention config"};let o=n.attention.threshold??.6,{nominationTtlDays:r}=z(e),i=r*24*60*60*1e3,d=k(e,{agent:t}).filter(f=>f.engaged||Date.now()-new Date(f.timestamp).getTime()<i).filter(f=>f.engaged);if(d.length<5)return {adjusted:false,oldThreshold:o,newThreshold:o,reason:`Insufficient data (${d.length}/5 engaged nominations)`};let l=d.filter(f=>f.response==="accepted").length,m=d.filter(f=>f.response==="dismissed").length,c=l/d.length,u=m/d.length,g=o,y="No adjustment needed";if(u>.6?(g=Math.min(.95,o+.05),y=`High dismiss rate (${(u*100).toFixed(0)}%) \u2014 raising threshold to reduce noise`):c>.8&&(g=Math.max(.2,o-.05),y=`High accept rate (${(c*100).toFixed(0)}%) \u2014 lowering threshold to contribute more`),g===o)return {adjusted:false,oldThreshold:o,newThreshold:g,reason:y};n.attention.threshold=g;let h=w.join(e,".paradigm/agents",`${t}.agent`),N=p.existsSync(h)?"project":"global";return j(t,n,N,e),U(e,{type:"work-completed",source:"agent-action",agent:t,context:`Attention threshold adjusted: ${o.toFixed(2)} \u2192 ${g.toFixed(2)} (${y})`,data:{old_threshold:o,new_threshold:g,accept_rate:c,dismiss_rate:u}}),{adjusted:true,oldThreshold:o,newThreshold:g,reason:y}}function st(e,t){let{nominationTtlDays:n}=z(e),o=n*24*60*60*1e3,i=k(e,{agent:t}).filter(c=>c.engaged||Date.now()-new Date(c.timestamp).getTime()<o),s=i.filter(c=>c.response==="accepted").length,a=i.filter(c=>c.response==="dismissed").length,d=i.filter(c=>c.response==="deferred").length,l=i.filter(c=>!c.engaged).length,m=s+a+d;return {total:i.length,accepted:s,dismissed:a,deferred:d,pending:l,acceptRate:m>0?s/m:0}}function Gt(e){let n=i(e).filter(c=>c$1(c.id,e)).map(c=>{let u=st(e,c.id),g=0;try{let y=w.join(ot.homedir(),".paradigm","notebooks",c.id);p.existsSync(y)&&(g=p.readdirSync(y).filter(h=>h.endsWith(".yaml")).length);}catch{}return {id:c.id,acceptRate:u.acceptRate,threshold:c.attention?.threshold??.5,expertiseCount:(c.expertise||[]).length,notebookCount:g,transferableCount:(c.transferable||[]).length,totalNominations:u.total}}),o=n.length||1,r=n.reduce((c,u)=>c+u.acceptRate,0)/o,i$1=n.reduce((c,u)=>c+u.threshold,0)/o,s=n.reduce((c,u)=>c+u.expertiseCount,0),a=n.reduce((c,u)=>c+u.notebookCount,0),d=n.reduce((c,u)=>c+u.transferableCount,0),l=n.reduce((c,u)=>c+u.totalNominations,0),m;return l<10?m="cold-start":r<.5?m="accumulating":r<.7?m="calibrating":m="mature",{agents:n,aggregate:{avgAcceptRate:r,avgThreshold:i$1,totalExpertise:s,totalNotebooks:a,totalTransferable:d},healthStatus:m}}function at(e,t){let n,o,r;try{let l=(Z(),d(Tt)),m=(Jt(),d(It));n=l.loadJournalEntries,o=m.addNotebookEntry,r=m.normalizeConcept;}catch{return {promoted:0,entries:[]}}let i=n(t,{trigger:"pattern_discovered",limit:100}),s=n(t,{trigger:"human_feedback",limit:100}),a=[...i,...s],d$1=[];for(let l of a)if(!l.promoted_to_notebook&&!((l.confidence_after??0)<.8))try{let{entry:m}=o(t,{context:l.pattern?.applies_when||l.insight.slice(0,80),snippet:l.pattern?.correct_approach||l.insight,concepts:(l.tags||[l.pattern?.id||"learned-pattern"]).map(r).filter(Boolean),provenance:{source:"lore",loreEntryId:l.id,createdBy:t}},"global",e);d$1.push({journalId:l.id,notebookId:m.id});try{let c=w.join(ot.homedir(),".paradigm","agents",t,"journal");if(p.existsSync(c)){let u=p.readdirSync(c).filter(g=>g.endsWith(".yaml"));for(let g of u){let y=w.join(c,g),h=p.readFileSync(y,"utf8");if(h.includes(l.id)){let N=h.replace(/promoted_to_notebook:.*$/m,`promoted_to_notebook: "${m.id}"`);if(N===h){let f=h.trimEnd().split(`
|
|
29
|
+
`);f.push(`promoted_to_notebook: "${m.id}"`),p.writeFileSync(y,f.join(`
|
|
30
|
+
`)+`
|
|
31
|
+
`,"utf8");}else p.writeFileSync(y,N,"utf8");break}}}}catch{}}catch{}return {promoted:d$1.length,entries:d$1}}var Pe=".paradigm/surfacing.yaml";function Vt(e){let t=w.join(e,Pe),n={default_min_urgency:"low",enable_debates:true};if(!p.existsSync(t))return n;try{let o=a("js-yaml"),r=p.readFileSync(t,"utf8"),i=o.load(r);return {...n,...i}}catch{return n}}function Kt(e,t){let n={critical:0,high:1,medium:2,low:3},o=n[t.default_min_urgency||"low"]??3;return e.filter(r=>{let i=n[r.urgency]??3;if(t.preferences){let s=t.preferences.find(a=>a.agent===r.agent);if(s){if(s.always_show)return true;if(s.mute_unless?.length&&!s.mute_unless.some(d=>r.urgency===d||r.type===d))return false;if(s.min_urgency){let a=n[s.min_urgency]??3;return i<=a}}}return i<=o})}var Ae=".paradigm/decisions";function Xt(e,t){let n=w.join(e,Ae);if(!p.existsSync(n))return [];let o=[],r=p.readdirSync(n).filter(s=>s.endsWith(".yaml"));for(let s of r)try{let a=p.readFileSync(w.join(n,s),"utf8"),d=P.load(a);d&&d.id&&o.push(d);}catch{}let i=o;return (i=i.filter(s=>s.status===t.status)),t?.participant&&(i=i.filter(s=>s.participants.some(a=>a.id===t.participant))),t?.symbol&&(i=i.filter(s=>s.symbols_affected?.includes(t.symbol))),t?.tag&&(i=i.filter(s=>s.tags?.some(a=>a.startsWith(t.tag)))),t?.dateFrom&&(i=i.filter(s=>s.timestamp>=t.dateFrom)),t?.dateTo&&(i=i.filter(s=>s.timestamp<=t.dateTo)),i.sort((s,a)=>a.timestamp.localeCompare(s.timestamp)),t?.limit&&(i=i.slice(0,t.limit)),i}Z();function on(){return [{name:"paradigm_ambient_nominations",description:"Get pending agent nominations \u2014 agents that self-nominated contributions based on recent events. Filters by urgency, agent, pending status. Marks returned nominations as surfaced. ~200 tokens.",inputSchema:{type:"object",properties:{urgency:{type:"string",enum:["critical","high","medium","low"],description:"Filter by urgency level"},agent:{type:"string",description:"Filter by agent ID"},pending_only:{type:"boolean",description:"Only show un-engaged nominations (default: true)"},include_debates:{type:"boolean",description:"Include debate groupings (default: false)"},limit:{type:"number",description:"Max nominations to return (default: 20)"}}},annotations:{readOnlyHint:false,destructiveHint:false}},{name:"paradigm_ambient_events",description:"Query the ambient event stream \u2014 recent tool calls, file edits, gate checks, and other project activity. Filters by type, source, symbol, agent, time window. ~200 tokens.",inputSchema:{type:"object",properties:{type:{type:"string",description:'Event type filter (e.g., "file-modified", "gate-checked", "decision-made")'},source:{type:"string",description:'Event source filter (e.g., "mcp-tool-call", "post-write-hook")'},symbol:{type:"string",description:"Filter events referencing this symbol"},agent:{type:"string",description:"Filter events from this agent"},since:{type:"string",description:'Relative time filter (e.g., "1h", "30m", "2d") or ISO timestamp'},limit:{type:"number",description:"Max events to return (default: 50)"}}},annotations:{readOnlyHint:true,destructiveHint:false}},{name:"paradigm_ambient_engage",description:"Accept, dismiss, or defer a nomination. Optionally resolves a debate by choosing this nomination over others. ~50 tokens.",inputSchema:{type:"object",properties:{nomination_id:{type:"string",description:"Nomination ID to engage with"},response:{type:"string",enum:["accepted","dismissed","deferred"],description:"How to respond"},resolve_debate:{type:"string",description:"Optional debate ID to resolve by choosing this nomination"},reason:{type:"string",description:"Reason for response \u2014 stored on nomination for learning feedback. Especially valuable for dismissals."}},required:["nomination_id","response"]},annotations:{readOnlyHint:false,destructiveHint:false}},{name:"paradigm_context_compose",description:"Compose full agent session context: profile enrichment + recent decisions + transferable journal entries + pending nominations. Returns a markdown context block for prompt injection. ~300 tokens.",inputSchema:{type:"object",properties:{agent:{type:"string",description:"Agent ID to compose context for"},symbols:{type:"array",items:{type:"string"},description:"Relevant symbols for expertise filtering"},include_nominations:{type:"boolean",description:"Include pending nominations (default: true)"},include_decisions:{type:"boolean",description:"Include recent team decisions (default: true)"},include_journal:{type:"boolean",description:"Include transferable journal entries (default: true)"},max_decisions:{type:"number",description:"Max decisions to include (default: 5)"},max_journal:{type:"number",description:"Max journal entries to include (default: 5)"}},required:["agent"]},annotations:{readOnlyHint:true,destructiveHint:false}},{name:"paradigm_ambient_promote",description:"Auto-promote high-confidence pattern discoveries from an agent's learning journal to its notebook. Promotes entries with trigger=pattern_discovered and confidence_after >= 0.8. ~100 tokens.",inputSchema:{type:"object",properties:{agent:{type:"string",description:"Agent ID whose journal to scan"}},required:["agent"]},annotations:{readOnlyHint:false,destructiveHint:false}},{name:"paradigm_ambient_learn",description:"Analyze an agent's nomination acceptance/dismissal history and adjust its attention threshold. If >60% dismissed \u2192 raise threshold (less noise). If >80% accepted \u2192 lower threshold (contribute more). Also returns engagement stats. ~100 tokens.",inputSchema:{type:"object",properties:{agent:{type:"string",description:"Agent ID to analyze and adjust"},dry_run:{type:"boolean",description:"If true, return stats without adjusting (default: false)"}},required:["agent"]},annotations:{readOnlyHint:false,destructiveHint:false}},{name:"paradigm_ambient_health",description:"Agent learning health metrics \u2014 aggregate learning quality across all agents: nomination acceptance rates, threshold drift, notebook counts, expertise growth, and overall health status (cold-start \u2192 accumulating \u2192 calibrating \u2192 mature).",inputSchema:{type:"object",properties:{}},annotations:{readOnlyHint:true,destructiveHint:false}},{name:"paradigm_ambient_learn_postflight",description:"Postflight learning pass \u2014 converts session work log verdicts into agent journal entries. Reads accepted/dismissed/revised verdicts from the session log, creates journal entries for each agent, then auto-promotes high-confidence entries to notebooks. Typically called at session end by the stop hook. ~200 tokens.",inputSchema:{type:"object",properties:{session_id:{type:"string",description:"Session ID (default: current session)"},dry_run:{type:"boolean",description:"If true, show what would be written without writing (default: false)"}}},annotations:{readOnlyHint:false,destructiveHint:false}}]}function Oe(e){let t=Date.now(),n=e.match(/^(\d+)(m|h|d)$/);if(n){let o=parseInt(n[1],10),r=n[2],i=r==="m"?o*6e4:r==="h"?o*36e5:o*864e5;return new Date(t-i).toISOString()}return e}async function rn(e,t,n){let o=r=>JSON.stringify(r,null,2);switch(e){case "paradigm_ambient_nominations":{zt(n.rootDir);let i=t.pending_only!==false,s=t.limit||20,a=k(n.rootDir,{agent:t.agent,urgency:t.urgency,pending_only:i,limit:s+20}),d=Vt(n.rootDir);a=Kt(a,d).slice(0,s);let l=w.join(n.rootDir,".paradigm/events/nominations.jsonl");if(p.existsSync(l))try{let c=p.readFileSync(l,"utf8"),u=new Set(a.map(y=>y.id)),g=c.trim().split(`
|
|
32
|
+
`).map(y=>{try{let h=JSON.parse(y);return u.has(h.id)?(h.surfaced=!0,JSON.stringify(h)):y}catch{return y}});p.writeFileSync(l,g.join(`
|
|
33
|
+
`)+`
|
|
34
|
+
`,"utf8");}catch{}let m={count:a.length,nominations:a.map(c=>({id:c.id,agent:c.agent,urgency:c.urgency,type:c.type,brief:c.brief,relevance:c.relevance,timestamp:c.timestamp,engaged:c.engaged,response:c.response}))};if(t.include_debates){let u=Bt(n.rootDir).filter(g=>!g.resolution);m.debates=u.map(g=>({id:g.id,topic:g.topic,type:g.type,nominations:g.nominations})),m.debate_count=u.length;}return {text:o(m),handled:true}}case "paradigm_ambient_events":{let r=t.since?Oe(t.since):void 0,i=t.limit||50,s=kt(n.rootDir,{type:t.type,source:t.source,symbol:t.symbol,agent:t.agent,since:r,limit:i});return {text:o({count:s.length,events:s.map(a=>({id:a.id,type:a.type,source:a.source,timestamp:a.timestamp,path:a.path,symbols:a.symbols,context:a.context,agent:a.agent,tool:a.tool,severity:a.severity}))}),handled:true}}case "paradigm_ambient_engage":{let r=t.nomination_id,i=t.response,s=t.reason,a=Ht(n.rootDir,r,i,s);if(a)try{let{appendSessionWorkEntry:l,appendVerdictEntry:m}=await import('./session-work-log-QXPAXY5K.js'),u=k(n.rootDir,{limit:500}).find(y=>y.id===r),g={timestamp:new Date().toISOString(),type:"user-verdict",agent:u?.agent,nominationId:r,verdict:i,reason:s};l(n.rootDir,g),m(n.rootDir,g);}catch{}let d=false;return t.resolve_debate&&a&&(d=Wt(n.rootDir,t.resolve_debate,r,t.reason)),{text:o({engaged:a,nomination_id:r,response:i,debate_resolved:d||void 0}),handled:true}}case "paradigm_context_compose":{let r=t.agent,i=t.symbols||[],s=t.include_nominations!==false,a=t.include_decisions!==false,d=t.include_journal!==false,l=t.max_decisions||5,m=t.max_journal||5,c=f(n.rootDir,r);if(!c)return {text:o({error:`Agent profile not found: ${r}`}),handled:true};let u=[],g=p$1(c,i);if(g.trim()&&u.push(g),a){let y=Xt(n.rootDir,{status:"active",limit:l});if(y.length>0){u.push("## Recent Team Decisions");for(let h of y)u.push(`- **${h.title}**: ${h.decision.slice(0,150)}${h.decision.length>150?"...":""}`);u.push("");}}if(d){let y=F(r,{transferable:true,limit:m});if(y.length>0){u.push("## Transferable Insights");for(let h of y)u.push(`- [${h.trigger}] ${h.insight.slice(0,150)}${h.insight.length>150?"...":""}`);u.push("");}}if(s){let y=k(n.rootDir,{pending_only:true,limit:10});if(y.length>0){u.push("## Pending Nominations");for(let h of y)u.push(`- [${h.urgency}] ${h.brief}`);u.push("");}}return {text:o({agent:r,context:u.join(`
|
|
35
|
+
`),sections_included:{profile:true,decisions:a,journal:d,nominations:s}}),handled:true}}case "paradigm_ambient_promote":{let r=t.agent,i=at(n.rootDir,r);return {text:o({agent:r,promoted:i.promoted,entries:i.entries}),handled:true}}case "paradigm_ambient_learn":{let r=t.agent,i=t.dry_run===true,s=st(n.rootDir,r);if(i)return {text:o({agent:r,dry_run:true,stats:s,note:s.total<5?"Insufficient data for threshold adjustment (need 5+ engaged nominations)":`Accept rate: ${(s.acceptRate*100).toFixed(0)}% \u2014 ${s.acceptRate>.8?"would lower threshold":s.acceptRate<.4?"would raise threshold":"no adjustment needed"}`}),handled:true};let a=qt(n.rootDir,r);return {text:o({agent:r,...a,stats:s}),handled:true}}case "paradigm_ambient_health":case "paradigm_ambient_neverland":{let r=Gt(n.rootDir);return {text:o(r),handled:true}}case "paradigm_ambient_learn_postflight":return {text:o(await Ie(n.rootDir,t)),handled:true};default:return {text:`Unknown ambient tool: ${e}`,handled:false}}}var Fe={accepted:"human_feedback",dismissed:"confidence_miss",revised:"correction_received"};function Ce(e){try{let t=w.join(e,".paradigm","config.yaml");if(p.existsSync(t)){let o=p.readFileSync(t,"utf8").match(/project:\s*["']?([^"'\n]+)["']?/);if(o)return o[1].trim()}}catch{}return w.basename(e)}async function Ie(e$1,t={}){let n=t.dry_run===true,o=Ce(e$1),r=e(e$1).filter(f=>f.verdict&&f.agent),i=g(e$1).filter(f=>f.agent&&f.corrections.length>0),s=b$1(e$1);if(r.length===0&&i.length===0)return {sessionEntries:s.length,agentsProcessed:[],journalsWritten:0,journalsByAgent:{},promoted:0,promotedByAgent:{},dryRun:n,details:[]};let a=new Map;for(let f of r){let b=f.agent;a.has(b)||a.set(b,[]),a.get(b).push(f);}let d=s.filter(f=>f.type==="agent-contribution"),l=new Map;for(let f of d)f.agent&&(l.has(f.agent)||l.set(f.agent,[]),l.get(f.agent).push(f));let m=[],c={},u=0;for(let[f,b]of a){c[f]=0;let A=b.filter(S=>S.verdict==="accepted").length;b.filter(S=>S.verdict==="dismissed").length;b.filter(S=>S.verdict==="revised").length;let G=b.length,Qt=G>0?A/G:0;for(let S of b){let V=Fe[S.verdict];if(!V)continue;let Zt=l.get(f)?.shift(),dt=Je(S,Zt,{acceptRate:Qt,total:G,accepted:A}),te=typeof S.confidence=="number"?S.confidence:S.verdict==="accepted"?.85:S.verdict==="revised"?.6:.4,ee={agent:f,verdict:S.verdict,trigger:V,insight:dt,symbols:S.symbols};if(m.push(ee),n)c[f]++,u++;else try{H(f,{trigger:V,insight:dt,confidence_before:S.verdict==="accepted"?.7:.8,confidence_after:te,project:o,transferable:S.verdict==="dismissed",tags:["postflight",`verdict:${S.verdict}`,...(S.symbols||[]).map(ne=>`symbol:${ne}`)]}),c[f]++,u++;}catch{}}}let g$1=new Set;for(let f of i){let b=f.agent;g$1.add(b),c[b]===void 0&&(c[b]=0);let A=`Self-revision during iteration round ${f.round}: ${f.corrections.join("; ")}`;if(m.push({agent:b,verdict:"iteration-revision",trigger:"self_reflection",insight:A,symbols:f.symbols}),n)c[b]++,u++;else try{H(b,{trigger:"self_reflection",insight:A,confidence_before:.6,confidence_after:typeof f.confidence=="number"?f.confidence:.75,project:o,transferable:!1,tags:["postflight","iteration-revision",`round:${f.round}`,...(f.symbols||[]).map(q=>`symbol:${q}`)]}),c[b]++,u++;}catch{}}let y={},h$1=0,N=new Set([...a.keys(),...g$1]);if(!n)for(let f of N)try{let b=at(e$1,f);b.promoted>0&&(y[f]=b.promoted,h$1+=b.promoted);}catch{}return !n&&r.length>0&&f$1(e$1,r.map(f=>f.nominationId).filter(Boolean)),!n&&i.length>0&&h(e$1,i.map(f=>f.id)),{sessionEntries:s.length,agentsProcessed:Array.from(N),journalsWritten:u,journalsByAgent:c,promoted:h$1,promotedByAgent:y,dryRun:n,details:m}}function Je(e,t,n){let o=e.symbols?.length?` (symbols: ${e.symbols.join(", ")})`:"",r=e.reason?` Reason: ${e.reason}.`:"";switch(e.verdict){case "accepted":return `Contribution accepted by user${o}.${r}`+(t?.contribution?` Original: "${t.contribution.slice(0,120)}".`:"")+` Session accept rate: ${(n.acceptRate*100).toFixed(0)}% (${n.accepted}/${n.total}).`;case "dismissed":return `Contribution dismissed by user${o}.${r}`+(t?.contribution?` Rejected contribution: "${t.contribution.slice(0,120)}".`:"")+` Learn from this dismissal to improve future nominations. Session accept rate: ${(n.acceptRate*100).toFixed(0)}% (${n.accepted}/${n.total}).`;case "revised":return `Contribution revised by user${o}.${r}`+(e.revisionDelta?` Delta: "${e.revisionDelta.slice(0,120)}".`:"")+(t?.contribution?` Original: "${t.contribution.slice(0,120)}".`:"")+` Partial credit \u2014 close but not accurate enough. Session accept rate: ${(n.acceptRate*100).toFixed(0)}% (${n.accepted}/${n.total}).`;default:return `Unknown verdict "${e.verdict}"${o}.${r}`}}export{on as getAmbientToolsList,rn as handleAmbientTool,Ie as runPostflightLearning};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
export{E as assembleCaptainBoard,C as getCaptainToolsList,D as handleCaptainTool,F as proposeClaimantFor}from'./chunk-K54L6CFR.js';import'./chunk-QBIQ2FYB.js';import'./chunk-Q527BPUF.js';import'./chunk-RGSFU2YW.js';import'./chunk-TMDPDIWA.js';import'./chunk-KLBH26PA.js';import'./chunk-GRZQIKST.js';import'./chunk-ACJWUOMA.js';import'./chunk-33ERV2MW.js';import'./chunk-EK4ZRIFJ.js';import'./chunk-5TAVYPOV.js';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {c,b}from'./chunk-5TAVYPOV.js';import*as e from'fs';import*as o from'path';var L={};c(L,{appendSessionWorkEntry:()=>N,appendVerdictEntry:()=>O,clearActivityMetrics:()=>J,clearSessionWorkLog:()=>C,countNotebookReferences:()=>_,getAgentEntries:()=>h,getAgentVerdicts:()=>j,getContributingAgents:()=>M,getNotebookReferences:()=>v,getSessionActivitySummary:()=>W,markIterationRevisionsConsumed:()=>A,markVerdictsConsumed:()=>P,readPendingIterationRevisions:()=>F,readPendingVerdicts:()=>R,readSessionWorkLog:()=>g,recordActivityMetric:()=>w,recordNotebookReference:()=>D});function N(i,n){try{let t=o.join(i,y),r=o.dirname(t);if(e.existsSync(r)||e.mkdirSync(r,{recursive:!0}),e.existsSync(t)&&e.readFileSync(t,"utf8").trim().split(`
|
|
3
|
+
`).filter(c=>c.trim()).length>=I)return;let f=JSON.stringify(n)+`
|
|
4
|
+
`;e.appendFileSync(t,f,"utf8"),n.type==="user-verdict"&&n.agent&&n.symbols?.length&&import('./agent-loader-W3RQJVW7.js').then(({loadAgentProfile:a,saveAgentProfile:s})=>{try{let c=a(i,n.agent);if(c?.expertise){let l=n.verdict==="accepted"?.03:n.verdict==="dismissed"?-.02:n.verdict==="revised"?-.01:0;if(l!==0){for(let b of n.symbols){let u=c.expertise.find(k=>k.symbol===b);u&&(u.confidence=Math.max(0,Math.min(1,u.confidence+l)),u.sessions=(u.sessions||0)+1,u.lastTouch=new Date().toISOString());}s(n.agent,c,"global");}}}catch{}}).catch(()=>{});}catch{}}function 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 C(i){try{let n=o.join(i,y);e.existsSync(n)&&e.writeFileSync(n,"","utf8");}catch{}}function O(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 R(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 P(i,n){try{let t=o.join(i,p);if(!e.existsSync(t))return;let r=new Set(n),a=e.readFileSync(t,"utf8").trim().split(`
|
|
8
|
+
`).filter(s=>s.trim()).map(s=>{try{let c=JSON.parse(s);return c.nominationId&&r.has(c.nominationId)?JSON.stringify({...c,consumed:!0}):s}catch{return s}});e.writeFileSync(t,a.join(`
|
|
9
|
+
`)+`
|
|
10
|
+
`,"utf8");}catch{}}function F(i){try{let n=o.join(i,m);return e.existsSync(n)?e.readFileSync(n,"utf8").trim().split(`
|
|
11
|
+
`).filter(t=>t.trim()).map(t=>{try{return JSON.parse(t)}catch{return null}}).filter(t=>t!==null&&t.type==="iteration-revision"&&!t.consumed):[]}catch{return []}}function A(i,n){try{let t=o.join(i,m);if(!e.existsSync(t))return;let r=new Set(n),a=e.readFileSync(t,"utf8").trim().split(`
|
|
12
|
+
`).filter(s=>s.trim()).map(s=>{try{let c=JSON.parse(s);return c.id&&r.has(c.id)?JSON.stringify({...c,consumed:!0}):s}catch{return s}});e.writeFileSync(t,a.join(`
|
|
13
|
+
`)+`
|
|
14
|
+
`,"utf8");}catch{}}function M(i){let n=g(i),t=new Set;for(let r of n)r.agent&&t.add(r.agent);return Array.from(t)}function h(i,n){return g(i).filter(t=>t.agent===n)}function j(i,n){let t=h(i,n),r=t.filter(s=>s.type==="agent-contribution"),f=t.filter(s=>s.type==="user-verdict"),a=[];for(let s of r)a.push({contribution:s});for(let s of f){let c=a.find(l=>!l.verdict&&l.contribution);c?c.verdict=s:a.push({verdict:s});}return a}function w(i,n){try{let t=o.join(i,d),r=o.dirname(t);e.existsSync(r)||e.mkdirSync(r,{recursive:!0});let f={timestamp:new Date().toISOString(),type:"activity",...n},a=JSON.stringify(f)+`
|
|
15
|
+
`;e.appendFileSync(t,a,"utf8");}catch{}}function B(i){try{let n=o.join(i,d);return e.existsSync(n)?e.readFileSync(n,"utf8").trim().split(`
|
|
16
|
+
`).filter(t=>t.trim()).map(t=>{try{return JSON.parse(t)}catch{return null}}).filter(t=>t!==null&&t.type==="activity"):[]}catch{return []}}function W(i){let n=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 D(i,n,t,r){try{if(t.length===0)return;let f=o.join(i,S),a=o.dirname(f);e.existsSync(a)||e.mkdirSync(a,{recursive:!0});let s={timestamp:new Date().toISOString(),type:"notebook-reference",agentId:n,notebookEntryIds:t,...r?{orchestrationId:r}:{}},c=JSON.stringify(s)+`
|
|
17
|
+
`;e.appendFileSync(f,c,"utf8");}catch{}}function v(i){try{let n=o.join(i,S);return e.existsSync(n)?e.readFileSync(n,"utf8").trim().split(`
|
|
18
|
+
`).filter(t=>t.trim()).map(t=>{try{return JSON.parse(t)}catch{return null}}).filter(t=>t!==null&&t.type==="notebook-reference"):[]}catch{return []}}function _(i){return v(i).length}var y,d,p,m,I,S,T=b(()=>{y=".paradigm/events/session-log.jsonl",d=".paradigm/events/session-metrics.jsonl",p=".paradigm/events/verdicts.jsonl",m=".paradigm/events/iteration-revisions.jsonl",I=200,S=".paradigm/events/notebook-refs.jsonl";});export{N as a,g as b,C as c,O as d,R as e,P as f,F as g,A as h,M as i,h as j,j as k,w as l,W as m,J as n,D as o,v as p,_ as q,L as r,T as s};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {b as b$1,a}from'./chunk-EK4ZRIFJ.js';import*as r from'fs';import*as o from'path';import*as f from'js-yaml';b$1();var m=".paradigm/tasks",T="entries",F="index.yaml";function k(e){if(e&&e.session_link&&!e.external_ref){let t=e.session_link,n=t.toLowerCase(),s;n.includes("github")?s="github":n.includes("session")?s="session":s="url",e.external_ref={kind:s,ref:t},delete e.session_link;}return e}function j(e,t){let n=o.join(e,m,T,t);if(!r.existsSync(n))return `T-${t}-001`;let s=r.readdirSync(n).filter(i=>i.startsWith("T-")&&i.endsWith(".yaml")).map(i=>{let l=i.match(/T-\d{4}-\d{2}-\d{2}-(\d+)\.yaml/);return l?parseInt(l[1],10):0}),a=s.length>0?Math.max(...s)+1:1;return `T-${t}-${String(a).padStart(3,"0")}`}function O(e,t){return e===t?true:({open:["in-progress","done","shelved"],"in-progress":["done","open","shelved"],shelved:["open"],done:[]}[e]??[]).includes(t)}var _={high:0,medium:1,low:2},E=["open","in-progress"];function N(e,t){return t==="all"?true:t==="active"?E.includes(e.status):e.status===t}function b(e){let t=e.created?new Date(e.created).getTime():NaN;if(!Number.isNaN(t))return t;let n=e.id?.match(/^T-(\d{4}-\d{2}-\d{2})-/);if(n){let s=new Date(n[1]).getTime();if(!Number.isNaN(s))return s}return 0}function C(e,t){let n=e;return t.status&&t.status!=="all"&&(n=n.filter(s=>N(s,t.status))),t.priority&&(n=n.filter(s=>s.priority===t.priority)),t.tag&&(n=n.filter(s=>s.tags.includes(t.tag))),n.sort((s,a)=>{let i=(_[s.priority]??1)-(_[a.priority]??1);return i!==0?i:b(a)-b(s)}),t.limit&&(n=n.slice(0,t.limit)),n}async function D(e,t){let n=o.join(e,m,T);if(!r.existsSync(n))return [];let s={status:"open",limit:20,...t},a=[],i=r.readdirSync(n).filter(l=>/^\d{4}-\d{2}-\d{2}$/.test(l)).sort().reverse();for(let l of i){let g=o.join(n,l),d=r.readdirSync(g).filter(c=>c.endsWith(".yaml")).sort();for(let c of d)try{let u=r.readFileSync(o.join(g,c),"utf8"),h=k(f.load(u));a.push(h);}catch{}}return C(a,s)}async function $(e,t){let n=t.match(/^T-(\d{4}-\d{2}-\d{2})-/);if(n){let a=o.join(e,m,T,n[1],`${t}.yaml`);if(r.existsSync(a))try{return k(f.load(r.readFileSync(a,"utf8")))}catch{return null}}return (await D(e,{status:"all",limit:9999})).find(a=>a.id===t)||null}async function A(e,t){let n=new Date,s=n.toISOString().slice(0,10),a=o.join(e,m,T,s);r.mkdirSync(a,{recursive:true});let i=j(e,s),l={id:i,blurb:t.blurb,priority:t.priority||"medium",status:"open",tags:t.tags||[],created:n.toISOString(),related_lore:t.related_lore,claimant:t.claimant,parentTaskId:t.parentTaskId,dependsOn:t.dependsOn,stage:t.stage,external_ref:t.external_ref,session_link:t.session_link};return k(l),r.writeFileSync(o.join(a,`${i}.yaml`),f.dump(w(l),{lineWidth:-1,noRefs:true})),await v(e),i}async function I(e,t,n){let s=await $(e,t);if(!s)return false;let a$1=s.created.slice(0,10),i=o.join(e,m,T,a$1,`${t}.yaml`);if(!r.existsSync(i))return false;let{id:l,created:g,...d}=n;if(d.status!==void 0&&d.status!==s.status){if(!O(s.status,d.status))return a.component("#task-loader").warn("Illegal task status transition rejected",{taskId:t,from:s.status,to:d.status}),false;d.status==="in-progress"&&!s.started_at&&d.started_at===void 0&&(d.started_at=new Date().toISOString());}let c={...s,...d};if(r.writeFileSync(i,f.dump(w(c),{lineWidth:-1,noRefs:true})),await v(e),W(c.status)&&c.parentTaskId)try{let{settleParentIfComplete:u}=await import('./task-settlement-NW4XMJGJ.js');await u(e,c.parentTaskId,c.id);}catch(u){a.component("#task-loader").warn("Settlement after updateTask failed (non-fatal)",{taskId:t,parentTaskId:c.parentTaskId,error:u instanceof Error?u.message:String(u)});}return true}function W(e){return e==="done"||e==="shelved"}async function L(e,t){return I(e,t,{status:"done",completed:new Date().toISOString()})}async function M(e,t){return I(e,t,{status:"shelved",shelved:new Date().toISOString()})}async function v(e){let t=o.join(e,m,T),n=o.join(e,m),s=0,a=0,i=0,l=0,g=0,d=[];if(r.existsSync(t)){let u=r.readdirSync(t).filter(h=>/^\d{4}-\d{2}-\d{2}$/.test(h));for(let h of u){let x=o.join(t,h),P=r.readdirSync(x).filter(y=>y.endsWith(".yaml"));for(let y of P)try{let p=k(f.load(r.readFileSync(o.join(x,y),"utf8")));s++,p.status==="open"?a++:p.status==="in-progress"?i++:p.status==="done"?l++:p.status==="shelved"&&g++,!p.parentTaskId&&p.id&&d.push(p.id);}catch{}}}let c={version:"1.1",total:s,open:a,in_progress:i,done:l,shelved:g,roots:d,last_updated:new Date().toISOString()};return r.mkdirSync(n,{recursive:true}),r.writeFileSync(o.join(n,F),f.dump(c,{lineWidth:-1,noRefs:true})),c}function w(e){let t={};for(let[n,s]of Object.entries(e))s!==void 0&&(t[n]=s);return t}export{k as a,O as b,D as c,$ as d,A as e,I as f,L as g,M as h,v as i};
|