@theholocron/cli 5.0.0-alpha.517 → 5.0.0-alpha.519

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/cli.mjs CHANGED
@@ -22,8 +22,8 @@ import { ConfigError, ConfigError as ConfigError$1, createConfigSystem, lastWins
22
22
  import { LoaderError, assertPluginsResolvable as assertPluginsResolvable$1, createPluginSystem, defaultImporter as defaultImporter$1, isModuleNotFound, isModuleNotFound as isModuleNotFound$1, resolvePluginPackage as resolvePluginPackage$1 } from "@theholocron/kyber/plugins";
23
23
  import { readGitRemote, updateGitignore, upsertManagedBlock } from "@theholocron/git-utils";
24
24
  import { bumpCatalogPins, discoverWorkspacePackages, parseCatalogs, readPackageJson, readPackageJsonSync, resolveWorkspaceGlobs } from "@theholocron/pkg-utils";
25
- import { Separator, checkbox, confirm, input, password, select } from "@inquirer/prompts";
26
25
  import { runCheckAgainstUrl } from "@theholocron/kyber/checks";
26
+ import { Separator, checkbox, confirm, input, password, select } from "@inquirer/prompts";
27
27
  import { access, copyFile, lstat, mkdir, open, readFile, readdir, realpath, rename, rm, stat, symlink, unlink, writeFile } from "node:fs/promises";
28
28
  import { createHash, createHmac, randomBytes, randomUUID } from "node:crypto";
29
29
  import { promptForPositionals } from "@theholocron/kyber/prompts";
@@ -115,6 +115,7 @@ const COMMAND_CONTEXTS = {
115
115
  "doctor github-app": "workspace",
116
116
  "move issues": "workspace",
117
117
  "apply properties": "workspace",
118
+ "apply issue-types": "workspace",
118
119
  "migrate issue": "workspace",
119
120
  "migrate issues": "workspace",
120
121
  "migrate project": "workspace",
@@ -164,6 +165,21 @@ function contextForCommand(name) {
164
165
  function commandsInContext(context) {
165
166
  return Object.entries(COMMAND_CONTEXTS).filter(([, c]) => c === context).map(([name]) => name);
166
167
  }
168
+ // src/commands/apply-issue-types/apply-issue-types.entry.ts
169
+ const applyIssueTypesEntry = {
170
+ name: "apply issue-types",
171
+ description: "Make the organization's issue Types match the org area's issueTypes",
172
+ positionals: [],
173
+ options: [{
174
+ key: "update",
175
+ flag: "--update",
176
+ type: "confirm",
177
+ default: false,
178
+ message: "Also set the description and colour of a Type that exists and differs?"
179
+ }],
180
+ skipOptions: ["yes"],
181
+ supportsDryRun: true
182
+ };
167
183
  // src/auth/auth.ts
168
184
  /**
169
185
  * The CLI's credentials: the OS keyring every plugin's bootstrap token lives in, and the two token resolvers built on
@@ -657,12 +673,7 @@ const ideasSyncEntry = {
657
673
  function addIssueFieldOptions(y) {
658
674
  return y.option("type", {
659
675
  type: "string",
660
- choices: [
661
- "bug",
662
- "feature",
663
- "task"
664
- ],
665
- describe: "The issue's kind: GitHub's issue Type, a label on Linear"
676
+ describe: "The issue's kind: bug, feature, task or a Type the organization declares (GitHub's issue Type, a label on Linear)"
666
677
  }).option("priority", {
667
678
  type: "string",
668
679
  choices: [
@@ -712,7 +723,9 @@ const ISSUE_FIELD_MENU_OPTIONS = [
712
723
  choices: [
713
724
  "bug",
714
725
  "feature",
715
- "task"
726
+ "task",
727
+ "epic",
728
+ "spike"
716
729
  ],
717
730
  message: "Kind of issue:"
718
731
  },
@@ -780,7 +793,7 @@ const ISSUE_FIELD_MENU_OPTIONS = [
780
793
  /** The issue-field flags that were given, in the words of the run functions; a flag not given is absent. */
781
794
  function readIssueFieldArgs(argv) {
782
795
  return {
783
- ...argv.type ? { kind: argv.type } : {},
796
+ ...argv.type ? { kind: argv.type.toLowerCase() } : {},
784
797
  ...argv.priority ? { priority: argv.priority } : {},
785
798
  ...argv.effort ? { effort: argv.effort } : {},
786
799
  ...argv.startDate ? { startDate: String(argv.startDate) } : {},
@@ -1711,7 +1724,11 @@ const setupEntry = {
1711
1724
  name: "setup",
1712
1725
  description: "Apply infra setup actions across every configured capability",
1713
1726
  positionals: [],
1714
- skipOptions: ["repo", "hooks"],
1727
+ skipOptions: [
1728
+ "repo",
1729
+ "hooks",
1730
+ "yes"
1731
+ ],
1715
1732
  supportsDryRun: true
1716
1733
  };
1717
1734
  // src/commands/skills/skills-install.entry.ts
@@ -1857,7 +1874,9 @@ const startWorkEntry = {
1857
1874
  choices: [
1858
1875
  "bug",
1859
1876
  "feature",
1860
- "task"
1877
+ "task",
1878
+ "epic",
1879
+ "spike"
1861
1880
  ],
1862
1881
  message: "Kind of issue:"
1863
1882
  },
@@ -2128,6 +2147,7 @@ const registry = createCommandRegistry([
2128
2147
  doctorWorkersEntry,
2129
2148
  projectMoveEntry,
2130
2149
  repoPropertiesApplyEntry,
2150
+ applyIssueTypesEntry,
2131
2151
  migrateIssueEntry,
2132
2152
  migrateIssuesEntry,
2133
2153
  migrateProjectEntry,
@@ -2530,17 +2550,6 @@ const endSession = telemetry.endSession;
2530
2550
  /** Drain both sinks and return to the no-ops. */
2531
2551
  const flush = telemetry.flush;
2532
2552
  telemetry.resetTelemetry;
2533
- // src/commands/group-menu/group-menu.ts
2534
- /** Layer 2: a bare group command (`holocron repo`, `holocron upgrade`, …) opens the menu at that level. */
2535
- async function launchGroupMenu(parent, argv) {
2536
- await launchMenu(COMMAND_REGISTRY, argv, {
2537
- pickMessage: `${parent} — choose a subcommand:`,
2538
- nonInteractiveMessage: `Run \`holocron ${parent} --help\` to see available ${parent} subcommands.`,
2539
- startPath: parent.split(" ")
2540
- });
2541
- }
2542
- /** The hidden `$0` of a command group: bare `holocron <group>` opens the menu at that group. */
2543
- const groupMenu = (parent) => groupMenu$1(parent, launchGroupMenu);
2544
2553
  // src/credentials-environments/derives-environment/derives-environment.ts
2545
2554
  /** The providers whose `credentials` entry may leave `environment` out and have it derived (#2063). */
2546
2555
  const DERIVING = /* @__PURE__ */ new Set(["1password"]);
@@ -2694,6 +2703,73 @@ function validateEnvironmentChoice(entry, what, required = true) {
2694
2703
  }
2695
2704
  if (required) throw new ConfigError$1(`${what} needs the name of a vault environment (\`environment\`) or a \`layer\``);
2696
2705
  }
2706
+ // src/config/validate-issue-types/validate-issue-types.ts
2707
+ /** The colour words GitHub's issue Types take. */
2708
+ const ISSUE_TYPE_COLORS = [
2709
+ "gray",
2710
+ "blue",
2711
+ "green",
2712
+ "yellow",
2713
+ "orange",
2714
+ "red",
2715
+ "pink",
2716
+ "purple"
2717
+ ];
2718
+ /** The Conventional Commit types a Type's `commit` may name (the ones `start work` and commitlint know). */
2719
+ const COMMIT_TYPES = [
2720
+ "feat",
2721
+ "fix",
2722
+ "chore",
2723
+ "docs",
2724
+ "refactor",
2725
+ "perf",
2726
+ "test",
2727
+ "ci",
2728
+ "build",
2729
+ "style",
2730
+ "revert"
2731
+ ];
2732
+ const isObject$3 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
2733
+ const KEYS$1 = [
2734
+ "name",
2735
+ "description",
2736
+ "color",
2737
+ "enabled",
2738
+ "label",
2739
+ "commit"
2740
+ ];
2741
+ /**
2742
+ * Checks the organization's `issueTypes` list (spec `tech-org-issue-types`, #2512) and returns it. `at` names where it
2743
+ * came from (`.holocron/org.ts` or `issueTypes`) so the error says which file to fix. A name that repeats ignoring
2744
+ * case, a `color` that is not one of GitHub's eight words, a `commit` that is not a Conventional Commit type, a key
2745
+ * the list does not know or a value that is not text is a {@link ConfigError} naming the entry.
2746
+ */
2747
+ function validateIssueTypes(value, at = "issueTypes") {
2748
+ if (!Array.isArray(value)) throw new ConfigError$1(`${at} must be a list of { name, description?, color?, ... }`);
2749
+ const seen = /* @__PURE__ */ new Set();
2750
+ return value.map((entry, index) => {
2751
+ const where = `${at}[${index}]`;
2752
+ if (!isObject$3(entry)) throw new ConfigError$1(`${where} must be an object with a "name"`);
2753
+ for (const key of Object.keys(entry)) if (!KEYS$1.includes(key)) throw new ConfigError$1(`${where}: "${key}" is not an issue Type option. Known: ${KEYS$1.join(", ")}`);
2754
+ const { name, description, color, enabled, label, commit } = entry;
2755
+ if (typeof name !== "string" || name.trim() === "") throw new ConfigError$1(`${where}: "name" must be a non-empty string`);
2756
+ const key = name.trim().toLowerCase();
2757
+ if (seen.has(key)) throw new ConfigError$1(`${where}: the name "${name}" repeats an earlier Type (names are compared ignoring case)`);
2758
+ seen.add(key);
2759
+ for (const [option, text] of [["description", description], ["label", label]]) if (text !== void 0 && (typeof text !== "string" || text.trim() === "")) throw new ConfigError$1(`${where}: "${option}" must be a non-empty string`);
2760
+ if (color !== void 0 && !ISSUE_TYPE_COLORS.includes(color)) throw new ConfigError$1(`${where}: "color" must be one of ${ISSUE_TYPE_COLORS.join(", ")}, got ${JSON.stringify(color)}`);
2761
+ if (commit !== void 0 && !COMMIT_TYPES.includes(commit)) throw new ConfigError$1(`${where}: "commit" must be a Conventional Commit type (${COMMIT_TYPES.join(", ")}), got ${JSON.stringify(commit)}`);
2762
+ if (enabled !== void 0 && typeof enabled !== "boolean") throw new ConfigError$1(`${where}: "enabled" must be true or false`);
2763
+ return {
2764
+ name: name.trim(),
2765
+ ...description !== void 0 ? { description } : {},
2766
+ ...color !== void 0 ? { color } : {},
2767
+ ...enabled !== void 0 ? { enabled } : {},
2768
+ ...label !== void 0 ? { label } : {},
2769
+ ...commit !== void 0 ? { commit } : {}
2770
+ };
2771
+ });
2772
+ }
2697
2773
  // src/config/validate-repo-labels/validate-repo-labels.ts
2698
2774
  /** What an area name may be: the rest of `area:<name>`, so no colon, comma, space or leading symbol. */
2699
2775
  const AREA_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
@@ -3039,6 +3115,7 @@ function resolveConfig(raw) {
3039
3115
  if (raw.dev !== void 0) validateDev(raw.dev);
3040
3116
  if (raw.githubApps !== void 0) validateGitHubApps(raw.githubApps);
3041
3117
  if (raw.ideas !== void 0) validateIdeas(raw.ideas);
3118
+ if (raw.issueTypes !== void 0) validateIssueTypes(raw.issueTypes);
3042
3119
  validateRepoLabels(raw.repo?.labels);
3043
3120
  validateVariablesSync(raw.repo?.variables);
3044
3121
  validateSecretsDeploy(raw.repo?.secrets);
@@ -3058,6 +3135,7 @@ function resolveConfig(raw) {
3058
3135
  homepage,
3059
3136
  org: raw.org,
3060
3137
  domain: raw.domain,
3138
+ issueTypes: raw.issueTypes,
3061
3139
  repo: raw.repo,
3062
3140
  repoValidation: raw.repoValidation,
3063
3141
  tasks: raw.tasks,
@@ -3284,8 +3362,9 @@ const isTuple = (entry) => Array.isArray(entry) && entry.length === 2 && typeof
3284
3362
  */
3285
3363
  function validate(area) {
3286
3364
  if (!isObject$2(area.value)) throw new ConfigError$1(`${area.path} must export the org settings as an object`);
3287
- const { domain, ...rest } = area.value;
3365
+ const { domain, issueTypes, ...rest } = area.value;
3288
3366
  if (domain !== void 0 && (typeof domain !== "string" || domain === "")) throw new ConfigError$1(`${area.path}: "domain" must be a non-empty string`);
3367
+ const types = issueTypes === void 0 ? void 0 : validateIssueTypes(issueTypes, `${area.path}: issueTypes`);
3289
3368
  for (const [provider, options] of Object.entries(rest)) {
3290
3369
  const allowed = ORG_OPTIONS[provider];
3291
3370
  if (allowed === void 0) throw new ConfigError$1(`${area.path} has an unknown provider "${provider}". Known: ${Object.keys(ORG_OPTIONS).join(", ")}`);
@@ -3297,6 +3376,7 @@ function validate(area) {
3297
3376
  }
3298
3377
  return {
3299
3378
  ...domain !== void 0 ? { domain } : {},
3379
+ ...types !== void 0 ? { issueTypes: types } : {},
3300
3380
  providers: rest
3301
3381
  };
3302
3382
  }
@@ -3307,12 +3387,17 @@ function validate(area) {
3307
3387
  function merge(area) {
3308
3388
  const providers = {};
3309
3389
  let domain;
3390
+ let issueTypes;
3310
3391
  for (const layer of area.root ? [area.root, area] : [area]) {
3311
3392
  const checked = validate(layer);
3312
3393
  if (checked.domain !== void 0) domain = {
3313
3394
  value: checked.domain,
3314
3395
  path: layer.path
3315
3396
  };
3397
+ if (checked.issueTypes !== void 0) issueTypes = {
3398
+ value: checked.issueTypes,
3399
+ path: layer.path
3400
+ };
3316
3401
  for (const [provider, options] of Object.entries(checked.providers)) {
3317
3402
  const sourced = providers[provider] ??= {};
3318
3403
  for (const [option, value] of Object.entries(options)) sourced[option] = {
@@ -3323,6 +3408,7 @@ function merge(area) {
3323
3408
  }
3324
3409
  return {
3325
3410
  ...domain ? { domain } : {},
3411
+ ...issueTypes ? { issueTypes } : {},
3326
3412
  providers
3327
3413
  };
3328
3414
  }
@@ -3343,7 +3429,8 @@ function fill(entry, org, capability) {
3343
3429
  }
3344
3430
  /**
3345
3431
  * Fill `.holocron/org.*` into the config. Its top-level `domain` (the org's zone) is set on a config that leaves
3346
- * `domain` out; set inline and in the file it is a `ConfigError` naming both. Its provider options go into the
3432
+ * `domain` out; set inline and in the file it is a `ConfigError` naming both. Its `issueTypes` (#2512) are placed the
3433
+ * same way, a list that the subdirectory file replaces whole. Its provider options go into the
3347
3434
  * providers the config uses. A provider entry (a name, a
3348
3435
  * `[name, options]` tuple, or either inside a list) that names a provider the file holds gets each option it leaves
3349
3436
  * out. An option set inline and in the file is a `ConfigError` naming both (no merge, no precedence); a provider the
@@ -3352,10 +3439,15 @@ function fill(entry, org, capability) {
3352
3439
  * option by option and the config's own file wins; that is not an error.
3353
3440
  */
3354
3441
  function placeOrg(raw, area) {
3355
- const { domain, providers: org } = merge(area);
3442
+ const { domain, issueTypes, providers: org } = merge(area);
3356
3443
  if (domain !== void 0 && raw.domain !== void 0) throw new ConfigError$1(`domain is set in the config and in ${domain.path}. Set it in one place: remove the inline value or the key from ${domain.path}`);
3357
- const withDomain = domain === void 0 ? raw : {
3444
+ if (issueTypes !== void 0 && raw.issueTypes !== void 0) throw new ConfigError$1(`issueTypes is set in the config and in ${issueTypes.path}. Set it in one place: remove the inline value or the key from ${issueTypes.path}`);
3445
+ const withTypes = issueTypes === void 0 ? raw : {
3358
3446
  ...raw,
3447
+ issueTypes: issueTypes.value
3448
+ };
3449
+ const withDomain = domain === void 0 ? withTypes : {
3450
+ ...withTypes,
3359
3451
  domain: domain.value
3360
3452
  };
3361
3453
  if (withDomain.providers === void 0) return withDomain;
@@ -3729,6 +3821,7 @@ const system = createPluginSystem({
3729
3821
  ...config.repo?.name ? { repo: config.repo.name } : {},
3730
3822
  ...config.repoValidation?.docsCoverage ? { docsCoverage: config.repoValidation.docsCoverage } : {},
3731
3823
  ...config.repo?.labels ? { areaLabels: config.repo.labels } : {},
3824
+ ...config.issueTypes ? { issueTypes: config.issueTypes } : {},
3732
3825
  ...context,
3733
3826
  ...effectiveToken !== void 0 ? { cliToken: effectiveToken } : {},
3734
3827
  cliTokens: void 0,
@@ -3849,6 +3942,190 @@ function actionsOf(plugin) {
3849
3942
  ...plugin.doctor ? { doctor: plugin.doctor } : {}
3850
3943
  };
3851
3944
  }
3945
+ // src/commands/issue-types/classify-type-error/classify-type-error.ts
3946
+ /** Reads a thrown error as one of the four things `ensureIssueTypes()` acts on differently. */
3947
+ function classifyTypeError(err) {
3948
+ if (!(err instanceof ProviderApiError)) return "other";
3949
+ if (err.status === 429 || err.status === 403 && /rate limit/i.test(`${err.message} ${String(err.details)}`)) return "rate-limit";
3950
+ if (err.status === 401 || err.status === 403) return "refused";
3951
+ if (err.status === 409 || err.status === 422) return "conflict";
3952
+ return "other";
3953
+ }
3954
+ // src/commands/issue-types/plan-issue-types/plan-issue-types.ts
3955
+ /**
3956
+ * Compares the declared Types with the organization's, by name ignoring case. A missing one is made; with `update` an
3957
+ * existing one whose stated description or colour differs is updated (only those two fields, only when the declaration
3958
+ * states them). `enabled` and the name are never compared: a Type is never renamed, turned on or off, or deleted.
3959
+ */
3960
+ function planIssueTypes(declared, existing, update) {
3961
+ const byName = new Map(existing.map((t) => [t.name.toLowerCase(), t]));
3962
+ const actions = declared.map((d) => {
3963
+ const have = byName.get(d.name.toLowerCase());
3964
+ if (!have) return {
3965
+ kind: "create",
3966
+ declared: d
3967
+ };
3968
+ const changes = [];
3969
+ if (update) {
3970
+ if (d.description !== void 0 && d.description !== (have.description ?? "")) changes.push({
3971
+ field: "description",
3972
+ was: have.description ?? "",
3973
+ to: d.description
3974
+ });
3975
+ if (d.color !== void 0 && d.color !== (have.color ?? "")) changes.push({
3976
+ field: "color",
3977
+ was: have.color ?? "",
3978
+ to: d.color
3979
+ });
3980
+ }
3981
+ return changes.length > 0 ? {
3982
+ kind: "update",
3983
+ declared: d,
3984
+ existing: have,
3985
+ changes
3986
+ } : {
3987
+ kind: "exists",
3988
+ declared: d,
3989
+ existing: have
3990
+ };
3991
+ });
3992
+ return {
3993
+ actions,
3994
+ total: existing.length + actions.filter((a) => a.kind === "create").length
3995
+ };
3996
+ }
3997
+ const WRITE_PERMISSION = "creating or changing issue Types needs an organization admin and the organization permission Issue types: write (HOLOCRON_ORG_TOKEN)";
3998
+ const READ_PERMISSION = "reading the organization's issue Types needs the organization permission Issue types: read (HOLOCRON_ORG_TOKEN)";
3999
+ const row$33 = (id, title, status, detail, problems = []) => ({
4000
+ id: `issue-types:${id}`,
4001
+ title,
4002
+ status,
4003
+ detail,
4004
+ problems
4005
+ });
4006
+ const toDeclaration = (t) => ({
4007
+ name: t.name,
4008
+ ...t.description !== void 0 ? { description: t.description } : {},
4009
+ ...t.color !== void 0 ? { color: t.color } : {},
4010
+ ...t.enabled !== void 0 ? { enabled: t.enabled } : {}
4011
+ });
4012
+ /** Reads the declared Types against the organization and, unless `dryRun`, writes the difference. See the file comment. */
4013
+ async function ensureIssueTypes(input) {
4014
+ const created = [];
4015
+ const updated = [];
4016
+ const refused = input.caller === "setup" ? "skip" : "fail";
4017
+ const stop = (status, detail, problems = []) => ({
4018
+ status,
4019
+ rows: [row$33("types", "issue types", status, detail, problems)],
4020
+ created,
4021
+ updated
4022
+ });
4023
+ const declared = input.declared ?? [];
4024
+ if (declared.length === 0) return stop("skip", "no issueTypes declared in the org area");
4025
+ const issues = input.issues;
4026
+ if (!issues) return stop(refused, input.missingReason ?? "no `issues` provider to read the Types with");
4027
+ if (!issues.listTypes || !issues.createType) return stop("skip", `the \`${issues.providerName}\` provider has no issue Types`);
4028
+ let existing;
4029
+ try {
4030
+ existing = await issues.listTypes();
4031
+ } catch (err) {
4032
+ return stop(refused, classifyTypeError(err) === "refused" ? READ_PERMISSION : describeError(err));
4033
+ }
4034
+ if (existing === void 0) return stop(refused, `cannot read the organization's issue Types: ${READ_PERMISSION}`);
4035
+ const plan = planIssueTypes(declared, existing, input.update);
4036
+ const creates = plan.actions.filter((a) => a.kind === "create");
4037
+ if (creates.length > 0 && plan.total > 25) return stop(refused, `${existing.length} Types exist and ${creates.length} more would be made: ${plan.total} is over the limit of 25; nothing was written`);
4038
+ const todo = plan.actions.filter((a) => a.kind !== "exists");
4039
+ if (input.dryRun || todo.length === 0) {
4040
+ const rows = plan.actions.map((a) => describeAction(a));
4041
+ const names = (kind) => plan.actions.filter((a) => a.kind === kind).map((a) => a.declared.name);
4042
+ return {
4043
+ status: "ok",
4044
+ rows,
4045
+ created: input.dryRun ? names("create") : [],
4046
+ updated: input.dryRun ? names("update") : []
4047
+ };
4048
+ }
4049
+ if (!input.yes) {
4050
+ if (!(input.interactive ?? Boolean(process.stdin.isTTY))) {
4051
+ if (input.caller === "apply") throw new NonInteractiveError("`apply issue-types` changes the organization's issue Types; pass --yes to run it without asking");
4052
+ return stop("skip", "changing the organization's issue Types needs an answer: pass --yes");
4053
+ }
4054
+ if (!await (input.confirm ?? ((message) => confirm({
4055
+ message,
4056
+ default: false
4057
+ })))(`Change the organization's issue Types?\n${todo.map((a) => ` ${describeAction(a).detail} ${a.declared.name}`).join("\n")}`)) return {
4058
+ status: "cancelled",
4059
+ rows: [row$33("types", "issue types", "skip", "cancelled; nothing was changed")],
4060
+ created,
4061
+ updated
4062
+ };
4063
+ }
4064
+ const rows = [];
4065
+ let limited = false;
4066
+ let refusedOnce = false;
4067
+ for (const action of plan.actions) {
4068
+ const name = action.declared.name;
4069
+ if (action.kind === "exists") {
4070
+ rows.push(describeAction(action));
4071
+ continue;
4072
+ }
4073
+ if (limited) {
4074
+ rows.push(row$33(name, name, "skip", "left: stopped at a rate limit"));
4075
+ continue;
4076
+ }
4077
+ if (refusedOnce) {
4078
+ rows.push(row$33(name, name, refused, "not written: the token was refused"));
4079
+ continue;
4080
+ }
4081
+ try {
4082
+ if (action.kind === "create") {
4083
+ await issues.createType(toDeclaration(action.declared));
4084
+ created.push(name);
4085
+ rows.push(row$33(name, name, "ok", "created"));
4086
+ } else {
4087
+ const patch = Object.fromEntries(action.changes.map((c) => [c.field, c.to]));
4088
+ await issues.updateType?.(action.existing.id, patch);
4089
+ updated.push(name);
4090
+ rows.push(row$33(name, name, "ok", `updated ${action.changes.map((c) => c.field).join(", ")}`));
4091
+ }
4092
+ } catch (err) {
4093
+ const kind = classifyTypeError(err);
4094
+ if (kind === "rate-limit") {
4095
+ limited = true;
4096
+ rows.push(row$33(name, name, "fail", "rate limited: stopped; run it again to finish"));
4097
+ } else if (kind === "refused") {
4098
+ refusedOnce = true;
4099
+ rows.push(row$33(name, name, refused, WRITE_PERMISSION));
4100
+ } else if (kind === "conflict" && action.kind === "create" && await nowExists(issues, name)) rows.push(row$33(name, name, "ok", "exists (made in the meantime)"));
4101
+ else rows.push(row$33(name, name, "fail", describeError(err)));
4102
+ }
4103
+ }
4104
+ return {
4105
+ status: rows.some((r) => r.status === "fail") ? "fail" : rows.every((r) => r.status === "skip") ? "skip" : "ok",
4106
+ rows,
4107
+ created,
4108
+ updated
4109
+ };
4110
+ }
4111
+ /** After a 409 or 422 on create: whether the name is in the organization's list now. */
4112
+ async function nowExists(issues, name) {
4113
+ try {
4114
+ return (await issues.listTypes?.() ?? []).some((t) => t.name.toLowerCase() === name.toLowerCase());
4115
+ } catch {
4116
+ return false;
4117
+ }
4118
+ }
4119
+ /** The row of an action that is not carried out (a dry run, or the list shown before asking), or that needs none. */
4120
+ function describeAction(action) {
4121
+ const name = action.declared.name;
4122
+ if (action.kind === "create") return row$33(name, name, "skip", "would create");
4123
+ if (action.kind === "update") {
4124
+ const fields = action.changes.map((c) => c.field).join(", ");
4125
+ return row$33(name, name, "skip", `would update ${fields}`, action.changes.map((c) => `${c.field}: was ${JSON.stringify(c.was)}, to ${JSON.stringify(c.to)}`));
4126
+ }
4127
+ return row$33(name, name, "ok", action.existing.enabled ? "exists" : "exists (turned off in the organization)");
4128
+ }
3852
4129
  // src/commands/notifications-channel-add/private-host.ts
3853
4130
  /**
3854
4131
  * Whether a URL host is one an avatar redirect must never lead to: a name that means this machine or a private
@@ -4438,6 +4715,82 @@ function layoutSecretNames(layout) {
4438
4715
  const fromRoles = (layout.roles ?? []).flatMap((role) => role.secret ? [role.secret] : []);
4439
4716
  return [...fromChannels, ...fromRoles];
4440
4717
  }
4718
+ // src/commands/apply-issue-types/run-issue-types-apply/run-issue-types-apply.ts
4719
+ /**
4720
+ * `holocron apply issue-types` — make the organization's issue Types match the org area's `issueTypes`.
4721
+ *
4722
+ * The explicit, deliberate step beside `apply properties`: the Types are organization-wide, so it asks first (`--yes`
4723
+ * skips the question; without a terminal it refuses), `--dry-run` only reads, and it only ever adds a Type, or with
4724
+ * `--update` sets a differing description or colour. It never deletes, renames or turns a Type on or off. The work is
4725
+ * `ensureIssueTypes()`, which the `setup` step calls too.
4726
+ */
4727
+ async function runIssueTypesApply(input) {
4728
+ const print = input.print ?? ((line) => console.log(line));
4729
+ const declared = input.loaded.resolved.issueTypes;
4730
+ let issues;
4731
+ let missingReason;
4732
+ if (declared && declared.length > 0) {
4733
+ const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
4734
+ await loader.load();
4735
+ assertPluginsResolvable(loader, "apply issue-types");
4736
+ issues = loader.has("issues") ? loader.get("issues") : void 0;
4737
+ missingReason = whyMissing(loader, "issues", "no `issues` provider to read the Types with");
4738
+ }
4739
+ const report = await ensureIssueTypes({
4740
+ declared,
4741
+ issues,
4742
+ caller: "apply",
4743
+ update: input.update === true,
4744
+ dryRun: input.context.dryRun === true,
4745
+ ...missingReason !== void 0 ? { missingReason } : {},
4746
+ ...input.yes ? { yes: true } : {},
4747
+ ...input.interactive !== void 0 ? { interactive: input.interactive } : {},
4748
+ ...input.confirm ? { confirm: input.confirm } : {}
4749
+ });
4750
+ printCheckRows(report.rows, print);
4751
+ printCheckSummary(summariseChecks(report.rows), print);
4752
+ return report;
4753
+ }
4754
+ // src/commands/apply-issue-types/apply-issue-types.command.ts
4755
+ const applyIssueTypesCommand = {
4756
+ command: "issue-types",
4757
+ describe: "Make the organization's issue Types match the org area's issueTypes",
4758
+ builder: (y) => y.option("update", {
4759
+ type: "boolean",
4760
+ describe: "Also set the description and colour of a Type that exists and differs (never its name or whether it is on)"
4761
+ }).option("yes", {
4762
+ type: "boolean",
4763
+ describe: "Change without asking"
4764
+ }),
4765
+ handler: async (argv) => {
4766
+ const tokens = tokenContext(argv.token);
4767
+ if (!tokens) return;
4768
+ const loaded = await loadConfig(argv.cwd);
4769
+ applyResolvedConfig(argv, loaded.resolved);
4770
+ if ((await runIssueTypesApply({
4771
+ loaded,
4772
+ context: {
4773
+ repoRoot: argv.cwd,
4774
+ dryRun: argv.dryRun,
4775
+ ...tokens,
4776
+ org: resolveOrg(argv, loaded.resolved)
4777
+ },
4778
+ ...argv.update ? { update: true } : {},
4779
+ ...argv.yes ? { yes: true } : {}
4780
+ })).status === "fail") process.exitCode = 1;
4781
+ }
4782
+ };
4783
+ // src/commands/group-menu/group-menu.ts
4784
+ /** Layer 2: a bare group command (`holocron repo`, `holocron upgrade`, …) opens the menu at that level. */
4785
+ async function launchGroupMenu(parent, argv) {
4786
+ await launchMenu(COMMAND_REGISTRY, argv, {
4787
+ pickMessage: `${parent} — choose a subcommand:`,
4788
+ nonInteractiveMessage: `Run \`holocron ${parent} --help\` to see available ${parent} subcommands.`,
4789
+ startPath: parent.split(" ")
4790
+ });
4791
+ }
4792
+ /** The hidden `$0` of a command group: bare `holocron <group>` opens the menu at that group. */
4793
+ const groupMenu = (parent) => groupMenu$1(parent, launchGroupMenu);
4441
4794
  // src/commands/repo-properties/capability-property/capability-property.ts
4442
4795
  /** The organization's custom property that lists the capabilities a repo wires. */
4443
4796
  const CAPABILITIES_PROPERTY = "holocron_capabilities";
@@ -4546,7 +4899,7 @@ const repoPropertiesApplyCommand = {
4546
4899
  const applyCommand = {
4547
4900
  command: "apply",
4548
4901
  describe: "Apply organization-level settings the repo's config depends on",
4549
- builder: (y) => y.command(repoPropertiesApplyCommand).command(groupMenu("apply")),
4902
+ builder: (y) => y.command(repoPropertiesApplyCommand).command(applyIssueTypesCommand).command(groupMenu("apply")),
4550
4903
  handler: () => {}
4551
4904
  };
4552
4905
  // src/commands/auth/auth-check.args.ts
@@ -7333,11 +7686,18 @@ const TYPES = /* @__PURE__ */ new Set([
7333
7686
  "style",
7334
7687
  "revert"
7335
7688
  ]);
7336
- const KIND_TYPE = {
7689
+ /** The commit type of the core kinds, which hold with no declaration. A declared `commit` is added to it. */
7690
+ const CORE_KIND_TYPE = {
7337
7691
  bug: "fix",
7338
7692
  feature: "feat",
7339
7693
  task: "chore"
7340
7694
  };
7695
+ /** The commit type of each kind this run knows: the core three, then each declared Type's `commit` (#2512). */
7696
+ function kindCommitTypes(types) {
7697
+ const table = { ...CORE_KIND_TYPE };
7698
+ for (const t of types ?? []) if (t.commit) table[t.name.toLowerCase()] = t.commit;
7699
+ return table;
7700
+ }
7341
7701
  const LABEL_TYPE = {
7342
7702
  bug: "fix",
7343
7703
  enhancement: "feat",
@@ -7347,8 +7707,9 @@ const LABEL_TYPE = {
7347
7707
  /**
7348
7708
  * The Conventional Commit title of the work's pull request and, with no spec, of its first commit. semantic-release
7349
7709
  * reads the squashed title, so the type is chosen in order: the issue's kind (Bug `fix`, Feature `feat`, Task
7350
- * `chore`), the type the issue's own title starts with, a kind label (`bug`, `enhancement`, `documentation`,
7351
- * `chore`), then `chore`. The scope is the one the issue's title names. A spec-only pull request is `docs(specs)`.
7710
+ * `chore`, or a declared Type's `commit`), the type the issue's own title starts with, a kind label (`bug`,
7711
+ * `enhancement`, `documentation`, `chore`), then `chore`. A kind with no commit type (Epic, Spike) skips the labels:
7712
+ * the title's own prefix, else `chore`. The scope is the one the issue's title names. A spec-only pull request is `docs(specs)`.
7352
7713
  */
7353
7714
  function workTitle(input) {
7354
7715
  const clean = input.issueTitle.replace(/\p{Extended_Pictographic}|‍|️/gu, "").trim();
@@ -7365,7 +7726,9 @@ function workTitle(input) {
7365
7726
  reason
7366
7727
  });
7367
7728
  if (input.specOnly) return finish("docs", "the pull request carries only the spec", "specs");
7368
- if (input.kind) return finish(KIND_TYPE[input.kind], `the issue's kind is ${input.kind}`, scope);
7729
+ const kindType = input.kind ? (input.kindTypes ?? CORE_KIND_TYPE)[input.kind] ?? CORE_KIND_TYPE[input.kind] : void 0;
7730
+ if (input.kind && kindType) return finish(kindType, `the issue's kind is ${input.kind}`, scope);
7731
+ if (input.kind && !titleType) return finish("chore", `the issue's kind is ${input.kind}, which has no commit type; chore is the default`, scope);
7369
7732
  if (titleType) return finish(titleType, "the issue's title says so", scope);
7370
7733
  for (const label of input.labels ?? []) {
7371
7734
  const type = LABEL_TYPE[label.toLowerCase()];
@@ -7487,7 +7850,10 @@ async function runStartWork(input) {
7487
7850
  rows.push(row$28(key, "ok", `${issue.summary} (${issue.status})`));
7488
7851
  const named = workTitle({
7489
7852
  issueTitle: issue.summary,
7490
- ...input.kind ? { kind: input.kind } : {},
7853
+ ...input.kind ? {
7854
+ kind: input.kind,
7855
+ kindTypes: kindCommitTypes(input.loaded.resolved.issueTypes)
7856
+ } : {},
7491
7857
  labels: record?.labels ?? [],
7492
7858
  specOnly
7493
7859
  });
@@ -11170,7 +11536,7 @@ function errorsRows(found, providerName) {
11170
11536
  * integration and rule are `doctor notifications`' rows and are not repeated. A project the provider says is missing
11171
11537
  * fails; anything that cannot be read (no token, no `org`, a token without the alert scope) is a skip with the reason.
11172
11538
  */
11173
- const skip$1 = (detail) => ({
11539
+ const skip$2 = (detail) => ({
11174
11540
  id: "errors",
11175
11541
  title: "errors",
11176
11542
  status: "skip",
@@ -11186,16 +11552,16 @@ async function runDoctorErrors(input) {
11186
11552
  let rows;
11187
11553
  if (!loader.has("errors")) {
11188
11554
  const failure = loader.loadFailures().find((f) => f.key === "errors");
11189
- rows = [skip$1(failure ? `\`${failure.provider}\` failed to load: ${describeError(failure.error)}` : "no `errors` provider is configured in holocron.config.ts")];
11555
+ rows = [skip$2(failure ? `\`${failure.provider}\` failed to load: ${describeError(failure.error)}` : "no `errors` provider is configured in holocron.config.ts")];
11190
11556
  } else {
11191
11557
  const errors = loader.get("errors");
11192
- if (!errors.inspect) rows = [skip$1(`${errors.providerName} cannot read its organization`)];
11558
+ if (!errors.inspect) rows = [skip$2(`${errors.providerName} cannot read its organization`)];
11193
11559
  else {
11194
11560
  const layouts = (loader.has("notifications") ? loader.get("notifications") : []).flatMap((p) => p.layout ? [p.layout] : []);
11195
11561
  try {
11196
11562
  rows = errorsRows(await errors.inspect({ projects: declaredProjects$1(layouts) }), errors.providerName);
11197
11563
  } catch (err) {
11198
- rows = [skip$1(missingTokenReason(err) ?? `could not read ${errors.providerName}: ${describeError(err)}`)];
11564
+ rows = [skip$2(missingTokenReason(err) ?? `could not read ${errors.providerName}: ${describeError(err)}`)];
11199
11565
  }
11200
11566
  }
11201
11567
  }
@@ -15616,6 +15982,89 @@ function coverageStatusContexts(input) {
15616
15982
  documentation
15617
15983
  });
15618
15984
  }
15985
+ // src/commands/doctor-repo/issue-types-check/issue-types-check.ts
15986
+ const lower = (value) => value.toLowerCase();
15987
+ /**
15988
+ * Compares the issue Types the org area declares with the organization's own (spec `tech-org-issue-types`, section 5).
15989
+ * Pure: names, descriptions and colour words only. A declared Type the organization lacks is the one problem
15990
+ * (`holocron apply issue-types` or `setup` makes it); everything else is an `info` note, never a failure, because a
15991
+ * description, colour or switch can be changed by a person on purpose and a Type nobody declared is not wrong. Names
15992
+ * match ignoring case; a field the declaration leaves out is not compared.
15993
+ */
15994
+ function compareIssueTypes(declared, actual) {
15995
+ const have = new Map(actual.map((t) => [lower(t.name), t]));
15996
+ const wanted = new Set(declared.map((t) => lower(t.name)));
15997
+ const problems = [];
15998
+ const info = [];
15999
+ for (const type of declared) {
16000
+ const found = have.get(lower(type.name));
16001
+ if (!found) {
16002
+ problems.push(`missing issue Type ${type.name}; run \`holocron apply issue-types\` (or \`holocron setup\`)`);
16003
+ continue;
16004
+ }
16005
+ if (type.description !== void 0 && type.description !== (found.description ?? "")) info.push(`${type.name} description was ${JSON.stringify(found.description ?? "")}, declared ${JSON.stringify(type.description)}; \`holocron apply issue-types --update\` sets it`);
16006
+ if (type.color !== void 0 && lower(type.color) !== lower(found.color ?? "")) info.push(`${type.name} colour was ${found.color ?? "none"}, declared ${type.color}; \`holocron apply issue-types --update\` sets it`);
16007
+ if (!found.enabled && type.enabled !== false) info.push(`${type.name} is turned off in the organization's settings`);
16008
+ }
16009
+ for (const type of actual) if (!wanted.has(lower(type.name))) info.push(`${type.name} is not declared in \`issueTypes\``);
16010
+ return {
16011
+ problems,
16012
+ checked: declared.length,
16013
+ info
16014
+ };
16015
+ }
16016
+ // src/commands/doctor-repo/issue-types-check/issue-types-row.ts
16017
+ const base = {
16018
+ id: "issue-types",
16019
+ title: "issue Types match the declaration"
16020
+ };
16021
+ const UNREADABLE = "the organization's issue Types cannot be read with this token (it needs the organization's Issue types: read permission)";
16022
+ const skip$1 = (detail) => ({
16023
+ ...base,
16024
+ status: "skip",
16025
+ detail,
16026
+ problems: []
16027
+ });
16028
+ /**
16029
+ * The `issue-types` row of `doctor repo` (spec `tech-org-issue-types`, section 5): the declaration against the
16030
+ * organization's Types, read through the `issues` provider. Every way it cannot be read (no declaration, no
16031
+ * provider, no `listTypes`, no token, a 401 or 403, an unreadable list) is a skip with the reason; only an error that
16032
+ * is not about access fails. Names and counts only, never a token or an id.
16033
+ */
16034
+ async function issueTypesRow(declared, issues, whyNoIssues) {
16035
+ if (!declared || declared.length === 0) return skip$1("no `issueTypes` declared in the org area");
16036
+ if (!issues) return skip$1(whyNoIssues);
16037
+ if (typeof issues.listTypes !== "function") return skip$1("provider does not implement listTypes");
16038
+ let found;
16039
+ try {
16040
+ found = await issues.listTypes();
16041
+ } catch (err) {
16042
+ const noToken = missingTokenReason(err);
16043
+ if (noToken !== void 0) return skip$1(noToken);
16044
+ if (err instanceof ProviderApiError && (err.status === 401 || err.status === 403)) return skip$1(UNREADABLE);
16045
+ return {
16046
+ ...base,
16047
+ status: "fail",
16048
+ detail: errorMessage(err),
16049
+ problems: []
16050
+ };
16051
+ }
16052
+ if (found === void 0) return skip$1(UNREADABLE);
16053
+ const result = compareIssueTypes(declared, found);
16054
+ const note = result.info && result.info.length > 0 ? `; info: ${result.info.join("; ")}` : "";
16055
+ if (result.problems.length > 0) return {
16056
+ ...base,
16057
+ status: "fail",
16058
+ detail: `${result.problems.length} problem(s)${note}`,
16059
+ problems: result.problems
16060
+ };
16061
+ return {
16062
+ ...base,
16063
+ status: "ok",
16064
+ detail: `${result.checked} of ${result.checked} match${note}`,
16065
+ problems: []
16066
+ };
16067
+ }
15619
16068
  // src/commands/repo-files/hosted-reusables.ts
15620
16069
  /** The name of the private package that holds the reusable workflows and composite actions. */
15621
16070
  const CI_PACKAGE = "@theholocron/ci";
@@ -15906,11 +16355,6 @@ const CANONICAL_LABELS = [
15906
16355
  color: "a2eeef",
15907
16356
  description: "New feature or request"
15908
16357
  },
15909
- {
15910
- name: "epic",
15911
- color: "5319e7",
15912
- description: "A body of work made of several issues"
15913
- },
15914
16358
  {
15915
16359
  name: "good first issue",
15916
16360
  color: "7057ff",
@@ -16311,6 +16755,7 @@ async function runDoctorRepo(input) {
16311
16755
  }
16312
16756
  }
16313
16757
  }
16758
+ rows.push(await issueTypesRow(input.loaded.resolved.issueTypes, loader.has("issues") ? loader.get("issues") : void 0, whyMissing(loader, "issues", "no `issues` provider to read the issue Types with")));
16314
16759
  printCheckRows(rows, print);
16315
16760
  const summary = summariseChecks(rows);
16316
16761
  printCheckSummary(summary, print);
@@ -21979,6 +22424,41 @@ function errorsEnvKeys(described, stack) {
21979
22424
  unknown
21980
22425
  };
21981
22426
  }
22427
+ // src/commands/setup/issue-types-step/issue-types-step.ts
22428
+ function toStatus(row, dryRun) {
22429
+ if (row.status === "fail") return "fail";
22430
+ if (row.status === "skip") return dryRun && row.detail.startsWith("would") ? "dry-run" : "skip";
22431
+ return "ok";
22432
+ }
22433
+ /**
22434
+ * `holocron setup`'s step for the organization's issue Types (spec `tech-org-issue-types`, #2512): make each Type the
22435
+ * org area's `issueTypes` declares, through `ensureIssueTypes()` as the `setup` caller. It only adds a missing Type
22436
+ * (never `update`, never deletes), and a refusal, an unreadable list, the limit or no terminal without `--yes` is a
22437
+ * skip row, never a failure, so a contributor without the organization permission still gets a passing `setup`.
22438
+ * Nothing declared, no steps: setup's output is unchanged. `holocron apply issue-types` is the deliberate version.
22439
+ */
22440
+ async function issueTypesStep(input) {
22441
+ if (!input.declared || input.declared.length === 0) return [];
22442
+ const { loader } = input;
22443
+ const issues = loader.has("issues") ? loader.get("issues") : void 0;
22444
+ const missingReason = whyMissing(loader, "issues", "no `issues` provider to read the Types with");
22445
+ return (await ensureIssueTypes({
22446
+ declared: input.declared,
22447
+ issues,
22448
+ caller: "setup",
22449
+ update: false,
22450
+ dryRun: input.dryRun,
22451
+ missingReason,
22452
+ ...input.yes ? { yes: true } : {},
22453
+ ...input.interactive !== void 0 ? { interactive: input.interactive } : {},
22454
+ ...input.confirm ? { confirm: input.confirm } : {}
22455
+ })).rows.map((row) => ({
22456
+ capability: "issues",
22457
+ step: row.id === "issue-types:types" ? "issue types" : `issue type ${row.title}`,
22458
+ status: toStatus(row, input.dryRun),
22459
+ message: [row.detail, ...row.problems].filter(Boolean).join("; ")
22460
+ }));
22461
+ }
21982
22462
  // src/commands/setup/run-step/run-step.ts
21983
22463
  async function runStep(capability, step, dryRun, body, opts = {}) {
21984
22464
  const { result, logged } = await execStep(capability, step, dryRun, body, opts);
@@ -22904,6 +23384,21 @@ async function runSetup(input) {
22904
23384
  print(formatStep(step));
22905
23385
  }
22906
23386
  }
23387
+ const issueTypeSteps = await issueTypesStep({
23388
+ declared: config.issueTypes,
23389
+ loader,
23390
+ dryRun,
23391
+ ...input.yes ? { yes: true } : {},
23392
+ ...input.interactive !== void 0 ? { interactive: input.interactive } : {},
23393
+ ...input.confirm ? { confirm: input.confirm } : {}
23394
+ });
23395
+ if (issueTypeSteps.length > 0) {
23396
+ print(style.step("issue types"));
23397
+ for (const step of issueTypeSteps) {
23398
+ steps.push(step);
23399
+ print(formatStep(step));
23400
+ }
23401
+ }
22907
23402
  if (loader.has("monitoring")) {
22908
23403
  const monitoring = loader.get("monitoring");
22909
23404
  print(style.step("monitoring"));
@@ -24689,6 +25184,28 @@ const ideasPromoteCommand = {
24689
25184
  })).status === "fail") process.exitCode = 1;
24690
25185
  }
24691
25186
  };
25187
+ // src/commands/issue-fields/issue-kinds/issue-kinds.ts
25188
+ /** The kinds the CLI always knows (GitHub's default issue Types), whatever the organization declares. */
25189
+ const CORE_KINDS = [
25190
+ "bug",
25191
+ "feature",
25192
+ "task"
25193
+ ];
25194
+ /**
25195
+ * The kinds `--type` accepts (spec `tech-org-issue-types`, #2512): the core three, then each declared Type's name in
25196
+ * lower case, in the declaration's order. A declared name equal to a core one is that core kind, so it is listed once.
25197
+ * This is the one place the list is built.
25198
+ */
25199
+ function issueKinds(types) {
25200
+ return [.../* @__PURE__ */ new Set([...CORE_KINDS, ...(types ?? []).map((t) => t.name.toLowerCase())])];
25201
+ }
25202
+ /** What is wrong with a `--type` value, or `undefined` when it is a kind this run knows. Case is ignored. */
25203
+ function kindProblem(value, types) {
25204
+ if (value === void 0) return void 0;
25205
+ const kinds = issueKinds(types);
25206
+ if (kinds.includes(value.toLowerCase())) return void 0;
25207
+ return `--type ${JSON.stringify(value)} is not a kind this organization knows. Use one of: ${kinds.join(", ")}`;
25208
+ }
24692
25209
  // src/commands/issue-create/read-issue-body/read-issue-body.ts
24693
25210
  /**
24694
25211
  * The text of an issue from `--body-file`: a path (relative to `cwd`), or `-` for standard input. `read` is injected
@@ -24845,6 +25362,12 @@ const issueCreateCommand = {
24845
25362
  if (!tokens) return;
24846
25363
  const loaded = await loadConfig(argv.cwd);
24847
25364
  applyResolvedConfig(argv, loaded.resolved);
25365
+ const problem = kindProblem(argv.type, loaded.resolved.issueTypes);
25366
+ if (problem) {
25367
+ console.error(problem);
25368
+ process.exitCode = 1;
25369
+ return;
25370
+ }
24848
25371
  let body = argv.body;
24849
25372
  if (argv.bodyFile) try {
24850
25373
  body = readIssueBody(argv.bodyFile, argv.cwd);
@@ -25230,6 +25753,12 @@ const newWorkCommand = {
25230
25753
  if (!tokens) return;
25231
25754
  const loaded = await loadConfig(argv.cwd);
25232
25755
  applyResolvedConfig(argv, loaded.resolved);
25756
+ const problem = kindProblem(argv.type, loaded.resolved.issueTypes);
25757
+ if (problem) {
25758
+ console.error(problem);
25759
+ process.exitCode = 1;
25760
+ return;
25761
+ }
25233
25762
  let body = argv.body;
25234
25763
  if (argv.bodyFile) try {
25235
25764
  body = readIssueBody(argv.bodyFile, argv.cwd);
@@ -32257,6 +32786,10 @@ const setupArgs = (y) => y.option("repo", {
32257
32786
  type: "string",
32258
32787
  global: false,
32259
32788
  describe: "Repo coords (\"owner/name\"). Defaults to plugin-specific resolution."
32789
+ }).option("yes", {
32790
+ type: "boolean",
32791
+ global: false,
32792
+ describe: "Change the organization's issue Types without asking (only when the org area declares some)."
32260
32793
  }).option("hooks", {
32261
32794
  type: "boolean",
32262
32795
  global: false,
@@ -32281,7 +32814,8 @@ const setupCommand = {
32281
32814
  ...tokens,
32282
32815
  org: resolveOrg(argv, loaded.resolved)
32283
32816
  },
32284
- ...argv.hooks !== void 0 ? { hooks: argv.hooks } : {}
32817
+ ...argv.hooks !== void 0 ? { hooks: argv.hooks } : {},
32818
+ ...argv.yes ? { yes: true } : {}
32285
32819
  })).summary.fail > 0) process.exitCode = 1;
32286
32820
  }
32287
32821
  };
@@ -32345,12 +32879,7 @@ const startWorkCommand = {
32345
32879
  describe: "With --spec: one pull request for the spec and the code, titled like the code"
32346
32880
  }).option("type", {
32347
32881
  type: "string",
32348
- choices: [
32349
- "bug",
32350
- "feature",
32351
- "task"
32352
- ],
32353
- describe: "The issue's kind, deciding the commit type (default: its title and labels)"
32882
+ describe: "The issue's kind, deciding the commit type: bug, feature, task or a Type the organization declares (default: its title and labels)"
32354
32883
  }).option("effort", {
32355
32884
  type: "string",
32356
32885
  choices: [
@@ -32379,6 +32908,12 @@ const startWorkCommand = {
32379
32908
  if (!tokens) return;
32380
32909
  const loaded = await loadConfig(argv.cwd);
32381
32910
  applyResolvedConfig(argv, loaded.resolved);
32911
+ const problem = kindProblem(argv.type, loaded.resolved.issueTypes);
32912
+ if (problem) {
32913
+ console.error(problem);
32914
+ process.exitCode = 1;
32915
+ return;
32916
+ }
32382
32917
  if ((await runStartWork({
32383
32918
  issue: String(argv.issue),
32384
32919
  loaded,
@@ -32395,7 +32930,7 @@ const startWorkCommand = {
32395
32930
  ...argv.worktreePath ? { worktreePath: argv.worktreePath } : {},
32396
32931
  ...argv.spec ? { spec: argv.spec } : {},
32397
32932
  ...argv.onePr ? { onePr: true } : {},
32398
- ...argv.type ? { kind: argv.type } : {},
32933
+ ...argv.type ? { kind: argv.type.toLowerCase() } : {},
32399
32934
  ...argv.effort ? { effort: argv.effort } : {},
32400
32935
  ...argv.assignee ? { assignees: argv.assignee.map(String) } : {},
32401
32936
  ...argv.project ? { project: argv.project } : {},
@@ -35489,6 +36024,12 @@ const issueUpdateCommand = {
35489
36024
  if (!tokens) return;
35490
36025
  const loaded = await loadConfig(argv.cwd);
35491
36026
  applyResolvedConfig(argv, loaded.resolved);
36027
+ const problem = kindProblem(argv.type, loaded.resolved.issueTypes);
36028
+ if (problem) {
36029
+ console.error(problem);
36030
+ process.exitCode = 1;
36031
+ return;
36032
+ }
35492
36033
  let body = argv.body;
35493
36034
  if (argv.bodyFile) try {
35494
36035
  body = readIssueBody(argv.bodyFile, argv.cwd);
@@ -35590,6 +36131,12 @@ const updateWorkCommand = {
35590
36131
  if (!tokens) return;
35591
36132
  const loaded = await loadConfig(argv.cwd);
35592
36133
  applyResolvedConfig(argv, loaded.resolved);
36134
+ const problem = kindProblem(argv.type, loaded.resolved.issueTypes);
36135
+ if (problem) {
36136
+ console.error(problem);
36137
+ process.exitCode = 1;
36138
+ return;
36139
+ }
35593
36140
  if ((await runUpdateWork({
35594
36141
  issue: String(argv.issue),
35595
36142
  loaded,