@icebreakers/monorepo 3.2.18 → 4.0.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.
package/dist/index.d.mts CHANGED
@@ -1,703 +1,283 @@
1
- import * as git_url_parse0 from "git-url-parse";
1
+ import { $ as LintStagedToolingConfig, A as ConfigValues, B as PackageJson, C as defineEslintConfig, Ct as createTimestampFolderName, D as defineVitestConfig, Dt as loadAgenticTasks, E as defineTsconfigConfig, Et as generateAgenticTemplates, F as WorkspacePackage, G as AiCommandConfig, H as PackageJsonExports, I as WorkspacePackageManifest, J as CreateChoiceOption, K as CleanCommandConfig, L as WorkspacePackageSummary, M as SimpleGitOptions, N as GetWorkspacePackagesOptions, O as defineVitestProjectConfig, Ot as CliOpts, P as WorkspaceData, Q as InitCommandConfig, R as WorkspacePackageSummaryData, S as defineCommitlintConfig, St as GenerateAgenticTemplateOptions, T as defineStylelintConfig, Tt as generateAgenticTemplate, U as PackageJsonPerson, V as PackageJsonBugs, W as PackageJsonRepository, X as EslintToolingConfig, Y as CreateCommandConfig, Z as HuskyToolingConfig, _ as createMonorepoLintStagedConfig, _t as getTemplateMap, a as MonorepoEslintConfig, at as UpgradeCommandConfig, b as createMonorepoVitestConfig, bt as AgenticTemplateFormat, c as MonorepoStylelintConfig, ct as init, d as MonorepoVitestConfigOverrides, dt as normalizeInitToolingTargets, et as MirrorCommandConfig, f as MonorepoVitestConfigResult, ft as initToolingTargets, g as createMonorepoEslintConfig, gt as getCreateChoices, h as createMonorepoCommitlintConfig, ht as CreateNewProjectPlan, i as MonorepoCommitlintConfig, it as TsconfigToolingConfig, j as SimpleGit, k as loadMonorepoToolingConfig, l as MonorepoTsconfig, lt as initMetadata, m as MonorepoVitestProjectConfigResult, mt as CreateNewProjectOptions, n as DefineVitestConfigOptions, nt as StylelintToolingConfig, o as MonorepoLintStagedConfig, ot as VitestProjectToolingConfig, p as MonorepoVitestProjectConfigOptions, pt as createNewProject, q as CommitlintToolingConfig, r as DefineVitestProjectConfigOptions, rt as ToolingConfig, s as MonorepoLintStagedConfigOptions, st as VitestToolingConfig, t as DefineConfigOptions, tt as MonorepoConfig, u as MonorepoVitestConfigOptions, ut as initTooling, v as createMonorepoStylelintConfig, vt as resolveCreateNewProjectPlan, w as defineLintStagedConfig, wt as defaultAgenticBaseDir, x as createMonorepoVitestProjectConfig, xt as AgenticTemplateTask, y as createMonorepoTsconfig, yt as templateMap, z as WorkspacePackageWithJsonPath } from "./index-BBxViYZd.mjs";
2
2
  import gitUrlParse from "git-url-parse";
3
- import * as simple_git0 from "simple-git";
4
- import { ConfigValues, SimpleGit, SimpleGitOptions } from "simple-git";
3
+ import * as _$simple_git0 from "simple-git";
5
4
  import { mkdtemp, readFile, stat, writeFile } from "node:fs/promises";
6
- import * as consola from "consola";
7
- import { TemplateDefinition, assetsDir, isGitignoreFile, templatesDir, toPublishGitignorePath, toWorkspaceGitignorePath } from "@icebreakers/monorepo-templates";
5
+ import * as _$consola from "consola";
6
+ import { execFileSync, spawnSync } from "node:child_process";
7
+ import { isGitignoreFile, toPublishGitignorePath, toWorkspaceGitignorePath } from "@icebreakers/monorepo-templates";
8
8
  import crypto from "node:crypto";
9
- import * as _pnpm_types0 from "@pnpm/types";
9
+ import { Buffer } from "node:buffer";
10
10
 
11
- //#region src/types/cli.d.ts
12
- /**
13
- * CLI 公用参数,保证各命令对外暴露一致的行为。
14
- */
15
- interface CliOpts {
16
- /**
17
- * 是否开启交互模式,开启后每一步都会提示用户确认。
18
- * @default false
19
- */
20
- interactive?: boolean;
21
- /**
22
- * 是否使用 core 版资产,只同步最精简的文件集合。
23
- * @default false
24
- */
25
- core?: boolean;
26
- /**
27
- * 输出目录(相对 `cwd`),用于放置生成或拷贝出来的文件。
28
- * @default ''
29
- */
30
- outDir?: string;
31
- /**
32
- * 命令执行的工作目录。
33
- * @default process.cwd()
34
- */
35
- cwd?: string;
36
- /**
37
- * 是否跳过已有文件的覆写;开启后保留旧文件不做对比。
38
- * @default false
39
- */
40
- skipOverwrite?: boolean;
11
+ //#region src/commands/check.d.ts
12
+ interface RecommendedCheckOptions {
13
+ cwd: string;
14
+ full?: boolean;
15
+ staged?: boolean;
16
+ editFile?: string;
41
17
  }
42
- //#endregion
43
- //#region src/commands/ai.d.ts
44
- type AgenticTemplateFormat = 'md' | 'json';
45
- interface GenerateAgenticTemplateOptions {
46
- cwd?: string;
47
- output?: string;
48
- force?: boolean;
49
- format?: AgenticTemplateFormat;
50
- /**
51
- * 任务名,用于快速生成带目录与后缀的文件。
52
- */
53
- name?: string;
54
- /**
55
- * 基础目录,配合 name 使用。
56
- * @default 'agentic/prompts'
57
- */
58
- baseDir?: string;
59
- /**
60
- * 自动生成目录时使用的自定义文件夹名称。
61
- * @default 自动生成的时间戳
62
- */
63
- folderName?: string;
18
+ type RecommendedCheckMode = 'commit-msg' | 'full' | 'staged' | 'default';
19
+ interface RecommendedCheckPlanCommand {
20
+ name: string;
21
+ command: string;
22
+ description: string;
64
23
  }
65
- type AgenticTemplateTask = string | (Omit<GenerateAgenticTemplateOptions, 'cwd'> & {
66
- name?: string;
67
- });
68
- declare const defaultAgenticBaseDir = "agentic/prompts";
69
- declare function createTimestampFolderName(date?: Date): string;
70
- /**
71
- * 生成 Agentic 任务提示词模板,默认写入 agentic/prompts/<timestamp>/prompt.md,可自定义输出路径。
72
- */
73
- declare function generateAgenticTemplate(options?: GenerateAgenticTemplateOptions): Promise<string>;
74
- declare function loadAgenticTasks(filePath: string, cwd: string): Promise<AgenticTemplateTask[]>;
75
- declare function generateAgenticTemplates(tasks: AgenticTemplateTask[], defaults?: GenerateAgenticTemplateOptions): Promise<string[]>;
24
+ interface RecommendedCheckPlan {
25
+ cwd: string;
26
+ mode: RecommendedCheckMode;
27
+ commands: RecommendedCheckPlanCommand[];
28
+ }
29
+ declare function resolveRecommendedCheckPlan(options: RecommendedCheckOptions): RecommendedCheckPlan;
30
+ declare function runRecommendedCheck(options: RecommendedCheckOptions): Promise<void>;
76
31
  //#endregion
77
- //#region src/commands/create.d.ts
78
- /**
79
- * 内置模板映射表,source 指向 templates 根目录下的来源目录,target 为生成路径。
80
- */
81
- declare const templateMap: {
82
- readonly tsup: {
83
- readonly source: "tsup";
84
- readonly target: "packages/tsup";
85
- };
86
- readonly tsdown: {
87
- readonly source: "tsdown";
88
- readonly target: "packages/tsdown";
89
- };
90
- readonly unbuild: {
91
- readonly source: "unbuild";
92
- readonly target: "packages/unbuild";
93
- };
94
- readonly 'vue-lib': {
95
- readonly source: "vue-lib";
96
- readonly target: "packages/vue-lib";
97
- };
98
- readonly 'hono-server': {
99
- readonly source: "server";
100
- readonly target: "apps/server";
101
- };
102
- readonly 'vue-hono': {
103
- readonly source: "client";
104
- readonly target: "apps/client";
105
- };
106
- readonly vitepress: {
107
- readonly source: "vitepress";
108
- readonly target: "apps/website";
109
- };
110
- readonly cli: {
111
- readonly source: "cli";
112
- readonly target: "apps/cli";
113
- };
114
- };
115
- type CreateNewProjectType = keyof typeof templateMap;
116
- interface CreateNewProjectOptions {
117
- name?: string;
118
- cwd?: string;
119
- renameJson?: boolean;
120
- type?: CreateNewProjectType | string;
32
+ //#region src/commands/config.d.ts
33
+ interface ConfigInspection {
34
+ cwd: string;
35
+ file: string | null;
36
+ config: MonorepoConfig;
121
37
  }
122
- /**
123
- * 若配置中提供 choices 则优先使用,否则退回默认预设。
124
- */
125
- declare function getCreateChoices(choices?: CreateChoiceOption[]): CreateChoiceOption[] | ({
126
- readonly name: "unbuild 打包";
127
- readonly value: "unbuild";
128
- } | {
129
- readonly name: "tsup 打包";
130
- readonly value: "tsup";
131
- } | {
132
- readonly name: "tsdown 打包";
133
- readonly value: "tsdown";
134
- } | {
135
- readonly name: "vue 组件";
136
- readonly value: "vue-lib";
137
- } | {
138
- readonly name: "vue hono 全栈";
139
- readonly value: "vue-hono";
140
- } | {
141
- readonly name: "hono 模板";
142
- readonly value: "hono-server";
143
- } | {
144
- readonly name: "vitepress 文档";
145
- readonly value: "vitepress";
146
- } | {
147
- readonly name: "cli 模板";
148
- readonly value: "cli";
149
- })[];
150
- /**
151
- * 合并内置与自定义模板映射,允许扩展新的模板类型。
152
- */
153
- declare function getTemplateMap(extra?: Record<string, string | TemplateDefinition>): Record<string, TemplateDefinition>;
154
- /**
155
- * 根据提供的参数或配置生成新工程目录,并可自动改写 package.json。
156
- */
157
- declare function createNewProject(options?: CreateNewProjectOptions): Promise<void>;
38
+ declare function inspectMonorepoConfig(cwd: string): Promise<ConfigInspection>;
158
39
  //#endregion
159
- //#region src/types/workspace.d.ts
160
- /**
161
- * 工作区工具可接收的筛选选项。
162
- */
163
- interface GetWorkspacePackagesOptions {
164
- /**
165
- * 是否在结果中排除 workspace 根包。
166
- * @default true
167
- */
168
- ignoreRootPackage?: boolean;
169
- /**
170
- * 是否过滤掉标记为 `private` 的包。
171
- * @default true
172
- */
173
- ignorePrivatePackage?: boolean;
174
- /**
175
- * 自定义 glob,覆盖 `pnpm-workspace.yaml` 的 `packages` 配置。
176
- * @default workspace manifest `packages`
177
- */
178
- patterns?: string[];
40
+ //#region src/commands/doctor.d.ts
41
+ type DoctorStatus = 'pass' | 'warn' | 'fail';
42
+ interface DoctorCheck {
43
+ id: string;
44
+ title: string;
45
+ status: DoctorStatus;
46
+ detail: string;
47
+ fix?: string;
48
+ }
49
+ interface DoctorSummary {
50
+ pass: number;
51
+ warn: number;
52
+ fail: number;
53
+ }
54
+ interface DoctorReport {
55
+ cwd: string;
56
+ workspaceDir: string;
57
+ packageCount: number;
58
+ checks: DoctorCheck[];
59
+ summary: DoctorSummary;
179
60
  }
61
+ declare function runDoctor(cwd: string): Promise<{
62
+ cwd: string;
63
+ workspaceDir: string;
64
+ packageCount: number;
65
+ checks: DoctorCheck[];
66
+ summary: DoctorSummary;
67
+ }>;
180
68
  //#endregion
181
- //#region src/types/config.d.ts
182
- interface AiCommandConfig {
183
- /**
184
- * 默认输出路径,不填则自动创建 `agentic/prompts/<timestamp>/prompt.md` 文件夹与模板。
185
- * @default undefined
186
- */
187
- output?: string;
188
- /**
189
- * 默认存放目录,配合 name / tasks 批量生成时使用。
190
- * @default 'agentic/prompts'
191
- */
192
- baseDir?: string;
193
- /**
194
- * 是否允许覆盖已存在文件。
195
- * @default false
196
- */
197
- force?: boolean;
198
- /**
199
- * 模板格式。
200
- * @default 'md'
201
- */
202
- format?: AgenticTemplateFormat;
203
- /**
204
- * 任务清单文件路径(JSON 数组),用于批量生成。
205
- * @default undefined
206
- */
207
- tasksFile?: string;
69
+ //#region src/commands/env.d.ts
70
+ interface EnvInfo {
71
+ cwd: string;
72
+ workspaceDir: string;
73
+ packageManager?: string;
74
+ nodeVersion: string;
75
+ nodeRange?: string;
76
+ pnpmVersion?: string;
77
+ platform: string;
78
+ arch: string;
79
+ packageCount: number;
208
80
  }
209
- /**
210
- * `monorepo new` 命令的配置项,允许外部覆写模板目录、模板清单等。
211
- */
212
- interface CreateCommandConfig extends Partial<Omit<CreateNewProjectOptions, 'cwd'>> {
213
- /**
214
- * 自定义模板根目录。
215
- * @default 内置模板所在的 `packages/monorepo/templates`
216
- */
217
- templatesDir?: string;
218
- /**
219
- * 扩展模板映射表,key 为类型,value 为模板来源/目标路径。
220
- * @default 内置 `templateMap`
221
- */
222
- templateMap?: Record<string, string | TemplateDefinition>;
223
- /**
224
- * 自定义交互提示的选项列表。
225
- * @default 内置 `baseChoices`
226
- */
227
- choices?: CreateChoiceOption[];
228
- /**
229
- * 当未选择模板时使用的默认模板。
230
- * @default 'unbuild'
231
- */
232
- defaultTemplate?: CreateNewProjectOptions['type'];
81
+ interface EnvSnapshot {
82
+ generatedAt: string;
83
+ env: EnvInfo;
84
+ doctor: DoctorReport;
85
+ checkPlan: RecommendedCheckPlan;
233
86
  }
234
- /**
235
- * CLI 交互式选择框的选项结构。
236
- */
237
- interface CreateChoiceOption {
238
- /**
239
- * 唯一值,将回传给命令逻辑使用。
240
- * @default undefined
241
- */
242
- value: string;
243
- /**
244
- * 选项展示名称。
245
- * @default value
246
- */
247
- name?: string;
248
- /**
249
- * 选项描述信息。
250
- * @default undefined
251
- */
252
- description?: string;
253
- /**
254
- * 短名称,用于命令行紧凑展示。
255
- * @default undefined
256
- */
257
- short?: string;
258
- /**
259
- * 设置为 true 或字符串即可禁用该选项并显示原因。
260
- * @default false
261
- */
262
- disabled?: boolean | string;
87
+ interface EnvSupportBundle {
88
+ generatedAt: string;
89
+ env: EnvInfo;
90
+ paths: EnvPaths;
91
+ config: ConfigInspection;
92
+ doctor: DoctorReport;
93
+ checkPlan: RecommendedCheckPlan;
263
94
  }
264
- /**
265
- * `monorepo clean` 命令配置,可控制自动选择、排除包等行为。
266
- */
267
- interface CleanCommandConfig {
268
- /**
269
- * 是否跳过交互直接清理全部。
270
- * @default false
271
- */
272
- autoConfirm?: boolean;
273
- /**
274
- * 不允许被清理的包名列表。
275
- * @default []
276
- */
277
- ignorePackages?: string[];
278
- /**
279
- * 是否包含 private 包。
280
- * @default true
281
- */
282
- includePrivate?: boolean;
283
- /**
284
- * 强制写回的 @icebreakers/monorepo 版本。
285
- * @default 当前依赖版本
286
- */
287
- pinnedVersion?: string;
95
+ interface EnvPathEntry {
96
+ path: string;
97
+ relativePath: string;
98
+ exists: boolean;
288
99
  }
289
- /**
290
- * `monorepo sync` 命令配置,可覆盖 workspace 过滤规则或同步命令模板。
291
- */
292
- interface SyncCommandConfig extends Partial<GetWorkspacePackagesOptions> {
293
- /**
294
- * 并发执行同步命令的最大数量。
295
- * @default os.cpus().length
296
- */
297
- concurrency?: number;
298
- /**
299
- * 自定义执行的同步命令模板,使用 {name} 占位。
300
- * @default 'cnpm sync {name}'
301
- */
302
- command?: string;
303
- /**
304
- * 仅同步指定的包(按名称过滤)。
305
- * @default 同步全部可见包
306
- */
307
- packages?: string[];
100
+ interface EnvPaths {
101
+ cwd: string;
102
+ workspaceDir: string;
103
+ paths: {
104
+ packageJson: EnvPathEntry;
105
+ workspaceManifest: EnvPathEntry;
106
+ repoctlConfig: EnvPathEntry;
107
+ repoctlConfigs: EnvPathEntry[];
108
+ legacyConfig: EnvPathEntry;
109
+ legacyConfigs: EnvPathEntry[];
110
+ toolingDir: EnvPathEntry;
111
+ reportsDir: EnvPathEntry;
112
+ doctorReport: EnvPathEntry;
113
+ envReport: EnvPathEntry;
114
+ snapshotReport: EnvPathEntry;
115
+ checkPlanReport: EnvPathEntry;
116
+ };
308
117
  }
118
+ declare function collectEnvInfo(cwd: string): Promise<EnvInfo>;
119
+ declare function collectEnvPaths(cwd: string): Promise<EnvPaths>;
120
+ declare function collectEnvSnapshot(cwd: string, now?: Date): Promise<EnvSnapshot>;
121
+ declare function collectEnvSupportBundle(cwd: string, now?: Date): Promise<EnvSupportBundle>;
122
+ //#endregion
123
+ //#region src/commands/skills.d.ts
309
124
  /**
310
- * `monorepo upgrade` 命令配置,覆盖脚本、目标文件等能力。
125
+ * 当前支持的 skills 同步目标。
311
126
  */
312
- interface UpgradeCommandConfig extends Partial<CliOpts> {
313
- /**
314
- * 额外需要写入的目标文件列表。
315
- * @default []
316
- */
317
- targets?: string[];
318
- /**
319
- * 是否与默认目标合并,false 表示完全覆盖。
320
- * @default true
321
- */
322
- mergeTargets?: boolean;
127
+ declare const skillTargets: readonly ["codex", "claude"];
128
+ type SkillTarget = typeof skillTargets[number];
129
+ interface SyncSkillsOptions {
323
130
  /**
324
- * 需要写入 package.json 的脚本集合。
325
- * @default {}
131
+ * 当前工作目录。
132
+ * 仅用于生成更友好的错误提示。
133
+ * @default process.cwd()
326
134
  */
327
- scripts?: Record<string, string>;
135
+ cwd?: string;
328
136
  /**
329
- * 是否跳过生成 changeset markdown。
330
- * @default true
137
+ * 需要同步的目标列表。
138
+ * 未提供时会在 CLI 中交互选择。
139
+ * @default undefined
331
140
  */
332
- skipChangesetMarkdown?: boolean;
141
+ targets?: SkillTarget[];
333
142
  }
334
143
  /**
335
- * `monorepo init` 命令配置,用于跳过部分初始化步骤。
144
+ * 计算各个目标平台的 skills 安装路径。
145
+ *
146
+ * @param homeDir 用户 home 目录,默认取 `os.homedir()`
336
147
  */
337
- interface InitCommandConfig {
338
- /**
339
- * 是否跳过 README 生成。
340
- * @default false
341
- */
342
- skipReadme?: boolean;
343
- /**
344
- * 是否跳过 package.json 写入。
345
- * @default false
346
- */
347
- skipPkgJson?: boolean;
348
- /**
349
- * 是否跳过 changeset 的更新。
350
- * @default false
351
- */
352
- skipChangeset?: boolean;
353
- /**
354
- * 是否跳过 Issue 模版 discussions 链接的更新。
355
- * @default false
356
- */
357
- skipIssueTemplateConfig?: boolean;
358
- }
148
+ declare function getSkillTargetPaths(homeDir?: string): Record<SkillTarget, string>;
359
149
  /**
360
- * `monorepo mirror` 命令配置,可增加额外的环境变量镜像。
150
+ * 将内置 skills 同步到一个或多个目标平台目录。
151
+ *
152
+ * @param options 同步选项
153
+ * @returns 成功同步的目标及落盘路径列表
361
154
  */
362
- interface MirrorCommandConfig {
363
- /**
364
- * 需要注入的环境变量键值对。
365
- * @default {}
366
- */
367
- env?: Record<string, string>;
155
+ declare function syncSkills(options?: SyncSkillsOptions): Promise<{
156
+ target: SkillTarget;
157
+ dest: string;
158
+ }[]>;
159
+ //#endregion
160
+ //#region src/commands/templates.d.ts
161
+ type TemplateHealthStatus = 'pass' | 'warn' | 'fail';
162
+ interface TemplateHealthCheck {
163
+ id: string;
164
+ status: TemplateHealthStatus;
165
+ title: string;
166
+ detail: string;
167
+ template?: string;
168
+ fix?: string;
368
169
  }
369
- /**
370
- * 项目级配置入口,按命令划分可插拔的配置块。
371
- */
372
- interface MonorepoConfig {
373
- /**
374
- * 按命令分类的可选配置。
375
- * @default {}
376
- */
377
- commands?: {
378
- ai?: AiCommandConfig;
379
- create?: CreateCommandConfig;
380
- clean?: CleanCommandConfig;
381
- sync?: SyncCommandConfig;
382
- upgrade?: UpgradeCommandConfig;
383
- init?: InitCommandConfig;
384
- mirror?: MirrorCommandConfig;
385
- };
170
+ interface TemplateHealthSummary {
171
+ pass: number;
172
+ warn: number;
173
+ fail: number;
386
174
  }
175
+ interface TemplateHealthReport {
176
+ templatesDir: string;
177
+ templateCount: number;
178
+ checks: TemplateHealthCheck[];
179
+ summary: TemplateHealthSummary;
180
+ }
181
+ interface CheckTemplatesOptions {
182
+ templatesDir?: string;
183
+ }
184
+ declare function checkTemplates(options?: CheckTemplatesOptions): Promise<TemplateHealthReport>;
387
185
  //#endregion
388
- //#region ../../node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.d.mts
389
- interface PackageJson {
390
- /**
391
- * The name is what your thing is called.
392
- * Some rules:
393
- * - The name must be less than or equal to 214 characters. This includes the scope for scoped packages.
394
- * - The name can’t start with a dot or an underscore.
395
- * - New packages must not have uppercase letters in the name.
396
- * - The name ends up being part of a URL, an argument on the command line, and a folder name. Therefore, the name can’t contain any non-URL-safe characters.
397
- */
398
- name?: string;
399
- /**
400
- * Version must be parseable by `node-semver`, which is bundled with npm as a dependency. (`npm install semver` to use it yourself.)
401
- */
402
- version?: string;
403
- /**
404
- * Put a description in it. It’s a string. This helps people discover your package, as it’s listed in `npm search`.
405
- */
406
- description?: string;
407
- /**
408
- * Put keywords in it. It’s an array of strings. This helps people discover your package as it’s listed in `npm search`.
409
- */
410
- keywords?: string[];
411
- /**
412
- * The url to the project homepage.
413
- */
414
- homepage?: string;
415
- /**
416
- * The url to your project’s issue tracker and / or the email address to which issues should be reported. These are helpful for people who encounter issues with your package.
417
- */
418
- bugs?: string | {
419
- url?: string;
420
- email?: string;
421
- };
422
- /**
423
- * You should specify a license for your package so that people know how they are permitted to use it, and any restrictions you’re placing on it.
424
- */
425
- license?: string;
426
- /**
427
- * Specify the place where your code lives. This is helpful for people who want to contribute. If the git repo is on GitHub, then the `npm docs` command will be able to find you.
428
- * For GitHub, GitHub gist, Bitbucket, or GitLab repositories you can use the same shortcut syntax you use for npm install:
429
- */
430
- repository?: string | {
431
- type: string;
432
- url: string;
433
- /**
434
- * If the `package.json` for your package is not in the root directory (for example if it is part of a monorepo), you can specify the directory in which it lives:
435
- */
436
- directory?: string;
437
- };
438
- /**
439
- * The `scripts` field is a dictionary containing script commands that are run at various times in the lifecycle of your package.
440
- */
441
- scripts?: PackageJsonScripts;
442
- /**
443
- * If you set `"private": true` in your package.json, then npm will refuse to publish it.
444
- */
445
- private?: boolean;
446
- /**
447
- * The “author” is one person.
448
- */
449
- author?: PackageJsonPerson;
450
- /**
451
- * “contributors” is an array of people.
452
- */
453
- contributors?: PackageJsonPerson[];
454
- /**
455
- * An object containing a URL that provides up-to-date information
456
- * about ways to help fund development of your package,
457
- * a string URL, or an array of objects and string URLs
458
- */
459
- funding?: PackageJsonFunding | PackageJsonFunding[];
460
- /**
461
- * The optional `files` field is an array of file patterns that describes the entries to be included when your package is installed as a dependency. File patterns follow a similar syntax to `.gitignore`, but reversed: including a file, directory, or glob pattern (`*`, `**\/*`, and such) will make it so that file is included in the tarball when it’s packed. Omitting the field will make it default to `["*"]`, which means it will include all files.
462
- */
463
- files?: string[];
464
- /**
465
- * The main field is a module ID that is the primary entry point to your program. That is, if your package is named `foo`, and a user installs it, and then does `require("foo")`, then your main module’s exports object will be returned.
466
- * This should be a module ID relative to the root of your package folder.
467
- * For most modules, it makes the most sense to have a main script and often not much else.
468
- */
469
- main?: string;
470
- /**
471
- * If your module is meant to be used client-side the browser field should be used instead of the main field. This is helpful to hint users that it might rely on primitives that aren’t available in Node.js modules. (e.g. window)
472
- */
473
- browser?: string | Record<string, string | false>;
474
- /**
475
- * The `unpkg` field is used to specify the URL to a UMD module for your package. This is used by default in the unpkg.com CDN service.
476
- */
477
- unpkg?: string;
186
+ //#region src/commands/verify/index.d.ts
187
+ interface VerifyCommandOptions {
478
188
  /**
479
- * A map of command name to local file name. On install, npm will symlink that file into `prefix/bin` for global installs, or `./node_modules/.bin/` for local installs.
480
- */
481
- bin?: string | Record<string, string>;
482
- /**
483
- * Specify either a single file or an array of filenames to put in place for the `man` program to find.
484
- */
485
- man?: string | string[];
486
- /**
487
- * Dependencies are specified in a simple object that maps a package name to a version range. The version range is a string which has one or more space-separated descriptors. Dependencies can also be identified with a tarball or git URL.
488
- */
489
- dependencies?: Record<string, string>;
490
- /**
491
- * If someone is planning on downloading and using your module in their program, then they probably don’t want or need to download and build the external test or documentation framework that you use.
492
- * In this case, it’s best to map these additional items in a `devDependencies` object.
493
- */
494
- devDependencies?: Record<string, string>;
495
- /**
496
- * If a dependency can be used, but you would like npm to proceed if it cannot be found or fails to install, then you may put it in the `optionalDependencies` object. This is a map of package name to version or url, just like the `dependencies` object. The difference is that build failures do not cause installation to fail.
497
- */
498
- optionalDependencies?: Record<string, string>;
499
- /**
500
- * In some cases, you want to express the compatibility of your package with a host tool or library, while not necessarily doing a `require` of this host. This is usually referred to as a plugin. Notably, your module may be exposing a specific interface, expected and specified by the host documentation.
501
- */
502
- peerDependencies?: Record<string, string>;
503
- /**
504
- * TypeScript typings, typically ending by `.d.ts`.
505
- */
506
- types?: string;
507
- /**
508
- * This field is synonymous with `types`.
509
- */
510
- typings?: string;
511
- /**
512
- * Non-Standard Node.js alternate entry-point to main.
513
- * An initial implementation for supporting CJS packages (from main), and use module for ESM modules.
514
- */
515
- module?: string;
516
- /**
517
- * Make main entry-point be loaded as an ESM module, support "export" syntax instead of "require"
518
- *
519
- * Docs:
520
- * - https://nodejs.org/docs/latest-v14.x/api/esm.html#esm_package_json_type_field
521
- *
522
- * @default 'commonjs'
523
- * @since Node.js v14
189
+ * 命令执行根目录。
190
+ * @default process.cwd()
524
191
  */
525
- type?: "module" | "commonjs";
192
+ cwd?: string;
193
+ }
194
+ interface PrePushVerifyOptions extends VerifyCommandOptions {
526
195
  /**
527
- * Alternate and extensible alternative to "main" entry point.
528
- *
529
- * When using `{type: "module"}`, any ESM module file MUST end with `.mjs` extension.
530
- *
531
- * Docs:
532
- * - https://nodejs.org/docs/latest-v14.x/api/esm.html#esm_exports_sugar
533
- *
534
- * @since Node.js v12.7
196
+ * pre-push hook 的 stdin 原始文本。
197
+ * 未提供时会从真实 stdin 读取。
198
+ * @default undefined
535
199
  */
536
- exports?: PackageJsonExports;
200
+ stdinText?: string;
537
201
  /**
538
- * Docs:
539
- * - https://nodejs.org/api/packages.html#imports
202
+ * 参与变更归属计算的 workspace 列表。
203
+ * @default 内置 `defaultWorkspaceOrder`
540
204
  */
541
- imports?: Record<string, string | Record<string, string>>;
205
+ workspaces?: string[];
542
206
  /**
543
- * The field is used to define a set of sub-packages (or workspaces) within a monorepo.
544
- *
545
- * This field is an array of glob patterns or an object with specific configurations for managing
546
- * multiple packages in a single repository.
207
+ * 可注入的 `execFileSync` 实现,主要用于测试。
208
+ * @default node:child_process.execFileSync
547
209
  */
548
- workspaces?: string[] | {
549
- /**
550
- * Workspace package paths. Glob patterns are supported.
551
- */
552
- packages?: string[];
553
- /**
554
- * Packages to block from hoisting to the workspace root.
555
- * Uses glob patterns to match module paths in the dependency tree.
556
- *
557
- * Docs:
558
- * - https://classic.yarnpkg.com/blog/2018/02/15/nohoist/
559
- */
560
- nohoist?: string[];
561
- };
210
+ execFile?: typeof execFileSync;
562
211
  /**
563
- * The field is used to specify different TypeScript declaration files for
564
- * different versions of TypeScript, allowing for version-specific type definitions.
212
+ * 可注入的 `spawnSync` 实现,主要用于测试。
213
+ * @default node:child_process.spawnSync
565
214
  */
566
- typesVersions?: Record<string, Record<string, string[]>>;
215
+ spawn?: typeof spawnSync;
216
+ }
217
+ interface StagedTypecheckOptions extends VerifyCommandOptions {
567
218
  /**
568
- * You can specify which operating systems your module will run on:
569
- * ```json
570
- * {
571
- * "os": ["darwin", "linux"]
572
- * }
573
- * ```
574
- * You can also block instead of allowing operating systems, just prepend the blocked os with a '!':
575
- * ```json
576
- * {
577
- * "os": ["!win32"]
578
- * }
579
- * ```
580
- * The host operating system is determined by `process.platform`
581
- * It is allowed to both block and allow an item, although there isn't any good reason to do this.
219
+ * 可注入的 `spawnSync` 实现,主要用于测试。
220
+ * @default node:child_process.spawnSync
582
221
  */
583
- os?: string[];
222
+ spawn?: typeof spawnSync;
223
+ }
224
+ interface CommitMsgVerifyOptions extends VerifyCommandOptions {
584
225
  /**
585
- * If your code only runs on certain cpu architectures, you can specify which ones.
586
- * ```json
587
- * {
588
- * "cpu": ["x64", "ia32"]
589
- * }
590
- * ```
591
- * Like the `os` option, you can also block architectures:
592
- * ```json
593
- * {
594
- * "cpu": ["!arm", "!mips"]
595
- * }
596
- * ```
597
- * The host architecture is determined by `process.arch`
226
+ * commit message 文件路径。
598
227
  */
599
- cpu?: string[];
228
+ editFile: string;
600
229
  /**
601
- * This is a set of config values that will be used at publish-time.
230
+ * 可注入的 `spawnSync` 实现,主要用于测试。
231
+ * @default node:child_process.spawnSync
602
232
  */
603
- publishConfig?: {
604
- /**
605
- * The registry that will be used if the package is published.
606
- */
607
- registry?: string;
608
- /**
609
- * The tag that will be used if the package is published.
610
- */
611
- tag?: string;
612
- /**
613
- * The access level that will be used if the package is published.
614
- */
615
- access?: "public" | "restricted";
616
- /**
617
- * **pnpm-only**
618
- *
619
- * By default, for portability reasons, no files except those listed in
620
- * the bin field will be marked as executable in the resulting package
621
- * archive. The executableFiles field lets you declare additional fields
622
- * that must have the executable flag (+x) set even if
623
- * they aren't directly accessible through the bin field.
624
- */
625
- executableFiles?: string[];
626
- /**
627
- * **pnpm-only**
628
- *
629
- * You also can use the field `publishConfig.directory` to customize
630
- * the published subdirectory relative to the current `package.json`.
631
- *
632
- * It is expected to have a modified version of the current package in
633
- * the specified directory (usually using third party build tools).
634
- */
635
- directory?: string;
636
- /**
637
- * **pnpm-only**
638
- *
639
- * When set to `true`, the project will be symlinked from the
640
- * `publishConfig.directory` location during local development.
641
- * @default true
642
- */
643
- linkDirectory?: boolean;
644
- } & Pick<PackageJson, "bin" | "main" | "exports" | "types" | "typings" | "module" | "browser" | "unpkg" | "typesVersions" | "os" | "cpu">;
233
+ spawn?: typeof spawnSync;
234
+ }
235
+ interface PreCommitVerifyOptions extends VerifyCommandOptions {
645
236
  /**
646
- * See: https://nodejs.org/api/packages.html#packagemanager
647
- * This field defines which package manager is expected to be used when working on the current project.
648
- * Should be of the format: `<name>@<version>[#hash]`
237
+ * 可注入的 `spawnSync` 实现,主要用于测试。
238
+ * @default node:child_process.spawnSync
649
239
  */
650
- packageManager?: string;
651
- [key: string]: any;
240
+ spawn?: typeof spawnSync;
652
241
  }
653
242
  /**
654
- * See: https://docs.npmjs.com/cli/v11/using-npm/scripts#pre--post-scripts
655
- */
656
- type PackageJsonScriptWithPreAndPost<S extends string> = S | `${"pre" | "post"}${S}`;
657
- /**
658
- * See: https://docs.npmjs.com/cli/v11/using-npm/scripts#life-cycle-operation-order
659
- */
660
- type PackageJsonNpmLifeCycleScripts = "dependencies" | "prepublishOnly" | PackageJsonScriptWithPreAndPost<"install" | "pack" | "prepare" | "publish" | "restart" | "start" | "stop" | "test" | "version">;
661
- /**
662
- * See: https://pnpm.io/scripts#lifecycle-scripts
663
- */
664
- type PackageJsonPnpmLifeCycleScripts = "pnpm:devPreinstall";
665
- type PackageJsonCommonScripts = "build" | "coverage" | "deploy" | "dev" | "format" | "lint" | "preview" | "release" | "typecheck" | "watch";
666
- type PackageJsonScriptName = PackageJsonCommonScripts | PackageJsonNpmLifeCycleScripts | PackageJsonPnpmLifeCycleScripts | (string & {});
667
- type PackageJsonScripts = { [P in PackageJsonScriptName]?: string };
668
- /**
669
- * A “person” is an object with a “name” field and optionally “url” and “email”. Or you can shorten that all into a single string, and npm will parse it for you.
670
- */
671
- type PackageJsonPerson = string | {
672
- name: string;
673
- email?: string;
674
- url?: string;
675
- };
676
- type PackageJsonFunding = string | {
677
- url: string;
678
- type?: string;
679
- };
680
- type PackageJsonExportKey = "." | "import" | "require" | "types" | "node" | "browser" | "default" | (string & {});
681
- type PackageJsonExportsObject = { [P in PackageJsonExportKey]?: string | PackageJsonExportsObject | Array<string | PackageJsonExportsObject> };
682
- type PackageJsonExports = string | PackageJsonExportsObject | Array<string | PackageJsonExportsObject>;
683
- /**
684
- * Defines a PackageJson structure.
685
- * @param pkg - The `package.json` content as an object. See {@link PackageJson}.
686
- * @returns the same `package.json` object.
687
- */
688
- //#endregion
689
- //#region src/commands/skills.d.ts
690
- declare const skillTargets: readonly ["codex", "claude"];
691
- type SkillTarget = typeof skillTargets[number];
692
- interface SyncSkillsOptions {
693
- cwd?: string;
694
- targets?: SkillTarget[];
695
- }
696
- declare function getSkillTargetPaths(homeDir?: string): Record<SkillTarget, string>;
697
- declare function syncSkills(options?: SyncSkillsOptions): Promise<{
698
- target: SkillTarget;
699
- dest: string;
700
- }[]>;
243
+ * 执行 pre-push 校验。
244
+ *
245
+ * 该函数会根据 push 范围内的改动文件,推导需要运行的 workspace 任务:
246
+ * - workspace 内改动:按包执行 `build` / `test` / `tsd`
247
+ * - 根级配置改动:在仓库根执行 `build` / `test` / `tsd`
248
+ * - 无论改动范围如何,都会强制在仓库根执行整仓 `lint` 与 `typecheck`
249
+ *
250
+ * @param options pre-push 运行参数
251
+ * @returns Promise<void>
252
+ */
253
+ declare function verifyPrePush(options?: PrePushVerifyOptions): Promise<void>;
254
+ /**
255
+ * 对暂存区中涉及类型检查的文件,按最近的 workspace 归属执行 `typecheck`。
256
+ *
257
+ * 当前识别的扩展名:`.ts`、`.tsx`、`.mts`、`.cts`、`.vue`。
258
+ *
259
+ * @param stagedFiles 暂存区文件路径列表
260
+ * @param options 运行参数
261
+ */
262
+ declare function verifyStagedTypecheck(stagedFiles: string[], options?: StagedTypecheckOptions): void;
263
+ /**
264
+ * 执行 commit-msg 校验。
265
+ *
266
+ * 优先读取 `tooling.husky.commitMsgCommand`;若未配置,则回退到
267
+ * `pnpm exec commitlint --edit <editFile>`。
268
+ *
269
+ * @param options commit-msg 运行参数
270
+ */
271
+ declare function verifyCommitMsg(options: CommitMsgVerifyOptions): Promise<void>;
272
+ /**
273
+ * 执行 pre-commit 校验。
274
+ *
275
+ * 优先读取 `tooling.husky.preCommitCommand`;若未配置,则回退到
276
+ * `pnpm exec lint-staged`。
277
+ *
278
+ * @param options pre-commit 运行参数
279
+ */
280
+ declare function verifyPreCommit(options?: PreCommitVerifyOptions): Promise<void>;
701
281
  //#endregion
702
282
  //#region src/core/git.d.ts
703
283
  /**
@@ -710,7 +290,7 @@ declare class GitClient {
710
290
  /**
711
291
  * 读取 Git 的 config 列表,原样返回 simple-git 的结果。
712
292
  */
713
- listConfig(): simple_git0.Response<simple_git0.ConfigListSummary>;
293
+ listConfig(): _$simple_git0.Response<_$simple_git0.ConfigListSummary>;
714
294
  /**
715
295
  * 初始化配置缓存,避免多次访问 Git 产生的性能损耗。
716
296
  */
@@ -742,31 +322,35 @@ declare class GitClient {
742
322
  //#endregion
743
323
  //#region src/core/workspace.d.ts
744
324
  /**
745
- * 读取 pnpm workspace 下的所有包,并根据配置过滤与补充字段。
325
+ * 清空当前进程内的 workspace 发现缓存。
326
+ *
327
+ * 普通 CLI 命令执行后进程会退出;长期运行的集成测试或程序化调用在修改
328
+ * `pnpm-workspace.yaml` / package 目录后,可以调用它让后续扫描重新读磁盘。
746
329
  */
747
- declare function getWorkspacePackages(workspaceDir: string, options?: GetWorkspacePackagesOptions): Promise<{
748
- pkgJsonPath: string;
749
- rootDir: _pnpm_types0.ProjectRootDir;
750
- rootDirRealPath: _pnpm_types0.ProjectRootDirRealPath;
751
- modulesDir?: string;
752
- manifest: _pnpm_types0.ProjectManifest;
753
- writeProjectManifest: (manifest: _pnpm_types0.ProjectManifest, force?: boolean | undefined) => Promise<void>;
754
- }[]>;
330
+ declare function clearWorkspaceCache(): void;
755
331
  /**
756
- * 将工作区绝对路径、包列表与当前 cwd 打包返回,方便调用方一次获取所有信息。
332
+ * 读取 pnpm workspace 下的所有包,并根据选项做过滤。
333
+ *
334
+ * 默认值:
335
+ * - `ignoreRootPackage`: `true`
336
+ * - `ignorePrivatePackage`: `true`
337
+ *
338
+ * @param workspaceDir workspace 根目录
339
+ * @param options 过滤选项
340
+ * @returns 带有 `pkgJsonPath` 字段的 workspace package 列表
757
341
  */
758
- declare function getWorkspaceData(cwd: string, options?: GetWorkspacePackagesOptions): Promise<{
759
- cwd: string;
760
- workspaceDir: string;
761
- packages: {
762
- pkgJsonPath: string;
763
- rootDir: _pnpm_types0.ProjectRootDir;
764
- rootDirRealPath: _pnpm_types0.ProjectRootDirRealPath;
765
- modulesDir?: string;
766
- manifest: _pnpm_types0.ProjectManifest;
767
- writeProjectManifest: (manifest: _pnpm_types0.ProjectManifest, force?: boolean | undefined) => Promise<void>;
768
- }[];
769
- }>;
342
+ declare function getWorkspacePackages(workspaceDir: string, options?: GetWorkspacePackagesOptions): Promise<WorkspacePackageWithJsonPath[]>;
343
+ /**
344
+ * 一次性返回 `cwd`、真实 `workspaceDir` 与过滤后的包列表。
345
+ *
346
+ * @param cwd 当前工作目录
347
+ * @param options 传给 `getWorkspacePackages()` 的过滤选项
348
+ */
349
+ declare function getWorkspaceData(cwd: string, options?: GetWorkspacePackagesOptions): Promise<WorkspaceData>;
350
+ /**
351
+ * 返回适合展示和程序化消费的 workspace package 摘要。
352
+ */
353
+ declare function getWorkspacePackageSummaries(cwd: string, options?: GetWorkspacePackagesOptions): Promise<WorkspacePackageSummaryData>;
770
354
  //#endregion
771
355
  //#region src/commands/clean.d.ts
772
356
  /**
@@ -774,24 +358,12 @@ declare function getWorkspaceData(cwd: string, options?: GetWorkspacePackagesOpt
774
358
  */
775
359
  declare function cleanProjects(cwd: string, overrides?: Partial<CleanCommandConfig>): Promise<void>;
776
360
  //#endregion
777
- //#region src/commands/init/index.d.ts
778
- /**
779
- * 初始化命令入口,根据配置逐步生成基础文件。
780
- */
781
- declare function init(cwd: string): Promise<void>;
782
- //#endregion
783
361
  //#region src/commands/mirror/binaryMirror.d.ts
784
362
  /**
785
363
  * 根据中国大陆镜像源,自动向 VSCode settings.json 注入终端环境变量。
786
364
  */
787
365
  declare function setVscodeBinaryMirror(cwd: string): Promise<void>;
788
366
  //#endregion
789
- //#region src/commands/sync.d.ts
790
- /**
791
- * 批量执行 `cnpm sync`(或自定义命令),将所有包同步到 npmmirror。
792
- */
793
- declare function syncNpmMirror(cwd: string, options?: GetWorkspacePackagesOptions): Promise<void>;
794
- //#endregion
795
367
  //#region src/commands/upgrade/index.d.ts
796
368
  /**
797
369
  * 将 assets 目录的模版文件同步到工程中,实现一键升级脚手架能力。
@@ -803,80 +375,171 @@ declare let name: string;
803
375
  declare let version: string;
804
376
  //#endregion
805
377
  //#region src/constants.d.ts
378
+ /**
379
+ * 用户默认看到的 CLI 名称。兼容别名仍然可用,但帮助文案统一引导到 repo。
380
+ */
381
+ declare const cliName = "repo";
806
382
  /**
807
383
  * @icebreakers/monorepo 包的根目录。
808
384
  */
809
385
  declare const packageDir: string;
386
+ declare const assetsDir: string;
387
+ declare const templatesDir: string;
810
388
  /**
811
389
  * monorepo 根目录,方便需要跳出当前包的逻辑(例如定位工作区文件)。
812
390
  */
813
391
  declare const rootDir: string;
814
392
  //#endregion
815
393
  //#region src/core/config.d.ts
394
+ interface LoadedMonorepoConfig {
395
+ file: string | null;
396
+ config: MonorepoConfig;
397
+ }
398
+ declare const configExtensions: readonly ["ts", "mts", "cts", "js", "mjs", "cjs"];
399
+ declare function getMonorepoConfigCandidates(cwd: string): {
400
+ repoctl: string[];
401
+ monorepo: string[];
402
+ };
816
403
  /**
817
- * 提供类型提示的辅助函数,供外部定义配置时使用。
404
+ * 为 `repoctl.config.ts` / `monorepo.config.ts` 提供类型提示的辅助函数。
405
+ *
406
+ * 推荐在用户项目中这样写:
407
+ *
408
+ * @example
409
+ * ```ts
410
+ * import { defineMonorepoConfig } from '@icebreakers/monorepo'
411
+ *
412
+ * export default defineMonorepoConfig({
413
+ * tooling: {
414
+ * vitest: {
415
+ * includeWorkspaceRootConfig: false,
416
+ * },
417
+ * },
418
+ * })
419
+ * ```
818
420
  */
819
421
  declare function defineMonorepoConfig(config: MonorepoConfig): MonorepoConfig;
820
422
  /**
821
- * 加载指定目录的 monorepo 配置,并利用缓存提升性能。
423
+ * 加载配置对象和实际命中的配置文件路径,供诊断和脚本集成使用。
424
+ * 优先级为 `repoctl.config.*`,如果两者同时存在则直接报错。
425
+ *
426
+ * @param cwd 配置文件解析起点
427
+ * @returns 配置文件路径和解析后的配置对象;未找到时 file 为 null、config 为空对象
428
+ */
429
+ declare function loadMonorepoConfigDetails(cwd: string): Promise<LoadedMonorepoConfig>;
430
+ /**
431
+ * 加载指定目录的 `repoctl.config.*` 或 `monorepo.config.*`,并在当前进程内做内存缓存。
432
+ * 优先级为 `repoctl.config.*`,如果两者同时存在则直接报错。
433
+ *
434
+ * @param cwd 配置文件解析起点
435
+ * @returns 解析后的配置对象;未找到时返回空对象
822
436
  */
823
437
  declare function loadMonorepoConfig(cwd: string): Promise<MonorepoConfig>;
824
438
  /**
825
- * 获取命令对应的合并配置,若未配置则返回空对象,保证调用端逻辑简单。
439
+ * 获取单个命令对应的配置块。
440
+ *
441
+ * @param name 命令名称,对应 `repoctl.config.ts` / `monorepo.config.ts -> commands.<name>`
442
+ * @param cwd 配置文件解析起点
443
+ * @returns 对应命令配置;未配置时返回空对象
826
444
  */
827
445
  declare function resolveCommandConfig<Name extends keyof NonNullable<MonorepoConfig['commands']>>(name: Name, cwd: string): Promise<NonNullable<MonorepoConfig['commands']>[Name]>;
828
- //#endregion
829
- //#region src/core/context.d.ts
830
446
  /**
831
- * 构建命令执行上下文,封装常用的工作区、Git、配置等信息。
447
+ * 获取 `repoctl.config.ts` / `monorepo.config.ts` 中完整的 `tooling` 配置块。
448
+ *
449
+ * @param cwd 配置文件解析起点
450
+ * @returns `tooling` 配置;未配置时返回空对象
832
451
  */
833
- declare function createContext(cwd: string): Promise<{
452
+ declare function resolveToolingConfig(cwd: string): Promise<NonNullable<MonorepoConfig['tooling']>>;
453
+ //#endregion
454
+ //#region src/core/context.d.ts
455
+ interface Context {
834
456
  cwd: string;
835
457
  git: GitClient;
836
- gitUrl: git_url_parse0.GitUrl | undefined;
837
- gitUser: {
838
- name: string | string[] | undefined;
839
- email: string | string[] | undefined;
840
- };
458
+ gitUrl: Awaited<ReturnType<GitClient['getGitUrl']>>;
459
+ gitUser: Awaited<ReturnType<GitClient['getUser']>>;
841
460
  workspaceDir: string;
842
461
  workspaceFilepath: string;
843
- packages: {
844
- pkgJsonPath: string;
845
- rootDir: _pnpm_types0.ProjectRootDir;
846
- rootDirRealPath: _pnpm_types0.ProjectRootDirRealPath;
847
- modulesDir?: string;
848
- manifest: _pnpm_types0.ProjectManifest;
849
- writeProjectManifest: (manifest: _pnpm_types0.ProjectManifest, force?: boolean | undefined) => Promise<void>;
850
- }[];
851
- config: MonorepoConfig;
852
- }>;
462
+ packages: Awaited<ReturnType<typeof getWorkspaceData>>['packages'];
463
+ config: Awaited<ReturnType<typeof loadMonorepoConfig>>;
464
+ }
853
465
  /**
854
- * 统一导出的上下文类型,方便下游函数准确获知可用字段。
466
+ * 构建命令执行上下文,封装常用的工作区、Git、配置等信息。
855
467
  */
856
- type Context = Awaited<ReturnType<typeof createContext>>;
468
+ declare function createContext(cwd: string): Promise<Context>;
857
469
  //#endregion
858
470
  //#region src/core/logger.d.ts
859
471
  /**
860
472
  * 统一的日志实例,便于在命令行中输出带有前缀和颜色的消息。
861
473
  */
862
- declare const logger: consola.ConsolaInstance;
474
+ declare const logger: _$consola.ConsolaInstance;
863
475
  //#endregion
864
476
  //#region src/utils/fs.d.ts
477
+ /**
478
+ * JSON 输出选项。
479
+ */
865
480
  interface JsonWriteOptions {
481
+ /**
482
+ * `JSON.stringify` 缩进空格数。
483
+ * @default undefined
484
+ */
866
485
  spaces?: number;
867
486
  }
487
+ /**
488
+ * 判断文件或目录是否存在。
489
+ *
490
+ * @param targetPath 目标路径
491
+ * @returns 存在时返回 `true`
492
+ */
868
493
  declare function pathExists(targetPath: string): Promise<boolean>;
494
+ /**
495
+ * `pathExists()` 的别名。
496
+ */
869
497
  declare const exists: typeof pathExists;
498
+ /**
499
+ * 递归创建目录。
500
+ */
870
501
  declare function ensureDir(targetPath: string): Promise<void>;
502
+ /**
503
+ * 确保文件存在;若父目录不存在会自动创建。
504
+ */
871
505
  declare function ensureFile(targetPath: string): Promise<void>;
506
+ /**
507
+ * 递归删除文件或目录。
508
+ *
509
+ * 默认启用 `force: true`、`recursive: true`,并带少量重试。
510
+ */
872
511
  declare function remove(targetPath: string): Promise<void>;
512
+ /**
513
+ * 递归复制文件或目录。
514
+ */
873
515
  declare function copy(sourcePath: string, targetPath: string): Promise<void>;
516
+ /**
517
+ * 自动创建父目录后写入文件。
518
+ */
874
519
  declare function outputFile(targetPath: string, data: Parameters<typeof writeFile>[1], options?: Parameters<typeof writeFile>[2]): Promise<void>;
520
+ /**
521
+ * 读取 JSON 文件并解析。
522
+ */
875
523
  declare function readJson<T = any>(targetPath: string): Promise<T>;
524
+ /**
525
+ * `readJson()` 的别名。
526
+ */
876
527
  declare const readJSON: typeof readJson;
528
+ /**
529
+ * 写入 JSON 文件,不会自动创建父目录。
530
+ */
877
531
  declare function writeJson(targetPath: string, data: unknown, options?: JsonWriteOptions): Promise<void>;
532
+ /**
533
+ * `writeJson()` 的别名。
534
+ */
878
535
  declare const writeJSON: typeof writeJson;
536
+ /**
537
+ * 自动创建父目录后写入 JSON 文件。
538
+ */
879
539
  declare function outputJson(targetPath: string, data: unknown, options?: JsonWriteOptions): Promise<void>;
540
+ /**
541
+ * `outputJson()` 的别名。
542
+ */
880
543
  declare const outputJSON: typeof outputJson;
881
544
  /**
882
545
  * 判断是否为可忽略的文件系统错误。
@@ -893,11 +556,18 @@ declare function updateIssueTemplateConfig(source: string, repoName?: string): s
893
556
  //#endregion
894
557
  //#region src/utils/hash.d.ts
895
558
  /**
896
- * 生成给定二进制内容的 md5 摘要,用于快速比较文件内容。
559
+ * 生成给定内容的 md5 摘要。
560
+ *
561
+ * @param data 任意 `crypto.BinaryLike` 内容
562
+ * @returns 32 位十六进制 md5 字符串
897
563
  */
898
564
  declare function getFileHash(data: crypto.BinaryLike): string;
899
565
  /**
900
- * 对比两个文件的 md5,如果不一致则认为内容有变化。
566
+ * 对比两段内容的 md5,判断内容是否发生变化。
567
+ *
568
+ * @param src 当前内容
569
+ * @param dest 旧内容
570
+ * @returns 两者 md5 不一致时返回 `true`
901
571
  */
902
572
  declare function isFileChanged(src: crypto.BinaryLike, dest: crypto.BinaryLike): boolean;
903
573
  //#endregion
@@ -915,4 +585,4 @@ declare function escapeStringRegexp(str: string): string;
915
585
  */
916
586
  declare function isMatch(str: string, arr: RegExp[]): boolean;
917
587
  //#endregion
918
- export { type AgenticTemplateFormat, type AgenticTemplateTask, type AiCommandConfig, type CleanCommandConfig, type CliOpts, type ConfigValues, Context, type CreateChoiceOption, type CreateCommandConfig, type CreateNewProjectOptions, type GenerateAgenticTemplateOptions, type GetWorkspacePackagesOptions, GitClient, type InitCommandConfig, JsonWriteOptions, type MirrorCommandConfig, type MonorepoConfig, type PackageJson, type SimpleGit, type SimpleGitOptions, type SkillTarget, type SyncCommandConfig, type SyncSkillsOptions, type UpgradeCommandConfig, assetsDir, cleanProjects, copy, createContext, createNewProject, createTimestampFolderName, defaultAgenticBaseDir, defineMonorepoConfig, ensureDir, ensureFile, escapeStringRegexp, exists, generateAgenticTemplate, generateAgenticTemplates, getCreateChoices, getFileHash, getSkillTargetPaths, getTemplateMap, getWorkspaceData, getWorkspacePackages, init, isFileChanged, isGitignoreFile, isIgnorableFsError, isMatch, loadAgenticTasks, loadMonorepoConfig, logger, name, outputFile, outputJSON, outputJson, packageDir, pathExists, readJSON, readJson, remove, resolveCommandConfig, rootDir, setByPath, setVscodeBinaryMirror, skillTargets, syncNpmMirror, syncSkills, templateMap, templatesDir, toPublishGitignorePath, toWorkspaceGitignorePath, updateIssueTemplateConfig, upgradeMonorepo, version, writeJSON, writeJson };
588
+ export { type AgenticTemplateFormat, type AgenticTemplateTask, type AiCommandConfig, type CheckTemplatesOptions, type CleanCommandConfig, type CliOpts, type CommitMsgVerifyOptions, type CommitlintToolingConfig, type ConfigInspection, ConfigValues, Context, type CreateChoiceOption, type CreateCommandConfig, type CreateNewProjectOptions, type CreateNewProjectPlan, DefineConfigOptions, DefineVitestConfigOptions, DefineVitestProjectConfigOptions, type DoctorCheck, type DoctorReport, type DoctorStatus, type DoctorSummary, type EnvInfo, type EnvPathEntry, type EnvPaths, type EnvSnapshot, type EnvSupportBundle, type EslintToolingConfig, type GenerateAgenticTemplateOptions, type GetWorkspacePackagesOptions, GitClient, type HuskyToolingConfig, type InitCommandConfig, JsonWriteOptions, type LintStagedToolingConfig, LoadedMonorepoConfig, type MirrorCommandConfig, MonorepoCommitlintConfig, type MonorepoConfig, MonorepoEslintConfig, MonorepoLintStagedConfig, MonorepoLintStagedConfigOptions, MonorepoStylelintConfig, MonorepoTsconfig, MonorepoVitestConfigOptions, MonorepoVitestConfigOverrides, MonorepoVitestConfigResult, MonorepoVitestProjectConfigOptions, MonorepoVitestProjectConfigResult, PackageJson, PackageJsonBugs, PackageJsonExports, PackageJsonPerson, PackageJsonRepository, type PreCommitVerifyOptions, type PrePushVerifyOptions, type RecommendedCheckMode, type RecommendedCheckOptions, type RecommendedCheckPlan, type RecommendedCheckPlanCommand, SimpleGit, SimpleGitOptions, type SkillTarget, type StagedTypecheckOptions, type StylelintToolingConfig, type SyncSkillsOptions, type TemplateHealthCheck, type TemplateHealthReport, type TemplateHealthStatus, type TemplateHealthSummary, type ToolingConfig, TsconfigToolingConfig, type UpgradeCommandConfig, type VerifyCommandOptions, type VitestProjectToolingConfig, type VitestToolingConfig, WorkspaceData, WorkspacePackage, WorkspacePackageManifest, WorkspacePackageSummary, WorkspacePackageSummaryData, WorkspacePackageWithJsonPath, assetsDir, checkTemplates, cleanProjects, clearWorkspaceCache, cliName, collectEnvInfo, collectEnvPaths, collectEnvSnapshot, collectEnvSupportBundle, configExtensions, copy, createContext, createMonorepoCommitlintConfig, createMonorepoEslintConfig, createMonorepoLintStagedConfig, createMonorepoStylelintConfig, createMonorepoTsconfig, createMonorepoVitestConfig, createMonorepoVitestProjectConfig, createNewProject, createTimestampFolderName, defaultAgenticBaseDir, defineCommitlintConfig, defineEslintConfig, defineLintStagedConfig, defineMonorepoConfig, defineStylelintConfig, defineTsconfigConfig, defineVitestConfig, defineVitestProjectConfig, ensureDir, ensureFile, escapeStringRegexp, exists, generateAgenticTemplate, generateAgenticTemplates, getCreateChoices, getFileHash, getMonorepoConfigCandidates, getSkillTargetPaths, getTemplateMap, getWorkspaceData, getWorkspacePackageSummaries, getWorkspacePackages, init, initMetadata, initTooling, initToolingTargets, inspectMonorepoConfig, isFileChanged, isGitignoreFile, isIgnorableFsError, isMatch, loadAgenticTasks, loadMonorepoConfig, loadMonorepoConfigDetails, loadMonorepoToolingConfig, logger, normalizeInitToolingTargets, outputFile, outputJSON, outputJson, packageDir, name as packageName, pathExists, readJSON, readJson, remove, resolveCommandConfig, resolveCreateNewProjectPlan, resolveRecommendedCheckPlan, resolveToolingConfig, rootDir, runDoctor, runRecommendedCheck, setByPath, setVscodeBinaryMirror, skillTargets, syncSkills, templateMap, templatesDir, toPublishGitignorePath, toWorkspaceGitignorePath, updateIssueTemplateConfig, upgradeMonorepo, verifyCommitMsg, verifyPreCommit, verifyPrePush, verifyStagedTypecheck, version, writeJSON, writeJson };