@zythegit/agentforge 0.2.2-rc.1 → 0.2.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/aforge.js +1 -1
- package/package.json +1 -1
package/dist/aforge.js
CHANGED
|
@@ -499,7 +499,7 @@ Before finishing: run {{#each ai.verification}}{{#if @first}}{{this}}{{else if @
|
|
|
499
499
|
${n.map(o=>` - ${o}`).join(`
|
|
500
500
|
`)}`,{hint:"bundle \u5728\u4F20\u8F93\u4E2D\u88AB\u6539\u52A8\u6216\u635F\u574F\uFF1B\u91CD\u65B0\u5BFC\u51FA\u4E00\u4EFD\uFF08\u54C8\u5E0C\u6309 LF \u89C4\u8303\u5316\u8BA1\u7B97\uFF0C\u6362\u884C\u5DEE\u5F02\u4E0D\u4F1A\u8BEF\u62A5\uFF09",details:{problems:n}});return i}a(IF,"verifyFiles");async function PF(e,t){let r=`${t}${Nb}`;if(!await e.exists(r))return r;for(let i=2;i<=Lb;i+=1){let n=`${t}${Nb}-${i}`;if(!await e.exists(n))return n}throw new $e(`\u91CD\u547D\u540D\u843D\u70B9\u5168\u90E8\u88AB\u5360\u7528: ${r}\uFF08\u5DF2\u5C1D\u8BD5 ${Lb} \u4E2A\u540E\u7F00\uFF09`,{hint:"\u624B\u5DE5\u6E05\u7406\u76EE\u6807\u76EE\u5F55\u91CC\u7684 *.imported* \u6B8B\u7559\u540E\u91CD\u8BD5",details:{target:t,suffix:Nb,attempts:Lb}})}a(PF,"resolveRenameTarget");async function EF(e,t,r,i){let n=un.join(t,...r.rel.split("/"));if(await e.exists(n)){if(i==="skip")return{path:r.rel,target:n,action:"skipped"};if(i==="rename"){let o=await PF(e,n);return await ce(e,un.dirname(o)),await te(e,o,r.content),{path:r.rel,target:o,action:"renamed"}}}return await ce(e,un.dirname(n)),await te(e,n,r.content),{path:r.rel,target:n,action:"written"}}a(EF,"writeOne");async function CF(e,t,r){let i=new Set,n=[];for(let o of r){let s=o.rel.split("/"),c=t;for(let l of s)c=un.join(c,l),!i.has(c)&&(i.add(c),await id(e,c)&&n.push(`${c}\uFF08\u5BFC\u5165 ${o.rel} \u65F6\u4F1A\u7A7F\u900F\u5230\u94FE\u63A5\u76EE\u6807\uFF09`))}if(n.length>0)throw new k(`\u76EE\u6807 SoT \u7684\u8DEF\u5F84\u4E0A\u5B58\u5728 symlink\uFF0C\u62D2\u7EDD\u5199\u5165:
|
|
501
501
|
${n.map(o=>` - ${o}`).join(`
|
|
502
|
-
`)}`,{hint:"\u628A\u8FD9\u4E9B symlink \u6362\u6210\u771F\u5B9E\u76EE\u5F55\uFF08\u6216\u6539\u7528 --scope \u843D\u5230\u53E6\u4E00\u5C42\uFF09\u540E\u91CD\u8BD5\uFF1Bbundle \u4E0D\u8DDF\u968F symlink \u5199\u76D8",details:{sotRoot:t,problems:n}})}a(CF,"assertNoSymlinkOnWritePath");function OF(e,t){return t==="project"?fe(e.cwd,e.os):ie(Z(e.host),e.os)}a(OF,"resolveTargetSoT");async function U0(e,t){let r=un.resolve(e.cwd,t.from),i=un.join(r,nd),n=t.onConflict??"skip",o=t.scope??Z(e.host).agfScope??"project",s=OF(e,o),c=await xF(e.host,r),l=await IF(e.host,i,c),u=new Set(l.map(f=>f.rel)),p=(await ra(e.host,e.os,i)).files.filter(f=>!u.has(f));await ce(e.host,s);let d=await Me(e.host,s,e.os,async()=>{await CF(e.host,s,l);let f=[];for(let m of l)f.push(await EF(e.host,s,m,n));return f});return{scope:o,sotRoot:s,bundleDir:r,manifest:c,onConflict:n,entries:d,unlisted:p}}a(U0,"importBundle");B();var dn="0.2.2
|
|
502
|
+
`)}`,{hint:"\u628A\u8FD9\u4E9B symlink \u6362\u6210\u771F\u5B9E\u76EE\u5F55\uFF08\u6216\u6539\u7528 --scope \u843D\u5230\u53E6\u4E00\u5C42\uFF09\u540E\u91CD\u8BD5\uFF1Bbundle \u4E0D\u8DDF\u968F symlink \u5199\u76D8",details:{sotRoot:t,problems:n}})}a(CF,"assertNoSymlinkOnWritePath");function OF(e,t){return t==="project"?fe(e.cwd,e.os):ie(Z(e.host),e.os)}a(OF,"resolveTargetSoT");async function U0(e,t){let r=un.resolve(e.cwd,t.from),i=un.join(r,nd),n=t.onConflict??"skip",o=t.scope??Z(e.host).agfScope??"project",s=OF(e,o),c=await xF(e.host,r),l=await IF(e.host,i,c),u=new Set(l.map(f=>f.rel)),p=(await ra(e.host,e.os,i)).files.filter(f=>!u.has(f));await ce(e.host,s);let d=await Me(e.host,s,e.os,async()=>{await CF(e.host,s,l);let f=[];for(let m of l)f.push(await EF(e.host,s,m,n));return f});return{scope:o,sotRoot:s,bundleDir:r,manifest:c,onConflict:n,entries:d,unlisted:p}}a(U0,"importBundle");B();var dn="0.2.2";async function AF(e,t){return z0({host:e.host,cwd:e.cwd,os:e.os,agentforgeVersion:dn},{out:t.out,scope:t.scope,redact:t.redact,keepDetected:t.keepDetected})}a(AF,"runBundleExport");async function jF(e,t){return U0({host:e.host,cwd:e.cwd,os:e.os},{from:t.from,scope:t.scope,onConflict:t.onConflict})}a(jF,"runBundleImport");function NF(e){if(e!==void 0){if(!Db.includes(e))throw new k(`\u975E\u6CD5 --on-conflict: ${e}`,{hint:`\u6709\u6548\u503C: ${Db.join(", ")}`,details:{onConflict:e}});return e}}a(NF,"parseConflictPolicy");var F0=20;function od(e,t,r){for(let n of t.slice(0,F0))e.push(`${r}${n}`);let i=t.length-F0;i>0&&e.push(`${r}... and ${i} more (use --json for the full list)`)}a(od,"pushCapped");var qt=10;function LF(e,t=F()){let r=e.manifest,i=[`${t.green("bundle exported")}: ${t.path(e.outDir)}`,t.kv("scope",`${e.scope} (${t.path(e.sotRoot)})`,qt),t.kv("manifest",t.path(e.manifestFile),qt),t.kv("content",t.path(e.contentDir),qt),t.kv("files",`${r.files.length} file(s) carried`,qt)];if(od(i,r.files.map(n=>t.dim(`- ${n.path}${n.transformed?" [transformed]":""}`))," "),r.excluded.length>0&&(i.push(t.kv("excluded",`${r.excluded.length} entry(ies) left behind`,qt)),od(i,r.excluded.map(n=>t.dim(`- ${n.path} (${n.reason})`))," ")),r.redacted.length>0&&(i.push(t.kv("redacted",t.yellow(`${r.redacted.length} credential value(s) replaced by a placeholder`),qt)),od(i,r.redacted.map(n=>`- ${n}`)," ")),r.warnings.length>0){i.push(` ${t.yellow("warnings :")}`);for(let n of r.warnings)i.push(` - ${t.yellow(n)}`)}return i.push("",t.next("move this directory to the target machine, then run"),` ${t.code(`aforge bundle import --from ${e.outDir}`)}`),i.join(`
|
|
503
503
|
`)}a(LF,"renderExport");var B0="=".repeat(72);function DF(e,t,r){let i=t.manifest.redacted;if(i.length!==0){e.push("",r.red(B0),`${r.badge("warn")} ${r.yellow(`${i.length} credential value(s) are placeholders.`)}`),e.push(r.yellow(" The MCP server(s) below will fail auth until you set them again:"));for(let n of i)e.push(` - ${r.bold(n)}`);e.push(` Edit ${r.path(TF.join(t.sotRoot,"profile.yaml"))}, then run ${r.code("aforge sync")}.`,r.red(B0))}}a(DF,"pushCredentialAlert");function RF(e,t=F()){let r={written:e.entries.filter(n=>n.action==="written").length,skipped:e.entries.filter(n=>n.action==="skipped").length,renamed:e.entries.filter(n=>n.action==="renamed").length},i=[`${t.green("bundle imported")}: ${t.path(e.bundleDir)}`,t.kv("scope",`${e.scope} (${t.path(e.sotRoot)})`,qt),t.kv("policy",e.onConflict,qt),t.kv("written",String(r.written),qt),t.kv("skipped",String(r.skipped),qt),t.kv("renamed",String(r.renamed),qt)];if(od(i,e.entries.map(n=>t.dim(`- ${n.path} [${n.action}] -> ${n.target}`))," "),r.skipped>0&&e.onConflict==="skip"&&i.push("",t.yellow("note: existing files were kept. rerun with --on-conflict overwrite (replace)"),t.yellow(" or --on-conflict rename (park the incoming copy next to yours).")),e.manifest.warnings.length>0){let n=jb(e.manifest.redacted.length),o=e.manifest.warnings.filter(s=>s!==n);if(o.length>0){i.push("",t.yellow("export-time warnings:"));for(let s of o)i.push(` - ${t.yellow(s)}`)}}return e.unlisted.length>0&&i.push("",t.yellow(`note: ${e.unlisted.length} file(s) in the bundle are not listed in manifest.json and were NOT imported:`),` ${sr(e.unlisted)}`),i.push("",t.next(`${t.code("aforge detect")} (refresh this machine toolchain snapshot)`),` ${t.code("aforge sync")} (project the imported SoT to your agents)`),DF(i,e,t),i.join(`
|
|
504
504
|
`)}a(RF,"renderImport");function H0(e){let t=e.command("bundle").description("export / import a whole SoT layer (migration, backup, new machine)");t.command("export").description("copy one SoT layer into a portable bundle directory (manifest + sot/)").requiredOption("--out <dir>","output directory (must be empty or missing)").option("--scope <scope>","SoT scope to export: project or user (default: effective scope)").option("--no-redact","keep MCP credentials as-is (default: replace values by a placeholder)").option("--keep-detected","keep habits.detected (default: dropped - it is a machine snapshot)").option("--json","machine-readable output (absolute paths) - Spec 6.2").action(async(r,i)=>{let n=await AF(Q(),{out:r.out,scope:Tt(r.scope),redact:r.redact,keepDetected:r.keepDetected===!0});if(K(i,r.json)){V(n);return}console.log(LF(n))}),t.command("import").description("write a bundle directory into one SoT layer (verifies sha256 before writing)").requiredOption("--from <dir>","bundle directory produced by `aforge bundle export`").option("--scope <scope>","SoT scope to write: project or user (default: AGF_SCOPE or project)").option("--on-conflict <policy>","existing target files: skip (default) | overwrite | rename").option("--json","machine-readable output (absolute paths) - Spec 6.2").action(async(r,i)=>{let n=await jF(Q(),{from:r.from,scope:Tt(r.scope),onConflict:NF(r.onConflict)});if(K(i,r.json)){V(n);return}console.log(RF(n))})}a(H0,"registerBundleCommand");import pn from"node:path";B();var Z0=["fnm","nvm","volta","mise"],V0=["uv","poetry","pipenv","conda","pyenv"],G0=["pnpm","bun","npm","yarn"],W0=[...Z0,...V0,...G0],MF=new Map(W0.map(e=>[e,new RegExp(`\\b${e}\\b`,"i")]));function J0(e){let r=(nr(e).split("/").pop()??"").toLowerCase();if(r==="agents.md")return"AGENTS.md";if(r==="claude.md")return"CLAUDE.md"}a(J0,"identifyImportFile");function zF(e){let t=e,r=Ct(t);for(;r.hasMarkers;)t=r.before+r.after,r=Ct(t);return t}a(zF,"stripAllMarkerSections");function UF(e,t){let r=e.toLowerCase(),i=[];for(let n of W0)MF.get(n)?.test(r)===!0&&i.push(n);return{heading:t,content:e,toolchainHits:i}}a(UF,"makeBlock");function FF(e){let t=[],r=[],i=null,n=a(()=>{r.join("").trim()!==""&&t.push(UF(r.join(""),i)),r=[],i=null},"flush");for(let o of e.split(/(?<=\n)/)){let s=/^##[ \t]+([^\r\n]*)/.exec(o);s!==null?(n(),i=(s[1]??"").trim(),r=[o]):r.push(o)}return n(),t}a(FF,"splitMarkdownBlocks");function q0(e,t){for(let r of t)for(let i of e)if(i.toolchainHits.includes(r))return r}a(q0,"firstHit");function BF(e,t){return t.filter(r=>e.some(i=>i.toolchainHits.includes(r)))}a(BF,"allHits");function K0(e){return e.nodeManager!==void 0||e.pythonManager!==void 0||e.packageManagers.length>0}a(K0,"hasAnySuggestion");function Y0(e){let t=FF(zF(e)),r=t.filter(n=>n.toolchainHits.length>0),i=t.filter(n=>n.toolchainHits.length===0);return{blocks:t,toolchainBlocks:r,customBlocks:i,suggestions:{nodeManager:q0(t,Z0),pythonManager:q0(t,V0),packageManagers:BF(t,G0)}}}a(Y0,"parseImportedFile");function X0(e,t,r){return{source:"import",imported_from:t,imported_at:r,...e.nodeManager!==void 0?{node:{manager:e.nodeManager,source:"import"}}:{},...e.pythonManager!==void 0?{python:{manager:e.pythonManager,source:"import"}}:{},...e.packageManagers.length>0?{package_managers:e.packageManagers.map(i=>({name:i,source:"import"}))}:{}}}a(X0,"buildImportDetected");function Q0(e){let t=a(r=>String(r).padStart(2,"0"),"pad");return[`${e.getUTCFullYear()}${t(e.getUTCMonth()+1)}${t(e.getUTCDate())}`,`${t(e.getUTCHours())}${t(e.getUTCMinutes())}${t(e.getUTCSeconds())}`].join("-")}a(Q0,"importTimestamp");function e2(e){let t=e.map(r=>Wt(r.content,"lf").trim()).filter(r=>r!=="").join(`
|
|
505
505
|
|
package/package.json
CHANGED