@longzai-intelligence-agent-tools/config 0.0.13

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.
@@ -0,0 +1,208 @@
1
+ //#region src/types.d.ts
2
+ /**
3
+ * 共享提示词类别(config 侧自持定义,与 core 包机制域联合类型结构一致)
4
+ *
5
+ * agents = 根指令条目(hub agents/items/ → .lzi/agents/items/<ns>/);
6
+ * rules = 项目规则(hub rules/ → .lzi/rules/<ns>/,trae 工具提示词
7
+ * .trae/rules/ 的真源集中化通道)。本包零运行时依赖,不跨包引用
8
+ * core 类型(沿订阅类型双轨维护的既有模式,结构兼容由 zod 兜底)。
9
+ */
10
+ type SharedPromptsCategory = 'agents' | 'rules';
11
+ /**
12
+ * 共享提示词订阅(项目侧配置单元)
13
+ *
14
+ * 项目对某 hub 仓的订阅声明,配置于 agent-tools 专属配置文件
15
+ * lzi-agent-tools.config.ts(见 SharedPromptsConfig),由
16
+ * shared register / shared unregister 机器维护。
17
+ * 只含跨机器稳定的项目事实(身份与语义);hub 位置是机器本地
18
+ * 环境数据,落 .env 的 LZI_AGENT_TOOLS_SHARED_PROMPTS_ROOT,不进 git。
19
+ */
20
+ type SharedPromptsSubscription = {
21
+ /**
22
+ * hub 仓库名(目录名,如 longzai-intelligence-agent-prompts;稳定标识,非路径)
23
+ */
24
+ readonly name: string;
25
+ /**
26
+ * 订阅类别(决定 hub 条目库与项目物化目标目录);缺省按 agents 解析
27
+ * (手写配置兼容),机器再生配置显式写入
28
+ */
29
+ readonly category?: SharedPromptsCategory;
30
+ /**
31
+ * 订阅范围 glob 列表(相对 hub 侧该类别的条目库目录,如 ['lang/**']);null = 订阅全部
32
+ */
33
+ readonly include: readonly string[] | null;
34
+ /**
35
+ * 排除 glob 列表(相对 hub 侧该类别的条目库目录,从 include 命中集中剔除);null = 无排除
36
+ */
37
+ readonly exclude: readonly string[] | null;
38
+ };
39
+ /**
40
+ * 共享提示词配置(agentTools.sharedPrompts)
41
+ *
42
+ * 订阅列表的配置载体。经 shared-config 标准组合加载:
43
+ * 专属文件 lzi-agent-tools.config.ts 优先,统一配置 lzi.config.ts 的
44
+ * agentTools 字段兜底(先命中者整配置生效,不做字段级合并)。
45
+ */
46
+ type SharedPromptsConfig = {
47
+ /**
48
+ * 订阅列表(按声明顺序;命名空间全表唯一)
49
+ */
50
+ readonly subscriptions: readonly SharedPromptsSubscription[];
51
+ };
52
+ /**
53
+ * rules 类别 → trae 的分发形态
54
+ *
55
+ * 只影响产物落位(IDE 兼容面),不影响真源组织(hub 库与 .lzi/rules/
56
+ * 的主题目录强制与平铺守卫不变,0011 第四轮裁定)。
57
+ */
58
+ type RulesTraeDistribution = {
59
+ /**
60
+ * 平铺开关:true = `.trae/rules/` 产物平铺到目录根(仅文件名落位,
61
+ * 丢弃真源主题子目录层级);false = 保留主题子目录。
62
+ * 缺省 **true**——Trae 对 rules 子目录的支持未证实,默认取 322 仓
63
+ * 历史证明的平铺布局(0011 第五轮裁定)。
64
+ */
65
+ readonly flatten?: boolean;
66
+ };
67
+ /**
68
+ * 类别分发形态配置(IDE 产物目录布局)
69
+ *
70
+ * v1 仅 rules → trae 一个旋钮(rules 域限定红线:claude/zcode 零分发)。
71
+ */
72
+ type DistributionConfig = {
73
+ /**
74
+ * rules 类别分发形态
75
+ */
76
+ readonly rules?: {
77
+ /**
78
+ * trae(.trae/rules/)产物布局
79
+ */
80
+ readonly trae?: RulesTraeDistribution;
81
+ };
82
+ };
83
+ /**
84
+ * Agent Tools 配置
85
+ *
86
+ * 通过 shared-config 标准组合提供:专属文件 lzi-agent-tools.config.ts
87
+ * (default export 本类型,shared register 机器维护)优先于统一配置
88
+ * lzi.config.ts 的 agentTools 字段。
89
+ */
90
+ type AgentToolsConfig = {
91
+ /**
92
+ * 目标 Agent 类型输入串
93
+ *
94
+ * 支持单值(claude)、多值(逗号分隔,如 claude,trae)或 auto(按真源推断)。
95
+ * 优先级低于环境变量 LZI_AGENT_TYPE,高于默认 auto。
96
+ */
97
+ readonly agentType?: string;
98
+ /**
99
+ * 占位符值
100
+ *
101
+ * 替换源 markdown 中的 {{KEY}}。机器特定绝对路径应写在此处。
102
+ */
103
+ readonly placeholders?: Record<string, string>;
104
+ /**
105
+ * 类别分发形态(IDE 产物目录布局;可人工编辑,register 再生时按当时解析值保留)
106
+ */
107
+ readonly distribution?: DistributionConfig;
108
+ /**
109
+ * 共享提示词订阅配置
110
+ *
111
+ * 订阅的增删走 shared register / shared unregister(写入专属配置文件);
112
+ * 也可在统一配置中手工声明(专属文件存在时整配置以专属文件为准)。
113
+ */
114
+ readonly sharedPrompts?: SharedPromptsConfig;
115
+ };
116
+ //#endregion
117
+ //#region src/constants.d.ts
118
+ /**
119
+ * agent-tools 配置域常量(配置管理的单一真源)
120
+ */
121
+ /**
122
+ * agent-tools 专属配置文件名
123
+ *
124
+ * shared-config 标准组合的项目侧落点:本文件(default export
125
+ * AgentToolsConfig)优先于统一配置 lzi.config.ts 的 agentTools 字段,
126
+ * 先命中者整配置生效(loadUnifiedConfig 的 standaloneFile 通道)。
127
+ * 由 shared register / shared unregister 以解析值整文件再生
128
+ * (agentType / placeholders 等字段按当时解析值保留)。
129
+ * 配置属于项目管理层——.lzi/ 是纯内容真源目录,不落任何配置文件。
130
+ */
131
+ declare const STANDALONE_CONFIG_FILE: 'lzi-agent-tools.config.ts';
132
+ /**
133
+ * 环境变量名称常量
134
+ *
135
+ * 前缀规矩(docs/issues/0010):agent-tools 新增环境变量一律
136
+ * LZI_AGENT_TOOLS_ 前缀(域段 = 完整工具名,与包名、专属配置文件名
137
+ * 的域段一字不差)。存量 LZI_AGENT_TYPE / LZI_PLACEHOLDER_ 属例外,
138
+ * 未经裁定不迁移。
139
+ *
140
+ * 例外补记(0011 用户第四轮裁定):hub 根目录变量由
141
+ * LZI_AGENT_TOOLS_SHARED_PROMPTS_ROOT 明确更名为 LZI_AGENT_PROMPTS_ROOT
142
+ * (去除 TOOLS/SHARED 词汇,域段与 hub 仓名对齐),属 0010 前缀规矩的
143
+ * 裁定例外,非新变量。
144
+ */
145
+ declare const ENV_KEYS: {
146
+ /**
147
+ * 当前 Agent 类型(存量变量,早于 0010 前缀规矩)
148
+ */
149
+ readonly AGENT_TYPE: 'LZI_AGENT_TYPE';
150
+ /**
151
+ * 占位符环境变量前缀(存量变量,早于 0010 前缀规矩)
152
+ */
153
+ readonly PLACEHOLDER_PREFIX: 'LZI_PLACEHOLDER_';
154
+ /**
155
+ * 共享提示词中心仓根目录(机器本地真源;0011 第四轮裁定更名)
156
+ *
157
+ * hub 定位解析链的最高优先级:值承载于项目 .env(Bun 自动加载,
158
+ * 不进 git)——hub 位置是机器环境数据,配置文件零路径。
159
+ * shared register 定位成功后幂等固化到 .env;.env.example 由
160
+ * register 维护占位条目(进 git,不含机器数据)。
161
+ */
162
+ readonly PROMPTS_ROOT: 'LZI_AGENT_PROMPTS_ROOT';
163
+ };
164
+ //#endregion
165
+ //#region src/define-config.config.d.ts
166
+ /**
167
+ * 定义 agent-tools 专属配置的工厂函数
168
+ *
169
+ * 纯类型透传,运行时无副作用。项目在 lzi-agent-tools.config.ts 中
170
+ * 通过本函数默认导出配置(shared-config 标准组合的 standalone 通道,
171
+ * loadUnifiedConfig 读取 default export)。
172
+ *
173
+ * @example
174
+ * ```typescript
175
+ * import { defineConfig } from '@longzai-intelligence-agent-tools/config';
176
+ *
177
+ * export default defineConfig({
178
+ * sharedPrompts: {
179
+ * subscriptions: [
180
+ * {
181
+ * name: 'longzai-intelligence-agent-prompts',
182
+ * namespace: 'shared',
183
+ * include: null,
184
+ * exclude: null,
185
+ * },
186
+ * ],
187
+ * },
188
+ * });
189
+ * ```;
190
+ *
191
+ * @param config - agent-tools 配置对象
192
+ * @returns 传入的配置对象(原样返回)
193
+ */
194
+ declare function defineConfig(config: AgentToolsConfig): AgentToolsConfig;
195
+ //#endregion
196
+ //#region src/templates.d.ts
197
+ /**
198
+ * 生成 agent-tools 专属配置文件内容(lzi-agent-tools.config.ts)
199
+ *
200
+ * undefined 字段整体省略(agentType / placeholders / sharedPrompts),
201
+ * placeholders 键排序保证确定性;订阅列表为空时省略 sharedPrompts。
202
+ *
203
+ * @param config - 配置状态模型(agentType / placeholders 按当时解析值保留)
204
+ * @returns 完整 TS 模块源码(含维护语义头与文件尾换行)
205
+ */
206
+ declare const buildAgentToolsConfigFileContent: (config: AgentToolsConfig) => string;
207
+ //#endregion
208
+ export { type AgentToolsConfig, type DistributionConfig, ENV_KEYS, type RulesTraeDistribution, STANDALONE_CONFIG_FILE, type SharedPromptsCategory, type SharedPromptsConfig, type SharedPromptsSubscription, buildAgentToolsConfigFileContent, defineConfig };
package/dist/index.js ADDED
@@ -0,0 +1,17 @@
1
+ const e=`lzi-agent-tools.config.ts`,t={AGENT_TYPE:`LZI_AGENT_TYPE`,PLACEHOLDER_PREFIX:`LZI_PLACEHOLDER_`,PROMPTS_ROOT:`LZI_AGENT_PROMPTS_ROOT`};function n(e){return e}const r=e=>`'${e.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`)}'`,i=e=>`[${e.map(e=>r(e)).join(`, `)}]`,a=e=>{let t=e.agentType===void 0?``:` agentType: ${r(e.agentType)},\n`,n=e.placeholders===void 0?``:` placeholders: {\n${Object.keys(e.placeholders).sort().map(t=>` ${r(t)}: ${r(e.placeholders?.[t]??``)},`).join(`
2
+ `)}\n },\n`,a=e.sharedPrompts===void 0||e.sharedPrompts.subscriptions.length===0?``:` sharedPrompts: {\n subscriptions: [\n${e.sharedPrompts.subscriptions.map(e=>` {\n name: ${r(e.name)},\n category: ${r(e.category??`agents`)},\n include: ${e.include===null?`null`:i(e.include)},\n exclude: ${e.exclude===null?`null`:i(e.exclude)},\n },`).join(`
3
+ `)}\n ],\n },\n`;return`/**
4
+ * agent-tools 专属配置(shared-config 标准组合:本文件 > lzi.config.ts 的 agentTools 字段)
5
+ *
6
+ * 由 lzi-agent-cli 维护:shared register / shared unregister 以解析值整文件再生,
7
+ * 节内手工注释不保留(长篇说明请写入项目 docs)。agentType / placeholders /
8
+ * distribution 可手工编辑,再生时按当时解析值保留。订阅零路径:hub 位置是
9
+ * 机器本地环境数据,由项目 .env 的 LZI_AGENT_PROMPTS_ROOT 提供(register 定位后固化)。
10
+ */
11
+ import type { AgentToolsConfig } from '@longzai-intelligence-agent-tools/config';
12
+
13
+ const config: AgentToolsConfig = {
14
+ ${t}${n}${e.distribution?.rules?.trae===void 0?``:` distribution: {\n rules: {\n trae: {\n flatten: ${e.distribution.rules.trae.flatten===!0},\n },\n },\n },\n`}${a}};
15
+
16
+ export default config;
17
+ `};export{t as ENV_KEYS,e as STANDALONE_CONFIG_FILE,a as buildAgentToolsConfigFileContent,n as defineConfig};
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@longzai-intelligence-agent-tools/config",
3
+ "version": "0.0.13",
4
+ "private": false,
5
+ "license": "UNLICENSED",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "type": "module",
10
+ "main": "./dist/index.js",
11
+ "types": "./dist/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.js"
16
+ }
17
+ },
18
+ "scripts": {
19
+ "build": "lzi-builder",
20
+ "build:prod": "NODE_ENV=production bun run build",
21
+ "prepublishOnly": "bun run build:prod",
22
+ "typecheck": "bun run typecheck:app && bun run typecheck:node && bun run typecheck:test",
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
+ "lint": "oxlint && oxfmt --check",
27
+ "lint:fix": "oxlint --fix && oxfmt",
28
+ "test": "bun test",
29
+ "test:watch": "bun test --watch",
30
+ "test:coverage": "bun test --coverage",
31
+ "clean": "lzi-dev-cli clean"
32
+ },
33
+ "dependencies": {}
34
+ }