ly-workflow-codex 0.2.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.
@@ -0,0 +1,223 @@
1
+ import * as i18next from 'i18next';
2
+
3
+ /** 宿主 id(兼容旧配置读取;codex 单宿主只安装 codex) */
4
+ type HostId = 'codex' | 'claude';
5
+ /** 宿主无关的模板渲染配置(共享 LyConfig 的相关切片) */
6
+ interface HostAdapterConfig {
7
+ /** 审查 agent A 模型(LyConfig.codexHost.reviewModel);未配置或空白时回退当前会话模型 */
8
+ reviewModel?: string;
9
+ /** 审查 agent B 模型(LyConfig.codexHost.reviewModelB);未配置或空白时回退当前会话模型 */
10
+ reviewModelB?: string;
11
+ /** coding subagent(实施)模型(LyConfig.codexHost.codingModel);未配置或空白时回退当前会话模型 */
12
+ codingModel?: string;
13
+ }
14
+ /** 适配器安装/卸载/校验共用的上下文 */
15
+ interface HostAdapterContext {
16
+ /** 宿主安装根目录(保留统一形态;codex 宿主不使用) */
17
+ installDir: string;
18
+ force: boolean;
19
+ /** npm 包内 templates/ 目录 */
20
+ templateDir: string;
21
+ /** 共享角色词位置(~/.ly/prompts/,测试可注入) */
22
+ promptsDir: string;
23
+ /** codex skills 安装目录(~/.agents/skills/,测试可注入) */
24
+ codexSkillsDir: string;
25
+ config: HostAdapterConfig;
26
+ result: InstallResult;
27
+ }
28
+ /** 命令模板的源目录与安装目标 */
29
+ interface HostTemplateTarget {
30
+ sourceDir: string;
31
+ targetDir: string;
32
+ /** 目标目录名前缀(codex 宿主 = 'lyx-',安装为 <targetDir>/lyx-<cmd>/SKILL.md) */
33
+ filePrefix?: string;
34
+ }
35
+ interface HostAdapter {
36
+ id: HostId;
37
+ /** 命令模板安装目标(源目录 + 目标目录 + 文件名前缀) */
38
+ promptsTarget: (ctx: HostAdapterContext) => HostTemplateTarget;
39
+ /** 模板渲染规则:宿主可追加宿主专属变量处理(在共享 injectConfigVariables 之后) */
40
+ renderTemplate: (content: string, ctx: HostAdapterContext) => string;
41
+ /** 卸载清单:该宿主名下的产物路径清单(lyx-* 绝对路径清单) */
42
+ uninstallList: (ctx: HostAdapterContext) => Promise<string[]>;
43
+ /** 可选:宿主专属的附加安装步骤(codex 无) */
44
+ installExtras?: (ctx: HostAdapterContext) => Promise<void>;
45
+ /** 可选:安装后校验(codex = ROLE_FILE 目标存在性) */
46
+ verify?: (ctx: HostAdapterContext) => Promise<void>;
47
+ }
48
+ /** 统一注册表(codex 单宿主;保留 Record 形态供未来扩展) */
49
+ declare const ADAPTERS: Record<'codex', HostAdapter>;
50
+
51
+ interface CliOptions {
52
+ lang?: SupportedLang;
53
+ force?: boolean;
54
+ skipPrompt?: boolean;
55
+ workflows?: string;
56
+ installDir?: string;
57
+ }
58
+
59
+ type SupportedLang = 'zh-CN' | 'en';
60
+ interface LyConfig {
61
+ general: {
62
+ version: string;
63
+ language: SupportedLang;
64
+ createdAt: string;
65
+ };
66
+ workflows: {
67
+ installed: string[];
68
+ };
69
+ installedHosts?: HostId[];
70
+ paths: {
71
+ commands: string;
72
+ prompts: string;
73
+ backup: string;
74
+ };
75
+ codexHost?: {
76
+ reviewModel?: string;
77
+ reviewModelB?: string;
78
+ codingModel?: string;
79
+ };
80
+ }
81
+ interface WorkflowConfig {
82
+ id: string;
83
+ name: string;
84
+ nameEn: string;
85
+ category: string;
86
+ commands: string[];
87
+ defaultSelected: boolean;
88
+ order: number;
89
+ description?: string;
90
+ descriptionEn?: string;
91
+ }
92
+ interface InitOptions {
93
+ lang?: SupportedLang;
94
+ skipPrompt?: boolean;
95
+ force?: boolean;
96
+ workflows?: string;
97
+ installDir?: string;
98
+ }
99
+ interface InstallResult {
100
+ success: boolean;
101
+ installedCommands: string[];
102
+ installedPrompts: string[];
103
+ /** 非 force 安装时因目标已存在而跳过的命令(修复"假成功"计数,供共存提示) */
104
+ skippedCommands?: string[];
105
+ errors: string[];
106
+ configPath: string;
107
+ }
108
+
109
+ declare function init(options?: InitOptions): Promise<void>;
110
+
111
+ declare function showMainMenu(): Promise<void>;
112
+
113
+ /**
114
+ * Main update command - checks for updates and installs if available
115
+ */
116
+ declare function update(): Promise<void>;
117
+
118
+ declare const i18n: i18next.i18n;
119
+ declare function initI18n(lang?: SupportedLang): Promise<void>;
120
+ declare function changeLanguage(lang: SupportedLang): Promise<void>;
121
+
122
+ declare function getLyPromptsDir(): string;
123
+ declare function getLyDir(): string;
124
+ declare function getConfigPath(): string;
125
+ declare function readLyConfig(): Promise<LyConfig | null>;
126
+ declare function writeLyConfig(config: LyConfig): Promise<void>;
127
+ declare function createDefaultConfig(options: {
128
+ language: SupportedLang;
129
+ installedWorkflows: string[];
130
+ codexHost?: {
131
+ reviewModel?: string;
132
+ reviewModelB?: string;
133
+ codingModel?: string;
134
+ };
135
+ /** 已安装宿主集合(兼容旧配置;codex 单宿主缺省 ['codex']) */
136
+ installedHosts?: HostId[];
137
+ }): LyConfig;
138
+
139
+ declare function getWorkflowConfigs(): WorkflowConfig[];
140
+ declare function getWorkflowById(id: string): WorkflowConfig | undefined;
141
+
142
+ /**
143
+ * installWorkflows 的配置入参。
144
+ * promptsDir / codexSkillsDir 供测试注入,缺省用真实 homedir 路径。
145
+ */
146
+ interface InstallWorkflowsConfig {
147
+ /** codex 宿主审查模型(LyConfig.codexHost.reviewModel) */
148
+ reviewModel?: string;
149
+ /** 共享角色词目录(默认 ~/.ly/prompts/) */
150
+ promptsDir?: string;
151
+ /** codex skills 安装目录(默认 ~/.agents/skills/,测试可注入) */
152
+ codexSkillsDir?: string;
153
+ }
154
+ /**
155
+ * 旧位置角色词迁移:~/.claude/.ly/prompts/ → ~/.ly/prompts/(内容移动 + 旧目录清理)。
156
+ * 失败不抛出(返回 error 字段,调用方报告但不阻断安装主流程)。
157
+ */
158
+ interface PromptsMigrationResult {
159
+ migrated: boolean;
160
+ from?: string;
161
+ to?: string;
162
+ error?: string;
163
+ }
164
+ declare function migrateLegacyPrompts(options?: {
165
+ homeDir?: string;
166
+ promptsDir?: string;
167
+ }): Promise<PromptsMigrationResult>;
168
+ declare function installWorkflows(workflowIds: string[], installDir: string, force?: boolean, config?: InstallWorkflowsConfig): Promise<InstallResult>;
169
+ interface UninstallResult {
170
+ success: boolean;
171
+ /** 移除的 ~/.agents/skills/lyx-* skill 目录名 */
172
+ removedSkills: string[];
173
+ /** 清理的旧安装位残留 ~/.codex/prompts/ly-*.md 文件名 */
174
+ removedLegacyPrompts: string[];
175
+ /** 是否清除了共享角色词子目录 ~/.ly/prompts/codex/(父目录与其余子目录保留) */
176
+ removedSharedPrompts: boolean;
177
+ /** 共享配置 ~/.ly/config.toml 是否保留(保守策略:一律保留,仅提示) */
178
+ configTomlKept: boolean;
179
+ errors: string[];
180
+ }
181
+ /**
182
+ * Uninstall workflows(codex 单宿主):
183
+ * - 移除 ~/.agents/skills/ly-* skill 目录,并清理旧安装位 ~/.codex/prompts/ly-*.md 残留
184
+ * - 仅移除共享角色词子目录 ~/.ly/prompts/codex/(本包归属产物;父目录与其余子目录保留)
185
+ * - 保留共享配置 ~/.ly/config.toml(~/.ly 为 ly-workflow 共享命名空间,含 worktrees 等真实数据)
186
+ * - 触发 codex 侧残留清理(AGENTS.md 区块 / config.toml 旧区块 / 旧 agents)
187
+ */
188
+ declare function uninstallWorkflows(installDir: string, options?: {
189
+ legacyCleanupDirs?: {
190
+ codexDir?: string;
191
+ homeDir?: string;
192
+ };
193
+ lyPromptsDir?: string;
194
+ /** codex skills 安装目录(默认 ~/.agents/skills/,测试可注入) */
195
+ codexSkillsDir?: string;
196
+ /** 共享配置目录(默认 ~/.ly,测试可注入) */
197
+ lyDir?: string;
198
+ }): Promise<UninstallResult>;
199
+
200
+ /**
201
+ * Get current installed version from package.json
202
+ */
203
+ declare function getCurrentVersion(): Promise<string>;
204
+ /**
205
+ * Get latest version from npm registry
206
+ */
207
+ declare function getLatestVersion(packageName?: string): Promise<string | null>;
208
+ /**
209
+ * Compare two semantic versions
210
+ * @returns 1 if v1 > v2, -1 if v1 < v2, 0 if equal
211
+ */
212
+ declare function compareVersions(v1: string, v2: string): number;
213
+ /**
214
+ * Check if update is available
215
+ */
216
+ declare function checkForUpdates(): Promise<{
217
+ hasUpdate: boolean;
218
+ currentVersion: string;
219
+ latestVersion: string | null;
220
+ }>;
221
+
222
+ export { ADAPTERS, changeLanguage, checkForUpdates, compareVersions, createDefaultConfig, getConfigPath, getCurrentVersion, getLatestVersion, getLyDir, getLyPromptsDir, getWorkflowById, getWorkflowConfigs, i18n, init, initI18n, installWorkflows, migrateLegacyPrompts, readLyConfig, showMainMenu, uninstallWorkflows, update, writeLyConfig };
223
+ export type { CliOptions, HostAdapter, HostId, InitOptions, InstallResult, LyConfig, SupportedLang, WorkflowConfig };
@@ -0,0 +1,223 @@
1
+ import * as i18next from 'i18next';
2
+
3
+ /** 宿主 id(兼容旧配置读取;codex 单宿主只安装 codex) */
4
+ type HostId = 'codex' | 'claude';
5
+ /** 宿主无关的模板渲染配置(共享 LyConfig 的相关切片) */
6
+ interface HostAdapterConfig {
7
+ /** 审查 agent A 模型(LyConfig.codexHost.reviewModel);未配置或空白时回退当前会话模型 */
8
+ reviewModel?: string;
9
+ /** 审查 agent B 模型(LyConfig.codexHost.reviewModelB);未配置或空白时回退当前会话模型 */
10
+ reviewModelB?: string;
11
+ /** coding subagent(实施)模型(LyConfig.codexHost.codingModel);未配置或空白时回退当前会话模型 */
12
+ codingModel?: string;
13
+ }
14
+ /** 适配器安装/卸载/校验共用的上下文 */
15
+ interface HostAdapterContext {
16
+ /** 宿主安装根目录(保留统一形态;codex 宿主不使用) */
17
+ installDir: string;
18
+ force: boolean;
19
+ /** npm 包内 templates/ 目录 */
20
+ templateDir: string;
21
+ /** 共享角色词位置(~/.ly/prompts/,测试可注入) */
22
+ promptsDir: string;
23
+ /** codex skills 安装目录(~/.agents/skills/,测试可注入) */
24
+ codexSkillsDir: string;
25
+ config: HostAdapterConfig;
26
+ result: InstallResult;
27
+ }
28
+ /** 命令模板的源目录与安装目标 */
29
+ interface HostTemplateTarget {
30
+ sourceDir: string;
31
+ targetDir: string;
32
+ /** 目标目录名前缀(codex 宿主 = 'lyx-',安装为 <targetDir>/lyx-<cmd>/SKILL.md) */
33
+ filePrefix?: string;
34
+ }
35
+ interface HostAdapter {
36
+ id: HostId;
37
+ /** 命令模板安装目标(源目录 + 目标目录 + 文件名前缀) */
38
+ promptsTarget: (ctx: HostAdapterContext) => HostTemplateTarget;
39
+ /** 模板渲染规则:宿主可追加宿主专属变量处理(在共享 injectConfigVariables 之后) */
40
+ renderTemplate: (content: string, ctx: HostAdapterContext) => string;
41
+ /** 卸载清单:该宿主名下的产物路径清单(lyx-* 绝对路径清单) */
42
+ uninstallList: (ctx: HostAdapterContext) => Promise<string[]>;
43
+ /** 可选:宿主专属的附加安装步骤(codex 无) */
44
+ installExtras?: (ctx: HostAdapterContext) => Promise<void>;
45
+ /** 可选:安装后校验(codex = ROLE_FILE 目标存在性) */
46
+ verify?: (ctx: HostAdapterContext) => Promise<void>;
47
+ }
48
+ /** 统一注册表(codex 单宿主;保留 Record 形态供未来扩展) */
49
+ declare const ADAPTERS: Record<'codex', HostAdapter>;
50
+
51
+ interface CliOptions {
52
+ lang?: SupportedLang;
53
+ force?: boolean;
54
+ skipPrompt?: boolean;
55
+ workflows?: string;
56
+ installDir?: string;
57
+ }
58
+
59
+ type SupportedLang = 'zh-CN' | 'en';
60
+ interface LyConfig {
61
+ general: {
62
+ version: string;
63
+ language: SupportedLang;
64
+ createdAt: string;
65
+ };
66
+ workflows: {
67
+ installed: string[];
68
+ };
69
+ installedHosts?: HostId[];
70
+ paths: {
71
+ commands: string;
72
+ prompts: string;
73
+ backup: string;
74
+ };
75
+ codexHost?: {
76
+ reviewModel?: string;
77
+ reviewModelB?: string;
78
+ codingModel?: string;
79
+ };
80
+ }
81
+ interface WorkflowConfig {
82
+ id: string;
83
+ name: string;
84
+ nameEn: string;
85
+ category: string;
86
+ commands: string[];
87
+ defaultSelected: boolean;
88
+ order: number;
89
+ description?: string;
90
+ descriptionEn?: string;
91
+ }
92
+ interface InitOptions {
93
+ lang?: SupportedLang;
94
+ skipPrompt?: boolean;
95
+ force?: boolean;
96
+ workflows?: string;
97
+ installDir?: string;
98
+ }
99
+ interface InstallResult {
100
+ success: boolean;
101
+ installedCommands: string[];
102
+ installedPrompts: string[];
103
+ /** 非 force 安装时因目标已存在而跳过的命令(修复"假成功"计数,供共存提示) */
104
+ skippedCommands?: string[];
105
+ errors: string[];
106
+ configPath: string;
107
+ }
108
+
109
+ declare function init(options?: InitOptions): Promise<void>;
110
+
111
+ declare function showMainMenu(): Promise<void>;
112
+
113
+ /**
114
+ * Main update command - checks for updates and installs if available
115
+ */
116
+ declare function update(): Promise<void>;
117
+
118
+ declare const i18n: i18next.i18n;
119
+ declare function initI18n(lang?: SupportedLang): Promise<void>;
120
+ declare function changeLanguage(lang: SupportedLang): Promise<void>;
121
+
122
+ declare function getLyPromptsDir(): string;
123
+ declare function getLyDir(): string;
124
+ declare function getConfigPath(): string;
125
+ declare function readLyConfig(): Promise<LyConfig | null>;
126
+ declare function writeLyConfig(config: LyConfig): Promise<void>;
127
+ declare function createDefaultConfig(options: {
128
+ language: SupportedLang;
129
+ installedWorkflows: string[];
130
+ codexHost?: {
131
+ reviewModel?: string;
132
+ reviewModelB?: string;
133
+ codingModel?: string;
134
+ };
135
+ /** 已安装宿主集合(兼容旧配置;codex 单宿主缺省 ['codex']) */
136
+ installedHosts?: HostId[];
137
+ }): LyConfig;
138
+
139
+ declare function getWorkflowConfigs(): WorkflowConfig[];
140
+ declare function getWorkflowById(id: string): WorkflowConfig | undefined;
141
+
142
+ /**
143
+ * installWorkflows 的配置入参。
144
+ * promptsDir / codexSkillsDir 供测试注入,缺省用真实 homedir 路径。
145
+ */
146
+ interface InstallWorkflowsConfig {
147
+ /** codex 宿主审查模型(LyConfig.codexHost.reviewModel) */
148
+ reviewModel?: string;
149
+ /** 共享角色词目录(默认 ~/.ly/prompts/) */
150
+ promptsDir?: string;
151
+ /** codex skills 安装目录(默认 ~/.agents/skills/,测试可注入) */
152
+ codexSkillsDir?: string;
153
+ }
154
+ /**
155
+ * 旧位置角色词迁移:~/.claude/.ly/prompts/ → ~/.ly/prompts/(内容移动 + 旧目录清理)。
156
+ * 失败不抛出(返回 error 字段,调用方报告但不阻断安装主流程)。
157
+ */
158
+ interface PromptsMigrationResult {
159
+ migrated: boolean;
160
+ from?: string;
161
+ to?: string;
162
+ error?: string;
163
+ }
164
+ declare function migrateLegacyPrompts(options?: {
165
+ homeDir?: string;
166
+ promptsDir?: string;
167
+ }): Promise<PromptsMigrationResult>;
168
+ declare function installWorkflows(workflowIds: string[], installDir: string, force?: boolean, config?: InstallWorkflowsConfig): Promise<InstallResult>;
169
+ interface UninstallResult {
170
+ success: boolean;
171
+ /** 移除的 ~/.agents/skills/lyx-* skill 目录名 */
172
+ removedSkills: string[];
173
+ /** 清理的旧安装位残留 ~/.codex/prompts/ly-*.md 文件名 */
174
+ removedLegacyPrompts: string[];
175
+ /** 是否清除了共享角色词子目录 ~/.ly/prompts/codex/(父目录与其余子目录保留) */
176
+ removedSharedPrompts: boolean;
177
+ /** 共享配置 ~/.ly/config.toml 是否保留(保守策略:一律保留,仅提示) */
178
+ configTomlKept: boolean;
179
+ errors: string[];
180
+ }
181
+ /**
182
+ * Uninstall workflows(codex 单宿主):
183
+ * - 移除 ~/.agents/skills/ly-* skill 目录,并清理旧安装位 ~/.codex/prompts/ly-*.md 残留
184
+ * - 仅移除共享角色词子目录 ~/.ly/prompts/codex/(本包归属产物;父目录与其余子目录保留)
185
+ * - 保留共享配置 ~/.ly/config.toml(~/.ly 为 ly-workflow 共享命名空间,含 worktrees 等真实数据)
186
+ * - 触发 codex 侧残留清理(AGENTS.md 区块 / config.toml 旧区块 / 旧 agents)
187
+ */
188
+ declare function uninstallWorkflows(installDir: string, options?: {
189
+ legacyCleanupDirs?: {
190
+ codexDir?: string;
191
+ homeDir?: string;
192
+ };
193
+ lyPromptsDir?: string;
194
+ /** codex skills 安装目录(默认 ~/.agents/skills/,测试可注入) */
195
+ codexSkillsDir?: string;
196
+ /** 共享配置目录(默认 ~/.ly,测试可注入) */
197
+ lyDir?: string;
198
+ }): Promise<UninstallResult>;
199
+
200
+ /**
201
+ * Get current installed version from package.json
202
+ */
203
+ declare function getCurrentVersion(): Promise<string>;
204
+ /**
205
+ * Get latest version from npm registry
206
+ */
207
+ declare function getLatestVersion(packageName?: string): Promise<string | null>;
208
+ /**
209
+ * Compare two semantic versions
210
+ * @returns 1 if v1 > v2, -1 if v1 < v2, 0 if equal
211
+ */
212
+ declare function compareVersions(v1: string, v2: string): number;
213
+ /**
214
+ * Check if update is available
215
+ */
216
+ declare function checkForUpdates(): Promise<{
217
+ hasUpdate: boolean;
218
+ currentVersion: string;
219
+ latestVersion: string | null;
220
+ }>;
221
+
222
+ export { ADAPTERS, changeLanguage, checkForUpdates, compareVersions, createDefaultConfig, getConfigPath, getCurrentVersion, getLatestVersion, getLyDir, getLyPromptsDir, getWorkflowById, getWorkflowConfigs, i18n, init, initI18n, installWorkflows, migrateLegacyPrompts, readLyConfig, showMainMenu, uninstallWorkflows, update, writeLyConfig };
223
+ export type { CliOptions, HostAdapter, HostId, InitOptions, InstallResult, LyConfig, SupportedLang, WorkflowConfig };
package/dist/index.mjs ADDED
@@ -0,0 +1,12 @@
1
+ export { A as ADAPTERS, c as changeLanguage, n as checkForUpdates, o as compareVersions, d as createDefaultConfig, g as getConfigPath, p as getCurrentVersion, q as getLatestVersion, e as getLyDir, f as getLyPromptsDir, h as getWorkflowById, j as getWorkflowConfigs, a as i18n, i as init, b as initI18n, k as installWorkflows, m as migrateLegacyPrompts, r as readLyConfig, s as showMainMenu, l as uninstallWorkflows, u as update, w as writeLyConfig } from './shared/ly-workflow-codex.K-E7PMp3.mjs';
2
+ import 'node:child_process';
3
+ import 'node:os';
4
+ import 'node:util';
5
+ import 'ansis';
6
+ import 'fs-extra';
7
+ import 'inquirer';
8
+ import 'ora';
9
+ import 'pathe';
10
+ import 'smol-toml';
11
+ import 'i18next';
12
+ import 'node:url';