@ethan.carter/autocode 0.0.0-stage → 0.0.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 (117) hide show
  1. package/README.md +50 -3
  2. package/dist/chunk-2NNMZN27.js +11 -0
  3. package/dist/chunk-3ELWKXKT.js +1 -0
  4. package/dist/chunk-5YDARJ3U.js +1 -0
  5. package/dist/chunk-6FXKMMUR.js +1 -0
  6. package/dist/chunk-7F6366VK.js +1 -0
  7. package/dist/chunk-7LS5USHJ.js +2 -0
  8. package/dist/chunk-AMOK3G6D.js +1 -0
  9. package/dist/chunk-ATISEBEN.js +1 -0
  10. package/dist/chunk-AXRTYMYP.js +1 -0
  11. package/dist/chunk-BD2OOWDK.js +44 -0
  12. package/dist/chunk-BHULUCLO.js +221 -0
  13. package/dist/chunk-CBLU2NBO.js +3 -0
  14. package/dist/chunk-CLIIIRAX.js +1 -0
  15. package/dist/chunk-D6W6GJCQ.js +1 -0
  16. package/dist/chunk-DN5PIQX3.js +11 -0
  17. package/dist/chunk-EKLYVI5Z.js +3 -0
  18. package/dist/chunk-EOSGSOQ7.js +7 -0
  19. package/dist/chunk-F5O3VA3Z.js +1 -0
  20. package/dist/chunk-F7GM3KBX.js +7 -0
  21. package/dist/chunk-G3XA757G.js +6 -0
  22. package/dist/chunk-H35Q44QX.js +1 -0
  23. package/dist/chunk-HO3X6IFQ.js +8 -0
  24. package/dist/chunk-IAJUZSL4.js +5 -0
  25. package/dist/chunk-ILMLK7WM.js +1 -0
  26. package/dist/chunk-JVGNBSF4.js +1 -0
  27. package/dist/chunk-KKQQYXWN.js +1 -0
  28. package/dist/chunk-L4FTN2JM.js +10 -0
  29. package/dist/chunk-LDYALFZI.js +1 -0
  30. package/dist/chunk-LOULA2VD.js +7 -0
  31. package/dist/chunk-LVFFUKWY.js +1 -0
  32. package/dist/chunk-LVGVTFEP.js +6 -0
  33. package/dist/chunk-MHDSNQAC.js +2 -0
  34. package/dist/chunk-MR7DHACF.js +1 -0
  35. package/dist/chunk-MZ4HQDSJ.js +1 -0
  36. package/dist/chunk-NZSOD6C5.js +1 -0
  37. package/dist/chunk-OP2B3OCA.js +1 -0
  38. package/dist/chunk-PAVENFRW.js +1 -0
  39. package/dist/chunk-PWGSXL3V.js +1 -0
  40. package/dist/chunk-QIP56TP2.js +1 -0
  41. package/dist/chunk-S5M23OZE.js +4 -0
  42. package/dist/chunk-T7ZEXPKN.js +1 -0
  43. package/dist/chunk-TFNFQXFH.js +3 -0
  44. package/dist/chunk-TK24OTGL.js +3 -0
  45. package/dist/chunk-U5QH6OX7.js +5 -0
  46. package/dist/chunk-UCR2PGFQ.js +1 -0
  47. package/dist/chunk-UPEQGG6F.js +1 -0
  48. package/dist/chunk-WGKUZHE7.js +25 -0
  49. package/dist/chunk-WWJJMIQL.js +4 -0
  50. package/dist/chunk-XUSV3KOD.js +1 -0
  51. package/dist/chunk-ZXRDZ4KX.js +6 -0
  52. package/dist/hosts/templates/en/commands/auto-check.ejs +25 -0
  53. package/dist/hosts/templates/en/commands/auto-feat.ejs +69 -0
  54. package/dist/hosts/templates/en/commands/auto-fix.ejs +69 -0
  55. package/dist/hosts/templates/en/commands/auto-init.ejs +22 -0
  56. package/dist/hosts/templates/en/commands/auto-wiki.ejs +42 -0
  57. package/dist/hosts/templates/en/marker-block.ejs +6 -0
  58. package/dist/hosts/templates/en/skill-graph.ejs +30 -0
  59. package/dist/hosts/templates/en/skill-query.ejs +34 -0
  60. package/dist/hosts/templates/en/skill.ejs +54 -0
  61. package/dist/hosts/templates/zh/commands/auto-check.ejs +25 -0
  62. package/dist/hosts/templates/zh/commands/auto-feat.ejs +69 -0
  63. package/dist/hosts/templates/zh/commands/auto-fix.ejs +69 -0
  64. package/dist/hosts/templates/zh/commands/auto-init.ejs +22 -0
  65. package/dist/hosts/templates/zh/commands/auto-wiki.ejs +42 -0
  66. package/dist/hosts/templates/zh/marker-block.ejs +6 -0
  67. package/dist/hosts/templates/zh/skill-graph.ejs +30 -0
  68. package/dist/hosts/templates/zh/skill-query.ejs +34 -0
  69. package/dist/hosts/templates/zh/skill.ejs +54 -0
  70. package/dist/index.js +2 -0
  71. package/dist/prompts/templates/en/intent/check.ejs +17 -0
  72. package/dist/prompts/templates/en/intent/wiki.ejs +26 -0
  73. package/dist/prompts/templates/en/prompts/change-acquire.ejs +15 -0
  74. package/dist/prompts/templates/en/prompts/change-integrate-feat.ejs +59 -0
  75. package/dist/prompts/templates/en/prompts/change-integrate-fix.ejs +57 -0
  76. package/dist/prompts/templates/en/prompts/change-plan.ejs +37 -0
  77. package/dist/prompts/templates/en/prompts/domain-edit.ejs +1 -0
  78. package/dist/prompts/templates/en/prompts/domain-verify.ejs +14 -0
  79. package/dist/prompts/templates/en/prompts/domain.ejs +85 -0
  80. package/dist/prompts/templates/en/prompts/glossary-example.ejs +21 -0
  81. package/dist/prompts/templates/en/prompts/module-names.ejs +14 -0
  82. package/dist/prompts/templates/en/prompts/pipeline-material.ejs +18 -0
  83. package/dist/prompts/templates/en/prompts/structure.ejs +33 -0
  84. package/dist/prompts/templates/en/prompts/unit-edit.ejs +1 -0
  85. package/dist/prompts/templates/en/prompts/unit-retry.ejs +14 -0
  86. package/dist/prompts/templates/en/prompts/unit.ejs +100 -0
  87. package/dist/prompts/templates/en/prompts/wiki-evidence.ejs +22 -0
  88. package/dist/prompts/templates/en/prompts/wiki-plan.ejs +28 -0
  89. package/dist/prompts/templates/en/prompts/wiki-review.ejs +18 -0
  90. package/dist/prompts/templates/en/prompts/wiki-scope.ejs +28 -0
  91. package/dist/prompts/templates/en/render/domain.md.ejs +66 -0
  92. package/dist/prompts/templates/en/render/unit.md.ejs +65 -0
  93. package/dist/prompts/templates/en/system/agent.ejs +49 -0
  94. package/dist/prompts/templates/zh/intent/check.ejs +17 -0
  95. package/dist/prompts/templates/zh/intent/wiki.ejs +26 -0
  96. package/dist/prompts/templates/zh/prompts/change-acquire.ejs +15 -0
  97. package/dist/prompts/templates/zh/prompts/change-integrate-feat.ejs +59 -0
  98. package/dist/prompts/templates/zh/prompts/change-integrate-fix.ejs +57 -0
  99. package/dist/prompts/templates/zh/prompts/change-plan.ejs +37 -0
  100. package/dist/prompts/templates/zh/prompts/domain-edit.ejs +1 -0
  101. package/dist/prompts/templates/zh/prompts/domain-verify.ejs +14 -0
  102. package/dist/prompts/templates/zh/prompts/domain.ejs +86 -0
  103. package/dist/prompts/templates/zh/prompts/glossary-example.ejs +21 -0
  104. package/dist/prompts/templates/zh/prompts/module-names.ejs +14 -0
  105. package/dist/prompts/templates/zh/prompts/pipeline-material.ejs +18 -0
  106. package/dist/prompts/templates/zh/prompts/structure.ejs +33 -0
  107. package/dist/prompts/templates/zh/prompts/unit-edit.ejs +1 -0
  108. package/dist/prompts/templates/zh/prompts/unit-retry.ejs +14 -0
  109. package/dist/prompts/templates/zh/prompts/unit.ejs +101 -0
  110. package/dist/prompts/templates/zh/prompts/wiki-evidence.ejs +22 -0
  111. package/dist/prompts/templates/zh/prompts/wiki-plan.ejs +28 -0
  112. package/dist/prompts/templates/zh/prompts/wiki-review.ejs +18 -0
  113. package/dist/prompts/templates/zh/prompts/wiki-scope.ejs +28 -0
  114. package/dist/prompts/templates/zh/render/domain.md.ejs +66 -0
  115. package/dist/prompts/templates/zh/render/unit.md.ejs +65 -0
  116. package/dist/prompts/templates/zh/system/agent.ejs +37 -0
  117. package/package.json +27 -4
package/README.md CHANGED
@@ -1,3 +1,50 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
1
+ # autocode
2
+
3
+ 读代码、写业务文档的 agent。它不写代码,只回答「这段代码在业务上是什么、为什么这么做」,
4
+ 并把答案维护成一套随代码演进的知识库。
5
+
6
+ ## 运行要求
7
+
8
+ - **Node.js ≥ 22.5**(用到内置 `node:sqlite`)
9
+ - 本机已安装并登录 **Claude Code** 或 **Codex** CLI —— autocode 借用它们完成分析,
10
+ 不需要你另外配置 API Key,代码也不出本机。
11
+
12
+ ## 安装
13
+
14
+ ```
15
+ npm install -g @ethan.carter/autocode
16
+ autocode --help
17
+ ```
18
+
19
+ 升级:`npm install -g @ethan.carter/autocode@latest`。
20
+
21
+ ## 上手
22
+
23
+ ```
24
+ cd <你的项目>
25
+ autocode init # 建图 + 生成骨架,全程零 AI 调用
26
+ autocode wiki # 生成/更新知识库
27
+ autocode check # 体检:锚点失效、文档孤儿、结论矛盾
28
+ ```
29
+
30
+ `wiki` 接受自然语言,例如:
31
+
32
+ ```
33
+ autocode wiki "只重写工单创建这条能力"
34
+ autocode wiki "先别改文件,告诉我这次会动哪些"
35
+ ```
36
+
37
+ 产物落在项目的 `.autocode/` 下,代码图落在 `.autocode-graph/`(建议 git 忽略)。
38
+
39
+ ## 费用提示
40
+
41
+ `init` 与 `check` 不花钱。`wiki` 会调用本机 AI CLI,按你自己的订阅计费;
42
+ 执行前会回显「预计影响多少篇、预计调用多少次」,加上「先别改文件」即可只看计划不落盘。
43
+
44
+ ## 已知边界
45
+
46
+ - 入口自动识别覆盖 Go(gin)、TS/JS(Express 系与前端路由)、Python(Django / Flask / FastAPI)、
47
+ Java(Spring)。其它框架可在 `.autocode/config.yaml` 的 `entries.manual` 里手工声明入口。
48
+ - 知识库是 AI 产出:结论都挂了代码锚点便于核对,拿不准的地方它会提问而不是编造,
49
+ 但**重要结论仍建议回代码确认一次**。
50
+ - 运行时会打印一行 `node:sqlite` 的 ExperimentalWarning,不影响使用。
@@ -0,0 +1,11 @@
1
+ import{a as S,b as Q,c as E}from"./chunk-G3XA757G.js";import{a as y,b as x,c as T}from"./chunk-OP2B3OCA.js";import{A as v,B as C,C as w}from"./chunk-CBLU2NBO.js";import{a as f}from"./chunk-XUSV3KOD.js";function j(e){return(o,s)=>e(o,s)}f(j,"translateWith");function B(e){let{counts:o}=e;return o.done+o.failed+o.skipped+o.deferred+o.pending===0&&e.changes.length===0&&!e.stoppedBy}f(B,"isNoop");function I(e,o){let s=e.layers;if(!s||s.total===0)return"";let t=o("agent.wiki.layers",{ready:s.ready,total:s.total,threshold:s.threshold.toFixed(2)});return s.skipped>0?t+o("agent.wiki.layersSkipped",{skipped:s.skipped}):t}f(I,"layersLine");function q(e,o,s){let t=j(s),r=e.pipeline;if(r?.empty&&e.changes.length===0)return S([{key:"result",lines:[t("agent.wiki.pipelineEmpty",{reason:r.scope.reason||"\u2014"})]},{key:"changes",lines:[]},{key:"skippedQuestions",lines:[]},{key:"newQuestions",lines:[]},{key:"next",lines:[`- ${t("agent.wiki.nextEmpty")}`]}],o);if(B(e))return S([{key:"result",lines:[t("agent.wiki.noop")+I(e,t)]},{key:"changes",lines:[]},{key:"skippedQuestions",lines:[]},{key:"newQuestions",lines:[]},{key:"next",lines:[`- ${t("agent.wiki.nextNoop")}`]}],o);let h=e.changes.filter(n=>n.action==="added").length,g=e.changes.filter(n=>n.action==="updated").length,p=t("agent.wiki.result",{done:e.counts.done,added:h,updated:g,failed:e.counts.failed,deferred:e.counts.deferred,calls:e.cost.calls,usd:E(e.cost.usd)});e.questionHousekeeping&&(e.questionHousekeeping.merged>0||e.questionHousekeeping.deleted>0)&&(p+=t("agent.wiki.housekeeping",e.questionHousekeeping)),e.stoppedBy&&(p+=t("agent.wiki.stopped",{reason:e.stoppedBy})),e.timing&&(p+=t("agent.wiki.timing",{duration:D(e.timing.wallMs),retries:e.timing.retries,peak:e.timing.peakConcurrency})),r&&(p+=t("agent.wiki.pipeline",{rounds:r.rounds,units:r.scope.units.length,domains:r.scope.domains.length,creates:r.scope.creates.length})),p+=I(e,t),e.heavyCoercions&&e.heavyCoercions.length>0&&(p+=t("agent.wiki.coercions",{count:e.heavyCoercions.length,targets:e.heavyCoercions.map(n=>n.taskTarget).join(", ")}));let $=[...e.changes.map(n=>{let u=r?.edits.find(k=>k.path===n.path),i=u&&u.sections.length>0?t("agent.wiki.sections",{sections:u.sections.map(k=>k.name).join("\u3001")}):"";return`- ${Q(n.path)} \xB7 ${t(`agent.action.${n.action}`)} \xB7 ${n.summary}${i}`}),...e.failures.map(n=>`- ${n.taskType} ${n.taskTarget} \xB7 ${t("agent.action.failed")} \xB7 ${n.error}`)],l=[];for(let n of e.skippedQuestions){let u=n.path?` \xB7 ${Q(n.path)}`:"";l.push(`- ${n.questionId??"?"} \xB7 ${n.subject} \xB7 ${n.severity}${u}`),n.context&&l.push(` ${t("agent.question.context",{context:n.context})}`);let i=n.options&&n.options.length>0?n.options.join(" / "):t("agent.question.free");l.push(` ${t("agent.question.options",{options:i})}`)}l.length>0&&l.push(t("agent.skipped.note"));let c=e.newQuestions.filter(n=>!e.skippedQuestions.some(u=>u.questionId===n.questionId)).map(n=>`- ${n.questionId} \xB7 ${n.subject} \xB7 ${n.severity} \xB7 ${Q(n.path)}`),a=[];for(let n of r?.review.filter(u=>!u.satisfied)??[])a.push(`- ${t("agent.wiki.unmet",{requirement:n.requirement,gap:n.gap||"\u2014"})}`);return(e.skippedQuestions.length>0||c.length>0)&&a.push(`- ${t("agent.wiki.nextAnswer")}`),a.push(`- ${t("agent.wiki.nextRerun")}`),e.graphUnavailable&&a.push(`- ${t("agent.graphUnavailable")}`),e.counts.failed>0&&a.push(`- ${t("agent.wiki.nextLogs",{runId:e.runId})}`),S([{key:"result",lines:[p]},{key:"changes",lines:$},{key:"skippedQuestions",lines:l},{key:"newQuestions",lines:c},{key:"next",lines:a}],o)}f(q,"renderWikiRun");function R(e,o,s){let t=j(s);return S([{key:"result",lines:[t("agent.wiki.dryRun",{count:e.length})]},{key:"changes",lines:e.map(r=>`- ${r} \xB7 ${t("agent.wiki.willUpdate")}`)},{key:"skippedQuestions",lines:[]},{key:"newQuestions",lines:[]},{key:"next",lines:[`- ${t("agent.wiki.nextDryRun")}`]}],o)}f(R,"renderWikiDryRun");function D(e){let o=Math.round(e/1e3),s=Math.floor(o/60);return s>0?`${s}m${String(o%60).padStart(2,"0")}s`:`${o}s`}f(D,"formatDuration");async function _(e,o,s,t){let r=T(!!e.json,!!s.stdout.isTTY),h="wiki",g=await import("./chunk-BHULUCLO.js"),p=s.cwd(),$=(await g.loadConfig(p).catch(()=>null))?.language??"zh",l=g.translator($);if(e.check){if(o&&o.trim().length>0||e.scope!==void 0)return s.stderr.write(l("cli.usage.wikiCheck")+`
2
+ `),2;let{runCheckCommand:i}=await import("./chunk-LOULA2VD.js");return i({...e,check:!1,fix:!0},void 0,s)}if(e.scope!==void 0){if(o&&o.trim().length>0||t)return s.stderr.write(l("cli.usage.wikiScope")+`
3
+ `),2;let i=await g.resolveScopeDocuments(p,e.scope);if(i.unknown.length>0||i.documents.length===0)return s.stderr.write(l("cli.usage.wikiScopeUnknown",{items:i.unknown.join(", ")||e.scope})+`
4
+ `),2;t=new Set(i.documents)}let c=r==="tty"?await(await import("./chunk-JVGNBSF4.js")).mountWikiFlow(l,(await g.loadConfig(p).catch(()=>null))?.budget.max??0):null,a;try{a=await g.runWiki(p,o,t?{documents:t}:{},{onStage:c?i=>c.setStage(i):void 0,onQueue:c?i=>c.setTotal(i):void 0,onTaskStart:c?i=>c.startTask(i.id,`${i.type} ${i.target}`):void 0,onTaskFinish:c?(i,k,b)=>c.finishTask(i.id,k,b):void 0})}finally{c?.stop()}if(a.kind==="busy"){let i=a.at?new Date(a.at):null,k=l("run.busy",{owner:a.owner,pid:String(a.pid??"?"),since:i?i.toLocaleTimeString("zh-CN",{hour12:!1}):"?",minutes:i?String(Math.max(0,Math.round((Date.now()-i.getTime())/6e4))):"?"});return r==="json"?s.stdout.write(x(y(h,{problems:[{code:"run-busy",message:k}]}))+`
5
+ `):s.stderr.write(k+`
6
+ `),2}if(r!=="tty"&&a.kind!=="unresolved"){let i=g.openStateDb(p);try{g.recordEcho(i,a.echoLines)}finally{i.close()}}if(a.kind==="unresolved"){let i=`\u65E0\u6CD5\u89E3\u6790\u6307\u4EE4:${a.reason}
7
+ \u5EFA\u8BAE:${a.suggestion}`;return r==="json"?s.stdout.write(x(y(h,{problems:[{code:"intent-unresolved",message:i}]}))+`
8
+ `):s.stderr.write(i+`
9
+ `),2}if(a.kind==="dry-run")return r==="json"?s.stdout.write(x(y(h,{data:{echo:a.echoLines,affected:a.affected,dryRun:!0}}))+`
10
+ `):s.stdout.write(R(a.affected,$,l)),0;let{summary:d}=a,n=d.counts.failed>0?1:0;if(r==="json")return s.stdout.write(x(y(h,{data:{echo:a.echoLines,counts:d.counts,cost:d.cost,newQuestionIds:d.newQuestionIds,skippedQuestions:d.skippedQuestions,...d.stoppedBy?{stoppedBy:d.stoppedBy}:{},...d.pipeline?{pipeline:d.pipeline}:{},...d.layers?{layers:d.layers}:{}},problems:d.counts.failed>0?[{code:"tasks-failed",message:l("wiki.tasksFailed",{count:d.counts.failed})}]:[],changes:d.changes}))+`
11
+ `),n;let u=await g.loadConfig(p);if(r==="tty"){let{renderInk:i}=await import("./chunk-H35Q44QX.js"),{RunSummary:k}=await import("./chunk-6FXKMMUR.js"),{createElement:b}=await import("react");await i(b(k,{data:{...d,budgetMax:u.budget.max}}),l)}else s.stdout.write(q(d,$,l));return n}f(_,"runWikiCommand");export{_ as runWikiCommand};
@@ -0,0 +1 @@
1
+ import{a,b}from"./chunk-BD2OOWDK.js";import"./chunk-CBLU2NBO.js";import"./chunk-XUSV3KOD.js";export{b as openStateDb,a as stateDbPath};
@@ -0,0 +1 @@
1
+ import{a as o,b as g}from"./chunk-G3XA757G.js";import{a as t}from"./chunk-XUSV3KOD.js";function c(e){return e.map(s=>`- ${g(s.path)} \xB7 ${s.action} \xB7 ${s.summary}`)}t(c,"changeLines");function h(e,s,d){let i=t((l,a)=>d(l,a),"t"),n=e.steps.filter(l=>l.status==="failed").length;return o([{key:"result",lines:[i("agent.init.result",{done:e.steps.length-n,failed:n})]},{key:"changes",lines:c(e.changes)},{key:"next",lines:[`- ${i("agent.init.next")}`]}],s)}t(h,"renderInit");function p(e,s,d){let i=t((l,a)=>d(l,a),"t"),n=t(l=>e.changes.filter(a=>a.action===l).length,"count");return o([{key:"result",lines:[i("agent.install.result",{hosts:e.hosts.join(", "),added:n("added"),updated:n("updated"),skipped:n("skipped")})]},{key:"changes",lines:c(e.changes)},{key:"next",lines:[`- ${i("agent.install.next")}`]}],s)}t(p,"renderInstall");function k(e,s,d){let i=t((a,u)=>d(a,u),"t"),n=t(a=>e.changes.filter(u=>u.action===a).length,"count"),l=e.kept.length>0?[`- ${i("agent.uninstall.kept",{dirs:e.kept.join(", ")})}`]:[`- ${i("agent.uninstall.clean")}`];return o([{key:"result",lines:[i("agent.uninstall.result",{hosts:e.hosts.join(", "),removed:n("removed"),updated:n("updated"),skipped:n("skipped")})]},{key:"changes",lines:c(e.changes)},{key:"next",lines:l}],s)}t(k,"renderUninstall");export{h as a,p as b,k as c};
@@ -0,0 +1 @@
1
+ import{b as d}from"./chunk-F5O3VA3Z.js";import{a as p}from"./chunk-XUSV3KOD.js";import{jsx as s,jsxs as o}from"react/jsx-runtime";import{Box as u,Text as r}from"ink";var c={added:"+",updated:"~",skipped:"=",removed:"-"};function y({data:e}){let n=d(),{counts:l}=e;return o(u,{flexDirection:"column",children:[o(r,{bold:!0,children:[n("wiki.summary",{done:l.done,skipped:l.skipped,failed:l.failed,deferred:l.deferred,calls:e.cost.calls}),s(r,{dimColor:!0,children:n("wiki.cost",{calls:e.cost.calls,max:e.budgetMax})})]}),e.stoppedBy!==void 0&&s(r,{color:"yellow",children:e.stoppedBy==="interrupt"?n("wiki.stoppedInterrupt"):n("wiki.stoppedGate",{gate:e.stoppedBy})}),e.changes.length>0&&s(r,{bold:!0,children:n("init.changes")}),e.changes.map(i=>o(r,{children:[` ${c[i.action]??"?"} ${i.path} `,s(r,{dimColor:!0,children:i.summary})]},i.path)),e.pipeline!==void 0&&s(r,{dimColor:!0,children:n("wiki.pipeline",{rounds:e.pipeline.rounds,unmet:e.pipeline.review.filter(i=>!i.satisfied).length})}),e.pipeline?.review.filter(i=>!i.satisfied).map((i,t)=>s(r,{color:"yellow",children:n("wiki.unmet",{requirement:i.requirement,gap:i.gap||"\u2014"})},`unmet-${t}`)),e.layers!==void 0&&e.layers.total>0&&s(r,{dimColor:!0,children:n("wiki.layers",{ready:e.layers.ready,total:e.layers.total,threshold:e.layers.threshold.toFixed(2),updated:e.layers.updated,skipped:e.layers.skipped})}),l.pending>0&&s(r,{dimColor:!0,children:n("wiki.remaining",{count:l.pending})}),e.newQuestionIds.length>0&&s(r,{children:n("wiki.newQuestions",{count:e.newQuestionIds.length,ids:e.newQuestionIds.join("\u3001")})}),e.skippedQuestions.length>0&&o(u,{flexDirection:"column",children:[s(r,{bold:!0,children:n("wiki.skippedQuestions",{count:e.skippedQuestions.length})}),e.skippedQuestions.map((i,t)=>s(r,{color:"yellow",children:` \u26A0 [${i.severity}] ${i.subject}(${i.taskTarget})`},t))]})]})}p(y,"RunSummary");export{y as RunSummary};
@@ -0,0 +1 @@
1
+ import{b as A}from"./chunk-F5O3VA3Z.js";import{a as o}from"./chunk-XUSV3KOD.js";import{jsx as u,jsxs as m}from"react/jsx-runtime";import{useState as w}from"react";import{Box as K,Text as i}from"ink";import{useInput as E}from"ink";function I(n){E((s,t)=>{if(t.escape||t.ctrl&&s==="c")return n.onExit();if(t.upArrow)return n.onMove(-1);if(t.downArrow)return n.onMove(1);if(t.leftArrow)return n.onTabSwitch(-1);if(t.rightArrow)return n.onTabSwitch(1);if(t.tab)return n.onInsert();if(t.return)return n.onSubmit();if(t.backspace||t.delete)return n.onBackspace();if(s.length>0&&!t.ctrl&&!t.meta)return n.onChar(s)})}o(I,"useKeymap");function C({findings:n,onChoice:s,onDone:t}){let c=A(),x=c("check.markStale"),T=c("check.ignore"),g=c("check.answerNow"),b=c("check.skipAll"),[f,v]=w(0),[h,k]=w(0),[a,d]=w(""),e=n[f],p=[...e?.questionId?[x,g]:[],T,b],S=o(()=>{d(""),k(0),f+1>=n.length?t():v(f+1)},"advance");if(I({onMove:o(r=>k(l=>(l+r+p.length)%p.length),"onMove"),onTabSwitch:o(()=>{},"onTabSwitch"),onInsert:o(()=>{},"onInsert"),onSubmit:o(()=>{if(!e)return t();if(a.length>0)return s(e,e.questionId?{kind:"answer",text:a}:{kind:"note",text:a}),S();let r=p[h];if(r===b)return s(e,{kind:"skip-all"}),t();if(r===x)s(e,{kind:"mark-stale"});else{if(r===g)return;s(e,{kind:"ignore"})}S()},"onSubmit"),onBackspace:o(()=>d(r=>[...r].slice(0,-1).join("")),"onBackspace"),onChar:o(r=>d(l=>l+r),"onChar"),onExit:t}),!e)return u(i,{children:c("check.nothingToDispose")});let j=a.length===0;return m(K,{flexDirection:"column",borderStyle:"round",paddingX:1,children:[u(i,{dimColor:!0,children:c("check.flowHeader",{index:f+1,total:n.length})}),u(i,{color:"yellow",children:`[${e.kind}] ${e.path}`}),u(i,{children:e.message}),e.subject!==void 0&&u(i,{dimColor:!0,children:c("check.subject",{subject:e.subject})}),u(i,{children:" "}),p.map((r,l)=>m(i,{inverse:j&&l===h,children:[j&&l===h?"\u276F ":" ",r]},r)),m(i,{children:[e.questionId?c("check.answerPrompt"):c("check.notePrompt"),a,u(i,{inverse:!0,children:" "})]})]})}o(C,"CheckFlow");export{C as CheckFlow};
@@ -0,0 +1,2 @@
1
+ import{a as e,b as c}from"./chunk-XUSV3KOD.js";var I={};c(I,{getLog:()=>m,insertLog:()=>r,listLogs:()=>p,logStats:()=>h,nextAttempt:()=>E,pruneLogs:()=>l});function r(t,n){let a=t.connection.prepare(`INSERT INTO logs (ts, command, invocation_id, run_id, task_id, task_target, attempt, event, duration_ms, data)
2
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(n.ts,n.command,n.invocationId,n.runId??null,n.taskId??null,n.taskTarget??null,n.attempt??null,n.event,n.durationMs??null,JSON.stringify(n.data??null));return Number(a.lastInsertRowid)}e(r,"insertLog");function i(t){let n=null;try{n=JSON.parse(t.data)}catch{n=t.data}return{id:t.id,ts:t.ts,command:t.command,invocationId:t.invocation_id,...t.run_id!==null?{runId:t.run_id}:{},...t.task_id!==null?{taskId:t.task_id}:{},...t.task_target!==null?{taskTarget:t.task_target}:{},...t.attempt!==null?{attempt:t.attempt}:{},event:t.event,...t.duration_ms!==null?{durationMs:t.duration_ms}:{},data:n}}e(i,"fromRow");function p(t,n={}){let a=[],s=[];n.command&&(a.push("command = ?"),s.push(n.command)),n.invocationId&&(a.push("invocation_id = ?"),s.push(n.invocationId)),n.runId&&(a.push("run_id = ?"),s.push(n.runId)),n.taskId&&(a.push("task_id = ?"),s.push(n.taskId)),n.taskTarget&&(a.push("task_target LIKE ?"),s.push(`%${n.taskTarget}%`)),n.event&&(a.push("event = ?"),s.push(n.event)),n.afterId!==void 0&&(a.push("id > ?"),s.push(n.afterId));let o=a.length>0?`WHERE ${a.join(" AND ")}`:"",u=n.newestFirst?"DESC":"ASC",d=n.limit!==void 0?`LIMIT ${Math.max(1,Math.floor(n.limit))}`:"";return t.connection.prepare(`SELECT * FROM logs ${o} ORDER BY id ${u} ${d}`).all(...s).map(i)}e(p,"listLogs");function m(t,n){let a=t.connection.prepare("SELECT * FROM logs WHERE id = ?").get(n);return a?i(a):void 0}e(m,"getLog");function E(t,n){let a=t.connection.prepare("SELECT COUNT(*) AS n FROM logs WHERE task_id = ? AND event = 'task.claim'").get(n);return Number(a.n)+1}e(E,"nextAttempt");function h(t){let n=t.connection.prepare("SELECT COUNT(*) AS n, COALESCE(SUM(LENGTH(data)), 0) AS b FROM logs").get(),a=t.connection.prepare("SELECT command, COUNT(*) AS n FROM logs GROUP BY command ORDER BY n DESC").all();return{rows:Number(n.n),bytes:Number(n.b),byCommand:a.map(s=>({command:s.command,rows:Number(s.n)}))}}e(h,"logStats");function l(t,n){let a=[],s=[];if(n.before&&(a.push("ts < ?"),s.push(n.before)),n.runId&&(a.push("run_id = ?"),s.push(n.runId)),n.keepLast!==void 0){let u=Math.max(0,Math.floor(n.keepLast));a.push(`invocation_id NOT IN (SELECT invocation_id FROM (SELECT invocation_id, MAX(id) AS last FROM logs GROUP BY invocation_id ORDER BY last DESC LIMIT ${u}))`)}if(a.length===0)return 0;let o=t.connection.prepare(`DELETE FROM logs WHERE ${a.join(" AND ")}`).run(...s);return Number(o.changes)}e(l,"pruneLogs");export{r as a,E as b,I as c};
@@ -0,0 +1 @@
1
+ import{H as i,g as d,p as l}from"./chunk-CBLU2NBO.js";import{a}from"./chunk-XUSV3KOD.js";import{mkdir as s,readFile as E,writeFile as m}from"node:fs/promises";import u from"node:path";var p="doc.hash.";function I(e,t,n){e.connection.prepare("INSERT INTO meta (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value").run(p+t,i(n))}a(I,"recordGeneratedHash");function f(e,t){return e.connection.prepare("SELECT value FROM meta WHERE key = ?").get(p+t)?.value??null}a(f,"generatedHash");async function N(e,t,n){let o=f(t,n);if(o===null)return{humanEdited:!1};let r;try{r=await E(u.join(e,n),"utf8")}catch{return{humanEdited:!1}}return{humanEdited:i(r)!==o}}a(N,"inspectDocument");async function O(e,t,n){let o=t.split("/").pop(),r=`${d}/${l}/${o}`,c=u.join(e,r);return await s(u.dirname(c),{recursive:!0}),await m(c,n,"utf8"),r}a(O,"writePending");export{I as a,f as b,N as c,O as d};
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e}from"./chunk-LDYALFZI.js";import"./chunk-XUSV3KOD.js";export{b as acquireRunLock,c as releaseRunLock,a as runLockHolder,e as takeDigestReport,d as writeDigestReport};
@@ -0,0 +1 @@
1
+ import{a as o}from"./chunk-XUSV3KOD.js";var r="AUTOCODE_SPAWNED";function E(e=process.env){return e[r]==="1"||e.AUTOCODE_DIGEST==="1"}o(E,"isGeneratorSession");export{r as a,E as b};
@@ -0,0 +1,44 @@
1
+ import{g as o,i as N}from"./chunk-CBLU2NBO.js";import{a as t}from"./chunk-XUSV3KOD.js";import{DatabaseSync as i}from"node:sqlite";import{existsSync as c,mkdirSync as A,renameSync as O}from"node:fs";import a from"node:path";var s=[[`CREATE TABLE captures (
2
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
3
+ ts TEXT NOT NULL,
4
+ source TEXT NOT NULL,
5
+ session_id TEXT NOT NULL,
6
+ cwd TEXT NOT NULL,
7
+ user TEXT NOT NULL,
8
+ assistant TEXT NOT NULL,
9
+ ops_json TEXT NOT NULL,
10
+ consumed INTEGER NOT NULL DEFAULT 0
11
+ )`,`CREATE TABLE tasks (
12
+ id TEXT PRIMARY KEY,
13
+ run_id TEXT NOT NULL,
14
+ type TEXT NOT NULL,
15
+ target TEXT NOT NULL,
16
+ status TEXT NOT NULL DEFAULT 'pending',
17
+ cost REAL NOT NULL DEFAULT 0,
18
+ duration_ms INTEGER NOT NULL DEFAULT 0,
19
+ error TEXT,
20
+ raw_output TEXT,
21
+ updated_at TEXT NOT NULL
22
+ )`,`CREATE TABLE runs (
23
+ id TEXT PRIMARY KEY,
24
+ started_at TEXT NOT NULL,
25
+ finished_at TEXT,
26
+ mode TEXT NOT NULL,
27
+ summary_json TEXT,
28
+ reported INTEGER NOT NULL DEFAULT 0
29
+ )`,`CREATE TABLE meta (
30
+ key TEXT PRIMARY KEY,
31
+ value TEXT NOT NULL
32
+ )`],[`CREATE TABLE logs (
33
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
34
+ ts TEXT NOT NULL,
35
+ command TEXT NOT NULL,
36
+ invocation_id TEXT NOT NULL,
37
+ run_id TEXT,
38
+ task_id TEXT,
39
+ task_target TEXT,
40
+ attempt INTEGER,
41
+ event TEXT NOT NULL,
42
+ duration_ms INTEGER,
43
+ data TEXT NOT NULL
44
+ )`,"CREATE INDEX logs_task ON logs (task_id, attempt)","CREATE INDEX logs_run ON logs (run_id)","CREATE INDEX logs_invocation ON logs (invocation_id)","CREATE INDEX logs_event ON logs (event)"]];function L(E){E.exec("CREATE TABLE IF NOT EXISTS schema_info (version INTEGER NOT NULL)");let T=E.prepare("SELECT version FROM schema_info").get(),e=T?.version??0;for(T===void 0&&E.prepare("INSERT INTO schema_info (version) VALUES (0)").run();e<s.length;){E.exec("BEGIN");try{for(let r of s[e])E.exec(r);e+=1,E.prepare("UPDATE schema_info SET version = ?").run(e),E.exec("COMMIT")}catch(r){throw E.exec("ROLLBACK"),r}}return e}t(L,"migrate");function R(E){return a.join(E,o,N)}t(R,"stateDbPath");function n(E){let T=new i(E);try{T.exec("PRAGMA journal_mode = WAL"),T.exec("PRAGMA busy_timeout = 2000");let e=L(T);return{connection:T,schemaVersion:e}}catch(e){throw T.close(),e}}t(n,"openAndMigrate");function p(E){let T=R(E);A(a.dirname(T),{recursive:!0});let e;try{e=n(T)}catch(r){if(!c(T))throw r;O(T,`${T}.${Date.now()}.bak`),e=n(T)}return{connection:e.connection,schemaVersion:e.schemaVersion,close:t(()=>e.connection.close(),"close")}}t(p,"openStateDb");export{R as a,p as b};