@codedrifters/configulator 0.0.227 → 0.0.228

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/lib/index.mjs CHANGED
@@ -2190,6 +2190,148 @@ var companyProfileBundle = {
2190
2190
 
2191
2191
  // src/agent/bundles/github-workflow.ts
2192
2192
  import { GitHub } from "projen/lib/github";
2193
+ var setIssueTypeProcedure = {
2194
+ name: "set-issue-type.sh",
2195
+ description: "Assign a GitHub issue type (Feature / Task / Epic / Bug / etc.) via the updateIssueIssueType GraphQL mutation in a single step",
2196
+ content: [
2197
+ "#!/usr/bin/env bash",
2198
+ "# set-issue-type.sh \u2014 Assign a GitHub issue type in one step.",
2199
+ "#",
2200
+ "# Wraps the two-step GraphQL flow used to set an issue's type:",
2201
+ "# 1. Look up the repo's issue type node IDs.",
2202
+ "# 2. Call the updateIssueIssueType mutation.",
2203
+ "#",
2204
+ "# Usage:",
2205
+ "# .claude/procedures/set-issue-type.sh <issue-number> <type-name>",
2206
+ "#",
2207
+ "# Where <type-name> is the human-readable GitHub issue type name",
2208
+ "# (e.g. Feature, Task, Epic, Bug). Matching is case-insensitive.",
2209
+ "#",
2210
+ "# Exits 0 on success. Exits non-zero with a clear diagnostic on stderr",
2211
+ "# for any validation error or API failure.",
2212
+ "",
2213
+ "set -uo pipefail",
2214
+ "",
2215
+ "# \u2500\u2500 helpers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500",
2216
+ "",
2217
+ "err() {",
2218
+ ' printf "set-issue-type.sh: %s\\n" "$*" >&2',
2219
+ "}",
2220
+ "",
2221
+ "usage() {",
2222
+ " cat >&2 <<'USAGE'",
2223
+ "Usage: set-issue-type.sh <issue-number> <type-name>",
2224
+ "",
2225
+ " <issue-number> Positive integer GitHub issue number.",
2226
+ " <type-name> Human-readable issue type (Feature, Task, Epic, Bug,",
2227
+ " or any type defined at the org level). Case-insensitive.",
2228
+ "",
2229
+ "Examples:",
2230
+ " set-issue-type.sh 123 Feature",
2231
+ " set-issue-type.sh 456 bug",
2232
+ "USAGE",
2233
+ "}",
2234
+ "",
2235
+ "# \u2500\u2500 argument validation \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500",
2236
+ "",
2237
+ "if [[ $# -ne 2 ]]; then",
2238
+ ' err "expected 2 arguments, got $#"',
2239
+ " usage",
2240
+ " exit 2",
2241
+ "fi",
2242
+ "",
2243
+ 'issue_number="$1"',
2244
+ 'type_name="$2"',
2245
+ "",
2246
+ 'if ! [[ "$issue_number" =~ ^[1-9][0-9]*$ ]]; then',
2247
+ ` err "issue number must be a positive integer (got: '$issue_number')"`,
2248
+ " exit 2",
2249
+ "fi",
2250
+ "",
2251
+ 'if [[ -z "${type_name// /}" ]]; then',
2252
+ ' err "type name must be non-empty"',
2253
+ " exit 2",
2254
+ "fi",
2255
+ "",
2256
+ "# \u2500\u2500 dependency checks \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500",
2257
+ "",
2258
+ "for cmd in gh jq; do",
2259
+ ' if ! command -v "$cmd" >/dev/null 2>&1; then',
2260
+ ' err "required command not found on PATH: $cmd"',
2261
+ " exit 3",
2262
+ " fi",
2263
+ "done",
2264
+ "",
2265
+ "# \u2500\u2500 resolve repo owner/name \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500",
2266
+ "",
2267
+ "repo_json=$(gh repo view --json owner,name 2>/dev/null)",
2268
+ 'if [[ -z "$repo_json" ]]; then',
2269
+ ` err "could not resolve owning repo via 'gh repo view' (not a GitHub repo or gh not authenticated?)"`,
2270
+ " exit 4",
2271
+ "fi",
2272
+ "",
2273
+ `owner=$(echo "$repo_json" | jq -r '.owner.login // empty')`,
2274
+ `name=$(echo "$repo_json" | jq -r '.name // empty')`,
2275
+ "",
2276
+ 'if [[ -z "$owner" || -z "$name" ]]; then',
2277
+ ' err "could not parse owner/name from gh repo view output"',
2278
+ " exit 4",
2279
+ "fi",
2280
+ "",
2281
+ "# \u2500\u2500 look up issue type node ID \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500",
2282
+ "",
2283
+ "types_json=$(gh api graphql \\",
2284
+ " -f query='query($owner:String!,$repo:String!){repository(owner:$owner,name:$repo){issueTypes(first:50){nodes{id name}}}}' \\",
2285
+ ' -f owner="$owner" -f repo="$name" 2>/dev/null)',
2286
+ "",
2287
+ 'if [[ -z "$types_json" ]]; then',
2288
+ ' err "failed to query repo issue types via GraphQL"',
2289
+ " exit 5",
2290
+ "fi",
2291
+ "",
2292
+ `types_nodes=$(echo "$types_json" | jq -c '.data.repository.issueTypes.nodes // []')`,
2293
+ "",
2294
+ 'if [[ "$types_nodes" == "[]" || "$types_nodes" == "null" ]]; then',
2295
+ ' err "repo ${owner}/${name} has no issue types defined"',
2296
+ " exit 5",
2297
+ "fi",
2298
+ "",
2299
+ "# Case-insensitive match by name.",
2300
+ `type_id=$(echo "$types_nodes" | jq -r --arg n "$type_name" '`,
2301
+ " .[] | select((.name | ascii_downcase) == ($n | ascii_downcase)) | .id",
2302
+ "' | head -n 1)",
2303
+ "",
2304
+ 'if [[ -z "$type_id" ]]; then',
2305
+ ` available=$(echo "$types_nodes" | jq -r '.[].name' | paste -sd ',' - | sed 's/,/, /g')`,
2306
+ " err \"type '${type_name}' not found in ${owner}/${name}. Available types: ${available}\"",
2307
+ " exit 6",
2308
+ "fi",
2309
+ "",
2310
+ "# \u2500\u2500 look up issue node ID \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500",
2311
+ "",
2312
+ `issue_id=$(gh issue view "$issue_number" --json id -q '.id' 2>/dev/null || echo "")`,
2313
+ "",
2314
+ 'if [[ -z "$issue_id" ]]; then',
2315
+ ' err "issue #${issue_number} not found in ${owner}/${name}"',
2316
+ " exit 7",
2317
+ "fi",
2318
+ "",
2319
+ "# \u2500\u2500 apply the mutation \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500",
2320
+ "",
2321
+ "result=$(gh api graphql \\",
2322
+ " -f query='mutation($issueId:ID!,$typeId:ID!){updateIssueIssueType(input:{issueId:$issueId,issueTypeId:$typeId}){issue{number issueType{name}}}}' \\",
2323
+ ' -f issueId="$issue_id" -f typeId="$type_id" 2>&1)',
2324
+ "mutation_exit=$?",
2325
+ "",
2326
+ "if [[ $mutation_exit -ne 0 ]]; then",
2327
+ ' err "updateIssueIssueType mutation failed: ${result}"',
2328
+ " exit 8",
2329
+ "fi",
2330
+ "",
2331
+ "# Print the resulting {number, issueType: {name}} JSON line.",
2332
+ `echo "$result" | jq -c '.data.updateIssueIssueType.issue'`
2333
+ ].join("\n")
2334
+ };
2193
2335
  var githubWorkflowBundle = {
2194
2336
  name: "github-workflow",
2195
2337
  description: "GitHub issue and PR workflow automation patterns",
@@ -2252,19 +2394,20 @@ var githubWorkflowBundle = {
2252
2394
  " - `--title '<type>: <description>'`",
2253
2395
  " - `--body '<issue body>'`",
2254
2396
  " - `--label '<type-label>' --label '<priority-label>' --label '<status-label>'`",
2255
- "7. **Set the GitHub issue type** via the GraphQL `updateIssueIssueType` mutation:",
2256
- " - Look up the issue's node ID: `gh issue view <issue-number> --json id -q .id`",
2257
- " - Look up the repo's issue type node IDs (one-time, can be cached):",
2397
+ "7. **Set the GitHub issue type** by invoking the `set-issue-type.sh` helper (shipped with this bundle):",
2398
+ "",
2399
+ " ```sh",
2400
+ " .claude/procedures/set-issue-type.sh <issue-number> <Feature|Task|Epic|Bug>",
2401
+ " ```",
2258
2402
  "",
2259
- " ```sh",
2260
- " gh api graphql -f query='query($owner:String!,$repo:String!){repository(owner:$owner,name:$repo){issueTypes(first:20){nodes{id name}}}}' -f owner=<owner> -f repo=<repo>",
2261
- " ```",
2403
+ " The helper resolves owner/repo, looks up the issue type node ID, looks up the issue node ID, and applies the `updateIssueIssueType` mutation in one step. It exits non-zero with a clear diagnostic on any error and lists available types if the type name is not recognised.",
2262
2404
  "",
2263
- " - Apply the chosen type to the issue:",
2405
+ " **Under the hood** (documented fallback if the helper is unavailable): the helper performs a two-step GraphQL flow \u2014 first a `repository(...).issueTypes` query to map the human-readable type name to a node ID, then the `updateIssueIssueType` mutation. The canonical queries are:",
2264
2406
  "",
2265
- " ```sh",
2266
- " gh api graphql -f query='mutation($issueId:ID!,$typeId:ID!){updateIssueIssueType(input:{issueId:$issueId,issueTypeId:$typeId}){issue{number issueType{name}}}}' -f issueId=<issue-node-id> -f typeId=<issue-type-node-id>",
2267
- " ```",
2407
+ " ```sh",
2408
+ " gh api graphql -f query='query($owner:String!,$repo:String!){repository(owner:$owner,name:$repo){issueTypes(first:50){nodes{id name}}}}' -f owner=<owner> -f repo=<repo>",
2409
+ " gh api graphql -f query='mutation($issueId:ID!,$typeId:ID!){updateIssueIssueType(input:{issueId:$issueId,issueTypeId:$typeId}){issue{number issueType{name}}}}' -f issueId=<issue-node-id> -f typeId=<issue-type-node-id>",
2410
+ " ```",
2268
2411
  "",
2269
2412
  "### Issue Body Template",
2270
2413
  "",
@@ -2285,7 +2428,7 @@ var githubWorkflowBundle = {
2285
2428
  "### Important",
2286
2429
  "",
2287
2430
  "- Always use the conventional prefix in the issue title",
2288
- "- Always assign the correct GitHub issue type via the `updateIssueIssueType` GraphQL mutation (step 7) \u2014 never via `gh issue create --type`",
2431
+ "- Always assign the correct GitHub issue type via the `set-issue-type.sh` helper (step 7) \u2014 never via `gh issue create --type`",
2289
2432
  "- Always include `type:*`, `priority:*`, and `status:*` labels",
2290
2433
  "- If the user does not specify a type, ask before creating the issue",
2291
2434
  "- If the priority cannot be inferred from the description, ask the user before creating the issue",
@@ -2337,7 +2480,8 @@ var githubWorkflowBundle = {
2337
2480
  ].join("\n"),
2338
2481
  tags: ["workflow"]
2339
2482
  }
2340
- ]
2483
+ ],
2484
+ procedures: [setIssueTypeProcedure]
2341
2485
  };
2342
2486
 
2343
2487
  // src/agent/bundles/industry-discovery.ts