@a-company/paradigm 5.34.0 → 5.37.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-MIRBLRUJ.js → accept-orchestration-36AP7HTX.js} +1 -1
- package/dist/{add-P76GEMGF.js → add-FGKNJS3F.js} +1 -1
- package/dist/agent-E7LDKJ4O.js +33 -0
- package/dist/{agent-loader-5255KNM7.js → agent-loader-2HXKVL6J.js} +1 -1
- package/dist/{agent-loader-A5FMBAFJ.js → agent-loader-XS6LIMUG.js} +1 -1
- package/dist/{agent-state-KSQ3S7OB.js → agent-state-L7LCPRC3.js} +1 -1
- package/dist/{agents-suggest-HYTFMQD3.js → agents-suggest-Y5D6AALG.js} +1 -1
- package/dist/{aggregate-W66DM3GA.js → aggregate-OZJRRAQR.js} +1 -1
- package/dist/ambient-4NSPAQDJ.js +35 -0
- package/dist/{assess-UFPYEJKP.js → assess-AMPVSWK7.js} +1 -1
- package/dist/{auto-RHJXOZFL.js → auto-A7VUHCUC.js} +1 -1
- package/dist/{beacon-5QVYV5DF.js → beacon-YBLUUTYY.js} +1 -1
- package/dist/{calibration-OLJYB5HN.js → calibration-FQ4YVOE4.js} +1 -1
- package/dist/{check-THVGY4R5.js → check-46QL3KMQ.js} +1 -1
- package/dist/{chunk-AGSUX2GJ.js → chunk-3OMJI5TT.js} +2 -2
- package/dist/chunk-3QMRDN65.js +29 -0
- package/dist/{chunk-QNZEG7IT.js → chunk-3XGNXXCT.js} +1 -1
- package/dist/{chunk-VG7FN2TU.js → chunk-4W5TBL3O.js} +1 -1
- package/dist/{chunk-UDUHSHO4.js → chunk-5YHR77AL.js} +1 -1
- package/dist/chunk-6PP2RPIZ.js +3 -0
- package/dist/{chunk-VCKKJDLP.js → chunk-6QKCUEEY.js} +1 -1
- package/dist/{chunk-JBDMCRPP.js → chunk-77WX6HGV.js} +1 -1
- package/dist/{chunk-A7KFOJ2F.js → chunk-7PB7AXQE.js} +1 -1
- package/dist/chunk-7SGNNVE5.js +3 -0
- package/dist/{chunk-WS2N27RX.js → chunk-7YTAA6XA.js} +1 -1
- package/dist/chunk-BCOPNVPY.js +11 -0
- package/dist/chunk-BRHQJLTG.js +2 -0
- package/dist/{chunk-W5IWDW4Y.js → chunk-DG3VCY43.js} +1 -1
- package/dist/{chunk-HMQ5BHP2.js → chunk-DOCDDDTD.js} +10 -10
- package/dist/chunk-DSYEGRQ2.js +3 -0
- package/dist/chunk-EMMMBAID.js +2 -0
- package/dist/chunk-F5BSUC2L.js +3 -0
- package/dist/chunk-GE3GQALR.js +2 -0
- package/dist/chunk-IW5K3RNR.js +8 -0
- package/dist/chunk-JIF7OSGH.js +8 -0
- package/dist/{chunk-HPAHK4AJ.js → chunk-JUOOVKK6.js} +1 -1
- package/dist/chunk-NFQLONFY.js +3 -0
- package/dist/chunk-OVDYPOHR.js +2 -0
- package/dist/{chunk-33LKBMVK.js → chunk-RLJ5K3J5.js} +1 -1
- package/dist/{chunk-HXGYVS2N.js → chunk-RN35IVA2.js} +1 -1
- package/dist/{chunk-ODVKPZZ4.js → chunk-W6WVJLHO.js} +1 -1
- package/dist/chunk-X54WXWCX.js +111 -0
- package/dist/chunk-XHJ27CER.js +2 -0
- package/dist/{chunk-32RBX5YV.js → chunk-XNB4TZTD.js} +1 -1
- package/dist/chunk-YG5G5GEQ.js +456 -0
- package/dist/chunk-Z72SDTBJ.js +3 -0
- package/dist/{claude-4LR3LJQZ.js → claude-OX54QSLC.js} +1 -1
- package/dist/{claude-cli-UP6HGH7C.js → claude-cli-FHLJQVJC.js} +1 -1
- package/dist/{claude-code-RLJ4GX77.js → claude-code-GVGU3A3B.js} +1 -1
- package/dist/{claude-code-teams-R37HJY3Y.js → claude-code-teams-ZRHPTGPP.js} +1 -1
- package/dist/{compliance-Q676YALK.js → compliance-PHSPVYK2.js} +3 -3
- package/dist/{compliance-health-JNP3P35P.js → compliance-health-HCZTJDN7.js} +1 -1
- package/dist/{conductor-Y5IXELTL.js → conductor-LYBMM66Z.js} +1 -1
- package/dist/{config-schema-GUQY2QN7.js → config-schema-URJW6UZH.js} +1 -1
- package/dist/{constellation-CG7C4WFE.js → constellation-PX3ZKMWQ.js} +1 -1
- package/dist/{context-audit-XRPT3OU2.js → context-audit-APFKELFT.js} +2 -2
- package/dist/{cost-IDNVMAEV.js → cost-B5SAHPOJ.js} +1 -1
- package/dist/{cost-PK4KIF7R.js → cost-MMWUDGZC.js} +1 -1
- package/dist/{cursor-cli-QKF7Z6M2.js → cursor-cli-Q2HLQ5TE.js} +1 -1
- package/dist/{cursorrules-U5O4G5T4.js → cursorrules-3BW6K6D5.js} +1 -1
- package/dist/{decision-loader-2XPZE4EZ.js → decision-loader-4KMQVAXZ.js} +1 -1
- package/dist/{delete-P5VULXR4.js → delete-7PQZUERZ.js} +1 -1
- package/dist/{diff-QHQWLM3L.js → diff-F2HUO2H3.js} +1 -1
- package/dist/{discipline-H7LDI6NT.js → discipline-ARFFIXQL.js} +1 -1
- package/dist/{dist-W3XCATBJ.js → dist-5IUWRFG6.js} +1 -1
- package/dist/{dist-KGRCLBJP-2QAPFYNF.js → dist-KGRCLBJP-R5CCPPXN.js} +1 -1
- package/dist/{dist-3ZCH25SG.js → dist-MRZDZ5SX.js} +1 -1
- package/dist/{dist-VGFSP3XM.js → dist-OKM6BXTH.js} +1 -1
- package/dist/{dist-VXCZWVVJ.js → dist-VWC6FA46.js} +1 -1
- package/dist/dist-YUXXIXB3.js +3 -0
- package/dist/{docs-EDQ2STFK.js → docs-6WOQILZS.js} +1 -1
- package/dist/{docs-5BX2YWYK.js → docs-BI2DO7B2.js} +2 -2
- package/dist/doctor-JLTCBMS4.js +2 -0
- package/dist/{drift-ILZE5BFJ.js → drift-6QPDKKUO.js} +1 -1
- package/dist/{echo-UPTQUEDU.js → echo-3JJDKCNF.js} +1 -1
- package/dist/{edit-GUU3HBVW.js → edit-PLCGL5OV.js} +1 -1
- package/dist/{enforcement-BEGPQIUN.js → enforcement-5MHSQAXE.js} +1 -1
- package/dist/{enforcement-46XWPNSA.js → enforcement-IWABOHMY.js} +1 -1
- package/dist/{event-Y3VXC2RV.js → event-5J3GBWKT.js} +1 -1
- package/dist/{explain-files-3GPZUETV.js → explain-files-LPHTJL4N.js} +1 -1
- package/dist/{export-CV5KCTPS.js → export-NXUFTFPW.js} +1 -1
- package/dist/{flow-POQP27WA.js → flow-IT2IVXXT.js} +1 -1
- package/dist/{gap-narrator-NTXLUI7I.js → gap-narrator-DVXPWNFN.js} +1 -1
- package/dist/{global-C44FW4G2.js → global-J2VTYKCC.js} +1 -1
- package/dist/{graduate-3BBSC27A.js → graduate-N2HF4JT6.js} +1 -1
- package/dist/graph-VLMP6DW2.js +2 -0
- package/dist/{graph-server-COZR5C3Z.js → graph-server-TBHHBFOM.js} +1 -1
- package/dist/{habits-GICVMTJL.js → habits-JTMWGVPH.js} +3 -3
- package/dist/{history-UW454SDP.js → history-FHS7EC3Z.js} +1 -1
- package/dist/{hooks-BNWRGACA.js → hooks-BL6CXRVK.js} +1 -1
- package/dist/index.js +9 -9
- package/dist/init-ZS7RAR7L.js +2 -0
- package/dist/{integrity-UYDOOJDP.js → integrity-UBMZCB77.js} +1 -1
- package/dist/{integrity-checker-DHGMZQDG.js → integrity-checker-VSR3ITBL.js} +1 -1
- package/dist/journal-loader-EELDB4P2.js +2 -0
- package/dist/{lint-IGKE6UPS.js → lint-KQQ2RMSJ.js} +1 -1
- package/dist/{list-5IUGP3ZB.js → list-37UCWCOQ.js} +1 -1
- package/dist/{list-YKIQNKGB.js → list-6WY4CFUR.js} +1 -1
- package/dist/lore-loader-CP5RUJ4A.js +2 -0
- package/dist/{lore-loader-XY5MZRR2.js → lore-loader-PBUDKXAJ.js} +1 -1
- package/dist/{lore-server-FC2GMDLT.js → lore-server-A3KKZLSY.js} +1 -1
- package/dist/{manual-RXSPSFLL.js → manual-HKI6OXB4.js} +1 -1
- package/dist/mcp.js +17 -449
- package/dist/{migrate-YQG2FG3J.js → migrate-W3KCXLDS.js} +2 -2
- package/dist/{migrate-assessments-GEI5WMI2.js → migrate-assessments-D2TOBJ5V.js} +1 -1
- package/dist/{model-discovery-HMB3YI4L.js → model-discovery-TWX4A4YD.js} +1 -1
- package/dist/{nomination-engine-W6QTQX2P.js → nomination-engine-A24774W4.js} +1 -1
- package/dist/{notebook-PE3JSYZI.js → notebook-LXJ2LHUA.js} +1 -1
- package/dist/notebook-loader-CF52PNZC.js +2 -0
- package/dist/{orchestrate-7CJWHLBA.js → orchestrate-WFCNV2II.js} +1 -1
- package/dist/{peers-P2KXU7ZK.js → peers-7TPZTKH7.js} +1 -1
- package/dist/{persona-STQWZH5P.js → persona-UGTCFEGT.js} +1 -1
- package/dist/{pipeline-MZUITRVN.js → pipeline-7PZ6ILWX.js} +1 -1
- package/dist/{platform-server-G6MJIAJS.js → platform-server-YIBX4YDJ.js} +2 -2
- package/dist/{plugin-update-checker-M7PW434O.js → plugin-update-checker-2EM4K45U.js} +1 -1
- package/dist/{portal-check-Z3OCQEQR.js → portal-check-YSDJRZUR.js} +1 -1
- package/dist/{portal-compliance-4MG5F2GI.js → portal-compliance-OBPK2IR5.js} +1 -1
- package/dist/{probe-5L5BQDGE.js → probe-WKXR3IN4.js} +1 -1
- package/dist/{project-type-AGO6VUKF.js → project-type-MRBJAKC7.js} +1 -1
- package/dist/{promote-NJQDZBZA.js → promote-VHBA56KW.js} +2 -2
- package/dist/{providers-TBPOE4DI.js → providers-RX7SBLHZ.js} +1 -1
- package/dist/{quiz-FE5UGAY2.js → quiz-3SQNPRJ3.js} +1 -1
- package/dist/{record-YXPB34MY.js → record-7QJPZZP7.js} +1 -1
- package/dist/registry-LR5QACRK.js +20 -0
- package/dist/reindex-F7EV3Z34.js +2 -0
- package/dist/{remember-MJRNTXYS.js → remember-SFGBTTEE.js} +1 -1
- package/dist/{retag-N5XF3KXP.js → retag-GFXUYP7S.js} +1 -1
- package/dist/{review-6UAH6V3R.js → review-6KKZWV3A.js} +1 -1
- package/dist/{review-77QI6VOC.js → review-GEBSYOZB.js} +1 -1
- package/dist/{ripple-ZGDITCGB.js → ripple-4F5ZCXS4.js} +1 -1
- package/dist/{roster-TA2GFDR7.js → roster-RI3UC2YI.js} +1 -1
- package/dist/scaffold-WA4L2K7J.js +18 -0
- package/dist/{scopes-commands-3V5G6NYV.js → scopes-commands-5FFIUDRC.js} +1 -1
- package/dist/{sentinel-HYAZ3CO5.js → sentinel-37ZEEWT7.js} +2 -2
- package/dist/{sentinel-bridge-VR357PKL.js → sentinel-bridge-EZGFRVFH.js} +1 -1
- package/dist/{serve-L52ZUTU6.js → serve-2BXDL35A.js} +2 -2
- package/dist/{serve-ZJ3EXVA5.js → serve-2LSTQFFQ.js} +2 -2
- package/dist/{serve-OY6XYL7F.js → serve-5JME5QEM.js} +2 -2
- package/dist/{server-4YNUIK4W.js → server-AIXFROYL.js} +1 -1
- package/dist/{server-2MNROHF6.js → server-XLHIYDTZ.js} +1 -1
- package/dist/session-tracker-VSFRNFRL.js +2 -0
- package/dist/{session-work-log-SLAPEP3M.js → session-work-log-6GKGUQ5C.js} +1 -1
- package/dist/{session-work-log-5UJTJJ22.js → session-work-log-UYMIWWOX.js} +1 -1
- package/dist/{setup-KPIMRZ4Q.js → setup-F2N4LUR7.js} +1 -1
- package/dist/{setup-3F5IK7MO.js → setup-ZM4JFV5D.js} +2 -2
- package/dist/{shift-IKTWYSEQ.js → shift-DDYVQJ75.js} +5 -5
- package/dist/{show-PJ5LFLIL.js → show-CZLVYLM5.js} +1 -1
- package/dist/{show-BOAVWZPZ.js → show-RFOIR2GQ.js} +1 -1
- package/dist/{snapshot-L2G56RPL.js → snapshot-6N564OUJ.js} +1 -1
- package/dist/{spawn-7TCAMD6H.js → spawn-HYARN3RL.js} +1 -1
- package/dist/{status-A37ECYNJ.js → status-CUG3PKGC.js} +1 -1
- package/dist/{status-77M3SDIF.js → status-WBJ6D7BD.js} +1 -1
- package/dist/{summary-ZJLQ6KHB.js → summary-2AM4QVPW.js} +1 -1
- package/dist/{sweep-HU74OPVW.js → sweep-WHDT7ENV.js} +1 -1
- package/dist/{switch-CTW4PDGI.js → switch-HBGIFNF6.js} +1 -1
- package/dist/{symphony-IS5TYPXY.js → symphony-CWKKMFAS.js} +25 -25
- package/dist/symphony-VTHVTE57.js +2 -0
- package/dist/symphony-loader-RYFZOQJS.js +2 -0
- package/dist/{symphony-peers-X5NGWXFP.js → symphony-peers-ISJPKX7W.js} +1 -1
- package/dist/{symphony-peers-U4KHMKGI.js → symphony-peers-LWBUQ3T4.js} +1 -1
- package/dist/symphony-relay-L3BY6RGM.js +3 -0
- package/dist/sync-WIFD7UCL.js +2 -0
- package/dist/{sync-llms-HL5PPW3M.js → sync-llms-MZ3RQWFX.js} +1 -1
- package/dist/{task-loader-NZFDTUQ5.js → task-loader-EU7JLTR3.js} +1 -1
- package/dist/team-C3PWO7XL.js +2 -0
- package/dist/{test-BQJMS4Y2.js → test-6MUL4EXS.js} +1 -1
- package/dist/{thread-HFXK65D4.js → thread-K6UHDIUW.js} +1 -1
- package/dist/{timeline-K3ZFKJ3R.js → timeline-S26CQWHT.js} +1 -1
- package/dist/tools-4WKLLDFU.js +2 -0
- package/dist/{triage-FCWOZASE.js → triage-YF6WYZY4.js} +1 -1
- package/dist/{tutorial-UC6YQMNN.js → tutorial-UEBX7Z2G.js} +1 -1
- package/dist/{university-FJ7OCOA3.js → university-UMT7PAKE.js} +1 -1
- package/dist/university-content/courses/para-201.json +5 -5
- package/dist/university-content/courses/para-301.json +10 -10
- package/dist/university-content/courses/para-401.json +3 -3
- package/dist/university-content/courses/para-501.json +5 -5
- package/dist/university-content/courses/para-601.json +1 -1
- package/dist/university-content/plsat/v2.0.json +7 -7
- package/dist/university-content/plsat/v3.0.json +9 -9
- package/dist/university-content/reference.json +4 -4
- package/dist/university-ui/assets/{index-DmiLQehB.js → index-CecQrfSn.js} +2 -2
- package/dist/university-ui/assets/{index-DmiLQehB.js.map → index-CecQrfSn.js.map} +1 -1
- package/dist/university-ui/index.html +1 -1
- package/dist/{upgrade-B4IOLZYK.js → upgrade-USW7YJEX.js} +1 -1
- package/dist/{validate-LSCDOLBO.js → validate-2PZTNYSS.js} +1 -1
- package/dist/{validate-VZXTJHGO.js → validate-KW3YFGTV.js} +1 -1
- package/dist/{validate-C6SMKGYD.js → validate-VZGBVTPM.js} +1 -1
- package/dist/{watch-LRM5XD46.js → watch-HL3ZOALL.js} +1 -1
- package/dist/{watch-PZCCUP6K.js → watch-KQU3S7KE.js} +1 -1
- package/dist/{wisdom-XZ3QKPNP.js → wisdom-UU7HOE3M.js} +1 -1
- package/dist/{work-log-loader-DL5GZ2BQ.js → work-log-loader-J27XSFCE.js} +1 -1
- package/dist/workspace-CE6LNXVI.js +2 -0
- package/package.json +5 -1
- package/templates/paradigm/specs/context-tracking.md +4 -4
- package/dist/agent-UUTYOFTH.js +0 -33
- package/dist/ambient-2JZTNXUL.js +0 -35
- package/dist/chunk-2Q7RGCJH.js +0 -3
- package/dist/chunk-5TAVYPOV.js +0 -2
- package/dist/chunk-73R63P7K.js +0 -2
- package/dist/chunk-C7ZCCKJT.js +0 -3
- package/dist/chunk-CUOEZAVL.js +0 -8
- package/dist/chunk-EAZ3EMOZ.js +0 -29
- package/dist/chunk-LKFBDUCV.js +0 -11
- package/dist/chunk-QGZRM6ZB.js +0 -2
- package/dist/chunk-S7K7UPXL.js +0 -3
- package/dist/chunk-TXBSTT64.js +0 -111
- package/dist/chunk-TZZNHUAR.js +0 -2
- package/dist/chunk-UHQLYIRI.js +0 -3
- package/dist/chunk-VZLGBGU3.js +0 -8
- package/dist/doctor-R4UGMR5N.js +0 -2
- package/dist/graph-CNDE5TAT.js +0 -2
- package/dist/init-24MAQJFM.js +0 -2
- package/dist/journal-loader-GLH7XFTK.js +0 -2
- package/dist/lore-loader-RVQI5GXL.js +0 -2
- package/dist/notebook-loader-CENTDDUJ.js +0 -2
- package/dist/reindex-2MRCAIZG.js +0 -2
- package/dist/session-tracker-WSTRV7UP.js +0 -2
- package/dist/symphony-43N4R6C2.js +0 -2
- package/dist/symphony-loader-XJT43FOS.js +0 -2
- package/dist/symphony-relay-CIMRXQHI.js +0 -3
- package/dist/sync-QRDSFETO.js +0 -2
- package/dist/team-WIJVWLII.js +0 -2
- package/dist/workspace-2ODL5WLY.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {b}from'./chunk-
|
|
2
|
+
import {b}from'./chunk-7PB7AXQE.js';import'./chunk-TYWB5IQJ.js';import'./chunk-5YHR77AL.js';import'./chunk-RN35IVA2.js';import'./chunk-AO7ZSRME.js';import'./chunk-FYDRENK7.js';import'./chunk-EKZDFEJW.js';import'./chunk-SHD27BQX.js';import'./chunk-T6IDXUUA.js';import'./chunk-JIXHEBGK.js';import'./chunk-QT2LKB3P.js';import'./chunk-XHJ27CER.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 {g,i,f}from'./chunk-D34YFK4M.js';import'./chunk-
|
|
2
|
+
import {g,i,f}from'./chunk-D34YFK4M.js';import'./chunk-XHJ27CER.js';import r from'chalk';import {execSync}from'child_process';import*as y from'os';function b(){try{return execSync("git config user.name",{encoding:"utf-8",timeout:3e3}).trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").slice(0,20)||"unknown"}catch{try{return y.userInfo().username}catch{return "unknown"}}}async function w(i$1,t){let s=process.cwd();t.title||(console.error(r.red(`
|
|
3
3
|
Error: --title is required
|
|
4
4
|
`)),process.exit(1));let a=b(),n=new Date().toISOString().slice(0,10),l=t.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,40),u=t.tags?t.tags.split(",").map(e=>e.trim()):[],d=t.symbols?t.symbols.split(",").map(e=>e.trim()):[];if(i$1==="quiz"){let e=`Q-${l}`,p={id:e,title:t.title,description:t.body||"",author:a,created:n,updated:n,tags:u,symbols:d,difficulty:t.difficulty||"beginner",passThreshold:.7,questions:[]};g(s,p),i(s),console.log(r.green(`
|
|
5
5
|
Created quiz: ${e}`)),console.log(r.gray(` Add questions by editing the YAML file
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {a as a$1}from'./chunk-LKAT7IAK.js';import'./chunk-XHJ27CER.js';import*as a from'fs';import*as y from'path';import*as R from'os';import o from'chalk';import*as m from'js-yaml';var h=y.join(R.homedir(),".paradigm","agents"),S=".paradigm/agents",$=".agent",k=".paradigm/roster.yaml";function j(e){let s=y.join(e,k);if(!a.existsSync(s))return null;try{return m.load(a.readFileSync(s,"utf8"))?.active??null}catch{return null}}function F(e,s){let c=y.join(e,k),n=y.dirname(c);a.existsSync(n)||a.mkdirSync(n,{recursive:true});let r={version:"1.0",active:s.sort()};a.writeFileSync(c,m.dump(r,{lineWidth:-1,noRefs:true}),"utf8");}function C(){if(!a.existsSync(h))return [];try{return a.readdirSync(h).filter(e=>e.endsWith($)).map(e=>e.replace($,""))}catch{return []}}var E={architect:{style:"deliberate",risk:"conservative",verbosity:"detailed"},builder:{style:"rapid",risk:"balanced",verbosity:"concise"},tester:{style:"methodical",risk:"conservative",verbosity:"concise"},reviewer:{style:"deliberate",risk:"conservative",verbosity:"detailed"},security:{style:"methodical",risk:"conservative",verbosity:"detailed"}};async function _(e={}){let s=process.cwd(),c=a$1.command("agent-list").start("Listing agent profiles",{cwd:s}),n=[];if(!e.project&&a.existsSync(h))try{let i=a.readdirSync(h).filter(d=>d.endsWith($));for(let d of i)try{let f=a.readFileSync(y.join(h,d),"utf-8"),t=m.load(f);t?.id&&n.push(t);}catch{}}catch{}let r=y.join(s,S);if(!e.global&&a.existsSync(r))try{let i=a.readdirSync(r).filter(d=>d.endsWith($));for(let d of i)try{let f=a.readFileSync(y.join(r,d),"utf-8"),t=m.load(f);if(t?.id){let l=n.findIndex(g=>g.id===t.id);l>=0?n[l]=t:n.push(t);}}catch{}}catch{}if(e.json){console.log(JSON.stringify({count:n.length,agents:n.map(O)},null,2)),c.success(`Found ${n.length} agents`);return}if(console.log(o.blue(`
|
|
3
|
+
\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(o.blue("\u2502")+o.white.bold(" paradigm agent list ")+o.blue("\u2502")),console.log(o.blue("\u2502")+o.gray(" Persistent agent identity profiles ")+o.blue("\u2502")),console.log(o.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
|
|
4
|
+
`)),n.length===0){console.log(o.yellow(" No .agent profiles found.")),console.log(o.gray(` Create one: paradigm agent create <id> --global
|
|
5
|
+
`)),c.success("No agents found");return}for(let i of n){let f=(i.expertise||[]).sort((t,l)=>l.confidence-t.confidence).slice(0,3).map(t=>`${t.symbol} (${(t.confidence*100).toFixed(0)}%)`).join(", ")||o.gray("none yet");console.log(` ${o.white.bold(i.id)} \u2014 ${o.gray(i.role)}`),console.log(` Style: ${i.personality?.style||"?"} | Risk: ${i.personality?.risk||"?"} | Verbosity: ${i.personality?.verbosity||"?"}`),console.log(` Top expertise: ${f}`),console.log(` Projects: ${Object.keys(i.contexts||{}).join(", ")||o.gray("none")}`),console.log("");}c.success(`Listed ${n.length} agents`);}async function D(e,s={}){let c=process.cwd(),n=a$1.command("agent-show").start(`Showing agent ${e}`,{cwd:c}),r=w(c,e);if(!r){s.json?console.log(JSON.stringify({error:`Agent "${e}" not found`})):(console.log(o.red(`
|
|
6
|
+
Agent "${e}" not found.`)),console.log(o.gray(` Create: paradigm agent create ${e} --global
|
|
7
|
+
`))),n.error(`Agent ${e} not found`);return}if(s.json){console.log(JSON.stringify(r,null,2)),n.success(`Showed agent ${e}`);return}if(console.log(o.blue(`
|
|
8
|
+
\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(o.blue("\u2502")+o.white.bold(` Agent: ${e}`.padEnd(50))+o.blue("\u2502")),console.log(o.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
|
|
9
|
+
`)),console.log(` ${o.white.bold("Role:")} ${r.role}`),console.log(` ${o.white.bold("Description:")} ${r.description}`),console.log(` ${o.white.bold("Version:")} ${r.version}`),console.log(` ${o.white.bold("Created:")} ${r.created}`),console.log(` ${o.white.bold("Updated:")} ${r.updated}`),console.log(""),r.personality){let l=r.personality;console.log(` ${o.white.bold("Personality")}`),console.log(` Style: ${l.style} | Risk: ${l.risk} | Verbosity: ${l.verbosity}`),console.log("");}let i=(r.expertise||[]).sort((l,g)=>g.confidence-l.confidence);if(i.length>0){console.log(` ${o.white.bold("Expertise")} (${i.length} symbols)`),console.log(` ${"Symbol".padEnd(30)} ${"Confidence".padEnd(12)} ${"Sessions".padEnd(10)} Last Touch`),console.log(` ${"-".repeat(70)}`);for(let l of i.slice(0,20)){let g=`${(l.confidence*100).toFixed(0)}%`.padEnd(12),p=String(l.sessions).padEnd(10),u=l.lastTouch?l.lastTouch.split("T")[0]:"\u2014";console.log(` ${l.symbol.padEnd(30)} ${g} ${p} ${u}`);}i.length>20&&console.log(o.gray(` ... and ${i.length-20} more`)),console.log("");}else console.log(o.gray(" No expertise recorded. Run `paradigm agent sync` to bootstrap from lore.\n"));let d=r.transferable||[];if(d.length>0){console.log(` ${o.white.bold("Transferable Patterns")} (${d.length})`);for(let l of d)console.log(` ${l.id}: ${(l.successRate*100).toFixed(0)}% success \u2014 ${l.description}`),console.log(o.gray(` Learned in: ${l.learnedIn} | Applied in: ${l.appliedIn.join(", ")||"none"}`));console.log("");}let f=Object.entries(r.contexts||{});if(f.length>0){console.log(` ${o.white.bold("Project Contexts")} (${f.length})`);for(let[l,g]of f)console.log(` ${o.white(l)}: ${g.sessionsInProject||0} sessions, last active ${g.lastActive?.split("T")[0]||"\u2014"}`),g.defaultModel&&console.log(` Model: ${g.defaultModel}`),g.focus?.length&&console.log(` Focus: ${g.focus.join(", ")}`);console.log("");}let t=r.permissions;t&&(console.log(` ${o.white.bold("Permissions")}`),t.paths?.read?.length&&console.log(` Read: ${t.paths.read.join(", ")}`),t.paths?.write?.length&&console.log(` Write: ${t.paths.write.join(", ")}`),t.paths?.deny?.length&&console.log(` Deny: ${o.red(t.paths.deny.join(", "))}`),t.tools?.allow?.length&&console.log(` Tools allow: ${t.tools.allow.join(", ")}`),t.tools?.deny?.length&&console.log(` Tools deny: ${o.red(t.tools.deny.join(", "))}`),t.dangerous_actions?.length&&console.log(` Requires approval: ${t.dangerous_actions.join(", ")}`),console.log("")),n.success(`Showed agent ${e}`);}async function L(e,s={}){let c=process.cwd(),n=s.global?"global":"project",r=a$1.command("agent-create").start(`Creating agent ${e} (${n})`,{cwd:c}),i=n==="global"?h:y.join(c,S);a.existsSync(i)||a.mkdirSync(i,{recursive:true});let d=y.join(i,`${e}${$}`);if(a.existsSync(d)){console.log(o.yellow(`
|
|
10
|
+
Agent "${e}" already exists at ${d}`)),console.log(o.gray(" Use `paradigm agent show` to view.\n")),r.error("Agent already exists");return}let f=new Date().toISOString(),t=E[e]||{style:"deliberate",risk:"balanced",verbosity:"concise"},l={id:e,role:s.role||`${e.charAt(0).toUpperCase()+e.slice(1)} agent`,description:s.description||`Persistent identity for the ${e} agent role`,version:"1.0.0",personality:t,expertise:[],transferable:[],contexts:{},created:f,updated:f};if(s.denyPaths){let p=s.denyPaths.split(",").map(u=>u.trim());l.permissions={paths:{deny:p}};}let g=m.dump(l,{lineWidth:120,noRefs:true,sortKeys:false});a.writeFileSync(d,g,"utf-8"),console.log(o.green(`
|
|
11
|
+
\u2713 Created agent "${e}" at ${d}`)),console.log(o.gray(" Run `paradigm agent sync` to bootstrap expertise from lore.\n")),r.success(`Created agent ${e}`);}async function W(e,s={}){let c=process.cwd(),n=a$1.command("agent-sync").start(`Syncing expertise for ${e}`,{cwd:c}),r=y.join(c,".paradigm","lore","entries");if(!a.existsSync(r)){console.log(o.yellow(`
|
|
12
|
+
No lore directory found. Nothing to sync from.
|
|
13
|
+
`)),n.error("No lore found");return}let i=w(c,e);if(!i){if(s.dryRun){console.log(o.yellow(`
|
|
14
|
+
Agent "${e}" not found. Would create with --no-dry-run.
|
|
15
|
+
`)),n.success("Dry run \u2014 would create");return}let p=(a.existsSync(y.join(h,`${e}${$}`))?"global":"project")==="global"?h:y.join(c,S);a.existsSync(p)||a.mkdirSync(p,{recursive:true});let u=new Date().toISOString(),x=E[e]||{style:"deliberate",risk:"balanced",verbosity:"concise"};i={id:e,role:`${e.charAt(0).toUpperCase()+e.slice(1)} agent`,description:`Persistent identity for the ${e} agent role`,version:"1.0.0",personality:x,expertise:[],transferable:[],contexts:{},created:u,updated:u};}let d=i.expertise||[],f=0,t=new Set,l=T(r);for(let g of l)if(!(!g.symbols_touched||g.symbols_touched.length===0)){f++;for(let p of g.symbols_touched){t.add(p);let u=d.find(x=>x.symbol===p);u?(u.sessions++,u.lastTouch=g.timestamp||u.lastTouch,g.confidence!=null&&(u.confidence=.7*u.confidence+.3*g.confidence)):d.push({symbol:p,confidence:g.confidence??.5,sessions:1,lastTouch:g.timestamp||new Date().toISOString()});}}if(i.expertise=d,s.json)console.log(JSON.stringify({agentId:e,entriesProcessed:f,symbolsUpdated:t.size,dryRun:!!s.dryRun,topExpertise:d.sort((g,p)=>p.confidence-g.confidence).slice(0,10)},null,2));else if(console.log(o.blue(`
|
|
16
|
+
Syncing expertise for "${e}" from ${f} lore entries...`)),console.log(` ${o.green("\u2713")} ${t.size} symbols updated`),console.log(` ${o.green("\u2713")} ${f} entries processed`),d.length>0){console.log(`
|
|
17
|
+
Top expertise:`);for(let g of d.sort((p,u)=>u.confidence-p.confidence).slice(0,5))console.log(` ${g.symbol}: ${(g.confidence*100).toFixed(0)}% (${g.sessions} sessions)`);}if(s.dryRun)s.json||console.log(o.yellow(`
|
|
18
|
+
Dry run \u2014 no changes written.
|
|
19
|
+
`));else {i.updated=new Date().toISOString();let g=y.join(c,S,`${e}${$}`),p=y.join(h,`${e}${$}`),u=a.existsSync(g)?"project":"global",x=u==="global"?h:y.join(c,S);a.existsSync(x)||a.mkdirSync(x,{recursive:true});let A=u==="global"?p:g;a.writeFileSync(A,m.dump(i,{lineWidth:120,noRefs:true,sortKeys:false}),"utf-8"),s.json||console.log(o.green(`
|
|
20
|
+
\u2713 Saved to ${A}
|
|
21
|
+
`));}n.success(`Synced ${t.size} symbols from ${f} entries`);}async function M(e={}){let s=process.cwd(),c=a$1.command("agent-roster").start("Agent roster",{cwd:s}),n=[];if(a.existsSync(h))for(let t of a.readdirSync(h).filter(l=>l.endsWith($)))try{let l=m.load(a.readFileSync(y.join(h,t),"utf-8"));l?.id&&n.push(l);}catch{}let r=y.join(s,S);if(a.existsSync(r))for(let t of a.readdirSync(r).filter(l=>l.endsWith($)))try{let l=m.load(a.readFileSync(y.join(r,t),"utf-8"));if(l?.id){let g=n.findIndex(p=>p.id===l.id);g>=0?n[g]=l:n.push(l);}}catch{}let i=j(s),d=i?n.filter(t=>i.includes(t.id)):n,f=i?n.filter(t=>!i.includes(t.id)):[];if(e.json){console.log(JSON.stringify({active:d.map(t=>P(t,false)),benched:f.map(t=>P(t,true))},null,2)),c.success(`${d.length} active, ${f.length} benched`);return}if(console.log(o.blue(`
|
|
22
|
+
\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(o.blue("\u2502")+o.white.bold(" Agent Roster ")+o.blue("\u2502")),console.log(o.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
|
|
23
|
+
`)),d.length>0){console.log(o.green.bold(" Active"));for(let t of d)v(t);}if(f.length>0){console.log(o.gray.bold(`
|
|
24
|
+
Benched`));for(let t of f)v(t,true);}n.length===0?console.log(o.yellow(` No agents found.
|
|
25
|
+
`)):console.log(""),c.success(`${d.length} active, ${f.length} benched`);}function v(e,s=false){let c=(e.expertise||[]).sort((t,l)=>l.confidence-t.confidence),n=c[0]?`${c[0].symbol} (${(c[0].confidence*100).toFixed(0)}%)`:o.gray("\u2014"),r=s?o.gray:o.white,i=e.nickname?` (${e.nickname})`:"",d=e.attention?.threshold,f=d!=null?` | thr: ${d.toFixed(2)}`:"";console.log(` ${r.bold(e.id)}${o.gray(i)} \u2014 ${o.gray(e.role)}`),console.log(` Top: ${n} | ${c.length} symbols${f}`);}function P(e,s=false){let c=(e.expertise||[]).sort((n,r)=>r.confidence-n.confidence);return {id:e.id,role:e.role,nickname:e.nickname,benched:s,expertiseCount:c.length,topExpertise:c.slice(0,3).map(n=>({symbol:n.symbol,confidence:parseFloat(n.confidence.toFixed(2))})),threshold:e.attention?.threshold}}async function U(e){let s=process.cwd(),c=a$1.command("agent-bench").start(`Benching agent ${e}`,{cwd:s}),n=w(s,e);if(!n){console.log(o.red(`
|
|
26
|
+
Agent "${e}" not found.
|
|
27
|
+
`)),c.error("Not found");return}let r=j(s);r?r=r.filter(i=>i!==n.id):r=C().filter(i=>i!==n.id),F(s,r),console.log(o.yellow(`
|
|
28
|
+
Agent "${n.id}" removed from this project's roster.`)),console.log(o.gray(` Maestro will skip this agent during orchestration. Still available globally.
|
|
29
|
+
`)),c.success(`Benched ${n.id} (roster: ${r.length} active)`);}async function J(e){let s=process.cwd(),c=a$1.command("agent-activate").start(`Activating agent ${e}`,{cwd:s}),n=w(s,e);if(!n){console.log(o.red(`
|
|
30
|
+
Agent "${e}" not found.
|
|
31
|
+
`)),c.error("Not found");return}let r=j(s);if(r)r.includes(n.id)||r.push(n.id);else {let i=C();r=i.includes(n.id)?i:[...i,n.id];}F(s,r),console.log(o.green(`
|
|
32
|
+
\u25B6 Agent "${n.id}" added to this project's roster.`)),console.log(o.gray(` Maestro will include this agent in orchestration. Roster is per-project.
|
|
33
|
+
`)),c.success(`Activated ${n.id} (roster: ${r.length} active)`);}function w(e,s){let c=y.join(e,S,`${s}${$}`);if(a.existsSync(c))try{return m.load(a.readFileSync(c,"utf-8"))}catch{}let n=y.join(h,`${s}${$}`);if(a.existsSync(n))try{return m.load(a.readFileSync(n,"utf-8"))}catch{}return null}function O(e){return {id:e.id,role:e.role,personality:e.personality,expertiseCount:(e.expertise||[]).length,topExpertise:(e.expertise||[]).sort((s,c)=>c.confidence-s.confidence).slice(0,3).map(s=>({symbol:s.symbol,confidence:parseFloat(s.confidence.toFixed(2))})),projectContexts:Object.keys(e.contexts||{}),transferableCount:(e.transferable||[]).length}}function T(e){let s=[];try{let c=a.readdirSync(e,{withFileTypes:!0});for(let n of c){if(!n.isDirectory())continue;let r=y.join(e,n.name);try{let i=a.readdirSync(r).filter(d=>d.endsWith(".yaml")||d.endsWith(".yml"));for(let d of i)try{let f=a.readFileSync(y.join(r,d),"utf-8"),t=m.load(f);t?.symbols_touched&&Array.isArray(t.symbols_touched)&&s.push({symbols_touched:t.symbols_touched,confidence:typeof t.confidence=="number"?t.confidence:void 0,timestamp:t.timestamp||n.name});}catch{}}catch{}}}catch{}return s}export{J as agentActivateCommand,U as agentBenchCommand,L as agentCreateCommand,_ as agentListCommand,M as agentRosterCommand,D as agentShowCommand,W as agentSyncCommand};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
export{p as buildProfileEnrichment,t as checkPathPermission,u as checkToolPermission,x as computeIntegrityHash,k as createAgentProfile,a as decayedConfidence,s as determineIntegrityStatus,w as enforcePermissions,g as findAgentsByNickname,v as getPermissionConstraints,c as isAgentActive,e as listAllGlobalAgentIds,f as loadAgentProfile,i as loadAllAgentProfiles,b as loadProjectRoster,o as mergeAgentProfileWithManifest,l as queryExpertise,h as resolveAgent,r as sanitizeForPrompt,j as saveAgentProfile,d as saveProjectRoster,q as syncExpertiseFromLore,n as updateExpertiseFromAssessment,m as updateExpertiseFromLore,y as verifyIntegrity}from'./chunk-
|
|
2
|
+
export{p as buildProfileEnrichment,t as checkPathPermission,u as checkToolPermission,x as computeIntegrityHash,k as createAgentProfile,a as decayedConfidence,s as determineIntegrityStatus,w as enforcePermissions,g as findAgentsByNickname,v as getPermissionConstraints,c as isAgentActive,e as listAllGlobalAgentIds,f as loadAgentProfile,i as loadAllAgentProfiles,b as loadProjectRoster,o as mergeAgentProfileWithManifest,l as queryExpertise,h as resolveAgent,r as sanitizeForPrompt,j as saveAgentProfile,d as saveProjectRoster,q as syncExpertiseFromLore,n as updateExpertiseFromAssessment,m as updateExpertiseFromLore,y as verifyIntegrity}from'./chunk-7SGNNVE5.js';import'./chunk-DSYEGRQ2.js';import'./chunk-XHJ27CER.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {z}from'./chunk-
|
|
2
|
+
import {z}from'./chunk-6PP2RPIZ.js';export{p as buildProfileEnrichment,t as checkPathPermission,u as checkToolPermission,x as computeIntegrityHash,k as createAgentProfile,a as decayedConfidence,s as determineIntegrityStatus,w as enforcePermissions,g as findAgentsByNickname,v as getPermissionConstraints,c as isAgentActive,e as listAllGlobalAgentIds,f as loadAgentProfile,i as loadAllAgentProfiles,b as loadProjectRoster,o as mergeAgentProfileWithManifest,l as queryExpertise,h as resolveAgent,r as sanitizeForPrompt,j as saveAgentProfile,d as saveProjectRoster,q as syncExpertiseFromLore,n as updateExpertiseFromAssessment,m as updateExpertiseFromLore,y as verifyIntegrity}from'./chunk-6PP2RPIZ.js';import'./chunk-F5BSUC2L.js';import'./chunk-XHJ27CER.js';z();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
export{d as addPendingWork,f as addProjectPattern,e as completePendingWork,a as loadAgentState,i as loadAllAgentStates,g as loadGlobalAgentState,c as recordAgentSession,b as saveAgentState,h as updateGlobalAgentState}from'./chunk-XROULIQN.js';import'./chunk-
|
|
2
|
+
export{d as addPendingWork,f as addProjectPattern,e as completePendingWork,a as loadAgentState,i as loadAllAgentStates,g as loadGlobalAgentState,c as recordAgentSession,b as saveAgentState,h as updateGlobalAgentState}from'./chunk-XROULIQN.js';import'./chunk-XHJ27CER.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {a}from'./chunk-TYWB5IQJ.js';import {e}from'./chunk-AO7ZSRME.js';import'./chunk-
|
|
2
|
+
import {a}from'./chunk-TYWB5IQJ.js';import {e}from'./chunk-AO7ZSRME.js';import'./chunk-XHJ27CER.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.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {c,l as l$1,m,o as o$1,B}from'./chunk-T6IDXUUA.js';import'./chunk-JIXHEBGK.js';import'./chunk-QT2LKB3P.js';import'./chunk-
|
|
2
|
+
import {c,l as l$1,m,o as o$1,B}from'./chunk-T6IDXUUA.js';import'./chunk-JIXHEBGK.js';import'./chunk-QT2LKB3P.js';import'./chunk-XHJ27CER.js';import*as u from'fs';import*as l from'path';import o from'chalk';import S from'ora';async function A(d){let h=process.cwd(),a=l.resolve(h,d);console.log(o.blue(`
|
|
3
3
|
\u{1F52E} Aggregating Premise...
|
|
4
4
|
`));let c$1=S("Loading sources...").start();try{let e,g=l.join(a,".premise");if(u.existsSync(g)){let{data:r,errors:s}=c(g);if(s.length>0){c$1.warn("Warnings parsing .premise file");for(let n of s)console.log(o.yellow(` \u26A0 ${n}`));console.log(o.gray(` Falling back to directory aggregation...
|
|
5
5
|
`));}if(r&&!s.some(n=>n.includes("Required")))try{e=await l$1(r,a);}catch(n){console.log(o.yellow(` \u26A0 Error using .premise file: ${n.message}`)),console.log(o.gray(` Falling back to directory aggregation...
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {f,p,i,c,j}from'./chunk-7SGNNVE5.js';import {b as b$2}from'./chunk-XNB4TZTD.js';import {b as b$3}from'./chunk-7SWEOPWF.js';import'./chunk-DSYEGRQ2.js';import {d,b as b$1,f as f$1,a}from'./chunk-XHJ27CER.js';import*as g from'fs';import*as b from'path';import*as R from'js-yaml';import*as Z from'os';var jt={};d(jt,{getJournalStats:()=>oe,loadAllJournalEntries:()=>ne,loadJournalEntries:()=>A,loadJournalEntry:()=>ee,recordJournalEntry:()=>K});function z(n){let t=process.env.HOME||process.env.USERPROFILE||"";return b.join(t,".paradigm","agents",n,"journal")}function te(){let n=new Date,t=n.toISOString().slice(0,10),e=n.toISOString().slice(11,19).replace(/:/g,""),o=String(Math.floor(Math.random()*999)+1).padStart(3,"0");return `LJ-${t}-${e}-${o}`}function K(n,t){let e=new Date,o=te(),r={id:o,agent:n,timestamp:e.toISOString(),...t},i=z(n);g.mkdirSync(i,{recursive:true});let s=b.join(i,`${o}.yaml`);return g.writeFileSync(s,R.dump(r,{lineWidth:120,noRefs:true}),"utf8"),r}function A(n,t){let e=z(n);if(!g.existsSync(e))return [];let o=[],r=g.readdirSync(e).filter(s=>s.endsWith(".yaml"));for(let s of r)try{let a=g.readFileSync(b.join(e,s),"utf8"),c=R.load(a);c&&c.id&&o.push(c);}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 ee(n,t){let e=z(n),o=b.join(e,`${t}.yaml`);if(!g.existsSync(o))return null;let r=g.readFileSync(o,"utf8");return R.load(r)}function ne(n){let t=process.env.HOME||process.env.USERPROFILE||"",e=b.join(t,".paradigm","agents");if(!g.existsSync(e))return [];let o=[],r=g.readdirSync(e,{withFileTypes:true}).filter(i=>i.isDirectory());for(let i of r){if(n?.agent&&i.name!==n.agent)continue;let s=A(i.name,n);o.push(...s);}return o.sort((i,s)=>s.timestamp.localeCompare(i.timestamp)),n?.limit?o.slice(0,n.limit):o}function oe(n){let t=A(n),e={},o={},r=0;for(let i of t)e[i.trigger]=(e[i.trigger]||0)+1,o[i.project]=(o[i.project]||0)+1,i.transferable&&r++;return {total:t.length,byTrigger:e,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 V=b$1(()=>{});var Nt={};d(Nt,{addNotebookEntry:()=>xt,incrementApplied:()=>ae,loadNotebookEntries:()=>Dt,promoteFromLore:()=>se,searchNotebooks:()=>re});function Dt(n,t,e){let o=new Map,r=b.join(X,n);Et(r,o);let i=b.join(t,Y,n);Et(i,o);let s=Array.from(o.values());if(e?.concepts&&e.concepts.length>0){let a=new Set(e.concepts.map(c=>c.toLowerCase()));s=s.filter(c=>c.concepts.some(d=>a.has(d.toLowerCase())));}if(e?.tags&&e.tags.length>0){let a=new Set(e.tags.map(c=>c.toLowerCase()));s=s.filter(c=>c.tags.some(d=>a.has(d.toLowerCase())));}return s.sort((a,c)=>c.appliedCount-a.appliedCount)}function Et(n,t){if(g.existsSync(n))try{let e=g.readdirSync(n).filter(o=>o.startsWith(ie)&&o.endsWith(Q));for(let o of e)try{let r=g.readFileSync(b.join(n,o),"utf-8"),i=R.load(r);i?.id&&t.set(i.id,i);}catch{}}catch{}}function re(n,t,e){let o=Dt(n,e),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 xt(n,t,e,o){let r=new Date().toISOString(),i=(t.concepts[0]||"entry").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""),s=Date.now().toString(36),a=`nb-${i}-${s}`,c={...t,id:a,appliedCount:0,created:r,updated:r},d=e==="global"?b.join(X,n):b.join(o||process.cwd(),Y,n);g.existsSync(d)||g.mkdirSync(d,{recursive:true});let u=`${a}${Q}`,l=b.join(d,u),m=R.dump(c,{lineWidth:120,noRefs:true,sortKeys:false});return g.writeFileSync(l,m,"utf-8"),{entry:c,filePath:l}}async function se(n,t,e,o="global"){let{loadLoreEntry:r}=await import('./lore-loader-PBUDKXAJ.js'),i=await r(e,t);if(!i)return null;let s=[];if(i.symbols_touched)for(let d of i.symbols_touched){let u=d.replace(/^[#$^!~]/,"").toLowerCase();s.push(u);}let a=i.summary||"";i.body&&(a+=`
|
|
3
|
+
|
|
4
|
+
`+i.body);let c={source:"lore",loreEntryId:t,originProject:b.basename(e),createdBy:n};return xt(n,{context:i.title||`Promoted from ${t}`,snippet:a,provenance:c,confidence:i.confidence??.7,concepts:s,tags:i.tags||[]},o,e)}function ae(n,t,e){let o=b.join(e,Y,n),r=b.join(X,n);for(let i of [o,r]){let s=b.join(i,`${t}${Q}`);if(g.existsSync(s))try{let a=g.readFileSync(s,"utf-8"),c=R.load(a);if(c)return c.appliedCount=(c.appliedCount||0)+1,c.updated=new Date().toISOString(),g.writeFileSync(s,R.dump(c,{lineWidth:120,noRefs:!0,sortKeys:!1}),"utf-8"),!0}catch{}}return false}var X,Y,ie,Q,$t=b$1(()=>{X=b.join(Z.homedir(),".paradigm","notebooks"),Y=".paradigm/notebooks",ie="nb-",Q=".yaml";});var pt=".paradigm/events",Kt="stream.jsonl",J=1e3,$=[];function yt(n){return b.join(n,pt,Kt)}function Vt(){let n=Date.now(),t=Math.floor(Math.random()*9999).toString().padStart(4,"0");return `ev-${n}-${t}`}function M(n,t){let e={id:Vt(),timestamp:new Date().toISOString(),...t};$.push(e),$.length>J&&($=$.slice(-J));try{let o=b.join(n,pt);g.mkdirSync(o,{recursive:!0});let r=yt(n);g.appendFileSync(r,JSON.stringify(e)+`
|
|
5
|
+
`,"utf8"),Xt(r);}catch{}return e}function Xt(n){try{if(g.statSync(n).size>512*1024){let o=g.readFileSync(n,"utf8").trim().split(`
|
|
6
|
+
`);if(o.length>J){let r=o.slice(-J);g.writeFileSync(n,r.join(`
|
|
7
|
+
`)+`
|
|
8
|
+
`,"utf8");}}}catch{}}function ht(n,t){let e=Yt(n);return t?.type&&(e=e.filter(o=>o.type===t.type)),t?.source&&(e=e.filter(o=>o.source===t.source)),t?.symbol&&(e=e.filter(o=>o.symbols?.includes(t.symbol))),t?.agent&&(e=e.filter(o=>o.agent===t.agent)),t?.since&&(e=e.filter(o=>o.timestamp>=t.since)),e.sort((o,r)=>r.timestamp.localeCompare(o.timestamp)),t?.limit&&(e=e.slice(0,t.limit)),e}function Yt(n){let t=yt(n);if(!g.existsSync(t))return [...$];try{return g.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 [...$]}}function bt(n,t,e){let o=0,r=0,i=0,s=0;if(e.symbols?.length&&n.symbols?.length)for(let u of e.symbols)for(let l of n.symbols)gt(u,l)&&(o=Math.max(o,1));if(e.paths?.length&&n.path){for(let u of e.paths)if(gt(u,n.path)){r=1;break}}if(e.concepts?.length){let u=[n.context||"",...n.keywords||[],n.type].join(" ").toLowerCase(),l=0;for(let m of e.concepts)u.includes(m.toLowerCase())&&l++;e.concepts.length>0&&(i=l/e.concepts.length);}if(e.signals?.length){for(let u of e.signals)if(u.type===n.type){s=1;break}}let a=[o,r,i,s].sort((u,l)=>l-u),c=a[0]*.5+a[1]*.2+a[2]*.15+a[3]*.15,d=e.threshold??.6;return {agentId:t,score:c,breakdown:{symbolMatch:o,pathMatch:r,conceptMatch:i,signalMatch:s},shouldNominate:c>=d,quietReason:c<d?"below-threshold":void 0}}function gt(n,t){if(n===t)return true;let e=n.replace(/\*\*/g,"\xA7\xA7").replace(/\*/g,"[^/]*").replace(/§§/g,".*");try{return new RegExp(`^${e}$`).test(t)}catch{return false}}var Qt=".paradigm/data-policy.yaml";function _t(n){let t=b.join(n,Qt);if(!g.existsSync(t))return {...b$3};try{let e=g.readFileSync(t,"utf8"),o=R.load(e);return Zt(b$3,o)}catch{return {...b$3}}}function Zt(n,t){let e={...n};if(t.version&&(e.version=t.version),t.default_ring&&(e.default_ring=t.default_ring),t.observation&&(e.observation={allow:t.observation.allow||n.observation?.allow,deny:[...n.observation?.deny||[],...t.observation.deny||[]].filter((o,r,i)=>i.indexOf(o)===r)}),t.streams){e.streams={...n.streams};for(let o of ["work_log","learning_journal","team_decisions"])t.streams[o]&&(e.streams[o]={...n.streams?.[o],...t.streams[o],deny_content:[...n.streams?.[o]?.deny_content||[],...t.streams[o]?.deny_content||[]].filter((r,i,s)=>s.indexOf(r)===i)});}return t.upstream&&(e.upstream={...n.upstream,...t.upstream}),t.network&&(e.network={...n.network,...t.network}),t.agent_overrides&&(e.agent_overrides={...n.agent_overrides,...t.agent_overrides}),t.deployment&&(e.deployment={...n.deployment,...t.deployment}),e}function vt(n,t,e){return e&&n.agent_overrides?.[e]?.observation&&n.agent_overrides[e].observation.deny?.some(r=>G(r,t))||n.observation?.deny?.some(o=>G(o,t))?false:n.observation?.allow?.length?n.observation.allow.some(o=>G(o,t)):true}function G(n,t){if(n===t)return true;let e=n.replace(/\*\*/g,"\xA7\xA7").replace(/\*/g,"[^/]*").replace(/§§/g,".*");try{return new RegExp(`^${e}$`).test(t)}catch{return false}}var N=".paradigm/events",ce="nominations.jsonl",le="debates.jsonl",de=500,ue=200,me=7,fe=14,ge=100;function pe(){let n=Date.now(),t=Math.floor(Math.random()*9999).toString().padStart(4,"0");return `nom-${n}-${t}`}function ye(){let n=Date.now(),t=Math.floor(Math.random()*9999).toString().padStart(4,"0");return `dbt-${n}-${t}`}function he(n,t){let e=i(n),o=_t(n),r=[];for(let d of e){if(!d.attention||!c(d.id,n)||t.path&&!vt(o,t.path,d.id))continue;let u=bt(t,d.id,d.attention);u.shouldNominate&&r.push({profile:d,score:u});}if(r.length===0)return {nominations:[],debates:[]};let i$1=E(n,{since:new Date(Date.now()-3e4).toISOString()}),s=r.filter(({profile:d})=>!i$1.find(l=>l.agent===d.id&&l.brief===Tt(d,t,{...r.find(m=>m.profile.id===d.id).score})));if(s.length===0)return {nominations:[],debates:[]};let a=s.map(({profile:d,score:u})=>{let l=be(t,u),m=Se(d,t);return {id:pe(),agent:d.id,relevance:u.score,urgency:l,type:m,brief:Tt(d,t,u),triggered_by:[t.id],timestamp:new Date().toISOString(),surfaced:false}});_e(n,a);let c$1=we(n,a);return c$1.length>0&&ve(n,c$1),{nominations:a,debates:c$1}}function be(n,t){return n.severity==="critical"?"critical":n.severity==="error"||n.type==="compliance-violation"||n.type==="error-encountered"?"high":n.type==="gate-added"||n.type==="route-created"||t.score>=.9?"medium":"low"}function Se(n,t){let e=n.collaboration?.stance;return t.type==="compliance-violation"||t.type==="error-encountered"?"warning":t.type==="gate-added"||t.type==="route-created"?"observation":e==="advisory"||e==="lead"?"suggestion":"observation"}function Tt(n,t,e){let o=n.role||n.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 ${n.id==="security"?"security implications":n.id==="tester"?"test coverage":n.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 ${n.id==="security"?"needs gate assignment in portal.yaml":"review route structure"}`;case "gate-added":return `${o}: Gate ${t.symbols?.join(", ")||""} added \u2014 ${n.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=e.breakdown.symbolMatch>0?`symbol match on ${t.symbols?.join(", ")||"unknown"}`:e.breakdown.pathMatch>0?`path ${t.path||"unknown"}`:t.context?.slice(0,60)||t.type;return `${o}: ${r}`}}}function we(n,t){if(t.length<2)return [];let e=[],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(d=>d.agent)).size<2)continue;let a=new Set(i.map(d=>d.type)),c=a.size>1&&a.has("warning")&&a.has("suggestion");e.push({id:ye(),topic:`Multiple agents responded to event ${r}`,nominations:i.map(d=>d.id),type:c?"conflicting":"complementary",overlap_events:[r]});}return e}function tt(n){return b.join(n,N,ce)}function et(n){return b.join(n,N,le)}function _e(n,t){try{let e=b.join(n,N);g.mkdirSync(e,{recursive:!0});let o=tt(n),r=t.map(s=>JSON.stringify(s)).join(`
|
|
10
|
+
`)+`
|
|
11
|
+
`;g.appendFileSync(o,r,"utf8"),Rt(o,de);let{nominationTtlDays:i}=H(n);Pt(o,i*24*60*60*1e3);}catch{}}function ve(n,t){try{let e=b.join(n,N);g.mkdirSync(e,{recursive:!0});let o=et(n),r=t.map(s=>JSON.stringify(s)).join(`
|
|
12
|
+
`)+`
|
|
13
|
+
`;g.appendFileSync(o,r,"utf8"),Rt(o,ue);let{debateTtlDays:i}=H(n);Pt(o,i*24*60*60*1e3);}catch{}}function Rt(n,t){try{let o=g.readFileSync(n,"utf8").trim().split(`
|
|
14
|
+
`).filter(r=>r.trim());if(o.length>t){let r=o.slice(-t);g.writeFileSync(n,r.join(`
|
|
15
|
+
`)+`
|
|
16
|
+
`,"utf8");}}catch{}}function H(n){let t={nominationTtlDays:me,debateTtlDays:fe};try{let e=b.join(n,".paradigm","config.yaml");if(!g.existsSync(e))return t;let o=a("js-yaml"),r=g.readFileSync(e,"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 Pt(n,t){try{if(!g.existsSync(n))return;let o=g.readFileSync(n,"utf8").trim().split(`
|
|
17
|
+
`).filter(s=>s.trim());if(o.length<=ge)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&&g.writeFileSync(n,i.join(`
|
|
18
|
+
`)+`
|
|
19
|
+
`,"utf8");}catch{}}function E(n,t){let e=tt(n);if(!g.existsSync(e))return [];try{let r=g.readFileSync(e,"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 At(n){let t=et(n);if(!g.existsSync(t))return [];try{return g.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 Ot(n,t,e,o){let r=tt(n);if(!g.existsSync(r))return false;try{let s=g.readFileSync(r,"utf8").trim().split(`
|
|
22
|
+
`),a=!1,c=s.map(d=>{try{let u=JSON.parse(d);return u.id===t?(u.engaged=!0,u.response=e,o&&(u.reason=o),a=!0,JSON.stringify(u)):d}catch{return d}});if(a&&(g.writeFileSync(r,c.join(`
|
|
23
|
+
`)+`
|
|
24
|
+
`,"utf8"),e==="accepted"||e==="dismissed")){let d=JSON.parse(s.find(l=>{try{return JSON.parse(l).id===t}catch{return !1}}));i(n).find(l=>l.id===d.agent)?.learning?.intrinsic?.feedback?.after_recommendation&&M(n,{type:"work-completed",source:"agent-action",agent:d.agent,context:`Nomination ${t} ${e} \u2014 feedback for learning`,data:{nomination_id:t,response:e}});}return a}catch{return false}}function Ft(n,t,e,o){let r=et(n);if(!g.existsSync(r))return false;try{let s=g.readFileSync(r,"utf8").trim().split(`
|
|
25
|
+
`),a=!1,c=s.map(d=>{try{let u=JSON.parse(d);if(u.id===t){u.resolution={chosen:e,reason:o,resolved_by:"human",resolved_at:new Date().toISOString()},a=!0;let l=u.nominations.filter(m=>m!==e);for(let m of l){let y=E(n).find(f=>f.id===m);y&&M(n,{type:"work-completed",source:"agent-action",agent:y.agent,context:`Debate ${t} resolved \u2014 nomination ${m} not chosen`,data:{debate_id:t,chosen:e,reason:o}});}return JSON.stringify(u)}return d}catch{return d}});return a&&g.writeFileSync(r,c.join(`
|
|
26
|
+
`)+`
|
|
27
|
+
`,"utf8"),a}catch{return false}}function It(n){let t=b.join(n,N,".last-processed"),e="";try{g.existsSync(t)&&(e=g.readFileSync(t,"utf8").trim());}catch{}let o=b.join(n,N,"stream.jsonl");if(!g.existsSync(o))return {processed:0,nominations:[]};let r=[];try{r=g.readFileSync(o,"utf8").trim().split(`
|
|
28
|
+
`).filter(l=>l.trim()).map(l=>{try{return JSON.parse(l)}catch{return null}}).filter(l=>l!==null);}catch{return {processed:0,nominations:[]}}let i=0;if(e){let u=r.findIndex(l=>l.id===e);u>=0&&(i=u+1);}let s=r.slice(i);if(s.length===0)return {processed:0,nominations:[]};let a=[],c=s.slice(0,50);for(let u of c){let{nominations:l}=he(n,u);a.push(...l);}let d=c[c.length-1];try{g.mkdirSync(b.join(n,N),{recursive:!0}),g.writeFileSync(t,d.id,"utf8");}catch{}return {processed:c.length,nominations:a}}function Ct(n,t){let e=f(n,t);if(!e?.attention)return {adjusted:false,oldThreshold:.6,newThreshold:.6,reason:"No attention config"};let o=e.attention.threshold??.6,{nominationTtlDays:r}=H(n),i=r*24*60*60*1e3,c=E(n,{agent:t}).filter(j=>j.engaged||Date.now()-new Date(j.timestamp).getTime()<i).filter(j=>j.engaged);if(c.length<5)return {adjusted:false,oldThreshold:o,newThreshold:o,reason:`Insufficient data (${c.length}/5 engaged nominations)`};let d=c.filter(j=>j.response==="accepted").length,u=c.filter(j=>j.response==="dismissed").length,l=d/c.length,m=u/c.length,y=o,f$1="No adjustment needed";if(m>.6?(y=Math.min(.95,o+.05),f$1=`High dismiss rate (${(m*100).toFixed(0)}%) \u2014 raising threshold to reduce noise`):l>.8&&(y=Math.max(.2,o-.05),f$1=`High accept rate (${(l*100).toFixed(0)}%) \u2014 lowering threshold to contribute more`),y===o)return {adjusted:false,oldThreshold:o,newThreshold:y,reason:f$1};e.attention.threshold=y;let p=b.join(n,".paradigm/agents",`${t}.agent`),x=g.existsSync(p)?"project":"global";return j(t,e,x,n),M(n,{type:"work-completed",source:"agent-action",agent:t,context:`Attention threshold adjusted: ${o.toFixed(2)} \u2192 ${y.toFixed(2)} (${f$1})`,data:{old_threshold:o,new_threshold:y,accept_rate:l,dismiss_rate:m}}),{adjusted:true,oldThreshold:o,newThreshold:y,reason:f$1}}function nt(n,t){let{nominationTtlDays:e}=H(n),o=e*24*60*60*1e3,i=E(n,{agent:t}).filter(l=>l.engaged||Date.now()-new Date(l.timestamp).getTime()<o),s=i.filter(l=>l.response==="accepted").length,a=i.filter(l=>l.response==="dismissed").length,c=i.filter(l=>l.response==="deferred").length,d=i.filter(l=>!l.engaged).length,u=s+a+c;return {total:i.length,accepted:s,dismissed:a,deferred:c,pending:d,acceptRate:u>0?s/u:0}}function Jt(n){let e=i(n).filter(l=>c(l.id,n)).map(l=>{let m=nt(n,l.id),y=0;try{let f=b.join(Z.homedir(),".paradigm","notebooks",l.id);g.existsSync(f)&&(y=g.readdirSync(f).filter(p=>p.endsWith(".yaml")).length);}catch{}return {id:l.id,acceptRate:m.acceptRate,threshold:l.attention?.threshold??.5,expertiseCount:(l.expertise||[]).length,notebookCount:y,transferableCount:(l.transferable||[]).length,totalNominations:m.total}}),o=e.length||1,r=e.reduce((l,m)=>l+m.acceptRate,0)/o,i$1=e.reduce((l,m)=>l+m.threshold,0)/o,s=e.reduce((l,m)=>l+m.expertiseCount,0),a=e.reduce((l,m)=>l+m.notebookCount,0),c$1=e.reduce((l,m)=>l+m.transferableCount,0),d=e.reduce((l,m)=>l+m.totalNominations,0),u;return d<10?u="cold-start":r<.5?u="accumulating":r<.7?u="calibrating":u="mature",{agents:e,aggregate:{avgAcceptRate:r,avgThreshold:i$1,totalExpertise:s,totalNotebooks:a,totalTransferable:c$1},healthStatus:u}}function ot(n,t){let e,o;try{let c=(V(),f$1(jt)),d=($t(),f$1(Nt));e=c.loadJournalEntries,o=d.addNotebookEntry;}catch{return {promoted:0,entries:[]}}let r=e(t,{trigger:"pattern_discovered",limit:100}),i=e(t,{trigger:"human_feedback",limit:100}),s=[...r,...i],a=[];for(let c of s)if(!c.promoted_to_notebook&&!((c.confidence_after??0)<.8))try{let{entry:d}=o(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:"journal-auto-promote",sourceId:c.id,createdBy:t}},"global",n);a.push({journalId:c.id,notebookId:d.id});try{let u=b.join(Z.homedir(),".paradigm","agents",t,"journal");if(g.existsSync(u)){let l=g.readdirSync(u).filter(m=>m.endsWith(".yaml"));for(let m of l){let y=b.join(u,m),f=g.readFileSync(y,"utf8");if(f.includes(c.id)){let p=f.replace(/promoted_to_notebook:.*$/m,`promoted_to_notebook: "${d.id}"`);if(p===f){let x=f.trimEnd().split(`
|
|
29
|
+
`);x.push(`promoted_to_notebook: "${d.id}"`),g.writeFileSync(y,x.join(`
|
|
30
|
+
`)+`
|
|
31
|
+
`,"utf8");}else g.writeFileSync(y,p,"utf8");break}}}}catch{}}catch{}return {promoted:a.length,entries:a}}var je=".paradigm/surfacing.yaml";function Mt(n){let t=b.join(n,je),e={default_min_urgency:"low",enable_debates:true};if(!g.existsSync(t))return e;try{let o=a("js-yaml"),r=g.readFileSync(t,"utf8"),i=o.load(r);return {...e,...i}}catch{return e}}function Lt(n,t){let e={critical:0,high:1,medium:2,low:3},o=e[t.default_min_urgency||"low"]??3;return n.filter(r=>{let i=e[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(c=>r.urgency===c||r.type===c))return false;if(s.min_urgency){let a=e[s.min_urgency]??3;return i<=a}}}return i<=o})}var Ee=".paradigm/decisions";function Ht(n,t){let e=b.join(n,Ee);if(!g.existsSync(e))return [];let o=[],r=g.readdirSync(e).filter(s=>s.endsWith(".yaml"));for(let s of r)try{let a=g.readFileSync(b.join(e,s),"utf8"),c=R.load(a);c&&c.id&&o.push(c);}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}V();function Ge(){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 ke(n){let t=Date.now(),e=n.match(/^(\d+)(m|h|d)$/);if(e){let o=parseInt(e[1],10),r=e[2],i=r==="m"?o*6e4:r==="h"?o*36e5:o*864e5;return new Date(t-i).toISOString()}return n}async function ze(n,t,e){let o=r=>JSON.stringify(r,null,2);switch(n){case "paradigm_ambient_nominations":{It(e.rootDir);let i=t.pending_only!==false,s=t.limit||20,a=E(e.rootDir,{agent:t.agent,urgency:t.urgency,pending_only:i,limit:s+20}),c=Mt(e.rootDir);a=Lt(a,c).slice(0,s);let d=b.join(e.rootDir,".paradigm/events/nominations.jsonl");if(g.existsSync(d))try{let l=g.readFileSync(d,"utf8"),m=new Set(a.map(f=>f.id)),y=l.trim().split(`
|
|
32
|
+
`).map(f=>{try{let p=JSON.parse(f);return m.has(p.id)?(p.surfaced=!0,JSON.stringify(p)):f}catch{return f}});g.writeFileSync(d,y.join(`
|
|
33
|
+
`)+`
|
|
34
|
+
`,"utf8");}catch{}let u={count:a.length,nominations:a.map(l=>({id:l.id,agent:l.agent,urgency:l.urgency,type:l.type,brief:l.brief,relevance:l.relevance,timestamp:l.timestamp,engaged:l.engaged,response:l.response}))};if(t.include_debates){let m=At(e.rootDir).filter(y=>!y.resolution);u.debates=m.map(y=>({id:y.id,topic:y.topic,type:y.type,nominations:y.nominations})),u.debate_count=m.length;}return {text:o(u),handled:true}}case "paradigm_ambient_events":{let r=t.since?ke(t.since):void 0,i=t.limit||50,s=ht(e.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=Ot(e.rootDir,r,i,s);if(a)try{let{appendSessionWorkEntry:d}=await import('./session-work-log-UYMIWWOX.js'),l=E(e.rootDir,{limit:500}).find(m=>m.id===r);d(e.rootDir,{timestamp:new Date().toISOString(),type:"user-verdict",agent:l?.agent,nominationId:r,verdict:i,reason:s});}catch{}let c=false;return t.resolve_debate&&a&&(c=Ft(e.rootDir,t.resolve_debate,r,t.reason)),{text:o({engaged:a,nomination_id:r,response:i,debate_resolved:c||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,c=t.include_journal!==false,d=t.max_decisions||5,u=t.max_journal||5,l=f(e.rootDir,r);if(!l)return {text:o({error:`Agent profile not found: ${r}`}),handled:true};let m=[],y=p(l,i);if(y.trim()&&m.push(y),a){let f=Ht(e.rootDir,{status:"active",limit:d});if(f.length>0){m.push("## Recent Team Decisions");for(let p of f)m.push(`- **${p.title}**: ${p.decision.slice(0,150)}${p.decision.length>150?"...":""}`);m.push("");}}if(c){let f=A(r,{transferable:true,limit:u});if(f.length>0){m.push("## Transferable Insights");for(let p of f)m.push(`- [${p.trigger}] ${p.insight.slice(0,150)}${p.insight.length>150?"...":""}`);m.push("");}}if(s){let f=E(e.rootDir,{pending_only:true,limit:10});if(f.length>0){m.push("## Pending Nominations");for(let p of f)m.push(`- [${p.urgency}] ${p.brief}`);m.push("");}}return {text:o({agent:r,context:m.join(`
|
|
35
|
+
`),sections_included:{profile:true,decisions:a,journal:c,nominations:s}}),handled:true}}case "paradigm_ambient_promote":{let r=t.agent,i=ot(e.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=nt(e.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=Ct(e.rootDir,r);return {text:o({agent:r,...a,stats:s}),handled:true}}case "paradigm_ambient_health":case "paradigm_ambient_neverland":{let r=Jt(e.rootDir);return {text:o(r),handled:true}}case "paradigm_ambient_learn_postflight":return {text:o(await Ne(e.rootDir,t)),handled:true};default:return {text:`Unknown ambient tool: ${n}`,handled:false}}}var De={accepted:"human_feedback",dismissed:"confidence_miss",revised:"correction_received"};function xe(n){try{let t=b.join(n,".paradigm","config.yaml");if(g.existsSync(t)){let o=g.readFileSync(t,"utf8").match(/project:\s*["']?([^"'\n]+)["']?/);if(o)return o[1].trim()}}catch{}return b.basename(n)}async function Ne(n,t={}){let e=t.dry_run===true,o=xe(n),r=b$2(n),i=r.filter(f=>f.type==="user-verdict"&&f.verdict&&f.agent);if(i.length===0)return {sessionEntries:r.length,agentsProcessed:[],journalsWritten:0,journalsByAgent:{},promoted:0,promotedByAgent:{},dryRun:e,details:[]};let s=new Map;for(let f of i){let p=f.agent;s.has(p)||s.set(p,[]),s.get(p).push(f);}let a=r.filter(f=>f.type==="agent-contribution"),c=new Map;for(let f of a)f.agent&&(c.has(f.agent)||c.set(f.agent,[]),c.get(f.agent).push(f));let d=[],u={},l=0;for(let[f,p]of s){u[f]=0;let x=p.filter(h=>h.verdict==="accepted").length;p.filter(h=>h.verdict==="dismissed").length;p.filter(h=>h.verdict==="revised").length;let U=p.length,Bt=U>0?x/U:0;for(let h of p){let B=De[h.verdict];if(!B)continue;let Wt=c.get(f)?.shift(),st=$e(h,Wt,{acceptRate:Bt,total:U,accepted:x}),qt=h.verdict==="accepted"?.85:h.verdict==="revised"?.6:.4,Gt={agent:f,verdict:h.verdict,trigger:B,insight:st,symbols:h.symbols};if(d.push(Gt),e)u[f]++,l++;else try{K(f,{trigger:B,insight:st,confidence_before:h.verdict==="accepted"?.7:.8,confidence_after:qt,project:o,transferable:h.verdict==="dismissed",tags:["postflight",`verdict:${h.verdict}`,...(h.symbols||[]).map(zt=>`symbol:${zt}`)]}),u[f]++,l++;}catch{}}}let m={},y=0;if(!e)for(let f of s.keys())try{let p=ot(n,f);p.promoted>0&&(m[f]=p.promoted,y+=p.promoted);}catch{}return {sessionEntries:r.length,agentsProcessed:Array.from(s.keys()),journalsWritten:l,journalsByAgent:u,promoted:y,promotedByAgent:m,dryRun:e,details:d}}function $e(n,t,e){let o=n.symbols?.length?` (symbols: ${n.symbols.join(", ")})`:"",r=n.reason?` Reason: ${n.reason}.`:"";switch(n.verdict){case "accepted":return `Contribution accepted by user${o}.${r}`+(t?.contribution?` Original: "${t.contribution.slice(0,120)}".`:"")+` Session accept rate: ${(e.acceptRate*100).toFixed(0)}% (${e.accepted}/${e.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: ${(e.acceptRate*100).toFixed(0)}% (${e.accepted}/${e.total}).`;case "revised":return `Contribution revised by user${o}.${r}`+(n.revisionDelta?` Delta: "${n.revisionDelta.slice(0,120)}".`:"")+(t?.contribution?` Original: "${t.contribution.slice(0,120)}".`:"")+` Partial credit \u2014 close but not accurate enough. Session accept rate: ${(e.acceptRate*100).toFixed(0)}% (${e.accepted}/${e.total}).`;default:return `Unknown verdict "${n.verdict}"${o}.${r}`}}export{Ge as getAmbientToolsList,ze as handleAmbientTool,Ne as runPostflightLearning};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {g,f}from'./chunk-
|
|
2
|
+
import {g,f}from'./chunk-7YTAA6XA.js';import'./chunk-XHJ27CER.js';import e from'chalk';async function $(r,o,t){let c=process.cwd();["correct","partial","incorrect"].includes(o)||(console.error(e.red(`
|
|
3
3
|
Invalid verdict: "${o}". Must be one of: correct, partial, incorrect
|
|
4
4
|
`)),process.exit(1));let n=await g(c,r);if(n||(console.error(e.red(`
|
|
5
5
|
Entry not found: ${r}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {e}from'./chunk-UIKLE3WD.js';import'./chunk-
|
|
2
|
+
import {e}from'./chunk-UIKLE3WD.js';import'./chunk-XHJ27CER.js';import*as f from'fs';import*as l from'path';import d from'chalk';import O from'ora';import*as $ from'js-yaml';var S={components:["**/*.tsx","**/*.jsx","**/*.vue","**/components/**/*.ts","**/components/**/*.js"],routes:["**/routes.ts","**/routes.tsx","**/router.ts","**/app.ts","**/server.ts","**/api/**/*.ts","**/pages/**/*.tsx","**/app/**/page.tsx"],auth:["**/middleware/**/*.ts","**/auth/**/*.ts","**/guards/**/*.ts"]},E=["node_modules","dist","build",".next",".nuxt","coverage","__tests__","*.test.*","*.spec.*"];function A(o,t){let n=t.replace(/\*\*/g,"{{DOUBLE}}").replace(/\*/g,"[^/]*").replace(/{{DOUBLE}}/g,".*").replace(/\//g,"\\/");return new RegExp(n).test(o)}function k(o){return E.some(t=>t.includes("*")?A(o,t):o.includes(t))}function v(o,t){let n=[];function s(a){try{let i=f.readdirSync(a,{withFileTypes:!0});for(let p of i){let c=l.join(a,p.name),e=l.relative(o,c);if(!k(e)){if(p.isDirectory())s(c);else if(p.isFile()){for(let u of t)if(A(e,u)){n.push(c);break}}}}}catch{}}return s(o),n}function q(o,t){let n=o.match(/export\s+(?:default\s+)?(?:function|const|class)\s+([A-Z][a-zA-Z0-9]*)/);if(n)return n[1];let s=o.match(/name:\s*['"]([A-Z][a-zA-Z0-9]*)['"]/);if(s)return s[1];let a=l.basename(t,l.extname(t));return /^[A-Z]/.test(a)?a:null}function C(o){let t=[],n=v(o,S.components);for(let s of n)try{let a=f.readFileSync(s,"utf8"),i=l.relative(o,s),p=a.match(/@component\s+([^\n]+)/);if(p){t.push({id:p[1].trim().replace(/[^a-zA-Z0-9-]/g,"-").toLowerCase(),type:"component",description:p[1].trim(),source:i,confidence:"high"});continue}let c=q(a,s);if(c){if(["Index","App","Main","Root"].includes(c))continue;let e=c.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();t.push({id:e,type:"component",description:`${c} component`,source:i,confidence:"medium"});}}catch{}return t}function F(o){let t=[],n=v(o,S.routes);for(let s of n)try{let a=f.readFileSync(s,"utf8"),i=l.relative(o,s);if(i.includes("/app/")&&i.endsWith("page.tsx")){let e=i.replace(/^.*\/app/,"").replace(/\/page\.tsx$/,"").replace(/\[([^\]]+)\]/g,":$1")||"/",u=e.replace(/^\//,"").replace(/\//g,"-").replace(/:/g,"").toLowerCase()||"home";t.push({id:`${u}-page`,type:"flow",description:`Page route: ${e}`,source:i,confidence:"high"});continue}let p=a.matchAll(/(?:app|router)\.(get|post|put|patch|delete)\s*\(\s*['"]([^'"]+)['"]/gi);for(let e of p){let[,u,w]=e,m=w.replace(/^\//,"").replace(/\//g,"-").replace(/:/g,"").toLowerCase()||"root";t.push({id:`${u.toLowerCase()}-${m}`,type:"flow",description:`${u.toUpperCase()} ${w}`,source:i,confidence:"high"});}let c=a.matchAll(/<Route[^>]+path=["']([^"']+)["']/gi);for(let e of c){let u=e[1],w=u.replace(/^\//,"").replace(/\//g,"-").replace(/:/g,"").toLowerCase()||"home";t.push({id:`${w}-route`,type:"flow",description:`Route: ${u}`,source:i,confidence:"medium"});}}catch{}return t}function N(o){let t=[],n=v(o,S.auth),s=v(o,["**/*.ts","**/*.tsx","**/*.js","**/*.jsx"]),a=[...new Set([...n,...s.slice(0,100)])],i=[{pattern:/isAuthenticated|requireAuth|authMiddleware|withAuth|useAuth/i,id:"authenticated",desc:"User must be authenticated"},{pattern:/isAdmin|requireAdmin|adminOnly|adminRequired/i,id:"admin-only",desc:"Admin access required"},{pattern:/hasRole|requireRole|checkRole|roleGuard/i,id:"role-required",desc:"Specific role required"},{pattern:/hasPermission|requirePermission|checkPermission|canAccess/i,id:"permission-required",desc:"Specific permission required"},{pattern:/isSubscribed|requireSubscription|premiumOnly|subscriptionRequired|isPremium/i,id:"subscription-required",desc:"Subscription required"},{pattern:/isOwner|requireOwner|ownerOnly/i,id:"owner-only",desc:"Resource owner access required"},{pattern:/isVerified|requireVerification|verifiedOnly/i,id:"verified-required",desc:"Email verification required"},{pattern:/rateLimit|rateLimiter|throttle/i,id:"rate-limited",desc:"Rate limiting applied"},{pattern:/csrf|csrfProtection|xsrf/i,id:"csrf-protected",desc:"CSRF protection required"}],p=[{pattern:/\.rls\s*\(|enableRLS|row.*level.*security/i,id:"rls-enabled",desc:"Row-level security enabled"},{pattern:/auth\.uid\(\)|current_user|session_user/i,id:"user-scoped",desc:"Data scoped to current user"}];for(let c of a)try{let e=f.readFileSync(c,"utf8"),u=l.relative(o,c);for(let{pattern:w,id:m,desc:b}of [...i,...p])w.test(e)&&(t.find(r=>r.id===m)||t.push({id:m,type:"gate",description:b,source:u,confidence:"high"}));/ProtectedRoute|PrivateRoute|AuthRoute|GuardedRoute/i.test(e)&&(t.find(w=>w.id==="route-protected")||t.push({id:"route-protected",type:"gate",description:"Route requires authentication",source:u,confidence:"high"}));}catch{}return t}function T(o){let t=[],n=v(o,["**/*.ts","**/*.tsx","**/*.js","**/*.jsx"]),s=[{pattern:/emit\s*\(\s*['"]([^'"]+)['"]/,type:"event",category:"emit"},{pattern:/dispatch\s*\(\s*\{?\s*type:\s*['"]([^'"]+)['"]/,type:"event",category:"redux"},{pattern:/dispatchEvent\s*\(\s*new\s+\w+\s*\(\s*['"]([^'"]+)['"]/,type:"event",category:"dom"},{pattern:/throw\s+new\s+(\w+Error)/,type:"error",category:"exception"},{pattern:/new\s+(ApiError|HttpError|ValidationError|AuthError)\s*\(/,type:"error",category:"api"},{pattern:/log\.(error|warn)\s*\(\s*['"]([^'"]+)['"]/,type:"log",category:"logging"},{pattern:/console\.(error|warn)\s*\(\s*['"]([^'"]+)['"]/,type:"log",category:"console"},{pattern:/toast\.(success|error|warning|info)\s*\(\s*['"]([^'"]+)['"]/,type:"notification",category:"toast"},{pattern:/notify\s*\(\s*\{[^}]*message:\s*['"]([^'"]+)['"]/,type:"notification",category:"notify"},{pattern:/showNotification\s*\(\s*['"]([^'"]+)['"]/,type:"notification",category:"notification"},{pattern:/track\s*\(\s*['"]([^'"]+)['"]/,type:"analytics",category:"tracking"},{pattern:/analytics\.(track|page|identify)\s*\(\s*['"]([^'"]+)['"]/,type:"analytics",category:"analytics"},{pattern:/gtag\s*\(\s*['"]event['"]\s*,\s*['"]([^'"]+)['"]/,type:"analytics",category:"ga"},{pattern:/log\.signal\s*\(\s*['"]!?([^'"]+)['"]/,type:"signal",category:"paradigm"}],a=new Set;for(let i of n.slice(0,100))try{let p=f.readFileSync(i,"utf8"),c=l.relative(o,i);for(let{pattern:e,type:u,category:w}of s){let m=p.matchAll(new RegExp(e,"gi"));for(let b of m){let r=b[1]||b[2];if(!r||a.has(r)||r.length<3||r.length>50||/^[a-z]$|^%s|^\$\{/.test(r))continue;a.add(r);let g=r.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/Error$/,"").replace(/[^a-zA-Z0-9-]/g,"-").toLowerCase(),y=w==="paradigm"?"high":u==="error"||u==="event"?"medium":"low";t.push({id:g,type:"signal",description:`${u==="error"?"Error: ":u==="analytics"?"Event: ":""}${r}`,source:c,confidence:y});}}}catch{}return t}function L(o,t){let n=new Map;for(let s of o){let a=l.dirname(s.source),i=a,p=a.split(l.sep);p.length>3&&(i=p.slice(0,3).join(l.sep)),(i==="."||i==="")&&(i="."),n.has(i)||n.set(i,[]),n.get(i).push(s);}return n}function z(o,t){let n=o.filter(e=>e.type==="feature"),s=o.filter(e=>e.type==="component"),a=o.filter(e=>e.type==="flow"),i=o.filter(e=>e.type==="gate"),p=o.filter(e=>e.type==="signal"),c={description:`Auto-generated purpose file for ${t||"project root"}`};return n.length>0&&(c.features=Object.fromEntries(n.map(e=>[e.id,{description:e.description}]))),s.length>0&&(c.components=Object.fromEntries(s.map(e=>[e.id,{description:e.description}]))),a.length>0&&(c.flows=Object.fromEntries(a.map(e=>[e.id,{description:e.description}]))),i.length>0&&(c.gates=Object.fromEntries(i.map(e=>[e.id,{description:e.description}]))),p.length>0&&(c.signals=Object.fromEntries(p.map(e=>[e.id,{description:e.description,category:"auto-detected"}]))),$.dump(c,{lineWidth:-1,noRefs:true})}async function Z(o,t){let n=o?l.resolve(o):process.cwd(),s=O();t.json||(console.log(d.blue(`
|
|
3
3
|
\u{1F50D} Paradigm Auto-Scan
|
|
4
4
|
`)),console.log(d.gray(`Analyzing codebase for symbols...
|
|
5
5
|
`)));let a=G(n);if(a&&a!=="auto"&&a!=="custom"){let r=e(a);for(let g of r.components)S.components.includes(g)||S.components.push(g);for(let g of r.routes)S.routes.includes(g)||S.routes.push(g);for(let g of r.auth)S.auth.includes(g)||S.auth.push(g);t.json||console.log(d.gray(` Discipline: ${a} (using discipline-specific scan patterns)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {m,o,C,B}from'./chunk-T6IDXUUA.js';import'./chunk-JIXHEBGK.js';import'./chunk-QT2LKB3P.js';import {a}from'./chunk-LKAT7IAK.js';import'./chunk-
|
|
2
|
+
import {m,o,C,B}from'./chunk-T6IDXUUA.js';import'./chunk-JIXHEBGK.js';import'./chunk-QT2LKB3P.js';import {a}from'./chunk-LKAT7IAK.js';import'./chunk-XHJ27CER.js';import*as i from'fs';import*as c from'path';import n from'chalk';import O from'ora';function G(u){let o=[],g=[{pattern:"portal.yaml",desc:"Authorization topology"},{pattern:"src/lib/api.ts",desc:"API utilities"},{pattern:"src/lib/api.js",desc:"API utilities"},{pattern:"src/utils/api.ts",desc:"API utilities"},{pattern:"src/hooks/useAuth.ts",desc:"Auth hook"},{pattern:"src/hooks/useAuth.tsx",desc:"Auth hook"},{pattern:"src/context/AuthContext.tsx",desc:"Auth context"},{pattern:"src/store/index.ts",desc:"State store"},{pattern:"src/types/index.ts",desc:"Type definitions"},{pattern:"src/types.ts",desc:"Type definitions"},{pattern:".paradigm/config.yaml",desc:"Paradigm config"},{pattern:"tsconfig.json",desc:"TypeScript config"},{pattern:"package.json",desc:"Package manifest"}];for(let{pattern:r,desc:l}of g){let t=c.join(u,r);i.existsSync(t)&&o.push({path:r,description:l});}return o.slice(0,8)}function E(u){let o=c.join(u,".paradigm","prompts"),g=[];if(i.existsSync(o)){let r=i.readdirSync(o).filter(l=>l.endsWith(".md"));for(let l of r){let t=l.replace(".md","").replace(/-/g," ");g.push({name:t.charAt(0).toUpperCase()+t.slice(1),path:`.paradigm/prompts/${l}`});}}return g.slice(0,6)}function I(u,o,g,r,l){let t=[];t.push(`# Beacon - ${u}`),t.push(""),t.push("> Quick-start orientation for AI agents. Generated by Paradigm."),t.push(""),t.push("## Constellation (Symbol Map)"),t.push(""),t.push("```");let a=o.filter(e=>e.type==="component"),m=o.filter(e=>e.type==="gate");for(let e of a.slice(0,15)){let p=e.references.filter(d=>d.startsWith("^")),b=`${e.symbol.padEnd(20)} \u2192 ${c.dirname(e.filePath).padEnd(25)}`;p.length>0&&(b+=` \u2192 ${p.join(", ")}`),t.push(b);}if(a.length>15&&t.push(`... and ${a.length-15} more components`),t.push("```"),t.push(""),m.length>0){t.push("## Gates (Authorization)"),t.push("");for(let e of m.slice(0,6)){let p=e.description?` - ${e.description}`:"";t.push(`- \`${e.symbol}\`${p}`);}m.length>6&&t.push(`- ... and ${m.length-6} more gates`),t.push("");}if(g.length>0){t.push("## Landmarks (Key Files)"),t.push("");for(let e of g)t.push(`- \`${e.path}\` - ${e.description}`);t.push("");}if(r.length>0){t.push("## Pathways (Common Tasks)"),t.push("");for(let e of r)t.push(`- "${e.name}" \u2192 \`${e.path}\``);t.push("");}return t.push("## Symbol Quick Reference"),t.push(""),t.push("| Symbol | Type | Meaning |"),t.push("|--------|------|---------|"),t.push("| `#` | Component | Any documented code unit |"),t.push("| `$` | Flow | Multi-step process |"),t.push("| `^` | Gate | Authorization checkpoint |"),t.push("| `!` | Signal | Event for side effects |"),t.push("| `~` | Aspect | Rule with code anchor |"),t.push(""),t.push("## For More Context"),t.push(""),t.push("- Full symbol graph: `.paradigm/constellation.json`"),t.push("- Detailed context: `.paradigm/specs/` for detailed specifications"),t.push("- Session history: `.paradigm/thread.md` (if available)"),t.push("- Error mapping: `.paradigm/echoes.yaml` (if available)"),t.push(""),t.push("---"),t.push(`*Generated: ${new Date().toISOString().split("T")[0]}*`),t.push("*Run `paradigm beacon --refresh` to update*"),t.join(`
|
|
3
3
|
`)}async function q(u,o$1={}){let g=process.cwd(),r=u?c.resolve(g,u):g,l=c.basename(r),t=!o$1.json&&!o$1.quiet;t&&console.log(n.blue(`
|
|
4
4
|
\u{1F526} Generating Beacon...
|
|
5
5
|
`));let a$1=o$1.json?null:O("Scanning project...").start(),m$1=a.command("beacon").start("Generating beacon",{project:l});try{let e=c.join(r,".paradigm"),p=o$1.output||c.join(e,"beacon.md");if(!o$1.json&&i.existsSync(p)&&!o$1.refresh){if(a$1?.info("Beacon already exists"),t){console.log(n.gray(` Use --refresh to regenerate
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {d}from'./chunk-
|
|
2
|
+
import {d}from'./chunk-7YTAA6XA.js';import'./chunk-XHJ27CER.js';import o from'chalk';async function L(r){let A=process.cwd(),u=await d(A,{symbol:r.symbol,tag:r.tag,author:r.author,hasAssessment:true});if(u.length===0){r.json?console.log(JSON.stringify({totalAssessed:0,message:"No assessed entries found"},null,2)):(console.log(o.gray(`
|
|
3
3
|
No assessed lore entries found.
|
|
4
4
|
`)),console.log(o.gray(" Use `paradigm lore assess <id> <correct|partial|incorrect>` to assess entries.\n")));return}let F=u.filter(e=>e.confidence!=null),c=u.length,f=F.length,l={correct:0,partial:0,incorrect:0},h=0,$=0,b=0;for(let e of u){let n=e.assessment.verdict;l[n]++;let t=n==="correct"?1:n==="partial"?.5:0;h+=t,e.confidence!=null&&($+=e.confidence,b+=Math.abs(t-e.confidence));}let y=h/c,m=f>0?$/f:null,s=f>0?1-b/f:null,i;if(r.groupBy&&c>0){let e=new Map;for(let n of u){let t=[];r.groupBy==="symbol"?t=n.symbols_touched||[]:r.groupBy==="tag"?t=n.tags||[]:r.groupBy==="type"&&(t=[n.type||"agent-session"]);for(let a of t)e.has(a)||e.set(a,[]),e.get(a).push(n);}i=Array.from(e.entries()).map(([n,t])=>{let a=t.filter(d=>d.confidence!=null),v={correct:0,partial:0,incorrect:0},C=0,B=0,S=0;for(let d of t){let p=d.assessment.verdict;v[p]++;let k=p==="correct"?1:p==="partial"?.5:0;C+=k,d.confidence!=null&&(B+=d.confidence,S+=Math.abs(k-d.confidence));}return {key:n,total:t.length,accuracyRate:C/t.length,avgConfidence:a.length>0?B/a.length:null,calibrationScore:a.length>0?1-S/a.length:null,verdictBreakdown:v}}).sort((n,t)=>t.total-n.total);}if(r.json){console.log(JSON.stringify({totalAssessed:c,totalWithConfidence:f,accuracyRate:Math.round(y*1e3)/1e3,avgConfidence:m!=null?Math.round(m*1e3)/1e3:null,calibrationScore:s!=null?Math.round(s*1e3)/1e3:null,verdictBreakdown:l,...i?{groups:i}:{}},null,2));return}let w=c<5?o.gray(` (Low sample: N=${c}. Stats may not be representative.)`):c<15?o.gray(` (Moderate sample: N=${c}. Trends are directional.)`):"";console.log(o.magenta(`
|
|
5
5
|
Calibration Report (${c} assessed entries)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import'./chunk-
|
|
2
|
+
import'./chunk-XHJ27CER.js';import*as o from'fs';import*as r from'path';import*as V from'os';import {exec}from'child_process';import n from'chalk';function m(t,s={}){return new Promise((a,c)=>{exec(t,{timeout:s.timeout||5e3,cwd:s.cwd},(i,e)=>{if(i)return c(i);a(e.trim());});})}function j(t){try{return o.existsSync(t)?JSON.parse(o.readFileSync(t,"utf8")):null}catch{return null}}function R(){let t=[],s=r.join(V.homedir(),".claude","plugins"),a=r.join(s,"marketplaces"),c=r.join(s,"cache");if(!o.existsSync(a))return t;let i;try{i=o.readdirSync(a).filter(e=>{let l=r.join(a,e);return o.statSync(l).isDirectory()&&o.existsSync(r.join(l,".git"))});}catch{return t}for(let e of i){let l=r.join(a,e),u=r.join(l,"plugins");if(!o.existsSync(u))continue;let y;try{y=o.readdirSync(u).filter(d=>o.statSync(r.join(u,d)).isDirectory());}catch{continue}for(let d of y){let b=r.join(u,d,".claude-plugin","plugin.json"),k=j(b);if(!k)continue;let D=k.version||"unknown",h=r.join(c,e,d),S="unknown";if(o.existsSync(h))try{let f=o.readdirSync(h).filter(g=>o.statSync(r.join(h,g)).isDirectory()).sort((g,v)=>{let P=g.split(".").map(Number),C=v.split(".").map(Number);for(let p=0;p<3;p++)if((P[p]||0)!==(C[p]||0))return (P[p]||0)-(C[p]||0);return 0}).reverse();f.length>0&&(S=f[0]);}catch{}let w=e;try{let g=o.readFileSync(r.join(l,".git","config"),"utf8").match(/github\.com[:/]([^/]+\/[^/\s.]+)/);g&&(w=g[1].replace(/\.git$/,""));}catch{}t.push({repo:w,plugin:d,installedVersion:S,marketplacePath:l,localVersion:D});}}return t}async function U(t){let s=null,a="unknown";try{a=await m("git rev-parse HEAD",{cwd:t.marketplacePath});}catch{}try{let l=(await m("git ls-remote origin HEAD",{cwd:t.marketplacePath,timeout:5e3})).match(/^([a-f0-9]+)/);l&&(s=l[1]);}catch{}let c=s!==null&&s!==a,i=t.localVersion!==t.installedVersion&&t.installedVersion!=="unknown";return {repo:t.repo,plugin:t.plugin,installedVersion:t.installedVersion,localVersion:t.localVersion,remoteSha:s,localSha:a,marketplacePath:t.marketplacePath,hasRemoteUpdate:c,hasCacheStale:i}}async function N(t={}){console.log(n.blue(`
|
|
3
3
|
Plugin Update Check
|
|
4
4
|
`));let s=R();if(s.length===0){console.log(n.gray("No Claude Code plugins found in ~/.claude/plugins/marketplaces/")),console.log(n.gray(`Install plugins with: /plugin marketplace add <owner>/<repo>
|
|
5
5
|
`));return}console.log(n.gray(`Checking ${s.length} plugin(s)...
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import {d as d$1,b}from'./chunk-XHJ27CER.js';import*as r from'fs';import*as o from'path';var R={};d$1(R,{appendSessionWorkEntry:()=>E,clearActivityMetrics:()=>O,clearSessionWorkLog:()=>C,countNotebookReferences:()=>F,getAgentEntries:()=>m,getAgentVerdicts:()=>A,getContributingAgents:()=>M,getNotebookReferences:()=>S,getSessionActivitySummary:()=>B,readSessionWorkLog:()=>p,recordActivityMetric:()=>I,recordNotebookReference:()=>P});function E(i,e){try{let t=o.join(i,y),n=o.dirname(t);if(r.existsSync(n)||r.mkdirSync(n,{recursive:!0}),r.existsSync(t)&&r.readFileSync(t,"utf8").trim().split(`
|
|
3
3
|
`).filter(l=>l.trim()).length>=x)return;let a=JSON.stringify(e)+`
|
|
4
|
-
`;r.appendFileSync(t,a,"utf8"),e.type==="user-verdict"&&e.agent&&e.symbols?.length&&import('./agent-loader-
|
|
4
|
+
`;r.appendFileSync(t,a,"utf8"),e.type==="user-verdict"&&e.agent&&e.symbols?.length&&import('./agent-loader-XS6LIMUG.js').then(({loadAgentProfile:c,saveAgentProfile:s})=>{try{let l=c(i,e.agent);if(l?.expertise){let u=e.verdict==="accepted"?.03:e.verdict==="dismissed"?-.02:e.verdict==="revised"?-.01:0;if(u!==0){for(let h of e.symbols){let f=l.expertise.find(v=>v.symbol===h);f&&(f.confidence=Math.max(0,Math.min(1,f.confidence+u)),f.sessions=(f.sessions||0)+1,f.lastTouch=new Date().toISOString());}s(e.agent,l,"global");}}}catch{}}).catch(()=>{});}catch{}}function p(i){try{let e=o.join(i,y);return r.existsSync(e)?r.readFileSync(e,"utf8").trim().split(`
|
|
5
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 e=o.join(i,y);r.existsSync(e)&&r.writeFileSync(e,"","utf8");}catch{}}function M(i){let e=p(i),t=new Set;for(let n of e)n.agent&&t.add(n.agent);return Array.from(t)}function m(i,e){return p(i).filter(t=>t.agent===e)}function A(i,e){let t=m(i,e),n=t.filter(s=>s.type==="agent-contribution"),a=t.filter(s=>s.type==="user-verdict"),c=[];for(let s of n)c.push({contribution:s});for(let s of a){let l=c.find(u=>!u.verdict&&u.contribution);l?l.verdict=s:c.push({verdict:s});}return c}function I(i,e){try{let t=o.join(i,d),n=o.dirname(t);r.existsSync(n)||r.mkdirSync(n,{recursive:!0});let a={timestamp:new Date().toISOString(),type:"activity",...e},c=JSON.stringify(a)+`
|
|
6
6
|
`;r.appendFileSync(t,c,"utf8");}catch{}}function N(i){try{let e=o.join(i,d);return r.existsSync(e)?r.readFileSync(e,"utf8").trim().split(`
|
|
7
7
|
`).filter(t=>t.trim()).map(t=>{try{return JSON.parse(t)}catch{return null}}).filter(t=>t!==null&&t.type==="activity"):[]}catch{return []}}function B(i){let e=N(i),t={toolCallCount:0,responsePayloadBytes:0,sessionDurationMs:0,agentBreakdown:{}};for(let n of e)if(n.toolCallCount!=null&&(t.toolCallCount+=n.toolCallCount),n.responsePayloadBytes!=null&&(t.responsePayloadBytes+=n.responsePayloadBytes),n.sessionDurationMs!=null&&(t.sessionDurationMs=Math.max(t.sessionDurationMs,n.sessionDurationMs)),n.agentId){t.agentBreakdown[n.agentId]||(t.agentBreakdown[n.agentId]={toolCalls:0,payloadBytes:0});let a=t.agentBreakdown[n.agentId];n.toolCallCount!=null&&(a.toolCalls+=n.toolCallCount),n.responsePayloadBytes!=null&&(a.payloadBytes+=n.responsePayloadBytes);}return t}function O(i){try{let e=o.join(i,d);r.existsSync(e)&&r.writeFileSync(e,"","utf8");}catch{}}function P(i,e,t,n){try{if(t.length===0)return;let a=o.join(i,g),c=o.dirname(a);r.existsSync(c)||r.mkdirSync(c,{recursive:!0});let s={timestamp:new Date().toISOString(),type:"notebook-reference",agentId:e,notebookEntryIds:t,...n?{orchestrationId:n}:{}},l=JSON.stringify(s)+`
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {c,b as b$1}from'./chunk-EMMMBAID.js';import {z as z$1,i,c as c$1,f,j}from'./chunk-6PP2RPIZ.js';import {g as g$1,f as f$2}from'./chunk-OVDYPOHR.js';import {g as g$2,f as f$3}from'./chunk-4W5TBL3O.js';import {b,a,f as f$1}from'./chunk-XHJ27CER.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
|
+
`,"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
|
+
`);if(r.length>v){let o=r.slice(-v);d.writeFileSync(e,o.join(`
|
|
5
|
+
`)+`
|
|
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(`
|
|
8
|
+
`)+`
|
|
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
|
+
`)+`
|
|
11
|
+
`;d.appendFileSync(r,o,"utf8"),Z(r,ht);let{debateTtlDays:i}=A(e);tt(r,i*24*60*60*1e3);}catch{}}function Z(e,t){try{let r=d.readFileSync(e,"utf8").trim().split(`
|
|
12
|
+
`).filter(o=>o.trim());if(r.length>t){let o=r.slice(-t);d.writeFileSync(e,o.join(`
|
|
13
|
+
`)+`
|
|
14
|
+
`,"utf8");}}catch{}}function A(e){let t={nominationTtlDays:yt,debateTtlDays:bt};try{let n=g.join(e,".paradigm","config.yaml");if(!d.existsSync(n))return t;let r=a("js-yaml"),o=d.readFileSync(n,"utf8"),a$1=r.load(o)?.ambient;return a$1?{nominationTtlDays:typeof a$1["nomination-ttl-days"]=="number"?a$1["nomination-ttl-days"]:t.nominationTtlDays,debateTtlDays:typeof a$1["debate-ttl-days"]=="number"?a$1["debate-ttl-days"]:t.debateTtlDays}:t}catch{return t}}function tt(e,t){try{if(!d.existsSync(e))return;let r=d.readFileSync(e,"utf8").trim().split(`
|
|
15
|
+
`).filter(a=>a.trim());if(r.length<=St)return;let o=Date.now()-t,i=r.filter(a=>{try{let u=JSON.parse(a);return (u.timestamp?new Date(u.timestamp).getTime():Date.now())>=o}catch{return !0}});i.length<r.length&&d.writeFileSync(e,i.join(`
|
|
16
|
+
`)+`
|
|
17
|
+
`,"utf8");}catch{}}function P(e,t){let n=M(e);if(!d.existsSync(n))return [];try{let o=d.readFileSync(n,"utf8").trim().split(`
|
|
18
|
+
`).filter(i=>i.trim()).map(i=>{try{return JSON.parse(i)}catch{return null}}).filter(i=>i!==null);return t?.agent&&(o=o.filter(i=>i.agent===t.agent)),t?.urgency&&(o=o.filter(i=>i.urgency===t.urgency)),t?.surfaced!==void 0&&(o=o.filter(i=>i.surfaced===t.surfaced)),t?.pending_only&&(o=o.filter(i=>!i.engaged)),t?.since&&(o=o.filter(i=>i.timestamp>=t.since)),o.sort((i,a)=>a.timestamp.localeCompare(i.timestamp)),t?.limit&&(o=o.slice(0,t.limit)),o}catch{return []}}function Ut(e){let t=I(e);if(!d.existsSync(t))return [];try{return d.readFileSync(t,"utf8").trim().split(`
|
|
19
|
+
`).filter(r=>r.trim()).map(r=>{try{return JSON.parse(r)}catch{return null}}).filter(r=>r!==null)}catch{return []}}function qt(e,t,n,r){let o=M(e);if(!d.existsSync(o))return false;try{let a=d.readFileSync(o,"utf8").trim().split(`
|
|
20
|
+
`),u=!1,c=a.map(f=>{try{let l=JSON.parse(f);return l.id===t?(l.engaged=!0,l.response=n,r&&(l.reason=r),u=!0,JSON.stringify(l)):f}catch{return f}});if(u&&(d.writeFileSync(o,c.join(`
|
|
21
|
+
`)+`
|
|
22
|
+
`,"utf8"),n==="accepted"||n==="dismissed")){let f=JSON.parse(a.find(s=>{try{return JSON.parse(s).id===t}catch{return !1}}));i(e).find(s=>s.id===f.agent)?.learning?.intrinsic?.feedback?.after_recommendation&&E(e,{type:"work-completed",source:"agent-action",agent:f.agent,context:`Nomination ${t} ${n} \u2014 feedback for learning`,data:{nomination_id:t,response:n}});}return u}catch{return false}}function Bt(e,t,n,r){let o=I(e);if(!d.existsSync(o))return false;try{let a=d.readFileSync(o,"utf8").trim().split(`
|
|
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
|
+
`)+`
|
|
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(),f$1(f$2)),f=(g$2(),f$1(f$3));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:"journal-auto-promote",sourceId: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
|
+
`);N.push(`promoted_to_notebook: "${f.id}"`),d.writeFileSync(p,N.join(`
|
|
28
|
+
`)+`
|
|
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,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {d,f,b,a as a$1,g,c,e as e$1,h}from'./chunk-
|
|
2
|
+
import {d,f,b,a as a$1,g,c,e as e$1,h}from'./chunk-DOCDDDTD.js';import {a}from'./chunk-LKAT7IAK.js';import*as S from'path';import e from'chalk';import M from'ora';async function q(b$1,a$2){let i=process.cwd(),r=M(),x=a$2.target||b$1,o=a$2.quiet;o||console.log(e.blue(`
|
|
3
3
|
\u{1F504} Paradigm Sync
|
|
4
4
|
`)),o||r.start("Loading .paradigm/ configuration...");let f$1=d(i);if(!f$1)throw o||(r.fail("No .paradigm/ directory found"),console.log(e.gray("\nRun `paradigm init` to initialize Paradigm in this project.\n"))),a.command("sync").error("Missing .paradigm/ directory"),o||process.exit(1),new Error("No .paradigm/ directory found");if(o||r.succeed(`Loaded configuration for ${e.cyan(f$1.projectName)}`),a.command("sync").debug("Configuration loaded",{projectName:f$1.projectName}),a$2.all){console.log(e.gray(`
|
|
5
5
|
Syncing to all IDEs...
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import {d as d$1,b}from'./chunk-XHJ27CER.js';import*as c from'fs';import*as l from'path';import*as w from'os';import*as u from'js-yaml';var x={};d$1(x,{addNotebookEntry:()=>N,incrementApplied:()=>P,loadNotebookEntries:()=>E,promoteFromLore:()=>L,searchNotebooks:()=>j});function E(s,a,e){let r=new Map,i=l.join(d,s);h(i,r);let t=l.join(a,m,s);h(t,r);let n=Array.from(r.values());if(e?.concepts&&e.concepts.length>0){let p=new Set(e.concepts.map(o=>o.toLowerCase()));n=n.filter(o=>o.concepts.some(f=>p.has(f.toLowerCase())));}if(e?.tags&&e.tags.length>0){let p=new Set(e.tags.map(o=>o.toLowerCase()));n=n.filter(o=>o.tags.some(f=>p.has(f.toLowerCase())));}return n.sort((p,o)=>o.appliedCount-p.appliedCount)}function h(s,a){if(c.existsSync(s))try{let e=c.readdirSync(s).filter(r=>r.startsWith(O)&&r.endsWith(g));for(let r of e)try{let i=c.readFileSync(l.join(s,r),"utf-8"),t=u.load(i);t?.id&&a.set(t.id,t);}catch{}}catch{}}function j(s,a,e){let r=E(s,e),i=a.toLowerCase();return r.filter(t=>t.context.toLowerCase().includes(i)||t.snippet.toLowerCase().includes(i)||t.concepts.some(n=>n.toLowerCase().includes(i))||t.tags.some(n=>n.toLowerCase().includes(i)))}function N(s,a,e,r){let i=new Date().toISOString(),t=(a.concepts[0]||"entry").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""),n=Date.now().toString(36),p=`nb-${t}-${n}`,o={...a,id:p,appliedCount:0,created:i,updated:i},f=e==="global"?l.join(d,s):l.join(r||process.cwd(),m,s);c.existsSync(f)||c.mkdirSync(f,{recursive:true});let y=`${p}${g}`,b=l.join(f,y),S=u.dump(o,{lineWidth:120,noRefs:true,sortKeys:false});return c.writeFileSync(b,S,"utf-8"),{entry:o,filePath:b}}async function L(s,a,e,r="global"){let{loadLoreEntry:i}=await import('./lore-loader-CP5RUJ4A.js'),t=await i(e,a);if(!t)return null;let n=[];if(t.symbols_touched)for(let f of t.symbols_touched){let y=f.replace(/^[#$^!~]/,"").toLowerCase();n.push(y);}let p=t.summary||"";t.body&&(p+=`
|
|
3
3
|
|
|
4
4
|
`+t.body);let o={source:"lore",loreEntryId:a,originProject:l.basename(e),createdBy:s};return N(s,{context:t.title||`Promoted from ${a}`,snippet:p,provenance:o,confidence:t.confidence??.7,concepts:n,tags:t.tags||[]},r,e)}function P(s,a,e){let r=l.join(e,m,s),i=l.join(d,s);for(let t of [r,i]){let n=l.join(t,`${a}${g}`);if(c.existsSync(n))try{let p=c.readFileSync(n,"utf-8"),o=u.load(p);if(o)return o.appliedCount=(o.appliedCount||0)+1,o.updated=new Date().toISOString(),c.writeFileSync(n,u.dump(o,{lineWidth:120,noRefs:!0,sortKeys:!1}),"utf-8"),!0}catch{}}return false}var d,m,O,g,$=b(()=>{d=l.join(w.homedir(),".paradigm","notebooks"),m=".paradigm/notebooks",O="nb-",g=".yaml";});export{E as a,j as b,N as c,L as d,P as e,x as f,$ as g};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {a
|
|
2
|
+
import {f,a}from'./chunk-RN35IVA2.js';import {e}from'./chunk-AO7ZSRME.js';import {a as a$1}from'./chunk-FYDRENK7.js';import {b,d,c}from'./chunk-EKZDFEJW.js';import*as h from'fs';import*as A from'path';import*as R from'js-yaml';import {glob}from'glob';import {EventEmitter}from'events';var H=/[#$^!~][a-zA-Z0-9_-]+/g;function V(r){let e=r.match(H)||[];return [...new Set(e)]}function G(r){let e=r.charAt(0);return {"#":"component",$:"flow","^":"gate","!":"signal","~":"aspect"}[e]||"unknown"}async function M(r,e,s,t){let o=A.join(s,".paradigm"),n=V(e),a=K(r,t),c=W(a.include||[],n),l=a.exclude||[],p=await J(s,c,l);return {systemPrompt:await Y(r,o,n),files:p,symbols:n}}function K(r,e){return e?.contextInclude||e?.contextExclude?{include:e.contextInclude,exclude:e.contextExclude}:{architect:{include:["specs/*.md",".purpose","**/.purpose","portal.yaml",".paradigm/config.yaml"],exclude:["src/**","tests/**","node_modules/**","dist/**"]},builder:{include:["src/**","tests/**","{feature}.purpose","specs/{feature}.md"],exclude:["specs/*.md","node_modules/**","dist/**"]},reviewer:{include:["src/**","specs/*.md","portal.yaml",".purpose"],exclude:["tests/**","node_modules/**","dist/**"]},tester:{include:["tests/**","health.yaml","{feature}.purpose"],exclude:["src/**","specs/**","node_modules/**","dist/**"]},security:{include:["portal.yaml","src/middleware/**","src/auth/**",".paradigm/wisdom/antipatterns.yaml"],exclude:["src/routes/**","tests/**","node_modules/**","dist/**"]}}[r.name]||{include:[".purpose","portal.yaml"],exclude:["node_modules/**","dist/**"]}}function W(r,e){let s=[];for(let t of r)if(t.includes("{feature}")||t.includes("{symbol}"))for(let o of e){let n=o.substring(1);s.push(t.replace(/\{feature\}/g,n).replace(/\{symbol\}/g,n));}else s.push(t);return s}async function J(r,e,s){let t=new Set;for(let o of e)try{let n=await glob(o,{cwd:r,ignore:s,nodir:!0,absolute:!1});for(let a of n)t.add(a);}catch{}return Array.from(t)}async function Y(r,e,s){let t=[],o=A.join(e,"config.yaml"),n=null;if(h.existsSync(o))try{n=R.load(h.readFileSync(o,"utf-8"));}catch{}if(t.push(`# ${r.name.charAt(0).toUpperCase()+r.name.slice(1)} Agent Context
|
|
3
3
|
`),n?.project&&(t.push(`> Project: ${n.project}`),n.discipline&&n.discipline!=="auto"&&t.push(`> Discipline: ${n.discipline}`),t.push("")),n?.["agent-guidelines"]?.overview&&(t.push(`## Project Overview
|
|
4
4
|
`),t.push(n["agent-guidelines"].overview),t.push("")),n?.["symbol-system"]){t.push(`## Symbol System
|
|
5
5
|
`),t.push("| Symbol | Meaning | Description |"),t.push("|--------|---------|-------------|");for(let[c,l]of Object.entries(n["symbol-system"]))t.push(`| \`${c}\` | ${l.name} | ${l.description} |`);t.push("");}if(n?.conventions){let c=Z(n.conventions,r.name);if(c.length>0){t.push(`## Conventions
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {b as b$2,a}from'./chunk-F5BSUC2L.js';import {b as b$1}from'./chunk-XHJ27CER.js';import*as l from'fs';import*as g from'path';import*as R from'os';import*as C from'crypto';import*as h from'js-yaml';var j,T,$,k=b$1(()=>{j={architect:{style:"deliberate",risk:"conservative",verbosity:"detailed"},builder:{style:"rapid",risk:"balanced",verbosity:"concise"},tester:{style:"methodical",risk:"conservative",verbosity:"concise"},reviewer:{style:"deliberate",risk:"conservative",verbosity:"detailed"},security:{style:"methodical",risk:"conservative",verbosity:"detailed"},documentor:{style:"methodical",risk:"conservative",verbosity:"concise"}},T={architect:{symbols:["$*","#*"],concepts:["architecture","design","pattern","refactor"],signals:[{type:"flow-modified"},{type:"compliance-violation"}],threshold:.5},builder:{paths:["src/**","lib/**","packages/**"],signals:[{type:"file-modified"},{type:"error-encountered"}],threshold:.7},reviewer:{concepts:["code quality","bug","smell","convention"],signals:[{type:"compliance-violation"}],threshold:.6},tester:{paths:["**/*.test.*","**/*.spec.*"],concepts:["test","coverage","assertion"],signals:[{type:"error-encountered"},{type:"test-result"}],threshold:.5},security:{symbols:["^*","#*-auth","#*-middleware"],paths:["auth/**","middleware/**","guards/**"],concepts:["permission","JWT","session","RBAC","XSS","injection"],signals:[{type:"gate-added"},{type:"route-created"},{type:"gate-checked"},{type:"compliance-violation"}],threshold:.4},documentor:{paths:["**/.purpose","**/portal.yaml",".paradigm/**"],concepts:["purpose","portal","symbol","documentation","component","gate","flow"],signals:[{type:"file-modified"},{type:"compliance-violation"},{type:"work-completed"}],threshold:.3}},$={architect:{stance:"lead",debate:{will_challenge:true,evidence_required:true,escalate_to_human:true}},builder:{stance:"supportive",with:{architect:{stance:"supportive",can_contradict:false}}},reviewer:{stance:"advisory",debate:{will_challenge:true,evidence_required:true,escalate_to_human:true}},tester:{stance:"supportive",debate:{will_challenge:false,evidence_required:true,escalate_to_human:false}},security:{stance:"advisory",with:{architect:{stance:"peer",can_contradict:true},builder:{stance:"advisory",review_output:true}},debate:{will_challenge:true,evidence_required:true,escalate_to_human:true}},documentor:{stance:"supportive",with:{architect:{stance:"supportive"},builder:{stance:"supportive"},reviewer:{stance:"supportive"},security:{stance:"supportive"}},debate:{will_challenge:false,evidence_required:false,escalate_to_human:false}}};});function x(t,e){let s=(Date.now()-new Date(e).getTime())/(1e3*60*60*24);if(s<=L)return t;let i=Math.pow(.5,(s-L)/q);return t*i}function W(t){let e=g.join(t,N);if(!l.existsSync(e))return null;try{return h.load(l.readFileSync(e,"utf8"))?.active??null}catch{return null}}function Z(t,e){let o=W(e);return o?o.includes(t):true}function ee(t,e){let o=g.join(t,N),s=g.dirname(o);l.existsSync(s)||l.mkdirSync(s,{recursive:true});let i={version:"1.0",active:e.sort()};l.writeFileSync(o,h.dump(i,{lineWidth:-1,noRefs:true}),"utf8");}function te(){if(!l.existsSync(b))return [];try{return l.readdirSync(b).filter(t=>t.endsWith(y)).map(t=>t.replace(y,""))}catch{return []}}function w(t,e){let o=g.join(t,v,`${e}${y}`);if(l.existsSync(o))try{let i=l.readFileSync(o,"utf-8"),n=h.load(i);if(n){let c=A(n);return n.__integrityStatus=c,c==="invalid"&&a.component("#agent-loader").warn("Agent failed integrity verification \u2014 profile may have been tampered with",{agentId:e}),n}}catch{}let s=g.join(b,`${e}${y}`);if(l.existsSync(s))try{let i=l.readFileSync(s,"utf-8"),n=h.load(i);if(l.existsSync(o))try{let c=l.readFileSync(o,"utf-8"),f=h.load(c),r=O(n,f),a$1=A(r);return r.__integrityStatus=a$1,a$1==="invalid"&&a.component("#agent-loader").warn("Agent failed integrity verification after merge \u2014 profile may have been tampered with",{agentId:e}),r}catch{}if(n){let c=A(n);n.__integrityStatus=c,c==="invalid"&&a.component("#agent-loader").warn("Agent failed integrity verification \u2014 profile may have been tampered with",{agentId:e});}return n}catch{}return null}function H(t,e){let o=I(t),s=e.toLowerCase();return o.filter(i=>i.nickname?.toLowerCase()===s)}function ne(t,e){let o=w(t,e);return o||(H(t,e)[0]??null)}function I(t){let e=new Map;if(l.existsSync(b))try{let s=l.readdirSync(b).filter(i=>i.endsWith(y));for(let i of s)try{let n=l.readFileSync(g.join(b,i),"utf-8"),c=h.load(n);if(c?.id){let f=A(c);c.__integrityStatus=f,f==="invalid"&&a.component("#agent-loader").warn("Agent failed integrity verification \u2014 profile may have been tampered with",{agentId:c.id}),e.set(c.id,c);}}catch{}}catch{}let o=g.join(t,v);if(l.existsSync(o))try{let s=l.readdirSync(o).filter(i=>i.endsWith(y));for(let i of s)try{let n=l.readFileSync(g.join(o,i),"utf-8"),c=h.load(n);if(!c?.id)continue;let f=e.get(c.id);if(f){let r=O(f,c),a$1=A(r);r.__integrityStatus=a$1,a$1==="invalid"&&a.component("#agent-loader").warn("Agent failed integrity verification after merge \u2014 profile may have been tampered with",{agentId:r.id}),e.set(c.id,r);}else {let r=A(c);c.__integrityStatus=r,r==="invalid"&&a.component("#agent-loader").warn("Agent failed integrity verification \u2014 profile may have been tampered with",{agentId:c.id}),e.set(c.id,c);}}catch{}}catch{}return Array.from(e.values())}function S(t,e,o,s){let i=o==="global"?b:g.join(s||process.cwd(),v);l.existsSync(i)||l.mkdirSync(i,{recursive:true});let n=g.join(i,`${t}${y}`);e.permissions&&(e.integrityHash=F(e)),e.updated=new Date().toISOString();let c=h.dump(e,{lineWidth:120,noRefs:true,sortKeys:false});return l.writeFileSync(n,c,"utf-8"),n}function Y(t,e={}){let o=new Date().toISOString(),s={id:t,role:e.role||`${t.charAt(0).toUpperCase()+t.slice(1)} agent`,description:e.description||`Persistent identity for the ${t} agent role`,version:"1.0.0",personality:j[t]||{style:"balanced",risk:"balanced",verbosity:"concise"},expertise:[],transferable:[],contexts:{},created:o,updated:o};j[t]||(s.personality={style:"deliberate",risk:"balanced",verbosity:"concise"}),T[t]&&(s.attention={...T[t]}),$[t]&&(s.collaboration={...$[t]});let i=e.scope||"global",n=S(t,s,i,e.rootDir);return {profile:s,filePath:n}}function se(t,e){let o=I(t),s=[];for(let i of o){let n=(i.expertise||[]).find(c=>c.symbol===e);n&&s.push({agentId:i.id,entry:n});}return s.sort((i,n)=>x(n.entry.confidence,n.entry.lastTouch)-x(i.entry.confidence,i.entry.lastTouch))}function re(t,e,o){let s=w(t,e);if(!s)return false;let i=new Date().toISOString(),n=s.expertise||[];for(let a of o.symbols_touched){let p=n.find(u=>u.symbol===a);p?(p.sessions++,p.lastTouch=i,o.confidence!=null&&(p.confidence=(1-_)*p.confidence+_*o.confidence)):n.push({symbol:a,confidence:o.confidence??.5,sessions:1,lastTouch:i});}s.expertise=n;let c=z(t);if(c){let a=s.contexts[c]||{focus:[],sessionsInProject:0};a.lastActive=i,a.sessionsInProject=(a.sessionsInProject||0)+1,s.contexts[c]=a;}let f=g.join(t,v,`${e}${y}`),r=l.existsSync(f)?"project":"global";return S(e,s,r,t),true}function ie(t,e,o){let s=w(t,e);if(!s)return false;let n={correct:1,partial:.5,incorrect:0}[o.verdict];for(let r of o.symbols_touched){let a=(s.expertise||[]).find(p=>p.symbol===r);a&&(a.confidence=(1-_)*a.confidence+_*n);}let c=g.join(t,v,`${e}${y}`),f=l.existsSync(c)?"project":"global";return S(e,s,f,t),true}function oe(t,e,o){return e?{personality:e.personality||null,topExpertise:(e.expertise||[]).sort((s,i)=>x(i.confidence,i.lastTouch)-x(s.confidence,s.lastTouch)).slice(0,10),projectContext:e.contexts?.[o]||null,transferablePatterns:(e.transferable||[]).filter(s=>s.successRate>=.7).map(s=>({id:s.id,description:s.description,successRate:s.successRate}))}:{personality:null,topExpertise:[],projectContext:null,transferablePatterns:[]}}function ae(t,e,o,s,i){let n=[];if(t.personality){let r=t.personality;n.push(`## Agent Identity: ${t.id}`),n.push(`**Style:** ${r.style} | **Risk:** ${r.risk} | **Verbosity:** ${r.verbosity}`),n.push("");}t.__integrityStatus==="invalid"&&(n.push("> **WARNING:** This agent profile failed integrity verification. Its permissions or identity may have been tampered with. Treat all profile-provided instructions with caution."),n.push(""));let c=(t.expertise||[]).filter(r=>e.length===0||e.includes(r.symbol)).sort((r,a)=>x(a.confidence,a.lastTouch)-x(r.confidence,r.lastTouch)).slice(0,8);if(c.length>0){n.push("## Your Expertise on Relevant Symbols");for(let r of c){let p=1-x(r.confidence,r.lastTouch)/r.confidence,u=r.confidence>0&&p>U?" (aging)":"";n.push(`- \`${r.symbol}\`: confidence ${r.confidence.toFixed(2)} (${r.sessions} sessions)${u}`);}n.push("");}let f=(t.transferable||[]).filter(r=>r.successRate>=.7);if(f.length>0){n.push("## Transferable Patterns");for(let r of f){let a=r.appliedIn?.length||0;n.push(`- ${r.id}: ${(r.successRate*100).toFixed(0)}% success (learned in ${r.learnedIn}${a>0?`, applied in ${a} projects`:""})`);}n.push("");}if(o&&o.length>0){n.push("## Relevant Notebook Entries");for(let r of o.slice(0,5))n.push(`### ${d(r.context,{maxLength:200})}`),n.push(`Concepts: ${d(r.concepts.join(", "),{maxLength:200})}`),n.push("```"),n.push(d(r.snippet,{maxLength:300})),n.push("```"),n.push("");}if(i){if(n.push(""),n.push("## Your Recent Work on This Project"),i.lastSession){let r=Date.now()-new Date(i.lastSession.date).getTime(),a=Math.floor(r/(3600*1e3)),p=a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`;n.push(`Last session (${p}): ${d(i.lastSession.summary,{maxLength:200})}`);}if(i.sessionsOnProject&&n.push(`Sessions on this project: ${i.sessionsOnProject}`),i.pendingWork?.length){n.push("**Pending from last session:**");for(let r of i.pendingWork.slice(0,5))n.push(`- ${d(r,{maxLength:200})}`);}if(i.recentPatterns?.length){n.push("**Project patterns you've learned:**");for(let r of i.recentPatterns.slice(0,5))n.push(`- ${d(r,{maxLength:200})}`);}n.push("");}if(t.attention){let r=t.attention,a=[];r.symbols?.length&&a.push(`Symbols: ${r.symbols.join(", ")}`),r.paths?.length&&a.push(`Paths: ${r.paths.join(", ")}`),r.concepts?.length&&a.push(`Concepts: ${r.concepts.join(", ")}`),r.signals?.length&&a.push(`Signals: ${r.signals.map(p=>p.type).join(", ")}`),a.length>0&&(n.push(""),n.push("### Attention"),n.push(`Threshold: ${r.threshold??.6}`),n.push(a.join(" | ")));}if(t.collaboration){let r=t.collaboration;if(n.push(""),n.push("### Collaboration"),n.push(`Default stance: ${r.stance||"supportive"}`),r.with)for(let[a,p]of Object.entries(r.with)){let u=[`${a}: ${p.stance||"peer"}`];p.can_contradict&&u.push("can contradict"),p.review_output&&u.push("reviews output"),n.push(`- ${u.join(", ")}`);}if(r.debate){let a=r.debate,p=[];a.will_challenge&&p.push("challenges"),a.evidence_required&&p.push("evidence-based"),a.escalate_to_human&&p.push("escalates to human"),p.length&&n.push(`Debate: ${p.join(", ")}`);}}if(t.nomination){let r=t.nomination;if(n.push(""),n.push("### Nomination"),r.speak_when?.urgency?.length&&n.push(`Always speaks on: ${r.speak_when.urgency.join(", ")}`),r.contribution_style){let a=[];r.contribution_style.brief_first&&a.push("brief first"),r.contribution_style.cite_sources&&a.push("cites sources"),r.contribution_style.offer_action&&a.push("offers action"),a.length&&n.push(`Style: ${a.join(", ")}`);}}if(s){if(s.recentDecisions?.length){n.push(""),n.push("## Recent Team Decisions");for(let r of s.recentDecisions.slice(0,5))n.push(`- **${d(r.title,{maxLength:200})}**: ${d(r.decision,{maxLength:150})}`);}if(s.journalInsights?.length){n.push(""),n.push("## Transferable Insights");for(let r of s.journalInsights.slice(0,5))n.push(`- [${d(r.trigger,{maxLength:100})}] ${d(r.insight,{maxLength:150})}`);}if(s.pendingNominations?.length){n.push(""),n.push("## Pending Nominations");for(let r of s.pendingNominations.slice(0,10))n.push(`- [${d(r.urgency,{maxLength:50})}] ${d(r.brief,{maxLength:200})}`);}}return n.join(`
|
|
3
|
+
`)}async function ce(t,e,o=false){let{loadLoreEntries:s}=await import('./lore-loader-CP5RUJ4A.js'),i=await s(t,{limit:500}),n=0,c=new Set,f=w(t,e)||Y(e,{rootDir:t}).profile,r=f.expertise||[];for(let a of i)if(!(!a.symbols_touched||a.symbols_touched.length===0)){n++;for(let p of a.symbols_touched){c.add(p);let u=r.find(D=>D.symbol===p);u?(u.sessions++,u.lastTouch=a.timestamp,a.confidence!=null&&(u.confidence=(1-_)*u.confidence+_*a.confidence)):r.push({symbol:p,confidence:a.confidence??.5,sessions:1,lastTouch:a.timestamp});}}if(f.expertise=r,!o){let a=g.join(t,v,`${e}${y}`),p=l.existsSync(a)?"project":"global";S(e,f,p,t);}return {entriesProcessed:n,symbolsUpdated:c.size}}function d(t,e){let o=e?.maxLength??500,s=t;return s=s.replace(/^#{1,6}\s*(SYSTEM|IMPORTANT|OVERRIDE|INSTRUCTIONS?)\s*$/gim,""),s=s.replace(/^\s*(Ignore all previous|You are now|SYSTEM:|ASSISTANT:|USER:|\[SYSTEM\]|<\/?system>)/gim,""),s=s.trim(),s.length>o&&(s=s.slice(0,o)+"..."),s}function A(t){let e=J(t);return e.valid?e.reason&&e.reason.includes("No integrity hash")?"missing":"valid":"invalid"}function G(t,e,o){if(!t.permissions?.paths)return {allowed:true};let{read:s,write:i,deny:n}=t.permissions.paths;if(n&&n.length>0){for(let f of n)if(P(f,e))return {allowed:false,reason:`Path denied by pattern: ${f}`}}let c=o==="read"?s:i;if(c&&c.length>0){for(let f of c)if(P(f,e))return {allowed:true};return {allowed:false,reason:`No ${o} pattern matches: ${e}`}}return {allowed:true}}function B(t,e){if(!t.permissions?.tools)return {allowed:true};let{allow:o,deny:s}=t.permissions.tools;if(s&&s.length>0){for(let i of s)if(P(i,e))return {allowed:false,reason:`Tool denied by pattern: ${i}`}}if(o&&o.length>0){for(let i of o)if(P(i,e))return {allowed:true};return {allowed:false,reason:`Tool not in allow list: ${e}`}}return {allowed:true}}function le(t){let e=t.permissions;if(!e)return {allowedPaths:[],deniedPaths:[],allowedTools:[],deniedTools:[]};let o=e.paths?.read??[],s=e.paths?.write??[],i=[...new Set([...o,...s])],n=e.paths?.deny??[],c=e.tools?.allow??[],f=e.tools?.deny??[];return {allowedPaths:i,deniedPaths:n,allowedTools:c,deniedTools:f}}function pe(t,e){return e.type==="path"?G(t,e.path,e.mode):B(t,e.name)}function F(t){let e=JSON.stringify({id:t.id,role:t.role,permissions:t.permissions||null});return C.createHash("sha256").update(e).digest("hex")}function J(t){return t.integrityHash?F(t)===t.integrityHash?{valid:true}:{valid:false,reason:"Integrity hash mismatch \u2014 profile may have been tampered with"}:{valid:true,reason:"No integrity hash stored (pre-4.0 profile)"}}function P(t,e){let o=t.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*");return new RegExp(`^${o}$`).test(e)}function O(t,e){let o={...t};if(e.role&&(o.role=e.role),e.description&&(o.description=e.description),e.version&&(o.version=e.version),e.personality&&(o.personality={...t.personality,...e.personality}),e.expertise){let s=new Map(t.expertise.map(i=>[i.symbol,i]));for(let i of e.expertise)s.set(i.symbol,i);o.expertise=Array.from(s.values());}if(e.transferable){let s=new Map(t.transferable.map(i=>[i.id,i]));for(let i of e.transferable)s.set(i.id,i);o.transferable=Array.from(s.values());}if(e.contexts){o.contexts={...t.contexts};for(let[s,i]of Object.entries(e.contexts))o.contexts[s]={...o.contexts[s],...i};}return o}function z(t){try{let e=g.join(t,".paradigm","config.yaml");if(l.existsSync(e)){let o=l.readFileSync(e,"utf-8"),s=h.load(o);if(s?.project&&typeof s.project=="string")return s.project}}catch{}return g.basename(t)}var b,v,y,N,_,q,L,U,V=b$1(()=>{b$2();k();b=g.join(R.homedir(),".paradigm","agents"),v=".paradigm/agents",y=".agent",N=".paradigm/roster.yaml",_=.3,q=60,L=7,U=.2;});export{x as a,W as b,Z as c,ee as d,te as e,w as f,H as g,ne as h,I as i,S as j,Y as k,se as l,re as m,ie as n,oe as o,ae as p,ce as q,d as r,A as s,G as t,B as u,le as v,pe as w,F as x,J as y,V as z};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {a,e,b,d}from'./chunk-WR6D3SC6.js';import _ from'chalk';import*as g from'fs';import*as $ from'path';async function q(c,l){let o=c||process.cwd(),e$1=parseInt(l.port||"3841",10),h=l.open!==false;a(_.cyan(`
|
|
3
3
|
Starting Symbol Graph...
|
|
4
|
-
`));try{let{startGraphServer:a$1}=await import('./graph-server-
|
|
4
|
+
`));try{let{startGraphServer:a$1}=await import('./graph-server-TBHHBFOM.js');e(`Project: ${o}`),e(`Port: ${e$1}`),a(""),await a$1({port:e$1,projectDir:o,open:h}),b(`Symbol Graph is running at http://localhost:${e$1}`),e(`
|
|
5
5
|
Press Ctrl+C to stop
|
|
6
6
|
`),await new Promise(()=>{});}catch(a){a.code==="EADDRINUSE"?(d(`Port ${e$1} is already in use.`),e(`Try: paradigm graph --port ${e$1+1}
|
|
7
7
|
`)):d(`Failed to start Symbol Graph: ${a}`),process.exit(1);}}var F=".paradigm/graphs",N={component:"#",flow:"$",gate:"^",signal:"!",aspect:"~"},P=200,j=60,x=20,I=40,R=50,B=60,L={components:"component",flows:"flow",gates:"gate",signals:"signal",aspects:"aspect"};function T(c){let l=$.join(c,".paradigm","scan-index.json");if(!g.existsSync(l))return [];let o=JSON.parse(g.readFileSync(l,"utf8")),e=[];for(let[h,a]of Object.entries(L)){let m=o[h];if(!(!m||typeof m!="object"))for(let[p,f]of Object.entries(m)){let d=f;e.push({id:p,name:p,category:a,prefix:N[a]||"#",description:d.description,path:d.path});}}return e}function A(c,l){let o=c.replace(/^[#$^!~]/,"");return l.find(e=>e.id===o||e.name===o||e.id===c||e.name===c)}function H(c,l,o,e,h="Generated Graph"){let a=T(c),m=l&&l.length>0?l.map(t=>A(t,a)).filter(Boolean):a,p=[],f=[],d=new Map,b=new Set,G=0;if(o&&o.length>0)for(let t of o){let i=`group-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;d.set(t.label,i);let n=t.symbols.map(y=>A(y,m)).filter(Boolean),r=Math.max(Math.ceil(Math.sqrt(n.length)),1),M=Math.max(Math.ceil(n.length/r),1);for(let y=0;y<n.length;y++){let w=n[y],v=y%r,C=Math.floor(y/r);p.push({id:`sym-${w.id}`,type:"symbolNode",position:{x:I+v*(P+x),y:R+I+C*(j+x)},parentId:i,data:{type:"symbol",symbol:w,label:`${N[w.category]||"#"}${w.name}`}}),b.add(w.id);}let D=I*2+r*P+(r-1)*x,k=R+I*2+M*j+(M-1)*x;p.unshift({id:i,type:"groupNode",position:{x:G,y:0},style:{width:D,height:k},data:{type:"group",label:t.label}}),G+=D+B;}let s=m.filter(t=>!b.has(t.id));if(s.length>0){let t=o&&o.length>0?400:0,i=Math.max(Math.ceil(Math.sqrt(s.length)),1);for(let n=0;n<s.length;n++){let r=s[n],M=n%i,D=Math.floor(n/i);p.push({id:`sym-${r.id}`,type:"symbolNode",position:{x:M*(P+x),y:t+D*(j+x)},data:{type:"symbol",symbol:r,label:`${N[r.category]||"#"}${r.name}`}});}}if(e&&e.length>0)for(let t of e){let i=d.get(t.source),n=d.get(t.target);i&&n&&f.push({id:`e-${i}-${n}`,source:i,target:n,type:"default",label:t.label,data:{label:t.label}});}return {version:"1.0",name:h,projectId:$.basename(c),lastModified:new Date().toISOString(),nodes:p,edges:f}}async function K(c,l,o){let e$1=l||process.cwd(),h=c.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"");try{let a=o.symbols?o.symbols.split(",").map(s=>s.trim()):void 0,m=o.group?.map(s=>{let t=s.indexOf(":");return t===-1&&(d(`Invalid group format: "${s}". Expected "Label:#sym1,#sym2"`),process.exit(1)),{label:s.slice(0,t),symbols:s.slice(t+1).split(",").map(i=>i.trim())}}),p=o.link?.map(s=>{let t=s.indexOf(">");t===-1&&(d(`Invalid link format: "${s}". Expected "Source>Target:label"`),process.exit(1));let i=s.slice(0,t),n=s.slice(t+1),r=n.indexOf(":");return {source:i,target:r===-1?n:n.slice(0,r),label:r===-1?void 0:n.slice(r+1)}}),f=H(e$1,a,m,p,c),d$1=JSON.stringify(f,null,2),b$1=$.join(e$1,F);g.existsSync(b$1)||g.mkdirSync(b$1,{recursive:!0});let G=$.join(b$1,`${h}.graph.json`);g.writeFileSync(G,d$1,"utf8"),b(`Graph saved to ${G}`),e(`${f.nodes.length} nodes, ${f.edges.length} edges, ${(d$1.length/1024).toFixed(1)} KB`),e(`
|