@ethan.carter/autocode 0.0.1 → 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/dist/{chunk-EPSRIOBV.js → chunk-2NNMZN27.js} +2 -2
- package/dist/chunk-BHULUCLO.js +221 -0
- package/dist/{chunk-4A2CIJR7.js → chunk-D6W6GJCQ.js} +1 -1
- package/dist/{chunk-BQM4QR37.js → chunk-DN5PIQX3.js} +1 -1
- package/dist/{chunk-G3KR2EJY.js → chunk-EOSGSOQ7.js} +1 -1
- package/dist/{chunk-AQGJ4MSP.js → chunk-F7GM3KBX.js} +1 -1
- package/dist/chunk-HO3X6IFQ.js +8 -0
- package/dist/{chunk-KP52N3BI.js → chunk-IAJUZSL4.js} +3 -3
- package/dist/{chunk-4AM2FMYM.js → chunk-L4FTN2JM.js} +1 -1
- package/dist/{chunk-KTN3Q4ID.js → chunk-LOULA2VD.js} +2 -2
- package/dist/{chunk-5IDQON42.js → chunk-LVFFUKWY.js} +1 -1
- package/dist/{chunk-Z7PLBHDY.js → chunk-LVGVTFEP.js} +1 -1
- package/dist/{chunk-ABS7LDBZ.js → chunk-TFNFQXFH.js} +1 -1
- package/dist/{chunk-BHNGTTZK.js → chunk-U5QH6OX7.js} +1 -1
- package/dist/chunk-UPEQGG6F.js +1 -0
- package/dist/{chunk-7ZHLSWOM.js → chunk-WGKUZHE7.js} +4 -4
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-LUAASDJ5.js +0 -1
- package/dist/chunk-RVU64VJK.js +0 -8
- package/dist/chunk-TCHTUSVC.js +0 -221
|
@@ -1 +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-
|
|
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};
|
|
@@ -5,7 +5,7 @@ import{a as u,b as c,c as p}from"./chunk-OP2B3OCA.js";import{A as m,C as h}from"
|
|
|
5
5
|
`)+`
|
|
6
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
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-
|
|
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
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
10
|
`:`${l}
|
|
11
11
|
`),2}finally{await r.close()}}d(y,"runGraphCommand");export{f as renderGraph,y as runGraphCommand};
|
|
@@ -1,4 +1,4 @@
|
|
|
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-
|
|
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
|
`),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
3
|
`):e.stderr.write(o+`
|
|
4
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}}))+`
|
|
@@ -1,4 +1,4 @@
|
|
|
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-
|
|
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
|
`),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
3
|
`):n.stderr.write(o+`
|
|
4
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}}))+`
|
|
@@ -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};
|
|
@@ -1,5 +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-
|
|
2
|
-
`)}catch{}let{isInitialized:m}=await import("./chunk-
|
|
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
3
|
`)}else t.stderr.write(s+`
|
|
4
|
-
`);return 1}}if(n==="wiki"){let{runWikiCommand:o}=await import("./chunk-
|
|
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
5
|
`),2}w(k,"dispatch");export{T as runUserCommand};
|
|
@@ -1,4 +1,4 @@
|
|
|
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-
|
|
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
|
`),2;if(t.planOnly&&(t.plan===!1||t.attachments!==void 0||!d.findChangeId(s)))return e.stderr.write(r("cli.usage.planOnly")+`
|
|
3
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
4
|
`):void 0}),p=h((o,l,v)=>(a==="json"?e.stdout.write(w(y(n,{problems:[{code:o,message:l}]}))+`
|
|
@@ -1,7 +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-
|
|
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
2
|
`),d;l!=="json"&&i.stdout.write([r("check.fix.start",{count:n.length}),...n.map(w=>` ${w}`)].join(`
|
|
3
3
|
`)+`
|
|
4
|
-
`);let{runWikiCommand:p}=await import("./chunk-
|
|
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
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
6
|
`)+`
|
|
7
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};
|
|
@@ -1 +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-
|
|
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};
|
|
@@ -1,4 +1,4 @@
|
|
|
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-
|
|
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
|
`),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
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
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(`
|
|
@@ -1,3 +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-
|
|
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
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
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};
|
|
@@ -1,4 +1,4 @@
|
|
|
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-
|
|
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
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
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
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)}
|
|
@@ -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};
|
|
@@ -1,4 +1,4 @@
|
|
|
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-
|
|
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
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
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
4
|
`)+`
|
|
@@ -18,8 +18,8 @@ import{a as m}from"./chunk-XUSV3KOD.js";import{fileURLToPath as S}from"node:url"
|
|
|
18
18
|
autocode migrate [--dry-run] [--json]
|
|
19
19
|
autocode migrate --help
|
|
20
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-
|
|
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
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
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-
|
|
25
|
-
`),0}if(e==="captures")return await A(t);if(e==="digest-daemon"){let s=await h(),n=await import("./chunk-
|
|
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};
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var a=process.argv[2];if(a==="capture"||a==="inject"||a==="captures"||a==="digest-daemon"||a==="logs"||a==="migrate"){let{runHiddenCommand:t}=await import("./chunk-
|
|
2
|
+
var a=process.argv[2];if(a==="capture"||a==="inject"||a==="captures"||a==="digest-daemon"||a==="logs"||a==="migrate"){let{runHiddenCommand:t}=await import("./chunk-WGKUZHE7.js");process.exit(await t(a,process.argv.slice(3)))}var{runApp:e}=await import("./chunk-D6W6GJCQ.js");await e();
|
package/package.json
CHANGED
package/dist/chunk-LUAASDJ5.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r}from"./chunk-RVU64VJK.js";import"./chunk-CBLU2NBO.js";import"./chunk-XUSV3KOD.js";export{q as absorbableParts,a as changeDir,h as changeHash,b as changesRoot,d as findChangeId,c as kindOfId,j as listChangeDocs,k as listChangeFolders,f as nextChangeId,r as overviewOf,i as readChangeDoc,m as removeChangeFolder,g as serializeWithFrontmatter,o as setIntegrateStatus,n as setPlanStatus,e as slugify,p as stampConfirmedAt,l as writeChangeFile};
|
package/dist/chunk-RVU64VJK.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import{H as $,g as p,v as y,w as x,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 I,writeFile as S}from"node:fs/promises";import f from"node:path";import{parse as D,stringify as O}from"yaml";function C(e){return e==="feat"?y:"fix"}i(C,"changeDir");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 T(e){let t=/\b(feat|fix)-\d{8}-\d{3}\b/.exec(e);return t?t[0]:null}i(T,"findChangeId");function G(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(G,"slugify");async function U(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(U,"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 N(e,t){return $(`${e.version??""}
|
|
7
|
-
${e.confirmation??""}
|
|
8
|
-
${t.trim()}`)}i(N,"changeHash");async function g(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:N(o,n.body)}}i(g,"readChangeFile");async function H(e,t){let r=_(t);if(!r)return null;let a=await W(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 g(n,o,s.original),u=await g(n,o,s.integrate);if(!c||!u)return null;let h=[];for(let F of Array.isArray(u.meta.plans)?u.meta.plans:[]){let b=await g(n,o,F);if(!b)return null;h.push(b)}return{id:t,kind:r,folder:o,original:c,integrate:u,plans:h}}i(H,"readChangeDoc");async function W(e,t,r){try{return(await d(l(e,t))).find(n=>n===r||n.startsWith(`${r}-`))??null}catch{return null}}i(W,"findFolderName");async function X(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 H(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(X,"listChangeDocs");async function q(e,t){try{let r=await d(l(e,t)),a=[];for(let n of r)(await I(f.join(l(e,t),n))).isDirectory()&&a.push(n);return a}catch{return[]}}i(q,"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 S(o,R(a,n),"utf8")}i(m,"writeChangeFile");async function B(e,t){await A(f.join(e,t),{recursive:!0,force:!0})}i(B,"removeChangeFolder");async function J(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(J,"setPlanStatus");async function K(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(K,"setIntegrateStatus");async function M(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(M,"stampConfirmedAt");function Q(e){return e.plans.length>1?e.plans.filter(t=>t.meta.part!==0):e.plans}i(Q,"absorbableParts");function V(e){return e.plans.length>1?e.plans.find(t=>t.meta.part===0):void 0}i(V,"overviewOf");export{C as a,l as b,_ as c,T as d,G as e,U as f,R as g,N as h,H as i,X as j,q as k,m as l,B as m,J as n,K as o,M as p,Q as q,V as r};
|