agentix-cli 0.135.0 → 0.136.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{App-4UVAI5C5.js → App-D6W6IV2L.js} +2 -2
- package/dist/{ChatApp-COO67WIR.js → ChatApp-X7TNCFGW.js} +2 -2
- package/dist/{absorb-eval-WY3YMLS4.js → absorb-eval-COPVH2M2.js} +2 -2
- package/dist/{agent-3R5NY7I3.js → agent-VCGAUBER.js} +2 -2
- package/dist/{board-dashboard-U3ZSCO62.js → board-dashboard-JZM3FQNV.js} +4 -4
- package/dist/{board-dashboard-U3ZSCO62.js.map → board-dashboard-JZM3FQNV.js.map} +1 -1
- package/dist/chunk-4ZWZ42YE.js +5 -0
- package/dist/{chunk-KXR6GVL7.js.map → chunk-4ZWZ42YE.js.map} +1 -1
- package/dist/{chunk-DYGQF3MI.js → chunk-54OORW5I.js} +2 -2
- package/dist/chunk-54OORW5I.js.map +1 -0
- package/dist/{chunk-RVEMX5MJ.js → chunk-5J5USW2O.js} +2 -2
- package/dist/{chunk-3XVST5XX.js → chunk-5X37CXJF.js} +2 -2
- package/dist/{chunk-4XMALK7X.js → chunk-66DPMVUC.js} +2 -2
- package/dist/{chunk-SSQMFHSM.js → chunk-AK3XOA5N.js} +2 -2
- package/dist/chunk-AKWBDCMU.js +4 -0
- package/dist/chunk-AKWBDCMU.js.map +1 -0
- package/dist/{chunk-6WF56ME6.js → chunk-C43E3YFT.js} +2 -2
- package/dist/{chunk-LU7GDHGD.js → chunk-EVTTAM7S.js} +2 -2
- package/dist/{chunk-K445URSN.js → chunk-FQLSV2C4.js} +2 -2
- package/dist/{chunk-FWDRBUMS.js → chunk-GL3H7XMI.js} +2 -2
- package/dist/{chunk-ZGVVYJIK.js → chunk-H2N7DOPT.js} +2 -2
- package/dist/{chunk-BQIWMQNU.js → chunk-H4NSB54D.js} +2 -2
- package/dist/{chunk-XOUO4XNA.js → chunk-HEJTE7OC.js} +2 -2
- package/dist/{chunk-EEBK4F6E.js → chunk-HH7OFAEM.js} +2 -2
- package/dist/{chunk-QDWEM4DG.js → chunk-HZZW35FY.js} +2 -2
- package/dist/{chunk-RRGITX5B.js → chunk-IPMXIPTS.js} +2 -2
- package/dist/{chunk-MI7WOGH6.js → chunk-K75LFQE3.js} +2 -2
- package/dist/{chunk-ZFRXFUP7.js → chunk-KZXQD6ZK.js} +2 -2
- package/dist/{chunk-P3I7AATX.js → chunk-M5AHI2PZ.js} +2 -2
- package/dist/{chunk-5NT44FKL.js → chunk-M5B4QG6J.js} +2 -2
- package/dist/chunk-MTX4UPNB.js +3 -0
- package/dist/chunk-MTX4UPNB.js.map +1 -0
- package/dist/chunk-MWNCS57L.js +2 -0
- package/dist/chunk-MWNCS57L.js.map +1 -0
- package/dist/chunk-OISCRNMW.js +105 -0
- package/dist/chunk-OISCRNMW.js.map +1 -0
- package/dist/{chunk-ERULJ2ZL.js → chunk-OW5EXDVY.js} +2 -2
- package/dist/chunk-OWNQ2FD4.js +3 -0
- package/dist/chunk-OWNQ2FD4.js.map +1 -0
- package/dist/chunk-PE5V2LI7.js +2 -0
- package/dist/chunk-PE5V2LI7.js.map +1 -0
- package/dist/chunk-PV623BLN.js +55 -0
- package/dist/chunk-PV623BLN.js.map +1 -0
- package/dist/{chunk-L5UGH4T4.js → chunk-QCUJTAAZ.js} +6 -6
- package/dist/{chunk-GSKJ57XY.js → chunk-QTDKNJXD.js} +216 -216
- package/dist/chunk-QTDKNJXD.js.map +1 -0
- package/dist/{chunk-RGZARSHV.js → chunk-ROLSSYXE.js} +1 -1
- package/dist/{chunk-RGZARSHV.js.map → chunk-ROLSSYXE.js.map} +1 -1
- package/dist/{chunk-YA3P77LV.js → chunk-SKSYII3K.js} +2 -2
- package/dist/chunk-U6EJ53DA.js +16 -0
- package/dist/chunk-U6EJ53DA.js.map +1 -0
- package/dist/{chunk-WEPON4FP.js → chunk-UNIXYV3U.js} +2 -2
- package/dist/{chunk-SMAI7U6H.js → chunk-VA24JS2S.js} +2 -2
- package/dist/{chunk-LUYN6RAC.js → chunk-WRJFKA43.js} +2 -2
- package/dist/{chunk-H6VWU2HN.js → chunk-ZPJVDX2U.js} +2 -2
- package/dist/cli.js +1 -1
- package/dist/{client-NFPBE6L4.js → client-SMOWSRJY.js} +2 -2
- package/dist/{config-GHMRBRDL.js → config-OGUDWYAA.js} +2 -2
- package/dist/{config-mutate-2XV27EFV.js → config-mutate-BH27TMWK.js} +2 -2
- package/dist/config-mutator-Q62AS2TR.js +2 -0
- package/dist/{contributions-KLRJ4ZXV.js → contributions-H6T65TCY.js} +2 -2
- package/dist/{contributions-KLRJ4ZXV.js.map → contributions-H6T65TCY.js.map} +1 -1
- package/dist/{doctor-UBXVMGJG.js → doctor-ZOXHT7ZQ.js} +2 -2
- package/dist/enrich-R2LIDLPZ.js +2 -0
- package/dist/event-levels-WOYYEWSZ.js +3 -0
- package/dist/event-levels-WOYYEWSZ.js.map +1 -0
- package/dist/fact-proposals-X2O4W7VN.js +2 -0
- package/dist/{follow-up-tool-EARVITTS.js → follow-up-tool-GUBBXNEZ.js} +2 -2
- package/dist/{grants-HIFE6L5N.js → grants-CEUGZBQ4.js} +2 -2
- package/dist/hub-IIW2GBO5.js +2 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/ledger-P62U3FHT.js +2 -0
- package/dist/load-LQ2I2PQI.js +2 -0
- package/dist/model-call-J7JATTMW.js +2 -0
- package/dist/{program-U3HJY7E5.js → program-WROQ55F5.js} +233 -231
- package/dist/program-WROQ55F5.js.map +1 -0
- package/dist/promote-HDLU44MX.js +2 -0
- package/dist/push-bridge-325SXDGN.js +1 -1
- package/dist/query-6G27CBZQ.js +2 -0
- package/dist/query-runs-VXS572PQ.js +6 -0
- package/dist/query-runs-VXS572PQ.js.map +1 -0
- package/dist/{query-settings-2MGUS6AY.js → query-settings-G4M75LVQ.js} +3 -3
- package/dist/registry-3RE5SG22.js +2 -0
- package/dist/{request-planner-MFAIVLUQ.js → request-planner-T3VCZVVQ.js} +2 -2
- package/dist/{review-candidates-6WMDVVIZ.js → review-candidates-C3O3CENL.js} +2 -2
- package/dist/rotation-memo-store-Z4D5KRA6.js +2 -0
- package/dist/{rotation-memo-store-A4YW6FSK.js.map → rotation-memo-store-Z4D5KRA6.js.map} +1 -1
- package/dist/{routing-OPCLHIYW.js → routing-LD35TJM5.js} +2 -2
- package/dist/rules-HUUFXQD6.js +24 -0
- package/dist/rules-HUUFXQD6.js.map +1 -0
- package/dist/schedule-tool-46TVGEYU.js +2 -0
- package/dist/{scheduler-G3WWYETY.js → scheduler-I3QB4GI3.js} +2 -2
- package/dist/score-LNJ46A67.js +3 -0
- package/dist/score-LNJ46A67.js.map +1 -0
- package/dist/{seat-3HM4J7IX.js → seat-4Y3EW3KU.js} +2 -2
- package/dist/{select-VEFE2ESF.js → select-LZKN3FER.js} +2 -2
- package/dist/{set-enabled-US5BYKFZ.js → set-enabled-WSTOHJDE.js} +2 -2
- package/dist/{tool-HUSCHORN.js → tool-AKXO2EJU.js} +2 -2
- package/dist/tool-NLMIUOHR.js +4 -0
- package/dist/tool-NLMIUOHR.js.map +1 -0
- package/dist/types-YZX46RES.js +2 -0
- package/dist/wiki-ZS6OHOWQ.js +2 -0
- package/dist/wiki-enrich-NGPFWTVA.js +2 -0
- package/dist/wiki-enrich-NGPFWTVA.js.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-AKLZ4YO2.js +0 -4
- package/dist/chunk-AKLZ4YO2.js.map +0 -1
- package/dist/chunk-DYGQF3MI.js.map +0 -1
- package/dist/chunk-GSKJ57XY.js.map +0 -1
- package/dist/chunk-JRS5QRZG.js +0 -2
- package/dist/chunk-JRS5QRZG.js.map +0 -1
- package/dist/chunk-JTDUTCUE.js +0 -3
- package/dist/chunk-JTDUTCUE.js.map +0 -1
- package/dist/chunk-KA2UIZXG.js +0 -3
- package/dist/chunk-KA2UIZXG.js.map +0 -1
- package/dist/chunk-KXR6GVL7.js +0 -5
- package/dist/chunk-NY7NHGVT.js +0 -105
- package/dist/chunk-NY7NHGVT.js.map +0 -1
- package/dist/chunk-WWDYDLY2.js +0 -55
- package/dist/chunk-WWDYDLY2.js.map +0 -1
- package/dist/config-mutator-6ITNU5DT.js +0 -2
- package/dist/enrich-ZB5I7KHN.js +0 -16
- package/dist/enrich-ZB5I7KHN.js.map +0 -1
- package/dist/event-levels-CQWHSLMT.js +0 -3
- package/dist/event-levels-CQWHSLMT.js.map +0 -1
- package/dist/fact-proposals-LZWS5KFO.js +0 -2
- package/dist/hub-TILTOOSS.js +0 -2
- package/dist/ledger-CH7R756S.js +0 -2
- package/dist/load-EOZUZK7U.js +0 -2
- package/dist/model-call-PKV5UAQ7.js +0 -2
- package/dist/program-U3HJY7E5.js.map +0 -1
- package/dist/promote-RHVZB2QZ.js +0 -2
- package/dist/query-OZXZVLO7.js +0 -2
- package/dist/query-runs-7VX3YAC3.js +0 -4
- package/dist/query-runs-7VX3YAC3.js.map +0 -1
- package/dist/registry-LZLIPP7N.js +0 -2
- package/dist/rotation-memo-store-A4YW6FSK.js +0 -2
- package/dist/schedule-tool-KPVTMYL3.js +0 -2
- package/dist/score-DZGPLHCL.js +0 -3
- package/dist/score-DZGPLHCL.js.map +0 -1
- package/dist/tool-XLWLXGB5.js +0 -4
- package/dist/tool-XLWLXGB5.js.map +0 -1
- package/dist/types-LJZ2YY5W.js +0 -2
- package/dist/wiki-GCRRINW3.js +0 -2
- package/dist/wiki-enrich-P5TNWACZ.js +0 -2
- /package/dist/{App-4UVAI5C5.js.map → App-D6W6IV2L.js.map} +0 -0
- /package/dist/{ChatApp-COO67WIR.js.map → ChatApp-X7TNCFGW.js.map} +0 -0
- /package/dist/{absorb-eval-WY3YMLS4.js.map → absorb-eval-COPVH2M2.js.map} +0 -0
- /package/dist/{agent-3R5NY7I3.js.map → agent-VCGAUBER.js.map} +0 -0
- /package/dist/{chunk-RVEMX5MJ.js.map → chunk-5J5USW2O.js.map} +0 -0
- /package/dist/{chunk-3XVST5XX.js.map → chunk-5X37CXJF.js.map} +0 -0
- /package/dist/{chunk-4XMALK7X.js.map → chunk-66DPMVUC.js.map} +0 -0
- /package/dist/{chunk-SSQMFHSM.js.map → chunk-AK3XOA5N.js.map} +0 -0
- /package/dist/{chunk-6WF56ME6.js.map → chunk-C43E3YFT.js.map} +0 -0
- /package/dist/{chunk-LU7GDHGD.js.map → chunk-EVTTAM7S.js.map} +0 -0
- /package/dist/{chunk-K445URSN.js.map → chunk-FQLSV2C4.js.map} +0 -0
- /package/dist/{chunk-FWDRBUMS.js.map → chunk-GL3H7XMI.js.map} +0 -0
- /package/dist/{chunk-ZGVVYJIK.js.map → chunk-H2N7DOPT.js.map} +0 -0
- /package/dist/{chunk-BQIWMQNU.js.map → chunk-H4NSB54D.js.map} +0 -0
- /package/dist/{chunk-XOUO4XNA.js.map → chunk-HEJTE7OC.js.map} +0 -0
- /package/dist/{chunk-EEBK4F6E.js.map → chunk-HH7OFAEM.js.map} +0 -0
- /package/dist/{chunk-QDWEM4DG.js.map → chunk-HZZW35FY.js.map} +0 -0
- /package/dist/{chunk-RRGITX5B.js.map → chunk-IPMXIPTS.js.map} +0 -0
- /package/dist/{chunk-MI7WOGH6.js.map → chunk-K75LFQE3.js.map} +0 -0
- /package/dist/{chunk-ZFRXFUP7.js.map → chunk-KZXQD6ZK.js.map} +0 -0
- /package/dist/{chunk-P3I7AATX.js.map → chunk-M5AHI2PZ.js.map} +0 -0
- /package/dist/{chunk-5NT44FKL.js.map → chunk-M5B4QG6J.js.map} +0 -0
- /package/dist/{chunk-ERULJ2ZL.js.map → chunk-OW5EXDVY.js.map} +0 -0
- /package/dist/{chunk-L5UGH4T4.js.map → chunk-QCUJTAAZ.js.map} +0 -0
- /package/dist/{chunk-YA3P77LV.js.map → chunk-SKSYII3K.js.map} +0 -0
- /package/dist/{chunk-WEPON4FP.js.map → chunk-UNIXYV3U.js.map} +0 -0
- /package/dist/{chunk-SMAI7U6H.js.map → chunk-VA24JS2S.js.map} +0 -0
- /package/dist/{chunk-LUYN6RAC.js.map → chunk-WRJFKA43.js.map} +0 -0
- /package/dist/{chunk-H6VWU2HN.js.map → chunk-ZPJVDX2U.js.map} +0 -0
- /package/dist/{client-NFPBE6L4.js.map → client-SMOWSRJY.js.map} +0 -0
- /package/dist/{config-GHMRBRDL.js.map → config-OGUDWYAA.js.map} +0 -0
- /package/dist/{config-mutate-2XV27EFV.js.map → config-mutate-BH27TMWK.js.map} +0 -0
- /package/dist/{config-mutator-6ITNU5DT.js.map → config-mutator-Q62AS2TR.js.map} +0 -0
- /package/dist/{doctor-UBXVMGJG.js.map → doctor-ZOXHT7ZQ.js.map} +0 -0
- /package/dist/{fact-proposals-LZWS5KFO.js.map → enrich-R2LIDLPZ.js.map} +0 -0
- /package/dist/{grants-HIFE6L5N.js.map → fact-proposals-X2O4W7VN.js.map} +0 -0
- /package/dist/{follow-up-tool-EARVITTS.js.map → follow-up-tool-GUBBXNEZ.js.map} +0 -0
- /package/dist/{hub-TILTOOSS.js.map → grants-CEUGZBQ4.js.map} +0 -0
- /package/dist/{ledger-CH7R756S.js.map → hub-IIW2GBO5.js.map} +0 -0
- /package/dist/{load-EOZUZK7U.js.map → ledger-P62U3FHT.js.map} +0 -0
- /package/dist/{model-call-PKV5UAQ7.js.map → load-LQ2I2PQI.js.map} +0 -0
- /package/dist/{promote-RHVZB2QZ.js.map → model-call-J7JATTMW.js.map} +0 -0
- /package/dist/{query-OZXZVLO7.js.map → promote-HDLU44MX.js.map} +0 -0
- /package/dist/{registry-LZLIPP7N.js.map → query-6G27CBZQ.js.map} +0 -0
- /package/dist/{query-settings-2MGUS6AY.js.map → query-settings-G4M75LVQ.js.map} +0 -0
- /package/dist/{routing-OPCLHIYW.js.map → registry-3RE5SG22.js.map} +0 -0
- /package/dist/{request-planner-MFAIVLUQ.js.map → request-planner-T3VCZVVQ.js.map} +0 -0
- /package/dist/{review-candidates-6WMDVVIZ.js.map → review-candidates-C3O3CENL.js.map} +0 -0
- /package/dist/{schedule-tool-KPVTMYL3.js.map → routing-LD35TJM5.js.map} +0 -0
- /package/dist/{scheduler-G3WWYETY.js.map → schedule-tool-46TVGEYU.js.map} +0 -0
- /package/dist/{seat-3HM4J7IX.js.map → scheduler-I3QB4GI3.js.map} +0 -0
- /package/dist/{types-LJZ2YY5W.js.map → seat-4Y3EW3KU.js.map} +0 -0
- /package/dist/{select-VEFE2ESF.js.map → select-LZKN3FER.js.map} +0 -0
- /package/dist/{set-enabled-US5BYKFZ.js.map → set-enabled-WSTOHJDE.js.map} +0 -0
- /package/dist/{tool-HUSCHORN.js.map → tool-AKXO2EJU.js.map} +0 -0
- /package/dist/{wiki-GCRRINW3.js.map → types-YZX46RES.js.map} +0 -0
- /package/dist/{wiki-enrich-P5TNWACZ.js.map → wiki-ZS6OHOWQ.js.map} +0 -0
package/dist/chunk-JRS5QRZG.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{g as m}from"./chunk-6TURWSMN.js";import{spawn as f}from"child_process";var b=async(r,n,e)=>(await p(r,n,e)).text;function w(r){return async(n,e,c)=>{r.calls++;let{text:l,costUsd:t}=await p(n,e,c);return t===void 0?r.unpriced++:r.usd+=t,l}}async function p(r,n,e){let c=["-p","-","--output-format","json","--max-turns","1","--model",n,"--tools","","--strict-mcp-config","--mcp-config",'{"mcpServers":{}}',"--settings",'{"disableAllHooks":true}',"--setting-sources","","--no-session-persistence"],l=await new Promise((t,s)=>{let i=f("claude",c,{env:m(),stdio:["pipe","pipe","pipe"]}),u="",a="",d=setTimeout(()=>i.kill("SIGTERM"),e);i.stdout.on("data",o=>{u+=o}),i.stderr.on("data",o=>{a+=o}),i.on("error",o=>{clearTimeout(d),s(o)}),i.on("close",o=>{clearTimeout(d),o===0?t(u):s(new Error(`claude exited ${o}: ${a.trim().slice(0,200)}`))}),i.stdin.end(r)});try{let t=JSON.parse(l);if(t.is_error)throw new Error(`model error: ${String(t.result).slice(0,200)}`);let s=t.total_cost_usd;return{text:String(t.result??""),costUsd:typeof s=="number"&&Number.isFinite(s)?s:void 0}}catch(t){if(t instanceof SyntaxError)return{text:l};throw t}}function y(r){let n=r.match(/\{[\s\S]*\}/);if(!n)return null;try{let e=JSON.parse(n[0]);return e&&typeof e=="object"&&!Array.isArray(e)?e:null}catch{return null}}export{b as a,w as b,y as c};
|
|
2
|
-
//# sourceMappingURL=chunk-JRS5QRZG.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/wiki/model-call.ts"],"sourcesContent":["import { spawn } from \"child_process\"\nimport { claudeCliEnv } from \"@/utils/workspace-env\"\n\n/** One model call: prompt in, text out. Tests pass their own. */\nexport type ModelCall = (prompt: string, model: string, timeoutMs: number) => Promise<string>\n\n/**\n * One `claude -p` call with no tools. The prompt carries wiki text and\n * lines read from outside systems, so no built-in tool, MCP server, hook\n * or settings file is loaded: an instruction hidden in that text has\n * nothing to run, write or send with. No shell either: the prompt goes\n * in on stdin.\n */\nexport const claudeModelCall: ModelCall = async (prompt, model, timeoutMs) => (await claudeCall(prompt, model, timeoutMs)).text\n\n/** What the calls of a metered ModelCall spent. */\nexport interface ModelSpend {\n calls: number\n usd: number\n /** Calls whose reply named no cost: `usd` then counts low. */\n unpriced: number\n}\n\n/** claudeModelCall, adding each call's reported cost to `spend`. */\nexport function meteredModelCall(spend: ModelSpend): ModelCall {\n return async (prompt, model, timeoutMs) => {\n spend.calls++\n const { text, costUsd } = await claudeCall(prompt, model, timeoutMs)\n if (costUsd === undefined) spend.unpriced++\n else spend.usd += costUsd\n return text\n }\n}\n\nasync function claudeCall(prompt: string, model: string, timeoutMs: number): Promise<{ text: string; costUsd?: number }> {\n const args = [\"-p\", \"-\", \"--output-format\", \"json\", \"--max-turns\", \"1\", \"--model\", model,\n \"--tools\", \"\", \"--strict-mcp-config\", \"--mcp-config\", '{\"mcpServers\":{}}',\n \"--settings\", '{\"disableAllHooks\":true}', \"--setting-sources\", \"\", \"--no-session-persistence\"]\n const out = await new Promise<string>((ok, fail) => {\n const child = spawn(\"claude\", args, { env: claudeCliEnv(), stdio: [\"pipe\", \"pipe\", \"pipe\"] })\n let stdout = \"\"\n let stderr = \"\"\n const timer = setTimeout(() => child.kill(\"SIGTERM\"), timeoutMs)\n child.stdout.on(\"data\", (d) => { stdout += d })\n child.stderr.on(\"data\", (d) => { stderr += d })\n child.on(\"error\", (err) => { clearTimeout(timer); fail(err) })\n child.on(\"close\", (code) => {\n clearTimeout(timer)\n if (code === 0) ok(stdout)\n else fail(new Error(`claude exited ${code}: ${stderr.trim().slice(0, 200)}`))\n })\n child.stdin.end(prompt)\n })\n try {\n const envelope = JSON.parse(out) as { result?: string; is_error?: boolean; total_cost_usd?: unknown }\n if (envelope.is_error) throw new Error(`model error: ${String(envelope.result).slice(0, 200)}`)\n const cost = envelope.total_cost_usd\n return { text: String(envelope.result ?? \"\"), costUsd: typeof cost === \"number\" && Number.isFinite(cost) ? cost : undefined }\n } catch (err) {\n if (err instanceof SyntaxError) return { text: out }\n throw err\n }\n}\n\n/** The first JSON object in a model reply, or null. */\nexport function firstJsonObject(reply: string): Record<string, unknown> | null {\n const m = reply.match(/\\{[\\s\\S]*\\}/)\n if (!m) return null\n try {\n const parsed = JSON.parse(m[0])\n return parsed && typeof parsed === \"object\" && !Array.isArray(parsed) ? parsed as Record<string, unknown> : null\n } catch {\n return null\n }\n}\n"],"mappings":"wCAAA,OAAS,SAAAA,MAAa,gBAaf,IAAMC,EAA6B,MAAOC,EAAQC,EAAOC,KAAe,MAAMC,EAAWH,EAAQC,EAAOC,CAAS,GAAG,KAWpH,SAASE,EAAiBC,EAA8B,CAC7D,MAAO,OAAOL,EAAQC,EAAOC,IAAc,CACzCG,EAAM,QACN,GAAM,CAAE,KAAAC,EAAM,QAAAC,CAAQ,EAAI,MAAMJ,EAAWH,EAAQC,EAAOC,CAAS,EACnE,OAAIK,IAAY,OAAWF,EAAM,WAC5BA,EAAM,KAAOE,EACXD,CACT,CACF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AAa,MAAO,CAAE,KAAMV,CAAI,EACnD,MAAMU,CACR,CACF,CAGO,SAASI,EAAgBC,EAA+C,CAC7E,IAAMC,EAAID,EAAM,MAAM,aAAa,EACnC,GAAI,CAACC,EAAG,OAAO,KACf,GAAI,CACF,IAAMC,EAAS,KAAK,MAAMD,EAAE,CAAC,CAAC,EAC9B,OAAOC,GAAU,OAAOA,GAAW,UAAY,CAAC,MAAM,QAAQA,CAAM,EAAIA,EAAoC,IAC9G,MAAE,CACA,OAAO,IACT,CACF","names":["spawn","claudeModelCall","prompt","model","timeoutMs","claudeCall","meteredModelCall","spend","text","costUsd","args","out","ok","fail","child","spawn","claudeCliEnv","stdout","stderr","timer","d","err","code","envelope","cost","firstJsonObject","reply","m","parsed"]}
|
package/dist/chunk-JTDUTCUE.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{a as d}from"./chunk-RGZARSHV.js";import{existsSync as b,readFileSync as k,statSync as P,writeFileSync as O}from"fs";import{resolve as g}from"path";import h from"js-yaml";var n=(e=5)=>({panel:"history",title:"History",source:"history",show:e,importance:["major","normal"],fold:"minor",rollup:{min:5,days:30}}),c={panel:"discussed",title:"Discussed",source:"discussed",show:3,access:"owner"},s=(e=1)=>({panel:"notes",title:"Notes",source:"notes",show:e}),_=["device","server","app","domain","account","agent"],v=[{id:"person",label:"Person",plural:"People",pillar:"parties",schema:"Person",icon:"person",lens:[{panel:"roles",title:"Roles over time",from:["role_at","member_of","founded"],show:6,display:"timeline"},{panel:"relations",title:"Relations",from:["works_with","reports_to","client_of","works_on","related"],types:["person","organization","project"],show:5,group_by:"role"},{panel:"belongings",title:"Belongings",from:["owns","uses","related"],types:_.filter(e=>e!=="agent"),show:5},{panel:"obligations",title:"Obligations they carry",from:["subject_to"],show:3},n(),c,s()]},{id:"organization",label:"Organization",plural:"Organizations",pillar:"parties",schema:"Organization",icon:"org",lens:[{panel:"people",title:"People and roles",from:["role_at","member_of","founded"],show:6,group_by:"role"},{panel:"facts",title:"Key facts",from:["registered_with","located_in","identifier","legal_form"],show:6},{panel:"obligations",title:"Obligations and next due dates",from:["subject_to"],show:4},{panel:"agreements",title:"Agreements",source:"linked",types:["contract"],show:4},{panel:"decisions",title:"Decisions",source:"linked",types:["decision","policy"],show:4},n(),c,s()]},{id:"place",label:"Place",plural:"Places",pillar:"places",schema:"Place",icon:"pin",lens:[{panel:"here",title:"What is here",from:["located_in","related"],show:6},{panel:"laws",title:"Laws that apply here",from:["applies_in"],show:5},n(),s()]},{id:"jurisdiction",label:"Jurisdiction",plural:"Jurisdictions",pillar:"places",schema:"AdministrativeArea",icon:"pin",lens:[{panel:"laws",title:"Laws in force",from:["applies_in"],show:6},{panel:"authorities",title:"Authorities with reach",from:["jurisdiction_of"],show:5},{panel:"here",title:"What is here",from:["located_in"],show:5},s()]},{id:"device",label:"Device",plural:"Devices",pillar:"assets",schema:"Product",icon:"device",lens:[{panel:"state",title:"State now",source:"readings",latest:!0,show:6},n(),{panel:"apps",title:"Installed apps",from:["installed_on"],show:5},c,{panel:"parties",title:"Owner, user, location",from:["owns","uses","located_in","related"],types:["person","organization","place"],show:5},s()]},{id:"server",label:"Server",plural:"Servers",pillar:"assets",schema:"Product",icon:"server",lens:[{panel:"state",title:"State now",source:"readings",latest:!0,show:6},n(),{panel:"hosts",title:"Hosted services",from:["installed_on","runs_on"],show:6},c,{panel:"parties",title:"Owner and location",from:["owns","uses","located_in"],show:4},s()]},{id:"app",label:"App or system",plural:"Apps",pillar:"assets",schema:"SoftwareApplication",icon:"app",lens:[{panel:"installs",title:"Where it runs",from:["installed_on","runs_on"],show:5},{panel:"licence",title:"Licence or subscription",from:["party_to","licensed_by"],show:3},n(),c,s()]},{id:"domain",label:"Domain",plural:"Domains",pillar:"assets",schema:"WebSite",icon:"globe",lens:[{panel:"holder",title:"Holder",from:["owns","registrar"],show:3},{panel:"dues",title:"Renewal and due dates",source:"linked",types:["due_date"],show:4},{panel:"services",title:"Linked services",from:["related"],show:5},n(),s()]},{id:"account",label:"Account",plural:"Accounts",pillar:"assets",schema:"Service",icon:"key",lens:[{panel:"holder",title:"Holder",from:["owns","uses"],show:3},{panel:"dues",title:"Renewal and due dates",source:"linked",types:["due_date"],show:4},n(),s()]},{id:"agent",label:"Agent",plural:"Agents",pillar:"assets",schema:"SoftwareApplication",icon:"agent",lens:[{panel:"runs",title:"Where it runs",from:["runs_on","installed_on","related"],types:["server","device"],show:4},{panel:"works",title:"Works for",from:["works_for","uses","related"],types:["person","organization","project"],show:5},n(),c,s()]},{id:"project",label:"Project",plural:"Projects",pillar:"offerings",schema:"Project",icon:"project",lens:[{panel:"people",title:"Client and people",from:["client","client_of","works_on","related"],types:["person","organization","agent"],show:6,group_by:"role"},{panel:"agreements",title:"Agreements",source:"linked",types:["contract"],show:3},{panel:"decisions",title:"Decisions",source:"linked",types:["decision","policy"],show:4},n(6),c,s()]},{id:"offering",label:"Offering",plural:"Offerings",pillar:"offerings",schema:"Offer",icon:"project",lens:[{panel:"clients",title:"Clients",from:["client_of","related"],types:["organization","person"],show:5},n(),s()]},{id:"contract",label:"Agreement",plural:"Agreements",pillar:"agreements",schema:"Contract",icon:"contract",lens:[{panel:"parties",title:"Parties and roles",from:["party_to"],show:5,group_by:"role"},{panel:"terms",title:"Key terms and dates",from:["starts","renews","notice","amount"],show:6},{panel:"obligations",title:"Obligations it creates",from:["creates"],show:5},{panel:"amendments",title:"Amendments",from:["amends"],show:4},n(),s()]},{id:"legal_source",label:"Legal source",plural:"Legal sources",pillar:"law",schema:"Legislation",icon:"law",lens:[{panel:"reference",title:"Gazette reference and dates",from:["identifier","published_in","in_force_from","legal_force","issued_by"],show:6},{panel:"creates",title:"Obligations, penalties and reliefs it creates",from:["creates","created_by"],show:6},{panel:"amends",title:"Amends and amended by",from:["amends","repeals","implements"],show:5},{panel:"applies",title:"Where it applies",from:["applies_in"],show:3},s()]},{id:"obligation",label:"Obligation",plural:"Obligations",pillar:"law",schema:"LegalRuleML Obligation",icon:"law",lens:[{panel:"rule",title:"Who must do what, by when",from:["action","bearer","due_rule","amount_rule","authority","status"],show:6},{panel:"dues",title:"Next due dates",source:"linked",types:["due_date"],show:4},{panel:"sources",title:"Source articles",from:["created_by","changed_by"],show:4},{panel:"penalties",title:"Penalties and reliefs",from:["penalty_for","relieves"],show:4},{panel:"procedure",title:"Procedure",from:["procedure"],show:2},{panel:"bearers",title:"Who carries it",from:["subject_to"],show:5},n(4),s()]},{id:"penalty",label:"Penalty",plural:"Penalties",pillar:"law",schema:"LegalRuleML Penalty",icon:"law",lens:[{panel:"rule",title:"For which failure, how much",from:["penalty_for","kind","amount_rule","created_by"],show:6},s()]},{id:"relief",label:"Relief",plural:"Reliefs",pillar:"law",schema:"LegalRuleML Permission",icon:"law",lens:[{panel:"rule",title:"What it relieves, for whom, until when",from:["relieves","bearer","condition","created_by"],show:6},s()]},{id:"due_date",label:"Due date",plural:"Due dates",pillar:"law",schema:"Event",icon:"calendar",lens:[{panel:"due",title:"Due",from:["due_for","bearer","due","status","fulfilled_by"],show:6},s()]},{id:"event",label:"Event",plural:"Events",pillar:"events",schema:"Event",icon:"calendar",lens:[s(1),{panel:"involved",title:"Who and what was involved",from:["involves","affects","related"],show:8},{panel:"followed",title:"What followed",source:"linked",types:["event","decision"],show:4},c]},{id:"decision",label:"Decision",plural:"Decisions",pillar:"decisions",schema:"ChooseAction",icon:"decision",lens:[s(1),{panel:"affects",title:"What it affects",from:["affects","creates","related"],show:6},{panel:"replaced",title:"Replaced by",from:["replaced_by"],show:2},c]},{id:"policy",label:"Policy",plural:"Policies",pillar:"decisions",schema:"LegalRuleML Obligation",icon:"decision",lens:[{panel:"rule",title:"Rule",from:["action","bearer","creates","created_by"],show:6},{panel:"affects",title:"What it affects",from:["affects","related"],show:6},s()]},{id:"procedure",label:"Procedure",plural:"Procedures",pillar:"procedures",schema:"HowTo",icon:"steps",lens:[s(1),{panel:"triggers",title:"What triggers it",from:["procedure","triggered_by","related"],show:5},{panel:"runs",title:"Last runs",source:"linked",types:["event"],show:4}]},{id:"topic",label:"Topic",plural:"Topics",pillar:"topics",schema:"skos:Concept",icon:"topic",lens:[s(1),{panel:"related",title:"Related",from:["related"],show:8},n(4)]}],u={version:1,pillars:[{id:"parties",label:"Parties",description:"People and organisations, and the roles between them",icon:"person"},{id:"places",label:"Places & Jurisdictions",description:"Where things are, and whose rules apply there",icon:"pin"},{id:"assets",label:"Assets",description:"What is owned or run: devices, servers, apps, domains, accounts, agents",icon:"server"},{id:"offerings",label:"Offerings & Projects",description:"What is sold, built or delivered",icon:"project"},{id:"agreements",label:"Agreements",description:"Contracts, subscriptions and their terms",icon:"contract"},{id:"law",label:"Law & Obligations",description:"Legal sources, the obligations they create, penalties, reliefs and due dates",icon:"law"},{id:"events",label:"Events",description:"What happened, by importance",icon:"calendar"},{id:"decisions",label:"Decisions & Policies",description:"Why things are the way they are",icon:"decision"},{id:"procedures",label:"Procedures",description:"How things are done",icon:"steps"},{id:"topics",label:"Topics",description:"Pages no type fits yet. A growing count means a type is missing.",icon:"topic",sidebar:!1}],types:v,properties:[{id:"related",label:"related to",inverse:"related to"},{id:"role_at",label:"role at",inverse:"people",wikidata:"P108",range:["organization"],domain:["person"]},{id:"member_of",label:"member of",inverse:"members",wikidata:"P463",range:["organization"],domain:["person","organization"]},{id:"founded",label:"founded",inverse:"founded by",wikidata:"P112",domain:["person","organization"]},{id:"works_with",label:"works with",inverse:"works with",domain:["person","organization"]},{id:"reports_to",label:"reports to",inverse:"manages",domain:["person"]},{id:"client_of",label:"client of",inverse:"clients",wikidata:"P1972",domain:["person","organization"]},{id:"client",label:"is for client",inverse:"projects",range:["organization","person"],domain:["project","offering","contract"]},{id:"works_on",label:"works on",inverse:"people",range:["project"],domain:["person","organization","agent"]},{id:"works_for",label:"works for",inverse:"agents",wikidata:"P108",domain:["agent","person"]},{id:"owns",label:"owns",inverse:"owned by",wikidata:"P1830"},{id:"uses",label:"uses",inverse:"used by",wikidata:"P2283"},{id:"located_in",label:"located in",inverse:"here",wikidata:"P276"},{id:"installed_on",label:"installed on",inverse:"installed apps",range:["device","server"]},{id:"runs_on",label:"runs on",inverse:"hosts"},{id:"registered_with",label:"registered with",inverse:"registered"},{id:"identifier",label:"identifier",wikidata:"P1448"},{id:"legal_form",label:"legal form",wikidata:"P1454"},{id:"registrar",label:"registrar"},{id:"licensed_by",label:"licensed by",inverse:"licences"},{id:"party_to",label:"party to",inverse:"parties"},{id:"starts",label:"starts"},{id:"renews",label:"renews"},{id:"notice",label:"notice period"},{id:"amount",label:"amount"},{id:"creates",label:"creates",inverse:"created by"},{id:"created_by",label:"created by",inverse:"creates"},{id:"changed_by",label:"changed by",inverse:"changes"},{id:"amends",label:"amends",inverse:"amended by",wikidata:"P144"},{id:"repeals",label:"repeals",inverse:"repealed by"},{id:"implements",label:"implements",inverse:"implemented by"},{id:"issued_by",label:"issued by",inverse:"issues"},{id:"published_in",label:"published in",wikidata:"P1433"},{id:"in_force_from",label:"in force from",wikidata:"P7588"},{id:"legal_force",label:"legal force"},{id:"applies_in",label:"applies in",inverse:"laws that apply",wikidata:"P1001"},{id:"jurisdiction_of",label:"authority in",inverse:"authorities"},{id:"subject_to",label:"subject to",inverse:"carried by"},{id:"action",label:"action"},{id:"bearer",label:"bearer"},{id:"due_rule",label:"due"},{id:"amount_rule",label:"amount"},{id:"authority",label:"authority",inverse:"collects"},{id:"status",label:"status"},{id:"penalty_for",label:"penalty for",inverse:"penalties"},{id:"relieves",label:"relieves",inverse:"reliefs"},{id:"condition",label:"condition"},{id:"kind",label:"kind"},{id:"procedure",label:"procedure",inverse:"carries out"},{id:"due_for",label:"due for",inverse:"due dates"},{id:"due",label:"due on"},{id:"fulfilled_by",label:"fulfilled by",inverse:"fulfils"},{id:"involves",label:"involves",inverse:"events",wikidata:"P710"},{id:"affects",label:"affects",inverse:"affected by"},{id:"replaced_by",label:"replaced by",inverse:"replaces",wikidata:"P1366"},{id:"triggered_by",label:"triggered by",inverse:"triggers"},{id:"mentions",label:"mentions",inverse:"discussed in"},{id:"reading",label:"reading"},{id:"importance_set",label:"importance set"}],importance:{default:"normal",major_set_by:"owner",rollup:{min:5,days:30},rules:[{level:"minor",title:"\\b(disk|storage) (is |was |almost |nearly )?(full|pressure|cleanup|clean-up|usage|space)\\b"},{level:"minor",title:"\\b(cache|logs?|temp files?) (was |were )?(cleared|cleaned|purged|rotated|pruned)\\b"},{level:"minor",title:"\\b(restart(ed)?|reboot(ed)?|health ?check|heartbeat)\\b"}]},sidebar:{pins_max:5,pins:[]},classify:[{type:"agent",legacy:["person","concept","project"],title:"\\bagents?\\b|\\bbot\\b"},{type:"server",legacy:["place","concept"],title:"\\b(server|vps|host|node)\\b"},{type:"device",legacy:["place","concept"],title:"\\b(laptop|macbook|desktop|phone|tablet|printer|router)\\b"},{type:"person",legacy:["person"]},{type:"event",legacy:["event"]},{type:"decision",legacy:["decision"]},{type:"procedure",legacy:["pattern"]},{type:"place",legacy:["place"]},{type:"project",legacy:["project"]},{type:"organization",path:["clients","customers","vendors","suppliers","organizations","orgs","companies"]},{type:"organization",tags:["organization","company","client","vendor","supplier","agency","bank"]},{type:"server",path:["servers","hosts","infrastructure"]},{type:"server",tags:["server","vps","host"]},{type:"device",path:["devices"]},{type:"device",tags:["device","laptop","phone","printer"]},{type:"agent",tags:["agent"],title:"\\bagent\\b"},{type:"app",path:["apps","systems","services"]},{type:"domain",tags:["domain","dns"]},{type:"contract",path:["contracts","agreements"]},{type:"contract",tags:["contract","agreement","subscription"]},{type:"legal_source",path:["laws","legislation"]},{type:"legal_source",tags:["law","legislation","decree"]},{type:"obligation",path:["obligations","compliance"]},{type:"obligation",tags:["obligation","compliance"]},{type:"policy",path:["policies"]},{type:"policy",tags:["policy"]},{type:"procedure",path:["runbooks","procedures"]},{type:"procedure",tags:["runbook","procedure","how-to"]}],fallback_type:"topic"};var m="ontology.yaml",y=new Map;function E(e){let i=g(e,m);if(!b(i))return{ontology:u,errors:[],file:null};let r=P(i).mtimeMs,a=y.get(i);if(a&&a.mtimeMs===r)return a.loaded;let l,t=[];try{l=h.load(k(i,"utf-8"))}catch(w){t.push(`${m} is not valid YAML: ${w.message}`),l={}}let o=A(u,f(l)?l:{},t);t.push(...j(o));let p={ontology:o,errors:t,file:i};return y.set(i,{mtimeMs:r,loaded:p}),p}function T(e){let i=g(e,m);if(b(i))throw new Error(`${i} already exists`);let r=["# Wiki ontology: pillars, types, typed relations, event importance and lenses.","# Edit any section; what you leave out falls back to the built-in defaults.","# Check it with: agentx wiki ontology check",""].join(`
|
|
2
|
-
`);return O(i,r+h.dump(u,{lineWidth:120,noRefs:!0})),i}function A(e,i,r=[]){let a=structuredClone(e);typeof i.version=="number"&&(a.version=i.version);for(let l of["pillars","types","properties"]){let t=i[l];if(t!==void 0){if(!Array.isArray(t)){r.push(`${l} must be a list`);continue}a[l]=L(a[l],t,l,r)}}return f(i.importance)&&(a.importance={...a.importance,...i.importance}),f(i.sidebar)&&(a.sidebar={...a.sidebar,...i.sidebar}),i.classify!==void 0&&(Array.isArray(i.classify)?a.classify=i.classify:r.push("classify must be a list")),typeof i.fallback_type=="string"&&(a.fallback_type=i.fallback_type),i.agent_names!==void 0&&(Array.isArray(i.agent_names)?a.agent_names=i.agent_names.filter(l=>typeof l=="string"&&!!l.trim()):r.push("agent_names must be a list")),a}function L(e,i,r,a){let l=e.map(t=>({...t}));for(let t of i){if(!f(t)||typeof t.id!="string"){a.push(`every item in ${r} needs an id`);continue}let o=l.findIndex(p=>p.id===t.id);o===-1?l.push(t):l[o]={...l[o],...t}}return l}function j(e){let i=[],r=new Set(e.pillars.map(t=>t.id)),a=new Set(e.types.map(t=>t.id)),l=new Set(e.properties.map(t=>t.id));for(let t of e.types){r.has(t.pillar)||i.push(`type ${t.id}: unknown pillar "${t.pillar}"`);for(let o of t.lens??[]){for(let p of $(o))l.has(p)||i.push(`type ${t.id}, panel ${o.panel}: unknown property "${p}"`);for(let p of o.types??[])a.has(p)||i.push(`type ${t.id}, panel ${o.panel}: unknown type "${p}"`);for(let p of o.importance??[])d.includes(p)||i.push(`type ${t.id}, panel ${o.panel}: unknown importance "${p}"`)}}for(let t of e.classify)if(a.has(t.type)||i.push(`classify: unknown type "${t.type}"`),t.title)try{new RegExp(t.title,"i")}catch{i.push(`classify: bad title pattern "${t.title}"`)}a.has(e.fallback_type)||i.push(`fallback_type: unknown type "${e.fallback_type}"`),d.includes(e.importance.default)||i.push(`importance.default: unknown level "${e.importance.default}"`);for(let t of e.importance.rules??[])if(d.includes(t.level)||i.push(`importance.rules: unknown level "${t.level}"`),!t.title&&!t.tags?.length&&i.push(`importance.rules: a rule for "${t.level}" needs a title or tags`),t.title)try{new RegExp(t.title,"i")}catch{i.push(`importance.rules: bad title pattern "${t.title}"`)}return e.sidebar.pins.length>e.sidebar.pins_max&&i.push(`sidebar.pins: ${e.sidebar.pins.length} pins, only the first ${e.sidebar.pins_max} are shown`),i}function $(e){return e.from?Array.isArray(e.from)?e.from:[e.from]:[]}function M(e){return e.source?e.source:e.panel==="history"||e.panel==="discussed"||e.panel==="notes"?e.panel:e.latest?"readings":e.from?"statements":"linked"}function f(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}export{m as a,E as b,T as c,A as d,j as e,$ as f,M as g};
|
|
3
|
-
//# sourceMappingURL=chunk-JTDUTCUE.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/wiki/ontology/load.ts","../src/wiki/ontology/defaults.ts"],"sourcesContent":["// --- Load and check `ontology.yaml` (#811) ---\n//\n// The file is optional. Each section the owner writes is merged over the\n// defaults: pillars, types and properties by `id` (a listed id replaces\n// the fields it sets, a new id is added), `importance` and `sidebar`\n// field by field, and `classify` as a whole list. Problems are reported,\n// never thrown, so a typo in the file cannot take the wiki down.\n\nimport { existsSync, readFileSync, statSync, writeFileSync } from \"fs\"\nimport { resolve } from \"path\"\nimport yaml from \"js-yaml\"\nimport { DEFAULT_ONTOLOGY } from \"./defaults\"\nimport { IMPORTANCE_LEVELS, type LensPanel, type Ontology, type PanelSource } from \"./types\"\n\nexport const ONTOLOGY_FILE = \"ontology.yaml\"\n\nexport interface LoadedOntology {\n ontology: Ontology\n /** Problems found in the file. The defaults are used where they apply. */\n errors: string[]\n /** Path of the file read, or null when the defaults were used as they are. */\n file: string | null\n}\n\nconst cache = new Map<string, { mtimeMs: number; loaded: LoadedOntology }>()\n\nexport function loadOntology(wikiDir: string): LoadedOntology {\n const file = resolve(wikiDir, ONTOLOGY_FILE)\n if (!existsSync(file)) return { ontology: DEFAULT_ONTOLOGY, errors: [], file: null }\n\n const mtimeMs = statSync(file).mtimeMs\n const hit = cache.get(file)\n if (hit && hit.mtimeMs === mtimeMs) return hit.loaded\n\n let raw: unknown\n const errors: string[] = []\n try {\n raw = yaml.load(readFileSync(file, \"utf-8\"))\n } catch (err) {\n errors.push(`${ONTOLOGY_FILE} is not valid YAML: ${(err as Error).message}`)\n raw = {}\n }\n const ontology = mergeOntology(DEFAULT_ONTOLOGY, isObject(raw) ? raw : {}, errors)\n errors.push(...checkOntology(ontology))\n const loaded = { ontology, errors, file }\n cache.set(file, { mtimeMs, loaded })\n return loaded\n}\n\n/** Write the defaults as a starting `ontology.yaml`. Refuses to overwrite. */\nexport function writeDefaultOntology(wikiDir: string): string {\n const file = resolve(wikiDir, ONTOLOGY_FILE)\n if (existsSync(file)) throw new Error(`${file} already exists`)\n const header = [\n \"# Wiki ontology: pillars, types, typed relations, event importance and lenses.\",\n \"# Edit any section; what you leave out falls back to the built-in defaults.\",\n \"# Check it with: agentx wiki ontology check\",\n \"\",\n ].join(\"\\n\")\n writeFileSync(file, header + yaml.dump(DEFAULT_ONTOLOGY, { lineWidth: 120, noRefs: true }))\n return file\n}\n\nexport function mergeOntology(base: Ontology, over: Record<string, unknown>, errors: string[] = []): Ontology {\n const out: Ontology = structuredClone(base)\n if (typeof over.version === \"number\") out.version = over.version\n for (const key of [\"pillars\", \"types\", \"properties\"] as const) {\n const list = over[key]\n if (list === undefined) continue\n if (!Array.isArray(list)) { errors.push(`${key} must be a list`); continue }\n out[key] = mergeById(out[key] as Array<{ id: string }>, list, key, errors) as never\n }\n if (isObject(over.importance)) out.importance = { ...out.importance, ...over.importance } as Ontology[\"importance\"]\n if (isObject(over.sidebar)) out.sidebar = { ...out.sidebar, ...over.sidebar } as Ontology[\"sidebar\"]\n if (over.classify !== undefined) {\n if (Array.isArray(over.classify)) out.classify = over.classify as Ontology[\"classify\"]\n else errors.push(\"classify must be a list\")\n }\n if (typeof over.fallback_type === \"string\") out.fallback_type = over.fallback_type\n if (over.agent_names !== undefined) {\n if (Array.isArray(over.agent_names)) out.agent_names = over.agent_names.filter((n): n is string => typeof n === \"string\" && !!n.trim())\n else errors.push(\"agent_names must be a list\")\n }\n return out\n}\n\nfunction mergeById(base: Array<{ id: string }>, list: unknown[], key: string, errors: string[]): Array<{ id: string }> {\n const out = base.map(x => ({ ...x }))\n for (const item of list) {\n if (!isObject(item) || typeof item.id !== \"string\") { errors.push(`every item in ${key} needs an id`); continue }\n const at = out.findIndex(x => x.id === item.id)\n if (at === -1) out.push(item as { id: string })\n else out[at] = { ...out[at], ...item }\n }\n return out\n}\n\n/** Problems that make part of the ontology unusable. */\nexport function checkOntology(o: Ontology): string[] {\n const errors: string[] = []\n const pillars = new Set(o.pillars.map(p => p.id))\n const types = new Set(o.types.map(t => t.id))\n const props = new Set(o.properties.map(p => p.id))\n for (const t of o.types) {\n if (!pillars.has(t.pillar)) errors.push(`type ${t.id}: unknown pillar \"${t.pillar}\"`)\n for (const p of t.lens ?? []) {\n for (const f of panelFrom(p)) if (!props.has(f)) errors.push(`type ${t.id}, panel ${p.panel}: unknown property \"${f}\"`)\n for (const ty of p.types ?? []) if (!types.has(ty)) errors.push(`type ${t.id}, panel ${p.panel}: unknown type \"${ty}\"`)\n for (const lv of p.importance ?? []) if (!IMPORTANCE_LEVELS.includes(lv)) errors.push(`type ${t.id}, panel ${p.panel}: unknown importance \"${lv}\"`)\n }\n }\n for (const r of o.classify) {\n if (!types.has(r.type)) errors.push(`classify: unknown type \"${r.type}\"`)\n if (r.title) {\n try { new RegExp(r.title, \"i\") } catch { errors.push(`classify: bad title pattern \"${r.title}\"`) }\n }\n }\n if (!types.has(o.fallback_type)) errors.push(`fallback_type: unknown type \"${o.fallback_type}\"`)\n if (!IMPORTANCE_LEVELS.includes(o.importance.default)) errors.push(`importance.default: unknown level \"${o.importance.default}\"`)\n for (const r of o.importance.rules ?? []) {\n if (!IMPORTANCE_LEVELS.includes(r.level)) errors.push(`importance.rules: unknown level \"${r.level}\"`)\n if (!r.title && !r.tags?.length) errors.push(`importance.rules: a rule for \"${r.level}\" needs a title or tags`)\n if (r.title) {\n try { new RegExp(r.title, \"i\") } catch { errors.push(`importance.rules: bad title pattern \"${r.title}\"`) }\n }\n }\n if (o.sidebar.pins.length > o.sidebar.pins_max) {\n errors.push(`sidebar.pins: ${o.sidebar.pins.length} pins, only the first ${o.sidebar.pins_max} are shown`)\n }\n return errors\n}\n\nexport function panelFrom(p: LensPanel): string[] {\n if (!p.from) return []\n return Array.isArray(p.from) ? p.from : [p.from]\n}\n\nexport function panelSource(p: LensPanel): PanelSource {\n if (p.source) return p.source\n if (p.panel === \"history\" || p.panel === \"discussed\" || p.panel === \"notes\") return p.panel\n if (p.latest) return \"readings\"\n if (p.from) return \"statements\"\n return \"linked\"\n}\n\nfunction isObject(v: unknown): v is Record<string, unknown> {\n return typeof v === \"object\" && v !== null && !Array.isArray(v)\n}\n","// --- Default wiki ontology (#811) ---\n//\n// Generic starting point: nine pillars, the types inside them, the typed\n// relations between them and a lens for every type. An owner overrides\n// any section in `<wiki>/ontology.yaml`; `agentx wiki ontology init`\n// writes this file out as a starting point. Keep it free of any\n// particular organisation, person, country or product.\n\nimport type { LensPanel, Ontology, TypeDef } from \"./types\"\n\nconst history = (show = 5): LensPanel => ({\n panel: \"history\", title: \"History\", source: \"history\", show,\n importance: [\"major\", \"normal\"], fold: \"minor\", rollup: { min: 5, days: 30 },\n})\nconst discussed: LensPanel = { panel: \"discussed\", title: \"Discussed\", source: \"discussed\", show: 3, access: \"owner\" }\nconst notes = (show = 1): LensPanel => ({ panel: \"notes\", title: \"Notes\", source: \"notes\", show })\n\nconst ASSET_TYPES = [\"device\", \"server\", \"app\", \"domain\", \"account\", \"agent\"]\n\nconst types: TypeDef[] = [\n // Parties\n {\n id: \"person\", label: \"Person\", plural: \"People\", pillar: \"parties\", schema: \"Person\", icon: \"person\",\n lens: [\n { panel: \"roles\", title: \"Roles over time\", from: [\"role_at\", \"member_of\", \"founded\"], show: 6, display: \"timeline\" },\n { panel: \"relations\", title: \"Relations\", from: [\"works_with\", \"reports_to\", \"client_of\", \"works_on\", \"related\"], types: [\"person\", \"organization\", \"project\"], show: 5, group_by: \"role\" },\n // Agents are not a person's belongings or relations (#819).\n { panel: \"belongings\", title: \"Belongings\", from: [\"owns\", \"uses\", \"related\"], types: ASSET_TYPES.filter(t => t !== \"agent\"), show: 5 },\n { panel: \"obligations\", title: \"Obligations they carry\", from: [\"subject_to\"], show: 3 },\n history(),\n discussed,\n notes(),\n ],\n },\n {\n id: \"organization\", label: \"Organization\", plural: \"Organizations\", pillar: \"parties\", schema: \"Organization\", icon: \"org\",\n lens: [\n { panel: \"people\", title: \"People and roles\", from: [\"role_at\", \"member_of\", \"founded\"], show: 6, group_by: \"role\" },\n { panel: \"facts\", title: \"Key facts\", from: [\"registered_with\", \"located_in\", \"identifier\", \"legal_form\"], show: 6 },\n { panel: \"obligations\", title: \"Obligations and next due dates\", from: [\"subject_to\"], show: 4 },\n { panel: \"agreements\", title: \"Agreements\", source: \"linked\", types: [\"contract\"], show: 4 },\n { panel: \"decisions\", title: \"Decisions\", source: \"linked\", types: [\"decision\", \"policy\"], show: 4 },\n history(),\n discussed,\n notes(),\n ],\n },\n // Places & Jurisdictions\n {\n id: \"place\", label: \"Place\", plural: \"Places\", pillar: \"places\", schema: \"Place\", icon: \"pin\",\n lens: [\n { panel: \"here\", title: \"What is here\", from: [\"located_in\", \"related\"], show: 6 },\n { panel: \"laws\", title: \"Laws that apply here\", from: [\"applies_in\"], show: 5 },\n history(),\n notes(),\n ],\n },\n {\n id: \"jurisdiction\", label: \"Jurisdiction\", plural: \"Jurisdictions\", pillar: \"places\", schema: \"AdministrativeArea\", icon: \"pin\",\n lens: [\n { panel: \"laws\", title: \"Laws in force\", from: [\"applies_in\"], show: 6 },\n { panel: \"authorities\", title: \"Authorities with reach\", from: [\"jurisdiction_of\"], show: 5 },\n { panel: \"here\", title: \"What is here\", from: [\"located_in\"], show: 5 },\n notes(),\n ],\n },\n // Assets\n {\n id: \"device\", label: \"Device\", plural: \"Devices\", pillar: \"assets\", schema: \"Product\", icon: \"device\",\n lens: [\n { panel: \"state\", title: \"State now\", source: \"readings\", latest: true, show: 6 },\n history(),\n { panel: \"apps\", title: \"Installed apps\", from: [\"installed_on\"], show: 5 },\n discussed,\n { panel: \"parties\", title: \"Owner, user, location\", from: [\"owns\", \"uses\", \"located_in\", \"related\"], types: [\"person\", \"organization\", \"place\"], show: 5 },\n notes(),\n ],\n },\n {\n id: \"server\", label: \"Server\", plural: \"Servers\", pillar: \"assets\", schema: \"Product\", icon: \"server\",\n lens: [\n { panel: \"state\", title: \"State now\", source: \"readings\", latest: true, show: 6 },\n history(),\n { panel: \"hosts\", title: \"Hosted services\", from: [\"installed_on\", \"runs_on\"], show: 6 },\n discussed,\n { panel: \"parties\", title: \"Owner and location\", from: [\"owns\", \"uses\", \"located_in\"], show: 4 },\n notes(),\n ],\n },\n {\n id: \"app\", label: \"App or system\", plural: \"Apps\", pillar: \"assets\", schema: \"SoftwareApplication\", icon: \"app\",\n lens: [\n { panel: \"installs\", title: \"Where it runs\", from: [\"installed_on\", \"runs_on\"], show: 5 },\n { panel: \"licence\", title: \"Licence or subscription\", from: [\"party_to\", \"licensed_by\"], show: 3 },\n history(),\n discussed,\n notes(),\n ],\n },\n {\n id: \"domain\", label: \"Domain\", plural: \"Domains\", pillar: \"assets\", schema: \"WebSite\", icon: \"globe\",\n lens: [\n { panel: \"holder\", title: \"Holder\", from: [\"owns\", \"registrar\"], show: 3 },\n { panel: \"dues\", title: \"Renewal and due dates\", source: \"linked\", types: [\"due_date\"], show: 4 },\n { panel: \"services\", title: \"Linked services\", from: [\"related\"], show: 5 },\n history(),\n notes(),\n ],\n },\n {\n id: \"account\", label: \"Account\", plural: \"Accounts\", pillar: \"assets\", schema: \"Service\", icon: \"key\",\n lens: [\n { panel: \"holder\", title: \"Holder\", from: [\"owns\", \"uses\"], show: 3 },\n { panel: \"dues\", title: \"Renewal and due dates\", source: \"linked\", types: [\"due_date\"], show: 4 },\n history(),\n notes(),\n ],\n },\n {\n id: \"agent\", label: \"Agent\", plural: \"Agents\", pillar: \"assets\", schema: \"SoftwareApplication\", icon: \"agent\",\n lens: [\n { panel: \"runs\", title: \"Where it runs\", from: [\"runs_on\", \"installed_on\", \"related\"], types: [\"server\", \"device\"], show: 4 },\n { panel: \"works\", title: \"Works for\", from: [\"works_for\", \"uses\", \"related\"], types: [\"person\", \"organization\", \"project\"], show: 5 },\n history(),\n discussed,\n notes(),\n ],\n },\n // Offerings & Projects\n {\n id: \"project\", label: \"Project\", plural: \"Projects\", pillar: \"offerings\", schema: \"Project\", icon: \"project\",\n lens: [\n { panel: \"people\", title: \"Client and people\", from: [\"client\", \"client_of\", \"works_on\", \"related\"], types: [\"person\", \"organization\", \"agent\"], show: 6, group_by: \"role\" },\n { panel: \"agreements\", title: \"Agreements\", source: \"linked\", types: [\"contract\"], show: 3 },\n { panel: \"decisions\", title: \"Decisions\", source: \"linked\", types: [\"decision\", \"policy\"], show: 4 },\n history(6),\n discussed,\n notes(),\n ],\n },\n {\n id: \"offering\", label: \"Offering\", plural: \"Offerings\", pillar: \"offerings\", schema: \"Offer\", icon: \"project\",\n lens: [\n { panel: \"clients\", title: \"Clients\", from: [\"client_of\", \"related\"], types: [\"organization\", \"person\"], show: 5 },\n history(),\n notes(),\n ],\n },\n // Agreements\n {\n id: \"contract\", label: \"Agreement\", plural: \"Agreements\", pillar: \"agreements\", schema: \"Contract\", icon: \"contract\",\n lens: [\n { panel: \"parties\", title: \"Parties and roles\", from: [\"party_to\"], show: 5, group_by: \"role\" },\n { panel: \"terms\", title: \"Key terms and dates\", from: [\"starts\", \"renews\", \"notice\", \"amount\"], show: 6 },\n { panel: \"obligations\", title: \"Obligations it creates\", from: [\"creates\"], show: 5 },\n { panel: \"amendments\", title: \"Amendments\", from: [\"amends\"], show: 4 },\n history(),\n notes(),\n ],\n },\n // Law & Obligations\n {\n id: \"legal_source\", label: \"Legal source\", plural: \"Legal sources\", pillar: \"law\", schema: \"Legislation\", icon: \"law\",\n lens: [\n { panel: \"reference\", title: \"Gazette reference and dates\", from: [\"identifier\", \"published_in\", \"in_force_from\", \"legal_force\", \"issued_by\"], show: 6 },\n { panel: \"creates\", title: \"Obligations, penalties and reliefs it creates\", from: [\"creates\", \"created_by\"], show: 6 },\n { panel: \"amends\", title: \"Amends and amended by\", from: [\"amends\", \"repeals\", \"implements\"], show: 5 },\n { panel: \"applies\", title: \"Where it applies\", from: [\"applies_in\"], show: 3 },\n notes(),\n ],\n },\n {\n id: \"obligation\", label: \"Obligation\", plural: \"Obligations\", pillar: \"law\", schema: \"LegalRuleML Obligation\", icon: \"law\",\n lens: [\n { panel: \"rule\", title: \"Who must do what, by when\", from: [\"action\", \"bearer\", \"due_rule\", \"amount_rule\", \"authority\", \"status\"], show: 6 },\n { panel: \"dues\", title: \"Next due dates\", source: \"linked\", types: [\"due_date\"], show: 4 },\n { panel: \"sources\", title: \"Source articles\", from: [\"created_by\", \"changed_by\"], show: 4 },\n { panel: \"penalties\", title: \"Penalties and reliefs\", from: [\"penalty_for\", \"relieves\"], show: 4 },\n { panel: \"procedure\", title: \"Procedure\", from: [\"procedure\"], show: 2 },\n { panel: \"bearers\", title: \"Who carries it\", from: [\"subject_to\"], show: 5 },\n history(4),\n notes(),\n ],\n },\n {\n id: \"penalty\", label: \"Penalty\", plural: \"Penalties\", pillar: \"law\", schema: \"LegalRuleML Penalty\", icon: \"law\",\n lens: [\n { panel: \"rule\", title: \"For which failure, how much\", from: [\"penalty_for\", \"kind\", \"amount_rule\", \"created_by\"], show: 6 },\n notes(),\n ],\n },\n {\n id: \"relief\", label: \"Relief\", plural: \"Reliefs\", pillar: \"law\", schema: \"LegalRuleML Permission\", icon: \"law\",\n lens: [\n { panel: \"rule\", title: \"What it relieves, for whom, until when\", from: [\"relieves\", \"bearer\", \"condition\", \"created_by\"], show: 6 },\n notes(),\n ],\n },\n {\n id: \"due_date\", label: \"Due date\", plural: \"Due dates\", pillar: \"law\", schema: \"Event\", icon: \"calendar\",\n lens: [\n { panel: \"due\", title: \"Due\", from: [\"due_for\", \"bearer\", \"due\", \"status\", \"fulfilled_by\"], show: 6 },\n notes(),\n ],\n },\n // Events\n {\n id: \"event\", label: \"Event\", plural: \"Events\", pillar: \"events\", schema: \"Event\", icon: \"calendar\",\n lens: [\n notes(1),\n { panel: \"involved\", title: \"Who and what was involved\", from: [\"involves\", \"affects\", \"related\"], show: 8 },\n { panel: \"followed\", title: \"What followed\", source: \"linked\", types: [\"event\", \"decision\"], show: 4 },\n discussed,\n ],\n },\n // Decisions & Policies\n {\n id: \"decision\", label: \"Decision\", plural: \"Decisions\", pillar: \"decisions\", schema: \"ChooseAction\", icon: \"decision\",\n lens: [\n notes(1),\n { panel: \"affects\", title: \"What it affects\", from: [\"affects\", \"creates\", \"related\"], show: 6 },\n { panel: \"replaced\", title: \"Replaced by\", from: [\"replaced_by\"], show: 2 },\n discussed,\n ],\n },\n {\n id: \"policy\", label: \"Policy\", plural: \"Policies\", pillar: \"decisions\", schema: \"LegalRuleML Obligation\", icon: \"decision\",\n lens: [\n { panel: \"rule\", title: \"Rule\", from: [\"action\", \"bearer\", \"creates\", \"created_by\"], show: 6 },\n { panel: \"affects\", title: \"What it affects\", from: [\"affects\", \"related\"], show: 6 },\n notes(),\n ],\n },\n // Procedures\n {\n id: \"procedure\", label: \"Procedure\", plural: \"Procedures\", pillar: \"procedures\", schema: \"HowTo\", icon: \"steps\",\n lens: [\n notes(1),\n { panel: \"triggers\", title: \"What triggers it\", from: [\"procedure\", \"triggered_by\", \"related\"], show: 5 },\n { panel: \"runs\", title: \"Last runs\", source: \"linked\", types: [\"event\"], show: 4 },\n ],\n },\n // Topics (fallback, not in the sidebar)\n {\n id: \"topic\", label: \"Topic\", plural: \"Topics\", pillar: \"topics\", schema: \"skos:Concept\", icon: \"topic\",\n lens: [\n notes(1),\n { panel: \"related\", title: \"Related\", from: [\"related\"], show: 8 },\n history(4),\n ],\n },\n]\n\nexport const DEFAULT_ONTOLOGY: Ontology = {\n version: 1,\n pillars: [\n { id: \"parties\", label: \"Parties\", description: \"People and organisations, and the roles between them\", icon: \"person\" },\n { id: \"places\", label: \"Places & Jurisdictions\", description: \"Where things are, and whose rules apply there\", icon: \"pin\" },\n { id: \"assets\", label: \"Assets\", description: \"What is owned or run: devices, servers, apps, domains, accounts, agents\", icon: \"server\" },\n { id: \"offerings\", label: \"Offerings & Projects\", description: \"What is sold, built or delivered\", icon: \"project\" },\n { id: \"agreements\", label: \"Agreements\", description: \"Contracts, subscriptions and their terms\", icon: \"contract\" },\n { id: \"law\", label: \"Law & Obligations\", description: \"Legal sources, the obligations they create, penalties, reliefs and due dates\", icon: \"law\" },\n { id: \"events\", label: \"Events\", description: \"What happened, by importance\", icon: \"calendar\" },\n { id: \"decisions\", label: \"Decisions & Policies\", description: \"Why things are the way they are\", icon: \"decision\" },\n { id: \"procedures\", label: \"Procedures\", description: \"How things are done\", icon: \"steps\" },\n { id: \"topics\", label: \"Topics\", description: \"Pages no type fits yet. A growing count means a type is missing.\", icon: \"topic\", sidebar: false },\n ],\n types,\n properties: [\n { id: \"related\", label: \"related to\", inverse: \"related to\" },\n { id: \"role_at\", label: \"role at\", inverse: \"people\", wikidata: \"P108\", range: [\"organization\"], domain: [\"person\"] },\n { id: \"member_of\", label: \"member of\", inverse: \"members\", wikidata: \"P463\", range: [\"organization\"], domain: [\"person\", \"organization\"] },\n { id: \"founded\", label: \"founded\", inverse: \"founded by\", wikidata: \"P112\", domain: [\"person\", \"organization\"] },\n { id: \"works_with\", label: \"works with\", inverse: \"works with\", domain: [\"person\", \"organization\"] },\n { id: \"reports_to\", label: \"reports to\", inverse: \"manages\", domain: [\"person\"] },\n { id: \"client_of\", label: \"client of\", inverse: \"clients\", wikidata: \"P1972\", domain: [\"person\", \"organization\"] },\n { id: \"client\", label: \"is for client\", inverse: \"projects\", range: [\"organization\", \"person\"], domain: [\"project\", \"offering\", \"contract\"] },\n { id: \"works_on\", label: \"works on\", inverse: \"people\", range: [\"project\"], domain: [\"person\", \"organization\", \"agent\"] },\n { id: \"works_for\", label: \"works for\", inverse: \"agents\", wikidata: \"P108\", domain: [\"agent\", \"person\"] },\n { id: \"owns\", label: \"owns\", inverse: \"owned by\", wikidata: \"P1830\" },\n { id: \"uses\", label: \"uses\", inverse: \"used by\", wikidata: \"P2283\" },\n { id: \"located_in\", label: \"located in\", inverse: \"here\", wikidata: \"P276\" },\n { id: \"installed_on\", label: \"installed on\", inverse: \"installed apps\", range: [\"device\", \"server\"] },\n { id: \"runs_on\", label: \"runs on\", inverse: \"hosts\" },\n { id: \"registered_with\", label: \"registered with\", inverse: \"registered\" },\n { id: \"identifier\", label: \"identifier\", wikidata: \"P1448\" },\n { id: \"legal_form\", label: \"legal form\", wikidata: \"P1454\" },\n { id: \"registrar\", label: \"registrar\" },\n { id: \"licensed_by\", label: \"licensed by\", inverse: \"licences\" },\n { id: \"party_to\", label: \"party to\", inverse: \"parties\" },\n { id: \"starts\", label: \"starts\" },\n { id: \"renews\", label: \"renews\" },\n { id: \"notice\", label: \"notice period\" },\n { id: \"amount\", label: \"amount\" },\n { id: \"creates\", label: \"creates\", inverse: \"created by\" },\n { id: \"created_by\", label: \"created by\", inverse: \"creates\" },\n { id: \"changed_by\", label: \"changed by\", inverse: \"changes\" },\n { id: \"amends\", label: \"amends\", inverse: \"amended by\", wikidata: \"P144\" },\n { id: \"repeals\", label: \"repeals\", inverse: \"repealed by\" },\n { id: \"implements\", label: \"implements\", inverse: \"implemented by\" },\n { id: \"issued_by\", label: \"issued by\", inverse: \"issues\" },\n { id: \"published_in\", label: \"published in\", wikidata: \"P1433\" },\n { id: \"in_force_from\", label: \"in force from\", wikidata: \"P7588\" },\n { id: \"legal_force\", label: \"legal force\" },\n { id: \"applies_in\", label: \"applies in\", inverse: \"laws that apply\", wikidata: \"P1001\" },\n { id: \"jurisdiction_of\", label: \"authority in\", inverse: \"authorities\" },\n { id: \"subject_to\", label: \"subject to\", inverse: \"carried by\" },\n { id: \"action\", label: \"action\" },\n { id: \"bearer\", label: \"bearer\" },\n { id: \"due_rule\", label: \"due\" },\n { id: \"amount_rule\", label: \"amount\" },\n { id: \"authority\", label: \"authority\", inverse: \"collects\" },\n { id: \"status\", label: \"status\" },\n { id: \"penalty_for\", label: \"penalty for\", inverse: \"penalties\" },\n { id: \"relieves\", label: \"relieves\", inverse: \"reliefs\" },\n { id: \"condition\", label: \"condition\" },\n { id: \"kind\", label: \"kind\" },\n { id: \"procedure\", label: \"procedure\", inverse: \"carries out\" },\n { id: \"due_for\", label: \"due for\", inverse: \"due dates\" },\n { id: \"due\", label: \"due on\" },\n { id: \"fulfilled_by\", label: \"fulfilled by\", inverse: \"fulfils\" },\n { id: \"involves\", label: \"involves\", inverse: \"events\", wikidata: \"P710\" },\n { id: \"affects\", label: \"affects\", inverse: \"affected by\" },\n { id: \"replaced_by\", label: \"replaced by\", inverse: \"replaces\", wikidata: \"P1366\" },\n { id: \"triggered_by\", label: \"triggered by\", inverse: \"triggers\" },\n { id: \"mentions\", label: \"mentions\", inverse: \"discussed in\" },\n { id: \"reading\", label: \"reading\" },\n { id: \"importance_set\", label: \"importance set\" },\n ],\n importance: {\n default: \"normal\",\n major_set_by: \"owner\",\n rollup: { min: 5, days: 30 },\n // Routine machine upkeep: true for any fleet, so safe as a default.\n rules: [\n { level: \"minor\", title: \"\\\\b(disk|storage) (is |was |almost |nearly )?(full|pressure|cleanup|clean-up|usage|space)\\\\b\" },\n { level: \"minor\", title: \"\\\\b(cache|logs?|temp files?) (was |were )?(cleared|cleaned|purged|rotated|pruned)\\\\b\" },\n { level: \"minor\", title: \"\\\\b(restart(ed)?|reboot(ed)?|health ?check|heartbeat)\\\\b\" },\n ],\n },\n sidebar: { pins_max: 5, pins: [] },\n classify: [\n // Old pages filed agents as people and machines as places; the title\n // tells them apart until absorb writes `class` on the page.\n { type: \"agent\", legacy: [\"person\", \"concept\", \"project\"], title: \"\\\\bagents?\\\\b|\\\\bbot\\\\b\" },\n { type: \"server\", legacy: [\"place\", \"concept\"], title: \"\\\\b(server|vps|host|node)\\\\b\" },\n { type: \"device\", legacy: [\"place\", \"concept\"], title: \"\\\\b(laptop|macbook|desktop|phone|tablet|printer|router)\\\\b\" },\n { type: \"person\", legacy: [\"person\"] },\n { type: \"event\", legacy: [\"event\"] },\n { type: \"decision\", legacy: [\"decision\"] },\n { type: \"procedure\", legacy: [\"pattern\"] },\n { type: \"place\", legacy: [\"place\"] },\n // Folder and tag rules below refine untyped and concept pages only.\n { type: \"project\", legacy: [\"project\"] },\n { type: \"organization\", path: [\"clients\", \"customers\", \"vendors\", \"suppliers\", \"organizations\", \"orgs\", \"companies\"] },\n { type: \"organization\", tags: [\"organization\", \"company\", \"client\", \"vendor\", \"supplier\", \"agency\", \"bank\"] },\n { type: \"server\", path: [\"servers\", \"hosts\", \"infrastructure\"] },\n { type: \"server\", tags: [\"server\", \"vps\", \"host\"] },\n { type: \"device\", path: [\"devices\"] },\n { type: \"device\", tags: [\"device\", \"laptop\", \"phone\", \"printer\"] },\n { type: \"agent\", tags: [\"agent\"], title: \"\\\\bagent\\\\b\" },\n { type: \"app\", path: [\"apps\", \"systems\", \"services\"] },\n { type: \"domain\", tags: [\"domain\", \"dns\"] },\n { type: \"contract\", path: [\"contracts\", \"agreements\"] },\n { type: \"contract\", tags: [\"contract\", \"agreement\", \"subscription\"] },\n { type: \"legal_source\", path: [\"laws\", \"legislation\"] },\n { type: \"legal_source\", tags: [\"law\", \"legislation\", \"decree\"] },\n { type: \"obligation\", path: [\"obligations\", \"compliance\"] },\n { type: \"obligation\", tags: [\"obligation\", \"compliance\"] },\n { type: \"policy\", path: [\"policies\"] },\n { type: \"policy\", tags: [\"policy\"] },\n { type: \"procedure\", path: [\"runbooks\", \"procedures\"] },\n { type: \"procedure\", tags: [\"runbook\", \"procedure\", \"how-to\"] },\n ],\n fallback_type: \"topic\",\n}\n"],"mappings":"wCAQA,OAAS,cAAAA,EAAY,gBAAAC,EAAc,YAAAC,EAAU,iBAAAC,MAAqB,KAClE,OAAS,WAAAC,MAAe,OACxB,OAAOC,MAAU,UCAjB,IAAMC,EAAU,CAACC,EAAO,KAAkB,CACxC,MAAO,UAAW,MAAO,UAAW,OAAQ,UAAW,KAAAA,EACvD,WAAY,CAAC,QAAS,QAAQ,EAAG,KAAM,QAAS,OAAQ,CAAE,IAAK,EAAG,KAAM,EAAG,CAC7E,GACMC,EAAuB,CAAE,MAAO,YAAa,MAAO,YAAa,OAAQ,YAAa,KAAM,EAAG,OAAQ,OAAQ,EAC/GC,EAAQ,CAACF,EAAO,KAAkB,CAAE,MAAO,QAAS,MAAO,QAAS,OAAQ,QAAS,KAAAA,CAAK,GAE1FG,EAAc,CAAC,SAAU,SAAU,MAAO,SAAU,UAAW,OAAO,EAEtEC,EAAmB,CAEvB,CACE,GAAI,SAAU,MAAO,SAAU,OAAQ,SAAU,OAAQ,UAAW,OAAQ,SAAU,KAAM,SAC5F,KAAM,CACJ,CAAE,MAAO,QAAS,MAAO,kBAAmB,KAAM,CAAC,UAAW,YAAa,SAAS,EAAG,KAAM,EAAG,QAAS,UAAW,EACpH,CAAE,MAAO,YAAa,MAAO,YAAa,KAAM,CAAC,aAAc,aAAc,YAAa,WAAY,SAAS,EAAG,MAAO,CAAC,SAAU,eAAgB,SAAS,EAAG,KAAM,EAAG,SAAU,MAAO,EAE1L,CAAE,MAAO,aAAc,MAAO,aAAc,KAAM,CAAC,OAAQ,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,CAAC,MAAM,QAAQA,CAAC,CAChE","names":["existsSync","readFileSync","statSync","writeFileSync","resolve","yaml","history","show","discussed","notes","ASSET_TYPES","types","t","DEFAULT_ONTOLOGY","ONTOLOGY_FILE","cache","loadOntology","wikiDir","file","resolve","existsSync","DEFAULT_ONTOLOGY","mtimeMs","statSync","hit","raw","errors","yaml","readFileSync","err","ontology","mergeOntology","isObject","checkOntology","loaded","writeDefaultOntology","header","writeFileSync","base","over","out","key","list","mergeById","n","x","item","at","o","pillars","p","types","props","f","panelFrom","ty","lv","IMPORTANCE_LEVELS","r","panelSource","v"]}
|
package/dist/chunk-KA2UIZXG.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{b as F,c as S,d as $,f as x}from"./chunk-GQ76J72O.js";import{a as B,b as j,c as v}from"./chunk-ILEC3IAV.js";import{createHash as X}from"crypto";import{existsSync as z,statSync as G}from"fs";import{resolve as K}from"path";import{closeSync as D,existsSync as q,mkdirSync as C,openSync as M,readFileSync as N,renameSync as _,statSync as J,unlinkSync as g,writeFileSync as H}from"fs";import{dirname as E}from"path";var l=class extends Error{constructor(e,i){super(`fact ledger ${e} is unreadable (${i}). Nothing was written to it. Repair the JSON, or move the file aside to start an empty ledger.`);this.file=e;this.name="LedgerCorruptError"}},I=["id","subject","attribute","value","source","verifiedAt","verifiedBy","volatility"],W=["id","status","claim","source","verifiedAt","agentId"],L=(r,t)=>!!r&&typeof r=="object"&&!Array.isArray(r)&&t.every(e=>typeof r[e]=="string");function O(r){if(!q(r))return null;let t;try{t=JSON.parse(N(r,"utf-8"))}catch(s){throw new l(r,String(s?.message??s))}if(!t||typeof t!="object"||!Array.isArray(t.facts)||t.proposals!==void 0&&!Array.isArray(t.proposals))throw new l(r,"not a ledger: expected { facts: [], proposals: [] }");let e=t.facts.findIndex(s=>!L(s,I));if(e>=0)throw new l(r,`fact #${e+1} is missing ${I.join("/")}`);let i=(t.proposals??[]).findIndex(s=>!L(s,W));if(i>=0)throw new l(r,`proposal #${i+1} is missing ${W.join("/")}`);return{facts:t.facts,proposals:t.proposals??[]}}function P(r,t){C(E(r),{recursive:!0});let e=`${r}.${process.pid}.tmp`;H(e,JSON.stringify(t,null,2)+`
|
|
2
|
-
`),_(e,r)}var Q=r=>Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,r),p=new Set,w=(r,t)=>{try{return Date.now()-J(r).mtimeMs>t}catch{return!1}};function U(r,t){let e=`${r}.takeover`;if(w(e,t))try{g(e)}catch{}let i;try{i=M(e,"wx")}catch{return}try{w(r,t)&&g(r)}catch{}finally{D(i);try{g(e)}catch{}}}function R(r,t,e={}){let i=`${r}.lock`;if(p.has(i))return t();let s=e.timeoutMs??3e3,o=e.staleMs??15e3;C(E(i),{recursive:!0});let a=Date.now()+s,c;for(;c===void 0;)try{c=M(i,"wx")}catch(u){if(u?.code!=="EEXIST")throw u;if(w(i,o)&&U(i,o),Date.now()>a)throw new Error(`fact ledger is busy (${i}). If no agentx command is running, delete that lock and try again.`);Q(25)}p.add(i);try{return t()}finally{p.delete(i),D(c);try{g(i)}catch{}}}var d=r=>r.toLowerCase().replace(/\s+/g," ").trim();function V(r,t){return"f-"+X("sha1").update(`${d(r)}\0${d(t)}`).digest("hex").slice(0,10)}var T=class{constructor(t){this.wikiDir=t;this.file=K(t,"_facts.json")}file;cache;reported;load(){if(!z(this.file))return{version:1,facts:[],proposals:[]};let t=G(this.file).mtimeMs;if(this.cache?.mtimeMs===t)return structuredClone(this.cache.data);let e;try{e=O(this.file)}catch(s){throw this.reported!==t&&(this.reported=t,console.error(`[wiki-facts] ${s.message}`)),s}let i={version:1,facts:e?.facts??[],proposals:e?.proposals??[]};return this.cache={mtimeMs:t,data:i},structuredClone(i)}update(t){return R(this.file,()=>{this.cache=void 0;let e=this.load(),{save:i,result:s}=t(e);return i&&(P(this.file,e),this.cache=void 0),s})}list(){return this.load().facts}get(t){return this.list().find(e=>e.id===t||t.length>=6&&e.id.startsWith(t))??null}write(t,e={}){e.confirmedBy&&B("confirm a fact");let i=e.now??Date.now(),s=new Date(i).toISOString();if(!t.source?.trim())throw new Error('a fact needs a source: a system, URL, command or "owner said"');if(!t.subject?.trim()||!t.attribute?.trim()||!t.value?.trim())throw new Error("a fact needs a subject, an attribute and a value");let o=t.verifiedAt==="now"?i:Date.parse(t.verifiedAt??""),a=Number.isFinite(o),c=a?new Date(Math.min(o,i)).toISOString():s,u=F(t.volatility)?t.volatility:$(t.attribute,`${t.subject} ${t.attribute} is ${t.value}`),h={source:t.source.trim(),verifiedAt:c,verifiedBy:t.verifiedBy||"unknown",volatility:u,...typeof t.ttlDays=="number"?{ttlDays:t.ttlDays}:{}},b=V(t.subject,t.attribute),m=this.update(f=>{let n=f.facts.find(y=>y.id===b);if(!n){let y={id:b,subject:t.subject.trim(),attribute:t.attribute.trim(),value:t.value.trim(),...h,createdAt:s,updatedAt:s,...!a&&!e.confirmedBy?{undated:!0}:{},...e.confirmedBy?{confirmedBy:e.confirmedBy}:{}};return f.facts.push(y),{save:!0,result:{status:"created",fact:y}}}let A=Date.parse(n.verifiedAt),k=a&&(n.undated||!Number.isFinite(A)||Date.parse(c)>A);return d(n.value)===d(t.value)?!k&&!e.confirmedBy?{save:!1,result:{status:"unchanged",fact:n}}:(Object.assign(n,h,{updatedAt:s},e.confirmedBy?{confirmedBy:e.confirmedBy}:{}),delete n.undated,{save:!0,result:{status:"verified",fact:n}}):!e.confirmedBy&&(!k||n.confirmedBy)?{save:!1,result:{contradiction:n}}:(n.history=[...n.history??[],{value:n.value,source:n.source,verifiedAt:n.verifiedAt,verifiedBy:n.verifiedBy,replacedAt:s}].slice(-10),n.value=t.value.trim(),Object.assign(n,h,{updatedAt:s}),delete n.undated,e.confirmedBy?n.confirmedBy=e.confirmedBy:delete n.confirmedBy,{save:!0,result:{status:"updated",fact:n}})});if("contradiction"in m){let f=Y(this.wikiDir,m.contradiction,{...t,verifiedAt:a?c:"undated"});return{status:"contradiction",fact:m.contradiction,questionId:f.id,questionClosed:f.closed}}return m}};function Y(r,t,e){let i=new v(r),s={kind:"contradiction",agentId:e.verifiedBy||"unknown",path:"_facts.json",subject:t.subject,field:`${t.attribute}=${d(e.value)}`,tier:"pillar",factId:t.id,proposed:{value:e.value.trim(),source:e.source.trim(),verifiedAt:e.verifiedAt,verifiedBy:e.verifiedBy},question:`${t.subject} \xB7 ${t.attribute}: the wiki says "${t.value}" (${t.source}, checked ${t.verifiedAt.slice(0,10)}), but ${e.verifiedBy} reports "${e.value.trim()}" (${e.source.trim()}, checked ${e.verifiedAt.slice(0,10)}). Which is true?`},o=j(s.kind,s.agentId,s.subject,s.field);i.add([s]);let a=i.list().find(c=>c.id===o);return a?a.status==="answered"||a.status==="dismissed"?{closed:a.status}:{id:o}:{}}function dt(r){return new v(r).list("open").filter(t=>t.kind==="contradiction").map(t=>({type:"contradiction",articles:[`_facts.json#${t.factId??"?"}`],message:`[${t.id}] ${t.question}`,confidence:"high"}))}function ut(r,t=Date.now()){return r.undated===!0||x(r,t)}function lt(r,t){let e=d(r),i=null;for(let s of t){let o=d(s.subject);if(o.length<3||!e.includes(o))continue;let a=d(s.attribute).split(" ").filter(u=>u.length>2);(e.includes(d(s.value))||s.volatility!=="stable"&&S(r)===s.volatility||a.length>0&&a.every(u=>e.includes(u)))&&(!i||s.subject.length>i.subject.length)&&(i=s)}return i}export{R as a,V as b,T as c,dt as d,ut as e,lt as f};
|
|
3
|
-
//# sourceMappingURL=chunk-KA2UIZXG.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/wiki/facts/ledger.ts","../src/wiki/facts/ledger-file.ts"],"sourcesContent":["import { createHash } from \"crypto\"\nimport { existsSync, statSync } from \"fs\"\nimport { resolve } from \"path\"\nimport { readLedger, withLock, writeLedger } from \"./ledger-file\"\nimport { classifyAttribute, classifyFact, isFactClass, isPastTtl, type FactClass, type Provenance } from \"@/agents/fact-freshness\"\nimport type { ContradictionIssue } from \"../lint-contradictions\"\nimport { QuestionStore, questionId } from \"../questions\"\n\n// --- The wiki fact ledger: durable facts with provenance (#273) ---\n//\n// Articles are prose. A fact an agent states to a person (\"the vendor\n// account is past due\") needs more than prose: where it came from, when\n// it was last checked, by whom, and how long it stays true. This is that\n// record — one small JSON sidecar beside `_questions.json`, skipped by the\n// article index like every `_` file.\n//\n// Every other store references it: memory lines that restate a ledger\n// fact are replaced by a reference at injection (agents/memory-context),\n// and memo claims wait here as proposals (fact-proposals.ts) instead of\n// becoming memory.\n//\n// Overwrite safety: a write that disagrees with the current value needs a\n// check newer than the current one, or a person's confirmation. Otherwise\n// the old value stays and a contradiction question joins the wiki's\n// question queue (`agentx wiki questions`), where the answer is written\n// back through here.\n\nexport interface WikiFact extends Provenance {\n id: string\n subject: string\n attribute: string\n value: string\n createdAt: string\n updatedAt: string\n /** Set when a person confirmed the value over a newer-dated one. */\n confirmedBy?: string\n /** Recorded with no check time: never counts as checked, so it is\n * always shown UNVERIFIED until a dated check or a person confirms it. */\n undated?: true\n /** Earlier values, newest last. Nothing is replaced silently. */\n history?: Array<{ value: string; source: string; verifiedAt: string; verifiedBy: string; replacedAt: string }>\n}\n\nexport interface FactInput {\n subject: string\n attribute: string\n value: string\n source: string\n verifiedBy: string\n /** When the source was checked (ISO date, or \"now\"). Without it the\n * write is undated and never counts as newer than an existing fact. */\n verifiedAt?: string\n volatility?: FactClass\n ttlDays?: number\n}\n\nexport type WriteStatus = \"created\" | \"verified\" | \"unchanged\" | \"updated\" | \"contradiction\"\n\nexport interface WriteResult {\n status: WriteStatus\n fact: WikiFact\n /** The queued question, for a contradiction. */\n questionId?: string\n /** Set instead of questionId when a person already answered or\n * dismissed this same claim, so it is not asked again. */\n questionClosed?: \"answered\" | \"dismissed\"\n}\n\nexport interface LedgerFile {\n version: 1\n facts: WikiFact[]\n proposals: import(\"./fact-proposals\").FactProposal[]\n}\n\nconst norm = (s: string) => s.toLowerCase().replace(/\\s+/g, \" \").trim()\n\n/**\n * Confirming a fact is a person's act. A process an agent runs carries\n * AGENTX_AGENT_ID (the runtime sets it for every agent), so a confirmation\n * from inside one is refused: an agent can't outrank a person, or itself.\n */\nimport { assertPerson } from \"./person\"\nexport { assertPerson }\n\n/** Stable per subject and attribute, so a re-check lands on the same fact. */\nexport function factId(subject: string, attribute: string): string {\n return \"f-\" + createHash(\"sha1\").update(`${norm(subject)}\\u0000${norm(attribute)}`).digest(\"hex\").slice(0, 10)\n}\n\nexport class FactLedger {\n readonly file: string\n private cache?: { mtimeMs: number; data: LedgerFile }\n private reported?: number\n\n constructor(readonly wikiDir: string) {\n this.file = resolve(wikiDir, \"_facts.json\")\n }\n\n /** The ledger as stored. Throws LedgerCorruptError on a file that does\n * not parse: it is never read as empty, so it is never overwritten. */\n load(): LedgerFile {\n if (!existsSync(this.file)) return { version: 1, facts: [], proposals: [] }\n const mtimeMs = statSync(this.file).mtimeMs\n if (this.cache?.mtimeMs === mtimeMs) return structuredClone(this.cache.data)\n let raw\n try {\n raw = readLedger(this.file)\n } catch (e) {\n // Once per version of the bad file, not once per prompt.\n if (this.reported !== mtimeMs) {\n this.reported = mtimeMs\n console.error(`[wiki-facts] ${(e as Error).message}`)\n }\n throw e\n }\n const data: LedgerFile = { version: 1, facts: (raw?.facts ?? []) as WikiFact[], proposals: (raw?.proposals ?? []) as LedgerFile[\"proposals\"] }\n this.cache = { mtimeMs, data }\n return structuredClone(data)\n }\n\n /**\n * Load, change and save under the ledger's lock, so concurrent writers\n * (a daemon proposing memo claims, a CLI `set`) can't drop each other's\n * change. `fn` returns whether to save, and a result.\n */\n update<T>(fn: (data: LedgerFile) => { save: boolean; result: T }): T {\n return withLock(this.file, () => {\n this.cache = undefined\n const data = this.load()\n const { save, result } = fn(data)\n if (save) {\n writeLedger(this.file, data)\n this.cache = undefined\n }\n return result\n })\n }\n\n list(): WikiFact[] { return this.load().facts }\n\n get(id: string): WikiFact | null {\n return this.list().find((f) => f.id === id || (id.length >= 6 && f.id.startsWith(id))) ?? null\n }\n\n /**\n * Record a checked fact. Refuses a fact with no source. A different value\n * replaces the current one only with a dated check newer than the current\n * one, or `confirmedBy`. A value a person confirmed is replaced only by\n * another confirmation. Otherwise the current value stays and a\n * contradiction question is raised.\n *\n * A write with no `verifiedAt` is undated: it can create a fact, but it\n * never counts as newer than a fact already there.\n */\n write(input: FactInput, opts: { confirmedBy?: string; now?: number } = {}): WriteResult {\n if (opts.confirmedBy) assertPerson(\"confirm a fact\")\n const now = opts.now ?? Date.now()\n const nowIso = new Date(now).toISOString()\n if (!input.source?.trim()) throw new Error(\"a fact needs a source: a system, URL, command or \\\"owner said\\\"\")\n if (!input.subject?.trim() || !input.attribute?.trim() || !input.value?.trim()) {\n throw new Error(\"a fact needs a subject, an attribute and a value\")\n }\n const checked = input.verifiedAt === \"now\" ? now : Date.parse(input.verifiedAt ?? \"\")\n const dated = Number.isFinite(checked)\n // A check can't be dated after it happened.\n const verifiedAt = dated ? new Date(Math.min(checked, now)).toISOString() : nowIso\n const volatility = isFactClass(input.volatility)\n ? input.volatility\n : classifyAttribute(input.attribute, `${input.subject} ${input.attribute} is ${input.value}`)\n const provenance: Provenance = {\n source: input.source.trim(), verifiedAt, verifiedBy: input.verifiedBy || \"unknown\", volatility,\n ...(typeof input.ttlDays === \"number\" ? { ttlDays: input.ttlDays } : {}),\n }\n const id = factId(input.subject, input.attribute)\n\n const out = this.update<WriteResult | { contradiction: WikiFact }>((data) => {\n const existing = data.facts.find((f) => f.id === id)\n if (!existing) {\n const fact: WikiFact = {\n id, subject: input.subject.trim(), attribute: input.attribute.trim(), value: input.value.trim(),\n ...provenance, createdAt: nowIso, updatedAt: nowIso,\n ...(!dated && !opts.confirmedBy ? { undated: true as const } : {}),\n ...(opts.confirmedBy ? { confirmedBy: opts.confirmedBy } : {}),\n }\n data.facts.push(fact)\n return { save: true, result: { status: \"created\", fact } }\n }\n\n const prior = Date.parse(existing.verifiedAt)\n // Any dated check beats a fact that was never dated.\n const newer = dated && (existing.undated || !Number.isFinite(prior) || Date.parse(verifiedAt) > prior)\n if (norm(existing.value) === norm(input.value)) {\n if (!newer && !opts.confirmedBy) return { save: false, result: { status: \"unchanged\", fact: existing } }\n Object.assign(existing, provenance, { updatedAt: nowIso }, opts.confirmedBy ? { confirmedBy: opts.confirmedBy } : {})\n delete existing.undated\n return { save: true, result: { status: \"verified\", fact: existing } }\n }\n\n // A person's confirmation outranks any agent's date.\n if (!opts.confirmedBy && (!newer || existing.confirmedBy)) {\n return { save: false, result: { contradiction: existing } }\n }\n\n existing.history = [...(existing.history ?? []), {\n value: existing.value, source: existing.source, verifiedAt: existing.verifiedAt,\n verifiedBy: existing.verifiedBy, replacedAt: nowIso,\n }].slice(-10)\n existing.value = input.value.trim()\n Object.assign(existing, provenance, { updatedAt: nowIso })\n delete existing.undated\n if (opts.confirmedBy) existing.confirmedBy = opts.confirmedBy\n else delete existing.confirmedBy\n return { save: true, result: { status: \"updated\", fact: existing } }\n })\n\n if (\"contradiction\" in out) {\n const q = raiseContradiction(this.wikiDir, out.contradiction, { ...input, verifiedAt: dated ? verifiedAt : \"undated\" })\n return { status: \"contradiction\", fact: out.contradiction, questionId: q.id, questionClosed: q.closed }\n }\n return out\n }\n}\n\nfunction raiseContradiction(wikiDir: string, current: WikiFact, input: FactInput & { verifiedAt: string }): { id?: string; closed?: \"answered\" | \"dismissed\" } {\n const store = new QuestionStore(wikiDir)\n const item = {\n kind: \"contradiction\" as const,\n agentId: input.verifiedBy || \"unknown\",\n path: \"_facts.json\",\n subject: current.subject,\n // One question per refused value: a second, different claim is a new\n // question, while repeating the same claim does not ask twice.\n field: `${current.attribute}=${norm(input.value)}`,\n tier: \"pillar\",\n factId: current.id,\n proposed: { value: input.value.trim(), source: input.source.trim(), verifiedAt: input.verifiedAt, verifiedBy: input.verifiedBy },\n question:\n `${current.subject} · ${current.attribute}: the wiki says \"${current.value}\" ` +\n `(${current.source}, checked ${current.verifiedAt.slice(0, 10)}), but ${input.verifiedBy} reports ` +\n `\"${input.value.trim()}\" (${input.source.trim()}, checked ${input.verifiedAt.slice(0, 10)}). Which is true?`,\n }\n const id = questionId(item.kind, item.agentId, item.subject, item.field)\n store.add([item])\n // Undefined when the queue could not take it (an unreadable file): the\n // old value still stands, and the caller says the question is missing.\n // Only an open question is one the owner will see. A person who already\n // answered or dismissed this same claim is not asked again; a question\n // that is missing altogether means the queue could not take it (an\n // unreadable file), and the old value still stands.\n const q = store.list().find((x) => x.id === id)\n if (!q) return {}\n if (q.status === \"answered\" || q.status === \"dismissed\") return { closed: q.status }\n return { id }\n}\n\n/** Open fact contradictions, in the shape `wiki lint` reports. */\nexport function factContradictions(wikiDir: string): ContradictionIssue[] {\n return new QuestionStore(wikiDir).list(\"open\")\n .filter((q) => q.kind === \"contradiction\")\n .map((q) => ({\n type: \"contradiction\" as const,\n articles: [`_facts.json#${q.factId ?? \"?\"}`],\n message: `[${q.id}] ${q.question}`,\n confidence: \"high\" as const,\n }))\n}\n\n/** A fact is stale when it is past its class TTL. */\nexport function isStaleFact(f: WikiFact, now = Date.now()): boolean {\n return f.undated === true || isPastTtl(f, now)\n}\n\n/**\n * The ledger fact a memory line restates, if any. The line must name the\n * fact's subject, and either repeat its value, share its volatility class,\n * or name its attribute.\n */\nexport function matchFact(content: string, facts: WikiFact[]): WikiFact | null {\n const text = norm(content)\n let best: WikiFact | null = null\n for (const f of facts) {\n const subject = norm(f.subject)\n if (subject.length < 3 || !text.includes(subject)) continue\n const attrWords = norm(f.attribute).split(\" \").filter((w) => w.length > 2)\n const hit = text.includes(norm(f.value))\n || (f.volatility !== \"stable\" && classifyFact(content) === f.volatility)\n || (attrWords.length > 0 && attrWords.every((w) => text.includes(w)))\n if (hit && (!best || f.subject.length > best.subject.length)) best = f\n }\n return best\n}\n","import { closeSync, existsSync, mkdirSync, openSync, readFileSync, renameSync, statSync, unlinkSync, writeFileSync } from \"fs\"\nimport { dirname } from \"path\"\n\n// --- The fact ledger's file: strict reads, locked writes (#273) ---\n//\n// Two rules keep the ledger from losing facts with nobody watching:\n// 1. A file that does not parse is never treated as empty. Reading it\n// throws LedgerCorruptError, so no write can replace it; the file is\n// left exactly as it is for a person to repair.\n// 2. load → modify → save runs under a lockfile, so a daemon proposing\n// memo claims and a CLI `set` or `approve` can't drop each other's\n// write.\n\nexport class LedgerCorruptError extends Error {\n constructor(readonly file: string, cause: string) {\n super(\n `fact ledger ${file} is unreadable (${cause}). Nothing was written to it. ` +\n `Repair the JSON, or move the file aside to start an empty ledger.`,\n )\n this.name = \"LedgerCorruptError\"\n }\n}\n\nexport interface RawLedger {\n facts: unknown[]\n proposals: unknown[]\n}\n\nconst FACT_FIELDS = [\"id\", \"subject\", \"attribute\", \"value\", \"source\", \"verifiedAt\", \"verifiedBy\", \"volatility\"]\nconst PROPOSAL_FIELDS = [\"id\", \"status\", \"claim\", \"source\", \"verifiedAt\", \"agentId\"]\n\nconst hasStrings = (o: unknown, keys: string[]) =>\n !!o && typeof o === \"object\" && !Array.isArray(o) && keys.every((k) => typeof (o as Record<string, unknown>)[k] === \"string\")\n\n/** Null when the file does not exist; throws when it exists but is not a ledger. */\nexport function readLedger(file: string): RawLedger | null {\n if (!existsSync(file)) return null\n let raw: any\n try {\n raw = JSON.parse(readFileSync(file, \"utf-8\"))\n } catch (e) {\n throw new LedgerCorruptError(file, String((e as Error)?.message ?? e))\n }\n if (!raw || typeof raw !== \"object\" || !Array.isArray(raw.facts) || (raw.proposals !== undefined && !Array.isArray(raw.proposals))) {\n throw new LedgerCorruptError(file, \"not a ledger: expected { facts: [], proposals: [] }\")\n }\n // Every entry is read by prompt rendering; one malformed entry must stop\n // the ledger being used, not crash a prompt or be dropped on the next save.\n const bad = raw.facts.findIndex((f: any) => !hasStrings(f, FACT_FIELDS))\n if (bad >= 0) throw new LedgerCorruptError(file, `fact #${bad + 1} is missing ${FACT_FIELDS.join(\"/\")}`)\n const badP = (raw.proposals ?? []).findIndex((p: any) => !hasStrings(p, PROPOSAL_FIELDS))\n if (badP >= 0) throw new LedgerCorruptError(file, `proposal #${badP + 1} is missing ${PROPOSAL_FIELDS.join(\"/\")}`)\n return { facts: raw.facts, proposals: raw.proposals ?? [] }\n}\n\nexport function writeLedger(file: string, data: unknown): void {\n mkdirSync(dirname(file), { recursive: true })\n const tmp = `${file}.${process.pid}.tmp`\n writeFileSync(tmp, JSON.stringify(data, null, 2) + \"\\n\")\n renameSync(tmp, file)\n}\n\nconst sleep = (ms: number) => Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms)\n\n/** Locks this process holds, so a caller already inside one (approve →\n * write) re-enters instead of waiting on itself. */\nconst held = new Set<string>()\n\nconst isStale = (path: string, staleMs: number) => {\n try { return Date.now() - statSync(path).mtimeMs > staleMs } catch { return false }\n}\n\n/**\n * Take over a crashed holder's lock. Only one waiter may do it at a time\n * (a second `.takeover` lock), and it re-checks under that lock, so two\n * waiters that both saw the old lock can't both delete it — the second\n * would otherwise delete the first one's fresh lock.\n */\nexport function takeOver(lock: string, staleMs: number): void {\n const guard = `${lock}.takeover`\n if (isStale(guard, staleMs)) { try { unlinkSync(guard) } catch { /* another waiter did */ } }\n let fd: number\n try { fd = openSync(guard, \"wx\") } catch { return }\n try {\n if (isStale(lock, staleMs)) unlinkSync(lock)\n } catch {\n // Not removable (a directory, a permission): the wait times out with\n // an error naming the lock, rather than spinning.\n } finally {\n closeSync(fd)\n try { unlinkSync(guard) } catch { /* gone */ }\n }\n}\n\n/**\n * Run `fn` holding `<file>.lock`. Waits up to `timeoutMs` for another\n * holder; a lock older than `staleMs` is a crashed holder and is taken\n * over. Re-entrant within one process.\n */\nexport function withLock<T>(file: string, fn: () => T, opts: { timeoutMs?: number; staleMs?: number } = {}): T {\n const lock = `${file}.lock`\n if (held.has(lock)) return fn()\n const timeoutMs = opts.timeoutMs ?? 3000\n const staleMs = opts.staleMs ?? 15_000\n mkdirSync(dirname(lock), { recursive: true })\n const deadline = Date.now() + timeoutMs\n let fd: number | undefined\n while (fd === undefined) {\n try {\n fd = openSync(lock, \"wx\")\n } catch (e: any) {\n if (e?.code !== \"EEXIST\") throw e\n if (isStale(lock, staleMs)) takeOver(lock, staleMs)\n if (Date.now() > deadline) {\n throw new Error(`fact ledger is busy (${lock}). If no agentx command is running, delete that lock and try again.`)\n }\n sleep(25)\n }\n }\n held.add(lock)\n try {\n return fn()\n } finally {\n held.delete(lock)\n closeSync(fd)\n try { unlinkSync(lock) } catch { /* already gone */ }\n }\n}\n"],"mappings":"mHAAA,OAAS,cAAAA,MAAkB,SAC3B,OAAS,cAAAC,EAAY,YAAAC,MAAgB,KACrC,OAAS,WAAAC,MAAe,OCFxB,OAAS,aAAAC,EAAW,cAAAC,EAAY,aAAAC,EAAW,YAAAC,EAAU,gBAAAC,EAAc,cAAAC,EAAY,YAAAC,EAAU,cAAAC,EAAY,iBAAAC,MAAqB,KAC1H,OAAS,WAAAC,MAAe,OAYjB,IAAMC,EAAN,cAAiC,KAAM,CAC5C,YAAqBC,EAAcC,EAAe,CAChD,MACE,eAAeD,oBAAuBC,kGAExC,EAJmB,UAAAD,EAKnB,KAAK,KAAO,oBACd,CACF,EAOME,EAAc,CAAC,KAAM,UAAW,YAAa,QAAS,SAAU,aAAc,aAAc,YAAY,EACxGC,EAAkB,CAAC,KAAM,SAAU,QAAS,SAAU,aAAc,SAAS,EAE7EC,EAAa,CAACC,EAAYC,IAC9B,CAAC,CAACD,GAAK,OAAOA,GAAM,UAAY,CAAC,MAAM,QAAQA,CAAC,GAAKC,EAAK,MAAOC,GAAM,OAAQF,EAA8BE,CAAC,GAAM,QAAQ,EAGvH,SAASC,EAAWR,EAAgC,CACzD,GAAI,CAACV,EAAWU,CAAI,EAAG,OAAO,KAC9B,IAAIS,EACJ,GAAI,CACFA,EAAM,KAAK,MAAMhB,EAAaO,EAAM,OAAO,CAAC,CAC9C,OAASU,EAAP,CACA,MAAM,IAAIX,EAAmBC,EAAM,OAAQU,GAAa,SAAWA,CAAC,CAAC,CACvE,CACA,GAAI,CAACD,GAAO,OAAOA,GAAQ,UAAY,CAAC,MAAM,QAAQA,EAAI,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OAAO,IAAIqC,EAAcrC,CAAO,EAAE,KAAK,MAAM,EAC1C,OAAQiC,GAAMA,EAAE,OAAS,eAAe,EACxC,IAAKA,IAAO,CACX,KAAM,gBACN,SAAU,CAAC,eAAeA,EAAE,QAAU,KAAK,EAC3C,QAAS,IAAIA,EAAE,OAAOA,EAAE,WACxB,WAAY,MACd,EAAE,CACN,CAGO,SAASS,GAAY3B,EAAaI,EAAM,KAAK,IAAI,EAAY,CAClE,OAAOJ,EAAE,UAAY,IAAQ4B,EAAU5B,EAAGI,CAAG,CAC/C,CAOO,SAASyB,GAAUC,EAAiBC,EAAoC,CAC7E,IAAMC,EAAOjD,EAAK+C,CAAO,EACrBG,EAAwB,KAC5B,QAAWjC,KAAK+B,EAAO,CACrB,IAAMnD,EAAUG,EAAKiB,EAAE,OAAO,EAC9B,GAAIpB,EAAQ,OAAS,GAAK,CAACoD,EAAK,SAASpD,CAAO,EAAG,SACnD,IAAMsD,EAAYnD,EAAKiB,EAAE,SAAS,EAAE,MAAM,GAAG,EAAE,OAAQmC,GAAMA,EAAE,OAAS,CAAC,GAC7DH,EAAK,SAASjD,EAAKiB,EAAE,KAAK,CAAC,GACjCA,EAAE,aAAe,UAAYoC,EAAaN,CAAO,IAAM9B,EAAE,YACzDkC,EAAU,OAAS,GAAKA,EAAU,MAAOC,GAAMH,EAAK,SAASG,CAAC,CAAC,KACzD,CAACF,GAAQjC,EAAE,QAAQ,OAASiC,EAAK,QAAQ,UAASA,EAAOjC,GAEvE,OAAOiC,CACT","names":["createHash","existsSync","statSync","resolve","closeSync","existsSync","mkdirSync","openSync","readFileSync","renameSync","statSync","unlinkSync","writeFileSync","dirname","LedgerCorruptError","file","cause","FACT_FIELDS","PROPOSAL_FIELDS","hasStrings","o","keys","k","readLedger","raw","e","bad","f","badP","p","writeLedger","data","tmp","sleep","ms","held","isStale","path","staleMs","takeOver","lock","guard","fd","withLock","fn","opts","timeoutMs","deadline","norm","s","factId","subject","attribute","createHash","norm","FactLedger","wikiDir","resolve","existsSync","mtimeMs","statSync","raw","readLedger","e","data","fn","withLock","save","result","writeLedger","id","f","input","opts","assertPerson","now","nowIso","checked","dated","verifiedAt","volatility","isFactClass","classifyAttribute","provenance","out","existing","fact","prior","newer","q","raiseContradiction","current","store","QuestionStore","item","questionId","x","factContradictions","isStaleFact","isPastTtl","matchFact","content","facts","text","best","attrWords","w","classifyFact"]}
|
package/dist/chunk-KXR6GVL7.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{a as d,c as F}from"./chunk-KA2UIZXG.js";import{c as u,j as g,k as f}from"./chunk-GQ76J72O.js";import{a as l}from"./chunk-ILEC3IAV.js";import{createHash as w}from"crypto";var m=(t,r)=>"fp-"+w("sha1").update(`${t}\0${r.toLowerCase().replace(/\s+/g," ").trim()}`).digest("hex").slice(0,10);function b(t){let r=t.replace(/^[-*•]\s*/,"").replace(/\s*\((?:[^)]*)\)\s*$/,"").trim(),s=r.match(/^(.{2,60}?)\s+(?:is|are|was|were|has been|went|got)\s+(.{1,80})$/i);if(!s)return{};let a=u(r);return{subject:s[1].trim(),attribute:a==="stable"?"state":`${a} status`,value:s[2].trim()}}function y(t,r,s){let a=t.at??new Date().toISOString(),e=f(s),o=u(s);return{id:r,status:"pending",claim:s,...b(s),volatility:o==="stable"?"work-state":o,source:e?.source??`${t.origin} (unchecked summary)`,verifiedAt:e?.verifiedAt??a,verifiedBy:t.agentId,origin:t.origin,agentId:t.agentId,...t.chat?{chat:t.chat}:{},createdAt:a}}function I(t,r){return r.length===0?[]:t.update(s=>{let a=[],e=!1;for(let o of r){let i=o.claim.replace(/^[-*•]\s*/,"").trim();if(!i)continue;let c=m(o.agentId,i),n=s.proposals.find(v=>v.id===c);if(n){a.push(n);continue}let p=y(o,c,i);s.proposals.push(p),a.push(p),e=!0}return{save:e,result:a}})}function A(t,r){return t.load().proposals.filter(s=>!r||s.status===r)}var P=(t,r)=>t.id===r||r.length>=6&&t.id.startsWith(r);function j(t,r){return t.load().proposals.find(s=>P(s,r))}function h(t,r,s){return t.update(a=>{let e=a.proposals.find(o=>P(o,r));if(!e)throw new Error(`no fact proposal "${r}"`);if(e.status!=="pending")throw new Error(`proposal ${e.id} is already ${e.status}`);return Object.assign(e,s),{save:!0,result:e}})}function B(t,r,s,a={}){return l("approve a fact proposal"),d(t.file,()=>$(t,r,s,a))}function $(t,r,s,a){let e=j(t,r);if(!e)throw new Error(`no fact proposal "${r}"`);if(e.status!=="pending")throw new Error(`proposal ${e.id} is already ${e.status}`);let o=a.subject??e.subject,i=a.attribute??e.attribute,c=a.value??e.value;if(!o||!i||!c)throw new Error("could not read a subject, attribute and value from the claim; pass --subject, --attribute and --value");let n=t.write({subject:o,attribute:i,value:c,source:a.source??e.source,verifiedBy:e.verifiedBy,verifiedAt:e.verifiedAt,volatility:e.volatility},{confirmedBy:s});return{proposal:h(t,e.id,{status:"approved",decidedAt:new Date().toISOString(),decidedBy:s}),write:n}}function E(t,r,s,a){return l("reject a fact proposal"),h(t,r,{status:"rejected",decidedAt:new Date().toISOString(),decidedBy:s,...a?{reason:a}:{}})}function C(t,r,s){let{workState:a,claims:e}=g(r);if(e.length===0)return{workState:a.join(`
|
|
2
|
-
`),pinned:r,proposals:[]};let o=[],i;try{o=I(new F(t),e.map(n=>({claim:n,...s})))}catch(n){i=String(n?.message??n)}let c=e.map((n,p)=>`- UNVERIFIED claim (${o[p]?`wiki proposal ${o[p].id}`:"not checked"}): ${n.replace(/^[-*•]\s*/,"")}`);return{workState:a.join(`
|
|
3
|
-
`),pinned:[...a,...c].join(`
|
|
4
|
-
`),proposals:o,...i?{error:i}:{}}}export{b as a,I as b,A as c,B as d,E as e,C as f};
|
|
5
|
-
//# sourceMappingURL=chunk-KXR6GVL7.js.map
|
package/dist/chunk-NY7NHGVT.js
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import{b as I}from"./chunk-KEXBEUSU.js";import{a as P}from"./chunk-RGZARSHV.js";import{a as E,b as R,c as j,d as M,e as T,j as O}from"./chunk-ERULJ2ZL.js";import{y as L,z as U}from"./chunk-4XMALK7X.js";import{c as _,d as C}from"./chunk-QOYAX2FT.js";import{readFileSync as $,writeFileSync as w,appendFileSync as J,existsSync as b,mkdirSync as x,readdirSync as D,statSync as K}from"fs";import{resolve as u,join as V,relative as k,dirname as F}from"path";U();function N(v){return P.includes(v)}function Y(v){if(!v)return;let t;try{t=JSON.parse(v)}catch{return}if(!Array.isArray(t))return;let e=t.filter(r=>typeof r=="object"&&r!==null&&typeof r.property=="string"&&r.property!==""&&typeof r.value=="string"&&r.value!=="");return e.length?e:void 0}function z(v,t){let e=i=>{let n=/^(.*Z)(?:-(\d+))?\.md$/.exec(i);return n?[n[1],n[2]?Number(n[2]):0]:[i,0]},[r,a]=e(v),[o,s]=e(t);return r<o?-1:r>o?1:a-s}var B=class{baseDir;rawDir;log;constructor(t=u(process.cwd(),".agentx/wiki"),e=console.error.bind(console,"[wiki]")){this.baseDir=t,this.rawDir=u(t,"raw/entries"),this.log=e,x(this.rawDir,{recursive:!0}),x(u(t,"raw"),{recursive:!0}),this.ensureSchema()}canRead(t,e){return t.access==="public"?!0:e?!!(t.owner===e||t.access==="shared"&&t.sharedWith?.includes(e)):!1}canWrite(t,e){return t.owner===e}addEntry(t){let e=`${t.date}_${t.id}.md`,r=u(this.rawDir,e),a=["---",`id: ${t.id}`,`date: ${t.date}`,`agent: ${t.agentId}`,`source: ${t.source}`];if(t.sourceContext&&a.push(`context: ${t.sourceContext}`),t.meta)for(let[o,s]of Object.entries(t.meta))a.push(`${o}: ${JSON.stringify(s)}`);return a.push("---","",t.content),w(r,a.join(`
|
|
2
|
-
`)),this.appendLog("ingest",`${t.id} from ${t.agentId} via ${t.source}`),e}readEntries(t){if(t.length===0||!b(this.rawDir))return[];let e=new Set(t),r=[];for(let a of D(this.rawDir)){let o=a.replace(/\.md$/,"").replace(/^\d{4}-\d{2}-\d{2}_/,"");if(!e.has(o))continue;let s=this.parseEntry($(u(this.rawDir,a),"utf-8"),a);s&&r.push(s)}return r}listEntries(t){if(!b(this.rawDir))return[];let e=D(this.rawDir).filter(a=>a.endsWith(".md")).sort(),r=[];for(let a of e){let o=$(u(this.rawDir,a),"utf-8"),s=this.parseEntry(o,a);s&&(t?.agentId&&s.agentId!==t.agentId||t?.after&&s.date<t.after||t?.before&&s.date>t.before||r.push(s))}return r}parseEntry(t,e){let r=t.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);if(!r)return null;let a=r[1],o=r[2].trim(),s=c=>a.match(new RegExp(`^${c}:\\s*(.+)$`,"m"))?.[1]?.trim()||"",i=new Set(["id","date","agent","source","context"]),n={};for(let c of a.split(`
|
|
3
|
-
`)){let l=c.match(/^(\w+):\s*(.+)$/);if(!(!l||i.has(l[1])))try{n[l[1]]=JSON.parse(l[2])}catch{n[l[1]]=l[2].trim()}}return{id:s("id")||e.replace(".md",""),date:s("date"),agentId:s("agent"),source:s("source"),sourceContext:s("context")||void 0,content:o,meta:Object.keys(n).length>0?n:void 0}}writeArticle(t,e,r,a){let o=this.readArticle(t);if(o&&!this.canWrite(o.meta,a))return this.log(`Permission denied: "${a}" cannot write "${t}" (owner: ${o.meta.owner})`),!1;e.type&&!I(e.type)&&(this.log(`Dropping invalid article type "${e.type}" for "${t}" \u2014 enum is [person, project, place, concept, event, decision, pattern]`),e={...e,type:void 0});let s=u(this.baseDir,t);o&&this.saveVersion(t,s),x(F(s),{recursive:!0});let i=["---",`title: "${e.title}"`];e.type&&i.push(`type: ${e.type}`),e.related?.length&&i.push(`related: [${e.related.map(c=>`"${c}"`).join(", ")}]`),i.push(`tags: [${(e.tags||[]).map(c=>`"${c}"`).join(", ")}]`,`owner: ${e.owner}`,`access: ${e.access}`),e.sharedWith?.length&&i.push(`shared_with: [${e.sharedWith.map(c=>`"${c}"`).join(", ")}]`),i.push(`created: ${e.created}`,`last_updated: ${e.lastUpdated}`,`sources: [${e.sources.map(c=>`"${c}"`).join(", ")}]`),e.graphPath?.length&&i.push(`graph_path: [${e.graphPath.map(c=>`"${c}"`).join(", ")}]`),e.class&&i.push(`class: ${e.class}`),e.importance&&i.push(`importance: ${e.importance}`),e.importanceProposed&&i.push(`importance_proposed: ${e.importanceProposed}`),e.date&&i.push(`date: ${e.date}`),e.rolledUpInto&&i.push(`rolled_up_into: ${JSON.stringify(e.rolledUpInto)}`),e.aliases?.length&&i.push(`aliases: ${JSON.stringify(e.aliases)}`),e.statements?.length&&i.push(`statements: ${JSON.stringify(e.statements)}`),i.push("---","",r),w(s,i.join(`
|
|
4
|
-
`));let n=o?"update":"create";return this.appendLog(n,`${e.title} [${(e.tags||[]).slice(0,5).join(", ")}] by ${a} at ${t}`),!0}saveVersion(t,e){try{if(!b(e))return;let r=$(e,"utf-8"),a=new Date().toISOString().replace(/[:.]/g,"-"),o=u(this.baseDir,"_versions",t.replace(/\.md$/,""));x(o,{recursive:!0});for(let s=0;;s++)try{w(u(o,`${s?`${a}-${s}`:a}.md`),r,{flag:"wx"});return}catch(i){if(i.code!=="EEXIST")throw i}}catch{}}getVersions(t){let e=u(this.baseDir,"_versions",t.replace(/\.md$/,""));if(!b(e))return[];try{return D(e).filter(r=>r.endsWith(".md")).sort(z).reverse().map(r=>({timestamp:r.replace(/\.md$/,"").replace(/-/g,(a,o)=>o<19?o===10?"T":o===13||o===16?":":"-":a),path:u(e,r)}))}catch{return[]}}restoreVersion(t,e){let r=this.getVersions(t),a=r.find(o=>o.timestamp===e)??r.find(o=>o.timestamp.startsWith(e));if(!a)return!1;try{let o=$(a.path,"utf-8"),s=u(this.baseDir,t);return this.saveVersion(t,s),w(s,o),this.appendLog("restore",`${t} restored to ${e}`),!0}catch{return!1}}readArticle(t){let e=u(this.baseDir,t);if(!b(e))return null;let r=$(e,"utf-8");return this.parseArticle(r,t)}readArticleAs(t,e){let r=this.readArticle(t);return!r||!this.canRead(r.meta,e)?null:r}parseArticle(t,e){let r=t.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);if(!r)return null;let a=r[1],o=r[2].trim(),s=W=>a.match(new RegExp(`^${W}:\\s*(.+)$`,"m"))?.[1]?.trim().replace(/^"(.*)"$/,"$1")||"",i=W=>{let A=a.match(new RegExp(`^${W}:\\s*\\[(.*)\\]$`,"m"));return A?[...A[1].matchAll(/\s*(?:"(.*?)"(?=\s*(?:,|$))|([^,]+))/g)].map(S=>(S[1]??S[2]).trim()).filter(Boolean):[]},n=s("type")||s("kind"),l=new Set(["person","project","place","concept","event","decision","pattern"]).has(n)?n:void 0,g=i("tags").filter((W,A,S)=>W&&S.indexOf(W)===A),d=i("related"),p=i("graph_path"),m=i("aliases"),h=s("importance"),f=s("importance_proposed"),y=s("date");return{meta:{title:s("title"),type:l,related:d.length?d:void 0,tags:g,owner:s("owner"),access:s("access")||"public",sharedWith:i("shared_with"),created:s("created"),lastUpdated:s("last_updated"),sources:i("sources"),graphPath:p.length?p:void 0,class:/^[a-z][a-z0-9_]*$/.test(s("class"))?s("class"):void 0,importance:N(h)?h:void 0,importanceProposed:N(f)?f:void 0,date:/^\d{4}-\d{2}-\d{2}/.test(y)?y.slice(0,10):void 0,rolledUpInto:s("rolled_up_into")||void 0,aliases:m.length?m:void 0,statements:Y(s("statements"))},content:o,path:e}}listCache=new Map;listArticles(t){return this.listCached(t)}listAllArticles(){return this.listCached(null)}listCached(t){let e=[],r=[];this.walkDir(this.baseDir,(n,c)=>{if(!n.endsWith(".md"))return;let l=k(this.baseDir,n);l.startsWith("raw/")||l.startsWith("_")||(e.push(l),r.push(`${l}:${c?.mtimeMs??"?"}:${c?.size??"?"}`))});let a=r.join("|"),o=t??"\0all",s=this.listCache.get(o);if(s&&s.signature===a)return s.articles.slice();let i=[];for(let n of e){let c=this.readArticle(n);c&&(t===null||this.canRead(c.meta,t))&&i.push(c)}return this.listCache.set(o,{signature:a,articles:i}),i.slice()}search(t,e,r=10){let a=t.toLowerCase(),o=[];if(this.walkDir(this.baseDir,d=>{if(!d.endsWith(".md"))return;let p=k(this.baseDir,d);if(p.startsWith("raw/")||p.startsWith("_"))return;let m=this.readArticle(p);!m||!this.canRead(m.meta,e)||o.push(m)}),o.length===0)return[];let s=o.map(d=>d.content),i=u(this.baseDir,"_bm25_cache.json"),n=C(s,i),c=_(t,n),l=new Map(c.map(d=>[d.docIndex,d.score]));return o.map((d,p)=>{let m=l.get(p)??0;return d.meta.title.toLowerCase().includes(a)&&(m+=10),d.meta.tags?.some(h=>h.toLowerCase().includes(a))&&(m+=5),{article:d,score:m}}).filter(d=>d.score>0).sort((d,p)=>p.score-d.score).slice(0,r).map(d=>d.article)}async findRelevantReranked(t,e,r=10,a={}){let o=Math.max(r,a.shortlist??R),s=this.findRelevant(t,e,o);if(s.length<2)return s.slice(0,r);let i=s.map((l,g)=>({id:`c${g}`,title:l.meta.title||`(untitled ${g})`,tags:l.meta.tags,excerpt:l.content})),n=await L(E,j({query:t,candidates:i,excerptChars:a.excerptChars}),M(i),{incumbent:{best:i[0].id},features:{agent:e??"unknown"}});return!n||n.mode!=="active"?s.slice(0,r):T(n.answers,i).ranked.map(l=>s[Number(l.slice(1))]).filter(l=>!!l).slice(0,r)}findRelevant(t,e,r=3,a,o={graph:.6,bm25:.4}){let s=[];if(this.walkDir(this.baseDir,h=>{if(!h.endsWith(".md"))return;let f=k(this.baseDir,h);if(f.startsWith("raw/")||f.startsWith("_"))return;let y=this.readArticle(f);!y||!this.canRead(y.meta,e)||s.push(y)}),s.length===0)return[];let i=s.map(h=>`${h.meta.title} ${(h.meta.tags||[]).join(" ")} ${h.content}`),n=u(this.baseDir,"_bm25_relevance_cache.json"),c=C(i,n),l=_(t,c),g=l.reduce((h,f)=>Math.max(h,f.score),0)||1,d=new Map(l.map(h=>[h.docIndex,h.score/g])),p=!!(a&&a.length>0);return s.map((h,f)=>{let y=d.get(f)??0,W=0;p&&h.meta.graphPath?.length&&(W=O(a,h.meta.graphPath));let A=p?o.graph*W+o.bm25*y:y;return{article:h,score:A}}).filter(h=>h.score>0).sort((h,f)=>f.score-h.score).slice(0,r).map(h=>h.article)}buildContext(t,e=4e3){if(t.length===0)return"";let r=["[Wiki Knowledge]"],a=0;for(let o of t){let s=`
|
|
5
|
-
## ${o.meta.title} [${(o.meta.tags||[]).slice(0,3).join(", ")}]`,i=o.content.length>600?o.content.slice(0,600)+"...":o.content,n=s+`
|
|
6
|
-
`+i;if(a+n.length>e)break;r.push(n),a+=n.length}return r.push(`
|
|
7
|
-
[End Wiki Knowledge]`),r.join(`
|
|
8
|
-
`)}rebuildIndex(){let t=[],e=new Map;this.walkDir(this.baseDir,s=>{if(!s.endsWith(".md"))return;let i=k(this.baseDir,s);if(i.startsWith("raw/")||i.startsWith("_"))return;let n=this.readArticle(i);if(!n)return;let c=n.content.match(/\[\[([^\]]+)\]\]/g)||[];for(let g of c){let d=g.replace(/\[\[|\]\]/g,"");e.set(d,(e.get(d)||0)+1)}let l=[n.meta.title.toLowerCase()];n.meta.tags&&l.push(...n.meta.tags.map(g=>g.toLowerCase())),t.push({path:i,title:n.meta.title,type:n.meta.type,related:n.meta.related,tags:n.meta.tags||[],owner:n.meta.owner,access:n.meta.access,sharedWith:n.meta.sharedWith,aliases:l,backlinks:e.get(n.meta.title)||0,sources:n.meta.sources,lastUpdated:n.meta.lastUpdated,graphPath:n.meta.graphPath})});let r={articles:t,lastRebuilt:new Date().toISOString()};w(u(this.baseDir,"_index.json"),JSON.stringify(r,null,2)),this.writeCatalog(t,r.lastRebuilt);let a=["# Wiki Index","",`Last rebuilt: ${r.lastRebuilt}`,""],o=new Map;for(let s of t){let i=s.access||"public",n=o.get(i)||[];n.push(s),o.set(i,n)}for(let[s,i]of Array.from(o.entries()).sort()){a.push(`## ${s}`,"");for(let n of i.sort((c,l)=>c.title.localeCompare(l.title))){let c=n.type?` [${n.type}]`:"";a.push(`- [${n.title}](${n.path})${c} \u2014 owner: ${n.owner}`)}a.push("")}return w(u(this.baseDir,"WIKI.md"),a.join(`
|
|
9
|
-
`)),this.log(`Index rebuilt: ${t.length} articles`),this.appendLog("rebuild-index",`${t.length} articles indexed`),r}writeCatalog(t,e){let r=["person","project","place","concept","event","decision","pattern","untyped"],a={person:"## People",project:"## Projects",place:"## Places",concept:"## Concepts",event:"## Events",decision:"## Decisions",pattern:"## Patterns",untyped:"## Untyped (needs migration)"},o=new Map;for(let i of t){let n=i.type||"untyped",c=o.get(n)||[];c.push(i),o.set(n,c)}let s=["# Wiki Content Catalog","",`_Last rebuilt: ${e}_`,"","Articles grouped by type. Agentic query walks this file first to pick candidates.",""];for(let i of r){let n=o.get(i);if(!(!n||n.length===0)){s.push(a[i]||`## ${i}`,"");for(let c of n.sort((l,g)=>l.title.localeCompare(g.title))){let l=c.access==="private"?" (private)":c.access==="shared"?" (shared)":"",g=c.related?.length?` \u2192 [[${c.related.slice(0,3).join("]], [[")}]]${c.related.length>3?", \u2026":""}`:"";s.push(`- [${c.title}](${c.path})${l}${g}`)}s.push("")}}w(u(this.baseDir,"_index.md"),s.join(`
|
|
10
|
-
`))}stats(){let t=0,e={},r={},a={};this.walkDir(this.baseDir,s=>{if(!s.endsWith(".md"))return;let i=k(this.baseDir,s);if(i.startsWith("raw/")||i.startsWith("_")||i==="WIKI.md")return;let n=this.readArticle(i);if(n){t++;for(let c of n.meta.tags||[])e[c]=(e[c]||0)+1;r[n.meta.access]=(r[n.meta.access]||0)+1,a[n.meta.owner]=(a[n.meta.owner]||0)+1}});let o=b(this.rawDir)?D(this.rawDir).filter(s=>s.endsWith(".md")).length:0;return{totalArticles:t,totalEntries:o,articlesByType:e,articlesByAccess:r,articlesByOwner:a}}appendLog(t,e){let r=u(this.baseDir,"log.md"),o=`## [${new Date().toISOString().replace("T"," ").slice(0,16)}] ${t} | ${e}
|
|
11
|
-
|
|
12
|
-
`;b(r)||w(r,`# Wiki Log
|
|
13
|
-
|
|
14
|
-
Chronological record of all wiki operations.
|
|
15
|
-
|
|
16
|
-
`),J(r,o)}getLog(t=20){let e=u(this.baseDir,"log.md");return b(e)?$(e,"utf-8").split(/^## /m).filter(o=>o.startsWith("[")).slice(-t).map(o=>o.trim()):[]}ensureSchema(){let t=u(this.baseDir,"_schema.md");if(b(t))return;w(t,`# Wiki Schema
|
|
17
|
-
|
|
18
|
-
A personal wiki maintained by LLMs. Karpathy pattern: plain files, aggressive tagging,
|
|
19
|
-
structure emerges from data. The wiki is a compounding artifact.
|
|
20
|
-
|
|
21
|
-
## Structure
|
|
22
|
-
|
|
23
|
-
\`\`\`
|
|
24
|
-
wiki/
|
|
25
|
-
_schema.md # This file
|
|
26
|
-
worldview.md # YOUR mental model \u2014 the LLM reads this during absorb
|
|
27
|
-
raw/entries/ # Immutable raw sources (conversations, imports, anything)
|
|
28
|
-
[LLM-chosen dirs] # Structure emerges from data \u2014 the LLM picks paths
|
|
29
|
-
\`\`\`
|
|
30
|
-
|
|
31
|
-
The LLM decides how to organize articles. You describe YOUR world in worldview.md.
|
|
32
|
-
|
|
33
|
-
## Article Format
|
|
34
|
-
|
|
35
|
-
\`\`\`yaml
|
|
36
|
-
---
|
|
37
|
-
title: "Staging Deployment Process"
|
|
38
|
-
tags: ["deploy", "staging", "devops", "process", "2026-04-06"]
|
|
39
|
-
owner: devops-agent
|
|
40
|
-
access: public
|
|
41
|
-
created: 2026-04-06
|
|
42
|
-
last_updated: 2026-04-06
|
|
43
|
-
sources: ["entry-id-1", "entry-id-2"]
|
|
44
|
-
---
|
|
45
|
-
|
|
46
|
-
Article content with [[wikilinks]] and section tags.
|
|
47
|
-
|
|
48
|
-
## Deploy Steps
|
|
49
|
-
<!-- tags: process, runbook, staging -->
|
|
50
|
-
Content specific to this section...
|
|
51
|
-
\`\`\`
|
|
52
|
-
|
|
53
|
-
## Tags
|
|
54
|
-
|
|
55
|
-
Tags are the primary context-narrowing mechanism. The more tags, the better.
|
|
56
|
-
|
|
57
|
-
Tag aggressively:
|
|
58
|
-
- **Who**: people, agents, teams involved
|
|
59
|
-
- **What**: project, client, topic, technology
|
|
60
|
-
- **When**: dates, periods, milestones
|
|
61
|
-
- **Where**: server, environment, channel
|
|
62
|
-
- **How**: process, decision, pattern
|
|
63
|
-
- **Your terms**: whatever vocabulary makes sense in YOUR world
|
|
64
|
-
|
|
65
|
-
Section tags (\`<!-- tags: ... -->\`) let different parts of an article
|
|
66
|
-
match different queries. A deploy article might have sections tagged
|
|
67
|
-
"runbook" and "incident" separately.
|
|
68
|
-
|
|
69
|
-
## Operations
|
|
70
|
-
|
|
71
|
-
### Absorb
|
|
72
|
-
Read raw entries \u2192 read worldview.md \u2192 tag aggressively \u2192 create/update articles.
|
|
73
|
-
Also identify GAPS: "We mention X but have no article for it."
|
|
74
|
-
|
|
75
|
-
### Query
|
|
76
|
-
Match by tags first \u2192 then keyword within matched articles \u2192 synthesize.
|
|
77
|
-
If agent is working on a specific project, only send content tagged for that project.
|
|
78
|
-
|
|
79
|
-
### Lint
|
|
80
|
-
Check for: orphan articles, broken [[wikilinks]], untagged articles,
|
|
81
|
-
articles over 100 lines that should split, mentioned-but-missing topics.
|
|
82
|
-
|
|
83
|
-
## Worldview
|
|
84
|
-
|
|
85
|
-
Edit \`worldview.md\` to describe YOUR world. This is not a schema \u2014 it's your
|
|
86
|
-
mental model. The LLM reads it during absorb to understand where things go.
|
|
87
|
-
|
|
88
|
-
Example worldview.md:
|
|
89
|
-
\`\`\`
|
|
90
|
-
I'm the founder of Acme Corp.
|
|
91
|
-
We build software products.
|
|
92
|
-
Our agents: Marketing Bot, DevOps Bot, Coordinator.
|
|
93
|
-
Clients: ClientA (enterprise), ClientB (startup).
|
|
94
|
-
Infrastructure: local dev machine, cloud server.
|
|
95
|
-
We use GitLab for version control.
|
|
96
|
-
\`\`\`
|
|
97
|
-
`),this.log("Created _schema.md")}extractWikilinks(t){return(t.match(/\[\[([^\]]+)\]\]/g)||[]).map(r=>r.replace(/\[\[|\]\]/g,""))}buildBacklinks(){let t={};return this.walkDir(this.baseDir,e=>{if(!e.endsWith(".md"))return;let r=k(this.baseDir,e);if(r.startsWith("raw/")||r.startsWith("_")||r==="WIKI.md"||r==="log.md")return;let a=$(e,"utf-8"),o=this.extractWikilinks(a);for(let s of o)t[s]||(t[s]=[]),t[s].push(r)}),w(u(this.baseDir,"_backlinks.json"),JSON.stringify(t,null,2)),t}getBacklinks(t){let e=u(this.baseDir,"_backlinks.json");if(!b(e))return[];try{return JSON.parse($(e,"utf-8"))[t]||[]}catch{return[]}}findByTags(t,e,r=10){let a=t.map(s=>s.toLowerCase()),o=[];return this.walkDir(this.baseDir,s=>{if(!s.endsWith(".md"))return;let i=k(this.baseDir,s);if(i.startsWith("raw/")||i.startsWith("_"))return;let n=this.readArticle(i);if(!n||e&&!this.canRead(n.meta,e))return;let c=(n.meta.tags||[]).map(p=>p.toLowerCase()),l=(n.content.match(/<!--\s*tags?:\s*([^>]+)\s*-->/gi)||[]).flatMap(p=>p.replace(/<!--\s*tags?:\s*|\s*-->/gi,"").split(",").map(m=>m.trim().toLowerCase())),g=[...c,...l],d=a.filter(p=>g.includes(p)).length;d>0&&o.push({article:n,score:d})}),o.sort((s,i)=>i.score-s.score).slice(0,r).map(s=>s.article)}getAllTags(){let t=new Map;return this.walkDir(this.baseDir,e=>{if(!e.endsWith(".md"))return;let r=k(this.baseDir,e);if(r.startsWith("raw/")||r.startsWith("_"))return;let a=this.readArticle(r);if(a?.meta.tags)for(let o of a.meta.tags)t.set(o,(t.get(o)||0)+1)}),t}getWorldview(){let t=u(this.baseDir,"worldview.md");return b(t)?$(t,"utf-8"):null}setWorldview(t){w(u(this.baseDir,"worldview.md"),t),this.appendLog("worldview","Updated worldview")}lint(){let t=[],e=new Set,r=new Map,a=new Map;this.walkDir(this.baseDir,s=>{if(!s.endsWith(".md"))return;let i=k(this.baseDir,s);if(i.startsWith("raw/")||i.startsWith("_")||i==="WIKI.md"||i==="log.md")return;let n=this.readArticle(i);if(!n)return;e.add(n.meta.title),a.set(n.meta.title,i);let c=this.extractWikilinks(n.content);r.set(i,c);let l=n.content.split(`
|
|
98
|
-
`).length;l>100&&t.push({type:"bloated",article:i,message:`${l} lines \u2014 consider splitting`}),n.meta.sources?.length||t.push({type:"unsourced",article:i,message:"No sources listed in frontmatter"}),l<10&&n.content.trim().length<100&&t.push({type:"stub",article:i,message:"Very short article \u2014 needs enrichment"})});for(let[s,i]of r)for(let n of i)e.has(n)||t.push({type:"broken-link",article:s,message:`[[${n}]] \u2014 target article not found`});let o=this.buildBacklinks();for(let[s,i]of a)(!o[s]||o[s].length===0)&&t.push({type:"orphan",article:i,message:`No other articles link to "${s}"`});return this.appendLog("lint",`Found ${t.length} issues`),t}getUnabsorbedEntries(){let t=new Set;return this.walkDir(this.baseDir,r=>{if(!r.endsWith(".md"))return;let a=k(this.baseDir,r);if(a.startsWith("raw/")||a.startsWith("_"))return;let o=this.readArticle(a);if(o?.meta.sources)for(let s of o.meta.sources)t.add(s)}),this.listEntries().filter(r=>!t.has(r.id))}buildAbsorbPrompt(t=20){let e=this.getUnabsorbedEntries().slice(0,t);if(e.length===0)return null;let r=e.map(a=>`[${a.date} ${a.agentId} via ${a.source}] ${a.content.slice(0,200)}`).join(`
|
|
99
|
-
|
|
100
|
-
`);return`/wiki absorb
|
|
101
|
-
|
|
102
|
-
There are ${e.length} unprocessed entries. Read each, understand what it means, and create or update wiki articles.
|
|
103
|
-
|
|
104
|
-
${r}`}walkDir(t,e){if(b(t))for(let r of D(t)){let a=V(t,r),o=K(a);o.isDirectory()?this.walkDir(a,e):e(a,o)}}};export{B as a};
|
|
105
|
-
//# sourceMappingURL=chunk-NY7NHGVT.js.map
|