dal-code 1.0.40 → 1.0.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/NOTICE +76 -1
  3. package/PRIVACY.md +68 -2
  4. package/dist/cli/startup-ui.js +1 -1
  5. package/dist/core/agent-session.d.ts +3 -0
  6. package/dist/core/agent-session.js +6 -6
  7. package/dist/core/bug-report.js +5 -5
  8. package/dist/core/settings-manager.d.ts +0 -5
  9. package/dist/core/settings-manager.js +1 -1
  10. package/dist/dal/manifest.js +1 -1
  11. package/dist/modes/interactive/components/status-indicator.d.ts +1 -1
  12. package/dist/modes/interactive/components/status-indicator.js +1 -1
  13. package/dist/modes/interactive/interactive-mode.d.ts +1 -0
  14. package/dist/modes/interactive/interactive-mode.js +2 -2
  15. package/dist/modes/print-mode.d.ts +1 -1
  16. package/dist/modes/print-mode.js +7 -6
  17. package/dist/modes/rpc/rpc-client.d.ts +5 -1
  18. package/dist/modes/rpc/rpc-client.js +3 -3
  19. package/dist/modes/rpc/rpc-mode.js +1 -1
  20. package/dist/modes/rpc/rpc-types.d.ts +25 -0
  21. package/dist/node_modules/@dalcode/dal-advisor/package.json +3 -3
  22. package/dist/node_modules/@dalcode/dal-advisor/src/index.js +9 -8
  23. package/dist/node_modules/@dalcode/dal-awake/LICENSE +21 -0
  24. package/dist/node_modules/@dalcode/dal-awake/package.json +31 -0
  25. package/dist/node_modules/@dalcode/dal-awake/src/index.js +3 -0
  26. package/dist/node_modules/@dalcode/dal-awake/src/inhibitor.js +1 -0
  27. package/dist/node_modules/@dalcode/dal-bridge/package.json +2 -2
  28. package/dist/node_modules/@dalcode/dal-capabilities/package.json +4 -4
  29. package/dist/node_modules/@dalcode/dal-compat/package.json +2 -2
  30. package/dist/node_modules/@dalcode/dal-compat/src/at-imports.js +3 -0
  31. package/dist/node_modules/@dalcode/dal-compat/src/index.js +7 -5
  32. package/dist/node_modules/@dalcode/dal-dap/package.json +2 -2
  33. package/dist/node_modules/@dalcode/dal-dap/src/install.js +2 -2
  34. package/dist/node_modules/@dalcode/dal-gateway/package.json +2 -2
  35. package/dist/node_modules/@dalcode/dal-goal/package.json +3 -3
  36. package/dist/node_modules/@dalcode/dal-guard/package.json +4 -4
  37. package/dist/node_modules/@dalcode/dal-guard/src/edit-anchor-core.js +22 -21
  38. package/dist/node_modules/@dalcode/dal-guard/src/edit-anchor.js +4 -4
  39. package/dist/node_modules/@dalcode/dal-halo/package.json +1 -1
  40. package/dist/node_modules/@dalcode/dal-interactive/package.json +2 -2
  41. package/dist/node_modules/@dalcode/dal-lang/package.json +3 -3
  42. package/dist/node_modules/@dalcode/dal-learn/package.json +5 -2
  43. package/dist/node_modules/@dalcode/dal-learn/src/index.js +10 -10
  44. package/dist/node_modules/@dalcode/dal-learn/src/lessons.js +3 -3
  45. package/dist/node_modules/@dalcode/dal-learn/src/patches.js +10 -0
  46. package/dist/node_modules/@dalcode/dal-lsp/package.json +3 -3
  47. package/dist/node_modules/@dalcode/dal-mcp/package.json +5 -5
  48. package/dist/node_modules/@dalcode/dal-office/package.json +2 -2
  49. package/dist/node_modules/@dalcode/dal-office/src/index.d.ts +1 -0
  50. package/dist/node_modules/@dalcode/dal-office/src/index.js +1 -1
  51. package/dist/node_modules/@dalcode/dal-office/src/render/deck-source.d.ts +10 -0
  52. package/dist/node_modules/@dalcode/dal-office/src/render/deck-source.js +2 -0
  53. package/dist/node_modules/@dalcode/dal-office/src/render/pptx.js +3 -3
  54. package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.js +3 -3
  55. package/dist/node_modules/@dalcode/dal-pi-kit/package.json +1 -1
  56. package/dist/node_modules/@dalcode/dal-pi-kit/src/i18n.js +3 -3
  57. package/dist/node_modules/@dalcode/dal-plugins/package.json +4 -4
  58. package/dist/node_modules/@dalcode/dal-recall/package.json +2 -2
  59. package/dist/node_modules/@dalcode/dal-review/package.json +3 -3
  60. package/dist/node_modules/@dalcode/dal-review/src/core.d.ts +1 -0
  61. package/dist/node_modules/@dalcode/dal-review/src/core.js +1 -1
  62. package/dist/node_modules/@dalcode/dal-review/src/findings.js +2 -2
  63. package/dist/node_modules/@dalcode/dal-review/src/index.js +1 -1
  64. package/dist/node_modules/@dalcode/dal-review/src/prompt.d.ts +1 -1
  65. package/dist/node_modules/@dalcode/dal-review/src/prompt.js +3 -2
  66. package/dist/node_modules/@dalcode/dal-review/src/runner.d.ts +2 -1
  67. package/dist/node_modules/@dalcode/dal-review/src/runner.js +2 -2
  68. package/dist/node_modules/@dalcode/dal-review/src/simplify.d.ts +5 -0
  69. package/dist/node_modules/@dalcode/dal-review/src/simplify.js +30 -0
  70. package/dist/node_modules/@dalcode/dal-review/src/types.d.ts +5 -0
  71. package/dist/node_modules/@dalcode/dal-review/src/types.js +1 -1
  72. package/dist/node_modules/@dalcode/dal-rewind/package.json +2 -2
  73. package/dist/node_modules/@dalcode/dal-router/package.json +4 -4
  74. package/dist/node_modules/@dalcode/dal-rtk/LICENSE +21 -0
  75. package/dist/node_modules/@dalcode/dal-rtk/package.json +31 -0
  76. package/dist/node_modules/@dalcode/dal-rtk/src/index.js +2 -0
  77. package/dist/node_modules/@dalcode/dal-skills/package.json +3 -3
  78. package/dist/node_modules/@dalcode/dal-skills/src/bundled/bounded-code-repair/SKILL.md +45 -0
  79. package/dist/node_modules/@dalcode/dal-skills/src/bundled/evidence-first-retrieval/SKILL.md +43 -0
  80. package/dist/node_modules/@dalcode/dal-skills/src/bundled/validated-structured-output/SKILL.md +36 -0
  81. package/dist/node_modules/@dalcode/dal-skills/src/bundled.js +1 -1
  82. package/dist/node_modules/@dalcode/dal-statusline/package.json +2 -2
  83. package/dist/node_modules/@dalcode/dal-structured/package.json +2 -2
  84. package/dist/node_modules/@dalcode/dal-subagent/package.json +5 -5
  85. package/dist/node_modules/@dalcode/dal-subagent/src/index.js +21 -21
  86. package/dist/node_modules/@dalcode/dal-telemetry/package.json +8 -2
  87. package/dist/node_modules/@dalcode/dal-telemetry/src/config.js +3 -2
  88. package/dist/node_modules/@dalcode/dal-telemetry/src/consent.js +1 -0
  89. package/dist/node_modules/@dalcode/dal-telemetry/src/failure-queue.js +4 -0
  90. package/dist/node_modules/@dalcode/dal-telemetry/src/failure-reporting.js +5 -0
  91. package/dist/node_modules/@dalcode/dal-telemetry/src/failures.js +2 -0
  92. package/dist/node_modules/@dalcode/dal-telemetry/src/index.js +4 -3
  93. package/dist/node_modules/@dalcode/dal-telemetry/src/reporter.js +1 -1
  94. package/dist/node_modules/@dalcode/dal-telemetry/src/repro.js +1 -0
  95. package/dist/node_modules/@dalcode/dal-terminal/package.json +2 -2
  96. package/dist/node_modules/@dalcode/dal-tool-catalog/package.json +2 -2
  97. package/dist/node_modules/@dalcode/dal-tool-catalog/src/index.js +4 -4
  98. package/dist/node_modules/@dalcode/dal-tool-catalog/src/path-hint.js +1 -0
  99. package/dist/node_modules/@dalcode/dal-tool-catalog/src/repair-hook.js +2 -1
  100. package/dist/node_modules/@dalcode/dal-tool-catalog/src/repair.js +1 -1
  101. package/dist/node_modules/@dalcode/dal-tool-catalog/src/tool-name.js +1 -0
  102. package/dist/node_modules/@dalcode/dal-usage/package.json +2 -2
  103. package/dist/node_modules/@dalcode/dal-usage/src/index.d.ts +1 -0
  104. package/dist/node_modules/@dalcode/dal-usage/src/index.js +2 -2
  105. package/dist/node_modules/@dalcode/dal-usage/src/time-limit.d.ts +4 -0
  106. package/dist/node_modules/@dalcode/dal-usage/src/time-limit.js +2 -0
  107. package/dist/node_modules/@dalcode/dal-web/package.json +3 -3
  108. package/dist/node_modules/@dalcode/dal-workflow/package.json +2 -2
  109. package/dist/node_modules/@dalcode/dal-workflow/src/index.js +4 -4
  110. package/dist/node_modules/@dalcode/dal-workflow/src/lean-code.js +1 -1
  111. package/dist/node_modules/@dalcode/dal-workflow/src/working-contract.js +1 -0
  112. package/dist/node_modules/@dalcode/deepailab/package.json +3 -3
  113. package/dist/node_modules/@dalcode/deepailab/src/index.js +3 -3
  114. package/dist/node_modules/@earendil-works/chord/package.json +1 -1
  115. package/dist/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
  116. package/dist/node_modules/@earendil-works/pi-ai/dist/cli.js +0 -0
  117. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  118. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/baseten.json +1 -1
  119. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  120. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/together.json +1 -1
  121. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
  122. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/zai-coding-cn.json +1 -1
  123. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/retry.d.ts +1 -0
  124. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/retry.js +1 -1
  125. package/dist/node_modules/@earendil-works/pi-ai/package.json +2 -2
  126. package/dist/node_modules/@earendil-works/pi-client/package.json +3 -3
  127. package/dist/node_modules/@earendil-works/pi-codemode/package.json +1 -1
  128. package/dist/node_modules/@earendil-works/pi-coding-agent/package.json +1 -1
  129. package/dist/node_modules/@earendil-works/pi-mcp/package.json +1 -1
  130. package/dist/node_modules/@earendil-works/pi-protocol/package.json +2 -2
  131. package/dist/node_modules/@earendil-works/pi-server/package.json +3 -3
  132. package/dist/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
  133. package/dist/node_modules/@earendil-works/pi-tui/package.json +1 -1
  134. package/dist/sdk/index.d.ts +1 -1
  135. package/dist/sdk/office.d.ts +1 -1
  136. package/dist/sdk/office.js +1 -1
  137. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  138. package/examples/extensions/gondolin/package-lock.json +2 -2
  139. package/examples/extensions/gondolin/package.json +1 -1
  140. package/examples/extensions/sandbox/package-lock.json +2 -2
  141. package/examples/extensions/sandbox/package.json +1 -1
  142. package/examples/extensions/with-deps/package-lock.json +2 -2
  143. package/examples/extensions/with-deps/package.json +1 -1
  144. package/npm-shrinkwrap.json +2 -2
  145. package/package.json +1 -1
@@ -1,22 +1,23 @@
1
- var D=Object.defineProperty;var a=(s,e)=>D(s,"name",{value:e,configurable:!0});var _=Object.defineProperty,i=a((s,e)=>_(s,"name",{value:e,configurable:!0}),"i");import{readFileSync as L}from"node:fs";import{join as N}from"node:path";import{t as I}from"@dalcode/dal-pi-kit";import{pickSecondOpinion as W,routerAdvisorPool as Y}from"@dalcode/dal-router/advisor";import{uuidv7 as B}from"@earendil-works/pi-ai";import{buildSessionContext as F,convertToLlm as U,getAgentDir as q,serializeConversation as G}from"@earendil-works/pi-coding-agent";import{Type as V}from"typebox";const p="advisor",y=3,X=24e4,z=2e3,$=`You are a senior engineer giving a second opinion to a coding assistant that is in the middle of a task.
1
+ var D=Object.defineProperty;var a=(t,e)=>D(t,"name",{value:e,configurable:!0});var _=Object.defineProperty,i=a((t,e)=>_(t,"name",{value:e,configurable:!0}),"i");import{readFileSync as I}from"node:fs";import{join as L}from"node:path";import{t as N}from"@dalcode/dal-pi-kit";import{pickSecondOpinion as W,routerAdvisorPool as Y}from"@dalcode/dal-router/advisor";import{uuidv7 as B}from"@earendil-works/pi-ai";import{buildSessionContext as F,convertToLlm as U,getAgentDir as q,serializeConversation as G}from"@earendil-works/pi-coding-agent";import{Type as V}from"typebox";const p="advisor",y=3,X=24e4,z=2e3,b=`You are a senior engineer giving a second opinion to a coding assistant that is in the middle of a task.
2
2
  You get the task and the conversation so far as a transcript (every tool call and result the assistant saw), plus the tools it can use.
3
3
  Review its current approach. Answer with:
4
4
  1. The risks: wrong assumptions, steps that will fail, things it has not checked, a simpler or safer way it missed. Name files, commands and lines from the transcript.
5
5
  2. What to do next, as concrete steps; or say plainly that the approach is sound.
6
6
  3. When the task cannot be done safely as asked, say that it should stop and ask the user, and why.
7
- You cannot run tools or change anything. Do not repeat the transcript. Be brief and direct; no preamble. Answer in the language of the user's task.`;function w(s=q()){try{const e=JSON.parse(L(N(s,"settings.json"),"utf8")).dalAdvisor,t=e?.maxCallsPerSession;return{...typeof e?.model=="string"&&e.model.includes("/")?{model:e.model}:{},maxCallsPerSession:typeof t=="number"&&Number.isInteger(t)&&t>=0?t:y}}catch{return{maxCallsPerSession:y}}}a(w,"L"),i(w,"readAdvisorSettings");function b(s){const e=new Set;s.model&&(e.add(s.model.id),e.add(`${s.model.provider}/${s.model.id}`));const t=s.sessionManager.getBranch();for(let n=t.length-1;n>=0;n--){const r=t[n];if(r.type==="message"&&r.message.role==="assistant"){e.add(r.message.model),e.add(`${r.message.provider}/${r.message.model}`);break}}return[...e]}a(b,"W"),i(b,"workingModels");function S(s,e){if(e.model){const o=e.model.indexOf("/");return s.modelRegistry.find(e.model.slice(0,o),e.model.slice(o+1))}const t=s.modelRegistry.getAvailable(),n=Y(),r=[];for(const o of t){const g=n?.find(l=>l.id===o.id&&l.provider===o.provider);n&&!g||r.push({provider:o.provider,id:o.id,reasoning:g?.reasoning??o.reasoning===!0,costPerMtok:g?.costPerMtok??(o.cost?.input??0)+(o.cost?.output??0),model:o})}return W(r,b(s))?.model}a(S,"Y"),i(S,"pickAdvisorModel");function R(s,e){if(s.length<=e)return s;const t=s.slice(-e),n=t.indexOf(`
7
+ A claim that the work is done or verified, backed only by reading code or trying a few cases rather than running the change, is a risk: name it.
8
+ You cannot run tools or change anything. Do not repeat the transcript or tell the assistant what it already knows. If the approach is sound, say so in one line and stop. Be brief and direct; no preamble. Answer in the language of the user's task.`;function w(t=q()){try{const e=JSON.parse(I(L(t,"settings.json"),"utf8")).dalAdvisor,s=e?.maxCallsPerSession;return{...typeof e?.model=="string"&&e.model.includes("/")?{model:e.model}:{},maxCallsPerSession:typeof s=="number"&&Number.isInteger(s)&&s>=0?s:y}}catch{return{maxCallsPerSession:y}}}a(w,"L"),i(w,"readAdvisorSettings");function $(t){const e=new Set;t.model&&(e.add(t.model.id),e.add(`${t.model.provider}/${t.model.id}`));const s=t.sessionManager.getBranch();for(let n=s.length-1;n>=0;n--){const r=s[n];if(r.type==="message"&&r.message.role==="assistant"){e.add(r.message.model),e.add(`${r.message.provider}/${r.message.model}`);break}}return[...e]}a($,"W"),i($,"workingModels");function k(t,e){if(e.model){const o=e.model.indexOf("/");return t.modelRegistry.find(e.model.slice(0,o),e.model.slice(o+1))}const s=t.modelRegistry.getAvailable(),n=Y(),r=[];for(const o of s){const h=n?.find(l=>l.id===o.id&&l.provider===o.provider);n&&!h||r.push({provider:o.provider,id:o.id,reasoning:h?.reasoning??o.reasoning===!0,costPerMtok:h?.costPerMtok??(o.cost?.input??0)+(o.cost?.output??0),model:o})}return W(r,$(t))?.model}a(k,"Y"),i(k,"pickAdvisorModel");function R(t,e){if(t.length<=e)return t;const s=t.slice(-e),n=s.indexOf(`
8
9
  `);return`[\u2026 earlier conversation omitted \u2026]
9
- ${n>=0?t.slice(n+1):t}`}a(R,"V"),i(R,"keepTail");function k(s,e){return{role:"user",content:[{type:"text",text:[`## Tools the assistant can use
10
+ ${n>=0?s.slice(n+1):s}`}a(R,"V"),i(R,"keepTail");function S(t,e){return{role:"user",content:[{type:"text",text:[`## Tools the assistant can use
10
11
 
11
- ${e.map(t=>`- ${t.name}: ${(t.description??"").split(`
12
+ ${e.map(s=>`- ${s.name}: ${(s.description??"").split(`
12
13
  `)[0].slice(0,160)}`).join(`
13
14
  `)||"(none)"}`,`## Conversation so far
14
15
 
15
- ${s||"(empty)"}`,`## Your review
16
+ ${t||"(empty)"}`,`## Your review
16
17
 
17
18
  Give your second opinion on the assistant's current approach now.`].join(`
18
19
 
19
- `)}],timestamp:Date.now()}}a(k,"B"),i(k,"advisorRequest");function C(s){return s.content.filter(e=>e.type==="text").map(e=>e.text).join(`
20
- `).trim()}a(C,"F"),i(C,"textOf");function P(s,e){return s?(s.input+=e.input,s.output+=e.output,s.cacheRead+=e.cacheRead,s.cacheWrite+=e.cacheWrite,s.totalTokens+=e.totalTokens,s.cost.input+=e.cost.input,s.cost.output+=e.cost.output,s.cost.cacheRead+=e.cost.cacheRead,s.cost.cacheWrite+=e.cost.cacheWrite,s.cost.total+=e.cost.total,s):structuredClone(e)}a(P,"X"),i(P,"addUsage");function T(s){return s.sessionManager.getBranch().filter(e=>e.type==="message"&&e.message.role==="toolResult"&&e.message.toolName===p&&!e.message.isError).length}a(T,"q"),i(T,"callsSoFar");function x(s={}){return i(function(e){const t=s.settings??(()=>w());e.on("session_start",async()=>{if(t().maxCallsPerSession>0)return;const n=e.getActiveTools();n.includes(p)&&e.setActiveTools(n.filter(r=>r!==p))}),e.registerTool({name:p,label:I("\u7B2C\u4E8C\u610F\u89C1"),description:"Ask another strong model to review your current approach and name its risks. No arguments: the conversation is sent automatically. Limited per session.",promptSnippet:"advisor - second opinion on the current plan from another strong model",promptGuidelines:["Use advisor only before a risky or hard-to-undo change, after repeated failures, or before finishing a complex task; tell the user its key point."],parameters:V.Object({}),async execute(n,r,o,g,l){const d=t(),h=T(l);if(d.maxCallsPerSession===0)throw new Error("advisor is turned off in the settings.");if(h>=d.maxCallsPerSession)throw new Error(`advisor was already used ${h} times in this session (limit ${d.maxCallsPerSession}); continue on your own judgment.`);const c=S(l,d);if(!c)throw new Error(d.model?`The advisor model ${d.model} is not available.`:"No other model is available for a second opinion; continue on your own judgment.");const{messages:M}=F(l.sessionManager.getEntries(),l.sessionManager.getLeafId()),O=R(G(U(M)),X),E=k(O,e.getAllTools()),f=`${c.provider}/${c.id}`;let m,v="";for(let A=0;A<2&&!v;A++){const u=await l.modelRegistry.complete(c,{systemPrompt:$,messages:[E]},{...o?{signal:o}:{},cacheRetention:"none",sessionId:B(),maxTokens:z});if(m=P(m,u.usage),u.stopReason==="aborted"||u.stopReason==="error")throw e.appendUsage(m,{kind:"advisor",provider:c.provider,model:c.id}),new Error(u.stopReason==="aborted"?"advisor call aborted":`advisor call to ${f} failed: ${u.errorMessage??"unknown error"}`);v=C(u)}const j={model:f,calls:h+1,limit:d.maxCallsPerSession};return{content:[{type:"text",text:v?`[Second opinion from ${f}; ${h+1}/${d.maxCallsPerSession} this session]
20
+ `)}],timestamp:Date.now()}}a(S,"B"),i(S,"advisorRequest");function C(t){return t.content.filter(e=>e.type==="text").map(e=>e.text).join(`
21
+ `).trim()}a(C,"F"),i(C,"textOf");function P(t,e){return t?(t.input+=e.input,t.output+=e.output,t.cacheRead+=e.cacheRead,t.cacheWrite+=e.cacheWrite,t.totalTokens+=e.totalTokens,t.cost.input+=e.cost.input,t.cost.output+=e.cost.output,t.cost.cacheRead+=e.cost.cacheRead,t.cost.cacheWrite+=e.cost.cacheWrite,t.cost.total+=e.cost.total,t):structuredClone(e)}a(P,"X"),i(P,"addUsage");function T(t){return t.sessionManager.getBranch().filter(e=>e.type==="message"&&e.message.role==="toolResult"&&e.message.toolName===p&&!e.message.isError).length}a(T,"q"),i(T,"callsSoFar");function x(t={}){return i(function(e){const s=t.settings??(()=>w());e.on("session_start",async()=>{if(s().maxCallsPerSession>0)return;const n=e.getActiveTools();n.includes(p)&&e.setActiveTools(n.filter(r=>r!==p))}),e.registerTool({name:p,label:N("\u7B2C\u4E8C\u610F\u89C1"),description:"Ask another strong model to review your current approach and name its risks. No arguments: the conversation is sent automatically. Limited per session.",promptSnippet:"advisor - second opinion on the current plan from another strong model",promptGuidelines:["Use advisor only before a risky or hard-to-undo change, after repeated failures, or before finishing a complex task; tell the user its key point."],parameters:V.Object({}),async execute(n,r,o,h,l){const d=s(),g=T(l);if(d.maxCallsPerSession===0)throw new Error("advisor is turned off in the settings.");if(g>=d.maxCallsPerSession)throw new Error(`advisor was already used ${g} times in this session (limit ${d.maxCallsPerSession}); continue on your own judgment.`);const c=k(l,d);if(!c)throw new Error(d.model?`The advisor model ${d.model} is not available.`:"No other model is available for a second opinion; continue on your own judgment.");const{messages:M}=F(l.sessionManager.getEntries(),l.sessionManager.getLeafId()),O=R(G(U(M)),X),E=S(O,e.getAllTools()),f=`${c.provider}/${c.id}`;let m,v="";for(let A=0;A<2&&!v;A++){const u=await l.modelRegistry.complete(c,{systemPrompt:b,messages:[E]},{...o?{signal:o}:{},cacheRetention:"none",sessionId:B(),maxTokens:z});if(m=P(m,u.usage),u.stopReason==="aborted"||u.stopReason==="error")throw e.appendUsage(m,{kind:"advisor",provider:c.provider,model:c.id}),new Error(u.stopReason==="aborted"?"advisor call aborted":`advisor call to ${f} failed: ${u.errorMessage??"unknown error"}`);v=C(u)}const j={model:f,calls:g+1,limit:d.maxCallsPerSession};return{content:[{type:"text",text:v?`[Second opinion from ${f}; ${g+1}/${d.maxCallsPerSession} this session]
21
22
 
22
- ${v}`:`${f} gave no answer.`}],details:j,...m?{usage:m}:{}}}})},"dalAdvisor")}a(x,"G"),i(x,"createDalAdvisor");var J=x();export{$ as ADVISOR_SYSTEM_PROMPT,p as ADVISOR_TOOL,y as DEFAULT_MAX_CALLS_PER_SESSION,k as advisorRequest,x as createDalAdvisor,J as default,S as pickAdvisorModel,w as readAdvisorSettings};
23
+ ${v}`:`${f} gave no answer.`}],details:j,...m?{usage:m}:{}}}})},"dalAdvisor")}a(x,"G"),i(x,"createDalAdvisor");var J=x();export{b as ADVISOR_SYSTEM_PROMPT,p as ADVISOR_TOOL,y as DEFAULT_MAX_CALLS_PER_SESSION,S as advisorRequest,x as createDalAdvisor,J as default,k as pickAdvisorModel,w as readAdvisorSettings};
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Mario Zechner
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@dalcode/dal-awake",
3
+ "version": "1.0.42",
4
+ "private": true,
5
+ "description": "Keeps the computer from going to sleep while a long agent run is in progress, and lets it sleep again when the run ends. Adapted from @narumitw/pi-caffeinate (MIT).",
6
+ "type": "module",
7
+ "main": "./src/index.js",
8
+ "exports": {
9
+ ".": "./src/index.js",
10
+ "./package.json": "./package.json"
11
+ },
12
+ "files": [
13
+ "src"
14
+ ],
15
+ "pi": {
16
+ "extensions": [
17
+ "./src/index.js"
18
+ ]
19
+ },
20
+ "dependencies": {
21
+ "@dalcode/dal-pi-kit": "1.0.42"
22
+ },
23
+ "peerDependencies": {
24
+ "@earendil-works/pi-coding-agent": "^1.0.9"
25
+ },
26
+ "peerDependenciesMeta": {
27
+ "@earendil-works/pi-coding-agent": {
28
+ "optional": false
29
+ }
30
+ }
31
+ }
@@ -0,0 +1,3 @@
1
+ var g=Object.defineProperty;var D=(e,o)=>g(e,"name",{value:o,configurable:!0});var w=Object.defineProperty,F=D((e,o)=>w(e,"name",{value:o,configurable:!0}),"i");import{readFileSync as _}from"node:fs";import{join as v}from"node:path";import{t as i}from"@dalcode/dal-pi-kit";import{getAgentDir as b}from"@earendil-works/pi-coding-agent";import{inhibitorCommand as k,startInhibitor as S,stopInhibitor as P}from"./inhibitor.js";import{commandOnPath as y,inhibitorCommand as I,WINDOWS_SCRIPT as W}from"./inhibitor.js";const B=3e4;function l(e,o){const t=e.DAL_KEEP_AWAKE?.trim().toLowerCase();if(t==="off"||t==="0"||t==="false")return!1;if(t==="on"||t==="1"||t==="true")return!0;if(Number(e.DAL_SUBAGENT_DEPTH??0)>0)return!1;try{return JSON.parse(_(v(o,"settings.json"),"utf8")).dalKeepAwake!==!1}catch{return!0}}D(l,"C"),F(l,"keepAwakeEnabled");function E(e={}){return F(function(o){const t=e.env??process.env,p=e.delayMs??B,C=e.command??k;let d=!1,m=!1,r,a,c;const f=F(()=>{r&&clearTimeout(r),r=void 0;const n=a;a=void 0,n&&P(n.child,n.command)},"release"),h=F(()=>{if(r=void 0,a||!d||m)return;const n=C({platform:e.platform??process.platform,pid:process.pid,env:t});if(!n){c=i("\u8FD9\u53F0\u7535\u8111\u4E0A\u6CA1\u6709\u53EF\u7528\u7684\u9632\u4F11\u7720\u65B9\u5F0F");return}try{const u=S(n,A=>{a?.child===u&&(a=void 0,c=`${n.description}: ${A}`)},e.spawn);a={child:u,command:n,since:Date.now()},c=void 0}catch(u){c=`${n.description}: ${u instanceof Error?u.message:String(u)}`}},"hold");o.on("session_start",()=>{f(),d=l(t,(e.agentDir??b)())}),o.on("agent_start",()=>{!d||m||a||r||(r=setTimeout(h,p),r.unref())}),o.on("agent_end",()=>f()),o.on("session_shutdown",()=>f()),o.registerCommand("awake",{description:i("\u957F\u4EFB\u52A1\u9632\u4F11\u7720\uFF1A\u67E5\u770B\u72B6\u6001\uFF0C\u6216\u672C\u6B21\u4F1A\u8BDD\u5173\u95ED / \u91CD\u65B0\u6253\u5F00\uFF08off | on\uFF09"),getArgumentCompletions:F(n=>["on","off"].filter(u=>u.startsWith(n.trim())).map(u=>({value:u,label:u})),"getArgumentCompletions"),handler:F(async(n,u)=>{const A=n.trim();A==="off"?(m=!0,f()):A==="on"&&(m=!1);let s;d?m?s=i("\u957F\u4EFB\u52A1\u9632\u4F11\u7720\uFF1A\u672C\u6B21\u4F1A\u8BDD\u5DF2\u5173\u95ED\uFF08/awake on \u91CD\u65B0\u6253\u5F00\uFF09"):a?s=i("\u957F\u4EFB\u52A1\u9632\u4F11\u7720\uFF1A\u6B63\u5728\u4FDD\u6301\u7535\u8111\u5524\u9192\uFF08{seconds} \u79D2\uFF09").replace("{seconds}",String(Math.round((Date.now()-a.since)/1e3))):s=i("\u957F\u4EFB\u52A1\u9632\u4F11\u7720\u5DF2\u5F00\u542F\uFF1A\u4EFB\u52A1\u8FD0\u884C\u8D85\u8FC7 {seconds} \u79D2\u65F6\u4FDD\u6301\u7535\u8111\u5524\u9192\uFF0C\u7ED3\u675F\u540E\u6062\u590D").replace("{seconds}",String(Math.round(p/1e3))):s=i("\u957F\u4EFB\u52A1\u9632\u4F11\u7720\u5DF2\u5173\u95ED\uFF08\u8BBE\u7F6E\u91CC dalKeepAwake \u4E3A false\uFF0C\u6216\u8BBE\u7F6E\u4E86 DAL_KEEP_AWAKE=off\uFF09"),c&&(s+=`
2
+ ${i("\u4E0A\u6B21\u672A\u80FD\u9632\u4F11\u7720\uFF1A")}${c}`),u.hasUI?u.ui.notify(s,"info"):process.stdout.write(`${s}
3
+ `)},"handler")})},"dalAwake")}D(E,"k"),F(E,"createDalAwake");var L=E();export{B as DEFAULT_DELAY_MS,W as WINDOWS_SCRIPT,y as commandOnPath,E as createDalAwake,L as default,I as inhibitorCommand,l as keepAwakeEnabled};
@@ -0,0 +1 @@
1
+ var $=Object.defineProperty;var n=(e,t)=>$(e,"name",{value:t,configurable:!0});var w=Object.defineProperty,a=n((e,t)=>w(e,"name",{value:t,configurable:!0}),"r");import{spawn as b}from"node:child_process";import{existsSync as c}from"node:fs";import{delimiter as x,join as S}from"node:path";const g="DAL Code",v="A DAL Code task is running";function l(e,t=process.env,i=process.platform){const r=i==="win32"?["",".exe",".cmd",".bat"]:[""];for(const o of(t.PATH??"").split(i==="win32"?";":x))if(o){for(const s of r)if(c(S(o,`${e}${s}`)))return!0}return!1}n(l,"h"),a(l,"commandOnPath");function u(){try{return c("/proc/sys/fs/binfmt_misc/WSLInterop")}catch{return!1}}n(u,"w"),a(u,"detectWsl");const y=`parent=$1; shift; "$@" & child=$!; ( while kill -0 "$parent" 2>/dev/null; do sleep 5; done; kill "$child" 2>/dev/null ) & watcher=$!; cleanup() { kill "$watcher" 2>/dev/null; kill "$child" 2>/dev/null; wait "$child" 2>/dev/null; }; trap 'cleanup; exit 0' INT TERM HUP EXIT; wait "$child"; status=$?; kill "$watcher" 2>/dev/null; trap - EXIT; exit "$status"`,m=`$ErrorActionPreference = 'Stop'; Add-Type -Namespace Native -Name Power -MemberDefinition '[DllImport("kernel32.dll")] public static extern uint SetThreadExecutionState(uint esFlags);'; $flags = [uint32]'0x80000001'; $release = [uint32]'0x80000000'; $stdin = [Console]::OpenStandardInput(); $buffer = New-Object byte[] 1; $readTask = $stdin.ReadAsync($buffer, 0, 1); try { while ($true) { [Native.Power]::SetThreadExecutionState($flags) | Out-Null; if ($readTask.Wait(30000)) { break } } } finally { [Native.Power]::SetThreadExecutionState($release) | Out-Null }`;function d(){return{command:"powershell.exe",args:["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-Command",m],description:"SetThreadExecutionState",releaseOnStdinClose:!0}}n(d,"l"),a(d,"windowsCommand");function f(e){const t=e.hasCommand??(i=>l(i,e.env));if(e.platform==="darwin")return{command:"caffeinate",args:["-i","-m","-s","-w",String(e.pid)],description:"caffeinate"};if(e.platform==="win32")return d();if(e.platform==="linux"){if((e.isWsl??u)()&&t("powershell.exe"))return d();if(t("systemd-inhibit"))return{command:"sh",args:["-c",y,"dal-awake",String(e.pid),"systemd-inhibit","--what=idle:sleep",`--who=${g}`,`--why=${v}`,"--mode=block","sleep","infinity"],description:"systemd-inhibit"}}}n(f,"y"),a(f,"inhibitorCommand");function p(e,t,i=b){const r=i(e.command,e.args,{detached:!1,stdio:[e.releaseOnStdinClose?"pipe":"ignore","ignore","ignore"],windowsHide:!0});return r.once("error",o=>t(o.message)),r.once("exit",(o,s)=>t(s?`signal ${s}`:`code ${o??"?"}`)),r.unref(),r.stdin?.unref?.(),r}n(p,"I"),a(p,"startInhibitor");function h(e,t){if(e.removeAllListeners("exit"),e.removeAllListeners("error"),e.on("error",()=>{}),!(e.exitCode!==null||e.signalCode!==null)){if(t.releaseOnStdinClose&&e.stdin&&!e.stdin.destroyed){e.stdin.end();const i=setTimeout(()=>{e.exitCode===null&&e.signalCode===null&&e.kill()},2e3);i.unref(),e.once("exit",()=>clearTimeout(i));return}e.kill(process.platform==="win32"?void 0:"SIGTERM")}}n(h,"P"),a(h,"stopInhibitor");export{m as WINDOWS_SCRIPT,l as commandOnPath,f as inhibitorCommand,p as startInhibitor,h as stopInhibitor};
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-bridge",
3
- "version": "1.0.40",
3
+ "version": "1.0.42",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -18,7 +18,7 @@
18
18
  ]
19
19
  },
20
20
  "dependencies": {
21
- "@dalcode/dal-pi-kit": "1.0.40",
21
+ "@dalcode/dal-pi-kit": "1.0.42",
22
22
  "typebox": "1.3.7"
23
23
  },
24
24
  "peerDependencies": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-capabilities",
3
- "version": "1.0.40",
3
+ "version": "1.0.42",
4
4
  "private": true,
5
5
  "description": "Capability center for DAL: switches on the reviewed MCP connectors, skills and engine packages a task needs (installed automatically from the signed DAL market), with /capabilities to list, disable and enable them.",
6
6
  "license": "MIT",
@@ -23,9 +23,9 @@
23
23
  ]
24
24
  },
25
25
  "dependencies": {
26
- "@dalcode/dal-mcp": "1.0.40",
27
- "@dalcode/dal-pi-kit": "1.0.40",
28
- "@dalcode/deepailab": "1.0.40"
26
+ "@dalcode/dal-mcp": "1.0.42",
27
+ "@dalcode/dal-pi-kit": "1.0.42",
28
+ "@dalcode/deepailab": "1.0.42"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "@earendil-works/pi-coding-agent": "^1.0.9"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-compat",
3
- "version": "1.0.40",
3
+ "version": "1.0.42",
4
4
  "private": true,
5
5
  "description": "Claude Code compatibility: the user's and project's .claude/rules/ and .claude/CLAUDE.md apply in DAL. Grown from the claude-rules extension example.",
6
6
  "type": "module",
@@ -18,7 +18,7 @@
18
18
  ]
19
19
  },
20
20
  "dependencies": {
21
- "@dalcode/dal-pi-kit": "1.0.40",
21
+ "@dalcode/dal-pi-kit": "1.0.42",
22
22
  "minimatch": "10.2.6"
23
23
  },
24
24
  "peerDependencies": {
@@ -0,0 +1,3 @@
1
+ var z=Object.defineProperty;var s=(t,i)=>z(t,"name",{value:i,configurable:!0});var D=Object.defineProperty,o=s((t,i)=>D(t,"name",{value:i,configurable:!0}),"s");import{readFileSync as $,realpathSync as A,statSync as E}from"node:fs";import{homedir as F}from"node:os";import{dirname as _,isAbsolute as I,relative as R,resolve as a}from"node:path";const T=5,b=64*1024,S=256*1024,X=/(^|[ \t])@([./~A-Za-z0-9_-][^\s]*)/g,B=/[.,;:!?)\]}"',。;:!?)]+$/,L=/(^|\/)(\.env(\..*)?|\.netrc|\.npmrc|\.pypirc|auth\.json|credentials(\.json)?|secrets?(\.\w+)?|id_(rsa|dsa|ecdsa|ed25519)(\.pub)?)$|(^|\/)\.(ssh|aws|gnupg|docker|kube|dal|claude\/\.credentials)(\/|$)|\.(pem|key|p12|pfx|keystore|jks)$/i;function M(t,i){const e=R(t,i);return e===""||!e.startsWith("..")&&!I(e)}s(M,"j"),o(M,"within");function j(t,i){let e;try{e=A(t)}catch{return}if(!(!M(i.root,e)||L.test(e.replace(/\\/g,"/"))))try{const n=E(e);if(!n.isFile()||n.size>b||n.size>i.budget.left)return;const r=$(e,"utf8");return r.includes("\0")?void 0:(i.budget.left-=n.size,r)}catch{return}}s(j,"z"),o(j,"readImport");function k(t,i,e){return t==="~"?a(e):t.startsWith("~/")?a(e,t.slice(2)):I(t)?a(t):a(i,t)}s(k,"X"),o(k,"resolveImportPath");function O(t,i){let e=!1,n=0;for(;n<i&&n<t.length;)if(t[n]==="`"){for(;n<t.length&&t[n]==="`";)n++;e=!e}else n++;return e}s(O,"$"),o(O,"isInsideInlineCode");function P(t){const i=/^[ \t]*(`{3,}|~{3,})/.exec(t);return i?{char:i[1][0],len:i[1].length}:void 0}s(P,"F"),o(P,"matchFence");function v(t,i,e,n){if(e>=n.maxDepth||!t.includes("@"))return t;const r=t.split(`
2
+ `);let l;for(let d=0;d<r.length;d++){const c=r[d],u=P(c);if(l){u&&u.char===l.char&&u.len>=l.len&&(l=void 0);continue}if(u){l=u;continue}if(!c.includes("@"))continue;let x="",f=0;for(const p of c.matchAll(X)){const m=(p.index??0)+p[1].length;if(O(c,m))continue;const g=p[2].replace(B,"");if(!g)continue;const h=k(g,i,n.home);if(n.visited.has(h))continue;const y=j(h,n);y!==void 0&&(n.visited.add(h),x+=c.slice(f,m)+v(y,_(h),e+1,n),f=m+1+g.length)}f>0&&(r[d]=x+c.slice(f))}return r.join(`
3
+ `)}s(v,"T"),o(v,"expand");function w(t,i,e){const n=a(i);let r=a(e.root);try{r=A(r)}catch{}return v(t,_(n),0,{visited:new Set([n]),budget:{left:S},root:r,home:e.home??F(),maxDepth:e.maxDepth??T})}s(w,"L"),o(w,"expandAtImports");export{T as MAX_AT_IMPORT_DEPTH,S as MAX_IMPORTS_TOTAL_BYTES,b as MAX_IMPORT_BYTES,w as expandAtImports};
@@ -1,7 +1,9 @@
1
- var E=Object.defineProperty;var s=(t,e)=>E(t,"name",{value:e,configurable:!0});var g=Object.defineProperty,i=s((t,e)=>g(t,"name",{value:e,configurable:!0}),"r");import{readFileSync as R}from"node:fs";import{join as y}from"node:path";import{t as F}from"@dalcode/dal-pi-kit";import{getAgentDir as S}from"@earendil-works/pi-coding-agent";import{findClaudeRules as C,ruleMatches as T}from"./claude-rules.js";import{findClaudeRules as j,MAX_RULE_FILE_BYTES as w,MAX_RULES_TOTAL_BYTES as x,parseRuleFile as L,projectDirs as A,ruleMatches as M}from"./claude-rules.js";const v=new Set(["read","edit","write"]);function m(t,e){if(e.includes("--no-context-files")||e.includes("-nc"))return!1;try{return JSON.parse(R(y(t,"settings.json"),"utf8")).dalCompat?.claudeRules!==!1}catch{return!0}}s(m,"E"),i(m,"claudeRulesEnabled");function f(t){return`<project_instructions path="${t.path}" applies_to="${(t.paths??[]).join(", ")}">
2
- ${t.content}
3
- </project_instructions>`}s(f,"w"),i(f,"conditionalRuleText");function d(t={}){return i(function(e){let u=!1,l=process.cwd(),r=[];const p=new Set,h=i(o=>{r=C({cwd:l,...t.home?{home:t.home}:{},alreadyLoaded:o})},"rescan");e.on("session_start",async(o,n)=>{l=n.cwd,p.clear(),u=m(S(),t.argv??process.argv),u&&(h([]),r.length>0&&n.mode==="tui"&&n.ui.notify(F("\u5DF2\u5E94\u7528 {count} \u4E2A Claude Code \u89C4\u5219\u6587\u4EF6\uFF08.claude/\uFF09").replace("{count}",String(r.length)),"info"))}),e.on("before_agent_start",async o=>{if(!u)return;const n=o.systemPromptOptions;h(n.contextFiles.map(a=>a.path));for(const a of r)a.paths||n.contextFiles.push({path:a.path,content:a.content})}),e.on("tool_result",async o=>{if(!u||o.isError||!v.has(o.toolName))return;const n=typeof o.input.path=="string"?o.input.path:void 0;if(!n)return;const a=r.filter(c=>!p.has(c.path)&&T(c,n,l));if(a.length===0)return;for(const c of a)p.add(c.path);const _=["The following project rules apply to this file; follow them:",...a.map(f)].join(`
1
+ var D=Object.defineProperty;var f=(e,r)=>D(e,"name",{value:r,configurable:!0});var v=Object.defineProperty,i=f((e,r)=>v(e,"name",{value:r,configurable:!0}),"s");import{existsSync as O,readFileSync as g,statSync as X}from"node:fs";import{homedir as $}from"node:os";import{dirname as E,isAbsolute as b,join as j,relative as P,resolve as p}from"node:path";import{t as U}from"@dalcode/dal-pi-kit";import{getAgentDir as B}from"@earendil-works/pi-coding-agent";import{expandAtImports as Y}from"./at-imports.js";import{findClaudeRules as N,MAX_RULE_FILE_BYTES as H,projectDirs as k,ruleMatches as z}from"./claude-rules.js";import{expandAtImports as G,MAX_AT_IMPORT_DEPTH as J}from"./at-imports.js";import{findClaudeRules as W,MAX_RULE_FILE_BYTES as q,MAX_RULES_TOTAL_BYTES as K,parseRuleFile as Q,projectDirs as V,ruleMatches as Z}from"./claude-rules.js";const tt=new Set(["read","edit","write"]);function w(e,r){const a=i(o=>({claudeRules:o,atImports:o,nestedInstructions:o}),"all");if(r.includes("--no-context-files")||r.includes("-nc"))return a(!1);try{const o=JSON.parse(g(j(e,"settings.json"),"utf8")).dalCompat??{};return{claudeRules:o.claudeRules!==!1,atImports:o.atImports!==!1,nestedInstructions:o.nestedInstructions!==!1}}catch{return a(!0)}}f(w,"k"),i(w,"compatEnabled");const et=["AGENTS.md","CLAUDE.md"];function A(e,r){return`<project_instructions path="${e}" applies_to="${E(e)}/**">
2
+ ${r}
3
+ </project_instructions>`}f(A,"z"),i(A,"nestedInstructionText");function S(e){return`<project_instructions path="${e.path}" applies_to="${(e.paths??[]).join(", ")}">
4
+ ${e.content}
5
+ </project_instructions>`}f(S,"G"),i(S,"conditionalRuleText");function _(e,r){const a=P(e,r);return a!==""&&!a.startsWith("..")&&!b(a)}f(_,"_"),i(_,"inside");function x(e={}){return i(function(r){let a={claudeRules:!1,atImports:!1,nestedInstructions:!1},o=process.cwd(),m=[];const h=new Set;let R=new Set;const I=i(()=>e.home??$(),"home"),y=i(s=>{m=N({cwd:o,...e.home?{home:e.home}:{},alreadyLoaded:s})},"rescan"),L=i(s=>{const t=k(o,I())[0]??p(o);return _(t,p(s))?t:_(p(I()),p(s))?I():E(p(s))},"importRoot"),T=i((s,t)=>a.atImports?Y(t,s,{root:L(s),home:I()}):t,"withImports");r.on("session_start",async(s,t)=>{o=t.cwd,h.clear(),R=new Set,a=w(B(),e.argv??process.argv),a.claudeRules&&(y([]),m.length>0&&t.mode==="tui"&&t.ui.notify(U("\u5DF2\u5E94\u7528 {count} \u4E2A Claude Code \u89C4\u5219\u6587\u4EF6\uFF08.claude/\uFF09").replace("{count}",String(m.length)),"info"))}),r.on("before_agent_start",async s=>{const t=s.systemPromptOptions;if(a.claudeRules){y(t.contextFiles.map(n=>n.path));for(const n of m)n.paths||t.contextFiles.push({path:n.path,content:n.content})}if(a.atImports)for(const n of t.contextFiles)n.content=T(n.path,n.content);R=new Set(t.contextFiles.map(n=>p(n.path)))});const M=i(s=>{const t=p(o,s),n=p(o);if(!_(n,t))return[];const u=[],c=[];for(let d=E(t);_(n,d);d=E(d))c.unshift(d);for(const d of c)for(const C of et){const l=j(d,C);if(O(l)){if(!h.has(l)&&!R.has(l)){h.add(l);try{if(X(l).size<=H){const F=g(l,"utf8").trim();F&&u.push(A(l,T(l,F)))}}catch{}}break}}return u},"nestedInstructions");r.on("tool_result",async s=>{if(s.isError||!tt.has(s.toolName))return;const t=typeof s.input.path=="string"?s.input.path:void 0;if(!t)return;const n=[];if(a.nestedInstructions){const u=M(t);u.length>0&&n.push("This directory has its own project instructions; follow them for files here:",...u)}if(a.claudeRules){const u=m.filter(c=>!h.has(c.path)&&z(c,t,o));for(const c of u)h.add(c.path);u.length>0&&n.push("The following project rules apply to this file; follow them:",...u.map(c=>S({...c,content:T(c.path,c.content)})))}if(n.length!==0)return{content:[...s.content,{type:"text",text:`
4
6
 
5
- `);return{content:[...o.content,{type:"text",text:`
7
+ ${n.join(`
6
8
 
7
- ${_}`}]}})},"dalCompat")}s(d,"S"),i(d,"createDalCompat");var D=d();export{x as MAX_RULES_TOTAL_BYTES,w as MAX_RULE_FILE_BYTES,f as conditionalRuleText,d as createDalCompat,D as default,j as findClaudeRules,L as parseRuleFile,A as projectDirs,M as ruleMatches};
9
+ `)}`}]}})},"dalCompat")}f(x,"H"),i(x,"createDalCompat");var st=x();export{J as MAX_AT_IMPORT_DEPTH,K as MAX_RULES_TOTAL_BYTES,q as MAX_RULE_FILE_BYTES,S as conditionalRuleText,x as createDalCompat,st as default,G as expandAtImports,W as findClaudeRules,A as nestedInstructionText,Q as parseRuleFile,V as projectDirs,Z as ruleMatches};
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-dap",
3
- "version": "1.0.40",
3
+ "version": "1.0.42",
4
4
  "private": true,
5
5
  "description": "Debugger for DAL: breakpoints, stepping, call stacks and variables in Node.js and Python programs over the Debug Adapter Protocol, installing the adapter on first use. The DAP client is adapted from oh-my-pi's src/dap (MIT).",
6
6
  "license": "MIT",
@@ -24,7 +24,7 @@
24
24
  ]
25
25
  },
26
26
  "dependencies": {
27
- "@dalcode/dal-pi-kit": "1.0.40",
27
+ "@dalcode/dal-pi-kit": "1.0.42",
28
28
  "typebox": "1.3.27"
29
29
  },
30
30
  "peerDependencies": {
@@ -1,2 +1,2 @@
1
- var P=Object.defineProperty;var s=(e,r)=>P(e,"name",{value:r,configurable:!0});var R=Object.defineProperty,l=s((e,r)=>R(e,"name",{value:r,configurable:!0}),"c");import{spawn as j}from"node:child_process";import{createHash as z,randomBytes as I}from"node:crypto";import{existsSync as k,mkdirSync as B,readFileSync as L,renameSync as O,rmSync as F,writeFileSync as D}from"node:fs";import{join as d}from"node:path";import{t as f}from"@dalcode/dal-pi-kit";import{getAgentDir as M}from"@earendil-works/pi-coding-agent";const _={id:"debugpy-1.8.21",label:"debugpy 1.8.21",file:"debugpy-1.8.21-py2.py3-none-any.whl",sha256:"b1e37d333663c8851516a47364ef473da127f9caebe4417e6df6f5825a7e9a92",bytes:5374e3,urls:["https://mirrors.aliyun.com/pypi/packages/95/51/67e7cf11a53e40694f720457d5b3a1cdaaa3d5a9a633e482f225456b93ff/debugpy-1.8.21-py2.py3-none-any.whl","https://files.pythonhosted.org/packages/95/51/67e7cf11a53e40694f720457d5b3a1cdaaa3d5a9a633e482f225456b93ff/debugpy-1.8.21-py2.py3-none-any.whl"],format:"wheel"},G={id:"js-debug-1.140.0",label:"vscode-js-debug 1.140.0",file:"js-debug-dap-v1.140.0.tar.gz",sha256:"27dab92937ec1ab35821ae955aac867544fe06a1b6307229049f2d789af10968",bytes:1249709,urls:["https://github.com/microsoft/vscode-js-debug/releases/download/v1.140.0/js-debug-dap-v1.140.0.tar.gz"],format:"tar.gz"},H=20*1024*1024,U=12e4,C=".dal-installed";function y(){return d(M(),"tools","dap")}s(y,"S"),l(y,"adapterInstallRoot");function h(e,r=y()){const u=d(r,e.id);try{return L(d(u,C),"utf8").trim()===e.sha256?u:void 0}catch{return}}s(h,"h"),l(h,"installedArtifactDir");function v(){return process.env.DALCODE_MCP_MIRROR?.trim().toLowerCase()==="off"}s(v,"R"),l(v,"mirrorsOff");function A(){const e=process.env.PI_OFFLINE?.toLowerCase();return e==="1"||e==="true"||e==="yes"}s(A,"z"),l(A,"offline");function g(e){try{return new URL(e).host}catch{return e}}s(g,"x"),l(g,"hostOf");async function S(e,r,u,p){const b=AbortSignal.timeout(U),i=await u(e,{signal:p?AbortSignal.any([p,b]):b});if(!i.ok)throw await i.body?.cancel(),new Error(`HTTP ${i.status}`);const c=i.body?.getReader();if(!c)throw new Error(f("\u54CD\u5E94\u6CA1\u6709\u5185\u5BB9"));const n=[];let o=0;for(;;){const{done:w,value:E}=await c.read();if(w)break;if(o+=E.byteLength,o>H)throw await c.cancel(),new Error(f("\u6587\u4EF6\u8D85\u8FC7 20 MB\uFF0C\u5DF2\u505C\u6B62\u4E0B\u8F7D"));n.push(E)}const a=Buffer.concat(n),t=z("sha256").update(a).digest("hex");if(t!==r.sha256)throw new Error(f("\u6821\u9A8C\u503C\u4E0D\u7B26\uFF08\u4E0B\u8F7D\u5230\u7684 {got}\uFF0C\u5E94\u4E3A {want}\uFF09\uFF0C\u5DF2\u4E22\u5F03").replace("{got}",t.slice(0,12)).replace("{want}",r.sha256.slice(0,12)));return a}s(S,"F"),l(S,"downloadVerified");function m(e,r,u){return new Promise((p,b)=>{const i=j(e,r,{cwd:u,stdio:["ignore","ignore","pipe"],windowsHide:!0});let c="";i.stderr.on("data",n=>{c=(c+n.toString("utf8")).slice(-2e3)}),i.once("error",b),i.once("exit",n=>n===0?p():b(new Error(`${e} exited ${n}: ${c.trim()}`)))})}s(m,"E"),l(m,"run");function $(){if(process.platform!=="win32")return"tar";const e=d(process.env.SystemRoot??"C:\\Windows","System32","tar.exe");return k(e)?e:"tar.exe"}s($,"M"),l($,"tarCommand");async function x(e,r={}){const u=r.root??y(),p=h(e,u);if(p)return p;if(A())throw new Error(f("\u79BB\u7EBF\u6A21\u5F0F\u4E0B\u4E0D\u80FD\u4E0B\u8F7D\u8C03\u8BD5\u5668 {label}\u3002").replace("{label}",e.label));const b=r.fetchImpl??((a,t)=>fetch(a,t)),i=v()?e.urls.slice(-1):e.urls,c=[];let n;for(const a of i){r.onProgress?.(f("\u6B63\u5728\u5B89\u88C5\u8C03\u8BD5\u5668 {label}\uFF08\u7EA6 {size} MB\uFF0C\u6765\u6E90 {host}\uFF09\u2026").replace("{label}",e.label).replace("{size}",(e.bytes/1024/1024).toFixed(1)).replace("{host}",g(a)));try{n=await S(a,e,b,r.signal);break}catch(t){if(r.signal?.aborted)throw t;c.push(`${g(a)}: ${t instanceof Error?t.message:String(t)}`)}}if(!n)throw new Error(`${f("\u8C03\u8BD5\u5668 {label} \u4E0B\u8F7D\u5931\u8D25\uFF1A").replace("{label}",e.label)}${c.join("\uFF1B")}${f("\u3002\u8BF7\u68C0\u67E5\u7F51\u7EDC\u6216\u4EE3\u7406\u8BBE\u7F6E\u540E\u91CD\u8BD5\u3002")}`);B(u,{recursive:!0});const o=d(u,`.${e.id}-${process.pid}-${I(4).toString("hex")}`);B(o,{recursive:!0});try{const a=d(o,e.file);if(D(a,n),e.format==="wheel"){if(!r.python)throw new Error(f("\u89E3\u538B debugpy \u9700\u8981 Python"));await m(r.python,["-I","-m","zipfile","-e",a,o],o)}else await m($(),["-xzf",a,"-C",o],o);F(a,{force:!0}),D(d(o,C),`${e.sha256}
2
- `);const t=d(u,e.id);if(h(e,u))return t;F(t,{recursive:!0,force:!0});try{O(o,t)}catch(w){if(h(e,u))return t;throw w}return t}catch(a){throw new Error(`${f("\u8C03\u8BD5\u5668 {label} \u89E3\u538B\u5931\u8D25\uFF1A").replace("{label}",e.label)}${a instanceof Error?a.message:String(a)}`)}finally{F(o,{recursive:!0,force:!0})}}s(x,"J"),l(x,"ensureArtifact");export{_ as DEBUGPY,G as JS_DEBUG,y as adapterInstallRoot,x as ensureArtifact,h as installedArtifactDir};
1
+ var M=Object.defineProperty;var i=(e,r)=>M(e,"name",{value:r,configurable:!0});var L=Object.defineProperty,l=i((e,r)=>L(e,"name",{value:r,configurable:!0}),"l");import{spawn as T}from"node:child_process";import{createHash as U,randomBytes as _}from"node:crypto";import{existsSync as G,mkdirSync as v,readFileSync as H,renameSync as W,rmSync as F,writeFileSync as S}from"node:fs";import{join as m}from"node:path";import{gunzipSync as J}from"node:zlib";import{t as p}from"@dalcode/dal-pi-kit";import{getAgentDir as V}from"@earendil-works/pi-coding-agent";const A=["https://registry.npmmirror.com","https://registry.npmjs.org"];function B(e,r,t){const o=r.includes("/")?r.slice(r.indexOf("/")+1):r;return`${e.replace(/\/+$/,"")}/${r}/-/${o}-${t}.tgz`}i(B,"D"),l(B,"npmTarballUrl");const Y={id:"debugpy-1.8.21",label:"debugpy 1.8.21",file:"debugpy-1.8.21-py2.py3-none-any.whl",sha256:"b1e37d333663c8851516a47364ef473da127f9caebe4417e6df6f5825a7e9a92",bytes:5374e3,urls:["https://mirrors.aliyun.com/pypi/packages/95/51/67e7cf11a53e40694f720457d5b3a1cdaaa3d5a9a633e482f225456b93ff/debugpy-1.8.21-py2.py3-none-any.whl","https://files.pythonhosted.org/packages/95/51/67e7cf11a53e40694f720457d5b3a1cdaaa3d5a9a633e482f225456b93ff/debugpy-1.8.21-py2.py3-none-any.whl"],format:"wheel"},q={id:"js-debug-1.140.0",label:"vscode-js-debug 1.140.0",file:"js-debug-dap-v1.140.0.tar.gz",sha256:"27dab92937ec1ab35821ae955aac867544fe06a1b6307229049f2d789af10968",bytes:1249709,urls:["https://github.com/microsoft/vscode-js-debug/releases/download/v1.140.0/js-debug-dap-v1.140.0.tar.gz"],format:"tar.gz",npm:{name:"@deepailab/js-debug-dap",version:"1.140.0"}},x=20*1024*1024,K=12e4,P=".dal-installed";function E(){return m(V(),"tools","dap")}i(E,"E"),l(E,"adapterInstallRoot");function y(e,r=E()){const t=m(r,e.id);try{return H(m(t,P),"utf8").trim()===e.sha256?t:void 0}catch{return}}i(y,"w"),l(y,"installedArtifactDir");function k(){return process.env.DALCODE_MCP_MIRROR?.trim().toLowerCase()==="off"}i(k,"F"),l(k,"mirrorsOff");function j(){const e=process.env.PI_OFFLINE?.toLowerCase();return e==="1"||e==="true"||e==="yes"}i(j,"j"),l(j,"offline");function C(e){try{return new URL(e).host}catch{return e}}i(C,"v"),l(C,"hostOf");function I(e){if(k())return e.urls.slice(-1).map(t=>({url:t,inNpmPackage:!1}));const r=e.npm;return[...r?A.map(t=>({url:B(t,r.name,r.version),inNpmPackage:!0})):[],...e.urls.map(t=>({url:t,inNpmPackage:!1}))]}i(I,"T"),l(I,"sourcesOf");function D(e,r){let t=0,o;for(;t+512<=e.length;){const d=e.subarray(t,t+512);if(d.every(b=>b===0))return;const c=l((b,h)=>{const w=d.subarray(b,b+h),g=w.indexOf(0);return w.subarray(0,g===-1?h:g).toString("utf8")},"field"),n=Number.parseInt(c(124,12).trim()||"0",8),a=t+512;if(!Number.isFinite(n)||n<0||a+n>e.length)return;const u=String.fromCharCode(d[156]??0),s=c(345,155),f=o??(s?`${s}/${c(0,100)}`:c(0,100));if(o=void 0,u==="x")o=/(?:^|\n)\d+ path=([^\n]*)\n/.exec(e.subarray(a,a+n).toString("utf8"))?.[1];else if((u==="0"||u==="\0")&&f===r)return Buffer.from(e.subarray(a,a+n));t=a+Math.ceil(n/512)*512}}i(D,"U"),l(D,"tarMember");function O(e,r){let t;try{t=J(e,{maxOutputLength:x*2})}catch{throw new Error(p("npm \u5305\u65E0\u6CD5\u89E3\u5F00"))}const o=D(t,`package/${r.file}`);if(!o)throw new Error(p("npm \u5305\u91CC\u6CA1\u6709 {file}").replace("{file}",r.file));return o}i(O,"G"),l(O,"fromNpmPackage");async function R(e,r,t,o){const d=e.url,c=AbortSignal.timeout(K),n=await t(d,{signal:o?AbortSignal.any([o,c]):c});if(!n.ok)throw await n.body?.cancel(),new Error(`HTTP ${n.status}`);const a=n.body?.getReader();if(!a)throw new Error(p("\u54CD\u5E94\u6CA1\u6709\u5185\u5BB9"));const u=[];let s=0;for(;;){const{done:w,value:g}=await a.read();if(w)break;if(s+=g.byteLength,s>x)throw await a.cancel(),new Error(p("\u6587\u4EF6\u8D85\u8FC7 20 MB\uFF0C\u5DF2\u505C\u6B62\u4E0B\u8F7D"));u.push(g)}const f=Buffer.concat(u),b=e.inNpmPackage?O(f,r):f,h=U("sha256").update(b).digest("hex");if(h!==r.sha256)throw new Error(p("\u6821\u9A8C\u503C\u4E0D\u7B26\uFF08\u4E0B\u8F7D\u5230\u7684 {got}\uFF0C\u5E94\u4E3A {want}\uFF09\uFF0C\u5DF2\u4E22\u5F03").replace("{got}",h.slice(0,12)).replace("{want}",r.sha256.slice(0,12)));return b}i(R,"H"),l(R,"downloadVerified");function $(e,r,t){return new Promise((o,d)=>{const c=T(e,r,{cwd:t,stdio:["ignore","ignore","pipe"],windowsHide:!0});let n="";c.stderr.on("data",a=>{n=(n+a.toString("utf8")).slice(-2e3)}),c.once("error",d),c.once("exit",a=>a===0?o():d(new Error(`${e} exited ${a}: ${n.trim()}`)))})}i($,"P"),l($,"run");function z(){if(process.platform!=="win32")return"tar";const e=m(process.env.SystemRoot??"C:\\Windows","System32","tar.exe");return G(e)?e:"tar.exe"}i(z,"W"),l(z,"tarCommand");async function N(e,r={}){const t=r.root??E(),o=y(e,t);if(o)return o;if(j())throw new Error(p("\u79BB\u7EBF\u6A21\u5F0F\u4E0B\u4E0D\u80FD\u4E0B\u8F7D\u8C03\u8BD5\u5668 {label}\u3002").replace("{label}",e.label));const d=r.fetchImpl??((u,s)=>fetch(u,s)),c=[];let n;for(const u of I(e)){const s=u.url;r.onProgress?.(p("\u6B63\u5728\u5B89\u88C5\u8C03\u8BD5\u5668 {label}\uFF08\u7EA6 {size} MB\uFF0C\u6765\u6E90 {host}\uFF09\u2026").replace("{label}",e.label).replace("{size}",(e.bytes/1024/1024).toFixed(1)).replace("{host}",C(s)));try{n=await R(u,e,d,r.signal);break}catch(f){if(r.signal?.aborted)throw f;c.push(`${C(s)}: ${f instanceof Error?f.message:String(f)}`)}}if(!n)throw new Error(`${p("\u8C03\u8BD5\u5668 {label} \u4E0B\u8F7D\u5931\u8D25\uFF1A").replace("{label}",e.label)}${c.join("\uFF1B")}${p("\u3002\u8BF7\u68C0\u67E5\u7F51\u7EDC\u6216\u4EE3\u7406\u8BBE\u7F6E\u540E\u91CD\u8BD5\u3002")}`);v(t,{recursive:!0});const a=m(t,`.${e.id}-${process.pid}-${_(4).toString("hex")}`);v(a,{recursive:!0});try{const u=m(a,e.file);if(S(u,n),e.format==="wheel"){if(!r.python)throw new Error(p("\u89E3\u538B debugpy \u9700\u8981 Python"));await $(r.python,["-I","-m","zipfile","-e",u,a],a)}else await $(z(),["-xzf",u,"-C",a],a);F(u,{force:!0}),S(m(a,P),`${e.sha256}
2
+ `);const s=m(t,e.id);if(y(e,t))return s;F(s,{recursive:!0,force:!0});try{W(a,s)}catch(f){if(y(e,t))return s;throw f}return s}catch(u){throw new Error(`${p("\u8C03\u8BD5\u5668 {label} \u89E3\u538B\u5931\u8D25\uFF1A").replace("{label}",e.label)}${u instanceof Error?u.message:String(u)}`)}finally{F(a,{recursive:!0,force:!0})}}i(N,"te"),l(N,"ensureArtifact");export{Y as DEBUGPY,q as JS_DEBUG,A as NPM_REGISTRIES,E as adapterInstallRoot,N as ensureArtifact,y as installedArtifactDir,B as npmTarballUrl,D as tarMember};
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-gateway",
3
- "version": "1.0.40",
3
+ "version": "1.0.42",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -17,7 +17,7 @@
17
17
  ]
18
18
  },
19
19
  "dependencies": {
20
- "@dalcode/deepailab": "1.0.40"
20
+ "@dalcode/deepailab": "1.0.42"
21
21
  },
22
22
  "peerDependencies": {
23
23
  "@earendil-works/pi-coding-agent": "^1.0.9"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-goal",
3
- "version": "1.0.40",
3
+ "version": "1.0.42",
4
4
  "private": true,
5
5
  "description": "Goal mode for DAL: /goal keeps the agent working on one objective until it is verified complete, with token and continuation limits. Adapted from @narumitw/pi-goal 0.54.11 (MIT, narumiruna); the independent completion check adapts pi-goal-x 0.32.3 (MIT, Lucas).",
6
6
  "license": "MIT",
@@ -21,8 +21,8 @@
21
21
  ]
22
22
  },
23
23
  "dependencies": {
24
- "@dalcode/dal-pi-kit": "1.0.40",
25
- "@dalcode/dal-subagent": "1.0.40",
24
+ "@dalcode/dal-pi-kit": "1.0.42",
25
+ "@dalcode/dal-subagent": "1.0.42",
26
26
  "typebox": "1.3.27"
27
27
  },
28
28
  "peerDependencies": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-guard",
3
- "version": "1.0.40",
3
+ "version": "1.0.42",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -20,9 +20,9 @@
20
20
  ]
21
21
  },
22
22
  "dependencies": {
23
- "@dalcode/dal-pi-kit": "1.0.40",
24
- "@dalcode/dal-bridge": "1.0.40",
25
- "@dalcode/dal-halo": "1.0.40"
23
+ "@dalcode/dal-pi-kit": "1.0.42",
24
+ "@dalcode/dal-bridge": "1.0.42",
25
+ "@dalcode/dal-halo": "1.0.42"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "@earendil-works/pi-coding-agent": "^1.0.9"
@@ -1,23 +1,24 @@
1
- var U=Object.defineProperty;var u=(e,n)=>U(e,"name",{value:n,configurable:!0});var $=Object.defineProperty,g=u((e,n)=>$(e,"name",{value:n,configurable:!0}),"g");import{normalizeForFuzzyMatch as T}from"@earendil-works/pi-coding-agent";function p(e){return(e.startsWith("\uFEFF")?e.slice(1):e).replace(/\r\n/g,`
1
+ var U=Object.defineProperty;var u=(i,t)=>U(i,"name",{value:t,configurable:!0});var C=Object.defineProperty,g=u((i,t)=>C(i,"name",{value:t,configurable:!0}),"g");import{normalizeForFuzzyMatch as v}from"@earendil-works/pi-coding-agent";function p(i){return(i.startsWith("\uFEFF")?i.slice(1):i).replace(/\r\n/g,`
2
2
  `).replace(/\r/g,`
3
- `)}u(p,"m"),g(p,"toLF");function x(e,n){if(n.length===0)return 0;const r=e.split(n).length-1;if(r>0)return r;const t=T(n);return t.length===0?0:T(e).split(t).length-1}u(x,"x"),g(x,"countMatches");function v(e,n){if(x(e,n)!==1)return;let r=e,t=n,o=r.indexOf(t);if(o===-1&&(r=T(e),t=T(n),o=r.indexOf(t),o===-1))return;const i=M(r,0,o),l=i+M(t,0,t.length)-(t.endsWith(`
4
- `)?1:0),f=e.split(`
5
- `);return{first:i,last:l,text:f.slice(i,l+1).join(`
6
- `)}}u(v,"w"),g(v,"matchedLines");function M(e,n,r){let t=0;for(let o=n;o<r;o++)e.charCodeAt(o)===10&&t++;return t}u(M,"k"),g(M,"countNewlines");function b(e,n){if(e===n)return;const r=e.split(`
7
- `),t=n.split(`
8
- `);let o=0;for(;o<r.length&&o<t.length&&r[o]===t[o];)o++;let i=0;for(;i<r.length-o&&i<t.length-o&&r[r.length-1-i]===t[t.length-1-i];)i++;return{from:o+1,to:Math.max(o+1,t.length-i)}}u(b,"A"),g(b,"changedRange");function y(e,n,r){const t=e.split(`
9
- `),o=Math.max(1,n),i=Math.min(t.length,r),l=String(i).length,f=[];for(let a=o;a<=i;a++)f.push(`${String(a).padStart(l," ")}| ${t[a-1]}`);return f.join(`
10
- `)}u(y,"L"),g(y,"numberedLines");const z=3,C=40;function F(e,n,r){if(e===n)return{kind:"ok"};for(let o=0;o<r.length;o++){const i=p(r[o].oldText),l=v(e,i);if(!l)continue;const f=x(n,i),a=f===1?v(n,i):void 0;if(a&&a.text===l.text&&W(e,l,n,a))continue;const m=f===0?"gone":f>1?"ambiguous":a&&a.text===l.text?"moved":"changed",c=a?{from:a.first+1,to:a.last+1}:N(e,n,l.first,l.last),s=Math.max(1,c.from-z),h=Math.min(c.to+z,s+C-1);return{kind:"stale",editIndex:o,reason:m,occurrences:f,from:s,to:h}}const t=b(e,n);return t?{kind:"changed-elsewhere",...t}:{kind:"ok"}}u(F,"B"),g(F,"checkAgainstSnapshot");function W(e,n,r,t){const o=e.split(`
11
- `),i=r.split(`
12
- `);return o[n.first-1]===i[t.first-1]&&o[n.last+1]===i[t.last+1]}u(W,"M"),g(W,"sameNeighbours");function N(e,n,r,t){const o=e.split(`
13
- `),i=n.split(`
14
- `);let l=0;for(;l<o.length&&l<i.length&&o[l]===i[l];)l++;let f=0;for(;f<o.length-l&&f<i.length-l&&o[o.length-1-f]===i[i.length-1-f];)f++;const a=o.length-f,m=i.length-o.length;return t<l?{from:r+1,to:t+1}:r>=a?{from:r+1+m,to:t+1+m}:{from:l+1,to:Math.max(l+1,i.length-f)}}u(N,"v"),g(N,"mapRegion");const I=/\n{1,2}\[(?:Showing lines \d+-\d+ of \d+(?: \([^)\]]*\))?\. Use offset=\d+ to continue\.|\d+ more lines in file\. Use offset=\d+ to continue\.)\]\s*$/;function S(e){const n=I.exec(e);return n?e.slice(0,n.index):void 0}u(S,"S"),g(S,"stripReadNotice");function w(e){return/^[ \t]*/.exec(e)?.[0]??""}u(w,"y"),g(w,"leadingWhitespace");function R(e,n){const r=p(n.oldText).split(`
15
- `);if(r.length>1&&r[r.length-1]===""&&r.pop(),r.every(s=>s.trim()===""))return;const t=e.split(`
16
- `),o=r.map(s=>s.trim());let i=-1;for(let s=0;s+r.length<=t.length;s++){let h=!0;for(let d=0;d<r.length&&h;d++)h=t[s+d].trim()===o[d];if(h){if(i!==-1)return;i=s}}if(i===-1)return;let l;for(let s=0;s<r.length;s++){if(o[s]==="")continue;const h=w(t[i+s]),d=w(r[s]);let k;if(h.endsWith(d))k={add:h.slice(0,h.length-d.length)};else if(d.endsWith(h))k={remove:d.slice(0,d.length-h.length)};else return;if(!l)l=k;else if(JSON.stringify(l)!==JSON.stringify(k))return}if(!l)return;const f=t.slice(i,i+r.length).join(`
17
- `),a=p(n.oldText).endsWith(`
18
- `),m=p(n.newText).split(`
19
- `),c=m.map((s,h)=>s.trim()===""||h===m.length-1&&s===""?s:"add"in l?l.add+s:s.startsWith(l.remove)?s.slice(l.remove.length):s);return{oldText:f+(a?`
3
+ `)}u(p,"m"),g(p,"toLF");function x(i,t){if(t.length===0)return 0;const n=i.split(t).length-1;if(n>0)return n;const e=v(t);return e.length===0?0:v(i).split(e).length-1}u(x,"b"),g(x,"countMatches");function k(i,t){if(x(i,t)!==1)return;let n=i,e=t,s=n.indexOf(e);if(s===-1&&(n=v(i),e=v(t),s=n.indexOf(e),s===-1))return;const o=b(n,0,s),l=o+b(e,0,e.length)-(e.endsWith(`
4
+ `)?1:0),a=i.split(`
5
+ `);return{first:o,last:l,text:a.slice(o,l+1).join(`
6
+ `)}}u(k,"k"),g(k,"matchedLines");function b(i,t,n){let e=0;for(let s=t;s<n;s++)i.charCodeAt(s)===10&&e++;return e}u(b,"w"),g(b,"countNewlines");function y(i,t){if(i===t)return;const n=i.split(`
7
+ `),e=t.split(`
8
+ `);let s=0;for(;s<n.length&&s<e.length&&n[s]===e[s];)s++;let o=0;for(;o<n.length-s&&o<e.length-s&&n[n.length-1-o]===e[e.length-1-o];)o++;return{from:s+1,to:Math.max(s+1,e.length-o)}}u(y,"v"),g(y,"changedRange");function R(i,t,n){const e=i.split(`
9
+ `),s=Math.max(1,t),o=Math.min(e.length,n),l=String(o).length,a=[];for(let h=s;h<=o;h++)a.push(`${String(h).padStart(l," ")}| ${e[h-1]}`);return a.join(`
10
+ `)}u(R,"$"),g(R,"numberedLines");const z=3,I=40;function F(i,t,n){if(i===t)return{kind:"ok"};for(let s=0;s<n.length;s++){const o=p(n[s].oldText),l=k(i,o);if(!l)continue;const a=x(t,o),h=a===1?k(t,o):void 0;if(h&&h.text===l.text&&W(i,l,t,h))continue;const m=a===0?"gone":a>1?"ambiguous":h&&h.text===l.text?"moved":"changed",c=h?{from:h.first+1,to:h.last+1}:N(i,t,l.first,l.last),r=Math.max(1,c.from-z),f=Math.min(c.to+z,r+I-1);return{kind:"stale",editIndex:s,reason:m,occurrences:a,from:r,to:f}}const e=y(i,t);return e?{kind:"changed-elsewhere",...e}:{kind:"ok"}}u(F,"B"),g(F,"checkAgainstSnapshot");function W(i,t,n,e){const s=i.split(`
11
+ `),o=n.split(`
12
+ `);return s[t.first-1]===o[e.first-1]&&s[t.last+1]===o[e.last+1]}u(W,"z"),g(W,"sameNeighbours");function N(i,t,n,e){const s=i.split(`
13
+ `),o=t.split(`
14
+ `);let l=0;for(;l<s.length&&l<o.length&&s[l]===o[l];)l++;let a=0;for(;a<s.length-l&&a<o.length-l&&s[s.length-1-a]===o[o.length-1-a];)a++;const h=s.length-a,m=o.length-s.length;return e<l?{from:n+1,to:e+1}:n>=h?{from:n+1+m,to:e+1+m}:{from:l+1,to:Math.max(l+1,o.length-a)}}u(N,"A"),g(N,"mapRegion");const J=/\n{1,2}\[(?:Showing lines \d+-\d+ of \d+(?: \([^)\]]*\))?\. Use offset=\d+ to continue\.|\d+ more lines in file\. Use offset=\d+ to continue\.)\]\s*$/;function w(i){const t=J.exec(i);return t?i.slice(0,t.index):void 0}u(w,"E"),g(w,"stripReadNotice");function L(i){return/^[ \t]*/.exec(i)?.[0]??""}u(L,"S"),g(L,"leadingWhitespace");function M(i,t){const n=p(t.oldText).split(`
15
+ `);if(n.length>1&&n[n.length-1]===""&&n.pop(),n.every(r=>r.trim()===""))return;const e=i.split(`
16
+ `),s=n.map(r=>r.trim());let o=-1;for(let r=0;r+n.length<=e.length;r++){let f=!0;for(let d=0;d<n.length&&f;d++)f=e[r+d].trim()===s[d];if(f){if(o!==-1)return;o=r}}if(o===-1)return;let l;for(let r=0;r<n.length;r++){if(s[r]==="")continue;const f=L(e[o+r]),d=L(n[r]);let T;if(f.endsWith(d))T={add:f.slice(0,f.length-d.length)};else if(d.endsWith(f))T={remove:d.slice(0,d.length-f.length)};else return;if(!l)l=T;else if(JSON.stringify(l)!==JSON.stringify(T))return}if(!l)return;const a=e.slice(o,o+n.length).join(`
17
+ `),h=p(t.oldText).endsWith(`
18
+ `),m=p(t.newText).split(`
19
+ `),c=m.map((r,f)=>r.trim()===""||f===m.length-1&&r===""?r:"add"in l?l.add+r:r.startsWith(l.remove)?r.slice(l.remove.length):r);return{oldText:a+(h?`
20
20
  `:""),newText:c.join(`
21
- `)}}u(R,"O"),g(R,"indentationRepair");function O(e,n){if(x(e,p(n.oldText))>0)return;const r=S(p(n.oldText));if(r!==void 0&&r.length>0&&x(e,r)===1)return{edit:{oldText:r,newText:S(p(n.newText))??n.newText},kind:"read-notice"};const t=R(e,n);if(t&&x(e,t.oldText)===1)return{edit:t,kind:"indentation"}}u(O,"C"),g(O,"repairEdit");function L(e){const n=e.replace(/\s+/g," ").trim(),r=new Set;for(let t=0;t<n.length-1;t++)r.add(n.slice(t,t+2));return r}u(L,"E"),g(L,"bigrams");function j(e,n){if(e===n)return 1;const r=L(e),t=L(n);if(r.size===0||t.size===0)return 0;let o=0;for(const i of r)t.has(i)&&o++;return 2*o/(r.size+t.size)}u(j,"R"),g(j,"similarity");const J=4e5;function A(e,n,r=2){const t=p(n).split(`
22
- `).map(c=>c.trim());for(;t.length>1&&t[t.length-1]==="";)t.pop();const o=e.split(`
23
- `).map(c=>c.trim()),i=Math.min(t.length,o.length);if(i===0||t.every(c=>c===""))return[];const l=o.length*i<=J,f=g((c,s)=>s===""?0:c===s?1:l?j(c,s):0,"lineScore"),a=[];for(let c=0;c+i<=o.length;c++){let s=0;for(let h=0;h<i;h++)s+=f(o[c+h],t[h]);a.push({start:c,score:s/i})}a.sort((c,s)=>s.score-c.score||c.start-s.start);const m=[];for(const c of a){if(m.length>=r||c.score<.4)break;const s=c.start+1,h=c.start+i;m.some(d=>s<=d.to&&h>=d.from)||m.push({from:s,to:h,score:c.score})}return m}u(A,"F"),g(A,"nearestRegions");function E(e,n,r=5){let t=e,o=n;t.includes(o)||(t=T(e),o=T(n));const i=[];if(o.length===0)return i;let l=0;for(;i.length<r;){const f=t.indexOf(o,l);if(f===-1)break;i.push(M(t,0,f)+1),l=f+o.length}return i}u(E,"U"),g(E,"occurrenceLines");export{b as changedRange,F as checkAgainstSnapshot,x as countMatches,R as indentationRepair,v as matchedLines,A as nearestRegions,y as numberedLines,E as occurrenceLines,O as repairEdit,S as stripReadNotice,p as toLF};
21
+ `)}}u(M,"O"),g(M,"indentationRepair");function O(i,t){if(x(i,p(t.oldText))>0)return;const n=w(p(t.oldText));if(n!==void 0&&n.length>0&&x(i,n)===1)return{edit:{oldText:n,newText:w(p(t.newText))??t.newText},kind:"read-notice"};const e=M(i,t);if(e&&x(i,e.oldText)===1)return{edit:e,kind:"indentation"}}u(O,"C"),g(O,"repairEdit");function S(i){const t=i.replace(/\s+/g," ").trim(),n=new Set;for(let e=0;e<t.length-1;e++)n.add(t.slice(e,e+2));return n}u(S,"T"),g(S,"bigrams");function j(i,t){if(i===t)return 1;const n=S(i),e=S(t);if(n.size===0||e.size===0)return 0;let s=0;for(const o of n)e.has(o)&&s++;return 2*s/(n.size+e.size)}u(j,"R"),g(j,"similarity");const B=4e5;function E(i,t,n=2){const e=p(t).split(`
22
+ `).map(c=>c.trim());for(;e.length>1&&e[e.length-1]==="";)e.pop();const s=i.split(`
23
+ `).map(c=>c.trim()),o=Math.min(e.length,s.length);if(o===0||e.every(c=>c===""))return[];const l=s.length*o<=B,a=g((c,r)=>r===""?0:c===r?1:l?j(c,r):0,"lineScore"),h=[];for(let c=0;c+o<=s.length;c++){let r=0;for(let f=0;f<o;f++)r+=a(s[c+f],e[f]);h.push({start:c,score:r/o})}h.sort((c,r)=>r.score-c.score||c.start-r.start);const m=[];for(const c of h){if(m.length>=n||c.score<.4)break;const r=c.start+1,f=c.start+o;m.some(d=>r<=d.to&&f>=d.from)||m.push({from:r,to:f,score:c.score})}return m}u(E,"F"),g(E,"nearestRegions");function $(i,t,n=5){let e=i,s=t;e.includes(s)||(e=v(i),s=v(t));const o=[];if(s.length===0)return o;let l=0;for(;o.length<n;){const a=e.indexOf(s,l);if(a===-1)break;o.push(b(e,0,a)+1),l=a+s.length}return o}u($,"U"),g($,"occurrenceLines");const D=/^\s*(?:(?:\/\/+|#+|--|;+|\/\*+|\*|<!--|\{\/\*)\s*|(?=(?:\.{3}|…)\s))(?:(?:\.{3}|…)\s*(?:\(?\s*)?(?:rest|remaining|existing|other|previous|unchanged|same|more|omitted|省略|其余|其他|其它|原有|不变|保持|以下|以上|之前|同上)[^\n]{0,80}|(?:rest of (?:the )?(?:code|file|implementation|function|class|methods?)|(?:the )?(?:existing|remaining|other) (?:code|methods|functions|implementation)s?(?: (?:here|goes here|unchanged|stays the same|remains? (?:the same|unchanged)))?|(?:code|everything) (?:above|below) (?:is |stays |remains )?unchanged|(?:其余|其他|其它|剩余|原有|以下|以上)(?:的)?(?:代码|部分|内容|实现|方法)?(?:不变|保持不变|同上|省略|略)|(?:此处)?省略(?:其余|若干|部分)?(?:代码|内容)?)\s*(?:\.{3}|…)?)\s*(?:\*\/|-->|\*\/\})?\s*$/i;function A(i){const t=[];return p(i).split(`
24
+ `).forEach((n,e)=>{n.trim()&&D.test(n)&&t.push(e+1)}),t}u(A,"D"),g(A,"elisionLines");export{y as changedRange,F as checkAgainstSnapshot,x as countMatches,A as elisionLines,M as indentationRepair,k as matchedLines,E as nearestRegions,R as numberedLines,$ as occurrenceLines,O as repairEdit,w as stripReadNotice,p as toLF};
@@ -1,4 +1,4 @@
1
- var I=Object.defineProperty;var r=(t,u)=>I(t,"name",{value:u,configurable:!0});var M=Object.defineProperty,a=r((t,u)=>M(t,"name",{value:u,configurable:!0}),"u");import{readFileSync as _,statSync as R}from"node:fs";import{basename as L}from"node:path";import{tm as E}from"@dalcode/dal-pi-kit";import{resolveToCwd as m}from"@earendil-works/pi-coding-agent";import{checkAgainstSnapshot as z,countMatches as O,nearestRegions as P,numberedLines as b,occurrenceLines as $,repairEdit as H,stripReadNotice as U,toLF as g}from"./edit-anchor-core.js";const q=2*1024*1024,X=64;function l(t,u){return t.replace(/\{(\w+)\}/g,(o,e)=>e in u?String(u[e]):o)}r(l,"l"),a(l,"fill");function p(t){try{const u=R(t);return!u.isFile()||u.size>q?void 0:g(_(t,"utf8"))}catch{return}}r(p,"w"),a(p,"readText");function A(t){return(typeof t.path=="string"?t.path:typeof t.file_path=="string"?t.file_path:void 0)?.trim()||void 0}r(A,"A"),a(A,"inputPath");function x(t){const u=t.edits;if(!Array.isArray(u))return;const o=u.filter(e=>!!e&&typeof e.oldText=="string"&&typeof e.newText=="string");return o.length===u.length?o:void 0}r(x,"S"),a(x,"editsOf");function v(){return{snapshots:new Map,notes:new Map}}r(v,"U"),a(v,"createEditAnchorState");function w(t,u,o){if(t.snapshots.delete(u),o!==void 0)for(t.snapshots.set(u,o);t.snapshots.size>X;){const e=t.snapshots.keys().next().value;if(e===void 0)break;t.snapshots.delete(e)}}r(w,"N"),a(w,"remember");function k(t,u,o,e){const i=u>1?`edits[${o.editIndex}]`:"oldText",s=o.reason==="gone"?E("\u5B83\u8981\u66FF\u6362\u7684\u5185\u5BB9\u5DF2\u7ECF\u4E0D\u5728\u6587\u4EF6\u91CC\u4E86"):o.reason==="ambiguous"?l(E("\u5B83\u73B0\u5728\u5728\u6587\u4EF6\u91CC\u51FA\u73B0\u4E86 {n} \u5904"),{n:o.occurrences}):o.reason==="moved"?E("\u5B83\u524D\u540E\u7684\u4EE3\u7801\u53D8\u4E86\uFF0C\u73B0\u5728\u5339\u914D\u5230\u7684\u53EF\u80FD\u5DF2\u7ECF\u4E0D\u662F\u4F60\u770B\u5230\u7684\u90A3\u4E00\u5904"):E("\u5B83\u6240\u5728\u7684\u884C\u5DF2\u7ECF\u88AB\u6539\u8FC7");return[l(E("\u7F16\u8F91\u672A\u6267\u884C\uFF1A{path} \u5728\u4F60\u4E0A\u6B21\u8BFB\u53D6\u4E4B\u540E\u88AB\u6539\u52A8\u8FC7\uFF08\u683C\u5F0F\u5316\u3001\u811A\u672C\u6216\u5176\u4ED6\u8FDB\u7A0B\uFF09\uFF0C{which} \u7684\u951A\u70B9\u5DF2\u8FC7\u671F\uFF1A{why}\u3002\u4E3A\u4E86\u4E0D\u6539\u9519\u5730\u65B9\uFF0C\u8FD9\u6B21\u4EC0\u4E48\u90FD\u6CA1\u5199\u3002\u4E0B\u9762\u662F\u8BE5\u4F4D\u7F6E\u73B0\u5728\u7684\u5185\u5BB9\uFF08\u7B2C {from}-{to} \u884C\uFF09\uFF0C\u8BF7\u6309\u5B83\u91CD\u5199 oldText\uFF1B\u9700\u8981\u66F4\u591A\u4E0A\u4E0B\u6587\u5C31\u91CD\u65B0 read \u8FD9\u4E2A\u6587\u4EF6\u3002"),{path:t,which:i,why:s,from:o.from,to:o.to}),"",b(e,o.from,o.to)].join(`
2
- `)}r(k,"z"),a(k,"staleMessage");function y(t,u,o){const e=u.input;if(u.toolName==="bash"||u.toolName==="powershell"){const n=typeof e.command=="string"?e.command:"";for(const f of[...t.snapshots.keys()])n.includes(L(f))&&t.snapshots.delete(f);return}if(u.toolName==="write"){const n=A(e),f=typeof e.content=="string"?e.content:void 0;if(!n||f===void 0)return;const D=U(g(f));if(D===void 0)return;const h=p(m(n,o));return h===void 0||h.length<=D.length?void 0:{block:!0,reason:l(E("\u5199\u5165\u672A\u6267\u884C\uFF1A\u5185\u5BB9\u7ED3\u5C3E\u662F\u8BFB\u53D6\u5DE5\u5177\u7684\u622A\u65AD\u63D0\u793A\uFF08\u201CUse offset=\u2026 to continue\u201D\uFF09\uFF0C\u8BF4\u660E\u4F60\u53EA\u770B\u5230\u4E86 {path} \u7684\u4E00\u90E8\u5206\uFF0C\u800C\u73B0\u6709\u6587\u4EF6\u66F4\u957F\uFF1B\u8FD9\u6837\u5199\u4F1A\u628A\u6CA1\u770B\u5230\u7684\u90E8\u5206\u5220\u6389\u3002\u53EA\u6539\u5176\u4E2D\u4E00\u5904\u8BF7\u7528 edit\uFF1B\u786E\u5B9E\u8981\u6574\u4F53\u91CD\u5199\uFF0C\u5148\u8BFB\u5B8C\u6574\u4E2A\u6587\u4EF6\uFF0C\u5E76\u53BB\u6389\u8FD9\u884C\u63D0\u793A\u3002"),{path:n})}}if(u.toolName!=="edit")return;const i=A(e),s=x(e);if(!i||!s||s.length===0)return;const c=m(i,o),F=p(c);if(F===void 0)return;const B=t.snapshots.get(c);if(B!==void 0){const n=z(B,F,s);if(n.kind==="stale")return w(t,c,F),{block:!0,reason:k(i,s.length,n,F)};n.kind==="changed-elsewhere"&&T(t,u.toolCallId,l(E("\u6CE8\u610F\uFF1A{path} \u5728\u4F60\u4E0A\u6B21\u8BFB\u53D6\u4E4B\u540E\u6709\u522B\u5904\u88AB\u6539\u52A8\uFF08\u7B2C {from}-{to} \u884C\uFF09\uFF0C\u4F60\u7684\u4FEE\u6539\u5DF2\u6309\u539F\u610F\u5E94\u7528\uFF1B\u8981\u7528\u5230\u90A3\u51E0\u884C\u8BF7\u5148\u91CD\u65B0\u8BFB\u53D6\u3002"),{path:i,from:n.from,to:n.to}))}let d=!1;const C=s.map((n,f)=>{const D=H(F,n);if(!D)return n;d=!0;const h=s.length>1?`edits[${f}]`:"oldText";return T(t,u.toolCallId,D.kind==="read-notice"?l(E("\u5DF2\u81EA\u52A8\u4FEE\u6B63\uFF1A{which} \u7ED3\u5C3E\u5E26\u4E86\u8BFB\u53D6\u5DE5\u5177\u7684\u622A\u65AD\u63D0\u793A\uFF08\u4E0D\u662F\u6587\u4EF6\u5185\u5BB9\uFF09\uFF0C\u5DF2\u53BB\u6389\u540E\u518D\u5339\u914D\u3002"),{which:h}):l(E("\u5DF2\u81EA\u52A8\u4FEE\u6B63\uFF1A{which} \u7684\u7F29\u8FDB\u548C\u6587\u4EF6\u4E0D\u4E00\u81F4\uFF0C\u5DF2\u6309\u6587\u4EF6\u7684\u5B9E\u9645\u7F29\u8FDB\u5339\u914D\uFF0C\u5E76\u5BF9 newText \u505A\u4E86\u540C\u6837\u7684\u7F29\u8FDB\u8C03\u6574\uFF1B\u8BF7\u68C0\u67E5\u7ED3\u679C\u3002"),{which:h})),D.edit});d&&(e.edits=C)}r(y,"D"),a(y,"onToolCall");function T(t,u,o){const e=t.notes.get(u)??[];e.push(o),t.notes.set(u,e)}r(T,"k"),a(T,"addNote");const Y=/Could not find (?:the exact text|edits\[(\d+)\])/,G=/Found (\d+) occurrences of (?:the text|edits\[(\d+)\])/;function S(t,u,o,e){const i=Y.exec(t);if(i){const c=i[1]?Number(i[1]):0,F=u[c];if(!F)return;const B=P(o,F.oldText);if(B.length===0)return l(E("{path} \u91CC\u6CA1\u6709\u4E0E oldText \u76F8\u8FD1\u7684\u5185\u5BB9\u3002\u6587\u4EF6\u53EF\u80FD\u5DF2\u7ECF\u6539\u8FC7\uFF0C\u6216\u8005\u8DEF\u5F84\u4E0D\u5BF9\uFF1A\u8BF7\u91CD\u65B0 read \u540E\u518D\u7F16\u8F91\u3002"),{path:e});const d=[l(E("{path} \u91CC\u4E0E oldText \u6700\u63A5\u8FD1\u7684\u4F4D\u7F6E\u5982\u4E0B\uFF08\u884C\u53F7| \u5185\u5BB9\uFF09\u3002\u7167\u8FD9\u4E9B\u884C\u7684\u539F\u6587\u91CD\u5199 oldText\uFF1B\u90FD\u4E0D\u5BF9\u5C31\u91CD\u65B0 read\u3002"),{path:e})];for(const C of B)d.push("",b(o,C.from-1,C.to+1));return d.join(`
3
- `)}const s=G.exec(t);if(s){const c=s[2]?Number(s[2]):0,F=u[c];if(!F)return;const B=$(o,g(F.oldText));return B.length===0?void 0:l(E("\u8FD9\u4E9B\u51FA\u73B0\u4F4D\u7F6E\u5728\u7B2C {lines} \u884C\u3002\u628A\u8981\u6539\u7684\u90A3\u4E00\u5904\u524D\u540E\u591A\u5E26\u4E00\u4E24\u884C\uFF0C\u8BA9 oldText \u53EA\u5339\u914D\u4E00\u5904\u3002"),{lines:B.join(", ")})}}r(S,"B"),a(S,"failureHelp");function N(t,u,o){const e=u.input,i=t.notes.get(u.toolCallId);if(t.notes.delete(u.toolCallId),u.toolName!=="read"&&u.toolName!=="write"&&u.toolName!=="edit")return;const s=A(e);if(!s)return;const c=m(s,o);if(u.isError){if(u.toolName!=="edit")return;const F=x(e),B=p(c),d=u.content.map(n=>n.type==="text"?n.text:"").join(`
4
- `),C=F&&B!==void 0?S(d,F,B,s):void 0;return C?{content:[...u.content,{type:"text",text:C}]}:void 0}if(!(u.toolName==="read"&&u.content.some(F=>F.type==="image"))&&(w(t,c,p(c)),!!i?.length))return{content:[...u.content,...i.map(F=>({type:"text",text:F}))]}}r(N,"Y"),a(N,"onToolResult");function j(t){const u=v();t.on("session_start",()=>{u.snapshots.clear(),u.notes.clear()}),t.on("tool_call",(o,e)=>y(u,o,e.cwd)),t.on("tool_result",(o,e)=>N(u,o,e.cwd))}r(j,"q"),a(j,"editAnchor");export{O as countMatches,v as createEditAnchorState,j as default,y as onToolCall,N as onToolResult};
1
+ var L=Object.defineProperty;var r=(t,u)=>L(t,"name",{value:u,configurable:!0});var R=Object.defineProperty,a=r((t,u)=>R(t,"name",{value:u,configurable:!0}),"u");import{readFileSync as $,statSync as z}from"node:fs";import{basename as O}from"node:path";import{tm as i}from"@dalcode/dal-pi-kit";import{resolveToCwd as p}from"@earendil-works/pi-coding-agent";import{checkAgainstSnapshot as P,countMatches as H,elisionLines as m,nearestRegions as U,numberedLines as S,occurrenceLines as q,repairEdit as G,stripReadNotice as J,toLF as x}from"./edit-anchor-core.js";const K=2*1024*1024,X=64;function B(t,u){return t.replace(/\{(\w+)\}/g,(e,o)=>o in u?String(u[o]):e)}r(B,"h"),a(B,"fill");function A(t){try{const u=z(t);return!u.isFile()||u.size>K?void 0:x($(t,"utf8"))}catch{return}}r(A,"T"),a(A,"readText");function g(t){return(typeof t.path=="string"?t.path:typeof t.file_path=="string"?t.file_path:void 0)?.trim()||void 0}r(g,"E"),a(g,"inputPath");function w(t){const u=t.edits;if(!Array.isArray(u))return;const e=u.filter(o=>!!o&&typeof o.oldText=="string"&&typeof o.newText=="string");return e.length===u.length?e:void 0}r(w,"b"),a(w,"editsOf");function T(){return{snapshots:new Map,notes:new Map}}r(T,"D"),a(T,"createEditAnchorState");function v(t,u,e){if(t.snapshots.delete(u),e!==void 0)for(t.snapshots.set(u,e);t.snapshots.size>X;){const o=t.snapshots.keys().next().value;if(o===void 0)break;t.snapshots.delete(o)}}r(v,"R"),a(v,"remember");function I(t,u,e,o){const E=u>1?`edits[${e.editIndex}]`:"oldText",n=e.reason==="gone"?i("\u5B83\u8981\u66FF\u6362\u7684\u5185\u5BB9\u5DF2\u7ECF\u4E0D\u5728\u6587\u4EF6\u91CC\u4E86"):e.reason==="ambiguous"?B(i("\u5B83\u73B0\u5728\u5728\u6587\u4EF6\u91CC\u51FA\u73B0\u4E86 {n} \u5904"),{n:e.occurrences}):e.reason==="moved"?i("\u5B83\u524D\u540E\u7684\u4EE3\u7801\u53D8\u4E86\uFF0C\u73B0\u5728\u5339\u914D\u5230\u7684\u53EF\u80FD\u5DF2\u7ECF\u4E0D\u662F\u4F60\u770B\u5230\u7684\u90A3\u4E00\u5904"):i("\u5B83\u6240\u5728\u7684\u884C\u5DF2\u7ECF\u88AB\u6539\u8FC7");return[B(i("\u7F16\u8F91\u672A\u6267\u884C\uFF1A{path} \u5728\u4F60\u4E0A\u6B21\u8BFB\u53D6\u4E4B\u540E\u88AB\u6539\u52A8\u8FC7\uFF08\u683C\u5F0F\u5316\u3001\u811A\u672C\u6216\u5176\u4ED6\u8FDB\u7A0B\uFF09\uFF0C{which} \u7684\u951A\u70B9\u5DF2\u8FC7\u671F\uFF1A{why}\u3002\u4E3A\u4E86\u4E0D\u6539\u9519\u5730\u65B9\uFF0C\u8FD9\u6B21\u4EC0\u4E48\u90FD\u6CA1\u5199\u3002\u4E0B\u9762\u662F\u8BE5\u4F4D\u7F6E\u73B0\u5728\u7684\u5185\u5BB9\uFF08\u7B2C {from}-{to} \u884C\uFF09\uFF0C\u8BF7\u6309\u5B83\u91CD\u5199 oldText\uFF1B\u9700\u8981\u66F4\u591A\u4E0A\u4E0B\u6587\u5C31\u91CD\u65B0 read \u8FD9\u4E2A\u6587\u4EF6\u3002"),{path:t,which:E,why:n,from:e.from,to:e.to}),"",S(o,e.from,e.to)].join(`
2
+ `)}r(I,"X"),a(I,"staleMessage");function y(t,u,e){const o=u.input;if(u.toolName==="bash"||u.toolName==="powershell"){const F=typeof o.command=="string"?o.command:"";for(const l of[...t.snapshots.keys()])F.includes(O(l))&&t.snapshots.delete(l);return}if(u.toolName==="write"){const F=g(o),l=typeof o.content=="string"?o.content:void 0;if(!F||l===void 0)return;const f=m(l);if(f.length>0){const j=A(p(F,e));if(j!==void 0&&m(j).length<f.length)return{block:!0,reason:B(i("\u5199\u5165\u672A\u6267\u884C\uFF1A\u5185\u5BB9\u7B2C {lines} \u884C\u662F\u201C\u2026\u5176\u4F59\u4EE3\u7801\u4E0D\u53D8\u2026\u201D\u8FD9\u7C7B\u5360\u4F4D\u6CE8\u91CA\uFF0C\u800C\u4E0D\u662F\u771F\u6B63\u7684\u4EE3\u7801\uFF1B\u6309\u8FD9\u6837\u5199\u5165\uFF0C{path} \u91CC\u88AB\u7701\u7565\u7684\u90E8\u5206\u4F1A\u88AB\u5220\u6389\u3002\u53EA\u6539\u5176\u4E2D\u51E0\u5904\u8BF7\u7528 edit\uFF1B\u786E\u5B9E\u8981\u6574\u4F53\u91CD\u5199\uFF0C\u5C31\u628A\u5B8C\u6574\u5185\u5BB9\u90FD\u5199\u51FA\u6765\u3002"),{lines:f.slice(0,5).join(", "),path:F})}}const h=J(x(l));if(h===void 0)return;const k=A(p(F,e));return k===void 0||k.length<=h.length?void 0:{block:!0,reason:B(i("\u5199\u5165\u672A\u6267\u884C\uFF1A\u5185\u5BB9\u7ED3\u5C3E\u662F\u8BFB\u53D6\u5DE5\u5177\u7684\u622A\u65AD\u63D0\u793A\uFF08\u201CUse offset=\u2026 to continue\u201D\uFF09\uFF0C\u8BF4\u660E\u4F60\u53EA\u770B\u5230\u4E86 {path} \u7684\u4E00\u90E8\u5206\uFF0C\u800C\u73B0\u6709\u6587\u4EF6\u66F4\u957F\uFF1B\u8FD9\u6837\u5199\u4F1A\u628A\u6CA1\u770B\u5230\u7684\u90E8\u5206\u5220\u6389\u3002\u53EA\u6539\u5176\u4E2D\u4E00\u5904\u8BF7\u7528 edit\uFF1B\u786E\u5B9E\u8981\u6574\u4F53\u91CD\u5199\uFF0C\u5148\u8BFB\u5B8C\u6574\u4E2A\u6587\u4EF6\uFF0C\u5E76\u53BB\u6389\u8FD9\u884C\u63D0\u793A\u3002"),{path:F})}}if(u.toolName!=="edit")return;const E=g(o),n=w(o);if(!E||!n||n.length===0)return;const c=p(E,e),s=A(c);if(s===void 0)return;for(const[F,l]of n.entries())if(!(m(l.newText).length-m(l.oldText).length<=0))return{block:!0,reason:B(i("\u7F16\u8F91\u672A\u6267\u884C\uFF1A{which} \u7684 newText \u91CC\u6709\u201C\u2026\u5176\u4F59\u4EE3\u7801\u4E0D\u53D8\u2026\u201D\u8FD9\u7C7B\u5360\u4F4D\u6CE8\u91CA\uFF0ColdText \u91CC\u6CA1\u6709\uFF1Bedit \u4F1A\u539F\u6837\u5199\u5165 newText\uFF0C\u88AB\u7701\u7565\u7684\u4EE3\u7801\u4F1A\u88AB\u5220\u6389\u3002\u8BF7\u8BA9 oldText \u53EA\u5305\u542B\u8981\u6539\u7684\u90A3\u51E0\u884C\uFF0CnewText \u5199\u51FA\u5B8C\u6574\u7684\u66FF\u6362\u5185\u5BB9\u3002"),{which:n.length>1?`edits[${F}]`:"newText"})};const C=t.snapshots.get(c);if(C!==void 0){const F=P(C,s,n);if(F.kind==="stale")return v(t,c,s),{block:!0,reason:I(E,n.length,F,s)};F.kind==="changed-elsewhere"&&b(t,u.toolCallId,B(i("\u6CE8\u610F\uFF1A{path} \u5728\u4F60\u4E0A\u6B21\u8BFB\u53D6\u4E4B\u540E\u6709\u522B\u5904\u88AB\u6539\u52A8\uFF08\u7B2C {from}-{to} \u884C\uFF09\uFF0C\u4F60\u7684\u4FEE\u6539\u5DF2\u6309\u539F\u610F\u5E94\u7528\uFF1B\u8981\u7528\u5230\u90A3\u51E0\u884C\u8BF7\u5148\u91CD\u65B0\u8BFB\u53D6\u3002"),{path:E,from:F.from,to:F.to}))}let d=!1;const D=n.map((F,l)=>{const f=G(s,F);if(!f)return F;d=!0;const h=n.length>1?`edits[${l}]`:"oldText";return b(t,u.toolCallId,f.kind==="read-notice"?B(i("\u5DF2\u81EA\u52A8\u4FEE\u6B63\uFF1A{which} \u7ED3\u5C3E\u5E26\u4E86\u8BFB\u53D6\u5DE5\u5177\u7684\u622A\u65AD\u63D0\u793A\uFF08\u4E0D\u662F\u6587\u4EF6\u5185\u5BB9\uFF09\uFF0C\u5DF2\u53BB\u6389\u540E\u518D\u5339\u914D\u3002"),{which:h}):B(i("\u5DF2\u81EA\u52A8\u4FEE\u6B63\uFF1A{which} \u7684\u7F29\u8FDB\u548C\u6587\u4EF6\u4E0D\u4E00\u81F4\uFF0C\u5DF2\u6309\u6587\u4EF6\u7684\u5B9E\u9645\u7F29\u8FDB\u5339\u914D\uFF0C\u5E76\u5BF9 newText \u505A\u4E86\u540C\u6837\u7684\u7F29\u8FDB\u8C03\u6574\uFF1B\u8BF7\u68C0\u67E5\u7ED3\u679C\u3002"),{which:h})),f.edit});d&&(o.edits=D)}r(y,"B"),a(y,"onToolCall");function b(t,u,e){const o=t.notes.get(u)??[];o.push(e),t.notes.set(u,o)}r(b,"C"),a(b,"addNote");const Y=/Could not find (?:the exact text|edits\[(\d+)\])/,Q=/Found (\d+) occurrences of (?:the text|edits\[(\d+)\])/;function M(t,u,e,o){const E=Y.exec(t);if(E){const c=E[1]?Number(E[1]):0,s=u[c];if(!s)return;const C=U(e,s.oldText);if(C.length===0)return B(i("{path} \u91CC\u6CA1\u6709\u4E0E oldText \u76F8\u8FD1\u7684\u5185\u5BB9\u3002\u6587\u4EF6\u53EF\u80FD\u5DF2\u7ECF\u6539\u8FC7\uFF0C\u6216\u8005\u8DEF\u5F84\u4E0D\u5BF9\uFF1A\u8BF7\u91CD\u65B0 read \u540E\u518D\u7F16\u8F91\u3002"),{path:o});const d=[B(i("{path} \u91CC\u4E0E oldText \u6700\u63A5\u8FD1\u7684\u4F4D\u7F6E\u5982\u4E0B\uFF08\u884C\u53F7| \u5185\u5BB9\uFF09\u3002\u7167\u8FD9\u4E9B\u884C\u7684\u539F\u6587\u91CD\u5199 oldText\uFF1B\u90FD\u4E0D\u5BF9\u5C31\u91CD\u65B0 read\u3002"),{path:o})];for(const D of C)d.push("",S(e,D.from-1,D.to+1));return d.join(`
3
+ `)}const n=Q.exec(t);if(n){const c=n[2]?Number(n[2]):0,s=u[c];if(!s)return;const C=q(e,x(s.oldText));return C.length===0?void 0:B(i("\u8FD9\u4E9B\u51FA\u73B0\u4F4D\u7F6E\u5728\u7B2C {lines} \u884C\u3002\u628A\u8981\u6539\u7684\u90A3\u4E00\u5904\u524D\u540E\u591A\u5E26\u4E00\u4E24\u884C\uFF0C\u8BA9 oldText \u53EA\u5339\u914D\u4E00\u5904\u3002"),{lines:C.join(", ")})}}r(M,"G"),a(M,"failureHelp");function N(t,u,e){const o=u.input,E=t.notes.get(u.toolCallId);if(t.notes.delete(u.toolCallId),u.toolName!=="read"&&u.toolName!=="write"&&u.toolName!=="edit")return;const n=g(o);if(!n)return;const c=p(n,e);if(u.isError){if(u.toolName!=="edit")return;const s=w(o),C=A(c),d=u.content.map(F=>F.type==="text"?F.text:"").join(`
4
+ `),D=s&&C!==void 0?M(d,s,C,n):void 0;return D?{content:[...u.content,{type:"text",text:D}]}:void 0}if(!(u.toolName==="read"&&u.content.some(s=>s.type==="image"))&&(v(t,c,A(c)),!!E?.length))return{content:[...u.content,...E.map(s=>({type:"text",text:s}))]}}r(N,"J"),a(N,"onToolResult");function _(t){const u=T();t.on("session_start",()=>{u.snapshots.clear(),u.notes.clear()}),t.on("tool_call",(e,o)=>y(u,e,o.cwd)),t.on("tool_result",(e,o)=>N(u,e,o.cwd))}r(_,"K"),a(_,"editAnchor");export{H as countMatches,T as createEditAnchorState,_ as default,y as onToolCall,N as onToolResult};
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-halo",
3
- "version": "1.0.40",
3
+ "version": "1.0.42",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-interactive",
3
- "version": "1.0.40",
3
+ "version": "1.0.42",
4
4
  "private": true,
5
5
  "description": "Terminal-UI conveniences adopted from pi's example extensions: the questionnaire tool (the model asks you questions), /handoff (carry context into a new session) and interactive ! commands (vim, git rebase -i, htop). Active only in the TUI; stands down under DAL Code.",
6
6
  "license": "MIT",
@@ -20,7 +20,7 @@
20
20
  ]
21
21
  },
22
22
  "dependencies": {
23
- "@dalcode/dal-pi-kit": "1.0.40",
23
+ "@dalcode/dal-pi-kit": "1.0.42",
24
24
  "typebox": "1.3.7"
25
25
  },
26
26
  "peerDependencies": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-lang",
3
- "version": "1.0.40",
3
+ "version": "1.0.42",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -17,8 +17,8 @@
17
17
  ]
18
18
  },
19
19
  "dependencies": {
20
- "@dalcode/dal-pi-kit": "1.0.40",
21
- "@dalcode/dal-bridge": "1.0.40"
20
+ "@dalcode/dal-pi-kit": "1.0.42",
21
+ "@dalcode/dal-bridge": "1.0.42"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "@earendil-works/pi-coding-agent": "^1.0.9"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-learn",
3
- "version": "1.0.40",
3
+ "version": "1.0.42",
4
4
  "private": true,
5
5
  "description": "Self-evolution for DAL: lessons learned from earlier sessions (project and personal), a project map of verified commands and locations, effect tracking, and skill proposals for recurring procedures (/lessons).",
6
6
  "license": "MIT",
@@ -11,6 +11,9 @@
11
11
  "./store": "./src/store.js",
12
12
  "./lessons": "./src/lessons.js",
13
13
  "./project-map": "./src/project-map.js",
14
+ "./signals": "./src/signals.js",
15
+ "./safety": "./src/safety.js",
16
+ "./patches": "./src/patches.js",
14
17
  "./package.json": "./package.json"
15
18
  },
16
19
  "files": [
@@ -22,7 +25,7 @@
22
25
  ]
23
26
  },
24
27
  "dependencies": {
25
- "@dalcode/dal-pi-kit": "1.0.40"
28
+ "@dalcode/dal-pi-kit": "1.0.42"
26
29
  },
27
30
  "peerDependencies": {
28
31
  "@earendil-works/pi-coding-agent": "^1.0.9"