@icebreakers/monorepo 6.0.1 → 6.1.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.
Files changed (34) hide show
  1. package/dist/{baseline-B6uEfHrm.mjs → baseline-Dpdng8Pw.mjs} +1 -1
  2. package/dist/{catalog-YipXrou_.mjs → catalog-A1_tGyBz.mjs} +3 -3
  3. package/dist/cli.mjs +186 -115
  4. package/dist/{commands-D1KtdxnV.mjs → commands-C8PiGh9h.mjs} +1507 -149
  5. package/dist/{config--wYfkdsO.mjs → config-CtnhpveO.mjs} +3 -3
  6. package/dist/{create-flow-D3ZzvBw6.mjs → create-flow-CqtNwZs7.mjs} +3 -3
  7. package/dist/{deps-qu9CwEKc.mjs → deps-CFZftEq2.mjs} +3 -3
  8. package/dist/docs-context-entry.d.mts +25 -0
  9. package/dist/docs-context-entry.mjs +88 -0
  10. package/dist/{execute-DP6M6JqN.mjs → execute-Brlvq-TY.mjs} +2 -2
  11. package/dist/{execute-BVtr43XS.mjs → execute-DE3pJ4nx.mjs} +2 -2
  12. package/dist/{format-VPlFgfoH.mjs → format-BXQ2yRvk.mjs} +1 -1
  13. package/dist/{index-DewDhzGv.d.mts → index-BJaI8Sig.d.mts} +170 -2
  14. package/dist/index.d.mts +45 -116
  15. package/dist/index.mjs +10 -10
  16. package/dist/{inputs-B_-kWnm2.mjs → inputs-DRWom7Va.mjs} +1 -1
  17. package/dist/{npm-S2sT1UgC.mjs → npm-CrQi6Gci.mjs} +1 -1
  18. package/dist/{plan-DuHMR5Za.mjs → plan-DT1Gz8tE.mjs} +1 -1
  19. package/dist/{run-BGHVj0Lj.mjs → run-BBf92Scj.mjs} +4 -4
  20. package/dist/{save-UiJgdSaY.mjs → save-CCCUswjG.mjs} +3 -3
  21. package/dist/{scan-Bg1EPIk6.mjs → scan-KcMaJTx2.mjs} +5 -4
  22. package/dist/{template-drift-BOk4oxoR.mjs → template-drift-BKCMx9vC.mjs} +3 -3
  23. package/dist/tooling-entry.d.mts +1 -1
  24. package/dist/tooling-entry.mjs +2 -2
  25. package/dist/{transaction-Cg5I2q47.mjs → transaction-CTFrGYJO.mjs} +2 -2
  26. package/dist/{tsconfig-rZG7b9Ul.mjs → tsconfig-CO_6DRDo.mjs} +127 -42
  27. package/dist/{vitest-BbbU7-qn.mjs → vitest-Deitv0TQ.mjs} +1 -1
  28. package/dist/{workspace-tasks--x70rhb8.mjs → workspace-tasks-CbetXdoh.mjs} +6 -6
  29. package/package.json +8 -3
  30. package/resources/maintenance/validate.mjs +14 -0
  31. package/resources/skills/repoctl/references/commands.md +36 -0
  32. package/resources/skills/repoctl/references/config.md +10 -1
  33. package/resources/skills/repoctl/references/dependencies.md +2 -0
  34. package/resources/skills/repoctl/references/templates.md +6 -0
@@ -6,6 +6,7 @@ import process from "node:process";
6
6
  import { lstat, readFile, realpath } from "node:fs/promises";
7
7
  import fs$1 from "node:fs";
8
8
  import { loadConfig } from "c12";
9
+ import { createDefu } from "defu";
9
10
  import { AsyncLocalStorage } from "node:async_hooks";
10
11
  import { satisfies, valid, validRange } from "semver";
11
12
  import validatePackageName from "validate-npm-package-name";
@@ -24,37 +25,6 @@ async function commandConfigDirectory(name, cwd) {
24
25
  ].includes(name) ? await findWorkspaceDir(cwd) ?? cwd : cwd;
25
26
  }
26
27
  //#endregion
27
- //#region src/core/config/legacy-hooks.ts
28
- const compatibility = new AsyncLocalStorage();
29
- /** Only upgrade and diagnosis may read removed hook fields, to preserve custom setups. */
30
- const legacyHookConfigEnabled = () => compatibility.getStore() === true;
31
- const withLegacyHookConfig = (read) => compatibility.run(true, read);
32
- //#endregion
33
- //#region src/core/config/refresh.ts
34
- /** Keep C12's resolution and merging while bypassing native ESM's immutable cache. */
35
- function freshConfigLoading(files) {
36
- return {
37
- jitiOptions: {
38
- tryNative: false,
39
- moduleCache: false,
40
- fsCache: false
41
- },
42
- resolve(_source, { jiti }) {
43
- if (jiti) jiti.import = async (filename, options) => {
44
- const { bundleConfig } = await import("./bundle-B9vRch4R.mjs");
45
- const bundled = await bundleConfig(filename);
46
- for (const file of bundled.files) files.add(file);
47
- const loaded = await jiti.evalModule(bundled.code, {
48
- filename,
49
- async: true,
50
- forceTranspile: true
51
- });
52
- return options?.default ? loaded?.default ?? loaded : loaded;
53
- };
54
- }
55
- };
56
- }
57
- //#endregion
58
28
  //#region src/core/config/paths.ts
59
29
  /** Dot paths escape literal dots and backslashes in dynamic map keys. */
60
30
  function appendConfigPath(prefix, key) {
@@ -178,6 +148,57 @@ function validateSchema(value, schema, path, diagnostics, ancestors = /* @__PURE
178
148
  }
179
149
  }
180
150
  //#endregion
151
+ //#region src/core/config/docs-targets.ts
152
+ /** Switching provider replaces its identity contract; same-provider objects retain normal preset merging. */
153
+ function replaceDocsTarget(field, current, next) {
154
+ const parts = splitConfigPath(field);
155
+ const relative = parts[0] === "commands" && parts[1] === "docs" ? parts.slice(2) : parts;
156
+ return relative.length === 3 && relative[0] === "sites" && ["preview", "stable"].includes(relative[2]) && (next["provider"] !== void 0 || next["deployScript"] !== void 0) && current["provider"] !== next["provider"];
157
+ }
158
+ /** Preserve C12's own defaults/array semantics while replacing switched target contracts. */
159
+ const mergeProjectValues = createDefu((object, key, value, namespace) => {
160
+ const previous = object[key];
161
+ if (isRecord(previous) && isRecord(value) && replaceDocsTarget(namespace ? `${namespace}.${String(key)}` : String(key), previous, value)) {
162
+ object[key] = value;
163
+ return true;
164
+ }
165
+ return false;
166
+ });
167
+ function mergeProjectConfig(...sources) {
168
+ return mergeProjectValues({}, ...sources.map((source) => source ?? {}));
169
+ }
170
+ //#endregion
171
+ //#region src/core/config/legacy-hooks.ts
172
+ const compatibility = new AsyncLocalStorage();
173
+ /** Only upgrade and diagnosis may read removed hook fields, to preserve custom setups. */
174
+ const legacyHookConfigEnabled = () => compatibility.getStore() === true;
175
+ const withLegacyHookConfig = (read) => compatibility.run(true, read);
176
+ //#endregion
177
+ //#region src/core/config/refresh.ts
178
+ /** Keep C12's resolution and merging while bypassing native ESM's immutable cache. */
179
+ function freshConfigLoading(files) {
180
+ return {
181
+ jitiOptions: {
182
+ tryNative: false,
183
+ moduleCache: false,
184
+ fsCache: false
185
+ },
186
+ resolve(_source, { jiti }) {
187
+ if (jiti) jiti.import = async (filename, options) => {
188
+ const { bundleConfig } = await import("./bundle-B9vRch4R.mjs");
189
+ const bundled = await bundleConfig(filename);
190
+ for (const file of bundled.files) files.add(file);
191
+ const loaded = await jiti.evalModule(bundled.code, {
192
+ filename,
193
+ async: true,
194
+ forceTranspile: true
195
+ });
196
+ return options?.default ? loaded?.default ?? loaded : loaded;
197
+ };
198
+ }
199
+ };
200
+ }
201
+ //#endregion
181
202
  //#region src/core/presets/reference.ts
182
203
  const presetPackageName = {
183
204
  expected: "npm package name",
@@ -246,10 +267,38 @@ function resolveNightlyConfig(config = {}) {
246
267
  }
247
268
  //#endregion
248
269
  //#region src/core/config/validation/docs.ts
249
- const target = object({
250
- deployScript: nonempty,
251
- url: nonempty
252
- }, ["deployScript"]);
270
+ const milliseconds = (maximum) => ({
271
+ expected: `integer milliseconds from 1 to ${maximum}`,
272
+ accepts: (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 1 && value <= maximum
273
+ });
274
+ const readiness = object({
275
+ timeoutMs: milliseconds(6e5),
276
+ requestTimeoutMs: milliseconds(3e4)
277
+ });
278
+ const target = union({
279
+ ...object({
280
+ deployScript: nonempty,
281
+ url: nonempty,
282
+ readiness
283
+ }, ["deployScript"]),
284
+ accepts: (value) => isRecord(value) && value["provider"] === void 0
285
+ }, {
286
+ ...object({
287
+ provider: choices("cloudflare-workers"),
288
+ config: nonempty,
289
+ workerName: nonempty,
290
+ accountId: nonempty,
291
+ environment: nonempty,
292
+ url: nonempty,
293
+ readiness
294
+ }, [
295
+ "provider",
296
+ "config",
297
+ "workerName",
298
+ "accountId"
299
+ ]),
300
+ accepts: (value) => isRecord(value) && value["provider"] === "cloudflare-workers"
301
+ });
253
302
  const docsSchema = object({ sites: record(object({
254
303
  packages: names,
255
304
  releaseInputs: record(names),
@@ -265,6 +314,35 @@ const docsSchema = object({ sites: record(object({
265
314
  "patchPaths"
266
315
  ])) });
267
316
  //#endregion
317
+ //#region src/core/config/validation/upgrade.ts
318
+ function isUpgradeExpiry(value) {
319
+ return typeof value === "string" && /^\d{4}-\d{2}-\d{2}$/.test(value) && !Number.isNaN(Date.parse(value)) && new Date(value).toISOString().slice(0, 10) === value;
320
+ }
321
+ const fingerprint = {
322
+ expected: "SHA-256 fingerprint from the upgrade preview",
323
+ accepts: (value) => typeof value === "string" && /^[\da-f]{64}$/.test(value)
324
+ };
325
+ const upgradeKeepSchema = array(object({
326
+ file: choices("pnpm-workspace.yaml"),
327
+ path: {
328
+ expected: "[\"overrides\", nonempty selector]",
329
+ accepts: (value) => Array.isArray(value) && value.length === 2 && value[0] === "overrides" && typeof value[1] === "string" && value[1].trim().length > 0
330
+ },
331
+ reason: nonempty,
332
+ upstreamHash: fingerprint,
333
+ localHash: fingerprint,
334
+ expires: {
335
+ expected: "inclusive UTC YYYY-MM-DD date",
336
+ accepts: isUpgradeExpiry
337
+ }
338
+ }, [
339
+ "file",
340
+ "path",
341
+ "reason",
342
+ "upstreamHash",
343
+ "localHash"
344
+ ]));
345
+ //#endregion
268
346
  //#region src/core/config/validation/commands.ts
269
347
  const dependencyTypes = array(choices("dependencies", "devDependencies", "peerDependencies", "optionalDependencies"));
270
348
  const toolingTargets = array(choices("commitlint", "eslint", "stylelint", "lefthook", "tsconfig", "vitest"));
@@ -452,7 +530,8 @@ const commandSchemas = {
452
530
  targets: strings,
453
531
  mergeTargets: boolean,
454
532
  scripts: record(string),
455
- skipChangesetMarkdown: boolean
533
+ skipChangesetMarkdown: boolean,
534
+ keep: upgradeKeepSchema
456
535
  })
457
536
  };
458
537
  //#endregion
@@ -763,6 +842,7 @@ function validatedConfigLoading(files, refresh) {
763
842
  const wrapped = /* @__PURE__ */ new WeakSet();
764
843
  return {
765
844
  ...fresh,
845
+ merger: mergeProjectConfig,
766
846
  jitiOptions: {
767
847
  ...fresh?.jitiOptions,
768
848
  fsCache: false
@@ -790,7 +870,7 @@ function validatedConfigLoading(files, refresh) {
790
870
  //#endregion
791
871
  //#region src/core/config/merge.ts
792
872
  /** Preset boundaries merge objects and replace arrays, without changing C12's project merge. */
793
- function mergeConfigValues(layers) {
873
+ function mergeConfigValues(layers, replaceObject) {
794
874
  const values = {};
795
875
  const sources = {};
796
876
  function clear(field) {
@@ -802,7 +882,7 @@ function mergeConfigValues(layers) {
802
882
  if (value === void 0) continue;
803
883
  const field = appendConfigPath(prefix, key);
804
884
  if (isRecord(value) && !next.has(value)) {
805
- const existing = Object.hasOwn(target, key) && isRecord(target[key]);
885
+ const existing = Object.hasOwn(target, key) && isRecord(target[key]) && !replaceObject?.(field, target[key], value);
806
886
  if (!existing) clear(field);
807
887
  else if (Object.keys(value).length) delete sources[field];
808
888
  const child = existing ? target[key] : {};
@@ -835,7 +915,7 @@ function mergeConfigValues(layers) {
835
915
  //#endregion
836
916
  //#region package.json
837
917
  var name = "@icebreakers/monorepo";
838
- var version = "6.0.1";
918
+ var version = "6.1.0";
839
919
  var engines = { "node": "^22.23.4 || ^24.22.1 || >=26.12.1" };
840
920
  var package_default = {
841
921
  name,
@@ -878,7 +958,11 @@ var package_default = {
878
958
  },
879
959
  "./tsconfig": "./tsconfig.base.json",
880
960
  "./tsconfig.json": "./tsconfig.base.json",
881
- "./package.json": "./package.json"
961
+ "./package.json": "./package.json",
962
+ "./docs-context": {
963
+ "types": "./dist/docs-context-entry.d.mts",
964
+ "default": "./dist/docs-context-entry.mjs"
965
+ }
882
966
  },
883
967
  main: "./dist/index.mjs",
884
968
  module: "./dist/index.mjs",
@@ -936,6 +1020,7 @@ var package_default = {
936
1020
  "comment-json": "catalog:",
937
1021
  "consola": "^3.4.2",
938
1022
  "cross-spawn": "^7.0.6",
1023
+ "defu": "^6.1.7",
939
1024
  "esbuild": "catalog:",
940
1025
  "git-url-parse": "^16.1.0",
941
1026
  "json5": "^2.2.3",
@@ -1438,7 +1523,7 @@ async function loadConfigInternal(cwd, refresh = false) {
1438
1523
  const merged = mergeConfigValues(sourceLayers.map((layer) => ({
1439
1524
  source: layer.source,
1440
1525
  values: layer.config
1441
- })));
1526
+ })), replaceDocsTarget);
1442
1527
  assertMonorepoConfig(merged.values);
1443
1528
  return {
1444
1529
  file,
@@ -1583,4 +1668,4 @@ async function defineTsconfigConfig(input = {}) {
1583
1668
  return createMonorepoTsconfig(mergeTsconfig(await loadToolingSection("tsconfig", resolved.cwd) ?? {}, resolved.options));
1584
1669
  }
1585
1670
  //#endregion
1586
- export { package_default as A, templateSourcePath as B, checkedFile as C, relativeFile as D, readOptionalSource as E, validateMonorepoConfig as F, validateSchema as G, resolveNightlyConfig as H, normalizeTemplateRemoteSource as I, withLegacyHookConfig as J, appendConfigPath as K, normalizeTemplateSourceRequest as L, mergeConfigValues as M, ConfigValidationError as N, engines as O, assertMonorepoConfig as P, registryUrl as R, canonicalDirectory as S, readOptional as T, presetPackageName as U, commandSchemas as V, presetVersion as W, commandConfigDirectory as Y, listToolingCapabilities as _, loadToolingSection as a, presetRelativePath as b, config_exports as c, loadMonorepoConfig as d, loadMonorepoConfigDetails as f, presetAssetTarget as g, resolveOrganizationPresets as h, loadMonorepoToolingConfig as i, version as j, name as k, defineMonorepoConfig as l, resolveToolingConfig as m, defineTsconfigConfig as n, resolveConfigInput as o, resolveCommandConfig as p, splitConfigPath as q, isDefineConfigWrapper as r, configExtensions as s, createMonorepoTsconfig as t, getRepoctlConfigCandidates as u, installedPresetDirectory as v, hash as w, readPresetFile as x, parsePresetJson as y, sourceRequestKey as z };
1671
+ export { package_default as A, templateSourcePath as B, checkedFile as C, relativeFile as D, readOptionalSource as E, validateMonorepoConfig as F, presetVersion as G, isUpgradeExpiry as H, normalizeTemplateRemoteSource as I, isRecord as J, withLegacyHookConfig as K, normalizeTemplateSourceRequest as L, mergeConfigValues as M, ConfigValidationError as N, engines as O, assertMonorepoConfig as P, commandConfigDirectory as Q, registryUrl as R, canonicalDirectory as S, readOptional as T, resolveNightlyConfig as U, commandSchemas as V, presetPackageName as W, appendConfigPath as X, validateSchema as Y, splitConfigPath as Z, listToolingCapabilities as _, loadToolingSection as a, presetRelativePath as b, config_exports as c, loadMonorepoConfig as d, loadMonorepoConfigDetails as f, presetAssetTarget as g, resolveOrganizationPresets as h, loadMonorepoToolingConfig as i, version as j, name as k, defineMonorepoConfig as l, resolveToolingConfig as m, defineTsconfigConfig as n, resolveConfigInput as o, resolveCommandConfig as p, replaceDocsTarget as q, isDefineConfigWrapper as r, configExtensions as s, createMonorepoTsconfig as t, getRepoctlConfigCandidates as u, installedPresetDirectory as v, hash as w, readPresetFile as x, parsePresetJson as y, sourceRequestKey as z };
@@ -1,4 +1,4 @@
1
- import { a as loadToolingSection, o as resolveConfigInput, r as isDefineConfigWrapper } from "./tsconfig-rZG7b9Ul.mjs";
1
+ import { a as loadToolingSection, o as resolveConfigInput, r as isDefineConfigWrapper } from "./tsconfig-CO_6DRDo.mjs";
2
2
  import { createRequire } from "node:module";
3
3
  import process from "node:process";
4
4
  import fs from "node:fs";
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
2
- import { N as ConfigValidationError, f as loadMonorepoConfigDetails, j as version, u as getRepoctlConfigCandidates } from "./tsconfig-rZG7b9Ul.mjs";
2
+ import { N as ConfigValidationError, f as loadMonorepoConfigDetails, j as version, u as getRepoctlConfigCandidates } from "./tsconfig-CO_6DRDo.mjs";
3
3
  import { createRequire } from "node:module";
4
4
  import gitUrlParse from "git-url-parse";
5
5
  import { simpleGit } from "simple-git";
@@ -1986,16 +1986,16 @@ var knip_exports = /* @__PURE__ */ __exportAll({
1986
1986
  saveKnipBaseline: () => saveKnipBaseline
1987
1987
  });
1988
1988
  async function planKnipCheck(cwd, options = {}) {
1989
- return (await import("./plan-DuHMR5Za.mjs")).planKnipCheck(cwd, options);
1989
+ return (await import("./plan-DT1Gz8tE.mjs")).planKnipCheck(cwd, options);
1990
1990
  }
1991
1991
  async function runKnipCheck(cwd, options = {}) {
1992
- return (await import("./run-BGHVj0Lj.mjs")).runKnipCheck(cwd, options);
1992
+ return (await import("./run-BBf92Scj.mjs")).runKnipCheck(cwd, options);
1993
1993
  }
1994
1994
  async function getKnipConfigurationSuggestions(cwd) {
1995
- return (await import("./config--wYfkdsO.mjs")).getKnipConfigurationSuggestions(cwd);
1995
+ return (await import("./config-CtnhpveO.mjs")).getKnipConfigurationSuggestions(cwd);
1996
1996
  }
1997
1997
  async function saveKnipBaseline(cwd, report, file) {
1998
- return (await import("./save-UiJgdSaY.mjs")).saveKnipBaseline(cwd, report, file);
1998
+ return (await import("./save-CCCUswjG.mjs")).saveKnipBaseline(cwd, report, file);
1999
1999
  }
2000
2000
  //#endregion
2001
2001
  //#region src/commands/env-cache/config.ts
@@ -2184,7 +2184,7 @@ function scanSource(filename, source) {
2184
2184
  try {
2185
2185
  ast = parse$2(part.text, {
2186
2186
  sourceType: "unambiguous",
2187
- plugins: /\.[cm]?ts$/.test(filename) ? ["typescript"] : ["typescript", "jsx"],
2187
+ plugins: /\.[cm]?ts$/i.test(filename) ? [["typescript", { dts: /\.d\.[cm]?ts$/i.test(filename) }]] : ["typescript", "jsx"],
2188
2188
  allowAwaitOutsideFunction: true,
2189
2189
  allowReturnOutsideFunction: true
2190
2190
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@icebreakers/monorepo",
3
3
  "type": "module",
4
- "version": "6.0.1",
4
+ "version": "6.1.0",
5
5
  "description": "Core engine and programmatic APIs for repoctl",
6
6
  "author": "ice breaker <hi@sonofmagic.top>",
7
7
  "license": "MIT",
@@ -43,7 +43,11 @@
43
43
  },
44
44
  "./tsconfig": "./tsconfig.base.json",
45
45
  "./tsconfig.json": "./tsconfig.base.json",
46
- "./package.json": "./package.json"
46
+ "./package.json": "./package.json",
47
+ "./docs-context": {
48
+ "types": "./dist/docs-context-entry.d.mts",
49
+ "default": "./dist/docs-context-entry.mjs"
50
+ }
47
51
  },
48
52
  "main": "./dist/index.mjs",
49
53
  "module": "./dist/index.mjs",
@@ -87,7 +91,7 @@
87
91
  "@babel/parser": "^7.29.9",
88
92
  "@icebreakers/commitlint-config": "4.1.4",
89
93
  "@icebreakers/eslint-config": "8.0.11",
90
- "@icebreakers/monorepo-templates": "3.0.1",
94
+ "@icebreakers/monorepo-templates": "3.1.0",
91
95
  "@icebreakers/stylelint-config": "5.1.5",
92
96
  "@npmcli/config": "10.14.0",
93
97
  "@pnpm/find-workspace-dir": "^1000.1.5",
@@ -100,6 +104,7 @@
100
104
  "comment-json": "^5.0.0",
101
105
  "consola": "^3.4.2",
102
106
  "cross-spawn": "^7.0.6",
107
+ "defu": "^6.1.7",
103
108
  "esbuild": "^0.28.2",
104
109
  "git-url-parse": "^16.1.0",
105
110
  "json5": "^2.2.3",
@@ -66,6 +66,20 @@ export async function validateMaintenanceArtifact({ cwd, directory, expected, re
66
66
  || !report.checks.some(check => ['lint', 'typecheck', 'test'].includes(check.name) && check.status === 'passed')) {
67
67
  fail('the plan or validation did not complete successfully')
68
68
  }
69
+ for (const file of report.plan?.files ?? []) {
70
+ const policy = file.workspacePolicy
71
+ if (policy === undefined) {
72
+ continue
73
+ }
74
+ const expires = policy?.expires
75
+ if (!policy || !Array.isArray(policy.findings)
76
+ || policy.findings.some(finding => !['compatible', 'kept'].includes(finding?.status))
77
+ || (expires !== undefined && (typeof expires !== 'string' || !/^\d{4}-\d{2}-\d{2}$/.test(expires)
78
+ || Number.isNaN(Date.parse(expires)) || new Date(expires).toISOString().slice(0, 10) !== expires
79
+ || expires < new Date().toISOString().slice(0, 10)))) {
80
+ fail('workspace override policy is unverified, conflicting or expired; review a new upgrade plan')
81
+ }
82
+ }
69
83
  if (!expected.appConfigured) {
70
84
  fail('configure REPOCTL_APP_CLIENT_ID and REPOCTL_APP_PRIVATE_KEY with contents, pull requests and workflows write access')
71
85
  }
@@ -1,5 +1,31 @@
1
1
  # Commands
2
2
 
3
+ ## docs plan / docs deploy
4
+
5
+ ```bash
6
+ repo docs plan guide --channel preview --source-sha <full-main-sha> --json
7
+ repo docs plan guide --channel stable --release <completion-record-id> --json
8
+ repo docs plan guide --channel stable --commits <correction-sha> --json
9
+ ```
10
+
11
+ Enable `commands.docs.sites` explicitly. Preview uses the exact latest main source; stable uses a completed main/latest release and the covered packages' publication evidence. `plan` is read-only and does not perform provider credential preflight. Run stable `deploy` with the same inputs through managed `repoctl-docs.yml` / `repoctl-docs-deploy.yml`, with the actual `docs-<site>-<channel>` concurrency group. Keep one deployment owner per channel.
12
+
13
+ Targets retain `{ deployScript, url? }` or use `{ provider: 'cloudflare-workers', config, workerName, accountId, environment?, url? }`. Do not mix them or insert a new `provider: 'script'` discriminator into old configuration. A native target checks an explicit repository-relative static JSON/JSONC Wrangler config for an assets-only Worker. Named environments must exist, replace the whole assets object when overriding it, and explicitly configure routes when the top level owns routes. Preview/stable cannot share the same account+Worker, even with different environment names, or claim the same domains. Worker/account/url values are assertions, not silent config overrides. TOML, generated/plugin configs, Worker code, build hooks, bindings, service environments and unsupported deployment features use a script adapter.
14
+
15
+ Native `deploy` preflights the frozen target, paths, runtime `CLOUDFLARE_API_TOKEN` and read-only Cloudflare deployment/version access before frozen-source install/build. Optional `CLOUDFLARE_ACCOUNT_ID` and effective Wrangler `account_id` must equal configured `accountId`. Read success does not prove future upload or domain-write permissions. Only Worker HTTP 404 plus code `10007` permits first deployment; ambiguous/empty responses, auth errors and rate limits fail. Install and lock Wrangler in the workspace; do not download or substitute an unrelated CLI during deployment. Recheck configuration and symlink containment after build.
16
+
17
+ The native provider writes `/.well-known/repoctl-deployment.json` in assets with the full deployment identity; an existing file must already match that identity. Confirmation requires the latest active version at 100% with exact `repoctl-docs:<deploymentId>` annotation, never a historical match. Matching active identity reuses the remote version without another upload. New uploads must match Wrangler's Worker/environment/version and the active API result. This confirms provider state; optional target `readiness` adds exact public HTTP identity verification.
18
+
19
+ The selected site build and provider/deployment phase receive frozen `REPO_DOCS_*` context. Frozen-source installation removes every inherited `REPO_DOCS_*` variable, retains ordinary CI/package-manager environment and lifecycle scripts, and sets `LEFTHOOK=0`; unrelated sites built by postinstall use their own defaults. The caller's environment is not mutated. Script adapters receive `REPO_DOCS_SITE`, `REPO_DOCS_CHANNEL`, `REPO_DOCS_SOURCE_SHA`, `REPO_DOCS_TREE_SHA`, `REPO_DOCS_RELEASE_ID`, `REPO_DOCS_DEPLOYMENT_ID`, `REPO_DOCS_URL` and `REPO_DOCS_RESULT_FILE`; write `{ versionId, url? }` to the result file only after provider verification. Native targets return that result directly. Credentials never enter the frozen identity.
20
+
21
+ Both providers keep revision-checked claims and stable snapshots. Retry unknown uploads that lack a saved verification receipt, or final checkpoint failures with readiness disabled, using the same release/correction inputs: installation and rebuild still run, then reconciliation decides whether upload is needed. Failed retry preflight/build must retain an existing `deploying` claim. A different stable deployment cannot replace it; serialized latest-main preview can supersede an older preview. Already completed deployments skip. Older pending script snapshots keep their exact configuration and original source after live configuration moves to native targets. Never rewrite snapshots, republish npm to retry docs, or fake a stable completion record.
22
+
23
+ Opt in per target with `readiness: {}` or bounded `timeoutMs`/`requestTimeoutMs`. Use an explicit HTTPS target URL; fetch only its origin-root manifest, without credentials, redirects or caching. Native targets stamp the manifest. Script targets must publish `schemaVersion: 1`, site/channel/deploymentId/sourceSha/treeSha from the supplied `REPO_DOCS_*` context, and releaseId only for stable; do not recompute the corrected tree or replace Nimbus `_headers`. A readiness receipt permits only a nonempty control-free versionId (≤512 characters) and optional HTTP(S) URL without credentials/query/fragment.
24
+
25
+ Provider confirmation persists `verifying` plus its receipt before public HTTP. Timeout/finalization failure keeps the previous fully verified current, although public traffic may already serve the new version. Same-deployment retries skip frozen install/build/upload: native targets recheck the saved active version before polling and finalization; scripts reuse the receipt without rerunning deployScript. The workflow bootstrap install still runs. Another stable deployment cannot replace verifying, and saved stable policy/URL survive changes/removal on main. Never fall back to uploading because readiness failed.
26
+
27
+ `deployDocs` success/skip may include `DocsDeploymentReport`; failure throws `DocsDeploymentError` with safe `.report`. Stages are plan/preflight/install/build/provider/readiness/finalize with explicit skips, monotonic elapsedMs, upload/reconcile and optional failedStage/resumablePhase. `--json` writes result/failure JSON only to stdout and streams child output live to stderr; `DocsOptions.json` selects that transport programmatically. Failures exit nonzero. Known repoctl failures retain fixed reason codes and actionable guidance. Generated reports omit raw exceptions/response bodies/credentials; scripts own their terminal logs. Escaped `GITHUB_STEP_SUMMARY` is best-effort: `summary-write-failed` warns without changing the outcome or hiding the primary failure.
28
+
3
29
  ## init
4
30
 
5
31
  Purpose: bootstrap workspace metadata plus recommended tooling defaults.
@@ -80,6 +106,8 @@ Usage:
80
106
  - `--json` emits the structured report only and still exits non-zero when blocking failures exist
81
107
  - `--out <file>` persists the text or JSON report and still exits non-zero when blocking failures exist
82
108
 
109
+ Text and Markdown show stable rule IDs, exact affected paths and manifest fields. Identical findings share an explanation and fix while retaining every path and original check count; different reasons, fixes and suppressions stay separate. Use the displayed ID with `--rules`, for example `repo doctor --rules template-instance-drift`. Grouped display never changes statuses, effective totals, suppression policy or full individual JSON records. Use `--redact` before sharing local paths.
110
+
83
111
  ```bash
84
112
  repo doctor --list-rules
85
113
  repo doctor --rules root-scripts,package-manager --strict
@@ -105,6 +133,10 @@ Preview the complete operation with `repo upgrade --dry-run`, `--json` or `--mar
105
133
 
106
134
  Root assets use old-upstream/local/new-upstream three-way merging. Commit `.repoctl/baselines/root/` to preserve the upstream records across clones; record updates are reviewed in each file's `baseline` plan entry and applied atomically with that file. Independent changes merge automatically, while conflicting files and their baselines stay unchanged. Local deletion is never undone. API results expose unresolved `conflicts`; CLI preview and apply exit with code 1 when conflicts remain. Saved plans are reviewed write payloads; their hashes detect stale inputs and inconsistent content, not authorship. Generated app/package directories are outside this feature.
107
135
 
136
+ New workspace overrides are checked against declarations in the proposed package membership and `commands.deps.groups`. Scope expansion or incompatible replacements produce `workspace-override-policy` conflicts, including with `--yes`/`--overwrite`. Inspect `workspacePolicy.findings` for affected manifests/groups and both value fingerprints. New parent-qualified selectors and non-semver replacements are `unverified`; ordinary upgrade requires explicit file selection, automatic maintenance rejects them, and reviewed saved-plan apply remains available. To retain an individual value or its absence, commit `commands.upgrade.keep` entries with `file: 'pnpm-workspace.yaml'`, `path: ['overrides', selector]`, `reason`, copied `upstreamHash`/`localHash`, and optional inclusive UTC `expires`. Regenerate the plan after configuration changes. Changed upstream/local values and elapsed expiry invalidate the decision; apply also checks configuration, inspected manifests and the proposed package set. Do not replace scoped overrides with global ones to silence this check. Existing template-instance `excludedPaths` and file selections remain separate.
137
+
138
+ A recognized automatic default hook migration marks unverified override additions as `deferred` and leaves them absent. Preview again afterwards, then explicitly review/select or apply the new saved plan to accept them. Hard conflicts and protected skips of required files block every member of an atomic group, including explicit partial selection; preset-owned targets and preserved local deletions cannot leave hooks partially migrated. Automatic maintenance preparation and the independent publisher reject both `unverified` and `deferred`; finish the ordinary hook migration and override review before retrying maintenance.
139
+
108
140
  Upgrade apply holds `.repoctl/upgrade.lock` through validation, no-op detection, writes, rollback and cleanup. It never removes colliding recovery files, changed recovery bytes or replacement directories. After an interruption, confirm no writer is active and recover retained backups before removing the lock and regenerating the plan.
109
141
 
110
142
  Versioned migrations appear in `migrations` with stable IDs and affected files. The Changesets-to-pnpm migration starts at template 1.1.0. Use `--from-version <exact-semver>` only when the old version is known; dependency ranges are not version evidence. Unknown sources adopt only recognized legacy formats. Commit `.repoctl/migrations/ledger.json` when created; its cursor covers migrations, not all assets. Preview writes nothing. Pending/failed bytes and completed diffs are reviewed together; migration groups cannot be split, and completed is written only at the end of a successful migration transaction. Re-preview pending/failed attempts to see already-applied versus remaining files; third-state local edits block recovery and retain attempt-specific backups. The shared `.repoctl/upgrade.lock` is never stolen by age; confirm no writer is active and recover pending backups before clearing it. Recovery performs no network/publish actions or historical script execution.
@@ -458,3 +490,7 @@ Automatic maintenance can complete the built-in Changesets migration and update
458
490
  Preview `repo workspace prepare <exact-name-or-./directory> --mode prune|deploy --out ../empty-output --json`; save the plan outside the source workspace. Apply only after review with `repo workspace prepare --apply ../plan.json`. Prune uses local Turbo 2 and optional `--docker`; deploy uses exact pinned pnpm 10/11/12 with production dependencies, frozen lockfile, disabled lifecycle/pnpmfile hooks, optional `--offline`/explicit `--legacy`, and an existing built `--entry` or manifest main/single bin. Native version-specific injection and peer behavior remains authoritative. No application, image publishing or cloud deployment is executed.
459
491
 
460
492
  Native commands receive an isolated copy without node_modules, Git/operation/cache directories, real env files or named authentication files. Public .env.example/.env.sample remain. Source symlinks/special files, source-directed native write settings and inventories above 100,000 entries/1 GiB are unsupported. Output must be outside the workspace; links must remain inside the artifact. Publish files exclusively and commit the receipt last. Replays verify source/tool/config fingerprints and complete output; failures preserve concurrent edits and report retained paths. Review cleanupPending and recover partial output before removing a stale .repoctl/workspace-artifacts.lock. Do not hand-edit lockfiles or overwrite nonempty output. On Windows, transfer junction contents with an appropriate copy/archive mode.
493
+
494
+ ## Documentation build context
495
+
496
+ Use `resolveDocsContext({ channel, url, previewOrigin, stableOrigin })` from `repoctl/docs-context` for public build metadata, plus `docsRobots`, `docsPreviewRobots` and ownership-aware `mergeDocsHeaders`. The pure entrypoint loads no provider, credentials or GitHub state. Default local builds are preview; `REPO_DOCS_CHANNEL=stable pnpm build` is allowed without deployment authorization. Distinct HTTP(S) origins are required and optional `REPO_DOCS_URL` must match. Review cached tasks with `repo env check build lint typecheck test --json`.
@@ -7,7 +7,7 @@ Rule:
7
7
  - Load `repoctl.config.*`; rename legacy `monorepo.config.*`, which is no longer loaded.
8
8
  - Validate repoctl-owned fields before command side effects with `repo config validate --json`.
9
9
  - Native tooling passthrough and callbacks keep their extension boundary. Config modules are trusted executable project code.
10
- - Use `repo config inspect --command ai --set 'format="json"' --json` for shared defaults/project/CLI provenance. Contexts: ai, clean, create, deps, doctor, init, mirror, release, upgrade. Runtime selection is explained by each command's plan.
10
+ - Use `repo config inspect --command ai --set 'format="json"' --json` for shared defaults/project/CLI provenance. Contexts: ai, clean, create, deps, doctor, docs, init, mirror, release, upgrade. Runtime selection is explained by each command's plan.
11
11
  - Reports redact env values and native tool payloads by default; `--redact` additionally hides local paths. For programmatic safe reports use `explainMonorepoConfig` or `validateConfigFile`; runtime config APIs retain callbacks and should not be serialized for sharing.
12
12
  - Git hooks use native `lefthook.yml`. Migrate old `tooling.lintStaged` and `tooling.husky` settings into that file.
13
13
  - Organization presets use `presets: [{ packageName, version }]` with an exact installed dependency and JSON-only `repoctl.preset.json`. Loading never imports package code, installs or fetches. Parents precede declaring presets, then the project and CLI; arrays replace at preset boundaries. `config inspect` exposes ordered layers and precise package/version sources.
@@ -70,6 +70,9 @@ Key areas:
70
70
  - upgrade: overwrite behavior and extra targets
71
71
  - init: skip steps for README/package.json/pnpm change intent setup
72
72
  - mirror: add or override env mirrors
73
+ - docs: explicit sites with covered `packages`, a root `buildScript`, `preview`/`stable` targets, allowed `patchPaths` and optional per-package `releaseInputs`. Targets choose `{ deployScript, url? }` or `{ provider: 'cloudflare-workers', config, workerName, accountId, environment?, url? }`, never both. Native Cloudflare supports static assets-only JSON/JSONC configurations; freeze the nonsecret account identity, keep credentials in runtime environment secrets, and preserve old script snapshots for retry. See the docs section in `commands.md` for preflight and recovery boundaries.
74
+
75
+ Both docs target variants accept optional `readiness: { timeoutMs?, requestTimeoutMs? }`. Omission means no public HTTP. `{}` requires an explicit HTTPS target URL without userinfo/query/fragment; probe the fixed origin-root `/.well-known/repoctl-deployment.json`. Positive integer defaults/limits: total 120000 ms / 1–600000, request 10000 ms / 1–30000. Runtime defaults do not alter stored config identity. Saved stable verification retains its original target and policy even if main removes them.
73
76
 
74
77
  ## `commands.doctor`
75
78
 
@@ -129,3 +132,9 @@ The root aggregates selected projects. Only explicit `relations` add compilation
129
132
  Existing references remain manually owned. Only newly added entries are recorded in `.repoctl/typescript-references.json`; commit that registry alongside the tsconfigs. Removing or excluding a project removes only entries recorded there. Editing/removing an owned entry blocks synchronization: restore it, or deliberately remove its registry entry to return ownership to the user. JSONC content outside the `references` value, BOM and line endings are preserved. Root aggregation and explicit edges produce stable relative config-file paths.
130
133
 
131
134
  Saved plans include input fingerprints and exact diffs. Applying a stale or edited plan fails before writes; reapplying an already completed plan is a no-op. A process lock at `.repoctl/typescript-references.lock` covers revalidation, writing, verification, rollback and cleanup. Changes stage together with backups and roll back on failure. If concurrent edits prevent safe rollback, the error names retained recovery files: preserve them, reconcile the business edit with the original backup, restore the ownership registry consistently and generate a new plan. A killed process can also leave `.repoctl-references-*.bak`/`.tmp` files; verify no writer remains, reconcile matching backups and the registry, then remove the stale lock. No recovery action overwrites a concurrent edit automatically.
135
+
136
+ - upgrade `keep`: reviewed `pnpm-workspace.yaml` override decisions only; each entry has `file`, exact array `path`, nonempty `reason`, `upstreamHash`, `localHash`, and optional inclusive UTC `expires`. Copy fingerprints from `workspacePolicy.findings`; absence and null differ. Re-preview after editing configuration. Upstream/local value changes or expiry require renewed review.
137
+
138
+ ## Documentation channel rendering
139
+
140
+ Provider target URLs and template origins must agree. `repoctl/docs-context` validates public channel/URL values only; it does not authorize deployments or stamp deployment manifests. Configure the Nimbus or VitePress deployment module with distinct preview/stable origins and keep channel/URL in task-local Turbo `env` hashes. Preview crawler restrictions must not disable local search. Preserve project-owned layouts and user/Nimbus `_headers` rules through the marked merge helper.
@@ -35,3 +35,5 @@ Only plain semver ranges and same-source npm aliases can migrate. An alias keeps
35
35
  Apply is bound to the same workspace and full input set. Stale YAML, changed manifests/policies, new packages, linked files, partial application and modified plan contents are rejected before writes. It uses the same staged replacements, backups and rollback as dependency fixes, across both YAML and JSON. A fully applied plan and a repeated migration are no-ops. If recovery cannot safely replace a concurrent edit, inspect the listed `.repoctl-deps-*.bak` originals, restore reviewed files, remove stale temporary files and generate a fresh plan; the concurrent edit is preserved.
36
36
 
37
37
  Public APIs are `checkCatalogs(cwd, options?)`, `planCatalogMigration(cwd, options)` and `applyCatalogMigrationPlan(cwd, plan)`. See [pnpm catalogs](https://pnpm.io/catalogs) for protocol semantics and [Syncpack](https://syncpack.dev/) for intentional version-group policy patterns.
38
+
39
+ Workspace upgrade reuses dependency groups when evaluating new overrides. It scans the proposed workspace membership, reports selector expansion and declarations incompatible with replacement versions, and keeps unverified parent-qualified/non-semver cases explicit. Use fingerprint-bound `commands.upgrade.keep` decisions to retain reviewed local override values or absence; do not remove intentional cohorts merely to accept template defaults.
@@ -68,3 +68,9 @@ npm configuration supplies scoped registry/authentication. Never put credentials
68
68
  ## Existing-package generators
69
69
 
70
70
  Use `repo generate <vue-component|react-component|hono-route> <kebab-name> --package <exact-name-or-relative-dir> --json` to inspect source and behavior-test files before writing. Run without `--json` to apply; `--export` explicitly adds a named export to `src/index.ts` (or `--barrel`). `--directory` stays inside the selected package. Strict parameters, framework requirements, stale plans, symlinks and conflicting files fail before writes. Repeated identical generation is unchanged. Hono route registration remains an explicit printed next step. Validate generated output with build, ESLint/Stylelint, tsc/vue-tsc and tests. Keep `repo new` for whole new packages; it never overwrites existing directories.
71
+
72
+ ## Documentation channels
73
+
74
+ Nimbus and VitePress use `repoctl/docs-context` with explicit `REPO_DOCS_CHANNEL` and `REPO_DOCS_URL` build inputs. Configure distinct preview/stable HTTP(S) origins in the local deployment module; paths belong to the framework base. Missing/empty channel defaults to preview; supplied URL must match the selected origin. Local stable builds require no token or release record.
75
+
76
+ Keep preview banners, robots/meta/X-Robots-Tag restrictions and search independent: preview remains searchable with official AI exports. `mergeDocsHeaders` owns marked fields only and preserves user/Nimbus rules; malformed markers fail. Keep task-local Turbo env hashes and authored content/config/script inputs, and run `repo env check build lint typecheck test --json`. Both docs packages declare repoctl directly. Existing layouts remain project-owned; use reviewed template upgrades or manual integration.