@zythegit/agentforge 0.2.3-rc.4 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/aforge.js +1 -1
  2. package/package.json +1 -1
package/dist/aforge.js CHANGED
@@ -580,7 +580,7 @@ Detected by AgentForge, **for reference only \u2014 not rules**. Declared habits
580
580
  ${n.map(i=>` - ${i}`).join(`
581
581
  `)}`,{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 o}a(AB,"verifyFiles");async function TB(e,t){let r=`${t}${nw}`;if(!await e.exists(r))return r;for(let o=2;o<=ow;o+=1){let n=`${t}${nw}-${o}`;if(!await e.exists(n))return n}throw new be(`\u91CD\u547D\u540D\u843D\u70B9\u5168\u90E8\u88AB\u5360\u7528: ${r}\uFF08\u5DF2\u5C1D\u8BD5 ${ow} \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:nw,attempts:ow}})}a(TB,"resolveRenameTarget");async function RB(e,t,r,o){let n=En.join(t,...r.rel.split("/"));if(await e.exists(n)){if(o==="skip")return{path:r.rel,target:n,action:"skipped"};if(o==="rename"){let i=await TB(e,n);return await ce(e,En.dirname(i)),await ee(e,i,r.content),{path:r.rel,target:i,action:"renamed"}}}return await ce(e,En.dirname(n)),await ee(e,n,r.content),{path:r.rel,target:n,action:"written"}}a(RB,"writeOne");async function jB(e,t,r){let o=new Set,n=[];for(let i of r){let s=i.rel.split("/"),c=t;for(let l of s)c=En.join(c,l),!o.has(c)&&(o.add(c),await dp(e,c)&&n.push(`${c}\uFF08\u5BFC\u5165 ${i.rel} \u65F6\u4F1A\u7A7F\u900F\u5230\u94FE\u63A5\u76EE\u6807\uFF09`))}if(n.length>0)throw new $(`\u76EE\u6807 SoT \u7684\u8DEF\u5F84\u4E0A\u5B58\u5728 symlink\uFF0C\u62D2\u7EDD\u5199\u5165:
582
582
  ${n.map(i=>` - ${i}`).join(`
583
- `)}`,{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(jB,"assertNoSymlinkOnWritePath");function DB(e,t){return t==="project"?le(e.cwd,e.os):ne(q(e.host),e.os)}a(DB,"resolveTargetSoT");async function sT(e,t){let r=En.resolve(e.cwd,t.from),o=En.join(r,up),n=t.onConflict??"skip",i=t.scope??q(e.host).agfScope??"project",s=DB(e,i),c=await OB(e.host,r),l=await AB(e.host,o,c),u=new Set(l.map(f=>f.rel)),p=(await Da(e.host,e.os,o)).files.filter(f=>!u.has(f));await ce(e.host,s);let d=await Ue(e.host,s,e.os,async()=>{await jB(e.host,s,l);let f=[];for(let m of l)f.push(await RB(e.host,s,m,n));return f});return{scope:i,sotRoot:s,bundleDir:r,manifest:c,onConflict:n,entries:d,unlisted:p}}a(sT,"importBundle");H();var Pn="0.2.3-rc.4";async function LB(e,t){return iT({host:e.host,cwd:e.cwd,os:e.os,agentforgeVersion:Pn},{out:t.out,scope:t.scope,redact:t.redact,keepDetected:t.keepDetected})}a(LB,"runBundleExport");async function MB(e,t){return sT({host:e.host,cwd:e.cwd,os:e.os},{from:t.from,scope:t.scope,onConflict:t.onConflict})}a(MB,"runBundleImport");function zB(e){if(e!==void 0){if(!iw.includes(e))throw new $(`\u975E\u6CD5 --on-conflict: ${e}`,{hint:`\u6709\u6548\u503C: ${iw.join(", ")}`,details:{onConflict:e}});return e}}a(zB,"parseConflictPolicy");var aT=20;function pp(e,t,r){for(let n of t.slice(0,aT))e.push(`${r}${n}`);let o=t.length-aT;o>0&&e.push(`${r}... and ${o} more (use --json for the full list)`)}a(pp,"pushCapped");var or=10;function FB(e,t=F()){let r=e.manifest,o=[`${t.green("bundle exported")}: ${t.path(e.outDir)}`,t.kv("scope",`${e.scope} (${t.path(e.sotRoot)})`,or),t.kv("manifest",t.path(e.manifestFile),or),t.kv("content",t.path(e.contentDir),or),t.kv("files",`${r.files.length} file(s) carried`,or)];if(pp(o,r.files.map(n=>t.dim(`- ${n.path}${n.transformed?" [transformed]":""}`))," "),r.excluded.length>0&&(o.push(t.kv("excluded",`${r.excluded.length} entry(ies) left behind`,or)),pp(o,r.excluded.map(n=>t.dim(`- ${n.path} (${n.reason})`))," ")),r.redacted.length>0&&(o.push(t.kv("redacted",t.yellow(`${r.redacted.length} credential value(s) replaced by a placeholder`),or)),pp(o,r.redacted.map(n=>`- ${n}`)," ")),r.warnings.length>0){o.push(` ${t.yellow("warnings :")}`);for(let n of r.warnings)o.push(` - ${t.yellow(n)}`)}return o.push("",t.next("move this directory to the target machine, then run"),` ${t.code(`aforge bundle import --from ${e.outDir}`)}`),o.join(`
583
+ `)}`,{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(jB,"assertNoSymlinkOnWritePath");function DB(e,t){return t==="project"?le(e.cwd,e.os):ne(q(e.host),e.os)}a(DB,"resolveTargetSoT");async function sT(e,t){let r=En.resolve(e.cwd,t.from),o=En.join(r,up),n=t.onConflict??"skip",i=t.scope??q(e.host).agfScope??"project",s=DB(e,i),c=await OB(e.host,r),l=await AB(e.host,o,c),u=new Set(l.map(f=>f.rel)),p=(await Da(e.host,e.os,o)).files.filter(f=>!u.has(f));await ce(e.host,s);let d=await Ue(e.host,s,e.os,async()=>{await jB(e.host,s,l);let f=[];for(let m of l)f.push(await RB(e.host,s,m,n));return f});return{scope:i,sotRoot:s,bundleDir:r,manifest:c,onConflict:n,entries:d,unlisted:p}}a(sT,"importBundle");H();var Pn="0.3.0";async function LB(e,t){return iT({host:e.host,cwd:e.cwd,os:e.os,agentforgeVersion:Pn},{out:t.out,scope:t.scope,redact:t.redact,keepDetected:t.keepDetected})}a(LB,"runBundleExport");async function MB(e,t){return sT({host:e.host,cwd:e.cwd,os:e.os},{from:t.from,scope:t.scope,onConflict:t.onConflict})}a(MB,"runBundleImport");function zB(e){if(e!==void 0){if(!iw.includes(e))throw new $(`\u975E\u6CD5 --on-conflict: ${e}`,{hint:`\u6709\u6548\u503C: ${iw.join(", ")}`,details:{onConflict:e}});return e}}a(zB,"parseConflictPolicy");var aT=20;function pp(e,t,r){for(let n of t.slice(0,aT))e.push(`${r}${n}`);let o=t.length-aT;o>0&&e.push(`${r}... and ${o} more (use --json for the full list)`)}a(pp,"pushCapped");var or=10;function FB(e,t=F()){let r=e.manifest,o=[`${t.green("bundle exported")}: ${t.path(e.outDir)}`,t.kv("scope",`${e.scope} (${t.path(e.sotRoot)})`,or),t.kv("manifest",t.path(e.manifestFile),or),t.kv("content",t.path(e.contentDir),or),t.kv("files",`${r.files.length} file(s) carried`,or)];if(pp(o,r.files.map(n=>t.dim(`- ${n.path}${n.transformed?" [transformed]":""}`))," "),r.excluded.length>0&&(o.push(t.kv("excluded",`${r.excluded.length} entry(ies) left behind`,or)),pp(o,r.excluded.map(n=>t.dim(`- ${n.path} (${n.reason})`))," ")),r.redacted.length>0&&(o.push(t.kv("redacted",t.yellow(`${r.redacted.length} credential value(s) replaced by a placeholder`),or)),pp(o,r.redacted.map(n=>`- ${n}`)," ")),r.warnings.length>0){o.push(` ${t.yellow("warnings :")}`);for(let n of r.warnings)o.push(` - ${t.yellow(n)}`)}return o.push("",t.next("move this directory to the target machine, then run"),` ${t.code(`aforge bundle import --from ${e.outDir}`)}`),o.join(`
584
584
  `)}a(FB,"renderExport");var cT="=".repeat(72);function UB(e,t,r){let o=t.manifest.redacted;if(o.length!==0){e.push("",r.red(cT),`${r.badge("warn")} ${r.yellow(`${o.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 o)e.push(` - ${r.bold(n)}`);e.push(` Edit ${r.path(NB.join(t.sotRoot,"profile.yaml"))}, then run ${r.code("aforge sync")}.`,r.red(cT))}}a(UB,"pushCredentialAlert");function HB(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},o=[`${t.green("bundle imported")}: ${t.path(e.bundleDir)}`,t.kv("scope",`${e.scope} (${t.path(e.sotRoot)})`,or),t.kv("policy",e.onConflict,or),t.kv("written",String(r.written),or),t.kv("skipped",String(r.skipped),or),t.kv("renamed",String(r.renamed),or)];if(pp(o,e.entries.map(n=>t.dim(`- ${n.path} [${n.action}] -> ${n.target}`))," "),r.skipped>0&&e.onConflict==="skip"&&o.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=rw(e.manifest.redacted.length),i=e.manifest.warnings.filter(s=>s!==n);if(i.length>0){o.push("",t.yellow("export-time warnings:"));for(let s of i)o.push(` - ${t.yellow(s)}`)}}return e.unlisted.length>0&&o.push("",t.yellow(`note: ${e.unlisted.length} file(s) in the bundle are not listed in manifest.json and were NOT imported:`),` ${xt(e.unlisted)}`),o.push("",t.next(`${t.code("aforge detect")} (refresh this machine toolchain snapshot)`),` ${t.code("aforge sync")} (project the imported SoT to your agents)`),UB(o,e,t),o.join(`
585
585
  `)}a(HB,"renderImport");function lT(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,o)=>{let n=await LB(Q(),{out:r.out,scope:Ut(r.scope),redact:r.redact,keepDetected:r.keepDetected===!0});if(K(o,r.json)){G(n);return}console.log(FB(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,o)=>{let n=await MB(Q(),{from:r.from,scope:Ut(r.scope),onConflict:zB(r.onConflict)});if(K(o,r.json)){G(n);return}console.log(HB(n))})}a(lT,"registerBundleCommand");import ho from"node:path";H();var sw=["fnm","nvm","volta","mise","nodenv","asdf"],aw=["uv","poetry","pipenv","conda","pyenv","pdm","hatch","rye","mamba","virtualenv"],cw=["pnpm","bun","npm","yarn","deno"],BB=["cargo","rustup","rustc","clippy","rustfmt"],VB=["golang","go.mod","go.sum","gofmt","goimports","gopls"],qB=["maven","gradle","mvnw","gradlew","sdkman","jdk","java"],ZB=["dotnet","nuget","msbuild","csproj","csharp"],GB=["turborepo","turbo","nx","lerna","rush.json","rushstack","changesets","pnpm-workspace","workspaces"],WB=["github actions","gitlab ci","azure pipelines","jenkins","circleci","travis","dependabot","husky","lint-staged","pre-commit","commitlint"],Ci=[{id:"rust",detectedKey:"rust",label:"rust toolchain",keywords:BB},{id:"go",detectedKey:"go",label:"go toolchain",keywords:VB},{id:"java",detectedKey:"java",label:"java toolchain",keywords:qB},{id:"dotnet",detectedKey:"dotnet",label:"dotnet toolchain",keywords:ZB},{id:"monorepo",detectedKey:"monorepo",label:"monorepo tools",keywords:GB},{id:"ci",detectedKey:"ci",label:"ci / hooks",keywords:WB}],lw=[...new Set([...sw,...aw,...cw,...Ci.flatMap(e=>e.keywords)])],uT=/[A-Za-z0-9_]/;function KB(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}a(KB,"escapeRegExp");function dT(e){let t=e.trim(),r=t.split(/\s+/).map(KB).join("\\s+"),o=t.slice(0,1),n=t.slice(-1),i=uT.test(o)?"(?<![A-Za-z0-9_])":"",s=uT.test(n)?"(?![A-Za-z0-9_])":"";return new RegExp(`${i}${r}${s}`,"i")}a(dT,"keywordRegExp");var JB=new Map(lw.map(e=>[e,dT(e)]));function pT(e,t){return(JB.get(t)??dT(t)).test(e)}a(pT,"matchesKeyword");var uw=[{kind:"AGENTS.md",tool:"agents.md \u7EA6\u5B9A\uFF08opencode / codex / pi \u7B49\uFF09",basename:"agents.md"},{kind:"CLAUDE.md",tool:"Claude Code",basename:"claude.md"},{kind:"GEMINI.md",tool:"Gemini CLI",basename:"gemini.md"},{kind:"opencode.md",tool:"opencode",basename:"opencode.md"},{kind:".cursorrules",tool:"Cursor\uFF08\u65E7\u7248\u5355\u6587\u4EF6\uFF09",basename:".cursorrules"},{kind:".cursor/rules/*.mdc",tool:"Cursor\uFF08\u65B0\u7248\u89C4\u5219\u76EE\u5F55\uFF09",extension:".mdc",parentDirs:[".cursor","rules"],nestedUnderParents:!0},{kind:".windsurfrules",tool:"Windsurf",basename:".windsurfrules"},{kind:".github/copilot-instructions.md",tool:"GitHub Copilot",basename:"copilot-instructions.md",parentDirs:[".github"]}];function YB(e){let t=mr(e).split("/").filter(o=>o!=="").map(o=>o.toLowerCase());return{base:t.pop()??"",ancestors:t}}a(YB,"splitPathSegments");function XB(e,t,r){if(t.length>e.length)return!1;if(!r){let o=e.slice(e.length-t.length);return t.every((n,i)=>o[i]===n)}for(let o=0;o+t.length<=e.length;o+=1)if(t.every((n,i)=>e[o+i]===n))return!0;return!1}a(XB,"ancestorsMatch");function QB(e,t){return!(e.basename!==void 0&&t.base!==e.basename||e.extension!==void 0&&(t.base===e.extension||!t.base.endsWith(e.extension))||e.parentDirs!==void 0&&!XB(t.ancestors,e.parentDirs,e.nestedUnderParents===!0))}a(QB,"ruleMatches");function dw(e){let t=YB(e);if(t.base!=="")return uw.find(r=>QB(r,t))?.kind}a(dw,"identifyImportFile");function fT(){return uw.map(e=>e.kind)}a(fT,"supportedImportFileKinds");function pw(){return`\u652F\u6301\u7684\u6587\u4EF6\uFF08\u5927\u5C0F\u5199\u4E0D\u654F\u611F\uFF09\uFF1A${fT().join(" / ")}\uFF1B\u5E26\u76EE\u5F55\u524D\u7F00\u7684\u9700\u8981\u653E\u5728\u5BF9\u5E94\u76EE\u5F55\u4E0B`}a(pw,"supportedImportFileHint");function e5(e){let t=e,r=zt(t);for(;r.hasMarkers;)t=r.before+r.after,r=zt(t);return t}a(e5,"stripAllMarkerSections");function t5(e,t){let r=lw.filter(o=>pT(e,o));return{heading:t,content:e,toolchainHits:r}}a(t5,"makeBlock");function r5(e){let t=[],r=[],o=null,n=a(()=>{r.join("").trim()!==""&&t.push(t5(r.join(""),o)),r=[],o=null},"flush");for(let i of e.split(/(?<=\n)/)){let s=/^##[ \t]+([^\r\n]*)/.exec(i);s!==null?(n(),o=(s[1]??"").trim(),r=[i]):r.push(i)}return n(),t}a(r5,"splitMarkdownBlocks");function mT(e,t){for(let r of t)for(let o of e)if(o.toolchainHits.includes(r))return r}a(mT,"firstHit");function hT(e,t){return t.filter(r=>e.some(o=>o.toolchainHits.includes(r)))}a(hT,"allHits");function gT(e){return e.nodeManager!==void 0||e.pythonManager!==void 0||e.packageManagers.length>0||Object.keys(e.extraToolchains).length>0}a(gT,"hasAnySuggestion");function n5(e){let t={};for(let r of Ci){let o=hT(e,r.keywords);o.length>0&&(t[r.id]=o)}return t}a(n5,"collectExtraToolchains");function yT(e){let t=r5(e5(e)),r=t.filter(n=>n.toolchainHits.length>0),o=t.filter(n=>n.toolchainHits.length===0);return{blocks:t,toolchainBlocks:r,customBlocks:o,suggestions:{nodeManager:mT(t,sw),pythonManager:mT(t,aw),packageManagers:hT(t,cw),extraToolchains:n5(t)}}}a(yT,"parseImportedFile");function o5(e){let t={};for(let r of Ci){let o=e.extraToolchains[r.id];o!==void 0&&o.length>0&&(t[r.detectedKey]=o.map(n=>({name:n,source:"import"})))}return t}a(o5,"extraDetectedEntries");function vT(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(o=>({name:o,source:"import"}))}:{},...o5(e)}}a(vT,"buildImportDetected");function ST(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(ST,"importTimestamp");function _T(e){let t=e.map(r=>lr(r.content,"lf").trim()).filter(r=>r!=="").join(`
586
586
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zythegit/agentforge",
3
- "version": "0.2.3-rc.4",
3
+ "version": "0.3.0",
4
4
  "description": "AgentForge — manage AI coding CLI rule projections (SoT → opencode/codex/claude/pi) from one source of truth",
5
5
  "type": "module",
6
6
  "bin": {