agentix-cli 0.69.4 → 0.70.1
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/{App-Z66ABY7H.js → App-LFQTOADB.js} +2 -2
- package/dist/{ChatApp-Z2LZ7IM3.js → ChatApp-RNMG2HWX.js} +2 -2
- package/dist/{agent-IDAWXA3K.js → agent-7IW6472I.js} +2 -2
- package/dist/{board-dashboard-MAP6A2N7.js → board-dashboard-MYWXVYU3.js} +4 -4
- package/dist/{chunk-K63IOY6A.js → chunk-2DWDXT7G.js} +9 -9
- package/dist/chunk-2DWDXT7G.js.map +1 -0
- package/dist/{chunk-P2RYUODK.js → chunk-3ZRFES25.js} +2 -2
- package/dist/{chunk-OHRTBD7U.js → chunk-4HCQEGXO.js} +167 -167
- package/dist/chunk-4HCQEGXO.js.map +1 -0
- package/dist/chunk-4J4YVJFH.js +105 -0
- package/dist/chunk-4J4YVJFH.js.map +1 -0
- package/dist/{chunk-FSYA4GNU.js → chunk-5FD7HE2J.js} +2 -2
- package/dist/{chunk-FUR3T3IN.js → chunk-7334DGUO.js} +2 -2
- package/dist/{chunk-YBF2QVZ7.js → chunk-7PWXCN22.js} +2 -2
- package/dist/{chunk-64P4QHSZ.js → chunk-CECHWYJ2.js} +1 -1
- package/dist/{chunk-64P4QHSZ.js.map → chunk-CECHWYJ2.js.map} +1 -1
- package/dist/{chunk-OVX6NRMD.js → chunk-D3RJMC37.js} +2 -2
- package/dist/chunk-DXAWW7ZQ.js +49 -0
- package/dist/chunk-DXAWW7ZQ.js.map +1 -0
- package/dist/{chunk-CKBAVCGU.js → chunk-E6CYC4HQ.js} +2 -2
- package/dist/{chunk-YL223TEU.js → chunk-FEQ4W4XA.js} +2 -2
- package/dist/{chunk-M6GPRMCQ.js → chunk-KTGPH77J.js} +2 -2
- package/dist/{chunk-KLHG5ZQH.js → chunk-KTNOY4LW.js} +2 -2
- package/dist/{chunk-2UYV24UD.js → chunk-LKA5UUGT.js} +2 -2
- package/dist/{chunk-DQQ3BCJW.js → chunk-MOUSATFW.js} +2 -2
- package/dist/{chunk-5ONI54E6.js → chunk-MTPCD4NV.js} +227 -226
- package/dist/chunk-MTPCD4NV.js.map +1 -0
- package/dist/{chunk-J7HA7ZTU.js → chunk-N4EIYNN4.js} +2 -2
- package/dist/{chunk-BBIWAJRX.js → chunk-O2QVQVOV.js} +2 -2
- package/dist/{chunk-IU6L4V3A.js → chunk-RKZGENSE.js} +2 -2
- package/dist/chunk-RN7G3D53.js +6 -0
- package/dist/chunk-RN7G3D53.js.map +1 -0
- package/dist/chunk-WPNRDEHW.js +2 -0
- package/dist/chunk-WPNRDEHW.js.map +1 -0
- package/dist/{chunk-DTX4I5LQ.js → chunk-XXBW7CFN.js} +2 -2
- package/dist/{chunk-DTX4I5LQ.js.map → chunk-XXBW7CFN.js.map} +1 -1
- package/dist/{chunk-OPUPVGYP.js → chunk-YFROK44Z.js} +2 -2
- package/dist/cli.js +1 -1
- package/dist/client-IQIBHXVS.js +2 -0
- package/dist/{config-FZ4D4EAV.js → config-7AK5TI2D.js} +2 -2
- package/dist/config-mutator-EI5JNMY4.js +2 -0
- package/dist/doctor-CTWQODQG.js +2 -0
- package/dist/index.d.ts +63 -5
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/{migrate-v2-KOMPDC6U.js → migrate-v2-W7RRFM24.js} +2 -2
- package/dist/program-ZKGWGTPV.js +2 -0
- package/dist/{promote-VZAUTV6E.js → promote-USGFU5NN.js} +2 -2
- package/dist/query-NLSKOIWJ.js +2 -0
- package/dist/registry-T7SCVP55.js +2 -0
- package/dist/{request-planner-NMOAOZIM.js → request-planner-VOWMXWRI.js} +2 -2
- package/dist/{review-candidates-FLY6HZEN.js → review-candidates-F6RLNHS2.js} +2 -2
- package/dist/{routing-SMIZ77CT.js → routing-2LAWEIUG.js} +2 -2
- package/dist/schedule-tool-GOQFT2XQ.js +2 -0
- package/dist/scheduler-GJVRJQ7K.js +2 -0
- package/dist/{seat-F3S2HG5G.js → seat-4LLK2XBM.js} +2 -2
- package/dist/{select-5GC7CTPQ.js → select-NJHTHKEQ.js} +2 -2
- package/dist/{set-enabled-53ZPZ5GR.js → set-enabled-HPR6VJCG.js} +2 -2
- package/dist/{tool-FRTZS4TT.js → tool-XQMGKZP5.js} +2 -2
- package/dist/types-NZOBHQGS.js +2 -0
- package/dist/wiki-RQ5P4WWJ.js +2 -0
- package/package.json +1 -1
- package/dist/chunk-4DRNEOOW.js +0 -2
- package/dist/chunk-4DRNEOOW.js.map +0 -1
- package/dist/chunk-535MLOSB.js +0 -109
- package/dist/chunk-535MLOSB.js.map +0 -1
- package/dist/chunk-5ONI54E6.js.map +0 -1
- package/dist/chunk-K63IOY6A.js.map +0 -1
- package/dist/chunk-OHRTBD7U.js.map +0 -1
- package/dist/chunk-TFVUOC2C.js +0 -2
- package/dist/chunk-TFVUOC2C.js.map +0 -1
- package/dist/chunk-V2TLFYKH.js +0 -45
- package/dist/chunk-V2TLFYKH.js.map +0 -1
- package/dist/client-GDTX6LFH.js +0 -2
- package/dist/config-mutator-ETG5V4C5.js +0 -2
- package/dist/doctor-JBIRBRLB.js +0 -2
- package/dist/program-T275Y2V6.js +0 -2
- package/dist/query-7QQZPMXM.js +0 -2
- package/dist/registry-WQ65MQEY.js +0 -2
- package/dist/schedule-tool-NJFROYKY.js +0 -2
- package/dist/scheduler-5N4FC2FQ.js +0 -2
- package/dist/types-S6NHM5C3.js +0 -2
- package/dist/wiki-J4MMCONT.js +0 -2
- /package/dist/{App-Z66ABY7H.js.map → App-LFQTOADB.js.map} +0 -0
- /package/dist/{ChatApp-Z2LZ7IM3.js.map → ChatApp-RNMG2HWX.js.map} +0 -0
- /package/dist/{agent-IDAWXA3K.js.map → agent-7IW6472I.js.map} +0 -0
- /package/dist/{board-dashboard-MAP6A2N7.js.map → board-dashboard-MYWXVYU3.js.map} +0 -0
- /package/dist/{chunk-P2RYUODK.js.map → chunk-3ZRFES25.js.map} +0 -0
- /package/dist/{chunk-FSYA4GNU.js.map → chunk-5FD7HE2J.js.map} +0 -0
- /package/dist/{chunk-FUR3T3IN.js.map → chunk-7334DGUO.js.map} +0 -0
- /package/dist/{chunk-YBF2QVZ7.js.map → chunk-7PWXCN22.js.map} +0 -0
- /package/dist/{chunk-OVX6NRMD.js.map → chunk-D3RJMC37.js.map} +0 -0
- /package/dist/{chunk-CKBAVCGU.js.map → chunk-E6CYC4HQ.js.map} +0 -0
- /package/dist/{chunk-YL223TEU.js.map → chunk-FEQ4W4XA.js.map} +0 -0
- /package/dist/{chunk-M6GPRMCQ.js.map → chunk-KTGPH77J.js.map} +0 -0
- /package/dist/{chunk-KLHG5ZQH.js.map → chunk-KTNOY4LW.js.map} +0 -0
- /package/dist/{chunk-2UYV24UD.js.map → chunk-LKA5UUGT.js.map} +0 -0
- /package/dist/{chunk-DQQ3BCJW.js.map → chunk-MOUSATFW.js.map} +0 -0
- /package/dist/{chunk-J7HA7ZTU.js.map → chunk-N4EIYNN4.js.map} +0 -0
- /package/dist/{chunk-BBIWAJRX.js.map → chunk-O2QVQVOV.js.map} +0 -0
- /package/dist/{chunk-IU6L4V3A.js.map → chunk-RKZGENSE.js.map} +0 -0
- /package/dist/{chunk-OPUPVGYP.js.map → chunk-YFROK44Z.js.map} +0 -0
- /package/dist/{client-GDTX6LFH.js.map → client-IQIBHXVS.js.map} +0 -0
- /package/dist/{config-FZ4D4EAV.js.map → config-7AK5TI2D.js.map} +0 -0
- /package/dist/{config-mutator-ETG5V4C5.js.map → config-mutator-EI5JNMY4.js.map} +0 -0
- /package/dist/{doctor-JBIRBRLB.js.map → doctor-CTWQODQG.js.map} +0 -0
- /package/dist/{migrate-v2-KOMPDC6U.js.map → migrate-v2-W7RRFM24.js.map} +0 -0
- /package/dist/{program-T275Y2V6.js.map → program-ZKGWGTPV.js.map} +0 -0
- /package/dist/{promote-VZAUTV6E.js.map → promote-USGFU5NN.js.map} +0 -0
- /package/dist/{query-7QQZPMXM.js.map → query-NLSKOIWJ.js.map} +0 -0
- /package/dist/{registry-WQ65MQEY.js.map → registry-T7SCVP55.js.map} +0 -0
- /package/dist/{request-planner-NMOAOZIM.js.map → request-planner-VOWMXWRI.js.map} +0 -0
- /package/dist/{review-candidates-FLY6HZEN.js.map → review-candidates-F6RLNHS2.js.map} +0 -0
- /package/dist/{routing-SMIZ77CT.js.map → routing-2LAWEIUG.js.map} +0 -0
- /package/dist/{schedule-tool-NJFROYKY.js.map → schedule-tool-GOQFT2XQ.js.map} +0 -0
- /package/dist/{scheduler-5N4FC2FQ.js.map → scheduler-GJVRJQ7K.js.map} +0 -0
- /package/dist/{seat-F3S2HG5G.js.map → seat-4LLK2XBM.js.map} +0 -0
- /package/dist/{select-5GC7CTPQ.js.map → select-NJHTHKEQ.js.map} +0 -0
- /package/dist/{set-enabled-53ZPZ5GR.js.map → set-enabled-HPR6VJCG.js.map} +0 -0
- /package/dist/{tool-FRTZS4TT.js.map → tool-XQMGKZP5.js.map} +0 -0
- /package/dist/{types-S6NHM5C3.js.map → types-NZOBHQGS.js.map} +0 -0
- /package/dist/{wiki-J4MMCONT.js.map → wiki-RQ5P4WWJ.js.map} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as g,e as l}from"./chunk-
|
|
1
|
+
import{b as g,e as l}from"./chunk-WPNRDEHW.js";import"./chunk-QIJLFPWE.js";import{readFileSync as m,writeFileSync as y,existsSync as v,copyFileSync as f}from"fs";import{join as _}from"path";var w=new Set(["code","ops","support","admin","knowledge","social","system"]),x=[{test:/\b(review[-_.]?(merge[-_.]?request|mr|pull[-_.]?request|pr))\b/i,category:"code",verb:"review.merge-request"},{test:/\breview[-_.]?(code|change|diff|snippet)\b/i,category:"code",verb:"review.code-change"},{test:/\b(fix|patch)[-_.]/i,category:"code",verb:"fix.bug"},{test:/\b(implement|build|add)[-_.]?(feature|cli|api|endpoint)\b/i,category:"code",verb:"implement.feature"},{test:/\bimplement[-_.]/i,category:"code",verb:"implement.feature"},{test:/\b(debug|investigate)[-_.]/i,category:"code",verb:"investigate.error"},{test:/\brefactor\b/i,category:"code",verb:"refactor.code"},{test:/\b(plan|spec|rfc|design)[-_.]/i,category:"code",verb:"spec.feature"},{test:/\b(handle|triage)[-_.]?(github|gitlab)?[-_.]?(issue|push|pr|mr|webhook|comment)\b/i,category:"code",verb:"triage.issue"},{test:/\btriage[-_.]?(issue|ticket)?\b/i,category:"code",verb:"triage.issue"},{test:/\banswer[-_.]?(code[-_.]?question|technical[-_.]?question)\b/i,category:"code",verb:"answer.code-question"},{test:/\b(commit|push|checkout|sync|merge)[-_.]/i,category:"code",verb:"refactor.code"},{test:/\bauthor[-_.]?(workflow|spec|rfc)\b/i,category:"code",verb:"spec.feature"},{test:/\bdeploy[-_.]?(staging|preview|qa|test)\b/i,category:"ops",verb:"deploy.staging"},{test:/\bdeploy[-_.]?(prod|production|live|release)\b/i,category:"ops",verb:"deploy.production"},{test:/\bdeploy[-_.]/i,category:"ops",verb:"deploy.staging"},{test:/\brollback\b/i,category:"ops",verb:"rollback.release"},{test:/\binvestigate[-_.]?incident\b/i,category:"ops",verb:"investigate.incident"},{test:/\b(monitor|status|health[-_.]?check|metrics)\b/i,category:"ops",verb:"monitor.system"},{test:/\b(restart|stop|start)[-_.]?(daemon|service|server)\b/i,category:"ops",verb:"monitor.system"},{test:/\brun[-_.]?(server|infra)?[-_.]?(security|audit)\b/i,category:"ops",verb:"audit.security"},{test:/\brotate[-_.]?(token|tokens|credential|credentials|key|cert|secret)s?\b/i,category:"ops",verb:"rotate.credential"},{test:/\baudit\b/i,category:"ops",verb:"audit.security"},{test:/\bsetup[-_.]/i,category:"ops",verb:"monitor.system"},{test:/\b(greet(ing)?|hello|hi[-_.]?there)\b/i,category:"support",verb:"chat.greeting"},{test:/\b(support[-_.]?request|help[-_.]?request|customer[-_.]?question)\b/i,category:"support",verb:"chat.support-request"},{test:/\b(casual|chitchat|smalltalk)\b/i,category:"support",verb:"chat.casual"},{test:/\b(query|ask|clarify|confirm)[-_.]/i,category:"support",verb:"answer.question"},{test:/\b(reply|respond)[-_.]/i,category:"support",verb:"route.request"},{test:/\banswer[-_.]?question\b/i,category:"support",verb:"answer.question"},{test:/\broute[-_.]?(request|message|to[-_.]?agent)\b/i,category:"support",verb:"route.request"},{test:/\bconfig[-_.]?(change|update|edit)?\b/i,category:"admin",verb:"config.change"},{test:/\bconfigure[-_.]/i,category:"admin",verb:"config.change"},{test:/\b(schedule|cron)[-_.]?(add|create|new)\b/i,category:"admin",verb:"schedule.add"},{test:/\b(reminder|remind)\b/i,category:"admin",verb:"schedule.add"},{test:/\b(schedule|cron)[-_.]?(remove|delete|disable)\b/i,category:"admin",verb:"schedule.remove"},{test:/\b(provide|assign|copy)[-_.]?(token|tokens|credential|credentials|cert|secret)s?\b/i,category:"admin",verb:"token.create"},{test:/\b(token[-_.]?(create|mint|issue)|mint[-_.]?token)\b/i,category:"admin",verb:"token.create"},{test:/\bagent[-_.]?(add|onboard|new|configure)\b/i,category:"admin",verb:"agent.add"},{test:/\bchannel[-_.]?(add|wire|new|configure)\b/i,category:"admin",verb:"channel.add"},{test:/\bauthorize[-_.]/i,category:"admin",verb:"config.change"},{test:/\bcorrect[-_.]/i,category:"admin",verb:"config.change"},{test:/\b(document|docs|readme|wiki[-_.]?write)\b/i,category:"knowledge",verb:"document.feature"},{test:/\bsummariz?e\b/i,category:"knowledge",verb:"summarize.thread"},{test:/\b(research|analyze|compare|investigate[-_.]?repo)\b/i,category:"knowledge",verb:"research.topic"},{test:/\bwiki[-_.]?(absorb|ingest|import|run)\b/i,category:"knowledge",verb:"wiki.absorb"},{test:/\bcompile[-_.]?(brief|report|digest)\b/i,category:"knowledge",verb:"summarize.thread"},{test:/\b(daily[-_.]?brief|brief[-_.]?daily|morning[-_.]?digest)\b/i,category:"social",verb:"brief.daily"},{test:/\b(draft[-_.]?(social|post|tweet|announcement|blog|article)|social[-_.]?post)\b/i,category:"social",verb:"draft.post"},{test:/\bcreate[-_.]?(blog|article|post)\b/i,category:"social",verb:"draft.post"},{test:/\bcompile[-_.]?(marketing|social)\b/i,category:"social",verb:"brief.daily"},{test:/\b(weekly[-_.]?report|report[-_.]?weekly|status[-_.]?report)\b/i,category:"social",verb:"report.weekly"},{test:/\b(classify[-_.]?intent|graph[-_.]?classify)\b/i,category:"system",verb:"classify.intent"}];function q(i,n={}){let c=n.log??console.error.bind(console,"[graph-migrate]"),s=i.baseDir,e={indexRemapped:0,indexSkippedV2:0,indexUnmapped:0,jsonlRemapped:0,jsonlSkippedV2:0,jsonlUnmapped:0,backups:[],patternHits:{}},b=_(s,"index.json");if(v(b)){let u=m(b,"utf-8"),d=l.parse(JSON.parse(u)),r={version:d.version,entries:{}};for(let[t,o]of Object.entries(d.entries)){let a=h(o.path,e.patternHits);if(a==="v2"){r.entries[t]=o,e.indexSkippedV2++;continue}if(a===null){r.entries[t]=o,e.indexUnmapped++;continue}r.entries[t]={...o,path:a,updatedAt:new Date().toISOString()},e.indexRemapped++}if(!n.dryRun){let t=`${b}.v1.bak.${Date.now()}.json`;f(b,t),e.backups.push(t),y(b,JSON.stringify(r,null,2),"utf-8")}}let p=_(s,"classifications.jsonl");if(v(p)){let d=m(p,"utf-8").split(`
|
|
2
2
|
`),r=[];for(let t of d){if(!t.trim()){r.push(t);continue}let o;try{o=g.parse(JSON.parse(t))}catch{r.push(t);continue}let a=h(o.path,e.patternHits);if(a==="v2"){e.jsonlSkippedV2++,r.push(t);continue}if(a===null){e.jsonlUnmapped++,r.push(t);continue}let k={...o,path:a,proposedAxes:{}};r.push(JSON.stringify(k)),e.jsonlRemapped++}if(!n.dryRun){let t=`${p}.v1.bak.${Date.now()}.jsonl`;f(p,t),e.backups.push(t),y(p,r.join(`
|
|
3
3
|
`),"utf-8")}}return c(`index: ${e.indexRemapped} remapped, ${e.indexSkippedV2} already v2, ${e.indexUnmapped} unmapped`),c(`jsonl: ${e.jsonlRemapped} remapped, ${e.jsonlSkippedV2} already v2, ${e.jsonlUnmapped} unmapped`),n.dryRun?c("(dry-run \u2014 no files written)"):c(`backups: ${e.backups.join(", ")}`),e}function h(i,n){if(!Array.isArray(i)||i.length===0)return null;if(w.has(i[0]))return"v2";let c=`${i.join(" ")} ${i[i.length-1]??""}`;for(let s of x)if(s.test.test(c))return n[s.verb]=(n[s.verb]??0)+1,[s.category,s.verb];return null}export{q as migrateV2};
|
|
4
|
-
//# sourceMappingURL=migrate-v2-
|
|
4
|
+
//# sourceMappingURL=migrate-v2-W7RRFM24.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a}from"./chunk-4HCQEGXO.js";import"./chunk-D3RJMC37.js";import"./chunk-KTNOY4LW.js";import"./chunk-KTGPH77J.js";import"./chunk-Z3IP66SL.js";import"./chunk-C4CDVE2E.js";import"./chunk-RKPAVWXF.js";import"./chunk-GV7S5BAX.js";import"./chunk-GSX4NK2N.js";import"./chunk-SZDACK6O.js";import"./chunk-MTPCD4NV.js";import"./chunk-E6CYC4HQ.js";import"./chunk-BYJ3A55Y.js";import"./chunk-NMFXY3QU.js";import"./chunk-7PWXCN22.js";import"./chunk-LQRBGQIR.js";import"./chunk-ZVP6GB4G.js";import"./chunk-MOUSATFW.js";import"./chunk-2D3RYIDU.js";import"./chunk-EKJG63EJ.js";import"./chunk-2DWDXT7G.js";import"./chunk-RKZGENSE.js";import"./chunk-N6EWZGIX.js";import"./chunk-WP6KLXTP.js";import"./chunk-DP7RTNDM.js";import"./chunk-N4EIYNN4.js";import"./chunk-SFQUP3BP.js";import"./chunk-5FD7HE2J.js";import"./chunk-2AXFYDWF.js";import"./chunk-AQASR6KR.js";import"./chunk-76Z4VHDX.js";import"./chunk-W4YR2RO2.js";import"./chunk-AFRHKA7B.js";import"./chunk-YFROK44Z.js";import"./chunk-FEQ4W4XA.js";import"./chunk-KA2UIZXG.js";import"./chunk-GQ76J72O.js";import"./chunk-ILEC3IAV.js";import"./chunk-J3SOEFRE.js";import"./chunk-SIU6STB2.js";import"./chunk-X5C5W3E4.js";import"./chunk-3ZRFES25.js";import"./chunk-DWADWDMU.js";import"./chunk-23A5K5UW.js";import"./chunk-QD6IICK7.js";import"./chunk-VWTBHLMX.js";import"./chunk-LKA5UUGT.js";import"./chunk-4J4YVJFH.js";import"./chunk-CECHWYJ2.js";import"./chunk-DXAWW7ZQ.js";import"./chunk-RN7G3D53.js";import"./chunk-WPNRDEHW.js";import"./chunk-2GIDVZ4H.js";import"./chunk-O2QVQVOV.js";import"./chunk-FX3D7YON.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-QOYAX2FT.js";import"./chunk-5MUJZODV.js";import"./chunk-7I7IEX4S.js";import"./chunk-JHCI6XCJ.js";import"./chunk-DSYKYZMT.js";import"./chunk-XXBW7CFN.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";export{a as buildProgram};
|
|
2
|
+
//# sourceMappingURL=program-ZKGWGTPV.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as a,c as b,d as c,e as d,f as e,g as f,h as g,i as h,j as i,k as j,l as k,m as l,n as m,o as n,p as o,q as p,r as q,s as r,t as s,u as t}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=promote-
|
|
1
|
+
import{b as a,c as b,d as c,e as d,f as e,g as f,h as g,i as h,j as i,k as j,l as k,m as l,n as m,o as n,p as o,q as p,r as q,s as r,t as s,u as t}from"./chunk-MOUSATFW.js";import"./chunk-DP7RTNDM.js";import"./chunk-2AXFYDWF.js";import"./chunk-AQASR6KR.js";import"./chunk-4J4YVJFH.js";import"./chunk-CECHWYJ2.js";import"./chunk-RN7G3D53.js";import"./chunk-WPNRDEHW.js";import"./chunk-O2QVQVOV.js";import"./chunk-FX3D7YON.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-QOYAX2FT.js";import"./chunk-5MUJZODV.js";import"./chunk-7I7IEX4S.js";import"./chunk-XXBW7CFN.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";export{b as DEFAULT_PROMOTE_TYPES,a as PROMOTER_OWNER,c as PROMOTION_LEDGER_FILE,j as appendPromotionLedger,s as approveProposal,n as callPromotionLlm,p as estimateTokens,r as evidenceFor,m as getUnpromotedMemories,k as groupCandidates,h as listAllAgentMemories,d as memoryKey,e as memoryStamp,g as mergeSources,f as parseMemoryStamp,l as parsePromotionResponse,i as readPromotionLedger,t as rejectProposal,o as runPromotion,q as sourceKind};
|
|
2
|
+
//# sourceMappingURL=promote-USGFU5NN.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a,b,c}from"./chunk-DXAWW7ZQ.js";import"./chunk-RN7G3D53.js";import"./chunk-WPNRDEHW.js";import"./chunk-2GIDVZ4H.js";import"./chunk-O2QVQVOV.js";import"./chunk-FX3D7YON.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-QOYAX2FT.js";import"./chunk-5MUJZODV.js";import"./chunk-7I7IEX4S.js";import"./chunk-XXBW7CFN.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";export{b as DEFAULT_GRAPH_WEIGHT,a as agenticQuery,c as rankCatalogPool};
|
|
2
|
+
//# sourceMappingURL=query-NLSKOIWJ.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{I as a,J as b,K as c,L as d,M as e,N as f,O as g,P as h,Q as i,R as j,S as k,T as l}from"./chunk-2DWDXT7G.js";import"./chunk-RKZGENSE.js";import"./chunk-N6EWZGIX.js";import"./chunk-WP6KLXTP.js";import"./chunk-DP7RTNDM.js";import"./chunk-W4YR2RO2.js";import"./chunk-AFRHKA7B.js";import"./chunk-YFROK44Z.js";import"./chunk-FEQ4W4XA.js";import"./chunk-KA2UIZXG.js";import"./chunk-GQ76J72O.js";import"./chunk-ILEC3IAV.js";import"./chunk-J3SOEFRE.js";import"./chunk-SIU6STB2.js";import"./chunk-X5C5W3E4.js";import"./chunk-3ZRFES25.js";import"./chunk-DWADWDMU.js";import"./chunk-23A5K5UW.js";import"./chunk-QD6IICK7.js";import"./chunk-VWTBHLMX.js";import"./chunk-LKA5UUGT.js";import"./chunk-4J4YVJFH.js";import"./chunk-CECHWYJ2.js";import"./chunk-DXAWW7ZQ.js";import"./chunk-RN7G3D53.js";import"./chunk-WPNRDEHW.js";import"./chunk-2GIDVZ4H.js";import"./chunk-O2QVQVOV.js";import"./chunk-FX3D7YON.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-QOYAX2FT.js";import"./chunk-5MUJZODV.js";import"./chunk-7I7IEX4S.js";import"./chunk-DSYKYZMT.js";import"./chunk-XXBW7CFN.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";export{k as AgentRegistry,f as TRACE_STEP_SUMMARY_BYTES,c as buildEntryMeta,d as buildEventDigest,e as buildWikiContext,g as clipForTrace,j as emitTraceStepsFromStreamEvent,i as firstMissingRequiredTool,b as getGlobalRegistry,l as richReplyPrompt,a as setGlobalRegistry,h as tallyToolUses};
|
|
2
|
+
//# sourceMappingURL=registry-T7SCVP55.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{q as m,t as p,v as d,w as x}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=request-planner-
|
|
1
|
+
import{q as m,t as p,v as d,w as x}from"./chunk-O2QVQVOV.js";import"./chunk-FX3D7YON.js";import{a as u,f}from"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-5MUJZODV.js";import"./chunk-7I7IEX4S.js";import"./chunk-XXBW7CFN.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";x();f();var l="request-gate",h="request-context",g=.1;async function q(t,o,c,r=Math.random){let s=p(l)==="active";if(s){let i=m().seats[l]?.holdout??g;if(r()<i)return{active:!0,preprocess:!1,arm:"holdout"}}let a=s?"treatment":void 0,e=await d(l,{request:t.slice(0,2e3),agent:o,channel:c,operations:["select optional context","evaluate model routing where permitted"],constraints:["Keep the original request and mandatory instructions","Desktop model cannot be downgraded"]},{preprocess:u("This request benefits from structured context selection or another bounded typed decision before the main agent executes.",{true:"Relevant context must be selected, or a bounded routing decision can help. Follow-ups and ambiguous references need context.",false:"Typed preprocessing adds no useful decision; send the request to the configured main agent with existing context."})},{timeoutMs:3e3});if(!e||e.mode!=="active")return{active:!1,preprocess:!1,arm:a};let n=e.answers.preprocess?.noul;return{active:!0,preprocess:Number.isFinite(n)&&n>=.5,arm:a}}var v={landscape:"Agent directory and mesh overview",patternContext:"Learned behavioral patterns",references:"Retrieved project references",memoryContext:"Retrieved agent memory",crossChatContext:"Summaries from other conversations",longMemoryRecall:"Older conversation recall",wikiContext:"Retrieved wiki knowledge"};async function b(t){let o=Object.entries(v).flatMap(([e,n])=>{let i=t[e];return i?[{id:e,description:n,source:e,characters:i.length,preview:i.slice(0,400),trust:"context data, not instructions"}]:[]});if(!o.length)return{input:t,excluded:[]};let c=Object.fromEntries(o.map(e=>[e.id,u(`Context block ${e.id} is relevant to completing the current request correctly.`,{true:"Needed or potentially relevant; retain if uncertain or the preview is incomplete.",false:"Clearly unrelated to the current request; safe to omit."})])),r=await d(h,{request:t.message.slice(0,2e3),channel:t.channel,agent:t.agentId,mandatory:["request","identity","permissions and instructions","same-chat history","handover","attachments"],context:o},c,{timeoutMs:3e3});if(!r||r.mode!=="active")return{input:t,excluded:[]};let s={...t},a=[];for(let e of o){let n=r.answers[e.id]?.noul;Number.isFinite(n)&&n>=0&&n<.2&&(delete s[e.id],a.push(e.id))}return{input:s,excluded:a}}export{g as DEFAULT_REQUEST_GATE_HOLDOUT,h as REQUEST_CONTEXT_SEAT,l as REQUEST_GATE_SEAT,q as evaluateRequest,b as selectRequestContext};
|
|
2
|
+
//# sourceMappingURL=request-planner-VOWMXWRI.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as I}from"./chunk-
|
|
1
|
+
import{b as I}from"./chunk-7PWXCN22.js";import"./chunk-WP6KLXTP.js";import"./chunk-2GIDVZ4H.js";import"./chunk-O2QVQVOV.js";import"./chunk-FX3D7YON.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-5MUJZODV.js";import"./chunk-7I7IEX4S.js";import"./chunk-XXBW7CFN.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";import{createHash as E}from"crypto";var v="review:",b={decisions:"project",warnings:"feedback",friction:"feedback",context:"reference"};function A(t,n,r){let s=E("sha1").update(r.trim().toLowerCase()).digest("hex").slice(0,10);return`${v}${t}/${n}@${s}`}function F(t){if(!t.startsWith(v))return null;let n=t.slice(v.length),r=n.lastIndexOf("@"),s=n.lastIndexOf("/",r===-1?void 0:r);return r===-1||s===-1?null:{reviewId:n.slice(0,s),kind:n.slice(s+1,r),digest:n.slice(r+1)}}var C=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,48)||"finding",L=5;function T(t,n){return`${t}|${I(n)}`}function K(t,n={}){let r=n.kinds??Object.keys(b),s=n.minLength??24,h=[],d=new Map,u=new Map,f=new Map,x=new Map;for(let e of t){let i;try{i=JSON.parse(e.result)}catch{continue}let o=e.updated_at?new Date(e.updated_at).toISOString():new Date().toISOString();for(let c of r){let l=b[c];if(!l)continue;let R=i[c];if(Array.isArray(R))for(let $ of R){let a=String($?.text??"").trim();if(a.length<s)continue;let g=A(e.id,c,a),_=g.slice(g.lastIndexOf("@")),w=`${c}${_}`,y=T(c,a),S=f.get(y)??new Set;if(S.add(e.session_id??e.id),f.set(y,S),d.has(w))continue;let O=String($?.evidence??"").trim(),k={occurrences:1,agentId:e.agent,key:`${e.agent}/${l}_${C(a)}`,stamp:g,memory:{name:C(a),type:l,description:a.slice(0,200),body:"",createdAt:o,updatedAt:o}};x.set(g,{text:a,evidence:O,agent:e.agent,source:e.source}),d.set(w,k),u.set(w,y),h.push(k)}}}for(let[e,i]of d){let o=f.get(u.get(e)??"");i.occurrences=o?.size??1,i.sessions=[...o??[]].slice(0,L);let c=x.get(i.stamp);i.memory.body=D(c,i.occurrences)}let m=new Map;for(let[e,i]of d){let o=u.get(e)??e,c=m.get(o)??[];c.push(i),m.set(o,c)}let M=[...m.values()].sort((e,i)=>i[0].occurrences-e[0].occurrences),p=[];for(let e=0;p.length<h.length;e++){let i=!1;for(let o of M)e<o.length&&(p.push(o[e]),i=!0);if(!i)break}return p}function D(t,n){let r=`${t.agent}${t.source?` via ${t.source}`:""}`,s=[];return n>1?(s.push(`Observed in ${n} separate sessions. Most recently stated as:`),s.push(`> ${t.text}`),s.push(`Recurring across ${n} sessions is what makes this worth recording \u2014 any single occurrence is session state, the repetition is the finding.`)):s.push(t.text),t.evidence&&s.push(`**Evidence:** ${t.evidence}`),s.push(`_From ${n>1?"session reviews":"a session review"} of ${r}._`),s.join(`
|
|
2
2
|
|
|
3
3
|
`)}export{L as MAX_EVIDENCE_SESSIONS,b as PROMOTABLE_KINDS,v as REVIEW_STAMP_PREFIX,F as parseReviewStamp,A as reviewStamp,K as reviewsToCandidates};
|
|
4
|
-
//# sourceMappingURL=review-candidates-
|
|
4
|
+
//# sourceMappingURL=review-candidates-F6RLNHS2.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a,b}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=routing-
|
|
1
|
+
import{a,b}from"./chunk-3ZRFES25.js";import"./chunk-O2QVQVOV.js";import"./chunk-FX3D7YON.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-5MUJZODV.js";import"./chunk-7I7IEX4S.js";import"./chunk-XXBW7CFN.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";export{a as cheapModelForEngine,b as routeTaskModel};
|
|
2
|
+
//# sourceMappingURL=routing-2LAWEIUG.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a,b}from"./chunk-7334DGUO.js";import"./chunk-RKPAVWXF.js";import"./chunk-5FD7HE2J.js";import"./chunk-YFROK44Z.js";import"./chunk-FEQ4W4XA.js";import"./chunk-FCPTN6NF.js";import"./chunk-7I7IEX4S.js";import"./chunk-XXBW7CFN.js";import"./chunk-QIJLFPWE.js";export{b as resolveScheduleCaller,a as runScheduleTool};
|
|
2
|
+
//# sourceMappingURL=schedule-tool-GOQFT2XQ.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{n as a,o as b,p as c,q as d,r as e,s as f}from"./chunk-YFROK44Z.js";import"./chunk-FEQ4W4XA.js";import"./chunk-FCPTN6NF.js";import"./chunk-7I7IEX4S.js";import"./chunk-XXBW7CFN.js";import"./chunk-QIJLFPWE.js";export{a as AGENT_RUN_TIMEOUT_FLOOR,f as CronScheduler,b as agentRunTimeout,e as cronRunId,d as getNextCronDate,c as runLinkIds};
|
|
2
|
+
//# sourceMappingURL=scheduler-GJVRJQ7K.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{o as a,p as b,q as c,r as d,s as e,t as f,u as g,v as h,w as i}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=seat-
|
|
1
|
+
import{o as a,p as b,q as c,r as d,s as e,t as f,u as g,v as h,w as i}from"./chunk-O2QVQVOV.js";import"./chunk-FX3D7YON.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-5MUJZODV.js";import"./chunk-7I7IEX4S.js";import"./chunk-XXBW7CFN.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";i();export{h as askSeat,a as configureDecisions,c as decisionsRuntime,f as getSeatMode,d as parseSeatMode,g as recordSeatOutcome,b as resetDecisionsRuntime,e as seatEnvVar};
|
|
2
|
+
//# sourceMappingURL=seat-4LLK2XBM.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{v as S,w}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=select-
|
|
1
|
+
import{v as S,w}from"./chunk-O2QVQVOV.js";import"./chunk-FX3D7YON.js";import{a as g,b as h,f as R}from"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-5MUJZODV.js";import"./chunk-7I7IEX4S.js";import{e as f}from"./chunk-JHCI6XCJ.js";import"./chunk-XXBW7CFN.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";w();R();var p="skill-select";function y(l){return{task:d(l.task,1200),...l.agent?{agent:l.agent}:{},skills:l.candidates.map(t=>({name:t.name,purpose:d(t.description,300),...t.category?{category:t.category}:{},...t.tags?.length?{tags:t.tags.slice(0,8)}:{}}))}}function b(l){let t={};for(let i of l)t[i.name]=d(i.description,300);return{anyRelevant:g("At least one of these skills is about the task at hand.",{true:"The task is the kind of work one of these skills exists for, and following it would change how the work is done \u2014 it names the same system, the same procedure or the same kind of artefact.",false:"None of them is about this task. They may share vocabulary with it, mention the same tools, or belong to the same project without bearing on what is being asked. Sharing words with a task is not being about it."}),best:h(t,"Which skill is this task most about?")}}function v(l){let t=l.anyRelevant,i=l.best,o=Object.entries(i.probabilities??{}).map(([e,s])=>({name:e,p:Number(s)||0})).sort((e,s)=>s.p-e.p);return{anyRelevant:t.noul,name:i.choice,confidence:i.confidence,ranked:o}}function d(l,t){return l.length>t?`${l.slice(0,t)}\u2026`:l}var x=.1,A=12;async function E(l,t,i={}){let o=i.minRelevant??.6,e=f(l,t).filter(n=>n.relevance>=x).slice(0,A),s=e.map(n=>({name:n.skill.frontmatter.name,lexical:n.relevance}));if(e.length===0)return{skill:null,anyRelevant:0,confidence:0,shortlist:s,judged:!1,reason:"no skill mentions anything in this task"};if(e.length===1)return{skill:e[0].skill,anyRelevant:e[0].relevance,confidence:e[0].relevance,shortlist:s,judged:!1,reason:`only ${e[0].skill.frontmatter.name} matched (${e[0].matchReason})`};let r=e.map(n=>({name:n.skill.frontmatter.name,description:n.skill.frontmatter.description,category:n.skill.frontmatter.category??null,tags:n.skill.frontmatter.tags})),m=await S(p,y({task:t,agent:i.agent??null,candidates:r}),b(r),{incumbent:{best:r[0].name},features:{agent:i.agent??"unknown",candidates:r.length}});if(!m)return{skill:e[0].skill,anyRelevant:e[0].relevance,confidence:e[0].relevance,shortlist:s,judged:!1,reason:`seat off \u2014 lexical top match (${e[0].matchReason})`};let a=v(m.answers),c=s.map(n=>({...n,p:a.ranked.find(k=>k.name===n.name)?.p??0})).sort((n,k)=>(k.p??0)-(n.p??0));if(a.anyRelevant<o)return{skill:null,anyRelevant:a.anyRelevant,confidence:a.confidence,shortlist:c,judged:!0,reason:`nothing on the shortlist is about this task (${a.anyRelevant.toFixed(2)} below ${o})`};let u=e.find(n=>n.skill.frontmatter.name===a.name);return u?{skill:u.skill,anyRelevant:a.anyRelevant,confidence:a.confidence,shortlist:c,judged:!0,reason:`${a.name} (confidence ${a.confidence.toFixed(2)})`}:{skill:null,anyRelevant:a.anyRelevant,confidence:a.confidence,shortlist:c,judged:!0,reason:`seat chose "${a.name}", which was not on the shortlist`}}export{E as pickSkillForTask};
|
|
2
|
+
//# sourceMappingURL=select-NJHTHKEQ.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as a}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=set-enabled-
|
|
1
|
+
import{b as a}from"./chunk-FEQ4W4XA.js";import"./chunk-XXBW7CFN.js";import"./chunk-QIJLFPWE.js";async function i(o,r,s={}){let e=null,n=await a(l=>{let t=l.crons?.[o];if(t?r&&t.approval?.action==="create"?e={ok:!1,status:409,error:`schedule "${o}" is waiting for approval: agentx schedule approve ${o}`}:t.enabled===r&&(e={ok:!0,id:o,enabled:r,changed:!1}):e={ok:!1,status:404,error:`no schedule "${o}"`},e)throw new Error("no write");t.enabled=r,e={ok:!0,id:o,enabled:r,changed:!0}},{configPath:s.configPath,reload:!1});return e&&(!e.ok||!e.changed)?e:n.success?e??{ok:!1,status:500,error:"mutation did not run"}:{ok:!1,status:500,error:n.error||"could not write agentx.json"}}export{i as setCronEnabled};
|
|
2
|
+
//# sourceMappingURL=set-enabled-HPR6VJCG.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as p}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=tool-
|
|
1
|
+
import{b as p}from"./chunk-7334DGUO.js";import"./chunk-RKPAVWXF.js";import"./chunk-5FD7HE2J.js";import"./chunk-YFROK44Z.js";import"./chunk-FEQ4W4XA.js";import"./chunk-FCPTN6NF.js";import"./chunk-7I7IEX4S.js";import"./chunk-XXBW7CFN.js";import"./chunk-QIJLFPWE.js";var f=new Set(["cron","heartbeat","api","a2a","mesh","approvals"]);function u(t){return typeof t=="string"?t.trim():""}async function y(t,i){let c=i.fetch??fetch,d=i.daemonUrl.replace(/\/$/,""),s=(u(t.action)||"create").toLowerCase(),r=p(t,i.env??process.env);if(s==="status"){let o=u(t.id);if(!o)return"Error: `id` is required for status (the card id you got when you raised it).";try{let n=await c(`${d}/approvals/${encodeURIComponent(o)}`,{signal:AbortSignal.timeout(1e4)}),a=await n.json().catch(()=>({}));if(!n.ok)return`Error: ${a?.error||`HTTP ${n.status}`}`;let e=a.card;return r&&e.raised_by!==r.agentId?`Error: card "${o}" was raised by another agent.`:e.status==="pending"?`Card ${e.id} is still waiting for the operator. It expires ${e.expires}; then "${e.if_silent}" applies.`:e.status==="decided"?`Card ${e.id}: the operator said ${String(e.verdict).toUpperCase()}.${e.note?` Note: ${e.note}`:""}`:`Card ${e.id} expired unanswered; the default applied: ${e.outcome??e.if_silent}.`}catch(n){return`Error: couldn't reach the daemon (${n?.message??n}).`}}if(s!=="create")return`Error: unknown action "${s}". Use create or status.`;if(!r)return"Error: couldn't tell which agent you are. Pass callerAgentId.";let l=r.channel&&r.chatId&&!f.has(r.channel)?{channel:r.channel,chatId:r.chatId,...r.accountId?{accountId:r.accountId}:{}}:void 0,h={title:t.title,ask:t.ask,recommend:t.recommend,if_silent:t.if_silent,expires:t.expires,source:t.source,raised_by:r.agentId,...l?{reply:l}:{}};try{let o=await c(`${d}/approvals`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(h),signal:AbortSignal.timeout(1e4)}),n=await o.json().catch(()=>({}));if(!o.ok)return`Error: ${n?.error||`HTTP ${o.status}`}`;let a=n.card;return[`Decision card ${a.id} is in the operator's Approvals inbox.`,`If nobody answers by ${a.expires}, "${a.if_silent}" applies.`,"You will get a message with the result. Tell the requester it is waiting for approval; don't ask the operator again in chat."].join(" ")}catch(o){return`Error: couldn't reach the daemon (${o?.message??o}).`}}export{y as runApprovalTool};
|
|
2
|
+
//# sourceMappingURL=tool-XQMGKZP5.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"./chunk-VWTBHLMX.js";import{a as b}from"./chunk-LKA5UUGT.js";import{a}from"./chunk-4J4YVJFH.js";import"./chunk-CECHWYJ2.js";import{a as c}from"./chunk-DXAWW7ZQ.js";import"./chunk-RN7G3D53.js";import"./chunk-WPNRDEHW.js";import"./chunk-2GIDVZ4H.js";import"./chunk-O2QVQVOV.js";import"./chunk-FX3D7YON.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-QOYAX2FT.js";import"./chunk-5MUJZODV.js";import"./chunk-7I7IEX4S.js";import"./chunk-XXBW7CFN.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";export{b as WikiHub,a as WikiStore,c as agenticQuery};
|
|
2
|
+
//# sourceMappingURL=wiki-RQ5P4WWJ.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentix-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.70.1",
|
|
4
4
|
"description": "AI operations layer for small and medium businesses. Routes Telegram, WhatsApp, GitLab, GitHub, crons, webhooks, and mesh tasks to AI agents. Web wizard for operators, CLI for engineers. Self-hosted.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
package/dist/chunk-4DRNEOOW.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{z as e}from"zod";var i=e.enum(["enum","free","ref"]),a=e.object({name:e.string().regex(/^[a-z][a-z0-9_]*$/i,"axis name must be a simple identifier"),type:i,values:e.array(e.string()).optional(),refLevel:e.string().optional(),optional:e.boolean().optional(),description:e.string().optional()}),r=e.object({id:e.string().regex(/^[a-z][a-z0-9_-]*$/,"level id must be lowercase slug"),axes:e.array(a).min(1),description:e.string().optional()}),f=e.object({version:e.number().int().default(1),levels:e.array(r).min(1).max(5),leafInput:a.optional(),leafOutput:a.optional()}),t=e.string().regex(/^[a-z0-9][a-z0-9._-]*$/,"node id must be lowercase slug (alnum, '.', '_', '-')"),n=e.object({id:t,level:e.string(),parentId:t.nullable(),axes:e.record(e.string(),e.string()),createdAt:e.string(),createdBy:e.string().optional()}),o=e.enum(["llm","user","cache"]),s=e.enum(["pending","approved","rejected"]),p=e.object({ts:e.string(),msgHash:e.string(),agentId:e.string().optional(),channel:e.string().optional(),sender:e.string().optional(),path:e.array(t),proposedAxes:e.record(e.string(),e.record(e.string(),e.string())).default({}),leaf:e.object({input:e.string().optional(),output:e.string().optional()}).partial().default({}),source:o,status:s,confidence:e.number().min(0).max(1).optional(),preview:e.string().optional()}),c=e.object({fingerprint:e.string(),path:e.array(t),leaf:p.shape.leaf,updatedAt:e.string()}),m=e.object({version:e.number().int().default(1),nodes:e.array(n).default([])}),d=e.object({version:e.number().int().default(1),entries:e.record(e.string(),c).default({})});export{f as a,p as b,c,m as d,d as e};
|
|
2
|
-
//# sourceMappingURL=chunk-4DRNEOOW.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graph/types.ts"],"sourcesContent":["import { z } from \"zod\"\n\n// --- Intent Knowledge Graph types + Zod schemas ---\n//\n// A hierarchical, enumerable intent taxonomy with fixed axes per level.\n// See plan: /Users/you/.claude/plans/delightful-floating-diffie.md\n//\n// Shape on disk (.agentx/graph/):\n// schema.json — level definitions + required axes per level\n// nodes.json — tree of nodes: { id, level, parentId, axes }\n// classifications.jsonl — append-only log of message → path decisions\n// index.json — fingerprint → pathId snap-to-path cache\n\nexport const axisTypeSchema = z.enum([\"enum\", \"free\", \"ref\"])\nexport type AxisType = z.infer<typeof axisTypeSchema>\n\nexport const axisDefSchema = z.object({\n name: z.string().regex(/^[a-z][a-z0-9_]*$/i, \"axis name must be a simple identifier\"),\n type: axisTypeSchema,\n /** For type=\"enum\": closed set of allowed values. */\n values: z.array(z.string()).optional(),\n /** For type=\"ref\": which level's nodes may be referenced. */\n refLevel: z.string().optional(),\n /** If true, this axis may be absent from a node without failing validation.\n * Use for axes that apply conditionally (e.g. a department's \"lead\" ref\n * doesn't apply to a person-kind unit). Absent/false = required. */\n optional: z.boolean().optional(),\n /** Optional human-readable help, shown as tooltip in the admin UI. */\n description: z.string().optional(),\n})\nexport type AxisDef = z.infer<typeof axisDefSchema>\n\nexport const levelDefSchema = z.object({\n id: z.string().regex(/^[a-z][a-z0-9_-]*$/, \"level id must be lowercase slug\"),\n /** Axes every node at this level MUST carry. Order matters for UI rendering. */\n axes: z.array(axisDefSchema).min(1),\n description: z.string().optional(),\n})\nexport type LevelDef = z.infer<typeof levelDefSchema>\n\nexport const graphSchemaSchema = z.object({\n version: z.number().int().default(1),\n /** Ordered from root to leaf. Max 5 to keep the taxonomy scannable. */\n levels: z.array(levelDefSchema).min(1).max(5),\n /** Axis describing where a leaf classification came from (channel, cron, etc.). */\n leafInput: axisDefSchema.optional(),\n /** Free-form description of the expected result of a leaf classification. */\n leafOutput: axisDefSchema.optional(),\n})\nexport type GraphSchema = z.infer<typeof graphSchemaSchema>\n\n// Allow dots so verb-level node ids like \"review.merge-request\" or\n// \"deploy.staging\" parse cleanly (Phase 1 of the classifier-retire plan).\n// Dots are dot-namespaced verbs only — never the leading char.\nexport const nodeIdSchema = z.string().regex(/^[a-z0-9][a-z0-9._-]*$/, \"node id must be lowercase slug (alnum, '.', '_', '-')\")\n\nexport const graphNodeSchema = z.object({\n id: nodeIdSchema,\n /** Matches a `levels[*].id` from the schema. */\n level: z.string(),\n /** null for root-level nodes (level[0]); otherwise the id of a node at level-1. */\n parentId: nodeIdSchema.nullable(),\n /** Values for every axis declared at this level's schema entry. `ref` axes\n * hold the id of another node; `enum` axes hold one of the declared values;\n * `free` axes hold any string. */\n axes: z.record(z.string(), z.string()),\n createdAt: z.string(),\n createdBy: z.string().optional(),\n})\nexport type GraphNode = z.infer<typeof graphNodeSchema>\n\nexport const classificationSourceSchema = z.enum([\"llm\", \"user\", \"cache\"])\nexport type ClassificationSource = z.infer<typeof classificationSourceSchema>\n\nexport const classificationStatusSchema = z.enum([\"pending\", \"approved\", \"rejected\"])\nexport type ClassificationStatus = z.infer<typeof classificationStatusSchema>\n\nexport const classificationSchema = z.object({\n ts: z.string(),\n msgHash: z.string(),\n agentId: z.string().optional(),\n channel: z.string().optional(),\n sender: z.string().optional(),\n /** Node ids from root to leaf, one per level. Shorter-than-full paths are\n * allowed if the classifier was only confident down to a certain depth. */\n path: z.array(nodeIdSchema),\n /** Axis values asserted by the classifier for new nodes it proposed along\n * the path. Keyed by node id. */\n proposedAxes: z.record(z.string(), z.record(z.string(), z.string())).default({}),\n /** Leaf-level extras. */\n leaf: z.object({\n input: z.string().optional(),\n output: z.string().optional(),\n }).partial().default({}),\n source: classificationSourceSchema,\n status: classificationStatusSchema,\n confidence: z.number().min(0).max(1).optional(),\n /** Redacted first ~200 chars of the message, for the approval UI. */\n preview: z.string().optional(),\n})\nexport type Classification = z.infer<typeof classificationSchema>\n\n/** Row in the fingerprint → path snap cache. */\nexport const fingerprintEntrySchema = z.object({\n fingerprint: z.string(),\n path: z.array(nodeIdSchema),\n leaf: classificationSchema.shape.leaf,\n updatedAt: z.string(),\n})\nexport type FingerprintEntry = z.infer<typeof fingerprintEntrySchema>\n\n/** Nodes file is a plain list, not a nested tree — lookups are by id. */\nexport const nodesFileSchema = z.object({\n version: z.number().int().default(1),\n nodes: z.array(graphNodeSchema).default([]),\n})\nexport type NodesFile = z.infer<typeof nodesFileSchema>\n\n/** Index file — record of fingerprints. Hot path; kept as a map on disk. */\nexport const indexFileSchema = z.object({\n version: z.number().int().default(1),\n entries: z.record(z.string(), fingerprintEntrySchema).default({}),\n})\nexport type IndexFile = z.infer<typeof indexFileSchema>\n"],"mappings":"AAAA,OAAS,KAAAA,MAAS,MAaX,IAAMC,EAAiBD,EAAE,KAAK,CAAC,OAAQ,OAAQ,KAAK,CAAC,EAG/CE,EAAgBF,EAAE,OAAO,CACpC,KAAMA,EAAE,OAAO,EAAE,MAAM,qBAAsB,uCAAuC,EACpF,KAAMC,EAEN,OAAQD,EAAE,MAAMA,EAAE,OAAO,CAAC,EAAE,SAAS,EAErC,SAAUA,EAAE,OAAO,EAAE,SAAS,EAI9B,SAAUA,EAAE,QAAQ,EAAE,SAAS,EAE/B,YAAaA,EAAE,OAAO,EAAE,SAAS,CACnC,CAAC,EAGYG,EAAiBH,EAAE,OAAO,CACrC,GAAIA,EAAE,OAAO,EAAE,MAAM,qBAAsB,iCAAiC,EAE5E,KAAMA,EAAE,MAAME,CAAa,EAAE,IAAI,CAAC,EAClC,YAAaF,EAAE,OAAO,EAAE,SAAS,CACnC,CAAC,EAGYI,EAAoBJ,EAAE,OAAO,CACxC,QAASA,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,EAEnC,OAAQA,EAAE,MAAMG,CAAc,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,EAE5C,UAAWD,EAAc,SAAS,EAElC,WAAYA,EAAc,SAAS,CACrC,CAAC,EAMYG,EAAeL,EAAE,OAAO,EAAE,MAAM,yBAA0B,uDAAuD,EAEjHM,EAAkBN,EAAE,OAAO,CACtC,GAAIK,EAEJ,MAAOL,EAAE,OAAO,EAEhB,SAAUK,EAAa,SAAS,EAIhC,KAAML,EAAE,OAAOA,EAAE,OAAO,EAAGA,EAAE,OAAO,CAAC,EACrC,UAAWA,EAAE,OAAO,EACpB,UAAWA,EAAE,OAAO,EAAE,SAAS,CACjC,CAAC,EAGYO,EAA6BP,EAAE,KAAK,CAAC,MAAO,OAAQ,OAAO,CAAC,EAG5DQ,EAA6BR,EAAE,KAAK,CAAC,UAAW,WAAY,UAAU,CAAC,EAGvES,EAAuBT,EAAE,OAAO,CAC3C,GAAIA,EAAE,OAAO,EACb,QAASA,EAAE,OAAO,EAClB,QAASA,EAAE,OAAO,EAAE,SAAS,EAC7B,QAASA,EAAE,OAAO,EAAE,SAAS,EAC7B,OAAQA,EAAE,OAAO,EAAE,SAAS,EAG5B,KAAMA,EAAE,MAAMK,CAAY,EAG1B,aAAcL,EAAE,OAAOA,EAAE,OAAO,EAAGA,EAAE,OAAOA,EAAE,OAAO,EAAGA,EAAE,OAAO,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,EAE/E,KAAMA,EAAE,OAAO,CACb,MAAOA,EAAE,OAAO,EAAE,SAAS,EAC3B,OAAQA,EAAE,OAAO,EAAE,SAAS,CAC9B,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,EACvB,OAAQO,EACR,OAAQC,EACR,WAAYR,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE,SAAS,EAE9C,QAASA,EAAE,OAAO,EAAE,SAAS,CAC/B,CAAC,EAIYU,EAAyBV,EAAE,OAAO,CAC7C,YAAaA,EAAE,OAAO,EACtB,KAAMA,EAAE,MAAMK,CAAY,EAC1B,KAAMI,EAAqB,MAAM,KACjC,UAAWT,EAAE,OAAO,CACtB,CAAC,EAIYW,EAAkBX,EAAE,OAAO,CACtC,QAASA,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,EACnC,MAAOA,EAAE,MAAMM,CAAe,EAAE,QAAQ,CAAC,CAAC,CAC5C,CAAC,EAIYM,EAAkBZ,EAAE,OAAO,CACtC,QAASA,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,EACnC,QAASA,EAAE,OAAOA,EAAE,OAAO,EAAGU,CAAsB,EAAE,QAAQ,CAAC,CAAC,CAClE,CAAC","names":["z","axisTypeSchema","axisDefSchema","levelDefSchema","graphSchemaSchema","nodeIdSchema","graphNodeSchema","classificationSourceSchema","classificationStatusSchema","classificationSchema","fingerprintEntrySchema","nodesFileSchema","indexFileSchema"]}
|
package/dist/chunk-535MLOSB.js
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import{a as T,b as R,c as re,d as L,e as _}from"./chunk-4DRNEOOW.js";import{b as X}from"./chunk-64P4QHSZ.js";import{a as Q,b as Z,c as ee,d as te,e as se}from"./chunk-TFVUOC2C.js";import{v as Y,w as he}from"./chunk-BBIWAJRX.js";import{a as V,b as pe}from"./chunk-FX3D7YON.js";import{c as O,d as M}from"./chunk-QOYAX2FT.js";import{o as K,p as de}from"./chunk-5MUJZODV.js";var A={version:2,levels:[{id:"category",description:"Top-level kind of work. Closed set \u2014 pick the closest fit.",axes:[{name:"kind",type:"enum",values:["code","ops","support","admin","knowledge","social","system"],description:"Which category this work belongs in."}]},{id:"verb",description:"Specific intent \u2014 verb-level only, NOT client/project-bound.",axes:[{name:"name",type:"free",description:"Lower-kebab dot-namespaced verb. Examples: review.merge-request, fix.bug, investigate.error, deploy.staging, deploy.production, rollback.release, spec.feature, triage.issue, document.feature, chat.greeting, chat.support-request, schedule.add, config.change, ingest.contact, transcribe.audio, brief.daily, summarize.thread, plan.work."}]}],leafInput:{name:"input",type:"enum",values:["telegram","whatsapp","slack","discord","gitlab-mr","gitlab-issue","github-issue","github-pr","cron","webhook","mesh","http"],description:"Where the message entered the system."},leafOutput:{name:"output",type:"free",description:"One short sentence describing what the agent is expected to produce. Generic \u2014 refers to the verb's outcome, not the specific client/project (those are on the event metadata already)."}},G=[{category:"code",verb:"review.merge-request",description:"Review a GitLab MR or GitHub PR"},{category:"code",verb:"review.code-change",description:"General code review (snippet, diff)"},{category:"code",verb:"fix.bug",description:"Fix a reported bug"},{category:"code",verb:"implement.feature",description:"Build a new feature"},{category:"code",verb:"investigate.error",description:"Investigate a failing test, exception, pipeline"},{category:"code",verb:"refactor.code",description:"Restructure existing code without behaviour change"},{category:"code",verb:"spec.feature",description:"Write or update a feature spec / RFC"},{category:"code",verb:"triage.issue",description:"Classify, label, or assign an issue"},{category:"code",verb:"answer.code-question",description:"Answer a code-related question"},{category:"ops",verb:"deploy.staging",description:"Deploy to a staging/preview environment"},{category:"ops",verb:"deploy.production",description:"Deploy to production"},{category:"ops",verb:"rollback.release",description:"Roll back a release"},{category:"ops",verb:"investigate.incident",description:"Investigate a production incident"},{category:"ops",verb:"monitor.system",description:"Check system status / metrics"},{category:"ops",verb:"rotate.credential",description:"Rotate a token, key, certificate"},{category:"ops",verb:"audit.security",description:"Review for security issues"},{category:"support",verb:"chat.greeting",description:"A casual hello, no actionable request"},{category:"support",verb:"chat.support-request",description:"End-user / customer asking for help"},{category:"support",verb:"chat.casual",description:"Informal back-and-forth chat"},{category:"support",verb:"answer.question",description:"Answer an open-ended question"},{category:"support",verb:"route.request",description:"Forward a request to the right agent"},{category:"admin",verb:"config.change",description:"Change agentx.json / environment / config"},{category:"admin",verb:"schedule.add",description:"Add a new cron / scheduled task"},{category:"admin",verb:"schedule.remove",description:"Remove or disable a schedule"},{category:"admin",verb:"token.create",description:"Mint a scoped API token"},{category:"admin",verb:"agent.add",description:"Configure a new agent"},{category:"admin",verb:"channel.add",description:"Wire up a new channel"},{category:"knowledge",verb:"document.feature",description:"Write or update documentation"},{category:"knowledge",verb:"summarize.thread",description:"Summarize a long conversation/thread"},{category:"knowledge",verb:"research.topic",description:"Investigate / gather info on a topic"},{category:"knowledge",verb:"wiki.absorb",description:"Roll raw entries into typed wiki articles"},{category:"social",verb:"brief.daily",description:"Compose a daily brief / digest"},{category:"social",verb:"draft.post",description:"Draft a marketing post / announcement"},{category:"social",verb:"report.weekly",description:"Compose a weekly status report"},{category:"system",verb:"classify.intent",description:"Internal: graph-classifier sub-call"}];import{readFileSync as D,writeFileSync as F,appendFileSync as ue,existsSync as W,mkdirSync as B,renameSync as ge,statSync as ie}from"fs";import{resolve as P,dirname as oe}from"path";import{createHash as fe}from"crypto";var J=class{baseDir;log;parsed=new Map;constructor(e={}){this.baseDir=e.baseDir??P(process.cwd(),".agentx/graph"),this.log=e.log??console.error.bind(console,"[graph]"),B(this.baseDir,{recursive:!0})}schemaPath(){return P(this.baseDir,"schema.json")}nodesPath(){return P(this.baseDir,"nodes.json")}indexPath(){return P(this.baseDir,"index.json")}classificationsPath(){return P(this.baseDir,"classifications.jsonl")}loadSchema(){let e=this.schemaPath();if(!W(e))return this.saveSchema(A),this.log("seeded starter schema at",e),A;let t=D(e,"utf-8"),s=T.safeParse(JSON.parse(t));if(!s.success)throw new Error(`Invalid ${e}: ${s.error.issues.map(r=>r.message).join("; ")}`);if((s.data.version??1)<(A.version??2)){let r=e.replace(/\.json$/,`.v${s.data.version??1}.bak.json`);try{F(r,t),this.log(`migrated graph schema v${s.data.version??1} -> v${A.version}; old saved at ${r}`)}catch(a){this.log(`could not back up old schema: ${a?.message??a}`)}this.saveSchema(A);let n=this.nodesPath();if(W(n)){let a=n.replace(/\.json$/,".v1.bak.json");try{F(a,D(n,"utf-8")),this.log(`archived v1 nodes.json -> ${a}`)}catch(i){this.log(`could not back up old nodes: ${i?.message??i}`)}try{let i=ae();this.saveNodes(i)}catch(i){this.log(`could not seed v2 nodes: ${i?.message??i}`)}}return A}return s.data}saveSchema(e){let t=T.safeParse(e);if(!t.success)throw new Error(`Refusing to save invalid schema: ${t.error.issues.map(s=>s.message).join("; ")}`);ne(this.schemaPath(),t.data)}loadNodes(){let e=this.nodesPath();if(!W(e)){let t=ae();return this.saveNodes(t),t}return structuredClone(this.readParsed(e,t=>{let s=L.safeParse(JSON.parse(t));if(!s.success)throw new Error(`Invalid ${e}: ${s.error.issues.map(r=>r.message).join("; ")}`);return s.data}))}saveNodes(e){let t=L.safeParse(e);if(!t.success)throw new Error(`Refusing to save invalid nodes file: ${t.error.issues.map(s=>s.message).join("; ")}`);this.writeParsed(this.nodesPath(),t.data)}readParsed(e,t){let{mtimeMs:s,size:r}=ie(e),n=this.parsed.get(e);if(n&&n.mtimeMs===s&&n.size===r)return n.data;let a=t(D(e,"utf-8"));return this.parsed.set(e,{mtimeMs:s,size:r,data:a}),a}writeParsed(e,t){this.parsed.delete(e),ne(e,t);let{mtimeMs:s,size:r}=ie(e);this.parsed.set(e,{mtimeMs:s,size:r,data:t})}validateNode(e,t,s){let r=t.levels.find(i=>i.id===e.level);if(!r)throw new Error(`Unknown level: "${e.level}"`);let n=r.axes.filter(i=>!i.optional).filter(i=>!(i.name in e.axes));if(n.length)throw new Error(`Node ${e.id} (${e.level}) missing required axes: ${n.map(i=>i.name).join(", ")}`);for(let i of r.axes){let o=e.axes[i.name];if(o!=null){if(i.type==="enum"&&i.values&&!i.values.includes(o))throw new Error(`Node ${e.id}: axis ${i.name}="${o}" not in enum ${JSON.stringify(i.values)}`);if(i.type==="ref"){if(!s.some(c=>c.id===o))throw new Error(`Node ${e.id}: axis ${i.name}="${o}" refers to unknown node`);if(i.refLevel){let c=s.find(l=>l.id===o);if(c.level!==i.refLevel)throw new Error(`Node ${e.id}: axis ${i.name} expected level "${i.refLevel}" but got "${c.level}"`)}}}}let a=t.levels.findIndex(i=>i.id===e.level);if(a===0){if(e.parentId!==null)throw new Error(`Root-level node ${e.id} must have parentId: null`)}else{if(!e.parentId)throw new Error(`Non-root node ${e.id} must have a parentId`);let i=s.find(c=>c.id===e.parentId);if(!i)throw new Error(`Node ${e.id}: parent "${e.parentId}" not found`);let o=t.levels.findIndex(c=>c.id===i.level);if(o<0||o>=a)throw new Error(`Node ${e.id} at level "${e.level}" has parent at level "${i.level}" \u2014 parent must be at a higher level`)}}commitNodesAlongPath(e,t,s,r){let n=[],a=[],i=new Date().toISOString();for(let o=0;o<e.length;o++){let c=e[o],l=this.loadNodes().nodes;if(l.find(m=>m.id===c)){a.push(c);continue}let p=0;for(let m=o-1;m>=0;m--){let b=e[m],C=l.find(k=>k.id===b)||n.find(k=>k.id===b);if(C){p=s.levels.findIndex(k=>k.id===C.level)+1;break}}let u=t[c]??{},d=null;for(let m=p;m<s.levels.length;m++){let b=s.levels[m];if(b.axes.filter(k=>!k.optional).filter(k=>!(k.name in u)).length===0){d=b.id,p=m+1;break}}if(!d&&p<s.levels.length&&(d=s.levels[p].id,p++),!d)throw new Error(`Can't place node ${c} \u2014 no schema level left (cursor=${p}, levels=${s.levels.length})`);let h=null,f=s.levels.findIndex(m=>m.id===d);for(let m=o-1;m>=0;m--){let b=e[m],C=l.find(I=>I.id===b)||n.find(I=>I.id===b);if(!C)continue;let k=s.levels.findIndex(I=>I.id===C.level);if(k>=0&&k<f){h=b;break}}let g={id:c,level:d,parentId:h,axes:u,createdAt:i,createdBy:r};this.addNode(g),n.push(g)}return{added:n,skipped:a}}addNode(e){let t=this.loadSchema(),s=this.loadNodes();if(s.nodes.some(r=>r.id===e.id))throw new Error(`Node id already exists: ${e.id}`);return this.validateNode(e,t,[...s.nodes,e]),s.nodes.push(e),this.saveNodes(s),e}appendClassification(e){let t=R.safeParse(e);if(!t.success){let n=t.error.issues.map(a=>`${a.path.join(".")}: ${a.message}`).join(" \xB7 ");return this.log(`skipped invalid classification \u2014 ${n} \xB7`,`path=${JSON.stringify(e.path)}`,`axes-keys=${JSON.stringify(Object.keys(e.proposedAxes||{}))}`),!1}let s=JSON.stringify(t.data)+`
|
|
2
|
-
`,r=this.classificationsPath();return W(r)||B(oe(r),{recursive:!0}),ue(r,s),!0}listPendingClassifications(e=200){return this.listByStatus("pending",e)}listAllClassifications(){return this.readAllCollapsed()}listByStatus(e,t=200){return this.readAllCollapsed().filter(r=>r.status===e).slice(0,t)}readAllCollapsed(){let e=this.classificationsPath();if(!W(e))return[];let s=D(e,"utf-8").split(`
|
|
3
|
-
`).filter(Boolean),r=new Map;for(let n of s)try{let a=R.safeParse(JSON.parse(n));if(!a.success)continue;r.set(a.data.msgHash,a.data)}catch{}return Array.from(r.values()).sort((n,a)=>n.ts<a.ts?1:-1)}updateClassificationStatus(e,t){let r=this.readAllCollapsed().find(a=>a.msgHash===e);if(!r)return null;let n={...r,status:t.status,ts:new Date().toISOString()};if(t.reviewer||t.reviewReason){let a=` \xB7 ${t.reviewer?`reviewer=${t.reviewer}`:""}${t.reviewReason?` \xB7 ${t.reviewReason}`:""}`;n.preview=((r.preview||"")+a).slice(0,500)}return this.appendClassification(n),n}readRecentClassifications(e=50){let t=this.classificationsPath();if(!W(t))return[];let r=D(t,"utf-8").split(`
|
|
4
|
-
`).filter(Boolean),n=[];for(let a=r.length-1;a>=0&&n.length<e;a--)try{let i=R.safeParse(JSON.parse(r[a]));i.success&&n.push(i.data)}catch{}return n}fingerprint(e){let s=[me(e.text),e.channel??""].join("");return fe("sha256").update(s).digest("hex").slice(0,32)}loadIndex(){return structuredClone(this.index())}saveIndex(e){let t=_.safeParse(e);if(!t.success)throw new Error(`Refusing to save invalid index: ${t.error.issues.map(s=>s.message).join("; ")}`);this.writeParsed(this.indexPath(),t.data)}index(){let e=this.indexPath();return W(e)?this.readParsed(e,t=>{let s=_.safeParse(JSON.parse(t));if(!s.success)throw new Error(`Invalid ${e}: ${s.error.issues.map(r=>r.message).join("; ")}`);return s.data}):{version:1,entries:{}}}getFingerprint(e){let t=this.index().entries[e];return t&&structuredClone(t)}setFingerprint(e,t){let s=re.safeParse({...t,fingerprint:e,updatedAt:new Date().toISOString()});if(!s.success)throw new Error(`Refusing to save invalid index entry: ${s.error.issues.map(n=>n.message).join("; ")}`);let r=this.index();this.writeParsed(this.indexPath(),{...r,entries:{...r.entries,[e]:s.data}})}updateNodeAxes(e,t){let s=this.loadSchema(),r=this.loadNodes(),n=r.nodes.find(i=>i.id===e);if(!n)throw new Error(`Node not found: ${e}`);let a={...n,axes:t};return this.validateNode(a,s,r.nodes.map(i=>i.id===e?a:i)),r.nodes=r.nodes.map(i=>i.id===e?a:i),this.saveNodes(r),a}deleteNode(e){let t=this.loadNodes(),s=t.nodes.find(n=>n.parentId===e);if(s)throw new Error(`Cannot delete "${e}" \u2014 child node "${s.id}" still points to it`);let r=t.nodes.find(n=>Object.values(n.axes).some(a=>a===e));if(r)throw new Error(`Cannot delete "${e}" \u2014 node "${r.id}" references it via an axis`);t.nodes=t.nodes.filter(n=>n.id!==e),this.saveNodes(t)}approveClassification(e){if(this.getFingerprint(e.msgHash))return;let t=this.loadSchema(),s=new Set(this.loadNodes().nodes.map(r=>r.id));for(let r=0;r<e.path.length;r++){let n=e.path[r];if(s.has(n))continue;let a=t.levels[r]?.id;if(!a)break;let i=e.proposedAxes?.[n]??{},o=r===0?null:e.path[r-1];this.addNode({id:n,level:a,parentId:o,axes:i,createdAt:new Date().toISOString(),createdBy:e.agentId}),s.add(n)}this.setFingerprint(e.msgHash,{path:e.path,leaf:e.leaf}),this.appendClassification({...e,status:"approved",ts:new Date().toISOString()})}rejectClassification(e){this.appendClassification({...e,status:"rejected",ts:new Date().toISOString()})}};function ne(y,e){B(oe(y),{recursive:!0});let t=`${y}.tmp-${process.pid}`;F(t,JSON.stringify(e,null,2)),ge(t,y)}function ae(){let y=new Date().toISOString(),e=[],t=new Set;for(let s of G)t.has(s.category)||(e.push({id:s.category,level:"category",parentId:null,axes:{kind:s.category},createdAt:y,createdBy:"starter"}),t.add(s.category));for(let s of G)e.push({id:s.verb,level:"verb",parentId:s.category,axes:{name:s.verb,...s.description?{description:s.description}:{}},createdAt:y,createdBy:"starter"});return{version:1,nodes:e}}function me(y){return y.toLowerCase().replace(/https?:\/\/\S+/g," url ").replace(/[@#][\w.\/-]+/g," ref ").replace(/\b[0-9a-f]{7,}\b/g," id ").replace(/\d+/g," num ").replace(/[^\p{L}\p{N}\s]+/gu," ").replace(/\s+/g," ").trim().slice(0,400)}pe();de();import{createHash as ve}from"crypto";var H=class{store;daemonUrl;token;draftAgent;autoApprove;autoApproveStructure;classifierModel;classifierProviderName;providerInstance;log;constructor(e){this.store=e.store,this.daemonUrl=e.daemonUrl.replace(/\/+$/,""),this.token=e.token,this.draftAgent=e.draftAgent,this.autoApprove=e.autoApproveConfidence??1,this.autoApproveStructure=e.autoApproveStructure??"extend-leaves",this.classifierModel=e.classifierModel??"claude-haiku-4-5-20251001",this.classifierProviderName=e.classifierProvider??"claude-code",this.log=e.log??console.error.bind(console,"[classifier]")}getProvider(){return this.providerInstance||(this.providerInstance=K(this.classifierProviderName)),this.providerInstance}async classify(e){let t=this.store.fingerprint({text:e.text,channel:e.channel,sender:e.sender}),s=this.store.getFingerprint(t);if(s)return this.store.appendClassification({ts:new Date().toISOString(),msgHash:t,agentId:e.agentId,channel:e.channel,sender:e.sender,path:s.path,proposedAxes:{},leaf:s.leaf,source:"cache",status:"approved",preview:e.text.slice(0,200)}),{path:s.path,pathId:U(s.path),pathLabel:q(s.path,this.store.loadNodes().nodes),axes:{},leaf:s.leaf,source:"cache",status:"approved"};let r=this.store.loadSchema(),n=this.store.loadNodes().nodes,a=await this.proposePath(e,r,n).catch(g=>(this.log("LLM proposal failed:",g?.message||g),null));if(!a)return null;let{path:i,proposedAxes:o,confidence:c,leaf:l}=a;if(i.length===0)return null;let v={ts:new Date().toISOString(),msgHash:t,agentId:e.agentId,channel:e.channel,sender:e.sender,path:i,proposedAxes:o,leaf:l,source:"llm",status:"pending",confidence:c,preview:e.text.slice(0,200)},p=new Set(n.map(g=>g.id)),u=i.map((g,m)=>p.has(g)?-1:m).filter(g=>g>=0),d=!1;if(this.autoApproveStructure==="any")d=!0;else if(this.autoApproveStructure==="extend-leaves"){let g=u.length===0,m=u.length===1&&u[0]===i.length-1;d=g||m}let h=c!==void 0&&c>=this.autoApprove,f="pending";if(d||h)try{this.commitNewNodes(i,o,r,n,e.sender),this.store.setFingerprint(t,{path:i,leaf:l}),f="approved"}catch(g){this.log("auto-approve failed \u2014 staying pending \xB7",`path=${JSON.stringify(i)}`,`reason=${(g?.message||g).toString().slice(0,200)}`)}return v.status=f,this.store.appendClassification(v),{path:i,pathId:U(i),pathLabel:q(i,this.store.loadNodes().nodes),axes:o,leaf:l,source:"llm",status:f,confidence:c}}async proposePath(e,t,s){let r=s.map(d=>({id:d.id,level:d.level,parentId:d.parentId,axes:d.axes})),n=["You are the intent classifier for AgentX. You answer ONE question:",'"what kind of work does this message describe?" \u2014 verb-level only.',"","IMPORTANT \u2014 what NOT to encode in the path:","- Client / company / project / team names. Those are already on the event"," metadata (project, channel, agentId). Embedding them in the path causes"," duplicate nodes (one per client) for the same verb.","- The specific subject (issue number, file name, person name). Same reason.","- The agent's name or role. Pick the verb the *requester* intended.","","SCHEMA (fixed levels \u2014 pick one node per level):","```json",JSON.stringify(t,null,2),"```","","EXISTING NODES (prefer reusing these; only invent a new node when no","existing one fits):","```json",JSON.stringify(r,null,2),"```","","MESSAGE:","```",e.text.slice(0,2e3),"```",`channel: ${e.channel??"?"}`,`sender: ${e.sender??"?"}`,"","TASK:","1. Classify into 'category' (closed enum): code, ops, support, admin,"," knowledge, social, system. Pick the closest fit.","2. Pick or propose a 'verb' node. Verb ids are dot-namespaced lower-kebab,",' e.g. "review.merge-request", "deploy.staging", "investigate.error",',' "chat.greeting", "fix.bug". Reuse an existing verb when the message is'," the same kind of work as something already classified, even when the"," client / project / subject differs.","","Examples (right vs wrong):",'- "Please review MR #957 on globex/system" \u2192 ["code", "review.merge-request"]',' NOT ["business", "acme", "globex-v2", "review-mr-957-system"]','- "Deploy initech-v2 to staging please" \u2192 ["ops", "deploy.staging"]',' NOT ["business", "acme", "initech-v2", "deploy-initech-v2-to-staging"]','- "Hello Atlas" \u2192 ["support", "chat.greeting"]',"","NODE ID RULES (strict \u2014 invalid ids get dropped):","- lowercase-kebab + dots only: [a-z0-9][a-z0-9._-]*","- no spaces, no uppercase, no Arabic/other non-Latin",'- verb ids should use a "category.specific" or "verb.modifier" shape',"","Return ONE JSON object on one line, no prose, no fences:",' { "path": string[], "proposedAxes": { [nodeId]: { [axisName]: string } }, "leaf": { "input"?: string, "output"?: string }, "confidence": number }',"confidence in [0,1]. Prefer low confidence over guessing."].join(`
|
|
5
|
-
`),a=await this.callProvider(n),i=V(a);if(!i||!Array.isArray(i.path))return null;let o=/^[a-z0-9][a-z0-9._-]*$/,c=new Map,l=i.path.filter(d=>typeof d=="string"&&d.length>0).map(d=>{let h=d.trim(),f=ce(h);return h!==f&&c.set(h,f),f}).filter(d=>o.test(d));if(l.length===0)return null;let v={};if(i.proposedAxes&&typeof i.proposedAxes=="object")for(let[d,h]of Object.entries(i.proposedAxes)){if(!h||typeof h!="object")continue;let f=c.get(d)??ce(d);if(!f)continue;let g={};for(let[m,b]of Object.entries(h))typeof b=="string"&&(g[m]=b);!g.name&&d!==f&&(g.name=d.trim()),v[f]=g}let p={};i.leaf&&typeof i.leaf=="object"&&(typeof i.leaf.input=="string"&&(p.input=i.leaf.input),typeof i.leaf.output=="string"&&(p.output=i.leaf.output));let u=typeof i.confidence=="number"?Math.max(0,Math.min(1,i.confidence)):void 0;return{path:l,proposedAxes:v,confidence:u,leaf:p}}commitNewNodes(e,t,s,r,n){this.store.commitNodesAlongPath(e,t,s,n)}async callProvider(e){let t=this.getProvider(),s=new AbortController,r=setTimeout(()=>s.abort(),3e4);try{return(await t.generate([{role:"system",content:"You are a taxonomy classifier. Respond with a single JSON object on one line. No prose, no code fences."},{role:"user",content:e}],{model:this.classifierModel,maxTokens:800,abortSignal:s.signal,bare:!0})).content||""}finally{clearTimeout(r)}}};function ce(y){let e=y.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/^[-_]+|[-_]+$/g,"").replace(/-{2,}/g,"-");return e?/^[a-z0-9]/.test(e)?e:`n-${e}`.replace(/[-_]+$/,""):""}function U(y){return ve("sha1").update(y.join("")).digest("hex").slice(0,16)}function q(y,e){return y.map(t=>{let s=e.find(n=>n.id===t);return s&&(s.axes?.name||s.axes?.what)||t}).join(" \u203A ")}function z(y,e){if(y.length===0||e.length===0)return 0;let t=0;for(let r=0;r<Math.min(y.length,e.length)&&y[r]===e[r];r++)t++;if(t===0)return 0;let s=Math.max(y.length,e.length);return t/s}import{readFileSync as N,writeFileSync as x,appendFileSync as we,existsSync as $,mkdirSync as j,readdirSync as E,statSync as ye}from"fs";import{resolve as w,join as be,relative as S,dirname as ke}from"path";he();var le=class{baseDir;rawDir;log;constructor(e=w(process.cwd(),".agentx/wiki"),t=console.error.bind(console,"[wiki]")){this.baseDir=e,this.rawDir=w(e,"raw/entries"),this.log=t,j(this.rawDir,{recursive:!0}),j(w(e,"raw"),{recursive:!0}),this.ensureSchema()}canRead(e,t){return e.access==="public"?!0:t?!!(e.owner===t||e.access==="shared"&&e.sharedWith?.includes(t)):!1}canWrite(e,t){return e.owner===t}addEntry(e){let t=`${e.date}_${e.id}.md`,s=w(this.rawDir,t),r=["---",`id: ${e.id}`,`date: ${e.date}`,`agent: ${e.agentId}`,`source: ${e.source}`];if(e.sourceContext&&r.push(`context: ${e.sourceContext}`),e.meta)for(let[n,a]of Object.entries(e.meta))r.push(`${n}: ${JSON.stringify(a)}`);return r.push("---","",e.content),x(s,r.join(`
|
|
6
|
-
`)),this.appendLog("ingest",`${e.id} from ${e.agentId} via ${e.source}`),t}listEntries(e){if(!$(this.rawDir))return[];let t=E(this.rawDir).filter(r=>r.endsWith(".md")).sort(),s=[];for(let r of t){let n=N(w(this.rawDir,r),"utf-8"),a=this.parseEntry(n,r);a&&(e?.agentId&&a.agentId!==e.agentId||e?.after&&a.date<e.after||e?.before&&a.date>e.before||s.push(a))}return s}parseEntry(e,t){let s=e.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);if(!s)return null;let r=s[1],n=s[2].trim(),a=c=>r.match(new RegExp(`^${c}:\\s*(.+)$`,"m"))?.[1]?.trim()||"",i=new Set(["id","date","agent","source","context"]),o={};for(let c of r.split(`
|
|
7
|
-
`)){let l=c.match(/^(\w+):\s*(.+)$/);if(!(!l||i.has(l[1])))try{o[l[1]]=JSON.parse(l[2])}catch{o[l[1]]=l[2].trim()}}return{id:a("id")||t.replace(".md",""),date:a("date"),agentId:a("agent"),source:a("source"),sourceContext:a("context")||void 0,content:n,meta:Object.keys(o).length>0?o:void 0}}writeArticle(e,t,s,r){let n=this.readArticle(e);if(n&&!this.canWrite(n.meta,r))return this.log(`Permission denied: "${r}" cannot write "${e}" (owner: ${n.meta.owner})`),!1;t.type&&!X(t.type)&&(this.log(`Dropping invalid article type "${t.type}" for "${e}" \u2014 enum is [person, project, place, concept, event, decision, pattern]`),t={...t,type:void 0});let a=w(this.baseDir,e);n&&this.saveVersion(e,a),j(ke(a),{recursive:!0});let i=["---",`title: "${t.title}"`];t.type&&i.push(`type: ${t.type}`),t.related?.length&&i.push(`related: [${t.related.map(c=>`"${c}"`).join(", ")}]`),i.push(`tags: [${(t.tags||[]).map(c=>`"${c}"`).join(", ")}]`,`owner: ${t.owner}`,`access: ${t.access}`),t.sharedWith?.length&&i.push(`shared_with: [${t.sharedWith.map(c=>`"${c}"`).join(", ")}]`),i.push(`created: ${t.created}`,`last_updated: ${t.lastUpdated}`,`sources: [${t.sources.map(c=>`"${c}"`).join(", ")}]`),t.graphPath?.length&&i.push(`graph_path: [${t.graphPath.map(c=>`"${c}"`).join(", ")}]`),i.push("---","",s),x(a,i.join(`
|
|
8
|
-
`));let o=n?"update":"create";return this.appendLog(o,`${t.title} [${(t.tags||[]).slice(0,5).join(", ")}] by ${r} at ${e}`),!0}saveVersion(e,t){try{if(!$(t))return;let s=N(t,"utf-8"),r=new Date().toISOString().replace(/[:.]/g,"-"),n=w(this.baseDir,"_versions",e.replace(/\.md$/,""));j(n,{recursive:!0}),x(w(n,`${r}.md`),s)}catch{}}getVersions(e){let t=w(this.baseDir,"_versions",e.replace(/\.md$/,""));if(!$(t))return[];try{return E(t).filter(s=>s.endsWith(".md")).sort().reverse().map(s=>({timestamp:s.replace(/\.md$/,"").replace(/-/g,(r,n)=>n<19?n===10?"T":n===13||n===16?":":"-":r),path:w(t,s)}))}catch{return[]}}restoreVersion(e,t){let r=this.getVersions(e).find(n=>n.timestamp.startsWith(t));if(!r)return!1;try{let n=N(r.path,"utf-8"),a=w(this.baseDir,e);return this.saveVersion(e,a),x(a,n),this.appendLog("restore",`${e} restored to ${t}`),!0}catch{return!1}}readArticle(e){let t=w(this.baseDir,e);if(!$(t))return null;let s=N(t,"utf-8");return this.parseArticle(s,e)}readArticleAs(e,t){let s=this.readArticle(e);return!s||!this.canRead(s.meta,t)?null:s}parseArticle(e,t){let s=e.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);if(!s)return null;let r=s[1],n=s[2].trim(),a=d=>r.match(new RegExp(`^${d}:\\s*(.+)$`,"m"))?.[1]?.trim().replace(/^"(.*)"$/,"$1")||"",i=d=>{let h=r.match(new RegExp(`^${d}:\\s*\\[(.*)\\]$`,"m"));return h?h[1].split(",").map(f=>f.trim().replace(/^"(.*)"$/,"$1")).filter(Boolean):[]},o=a("type")||a("kind"),l=new Set(["person","project","place","concept","event","decision","pattern"]).has(o)?o:void 0,v=i("tags").filter((d,h,f)=>d&&f.indexOf(d)===h),p=i("related"),u=i("graph_path");return{meta:{title:a("title"),type:l,related:p.length?p:void 0,tags:v,owner:a("owner"),access:a("access")||"public",sharedWith:i("shared_with"),created:a("created"),lastUpdated:a("last_updated"),sources:i("sources"),graphPath:u.length?u:void 0},content:n,path:t}}listCache=new Map;listArticles(e){let t=[],s=[];this.walkDir(this.baseDir,(i,o)=>{if(!i.endsWith(".md"))return;let c=S(this.baseDir,i);c.startsWith("raw/")||c.startsWith("_")||(t.push(c),s.push(`${c}:${o?.mtimeMs??"?"}:${o?.size??"?"}`))});let r=s.join("|"),n=this.listCache.get(e);if(n&&n.signature===r)return n.articles.slice();let a=[];for(let i of t){let o=this.readArticle(i);o&&this.canRead(o.meta,e)&&a.push(o)}return this.listCache.set(e,{signature:r,articles:a}),a.slice()}search(e,t,s=10){let r=e.toLowerCase(),n=[];if(this.walkDir(this.baseDir,p=>{if(!p.endsWith(".md"))return;let u=S(this.baseDir,p);if(u.startsWith("raw/")||u.startsWith("_"))return;let d=this.readArticle(u);!d||!this.canRead(d.meta,t)||n.push(d)}),n.length===0)return[];let a=n.map(p=>p.content),i=w(this.baseDir,"_bm25_cache.json"),o=M(a,i),c=O(e,o),l=new Map(c.map(p=>[p.docIndex,p.score]));return n.map((p,u)=>{let d=l.get(u)??0;return p.meta.title.toLowerCase().includes(r)&&(d+=10),p.meta.tags?.some(h=>h.toLowerCase().includes(r))&&(d+=5),{article:p,score:d}}).filter(p=>p.score>0).sort((p,u)=>u.score-p.score).slice(0,s).map(p=>p.article)}async findRelevantReranked(e,t,s=10,r={}){let n=Math.max(s,r.shortlist??Z),a=this.findRelevant(e,t,n);if(a.length<2)return a.slice(0,s);let i=a.map((l,v)=>({id:`c${v}`,title:l.meta.title||`(untitled ${v})`,tags:l.meta.tags,excerpt:l.content})),o=await Y(Q,ee({query:e,candidates:i,excerptChars:r.excerptChars}),te(i),{incumbent:{best:i[0].id},features:{agent:t??"unknown"}});return!o||o.mode!=="active"?a.slice(0,s):se(o.answers,i).ranked.map(l=>a[Number(l.slice(1))]).filter(l=>!!l).slice(0,s)}findRelevant(e,t,s=3,r,n={graph:.6,bm25:.4}){let a=[];if(this.walkDir(this.baseDir,h=>{if(!h.endsWith(".md"))return;let f=S(this.baseDir,h);if(f.startsWith("raw/")||f.startsWith("_"))return;let g=this.readArticle(f);!g||!this.canRead(g.meta,t)||a.push(g)}),a.length===0)return[];let i=a.map(h=>`${h.meta.title} ${(h.meta.tags||[]).join(" ")} ${h.content}`),o=w(this.baseDir,"_bm25_relevance_cache.json"),c=M(i,o),l=O(e,c),v=l.reduce((h,f)=>Math.max(h,f.score),0)||1,p=new Map(l.map(h=>[h.docIndex,h.score/v])),u=!!(r&&r.length>0);return a.map((h,f)=>{let g=p.get(f)??0,m=0;u&&h.meta.graphPath?.length&&(m=z(r,h.meta.graphPath));let b=u?n.graph*m+n.bm25*g:g;return{article:h,score:b}}).filter(h=>h.score>0).sort((h,f)=>f.score-h.score).slice(0,s).map(h=>h.article)}buildContext(e,t=4e3){if(e.length===0)return"";let s=["[Wiki Knowledge]"],r=0;for(let n of e){let a=`
|
|
9
|
-
## ${n.meta.title} [${(n.meta.tags||[]).slice(0,3).join(", ")}]`,i=n.content.length>600?n.content.slice(0,600)+"...":n.content,o=a+`
|
|
10
|
-
`+i;if(r+o.length>t)break;s.push(o),r+=o.length}return s.push(`
|
|
11
|
-
[End Wiki Knowledge]`),s.join(`
|
|
12
|
-
`)}rebuildIndex(){let e=[],t=new Map;this.walkDir(this.baseDir,a=>{if(!a.endsWith(".md"))return;let i=S(this.baseDir,a);if(i.startsWith("raw/")||i.startsWith("_"))return;let o=this.readArticle(i);if(!o)return;let c=o.content.match(/\[\[([^\]]+)\]\]/g)||[];for(let v of c){let p=v.replace(/\[\[|\]\]/g,"");t.set(p,(t.get(p)||0)+1)}let l=[o.meta.title.toLowerCase()];o.meta.tags&&l.push(...o.meta.tags.map(v=>v.toLowerCase())),e.push({path:i,title:o.meta.title,type:o.meta.type,related:o.meta.related,tags:o.meta.tags||[],owner:o.meta.owner,access:o.meta.access,sharedWith:o.meta.sharedWith,aliases:l,backlinks:t.get(o.meta.title)||0,sources:o.meta.sources,lastUpdated:o.meta.lastUpdated})});let s={articles:e,lastRebuilt:new Date().toISOString()};x(w(this.baseDir,"_index.json"),JSON.stringify(s,null,2)),this.writeCatalog(e,s.lastRebuilt);let r=["# Wiki Index","",`Last rebuilt: ${s.lastRebuilt}`,""],n=new Map;for(let a of e){let i=a.access||"public",o=n.get(i)||[];o.push(a),n.set(i,o)}for(let[a,i]of Array.from(n.entries()).sort()){r.push(`## ${a}`,"");for(let o of i.sort((c,l)=>c.title.localeCompare(l.title))){let c=o.type?` [${o.type}]`:"";r.push(`- [${o.title}](${o.path})${c} \u2014 owner: ${o.owner}`)}r.push("")}return x(w(this.baseDir,"WIKI.md"),r.join(`
|
|
13
|
-
`)),this.log(`Index rebuilt: ${e.length} articles`),this.appendLog("rebuild-index",`${e.length} articles indexed`),s}writeCatalog(e,t){let s=["person","project","place","concept","event","decision","pattern","untyped"],r={person:"## People",project:"## Projects",place:"## Places",concept:"## Concepts",event:"## Events",decision:"## Decisions",pattern:"## Patterns",untyped:"## Untyped (needs migration)"},n=new Map;for(let i of e){let o=i.type||"untyped",c=n.get(o)||[];c.push(i),n.set(o,c)}let a=["# Wiki Content Catalog","",`_Last rebuilt: ${t}_`,"","Articles grouped by type. Agentic query walks this file first to pick candidates.",""];for(let i of s){let o=n.get(i);if(!(!o||o.length===0)){a.push(r[i]||`## ${i}`,"");for(let c of o.sort((l,v)=>l.title.localeCompare(v.title))){let l=c.access==="private"?" (private)":c.access==="shared"?" (shared)":"",v=c.related?.length?` \u2192 [[${c.related.slice(0,3).join("]], [[")}]]${c.related.length>3?", \u2026":""}`:"";a.push(`- [${c.title}](${c.path})${l}${v}`)}a.push("")}}x(w(this.baseDir,"_index.md"),a.join(`
|
|
14
|
-
`))}stats(){let e=0,t={},s={},r={};this.walkDir(this.baseDir,a=>{if(!a.endsWith(".md"))return;let i=S(this.baseDir,a);if(i.startsWith("raw/")||i.startsWith("_")||i==="WIKI.md")return;let o=this.readArticle(i);if(o){e++;for(let c of o.meta.tags||[])t[c]=(t[c]||0)+1;s[o.meta.access]=(s[o.meta.access]||0)+1,r[o.meta.owner]=(r[o.meta.owner]||0)+1}});let n=$(this.rawDir)?E(this.rawDir).filter(a=>a.endsWith(".md")).length:0;return{totalArticles:e,totalEntries:n,articlesByType:t,articlesByAccess:s,articlesByOwner:r}}appendLog(e,t){let s=w(this.baseDir,"log.md"),n=`## [${new Date().toISOString().replace("T"," ").slice(0,16)}] ${e} | ${t}
|
|
15
|
-
|
|
16
|
-
`;$(s)||x(s,`# Wiki Log
|
|
17
|
-
|
|
18
|
-
Chronological record of all wiki operations.
|
|
19
|
-
|
|
20
|
-
`),we(s,n)}getLog(e=20){let t=w(this.baseDir,"log.md");return $(t)?N(t,"utf-8").split(/^## /m).filter(n=>n.startsWith("[")).slice(-e).map(n=>n.trim()):[]}ensureSchema(){let e=w(this.baseDir,"_schema.md");if($(e))return;x(e,`# Wiki Schema
|
|
21
|
-
|
|
22
|
-
A personal wiki maintained by LLMs. Karpathy pattern: plain files, aggressive tagging,
|
|
23
|
-
structure emerges from data. The wiki is a compounding artifact.
|
|
24
|
-
|
|
25
|
-
## Structure
|
|
26
|
-
|
|
27
|
-
\`\`\`
|
|
28
|
-
wiki/
|
|
29
|
-
_schema.md # This file
|
|
30
|
-
worldview.md # YOUR mental model \u2014 the LLM reads this during absorb
|
|
31
|
-
raw/entries/ # Immutable raw sources (conversations, imports, anything)
|
|
32
|
-
[LLM-chosen dirs] # Structure emerges from data \u2014 the LLM picks paths
|
|
33
|
-
\`\`\`
|
|
34
|
-
|
|
35
|
-
The LLM decides how to organize articles. You describe YOUR world in worldview.md.
|
|
36
|
-
|
|
37
|
-
## Article Format
|
|
38
|
-
|
|
39
|
-
\`\`\`yaml
|
|
40
|
-
---
|
|
41
|
-
title: "Staging Deployment Process"
|
|
42
|
-
tags: ["deploy", "staging", "devops", "process", "2026-04-06"]
|
|
43
|
-
owner: devops-agent
|
|
44
|
-
access: public
|
|
45
|
-
created: 2026-04-06
|
|
46
|
-
last_updated: 2026-04-06
|
|
47
|
-
sources: ["entry-id-1", "entry-id-2"]
|
|
48
|
-
---
|
|
49
|
-
|
|
50
|
-
Article content with [[wikilinks]] and section tags.
|
|
51
|
-
|
|
52
|
-
## Deploy Steps
|
|
53
|
-
<!-- tags: process, runbook, staging -->
|
|
54
|
-
Content specific to this section...
|
|
55
|
-
\`\`\`
|
|
56
|
-
|
|
57
|
-
## Tags
|
|
58
|
-
|
|
59
|
-
Tags are the primary context-narrowing mechanism. The more tags, the better.
|
|
60
|
-
|
|
61
|
-
Tag aggressively:
|
|
62
|
-
- **Who**: people, agents, teams involved
|
|
63
|
-
- **What**: project, client, topic, technology
|
|
64
|
-
- **When**: dates, periods, milestones
|
|
65
|
-
- **Where**: server, environment, channel
|
|
66
|
-
- **How**: process, decision, pattern
|
|
67
|
-
- **Your terms**: whatever vocabulary makes sense in YOUR world
|
|
68
|
-
|
|
69
|
-
Section tags (\`<!-- tags: ... -->\`) let different parts of an article
|
|
70
|
-
match different queries. A deploy article might have sections tagged
|
|
71
|
-
"runbook" and "incident" separately.
|
|
72
|
-
|
|
73
|
-
## Operations
|
|
74
|
-
|
|
75
|
-
### Absorb
|
|
76
|
-
Read raw entries \u2192 read worldview.md \u2192 tag aggressively \u2192 create/update articles.
|
|
77
|
-
Also identify GAPS: "We mention X but have no article for it."
|
|
78
|
-
|
|
79
|
-
### Query
|
|
80
|
-
Match by tags first \u2192 then keyword within matched articles \u2192 synthesize.
|
|
81
|
-
If agent is working on a specific project, only send content tagged for that project.
|
|
82
|
-
|
|
83
|
-
### Lint
|
|
84
|
-
Check for: orphan articles, broken [[wikilinks]], untagged articles,
|
|
85
|
-
articles over 100 lines that should split, mentioned-but-missing topics.
|
|
86
|
-
|
|
87
|
-
## Worldview
|
|
88
|
-
|
|
89
|
-
Edit \`worldview.md\` to describe YOUR world. This is not a schema \u2014 it's your
|
|
90
|
-
mental model. The LLM reads it during absorb to understand where things go.
|
|
91
|
-
|
|
92
|
-
Example worldview.md:
|
|
93
|
-
\`\`\`
|
|
94
|
-
I'm the founder of Acme Corp.
|
|
95
|
-
We build software products.
|
|
96
|
-
Our agents: Marketing Bot, DevOps Bot, Coordinator.
|
|
97
|
-
Clients: ClientA (enterprise), ClientB (startup).
|
|
98
|
-
Infrastructure: local dev machine, cloud server.
|
|
99
|
-
We use GitLab for version control.
|
|
100
|
-
\`\`\`
|
|
101
|
-
`),this.log("Created _schema.md")}extractWikilinks(e){return(e.match(/\[\[([^\]]+)\]\]/g)||[]).map(s=>s.replace(/\[\[|\]\]/g,""))}buildBacklinks(){let e={};return this.walkDir(this.baseDir,t=>{if(!t.endsWith(".md"))return;let s=S(this.baseDir,t);if(s.startsWith("raw/")||s.startsWith("_")||s==="WIKI.md"||s==="log.md")return;let r=N(t,"utf-8"),n=this.extractWikilinks(r);for(let a of n)e[a]||(e[a]=[]),e[a].push(s)}),x(w(this.baseDir,"_backlinks.json"),JSON.stringify(e,null,2)),e}getBacklinks(e){let t=w(this.baseDir,"_backlinks.json");if(!$(t))return[];try{return JSON.parse(N(t,"utf-8"))[e]||[]}catch{return[]}}findByTags(e,t,s=10){let r=e.map(a=>a.toLowerCase()),n=[];return this.walkDir(this.baseDir,a=>{if(!a.endsWith(".md"))return;let i=S(this.baseDir,a);if(i.startsWith("raw/")||i.startsWith("_"))return;let o=this.readArticle(i);if(!o||t&&!this.canRead(o.meta,t))return;let c=(o.meta.tags||[]).map(u=>u.toLowerCase()),l=(o.content.match(/<!--\s*tags?:\s*([^>]+)\s*-->/gi)||[]).flatMap(u=>u.replace(/<!--\s*tags?:\s*|\s*-->/gi,"").split(",").map(d=>d.trim().toLowerCase())),v=[...c,...l],p=r.filter(u=>v.includes(u)).length;p>0&&n.push({article:o,score:p})}),n.sort((a,i)=>i.score-a.score).slice(0,s).map(a=>a.article)}getAllTags(){let e=new Map;return this.walkDir(this.baseDir,t=>{if(!t.endsWith(".md"))return;let s=S(this.baseDir,t);if(s.startsWith("raw/")||s.startsWith("_"))return;let r=this.readArticle(s);if(r?.meta.tags)for(let n of r.meta.tags)e.set(n,(e.get(n)||0)+1)}),e}getWorldview(){let e=w(this.baseDir,"worldview.md");return $(e)?N(e,"utf-8"):null}setWorldview(e){x(w(this.baseDir,"worldview.md"),e),this.appendLog("worldview","Updated worldview")}lint(){let e=[],t=new Set,s=new Map,r=new Map;this.walkDir(this.baseDir,a=>{if(!a.endsWith(".md"))return;let i=S(this.baseDir,a);if(i.startsWith("raw/")||i.startsWith("_")||i==="WIKI.md"||i==="log.md")return;let o=this.readArticle(i);if(!o)return;t.add(o.meta.title),r.set(o.meta.title,i);let c=this.extractWikilinks(o.content);s.set(i,c);let l=o.content.split(`
|
|
102
|
-
`).length;l>100&&e.push({type:"bloated",article:i,message:`${l} lines \u2014 consider splitting`}),o.meta.sources?.length||e.push({type:"unsourced",article:i,message:"No sources listed in frontmatter"}),l<10&&o.content.trim().length<100&&e.push({type:"stub",article:i,message:"Very short article \u2014 needs enrichment"})});for(let[a,i]of s)for(let o of i)t.has(o)||e.push({type:"broken-link",article:a,message:`[[${o}]] \u2014 target article not found`});let n=this.buildBacklinks();for(let[a,i]of r)(!n[a]||n[a].length===0)&&e.push({type:"orphan",article:i,message:`No other articles link to "${a}"`});return this.appendLog("lint",`Found ${e.length} issues`),e}getUnabsorbedEntries(){let e=new Set;return this.walkDir(this.baseDir,s=>{if(!s.endsWith(".md"))return;let r=S(this.baseDir,s);if(r.startsWith("raw/")||r.startsWith("_"))return;let n=this.readArticle(r);if(n?.meta.sources)for(let a of n.meta.sources)e.add(a)}),this.listEntries().filter(s=>!e.has(s.id))}buildAbsorbPrompt(e=20){let t=this.getUnabsorbedEntries().slice(0,e);if(t.length===0)return null;let s=t.map(r=>`[${r.date} ${r.agentId} via ${r.source}] ${r.content.slice(0,200)}`).join(`
|
|
103
|
-
|
|
104
|
-
`);return`/wiki absorb
|
|
105
|
-
|
|
106
|
-
There are ${t.length} unprocessed entries. Read each, understand what it means, and create or update wiki articles.
|
|
107
|
-
|
|
108
|
-
${s}`}walkDir(e,t){if($(e))for(let s of E(e)){let r=be(e,s),n=ye(r);n.isDirectory()?this.walkDir(r,t):t(r,n)}}};export{A as a,J as b,H as c,q as d,le as e};
|
|
109
|
-
//# sourceMappingURL=chunk-535MLOSB.js.map
|