@longzai-intelligence-agent-tools/core 0.0.6 → 0.0.8

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/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import "./rolldown-runtime-BqT_7tdF.js";
1
2
  //#region src/types.d.ts
2
3
  /**
3
4
  * 支持的 AI Agent 类型
@@ -76,6 +77,13 @@ type CategoryRule = Readonly<Record<AgentType, VendorRule>>;
76
77
  * 通过 lzi.config.ts 的 agentTools 字段提供。
77
78
  */
78
79
  type AgentToolsConfig = {
80
+ /**
81
+ * 目标 Agent 类型输入串
82
+ *
83
+ * 支持单值(claude)、多值(逗号分隔,如 claude,trae)或 auto(按真源推断)。
84
+ * 优先级低于环境变量 LZI_AGENT_TYPE,高于默认 auto。
85
+ */
86
+ readonly agentType?: string;
79
87
  /**
80
88
  * 占位符值
81
89
  *
@@ -119,16 +127,22 @@ declare const IDE_OUTPUT_DIRS: Readonly<Record<AgentType, string>>;
119
127
  */
120
128
  declare const GENERATED_FILE_SUFFIX: '.generated';
121
129
  /**
122
- * 根指令文件入口引导文本
130
+ * 根指令文件生成区起始标记
123
131
  *
124
- * 根指令文件(CLAUDE.md / AGENTS.md)生成两份:
125
- * 1. <原名>.generated.md:真正的合成产物(共同 + 独有内容),文件名带后缀标识。
126
- * 2. <原名>(如 CLAUDE.md):入口文件,正文为此引导文本,指向对应的 .generated.md。
132
+ * 根指令文件(CLAUDE.md / AGENTS.md)采用单文件标记区锚定方案:
133
+ * 合成内容包裹在一对固定标记之间,工具只改标记之间的内容,
134
+ * 标记之外的手写内容永不触碰。
127
135
  *
128
- * 引导文本由工具固定生成(非真源内容),{{generatedFile}} 占位符替换为 .generated.md 文件名。
129
- * 入口文件保留原名是因为 IDE 以此为读取入口,实际内容载体是 .generated.md。
136
+ * 标记使用 HTML 注释格式,对 IDE 与 markdown 渲染均不可见,
137
+ * 不污染正文渲染,但工具可据此定位生成区边界。
130
138
  */
131
- declare const ROOT_ENTRY_TEMPLATE: '必须阅读 {{generatedFile}}。';
139
+ declare const GENERATED_BLOCK_BEGIN: '<!-- BEGIN Lzi Generated(工具维护,请勿手改;修改请编辑 .lzi/ 真源后运行 sync) -->';
140
+ /**
141
+ * 根指令文件生成区结束标记
142
+ *
143
+ * 与 {@link GENERATED_BLOCK_BEGIN} 成对使用,界定生成区尾部。
144
+ */
145
+ declare const GENERATED_BLOCK_END: '<!-- END Lzi Generated -->';
132
146
  /**
133
147
  * 内置合成规则表
134
148
  *
@@ -173,5 +187,24 @@ declare const ENV_KEYS: {
173
187
  * 始终可用,无需在配置中声明。
174
188
  */
175
189
  declare const BUILTIN_PLACEHOLDERS: Readonly<Record<string, () => string>>;
190
+ /**
191
+ * auto 关键词
192
+ *
193
+ * 当 LZI_AGENT_TYPE / --agent / lzi.config.ts.agentType 未配置时,默认进入 auto 模式,
194
+ * 由 detectAgentTypes 按真源自动推断目标 Agent 集合。auto 与显式 type 值互斥,不可混用。
195
+ */
196
+ declare const AUTO_AGENT_KEYWORD: 'auto';
197
+ /**
198
+ * 按真源自动推断目标 Agent 类型集合
199
+ *
200
+ * 遍历 VALID_AGENTS,对每个 type 检查其 SYNTHESIS_RULES 中任一规则的 agentSource
201
+ * (即 agents/agent.<type>.md)是否存在;存在则纳入。返回按 VALID_AGENTS 固定顺序的结果。
202
+ *
203
+ * 用于 auto 模式:用户未显式指定时,按 .lzi/ 实际真源决定为哪些 IDE 生成产物。
204
+ *
205
+ * @param projectRoot - 项目根目录绝对路径
206
+ * @returns 推断出的目标 Agent 类型集合(按 VALID_AGENTS 顺序)
207
+ */
208
+ declare const detectAgentTypes: (projectRoot: string) => Promise<readonly AgentType[]>;
176
209
  //#endregion
177
- export { type AgentToolsConfig, type AgentType, BUILTIN_PLACEHOLDERS, CATEGORY_RULES, COMMON_SOURCE, type Category, type CategoryRule, DEFAULT_SOURCES, ENV_KEYS, GENERATED_FILE_SUFFIX, IDE_OUTPUT_DIRS, LZI_DIR, ROOT_ENTRY_TEMPLATE, SYNTHESIS_RULES, type SynthesisMode, type SynthesisRule, VALID_AGENTS, type VendorRule };
210
+ export { AUTO_AGENT_KEYWORD, type AgentToolsConfig, type AgentType, BUILTIN_PLACEHOLDERS, CATEGORY_RULES, COMMON_SOURCE, type Category, type CategoryRule, DEFAULT_SOURCES, ENV_KEYS, GENERATED_BLOCK_BEGIN, GENERATED_BLOCK_END, GENERATED_FILE_SUFFIX, IDE_OUTPUT_DIRS, LZI_DIR, SYNTHESIS_RULES, type SynthesisMode, type SynthesisRule, VALID_AGENTS, type VendorRule, detectAgentTypes };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- const e={"agents/agent.md":`# 共同部分
1
+ import"./rolldown-runtime-BqT_7tdF.js";import{stat as e}from"node:fs/promises";import{join as t}from"node:path";const n={"agents/agent.md":`# 共同部分
2
2
 
3
3
  所有 AI IDE 都会读取此文件的内容。此文件与各 IDE 独有部分(agent.<ide>.md)拼接后,
4
4
  分别输出为 CLAUDE.md / AGENTS.md。
@@ -39,4 +39,4 @@ const e={"agents/agent.md":`# 共同部分
39
39
  # frontmatter 各 IDE 不同(claude paths / trae alwaysApply+globs),见 docs/vendors/
40
40
  `,"skills/.gitkeep":`# 此目录存放技能真源
41
41
  # 命名约定:<base>.md(共同)+ <base>.<type>.md(某 IDE 独有)
42
- `},t=`.lzi`,n=`agents/agent.md`,r={claude:`.claude`,trae:`.trae`,zcode:`.zcode`},i=`.generated`,a=`必须阅读 {{generatedFile}}。`,o={claude:[{output:`CLAUDE.md`,commonSource:n,agentSource:`agents/agent.claude.md`}],trae:[{output:`CLAUDE.md`,commonSource:n,agentSource:`agents/agent.claude.md`},{output:`AGENTS.md`,commonSource:n,agentSource:`agents/agent.trae.md`}],zcode:[{output:`AGENTS.md`,commonSource:n,agentSource:`agents/agent.zcode.md`}]},s={commands:{claude:{ideRoot:r.claude,mode:`append`},trae:{ideRoot:r.trae,mode:`append`},zcode:{ideRoot:r.zcode,mode:`append`}},rules:{claude:{ideRoot:r.claude,mode:`prepend`},trae:{ideRoot:r.trae,mode:`prepend`},zcode:{ideRoot:r.zcode,mode:`prepend`}},skills:{claude:{ideRoot:r.claude,mode:`append`},trae:{ideRoot:r.trae,mode:`append`},zcode:{ideRoot:r.zcode,mode:`append`}}},c=[`claude`,`trae`,`zcode`],l={AGENT_TYPE:`LZI_AGENT_TYPE`,PLACEHOLDER_PREFIX:`LZI_PLACEHOLDER_`},u={DATE:()=>new Date().toISOString().slice(0,10),PROJECT_NAME:()=>process.cwd().split(`/`).pop()??``};export{u as BUILTIN_PLACEHOLDERS,s as CATEGORY_RULES,n as COMMON_SOURCE,e as DEFAULT_SOURCES,l as ENV_KEYS,i as GENERATED_FILE_SUFFIX,r as IDE_OUTPUT_DIRS,t as LZI_DIR,a as ROOT_ENTRY_TEMPLATE,o as SYNTHESIS_RULES,c as VALID_AGENTS};
42
+ `},r=`.lzi`,i=`agents/agent.md`,a={claude:`.claude`,trae:`.trae`,zcode:`.zcode`},o=`.generated`,s=`<!-- BEGIN Lzi Generated(工具维护,请勿手改;修改请编辑 .lzi/ 真源后运行 sync) -->`,c=`<!-- END Lzi Generated -->`,l={claude:[{output:`CLAUDE.md`,commonSource:i,agentSource:`agents/agent.claude.md`}],trae:[{output:`CLAUDE.md`,commonSource:i,agentSource:`agents/agent.claude.md`},{output:`AGENTS.md`,commonSource:i,agentSource:`agents/agent.trae.md`}],zcode:[{output:`AGENTS.md`,commonSource:i,agentSource:`agents/agent.zcode.md`}]},u={commands:{claude:{ideRoot:a.claude,mode:`append`},trae:{ideRoot:a.trae,mode:`append`},zcode:{ideRoot:a.zcode,mode:`append`}},rules:{claude:{ideRoot:a.claude,mode:`prepend`},trae:{ideRoot:a.trae,mode:`prepend`},zcode:{ideRoot:a.zcode,mode:`prepend`}},skills:{claude:{ideRoot:a.claude,mode:`append`},trae:{ideRoot:a.trae,mode:`append`},zcode:{ideRoot:a.zcode,mode:`append`}}},d=[`claude`,`trae`,`zcode`],f={AGENT_TYPE:`LZI_AGENT_TYPE`,PLACEHOLDER_PREFIX:`LZI_PLACEHOLDER_`},p={DATE:()=>new Date().toISOString().slice(0,10),PROJECT_NAME:()=>process.cwd().split(`/`).pop()??``},m=`auto`,h=async t=>{try{return await e(t),!0}catch{return!1}},g=async e=>{let n=t(e,r);if(!await h(n))return[];let i=[];for(let e of d){let r=l[e];(await Promise.all(r.map(async e=>h(t(n,e.agentSource))))).some(e=>e)&&i.push(e)}return i};export{m as AUTO_AGENT_KEYWORD,p as BUILTIN_PLACEHOLDERS,u as CATEGORY_RULES,i as COMMON_SOURCE,n as DEFAULT_SOURCES,f as ENV_KEYS,s as GENERATED_BLOCK_BEGIN,c as GENERATED_BLOCK_END,o as GENERATED_FILE_SUFFIX,a as IDE_OUTPUT_DIRS,r as LZI_DIR,l as SYNTHESIS_RULES,d as VALID_AGENTS,g as detectAgentTypes};
@@ -0,0 +1 @@
1
+ import"node:module";export{};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longzai-intelligence-agent-tools/core",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "private": false,
5
5
  "license": "UNLICENSED",
6
6
  "files": [
@@ -17,12 +17,12 @@
17
17
  },
18
18
  "scripts": {
19
19
  "build": "lzi-builder",
20
- "build:prod": "NODE_ENV=production lzi-builder",
20
+ "build:prod": "NODE_ENV=production bun run build",
21
21
  "prepublishOnly": "bun run build:prod",
22
22
  "typecheck": "bun run typecheck:app && bun run typecheck:node && bun run typecheck:test",
23
- "typecheck:app": "tsgo --noEmit -p tsconfig/app.json",
24
- "typecheck:node": "tsgo --noEmit -p tsconfig/node.json",
25
- "typecheck:test": "tsgo --noEmit -p tsconfig/test.json",
23
+ "typecheck:app": "lzi-tsgo typecheck tsconfig/app.json",
24
+ "typecheck:node": "lzi-tsgo typecheck tsconfig/node.json",
25
+ "typecheck:test": "lzi-tsgo typecheck tsconfig/test.json",
26
26
  "lint": "oxlint && oxfmt --check",
27
27
  "lint:fix": "oxlint --fix && oxfmt",
28
28
  "test": "bun test",