@icebreakers/monorepo 3.2.17 → 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.
@@ -0,0 +1,1049 @@
1
+ import { ConfigValues, SimpleGit, SimpleGitOptions } from "simple-git";
2
+ import { TemplateDefinition } from "@icebreakers/monorepo-templates";
3
+ import { IcebreakerCommitlintConfig, IcebreakerCommitlintOptions } from "@icebreakers/commitlint-config";
4
+ import { IcebreakerEslintConfig, UserConfigItem, UserDefinedOptions } from "@icebreakers/eslint-config";
5
+ import { IcebreakerStylelintConfig, StylelintConfig } from "@icebreakers/stylelint-config";
6
+ import { ViteUserConfig } from "vitest/config";
7
+ import { Configuration } from "lint-staged";
8
+
9
+ //#region src/types/cli.d.ts
10
+ /**
11
+ * CLI 公用参数,保证各命令对外暴露一致的行为。
12
+ */
13
+ interface CliOpts {
14
+ /**
15
+ * 是否开启交互模式,开启后每一步都会提示用户确认。
16
+ * @default false
17
+ */
18
+ interactive?: boolean;
19
+ /**
20
+ * 是否使用 core 版资产,只同步最精简的文件集合。
21
+ * @default false
22
+ */
23
+ core?: boolean;
24
+ /**
25
+ * 输出目录(相对 `cwd`),用于放置生成或拷贝出来的文件。
26
+ * @default ''
27
+ */
28
+ outDir?: string;
29
+ /**
30
+ * 命令执行的工作目录。
31
+ * @default process.cwd()
32
+ */
33
+ cwd?: string;
34
+ /**
35
+ * 是否跳过已有文件的覆写;开启后保留旧文件不做对比。
36
+ * @default false
37
+ */
38
+ skipOverwrite?: boolean;
39
+ }
40
+ //#endregion
41
+ //#region src/commands/ai.d.ts
42
+ type AgenticTemplateFormat = 'md' | 'json';
43
+ interface GenerateAgenticTemplateOptions {
44
+ cwd?: string;
45
+ output?: string;
46
+ force?: boolean;
47
+ format?: AgenticTemplateFormat;
48
+ /**
49
+ * 任务名,用于快速生成带目录与后缀的文件。
50
+ */
51
+ name?: string;
52
+ /**
53
+ * 基础目录,配合 name 使用。
54
+ * @default 'agentic/prompts'
55
+ */
56
+ baseDir?: string;
57
+ /**
58
+ * 自动生成目录时使用的自定义文件夹名称。
59
+ * @default 自动生成的时间戳
60
+ */
61
+ folderName?: string;
62
+ }
63
+ type AgenticTemplateTask = string | (Omit<GenerateAgenticTemplateOptions, 'cwd'> & {
64
+ name?: string;
65
+ });
66
+ declare const defaultAgenticBaseDir = "agentic/prompts";
67
+ declare function createTimestampFolderName(date?: Date): string;
68
+ /**
69
+ * 生成 Agentic 任务提示词模板,默认写入 agentic/prompts/<timestamp>/prompt.md,可自定义输出路径。
70
+ */
71
+ declare function generateAgenticTemplate(options?: GenerateAgenticTemplateOptions): Promise<string>;
72
+ declare function loadAgenticTasks(filePath: string, cwd: string): Promise<AgenticTemplateTask[]>;
73
+ declare function generateAgenticTemplates(tasks: AgenticTemplateTask[], defaults?: GenerateAgenticTemplateOptions): Promise<string[]>;
74
+ //#endregion
75
+ //#region src/commands/create/plan.d.ts
76
+ /**
77
+ * 内置模板映射表,source 指向 templates 根目录下的来源目录,target 为生成路径。
78
+ */
79
+ declare const templateMap: {
80
+ readonly tsdown: {
81
+ readonly source: "tsdown";
82
+ readonly target: "packages/tsdown";
83
+ };
84
+ readonly 'vue-lib': {
85
+ readonly source: "vue-lib";
86
+ readonly target: "packages/vue-lib";
87
+ };
88
+ readonly 'hono-server': {
89
+ readonly source: "server";
90
+ readonly target: "apps/server";
91
+ };
92
+ readonly 'vue-hono': {
93
+ readonly source: "client";
94
+ readonly target: "apps/client";
95
+ };
96
+ readonly vitepress: {
97
+ readonly source: "vitepress";
98
+ readonly target: "apps/website";
99
+ };
100
+ readonly cli: {
101
+ readonly source: "cli";
102
+ readonly target: "apps/cli";
103
+ };
104
+ };
105
+ type CreateNewProjectType = keyof typeof templateMap;
106
+ interface CreateNewProjectOptions {
107
+ /**
108
+ * 目标项目名。
109
+ * 未提供时使用模板映射中的 `target`。
110
+ * @default undefined
111
+ */
112
+ name?: string;
113
+ /**
114
+ * 生成目标的工作目录。
115
+ * @default process.cwd()
116
+ */
117
+ cwd?: string;
118
+ /**
119
+ * 是否把模板里的 `package.json` 输出为 `package.mock.json`。
120
+ * @default false
121
+ */
122
+ renameJson?: boolean;
123
+ /**
124
+ * 模板类型。
125
+ * 未提供时优先读取 `commands.create.defaultTemplate`,最后回退到 `'tsdown'`。
126
+ * @default 'tsdown'
127
+ */
128
+ type?: CreateNewProjectType | string;
129
+ }
130
+ interface CreateNewProjectPlan {
131
+ cwd: string;
132
+ requestedTemplate: string;
133
+ template: string;
134
+ usedFallback: boolean;
135
+ sourceDir: string;
136
+ targetName: string;
137
+ targetDir: string;
138
+ targetExists: boolean;
139
+ renameJson: boolean;
140
+ hasPackageJson: boolean;
141
+ packageJsonFileName: 'package.json' | 'package.mock.json';
142
+ packageName: string;
143
+ templateDefinition: TemplateDefinition;
144
+ }
145
+ declare function getCreateChoices(choices?: CreateChoiceOption[]): CreateChoiceOption[];
146
+ declare function getTemplateMap(extra?: Record<string, string | TemplateDefinition>): Record<string, TemplateDefinition>;
147
+ declare function resolveCreateNewProjectPlan(options?: CreateNewProjectOptions): Promise<CreateNewProjectPlan>;
148
+ //#endregion
149
+ //#region src/commands/create/index.d.ts
150
+ /**
151
+ * 根据模板生成一个新项目目录,并自动补写 `package.json` 常用字段。
152
+ *
153
+ * 默认行为:
154
+ * - 优先读取 `repoctl.config.ts -> commands.create`,兼容 `monorepo.config.ts`
155
+ * - 模板类型默认回退到 `'tsdown'`
156
+ * - 若目标目录已存在则直接抛错
157
+ * - 若模板包含 `package.json`,会自动写入 `name`、`version` 与 Git 仓库信息
158
+ *
159
+ * @param options 运行时覆盖项
160
+ * @returns Promise<void>
161
+ */
162
+ declare function createNewProject(options?: CreateNewProjectOptions): Promise<void>;
163
+ //#endregion
164
+ //#region src/commands/init/tooling/types.d.ts
165
+ declare const initToolingTargets: readonly ["commitlint", "eslint", "stylelint", "lint-staged", "tsconfig", "vitest"];
166
+ type InitToolingTarget = (typeof initToolingTargets)[number];
167
+ interface InitToolingExecutionOptions {
168
+ targets?: InitToolingTarget[];
169
+ all?: boolean;
170
+ force?: boolean;
171
+ }
172
+ interface InitToolingResult {
173
+ selectedTargets: InitToolingTarget[];
174
+ writtenFiles: string[];
175
+ skippedFiles: string[];
176
+ updatedPackageJson: boolean;
177
+ }
178
+ //#endregion
179
+ //#region src/commands/init/tooling/index.d.ts
180
+ declare function normalizeInitToolingTargets(input: string[]): InitToolingTarget[];
181
+ declare function initTooling(cwd: string, options?: InitToolingExecutionOptions): Promise<InitToolingResult>;
182
+ //#endregion
183
+ //#region src/commands/init/index.d.ts
184
+ type InitPreset = 'minimal' | 'standard';
185
+ interface InitCommandRuntimeOptions {
186
+ tooling?: readonly InitToolingTarget[];
187
+ all?: boolean;
188
+ force?: boolean;
189
+ preset?: InitPreset;
190
+ }
191
+ declare function initMetadata(cwd: string): Promise<void>;
192
+ /**
193
+ * 初始化命令入口,根据配置逐步生成基础文件。
194
+ */
195
+ declare function init(cwd: string, options?: InitCommandRuntimeOptions): Promise<void>;
196
+ //#endregion
197
+ //#region src/types/config.d.ts
198
+ interface AiCommandConfig {
199
+ /**
200
+ * 默认输出路径,不填则自动创建 `agentic/prompts/<timestamp>/prompt.md` 文件夹与模板。
201
+ * @default undefined
202
+ */
203
+ output?: string;
204
+ /**
205
+ * 默认存放目录,配合 name / tasks 批量生成时使用。
206
+ * @default 'agentic/prompts'
207
+ */
208
+ baseDir?: string;
209
+ /**
210
+ * 是否允许覆盖已存在文件。
211
+ * @default false
212
+ */
213
+ force?: boolean;
214
+ /**
215
+ * 模板格式。
216
+ * @default 'md'
217
+ */
218
+ format?: AgenticTemplateFormat;
219
+ /**
220
+ * 任务清单文件路径(JSON 数组),用于批量生成。
221
+ * @default undefined
222
+ */
223
+ tasksFile?: string;
224
+ }
225
+ /**
226
+ * `monorepo package create` 命令的配置项,兼容旧入口 `monorepo new/create`。
227
+ */
228
+ interface CreateCommandConfig extends Partial<Omit<CreateNewProjectOptions, 'cwd'>> {
229
+ /**
230
+ * 自定义模板根目录。
231
+ * @default 内置模板所在的 `packages/monorepo/templates`
232
+ */
233
+ templatesDir?: string;
234
+ /**
235
+ * 扩展模板映射表,key 为类型,value 为模板来源/目标路径。
236
+ * @default 内置 `templateMap`
237
+ */
238
+ templateMap?: Record<string, string | TemplateDefinition>;
239
+ /**
240
+ * 自定义交互提示的选项列表。
241
+ * @default 内置 `baseChoices`
242
+ */
243
+ choices?: CreateChoiceOption[];
244
+ /**
245
+ * 当未选择模板时使用的默认模板。
246
+ * @default 'tsdown'
247
+ */
248
+ defaultTemplate?: CreateNewProjectOptions['type'];
249
+ }
250
+ /**
251
+ * CLI 交互式选择框的选项结构。
252
+ */
253
+ interface CreateChoiceOption {
254
+ /**
255
+ * 唯一值,将回传给命令逻辑使用。
256
+ * @default undefined
257
+ */
258
+ value: string;
259
+ /**
260
+ * 选项展示名称。
261
+ * @default value
262
+ */
263
+ name?: string;
264
+ /**
265
+ * 选项描述信息。
266
+ * @default undefined
267
+ */
268
+ description?: string;
269
+ /**
270
+ * 短名称,用于命令行紧凑展示。
271
+ * @default undefined
272
+ */
273
+ short?: string;
274
+ /**
275
+ * 设置为 true 或字符串即可禁用该选项并显示原因。
276
+ * @default false
277
+ */
278
+ disabled?: boolean | string;
279
+ }
280
+ /**
281
+ * `monorepo workspace clean` 命令配置,可控制自动选择、排除包等行为。
282
+ */
283
+ interface CleanCommandConfig {
284
+ /**
285
+ * 是否跳过交互直接清理全部。
286
+ * @default false
287
+ */
288
+ autoConfirm?: boolean;
289
+ /**
290
+ * 不允许被清理的包名列表。
291
+ * @default []
292
+ */
293
+ ignorePackages?: string[];
294
+ /**
295
+ * 是否包含 private 包。
296
+ * @default true
297
+ */
298
+ includePrivate?: boolean;
299
+ /**
300
+ * 强制写回的 @icebreakers/monorepo 版本。
301
+ * @default 当前依赖版本
302
+ */
303
+ pinnedVersion?: string;
304
+ }
305
+ /**
306
+ * `monorepo workspace upgrade` 命令配置,覆盖脚本、目标文件等能力。
307
+ */
308
+ interface UpgradeCommandConfig extends Partial<CliOpts> {
309
+ /**
310
+ * 额外需要写入的目标文件列表。
311
+ * @default []
312
+ */
313
+ targets?: string[];
314
+ /**
315
+ * 是否与默认目标合并,false 表示完全覆盖。
316
+ * @default true
317
+ */
318
+ mergeTargets?: boolean;
319
+ /**
320
+ * 需要写入 package.json 的脚本集合。
321
+ * @default {}
322
+ */
323
+ scripts?: Record<string, string>;
324
+ /**
325
+ * 是否跳过生成 changeset markdown。
326
+ * @default true
327
+ */
328
+ skipChangesetMarkdown?: boolean;
329
+ }
330
+ /**
331
+ * `monorepo workspace init` / `monorepo tooling init` 共享配置,用于跳过部分初始化步骤并配置 tooling 默认目标。
332
+ */
333
+ interface InitCommandConfig {
334
+ /**
335
+ * 是否跳过 README 生成。
336
+ * @default false
337
+ */
338
+ skipReadme?: boolean;
339
+ /**
340
+ * 是否跳过 package.json 写入。
341
+ * @default false
342
+ */
343
+ skipPkgJson?: boolean;
344
+ /**
345
+ * 是否跳过 changeset 的更新。
346
+ * @default false
347
+ */
348
+ skipChangeset?: boolean;
349
+ /**
350
+ * 是否跳过 Issue 模版 discussions 链接的更新。
351
+ * @default false
352
+ */
353
+ skipIssueTemplateConfig?: boolean;
354
+ /**
355
+ * 额外要生成的 tooling 配置文件列表。
356
+ * @default []
357
+ */
358
+ tooling?: InitToolingTarget[];
359
+ /**
360
+ * 初始化预设。
361
+ * @default undefined
362
+ */
363
+ preset?: InitPreset;
364
+ /**
365
+ * 是否覆盖已存在的 tooling 配置文件。
366
+ * @default false
367
+ */
368
+ force?: boolean;
369
+ }
370
+ /**
371
+ * `monorepo env mirror` 命令配置,可增加额外的环境变量镜像。
372
+ */
373
+ interface MirrorCommandConfig {
374
+ /**
375
+ * 需要注入的环境变量键值对。
376
+ * @default {}
377
+ */
378
+ env?: Record<string, string>;
379
+ }
380
+ /**
381
+ * `tooling.commitlint` 配置块。
382
+ *
383
+ * 该对象会与 `@icebreakers/commitlint-config` 的默认配置合并。
384
+ */
385
+ interface CommitlintToolingConfig extends IcebreakerCommitlintOptions {}
386
+ /**
387
+ * `tooling.eslint` 配置块。
388
+ *
389
+ * 该对象会与 `@icebreakers/eslint-config` 的默认 flat config 合并。
390
+ */
391
+ interface EslintToolingConfig extends UserDefinedOptions {
392
+ /**
393
+ * 额外传给 `createEslint(...userConfigs)` 的后续配置项。
394
+ * @default []
395
+ */
396
+ configs?: UserConfigItem[];
397
+ }
398
+ /**
399
+ * `tooling.stylelint` 配置块。
400
+ *
401
+ * 该对象会与 `@icebreakers/stylelint-config` 的默认配置合并。
402
+ */
403
+ interface StylelintToolingConfig extends StylelintConfig {}
404
+ /**
405
+ * `tooling.lintStaged` 配置块。
406
+ */
407
+ interface LintStagedToolingConfig {
408
+ /**
409
+ * 调用 monorepo CLI 的基础命令。
410
+ * 通常保持为 `pnpm exec repo`,以便 Husky 与 lint-staged 入口统一。
411
+ * @default 'pnpm exec repo'
412
+ */
413
+ monorepoCommand?: string;
414
+ /**
415
+ * 直接透传完整的 lint-staged 原生配置。
416
+ * 一旦提供,monorepo 默认规则将不再自动注入。
417
+ * @default undefined
418
+ */
419
+ config?: Configuration;
420
+ }
421
+ /**
422
+ * `tooling.tsconfig` 配置块。
423
+ *
424
+ * 该对象会与 monorepo 内置的 TypeScript 基线配置合并。
425
+ */
426
+ interface TsconfigToolingConfig {
427
+ /**
428
+ * 顶层 `extends` 字段。
429
+ * @default undefined
430
+ */
431
+ extends?: string | string[];
432
+ /**
433
+ * TypeScript `compilerOptions` 配置。
434
+ * @default undefined
435
+ */
436
+ compilerOptions?: Record<string, unknown>;
437
+ /**
438
+ * 顶层 `include` 字段。
439
+ * @default undefined
440
+ */
441
+ include?: string[];
442
+ /**
443
+ * 顶层 `exclude` 字段。
444
+ * @default undefined
445
+ */
446
+ exclude?: string[];
447
+ /**
448
+ * 顶层 `files` 字段。
449
+ * @default undefined
450
+ */
451
+ files?: string[];
452
+ /**
453
+ * 顶层 `references` 字段。
454
+ * @default undefined
455
+ */
456
+ references?: Array<{
457
+ path: string;
458
+ }>;
459
+ /**
460
+ * 顶层 `compileOnSave` 字段。
461
+ * @default undefined
462
+ */
463
+ compileOnSave?: boolean;
464
+ }
465
+ /**
466
+ * `tooling.vitest` 配置块。
467
+ *
468
+ * 这些字段会参与根级 Vitest 配置的自动推导。
469
+ */
470
+ interface VitestToolingConfig {
471
+ /**
472
+ * 项目扫描与 workspace 文件解析的根目录。
473
+ * @default process.cwd()
474
+ */
475
+ rootDir?: string;
476
+ /**
477
+ * 显式指定需要扫描的项目根目录。
478
+ * 未提供时优先从 `pnpm-workspace.yaml` 推导,失败后回退到 `['packages', 'apps']`。
479
+ * @default undefined
480
+ */
481
+ projectRoots?: string[];
482
+ /**
483
+ * 子项目 Vitest 配置文件候选名列表。
484
+ * @default ['vitest.config.ts', 'vitest.config.mts', 'vitest.config.js', 'vitest.config.cjs', 'vitest.workspace.ts', 'vitest.workspace.mts']
485
+ */
486
+ configCandidates?: string[];
487
+ /**
488
+ * workspace 配置文件名。
489
+ * @default 'pnpm-workspace.yaml'
490
+ */
491
+ workspaceFile?: string;
492
+ /**
493
+ * 是否把根级 `vitest.config.*` 也加入 `test.projects`。
494
+ * @default false
495
+ */
496
+ includeWorkspaceRootConfig?: boolean;
497
+ /**
498
+ * coverage 需要额外排除的 glob。
499
+ * @default undefined
500
+ */
501
+ coverageExclude?: string[];
502
+ /**
503
+ * 是否开启 coverage。
504
+ * @default true
505
+ */
506
+ coverageEnabled?: boolean;
507
+ /**
508
+ * 是否对未被测试覆盖的文件也统计 coverage。
509
+ * @default false
510
+ */
511
+ coverageAll?: boolean;
512
+ /**
513
+ * 是否跳过 100% 覆盖文件的输出。
514
+ * @default true
515
+ */
516
+ coverageSkipFull?: boolean;
517
+ /**
518
+ * 直接透传到最终 `vitest.config.*` 返回值的完整配置覆盖项。
519
+ * 适合配置 `test.coverage`、`resolve.alias`、`plugins` 等原生 Vitest/Vite 字段。
520
+ * @default undefined
521
+ */
522
+ overrides?: ViteUserConfig;
523
+ }
524
+ /**
525
+ * `tooling.vitestProject` 配置块。
526
+ *
527
+ * 用于单个 package/app 的项目级 Vitest 默认值。
528
+ */
529
+ interface VitestProjectToolingConfig {
530
+ /**
531
+ * 测试环境内的 alias 映射。
532
+ * @default undefined
533
+ */
534
+ alias?: Array<{
535
+ find: string | RegExp;
536
+ replacement: string;
537
+ }>;
538
+ /**
539
+ * 是否启用 Vitest globals。
540
+ * @default true
541
+ */
542
+ globals?: boolean;
543
+ /**
544
+ * 单测默认超时时间,单位毫秒。
545
+ * @default 60000
546
+ */
547
+ testTimeout?: number;
548
+ /**
549
+ * 测试环境类型。
550
+ * @default 'node'
551
+ */
552
+ environment?: string;
553
+ }
554
+ /**
555
+ * `tooling.husky` 配置块。
556
+ */
557
+ interface HuskyToolingConfig {
558
+ /**
559
+ * pre-commit 钩子执行命令。
560
+ * 未设置时默认运行 `pnpm exec lint-staged`。
561
+ * @default undefined
562
+ */
563
+ preCommitCommand?: string;
564
+ /**
565
+ * commit-msg 钩子执行命令。
566
+ * 可通过 `{editFile}` 占位符注入 commit message 文件路径。
567
+ * 未设置时默认运行 `pnpm exec commitlint --edit {editFile}`。
568
+ * @default undefined
569
+ */
570
+ commitMsgCommand?: string;
571
+ }
572
+ /**
573
+ * `repoctl.config.ts` / `monorepo.config.ts` 中 `tooling` 总配置。
574
+ *
575
+ * 每个字段分别映射到对应的配置工厂与验证命令。
576
+ */
577
+ interface ToolingConfig {
578
+ commitlint?: CommitlintToolingConfig;
579
+ eslint?: EslintToolingConfig;
580
+ stylelint?: StylelintToolingConfig;
581
+ lintStaged?: LintStagedToolingConfig;
582
+ tsconfig?: TsconfigToolingConfig;
583
+ vitest?: VitestToolingConfig;
584
+ vitestProject?: VitestProjectToolingConfig;
585
+ husky?: HuskyToolingConfig;
586
+ }
587
+ /**
588
+ * 项目级配置入口,按命令划分可插拔的配置块。
589
+ */
590
+ interface MonorepoConfig {
591
+ /**
592
+ * 按命令分类的可选配置。
593
+ * 各字段默认均为 `undefined`,命令执行时会按各自逻辑回退到内置默认值。
594
+ * @default {}
595
+ */
596
+ commands?: {
597
+ ai?: AiCommandConfig;
598
+ create?: CreateCommandConfig;
599
+ clean?: CleanCommandConfig;
600
+ upgrade?: UpgradeCommandConfig;
601
+ init?: InitCommandConfig;
602
+ mirror?: MirrorCommandConfig;
603
+ };
604
+ /**
605
+ * 按工程化能力分类的可选配置。
606
+ * 这些配置通常会被 `@icebreakers/monorepo/tooling` 中的 helper 消费。
607
+ * @default {}
608
+ */
609
+ tooling?: ToolingConfig;
610
+ }
611
+ //#endregion
612
+ //#region src/types/package-json.d.ts
613
+ interface PackageJsonPerson {
614
+ name?: string;
615
+ email?: string;
616
+ url?: string;
617
+ }
618
+ interface PackageJsonRepository {
619
+ type?: string;
620
+ url?: string;
621
+ directory?: string;
622
+ }
623
+ interface PackageJsonBugs {
624
+ url?: string;
625
+ email?: string;
626
+ }
627
+ type PackageJsonExports = unknown;
628
+ interface PackageJson extends Record<string, unknown> {
629
+ name?: string;
630
+ version?: string;
631
+ private?: boolean;
632
+ type?: string;
633
+ description?: string;
634
+ author?: string | PackageJsonPerson;
635
+ repository?: string | PackageJsonRepository;
636
+ bugs?: string | PackageJsonBugs;
637
+ homepage?: string;
638
+ license?: string;
639
+ packageManager?: string;
640
+ scripts?: Record<string, string | undefined>;
641
+ dependencies?: Record<string, string | undefined>;
642
+ devDependencies?: Record<string, string | undefined>;
643
+ peerDependencies?: Record<string, string | undefined>;
644
+ optionalDependencies?: Record<string, string | undefined>;
645
+ engines?: Record<string, string | undefined>;
646
+ publishConfig?: Record<string, unknown>;
647
+ bin?: string | Record<string, string | undefined>;
648
+ exports?: PackageJsonExports;
649
+ }
650
+ //#endregion
651
+ //#region src/types/workspace.d.ts
652
+ /**
653
+ * 工作区工具可接收的筛选选项。
654
+ */
655
+ interface GetWorkspacePackagesOptions {
656
+ /**
657
+ * 是否在结果中排除 workspace 根包。
658
+ * @default true
659
+ */
660
+ ignoreRootPackage?: boolean;
661
+ /**
662
+ * 是否过滤掉标记为 `private` 的包。
663
+ * @default true
664
+ */
665
+ ignorePrivatePackage?: boolean;
666
+ /**
667
+ * 自定义 glob,覆盖 `pnpm-workspace.yaml` 的 `packages` 配置。
668
+ * @default workspace manifest `packages`
669
+ */
670
+ patterns?: string[];
671
+ }
672
+ /**
673
+ * 兼容 pnpm workspace manifest 的轻量结构。
674
+ */
675
+ interface WorkspacePackageManifest {
676
+ name?: string;
677
+ private?: boolean;
678
+ description?: string;
679
+ }
680
+ /**
681
+ * 轻量的 workspace package 结构,避免导出类型泄漏到 pnpm 内部实现细节。
682
+ */
683
+ interface WorkspacePackage {
684
+ rootDir: string;
685
+ rootDirRealPath: string;
686
+ modulesDir?: string;
687
+ manifest: WorkspacePackageManifest;
688
+ writeProjectManifest?: unknown;
689
+ }
690
+ /**
691
+ * 附加 package.json 绝对路径后的 workspace package。
692
+ */
693
+ interface WorkspacePackageWithJsonPath extends WorkspacePackage {
694
+ pkgJsonPath: string;
695
+ }
696
+ /**
697
+ * 适合 CLI 与 JSON 输出消费的 workspace package 摘要。
698
+ */
699
+ interface WorkspacePackageSummary {
700
+ name?: string;
701
+ description?: string;
702
+ private: boolean;
703
+ rootDir: string;
704
+ relativeDir: string;
705
+ pkgJsonPath: string;
706
+ }
707
+ /**
708
+ * workspace package 摘要集合。
709
+ */
710
+ interface WorkspacePackageSummaryData {
711
+ cwd: string;
712
+ workspaceDir: string;
713
+ packages: WorkspacePackageSummary[];
714
+ }
715
+ /**
716
+ * 工作区基础信息与包集合。
717
+ */
718
+ interface WorkspaceData {
719
+ cwd: string;
720
+ workspaceDir: string;
721
+ packages: WorkspacePackageWithJsonPath[];
722
+ }
723
+ //#endregion
724
+ //#region src/tooling/index.d.ts
725
+ /**
726
+ * `commitlint.config.*` 最终导出的配置类型。
727
+ *
728
+ */
729
+ type MonorepoCommitlintConfig = IcebreakerCommitlintConfig;
730
+ /**
731
+ * `eslint.config.js` 最终导出的 flat config 类型。
732
+ */
733
+ type MonorepoEslintConfig = IcebreakerEslintConfig;
734
+ /**
735
+ * `stylelint.config.js` 最终导出的配置类型。
736
+ *
737
+ */
738
+ type MonorepoStylelintConfig = IcebreakerStylelintConfig;
739
+ /**
740
+ * `lint-staged` 最终配置对象。
741
+ *
742
+ * key 为 glob pattern,value 为命令数组或命令生成函数。
743
+ */
744
+ interface MonorepoLintStagedConfig {
745
+ [pattern: string]: string[] | ((files: string[]) => string | string[]);
746
+ }
747
+ /**
748
+ * `tsconfig.json` 最终导出的配置对象。
749
+ */
750
+ interface MonorepoTsconfig {
751
+ extends?: string | string[];
752
+ compilerOptions?: Record<string, unknown>;
753
+ include?: string[];
754
+ exclude?: string[];
755
+ files?: string[];
756
+ references?: Array<{
757
+ path: string;
758
+ }>;
759
+ compileOnSave?: boolean;
760
+ }
761
+ interface DefineConfigOptions<TConfig> {
762
+ cwd?: string;
763
+ options?: TConfig;
764
+ /**
765
+ * @deprecated 使用 `options` 代替,避免与 `tooling.lintStaged.config` 语义冲突。
766
+ */
767
+ config?: TConfig;
768
+ }
769
+ /**
770
+ * `createMonorepoLintStagedConfig()` 与 `defineLintStagedConfig()` 的配置项。
771
+ */
772
+ interface MonorepoLintStagedConfigOptions extends LintStagedToolingConfig {}
773
+ /**
774
+ * `createMonorepoVitestConfig()` 与 `defineVitestConfig()` 的共享配置项。
775
+ *
776
+ * 这些值会先参与 monorepo 级默认配置计算,再产出最终的 Vitest `test` 配置。
777
+ */
778
+ interface MonorepoVitestConfigOptions extends VitestToolingConfig {}
779
+ /**
780
+ * `createMonorepoVitestProjectConfig()` 的项目级配置项。
781
+ */
782
+ interface MonorepoVitestProjectConfigOptions extends VitestProjectToolingConfig {}
783
+ /**
784
+ * `createMonorepoVitestConfig()` 返回的标准结果结构。
785
+ *
786
+ * 该类型可用于约束自定义封装或二次 merge 的返回值。
787
+ */
788
+ interface MonorepoVitestConfigResult extends Omit<ViteUserConfig, 'test'> {
789
+ test: NonNullable<ViteUserConfig['test']> & {
790
+ projects?: NonNullable<ViteUserConfig['test']>['projects'];
791
+ coverage?: NonNullable<NonNullable<ViteUserConfig['test']>['coverage']> & {
792
+ enabled?: boolean;
793
+ all?: boolean;
794
+ skipFull?: boolean;
795
+ exclude?: string[];
796
+ };
797
+ forceRerunTriggers?: string[];
798
+ };
799
+ }
800
+ /**
801
+ * 单个 package/app 的 `vitest.config.*` 最终导出结构。
802
+ */
803
+ interface MonorepoVitestProjectConfigResult {
804
+ test: {
805
+ alias?: Array<{
806
+ find: string | RegExp;
807
+ replacement: string;
808
+ }>;
809
+ globals: boolean;
810
+ testTimeout: number;
811
+ environment?: string;
812
+ };
813
+ }
814
+ /**
815
+ * `defineVitestConfig()` 的最终覆盖项。
816
+ */
817
+ type MonorepoVitestConfigOverrides = ViteUserConfig;
818
+ interface DefineVitestConfigOptions {
819
+ cwd?: string;
820
+ options?: MonorepoVitestConfigOptions;
821
+ overrides?: MonorepoVitestConfigOverrides;
822
+ }
823
+ interface DefineVitestProjectConfigOptions {
824
+ cwd?: string;
825
+ options?: MonorepoVitestProjectConfigOptions;
826
+ /**
827
+ * @deprecated 使用 `options` 代替,保持与其他 `define*Config()` 包装器一致。
828
+ */
829
+ config?: MonorepoVitestProjectConfigOptions;
830
+ }
831
+ /**
832
+ * 读取当前工作目录下的 `monorepo.config.*` 中 `tooling` 配置块。
833
+ *
834
+ * @param cwd 配置文件解析起点。默认使用 `process.cwd()`
835
+ * @returns 标准化后的 tooling 配置;未配置时返回空对象
836
+ *
837
+ * @example
838
+ * ```ts
839
+ * import { loadMonorepoToolingConfig } from '@icebreakers/monorepo/tooling'
840
+ *
841
+ * const tooling = await loadMonorepoToolingConfig()
842
+ * console.log(tooling.vitest?.includeWorkspaceRootConfig)
843
+ * ```
844
+ */
845
+ declare function loadMonorepoToolingConfig(cwd?: string): Promise<NonNullable<ToolingConfig>>;
846
+ /**
847
+ * 基于 `@icebreakers/commitlint-config` 创建 commitlint 配置。
848
+ *
849
+ * 适合在需要手动传入覆盖项时使用;如果只想读取 `repoctl.config.ts` / `monorepo.config.ts` 默认值,
850
+ * 优先使用 `defineCommitlintConfig()`。
851
+ *
852
+ * @param options 额外合并到默认 commitlint 配置上的字段
853
+ * @returns 可直接作为 `commitlint.config.ts` 默认导出的配置对象
854
+ *
855
+ * @example
856
+ * ```ts
857
+ * import { createMonorepoCommitlintConfig } from '@icebreakers/monorepo/tooling'
858
+ *
859
+ * export default createMonorepoCommitlintConfig({
860
+ * rules: {
861
+ * 'subject-case': [0],
862
+ * },
863
+ * })
864
+ * ```
865
+ */
866
+ declare function createMonorepoCommitlintConfig(options?: CommitlintToolingConfig): MonorepoCommitlintConfig;
867
+ /**
868
+ * 从 `repoctl.config.ts` / `monorepo.config.ts` 读取 `tooling.commitlint`,并生成 commitlint 配置。
869
+ *
870
+ * @param input `cwd` 用于指定配置文件解析起点,`config` 用于追加运行时覆盖项
871
+ * @returns 可直接导出的 commitlint 配置对象
872
+ *
873
+ * @example
874
+ * ```ts
875
+ * import { defineCommitlintConfig } from '@icebreakers/monorepo/tooling'
876
+ *
877
+ * export default await defineCommitlintConfig()
878
+ * ```
879
+ */
880
+ declare function defineCommitlintConfig(input?: DefineConfigOptions<CommitlintToolingConfig>): Promise<MonorepoCommitlintConfig>;
881
+ /**
882
+ * 基于 `@icebreakers/eslint-config` 创建 ESLint 配置。
883
+ *
884
+ * 默认会追加一个用于忽略 `fixtures` 目录的 glob,除非显式传入其他 `ignores`。
885
+ *
886
+ * @param options 额外 ESLint 配置;`ignores` 默认会忽略 `fixtures` 目录
887
+ * @returns 可直接作为 `eslint.config.js` 默认导出的 flat config
888
+ */
889
+ declare function createMonorepoEslintConfig(options?: EslintToolingConfig): MonorepoEslintConfig;
890
+ /**
891
+ * 从 `repoctl.config.ts` / `monorepo.config.ts` 读取 `tooling.eslint`,并生成 ESLint 配置。
892
+ *
893
+ * @param input `cwd` 用于指定配置文件解析起点,`config` 用于追加运行时覆盖项
894
+ * @returns 可直接导出的 ESLint flat config
895
+ *
896
+ * @example
897
+ * ```js
898
+ * import { defineEslintConfig } from '@icebreakers/monorepo/tooling'
899
+ *
900
+ * export default await defineEslintConfig()
901
+ * ```
902
+ */
903
+ declare function defineEslintConfig(input?: DefineConfigOptions<EslintToolingConfig>): Promise<MonorepoEslintConfig>;
904
+ /**
905
+ * 基于 `@icebreakers/stylelint-config` 创建 Stylelint 配置。
906
+ *
907
+ * @param options 额外合并到默认 stylelint 配置上的字段
908
+ * @returns 可直接作为 `stylelint.config.js` 默认导出的配置对象
909
+ */
910
+ declare function createMonorepoStylelintConfig(options?: StylelintToolingConfig): MonorepoStylelintConfig;
911
+ /**
912
+ * 从 `repoctl.config.ts` / `monorepo.config.ts` 读取 `tooling.stylelint`,并生成 Stylelint 配置。
913
+ *
914
+ * @param input `cwd` 用于指定配置文件解析起点,`config` 用于追加运行时覆盖项
915
+ * @returns 可直接导出的 Stylelint 配置对象
916
+ */
917
+ declare function defineStylelintConfig(input?: DefineConfigOptions<StylelintToolingConfig>): Promise<MonorepoStylelintConfig>;
918
+ /**
919
+ * 创建 monorepo 内置的 TypeScript 基线配置。
920
+ *
921
+ * @param options 额外覆盖项,会与包内置 `tsconfig.base.json` 合并
922
+ * @returns 可直接写入或二次扩展的 `tsconfig.json` 配置对象
923
+ */
924
+ declare function createMonorepoTsconfig(options?: TsconfigToolingConfig): MonorepoTsconfig;
925
+ /**
926
+ * 从 `repoctl.config.ts` / `monorepo.config.ts` 读取 `tooling.tsconfig`,并生成最终的 TypeScript 配置对象。
927
+ *
928
+ * @param input `cwd` 用于指定配置文件解析起点,`config` 用于追加运行时覆盖项
929
+ * @returns 可直接写入或导出的 `tsconfig.json` 配置对象
930
+ */
931
+ declare function defineTsconfigConfig(input?: DefineConfigOptions<TsconfigToolingConfig>): Promise<MonorepoTsconfig>;
932
+ /**
933
+ * 创建适用于当前仓库约定的 `lint-staged` 配置。
934
+ *
935
+ * 默认行为:
936
+ * - `*.{js,jsx,mjs,ts,tsx,mts,cts}` 运行 `eslint --fix`
937
+ * - `*.vue` 同时运行 `eslint --fix` 与 `stylelint --fix --allow-empty-input`
938
+ * - `*.{ts,tsx,mts,cts,vue}` 调用 `pnpm exec repo verify staged-typecheck`
939
+ * - 样式文件运行 `stylelint --fix --allow-empty-input`
940
+ *
941
+ * @param options 仅支持 `monorepoCommand`,默认值为 `pnpm exec repo`
942
+ * @returns 可直接导出的 `lint-staged` 配置对象
943
+ *
944
+ * @example
945
+ * ```js
946
+ * import { createMonorepoLintStagedConfig } from '@icebreakers/monorepo/tooling'
947
+ *
948
+ * export default createMonorepoLintStagedConfig({
949
+ * monorepoCommand: 'pnpm exec repo',
950
+ * })
951
+ * ```
952
+ */
953
+ declare function createMonorepoLintStagedConfig(options?: MonorepoLintStagedConfigOptions): MonorepoLintStagedConfig;
954
+ /**
955
+ * 从 `repoctl.config.ts` / `monorepo.config.ts` 读取 `tooling.lintStaged`,并生成 `lint-staged` 配置。
956
+ *
957
+ * @param input `cwd` 用于指定配置文件解析起点,`config` 用于追加运行时覆盖项
958
+ * @returns 可直接导出的 `lint-staged` 配置对象
959
+ */
960
+ declare function defineLintStagedConfig(input?: DefineConfigOptions<MonorepoLintStagedConfigOptions>): Promise<MonorepoLintStagedConfig>;
961
+ /**
962
+ * 创建 monorepo 根级 Vitest 配置。
963
+ *
964
+ * 默认值:
965
+ * - `rootDir`: `process.cwd()`
966
+ * - `workspaceFile`: `'pnpm-workspace.yaml'`
967
+ * - `projectRoots`: 自动从 workspace packages 推导,失败时回退到 `['packages', 'apps']`
968
+ * - `includeWorkspaceRootConfig`: `false`
969
+ * - `coverageEnabled`: `true`
970
+ * - `coverageAll`: `false`
971
+ * - `coverageSkipFull`: `true`
972
+ *
973
+ * @param options Vitest 默认配置生成参数
974
+ * @returns 仅包含 `test` 字段的 Vitest 配置片段
975
+ *
976
+ * @example
977
+ * ```ts
978
+ * import { createMonorepoVitestConfig } from '@icebreakers/monorepo/tooling'
979
+ *
980
+ * export default {
981
+ * ...createMonorepoVitestConfig({
982
+ * includeWorkspaceRootConfig: false,
983
+ * coverageExclude: ['dist output glob'],
984
+ * }),
985
+ * }
986
+ * ```
987
+ */
988
+ declare function createMonorepoVitestConfig(options?: MonorepoVitestConfigOptions): MonorepoVitestConfigResult;
989
+ /**
990
+ * 从 `repoctl.config.ts` / `monorepo.config.ts` 读取 `tooling.vitest`,再叠加运行时 `options` 与 `overrides`
991
+ * 生成最终 Vitest 配置。
992
+ *
993
+ * 优先级从低到高:
994
+ * 1. `repoctl.config.ts` / `monorepo.config.ts -> tooling.vitest`
995
+ * 2. `options`
996
+ * 3. `overrides`
997
+ *
998
+ * 推荐把“参与默认值推导”的字段放在 `options`,把“最终局部覆盖”放在 `overrides`。
999
+ *
1000
+ * @param input `options` 会先与 `tooling.vitest` 合并;`overrides` 用于最终局部覆盖;`cwd` 用于配置文件解析起点
1001
+ * @returns 可直接作为 `defineConfig()` 返回值的 Vitest 配置对象
1002
+ *
1003
+ * @example
1004
+ * ```ts
1005
+ * import { defineVitestConfig } from '@icebreakers/monorepo/tooling'
1006
+ * import { defineConfig } from 'vitest/config'
1007
+ *
1008
+ * export default defineConfig(async () => await defineVitestConfig({
1009
+ * options: {
1010
+ * includeWorkspaceRootConfig: false,
1011
+ * },
1012
+ * overrides: {
1013
+ * test: {
1014
+ * coverage: {
1015
+ * exclude: ['dist output glob'],
1016
+ * skipFull: true,
1017
+ * },
1018
+ * },
1019
+ * },
1020
+ * }))
1021
+ * ```
1022
+ */
1023
+ declare function defineVitestConfig(input?: DefineVitestConfigOptions): Promise<MonorepoVitestConfigResult>;
1024
+ /**
1025
+ * 创建项目级 Vitest 配置。
1026
+ *
1027
+ * 默认值:
1028
+ * - `globals`: `true`
1029
+ * - `testTimeout`: `60_000`
1030
+ * - `environment`: `'node'`
1031
+ *
1032
+ * @param options 单个 package/app 的 Vitest 配置项
1033
+ * @returns 可直接给项目内 `vitest.config.ts` 使用的 `test` 配置片段
1034
+ */
1035
+ declare function createMonorepoVitestProjectConfig(options?: MonorepoVitestProjectConfigOptions): MonorepoVitestProjectConfigResult;
1036
+ /**
1037
+ * 从 `repoctl.config.ts` / `monorepo.config.ts` 读取 `tooling.vitestProject`,再叠加运行时 `options`
1038
+ * 生成单个 package/app 的项目级 Vitest 配置。
1039
+ *
1040
+ * 优先级从低到高:
1041
+ * 1. `repoctl.config.ts` / `monorepo.config.ts -> tooling.vitestProject`
1042
+ * 2. `options`
1043
+ *
1044
+ * @param input `cwd` 用于配置文件解析起点,`options` 用于追加项目内局部覆盖项
1045
+ * @returns 可直接传给 `defineProject()` 或与其他 Vite/Vitest 配置 merge 的项目级配置片段
1046
+ */
1047
+ declare function defineVitestProjectConfig(input?: DefineVitestProjectConfigOptions): Promise<MonorepoVitestProjectConfigResult>;
1048
+ //#endregion
1049
+ export { LintStagedToolingConfig as $, ConfigValues as A, PackageJson as B, defineEslintConfig as C, createTimestampFolderName as Ct, defineVitestConfig as D, loadAgenticTasks as Dt, defineTsconfigConfig as E, generateAgenticTemplates as Et, WorkspacePackage as F, AiCommandConfig as G, PackageJsonExports as H, WorkspacePackageManifest as I, CreateChoiceOption as J, CleanCommandConfig as K, WorkspacePackageSummary as L, SimpleGitOptions as M, GetWorkspacePackagesOptions as N, defineVitestProjectConfig as O, CliOpts as Ot, WorkspaceData as P, InitCommandConfig as Q, WorkspacePackageSummaryData as R, defineCommitlintConfig as S, GenerateAgenticTemplateOptions as St, defineStylelintConfig as T, generateAgenticTemplate as Tt, PackageJsonPerson as U, PackageJsonBugs as V, PackageJsonRepository as W, EslintToolingConfig as X, CreateCommandConfig as Y, HuskyToolingConfig as Z, createMonorepoLintStagedConfig as _, getTemplateMap as _t, MonorepoEslintConfig as a, UpgradeCommandConfig as at, createMonorepoVitestConfig as b, AgenticTemplateFormat as bt, MonorepoStylelintConfig as c, init as ct, MonorepoVitestConfigOverrides as d, normalizeInitToolingTargets as dt, MirrorCommandConfig as et, MonorepoVitestConfigResult as f, initToolingTargets as ft, createMonorepoEslintConfig as g, getCreateChoices as gt, createMonorepoCommitlintConfig as h, CreateNewProjectPlan as ht, MonorepoCommitlintConfig as i, TsconfigToolingConfig as it, SimpleGit as j, loadMonorepoToolingConfig as k, MonorepoTsconfig as l, initMetadata as lt, MonorepoVitestProjectConfigResult as m, CreateNewProjectOptions as mt, DefineVitestConfigOptions as n, StylelintToolingConfig as nt, MonorepoLintStagedConfig as o, VitestProjectToolingConfig as ot, MonorepoVitestProjectConfigOptions as p, createNewProject as pt, CommitlintToolingConfig as q, DefineVitestProjectConfigOptions as r, ToolingConfig as rt, MonorepoLintStagedConfigOptions as s, VitestToolingConfig as st, DefineConfigOptions as t, MonorepoConfig as tt, MonorepoVitestConfigOptions as u, initTooling as ut, createMonorepoStylelintConfig as v, resolveCreateNewProjectPlan as vt, defineLintStagedConfig as w, defaultAgenticBaseDir as wt, createMonorepoVitestProjectConfig as x, AgenticTemplateTask as xt, createMonorepoTsconfig as y, templateMap as yt, WorkspacePackageWithJsonPath as z };