agentix-cli 0.126.2 → 0.128.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.
Files changed (152) hide show
  1. package/dist/{App-BUYK4EGC.js → App-BOLQUKCN.js} +2 -2
  2. package/dist/{ChatApp-ZS6EPDDK.js → ChatApp-72HXQV24.js} +2 -2
  3. package/dist/absorb-eval-O3HA6XA5.js +2 -0
  4. package/dist/{agent-WJTYM5HR.js → agent-S2DXXALS.js} +2 -2
  5. package/dist/{board-dashboard-DQR2OSV7.js → board-dashboard-ZKXXK5CG.js} +303 -228
  6. package/dist/board-dashboard-ZKXXK5CG.js.map +1 -0
  7. package/dist/chunk-2SV4RKRW.js +128 -0
  8. package/dist/chunk-2SV4RKRW.js.map +1 -0
  9. package/dist/{chunk-WUDVBPQV.js → chunk-4V7SWL2S.js} +2 -2
  10. package/dist/chunk-52SIHG45.js +4 -0
  11. package/dist/chunk-52SIHG45.js.map +1 -0
  12. package/dist/chunk-5DAEJF5S.js +36 -0
  13. package/dist/chunk-5DAEJF5S.js.map +1 -0
  14. package/dist/{chunk-GUQDPA6R.js → chunk-6GGGXCOY.js} +2 -2
  15. package/dist/{chunk-JIXNSA67.js → chunk-6KIUVVKX.js} +2 -2
  16. package/dist/{chunk-O4XEQTEN.js → chunk-C5MTLW7O.js} +3 -3
  17. package/dist/chunk-C5MTLW7O.js.map +1 -0
  18. package/dist/{chunk-FHBPKMCF.js → chunk-D2WX3BET.js} +2 -2
  19. package/dist/chunk-DN3RLR5Z.js +17 -0
  20. package/dist/chunk-DN3RLR5Z.js.map +1 -0
  21. package/dist/{chunk-Z7XXUYBB.js → chunk-DQ2LNQ2D.js} +33 -35
  22. package/dist/chunk-DQ2LNQ2D.js.map +1 -0
  23. package/dist/{chunk-UUVFH7BO.js → chunk-EJT4MA3J.js} +102 -102
  24. package/dist/chunk-EJT4MA3J.js.map +1 -0
  25. package/dist/chunk-FSW4FUMW.js +55 -0
  26. package/dist/chunk-FSW4FUMW.js.map +1 -0
  27. package/dist/chunk-FXBMFGOV.js +6 -0
  28. package/dist/chunk-FXBMFGOV.js.map +1 -0
  29. package/dist/{chunk-WMTGAVPW.js → chunk-HKW56YZK.js} +2 -2
  30. package/dist/{chunk-VXKNB4AW.js → chunk-LDS4SZBU.js} +2 -2
  31. package/dist/chunk-MRYA4J5F.js +54 -0
  32. package/dist/chunk-MRYA4J5F.js.map +1 -0
  33. package/dist/{chunk-LVV7JBHM.js → chunk-O2BS6N3T.js} +2 -2
  34. package/dist/{chunk-ZQWWMAMJ.js → chunk-P4XGM7ZM.js} +2 -2
  35. package/dist/{chunk-D6SWAB5J.js → chunk-QACEFESP.js} +32 -32
  36. package/dist/chunk-QACEFESP.js.map +1 -0
  37. package/dist/{chunk-6GLJIA25.js → chunk-QFZU5CEO.js} +2 -2
  38. package/dist/{chunk-FVG2BADS.js → chunk-QQFURUMS.js} +2 -2
  39. package/dist/chunk-QUXMLLX5.js +2 -0
  40. package/dist/chunk-QUXMLLX5.js.map +1 -0
  41. package/dist/{chunk-CY6ABHF2.js → chunk-TG6CT54D.js} +2 -2
  42. package/dist/chunk-TPNTFCSQ.js +4 -0
  43. package/dist/chunk-TPNTFCSQ.js.map +1 -0
  44. package/dist/{chunk-56KNKUFF.js → chunk-VD7IO653.js} +3 -3
  45. package/dist/{chunk-56KNKUFF.js.map → chunk-VD7IO653.js.map} +1 -1
  46. package/dist/{chunk-JUIL2EW3.js → chunk-YWKLUQDC.js} +2 -2
  47. package/dist/chunk-Z3W7D5RR.js +4 -0
  48. package/dist/chunk-Z3W7D5RR.js.map +1 -0
  49. package/dist/{chunk-QQYXYJOG.js → chunk-ZLC4TSXF.js} +2 -2
  50. package/dist/cli.js +1 -1
  51. package/dist/{client-PO5LDFS4.js → client-VBV7Q43P.js} +2 -2
  52. package/dist/config-52C3DJD2.js +2 -0
  53. package/dist/config-mutate-DKQESY6F.js +2 -0
  54. package/dist/config-mutator-BF4D4QGN.js +2 -0
  55. package/dist/contributions-5OEZWYXI.js +57 -0
  56. package/dist/contributions-5OEZWYXI.js.map +1 -0
  57. package/dist/doctor-VLRC4HW2.js +2 -0
  58. package/dist/{follow-up-tool-AIOLNUF7.js → follow-up-tool-235LDEMP.js} +2 -2
  59. package/dist/{follow-up-tool-AIOLNUF7.js.map → follow-up-tool-235LDEMP.js.map} +1 -1
  60. package/dist/hub-5QK7KYTZ.js +2 -0
  61. package/dist/index.d.ts +339 -50
  62. package/dist/index.js +1 -1
  63. package/dist/index.js.map +1 -1
  64. package/dist/notes-YLTNRMB5.js +2 -0
  65. package/dist/notes-settings-X63D5HPM.js +2 -0
  66. package/dist/{program-LGCT7FFJ.js → program-MVD57PKP.js} +236 -232
  67. package/dist/program-MVD57PKP.js.map +1 -0
  68. package/dist/{promote-MQYJMGGZ.js → promote-UPPQ4BQE.js} +2 -2
  69. package/dist/query-XQS5JN6E.js +2 -0
  70. package/dist/registry-MOMTLJ6R.js +2 -0
  71. package/dist/{request-planner-XYHM26CO.js → request-planner-QGZJEAKY.js} +2 -2
  72. package/dist/{review-candidates-XRBAMRBH.js → review-candidates-PAKF2JQF.js} +2 -2
  73. package/dist/{rotation-memo-6UW6DTBQ.js → rotation-memo-7VLREGS6.js} +2 -2
  74. package/dist/routing-JG3EV4O4.js +2 -0
  75. package/dist/schedule-tool-O7ZZ2A7X.js +2 -0
  76. package/dist/scheduler-LMPBAA34.js +2 -0
  77. package/dist/scheduler-LMPBAA34.js.map +1 -0
  78. package/dist/score-KDNIUTNV.js +3 -0
  79. package/dist/score-KDNIUTNV.js.map +1 -0
  80. package/dist/{seat-LKBZ6SDS.js → seat-JN3IVZ3G.js} +2 -2
  81. package/dist/seat-JN3IVZ3G.js.map +1 -0
  82. package/dist/{select-BSC3TFMZ.js → select-ZMMRFMNO.js} +2 -2
  83. package/dist/{set-enabled-YWXWSKME.js → set-enabled-7Y3TW6Z4.js} +2 -2
  84. package/dist/{tool-FZEC5FQX.js → tool-OCYXCDOK.js} +2 -2
  85. package/dist/{tool-FZEC5FQX.js.map → tool-OCYXCDOK.js.map} +1 -1
  86. package/dist/{tool-5JTCSRTW.js → tool-S7QI6HRA.js} +2 -2
  87. package/dist/{tool-5JTCSRTW.js.map → tool-S7QI6HRA.js.map} +1 -1
  88. package/dist/wiki-OCLFFZG6.js +2 -0
  89. package/dist/wiki-OCLFFZG6.js.map +1 -0
  90. package/package.json +1 -1
  91. package/dist/absorb-eval-5Y5IZWW2.js +0 -2
  92. package/dist/board-dashboard-DQR2OSV7.js.map +0 -1
  93. package/dist/chunk-2C3X6DVD.js +0 -49
  94. package/dist/chunk-2C3X6DVD.js.map +0 -1
  95. package/dist/chunk-2W3X6H7Z.js +0 -51
  96. package/dist/chunk-2W3X6H7Z.js.map +0 -1
  97. package/dist/chunk-46JKX6CT.js +0 -54
  98. package/dist/chunk-46JKX6CT.js.map +0 -1
  99. package/dist/chunk-5DFUUYEA.js +0 -126
  100. package/dist/chunk-5DFUUYEA.js.map +0 -1
  101. package/dist/chunk-D6SWAB5J.js.map +0 -1
  102. package/dist/chunk-O4XEQTEN.js.map +0 -1
  103. package/dist/chunk-UUVFH7BO.js.map +0 -1
  104. package/dist/chunk-YNA5T43U.js +0 -4
  105. package/dist/chunk-YNA5T43U.js.map +0 -1
  106. package/dist/chunk-Z7XXUYBB.js.map +0 -1
  107. package/dist/config-L2RQ6EJX.js +0 -2
  108. package/dist/config-mutator-44OAOZXM.js +0 -2
  109. package/dist/doctor-AU5TCOSG.js +0 -2
  110. package/dist/hub-53YQQCVA.js +0 -2
  111. package/dist/program-LGCT7FFJ.js.map +0 -1
  112. package/dist/query-DNJONEKC.js +0 -2
  113. package/dist/registry-5A3SLBVJ.js +0 -2
  114. package/dist/routing-OMIWZKNC.js +0 -2
  115. package/dist/schedule-tool-YRANRFHO.js +0 -2
  116. package/dist/scheduler-L4P4Z55R.js +0 -2
  117. package/dist/wiki-BT3H2WCD.js +0 -2
  118. /package/dist/{App-BUYK4EGC.js.map → App-BOLQUKCN.js.map} +0 -0
  119. /package/dist/{ChatApp-ZS6EPDDK.js.map → ChatApp-72HXQV24.js.map} +0 -0
  120. /package/dist/{absorb-eval-5Y5IZWW2.js.map → absorb-eval-O3HA6XA5.js.map} +0 -0
  121. /package/dist/{agent-WJTYM5HR.js.map → agent-S2DXXALS.js.map} +0 -0
  122. /package/dist/{chunk-WUDVBPQV.js.map → chunk-4V7SWL2S.js.map} +0 -0
  123. /package/dist/{chunk-GUQDPA6R.js.map → chunk-6GGGXCOY.js.map} +0 -0
  124. /package/dist/{chunk-JIXNSA67.js.map → chunk-6KIUVVKX.js.map} +0 -0
  125. /package/dist/{chunk-FHBPKMCF.js.map → chunk-D2WX3BET.js.map} +0 -0
  126. /package/dist/{chunk-WMTGAVPW.js.map → chunk-HKW56YZK.js.map} +0 -0
  127. /package/dist/{chunk-VXKNB4AW.js.map → chunk-LDS4SZBU.js.map} +0 -0
  128. /package/dist/{chunk-LVV7JBHM.js.map → chunk-O2BS6N3T.js.map} +0 -0
  129. /package/dist/{chunk-ZQWWMAMJ.js.map → chunk-P4XGM7ZM.js.map} +0 -0
  130. /package/dist/{chunk-6GLJIA25.js.map → chunk-QFZU5CEO.js.map} +0 -0
  131. /package/dist/{chunk-FVG2BADS.js.map → chunk-QQFURUMS.js.map} +0 -0
  132. /package/dist/{chunk-CY6ABHF2.js.map → chunk-TG6CT54D.js.map} +0 -0
  133. /package/dist/{chunk-JUIL2EW3.js.map → chunk-YWKLUQDC.js.map} +0 -0
  134. /package/dist/{chunk-QQYXYJOG.js.map → chunk-ZLC4TSXF.js.map} +0 -0
  135. /package/dist/{client-PO5LDFS4.js.map → client-VBV7Q43P.js.map} +0 -0
  136. /package/dist/{config-L2RQ6EJX.js.map → config-52C3DJD2.js.map} +0 -0
  137. /package/dist/{config-mutator-44OAOZXM.js.map → config-mutate-DKQESY6F.js.map} +0 -0
  138. /package/dist/{doctor-AU5TCOSG.js.map → config-mutator-BF4D4QGN.js.map} +0 -0
  139. /package/dist/{hub-53YQQCVA.js.map → doctor-VLRC4HW2.js.map} +0 -0
  140. /package/dist/{promote-MQYJMGGZ.js.map → hub-5QK7KYTZ.js.map} +0 -0
  141. /package/dist/{query-DNJONEKC.js.map → notes-YLTNRMB5.js.map} +0 -0
  142. /package/dist/{registry-5A3SLBVJ.js.map → notes-settings-X63D5HPM.js.map} +0 -0
  143. /package/dist/{routing-OMIWZKNC.js.map → promote-UPPQ4BQE.js.map} +0 -0
  144. /package/dist/{schedule-tool-YRANRFHO.js.map → query-XQS5JN6E.js.map} +0 -0
  145. /package/dist/{scheduler-L4P4Z55R.js.map → registry-MOMTLJ6R.js.map} +0 -0
  146. /package/dist/{request-planner-XYHM26CO.js.map → request-planner-QGZJEAKY.js.map} +0 -0
  147. /package/dist/{review-candidates-XRBAMRBH.js.map → review-candidates-PAKF2JQF.js.map} +0 -0
  148. /package/dist/{rotation-memo-6UW6DTBQ.js.map → rotation-memo-7VLREGS6.js.map} +0 -0
  149. /package/dist/{seat-LKBZ6SDS.js.map → routing-JG3EV4O4.js.map} +0 -0
  150. /package/dist/{wiki-BT3H2WCD.js.map → schedule-tool-O7ZZ2A7X.js.map} +0 -0
  151. /package/dist/{select-BSC3TFMZ.js.map → select-ZMMRFMNO.js.map} +0 -0
  152. /package/dist/{set-enabled-YWXWSKME.js.map → set-enabled-7Y3TW6Z4.js.map} +0 -0
@@ -1,5 +1,5 @@
1
- import{oa as m,ra as b}from"./chunk-46JKX6CT.js";b();function w(t){let e=typeof t.node=="string"?t.node:"",n=typeof t.token=="string"?t.token:"";if(!e||!n)try{let o=m(t.config);e||(e=o.dashboard?.daemonUrl||""),n||(n=o.dashboard?.token||"")}catch{}return e||(e="http://localhost:18800"),{baseUrl:e.replace(/\/+$/,""),token:n}}async function d(t,e,n){let o={Accept:"application/json"};t.token&&(o.Authorization=`Bearer ${t.token}`);let r=await fetch(`${t.baseUrl}${e}`,{headers:o,signal:n});if(!r.ok)throw new Error(`GET ${e} \u2192 HTTP ${r.status}`);return await r.json()}function R(t,e){return d(t,"/agents",e)}async function S(t,e){return(await d(t,"/api/processes",e)).processes??[]}function P(t,e){return d(t,"/crons",e)}async function h(t,e,n,o){let r={Accept:"application/json","Content-Type":"application/json"};t.token&&(r.Authorization=`Bearer ${t.token}`);let s=await fetch(`${t.baseUrl}${e}`,{method:"POST",headers:r,body:JSON.stringify(n),signal:o}),a=await s.text(),i;try{i=a?JSON.parse(a):{}}catch{i={raw:a}}if(!s.ok)throw new Error(i?.error||`POST ${e} \u2192 HTTP ${s.status}`);return i}function A(t,e,n="tui"){return h(t,"/api/processes/kill",{...e,reason:n})}function C(t,e,n,o){return h(t,"/task",{agent:e,message:n,context:o??{channel:"tui",chatId:"tui:operator"}})}async function $(t,e,n,o={}){let r={Accept:"text/event-stream","Content-Type":"application/json"};t.token&&(r.Authorization=`Bearer ${t.token}`);let s=await fetch(`${t.baseUrl}/task`,{method:"POST",headers:r,body:JSON.stringify({agent:e,message:n,stream:!0,context:{channel:o.channel??"chat-cli",chatId:o.chatId??"chat-cli:operator"}}),signal:o.signal});if(!s.ok||!s.body){let g=await s.text().catch(()=>"");throw new Error(`POST /task (stream) \u2192 HTTP ${s.status}${g?`: ${g.slice(0,200)}`:""}`)}let a=s.body.getReader(),i=new TextDecoder,u={content:""},c="";try{for(;;){let{done:g,value:p}=await a.read();if(g)break;c+=i.decode(p,{stream:!0});let l;for(;(l=c.indexOf(`
1
+ import{oa as m,ua as b}from"./chunk-MRYA4J5F.js";b();function w(t){let e=typeof t.node=="string"?t.node:"",n=typeof t.token=="string"?t.token:"";if(!e||!n)try{let o=m(t.config);e||(e=o.dashboard?.daemonUrl||""),n||(n=o.dashboard?.token||"")}catch{}return e||(e="http://localhost:18800"),{baseUrl:e.replace(/\/+$/,""),token:n}}async function d(t,e,n){let o={Accept:"application/json"};t.token&&(o.Authorization=`Bearer ${t.token}`);let r=await fetch(`${t.baseUrl}${e}`,{headers:o,signal:n});if(!r.ok)throw new Error(`GET ${e} \u2192 HTTP ${r.status}`);return await r.json()}function R(t,e){return d(t,"/agents",e)}async function S(t,e){return(await d(t,"/api/processes",e)).processes??[]}function P(t,e){return d(t,"/crons",e)}async function h(t,e,n,o){let r={Accept:"application/json","Content-Type":"application/json"};t.token&&(r.Authorization=`Bearer ${t.token}`);let s=await fetch(`${t.baseUrl}${e}`,{method:"POST",headers:r,body:JSON.stringify(n),signal:o}),a=await s.text(),i;try{i=a?JSON.parse(a):{}}catch{i={raw:a}}if(!s.ok)throw new Error(i?.error||`POST ${e} \u2192 HTTP ${s.status}`);return i}function A(t,e,n="tui"){return h(t,"/api/processes/kill",{...e,reason:n})}function C(t,e,n,o){return h(t,"/task",{agent:e,message:n,context:o??{channel:"tui",chatId:"tui:operator"}})}async function $(t,e,n,o={}){let r={Accept:"text/event-stream","Content-Type":"application/json"};t.token&&(r.Authorization=`Bearer ${t.token}`);let s=await fetch(`${t.baseUrl}/task`,{method:"POST",headers:r,body:JSON.stringify({agent:e,message:n,stream:!0,context:{channel:o.channel??"chat-cli",chatId:o.chatId??"chat-cli:operator"}}),signal:o.signal});if(!s.ok||!s.body){let g=await s.text().catch(()=>"");throw new Error(`POST /task (stream) \u2192 HTTP ${s.status}${g?`: ${g.slice(0,200)}`:""}`)}let a=s.body.getReader(),i=new TextDecoder,u={content:""},c="";try{for(;;){let{done:g,value:p}=await a.read();if(g)break;c+=i.decode(p,{stream:!0});let l;for(;(l=c.indexOf(`
2
2
 
3
3
  `))>=0;){let k=c.slice(0,l);c=c.slice(l+2);let f=x(k);f&&T(f,o,u)}}}finally{try{a.releaseLock()}catch{}}return u}function T(t,e,n){let{event:o,data:r}=t;switch(o){case"text":r?.text&&(n.content+=r.text,e.onText?.(r.text));break;case"thinking":r?.text&&e.onThinking?.(r.text);break;case"tool":e.onTool?.(r);break;case"done":typeof r?.content=="string"&&(n.content=r.content),n.usage=r?.usage,n.duration=r?.duration;break;case"error":n.error=r?.error,n.errorKind=r?.errorKind;break}}function x(t){let e="message",n="";for(let r of t.split(`
4
4
  `))r.startsWith("event: ")?e=r.slice(7).trim():r.startsWith("data: ")&&(n=r.slice(6));if(!n)return null;let o;try{o=JSON.parse(n)}catch{o=n}return{event:e,data:o}}export{w as a,R as b,S as c,P as d,A as e,C as f,$ as g};
5
- //# sourceMappingURL=chunk-FHBPKMCF.js.map
5
+ //# sourceMappingURL=chunk-D2WX3BET.js.map
@@ -0,0 +1,17 @@
1
+ import{b as g}from"./chunk-FSW4FUMW.js";async function $(e,i,r,n,o={}){let a=o.retrieve??g,c=o.perEntry??2,s=o.maxArticles??8,f=o.queryChars??1500,h=new Map;for(let t of e){let l=[];try{l=await a(t.content.slice(0,f),i,r,{pool:n,maxCandidates:c,maxHops:1,maxArticles:c*2,stage:"absorb-covering"})}catch{}for(let u of l){let p=h.get(u.path);p?(p.hop=Math.min(p.hop,u.hop),p.entries.includes(t.id)||p.entries.push(t.id)):h.set(u.path,{...u,entries:[t.id]})}}return[...h.values()].sort((t,l)=>t.hop-l.hop||l.entries.length-t.entries.length||t.path.localeCompare(l.path)).slice(0,s)}function x(e){if(e.length===0)return"";let i=e.map(r=>{let n=`### ${r.meta.title} \u2014 ${r.meta.type||"untyped"} (${r.path})`,o=`Found for entries: ${r.entries.join(", ")}${r.hop>0?" (linked from a match)":""}`,a=r.meta.related?.length?`Related: ${r.meta.related.join(", ")}`:"";return[n,o,a,"",r.content].filter(c=>c!=="").join(`
2
+ `)}).join(`
3
+
4
+ ---
5
+
6
+ `);return`
7
+ ## Articles already covering these entries
8
+
9
+ These ${e.length} articles were found by searching the wiki for each entry below. Read them before you write.
10
+
11
+ - When an entry is about the subject of one of these articles, UPDATE that article: write it at the SAME path with the SAME title, carrying its full content merged with what the entry adds.
12
+ - Keep every fact the article already has: commit hashes, URLs, numbers, dates and [[wikilinks]]. Restructure freely, but do not drop one unless an entry explicitly says it is wrong. A save that drops one is refused and the entries stay queued.
13
+ - Do not create a second article (a new path or a near-identical title) for a subject one of these already covers.
14
+
15
+ ${i}
16
+ `}var d=/\bhttps?:\/\/[^\s<>"'`)\]]+/gi,y=/\[\[([^\]|]+)(?:\|[^\]]*)?\]\]/g,w=/(?<![\w-])(?=[0-9a-f]*[0-9])(?=[0-9a-f]*[a-f])[0-9a-f]{7,40}(?![\w-])/gi,k=/(?<![\w.,:/-])\d+(?:[.,:\-/]\d+)*(?![\w])/g,C=/^\s*\d+[.)]\s/gm;function A(e){let i=[...e.matchAll(d)].map(s=>s[0].replace(/[.,;:!?'"]+$/,"")),r=[...e.matchAll(y)].map(s=>s[1].trim()),n=e.replace(d," ").replace(y," ").replace(C," "),o=[...n.matchAll(w)].map(s=>s[0].toLowerCase()),c=[...n.replace(w," ").matchAll(k)].map(s=>v(s[0]));return{commits:m(o),urls:m(i),wikilinks:m(r),numbers:m(c)}}function R(e,i){let r=A(e),n=A(i),o=i.toLowerCase(),a=[];for(let t of r.commits)!o.includes(t)&&!n.commits.some(l=>l.startsWith(t)||t.startsWith(l))&&a.push(`commit ${t}`);let c=t=>t.toLowerCase().replace(/\/+$/,""),s=new Set(n.urls.map(c));for(let t of r.urls)s.has(c(t))||a.push(`link ${t}`);let f=new Set(n.wikilinks.map(t=>t.toLowerCase()));for(let t of r.wikilinks)f.has(t.toLowerCase())||a.push(`link [[${t}]]`);let h=new Set(n.numbers);for(let t of r.numbers)h.has(t)||a.push(`number ${t}`);return a}function v(e){return/^\d{1,3}(,\d{3})+$/.test(e)?e.replace(/,/g,""):e}function m(e){return[...new Set(e)]}function L(e,i){if(i.some(n=>n.path===e.path))return e.path;let r=b(e.title);return r?i.find(n=>b(n.title)===r)?.path??e.path:e.path}function b(e){return(e||"").toLowerCase().replace(/[^\p{L}\p{N}]+/gu," ").trim()}export{$ as a,x as b,A as c,R as d,L as e};
17
+ //# sourceMappingURL=chunk-DN3RLR5Z.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/wiki/absorb-context.ts"],"sourcesContent":["// What `agentx wiki absorb` knows about the wiki before it writes (#801).\n//\n// Absorb used to show the model the catalog — titles and paths — and\n// nothing else. In the 2026-10-07 A/B one model rewrote an existing event\n// article it had never read and lost the commit, the test count and the\n// review URL; the other wrote a second event article beside the first.\n// Both are what a writer does when it cannot see the page it is editing.\n//\n// So before the compile call, each entry is run through the wiki query\n// retrieval (BM25 shortlist, rerank seat, wikilink walk) and the articles\n// it lands on go into the prompt in full. After the call, a save that\n// would drop a commit, link or number from the article it replaces is\n// refused, and a new article whose title an existing one already has is\n// written over that one instead of beside it.\n\nimport { retrieveArticles, type CatalogEntry } from \"./query\"\nimport type { WikiArticle } from \"./types\"\nimport type { WikiStore } from \"./store\"\n\nexport type CoveringArticle = WikiArticle & { hop: number; entries: string[] }\n\nexport interface FindCoveringOptions {\n /** Articles picked per entry before the walk. Default 2. */\n perEntry?: number\n /** Cap on articles across the batch. Default 8. */\n maxArticles?: number\n /** Query text taken from each entry. Default 1500 chars. */\n queryChars?: number\n /** Swappable for tests. */\n retrieve?: typeof retrieveArticles\n}\n\n/**\n * The existing articles a batch of entries is about. Each entry is its own\n * query, so one batch mixing three subjects finds all three. Articles\n * picked directly (hop 0) and by more entries come first.\n */\nexport async function findCoveringArticles(\n entries: Array<{ id: string; content: string }>,\n store: WikiStore,\n agentId: string,\n pool: CatalogEntry[],\n opts: FindCoveringOptions = {},\n): Promise<CoveringArticle[]> {\n const retrieve = opts.retrieve ?? retrieveArticles\n const perEntry = opts.perEntry ?? 2\n const maxArticles = opts.maxArticles ?? 8\n const queryChars = opts.queryChars ?? 1500\n const found = new Map<string, CoveringArticle>()\n\n for (const entry of entries) {\n let hits: Array<WikiArticle & { hop: number }> = []\n try {\n hits = await retrieve(entry.content.slice(0, queryChars), store, agentId, {\n pool,\n maxCandidates: perEntry,\n maxHops: 1,\n maxArticles: perEntry * 2,\n stage: \"absorb-covering\",\n })\n } catch {\n // Retrieval is an aid; an absorb without it is the old absorb.\n }\n for (const hit of hits) {\n const seen = found.get(hit.path)\n if (seen) {\n seen.hop = Math.min(seen.hop, hit.hop)\n if (!seen.entries.includes(entry.id)) seen.entries.push(entry.id)\n } else {\n found.set(hit.path, { ...hit, entries: [entry.id] })\n }\n }\n }\n\n return [...found.values()]\n .sort((a, b) => a.hop - b.hop || b.entries.length - a.entries.length || a.path.localeCompare(b.path))\n .slice(0, maxArticles)\n}\n\n/** The prompt section carrying the covering articles, in full. Articles are\n * never cut short: the drop-guard checks the whole old article, so the\n * model must have seen all of it. */\nexport function renderCoveringBlock(articles: CoveringArticle[]): string {\n if (articles.length === 0) return \"\"\n const body = articles\n .map((a) => {\n const header = `### ${a.meta.title} — ${a.meta.type || \"untyped\"} (${a.path})`\n const why = `Found for entries: ${a.entries.join(\", \")}${a.hop > 0 ? \" (linked from a match)\" : \"\"}`\n const related = a.meta.related?.length ? `Related: ${a.meta.related.join(\", \")}` : \"\"\n return [header, why, related, \"\", a.content].filter((l) => l !== \"\").join(\"\\n\")\n })\n .join(\"\\n\\n---\\n\\n\")\n return `\n## Articles already covering these entries\n\nThese ${articles.length} articles were found by searching the wiki for each entry below. Read them before you write.\n\n- When an entry is about the subject of one of these articles, UPDATE that article: write it at the SAME path with the SAME title, carrying its full content merged with what the entry adds.\n- Keep every fact the article already has: commit hashes, URLs, numbers, dates and [[wikilinks]]. Restructure freely, but do not drop one unless an entry explicitly says it is wrong. A save that drops one is refused and the entries stay queued.\n- Do not create a second article (a new path or a near-identical title) for a subject one of these already covers.\n\n${body}\n`\n}\n\n// --- Drop-guard ---\n\nexport interface ArticleFacts {\n commits: string[]\n urls: string[]\n wikilinks: string[]\n numbers: string[]\n}\n\nconst URL_RE = /\\bhttps?:\\/\\/[^\\s<>\"'`)\\]]+/gi\nconst WIKILINK_RE = /\\[\\[([^\\]|]+)(?:\\|[^\\]]*)?\\]\\]/g\n// A short or full git hash: 7–40 hex chars holding at least one digit and\n// one letter, so words like \"defaced\" and plain numbers are not hashes.\nconst COMMIT_RE = /(?<![\\w-])(?=[0-9a-f]*[0-9])(?=[0-9a-f]*[a-f])[0-9a-f]{7,40}(?![\\w-])/gi\n// A number standing on its own: \"12\", \"1,234\", \"3.5\", \"2026-10-07\", \"14:30\",\n// \"v2\"-style suffixes excluded by the look-behind.\nconst NUMBER_RE = /(?<![\\w.,:/-])\\d+(?:[.,:\\-/]\\d+)*(?![\\w])/g\nconst LIST_MARKER_RE = /^\\s*\\d+[.)]\\s/gm\n\n/** The facts a rewrite must not lose, extracted from an article body. */\nexport function extractFacts(text: string): ArticleFacts {\n const urls = [...text.matchAll(URL_RE)].map((m) => m[0].replace(/[.,;:!?'\"]+$/, \"\"))\n const wikilinks = [...text.matchAll(WIKILINK_RE)].map((m) => m[1].trim())\n // Hashes and numbers are read with URLs and wikilink targets removed, so\n // a path segment or \"Release 2\" in a link is not counted twice.\n const rest = text.replace(URL_RE, \" \").replace(WIKILINK_RE, \" \").replace(LIST_MARKER_RE, \" \")\n const commits = [...rest.matchAll(COMMIT_RE)].map((m) => m[0].toLowerCase())\n const withoutCommits = rest.replace(COMMIT_RE, \" \")\n const numbers = [...withoutCommits.matchAll(NUMBER_RE)]\n .map((m) => normaliseNumber(m[0]))\n return {\n commits: unique(commits),\n urls: unique(urls),\n wikilinks: unique(wikilinks),\n numbers: unique(numbers),\n }\n}\n\n/**\n * The facts in `oldContent` that `newContent` no longer carries. Empty\n * means the rewrite is safe to save.\n *\n * A short hash is kept when the new text has it at any length; a URL or\n * wikilink is compared without case or trailing slash; a number is\n * compared as a token (thousands separators ignored), so \"12\" is not\n * found inside \"2012\".\n */\nexport function droppedFacts(oldContent: string, newContent: string): string[] {\n const before = extractFacts(oldContent)\n const after = extractFacts(newContent)\n const lowerNew = newContent.toLowerCase()\n const dropped: string[] = []\n\n for (const c of before.commits) {\n if (!lowerNew.includes(c) && !after.commits.some((n) => n.startsWith(c) || c.startsWith(n))) {\n dropped.push(`commit ${c}`)\n }\n }\n const urlKey = (u: string) => u.toLowerCase().replace(/\\/+$/, \"\")\n const newUrls = new Set(after.urls.map(urlKey))\n for (const u of before.urls) {\n if (!newUrls.has(urlKey(u))) dropped.push(`link ${u}`)\n }\n const newLinks = new Set(after.wikilinks.map((l) => l.toLowerCase()))\n for (const l of before.wikilinks) {\n if (!newLinks.has(l.toLowerCase())) dropped.push(`link [[${l}]]`)\n }\n const newNumbers = new Set(after.numbers)\n for (const n of before.numbers) {\n if (!newNumbers.has(n)) dropped.push(`number ${n}`)\n }\n return dropped\n}\n\nfunction normaliseNumber(n: string): string {\n // 1,234 → 1234; leave 3,5 (a decimal comma) and dates alone.\n return /^\\d{1,3}(,\\d{3})+$/.test(n) ? n.replace(/,/g, \"\") : n\n}\n\nfunction unique(list: string[]): string[] {\n return [...new Set(list)]\n}\n\n// --- Duplicate redirect ---\n\n/**\n * Where an absorbed article is written. A new path whose title an existing\n * article already carries is the same subject filed twice, so it goes to\n * the existing article — where the drop-guard then applies.\n */\nexport function absorbTargetPath(\n article: { path: string; title: string },\n catalog: Array<{ path: string; title: string }>,\n): string {\n if (catalog.some((a) => a.path === article.path)) return article.path\n const key = titleKey(article.title)\n if (!key) return article.path\n return catalog.find((a) => titleKey(a.title) === key)?.path ?? article.path\n}\n\nfunction titleKey(title: string): string {\n return (title || \"\").toLowerCase().replace(/[^\\p{L}\\p{N}]+/gu, \" \").trim()\n}\n"],"mappings":"wCAqCA,eAAsBA,EACpBC,EACAC,EACAC,EACAC,EACAC,EAA4B,CAAC,EACD,CAC5B,IAAMC,EAAWD,EAAK,UAAYE,EAC5BC,EAAWH,EAAK,UAAY,EAC5BI,EAAcJ,EAAK,aAAe,EAClCK,EAAaL,EAAK,YAAc,KAChCM,EAAQ,IAAI,IAElB,QAAWC,KAASX,EAAS,CAC3B,IAAIY,EAA6C,CAAC,EAClD,GAAI,CACFA,EAAO,MAAMP,EAASM,EAAM,QAAQ,MAAM,EAAGF,CAAU,EAAGR,EAAOC,EAAS,CACxE,KAAAC,EACA,cAAeI,EACf,QAAS,EACT,YAAaA,EAAW,EACxB,MAAO,iBACT,CAAC,CACH,MAAE,CAEF,CACA,QAAWM,KAAOD,EAAM,C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IAAIR,EAAM,UAAU,IAAKpB,GAAMA,EAAE,YAAY,CAAC,CAAC,EACpE,QAAWA,KAAKmB,EAAO,UAChBS,EAAS,IAAI5B,EAAE,YAAY,CAAC,GAAGsB,EAAQ,KAAK,UAAUtB,KAAK,EAElE,IAAM6B,EAAa,IAAI,IAAIT,EAAM,OAAO,EACxC,QAAWI,KAAKL,EAAO,QAChBU,EAAW,IAAIL,CAAC,GAAGF,EAAQ,KAAK,UAAUE,GAAG,EAEpD,OAAOF,CACT,CAEA,SAASR,EAAgBU,EAAmB,CAE1C,MAAO,qBAAqB,KAAKA,CAAC,EAAIA,EAAE,QAAQ,KAAM,EAAE,EAAIA,CAC9D,CAEA,SAAST,EAAOe,EAA0B,CACxC,MAAO,CAAC,GAAG,IAAI,IAAIA,CAAI,CAAC,CAC1B,CASO,SAASC,EACdC,EACAC,EACQ,CACR,GAAIA,EAAQ,KAAMzC,GAAMA,EAAE,OAASwC,EAAQ,IAAI,EAAG,OAAOA,EAAQ,KACjE,IAAME,EAAMC,EAASH,EAAQ,KAAK,EAClC,OAAKE,EACED,EAAQ,KAAMzC,GAAM2C,EAAS3C,EAAE,KAAK,IAAM0C,CAAG,GAAG,MAAQF,EAAQ,KADtDA,EAAQ,IAE3B,CAEA,SAASG,EAASC,EAAuB,CACvC,OAAQA,GAAS,IAAI,YAAY,EAAE,QAAQ,mBAAoB,GAAG,EAAE,KAAK,CAC3E","names":["findCoveringArticles","entries","store","agentId","pool","opts","retrieve","retrieveArticles","perEntry","maxArticles","queryChars","found","entry","hits","hit","seen","a","b","renderCoveringBlock","articles","body","header","why","related","l","URL_RE","WIKILINK_RE","COMMIT_RE","NUMBER_RE","LIST_MARKER_RE","extractFacts","text","urls","m","wikilinks","rest","commits","numbers","normaliseNumber","unique","droppedFacts","oldContent","newContent","before","after","lowerNew","dropped","c","n","urlKey","u","newUrls","newLinks","newNumbers","list","absorbTargetPath","article","catalog","key","titleKey","title"]}