@longzai-intelligence-agent-tools/cli 0.0.5 → 0.0.7

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/index.js +15 -7
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env bun
2
- import"./rolldown-runtime-BqT_7tdF.js";import{BUILTIN_PLACEHOLDERS as e,CATEGORY_RULES as t,COMMON_SOURCE as n,DEFAULT_SOURCES as r,ENV_KEYS as i,GENERATED_FILE_SUFFIX as a,LZI_DIR as o,ROOT_ENTRY_TEMPLATE as s,SYNTHESIS_RULES as c,VALID_AGENTS as l}from"@longzai-intelligence-agent-tools/core";import{join as u}from"node:path";import{stat as d}from"node:fs/promises";import{loadUnifiedConfig as f}from"@longzai-intelligence-shared-config/core";const p={RED:`\x1B[0;31m`,GREEN:`\x1B[0;32m`,YELLOW:`\x1B[1;33m`,BLUE:`\x1B[0;34m`,RESET:`\x1B[0m`};function m(e){return e.map(e=>{if(typeof e==`string`)return e;if(e instanceof Error)return e.message;try{return JSON.stringify(e)}catch{return String(e)}}).join(` `)}function h(...e){process.stdout.write(`${m(e)}\n`)}function g(...e){process.stderr.write(`${m(e)}\n`)}async function _(e){return process.stdout.write(e),new Promise(e=>{let t=process.stdin;t.setEncoding(`utf8`),t.resume();let n=r=>{t.removeListener(`data`,n),t.pause(),e(r.toString().trim())};t.once(`data`,n)})}const v=async e=>{let t=u(process.cwd(),o);h(`${p.BLUE}初始化 Agent Tools 源文件结构...${p.RESET}\n`),e.dryRun&&h(`${p.YELLOW}[预览模式] 将创建以下文件:${p.RESET}`);let n=[],a=[];for(let[i,s]of Object.entries(r)){let r=u(t,i);if(await Bun.file(r).exists()){n.push(i),e.dryRun||h(` ${p.YELLOW}跳过${p.RESET} ${i}(已存在)`);continue}if(a.push(i),e.dryRun){h(` ${p.GREEN}将创建${p.RESET} ${o}/${i}`);continue}await Bun.write(r,s,{createPath:!0}),h(` ${p.GREEN}已创建${p.RESET} ${o}/${i}`)}h(``),h(`${p.BLUE}后续步骤:${p.RESET}`),h(` 1. 编辑 ${o}/agents/agent.md,填写共同指令与 {{KEY}} 占位符`),h(` 2. 按需编辑 ${o}/agents/agent.<type>.md,填写各 Agent 专属指令`),h(` 3. 在 ${o}/commands/ rules/ skills/ 下按命名约定添加类别配置`),h(` 4. 创建 .env 文件,配置当前 Agent 类型:`),h(` ${i.AGENT_TYPE}=<${l.join(`|`)}>`),h(` ${i.PLACEHOLDER_PREFIX}<KEY>=<value> (如 LZI_PLACEHOLDER_LZI_ROOT=/path/to/project)`),h(` 5. 运行 lzi-agent-cli sync 同步生成 CLAUDE.md / AGENTS.md 并分发类别配置`),n.length>0&&(h(``),h(`${p.YELLOW}提示: ${n.length} 个文件已存在被跳过${p.RESET}`))},y=`${p.GREEN}存在${p.RESET}`,b=`${p.RED}缺失${p.RESET}`,x=e=>l.some(t=>t===e),S=async e=>Bun.file(e).exists(),ee=async()=>{let e=process.cwd(),r=u(e,o),a=process.env[i.AGENT_TYPE],s=a&&x(a)?a:null;h(`${p.BLUE}=== Agent Tools 状态 ===${p.RESET}\n`),h(s?`当前 Agent: ${p.GREEN}${s}${p.RESET}`:a?`当前 Agent: ${p.RED}${a}(无效,合法值: ${l.join(`, `)})${p.RESET}`:`当前 Agent: ${p.YELLOW}未设置(请在 .env 配置 ${i.AGENT_TYPE})${p.RESET}`),h(``),h(`${p.BLUE}源文件(${r}):${p.RESET}`);let d=new Set;if(d.add(n),s)for(let e of c[s])d.add(e.agentSource);for(let e of d){let t=u(r,e);h(` ${e}: ${await S(t)?y:b}`)}if(h(``),s){h(`${p.BLUE}输出目标(将覆盖):${p.RESET}`);for(let t of c[s]){let n=u(e,t.output),r=await S(n);h(` ${t.output}: ${r?y:b}`)}}else h(`${p.YELLOW}Agent 类型未配置,无法显示输出目标${p.RESET}`);h(``),h(`${p.BLUE}类别配置目录(${r} 下):${p.RESET}`);for(let e of Object.keys(t)){let t=u(r,e);h(` ${e}/: ${await S(t)?y:b}`)}},C=/\{\{([A-Z][A-Z0-9_]*)\}\}/g,w=()=>{let e={};for(let[t,n]of Object.entries(process.env))if(t.startsWith(i.PLACEHOLDER_PREFIX)&&n!==void 0){let r=t.slice(i.PLACEHOLDER_PREFIX.length);e[r]=n}return e},T=()=>{let t={};for(let[n,r]of Object.entries(e))t[n]=r();return t},E=e=>{let t=T(),n=w();return{...t,...n,...e}},D=(e,t)=>e.replace(C,(e,n)=>t[n]??e),O=async e=>{let t=Bun.file(e);return await t.exists()?t.text():null},k=async e=>{try{return await d(e),!0}catch{return!1}},A=async(e,t,n)=>{let r=new Bun.Glob(t),i=[];for await(let t of r.scan({cwd:e,onlyFiles:n}))i.push(t);return i.sort()},j=e=>{let t=e.replace(/\.md$/,``);for(let e of l){let n=`.${e}`;if(t.endsWith(n))return{baseRelPath:`${t.slice(0,-n.length)}.md`,isSpecific:!0,specificType:e}}return{baseRelPath:e,isSpecific:!1,specificType:null}},M=(e,t,n)=>e===``&&t===``?``:t===``?`${e.trimEnd()}\n`:e===``?`${t.trimEnd()}\n`:n===`prepend`?`${t.trimEnd()}\n\n${e.trimEnd()}\n`:`${e.trimEnd()}\n\n${t.trimEnd()}\n`,N=async(e,n,r,i)=>{let s=t[e];if(!s)return[];let c=s[n];if(!c)return[];let l=u(r,o,e);if(!await k(l))return[];let d=await A(l,`**/*.md`,!0),f=new Map;for(let e of d){let{baseRelPath:t,isSpecific:n,specificType:r}=j(e);f.has(t)||f.set(t,{common:null,specifics:new Map});let i=f.get(t);i!==void 0&&(n&&r?i.specifics.set(r,e):i.common=e)}let p=[];for(let[t,{common:r,specifics:o}]of f){let s=o.get(n)??null,d=r===null?null:u(l,r),f=s===null?null:u(l,s);if(d===null&&f===null)continue;let m=d===null?``:await O(d)??``,h=f===null?``:await O(f)??``,g=D(M(m,h,c.mode),i),_=t.replace(/\.md$/,`${a}.md`),v=u(c.ideRoot,e,_);p.push({category:e,agentType:n,output:v,content:g,commonSourcePath:d,agentSourcePath:f})}return p},P=async(e,n,r)=>{let i=u(n,o);if(!await k(i))return[];let a=(await A(i,`*/`,!1)).map(e=>e.replace(/\/$/,``)),s=[];for(let i of a){if(!t[i])continue;let a=await N(i,e,n,r);s.push(...a)}return s},F=async e=>{let t=Bun.file(e);return await t.exists()?t.text():null},I=async(e,t,n)=>{let r=u(t,o,e.commonSource),i=u(t,o,e.agentSource),a=await F(r);if(a===null)throw Error(`共同部分源文件不存在: ${r}`);let s=await F(i);if(s===null)throw Error(`独有部分源文件不存在: ${i}`);let c=D(`${a.trimEnd()}\n\n${s.trimEnd()}\n`,n);return{output:e.output,content:c,commonSourcePath:r,agentSourcePath:i}},L=async(e,t,n)=>{let r=c[e],i=[];for(let e of r){let r=await I(e,t,n);i.push(r)}return i},R=e=>l.some(t=>t===e),z=()=>{let e=process.env[i.AGENT_TYPE];return e?R(e)?e:(g(`错误: ${i.AGENT_TYPE} 值 '${e}' 无效,合法值为: ${l.join(`, `)}`),null):null},B=async()=>{let e=await f({unifiedField:`agentTools`});return e.success?e.config:void 0},V=async()=>{let e=z();return e||(g(`错误: 环境变量 ${i.AGENT_TYPE} 未设置`),g(`请在 .env 中配置,合法值为: ${l.join(`, `)}`),process.exit(1)),{agentType:e,placeholders:(await B())?.placeholders}},H=async(e,t)=>{let n=u(e,t);return Bun.file(n).exists()},U=async(e,t)=>{let n=u(e,t),r=Bun.file(n);return await r.exists()?r.text():null},W=(e,t)=>{let n=[];for(let t of e){let e=t.output.replace(/\.md$/,`${a}.md`),r=`${s.replace(`{{generatedFile}}`,e)}\n`;n.push({output:e,content:t.content,sourceLabel:`${t.commonSourcePath} + ${t.agentSourcePath}`}),n.push({output:t.output,content:r,sourceLabel:`入口占位 → ${e}`})}let r=t.map(e=>{let t=[];return e.commonSourcePath&&t.push(e.commonSourcePath),e.agentSourcePath&&t.push(e.agentSourcePath),{output:e.output,content:e.content,sourceLabel:t.join(` + `)}});return[...n,...r]},G=e=>{h(`${p.BLUE}=== 预览模式(不写入文件) ===${p.RESET}\n`);for(let t of e)h(`${p.GREEN}--- ${t.output} ---${p.RESET}`),h(`${p.YELLOW}源: ${t.sourceLabel}${p.RESET}`),h(``),h(t.content),h(``)},K=async(e,t)=>{h(`${p.BLUE}=== 校验模式(比对产物与真源) ===${p.RESET}\n`);let n=[],r=0;for(let i of t){let t=await U(e,i.output);t===null?n.push(`${i.output} (产物缺失)`):t===i.content?r+=1:n.push(`${i.output} (内容不一致)`)}if(n.length===0){h(`${p.GREEN}✓ 所有产物与真源一致${p.RESET}(${r} 个文件)`);return}h(`${p.RED}✗ 检测到 ${n.length} 处漂移:${p.RESET}`);for(let e of n)h(` ${p.RED}${e}${p.RESET}`);h(``),h(`${p.YELLOW}请运行 lzi-agent-cli sync 重新生成产物${p.RESET}`),process.exit(1)},q=async(e,t)=>{let n=u(e,t.output);await Bun.write(n,t.content),h(`${p.GREEN} ✓${p.RESET} ${t.output}`)},J=async e=>{let t=await V(),n=process.cwd(),r=E(t.placeholders),i=await L(t.agentType,n,r),a=await P(t.agentType,n,r),o=W(i,a);if(e.check){await K(n,o);return}if(e.dryRun){G(o);return}let s=[];for(let e of o)await H(n,e.output)&&s.push(e.output);if(s.length>0&&!e.force){h(`${p.YELLOW}将覆盖以下文件:${p.RESET}`);for(let e of s)h(` ${e}`);if((await _(`
3
- 确认覆盖?(y/N): `)).toLowerCase()!==`y`){h(`已取消`);return}}h(``),h(`${p.BLUE}正在写入...${p.RESET}`);for(let e of o)await q(n,e);h(`\n${p.GREEN}同步完成${p.RESET} (Agent: ${t.agentType},共 ${o.length} 个文件)`)},Y=`lzi-agent-cli`,X=`
4
- ${Y} - Longzai Intelligence Agent Tools
2
+ import"./rolldown-runtime-BqT_7tdF.js";import{AUTO_AGENT_KEYWORD as e,BUILTIN_PLACEHOLDERS as t,CATEGORY_RULES as n,COMMON_SOURCE as r,DEFAULT_SOURCES as i,ENV_KEYS as a,GENERATED_FILE_SUFFIX as o,LZI_DIR as s,ROOT_ENTRY_TEMPLATE as c,SYNTHESIS_RULES as l,VALID_AGENTS as u,detectAgentTypes as d}from"@longzai-intelligence-agent-tools/core";import{join as f}from"node:path";import{stat as p}from"node:fs/promises";import{loadUnifiedConfig as m}from"@longzai-intelligence-shared-config/core";const h={RED:`\x1B[0;31m`,GREEN:`\x1B[0;32m`,YELLOW:`\x1B[1;33m`,BLUE:`\x1B[0;34m`,RESET:`\x1B[0m`};function g(e){return e.map(e=>{if(typeof e==`string`)return e;if(e instanceof Error)return e.message;try{return JSON.stringify(e)}catch{return String(e)}}).join(` `)}function _(...e){process.stdout.write(`${g(e)}\n`)}function v(...e){process.stderr.write(`${g(e)}\n`)}async function y(e){return process.stdout.write(e),new Promise(e=>{let t=process.stdin;t.setEncoding(`utf8`),t.resume();let n=r=>{t.removeListener(`data`,n),t.pause(),e(r.toString().trim())};t.once(`data`,n)})}const b=e=>u.some(t=>t===e),x=e=>{let t=new Set(Object.keys(i));if(e===void 0)return t;let n=new Set;n.add(`agents/agent.md`);for(let t of l[e])n.add(`agents/${t.agentSource.split(`/`).pop()}`);for(let e of t)e.startsWith(`agents/`)||n.add(e);return n},S=async e=>{let t=e.agent===void 0?void 0:b(e.agent)?e.agent:null;t===null&&(_(`${h.RED}错误: --agent 值 '${e.agent}' 无效,合法值: ${u.join(`, `)}${h.RESET}`),process.exit(1));let n=f(process.cwd(),s),r=x(t);_(`${h.BLUE}初始化 Agent Tools 源文件结构...${h.RESET}\n`),e.dryRun&&_(`${h.YELLOW}[预览模式] 将创建以下文件:${h.RESET}`);let a=[],o=[];for(let[t,c]of Object.entries(i)){if(!r.has(t))continue;let i=f(n,t);if(await Bun.file(i).exists()){a.push(t),e.dryRun||_(` ${h.YELLOW}跳过${h.RESET} ${t}(已存在)`);continue}if(o.push(t),e.dryRun){_(` ${h.GREEN}将创建${h.RESET} ${s}/${t}`);continue}await Bun.write(i,c,{createPath:!0}),_(` ${h.GREEN}已创建${h.RESET} ${s}/${t}`)}_(``),_(`${h.BLUE}后续步骤:${h.RESET}`),_(` 1. 编辑 ${s}/agents/agent.md,填写共同指令与 {{KEY}} 占位符`),_(` 2. 按需编辑 ${s}/agents/agent.<type>.md,填写各 Agent 专属指令`),_(` 3. 在 ${s}/commands/ rules/ skills/ 下按命名约定添加类别配置`),_(` 4. 运行 lzi-agent-cli sync 同步生成 CLAUDE.md / AGENTS.md 并分发类别配置`),_(` 默认 auto:按 ${s}/agents/agent.<type>.md 真源自动推断为所有存在的类型生成`),_(` 定向同步:lzi-agent-cli sync --agent <${u.join(`|`)}> 或设 LZI_AGENT_TYPE`),_(` 占位符:可选设置 ${s}/../.env 的 LZI_PLACEHOLDER_<KEY>=<value>`),_(` 5. 运行 lzi-agent-cli status 查看真源与产物存在性`),a.length>0&&(_(``),_(`${h.YELLOW}提示: ${a.length} 个文件已存在被跳过${h.RESET}`))},C=`${h.GREEN}存在${h.RESET}`,w=`${h.RED}缺失${h.RESET}`,T=e=>u.some(t=>t===e),E=async e=>Bun.file(e).exists(),D=async()=>{let e=process.cwd(),t=f(e,s),i=process.env[a.AGENT_TYPE];_(`${h.BLUE}=== Agent Tools 状态 ===${h.RESET}\n`);let o;i===void 0||i===``?(o=await d(e),o.length>0?_(`当前 Agent: ${h.GREEN}auto → ${o.join(`, `)}${h.RESET}(默认,按真源推断)`):_(`当前 Agent: ${h.YELLOW}auto → 未推断到真源${h.RESET}(请运行 lzi-agent-cli init)`)):T(i)?(o=[i],_(`当前 Agent: ${h.GREEN}${i}${h.RESET}(环境变量 ${a.AGENT_TYPE})`)):(o=await d(e),_(`当前 Agent: ${h.RED}${i}(无效,合法值: ${u.join(`, `)})${h.RESET}`)),_(``),_(`${h.BLUE}源文件(${t}):${h.RESET}`);let c=new Set;c.add(r);for(let e of o)for(let t of l[e])c.add(t.agentSource);for(let e of c){let n=f(t,e);_(` ${e}: ${await E(n)?C:w}`)}if(_(``),o.length>0){_(`${h.BLUE}输出目标(将覆盖):${h.RESET}`);let t=new Set;for(let e of o)for(let n of l[e])t.add(n.output);for(let n of t){let t=f(e,n);_(` ${n}: ${await E(t)?C:w}`)}}else _(`${h.YELLOW}Agent 类型未配置,无法显示输出目标${h.RESET}`);_(``),_(`${h.BLUE}类别配置目录(${t} 下):${h.RESET}`);for(let e of Object.keys(n)){let n=f(t,e);_(` ${e}/: ${await E(n)?C:w}`)}},ee=/\{\{([A-Z][A-Z0-9_]*)\}\}/g,te=()=>{let e={};for(let[t,n]of Object.entries(process.env))if(t.startsWith(a.PLACEHOLDER_PREFIX)&&n!==void 0){let r=t.slice(a.PLACEHOLDER_PREFIX.length);e[r]=n}return e},O=()=>{let e={};for(let[n,r]of Object.entries(t))e[n]=r();return e},k=e=>{let t=O(),n=te();return{...t,...n,...e}},A=(e,t)=>e.replace(ee,(e,n)=>t[n]??e),j=async e=>{let t=Bun.file(e);return await t.exists()?t.text():null},M=async e=>{try{return await p(e),!0}catch{return!1}},N=async(e,t,n)=>{let r=new Bun.Glob(t),i=[];for await(let t of r.scan({cwd:e,onlyFiles:n}))i.push(t);return i.sort()},P=e=>{let t=e.replace(/\.md$/,``);for(let e of u){let n=`.${e}`;if(t.endsWith(n))return{baseRelPath:`${t.slice(0,-n.length)}.md`,isSpecific:!0,specificType:e}}return{baseRelPath:e,isSpecific:!1,specificType:null}},F=(e,t,n)=>e===``&&t===``?``:t===``?`${e.trimEnd()}\n`:e===``?`${t.trimEnd()}\n`:n===`prepend`?`${t.trimEnd()}\n\n${e.trimEnd()}\n`:`${e.trimEnd()}\n\n${t.trimEnd()}\n`,I=async(e,t,r,i)=>{let a=n[e];if(!a)return[];let c=a[t];if(!c)return[];let l=f(r,s,e);if(!await M(l))return[];let u=await N(l,`**/*.md`,!0),d=new Map;for(let e of u){let{baseRelPath:t,isSpecific:n,specificType:r}=P(e);d.has(t)||d.set(t,{common:null,specifics:new Map});let i=d.get(t);i!==void 0&&(n&&r?i.specifics.set(r,e):i.common=e)}let p=[];for(let[n,{common:r,specifics:a}]of d){let s=a.get(t)??null,u=r===null?null:f(l,r),d=s===null?null:f(l,s);if(u===null&&d===null)continue;let m=u===null?``:await j(u)??``,h=d===null?``:await j(d)??``,g=A(F(m,h,c.mode),i),_=n.replace(/\.md$/,`${o}.md`),v=f(c.ideRoot,e,_);p.push({category:e,agentType:t,output:v,content:g,commonSourcePath:u,agentSourcePath:d})}return p},L=async(e,t,r)=>{let i=f(t,s);if(!await M(i))return[];let a=(await N(i,`*/`,!1)).map(e=>e.replace(/\/$/,``)),o=[];for(let i of a){if(!n[i])continue;let a=await I(i,e,t,r);o.push(...a)}return o},R=async e=>{let t=Bun.file(e);return await t.exists()?t.text():null},z=async(e,t,n)=>{let r=f(t,s,e.commonSource),i=f(t,s,e.agentSource),a=await R(r);if(a===null)throw Error(`共同部分源文件不存在: ${r}`);let o=await R(i);if(o===null)throw Error(`独有部分源文件不存在: ${i}`);let c=A(`${a.trimEnd()}\n\n${o.trimEnd()}\n`,n);return{output:e.output,content:c,commonSourcePath:r,agentSourcePath:i}},B=async(e,t,n)=>{let r=l[e],i=[];for(let e of r){let r=await z(e,t,n);i.push(r)}return i},V=e=>u.some(t=>t===e),H=async(t,n)=>{let r=t.split(`,`),i=r.includes(e),o=r.filter(t=>t!==e&&t!==``);if(i&&o.length>0)throw Error(`${a.AGENT_TYPE} 值 '${t}' 非法:auto 与显式类型不可混用,请单独使用 auto 或逗号分隔的类型列表`);if(i)return[...await d(n)];if(o.length===0)return[];let s=new Set;for(let t of o){if(!V(t))throw Error(`${a.AGENT_TYPE} 值 '${t}' 无效,合法值: ${u.join(`, `)}, ${e}`);if(s.has(t))throw Error(`${a.AGENT_TYPE} 值 '${t}' 重复,多值不可重复`);s.add(t)}return u.filter(e=>s.has(e))},U=()=>{let e=process.env[a.AGENT_TYPE];return e===void 0||e===``?null:e},W=async()=>{let e=await m({unifiedField:`agentTools`});return e.success?e.config:void 0},G=async(t={})=>{let n=process.cwd(),r=await W(),i=t.agent??U()??r?.agentType??``,o=i===``?[...await d(n)]:await H(i,n);return o.length===0&&(v(`错误: 未指定目标 Agent 类型,且 auto 未推断到任何真源`),v(`请运行 lzi-agent-cli init 创建 .lzi/ 骨架,或用 --agent / ${a.AGENT_TYPE} 指定类型`),v(`合法值: ${u.join(`, `)}, ${e}`),process.exit(1)),{agentTypes:o,placeholders:r?.placeholders}},K=async(e,t)=>{let n=f(e,t);return Bun.file(n).exists()},q=async(e,t)=>{let n=f(e,t),r=Bun.file(n);return await r.exists()?r.text():null},J=(e,t)=>{let n=[];for(let t of e){let e=t.output.replace(/\.md$/,`${o}.md`),r=`${c.replace(`{{generatedFile}}`,e)}\n`;n.push({output:e,content:t.content,sourceLabel:`${t.commonSourcePath} + ${t.agentSourcePath}`}),n.push({output:t.output,content:r,sourceLabel:`入口占位 → ${e}`})}let r=t.map(e=>{let t=[];return e.commonSourcePath&&t.push(e.commonSourcePath),e.agentSourcePath&&t.push(e.agentSourcePath),{output:e.output,content:e.content,sourceLabel:t.join(` + `)}});return[...n,...r]},Y=e=>{_(`${h.BLUE}=== 预览模式(不写入文件) ===${h.RESET}\n`);for(let t of e)_(`${h.GREEN}--- ${t.output} ---${h.RESET}`),_(`${h.YELLOW}源: ${t.sourceLabel}${h.RESET}`),_(``),_(t.content),_(``)},X=async(e,t)=>{_(`${h.BLUE}=== 校验模式(比对产物与真源) ===${h.RESET}\n`);let n=[],r=0;for(let i of t){let t=await q(e,i.output);t===null?n.push(`${i.output} (产物缺失)`):t===i.content?r+=1:n.push(`${i.output} (内容不一致)`)}if(n.length===0){_(`${h.GREEN}✓ 所有产物与真源一致${h.RESET}(${r} 个文件)`);return}_(`${h.RED}✗ 检测到 ${n.length} 处漂移:${h.RESET}`);for(let e of n)_(` ${h.RED}${e}${h.RESET}`);_(``),_(`${h.YELLOW}请运行 lzi-agent-cli sync 重新生成产物${h.RESET}`),process.exit(1)},Z=async(e,t)=>{let n=f(e,t.output);await Bun.write(n,t.content),_(`${h.GREEN} ✓${h.RESET} ${t.output}`)},ne=async e=>{let t=await G({agent:e.agent}),n=process.cwd(),r=k(t.placeholders),i=[],a=[];for(let e of t.agentTypes){let t=await B(e,n,r);i.push(...t);let o=await L(e,n,r);a.push(...o)}let o=J(i,a);if(e.check){await X(n,o);return}if(e.dryRun){Y(o);return}let s=[];for(let e of o)await K(n,e.output)&&s.push(e.output);if(s.length>0&&!e.force){_(`${h.YELLOW}将覆盖以下文件:${h.RESET}`);for(let e of s)_(` ${e}`);if((await y(`
3
+ 确认覆盖?(y/N): `)).toLowerCase()!==`y`){_(`已取消`);return}}_(``),_(`${h.BLUE}正在写入...${h.RESET}`);for(let e of o)await Z(n,e);_(`\n${h.GREEN}同步完成${h.RESET} (Agent: ${t.agentTypes.join(`, `)},共 ${o.length} 个文件)`)},Q=`lzi-agent-cli`,re=`
4
+ ${Q} - Longzai Intelligence Agent Tools
5
5
 
6
- 把 .lzi/ 下的源 markdown(共同部分 + 各 IDE 独有部分)按当前 IDE 自动合成,
6
+ 把 .lzi/ 下的源 markdown(共同部分 + 各 IDE 独有部分)按目标 IDE 自动合成,
7
7
  同步覆盖为 CLAUDE.md / AGENTS.md,并分发 commands / rules / skills 类别配置。
8
8
 
9
9
  源文件(.lzi/ 下):
@@ -16,24 +16,32 @@ ${Y} - Longzai Intelligence Agent Tools
16
16
  skills/ 技能真源
17
17
 
18
18
  用法:
19
- ${Y} <command> [options]
19
+ ${Q} <command> [options]
20
20
 
21
21
  命令:
22
22
  init 创建 .lzi/ 目录和源文件骨架
23
23
  [--dry-run] 仅预览将创建的文件
24
+ [--agent <v>] 仅生成指定 Agent 的骨架(claude/trae/zcode),默认全套
24
25
 
25
26
  sync 合成根指令文件 + 分发类别配置,同步覆盖目标文件
26
27
  [--dry-run] 仅预览,不写入文件
27
28
  [--force] 跳过覆盖确认
28
29
  [--check] 仅校验:产物与真源不一致则退出码 1(CI 守门)
30
+ [--agent <v>] 目标 Agent 类型,单值 / 多值(逗号分隔)/ auto,默认 auto
29
31
 
30
32
  status 显示当前 Agent 类型、源文件存在性、输出目标
31
33
 
34
+ 目标 Agent 类型解析优先级:
35
+ --agent(命令行)> LZI_AGENT_TYPE(环境变量)> lzi.config.ts.agentType > auto(默认)
36
+
37
+ auto 模式按 .lzi/agents/agent.<type>.md 真源自动推断,为所有存在的类型各生成一套。
38
+ 未配置任何来源时默认 auto,开箱即用。
39
+
32
40
  环境变量:
33
- LZI_AGENT_TYPE 当前 Agent 类型(claude | trae | zcode
41
+ LZI_AGENT_TYPE 目标 Agent 类型(单值 / 逗号分隔多值 / auto
34
42
  LZI_PLACEHOLDER_<KEY> 占位符值(可选,优先级低于 lzi.config.ts)
35
43
 
36
44
  选项:
37
45
  --help 显示帮助信息
38
46
  --version 显示版本号
39
- `,Z=()=>{h(X.trim()),process.exit(0)},Q=()=>{h(`${Y} v0.0.1`),process.exit(0)},$=e=>({dryRun:e.includes(`--dry-run`),force:e.includes(`--force`),check:e.includes(`--check`)});(async()=>{let e=process.argv.slice(2);if(e.length===0||e[0]===`--help`){Z();return}if(e[0]===`--version`){Q();return}let t=e[0],n=e.slice(1);switch(t){case`init`:{let{dryRun:e}=$(n);await v({dryRun:e});break}case`sync`:{let{dryRun:e,force:t,check:r}=$(n);await J({dryRun:e,force:t,check:r});break}case`status`:await ee();break;default:g(`错误: 未知命令 '${t}'`),g(`使用 '${Y} --help' 查看可用命令`),process.exit(1)}})().catch(e=>{g(`错误:`,e instanceof Error?e.message:String(e)),process.exit(1)});export{};
47
+ `,ie=()=>{_(re.trim()),process.exit(0)},ae=()=>{_(`${Q} v0.0.7`),process.exit(0)},$=e=>{let t=e.includes(`--dry-run`),n=e.includes(`--force`),r=e.includes(`--check`),i=e.indexOf(`--agent`);return{dryRun:t,force:n,check:r,agent:i!==-1&&i+1<e.length?e[i+1]:void 0}};(async()=>{let e=process.argv.slice(2);if(e.length===0||e[0]===`--help`){ie();return}if(e[0]===`--version`){ae();return}let t=e[0],n=e.slice(1);switch(t){case`init`:{let{dryRun:e,agent:t}=$(n);await S({dryRun:e,agent:t});break}case`sync`:{let{dryRun:e,force:t,check:r,agent:i}=$(n);await ne({dryRun:e,force:t,check:r,agent:i});break}case`status`:await D();break;default:v(`错误: 未知命令 '${t}'`),v(`使用 '${Q} --help' 查看可用命令`),process.exit(1)}})().catch(e=>{v(`错误:`,e instanceof Error?e.message:String(e)),process.exit(1)});export{};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longzai-intelligence-agent-tools/cli",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "Longzai Intelligence Agent Tools CLI",
5
5
  "license": "UNLICENSED",
6
6
  "bin": {
@@ -34,7 +34,7 @@
34
34
  "clean": "lzi-dev-cli clean"
35
35
  },
36
36
  "dependencies": {
37
- "@longzai-intelligence-agent-tools/core": "0.0.5",
37
+ "@longzai-intelligence-agent-tools/core": "0.0.7",
38
38
  "@longzai-intelligence-shared-config/core": "^0.0.5"
39
39
  }
40
40
  }