@weavecode/weave 0.1.1 → 0.1.2

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 (166) hide show
  1. package/node_modules/@weavecode/cli/dist/cli.js +4 -4
  2. package/node_modules/@weavecode/cli/dist/commands/chpass.js +1 -1
  3. package/node_modules/@weavecode/cli/dist/commands/daemon-auth.js +1 -1
  4. package/node_modules/@weavecode/cli/dist/commands/daemon.d.ts +7 -0
  5. package/node_modules/@weavecode/cli/dist/commands/daemon.js +2 -2
  6. package/node_modules/@weavecode/cli/dist/commands/dashboard.js +2 -2
  7. package/node_modules/@weavecode/cli/dist/commands/doctor.js +1 -1
  8. package/node_modules/@weavecode/cli/dist/commands/init.js +1 -1
  9. package/node_modules/@weavecode/cli/dist/commands/scan.js +1 -1
  10. package/node_modules/@weavecode/cli/dist/commands/status.js +2 -2
  11. package/node_modules/@weavecode/cli/dist/commands/uninstall.js +1 -1
  12. package/node_modules/@weavecode/cli/dist/i18n/dict/en.js +1 -9
  13. package/node_modules/@weavecode/cli/dist/i18n/dict/zh.d.ts +0 -1
  14. package/node_modules/@weavecode/cli/dist/i18n/dict/zh.js +2 -10
  15. package/node_modules/@weavecode/cli/dist/i18n/index.js +1 -1
  16. package/node_modules/@weavecode/cli/dist/i18n/t.js +1 -1
  17. package/node_modules/@weavecode/cli/dist/init/claudemd-gen.d.ts +2 -3
  18. package/node_modules/@weavecode/cli/dist/init/claudemd-gen.js +4 -4
  19. package/node_modules/@weavecode/cli/dist/init/executor.js +3 -3
  20. package/node_modules/@weavecode/cli/dist/init/git-commit.js +2 -2
  21. package/node_modules/@weavecode/cli/dist/init/harnesses/claude.js +7 -7
  22. package/node_modules/@weavecode/cli/dist/init/harnesses/codex.js +1 -1
  23. package/node_modules/@weavecode/cli/dist/init/harnesses/zcode.d.ts +29 -0
  24. package/node_modules/@weavecode/cli/dist/init/harnesses/zcode.js +1 -0
  25. package/node_modules/@weavecode/cli/dist/init/instruction-link.js +1 -1
  26. package/node_modules/@weavecode/cli/dist/init/plugin-templates.js +1 -1
  27. package/node_modules/@weavecode/cli/dist/init/prompt.js +4 -4
  28. package/node_modules/@weavecode/cli/dist/init/uninstall.js +6 -6
  29. package/node_modules/@weavecode/cli/dist/init/wiring.js +1 -1
  30. package/node_modules/@weavecode/cli/dist/parser.js +1 -1
  31. package/node_modules/@weavecode/cli/dist/statusline/ansi.js +1 -1
  32. package/node_modules/@weavecode/cli/dist/statusline/mock-input.js +1 -1
  33. package/node_modules/@weavecode/cli/dist/statusline/preview.js +2 -2
  34. package/node_modules/@weavecode/cli/package.json +5 -5
  35. package/node_modules/@weavecode/core/dist/harness-checks.js +1 -1
  36. package/node_modules/@weavecode/core/dist/index.d.ts +1 -1
  37. package/node_modules/@weavecode/core/dist/index.js +1 -1
  38. package/node_modules/@weavecode/core/dist/platform.js +1 -1
  39. package/node_modules/@weavecode/core/dist/types.d.ts +0 -8
  40. package/node_modules/@weavecode/core/dist/types.js +1 -1
  41. package/node_modules/@weavecode/core/dist/utils/fs.js +1 -1
  42. package/node_modules/@weavecode/core/dist/utils/logger.js +1 -1
  43. package/node_modules/@weavecode/core/package.json +1 -1
  44. package/node_modules/@weavecode/harness/dist/claude/assets.d.ts +10 -0
  45. package/node_modules/@weavecode/harness/dist/claude/assets.js +4 -1
  46. package/node_modules/@weavecode/harness/dist/claude/capture.d.ts +4 -2
  47. package/node_modules/@weavecode/harness/dist/claude/capture.js +15 -9
  48. package/node_modules/@weavecode/harness/dist/claude/detect.js +1 -1
  49. package/node_modules/@weavecode/harness/dist/claude/event-source.js +1 -1
  50. package/node_modules/@weavecode/harness/dist/claude/index.d.ts +6 -1
  51. package/node_modules/@weavecode/harness/dist/claude/index.js +1 -1
  52. package/node_modules/@weavecode/harness/dist/claude/mcp-gen.js +1 -1
  53. package/node_modules/@weavecode/harness/dist/claude/messaging.js +2 -2
  54. package/node_modules/@weavecode/harness/dist/claude/model-aliases.d.ts +14 -0
  55. package/node_modules/@weavecode/harness/dist/claude/model-aliases.js +1 -1
  56. package/node_modules/@weavecode/harness/dist/claude/peers.js +1 -1
  57. package/node_modules/@weavecode/harness/dist/claude/plan.d.ts +2 -0
  58. package/node_modules/@weavecode/harness/dist/claude/plan.js +1 -0
  59. package/node_modules/@weavecode/harness/dist/claude/plugins.js +4 -4
  60. package/node_modules/@weavecode/harness/dist/claude/prompt-inbox.js +1 -1
  61. package/node_modules/@weavecode/harness/dist/claude/prompt.js +3 -3
  62. package/node_modules/@weavecode/harness/dist/claude/questions.js +2 -2
  63. package/node_modules/@weavecode/harness/dist/claude/settings-gen.js +1 -1
  64. package/node_modules/@weavecode/harness/dist/claude/side-question.d.ts +12 -0
  65. package/node_modules/@weavecode/harness/dist/claude/side-question.js +1 -0
  66. package/node_modules/@weavecode/harness/dist/claude/statusline/config.d.ts +200 -0
  67. package/node_modules/@weavecode/harness/dist/claude/statusline/config.js +1 -0
  68. package/node_modules/@weavecode/harness/dist/claude/statusline/generator.d.ts +12 -0
  69. package/node_modules/@weavecode/harness/dist/claude/statusline/generator.js +745 -0
  70. package/node_modules/@weavecode/harness/dist/claude/statusline/git-cache.d.ts +10 -0
  71. package/node_modules/@weavecode/harness/dist/claude/statusline/git-cache.js +1 -0
  72. package/node_modules/@weavecode/harness/dist/claude/statusline/surface.d.ts +20 -0
  73. package/node_modules/@weavecode/harness/dist/claude/statusline/surface.js +2 -0
  74. package/node_modules/@weavecode/harness/dist/claude/transcript.js +3 -3
  75. package/node_modules/@weavecode/harness/dist/codex/assets.js +1 -1
  76. package/node_modules/@weavecode/harness/dist/codex/detect.js +1 -1
  77. package/node_modules/@weavecode/harness/dist/codex/index.d.ts +1 -0
  78. package/node_modules/@weavecode/harness/dist/codex/index.js +1 -1
  79. package/node_modules/@weavecode/harness/dist/codex/mcp.d.ts +30 -0
  80. package/node_modules/@weavecode/harness/dist/codex/mcp.js +1 -0
  81. package/node_modules/@weavecode/harness/dist/codex/messaging.js +1 -1
  82. package/node_modules/@weavecode/harness/dist/codex/plugin-state.js +1 -1
  83. package/node_modules/@weavecode/harness/dist/codex/toml.js +9 -9
  84. package/node_modules/@weavecode/harness/dist/driver.d.ts +110 -2
  85. package/node_modules/@weavecode/harness/dist/driver.js +1 -1
  86. package/node_modules/@weavecode/harness/dist/init/generated.js +2 -2
  87. package/node_modules/@weavecode/harness/dist/init/pipeline.js +1 -1
  88. package/node_modules/@weavecode/harness/dist/registry-wiring.js +1 -1
  89. package/node_modules/@weavecode/harness/dist/shared/install-link.js +1 -1
  90. package/node_modules/@weavecode/harness/dist/zcode/assets.d.ts +8 -0
  91. package/node_modules/@weavecode/harness/dist/zcode/assets.js +1 -0
  92. package/node_modules/@weavecode/harness/dist/zcode/capture.d.ts +36 -0
  93. package/node_modules/@weavecode/harness/dist/zcode/capture.js +3 -0
  94. package/node_modules/@weavecode/harness/dist/zcode/detect.d.ts +2 -0
  95. package/node_modules/@weavecode/harness/dist/zcode/detect.js +1 -0
  96. package/node_modules/@weavecode/harness/dist/zcode/event-source.d.ts +8 -0
  97. package/node_modules/@weavecode/harness/dist/zcode/event-source.js +1 -0
  98. package/node_modules/@weavecode/harness/dist/zcode/index.d.ts +13 -0
  99. package/node_modules/@weavecode/harness/dist/zcode/index.js +1 -0
  100. package/node_modules/@weavecode/harness/dist/zcode/mcp.d.ts +6 -0
  101. package/node_modules/@weavecode/harness/dist/zcode/mcp.js +2 -0
  102. package/node_modules/@weavecode/harness/dist/zcode/messaging.d.ts +13 -0
  103. package/node_modules/@weavecode/harness/dist/zcode/messaging.js +1 -0
  104. package/node_modules/@weavecode/harness/dist/zcode/resume.d.ts +7 -0
  105. package/node_modules/@weavecode/harness/dist/zcode/resume.js +1 -0
  106. package/node_modules/@weavecode/harness/package.json +2 -2
  107. package/node_modules/@weavecode/server/dist/daemon/dev-entry.js +1 -1
  108. package/node_modules/@weavecode/server/dist/daemon/hook-pipeline.d.ts +8 -1
  109. package/node_modules/@weavecode/server/dist/daemon/hook-pipeline.js +1 -1
  110. package/node_modules/@weavecode/server/dist/daemon/hooks-routes.js +1 -1
  111. package/node_modules/@weavecode/server/dist/daemon/server.d.ts +7 -0
  112. package/node_modules/@weavecode/server/dist/daemon/server.js +8 -6
  113. package/node_modules/@weavecode/server/dist/daemon/session-probe.d.ts +13 -0
  114. package/node_modules/@weavecode/server/dist/daemon/session-probe.js +1 -1
  115. package/node_modules/@weavecode/server/dist/daemon/snapshot-refresher.d.ts +7 -1
  116. package/node_modules/@weavecode/server/dist/daemon/snapshot-refresher.js +1 -1
  117. package/node_modules/@weavecode/server/dist/daemon/sse-hub.d.ts +40 -0
  118. package/node_modules/@weavecode/server/dist/daemon/sse-hub.js +1 -0
  119. package/node_modules/@weavecode/server/dist/daemon/start.js +1 -1
  120. package/node_modules/@weavecode/server/dist/db/db.js +20 -2
  121. package/node_modules/@weavecode/server/dist/hooks/bus.d.ts +5 -0
  122. package/node_modules/@weavecode/server/dist/hooks/inbox-worker.d.ts +8 -1
  123. package/node_modules/@weavecode/server/dist/hooks/inbox-worker.js +3 -3
  124. package/node_modules/@weavecode/server/dist/hooks/message-deliverer.d.ts +29 -0
  125. package/node_modules/@weavecode/server/dist/hooks/message-deliverer.js +2 -2
  126. package/node_modules/@weavecode/server/dist/hooks/mirror.d.ts +9 -4
  127. package/node_modules/@weavecode/server/dist/hooks/mirror.js +4 -4
  128. package/node_modules/@weavecode/server/dist/hooks/session-purge.d.ts +3 -0
  129. package/node_modules/@weavecode/server/dist/hooks/session-purge.js +1 -1
  130. package/node_modules/@weavecode/server/dist/hooks/side-questions.d.ts +41 -0
  131. package/node_modules/@weavecode/server/dist/hooks/side-questions.js +1 -0
  132. package/node_modules/@weavecode/server/dist/hooks/toolkit.js +5 -5
  133. package/node_modules/@weavecode/server/dist/install/apply-update.js +1 -1
  134. package/node_modules/@weavecode/server/dist/install/capabilities.d.ts +10 -0
  135. package/node_modules/@weavecode/server/dist/install/capabilities.js +1 -1
  136. package/node_modules/@weavecode/server/dist/install/codex-toml.d.ts +8 -26
  137. package/node_modules/@weavecode/server/dist/install/codex-toml.js +1 -1
  138. package/node_modules/@weavecode/server/dist/install/global-config.d.ts +2 -4
  139. package/node_modules/@weavecode/server/dist/install/global-config.js +1 -2
  140. package/node_modules/@weavecode/server/dist/install/installer.d.ts +3 -5
  141. package/node_modules/@weavecode/server/dist/install/installer.js +1 -3
  142. package/node_modules/@weavecode/server/dist/install/mcp-rows.d.ts +5 -5
  143. package/node_modules/@weavecode/server/dist/install/mcp-rows.js +1 -1
  144. package/node_modules/@weavecode/server/dist/registry.js +2 -2
  145. package/node_modules/@weavecode/server/dist/repositories/hook-events.d.ts +7 -0
  146. package/node_modules/@weavecode/server/dist/repositories/hook-events.js +2 -2
  147. package/node_modules/@weavecode/server/dist/repositories/sessions.d.ts +15 -4
  148. package/node_modules/@weavecode/server/dist/repositories/sessions.js +2 -2
  149. package/node_modules/@weavecode/server/dist/repositories/side-questions.d.ts +50 -0
  150. package/node_modules/@weavecode/server/dist/repositories/side-questions.js +6 -0
  151. package/node_modules/@weavecode/server/dist/statusline/config.d.ts +4 -198
  152. package/node_modules/@weavecode/server/dist/statusline/config.js +1 -1
  153. package/node_modules/@weavecode/server/dist/statusline/generator.d.ts +5 -0
  154. package/node_modules/@weavecode/server/dist/statusline/generator.js +1 -717
  155. package/node_modules/@weavecode/server/dist/statusline/manager.d.ts +5 -5
  156. package/node_modules/@weavecode/server/dist/statusline/manager.js +3 -4
  157. package/node_modules/@weavecode/server/dist/surfaces.d.ts +11 -1
  158. package/node_modules/@weavecode/server/dist/surfaces.js +1 -1
  159. package/node_modules/@weavecode/server/package.json +4 -4
  160. package/node_modules/@weavecode/server/web/dist/assets/index-CHWbLAje.js +594 -0
  161. package/node_modules/@weavecode/server/web/dist/assets/index-D0s5v8QS.css +11 -0
  162. package/node_modules/@weavecode/server/web/dist/index.html +2 -2
  163. package/node_modules/@weavecode/templates/package.json +2 -2
  164. package/package.json +6 -6
  165. package/node_modules/@weavecode/server/web/dist/assets/index-D5WFh77i.css +0 -11
  166. package/node_modules/@weavecode/server/web/dist/assets/index-DJibaGnJ.js +0 -585
@@ -1,5 +1,5 @@
1
- import{logger as m}from"@weavecode/core";import{t as c}from"../i18n/index.js";export async function confirmPrompt(o,l,t){if(!t||!process.stdin.isTTY||!process.stdout.isTTY)return!0;const{createInterface:e}=await import("node:readline/promises"),s=e({input:process.stdin,output:process.stdout});try{const i=await s.question(`
2
- ${o}
1
+ import{logger as m}from"@weavecode/core";import{t as u}from"../i18n/index.js";export async function confirmPrompt(e,l,t){if(!t||!process.stdin.isTTY||!process.stdout.isTTY)return!0;const{createInterface:s}=await import("node:readline/promises"),n=s({input:process.stdin,output:process.stdout});try{const r=await n.question(`
2
+ ${e}
3
3
  ${l}
4
- ${c("init.proceed")} `);return!/^n(o)?$/i.test(i.trim())}finally{s.close()}}export function createPromptPort(o){const l=()=>o&&!!process.stdin.isTTY&&!!process.stdout.isTTY;return{confirm:(t,e="")=>confirmPrompt(t,e,o),async multiselect(t,e){if(!l())return[...e];if(t.length===0)return[];const{createInterface:s}=await import("node:readline/promises"),i=s({input:process.stdin,output:process.stdout});try{console.log(`
5
- ${c("init.multiselect.title")}`),t.forEach((n,f)=>console.log(` ${f+1}) ${n}`));const p=(await i.question(` ${c("init.multiselect.hint",{defaults:e.join(",")})} `)).trim();if(!p)return[...e];const r=[],u=[];for(const n of p.split(/[,\s]+/).filter(Boolean)){const a=(/^\d+$/.test(n)?t[Number(n)-1]:void 0)??t.find(d=>d.toLowerCase()===n.toLowerCase());a===void 0?u.push(n):r.includes(a)||r.push(a)}return u.length>0&&m.warn(c("init.multiselect.invalid",{keys:u.join(", ")})),r.length>0?r:[...e]}finally{i.close()}}}}
4
+ ${u("init.proceed")} `);return!/^n(o)?$/i.test(r.trim())}finally{n.close()}}export function createPromptPort(e){const l=()=>e&&!!process.stdin.isTTY&&!!process.stdout.isTTY;return{confirm:(t,s="")=>confirmPrompt(t,s,e),async multiselect(t,s){if(!l())return[...s];if(t.length===0)return[];const{createInterface:n}=await import("node:readline/promises"),r=n({input:process.stdin,output:process.stdout});try{console.log(`
5
+ ${u("init.multiselect.title")}`),t.forEach((o,i)=>console.log(` ${i+1}) ${o}`));const p=(await r.question(` ${u("init.multiselect.hint",{defaults:s.join(",")})} `)).trim();if(!p)return[...s];const c=[],a=[];for(const o of p.split(/[,\s]+/).filter(Boolean)){const i=(/^\d+$/.test(o)?t[Number(o)-1]:void 0)??t.find(f=>f.toLowerCase()===o.toLowerCase());i===void 0?a.push(o):c.includes(i)||c.push(i)}return a.length>0&&m.warn(u("init.multiselect.invalid",{keys:a.join(", ")})),c.length>0?c:[...s]}finally{r.close()}}}}
@@ -1,6 +1,6 @@
1
- import s from"node:path";import{lstat as T,readdir as _,readFile as G,rm as O,rmdir as W,unlink as m,writeFile as v}from"node:fs/promises";import{HARNESS_DIRS as x,HARNESS_KEYS as N,INSTRUCTION_FILES as S,logger as H}from"@weavecode/core";import{hashFile as C,projectPackFiles as U,unregisterProject as B}from"@weavecode/server";import{templateRegistry as F}from"@weavecode/templates";import{stripWeaveSettings as L}from"./settings-gen.js";import{stripWeaveMcp as V}from"./mcp-gen.js";import{WEAVE_BLOCK_START as J,WEAVE_BLOCK_END as R,WEAVE_MANAGED_HEADER as K}from"./claudemd-gen.js";import{WEAVE_HELPER_MARKER as q}from"./harnesses/claude.js";import{registerPluginTemplates as z}from"./plugin-templates.js";import{NESTED_GITIGNORE as Y}from"./executor.js";import{COMMIT_MESSAGE as $,findGitRepoRoot as Q,defaultGitExec as X}from"./git-commit.js";import{t as Z}from"../i18n/index.js";const tt="chore: weave uninstall \u79FB\u9664 init \u751F\u6210\u7269",k=S[1],et=[...S,".mcp.json",...N.map(n=>x[n].projectDir),".weave"];async function D(n){try{return await T(n),!0}catch{return!1}}async function p(n){try{return await G(n,"utf-8")}catch{return null}}async function b(n){const t=await p(n);if(t!==null)try{const i=JSON.parse(t);if(i&&typeof i=="object"&&!Array.isArray(i))return i}catch{}}async function j(n){const t=[];let i;try{i=await _(n,{withFileTypes:!0})}catch{return t}for(const e of i){const a=s.join(n,e.name);e.isDirectory()?t.push(...await j(a)):t.push(a)}return t}async function it(n,t){const[i,e]=await Promise.all([p(n),p(t)]);return i!==null&&i===e}async function A(n,t,i){let e=n;const a=s.resolve(t);for(;;){if(s.resolve(e)===a||!e.startsWith(a+s.sep))return;try{await W(e),i.push(e)}catch{return}e=s.dirname(e)}}class st{targetDir;execGit;dbPath;hooksDir;result;constructor(t){this.targetDir=s.resolve(t.targetDir),this.execGit=t.execGit??X,this.dbPath=t.dbPath,this.hooksDir=t.hooksDir,this.result={status:"ok",removedFiles:[],removedDirs:[],modifiedFiles:[],keptUserFiles:[],git:"no-changes",server:{outcome:"absent"}}}async run(){const t=s.join(this.targetDir,".weave");if(!await D(t))return this.result.status="not-initialized",this.unregisterFromServer(),this.result;const i=await U(this.targetDir),e=await rt(t);let a=[];try{a=(await z(this.targetDir)).registered}catch(r){H.warn(Z("uninstall.pluginScanFailed",{error:String(r)}))}for(const r of N)await this.sweepHarness(r,a);return await this.sweepMcp(),await this.sweepInstructionFiles(e),await this.sweepPackFiles(i),await O(t,{recursive:!0,force:!0}),this.result.removedDirs.push(t),await this.runGit(),this.unregisterFromServer(),this.result}unregisterFromServer(){try{const t=B(this.targetDir,this.dbPath,this.hooksDir);t&&(this.result.server={outcome:"removed",name:t.name,purged:t.purged})}catch(t){this.result.server={outcome:"failed",error:t instanceof Error?t.message:String(t)}}}async sweepHarness(t,i){const e=s.join(this.targetDir,x[t].projectDir);if(!await D(e))return;const a=s.join(e,"helpers");for(const o of await j(a)){const u=await p(o);u!==null&&u.includes(q)?(await m(o),this.result.removedFiles.push(o)):this.result.keptUserFiles.push(o)}const r=[["skills",F.getSkillsSourceDir()],["commands",F.getCommandsSourceDir()],["agents",F.getAgentsSourceDir()]];for(const[o,u]of r)u&&await this.removeTemplateMirrors(s.join(e,o),u);for(const o of i){const u=o.sourcePath;if(o.category==="skill")await this.removeTemplateMirrors(s.join(e,"skills",s.basename(u)),u);else{const y=o.category==="command"?"commands":"agents",l=s.join(e,y,s.basename(u));await this.removeIfSame(l,u)}}const c=s.join(e,"settings.json"),f=await b(c);if(f){const o=L(f);Object.keys(o).length>0?(await v(c,JSON.stringify(o,null,2)+`
2
- `,"utf-8"),this.result.modifiedFiles.push(c)):(await m(c),this.result.removedFiles.push(c))}const h=s.join(e,".gitignore");await p(h)===Y&&(await m(h),this.result.removedFiles.push(h));for(const o of["helpers","skills","commands","agents"])await A(s.join(e,o),this.targetDir,this.result.removedDirs);await A(e,this.targetDir,this.result.removedDirs)}async removeTemplateMirrors(t,i){for(const e of await j(i)){const a=s.relative(i,e);await this.removeIfSame(s.join(t,a),e)}}async removeIfSame(t,i){await D(t)&&(await it(t,i)?(await m(t),this.result.removedFiles.push(t)):this.result.keptUserFiles.push(t))}async sweepMcp(){const t=s.join(this.targetDir,".mcp.json"),i=await b(t);if(!i)return;const e=V(i);Object.keys(e).length>0?(await v(t,JSON.stringify(e,null,2)+`
3
- `,"utf-8"),this.result.modifiedFiles.push(t)):(await m(t),this.result.removedFiles.push(t))}async sweepInstructionFiles(t){for(const i of[...S].reverse()){const e=s.join(this.targetDir,i);let a;try{a=await T(e)}catch{continue}if(a.isSymbolicLink()){await m(e),this.result.removedFiles.push(e);continue}if(!a.isFile())continue;const r=await p(e);if(r===null)continue;if(r.includes(K)){await m(e),this.result.removedFiles.push(e);continue}const c=r.indexOf(J),f=r.indexOf(R);if(c!==-1&&f!==-1&&f>c){const h=(r.slice(0,c)+r.slice(f+R.length)).replace(/\s+$/,"");h===""?(await m(e),this.result.removedFiles.push(e)):(await v(e,h+`
4
- `,"utf-8"),this.result.modifiedFiles.push(e))}}if(t&&!await D(s.join(this.targetDir,k))){const i=await p(t);i!==null&&(await v(s.join(this.targetDir,k),i,"utf-8"),this.result.restoredFromBackup=s.join(this.targetDir,k))}}async sweepPackFiles(t){for(const[e,a]of t){const r=s.resolve(this.targetDir,e);r!==this.targetDir&&!r.startsWith(this.targetDir+s.sep)||(await C(r)===a?(await m(r).catch(()=>{}),this.result.removedFiles.push(r)):await D(r)&&this.result.keptUserFiles.push(r))}const i=[...new Set([...t.keys()].map(e=>s.dirname(s.resolve(this.targetDir,e))))];for(const e of i)await A(e,this.targetDir,this.result.removedDirs)}async git(t){return this.execGit("git",t,{cwd:this.targetDir})}async runGit(){if(!await Q(this.targetDir)){this.result.git="skipped-not-repo";return}try{if((await this.git(["diff","--cached","--quiet"])).code!==0){this.result.git="skipped-dirty-index";return}const e=await this.git(["log","-1","--format=%s %H %P"]);if(e.code===0){const[l,d,w]=e.stdout.trimEnd().split(" ");if(l===$&&w){const I=await this.git(["diff-tree","--no-commit-id","--name-only","-r",d]),P=I.code===0?I.stdout.split(`
5
- `).map(g=>g.trim()).filter(Boolean):[],M=g=>et.some(E=>g===E||g===E+"/"||g.startsWith(E+"/"));if(P.length>0&&P.every(M)){const g=await this.git(["reset","--mixed","HEAD~1"]);if(g.code===0){this.result.git="reset",this.result.gitSha=w.slice(0,7);return}this.result.git="failed",this.result.gitError=g.stderr.trim()||"git reset failed";return}}}const a=[...this.result.removedFiles,...this.result.modifiedFiles,...this.result.restoredFromBackup?[this.result.restoredFromBackup]:[],s.join(this.targetDir,".weave")],r=[...new Set(a.map(l=>s.relative(this.targetDir,l).replace(/\\/g,"/")))],c=50,f=new Set;for(let l=0;l<r.length;l+=c){const d=await this.git(["ls-files","--",...r.slice(l,l+c)]);if(d.code!==0){this.result.git="failed",this.result.gitError=d.stderr.trim()||"git ls-files failed";return}for(const w of d.stdout.split(`
6
- `))w.trim()&&f.add(w.trim().replace(/\\/g,"/"))}const h=[...f];if(h.length>0)for(let l=0;l<h.length;l+=c){const d=await this.git(["add","--",...h.slice(l,l+c)]);if(d.code!==0){this.result.git="failed",this.result.gitError=d.stderr.trim()||"git add failed";return}}if((await this.git(["diff","--cached","--quiet"])).code===0){this.result.git="no-changes";return}const u=await this.git(["commit","-m",tt]);if(u.code!==0){this.result.git="failed",this.result.gitError=u.stderr.trim()||"git commit failed";return}const y=await this.git(["rev-parse","--short","HEAD"]);this.result.git="committed",this.result.gitSha=y.code===0?y.stdout.trim():void 0}catch(i){this.result.git="failed",this.result.gitError=i instanceof Error?i.message:String(i)}}}async function rt(n){const t=s.join(n,"backup");let i;try{i=await _(t)}catch{return null}const e=i.filter(a=>S.some(r=>a.startsWith(r+"."))).sort();return e.length>0?s.join(t,e[e.length-1]):null}export async function executeUninstall(n){return new st(n).run()}
1
+ import s from"node:path";import{lstat as A,readdir as P,readFile as O,rm as T,rmdir as x,unlink as m,writeFile as v}from"node:fs/promises";import{HARNESS_DIRS as R,HARNESS_KEYS as _,INSTRUCTION_FILES as D,logger as M}from"@weavecode/core";import{hashFile as N,projectPackFiles as W,unregisterProject as H}from"@weavecode/server";import{templateRegistry as F}from"@weavecode/templates";import{stripWeaveSettings as B}from"./settings-gen.js";import{stripWeaveMcp as U}from"./mcp-gen.js";import{WEAVE_BLOCK_START as C,WEAVE_BLOCK_END as b,WEAVE_MANAGED_HEADER as L}from"./claudemd-gen.js";import{WEAVE_HELPER_MARKER as K}from"./harnesses/claude.js";import{registerPluginTemplates as V}from"./plugin-templates.js";import{NESTED_GITIGNORE as J}from"./executor.js";import{COMMIT_MESSAGE as q,findGitRepoRoot as z,defaultGitExec as Y}from"./git-commit.js";import{t as $}from"../i18n/index.js";const Q="chore: weave uninstall \u79FB\u9664 init \u751F\u6210\u7269",S=D[1],X=[...D,".mcp.json",..._.map(n=>R[n].projectDir),".weave"];async function p(n){try{return await A(n),!0}catch{return!1}}async function g(n){try{return await O(n,"utf-8")}catch{return null}}async function G(n){const t=await g(n);if(t!==null)try{const i=JSON.parse(t);if(i&&typeof i=="object"&&!Array.isArray(i))return i}catch{}}async function E(n){const t=[];let i;try{i=await P(n,{withFileTypes:!0})}catch{return t}for(const e of i){const a=s.join(n,e.name);e.isDirectory()?t.push(...await E(a)):t.push(a)}return t}async function Z(n,t){const[i,e]=await Promise.all([g(n),g(t)]);return i!==null&&i===e}async function j(n,t,i){let e=n;const a=s.resolve(t);for(;;){if(s.resolve(e)===a||!e.startsWith(a+s.sep))return;try{await x(e),i.push(e)}catch{return}e=s.dirname(e)}}class tt{targetDir;execGit;dbPath;hooksDir;result;constructor(t){this.targetDir=s.resolve(t.targetDir),this.execGit=t.execGit??Y,this.dbPath=t.dbPath,this.hooksDir=t.hooksDir,this.result={status:"ok",removedFiles:[],removedDirs:[],modifiedFiles:[],keptUserFiles:[],git:"no-changes",server:{outcome:"absent"}}}async run(){const t=s.join(this.targetDir,".weave");if(!await p(t))return this.result.status="not-initialized",this.unregisterFromServer(),this.result;const i=await W(this.targetDir),e=await et(t);let a=[];try{a=(await V(this.targetDir)).registered}catch(o){M.warn($("uninstall.pluginScanFailed",{error:String(o)}))}for(const o of _)await this.sweepHarness(o,a);return await this.sweepMcp(),await this.sweepInstructionFiles(e),await this.sweepPackFiles(i),await T(t,{recursive:!0,force:!0}),this.result.removedDirs.push(t),await this.runGit(),this.unregisterFromServer(),this.result}unregisterFromServer(){try{const t=H(this.targetDir,this.dbPath,this.hooksDir);t&&(this.result.server={outcome:"removed",name:t.name,purged:t.purged})}catch(t){this.result.server={outcome:"failed",error:t instanceof Error?t.message:String(t)}}}async sweepHarness(t,i){const e=s.join(this.targetDir,R[t].projectDir);if(!await p(e))return;const a=s.join(e,"helpers");for(const r of await E(a)){const l=await g(r);l!==null&&l.includes(K)?(await m(r),this.result.removedFiles.push(r)):this.result.keptUserFiles.push(r)}const o=[["skills",F.getSkillsSourceDir()],["commands",F.getCommandsSourceDir()],["agents",F.getAgentsSourceDir()]];for(const[r,l]of o)l&&await this.removeTemplateMirrors(s.join(e,r),l);for(const r of i){const l=r.sourcePath;if(r.category==="skill")await this.removeTemplateMirrors(s.join(e,"skills",s.basename(l)),l);else{const d=r.category==="command"?"commands":"agents",w=s.join(e,d,s.basename(l));await this.removeIfSame(w,l)}}const c=s.join(e,"settings.json"),u=await G(c);if(u){const r=B(u);Object.keys(r).length>0?(await v(c,JSON.stringify(r,null,2)+`
2
+ `,"utf-8"),this.result.modifiedFiles.push(c)):(await m(c),this.result.removedFiles.push(c))}const h=s.join(e,".gitignore");await g(h)===J&&(await m(h),this.result.removedFiles.push(h));for(const r of["helpers","skills","commands","agents"])await j(s.join(e,r),this.targetDir,this.result.removedDirs);await j(e,this.targetDir,this.result.removedDirs)}async removeTemplateMirrors(t,i){for(const e of await E(i)){const a=s.relative(i,e);await this.removeIfSame(s.join(t,a),e)}}async removeIfSame(t,i){await p(t)&&(await Z(t,i)?(await m(t),this.result.removedFiles.push(t)):this.result.keptUserFiles.push(t))}async sweepMcp(){const t=s.join(this.targetDir,".mcp.json"),i=await G(t);if(!i)return;const e=U(i);Object.keys(e).length>0?(await v(t,JSON.stringify(e,null,2)+`
3
+ `,"utf-8"),this.result.modifiedFiles.push(t)):(await m(t),this.result.removedFiles.push(t))}async sweepInstructionFiles(t){for(const i of[...D].reverse()){const e=s.join(this.targetDir,i);let a;try{a=await A(e)}catch{continue}if(a.isSymbolicLink()){await m(e),this.result.removedFiles.push(e);continue}if(!a.isFile())continue;const o=await g(e);if(o===null)continue;if(o.includes(L)){await m(e),this.result.removedFiles.push(e);continue}const c=o.indexOf(C),u=o.indexOf(b);if(c!==-1&&u!==-1&&u>c){const h=(o.slice(0,c)+o.slice(u+b.length)).replace(/\s+$/,"");h===""?(await m(e),this.result.removedFiles.push(e)):(await v(e,h+`
4
+ `,"utf-8"),this.result.modifiedFiles.push(e))}}if(t&&!await p(s.join(this.targetDir,S))){const i=await g(t);i!==null&&(await v(s.join(this.targetDir,S),i,"utf-8"),this.result.restoredFromBackup=s.join(this.targetDir,S))}}async sweepPackFiles(t){for(const[e,a]of t){const o=s.resolve(this.targetDir,e);o!==this.targetDir&&!o.startsWith(this.targetDir+s.sep)||(await N(o)===a?(await m(o).catch(()=>{}),this.result.removedFiles.push(o)):await p(o)&&this.result.keptUserFiles.push(o))}const i=[...new Set([...t.keys()].map(e=>s.dirname(s.resolve(this.targetDir,e))))];for(const e of i)await j(e,this.targetDir,this.result.removedDirs)}async git(t){return this.execGit("git",t,{cwd:this.targetDir})}async runGit(){if(!await z(this.targetDir)){this.result.git="skipped-not-repo";return}try{if((await this.git(["diff","--cached","--quiet"])).code!==0){this.result.git="skipped-dirty-index";return}const t=await this.git(["log","-1","--format=%s %H %P"]);if(t.code===0){const[r,l,d]=t.stdout.trimEnd().split(" ");if(r===q&&d){const w=await this.git(["diff-tree","--no-commit-id","--name-only","-r",l]),k=w.code===0?w.stdout.split(`
5
+ `).map(f=>f.trim()).filter(Boolean):[],I=f=>X.some(y=>f===y||f===y+"/"||f.startsWith(y+"/"));if(k.length>0&&k.every(I)){const f=await this.git(["reset","--mixed","HEAD~1"]);if(f.code===0){this.result.git="reset",this.result.gitSha=d.slice(0,7);return}this.result.git="failed",this.result.gitError=f.stderr.trim()||"git reset failed";return}}}const i=[...this.result.removedFiles,...this.result.modifiedFiles,...this.result.restoredFromBackup?[this.result.restoredFromBackup]:[],s.join(this.targetDir,".weave")],e=[...new Set(i.map(r=>s.relative(this.targetDir,r).replace(/\\/g,"/")))],a=50,o=new Set;for(let r=0;r<e.length;r+=a){const l=await this.git(["ls-files","--",...e.slice(r,r+a)]);if(l.code!==0){this.result.git="failed",this.result.gitError=l.stderr.trim()||"git ls-files failed";return}for(const d of l.stdout.split(`
6
+ `))d.trim()&&o.add(d.trim().replace(/\\/g,"/"))}const c=[...o];if(c.length>0)for(let r=0;r<c.length;r+=a){const l=await this.git(["add","--",...c.slice(r,r+a)]);if(l.code!==0){this.result.git="failed",this.result.gitError=l.stderr.trim()||"git add failed";return}}if((await this.git(["diff","--cached","--quiet"])).code===0){this.result.git="no-changes";return}const u=await this.git(["commit","-m",Q]);if(u.code!==0){this.result.git="failed",this.result.gitError=u.stderr.trim()||"git commit failed";return}const h=await this.git(["rev-parse","--short","HEAD"]);this.result.git="committed",this.result.gitSha=h.code===0?h.stdout.trim():void 0}catch(t){this.result.git="failed",this.result.gitError=t instanceof Error?t.message:String(t)}}}async function et(n){const t=s.join(n,"backup");let i;try{i=await P(t)}catch{return null}const e=i.filter(a=>D.some(o=>a.startsWith(o+"."))).sort();return e.length>0?s.join(t,e[e.length-1]):null}export async function executeUninstall(n){return new tt(n).run()}
@@ -1 +1 @@
1
- import{HARNESS_DRIVERS as o,createRuntimeRegistry as s}from"@weavecode/harness";import{ClaudeInitTemplate as c}from"./harnesses/claude.js";import{CodexInitTemplate as a}from"./harnesses/codex.js";const r={claude:c,codex:a};export function buildInitRegistry(){const t=s();for(const e of Object.keys(r)){const i=o[e],n={...i,capabilities:i.capabilities.includes("init")?i.capabilities:[...i.capabilities,"init"],init:r[e]};t.unregister(e),t.register(n)}return t}
1
+ import{HARNESS_DRIVERS as r,createRuntimeRegistry as n}from"@weavecode/harness";import{ClaudeInitTemplate as o}from"./harnesses/claude.js";import{CodexInitTemplate as c}from"./harnesses/codex.js";const s={claude:o,codex:c};export function buildInitRegistry(){const t=n();for(const e of Object.keys(s)){const i=r[e],a={...i,capabilities:i.capabilities.includes("init")?i.capabilities:[...i.capabilities,"init"],init:s[e]};t.unregister(e),t.register(a)}return t}
@@ -1 +1 @@
1
- import{t as c}from"./i18n/index.js";export class CommandParser{commands=new Map;globalOptions=[];constructor(){this.initGlobalOptions()}initGlobalOptions(){this.globalOptions=[{name:"help",short:"h",description:"flag.help",type:"boolean",default:!1},{name:"version",short:"V",description:"flag.version",type:"boolean",default:!1},{name:"verbose",short:"v",description:"flag.verbose",type:"boolean",default:!1},{name:"quiet",short:"q",description:"flag.quiet",type:"boolean",default:!1}]}registerCommand(e){if(this.commands.set(e.name,e),e.aliases)for(const t of e.aliases)this.commands.set(t,e)}getCommand(e){return this.commands.get(e)}getAllCommands(){const e=new Set;return Array.from(this.commands.values()).filter(t=>e.has(t)?!1:(e.add(t),!0))}parse(e){const t={command:[],flags:{_:[]},positional:[],raw:[...e]};let s;for(let r=0;r<e.length;r++){const i=e[r];if(i.startsWith("-"))break;if(t.command.length===0&&this.commands.has(i)){s=this.commands.get(i),t.command.push(i);continue}if(t.command.length===1&&s?.subcommands){const l=s.subcommands.find(u=>u.name===i||u.aliases?.includes(i));if(l){s=l,t.command.push(i);continue}}if(t.command.length===2&&s?.subcommands){const l=s.subcommands.find(u=>u.name===i||u.aliases?.includes(i));if(l){s=l,t.command.push(i);continue}}break}const f=this.buildAliases(s),n=this.booleanFlags(s);let a=!0,o=t.command.length;for(;o<e.length;){const r=e[o];if(r==="--"){a=!1,o++;continue}if(a&&r.startsWith("-")){const i=this.parseFlag(e,o,f,n);Object.assign(t.flags,i.flags),o=i.nextIndex;continue}t.positional.push(r),t.flags._.push(r),o++}return this.applyDefaults(t.flags,s),t}validateFlags(e,t){const s=[],f=[...this.globalOptions,...t?.options??[]];for(const n of f){const a=this.normalizeKey(n.name);if(n.required&&e[a]===void 0&&s.push(c("cli.missingRequired",{name:n.name})),n.choices&&e[a]!==void 0){const o=String(e[a]);n.choices.includes(o)||s.push(c("cli.invalidChoice",{name:n.name,value:o,choices:n.choices.join(", ")}))}if(n.validate&&e[a]!==void 0){const o=n.validate(e[a]);o!==!0&&s.push(o)}}return s}getGlobalOptions(){return[...this.globalOptions]}parseFlag(e,t,s,f){const n={},a=e[t];let o=t+1;if(a.startsWith("--")){const r=a.indexOf("=");if(r!==-1){const i=a.slice(2,r);n[this.normalizeKey(i)]=this.parseValue(a.slice(r+1))}else if(a.startsWith("--no-")){const i=a.slice(5);n[this.normalizeKey(i)]=!1}else{const i=a.slice(2),l=this.normalizeKey(i);f.has(l)?o<e.length&&this.isBooleanLiteral(e[o])?(n[l]=e[o].toLowerCase()==="true",o++):n[l]=!0:o<e.length&&this.isFlagValue(e[o])?(n[l]=this.parseValue(e[o]),o++):n[l]=!0}}else if(a.startsWith("-")){const r=a.slice(1);if(r.length===1){const i=s[r]||r,l=this.normalizeKey(i);f.has(l)?o<e.length&&this.isBooleanLiteral(e[o])?(n[l]=e[o].toLowerCase()==="true",o++):n[l]=!0:o<e.length&&this.isFlagValue(e[o])?(n[l]=this.parseValue(e[o]),o++):n[l]=!0}else for(const i of r){const l=s[i]||i;n[this.normalizeKey(l)]=!0}}return{flags:n,nextIndex:o}}isFlagValue(e){return e.startsWith("-")?/^-\d*\.?\d+(?:[eE][+-]?\d+)?$/.test(e):!0}isBooleanLiteral(e){const t=e.toLowerCase();return t==="true"||t==="false"}parseValue(e){if(e.toLowerCase()==="true")return!0;if(e.toLowerCase()==="false")return!1;const t=Number(e);return!isNaN(t)&&e.trim()!==""?t:e}normalizeKey(e){return e.replace(/-([a-z])/g,(t,s)=>s.toUpperCase())}buildAliases(e){const t={};for(const s of this.globalOptions)s.short&&(t[s.short]=s.name);if(e?.options)for(const s of e.options)s.short&&(t[s.short]=s.name);return t}booleanFlags(e){const t=new Set;for(const s of this.globalOptions)s.type==="boolean"&&t.add(this.normalizeKey(s.name));if(e?.options)for(const s of e.options)s.type==="boolean"?t.add(this.normalizeKey(s.name)):s.type&&t.delete(this.normalizeKey(s.name));return t}applyDefaults(e,t){const s=[];t?.options&&s.push(t.options),s.push(this.globalOptions);for(const f of s)for(const n of f){const a=this.normalizeKey(n.name);e[a]===void 0&&n.default!==void 0&&(e[a]=n.default)}}}
1
+ import{t as m}from"./i18n/index.js";export class CommandParser{commands=new Map;globalOptions=[];constructor(){this.initGlobalOptions()}initGlobalOptions(){this.globalOptions=[{name:"help",short:"h",description:"flag.help",type:"boolean",default:!1},{name:"version",short:"V",description:"flag.version",type:"boolean",default:!1},{name:"verbose",short:"v",description:"flag.verbose",type:"boolean",default:!1},{name:"quiet",short:"q",description:"flag.quiet",type:"boolean",default:!1}]}registerCommand(s){if(this.commands.set(s.name,s),s.aliases)for(const t of s.aliases)this.commands.set(t,s)}getCommand(s){return this.commands.get(s)}getAllCommands(){const s=new Set;return Array.from(this.commands.values()).filter(t=>s.has(t)?!1:(s.add(t),!0))}parse(s){const t={command:[],flags:{_:[]},positional:[],raw:[...s]};let o;for(let r=0;r<s.length;r++){const i=s[r];if(i.startsWith("-"))break;if(t.command.length===0&&this.commands.has(i)){o=this.commands.get(i),t.command.push(i);continue}if(t.command.length===1&&o?.subcommands){const l=o.subcommands.find(h=>h.name===i||h.aliases?.includes(i));if(l){o=l,t.command.push(i);continue}}if(t.command.length===2&&o?.subcommands){const l=o.subcommands.find(h=>h.name===i||h.aliases?.includes(i));if(l){o=l,t.command.push(i);continue}}break}const c=this.buildAliases(o),n=this.booleanFlags(o);let a=!0,e=t.command.length;for(;e<s.length;){const r=s[e];if(r==="--"){a=!1,e++;continue}if(a&&r.startsWith("-")){const i=this.parseFlag(s,e,c,n);Object.assign(t.flags,i.flags),e=i.nextIndex;continue}t.positional.push(r),t.flags._.push(r),e++}return this.applyDefaults(t.flags,o),t}validateFlags(s,t){const o=[],c=[...this.globalOptions,...t?.options??[]];for(const n of c){const a=this.normalizeKey(n.name);if(n.required&&s[a]===void 0&&o.push(m("cli.missingRequired",{name:n.name})),n.choices&&s[a]!==void 0){const e=String(s[a]);n.choices.includes(e)||o.push(m("cli.invalidChoice",{name:n.name,value:e,choices:n.choices.join(", ")}))}if(n.validate&&s[a]!==void 0){const e=n.validate(s[a]);e!==!0&&o.push(e)}}return o}getGlobalOptions(){return[...this.globalOptions]}parseFlag(s,t,o,c){const n={},a=s[t];let e=t+1;if(a.startsWith("--")){const r=a.indexOf("=");if(r!==-1){const i=a.slice(2,r);n[this.normalizeKey(i)]=this.parseValue(a.slice(r+1))}else if(a.startsWith("--no-")){const i=a.slice(5);n[this.normalizeKey(i)]=!1}else{const i=a.slice(2),l=this.normalizeKey(i);c.has(l)?e<s.length&&this.isBooleanLiteral(s[e])?(n[l]=s[e].toLowerCase()==="true",e++):n[l]=!0:e<s.length&&this.isFlagValue(s[e])?(n[l]=this.parseValue(s[e]),e++):n[l]=!0}}else if(a.startsWith("-")){const r=a.slice(1);if(r.length===1){const i=o[r]||r,l=this.normalizeKey(i);c.has(l)?e<s.length&&this.isBooleanLiteral(s[e])?(n[l]=s[e].toLowerCase()==="true",e++):n[l]=!0:e<s.length&&this.isFlagValue(s[e])?(n[l]=this.parseValue(s[e]),e++):n[l]=!0}else for(const i of r){const l=o[i]||i;n[this.normalizeKey(l)]=!0}}return{flags:n,nextIndex:e}}isFlagValue(s){return s.startsWith("-")?/^-\d*\.?\d+(?:[eE][+-]?\d+)?$/.test(s):!0}isBooleanLiteral(s){const t=s.toLowerCase();return t==="true"||t==="false"}parseValue(s){if(s.toLowerCase()==="true")return!0;if(s.toLowerCase()==="false")return!1;const t=Number(s);return!isNaN(t)&&s.trim()!==""?t:s}normalizeKey(s){return s.replace(/-([a-z])/g,(t,o)=>o.toUpperCase())}buildAliases(s){const t={};for(const o of this.globalOptions)o.short&&(t[o.short]=o.name);if(s?.options)for(const o of s.options)o.short&&(t[o.short]=o.name);return t}booleanFlags(s){const t=new Set;for(const o of this.globalOptions)o.type==="boolean"&&t.add(this.normalizeKey(o.name));if(s?.options)for(const o of s.options)o.type==="boolean"?t.add(this.normalizeKey(o.name)):o.type&&t.delete(this.normalizeKey(o.name));return t}applyDefaults(s,t){const o=[];t?.options&&o.push(t.options),o.push(this.globalOptions);for(const c of o)for(const n of c){const a=this.normalizeKey(n.name);s[a]===void 0&&n.default!==void 0&&(s[a]=n.default)}}}
@@ -1 +1 @@
1
- const m={31:"red",32:"green",33:"yellow",34:"blue",35:"magenta",36:"cyan",90:"gray"},p={41:"red",42:"green",43:"yellow",44:"blue",45:"magenta",46:"cyan",100:"gray"};function h(n,t,o){const e=u=>Math.max(0,Math.min(255,Math.round(u))).toString(16).padStart(2,"0");return`#${e(n)}${e(t)}${e(o)}`}export function toInkColor(n){const t="ansi256:";return n.startsWith(t)?`ansi256(${n.slice(t.length)})`:n}function b(n,t,o){if(n[t]!==o)return null;if(n[t+1]==="5"&&n[t+2]!==void 0){const e=Number(n[t+2]);return Number.isInteger(e)&&e>=0&&e<=255?{value:`ansi256:${e}`,next:t+3}:null}if(n[t+1]==="2"&&n[t+4]!==void 0){const[e,u,s]=[n[t+2],n[t+3],n[t+4]].map(Number);return[e,u,s].every(i=>Number.isFinite(i))?{value:h(e,u,s),next:t+5}:null}return null}export function parseAnsiSpans(n){const t=[];let o,e="";const u=()=>{o&&o.text&&t.push(o),o=void 0},s=()=>{e&&(t.push({text:e}),e="")},i=()=>(o||(s(),o={text:""}),o),d=n.split(/(\x1b\[[0-9;]*m)/);for(const c of d){const g=/^\x1b\[([0-9;]*)m$/.exec(c);if(!g){c&&(o?o.text+=c:e+=c);continue}const a=g[1].split(";").filter(r=>r!=="");for(let r=0;r<a.length;){const x=b(a,r,"38");if(x){i().color=x.value,r=x.next;continue}const f=b(a,r,"48");if(f){i().backgroundColor=f.value,r=f.next;continue}const l=a[r];l==="0"?u():l==="1"?i().bold=!0:l==="2"?i().dim=!0:m[l]?i().color=m[l]:p[l]&&(i().backgroundColor=p[l]),r++}}return u(),s(),t}export function stripAnsi(n){return n.replace(/\x1b\[[0-9;]*m/g,"")}
1
+ const m={31:"red",32:"green",33:"yellow",34:"blue",35:"magenta",36:"cyan",90:"gray"},p={41:"red",42:"green",43:"yellow",44:"blue",45:"magenta",46:"cyan",100:"gray"};function h(n,e,o){const t=i=>Math.max(0,Math.min(255,Math.round(i))).toString(16).padStart(2,"0");return`#${t(n)}${t(e)}${t(o)}`}export function toInkColor(n){const e="ansi256:";return n.startsWith(e)?`ansi256(${n.slice(e.length)})`:n}function b(n,e,o){if(n[e]!==o)return null;if(n[e+1]==="5"&&n[e+2]!==void 0){const t=Number(n[e+2]);return Number.isInteger(t)&&t>=0&&t<=255?{value:`ansi256:${t}`,next:e+3}:null}if(n[e+1]==="2"&&n[e+4]!==void 0){const[t,i,s]=[n[e+2],n[e+3],n[e+4]].map(Number);return[t,i,s].every(u=>Number.isFinite(u))?{value:h(t,i,s),next:e+5}:null}return null}export function parseAnsiSpans(n){const e=[];let o,t="";const i=()=>{o&&o.text&&e.push(o),o=void 0},s=()=>{t&&(e.push({text:t}),t="")},u=()=>(o||(s(),o={text:""}),o),d=n.split(/(\x1b\[[0-9;]*m)/);for(const c of d){const g=/^\x1b\[([0-9;]*)m$/.exec(c);if(!g){c&&(o?o.text+=c:t+=c);continue}const a=g[1].split(";").filter(r=>r!=="");for(let r=0;r<a.length;){const x=b(a,r,"38");if(x){u().color=x.value,r=x.next;continue}const f=b(a,r,"48");if(f){u().backgroundColor=f.value,r=f.next;continue}const l=a[r];l==="0"?i():l==="1"?u().bold=!0:l==="2"?u().dim=!0:m[l]?u().color=m[l]:p[l]&&(u().backgroundColor=p[l]),r++}}return i(),s(),e}export function stripAnsi(n){return n.replace(/\x1b\[[0-9;]*m/g,"")}
@@ -1,2 +1,2 @@
1
- import{mkdtempSync as _,writeFileSync as r}from"node:fs";import{tmpdir as a}from"node:os";import{join as n}from"node:path";export function writeFixtureTranscript(){const o=_(n(a(),"weave-sl-mock-")),t=n(o,"session.jsonl"),e=(s,i)=>`${JSON.stringify({type:"assistant",uuid:s,message:{id:s,usage:i}})}
1
+ import{mkdtempSync as _,writeFileSync as r}from"node:fs";import{tmpdir as a}from"node:os";import{join as s}from"node:path";export function writeFixtureTranscript(){const o=_(s(a(),"weave-sl-mock-")),t=s(o,"session.jsonl"),e=(n,i)=>`${JSON.stringify({type:"assistant",uuid:n,message:{id:n,usage:i}})}
2
2
  `;return r(t,e("msg_mock_1",{input_tokens:3e5,output_tokens:2e4,cache_read_input_tokens:1e5})+e("msg_mock_1",{input_tokens:3e5,output_tokens:2e4,cache_read_input_tokens:1e5})+e("msg_mock_2",{input_tokens:4e5,output_tokens:3e4,cache_read_input_tokens:110900})),t}export function buildMockInput(o,t=100,e=""){return{session_id:"mock-session",transcript_path:e,model:{display_name:"Fable 5",id:"claude-fable-5"},workspace:{current_dir:o},effort:{level:"high"},context_window:{used_percentage:42,remaining_percentage:58,context_window_size:1e6,total_input_tokens:42e4,total_output_tokens:0},cost:{total_cost_usd:1.234},rate_limits:{five_hour:{used_percentage:33,resets_at:0}},terminal:{columns:t}}}
@@ -1,3 +1,3 @@
1
- import{jsx as i,jsxs as w}from"react/jsx-runtime";import{spawnSync as Y}from"node:child_process";import _ from"node:path";import{useEffect as q,useState as b}from"react";import{render as U,Box as S,Text as a,useInput as V,useApp as X,useStdout as z}from"ink";import{applyStatuslineConfig as Q,generateStatuslineScript as W,readStatuslineConfig as Z,writeGlobalStatuslineConfig as ee}from"@weavecode/server";import{parseAnsiSpans as re,toInkColor as $}from"./ansi.js";import{buildMockInput as ne,writeFixtureTranscript as te}from"./mock-input.js";import{t as c}from"../i18n/index.js";const oe=["gray","red","green","yellow","blue","magenta","cyan"],le=["ansi256:196","ansi256:208","ansi256:39","#f7768e","#7aa2f7","#9ece6a"],x=[...oe,...le];export const COLOR_CYCLE=x;const I=[" \u2502 "," \xB7 "," \u2014 "," ",""],L=["left","center","right"],ie=["percent","bar","both"],A=[{fill:"\u2588",empty:"\u2591"},{fill:"\u25B0",empty:"\u25B1"},{fill:"=",empty:"\xB7"},{fill:"#",empty:"-"}],P=[": "," ",": "," \xBB "],ae={project:["","\u{1F4C1}"],git:["","\u{1F33F}"],git_user:["","\u{1F464}"],changes:["","\u270F\uFE0F"],model:["","\u{1F916}"],thinking:["","\u{1F9E9}"],context:["","\u{1F9E0}"],tokens:["","\u{1F522}"],cost:["","\u{1F4B8}"],rate:["","\u26A1"],time:["","\u{1F552}"]};let j;function ce(){return j===void 0&&(j=te()),j}export function runPreviewLines(e,r,t){const l=W(e).replace(/^#!.*\n/,""),h=JSON.stringify(ne(r,t,ce()));try{const n=Y(process.execPath,["-e",l],{input:h,encoding:"utf8",timeout:15e3,windowsHide:!0});return n.status!==0?{lines:[],error:(n.stderr||c("preview.scriptExit",{status:String(n.status)})).trim()}:{lines:(n.stdout??"").replace(/\r\n/g,`
1
+ import{jsx as i,jsxs as w}from"react/jsx-runtime";import{spawnSync as Y}from"node:child_process";import _ from"node:path";import{useEffect as q,useState as b}from"react";import{render as N,Box as S,Text as a,useInput as U,useApp as X,useStdout as z}from"ink";import{applyStatuslineConfig as Q,generateStatuslineScript as W,readStatuslineConfig as Z,writeGlobalStatuslineConfig as ee}from"@weavecode/server";import{parseAnsiSpans as re,toInkColor as $}from"./ansi.js";import{buildMockInput as ne,writeFixtureTranscript as te}from"./mock-input.js";import{t as c}from"../i18n/index.js";const oe=["gray","red","green","yellow","blue","magenta","cyan"],le=["ansi256:196","ansi256:208","ansi256:39","#f7768e","#7aa2f7","#9ece6a"],x=[...oe,...le];export const COLOR_CYCLE=x;const I=[" \u2502 "," \xB7 "," \u2014 "," ",""],L=["left","center","right"],ie=["percent","bar","both"],A=[{fill:"\u2588",empty:"\u2591"},{fill:"\u25B0",empty:"\u25B1"},{fill:"=",empty:"\xB7"},{fill:"#",empty:"-"}],P=[": "," ",": "," \xBB "],ae={project:["","\u{1F4C1}"],git:["","\u{1F33F}"],git_user:["","\u{1F464}"],changes:["","\u270F\uFE0F"],model:["","\u{1F916}"],thinking:["","\u{1F9E9}"],context:["","\u{1F9E0}"],tokens:["","\u{1F522}"],cost:["","\u{1F4B8}"],rate:["","\u26A1"],time:["","\u{1F552}"]};let j;function ce(){return j===void 0&&(j=te()),j}export function runPreviewLines(e,r,t){const l=W(e).replace(/^#!.*\n/,""),h=JSON.stringify(ne(r,t,ce()));try{const n=Y(process.execPath,["-e",l],{input:h,encoding:"utf8",timeout:15e3,windowsHide:!0});return n.status!==0?{lines:[],error:(n.stderr||c("preview.scriptExit",{status:String(n.status)})).trim()}:{lines:(n.stdout??"").replace(/\r\n/g,`
2
2
  `).split(`
3
- `).filter(v=>v!=="")}}catch(n){return{lines:[],error:String(n)}}}function y(e,r,t){return{...e,segments:{...e.segments,[r]:{...e.segments[r],...t}}}}export function toggleSegment(e,r){return y(e,r,{enabled:!e.segments[r].enabled})}export function cycleSegmentColor(e,r){const t=x.indexOf(e.segments[r].color);return y(e,r,{color:x[(t+1)%x.length]})}export function toggleSegmentBold(e,r){return y(e,r,{bold:!e.segments[r].bold})}export function toggleSegmentMerge(e,r){return y(e,r,{merge:!e.segments[r].merge})}export function cycleSegmentIcon(e,r){const t=ae[r]??[""],l=t.indexOf(e.segments[r].icon);return y(e,r,{icon:t[(l+1)%t.length]})}export function cycleContextStyle(e,r){if(r!=="context")return e;const t=ie,l=t.indexOf(e.segments[r].style??"both");return y(e,r,{style:t[(l+1)%t.length]})}export function cycleAlign(e){const r=L.indexOf(e.align);return{...e,align:L[(r+1)%L.length]}}export function togglePowerline(e){return{...e,powerline:{...e.powerline,enabled:!e.powerline.enabled}}}const k=["\uE0B0","\uE0B2","\uE0B4","\uE0B6"];export function cyclePowerlineGlyph(e){const r=e.powerline.separator??k[0],t=k.indexOf(r),l=k[(t+1)%k.length];return{...e,powerline:{...e.powerline,separator:l}}}export function cycleLogoColor(e){const r=x.indexOf(e.logoColor);return{...e,logoColor:x[(r+1)%x.length]}}export function cycleSeparator(e){const r=I.indexOf(e.separator);return{...e,separator:I[(r+1)%I.length]}}export function bumpRefreshInterval(e,r){return{...e,refreshInterval:Math.max(1,e.refreshInterval+r)}}export function setSegmentField(e,r,t,l){const h=l===""?{[t]:void 0}:{[t]:l};return y(e,r,h)}export function bumpBarCells(e,r){const t=Math.max(1,Math.min(40,e.bar.cells+r));return{...e,bar:{...e.bar,cells:t}}}export function cycleBarGlyph(e){const r=A.findIndex(l=>l.fill===e.bar.fill&&l.empty===e.bar.empty),t=A[(r+1)%A.length];return{...e,bar:{...e.bar,...t}}}export function cycleLabelSeparator(e){const r=P.indexOf(e.labelSeparator);return{...e,labelSeparator:P[(r+1)%P.length]}}export function clampCursor(e,r){const t=e.lines.length,l=Math.min(Math.max(r.row,0),t-1),h=e.lines[l]?.length??0,n=Math.min(Math.max(r.col,0),Math.max(0,h-1));return{row:l,col:n}}export function moveCursor(e,r,t,l){const h=e.lines.length;let n=Math.min(Math.max(r.row+t,0),h-1);for(;n!==r.row&&(e.lines[n]?.length??0)===0;)n-=Math.sign(n-r.row)||1;if((e.lines[n]?.length??0)===0)return r;const v=e.lines[n].length;let g=r.col+l;return g>=v&&(g=v-1),g<0&&(g=0),{row:n,col:g}}function se({line:e}){const r=re(e);return i(a,{children:r.map((t,l)=>i(a,{color:t.color?$(t.color):void 0,backgroundColor:t.backgroundColor?$(t.backgroundColor):void 0,bold:t.bold,dimColor:t.dim,children:t.text},l))})}function ue({segmentKey:e,seg:r,focused:t}){const l=`${r.enabled?"\u25CF":"\u25CB"}${r.icon?r.icon:""}${e}`;return i(a,{color:$(r.enabled?r.color:"gray"),bold:t,inverse:t,dimColor:!r.enabled,children:l})}function fe({initialConfig:e,projectPath:r,initialCursor:t}){const{exit:l}=X(),{stdout:h}=z(),[n,v]=b(e),[g,B]=b(t),[F,D]=b({lines:[]}),[J,T]=b(!1),[G,M]=b(null),[H,R]=b(!1),[m,C]=b(null),O=Math.max(60,h?.columns??100),f=n.lines[g.row]?.[g.col],p=s=>{v(s),T(!0),M(null)};q(()=>{const s=setTimeout(()=>{D(runPreviewLines(n,r,O))},60);return()=>clearTimeout(s)},[n,O,r]),V((s,u)=>{if(!H){if(m){if(u.escape){C(null);return}if(u.return){const{key:o,field:E,buf:K}=m;p(N=>setSegmentField(N,o,E,K)),C(null);return}if(u.backspace||u.delete){C({...m,buf:m.buf.slice(0,-1)});return}s&&!u.ctrl&&!u.meta&&C({...m,buf:m.buf+s});return}if(s==="q"){l();return}if(u.escape){l();return}if(u.upArrow){B(o=>moveCursor(n,o,-1,0));return}if(u.downArrow){B(o=>moveCursor(n,o,1,0));return}if(u.leftArrow){B(o=>moveCursor(n,o,0,-1));return}if(u.rightArrow){B(o=>moveCursor(n,o,0,1));return}if(!u.return){if(s==="B"){p(cycleBarGlyph);return}if(s==="L"){p(cycleLabelSeparator);return}if(s==="["){p(o=>bumpBarCells(o,-1));return}if(s==="]"){p(o=>bumpBarCells(o,1));return}if(f){if(s==="n"){C({key:f,field:"label",buf:n.segments[f].label??""});return}if(s==="f"){C({key:f,field:"format",buf:n.segments[f].format??""});return}switch(s.toLowerCase()){case" ":p(o=>toggleSegment(o,f));return;case"c":p(o=>cycleSegmentColor(o,f));return;case"b":p(o=>toggleSegmentBold(o,f));return;case"m":p(o=>toggleSegmentMerge(o,f));return;case"i":p(o=>cycleSegmentIcon(o,f));return;case"v":p(o=>cycleContextStyle(o,f));return;case"a":p(o=>cycleAlign(o));return;case"p":p(o=>togglePowerline(o));return;case"g":p(o=>cyclePowerlineGlyph(o));return;case"l":p(o=>cycleLogoColor(o));return;case"s":p(o=>cycleSeparator(o));return;case"r":D(runPreviewLines(n,r,O)),M(c("preview.reRendered"));return;case"w":(async()=>{R(!0);try{(n.source??"global")==="global"&&await ee(n),await Q(r,n),T(!1),M(c("preview.saved"))}catch(o){M(c("preview.writeFailed",{error:String(o)}))}finally{R(!1)}})();return;default:break}}}}});const d=f?n.segments[f]:void 0;return w(S,{flexDirection:"column",gap:0,children:[w(S,{children:[i(a,{bold:!0,color:"cyan",children:"weave statusline preview"}),w(a,{dimColor:!0,children:[" \u2014 ",_.basename(r)," "]}),i(a,{dimColor:!0,children:c("preview.headerMeta",{source:n.source??"global",refresh:n.refreshInterval,align:n.align,powerline:n.powerline.enabled?c("preview.on"):c("preview.off")})}),J&&i(a,{color:"yellow",children:c("preview.unsaved")})]}),i(S,{flexDirection:"column",borderStyle:"round",borderColor:"cyan",paddingX:1,marginY:0,children:F.error?i(a,{color:"red",children:c("preview.scriptError",{error:F.error})}):F.lines.length?F.lines.map((s,u)=>i(se,{line:s},u)):i(a,{dimColor:!0,children:c("preview.rendering")})}),w(S,{flexDirection:"column",children:[i(a,{dimColor:!0,children:c("preview.layoutHelp")}),n.lines.map((s,u)=>w(S,{gap:1,children:[i(a,{dimColor:!0,children:c("preview.rowLabel",{row:u+1})}),s.map((o,E)=>i(ue,{segmentKey:o,seg:n.segments[o],focused:g.row===u&&g.col===E},o))]},u))]}),w(S,{flexDirection:"column",gap:0,marginTop:1,children:[m?w(a,{children:[i(a,{bold:!0,color:"yellow",children:` ${m.key}.${m.field} `})," ",i(a,{children:m.buf}),i(a,{inverse:!0,children:" "}),i(a,{dimColor:!0,children:c("preview.editConfirm")})]}):d&&f?w(a,{children:[i(a,{bold:!0,inverse:!0,children:` ${f} `})," ",i(a,{dimColor:!0,children:c("preview.segDetail",{color:d.color,bold:d.bold?c("preview.on"):c("preview.off"),merge:d.merge?c("preview.on"):c("preview.off"),icon:d.icon||"\u2014",style:f==="context"?c("preview.styleSuffix",{style:d.style??"both"}):""})})]}):null,!m&&d&&f&&(d.label||d.format)?w(a,{dimColor:!0,children:[d.label?c("preview.labelValue",{value:`${d.label}${n.labelSeparator}`}):"",d.format?c("preview.formatValue",{value:d.format}):""]}):null,i(a,{dimColor:!0,children:c("preview.barLine",{cells:n.bar.cells,glyphs:`${n.bar.fill}${n.bar.empty}`,labelSep:JSON.stringify(n.labelSeparator)})}),i(a,{dimColor:!0,children:c("preview.keysHelp")}),G&&i(a,{color:"green",children:G}),H&&i(a,{color:"yellow",children:c("preview.writing")})]})]})}export async function runStatuslinePreview(e){const r=await Z(e),t=clampCursor(r,{row:0,col:0});await U(i(fe,{initialConfig:r,projectPath:e,initialCursor:t}),{exitOnCtrlC:!0}).waitUntilExit?.()}
3
+ `).filter(v=>v!=="")}}catch(n){return{lines:[],error:String(n)}}}function y(e,r,t){return{...e,segments:{...e.segments,[r]:{...e.segments[r],...t}}}}export function toggleSegment(e,r){return y(e,r,{enabled:!e.segments[r].enabled})}export function cycleSegmentColor(e,r){const t=x.indexOf(e.segments[r].color);return y(e,r,{color:x[(t+1)%x.length]})}export function toggleSegmentBold(e,r){return y(e,r,{bold:!e.segments[r].bold})}export function toggleSegmentMerge(e,r){return y(e,r,{merge:!e.segments[r].merge})}export function cycleSegmentIcon(e,r){const t=ae[r]??[""],l=t.indexOf(e.segments[r].icon);return y(e,r,{icon:t[(l+1)%t.length]})}export function cycleContextStyle(e,r){if(r!=="context")return e;const t=ie,l=t.indexOf(e.segments[r].style??"both");return y(e,r,{style:t[(l+1)%t.length]})}export function cycleAlign(e){const r=L.indexOf(e.align);return{...e,align:L[(r+1)%L.length]}}export function togglePowerline(e){return{...e,powerline:{...e.powerline,enabled:!e.powerline.enabled}}}const k=["\uE0B0","\uE0B2","\uE0B4","\uE0B6"];export function cyclePowerlineGlyph(e){const r=e.powerline.separator??k[0],t=k.indexOf(r),l=k[(t+1)%k.length];return{...e,powerline:{...e.powerline,separator:l}}}export function cycleLogoColor(e){const r=x.indexOf(e.logoColor);return{...e,logoColor:x[(r+1)%x.length]}}export function cycleSeparator(e){const r=I.indexOf(e.separator);return{...e,separator:I[(r+1)%I.length]}}export function bumpRefreshInterval(e,r){return{...e,refreshInterval:Math.max(1,e.refreshInterval+r)}}export function setSegmentField(e,r,t,l){const h=l===""?{[t]:void 0}:{[t]:l};return y(e,r,h)}export function bumpBarCells(e,r){const t=Math.max(1,Math.min(40,e.bar.cells+r));return{...e,bar:{...e.bar,cells:t}}}export function cycleBarGlyph(e){const r=A.findIndex(l=>l.fill===e.bar.fill&&l.empty===e.bar.empty),t=A[(r+1)%A.length];return{...e,bar:{...e.bar,...t}}}export function cycleLabelSeparator(e){const r=P.indexOf(e.labelSeparator);return{...e,labelSeparator:P[(r+1)%P.length]}}export function clampCursor(e,r){const t=e.lines.length,l=Math.min(Math.max(r.row,0),t-1),h=e.lines[l]?.length??0,n=Math.min(Math.max(r.col,0),Math.max(0,h-1));return{row:l,col:n}}export function moveCursor(e,r,t,l){const h=e.lines.length;let n=Math.min(Math.max(r.row+t,0),h-1);for(;n!==r.row&&(e.lines[n]?.length??0)===0;)n-=Math.sign(n-r.row)||1;if((e.lines[n]?.length??0)===0)return r;const v=e.lines[n].length;let g=r.col+l;return g>=v&&(g=v-1),g<0&&(g=0),{row:n,col:g}}function se({line:e}){const r=re(e);return i(a,{children:r.map((t,l)=>i(a,{color:t.color?$(t.color):void 0,backgroundColor:t.backgroundColor?$(t.backgroundColor):void 0,bold:t.bold,dimColor:t.dim,children:t.text},l))})}function ue({segmentKey:e,seg:r,focused:t}){const l=`${r.enabled?"\u25CF":"\u25CB"}${r.icon?r.icon:""}${e}`;return i(a,{color:$(r.enabled?r.color:"gray"),bold:t,inverse:t,dimColor:!r.enabled,children:l})}function fe({initialConfig:e,projectPath:r,initialCursor:t}){const{exit:l}=X(),{stdout:h}=z(),[n,v]=b(e),[g,B]=b(t),[F,D]=b({lines:[]}),[J,T]=b(!1),[G,M]=b(null),[H,R]=b(!1),[m,C]=b(null),O=Math.max(60,h?.columns??100),f=n.lines[g.row]?.[g.col],p=s=>{v(s),T(!0),M(null)};q(()=>{const s=setTimeout(()=>{D(runPreviewLines(n,r,O))},60);return()=>clearTimeout(s)},[n,O,r]),U((s,u)=>{if(!H){if(m){if(u.escape){C(null);return}if(u.return){const{key:o,field:E,buf:K}=m;p(V=>setSegmentField(V,o,E,K)),C(null);return}if(u.backspace||u.delete){C({...m,buf:m.buf.slice(0,-1)});return}s&&!u.ctrl&&!u.meta&&C({...m,buf:m.buf+s});return}if(s==="q"){l();return}if(u.escape){l();return}if(u.upArrow){B(o=>moveCursor(n,o,-1,0));return}if(u.downArrow){B(o=>moveCursor(n,o,1,0));return}if(u.leftArrow){B(o=>moveCursor(n,o,0,-1));return}if(u.rightArrow){B(o=>moveCursor(n,o,0,1));return}if(!u.return){if(s==="B"){p(cycleBarGlyph);return}if(s==="L"){p(cycleLabelSeparator);return}if(s==="["){p(o=>bumpBarCells(o,-1));return}if(s==="]"){p(o=>bumpBarCells(o,1));return}if(f){if(s==="n"){C({key:f,field:"label",buf:n.segments[f].label??""});return}if(s==="f"){C({key:f,field:"format",buf:n.segments[f].format??""});return}switch(s.toLowerCase()){case" ":p(o=>toggleSegment(o,f));return;case"c":p(o=>cycleSegmentColor(o,f));return;case"b":p(o=>toggleSegmentBold(o,f));return;case"m":p(o=>toggleSegmentMerge(o,f));return;case"i":p(o=>cycleSegmentIcon(o,f));return;case"v":p(o=>cycleContextStyle(o,f));return;case"a":p(o=>cycleAlign(o));return;case"p":p(o=>togglePowerline(o));return;case"g":p(o=>cyclePowerlineGlyph(o));return;case"l":p(o=>cycleLogoColor(o));return;case"s":p(o=>cycleSeparator(o));return;case"r":D(runPreviewLines(n,r,O)),M(c("preview.reRendered"));return;case"w":(async()=>{R(!0);try{(n.source??"global")==="global"&&await ee(n),await Q(r,n),T(!1),M(c("preview.saved"))}catch(o){M(c("preview.writeFailed",{error:String(o)}))}finally{R(!1)}})();return;default:break}}}}});const d=f?n.segments[f]:void 0;return w(S,{flexDirection:"column",gap:0,children:[w(S,{children:[i(a,{bold:!0,color:"cyan",children:"weave statusline preview"}),w(a,{dimColor:!0,children:[" \u2014 ",_.basename(r)," "]}),i(a,{dimColor:!0,children:c("preview.headerMeta",{source:n.source??"global",refresh:n.refreshInterval,align:n.align,powerline:n.powerline.enabled?c("preview.on"):c("preview.off")})}),J&&i(a,{color:"yellow",children:c("preview.unsaved")})]}),i(S,{flexDirection:"column",borderStyle:"round",borderColor:"cyan",paddingX:1,marginY:0,children:F.error?i(a,{color:"red",children:c("preview.scriptError",{error:F.error})}):F.lines.length?F.lines.map((s,u)=>i(se,{line:s},u)):i(a,{dimColor:!0,children:c("preview.rendering")})}),w(S,{flexDirection:"column",children:[i(a,{dimColor:!0,children:c("preview.layoutHelp")}),n.lines.map((s,u)=>w(S,{gap:1,children:[i(a,{dimColor:!0,children:c("preview.rowLabel",{row:u+1})}),s.map((o,E)=>i(ue,{segmentKey:o,seg:n.segments[o],focused:g.row===u&&g.col===E},o))]},u))]}),w(S,{flexDirection:"column",gap:0,marginTop:1,children:[m?w(a,{children:[i(a,{bold:!0,color:"yellow",children:` ${m.key}.${m.field} `})," ",i(a,{children:m.buf}),i(a,{inverse:!0,children:" "}),i(a,{dimColor:!0,children:c("preview.editConfirm")})]}):d&&f?w(a,{children:[i(a,{bold:!0,inverse:!0,children:` ${f} `})," ",i(a,{dimColor:!0,children:c("preview.segDetail",{color:d.color,bold:d.bold?c("preview.on"):c("preview.off"),merge:d.merge?c("preview.on"):c("preview.off"),icon:d.icon||"\u2014",style:f==="context"?c("preview.styleSuffix",{style:d.style??"both"}):""})})]}):null,!m&&d&&f&&(d.label||d.format)?w(a,{dimColor:!0,children:[d.label?c("preview.labelValue",{value:`${d.label}${n.labelSeparator}`}):"",d.format?c("preview.formatValue",{value:d.format}):""]}):null,i(a,{dimColor:!0,children:c("preview.barLine",{cells:n.bar.cells,glyphs:`${n.bar.fill}${n.bar.empty}`,labelSep:JSON.stringify(n.labelSeparator)})}),i(a,{dimColor:!0,children:c("preview.keysHelp")}),G&&i(a,{color:"green",children:G}),H&&i(a,{color:"yellow",children:c("preview.writing")})]})]})}export async function runStatuslinePreview(e){const r=await Z(e),t=clampCursor(r,{row:0,col:0});await N(i(fe,{initialConfig:r,projectPath:e,initialCursor:t}),{exitOnCtrlC:!0}).waitUntilExit?.()}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weavecode/cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "CLI entry point for weave — parser, commands, and init executor",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -22,9 +22,9 @@
22
22
  "node": ">=22.5.0"
23
23
  },
24
24
  "dependencies": {
25
- "@weavecode/core": "^0.1.1",
26
- "@weavecode/harness": "^0.1.1",
27
- "@weavecode/server": "^0.1.1",
28
- "@weavecode/templates": "^0.1.1"
25
+ "@weavecode/core": "^0.1.2",
26
+ "@weavecode/harness": "^0.1.2",
27
+ "@weavecode/server": "^0.1.2",
28
+ "@weavecode/templates": "^0.1.2"
29
29
  }
30
30
  }
@@ -1 +1 @@
1
- import a from"node:path";import{lstat as g,readFile as f,readlink as m,access as y}from"node:fs/promises";const o="CLAUDE.md",u="AGENTS.md",p=".claude/helpers/statusline.cjs",w=".claude/settings.json";async function h(t){try{return await y(t),!0}catch{return!1}}async function l(t){try{if(!(await g(t)).isSymbolicLink())return"file";const n=a.resolve(a.dirname(t),await m(t));return await h(n)?"link":"dangling"}catch{return"absent"}}async function S(t){const s=a.join(t,u);if(await l(s)!=="file")return null;const n=(await f(s,"utf-8").catch(()=>"")).trim();return{id:"instruction-link-not-materialised",params:{agents:u,claude:o},ok:n!==o}}async function j(t){const s=await l(a.join(t,o)),n=await l(a.join(t,u));return s==="absent"||n==="absent"?null:{id:"instruction-files-duplicated",params:{claude:o,agents:u},ok:!(s==="file"&&n==="file")}}async function E(t){const s=[];for(const n of[o,u]){const e=await l(a.join(t,n));if(e==="dangling"){s.push({id:"instruction-link-dangling",params:{name:n},ok:!1});break}e==="link"&&s.push({id:"instruction-link-dangling",params:{name:n},ok:!0})}return s}function L(t){const s=/"([^"]+)"/.exec(t);if(s)return s[1];const n=t.trim().split(/\s+/),e=n[n.length-1];return e&&d(e).includes(p)?e:null}function d(t){return t.replace(/\\/g,"/")}async function b(t){const s=a.join(t,w);let n;try{n=JSON.parse(await f(s,"utf-8"))}catch{return[]}const e=n.statusLine;if(!e||typeof e!="object")return[];const r=e.command;if(typeof r!="string"||!d(r).includes(p))return[];const i=L(r);if(!i)return[{id:"statusline-path-unresolved",params:{command:r},ok:!1}];const c=[{id:"statusline-path-unresolved",params:{command:r},ok:!0}],k=a.resolve(t)+a.sep;return a.resolve(i).startsWith(k)?(c.push({id:"statusline-path-foreign",params:{path:i},ok:!0}),c.push({id:"statusline-script-missing",params:{path:i},ok:await h(i)}),c):(c.push({id:"statusline-path-foreign",params:{path:i},ok:!1}),c)}export async function checkHarness(t){const[s,n,e,r]=await Promise.all([S(t),j(t),E(t),b(t)]);return[s,n,...e,...r].filter(i=>i!==null)}
1
+ import i from"node:path";import{lstat as k,readFile as p,readlink as g,access as y}from"node:fs/promises";const c="CLAUDE.md",u="AGENTS.md",d=".claude/helpers/statusline.cjs",w=".claude/settings.json";async function f(n){try{return await y(n),!0}catch{return!1}}async function l(n){try{if(!(await k(n)).isSymbolicLink())return"file";const t=i.resolve(i.dirname(n),await g(n));return await f(t)?"link":"dangling"}catch{return"absent"}}async function j(n){const t=i.join(n,u);if(await l(t)!=="file")return null;const a=(await p(t,"utf-8").catch(()=>"")).trim();return{id:"instruction-link-not-materialised",params:{agents:u,claude:c},ok:a!==c}}async function b(n){const t=await l(i.join(n,c)),a=await l(i.join(n,u));return t==="absent"||a==="absent"?null:{id:"instruction-files-duplicated",params:{claude:c,agents:u},ok:!(t==="file"&&a==="file")}}async function v(n){const t=[];for(const a of[c,u]){const s=await l(i.join(n,a));if(s==="dangling"){t.push({id:"instruction-link-dangling",params:{name:a},ok:!1});break}s==="link"&&t.push({id:"instruction-link-dangling",params:{name:a},ok:!0})}return t}function L(n){const t=/"([^"]+)"/.exec(n);if(t)return t[1];const a=n.trim().split(/\s+/),s=a[a.length-1];return s&&m(s).includes(d)?s:null}function m(n){return n.replace(/\\/g,"/")}async function S(n){const t=i.join(n,w);let a;try{a=JSON.parse(await p(t,"utf-8"))}catch{return[]}const s=a.statusLine;if(!s||typeof s!="object")return[];const r=s.command;if(typeof r!="string"||!m(r).includes(d))return[];const e=L(r);if(!e)return[{id:"statusline-path-unresolved",params:{command:r},ok:!1}];const o=[{id:"statusline-path-unresolved",params:{command:r},ok:!0}],h=i.resolve(n)+i.sep;return i.resolve(e).startsWith(h)?(o.push({id:"statusline-path-foreign",params:{path:e},ok:!0}),o.push({id:"statusline-script-missing",params:{path:e},ok:await f(e)}),o):(o.push({id:"statusline-path-foreign",params:{path:e},ok:!1}),o)}export async function checkHarness(n){const[t,a,s,r]=await Promise.all([j(n),b(n),v(n),S(n)]);return[t,a,...s,...r].filter(e=>e!==null)}
@@ -1,7 +1,7 @@
1
1
  export { type InitOptions, type InitResult, type InitComponents, type Preset } from './types.js';
2
2
  export { type HooksConfig, type SkillsConfig, type CommandsConfig, type AgentsConfig, type MCPConfig } from './types.js';
3
3
  export type { HookRule, HookRuleSource, HookRuleFilter, HookRuleOrigin, HandlerConfig, HookDispatchStatus, HookDispatchMode, PluginRuleEntry, WeavePluginManifest, } from './types.js';
4
- export { HookRuleSchema, HookRuleSourceSchema, HookRuleFilterSchema, HookRuleOriginSchema, HandlerConfigSchema, HookDispatchStatusSchema, HookDispatchModeSchema, PluginRuleEntrySchema, WeavePluginManifestSchema, WEAVE_PLUGIN_MANIFEST, WEAVE_INJECTION_MARKER, CLAUDE_HOOK_EVENTS, INJECTABLE_HOOK_EVENTS, } from './types.js';
4
+ export { HookRuleSchema, HookRuleSourceSchema, HookRuleFilterSchema, HookRuleOriginSchema, HandlerConfigSchema, HookDispatchStatusSchema, HookDispatchModeSchema, PluginRuleEntrySchema, WeavePluginManifestSchema, WEAVE_PLUGIN_MANIFEST, CLAUDE_HOOK_EVENTS, INJECTABLE_HOOK_EVENTS, } from './types.js';
5
5
  export { InitOptionsSchema, PresetSchema, resolveComponents } from './types.js';
6
6
  export { normalizeHookRuleSource, hookSourceHarness } from './types.js';
7
7
  export { type Harness, type InstructionFile, HARNESS_EVENTS, HARNESS_KEYS, HARNESS_NAMES, HARNESS_EVENT_UNION, HARNESS_INSTRUCTION_FILES, INSTRUCTION_FILES, INJECTABLE_EVENTS, TITLE_EFFECTIVE_EVENTS, HARNESS_DIRS, HARNESS_LIFECYCLE, HARNESS_COMPACTION, HARNESS_SESSION_CONTROL, type HarnessCompaction, isHarness, } from './harness.js';
@@ -1 +1 @@
1
- export{HookRuleSchema,HookRuleSourceSchema,HookRuleFilterSchema,HookRuleOriginSchema,HandlerConfigSchema,HookDispatchStatusSchema,HookDispatchModeSchema,PluginRuleEntrySchema,WeavePluginManifestSchema,WEAVE_PLUGIN_MANIFEST,WEAVE_INJECTION_MARKER,CLAUDE_HOOK_EVENTS,INJECTABLE_HOOK_EVENTS}from"./types.js";export{InitOptionsSchema,PresetSchema,resolveComponents}from"./types.js";export{normalizeHookRuleSource,hookSourceHarness}from"./types.js";export{HARNESS_EVENTS,HARNESS_KEYS,HARNESS_NAMES,HARNESS_EVENT_UNION,HARNESS_INSTRUCTION_FILES,INSTRUCTION_FILES,INJECTABLE_EVENTS,TITLE_EFFECTIVE_EVENTS,HARNESS_DIRS,HARNESS_LIFECYCLE,HARNESS_COMPACTION,HARNESS_SESSION_CONTROL,isHarness}from"./harness.js";export{TERMINAL_LOCATOR_ENV,TERMINAL_LOCATOR_ENV_KEYS}from"./terminal.js";export{DEFAULT_COMPONENTS,FULL_COMPONENTS,MINIMAL_COMPONENTS}from"./types.js";export{DEFAULT_HOOKS,DEFAULT_SKILLS,DEFAULT_COMMANDS,DEFAULT_AGENTS,DEFAULT_MCP}from"./types.js";export{detectPlatform}from"./platform.js";export{checkHarness}from"./harness-checks.js";export{ensureDir,writeFileIfAbsent,fileExists}from"./utils/fs.js";export{logger,formatTable}from"./utils/logger.js";
1
+ export{HookRuleSchema,HookRuleSourceSchema,HookRuleFilterSchema,HookRuleOriginSchema,HandlerConfigSchema,HookDispatchStatusSchema,HookDispatchModeSchema,PluginRuleEntrySchema,WeavePluginManifestSchema,WEAVE_PLUGIN_MANIFEST,CLAUDE_HOOK_EVENTS,INJECTABLE_HOOK_EVENTS}from"./types.js";export{InitOptionsSchema,PresetSchema,resolveComponents}from"./types.js";export{normalizeHookRuleSource,hookSourceHarness}from"./types.js";export{HARNESS_EVENTS,HARNESS_KEYS,HARNESS_NAMES,HARNESS_EVENT_UNION,HARNESS_INSTRUCTION_FILES,INSTRUCTION_FILES,INJECTABLE_EVENTS,TITLE_EFFECTIVE_EVENTS,HARNESS_DIRS,HARNESS_LIFECYCLE,HARNESS_COMPACTION,HARNESS_SESSION_CONTROL,isHarness}from"./harness.js";export{TERMINAL_LOCATOR_ENV,TERMINAL_LOCATOR_ENV_KEYS}from"./terminal.js";export{DEFAULT_COMPONENTS,FULL_COMPONENTS,MINIMAL_COMPONENTS}from"./types.js";export{DEFAULT_HOOKS,DEFAULT_SKILLS,DEFAULT_COMMANDS,DEFAULT_AGENTS,DEFAULT_MCP}from"./types.js";export{detectPlatform}from"./platform.js";export{checkHarness}from"./harness-checks.js";export{ensureDir,writeFileIfAbsent,fileExists}from"./utils/fs.js";export{logger,formatTable}from"./utils/logger.js";
@@ -1 +1 @@
1
- import n from"node:os";import i from"node:path";export function detectPlatform(){const c=n.platform(),a=n.arch(),s=n.homedir();let e,o,r;switch(c){case"win32":e="windows",o=process.env.PSModulePath?"powershell":"cmd",r=process.env.APPDATA||i.join(s,"AppData","Roaming");break;case"darwin":e="darwin",o=process.env.SHELL?.includes("zsh")?"zsh":"bash",r=i.join(s,"Library","Application Support");break;default:e="linux",o=process.env.SHELL?.includes("zsh")?"zsh":process.env.SHELL?.includes("bash")?"bash":"sh",r=process.env.XDG_CONFIG_HOME||i.join(s,".config")}return{os:e,arch:a,nodeVersion:process.version,shell:o,homeDir:s,configDir:r}}
1
+ import n from"node:os";import i from"node:path";export function detectPlatform(){const c=n.platform(),a=n.arch(),e=n.homedir();let s,o,r;switch(c){case"win32":s="windows",o=process.env.PSModulePath?"powershell":"cmd",r=process.env.APPDATA||i.join(e,"AppData","Roaming");break;case"darwin":s="darwin",o=process.env.SHELL?.includes("zsh")?"zsh":"bash",r=i.join(e,"Library","Application Support");break;default:s="linux",o=process.env.SHELL?.includes("zsh")?"zsh":process.env.SHELL?.includes("bash")?"bash":"sh",r=process.env.XDG_CONFIG_HOME||i.join(e,".config")}return{os:s,arch:a,nodeVersion:process.version,shell:o,homeDir:e,configDir:r}}
@@ -432,14 +432,6 @@ export declare const HookRuleSchema: z.ZodObject<{
432
432
  export type HookRule = z.infer<typeof HookRuleSchema>;
433
433
  /** 插件包 manifest 文件名(约定位于插件根目录)。 */
434
434
  export declare const WEAVE_PLUGIN_MANIFEST = "weave-plugin.json";
435
- /**
436
- * weave 注入消息的来源标记(唯一事实源:server 的直投路径用它当前缀)。
437
- * 直投把消息写成语义上的「用户消息」——会话分不出是手打还是控制台注入,
438
- * 这个标记就是转录里唯一可见的凭据;`weave init` 生成的 CLAUDE.md 块用同一个
439
- * 常量向会话解释它的含义(会话要据此知道这条消息该怎么处理)。标记**只**加在
440
- * 直投这一条路径,中继/终端兜底/注入都不带。
441
- */
442
- export declare const WEAVE_INJECTION_MARKER = "[weave] ";
443
435
  /**
444
436
  * rules.json 的元素:完整 HookRule 去掉 id/projectId(加载器生成),
445
437
  * enabled 可省略(默认 true,但用户在 dashboard 的开关改动会被保留)。
@@ -1 +1 @@
1
- import{z as e}from"zod";import{HARNESS_EVENTS as i,HARNESS_NAMES as r,INJECTABLE_EVENTS as s}from"./harness.js";export const PresetSchema=e.enum(["minimal","default","full"]),InitComponentsSchema=e.object({settings:e.boolean(),skills:e.boolean(),commands:e.boolean(),agents:e.boolean(),helpers:e.boolean(),mcp:e.boolean(),claudeMd:e.boolean(),agentsMd:e.boolean()}),HooksConfigSchema=e.object({preToolUse:e.boolean(),postToolUse:e.boolean(),userPromptSubmit:e.boolean(),sessionStart:e.boolean(),stop:e.boolean(),stopFailure:e.boolean(),subagentStop:e.boolean(),subagentStart:e.boolean(),notification:e.boolean(),postToolUseFailure:e.boolean(),permissionRequest:e.boolean(),permissionDenied:e.boolean(),preCompact:e.boolean(),sessionEnd:e.boolean(),preModelSwitch:e.boolean(),timeout:e.number().default(5e3),continueOnError:e.boolean().default(!0)}),CLAUDE_HOOK_EVENTS=i.claude,INJECTABLE_HOOK_EVENTS=s.claude;const a=e.enum(r),l=e.enum([...r,"any"]);export const HookRuleSourceSchema=e.discriminatedUnion("kind",[e.object({kind:e.literal("hook-event"),harness:l,event:e.string().min(1)}),e.object({kind:e.literal("webhook"),routeId:e.string().min(1)}),e.object({kind:e.literal("claude-event"),event:e.string().min(1)})]);export function normalizeHookRuleSource(t){return t.kind==="claude-event"?{kind:"hook-event",harness:"claude",event:t.event}:t}export function hookSourceHarness(t){return t.kind==="claude-event"?"claude":t.kind==="hook-event"?t.harness:null}export const HookRuleFilterSchema=e.object({toolNames:e.array(e.string().min(1)).optional(),pathGlobs:e.array(e.string().min(1)).optional(),crossProjectOnly:e.boolean().optional()}),HandlerConfigSchema=e.discriminatedUnion("type",[e.object({type:e.literal("log")}),e.object({type:e.literal("webhook"),url:e.string().url(),secret:e.string().optional(),headers:e.record(e.string(),e.string()).optional()}),e.object({type:e.literal("inject"),template:e.string().min(1)}),e.object({type:e.literal("manual"),template:e.string().min(1)}),e.object({type:e.literal("plugin"),pluginId:e.string().min(1),handlerType:e.string().min(1),config:e.record(e.string(),e.unknown()).optional()})]),HookRuleOriginSchema=e.enum(["user","plugin","builtin"]),HookRuleSchema=e.object({id:e.string().min(1),name:e.string().min(1),enabled:e.boolean(),priority:e.number().int(),projectId:e.number().int().nullable(),source:HookRuleSourceSchema,filter:HookRuleFilterSchema.default({}),handler:HandlerConfigSchema,timeoutMs:e.number().int().positive().default(5e3),record:e.boolean().default(!0),origin:HookRuleOriginSchema.default("user"),pluginId:e.string().min(1).nullable().default(null)}),WEAVE_PLUGIN_MANIFEST="weave-plugin.json",WEAVE_INJECTION_MARKER="[weave] ",PluginRuleEntrySchema=HookRuleSchema.omit({id:!0,projectId:!0}).extend({enabled:e.boolean().optional(),priority:e.number().int().optional()}),WeavePluginManifestSchema=e.object({manifestVersion:e.literal(1),id:e.string().regex(/^[a-z][a-z0-9-]{0,63}$/),name:e.string().min(1),version:e.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/),description:e.string().optional(),author:e.string().optional(),engines:e.object({weave:e.string().optional()}).optional(),rules:e.array(e.string().min(1)).default([]),handlers:e.array(e.object({type:e.string().min(1),entry:e.string().min(1)})).default([]),requires:e.object({events:e.array(e.string().min(1)).optional()}).optional(),templates:e.object({skills:e.array(e.string().min(1)).optional(),commands:e.array(e.string().min(1)).optional(),agents:e.array(e.string().min(1)).optional()}).optional(),mcpServers:e.record(e.string(),e.unknown()).optional(),subscribe:e.object({events:e.array(e.string().min(1)),entry:e.string().min(1)}).optional(),statusline:e.object({entry:e.string().min(1)}).optional(),config:e.record(e.string(),e.unknown()).optional()}),HookDispatchStatusSchema=e.enum(["pending","injected","running","succeeded","failed","timeout"]),HookDispatchModeSchema=e.enum(["auto","manual"]),SkillsConfigSchema=e.object({core:e.boolean()}),CommandsConfigSchema=e.object({core:e.boolean()}),AgentsConfigSchema=e.object({core:e.boolean()}),MCPConfigSchema=e.object({weave:e.boolean(),autoStart:e.boolean().default(!1)}),RuntimeConfigSchema=e.object({initVersion:e.string(),initTimestamp:e.string(),preset:PresetSchema,harnesses:e.array(a).optional(),components:InitComponentsSchema,hooks:HooksConfigSchema.partial().optional(),mcp:MCPConfigSchema.partial().optional()}),PlatformInfoSchema=e.object({os:e.enum(["windows","darwin","linux"]),arch:e.enum(["x64","arm64"]),nodeVersion:e.string(),shell:e.enum(["powershell","cmd","bash","zsh","sh"]),homeDir:e.string(),configDir:e.string()}),InitOptionsSchema=e.object({targetDir:e.string().default(process.cwd()),force:e.boolean().default(!1),interactive:e.boolean().default(!0),preset:PresetSchema.default("default"),harnesses:e.array(a).optional(),components:InitComponentsSchema.partial().default({}),hooks:HooksConfigSchema.partial().default({}),skills:SkillsConfigSchema.partial().default({}),commands:CommandsConfigSchema.partial().default({}),agents:AgentsConfigSchema.partial().default({}),mcp:MCPConfigSchema.partial().default({})}),InitResultSchema=e.object({success:e.boolean(),platform:PlatformInfoSchema,created:e.object({directories:e.array(e.string()),files:e.array(e.string())}),skipped:e.array(e.string()),merged:e.array(e.string()),updated:e.array(e.string()),errors:e.array(e.string()),removed:e.array(e.string()),summary:e.object({skillsCount:e.number(),commandsCount:e.number(),agentsCount:e.number(),hooksEnabled:e.number()})}),MINIMAL_COMPONENTS={settings:!0,skills:!0,commands:!1,agents:!1,helpers:!1,mcp:!1,claudeMd:!0,agentsMd:!0},DEFAULT_COMPONENTS={settings:!0,skills:!0,commands:!1,agents:!1,helpers:!0,mcp:!0,claudeMd:!0,agentsMd:!0},FULL_COMPONENTS={settings:!0,skills:!0,commands:!0,agents:!0,helpers:!0,mcp:!0,claudeMd:!0,agentsMd:!0},DEFAULT_HOOKS={preToolUse:!0,postToolUse:!0,userPromptSubmit:!0,sessionStart:!0,stop:!0,stopFailure:!0,subagentStop:!0,subagentStart:!0,notification:!0,postToolUseFailure:!0,permissionRequest:!0,permissionDenied:!0,preCompact:!0,sessionEnd:!0,preModelSwitch:!0,timeout:5e3,continueOnError:!0},DEFAULT_SKILLS={core:!0},DEFAULT_COMMANDS={core:!0},DEFAULT_AGENTS={core:!0},DEFAULT_MCP={weave:!1,autoStart:!1};export function resolveComponents(t,o){const n=t==="minimal"?MINIMAL_COMPONENTS:t==="full"?FULL_COMPONENTS:DEFAULT_COMPONENTS;return o?{...n,...o}:{...n}}
1
+ import{z as e}from"zod";import{HARNESS_EVENTS as r,HARNESS_NAMES as a,INJECTABLE_EVENTS as s}from"./harness.js";export const PresetSchema=e.enum(["minimal","default","full"]),InitComponentsSchema=e.object({settings:e.boolean(),skills:e.boolean(),commands:e.boolean(),agents:e.boolean(),helpers:e.boolean(),mcp:e.boolean(),claudeMd:e.boolean(),agentsMd:e.boolean()}),HooksConfigSchema=e.object({preToolUse:e.boolean(),postToolUse:e.boolean(),userPromptSubmit:e.boolean(),sessionStart:e.boolean(),stop:e.boolean(),stopFailure:e.boolean(),subagentStop:e.boolean(),subagentStart:e.boolean(),notification:e.boolean(),postToolUseFailure:e.boolean(),permissionRequest:e.boolean(),permissionDenied:e.boolean(),preCompact:e.boolean(),sessionEnd:e.boolean(),preModelSwitch:e.boolean(),timeout:e.number().default(5e3),continueOnError:e.boolean().default(!0)}),CLAUDE_HOOK_EVENTS=r.claude,INJECTABLE_HOOK_EVENTS=s.claude;const i=e.enum(a),l=e.enum([...a,"any"]);export const HookRuleSourceSchema=e.discriminatedUnion("kind",[e.object({kind:e.literal("hook-event"),harness:l,event:e.string().min(1)}),e.object({kind:e.literal("webhook"),routeId:e.string().min(1)}),e.object({kind:e.literal("claude-event"),event:e.string().min(1)})]);export function normalizeHookRuleSource(n){return n.kind==="claude-event"?{kind:"hook-event",harness:"claude",event:n.event}:n}export function hookSourceHarness(n){return n.kind==="claude-event"?"claude":n.kind==="hook-event"?n.harness:null}export const HookRuleFilterSchema=e.object({toolNames:e.array(e.string().min(1)).optional(),pathGlobs:e.array(e.string().min(1)).optional(),crossProjectOnly:e.boolean().optional()}),HandlerConfigSchema=e.discriminatedUnion("type",[e.object({type:e.literal("log")}),e.object({type:e.literal("webhook"),url:e.string().url(),secret:e.string().optional(),headers:e.record(e.string(),e.string()).optional()}),e.object({type:e.literal("inject"),template:e.string().min(1)}),e.object({type:e.literal("manual"),template:e.string().min(1)}),e.object({type:e.literal("plugin"),pluginId:e.string().min(1),handlerType:e.string().min(1),config:e.record(e.string(),e.unknown()).optional()})]),HookRuleOriginSchema=e.enum(["user","plugin","builtin"]),HookRuleSchema=e.object({id:e.string().min(1),name:e.string().min(1),enabled:e.boolean(),priority:e.number().int(),projectId:e.number().int().nullable(),source:HookRuleSourceSchema,filter:HookRuleFilterSchema.default({}),handler:HandlerConfigSchema,timeoutMs:e.number().int().positive().default(5e3),record:e.boolean().default(!0),origin:HookRuleOriginSchema.default("user"),pluginId:e.string().min(1).nullable().default(null)}),WEAVE_PLUGIN_MANIFEST="weave-plugin.json",PluginRuleEntrySchema=HookRuleSchema.omit({id:!0,projectId:!0}).extend({enabled:e.boolean().optional(),priority:e.number().int().optional()}),WeavePluginManifestSchema=e.object({manifestVersion:e.literal(1),id:e.string().regex(/^[a-z][a-z0-9-]{0,63}$/),name:e.string().min(1),version:e.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/),description:e.string().optional(),author:e.string().optional(),engines:e.object({weave:e.string().optional()}).optional(),rules:e.array(e.string().min(1)).default([]),handlers:e.array(e.object({type:e.string().min(1),entry:e.string().min(1)})).default([]),requires:e.object({events:e.array(e.string().min(1)).optional()}).optional(),templates:e.object({skills:e.array(e.string().min(1)).optional(),commands:e.array(e.string().min(1)).optional(),agents:e.array(e.string().min(1)).optional()}).optional(),mcpServers:e.record(e.string(),e.unknown()).optional(),subscribe:e.object({events:e.array(e.string().min(1)),entry:e.string().min(1)}).optional(),statusline:e.object({entry:e.string().min(1)}).optional(),config:e.record(e.string(),e.unknown()).optional()}),HookDispatchStatusSchema=e.enum(["pending","injected","running","succeeded","failed","timeout"]),HookDispatchModeSchema=e.enum(["auto","manual"]),SkillsConfigSchema=e.object({core:e.boolean()}),CommandsConfigSchema=e.object({core:e.boolean()}),AgentsConfigSchema=e.object({core:e.boolean()}),MCPConfigSchema=e.object({weave:e.boolean(),autoStart:e.boolean().default(!1)}),RuntimeConfigSchema=e.object({initVersion:e.string(),initTimestamp:e.string(),preset:PresetSchema,harnesses:e.array(i).optional(),components:InitComponentsSchema,hooks:HooksConfigSchema.partial().optional(),mcp:MCPConfigSchema.partial().optional()}),PlatformInfoSchema=e.object({os:e.enum(["windows","darwin","linux"]),arch:e.enum(["x64","arm64"]),nodeVersion:e.string(),shell:e.enum(["powershell","cmd","bash","zsh","sh"]),homeDir:e.string(),configDir:e.string()}),InitOptionsSchema=e.object({targetDir:e.string().default(process.cwd()),force:e.boolean().default(!1),interactive:e.boolean().default(!0),preset:PresetSchema.default("default"),harnesses:e.array(i).optional(),components:InitComponentsSchema.partial().default({}),hooks:HooksConfigSchema.partial().default({}),skills:SkillsConfigSchema.partial().default({}),commands:CommandsConfigSchema.partial().default({}),agents:AgentsConfigSchema.partial().default({}),mcp:MCPConfigSchema.partial().default({})}),InitResultSchema=e.object({success:e.boolean(),platform:PlatformInfoSchema,created:e.object({directories:e.array(e.string()),files:e.array(e.string())}),skipped:e.array(e.string()),merged:e.array(e.string()),updated:e.array(e.string()),errors:e.array(e.string()),removed:e.array(e.string()),summary:e.object({skillsCount:e.number(),commandsCount:e.number(),agentsCount:e.number(),hooksEnabled:e.number()})}),MINIMAL_COMPONENTS={settings:!0,skills:!0,commands:!1,agents:!1,helpers:!1,mcp:!1,claudeMd:!0,agentsMd:!0},DEFAULT_COMPONENTS={settings:!0,skills:!0,commands:!1,agents:!1,helpers:!0,mcp:!0,claudeMd:!0,agentsMd:!0},FULL_COMPONENTS={settings:!0,skills:!0,commands:!0,agents:!0,helpers:!0,mcp:!0,claudeMd:!0,agentsMd:!0},DEFAULT_HOOKS={preToolUse:!0,postToolUse:!0,userPromptSubmit:!0,sessionStart:!0,stop:!0,stopFailure:!0,subagentStop:!0,subagentStart:!0,notification:!0,postToolUseFailure:!0,permissionRequest:!0,permissionDenied:!0,preCompact:!0,sessionEnd:!0,preModelSwitch:!0,timeout:5e3,continueOnError:!0},DEFAULT_SKILLS={core:!0},DEFAULT_COMMANDS={core:!0},DEFAULT_AGENTS={core:!0},DEFAULT_MCP={weave:!1,autoStart:!1};export function resolveComponents(n,o){const t=n==="minimal"?MINIMAL_COMPONENTS:n==="full"?FULL_COMPONENTS:DEFAULT_COMPONENTS;return o?{...t,...o}:{...t}}
@@ -1 +1 @@
1
- import{mkdir as i,readFile as a,writeFile as n,stat as u}from"node:fs/promises";import c from"node:path";export async function ensureDir(t){await i(t,{recursive:!0})}export async function writeFileIfAbsent(t,r,e){try{if(await a(t,"utf-8"),!e)return!1}catch{}return await ensureDir(c.dirname(t)),await n(t,r,"utf-8"),!0}export async function fileExists(t){try{return await u(t),!0}catch{return!1}}
1
+ import{mkdir as i,readFile as e,writeFile as n,stat as s}from"node:fs/promises";import c from"node:path";export async function ensureDir(t){await i(t,{recursive:!0})}export async function writeFileIfAbsent(t,r,a){try{if(await e(t,"utf-8"),!a)return!1}catch{}return await ensureDir(c.dirname(t)),await n(t,r,"utf-8"),!0}export async function fileExists(t){try{return await s(t),!0}catch{return!1}}
@@ -1,2 +1,2 @@
1
- const l={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",cyan:"\x1B[36m"};function e(o,n){return process.env.NO_COLOR?o:`${l[n]}${o}${l.reset}`}export const logger={info(o){console.log(e(o,"cyan"))},success(o){console.log(e(o,"green"))},warn(o){console.log(e(o,"yellow"))},error(o){console.error(e(o,"red"))},dim(o){console.log(e(o,"dim"))}};export function formatTable(o){const n=Math.max(...o.map(([r])=>r.length));return o.map(([r,c])=>` ${r.padEnd(n+2)}${c}`).join(`
1
+ const l={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",cyan:"\x1B[36m"};function o(e,n){return process.env.NO_COLOR?e:`${l[n]}${e}${l.reset}`}export const logger={info(e){console.log(o(e,"cyan"))},success(e){console.log(o(e,"green"))},warn(e){console.log(o(e,"yellow"))},error(e){console.error(o(e,"red"))},dim(e){console.log(o(e,"dim"))}};export function formatTable(e){const n=Math.max(...e.map(([r])=>r.length));return e.map(([r,c])=>` ${r.padEnd(n+2)}${c}`).join(`
2
2
  `)}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weavecode/core",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Core types, schemas, and utilities for weave",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,4 +1,14 @@
1
1
  import type { AssetSurface } from '../driver.js';
2
+ /**
3
+ * `~/.claude.json` 解析不了就拒写:那是 Claude Code 自己的运行时文件,里面还有
4
+ * weave 不认识的键,宁可报错也不冒毁掉的风险。
5
+ */
6
+ export declare class ClaudeJsonCorruptError extends Error {
7
+ constructor(message: string);
8
+ }
9
+ /** `~/.claude.json` 的整份读(含 MCP 之外的键);解析不了就抛,坏文件下任何
10
+ * 结论都不可信。 */
11
+ export declare function readClaudeJson(homedir: string): Promise<Record<string, unknown>>;
2
12
  /**
3
13
  * Claude Code 资产表面(批 4a 迁入):文件资产目标目录、skills 项目/全局根、
4
14
  * 用户级配置路径、路径归属与 watch 观测集——原 `install/file-assets.ts`、
@@ -1 +1,4 @@
1
- import e from"node:path";import{FILE_ASSET_SPECS as t}from"../shared/file-specs.js";export const CLAUDE_ASSETS={harness:"claude",targetDir(s,c,i,o){const r=t[s].dirs.claude;if(c==="user"){if(!r?.user)throw new Error(`"${s}" is project-scoped only (no user-level directory)`);return e.join(o,...r.user.split("/"))}if(!r?.project)throw new Error(`"${s}" has no Claude project surface`);return e.join(i,...r.project.split("/"))},projectSkillsDir:()=>".claude/skills",globalSkillsRoots:s=>[e.join(s,...".claude/skills".split("/"))],userConfigFile:s=>e.join(s,".claude","settings.json"),mcpScopes:()=>["project","user"],mcpDest:(s,c)=>s==="project"?".mcp.json":e.join(c,".claude.json"),pluginCacheDir:s=>e.join(s,".claude","plugins","cache"),classify(s){return s===".claude"||s.startsWith(".claude/")||s===".mcp.json"?!0:s.slice(s.lastIndexOf("/")+1)==="CLAUDE.md"},ignore(s){return s===".claude"||s.startsWith(".claude/")?s===".claude/projects"||s.startsWith(".claude/projects/")||s===".claude/cache"||s.startsWith(".claude/cache/"):s!==".mcp.json"&&s!=="CLAUDE.md"}};
1
+ import{readFile as j,writeFile as u}from"node:fs/promises";import o from"node:path";import{FILE_ASSET_SPECS as m}from"../shared/file-specs.js";const l=".mcp.json",p=".claude.json";export class ClaudeJsonCorruptError extends Error{constructor(r){super(r),this.name="ClaudeJsonCorruptError"}}function f(e){if(!e||e.includes("/")||e.includes("\\")||e.includes(".."))throw new Error(`Invalid asset name: "${e}"`)}async function d(e){try{const r=JSON.parse(await j(e,"utf-8"));return r&&typeof r=="object"?r:{}}catch{return{}}}export async function readClaudeJson(e){const r=o.join(e,p);let c;try{c=await j(r,"utf-8")}catch{return{}}let t;try{t=JSON.parse(c)}catch(s){throw new ClaudeJsonCorruptError(`~/.claude.json is not valid JSON \u2014 refusing to write: ${s instanceof Error?s.message:String(s)}`)}if(!t||typeof t!="object"||Array.isArray(t))throw new ClaudeJsonCorruptError("~/.claude.json is not a JSON object \u2014 refusing to write");return t}export const CLAUDE_ASSETS={harness:"claude",targetDir(e,r,c,t){const s=m[e].dirs.claude;if(r==="user"){if(!s?.user)throw new Error(`"${e}" is project-scoped only (no user-level directory)`);return o.join(t,...s.user.split("/"))}if(!s?.project)throw new Error(`"${e}" has no Claude project surface`);return o.join(c,...s.project.split("/"))},projectSkillsDir:()=>".claude/skills",globalSkillsRoots:e=>[o.join(e,...".claude/skills".split("/"))],userConfigFile:e=>o.join(e,".claude","settings.json"),mcpScopes:()=>["project","user"],mcpDest:(e,r)=>e==="project"?".mcp.json":o.join(r,".claude.json"),pluginCacheDir:e=>o.join(e,".claude","plugins","cache"),async mcpRead(e,r,c){if(e==="project")return(await d(o.join(r,l))).mcpServers??{};const t=(await readClaudeJson(c)).mcpServers;return!t||typeof t!="object"||Array.isArray(t)?{}:t},async mcpWrite(e,r,c,t,s){if(f(t),e==="project"){const i=o.join(r,l),a=await d(i);a.mcpServers={...a.mcpServers??{},[t]:s},await u(i,`${JSON.stringify(a,null,2)}
2
+ `,"utf-8");return}const n=await readClaudeJson(c);n.mcpServers={...n.mcpServers??{},[t]:s},await u(o.join(c,p),`${JSON.stringify(n,null,2)}
3
+ `,"utf-8")},async mcpRemove(e,r,c,t){f(t);const s=e==="project"?o.join(r,l):o.join(c,p),n=e==="project"?await d(s):await readClaudeJson(c),i=n.mcpServers??{};return t in i?(delete i[t],n.mcpServers=i,await u(s,`${JSON.stringify(n,null,2)}
4
+ `,"utf-8"),!0):!1},classify(e){return e===".claude"||e.startsWith(".claude/")||e===".mcp.json"?!0:e.slice(e.lastIndexOf("/")+1)==="CLAUDE.md"},ignore(e){return e===".claude"||e.startsWith(".claude/")?e===".claude/projects"||e.startsWith(".claude/projects/")||e===".claude/cache"||e.startsWith(".claude/cache/"):e!==".mcp.json"&&e!=="CLAUDE.md"}};
@@ -1,3 +1,4 @@
1
+ import { type Harness } from '@weavecode/core';
1
2
  import type { CaptureDeps, CaptureScriptHealth, CaptureState, CaptureSurface } from '../driver.js';
2
3
  /**
3
4
  * weave 采集集成(hook-handler 脚本 + settings hooks 组)的 claude 实现——
@@ -8,9 +9,10 @@ import type { CaptureDeps, CaptureScriptHealth, CaptureState, CaptureSurface } f
8
9
  /**
9
10
  * hook-handler 脚本(跨端契约正文见脚本头注释)。version 只作脚本内的 weave
10
11
  * 版本标记(`@version weave@<version>`,weave 特性文件的覆写判据),由调用方
11
- * 传入——harness 包不依赖 server(版本常量在那边)。
12
+ * 传入——harness 包不依赖 server(版本常量在那边)。harness = 这份脚本自己
13
+ * 归属的 harness:镜像里同时躺着同项目各 harness 的注入规则,脚本按此过滤。
12
14
  */
13
- export declare function generateHookHandler(version: string): string;
15
+ export declare function generateHookHandler(version: string, harness?: Harness): string;
14
16
  /**
15
17
  * weave 采集组的路径段判据:weave 的 hook 命令永远指向某个 `.claude/helpers/
16
18
  * hook-handler.cjs`(项目档与 user 档同形),命令含该段即 weave 组;用户
@@ -1,4 +1,4 @@
1
- import{homedir as u}from"node:os";import{access as w,mkdir as f,readFile as h,unlink as j,writeFile as v}from"node:fs/promises";import i from"node:path";import{HARNESS_DIRS as d,HARNESS_EVENTS as b,INJECTABLE_EVENTS as _,TERMINAL_LOCATOR_ENV_KEYS as T}from"@weavecode/core";import{CLAUDE_PROMPT_INBOX as m}from"./prompt-inbox.js";export function generateHookHandler(e){return`#!/usr/bin/env node
1
+ import{homedir as l}from"node:os";import{access as k,mkdir as E,readFile as f,unlink as A,writeFile as h}from"node:fs/promises";import o from"node:path";import{HARNESS_DIRS as d,HARNESS_EVENTS as C,INJECTABLE_EVENTS as S,TERMINAL_LOCATOR_ENV_KEYS as w}from"@weavecode/core";import{CLAUDE_PROMPT_INBOX as v}from"./prompt-inbox.js";export function generateHookHandler(e,t="claude"){return`#!/usr/bin/env node
2
2
  /**
3
3
  * weave hook-handler \u2014 collects Claude Code hook events into the global weave
4
4
  * data directory and renders locally-mirrored injections. No network, no
@@ -36,13 +36,14 @@ const TITLE_EVENTS = ['SessionStart', 'UserPromptSubmit'];
36
36
  // Terminal pane locator env (mirrors TERMINAL_LOCATOR_ENV_KEYS in @weavecode/core):
37
37
  // captured in the pane's own child process and reported on the inbox line's side
38
38
  // channel, so the daemon can address THIS session's pane exactly.
39
- const TERMINAL_ENV_KEYS = ${JSON.stringify(T)};
39
+ const TERMINAL_ENV_KEYS = ${JSON.stringify(w)};
40
40
  const INBOX_MAX_BYTES = 4 * 1024 * 1024;
41
41
  const INBOX_MAX_LINES = 1000;
42
42
  const OUTBOX_MAX_LINES = 200;
43
43
  const DEDUPE_WINDOW_MS = 60000;
44
44
  const DISPATCH_MARKER = '<!--weave-dispatch-->';
45
45
  const MIRROR_VERSION = 1;
46
+ const OWN_HARNESS = ${JSON.stringify(t)};
46
47
 
47
48
  // Ultimate safety net: never let this process outlive the hook window.
48
49
  const GUARD = setTimeout(function () { process.exit(0); }, HOOK_GUARD_MS);
@@ -79,9 +80,9 @@ function hooksDir() {
79
80
  // \u8BE5\u4F1A\u8BDD\u7684 hooks \u4E0E Bash\uFF09\uFF1Adaemon \u4FA7\u53EA\u653E\u5185\u5B58\u3001\u4E0D\u843D\u5E93\u4E0D\u8FDB UI \u2014\u2014 \u4E0A\u62A5\u8D70 inbox
80
81
  // \u884C\u7684\u65C1\u8DEF\u5B57\u6BB5\uFF08\u4E0D\u8FDB report/payload\uFF09\u3002
81
82
  function messagingEnv() {
82
- var sock = process.env.${m.socketEnv};
83
+ var sock = process.env.${v.socketEnv};
83
84
  if (!sock) return null;
84
- return { socket: sock, token: process.env.${m.tokenEnv} || null };
85
+ return { socket: sock, token: process.env.${v.tokenEnv} || null };
85
86
  }
86
87
 
87
88
  // \u7EC8\u7AEF\u628A\u300C\u672C pane\u300D\u5BFC\u51FA\u7684\u73AF\u5883\u53D8\u91CF\uFF08wezterm \u7B49\uFF09\u3002\u672C\u8FDB\u7A0B\u751F\u5728\u4F1A\u8BDD\u81EA\u5DF1\u7684 pane \u91CC\uFF0C
@@ -311,7 +312,7 @@ async function main() {
311
312
 
312
313
  // 1. Collection first: a kill mid-injection still leaves the event on disk.
313
314
  appendInbox(path.join(hooksDir(), 'inbox'), token, {
314
- source: 'claude',
315
+ source: OWN_HARNESS,
315
316
  eventType: eventType,
316
317
  sessionId: sessionId,
317
318
  cwd: parsed.cwd || projectDir,
@@ -334,7 +335,12 @@ async function main() {
334
335
  var dirty = false;
335
336
  for (var i = 0; i < mirror.rules.length; i++) {
336
337
  var rule = mirror.rules[i];
337
- if (!rule || !Array.isArray(rule.events) || rule.events.indexOf(eventType) === -1) continue;
338
+ if (!rule) continue;
339
+ // \u955C\u50CF\u6309\u9879\u76EE\u5206\u7247\u3001\u540C\u9879\u76EE\u5404 harness \u5171\u8BFB\u4E00\u4EFD\uFF0C\u6545\u89C4\u5219\u81EA\u5E26\u5F52\u5C5E\u7968\uFF08\u7F3A\u7701 = \u8001
340
+ // \u955C\u50CF/\u8001 daemon \u5199\u7684\u90A3\u79CD\uFF0C\u5F53\u5E74\u53EA\u6709 claude \u4F1A\u8FDB\u955C\u50CF\uFF09\u3002
341
+ var owner = rule.harness || 'claude';
342
+ if (owner !== 'any' && owner !== OWN_HARNESS) continue;
343
+ if (!Array.isArray(rule.events) || rule.events.indexOf(eventType) === -1) continue;
338
344
  if (rule.tools && (!toolName || rule.tools.indexOf(toolName) === -1)) continue;
339
345
  if (rule.globs && rule.globs.length > 0) {
340
346
  if (!filePath || !matchAnyGlob(filePath, rule.globs)) continue;
@@ -375,6 +381,6 @@ async function main() {
375
381
  }
376
382
 
377
383
  main().catch(function () { process.exit(0); });
378
- `}export const HOOK_HANDLER_MARKER=".claude/helpers/hook-handler.cjs";function l(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function k(e){return e.replace(/\\/g,"/")}export function groupIsWeave(e){if(!l(e))return!1;const t=e.hooks;return Array.isArray(t)?t.some(r=>l(r)&&typeof r.command=="string"&&k(r.command).includes(HOOK_HANDLER_MARKER)):!1}export function captureHookGroup(e,t){const r=`node "${k(t)}/hook-handler.cjs"`,n=!_.claude.includes(e);return[{matcher:"*",hooks:[{type:"command",command:r,...n?{async:!0}:{}}]}]}export function sweepWeaveHookEvents(e){if(!l(e))return;const t={};for(const[r,n]of Object.entries(e)){if(!Array.isArray(n)){t[r]=n;continue}const s=n.filter(a=>!groupIsWeave(a));s.length>0&&(t[r]=s)}return Object.keys(t).length>0?t:void 0}export function captureGroupsPresent(e){if(!l(e))return!1;const t=e.hooks;return l(t)?Object.values(t).some(r=>Array.isArray(r)&&r.some(groupIsWeave)):!1}function y(e){return i.join(e,d.claude.userDir,"settings.json")}function p(e){return i.join(e,d.claude.userDir,"helpers")}const E="@version weave@";async function N(e){try{return await w(e),!0}catch{return!1}}async function g(e){let t;try{t=await h(e,"utf-8")}catch{return{}}let r;try{r=JSON.parse(t)}catch{throw new Error(`user settings is not parseable JSON: ${e}`)}if(!l(r))throw new Error(`user settings is not a JSON object: ${e}`);return r}async function S(e){let t;try{t=await g(e)}catch{return}const r=sweepWeaveHookEvents(t.hooks);r===void 0?delete t.hooks:t.hooks=r,await f(i.dirname(e),{recursive:!0}),await v(e,JSON.stringify(t,null,2)+`
379
- `,"utf-8")}export async function readUserCapture(e={}){const t=e.home??u(),r=await g(y(t));return{installed:captureGroupsPresent(r),helperPresent:await N(i.join(p(t),"hook-handler.cjs"))}}export async function readScriptHealth(e={}){const t=e.home??u(),r=i.join(p(t),"hook-handler.cjs"),n=e.projectPath?i.join(e.projectPath,d.claude.projectDir,"helpers","hook-handler.cjs"):null,s=(await readUserCapture({home:t})).installed,a=s?"user":n?"project":"none",c=s?r:n??r;let o=null;try{o=await h(c,"utf-8")}catch{o=null}return{source:a,present:o!==null,weaveOwned:o!==null&&o.includes(E),generatedVersion:o?.match(/@version weave@(\S+)/)?.[1]??null,reportsInbox:o!==null&&o.includes(m.socketEnv),reportsPaneEnv:o!==null&&o.includes("terminalEnv()")}}export async function installUserCapture(e){const t=e.home??u(),r=p(t);await f(r,{recursive:!0}),await v(i.join(r,"hook-handler.cjs"),generateHookHandler(e.version),"utf-8");const n=y(t),s=await g(n),a=sweepWeaveHookEvents(s.hooks)??{};for(const c of b.claude){const o=a[c];a[c]=Array.isArray(o)?[...o,...captureHookGroup(c,r)]:captureHookGroup(c,r)}s.hooks=a,await f(i.dirname(n),{recursive:!0}),await v(n,JSON.stringify(s,null,2)+`
380
- `,"utf-8")}export async function uninstallUserCapture(e={}){const t=e.home??u();await S(y(t));const r=i.join(p(t),"hook-handler.cjs");try{(await h(r,"utf-8")).includes(E)&&await j(r)}catch{}}export async function stripProjectCapture(e){await S(i.join(e,d.claude.projectDir,"settings.json"))}export const CLAUDE_CAPTURE={harness:"claude",readUserCapture:e=>readUserCapture(e),installUserCapture:e=>installUserCapture(e),uninstallUserCapture:e=>uninstallUserCapture(e),stripProjectCapture,scriptHealth:e=>readScriptHealth(e)};
384
+ `}export const HOOK_HANDLER_MARKER=".claude/helpers/hook-handler.cjs";function c(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function D(e){return e.replace(/\\/g,"/")}export function groupIsWeave(e){if(!c(e))return!1;const t=e.hooks;return Array.isArray(t)?t.some(r=>c(r)&&typeof r.command=="string"&&D(r.command).includes(HOOK_HANDLER_MARKER)):!1}export function captureHookGroup(e,t){const r=`node "${D(t)}/hook-handler.cjs"`,u=!S.claude.includes(e);return[{matcher:"*",hooks:[{type:"command",command:r,...u?{async:!0}:{}}]}]}export function sweepWeaveHookEvents(e){if(!c(e))return;const t={};for(const[r,u]of Object.entries(e)){if(!Array.isArray(u)){t[r]=u;continue}const i=u.filter(s=>!groupIsWeave(s));i.length>0&&(t[r]=i)}return Object.keys(t).length>0?t:void 0}export function captureGroupsPresent(e){if(!c(e))return!1;const t=e.hooks;return c(t)?Object.values(t).some(r=>Array.isArray(r)&&r.some(groupIsWeave)):!1}function F(e){return o.join(e,d.claude.userDir,"settings.json")}function p(e){return o.join(e,d.claude.userDir,"helpers")}const y="@version weave@";async function j(e){try{return await k(e),!0}catch{return!1}}async function m(e){let t;try{t=await f(e,"utf-8")}catch{return{}}let r;try{r=JSON.parse(t)}catch{throw new Error(`user settings is not parseable JSON: ${e}`)}if(!c(r))throw new Error(`user settings is not a JSON object: ${e}`);return r}async function g(e){let t;try{t=await m(e)}catch{return}const r=sweepWeaveHookEvents(t.hooks);r===void 0?delete t.hooks:t.hooks=r,await E(o.dirname(e),{recursive:!0}),await h(e,JSON.stringify(t,null,2)+`
385
+ `,"utf-8")}export async function readUserCapture(e={}){const t=e.home??l(),r=await m(F(t));return{installed:captureGroupsPresent(r),helperPresent:await j(o.join(p(t),"hook-handler.cjs"))}}export async function readScriptHealth(e={}){const t=e.home??l(),r=o.join(p(t),"hook-handler.cjs"),u=e.projectPath?o.join(e.projectPath,d.claude.projectDir,"helpers","hook-handler.cjs"):null,i=(await readUserCapture({home:t})).installed,s=i?"user":u?"project":"none",a=i?r:u??r;let n=null;try{n=await f(a,"utf-8")}catch{n=null}return{source:s,present:n!==null,weaveOwned:n!==null&&n.includes(y),generatedVersion:n?.match(/@version weave@(\S+)/)?.[1]??null,reportsInbox:n!==null&&n.includes(v.socketEnv),reportsPaneEnv:n!==null&&n.includes("terminalEnv()")}}export async function installUserCapture(e){const t=e.home??l(),r=p(t);await E(r,{recursive:!0}),await h(o.join(r,"hook-handler.cjs"),generateHookHandler(e.version),"utf-8");const u=F(t),i=await m(u),s=sweepWeaveHookEvents(i.hooks)??{};for(const a of C.claude){const n=s[a];s[a]=Array.isArray(n)?[...n,...captureHookGroup(a,r)]:captureHookGroup(a,r)}i.hooks=s,await E(o.dirname(u),{recursive:!0}),await h(u,JSON.stringify(i,null,2)+`
386
+ `,"utf-8")}export async function uninstallUserCapture(e={}){const t=e.home??l();await g(F(t));const r=o.join(p(t),"hook-handler.cjs");try{(await f(r,"utf-8")).includes(y)&&await A(r)}catch{}}export async function stripProjectCapture(e){await g(o.join(e,d.claude.projectDir,"settings.json"))}export const CLAUDE_CAPTURE={harness:"claude",readUserCapture:e=>readUserCapture(e),installUserCapture:e=>installUserCapture(e),uninstallUserCapture:e=>uninstallUserCapture(e),stripProjectCapture,scriptHealth:e=>readScriptHealth(e)};
@@ -1 +1 @@
1
- import{existsSync as o}from"node:fs";import s from"node:path";const t=[".claude","CLAUDE.md"];function r(e){return t.some(n=>o(s.join(e,n)))}export const CLAUDE_DETECTOR={markers:t,present:r,detect:e=>({harness:"claude",present:r(e)})};
1
+ import{existsSync as o}from"node:fs";import n from"node:path";const r=[".claude","CLAUDE.md"];function t(e){return r.some(s=>o(n.join(e,s)))}export const CLAUDE_DETECTOR={markers:r,present:t,detect:e=>({harness:"claude",present:t(e)})};
@@ -1 +1 @@
1
- import{HARNESS_EVENTS as u}from"@weavecode/core";function p(o){try{const t=JSON.parse(o);return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function i(o,...t){for(const n of t)if(o[n]!=null)return o[n];return null}const d=[["toolName",["tool_name","toolName"]],["toolInput",["tool_input","toolInput"]],["toolResponse",["tool_response","toolResponse"]],["cwd",["cwd"]],["transcriptPath",["transcript_path","transcriptPath"]]],l=/^<\$\.([A-Za-z0-9_]+(?:\.[A-Za-z0-9_]+)*)>$/,f=4e3,_=200;function a(o){if(typeof o=="string")return o.length>f?`${o.slice(0,f)}\u2026`:o;if(Array.isArray(o))return o.slice(0,_).map(a);if(o&&typeof o=="object"){const t={};for(const[n,e]of Object.entries(o))t[n]=a(e);return t}return o}function y(o){const t={...o};for(const[n,e]of d)for(const s of e)s in t&&(t[s]=`<$.${n}>`);return t}export function expandPayloadRefs(o){const t=o.raw;if(!t||typeof t!="object"||Array.isArray(t))return o;const n={...t};for(const[e,s]of Object.entries(n)){const c=typeof s=="string"?l.exec(s):null;c&&(n[e]=g(o,c[1]))}return{...o,raw:n}}function g(o,t){let n=o;for(const e of t.split(".")){if(!n||typeof n!="object")return null;n=n[e]}return n??null}export class ClaudeEventSource{source="claude";events=u.claude;normalize(t,n){const e=p(t.payload),s=t.eventType||String(e.hook_event_name??"unknown"),c=t.sessionId??i(e,"session_id","sessionId"),r={eventType:s,toolName:i(e,"tool_name","toolName"),toolInput:a(i(e,"tool_input","toolInput")),toolResponse:a(i(e,"tool_response","toolResponse")),cwd:t.cwd??i(e,"cwd"),transcriptPath:i(e,"transcript_path","transcriptPath"),raw:y(e)};return{projectId:n,source:"claude",eventType:s,sessionId:c??void 0,payload:JSON.stringify(r)}}}export const CLAUDE_EVENT_SOURCE=new ClaudeEventSource;export function frameFacts(o){const t=o?.raw,n=t&&typeof t=="object"&&typeof t.agent_id=="string"?t.agent_id:void 0;let e;if(o?.eventType==="PostToolUse"&&o.toolName==="Agent"){const r=o.toolResponse;r?.isAsync&&typeof r.agentId=="string"&&(e=r.agentId)}let s;Array.isArray(t&&typeof t=="object"?t.background_tasks:void 0)&&(s=t.background_tasks.filter(r=>r&&typeof r.id=="string"&&typeof r.status=="string").map(r=>({id:r.id,status:r.status})));const c={};return n&&(c.agentId=n),e&&(c.spawnAgentId=e),s&&(c.backgroundTasks=s),c}
1
+ import{HARNESS_EVENTS as l}from"@weavecode/core";function u(e){try{const t=JSON.parse(e);return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function c(e,...t){for(const n of t)if(e[n]!=null)return e[n];return null}const f=[["toolName",["tool_name","toolName"]],["toolInput",["tool_input","toolInput"]],["toolResponse",["tool_response","toolResponse"]],["cwd",["cwd"]],["transcriptPath",["transcript_path","transcriptPath"]]],d=/^<\$\.([A-Za-z0-9_]+(?:\.[A-Za-z0-9_]+)*)>$/,p=4e3,y=200;function i(e){if(typeof e=="string")return e.length>p?`${e.slice(0,p)}\u2026`:e;if(Array.isArray(e))return e.slice(0,y).map(i);if(e&&typeof e=="object"){const t={};for(const[n,o]of Object.entries(e))t[n]=i(o);return t}return e}function _(e){const t={...e};for(const[n,o]of f)for(const r of o)r in t&&(t[r]=`<$.${n}>`);return t}export function expandPayloadRefs(e){const t=e.raw;if(!t||typeof t!="object"||Array.isArray(t))return e;const n={...t};for(const[o,r]of Object.entries(n)){const a=typeof r=="string"?d.exec(r):null;a&&(n[o]=g(e,a[1]))}return{...e,raw:n}}function g(e,t){let n=e;for(const o of t.split(".")){if(!n||typeof n!="object")return null;n=n[o]}return n??null}export class ClaudeEventSource{source="claude";events=l.claude;normalize(t,n){const o=u(t.payload),r=t.eventType||String(o.hook_event_name??"unknown"),a=t.sessionId??c(o,"session_id","sessionId"),s={eventType:r,toolName:c(o,"tool_name","toolName"),toolInput:i(c(o,"tool_input","toolInput")),toolResponse:i(c(o,"tool_response","toolResponse")),cwd:t.cwd??c(o,"cwd"),transcriptPath:c(o,"transcript_path","transcriptPath"),raw:_(o)};return{projectId:n,source:"claude",eventType:r,sessionId:a??void 0,payload:JSON.stringify(s)}}}export const CLAUDE_EVENT_SOURCE=new ClaudeEventSource;export function frameFacts(e){const t=e?.raw,n=t&&typeof t=="object"&&typeof t.agent_id=="string"?t.agent_id:void 0;let o;if(e?.eventType==="PostToolUse"&&e.toolName==="Agent"){const s=e.toolResponse;s?.isAsync&&typeof s.agentId=="string"&&(o=s.agentId)}let r;Array.isArray(t&&typeof t=="object"?t.background_tasks:void 0)&&(r=t.background_tasks.filter(s=>s&&typeof s.id=="string"&&typeof s.status=="string").map(s=>({id:s.id,status:s.status})));const a={};return n&&(a.agentId=n),o&&(a.spawnAgentId=o),r&&(a.backgroundTasks=r),a}
@@ -1,6 +1,7 @@
1
1
  import type { HarnessDriver } from '../driver.js';
2
2
  export { ClaudeEventSource, CLAUDE_EVENT_SOURCE, frameFacts, expandPayloadRefs } from './event-source.js';
3
3
  export type { ClaudeFrameFacts, FramePayloadLike } from './event-source.js';
4
+ export { CLAUDE_ASSETS, ClaudeJsonCorruptError, readClaudeJson } from './assets.js';
4
5
  export { CLAUDE_PLUGINS, createClaudePluginSurface, WEAVE_MARKETPLACE } from './plugins.js';
5
6
  export type { PluginExecutor, PluginExecResult } from './plugins.js';
6
7
  export { CLAUDE_PLUGIN_STATE } from './plugin-state.js';
@@ -10,13 +11,17 @@ export { CLAUDE_MESSAGING } from './messaging.js';
10
11
  export { CLAUDE_BLOCKING_PROMPT } from './questions.js';
11
12
  export { CLAUDE_PROMPT_RELAY } from './prompt.js';
12
13
  export { CLAUDE_PROMPT_INBOX } from './prompt-inbox.js';
14
+ export { CLAUDE_SIDE_QUESTION } from './side-question.js';
13
15
  export { interruptMarkerAt, currentModelAt, currentModeAt } from './transcript.js';
14
- export { modelAliasTargets, aliasOfModel, switchedModelOf, type ModelAliasTarget } from './model-aliases.js';
16
+ export { modelAliasTargets, aliasOfModel, startedModelOf, switchedModelOf, effortLevelOf, type ModelAliasTarget } from './model-aliases.js';
15
17
  export { resolveClaudePeer } from './peers.js';
16
18
  export { CLAUDE_CAPTURE, generateHookHandler, captureHookGroup, sweepWeaveHookEvents, groupIsWeave, captureGroupsPresent, readUserCapture, installUserCapture, uninstallUserCapture, stripProjectCapture, HOOK_HANDLER_MARKER, } from './capture.js';
17
19
  export { generateSettingsJson, mergeSettingsJson, stripWeaveSettings, type SettingsGeneratorInput, } from './settings-gen.js';
18
20
  export { generateMcpJson, mergeMcpJson, stripWeaveMcp, type McpGeneratorInput } from './mcp-gen.js';
19
21
  export { generateAutoMemoryHook } from './helpers-gen.js';
22
+ export { CLAUDE_STATUSLINE } from './statusline/surface.js';
23
+ export { generateStatuslineScript, type GenerateStatuslineOptions, } from './statusline/generator.js';
24
+ export * from './statusline/config.js';
20
25
  /**
21
26
  * Claude 接入模块的驱动:批 4a 补 assets、批 4b 补 events/resume、批 5 补
22
27
  * detect、批 3 补 plugins、P2 补 pluginState、session-orchestration 批 1 补
@@ -1 +1 @@
1
- import{CLAUDE_ASSETS as e}from"./assets.js";import{CLAUDE_CAPTURE as r}from"./capture.js";import{CLAUDE_EVENT_SOURCE as o}from"./event-source.js";import{CLAUDE_MESSAGING as t}from"./messaging.js";import{CLAUDE_PLUGINS as E}from"./plugins.js";import{CLAUDE_PLUGIN_STATE as p}from"./plugin-state.js";import{CLAUDE_BLOCKING_PROMPT as s}from"./questions.js";import{CLAUDE_RESUME as a}from"./resume.js";import{CLAUDE_DETECTOR as m}from"./detect.js";export{ClaudeEventSource,CLAUDE_EVENT_SOURCE,frameFacts,expandPayloadRefs}from"./event-source.js";export{CLAUDE_PLUGINS,createClaudePluginSurface,WEAVE_MARKETPLACE}from"./plugins.js";export{CLAUDE_PLUGIN_STATE}from"./plugin-state.js";export{CLAUDE_RESUME}from"./resume.js";export{CLAUDE_DETECTOR}from"./detect.js";export{CLAUDE_MESSAGING}from"./messaging.js";export{CLAUDE_BLOCKING_PROMPT}from"./questions.js";export{CLAUDE_PROMPT_RELAY}from"./prompt.js";export{CLAUDE_PROMPT_INBOX}from"./prompt-inbox.js";export{interruptMarkerAt,currentModelAt,currentModeAt}from"./transcript.js";export{modelAliasTargets,aliasOfModel,switchedModelOf}from"./model-aliases.js";export{resolveClaudePeer}from"./peers.js";export{CLAUDE_CAPTURE,generateHookHandler,captureHookGroup,sweepWeaveHookEvents,groupIsWeave,captureGroupsPresent,readUserCapture,installUserCapture,uninstallUserCapture,stripProjectCapture,HOOK_HANDLER_MARKER}from"./capture.js";export{generateSettingsJson,mergeSettingsJson,stripWeaveSettings}from"./settings-gen.js";export{generateMcpJson,mergeMcpJson,stripWeaveMcp}from"./mcp-gen.js";export{generateAutoMemoryHook}from"./helpers-gen.js";export const CLAUDE_DRIVER={id:"claude",displayName:"Claude Code",capabilities:["assets","events","resume","detect","plugins","pluginState","messaging","questions","capture"],assets:e,events:o,resume:a,detect:m,plugins:E,pluginState:p,messaging:t,questions:s,capture:r};
1
+ import{CLAUDE_ASSETS as e}from"./assets.js";import{CLAUDE_CAPTURE as r}from"./capture.js";import{CLAUDE_EVENT_SOURCE as o}from"./event-source.js";import{CLAUDE_MESSAGING as t}from"./messaging.js";import{CLAUDE_PLUGINS as s}from"./plugins.js";import{CLAUDE_PLUGIN_STATE as a}from"./plugin-state.js";import{CLAUDE_BLOCKING_PROMPT as E}from"./questions.js";import{CLAUDE_RESUME as p}from"./resume.js";import{CLAUDE_DETECTOR as m}from"./detect.js";import{CLAUDE_STATUSLINE as A}from"./statusline/surface.js";export{ClaudeEventSource,CLAUDE_EVENT_SOURCE,frameFacts,expandPayloadRefs}from"./event-source.js";export{CLAUDE_ASSETS,ClaudeJsonCorruptError,readClaudeJson}from"./assets.js";export{CLAUDE_PLUGINS,createClaudePluginSurface,WEAVE_MARKETPLACE}from"./plugins.js";export{CLAUDE_PLUGIN_STATE}from"./plugin-state.js";export{CLAUDE_RESUME}from"./resume.js";export{CLAUDE_DETECTOR}from"./detect.js";export{CLAUDE_MESSAGING}from"./messaging.js";export{CLAUDE_BLOCKING_PROMPT}from"./questions.js";export{CLAUDE_PROMPT_RELAY}from"./prompt.js";export{CLAUDE_PROMPT_INBOX}from"./prompt-inbox.js";export{CLAUDE_SIDE_QUESTION}from"./side-question.js";export{interruptMarkerAt,currentModelAt,currentModeAt}from"./transcript.js";export{modelAliasTargets,aliasOfModel,startedModelOf,switchedModelOf,effortLevelOf}from"./model-aliases.js";export{resolveClaudePeer}from"./peers.js";export{CLAUDE_CAPTURE,generateHookHandler,captureHookGroup,sweepWeaveHookEvents,groupIsWeave,captureGroupsPresent,readUserCapture,installUserCapture,uninstallUserCapture,stripProjectCapture,HOOK_HANDLER_MARKER}from"./capture.js";export{generateSettingsJson,mergeSettingsJson,stripWeaveSettings}from"./settings-gen.js";export{generateMcpJson,mergeMcpJson,stripWeaveMcp}from"./mcp-gen.js";export{generateAutoMemoryHook}from"./helpers-gen.js";export{CLAUDE_STATUSLINE}from"./statusline/surface.js";export{generateStatuslineScript}from"./statusline/generator.js";export*from"./statusline/config.js";export const CLAUDE_DRIVER={id:"claude",displayName:"Claude Code",capabilities:["assets","events","resume","detect","plugins","pluginState","messaging","questions","capture","statusline"],assets:e,events:o,resume:p,detect:m,plugins:s,pluginState:a,messaging:t,questions:E,capture:r,statusline:A};
@@ -1 +1 @@
1
- export function generateMcpJson(e){const r={};if(e.includeWeaveServer){const s=e.platform.os==="windows"?"cmd":"npx",c=e.platform.os==="windows"?["/c","npx","weave","mcp","start"]:["weave","mcp","start"];r.weave={command:s,args:c,env:{WEAVE_MCP:"true"}}}return{mcpServers:r}}export function mergeMcpJson(e,r){const s={...e},c=o(r.mcpServers)?r.mcpServers:{},n=o(s.mcpServers)?{...s.mcpServers}:{};for(const[t,p]of Object.entries(c))(t==="weave"||n[t]===void 0)&&(n[t]=p);return s.mcpServers=n,s}function o(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}export function stripWeaveMcp(e){const r={...e};if(o(r.mcpServers)){const s={...r.mcpServers};delete s.weave,Object.keys(s).length>0?r.mcpServers=s:delete r.mcpServers}return r}
1
+ export function generateMcpJson(e){const r={};if(e.includeWeaveServer){const t=e.platform.os==="windows"?"cmd":"npx",c=e.platform.os==="windows"?["/c","npx","weave","mcp","start"]:["weave","mcp","start"];r.weave={command:t,args:c,env:{WEAVE_MCP:"true"}}}return{mcpServers:r}}export function mergeMcpJson(e,r){const t={...e},c=o(r.mcpServers)?r.mcpServers:{},n=o(t.mcpServers)?{...t.mcpServers}:{};for(const[s,p]of Object.entries(c))(s==="weave"||n[s]===void 0)&&(n[s]=p);return t.mcpServers=n,t}function o(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}export function stripWeaveMcp(e){const r={...e};if(o(r.mcpServers)){const t={...r.mcpServers};delete t.weave,Object.keys(t).length>0?r.mcpServers=t:delete r.mcpServers}return r}
@@ -1,4 +1,4 @@
1
- import{HARNESS_LIFECYCLE as t,INJECTABLE_EVENTS as n}from"@weavecode/core";import{CLAUDE_PROMPT_INBOX as p}from"./prompt-inbox.js";import{CLAUDE_PROMPT_RELAY as s}from"./prompt.js";import{CLAUDE_RESUME as m}from"./resume.js";export const CLAUDE_IMAGE_ATTACH={composePrompt(o,E){const r=E.map(e=>e.path).join(`
1
+ import{HARNESS_LIFECYCLE as r,INJECTABLE_EVENTS as t}from"@weavecode/core";import{CLAUDE_PROMPT_INBOX as m}from"./prompt-inbox.js";import{CLAUDE_PROMPT_RELAY as a}from"./prompt.js";import{CLAUDE_RESUME as i}from"./resume.js";import{CLAUDE_SIDE_QUESTION as p}from"./side-question.js";export const CLAUDE_IMAGE_ATTACH={composePrompt(o,s){const E=s.map(e=>e.path).join(`
2
2
  `);return o?`${o}
3
3
 
4
- ${r}`:r}},CLAUDE_MESSAGING={harness:"claude",discovery:!0,prompt:s,promptInbox:p,inject:{rideEvents:n.claude},headless:m,idleSignals:[...t.claude.close,"SessionEnd"],imageAttach:CLAUDE_IMAGE_ATTACH};
4
+ ${E}`:E}},CLAUDE_MESSAGING={harness:"claude",discovery:!0,prompt:a,promptInbox:m,inject:{rideEvents:t.claude},headless:i,idleSignals:[...r.claude.close,"SessionEnd"],imageAttach:CLAUDE_IMAGE_ATTACH,sideQuestion:p};