@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.
- package/README.md +50 -3
- package/dist/chunk-2NNMZN27.js +11 -0
- package/dist/chunk-3ELWKXKT.js +1 -0
- package/dist/chunk-5YDARJ3U.js +1 -0
- package/dist/chunk-6FXKMMUR.js +1 -0
- package/dist/chunk-7F6366VK.js +1 -0
- package/dist/chunk-7LS5USHJ.js +2 -0
- package/dist/chunk-AMOK3G6D.js +1 -0
- package/dist/chunk-ATISEBEN.js +1 -0
- package/dist/chunk-AXRTYMYP.js +1 -0
- package/dist/chunk-BD2OOWDK.js +44 -0
- package/dist/chunk-BHULUCLO.js +221 -0
- package/dist/chunk-CBLU2NBO.js +3 -0
- package/dist/chunk-CLIIIRAX.js +1 -0
- package/dist/chunk-D6W6GJCQ.js +1 -0
- package/dist/chunk-DN5PIQX3.js +11 -0
- package/dist/chunk-EKLYVI5Z.js +3 -0
- package/dist/chunk-EOSGSOQ7.js +7 -0
- package/dist/chunk-F5O3VA3Z.js +1 -0
- package/dist/chunk-F7GM3KBX.js +7 -0
- package/dist/chunk-G3XA757G.js +6 -0
- package/dist/chunk-H35Q44QX.js +1 -0
- package/dist/chunk-HO3X6IFQ.js +8 -0
- package/dist/chunk-IAJUZSL4.js +5 -0
- package/dist/chunk-ILMLK7WM.js +1 -0
- package/dist/chunk-JVGNBSF4.js +1 -0
- package/dist/chunk-KKQQYXWN.js +1 -0
- package/dist/chunk-L4FTN2JM.js +10 -0
- package/dist/chunk-LDYALFZI.js +1 -0
- package/dist/chunk-LOULA2VD.js +7 -0
- package/dist/chunk-LVFFUKWY.js +1 -0
- package/dist/chunk-LVGVTFEP.js +6 -0
- package/dist/chunk-MHDSNQAC.js +2 -0
- package/dist/chunk-MR7DHACF.js +1 -0
- package/dist/chunk-MZ4HQDSJ.js +1 -0
- package/dist/chunk-NZSOD6C5.js +1 -0
- package/dist/chunk-OP2B3OCA.js +1 -0
- package/dist/chunk-PAVENFRW.js +1 -0
- package/dist/chunk-PWGSXL3V.js +1 -0
- package/dist/chunk-QIP56TP2.js +1 -0
- package/dist/chunk-S5M23OZE.js +4 -0
- package/dist/chunk-T7ZEXPKN.js +1 -0
- package/dist/chunk-TFNFQXFH.js +3 -0
- package/dist/chunk-TK24OTGL.js +3 -0
- package/dist/chunk-U5QH6OX7.js +5 -0
- package/dist/chunk-UCR2PGFQ.js +1 -0
- package/dist/chunk-UPEQGG6F.js +1 -0
- package/dist/chunk-WGKUZHE7.js +25 -0
- package/dist/chunk-WWJJMIQL.js +4 -0
- package/dist/chunk-XUSV3KOD.js +1 -0
- package/dist/chunk-ZXRDZ4KX.js +6 -0
- package/dist/hosts/templates/en/commands/auto-check.ejs +25 -0
- package/dist/hosts/templates/en/commands/auto-feat.ejs +69 -0
- package/dist/hosts/templates/en/commands/auto-fix.ejs +69 -0
- package/dist/hosts/templates/en/commands/auto-init.ejs +22 -0
- package/dist/hosts/templates/en/commands/auto-wiki.ejs +42 -0
- package/dist/hosts/templates/en/marker-block.ejs +6 -0
- package/dist/hosts/templates/en/skill-graph.ejs +30 -0
- package/dist/hosts/templates/en/skill-query.ejs +34 -0
- package/dist/hosts/templates/en/skill.ejs +54 -0
- package/dist/hosts/templates/zh/commands/auto-check.ejs +25 -0
- package/dist/hosts/templates/zh/commands/auto-feat.ejs +69 -0
- package/dist/hosts/templates/zh/commands/auto-fix.ejs +69 -0
- package/dist/hosts/templates/zh/commands/auto-init.ejs +22 -0
- package/dist/hosts/templates/zh/commands/auto-wiki.ejs +42 -0
- package/dist/hosts/templates/zh/marker-block.ejs +6 -0
- package/dist/hosts/templates/zh/skill-graph.ejs +30 -0
- package/dist/hosts/templates/zh/skill-query.ejs +34 -0
- package/dist/hosts/templates/zh/skill.ejs +54 -0
- package/dist/index.js +2 -0
- package/dist/prompts/templates/en/intent/check.ejs +17 -0
- package/dist/prompts/templates/en/intent/wiki.ejs +26 -0
- package/dist/prompts/templates/en/prompts/change-acquire.ejs +15 -0
- package/dist/prompts/templates/en/prompts/change-integrate-feat.ejs +59 -0
- package/dist/prompts/templates/en/prompts/change-integrate-fix.ejs +57 -0
- package/dist/prompts/templates/en/prompts/change-plan.ejs +37 -0
- package/dist/prompts/templates/en/prompts/domain-edit.ejs +1 -0
- package/dist/prompts/templates/en/prompts/domain-verify.ejs +14 -0
- package/dist/prompts/templates/en/prompts/domain.ejs +85 -0
- package/dist/prompts/templates/en/prompts/glossary-example.ejs +21 -0
- package/dist/prompts/templates/en/prompts/module-names.ejs +14 -0
- package/dist/prompts/templates/en/prompts/pipeline-material.ejs +18 -0
- package/dist/prompts/templates/en/prompts/structure.ejs +33 -0
- package/dist/prompts/templates/en/prompts/unit-edit.ejs +1 -0
- package/dist/prompts/templates/en/prompts/unit-retry.ejs +14 -0
- package/dist/prompts/templates/en/prompts/unit.ejs +100 -0
- package/dist/prompts/templates/en/prompts/wiki-evidence.ejs +22 -0
- package/dist/prompts/templates/en/prompts/wiki-plan.ejs +28 -0
- package/dist/prompts/templates/en/prompts/wiki-review.ejs +18 -0
- package/dist/prompts/templates/en/prompts/wiki-scope.ejs +28 -0
- package/dist/prompts/templates/en/render/domain.md.ejs +66 -0
- package/dist/prompts/templates/en/render/unit.md.ejs +65 -0
- package/dist/prompts/templates/en/system/agent.ejs +49 -0
- package/dist/prompts/templates/zh/intent/check.ejs +17 -0
- package/dist/prompts/templates/zh/intent/wiki.ejs +26 -0
- package/dist/prompts/templates/zh/prompts/change-acquire.ejs +15 -0
- package/dist/prompts/templates/zh/prompts/change-integrate-feat.ejs +59 -0
- package/dist/prompts/templates/zh/prompts/change-integrate-fix.ejs +57 -0
- package/dist/prompts/templates/zh/prompts/change-plan.ejs +37 -0
- package/dist/prompts/templates/zh/prompts/domain-edit.ejs +1 -0
- package/dist/prompts/templates/zh/prompts/domain-verify.ejs +14 -0
- package/dist/prompts/templates/zh/prompts/domain.ejs +86 -0
- package/dist/prompts/templates/zh/prompts/glossary-example.ejs +21 -0
- package/dist/prompts/templates/zh/prompts/module-names.ejs +14 -0
- package/dist/prompts/templates/zh/prompts/pipeline-material.ejs +18 -0
- package/dist/prompts/templates/zh/prompts/structure.ejs +33 -0
- package/dist/prompts/templates/zh/prompts/unit-edit.ejs +1 -0
- package/dist/prompts/templates/zh/prompts/unit-retry.ejs +14 -0
- package/dist/prompts/templates/zh/prompts/unit.ejs +101 -0
- package/dist/prompts/templates/zh/prompts/wiki-evidence.ejs +22 -0
- package/dist/prompts/templates/zh/prompts/wiki-plan.ejs +28 -0
- package/dist/prompts/templates/zh/prompts/wiki-review.ejs +18 -0
- package/dist/prompts/templates/zh/prompts/wiki-scope.ejs +28 -0
- package/dist/prompts/templates/zh/render/domain.md.ejs +66 -0
- package/dist/prompts/templates/zh/render/unit.md.ejs +65 -0
- package/dist/prompts/templates/zh/system/agent.ejs +37 -0
- package/package.json +27 -4
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as e}from"./chunk-XUSV3KOD.js";var c=100,x=90,a=85,i=60,E=30;function u(t){let o=new Map;for(let r of t){let s=o.get(r.kind);(!s||r.value>s.value)&&o.set(r.kind,{...r})}return[...o.values()]}e(u,"pickBySource");var S=".autocode",O="config.yaml",F="state.db",A="mcp-codegraph.json",L="references.json",k="references",G="units",P="domains",w="questions",U="pending",b="glossary.md",M="entries.md",v="project.md",H="modules.json",Q=".autocode-graph",B="feat",y="fix",Y={feat:{original:"original.prd.md",integrate:"integrate.prd.md",plan:"prd.plan.md",planPrefix:"prd.plan."},fix:{original:"original.defect.md",integrate:"integrate.defect.md",plan:"defect.plan.md",planPrefix:"defect.plan."}};var q={version:1,provider:"auto",budget:{unit:"calls",max:2e3},maxTasks:200,entries:{patterns:[],manual:[],exclude:[]},language:"zh",captureDigest:{auto:!0,threshold:100,batch:50},confidenceThreshold:.5,maxRetries:2,concurrency:3,capabilities:{mergeThreshold:.7},modules:{aiNaming:!1},check:{coverageIgnore:[]},questions:{dedupThreshold:.5,maxBlocking:2,maxNormal:5},wiki:{reviewRounds:3,devThreshold:.8},inject:{historyTurns:20,budgetChars:6e3}},z=80;var $=0,J=1,K=2;var V=["result","changes","skippedQuestions","newQuestions","problems","terms","rules","documents","anchors","changeDocs","next"],Z={zh:{result:"\u7ED3\u679C",changes:"\u53D8\u66F4",skippedQuestions:"\u5F85\u4F18\u5148\u56DE\u7B54\u7684\u95EE\u9898",newQuestions:"\u65B0\u589E\u95EE\u9898",problems:"\u95EE\u9898",terms:"\u4E1A\u52A1\u672F\u8BED",rules:"\u89C4\u5219",documents:"\u6587\u6863",anchors:"\u951A\u70B9",changeDocs:"\u53D8\u66F4\u6587\u6863",next:"\u540E\u7EED"},en:{result:"Result",changes:"Changes",skippedQuestions:"Answer first",newQuestions:"New questions",problems:"Problems",terms:"Business terms",rules:"Rules",documents:"Documents",anchors:"Anchors",changeDocs:"Change documents",next:"Next"}},ee={zh:"\u65E0",en:"none"};function ce(t){return t.replaceAll("\\","/")}e(ce,"toPosixPath");import{createHash as p}from"node:crypto";function Ee(t){let o=t.replaceAll(`\r
|
|
2
|
+
`,`
|
|
3
|
+
`);return p("sha256").update(o,"utf8").digest("hex")}e(Ee,"contentHash");import{randomBytes as n}from"node:crypto";function le(t){for(;;){let o=`q-${n(3).toString("hex")}`;if(!t?.has(o))return o}}e(le,"newQuestionId");function fe(){return`run-${n(8).toString("hex")}`}e(fe,"newRunId");function Ie(){return`task-${n(8).toString("hex")}`}e(Ie,"newTaskId");export{c as a,x as b,a as c,i as d,E as e,u as f,S as g,O as h,F as i,A as j,L as k,k as l,G as m,P as n,w as o,U as p,b as q,M as r,v as s,H as t,Q as u,B as v,y as w,Y as x,q as y,z,$ as A,J as B,K as C,V as D,Z as E,ee as F,ce as G,Ee as H,le as I,fe as J,Ie as K};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d}from"./chunk-AMOK3G6D.js";import"./chunk-CBLU2NBO.js";import"./chunk-XUSV3KOD.js";export{b as generatedHash,c as inspectDocument,a as recordGeneratedHash,d as writePending};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as r}from"./chunk-XUSV3KOD.js";import{buildApplication as d,buildCommand as p,buildRouteMap as h,run as f}from"@stricli/core";var n={init:"onboard the repo: skeleton + code graph + references + provider probe (zero AI)",wiki:"generate / update the knowledge base (L2/L3)",check:"health-check the knowledge base (zero AI)",query:"machine-readable retrieval (for the AI host)",graph:"read-only code-graph lookup: callees / callers / same-file siblings",install:"install / refresh the host-side shell: slash commands, skill, marker blocks, hooks (zero AI)",uninstall:"remove the host-side shell installed by autocode; the knowledge base is kept (zero AI)",feat:"restate a requirement in the project's terms and draft its plan (original via stdin)",fix:"restate a defect, locate its cause and draft the fix plan (original via stdin)"};var s=2;var b={install:{placeholder:"host",brief:"claude | codex | all (optional; detected hosts by default)"},uninstall:{placeholder:"host",brief:"claude | codex | all (optional; both hosts' project files by default)"},feat:{placeholder:"words",brief:"what to build, or where the original is (the original itself goes through stdin)"},fix:{placeholder:"words",brief:"what to fix, or where the report is (the report itself goes through stdin)"},graph:{placeholder:"anchor",brief:"an anchor (qualifiedName, bare name or file::qualifiedName) or a keyword"}},u={check:{fix:{kind:"boolean",brief:"after the report, rewrite the documents it names (stale anchors, rules) with wiki"}},wiki:{check:{kind:"boolean",brief:"run check first, then rewrite only the documents its report names"},scope:{kind:"parsed",brief:"rewrite exactly these documents: unit:<slug>,domain:<id or name> (takes no instruction)"}},feat:{plan:{kind:"boolean",brief:"--no-plan: write the original and the restatement only, no plan yet"},planOnly:{kind:"boolean",brief:"write only the plans of an existing document (pass its id), from its restatement as it stands"},attachments:{kind:"parsed",brief:"a directory inside the repo with reference files (images, PDFs, interface docs) for the engine to read"}},graph:{depth:{kind:"parsed",brief:"hops of the call chain each way, 1-5 (default 2)"}},fix:{plan:{kind:"boolean",brief:"--no-plan: write the original and the restatement only, no plan yet"},planOnly:{kind:"boolean",brief:"write only the plans of an existing document (pass its id), from its restatement as it stands"},attachments:{kind:"parsed",brief:"a directory inside the repo with reference files (images, PDFs, interface docs) for the engine to read"}}};function m(e){let i=u[e],o=b[e]??{placeholder:"instruction",brief:"natural-language instruction (optional)"};return p({loader:r(async()=>{let{runUserCommand:t}=await import("./chunk-IAJUZSL4.js");return r(async function(l,c){this.process.exitCode=await t(e,l,c,this.process)},"impl")},"loader"),parameters:{positional:{kind:"tuple",parameters:[{placeholder:o.placeholder,brief:o.brief,parse:String,optional:!0}]},flags:{json:{kind:"boolean",brief:"emit the JSON envelope (machine-readable)",optional:!0},...Object.fromEntries(Object.entries(i??{}).map(([t,a])=>[t,a.kind==="parsed"?{kind:"parsed",parse:String,brief:a.brief,optional:!0}:{kind:"boolean",brief:a.brief,optional:!0}]))}},docs:{brief:n[e]??e}})}r(m,"placeholderCommand");async function y(){let e=h({routes:Object.fromEntries(Object.keys(n).map(t=>[t,m(t)])),docs:{brief:"autocode \u2014 business documentation writer for your repository"}}),i=d(e,{name:"autocode",versionInfo:{currentVersion:"0.0.2"},scanner:{caseStyle:"allow-kebab-for-camel"},documentation:{caseStyle:"convert-camel-to-kebab"}});await f(i,process.argv.slice(2),{process});let o=process.exitCode;typeof o=="number"&&![0,1,2].includes(o)&&(process.exitCode=s)}r(y,"runApp");export{y as runApp};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{a as u,b as c,c as p}from"./chunk-OP2B3OCA.js";import{A as m,C as h}from"./chunk-CBLU2NBO.js";import{a as d}from"./chunk-XUSV3KOD.js";function f(s,e){let t=[],n=e.candidates;if(!e.symbol){if(!n)return`\u56FE\u91CC\u6CA1\u6709\u300C${s}\u300D;\u4E1A\u52A1\u8BF4\u6CD5\u7528 \`autocode query ${s}\` \u627E\u6587\u6863,\u6587\u6863\u7684\u951A\u70B9\u518D\u6765\u67E5\u56FE / nothing in the graph is called "${s}"; for business words use \`autocode query\` and query the graph with the anchors it returns
|
|
2
|
+
`;t.push(n.reason==="ambiguous"?`\u300C${s}\u300D\u6709 ${n.symbols.length} \u4E2A\u540C\u540D\u7B26\u53F7,\u7528\u5176\u4E2D\u4E00\u4E2A\u951A\u70B9\u518D\u67E5 / ${n.symbols.length} symbols share that name; query again with one anchor:`:`\u6CA1\u6709\u53EB\u300C${s}\u300D\u7684\u7B26\u53F7,\u641C\u7D22\u5230 / no symbol has that name; the search found:`);for(let r of n.symbols)t.push(` ${r.anchor} ${r.file}:${r.line}`);return n.truncated&&t.push(" \u2026(\u66F4\u591A,\u6362\u4E2A\u66F4\u5177\u4F53\u7684\u5173\u952E\u5B57 / more; use a more specific keyword)"),t.join(`
|
|
3
|
+
`)+`
|
|
4
|
+
`}let{symbol:a}=e;n?.reason==="keyword"&&t.push("(\u6309\u5173\u952E\u5B57\u641C\u7D22\u547D\u4E2D / matched by keyword)"),t.push(`${a.qualifiedName} ${a.file}:${a.line}`,"");let o=e.chain?.tree??{up:[],down:[]};return t.push(`\u8C03\u7528\u65B9(\u5411\u4E0A ${e.depth??1} \u5C42)/ callers:`,...o.up.length>0?o.up.map(r=>` ${r}`):[" \u2014"],""),t.push(`\u88AB\u8C03\u7528(\u5411\u4E0B ${e.depth??1} \u5C42)/ callees:`,...o.down.length>0?o.down.map(r=>` ${r}`):[" \u2014"],""),t.push(`\u540C\u6587\u4EF6 / same file:${e.siblings.length} \u4E2A`),t.join(`
|
|
5
|
+
`)+`
|
|
6
|
+
`}d(f,"renderGraph");async function y(s,e,t={}){if(!s||s.trim().length===0)return e.stderr.write(`\u7528\u6CD5:autocode graph <\u951A\u70B9\u6216\u5173\u952E\u5B57> [--depth 1-5] [--json]
|
|
7
|
+
`),2;let n=t.depth===void 0?2:Number(t.depth);if(!Number.isInteger(n)||n<1||n>5)return e.stderr.write(`--depth \u53D6 1~5 / --depth takes 1-5
|
|
8
|
+
`),2;let a=p(!!t.json,!!e.stdout.isTTY)==="json",o=await import("./chunk-BHULUCLO.js"),r=o.createCodeGraphAdapter();try{await r.sync(e.cwd());let i=await o.exploreSymbol(r,s.trim(),{depth:n});return e.stdout.write(a?c(u("graph",{data:i}))+`
|
|
9
|
+
`:f(s.trim(),i)),0}catch(i){let l=i instanceof Error?i.message:String(i);return e.stdout.write(a?c(u("graph",{problems:[{code:"graph-unavailable",message:l}]}))+`
|
|
10
|
+
`:`${l}
|
|
11
|
+
`),2}finally{await r.close()}}d(y,"runGraphCommand");export{f as renderGraph,y as runGraphCommand};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as t}from"./chunk-XUSV3KOD.js";var u=2e4;var s=/^(<task-notification>|<system-reminder>|<command-|Another Claude session sent a message|Base directory for this skill:|This session is being continued from a previous conversation|Caveat: The messages below were generated)/;function i(e){return s.test(e.trim())}t(i,"isMachineTurn");function a(e){let n=e.user.trim();return!!(n.startsWith("/")||n.includes("<command-name>")||i(n)||n.length<4||e.assistant.trim().length===0)}t(a,"isNoise");function f(e){return e.length<=2e4?e:e.slice(0,2e4)+"\u2026[truncated]"}t(f,"truncateField");var r="<autocode-context>",o="</autocode-context>",m=r.length+o.length+2;function _(e){return`${r}
|
|
2
|
+
${e}
|
|
3
|
+
${o}`}t(_,"fenceInjection");var c=/<autocode-context>[\s\S]*?(<\/autocode-context>|$)/g;function C(e){return e.includes(r)?e.replace(c,"").trim():e}t(C,"stripInjection");export{m as a,_ as b,C as c,u as d,i as e,a as f,f as g};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{c as E}from"./chunk-5YDARJ3U.js";import"./chunk-G3XA757G.js";import{a as d,b as c,c as w}from"./chunk-OP2B3OCA.js";import{A as a,B as g,C as f}from"./chunk-CBLU2NBO.js";import{a as p}from"./chunk-XUSV3KOD.js";var v=new Set(["claude","codex","all"]);async function I(k,S,e){let r=w(!!k.json,!!e.stdout.isTTY),i=await import("./chunk-BHULUCLO.js"),h=e.cwd(),m=(await i.loadConfig(h).catch(()=>null))?.language??"zh",s=i.translator(m),l=S?.trim();if(l&&!v.has(l))return e.stderr.write(s("cli.usage.uninstall")+`
|
|
2
|
+
`),2;let t;try{t=await i.runUninstall(h,l??"auto")}catch(n){let o=n instanceof Error?n.message:String(n);return r==="json"?e.stdout.write(c(d("uninstall",{problems:[{code:"uninstall-failed",message:o}]}))+`
|
|
3
|
+
`):e.stderr.write(o+`
|
|
4
|
+
`),1}let T=t.changes.map(({path:n,action:o,summary:U})=>({path:n,action:o,summary:U}));if(r==="json")return e.stdout.write(c(d("uninstall",{data:{hosts:t.hosts,changes:t.changes,kept:t.kept}}))+`
|
|
5
|
+
`),0;if(r==="plain")return e.stdout.write(E({hosts:t.hosts,changes:T,kept:t.kept},m,s)),0;let j={added:"+",updated:"~",skipped:"=",removed:"-"},u=[s("uninstall.header",{hosts:t.hosts.join(", ")})];for(let n of t.changes)u.push(` ${j[n.action]} ${n.path} ${n.summary}`);return u.push(t.kept.length>0?s("uninstall.kept",{dirs:t.kept.join(", ")}):s("uninstall.clean")),e.stdout.write(u.join(`
|
|
6
|
+
`)+`
|
|
7
|
+
`),0}p(I,"runUninstallCommand");export{I as runUninstallCommand};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as t}from"./chunk-XUSV3KOD.js";import{createContext as n,useContext as o}from"react";var r=t((e=>e),"identity"),s=n(r);function x(){return o(s)}t(x,"useTranslate");export{s as a,x as b};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{b as E}from"./chunk-5YDARJ3U.js";import"./chunk-G3XA757G.js";import{a as c,b as u,c as w}from"./chunk-OP2B3OCA.js";import{A as a,B as g,C as p}from"./chunk-CBLU2NBO.js";import{a as f}from"./chunk-XUSV3KOD.js";var y=new Set(["claude","codex","all"]);async function _(S,T,n){let r=w(!!S.json,!!n.stdout.isTTY),l=await import("./chunk-BHULUCLO.js"),h=n.cwd(),m=(await l.loadConfig(h).catch(()=>null))?.language??"zh",s=l.translator(m),i=T?.trim();if(i&&!y.has(i))return n.stderr.write(s("cli.usage.install")+`
|
|
2
|
+
`),2;let e;try{e=await l.runInstall(h,i??"auto")}catch(t){let o=t instanceof Error?t.message:String(t);return r==="json"?n.stdout.write(u(c("install",{problems:[{code:"install-failed",message:o}]}))+`
|
|
3
|
+
`):n.stderr.write(o+`
|
|
4
|
+
`),1}let I=e.changes.map(({path:t,action:o,summary:v})=>({path:t,action:o,summary:v}));if(r==="json")return n.stdout.write(u(c("install",{data:{hosts:e.hosts,changes:e.changes,notes:e.notes}}))+`
|
|
5
|
+
`),0;if(r==="plain")return n.stdout.write(E({hosts:e.hosts,changes:I},m,s)),0;let j={added:"+",updated:"~",skipped:"=",removed:"-"},d=[s("install.header",{hosts:e.hosts.join(", ")})];for(let t of e.changes)d.push(` ${j[t.action]} ${t.path} ${t.summary}`);for(let t of e.notes)t==="no-host-detected"&&d.push(s("install.noHostDetected"));return n.stdout.write(d.join(`
|
|
6
|
+
`)+`
|
|
7
|
+
`),0}f(_,"runInstallCommand");export{_ as runInstallCommand};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{E as o,F as i}from"./chunk-CBLU2NBO.js";import{a as e}from"./chunk-XUSV3KOD.js";function c(n,r){return o[r][n]}e(c,"sectionTitle");function T(n,r){return n.map(t=>{let p=t.lines.length>0?t.lines.join(`
|
|
2
|
+
`):i[r];return`## ${c(t.key,r)}
|
|
3
|
+
${p}`}).join(`
|
|
4
|
+
|
|
5
|
+
`)+`
|
|
6
|
+
`}e(T,"renderAgentReport");function s(n){return n.replaceAll("\\","/").replace(/^\.\//,"")}e(s,"posixPath");function f(n){return n.toFixed(2)}e(f,"formatUsd");export{T as a,s as b,f as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./chunk-XUSV3KOD.js";async function s(t,n){let[{render:i},{createElement:r},{TranslateContext:a}]=await Promise.all([import("ink"),import("react"),import("./chunk-MZ4HQDSJ.js")]),o=n?r(a.Provider,{value:n},t):t;await i(o).waitUntilExit()}e(s,"renderInk");export{s as renderInk};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{H as $,g as p,v as g,w as h,x as w}from"./chunk-CBLU2NBO.js";import{a as i}from"./chunk-XUSV3KOD.js";import{mkdir as v,readFile as j,readdir as d,rm as A,stat as S,writeFile as I}from"node:fs/promises";import f from"node:path";import{parse as D,stringify as O}from"yaml";function C(e){return e==="feat"?g:"fix"}i(C,"changeDir");function T(e){return e.startsWith(`${g}/`)||e.startsWith(`${"fix"}/`)}i(T,"isChangeSource");function l(e,t){return f.join(e,p,C(t))}i(l,"changesRoot");function _(e){return/^feat-\d{8}-\d{3}$/.test(e)?"feat":/^fix-\d{8}-\d{3}$/.test(e)?"fix":null}i(_,"kindOfId");function G(e){let t=/\b(feat|fix)-\d{8}-\d{3}\b/.exec(e);return t?t[0]:null}i(G,"findChangeId");function U(e){let t=e.toLowerCase().replaceAll(new RegExp("[^a-z0-9\u4E00-\u9FFF]+","g"),"-").replaceAll(/-{2,}/g,"-").replaceAll(/^-|-$/g,"");return(t.length>0?t:"change").slice(0,40).replace(/-$/,"")}i(U,"slugify");async function X(e,t,r){let a=r().slice(0,10).replaceAll("-",""),n=`${t}-${a}-`,o=0;try{for(let s of await d(l(e,t))){if(!s.startsWith(n))continue;let c=Number(s.slice(n.length,n.length+3));Number.isFinite(c)&&c>o&&(o=c)}}catch{}return`${n}${String(o+1).padStart(3,"0")}`}i(X,"nextChangeId");function E(e){let t=/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/.exec(e);if(!t)return null;try{return{meta:D(t[1])??{},body:t[2]??""}}catch{return null}}i(E,"splitFrontmatter");function R(e,t){let r=Object.fromEntries(Object.entries(e).filter(([,a])=>a!==void 0));return`---
|
|
2
|
+
${O(r).trimEnd()}
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
${t.trim()}
|
|
6
|
+
`}i(R,"serializeWithFrontmatter");function W(e,t){return $(`${e.version??""}
|
|
7
|
+
${e.confirmation??""}
|
|
8
|
+
${t.trim()}`)}i(W,"changeHash");async function b(e,t,r){let a;try{a=await j(f.join(e,r),"utf8")}catch{return null}let n=E(a);if(!n)return null;let o=n.meta;return{name:r,path:`${t}/${r}`,meta:o,body:n.body,hash:W(o,n.body)}}i(b,"readChangeFile");async function N(e,t){let r=_(t);if(!r)return null;let a=await H(e,r,t);if(!a)return null;let n=f.join(l(e,r),a),o=`${p}/${C(r)}/${a}`,s=w[r],c=await b(n,o,s.original),u=await b(n,o,s.integrate);if(!c||!u)return null;let x=[];for(let F of Array.isArray(u.meta.plans)?u.meta.plans:[]){let y=await b(n,o,F);if(!y)return null;x.push(y)}return{id:t,kind:r,folder:o,original:c,integrate:u,plans:x}}i(N,"readChangeDoc");async function H(e,t,r){try{return(await d(l(e,t))).find(n=>n===r||n.startsWith(`${r}-`))??null}catch{return null}}i(H,"findFolderName");async function q(e,t={}){let r=[];for(let a of["feat","fix"]){let n=[];try{n=await d(l(e,a))}catch{continue}for(let o of n){let s=o.slice(0,a.length+13);if(!_(s))continue;let c=await N(e,s);c&&(t.confirmation&&c.integrate.meta.confirmation!==t.confirmation||t.status&&c.integrate.meta.status!==t.status||r.push(c))}}return r.sort((a,n)=>n.id.localeCompare(a.id))}i(q,"listChangeDocs");async function J(e,t){try{let r=await d(l(e,t)),a=[];for(let n of r)(await S(f.join(l(e,t),n))).isDirectory()&&a.push(n);return a}catch{return[]}}i(J,"listChangeFolders");async function m(e,t,r,a,n){let o=f.join(e,t.folder,r);await v(f.dirname(o),{recursive:!0}),await I(o,R(a,n),"utf8")}i(m,"writeChangeFile");async function K(e,t){await A(f.join(e,t),{recursive:!0,force:!0})}i(K,"removeChangeFolder");async function M(e,t,r,a,n={}){let o=t.plans.find(c=>c.name===r);if(!o)return;let s={...o.meta,status:a};a==="open"?(delete s.absorbed_at,delete s.absorbed_code_version,delete s.absorbed_version):Object.assign(s,n),await m(e,t,r,s,o.body)}i(M,"setPlanStatus");async function Q(e,t,r,a={}){let n={...t.integrate.meta,status:r};r==="open"?(delete n.absorbed_at,delete n.absorbed_code_version,delete n.absorbed_version):Object.assign(n,a),await m(e,t,t.integrate.name,n,t.integrate.body)}i(Q,"setIntegrateStatus");async function V(e,t,r){let a=!1;t.integrate.meta.confirmation==="confirmed"&&!t.integrate.meta.confirmed_at&&(await m(e,t,t.integrate.name,{...t.integrate.meta,confirmed_at:r()},t.integrate.body),a=!0);for(let n of t.plans)n.meta.confirmation==="confirmed"&&!n.meta.confirmed_at&&(await m(e,t,n.name,{...n.meta,confirmed_at:r()},n.body),a=!0);return a}i(V,"stampConfirmedAt");function Y(e){return e.plans.length>1?e.plans.filter(t=>t.meta.part!==0):e.plans}i(Y,"absorbableParts");function Z(e){return e.plans.length>1?e.plans.find(t=>t.meta.part===0):void 0}i(Z,"overviewOf");export{C as a,T as b,l as c,_ as d,G as e,U as f,X as g,R as h,W as i,N as j,q as k,J as l,m,K as n,M as o,Q as p,V as q,Y as r,Z as s};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{a as h,b as I,c as l}from"./chunk-OP2B3OCA.js";import{B as u,C as f}from"./chunk-CBLU2NBO.js";import{a as w}from"./chunk-XUSV3KOD.js";var C=new Set(["wiki","check","feat","fix"]);async function T(n,i,e,t){let c=l(!!i.json,!!t.stdout.isTTY);{let{findWorkspaceRoot:o}=await import("./chunk-BHULUCLO.js"),a=await o(t.cwd());a!==null&&a!==t.cwd()&&t.chdir(a)}if(c!=="json")try{let{pendingDigestReport:o}=await import("./chunk-BHULUCLO.js");for(let a of await o(t.cwd()))t.stderr.write(a+`
|
|
2
|
+
`)}catch{}let{isInitialized:m}=await import("./chunk-BHULUCLO.js");if(await m(t.cwd())){let o=await import("./chunk-BHULUCLO.js"),a=o.openStateDb(t.cwd()),s=o.createLogger(a,{command:n,invocationId:o.newInvocationId()}),d=Date.now();s.log("command.start",{argv:t.argv.slice(2),instruction:e??null,json:!!i.json,tty:!!t.stdout.isTTY,cwd:t.cwd(),version:process.version});try{let r=await o.withLogger(s,()=>k(n,i,e,t));return s.log("command.finish",{exitCode:r},Date.now()-d),r}catch(r){throw s.log("command.error",{error:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null},Date.now()-d),r}finally{a.close()}}return k(n,i,e,t)}w(T,"runUserCommand");async function k(n,i,e,t){let c=l(!!i.json,!!t.stdout.isTTY);if(n==="init"){let{runInitCommand:o}=await import("./chunk-TFNFQXFH.js");return o(i,t)}if(n==="install"){let{runInstallCommand:o}=await import("./chunk-F7GM3KBX.js");return o(i,e,t)}if(n==="uninstall"){let{runUninstallCommand:o}=await import("./chunk-EOSGSOQ7.js");return o(i,e,t)}if(C.has(n)){let{isInitialized:o,t:a}=await import("./chunk-BHULUCLO.js");if(!await o(t.cwd())){let s=a("cli.notInitialized","zh");if(c==="json"){let d=h(n,{problems:[{code:"not-initialized",message:s}]});t.stdout.write(I(d)+`
|
|
3
|
+
`)}else t.stderr.write(s+`
|
|
4
|
+
`);return 1}}if(n==="wiki"){let{runWikiCommand:o}=await import("./chunk-2NNMZN27.js");return o(i,e,t)}if(n==="feat"||n==="fix"){let{runChangeDocCommand:o}=await import("./chunk-L4FTN2JM.js");return o(n,i,e,t)}if(n==="graph"){let{runGraphCommand:o}=await import("./chunk-DN5PIQX3.js");return o(e,t,i)}if(n==="query"){let{runQueryCommand:o}=await import("./chunk-LVGVTFEP.js");return o(i,e,t)}if(n==="check"){let{runCheckCommand:o}=await import("./chunk-LOULA2VD.js");return o(i,e,t)}let{t:m}=await import("./chunk-BHULUCLO.js");return t.stderr.write(m("cli.notImplemented","zh",{command:n})+`
|
|
5
|
+
`),2}w(k,"dispatch");export{T as runUserCommand};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as c}from"./chunk-QIP56TP2.js";import"./chunk-KKQQYXWN.js";import{a,b}from"./chunk-PWGSXL3V.js";import"./chunk-AXRTYMYP.js";import"./chunk-7LS5USHJ.js";import"./chunk-MHDSNQAC.js";import"./chunk-CBLU2NBO.js";import"./chunk-XUSV3KOD.js";export{a as DEBT_REMINDER_KEY,c as maybeTriggerDigest,b as readDigestDebt};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as o}from"./chunk-XUSV3KOD.js";async function w(c,u){let[{render:m},{WikiFlow:p},{createElement:l},{TranslateContext:f}]=await Promise.all([import("ink"),import("./chunk-NZSOD6C5.js"),import("react"),import("./chunk-MZ4HQDSJ.js")]),t={stage:null,running:[],done:0,total:0,failed:0,costCalls:0,budgetMax:u},a=new Map,s=o(()=>[...a.values()].map(e=>({label:e.label,seconds:Math.round((Date.now()-e.startedAt)/1e3)})),"running"),n=o(()=>{i.rerender(l(f.Provider,{value:c},l(p,{state:t})))},"draw"),i=m(l("text",{}),{stdout:process.stderr}),d=setInterval(()=>{a.size!==0&&(t={...t,running:s()},n())},1e3);return d.unref?.(),n(),{setStage(e){t={...t,stage:e},n()},setTotal(e){t={...t,total:e},n()},startTask(e,r){a.set(e,{label:r,startedAt:Date.now()}),t={...t,running:s()},n()},finishTask(e,r,g){a.delete(e),t={...t,running:s(),done:t.done+(r==="done"?1:0),failed:t.failed+(r==="failed"?1:0),costCalls:t.costCalls+g},n()},stop(){clearInterval(d),i.unmount()}}}o(w,"mountWikiFlow");export{w as mountWikiFlow};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as d}from"./chunk-7LS5USHJ.js";import{a as o}from"./chunk-XUSV3KOD.js";import{AsyncLocalStorage as s}from"node:async_hooks";import{randomBytes as m}from"node:crypto";var i=new s;function l(){return`inv-${m(6).toString("hex")}`}o(l,"newInvocationId");function h(e,n){let a=o(t=>({scope:t,log(r,g,c){try{d(e,{ts:new Date().toISOString(),command:t.command,invocationId:t.invocationId,...t.runId!==void 0?{runId:t.runId}:{},...t.taskId!==void 0?{taskId:t.taskId}:{},...t.taskTarget!==void 0?{taskTarget:t.taskTarget}:{},...t.attempt!==void 0?{attempt:t.attempt}:{},event:r,...c!==void 0?{durationMs:Math.round(c)}:{},data:g??null})}catch{}},child(r){return a({...t,...r})}}),"make");return a(n)}o(h,"createLogger");function k(e,n){return i.run(e,n)}o(k,"withLogger");function x(){return i.getStore()}o(x,"currentLogger");function u(e,n,a){i.getStore()?.log(e,n,a)}o(u,"logEvent");async function S(e,n,a){let t=Date.now();try{let r=await a();return u(e,n,Date.now()-t),r}catch(r){throw u(`${e}.error`,{...n,error:r instanceof Error?r.message:String(r)},Date.now()-t),r}}o(S,"logTimed");export{l as a,h as b,k as c,x as d,u as e,S as f};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import{a as I,b as x,c as b}from"./chunk-G3XA757G.js";import{a as y,b as w,c as C}from"./chunk-OP2B3OCA.js";import{A as f,B as $,C as m}from"./chunk-CBLU2NBO.js";import{a as h}from"./chunk-XUSV3KOD.js";function j(n,t){let s=n.threshold.toFixed(2);if(n.ready)return t("agent.change.devReady",{threshold:s,count:n.documents.length});let e=n.documents.filter(a=>a.confidence===void 0||a.confidence<n.threshold).map(a=>a.missing?t("agent.change.devMissing",{subject:a.subject}):t("agent.change.devItem",{path:`.autocode/${a.path}`,confidence:a.confidence?.toFixed(2)??"\u2014",holding:a.holding.map(d=>t(`agent.change.devHolding.${d}`)).join("\u3001")||"\u2014"}));return t("agent.change.devNotReady",{threshold:s,items:e.join(";")||"\u2014"})}h(j,"devLine");function q(n,t,s){let e=h((c,g)=>s(c,g),"t"),d=[e("agent.change.result",{folder:x(n.folder),source:n.source,version:n.version,entries:n.entries.length,plans:n.files.plans.length,questions:n.questionIds.length,calls:n.cost.calls,usd:b(n.cost.usd)})];return n.revision&&d.push(e("agent.change.revision",{from:n.revision.from,to:n.revision.to,sections:n.revision.sections.join("\u3001")||"\u2014"})),I([{key:"result",lines:d},{key:"changes",lines:n.changes.map(c=>`- ${x(c.path)} \xB7 ${c.action} \xB7 ${c.summary}`)},{key:"newQuestions",lines:n.questionIds.map(c=>`- ${c} \xB7 .autocode/questions/${c}.md`)},{key:"next",lines:[`- ${e("agent.change.nextReview")}`,...n.files.plans.length===0?[`- ${e("agent.change.nextPlan",{kind:n.id.split("-")[0],id:n.id})}`]:[],`- ${e("agent.change.nextConfirm")}`,`- ${j(n.dev,e)}`,`- ${e("agent.change.nextLater")}`,...n.graphUnavailable?[`- ${e("agent.graphUnavailable")}`]:[]]}],t)}h(q,"renderChangeDoc");async function T(n){if(n.stdin.isTTY)return null;let t=[];try{for await(let e of n.stdin)t.push(Buffer.isBuffer(e)?e:Buffer.from(e))}catch{return null}let s=Buffer.concat(t).toString("utf8");return s.trim().length>0?s:null}h(T,"readStdin");async function D(n,t,s,e){let a=C(!!t.json,!!e.stdout.isTTY),d=await import("./chunk-BHULUCLO.js"),c=e.cwd(),g=(await d.loadConfig(c).catch(()=>null))?.language??"zh",r=d.translator(g);if(!s||s.trim().length===0)return e.stderr.write(r(n==="feat"?"cli.usage.feat":"cli.usage.fix")+`
|
|
2
|
+
`),2;if(t.planOnly&&(t.plan===!1||t.attachments!==void 0||!d.findChangeId(s)))return e.stderr.write(r("cli.usage.planOnly")+`
|
|
3
|
+
`),2;let E=t.planOnly?null:await T(e),k=t.planOnly?"plan":t.plan===!1?"restate":void 0,i=await d.runChangeDoc(c,n,s,E,{...k?{stage:k}:{},...t.attachments?{attachments:t.attachments}:{}},{onStage:a==="tty"?o=>e.stderr.write(`\u2026 ${r(`change.stage.${o}`)}
|
|
4
|
+
`):void 0}),p=h((o,l,v)=>(a==="json"?e.stdout.write(w(y(n,{problems:[{code:o,message:l}]}))+`
|
|
5
|
+
`):e.stderr.write(l+`
|
|
6
|
+
`),v),"fail");if(i.kind==="kind-mismatch")return p("kind-mismatch",r("change.kindMismatch",{id:i.id}),2);if(i.kind==="unavailable")return p("source-unavailable",r("change.unavailableMcp"),1);if(i.kind==="failed"){let o=[i.reason,...i.violations.map(l=>` - ${l}`)].join(`
|
|
7
|
+
`);return p(`change-${i.stage}-failed`,r("change.failed",{stage:i.stage,detail:o}),1)}if(a==="json"){let{changes:o,kind:l,...v}=i;return e.stdout.write(w(y(n,{data:v,changes:o}))+`
|
|
8
|
+
`),0}if(a==="plain")return e.stdout.write(q(i,g,r)),0;let u=[r("change.done",{folder:i.folder,version:i.version,source:i.source})];for(let o of i.changes)u.push(` ${o.action==="added"?"+":o.action==="updated"?"~":o.action==="removed"?"-":"="} ${o.path}`);return i.questionIds.length>0&&u.push(r("change.questions",{count:i.questionIds.length,ids:i.questionIds.join("\u3001")})),i.files.plans.length===0&&u.push(r("agent.change.nextPlan",{kind:n,id:i.id})),u.push(j(i.dev,(o,l)=>r(o,l))),u.push(r("change.nextTty")),e.stdout.write(u.join(`
|
|
9
|
+
`)+`
|
|
10
|
+
`),0}h(D,"runChangeDocCommand");export{D as runChangeDocCommand};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as n}from"./chunk-XUSV3KOD.js";var o="run.lock";function p(e){try{return process.kill(e,0),!0}catch{return!1}}n(p,"processAlive");function i(e){let r=e.connection.prepare("SELECT value FROM meta WHERE key = ?").get(o);try{let t=JSON.parse(r?.value??"");return{owner:t.owner,pid:t.pid,at:t.at}}catch{return{owner:"unknown",pid:null,at:null}}}n(i,"runLockHolder");function E(e,r){let t=e.connection.prepare("SELECT value FROM meta WHERE key = ?").get(o);if(t)try{let u=JSON.parse(t.value);if(u.pid!==process.pid&&p(u.pid))return!1}catch{}let a={pid:process.pid,owner:r,at:new Date().toISOString()};return e.connection.prepare("INSERT INTO meta (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value").run(o,JSON.stringify(a)),!0}n(E,"acquireRunLock");function l(e){e.connection.prepare("DELETE FROM meta WHERE key = ?").run(o)}n(l,"releaseRunLock");var c="digest.report";function s(e,r){e.connection.prepare("INSERT INTO meta (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value").run(c,JSON.stringify(r))}n(s,"writeDigestReport");function O(e){let r=e.connection.prepare("SELECT value FROM meta WHERE key = ?").get(c);if(!r)return null;e.connection.prepare("DELETE FROM meta WHERE key = ?").run(c);try{return JSON.parse(r.value)}catch{return null}}n(O,"takeDigestReport");export{i as a,E as b,l as c,s as d,O as e};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{a as q,b as y}from"./chunk-G3XA757G.js";import{a as E,b as F,c as S}from"./chunk-OP2B3OCA.js";import{A as x,B as I}from"./chunk-CBLU2NBO.js";import{a as h}from"./chunk-XUSV3KOD.js";var R={"stale-anchor":"high",frontmatter:"medium",orphan:"medium","host-outdated":"medium","change-doc-schema":"medium","change-doc-plan-order":"medium","change-doc-original-edited":"medium","change-doc-plan-stale":"low",coverage:"low","capture-missing":"low","tech-debt":"low","question-kind-suspect":"low","question-over-cap":"low","question-duplicate":"low","anchor-loose":"low","term-pending":"low","layer-link-dangling":"low","dev-below-threshold":"low","term-kind-legacy":"medium","rules-unstructured":"low","rule-ref-dangling":"medium","domain-file-collision":"high","module-unassigned":"medium","out-of-scope-doc":"medium"};function O(o){return R[o]??"medium"}h(O,"checkSeverity");function T(o,u,i){let l=h((e,d)=>i(e,d),"t"),t={high:[],medium:[],low:[]},g=h(e=>{try{return l(`agent.check.hint.${e}`)}catch{return""}},"hintOf"),k=new Map,r=[];for(let e of o.findings){if(e.kind==="stale-anchor"){(k.get(e.path)??k.set(e.path,[]).get(e.path)).push(e.subject??"?");continue}if(e.kind==="coverage"){r.push(e.path);continue}let d=g(e.kind);t[O(e.kind)].push(`- ${e.kind} \xB7 ${y(e.path)} \xB7 ${e.message}${d?`;${d}`:""}`)}for(let[e,d]of[...k.entries()].sort((c,a)=>c[0].localeCompare(a[0]))){let c=g("stale-anchor");t.high.unshift(`- stale-anchor \xB7 ${y(e)} \xB7 ${l("agent.check.staleGroup",{count:d.length,anchors:d.join("\u3001")})}${c?`;${c}`:""}`)}if(r.length>0){let e=new Map;for(let c of r){let a=y(c).split("/").slice(0,-1).join("/")||".";e.set(a,(e.get(a)??0)+1)}let d=[...e.entries()].sort((c,a)=>a[1]-c[1]||c[0].localeCompare(a[0])).slice(0,10).map(([c,a])=>`${c} (${a})`).join("\u3001");t.low.push(`- ${l("agent.check.coverageSummary",{count:r.length,ignored:o.coverage.ignoredFiles??0,dirs:d})}`)}let v={covered:o.coverage.coveredFiles,total:o.coverage.totalFiles,ratio:(o.coverage.ratio*100).toFixed(1)},s=o.findings.length===0?l("agent.check.passed",v):l("agent.check.result",{count:t.high.length+t.medium.length+t.low.length,high:t.high.length,medium:t.medium.length,low:t.low.length,...v}),m=[];for(let e of["high","medium","low"])m.push(`### ${l(`agent.check.group.${e}`)}`),m.push(...t[e].length>0?t[e]:[B(u)]);return q([{key:"result",lines:[s]},{key:"problems",lines:m},{key:"next",lines:[`- ${l("agent.check.next")}`]}],u)}h(T,"renderCheck");function B(o){return o==="zh"?"\u65E0":"none"}h(B,"emptyWord");async function G(o,u,i){let l=S(!!o.json,!!i.stdout.isTTY),t=await import("./chunk-BHULUCLO.js"),g=i.cwd(),k=(await t.loadConfig(g).catch(()=>null))?.language??"zh",r=t.translator(k),v={kind:"all",targets:[]};if(u&&u.trim().length>0){let n=await t.loadConfig(g),p=await t.selectProvider(n.provider,n.model?{model:n.model}:{}),f=await t.parseCheckIntent(u,{entries:[],domains:await t.readDomainSummaries(g),staleCount:0,openQuestions:0,pendingCaptures:0},{provider:p,lang:n.language});f?.kind==="scope"&&(v=f.scope.scope)}let s=await t.runCheck(g,v),m=[],e=[];if(l==="tty"&&s.findings.length>0){let{renderInk:n}=await import("./chunk-H35Q44QX.js"),{CheckFlow:p}=await import("./chunk-7F6366VK.js"),{createElement:f}=await import("react"),w=[];await n(f(p,{findings:s.findings,onChoice:h(($,C)=>{w.push([$,C])},"onChoice"),onDone:h(()=>{},"onDone")}),r);let D=new Date().toISOString();for(let[$,C]of w){let b=M($,C);if(!b)continue;let j=await t.applyDisposition(g,$,b,D);m.push(...j.changes),e.push(...j.newQuestionIds)}}let d=s.findings.length>0?1:0,c=h(async()=>{if(!o.fix)return d;let n=t.documentsToRegenerate(s);if(n.length===0)return l!=="json"&&i.stdout.write(r("check.fix.none")+`
|
|
2
|
+
`),d;l!=="json"&&i.stdout.write([r("check.fix.start",{count:n.length}),...n.map(w=>` ${w}`)].join(`
|
|
3
|
+
`)+`
|
|
4
|
+
`);let{runWikiCommand:p}=await import("./chunk-2NNMZN27.js"),f=await p({json:o.json},void 0,i,new Set(n));return f!==0?f:s.findings.some(w=>!t.isRegenerable(w))?1:0},"afterReport");if(l==="json")return i.stdout.write(F(E("check",{data:{coverage:s.coverage,checks:s.checks,newQuestionIds:e},problems:s.findings.map(n=>({code:n.kind,message:n.message,path:n.path})),changes:m}))+`
|
|
5
|
+
`),c();if(l==="plain")return i.stdout.write(T(s,k,r)),c();let a=[];if(s.findings.length===0)a.push(r("check.passed"));else{a.push(r("check.found",{count:s.findings.length}));for(let n of s.findings){let p=r(`check.kind.${n.kind}`);a.push(` [${p}] ${n.path} ${n.message}`)}}if(a.push(r("check.coverage",{covered:s.coverage.coveredFiles,total:s.coverage.totalFiles,blind:s.coverage.blindFiles.length,ratio:(s.coverage.ratio*100).toFixed(1)})),m.length>0){a.push(r("check.dispositions"));for(let n of m)a.push(` ~ ${n.path} ${n.summary}`)}return i.stdout.write(a.join(`
|
|
6
|
+
`)+`
|
|
7
|
+
`),c()}h(G,"runCheckCommand");function M(o,u){let i=u;return i.kind==="mark-stale"&&o.questionId?{kind:"mark-stale",questionId:o.questionId,codeStatement:o.message}:i.kind==="answer"&&o.questionId&&i.text?{kind:"answer",questionId:o.questionId,text:i.text}:i.kind==="note"&&i.text?{kind:"note",text:i.text}:null}h(M,"toDisposition");export{G as runCheckCommand};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,g as c,h as d,i as e,j as f,k as g,l as h,m as i}from"./chunk-U5QH6OX7.js";import"./chunk-EKLYVI5Z.js";import"./chunk-BD2OOWDK.js";import"./chunk-PWGSXL3V.js";import"./chunk-AXRTYMYP.js";import"./chunk-MHDSNQAC.js";import"./chunk-CBLU2NBO.js";import"./chunk-XUSV3KOD.js";export{a as INJECT_BUDGET_CHARS,b as applyBudget,f as composeInjection,h as injectOptions,e as injectionDisabled,c as isFirstTurn,d as markInjected,g as replayInjection,i as runInject};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{a as d,b as h}from"./chunk-G3XA757G.js";import{a as f,b as g,c as $}from"./chunk-OP2B3OCA.js";import{A as m,C as y}from"./chunk-CBLU2NBO.js";import{a as c}from"./chunk-XUSV3KOD.js";function p(s,a,r,l){let i=c((e,t)=>r(e,t),"t"),u=l.changeDocs??[];return s.empty?d([{key:"result",lines:[l.emptyGuidance]},{key:"terms",lines:[]},{key:"rules",lines:[]},{key:"documents",lines:[]},{key:"anchors",lines:[]},{key:"changeDocs",lines:[]},{key:"next",lines:[`- ${i("agent.query.next")}`]}],a):d([{key:"result",lines:[i("agent.query.result",{terms:s.terms.length,rules:(s.rules??[]).length,documents:s.documents.length,entries:(s.entries??[]).length,anchors:s.anchors.length,changeDocs:u.length})]},{key:"terms",lines:s.terms.map(e=>`- ${e.term}(${e.module} \xB7 ${l.kindLabel(e.kind)}):${e.definition}`)},{key:"rules",lines:(s.rules??[]).map(e=>`- ${e.id} \xB7 ${e.name} \xB7 ${e.domain} \xB7 ${h(e.path)}`)},{key:"documents",lines:s.documents.flatMap(e=>{let t=[i(`agent.query.layer.${e.layer??e.kind}`),...e.confidence!==void 0?[i("agent.query.confidence",{value:e.confidence.toFixed(2)})]:[],...e.anchorHit?[i("agent.query.anchorHit")]:[],h(e.path),e.title,...e.summary?[e.summary]:[]].join(" \xB7 "),o=e.up||e.down?[` ${i("agent.query.links",{up:(e.up??[]).join("\u3001")||"\u2014",down:(e.down??[]).join("\u3001")||"\u2014"})}`]:[];return[`- ${t}`,...o]})},{key:"anchors",lines:[...(s.entries??[]).map(e=>`- ${i("agent.query.entry",{anchor:e.anchor,label:e.label,location:h(e.location),fragment:e.fragment,unit:e.unit})}${e.written?"":i("agent.query.unitMissing")}`),...s.anchors.map(e=>`- ${e.qualifiedName} \xB7 ${h(e.location)}`)]},{key:"changeDocs",lines:u.map(e=>`- ${e.id} \xB7 ${e.title} \xB7 ${e.status} \xB7 v${e.version} \xB7 ${h(e.path)}`)},{key:"next",lines:[`- ${i("agent.query.next")}`]}],a)}c(p,"renderQuery");async function C(s,a,r){let l=$(!!s.json,!!r.stdout.isTTY),i=await import("./chunk-BHULUCLO.js"),u=(await i.loadConfig(r.cwd()).catch(()=>null))?.language??"zh",e=i.translator(u);if(!a||a.trim().length===0)return r.stderr.write(e("cli.usage.query")+`
|
|
2
|
+
`),2;let t=await i.runQuery(r.cwd(),a);if(l==="json")return r.stdout.write(g(f("query",{data:t.empty?{empty:!0,guidance:i.EMPTY_GUIDANCE}:{keyword:t.keyword,terms:t.terms,rules:t.rules,documents:t.documents,entries:t.entries,anchors:t.anchors,changeDocs:t.changeDocs}}))+`
|
|
3
|
+
`),0;if(l==="plain")return r.stdout.write(p(t,u,e,{emptyGuidance:i.EMPTY_GUIDANCE,kindLabel:c(n=>i.kindLabel(n,u),"kindLabel"),changeDocs:t.changeDocs})),0;if(t.empty)return r.stdout.write(i.EMPTY_GUIDANCE+`
|
|
4
|
+
`),0;let o=[];if(t.terms.length>0){o.push(e("query.terms"));for(let n of t.terms)o.push(` \u3010${n.term}\u3011(${n.module}\xB7${i.kindLabel(n.kind,u)}):${n.definition}`)}if(t.documents.length>0){o.push(e("query.documents"));for(let n of t.documents){let k=n.confidence!==void 0?` [${n.confidence.toFixed(2)}]`:"";o.push(` ${n.path} ${n.title}${k}${n.summary?` \u2014\u2014 ${n.summary}`:""}`),(n.up||n.down)&&o.push(` \u2191 ${(n.up??[]).join("\u3001")||"\u2014"} \u2193 ${(n.down??[]).join("\u3001")||"\u2014"}`)}}for(let n of t.entries)o.push(` ${n.label} \u2192 ${n.anchor} ${n.location} ${n.fragment} ${n.unit}${n.written?"":e("agent.query.unitMissing")}`);if(t.anchors.length>0){o.push(e("query.anchors"));for(let n of t.anchors)o.push(` ${n.qualifiedName} ${n.location}`)}return o.length===0&&o.push(e("query.noHit",{keyword:a})),r.stdout.write(o.join(`
|
|
5
|
+
`)+`
|
|
6
|
+
`),0}c(C,"runQueryCommand");export{C as runQueryCommand};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as i,b as u}from"./chunk-XUSV3KOD.js";var a={};u(a,{insertCapture:()=>r,listCaptures:()=>d,markConsumed:()=>p});function r(o,s){let n=o.connection.prepare(`INSERT INTO captures (ts, source, session_id, cwd, user, assistant, ops_json)
|
|
2
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)`).run(s.ts,s.source,s.sessionId,s.cwd,s.user,s.assistant,JSON.stringify(s.ops));return Number(n.lastInsertRowid)}i(r,"insertCapture");function d(o,s){let n=[],t=[];s.pending&&n.push("consumed = 0"),s.source&&(n.push("source = ?"),t.push(s.source)),s.session&&(n.push("session_id = ?"),t.push(s.session));let c=n.length>0?` WHERE ${n.join(" AND ")}`:"";return o.connection.prepare(`SELECT * FROM captures${c} ORDER BY id`).all(...t).map(e=>({id:e.id,ts:e.ts,source:e.source,sessionId:e.session_id,cwd:e.cwd,user:e.user,assistant:e.assistant,ops:JSON.parse(e.ops_json),consumed:e.consumed===1}))}i(d,"listCaptures");function p(o,s,n){let t=o.connection.prepare("UPDATE captures SET consumed = ? WHERE id = ?");for(let c of s)t.run(n?1:0,c)}i(p,"markConsumed");export{r as a,d as b,p as c,a as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as d,b as e,c as f}from"./chunk-S5M23OZE.js";import{d as a,f as b,g as c}from"./chunk-EKLYVI5Z.js";import"./chunk-BD2OOWDK.js";import"./chunk-AXRTYMYP.js";import"./chunk-MHDSNQAC.js";import"./chunk-CBLU2NBO.js";import"./chunk-XUSV3KOD.js";export{a as MAX_FIELD_CHARS,e as extractLastTurn,b as isNoise,d as parsePayload,f as runCapture,c as truncateField};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b}from"./chunk-F5O3VA3Z.js";import"./chunk-XUSV3KOD.js";export{a as TranslateContext,b as useTranslate};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as i}from"./chunk-F5O3VA3Z.js";import{a as e}from"./chunk-XUSV3KOD.js";import{jsxs as d,jsx as a}from"react/jsx-runtime";import{Box as h,Text as x}from"ink";import{jsx as t,jsxs as m}from"react/jsx-runtime";import{Box as p,Text as n}from"ink";function u({current:r,done:s,total:o,failed:c,costCalls:f,budgetMax:g}){let l=i();return m(p,{flexDirection:"column",children:[m(n,{children:[l("wiki.progress",{done:s,total:o}),c>0?t(n,{color:"red",children:l("wiki.progressFailed",{failed:c})}):null,t(n,{dimColor:!0,children:l("wiki.cost",{calls:f,max:g})})]}),r!==null&&t(n,{dimColor:!0,children:l("wiki.current",{target:r})})]})}e(u,"Progress");function F({state:r}){let s=i();return d(h,{flexDirection:"column",children:[r.stage!==null&&d(x,{dimColor:!0,children:["\u2026 ",r.stage]}),a(u,{current:null,done:r.done,total:r.total,failed:r.failed,costCalls:r.costCalls,budgetMax:r.budgetMax}),r.running.map(o=>a(x,{dimColor:!0,children:s("wiki.running",{target:o.label,seconds:o.seconds})},o.label))]})}e(F,"WikiFlow");export{F as WikiFlow};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as t}from"./chunk-XUSV3KOD.js";function u(e,n){let o=n.problems??[];return{ok:o.length===0,command:e,data:n.data??{},problems:o,changes:n.changes??[]}}t(u,"buildEnvelope");function p(e){return JSON.stringify(e,null,2)}t(p,"serializeEnvelope");function f(e,n){return e?"json":n?"tty":"plain"}t(f,"resolveOutputMode");export{u as a,p as b,f as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{A,B,C,D,E,F,G,H,I,J,K,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-CBLU2NBO.js";import"./chunk-XUSV3KOD.js";export{F as AGENT_SECTION_EMPTY,D as AGENT_SECTION_KEYS,E as AGENT_SECTION_TITLES,g as AUTOCODE_DIR,x as CHANGE_FILES,u as CODEGRAPH_DIR,d as CONFIDENCE_AI_REPLY,a as CONFIDENCE_CODE_FACT,e as CONFIDENCE_CODE_INFERENCE,b as CONFIDENCE_HUMAN_ANSWER,c as CONFIDENCE_HUMAN_UTTERANCE,h as CONFIG_FILE,y as DEFAULT_CONFIG,n as DOMAINS_DIR,r as ENTRIES_FILE,B as EXIT_PROBLEM,A as EXIT_SUCCESS,C as EXIT_USAGE,v as FEAT_DIR,w as FIX_DIR,q as GLOSSARY_FILE,l as LEGACY_REFERENCES_DIR,j as MCP_CONFIG_FILE,t as MODULES_FILE,z as OUTLINE_SYMBOL_THRESHOLD,p as PENDING_DIR,s as PROJECT_FILE,o as QUESTIONS_DIR,k as REFERENCES_FILE,i as STATE_DB_FILE,m as UNITS_DIR,H as contentHash,I as newQuestionId,J as newRunId,K as newTaskId,f as pickBySource,G as toPosixPath};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as t}from"./chunk-XUSV3KOD.js";var n="digest.debt";function o(r){let e=r.connection.prepare("SELECT value FROM meta WHERE key = ?").get(n);return e?Number(e.value):0}t(o,"readDigestDebt");export{n as a,o as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{e as l}from"./chunk-KKQQYXWN.js";import{a as u}from"./chunk-PWGSXL3V.js";import{b as h}from"./chunk-AXRTYMYP.js";import{b as f}from"./chunk-MHDSNQAC.js";import{g,h as p,y as i}from"./chunk-CBLU2NBO.js";import{a as t}from"./chunk-XUSV3KOD.js";import{spawn as w}from"node:child_process";import{readFile as T}from"node:fs/promises";import y from"node:path";import{parse as E}from"yaml";import{z as e}from"zod";var b=e.object({version:e.number().int().positive(),provider:e.enum(["auto","claude-code","codex"]),model:e.string(),budget:e.object({unit:e.enum(["calls","usd"]),max:e.number().positive()}).partial(),maxTasks:e.number().int().positive(),entries:e.object({patterns:e.array(e.string()),manual:e.array(e.string()),exclude:e.array(e.string())}).partial(),language:e.enum(["zh","en"]),captureDigest:e.object({auto:e.boolean(),threshold:e.number().int().positive(),batch:e.number().int().positive()}).partial(),confidenceThreshold:e.number().min(0).max(1),maxRetries:e.number().int().min(0),concurrency:e.number().int(),capabilities:e.object({mergeThreshold:e.number().min(0).max(1)}).partial(),modules:e.object({aiNaming:e.boolean()}).partial(),check:e.object({coverageIgnore:e.array(e.string())}).partial(),questions:e.object({dedupThreshold:e.number().min(0).max(1),maxBlocking:e.number().int().min(0),maxNormal:e.number().int().min(0)}).partial(),wiki:e.object({reviewRounds:e.number().int().min(1).max(10),devThreshold:e.number().min(0).max(1)}).partial(),inject:e.object({historyTurns:e.number().int().min(1).max(100),budgetChars:e.number().int().min(1e3).max(3e4)}).partial()}).partial();var m=class extends Error{static{t(this,"ConfigError")}constructor(r){super(r),this.name="ConfigError"}};function x(n){return y.join(n,g,p)}t(x,"configPath");var a={min:1,max:8};function v(n){if(n===void 0)return i.concurrency;let r=Math.min(a.max,Math.max(a.min,n));return r!==n&&(l("config.clamped",{key:"concurrency",value:n,clamped:r}),process.emitWarning(`config.yaml: concurrency ${n} is outside ${a.min}\u2013${a.max}; using ${r}`)),r}t(v,"clampConcurrency");function j(n){return{version:n.version??i.version,provider:n.provider??i.provider,...n.model&&n.model.trim().length>0?{model:n.model.trim()}:{},budget:{...i.budget,...n.budget},maxTasks:n.maxTasks??i.maxTasks,entries:{...i.entries,...n.entries},language:n.language??i.language,captureDigest:{...i.captureDigest,...n.captureDigest},confidenceThreshold:n.confidenceThreshold??i.confidenceThreshold,maxRetries:n.maxRetries??i.maxRetries,concurrency:v(n.concurrency),capabilities:{...i.capabilities,...n.capabilities},modules:{...i.modules,...n.modules},check:{...i.check,...n.check},questions:{...i.questions,...n.questions},wiki:{...i.wiki,...n.wiki},inject:{...i.inject,...n.inject}}}t(j,"mergeDefaults");async function D(n){let r;try{r=await T(x(n),"utf8")}catch{throw new m(`config not found: ${x(n)} \u2014 run \`autocode init\` first`)}let o=E(r)??{},s=b.safeParse(o);if(!s.success){let c=s.error.issues.map(d=>`${d.path.join(".")}: ${d.message}`).join("; ");throw new m(`invalid config.yaml \u2014 ${c}`)}return j(s.data)}t(D,"loadConfig");function k(n,r){w(process.execPath,[r,"digest-daemon"],{cwd:n,detached:!0,stdio:"ignore",env:{...process.env,AUTOCODE_DIGEST:"1"}}).unref()}t(k,"defaultSpawnDigest");async function B(n,r,o={}){try{if(h())return;let s=await D(r),c=f(n,{pending:!0}).length;if(c<s.captureDigest.threshold)return;if(!s.captureDigest.auto){n.connection.prepare("INSERT INTO meta (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value").run(u,String(c));return}o.spawnDigest?o.spawnDigest(r):o.binPath&&k(r,o.binPath)}catch{}}t(B,"maybeTriggerDigest");export{m as a,x as b,D as c,B as d};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{c as p,f as l,g as f}from"./chunk-EKLYVI5Z.js";import{b as g}from"./chunk-BD2OOWDK.js";import{b as x}from"./chunk-AXRTYMYP.js";import{a as S}from"./chunk-MHDSNQAC.js";import{a}from"./chunk-XUSV3KOD.js";import{readFile as j}from"node:fs/promises";var _=["session_id","sessionId","thread_id","threadId"],w=["cwd","workdir","working_directory","workingDirectory"],I=["transcript_path","transcriptPath","rollout_path","history_path"];function m(r,t){for(let s of t){let n=r[s];if(typeof n=="string"&&n.length>0)return n}}a(m,"firstString");function y(r,t){let s;try{s=JSON.parse(t)}catch{return null}if(typeof s!="object"||s===null)return null;let n=s,o=m(n,_),i=m(n,w),e=m(n,I);return!o||!i||!e?null:{sessionId:o,cwd:i,transcriptPath:e}}a(y,"parsePayload");function d(r){return typeof r=="string"?r:Array.isArray(r)?r.filter(t=>typeof t=="object"&&t!==null&&t.type==="text").map(t=>t.text).join(`
|
|
2
|
+
`):""}a(d,"textOf");function P(r){if(!Array.isArray(r))return[];let t=[];for(let s of r){if(typeof s!="object"||s===null)continue;let n=s;if(!(n.type!=="tool_use"||typeof n.input!="object"||n.input===null))for(let o of["file_path","path","command"]){let i=n.input[o];if(typeof i=="string"&&i.length>0){t.push(i);break}}}return t}a(P,"opsOf");function k(r){return r.type!=="user"||r.message?.role!=="user"?!1:d(r.message.content).trim().length>0}a(k,"isHumanUtterance");function h(r){let t=[];for(let e of r.split(`
|
|
3
|
+
`))if(e.trim().length!==0)try{t.push(JSON.parse(e))}catch{}let s=-1;for(let e=t.length-1;e>=0;e--)if(k(t[e])){s=e;break}if(s===-1)return;let n=d(t[s].message.content).trim(),o=[],i=[];for(let e of t.slice(s+1)){if(e.type!=="assistant")continue;let c=d(e.message?.content).trim();c.length>0&&o.push(c),i.push(...P(e.message?.content))}return{user:n,assistant:o.join(`
|
|
4
|
+
`),ops:i}}a(h,"extractLastTurn");async function A(r,t,s,n={}){if(!x())try{let o=y(t,s);if(!o)return;let i;try{i=await j(o.transcriptPath,"utf8")}catch{return}let e=h(i);if(!e)return;let c={...e,user:p(e.user),assistant:p(e.assistant)};if(l(c))return;let u=(n.openDb??g)(r);try{if(S(u,{ts:new Date().toISOString(),source:t,sessionId:o.sessionId,cwd:o.cwd,user:f(c.user),assistant:f(c.assistant),ops:c.ops}),n.onStored)await n.onStored(u,r);else{let{maybeTriggerDigest:b}=await import("./chunk-ILMLK7WM.js");await b(u,r,n.binPath?{binPath:n.binPath}:{})}}finally{u.close()}}catch{}}a(A,"runCapture");export{y as a,h as b,A as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as d}from"./chunk-F5O3VA3Z.js";import{a as n}from"./chunk-XUSV3KOD.js";import{jsx as r,jsxs as t}from"react/jsx-runtime";import{Box as a,Text as e}from"ink";var s={done:{glyph:"\u2713",color:"green"},skipped:{glyph:"=",color:"gray"},failed:{glyph:"\u2717",color:"red"}},c={added:"+",updated:"~",skipped:"=",removed:"-"};function u({report:i}){let l=d();return t(a,{flexDirection:"column",children:[r(e,{bold:!0,children:l(i.ok?"init.done":"init.doneWithFailures")}),i.steps.map(o=>t(e,{children:[r(e,{color:s[o.status].color,children:s[o.status].glyph}),` ${o.step} `,r(e,{dimColor:!0,children:o.detail})]},o.step)),i.changes.length>0&&r(e,{bold:!0,children:l("init.changes")}),i.changes.map(o=>t(e,{children:[` ${c[o.action]??"?"} ${o.path} `,r(e,{dimColor:!0,children:o.summary})]},o.path))]})}n(u,"InitReport");export{u as InitReport};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as $}from"./chunk-5YDARJ3U.js";import"./chunk-G3XA757G.js";import{a as w,b as h,c as g}from"./chunk-OP2B3OCA.js";import{A as m,B as p}from"./chunk-CBLU2NBO.js";import{a as c}from"./chunk-XUSV3KOD.js";async function S(s,t){let a=g(!!s.json,!!t.stdout.isTTY),{runInit:i}=await import("./chunk-BHULUCLO.js"),{loadConfig:e,translator:d}=await import("./chunk-BHULUCLO.js"),{findWorkspaceRoot:k}=await import("./chunk-BHULUCLO.js"),l=await k(t.cwd());l!==null&&l!==t.cwd()&&t.chdir(l);let u=(await e(t.cwd()).catch(()=>null))?.language??"zh",f=d(u),n=await i(t.cwd(),{onStep:a==="json"?void 0:r=>t.stderr.write(`\u2026 ${r}
|
|
2
|
+
`)});if(a==="json"){let r=w("init",{data:{steps:n.steps,providers:n.providers,hosts:n.hosts},problems:n.steps.filter(o=>o.status==="failed").map(o=>({code:`init-${o.step}-failed`,message:o.detail})),changes:n.changes});return t.stdout.write(h(r)+`
|
|
3
|
+
`),n.ok?0:1}if(a==="tty"){let{renderInk:r}=await import("./chunk-H35Q44QX.js"),{InitReport:o}=await import("./chunk-T7ZEXPKN.js"),{createElement:v}=await import("react");await r(v(o,{report:n}),f)}else t.stdout.write($(n,u,f));return n.ok?0:1}c(S,"runInitCommand");function T(s,t="Changes:"){let a={done:"\u2713",skipped:"=",failed:"\u2717"},i=s.steps.map(e=>`${a[e.status]} ${e.step} ${e.detail}`);if(s.changes.length>0){i.push(t);for(let e of s.changes){let d={added:"+",updated:"~",skipped:"=",removed:"-"}[e.action];i.push(` ${d} ${e.path} ${e.summary}`)}}return i}c(T,"reportLines");export{T as reportLines,S as runInitCommand};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{q as T}from"./chunk-WWJJMIQL.js";import"./chunk-KKQQYXWN.js";import"./chunk-7LS5USHJ.js";import{g as y,k as R,m as g,n as O,r as b,t as A}from"./chunk-CBLU2NBO.js";import{a as r}from"./chunk-XUSV3KOD.js";import{readFile as E,readdir as L}from"node:fs/promises";import m from"node:path";import{parse as M}from"yaml";var q=/^\s+- <a id="[^"]+"><\/a>(.*?) → `([^`]+)` · (\S+?)(?::\d+)?$/,z=/^### \S+?\.rule\.[a-z0-9][a-z0-9-]* · (.+)$/,C=/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/;async function K(e,t="zh"){let i=m.join(e,y),a=await k(i),o=await B(i),D=await J(i),x=r(s=>{let{file:f,name:u}=_(s);if(f)return f;let c=o.get(u);return a.get(u)?.file??(c&&c.size===1?[...c][0]:void 0)},"fileOf"),F=(await T(e)).map(s=>({term:s.term,module:s.module,kind:s.kind,status:s.status,aliases:s.aliases,files:h(s.anchors.map(x))})),N=[];for(let[s,f]of[[g,"unit"],[O,"domain"]]){let u;try{u=(await L(m.join(i,s))).filter(c=>c.endsWith(".md")).sort()}catch{continue}for(let c of u){let $=await E(m.join(i,s,c),"utf8"),w=C.exec($),S=w?.[2]??$,l={};try{l=(w?M(w[1]):null)??{}}catch{}let p=[...d([l.entry]),...d(l.entries)];if(f==="unit"&&p.some(n=>D.has(n)))continue;let I=d(l.anchors),j=p.map(n=>a.get(n)?.label).filter(n=>!!n);N.push({path:`${y}/${s}/${c}`,layer:f,title:/^#\s+(.+)$/m.exec(S)?.[1]?.trim()??c.replace(/\.md$/,""),summary:/^>\s+(.+)$/m.exec(S)?.[1]?.trim()??"",...typeof l.confidence=="number"?{confidence:l.confidence}:{},up:d(l.up).map(n=>`${y}/${n}`),names:h([...p,...I.map(n=>_(n).name),...j.flatMap(U)]),files:h([...p,...I].map(x)),terms:d(l.terms),rules:f==="domain"?S.split(`
|
|
2
|
+
`).map(n=>z.exec(n.trimEnd())?.[1]?.trim()).filter(n=>!!n):[]})}}return{terms:F,documents:N,language:t}}r(K,"readCatalog");function _(e){let t=e.indexOf("::");return t>0&&/[\\/]/.test(e.slice(0,t))?{file:e.slice(0,t),name:e.slice(t+2)}:{name:e}}r(_,"splitAnchor");function U(e){let t=/^[A-Z]+\s+(\/\S+)$/.exec(e.trim());return t?[e.trim(),t[1]]:[e.trim()]}r(U,"routeNames");async function k(e){let t=new Map,i;try{i=await E(m.join(e,b),"utf8")}catch{return t}for(let a of i.split(`
|
|
3
|
+
`)){let o=q.exec(a.trimEnd());o&&t.set(o[2],{label:o[1].trim(),file:o[3]})}return t}r(k,"readEntryCatalog");async function B(e){let t=new Map;try{let i=JSON.parse(await E(m.join(e,R),"utf8"));for(let a of i.symbols??[]){let o=t.get(a.qualifiedName);o?o.add(a.file):t.set(a.qualifiedName,new Set([a.file]))}}catch{}return t}r(B,"readSymbolFiles");async function J(e){try{let t=JSON.parse(await E(m.join(e,A),"utf8"));return new Set((t.excludedEntries??[]).map(i=>i.qualifiedName))}catch{return new Set}}r(J,"readExcludedEntries");function d(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}r(d,"strings");function h(e){return[...new Set(e.filter(t=>!!t))]}r(h,"unique");export{K as readCatalog,_ as splitAnchor};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{a as ft,b as pt,e as C}from"./chunk-EKLYVI5Z.js";import{b as mt}from"./chunk-BD2OOWDK.js";import{b as lt}from"./chunk-PWGSXL3V.js";import{b as dt}from"./chunk-AXRTYMYP.js";import{b as _}from"./chunk-MHDSNQAC.js";import{G as z,g as N,h as st,k as ct,m as L,n as U,o as q,q as D,r as W,t as it,v as at,w as ut,y as P}from"./chunk-CBLU2NBO.js";import{a as c}from"./chunk-XUSV3KOD.js";import{existsSync as Se}from"node:fs";import{readFile as Ie}from"node:fs/promises";import bt from"node:path";import{readdir as Ft,stat as Lt}from"node:fs/promises";import V from"node:path";var ht="inject.catalog",Ut=1;async function Wt(t){let e=V.join(t,N),n=[D,W,ct,it];for(let s of[L,U])try{n.push(...(await Ft(V.join(e,s))).filter(u=>u.endsWith(".md")).sort().map(u=>`${s}/${u}`))}catch{}let r=await Promise.all(n.map(async s=>{try{let u=await Lt(V.join(e,s));return`${s}:${u.size}:${u.mtimeMs}`}catch{return`${s}:-`}}));return`${Ut}|${r.join("|")}`}c(Wt,"signature");async function gt(t,e){let n=await Wt(t);try{let u=e.connection.prepare("SELECT value FROM meta WHERE key = ?").get(ht);if(u){let o=JSON.parse(u.value);if(o.signature===n)return o.catalog}}catch{}let{readCatalog:r}=await import("./chunk-TK24OTGL.js"),s=await r(t);try{e.connection.prepare("INSERT INTO meta (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value").run(ht,JSON.stringify({signature:n,catalog:s}))}catch{}return s}c(gt,"loadCatalog");import{readFile as Pt,readdir as St,stat as Ht}from"node:fs/promises";import j from"node:path";var Et="inject.status",Bt=1;async function Gt(t){let e=j.join(t,N),n=[];for(let s of[q,at,"fix"])try{let u=await St(j.join(e,s),{recursive:!0});n.push(...u.filter(o=>o.endsWith(".md")).map(o=>`${s}/${o}`))}catch{}n.sort();let r=await Promise.all(n.map(async s=>{try{let u=await Ht(j.join(e,s));return`${s}:${u.size}:${u.mtimeMs}`}catch{return`${s}:-`}}));return`${Bt}|${r.join("|")}`}c(Gt,"signature");async function It(t,e){let n=await Gt(t);try{let s=e.connection.prepare("SELECT value FROM meta WHERE key = ?").get(Et);if(s){let u=JSON.parse(s.value);if(u.signature===n)return u.lines}}catch{}let r=[...await Jt(t),...await qt(t)];try{e.connection.prepare("INSERT INTO meta (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value").run(Et,JSON.stringify({signature:n,lines:r}))}catch{}return r}c(It,"loadStatusLines");async function Jt(t){try{let{listChangeDocs:e,absorbableParts:n}=await import("./chunk-UPEQGG6F.js");return(await e(t,{confirmation:"confirmed",status:"open"})).map(s=>{let u=n(s),o=u.filter(m=>m.meta.status==="absorbed").length;return`- [\u53D8\u66F4/change] ${s.integrate.meta.title} \u2014\u2014 \u5DF2\u5438\u6536 ${o}/${u.length}(${s.folder})`})}catch{return[]}}c(Jt,"changeDocLines");async function qt(t){let e=j.join(t,N,q),n=0,r=0;try{for(let s of await St(e)){if(!s.endsWith(".md"))continue;let u=/^---\r?\n([\s\S]*?)\r?\n---/.exec(await Pt(j.join(e,s),"utf8"))?.[1]??"";/^status:\s*open\s*$/m.test(u)&&(n+=1,/^severity:\s*blocking\s*$/m.test(u)&&(r+=1))}}catch{return[]}return n===0?[]:[`\u5F85\u7B54\u95EE\u9898 ${n} \u4E2A(blocking ${r}),\u89C1 \`.autocode/questions/\`(\u5728\u95EE\u9898\u6587\u4EF6\u300C\u56DE\u7B54\u300D\u6BB5\u4F5C\u7B54)`]}c(qt,"openQuestionLine");var zt=6e3;function K(t){let e=t.head??[],n=c(l=>l.reduce((h,g)=>h+g.length+1,0),"size"),r=Math.max(0,(t.budget??6e3)-t.guidance.length-n(e)),s=t.blocks.map(l=>[...l]),u=s.reduce((l,h)=>l+n(h),0),o=0;for(let l=s.length-1;l>=0&&u>r;l--){let h=s[l];for(;h.length>0&&u>r;)u-=h.pop().length+1,o+=1}let m=s.flat();return o>0&&m.push(`\u2026\u53E6\u6709 ${o} \u9879\u672A\u5217\u51FA,\u7528 \`autocode query <\u5173\u952E\u8BCD>\` \u68C0\u7D22 / ${o} more, use \`autocode query\``),{text:[...e,...m,t.guidance].join(`
|
|
2
|
+
`),truncated:o}}c(K,"applyBudget");import H from"node:path";var Vt=5,Kt=5,yt=2,Yt=.15;function $t(t){let e=new Map;for(let r of t)for(let s of new Set(r))e.set(s,(e.get(s)??0)+1);let n=Math.max(2,t.length*Yt);return new Set([...e].filter(([,r])=>r>n).map(([r])=>r))}c($t,"commonFiles");var Xt=/[\\/]/,Qt=/"([^"]+)"|'([^']+)'|(\S+)/g;function Zt(t,e,n=e){let r=/\s/.test(t.trim())?[...t.matchAll(Qt)].map(o=>o[1]??o[2]??o[3]??""):[t.trim()],s=H.resolve(e),u=new Set;for(let o of r){let m=o.replace(/^[(<]+|[;,)>]+$/g,"").replace(/:\d+(?::\d+)?$/,"");if(!Xt.test(m)&&!/\.\w{1,8}$/.test(m)||m.startsWith("-")||/^[a-z]+:\/\//i.test(m))continue;let l=H.relative(s,H.resolve(n||e,m));l===""||l.startsWith("..")||H.isAbsolute(l)||u.add(z(l).replace(/\/+$/,""))}return[...u]}c(Zt,"filesOfOp");function Y(t,e){return[...new Set(t.ops.flatMap(n=>Zt(n,e,t.cwd)))]}c(Y,"filesOfCapture");var Tt=/^[\w$./:-]+$/;function te(t,e){return ee(e)(t)}c(te,"mentions");function ee(t){if(!Tt.test(t))return r=>r.includes(t);let e=t.replaceAll(/[.*+?^${}()|[\]\\/]/g,"\\$&"),n=new RegExp(`(?<![\\w$])${e}(?![\\w$])`);return r=>n.test(r)}c(ee,"mentionMatcher");function x(t){return Tt.test(t)}c(x,"isAsciiName");function Le(t,e){let n=new Set(e.files.map(o=>z(o)).filter(o=>!e.common?.has(o))),r=[...new Set(e.names??[])].filter(o=>o.length>=Kt),s=[...new Set(e.terms??[])].filter(o=>o.length>=2);if(n.size===0&&r.length===0&&s.length===0)return[];let u=[];for(let o of t){if(C(o.user))continue;let m=Y(o,e.root).filter(d=>n.has(d)).length,l=`${o.user}
|
|
3
|
+
${o.assistant}`,h=r.filter(d=>te(l,d)).length,g=s.filter(d=>o.user.includes(d)).length;m===0&&h===0&&g<yt||u.push({capture:o,overlap:m*3+h*2+(g>=yt?g:0)})}return u.sort((o,m)=>m.overlap-o.overlap||m.capture.id-o.capture.id),u.slice(0,Vt)}c(Le,"selectRelevantCaptures");var wt=/[\w$]/;function Nt(t){let e=new Map;for(let n of new Set(t)){if(n.length===0)continue;let r=e.get(n[0])??[];r.push({name:n,ascii:x(n)}),e.set(n[0],r)}return n=>{let r=new Set;for(let s=0;s<n.length;s++){let u=e.get(n[s]);if(u)for(let{name:o,ascii:m}of u)r.has(o)||!n.startsWith(o,s)||m&&(wt.test(n[s-1]??"")||wt.test(n[s+o.length]??""))||r.add(o)}return r}}c(Nt,"nameScanner");var ne=15,oe=5,re=.15,se=5,ce=2,X={files:3,names:3,terms:5},ie=.5,ae=2;function Q(t){return t.length>=se&&(/::|[./_]/.test(t)||/[a-z][A-Z]|[A-Z]{2}[a-z]/.test(t))}c(Q,"distinctiveIdentifier");function Ot(t){let e=x(t.term)?Q(t.term):t.term.length>=2,n=t.aliases.filter(r=>x(r)?Q(r):r.length>=3);return[...e?[t.term]:[],...n]}c(Ot,"termNames");function Ct(t){return t.names.filter(e=>e.startsWith("/")||/\s\//.test(e)||Q(e)||!x(e)&&e.length>=3)}c(Ct,"documentNames");var ue=20;function xt(t){return t.title.replace(/ · .*$/,"").trim()}c(xt,"titleOf");function Rt(t,e){if(t.length===0)return{terms:[],documents:[]};let n=e.documents,r=$t(n.map(i=>i.files)),s=new Map;for(let i of n)for(let f of new Set(i.terms))s.set(f,(s.get(f)??0)+1);let u=Math.max(2,n.length*re),o=c(i=>(s.get(i)??0)>u,"common"),m=Nt([...e.terms.flatMap(Ot),...n.flatMap(Ct),...n.map(xt).filter(i=>i.length>=2)]),l=t.map(i=>({said:m(i.said),replied:m(i.replied),files:new Set(i.files),fileWeight:Math.min(1,ue/Math.max(1,i.files.length))})),h=t.map(()=>new Set),g=[];for(let i of e.terms){let f=Ot(i),p=f.filter($=>x($)||$.length>=3),y=i.files.filter($=>!r.has($)),a=0;t.forEach(($,R)=>{let{said:G,replied:J,files:v,fileWeight:b}=l[R],M=f.some(T=>G.has(T))?1:p.some(T=>J.has(T))?.5:0,F=y.some(T=>v.has(T))?.5*b:0;M>0&&!o(i.term)&&h[R].add(i.term),a+=$.weight*(M+F)}),o(i.term)&&(a*=.25),a>=ie&&g.push({term:i,score:a})}let d=g.sort((i,f)=>f.score-i.score||+(f.term.status==="confirmed")-+(i.term.status==="confirmed")||i.term.term.localeCompare(f.term.term)).slice(0,ne),E=new Map,S=c((i,f,p)=>{let y=E.get(i.path)??{document:i,score:0,reasons:new Map};y.score+=f;for(let[a,$]of p)y.reasons.set(a,(y.reasons.get(a)??0)+$);E.set(i.path,y)},"credit");for(let i of n){let f=Ct(i),p=i.files.filter(a=>!r.has(a)),y=xt(i);t.forEach((a,$)=>{let{said:R,replied:G,files:J,fileWeight:v}=l[$],b=f.filter(w=>R.has(w)||G.has(w)).slice(0,X.names),M=p.filter(w=>J.has(w)).slice(0,X.files),F=i.terms.filter(w=>h[$].has(w)),T=F.length>=ce?F.slice(0,X.terms):[],ot=y.length>=2&&!o(y)&&R.has(y),rt=a.weight*(M.length*3*v+b.length*2+T.length+(ot?2:0));rt<=0||S(i,rt,[...M.map(w=>[`\u5BF9\u8BDD\u8BFB\u8FC7 ${w}`,a.weight*3*v]),...b.map(w=>[`\u63D0\u5230 \`${w}\``,a.weight*2]),...T.length>0?[[`\u672F\u8BED ${T.join("\u3001")}`,a.weight*T.length]]:[],...ot?[[`\u63D0\u5230\u300C${y}\u300D`,a.weight*2]]:[]])})}let O=new Map(n.map(i=>[i.path,i]));for(let i of[...E.values()].filter(f=>f.document.layer==="unit"))for(let f of i.document.up){let p=O.get(f);p&&S(p,i.score/2,[[`\u4E0B\u5C5E\u5355\u5143\u300C${i.document.title}\u300D\u76F8\u5173`,i.score/2]])}let I=[...E.values()].filter(i=>i.score>=ae).sort((i,f)=>f.score-i.score||i.document.path.localeCompare(f.document.path)).slice(0,oe).map(i=>({document:i.document,score:i.score,reasons:[...i.reasons].sort((f,p)=>p[1]-f[1]).map(([f])=>f).slice(0,3)}));return{terms:d,documents:I}}c(Rt,"scoreContext");var Mt="inject.session.";function Z(t,e){return t.connection.prepare("SELECT value FROM meta WHERE key = ?").get(Mt+e)===void 0}c(Z,"isFirstTurn");function tt(t,e){t.connection.prepare("INSERT INTO meta (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value").run(Mt+e,new Date().toISOString())}c(tt,"markInjected");var Dt="inject.seen.",_t=5;function jt(t,e){let n=t.connection.prepare("SELECT value FROM meta WHERE key = ?").get(Dt+e);try{let r=n?JSON.parse(n.value):{};return{turn:r.turn??0,documents:r.documents??{},terms:r.terms??{}}}catch{return{turn:0,documents:{},terms:{}}}}c(jt,"readSeen");function At(t,e,n){let r=c(s=>Object.fromEntries(Object.entries(s).filter(([,u])=>n.turn+1-u<=_t)),"recent");t.connection.prepare("INSERT INTO meta (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value").run(Dt+e,JSON.stringify({turn:n.turn,documents:r(n.documents),terms:r(n.terms)}))}c(At,"writeSeen");function et(t,e,n){let r=t[e];return r!==void 0&&n>r&&n-r<=_t}c(et,"seenRecently");function nt(t=process.env){return t.AUTOCODE_INJECT==="0"||dt(t)}c(nt,"injectionDisabled");var A=`${N}/`,me={object:"\u5BF9\u8C61",state:"\u72B6\u6001",event:"\u4E8B\u4EF6",action:"\u52A8\u4F5C"};function le(t){return["\u672C\u4ED3\u5E93\u6709\u4E1A\u52A1\u77E5\u8BC6\u5E93(\u7531 autocode \u751F\u6210),\u6D89\u53CA\u4E1A\u52A1\u542B\u4E49\u3001\u4E1A\u52A1\u89C4\u5219\u3001\u6D41\u7A0B\u6216\u53E3\u5F84\u65F6\u53EF\u4EE5\u76F4\u63A5\u67E5\u770B / This repository has a business knowledge base:",...t?[`- \u4E1A\u52A1\u672F\u8BED:${A}${D}(\u4E1A\u52A1\u53E3\u5F84;\u72B6\u6001\u4E3A\u300C\u5DF2\u786E\u8BA4\u300D\u7684\u7531\u4EBA\u62CD\u677F)`]:[],`- \u9886\u57DF\u6587\u6863:${A}${U}/(\u4E00\u4E2A\u4E1A\u52A1\u6A21\u5757\u4E00\u7BC7,\u542B\u9886\u57DF\u89C4\u5219)`,`- \u5355\u5143\u6587\u6863:${A}${L}/(\u4E00\u4E2A\u80FD\u529B\u4E00\u7BC7,\u542B\u4EE3\u7801\u951A\u70B9)`,`- \u5165\u53E3\u76EE\u5F55:${A}${W}(\u5168\u90E8\u8DEF\u7531\u3001\u9875\u9762\u3001\u6D88\u8D39\u8005\u7B49\u5165\u53E3\u53CA\u6240\u5C5E\u5355\u5143)`,""]}c(le,"locations");var fe=["","\u4EE5\u4E0A\u672F\u8BED\u4E0E\u6587\u6863\u662F\u6309\u672C\u8F6E\u8F93\u5165\u548C\u6700\u8FD1\u7684\u5BF9\u8BDD\u7531\u4EE3\u7801\u6311\u51FA\u7684\u7EBF\u7D22,\u4E0D\u4FDD\u8BC1\u5B8C\u6574;\u4E0E\u5F53\u524D\u4EFB\u52A1\u65E0\u5173\u5C31\u5FFD\u7565\u3002","\u9700\u8981\u8BE6\u60C5\u65F6\u76F4\u63A5\u8BFB\u5BF9\u5E94\u6587\u6863,\u6216\u8FD0\u884C `autocode query <\u5173\u952E\u8BCD>`(\u672F\u8BED\u91CA\u4E49\u3001\u6587\u6863\u3001\u4EE3\u7801\u951A\u70B9)\u3001`autocode graph <\u951A\u70B9>`(\u8C03\u7528\u94FE);\u4E0D\u8981\u51ED\u6807\u9898\u731C\u6D4B\u5185\u5BB9\u3002","The terms and documents above were picked by code from this prompt and the recent turns \u2014 clues, not a complete list. Read the documents, or run `autocode query` / `autocode graph` for more."].join(`
|
|
4
|
+
`);function k(t,e,n,r,s,u){let o=Rt(e,t),m=c(a=>et(n.terms,a,r),"repeatedTerm"),l=c(a=>et(n.documents,a,r),"repeatedDocument"),h=o.terms.filter(a=>!m(a.term.term)),g=o.terms.filter(a=>m(a.term.term)),d=o.documents.filter(a=>!l(a.document.path)),E=o.documents.filter(a=>l(a.document.path)),S=o.terms.length===0?[]:[`\u76F8\u5173\u4E1A\u52A1\u672F\u8BED(\u91CA\u4E49\u89C1 ${A}${D} \u6216 \`autocode query <\u672F\u8BED>\`):`,...h.map(({term:a})=>`- ${a.term}(${a.module} \xB7 ${me[a.kind]??a.kind} \xB7 ${a.status==="confirmed"?"\u5DF2\u786E\u8BA4":"\u5F85\u786E\u8BA4"})`),...g.length>0?[`- \u524D\u51E0\u8F6E\u5DF2\u5217\u51FA:${g.map(({term:a})=>a.term).join("\u3001")}`]:[],""],O=o.documents.length===0?[]:["\u53EF\u80FD\u76F8\u5173\u7684\u6587\u6863:",...d.flatMap(a=>pe(a.document,a.reasons)),...E.length>0?[`- \u524D\u51E0\u8F6E\u5DF2\u63D0\u4F9B:${E.map(a=>a.document.path).join("\u3001")}`]:[],""],I=t.documents.filter(a=>a.layer==="domain"),i=I.length===0?[]:["\u9886\u57DF\u76EE\u5F55:",...I.map(a=>`- ${a.title.replace(/ · .*$/,"")} \xB7 ${a.path}`),""],f=K({guidance:fe,head:le(t.terms.length>0),blocks:[S,O,i,s],budget:u-ft}),p=pt(f.text),y=f.truncated;return{text:p,truncated:y,picked:o,injected:{documents:d.filter(a=>p.includes(`${vt(a.document)}
|
|
5
|
+
`)).map(a=>a.document.path),terms:h.map(a=>a.term.term).filter(a=>p.includes(`- ${a}(`))}}}c(k,"composeInjection");var kt=80;function vt(t){let e=t.layer==="domain"?"\u9886\u57DF":"\u5355\u5143",n=t.confidence!==void 0?` \xB7 \u7F6E\u4FE1\u5EA6 ${t.confidence.toFixed(2)}`:"";return`- ${e}${n} \xB7 ${t.title} \xB7 ${t.path}`}c(vt,"documentHeader");function pe(t,e){let n=t.summary.length>kt?`${t.summary.slice(0,kt)}\u2026`:t.summary;return[vt(t),...n?[` ${n}`]:[],` \u76F8\u5173\u539F\u56E0:${e.join(";")}`,...t.rules.length>0?[` \u9886\u57DF\u89C4\u5219:${t.rules.slice(0,3).join(";")}`]:[]]}c(pe,"documentLines");var de=3,he=.2;function ge(t){return 1/(1+he*t)}c(ge,"historyWeight");function B(t,e,n,r){let s=[];return t.trim().length>0&&!C(t)&&s.push({said:t,replied:"",files:[],weight:de}),e.filter(o=>!C(o.user)).slice(-r).reverse().forEach((o,m)=>{s.push({said:o.user,replied:o.assistant,files:Y(o,n),weight:ge(m+1),captureId:o.id})}),s}c(B,"conversationContext");async function Ee(t,e,n={},r=P.inject){let{readCatalog:s}=await import("./chunk-TK24OTGL.js"),u=await s(t),o=new Map;for(let l of _(e,n.session?{session:n.session}:{}))C(l.user)||o.set(l.sessionId,[...o.get(l.sessionId)??[],l]);let m=[];for(let[l,h]of o){let g={turn:0,documents:{},terms:{}};h.forEach((d,E)=>{let S=E+1,O=B(d.user,h.slice(0,E),t,r.historyTurns),I=k(u,O,g,S,[],r.budgetChars),i=new Set(I.injected.documents),f=new Set(I.injected.terms);m.push({captureId:d.id,sessionId:l,turn:S,prompt:d.user,picked:I.picked,repeated:{documents:I.picked.documents.map(p=>p.document.path).filter(p=>!i.has(p)&&I.text.includes(p)),terms:I.picked.terms.map(p=>p.term.term).filter(p=>!f.has(p))},text:I.text,truncated:I.truncated});for(let p of I.injected.documents)g.documents[p]=S;for(let p of I.injected.terms)g.terms[p]=S;g.turn=S})}return m.sort((l,h)=>l.captureId-h.captureId)}c(Ee,"replayInjection");async function ye(t){let e=P.inject,n;try{n=await Ie(bt.join(t,N,st),"utf8")}catch{return e}let r=n.split(/\r?\n/),s=r.findIndex(m=>/^inject:\s*$/.test(m)),u=[];for(let m of s===-1?[]:r.slice(s+1)){if(!/^\s/.test(m))break;u.push(m.trim())}let o=c((m,l,h,g)=>{let d=Number(u.find(E=>E.startsWith(`${m}:`))?.slice(m.length+1).replace(/#.*$/,"").trim());return Number.isInteger(d)&&d>=l&&d<=h?d:g},"read");return{historyTurns:o("historyTurns",1,100,e.historyTurns),budgetChars:o("budgetChars",1e3,3e4,e.budgetChars)}}c(ye,"injectOptions");async function Rn(t,e,n={},r={}){let s={text:"",firstTurn:!1,truncated:0};try{if(nt(n.env)||!n.db&&!Se(bt.join(t,N)))return s;let u=await ye(t),o=n.db??mt(t),m=!n.db;try{let l=await gt(t,o);if(l.terms.length===0&&l.documents.length===0)return s;let h=Z(o,e);tt(o,e);let g=B(r.prompt??"",_(o,{session:e}),t,u.historyTurns),d=jt(o,e),E=d.turn+1,S=k(l,g,d,E,await $e(t,o),u.budgetChars);for(let O of S.injected.documents)d.documents[O]=E;for(let O of S.injected.terms)d.terms[O]=E;return At(o,e,{...d,turn:E}),{text:S.text,firstTurn:h,truncated:S.truncated,picked:S.picked}}finally{m&&o.close()}}catch{return s}}c(Rn,"runInject");async function $e(t,e){let n=lt(e)||_(e,{pending:!0}).length,[r,s]=Te(await It(t,e));return[...r,...n>0?[`\u672A\u96C6\u6210\u5BF9\u8BDD ${n} \u6761,\u5EFA\u8BAE\u8FD0\u884C \`autocode wiki\` \u6D88\u5316`]:[],...s]}c($e,"statusLines");function Te(t){return[t.filter(e=>e.startsWith("- [\u53D8\u66F4/change]")),t.filter(e=>!e.startsWith("- [\u53D8\u66F4/change]"))]}c(Te,"splitStatus");export{zt as a,K as b,$t as c,Y as d,te as e,Le as f,Z as g,tt as h,nt as i,k as j,Ee as k,ye as l,Rn as m};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e,m as f,n as g}from"./chunk-ZXRDZ4KX.js";import{a,b}from"./chunk-BD2OOWDK.js";import{c as d}from"./chunk-7LS5USHJ.js";import{d as c}from"./chunk-MHDSNQAC.js";import"./chunk-CBLU2NBO.js";import"./chunk-XUSV3KOD.js";export{c as captures,g as findWorkspaceRoot,d as logs,b as openStateDb,f as runs,a as stateDbPath,e as tasks};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s}from"./chunk-HO3X6IFQ.js";import"./chunk-CBLU2NBO.js";import"./chunk-XUSV3KOD.js";export{r as absorbableParts,a as changeDir,i as changeHash,c as changesRoot,e as findChangeId,b as isChangeSource,d as kindOfId,k as listChangeDocs,l as listChangeFolders,g as nextChangeId,s as overviewOf,j as readChangeDoc,n as removeChangeFolder,h as serializeWithFrontmatter,p as setIntegrateStatus,o as setPlanStatus,f as slugify,q as stampConfirmedAt,m as writeChangeFile};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import{a as m}from"./chunk-XUSV3KOD.js";import{fileURLToPath as S}from"node:url";process.removeAllListeners("warning");process.on("warning",()=>{});function j(e){let t=e.indexOf("--source");return t!==-1&&e[t+1]==="codex"?"codex":"claude-code"}m(j,"readSourceFlag");function f(e,t){let s=e.indexOf(t);return s!==-1?e[s+1]:void 0}m(f,"flagValue");function k(e,t){for(let s of t){let n=e[s];if(typeof n=="string"&&n.length>0)return n}}m(k,"firstString");async function x(e){let t=await h(),s=await import("./chunk-LVFFUKWY.js"),{openStateDb:n}=await import("./chunk-UCR2PGFQ.js"),a=n(t);try{let o=f(e,"--session"),u=await s.replayInjection(t,a,o?{session:o}:{},await s.injectOptions(t));if(e.includes("--json")){let c=u.map(d=>({captureId:d.captureId,sessionId:d.sessionId,turn:d.turn,prompt:d.prompt,terms:d.picked.terms.map(w=>({term:w.term.term,score:Number(w.score.toFixed(2))})),documents:d.picked.documents.map(w=>({path:w.document.path,score:Number(w.score.toFixed(2)),reasons:w.reasons})),repeated:d.repeated,length:d.text.length,truncated:d.truncated}));return process.stdout.write(JSON.stringify({ok:!0,command:"inject replay",data:{turns:c},problems:[],changes:[]},null,2)+`
|
|
2
|
+
`),0}let r=[];for(let c of u){r.push(`#${c.captureId} \xB7 \u4F1A\u8BDD ${c.sessionId.slice(0,8)} \u7B2C ${c.turn} \u8F6E \xB7 ${c.text.length} \u5B57${c.truncated>0?`(\u622A\u6389 ${c.truncated} \u884C)`:""}`),r.push(` \u8F93\u5165:${c.prompt.replaceAll(/\s+/g," ").slice(0,80)}`),r.push(` \u672F\u8BED:${c.picked.terms.map(d=>d.term.term).join("\u3001")||"(\u65E0)"}`),c.picked.documents.length===0&&r.push(" \u6587\u6863:(\u65E0)");for(let d of c.picked.documents){let w=c.repeated.documents.includes(d.document.path)?" [\u524D\u51E0\u8F6E\u5DF2\u63D0\u4F9B]":"";r.push(` \u6587\u6863:${d.document.path}(${d.score.toFixed(1)})${w} ${d.reasons.join(";")}`)}e.includes("--full")&&r.push("",...c.text.split(`
|
|
3
|
+
`).map(d=>` ${d}`)),r.push("")}let l=u.filter(c=>c.picked.documents.length>0).length,i=Math.max(0,...u.map(c=>c.text.length));return r.push(`\u5171 ${u.length} \u8F6E;\u5E26\u6587\u6863\u7EBF\u7D22 ${l} \u8F6E;\u6700\u957F ${i} \u5B57`),process.stdout.write(r.join(`
|
|
4
|
+
`)+`
|
|
5
|
+
`),0}finally{a.close()}}m(x,"runInjectReplay");async function $(){let e=[];for await(let t of process.stdin)e.push(t);return Buffer.concat(e).toString("utf8")}m($,"readAllStdin");var O=m(()=>S(new URL("./index.js",import.meta.url)),"selfPath");async function h(){let{findWorkspaceRoot:e}=await import("./chunk-UCR2PGFQ.js");return await e(process.cwd())??process.cwd()}m(h,"workspaceRoot");async function A(e){let t=await import("./chunk-UCR2PGFQ.js"),s=t.openStateDb(await h());try{let n=e[0];if(n==="list"){let a={};e.includes("--pending")&&(a.pending=!0);let o=f(e,"--source");(o==="codex"||o==="claude-code")&&(a.source=o);let u=f(e,"--session");u!==void 0&&(a.session=u);let r=t.captures.listCaptures(s,a);if(e.includes("--json"))process.stdout.write(JSON.stringify({ok:!0,command:"captures list",data:{captures:r},problems:[],changes:[]},null,2)+`
|
|
6
|
+
`);else for(let l of r)process.stdout.write(`${l.id} ${l.ts} ${l.source} ${l.consumed?"consumed":"pending"} ${l.user.slice(0,60).replaceAll(`
|
|
7
|
+
`," ")}
|
|
8
|
+
`);return 0}if(n==="mark"){let a=!e.includes("--unconsumed"),o=e.slice(1).filter(u=>/^\d+$/.test(u)).map(Number);return o.length===0?(process.stderr.write(`captures mark: no ids given
|
|
9
|
+
`),2):(t.captures.markConsumed(s,o,a),0)}return process.stderr.write("captures: expected `list` or `mark`\n"),2}finally{s.close()}}m(A,"runCaptures");async function J(e){let t=await import("./chunk-UCR2PGFQ.js"),s=t.openStateDb(await h());try{let n=e[0];if(n==="show"){let p=Number(e[1]),g=Number.isInteger(p)?t.logs.getLog(s,p):void 0;return g?(process.stdout.write(JSON.stringify(g,null,2)+`
|
|
10
|
+
`),0):(process.stderr.write(`logs show: no row ${e[1]??""}
|
|
11
|
+
`),1)}if(n==="stats")return process.stdout.write(JSON.stringify(t.logs.logStats(s),null,2)+`
|
|
12
|
+
`),0;if(n==="prune"){let p={},g=f(e,"--before");g!==void 0&&(p.before=g);let b=f(e,"--run");b!==void 0&&(p.runId=b);let y=f(e,"--keep-last");if(y!==void 0&&Number.isInteger(Number(y))&&(p.keepLast=Number(y)),Object.keys(p).length===0)return process.stderr.write(`logs prune: give --before <iso>, --run <id> or --keep-last N
|
|
13
|
+
`),2;let I=t.logs.pruneLogs(s,p);return process.stdout.write(JSON.stringify({ok:!0,command:"logs prune",data:{removed:I},problems:[],changes:[]})+`
|
|
14
|
+
`),0}let a=f(e,"--limit"),o=f(e,"--after"),u={newestFirst:!e.includes("--oldest"),limit:a!==void 0&&Number.isInteger(Number(a))?Number(a):50},r=f(e,"--command");r!==void 0&&(u.command=r);let l=f(e,"--run");l!==void 0&&(u.runId=l);let i=f(e,"--task");i!==void 0&&(u.taskTarget=i);let c=f(e,"--event");c!==void 0&&(u.event=c);let d=f(e,"--invocation");d!==void 0&&(u.invocationId=d),o!==void 0&&Number.isInteger(Number(o))&&(u.afterId=Number(o));let w=t.logs.listLogs(s,u);if(e.includes("--json"))return process.stdout.write(JSON.stringify({ok:!0,command:"logs",data:{logs:w},problems:[],changes:[]},null,2)+`
|
|
15
|
+
`),0;for(let p of w){let g=JSON.stringify(p.data??null).slice(0,120).replaceAll(`
|
|
16
|
+
`," ");process.stdout.write([p.id,p.ts,p.command,p.event,p.taskTarget??"-",p.attempt!==void 0?`#${p.attempt}`:"-",p.durationMs!==void 0?`${p.durationMs}ms`:"-",g].join(" ")+`
|
|
17
|
+
`)}return 0}finally{s.close()}}m(J,"runLogs");var N=`USAGE
|
|
18
|
+
autocode migrate [--dry-run] [--json]
|
|
19
|
+
autocode migrate --help
|
|
20
|
+
`,L=new Set(["--dry-run","--json"]);async function C(e){if(e.includes("--help")||e.includes("-h"))return process.stdout.write(N),0;let t=e.filter(i=>!L.has(i));if(t.length>0)return process.stderr.write(`migrate: unknown argument ${t.join(" ")}
|
|
21
|
+
${N}`),2;let s=await h(),n=await import("./chunk-BHULUCLO.js"),a=e.includes("--dry-run"),o=await n.runMigrate(s,{dryRun:a});if(e.includes("--json"))return process.stdout.write(JSON.stringify({ok:o.steps.every(i=>!i.error),command:"migrate",data:o,problems:o.steps.filter(i=>i.error).map(i=>({step:i.name,error:i.error})),changes:[]},null,2)+`
|
|
22
|
+
`),o.steps.some(i=>i.error)?1:0;let r=(await n.loadConfig(s)).language,l=[n.t("migrate.header",r,{mode:n.t(a?"migrate.mode.dry":"migrate.mode.apply",r),steps:o.steps.length})];for(let i of o.steps){if(i.error){l.push(`- ${n.t("migrate.stepFailed",r,{name:i.name,error:i.error})}`);continue}l.push(`- ${n.t("migrate.step",r,{name:i.name,count:i.changes.length})}`);for(let c of i.changes)l.push(` - ${c.action} ${c.path} \u2014\u2014 ${c.detail}`)}return o.steps.every(i=>i.changes.length===0&&!i.error)&&l.push(n.t("migrate.noChanges",r)),process.stdout.write(l.join(`
|
|
23
|
+
`)+`
|
|
24
|
+
`),o.steps.some(i=>i.error)?1:0}m(C,"runMigrateCommand");async function F(e,t){try{if(e==="logs")return await J(t);if(e==="migrate")return await C(t);if(e==="capture"){let s=await $(),{runCapture:n}=await import("./chunk-MR7DHACF.js");return await n(await h(),j(t),s,{binPath:O()}),0}if(e==="inject"){if(t.includes("--replay"))return await x(t);let s=await $(),n="unknown",a="";try{let r=JSON.parse(s);n=k(r,["session_id","sessionId","thread_id"])??n,a=k(r,["prompt","user_prompt","input"])??""}catch{}let{runInject:o}=await import("./chunk-LVFFUKWY.js"),u=await o(await h(),n,{},{prompt:a});return u.text.length>0&&process.stdout.write(JSON.stringify({hookSpecificOutput:{hookEventName:"UserPromptSubmit",additionalContext:u.text}})+`
|
|
25
|
+
`),0}if(e==="captures")return await A(t);if(e==="digest-daemon"){let s=await h(),n=await import("./chunk-BHULUCLO.js"),a=n.openStateDb(s),o=n.createLogger(a,{command:"digest",invocationId:n.newInvocationId()}),u=Date.now();try{o.log("command.start",{argv:t,cwd:s});let r=await n.withLogger(o,()=>n.runDigest(s,{db:a}));o.log("command.finish",{status:r.status,changes:r.changes},Date.now()-u)}finally{a.close()}return 0}return 2}catch{return e==="captures"||e==="logs"?1:0}}m(F,"runHiddenCommand");export{F as runHiddenCommand};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{e as L}from"./chunk-KKQQYXWN.js";import{H as O,g as A,q as $}from"./chunk-CBLU2NBO.js";import{a as i}from"./chunk-XUSV3KOD.js";import{z as u}from"zod";import{AsyncLocalStorage as Y}from"node:async_hooks";import{z as b}from"zod";var _=new Y;async function ot(t){let e=[];return{result:await _.run(e,t),coercions:e}}i(ot,"collectCoercions");function N(t){return t===null?"null":Array.isArray(t)?"array":typeof t}i(N,"kindOf");function j(t,e,n){_.getStore()?.push({path:t.path.join("."),from:N(e),to:n})}i(j,"record");function y(){let t=b.array(b.string());return b.preprocess((e,n)=>e==null?(e===null&&j(n,e,"array"),[]):typeof e=="string"?(j(n,e,"array"),e.trim()===""?[]:[e]):e,t)}i(y,"stringList");function M(t){let e=b.string();return b.preprocess((n,s)=>n??(n===null&&j(s,n,"string"),t),e)}i(M,"textOr");function rt(t){return b.preprocess((e,n)=>e??(e===null&&j(n,e,"array"),[]),t)}i(rt,"listOr");function it(t,e){return b.preprocess((n,s)=>{if(typeof n!="object"||n===null||Array.isArray(n))return n;let r={...n};return e(r,(o,f)=>_.getStore()?.push({path:[...s.path,o].join("."),from:N(n[o]),to:f})),r},t)}i(it,"patched");var w=["object","state","event","action"],ut=u.object({module:u.string().optional().describe("leave empty: the term belongs to this task's module. Name another module ONLY when the concept clearly belongs there by the module guide (it owns the object's lifecycle, or the term's anchors sit in that module's code location) \u2014 it must be one of the listed modules; an unlisted module is rejected, raise a question instead"),kind:u.enum(w).describe("exactly one of: object (what the system manages, with attributes and relations) / state (the situation an object is in; names its object) / event (a fact that has happened; may move an object between states) / action (what the system does). No other kind exists: whoever triggers the system (a user, a role, a scheduler, a third-party platform) is not a term \u2014 the action it triggers is; a policy is a rule not a term; UI behaviour is not a term"),term:u.string().min(1).describe("the term, one concept one name, unique within the module"),definition:u.string().min(1).describe("one-line definition in the reader's business language"),aliases:y().describe("other names seen in code or conversation; retrieval only"),object:M("").describe("for state (required) and event (optional): the object this belongs to, declared in this module; empty otherwise"),relations:y().default([]).describe("for object only: other objects of this module it holds or refers to (declared term names); empty otherwise"),effects:y().default([]).describe("for action only: events (declared term names) this action produces; empty otherwise"),side_effects:y().default([]).describe("for action only: effects leaving the system boundary \u2014 an external call, a message sent, a file written \u2014 in plain words; empty otherwise"),transitions:u.object({from:u.string().describe("the state the object leaves; empty string when it is the initial transition"),to:u.string().min(1).describe("the state the object enters (must be declared for the same object)")}).nullable().default(null).describe("for event only: which state change it causes; null when the event changes no state and for every other kind"),anchors:u.array(u.string()).min(1).describe("qualifiedNames of the code symbols carrying this concept, copied VERBATIM from the symbol map \u2014 at least one, never a file path")});import{mkdir as U,readFile as D,writeFile as z}from"node:fs/promises";import T from"node:path";function gt(t,e){return{module:e,kind:t.kind,term:t.term,definition:t.definition,aliases:t.aliases,object:t.object,relations:t.relations,effects:t.effects,sideEffects:t.side_effects,transitions:t.transitions,anchors:t.anchors,status:"pending"}}i(gt,"termFromPayload");function x(t){return`${t.module}.${t.kind}.${t.term}`}i(x,"termKey");var v={entity:"object","value-object":"object",command:"action",event:"event",state:"state"},F={zh:"# \u4E1A\u52A1\u672F\u8BED",en:"# Business terms"},q={zh:"| \u72B6\u6001 | \u7C7B\u578B | \u672F\u8BED | \u5B9A\u4E49 | \u522B\u540D | \u6240\u5C5E\u5BF9\u8C61 | \u5173\u7CFB | \u6D41\u8F6C / \u6548\u679C | \u526F\u4F5C\u7528 | \u951A\u70B9 | \u540C\u540D\u4E8E |",en:"| Status | Kind | Term | Definition | Aliases | Object | Relations | Transition / Effects | Side effects | Anchors | Same name in |"},P="|---|---|---|---|---|---|---|---|---|---|---|",R={zh:{pending:"\u5F85\u786E\u8BA4",confirmed:"\u5DF2\u786E\u8BA4"},en:{pending:"pending",confirmed:"confirmed"}},V=new Map(Object.values(R).flatMap(t=>Object.entries(t).map(([e,n])=>[n.toLowerCase(),e]))),I=new Map(w.map((t,e)=>[t,e])),B={zh:{object:"\u5BF9\u8C61",state:"\u72B6\u6001",event:"\u4E8B\u4EF6",action:"\u52A8\u4F5C"},en:{object:"Object",state:"State",event:"Event",action:"Action"}},G={\u5B9E\u4F53:"entity",\u503C\u5BF9\u8C61:"value-object",\u547D\u4EE4:"command",\u4E8B\u4EF6:"event",\u72B6\u6001:"state",Entity:"entity","Value object":"value-object",Command:"command",Event:"event",State:"state"},K=new Map([...Object.values(B).flatMap(t=>Object.entries(t).map(([e,n])=>[n,e])),...w.map(t=>[t,t]),...Object.entries(G).map(([t,e])=>[t,v[e]]),...Object.entries(v).map(([t,e])=>[t,e])]),H=new Set(["\u53C2\u4E0E\u8005","Actor","actor"]),yt=new Set([...H,...Object.keys(G).filter(t=>!["\u4E8B\u4EF6","\u72B6\u6001","Event","State"].includes(t)),"entity","value-object","command"]);function W(t,e){return B[e][t]??t}i(W,"kindLabel");var l=i(t=>t.replaceAll("|","\\|").replaceAll(/\r?\n/g," ").trim(),"cell"),p=i(t=>t.replaceAll("\\|","|").trim(),"uncell"),S=i(t=>t===void 0||t==="\u2014"?"":p(t),"dash"),h=i(t=>S(t).split("\u3001").map(e=>e.trim()).filter(Boolean),"list");function X(t){return t.split(/(?<!\\)\|/).map(e=>e.trim())}i(X,"splitRow");function E(t){return t.object}i(E,"ownerOf");function J(t){return t.kind==="event"?t.transitions?`${t.transitions.from||"\u2205"} \u2192 ${t.transitions.to}`:"":t.kind==="action"?t.effects.join("\u3001"):""}i(J,"changeOf");function Q(t,e,n={}){let s=new Map((n.moduleOrder??[]).map((a,d)=>[a,d])),r=i(a=>s.get(a)??Number.MAX_SAFE_INTEGER,"rank"),o=new Map;for(let a of t)(o.get(a.term)??o.set(a.term,new Set).get(a.term)).add(a.module);let f=i(a=>[...o.get(a.term)??[]].filter(d=>d!==a.module).sort().join("\u3001"),"sameNameIn"),c=[...t].sort((a,d)=>r(a.module)-r(d.module)||a.module.localeCompare(d.module)||(I.get(a.kind)??99)-(I.get(d.kind)??99)||E(a).localeCompare(E(d))||a.term.localeCompare(d.term)),m=[F[e],""],g=null;for(let a of c)a.module!==g&&(g!==null&&m.push(""),g=a.module,m.push(`## ${g}`,"",q[e],P)),m.push(`| ${R[e][a.status]} | ${W(a.kind,e)} | ${l(a.term)} | ${l(a.definition)} | ${l(a.aliases.join("\u3001"))||"\u2014"} | ${l(E(a))||"\u2014"} | ${l(a.relations.join("\u3001"))||"\u2014"} | ${l(J(a))||"\u2014"} | ${l(a.sideEffects.join("\u3001"))||"\u2014"} | ${l(a.anchors.join("\u3001"))||"\u2014"} | ${l(f(a))||"\u2014"} |`);return m.push(""),m.join(`
|
|
2
|
+
`)}i(Q,"renderGlossary");function C(t){let e=S(t),n=/^(.*?)\s*→\s*(.+)$/.exec(e);return n?{from:n[1]==="\u2205"?"":n[1].trim(),to:n[2].trim()}:null}i(C,"parseTransition");var k=i((t,e,n,s)=>({module:t,kind:e,term:n,definition:s,aliases:[],object:"",relations:[],effects:[],sideEffects:[],transitions:null,anchors:[],status:"pending"}),"EMPTY_TERM");function Z(t){let e=[],n="";for(let s of t.split(`
|
|
3
|
+
`)){let r=/^## (.+)$/.exec(s);if(r){n=r[1].trim();continue}if(!s.trim().startsWith("|"))continue;let o=X(s);if(o[1]==="\u72B6\u6001"&&o[2]==="\u7C7B\u578B"||o[1]==="Status"&&o[2]==="Kind")continue;let f="pending";o.length===13&&(f=V.get((o[1]??"").toLowerCase())??"pending",o=[o[0],...o.slice(2)]);let c=o[1]??"";if(c===""||c.startsWith("-")||c==="\u7C7B\u578B"||c==="Kind"||c==="\u672F\u8BED"||c==="Term")continue;let m=e.length;tt(o,c,n,e);for(let g of e.slice(m))g.status=f}return e}i(Z,"parseGlossary");function tt(t,e,n,s){if(t.length===12){let r=K.get(e);if(!r)return;let o=k(n,r,p(t[2]),p(t[3]));o.aliases=h(t[4]),r!=="action"&&(o.object=S(t[5])),o.relations=h(t[6]),r==="event"&&(o.transitions=C(t[7])),r==="action"&&(o.effects=h(t[7])),o.sideEffects=h(t[8]),o.anchors=h(t[9]),s.push(o);return}if(t.length===9||t.length===10){let r=K.get(e);if(!r)return;let o=k(n,r,p(t[2]),p(t[3]));o.aliases=h(t[4]);let f=S(t[5]);(r==="state"||r==="event")&&(o.object=f),r==="event"&&(o.transitions=C(t[6])),o.anchors=h(t[7]),s.push(o);return}if(t.length===6){let r=k(p(t[4])||n,"object",p(e),p(t[2]));r.aliases=h(t[3]),s.push(r)}}i(tt,"parseRow");async function jt(t){try{return Z(await D(T.join(t,A,$),"utf8"))}catch{return[]}}i(jt,"readGlossaryTerms");function wt(t,e){let n=new Map;for(let s of t)n.set(x(s),{...s});for(let s of e){let r=x(s),o=n.get(r);if(o?.status==="confirmed"){o.definition!==s.definition&&L("glossary.confirmed-kept",{key:r,proposed:s.definition});continue}n.set(r,{...s,status:"pending",aliases:[...new Set([...o?.aliases??[],...s.aliases])],anchors:[...new Set([...o?.anchors??[],...s.anchors])]})}return[...n.values()]}i(wt,"mergeTerms");function Et(t,e){return t.filter(n=>n.module===e)}i(Et,"termsOfModule");function xt(t){return t.length===0?"":t.map(e=>{let n=E(e);return`- ${e.status==="confirmed"?"[\u5DF2\u786E\u8BA4 / confirmed] ":""}${x(e)}${n?`(${n})`:""}:${e.definition}`}).join(`
|
|
4
|
+
`)}i(xt,"formatExistingTerms");async function St(t,e,n,s={}){let r=`${A}/${$}`,o=T.join(t,r),f=Q(e,n,s),c=null;try{c=await D(o,"utf8")}catch{}return c!==null&&O(c)===O(f)?{written:!1}:(await U(T.dirname(o),{recursive:!0}),await z(o,f,"utf8"),{written:!0,change:{path:r,action:c===null?"added":"updated",summary:`\u4E1A\u52A1\u672F\u8BED ${e.length} \u6761(\u5DF2\u786E\u8BA4 ${e.filter(m=>m.status==="confirmed").length})`}})}i(St,"persistGlossary");function At(t,e,n){return t.filter(s=>{let r=x({module:s.module||e,kind:s.kind,term:s.term});return n.has(r)?(L("glossary.confirmed-kept",{key:r,in:"patch"}),!1):!0})}i(At,"withoutConfirmed");export{ot as a,y as b,M as c,rt as d,it as e,w as f,ut as g,gt as h,x as i,v as j,V as k,H as l,yt as m,W as n,Q as o,Z as p,jt as q,wt as r,Et as s,xt as t,St as u,At as v};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var d=Object.defineProperty;var e=(b,a)=>d(b,"name",{value:a,configurable:!0});var f=(b,a)=>{for(var c in a)d(b,c,{get:a[c],enumerable:!0})};export{e as a,f as b};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{J as _,K as S,g as i,h as f,m as R,n as m,o as T}from"./chunk-CBLU2NBO.js";import{a as e,b as E}from"./chunk-XUSV3KOD.js";var D={};E(D,{claim:()=>l,claimById:()=>x,complete:()=>k,defer:()=>N,enqueue:()=>g,fail:()=>A,listByRun:()=>W,resetRunning:()=>y,resetTask:()=>U,skip:()=>O});function o(){return new Date().toISOString()}e(o,"now");function g(t,n,r){let s=t.connection.prepare("INSERT INTO tasks (id, run_id, type, target, status, updated_at) VALUES (?, ?, ?, ?, 'pending', ?)"),d=[];for(let p of r){let c=S();s.run(c,n,p.type,p.target,o()),d.push(c)}return d}e(g,"enqueue");function u(t){return{id:t.id,runId:t.run_id,type:t.type,target:t.target,status:t.status,cost:t.cost,durationMs:t.duration_ms,error:t.error??void 0}}e(u,"toRecord");function l(t,n){let r=t.connection.prepare(`UPDATE tasks SET status = 'running', updated_at = ?
|
|
2
|
+
WHERE id = (SELECT id FROM tasks WHERE run_id = ? AND status = 'pending' ORDER BY rowid LIMIT 1)
|
|
3
|
+
AND status = 'pending'
|
|
4
|
+
RETURNING *`).get(o(),n);return r?u(r):void 0}e(l,"claim");function x(t,n){let r=t.connection.prepare(`UPDATE tasks SET status = 'running', updated_at = ?
|
|
5
|
+
WHERE id = ? AND status = 'pending'
|
|
6
|
+
RETURNING *`).get(o(),n);return r?u(r):void 0}e(x,"claimById");function k(t,n,r){t.connection.prepare("UPDATE tasks SET status = 'done', cost = ?, duration_ms = ?, updated_at = ? WHERE id = ?").run(r.cost,r.durationMs,o(),n)}e(k,"complete");function A(t,n,r,s){t.connection.prepare("UPDATE tasks SET status = 'failed', error = ?, raw_output = ?, updated_at = ? WHERE id = ?").run(r,s??null,o(),n)}e(A,"fail");function O(t,n){t.connection.prepare("UPDATE tasks SET status = 'skipped', updated_at = ? WHERE id = ?").run(o(),n)}e(O,"skip");function N(t,n){t.connection.prepare("UPDATE tasks SET status = 'deferred', updated_at = ? WHERE id = ?").run(o(),n)}e(N,"defer");function U(t,n){t.connection.prepare("UPDATE tasks SET status = 'pending', error = NULL, updated_at = ? WHERE id = ?").run(o(),n)}e(U,"resetTask");function y(t){t.connection.prepare("UPDATE tasks SET status = 'pending', updated_at = ? WHERE status = 'running'").run(o())}e(y,"resetRunning");function W(t,n){return t.connection.prepare("SELECT * FROM tasks WHERE run_id = ? ORDER BY rowid").all(n).map(u)}e(W,"listByRun");var I={};E(I,{createRun:()=>w,finishRun:()=>H,getRun:()=>L,listFailures:()=>P});function w(t,n){let r=_();return t.connection.prepare("INSERT INTO runs (id, started_at, mode) VALUES (?, ?, ?)").run(r,new Date().toISOString(),n),r}e(w,"createRun");function H(t,n,r){t.connection.prepare("UPDATE runs SET finished_at = ?, summary_json = ? WHERE id = ?").run(new Date().toISOString(),JSON.stringify(r),n)}e(H,"finishRun");function L(t,n){let r=t.connection.prepare("SELECT * FROM runs WHERE id = ?").get(n);if(r)return{id:r.id,startedAt:r.started_at,finishedAt:r.finished_at,mode:r.mode,summary:r.summary_json===null?void 0:JSON.parse(r.summary_json),reported:r.reported===1}}e(L,"getRun");function P(t,n){return t.connection.prepare("SELECT id, target, error, raw_output FROM tasks WHERE run_id = ? AND status = 'failed' ORDER BY rowid").all(n).map(s=>({taskId:s.id,target:s.target,error:s.error??"",rawOutput:s.raw_output}))}e(P,"listFailures");import{access as h,mkdir as F}from"node:fs/promises";import a from"node:path";var M=[R,m,T];async function C(t){let n=a.resolve(t);for(;;){if(await j(n))return n;let r=a.dirname(n);if(r===n)return null;n=r}}e(C,"findWorkspaceRoot");async function j(t){try{return await h(a.join(t,i,f)),!0}catch{return!1}}e(j,"isInitialized");async function q(t){for(let n of M)await F(a.join(t,i,n),{recursive:!0})}e(q,"ensureLayout");export{g as a,x as b,k as c,A as d,O as e,N as f,U as g,y as h,W as i,D as j,w as k,H as l,I as m,C as n,j as o,q as p};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Health-check the knowledge base - stale anchors, orphans, frontmatter, host file versions, tech debt (zero AI)
|
|
3
|
+
argument-hint: "[scope]"
|
|
4
|
+
<% if (host === "claude") { -%>
|
|
5
|
+
allowed-tools: Bash(autocode:*), Read, Glob, Grep
|
|
6
|
+
<% } -%>
|
|
7
|
+
autocode-template: 1
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# /auto-check
|
|
11
|
+
|
|
12
|
+
## Run
|
|
13
|
+
From the project root, with the Bash tool and a timeout of at least <%= timeoutMinutes %> minutes; never use inline `!` execution:
|
|
14
|
+
autocode check "$ARGUMENTS"
|
|
15
|
+
(Pass no quotes when there is no argument.)
|
|
16
|
+
|
|
17
|
+
## Relay
|
|
18
|
+
The output is sectioned Markdown grouped High / Medium / Low. Relay it as is; do not embellish or add conclusions the engine did not state.
|
|
19
|
+
- `host-outdated` means a host-side file is missing or behind; suggest the user run `autocode install`.
|
|
20
|
+
- "not initialised" → suggest /auto-init.
|
|
21
|
+
|
|
22
|
+
## Never
|
|
23
|
+
- Never create or edit anything under `.autocode/`; it is generated.
|
|
24
|
+
- Never answer the engine's questions on the user's behalf.
|
|
25
|
+
- Never decompose the work yourself or bypass the command to edit documents; the workflow lives in the engine.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Locate the original requirement (pasted text / URL / work item / file), produce the requirement restated in this project's business terms plus an implementation plan, for review and confirmation; implements the plan once the knowledge base reaches the development threshold and the user agrees
|
|
3
|
+
argument-hint: "<what to build, or where the source is: pasted text / URL / work item / file>"
|
|
4
|
+
<% if (host === "claude") { -%>
|
|
5
|
+
allowed-tools: Bash(autocode:*), Read, Glob, Grep, Edit, WebFetch, mcp__*
|
|
6
|
+
<% } -%>
|
|
7
|
+
autocode-template: 3
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# /auto-feat
|
|
11
|
+
|
|
12
|
+
## Step 1: locate the original requirement document
|
|
13
|
+
`$ARGUMENTS` is what the user said, not necessarily the requirement itself. Decide where the source is, in this order, and stop at the first hit:
|
|
14
|
+
1. The user pasted the requirement into the conversation → that is the source; take it verbatim, never rewrite or summarise.
|
|
15
|
+
2. The user gave a URL → fetch the page body with the web-fetch tool.
|
|
16
|
+
3. The user refers to a work item in a project tool (Feishu Project, Jira, ...) → fetch title, description and acceptance criteria with the matching MCP tool.
|
|
17
|
+
4. The user refers to a file in the repo → Read it.
|
|
18
|
+
5. None of the above → the user's words are the source; append the relevant background, goals, known files and constraints from the conversation, each marked "from conversation".
|
|
19
|
+
Put one source comment on the first line of the text: `<!-- autocode-source: conversation|url|mcp|file|prompt <reference> -->`.
|
|
20
|
+
When fetching the source:
|
|
21
|
+
- Feishu / Lark document links (`/wiki/`, `/docx/`) cannot be web-fetched: use lark-cli or a Feishu MCP when available to get the Markdown body, and download the images in it.
|
|
22
|
+
- Pages behind a login or rendered by scripts: use a browser automation tool when available.
|
|
23
|
+
- PDF: Read it directly (images and CJK PDFs included); do not use extraction tools such as pdftotext.
|
|
24
|
+
- Images, interface documents and other material the source refers to are not pasted into it: put them in a scratch folder inside the repo (not under `.autocode/`) and hand it over with `--attachments` in step 2. The engine keeps a copy in the change folder; the scratch folder can go afterwards.
|
|
25
|
+
|
|
26
|
+
## Step 2: run (source goes through stdin)
|
|
27
|
+
autocode feat "$ARGUMENTS" <<'AUTOCODE_ORIGINAL'
|
|
28
|
+
<source text>
|
|
29
|
+
AUTOCODE_ORIGINAL
|
|
30
|
+
Bash tool, timeout of at least <%= timeoutMinutes %> minutes. The source always goes through stdin, never into the argument.
|
|
31
|
+
- Material to hand over: add `--attachments <scratch folder>`.
|
|
32
|
+
- The user says "no plan yet" / "just the restatement": add `--no-plan` and read only the integrate document in step 3; when the user wants the plan later, run `autocode feat --plan-only <document id>` (plans from the existing restatement, reads no stdin).
|
|
33
|
+
The "Result" section gives the folder path, the source kind and the version; "Changes" lists every generated file.
|
|
34
|
+
|
|
35
|
+
## Step 3: read the files in order and present them
|
|
36
|
+
1. integrate.prd.md - the requirement restated in this project's own business terms, business units and code locations.
|
|
37
|
+
2. prd.plan.md - the implementation plan. If it is an overview (it has a sub-plans section), read prd.plan.01-*.md, 02-*.md ... in order; each sub-plan states its dependencies.
|
|
38
|
+
3. original.prd.md - the source; consult it only when the first two are ambiguous.
|
|
39
|
+
Present to the user: the key points of the restatement, the business units and code involved, how many plans and what each covers, the open questions, and this version number.
|
|
40
|
+
|
|
41
|
+
After every generation or revision (`--no-plan` and `--plan-only` included), first give the user a **summary of this version** with four fixed items:
|
|
42
|
+
1. **Version**: vn; for a revision, vold → vnew.
|
|
43
|
+
2. **What changed**: for a new document, the gist of the restatement and of the plans; for a revision, go through the "restatement sections changed" listed under "Result" section by section and say what each now reads (open the file and read them, never from memory), and through the plan files the "Changes" section lists as added / updated / removed.
|
|
44
|
+
3. **Questions for the developer**: every item under "New questions" (subject, severity, question file), plus the rest of the "Open questions" section of integrate.prd.md; "none" when there are none.
|
|
45
|
+
4. **Can it be implemented directly**: relay the development-threshold line under "Next", and what is missing when it is not ready.
|
|
46
|
+
|
|
47
|
+
## Step 4: ask for review
|
|
48
|
+
Ask three things: is the restatement right, can the plan be done this way, how should the open questions be answered. Then:
|
|
49
|
+
- Changes wanted: let the user edit the files, or rerun this command with the document id and the feedback (`/auto-feat <document id> <feedback>`); the engine produces a new version; back to step 3.
|
|
50
|
+
- Confirmed: set `confirmation` to `confirmed` in the frontmatter of integrate.prd.md and every plan file. That is the only field you may change.
|
|
51
|
+
- Undecided: change nothing; the documents stay pending.
|
|
52
|
+
|
|
53
|
+
## Step 5: may the knowledge base carry the implementation
|
|
54
|
+
Read the development-threshold line under "Next" in step 2's output (`data.dev` with `--json`).
|
|
55
|
+
- Ready (`dev.ready` is true) and the user confirmed the restatement and every plan in step 4 → ask the user whether to implement the plan now. Start only on a yes:
|
|
56
|
+
- Implement strictly along the plan steps and the code locations and anchors the restatement lists; before touching code, read the related knowledge-base documents with `autocode query <anchor> --json`, then the code.
|
|
57
|
+
- After each plan step, tell the user which files it changed.
|
|
58
|
+
- When a module, interface or data structure outside the plan has to change, stop and ask the user first.
|
|
59
|
+
- At the end, list every changed file with its plan step and ask the user to review the code.
|
|
60
|
+
- Not ready (`dev.ready` is false), documents unconfirmed, or the user does not want it now → relay what the "First" list names (answer questions, confirm business terms, run /auto-wiki first); this command ends here. Do not start writing code; do not run autocode wiki.
|
|
61
|
+
|
|
62
|
+
On either branch, never run autocode wiki and never change files under `.autocode/`; the knowledge base updates when the user runs /auto-wiki, from the code and the confirmed documents.
|
|
63
|
+
|
|
64
|
+
## Never
|
|
65
|
+
- Outside the ready branch of step 5, never implement the requirement or change business code; never implement below the threshold or on unconfirmed documents.
|
|
66
|
+
- Never create or edit anything under `.autocode/`; the only exception is the `confirmation` field after the user explicitly confirms.
|
|
67
|
+
- Never answer the engine's questions on the user's behalf.
|
|
68
|
+
- Never put the source into the command-line argument; never rewrite or summarise it.
|
|
69
|
+
- Pending documents are not read by the knowledge base; never imply they already are.
|