dev-loops 0.7.1 → 0.7.2

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 (86) hide show
  1. package/.claude/.claude-plugin/plugin.json +1 -1
  2. package/.claude/agents/dev-loop.md +7 -7
  3. package/.claude/agents/fixer.md +1 -0
  4. package/.claude/agents/refiner.md +2 -2
  5. package/.claude/agents/review.md +2 -2
  6. package/.claude/commands/loop-enqueue.md +1 -1
  7. package/.claude/commands/loop-info.md +1 -1
  8. package/.claude/commands/loop-start-spike.md +1 -1
  9. package/.claude/skills/copilot-pr-followup/SKILL.md +37 -23
  10. package/.claude/skills/dev-loop/SKILL.md +6 -6
  11. package/.claude/skills/docs/acceptance-criteria-verification.md +3 -2
  12. package/.claude/skills/docs/anti-patterns.md +3 -2
  13. package/.claude/skills/docs/artifact-authority-contract.md +12 -11
  14. package/.claude/skills/docs/confirmation-rules.md +1 -0
  15. package/.claude/skills/docs/contract-style-guide.md +37 -0
  16. package/.claude/skills/docs/copilot-loop-operations.md +18 -14
  17. package/.claude/skills/docs/cross-harness-regression-contract.md +2 -2
  18. package/.claude/skills/docs/debt-remediation-contract.md +1 -1
  19. package/.claude/skills/docs/epic-tree-refinement-procedure.md +25 -22
  20. package/.claude/skills/docs/issue-intake-procedure.md +25 -19
  21. package/.claude/skills/docs/merge-preconditions.md +13 -11
  22. package/.claude/skills/docs/pr-lifecycle-contract.md +44 -35
  23. package/.claude/skills/docs/public-dev-loop-contract.md +59 -43
  24. package/.claude/skills/docs/retrospective-checkpoint-contract.md +18 -5
  25. package/.claude/skills/docs/spike-mode-contract.md +14 -7
  26. package/.claude/skills/docs/stop-conditions.md +30 -15
  27. package/.claude/skills/docs/tracker-first-loop-state.md +13 -8
  28. package/.claude/skills/docs/validation-policy.md +4 -5
  29. package/.claude/skills/local-implementation/SKILL.md +48 -142
  30. package/CHANGELOG.md +6 -0
  31. package/agents/dev-loop.agent.md +8 -8
  32. package/agents/fixer.agent.md +1 -0
  33. package/agents/refiner.agent.md +2 -2
  34. package/agents/review.agent.md +2 -2
  35. package/package.json +5 -4
  36. package/scripts/_core-helpers.mjs +2 -0
  37. package/scripts/claude/headless-dev-loop.mjs +1 -1
  38. package/scripts/docs/validate-rule-ownership.mjs +442 -0
  39. package/scripts/docs/validate-state-machine-conformance.mjs +1092 -0
  40. package/scripts/github/_review-thread-mutations.mjs +5 -2
  41. package/scripts/github/create-pr.mjs +119 -10
  42. package/scripts/github/detect-checkpoint-evidence.mjs +102 -17
  43. package/scripts/github/list-review-threads.mjs +277 -0
  44. package/scripts/github/post-gate-findings.mjs +6 -3
  45. package/scripts/github/request-copilot-review.mjs +92 -26
  46. package/scripts/github/upsert-checkpoint-verdict.mjs +74 -5
  47. package/scripts/github/verify-briefing-prefixes.mjs +191 -0
  48. package/scripts/github/verify-fresh-review-context.mjs +78 -3
  49. package/scripts/github/wait-pr-checks.mjs +171 -0
  50. package/scripts/github/write-gate-context.mjs +213 -7
  51. package/scripts/github/write-gate-findings-log.mjs +54 -2
  52. package/scripts/loop/copilot-pr-handoff.mjs +29 -2
  53. package/scripts/loop/detect-change-scope.mjs +2 -2
  54. package/scripts/loop/detect-copilot-loop-state.mjs +23 -3
  55. package/scripts/loop/detect-pr-gate-coordination-state.mjs +35 -3
  56. package/scripts/loop/resolve-dev-loop-startup.mjs +145 -8
  57. package/scripts/loop/sanctioned-commands.mjs +2 -0
  58. package/scripts/loop/validate-pr-body-spec.mjs +21 -5
  59. package/scripts/pages/build-state-atlas.mjs +50 -48
  60. package/scripts/projects/_resolve-project.mjs +1 -148
  61. package/scripts/projects/list-queue-items.mjs +3 -377
  62. package/scripts/projects/move-queue-item.mjs +3 -410
  63. package/scripts/projects/reorder-queue-item.mjs +3 -22
  64. package/skills/copilot-pr-followup/SKILL.md +37 -23
  65. package/skills/dev-loop/SKILL.md +1 -1
  66. package/skills/docs/acceptance-criteria-verification.md +3 -2
  67. package/skills/docs/anti-patterns.md +3 -2
  68. package/skills/docs/artifact-authority-contract.md +12 -11
  69. package/skills/docs/confirmation-rules.md +1 -0
  70. package/skills/docs/contract-style-guide.md +37 -0
  71. package/skills/docs/copilot-loop-operations.md +18 -14
  72. package/skills/docs/cross-harness-regression-contract.md +2 -2
  73. package/skills/docs/debt-remediation-contract.md +1 -1
  74. package/skills/docs/epic-tree-refinement-procedure.md +25 -22
  75. package/skills/docs/issue-intake-procedure.md +25 -19
  76. package/skills/docs/merge-preconditions.md +13 -11
  77. package/skills/docs/pr-lifecycle-contract.md +44 -35
  78. package/skills/docs/public-dev-loop-contract.md +59 -43
  79. package/skills/docs/required-rules.json +149 -0
  80. package/skills/docs/retrospective-checkpoint-contract.md +18 -5
  81. package/skills/docs/spike-mode-contract.md +14 -7
  82. package/skills/docs/stop-conditions.md +30 -15
  83. package/skills/docs/tracker-first-loop-state.md +13 -8
  84. package/skills/docs/validation-policy.md +4 -5
  85. package/skills/local-implementation/SKILL.md +48 -142
  86. package/scripts/docs/validate-no-duplicate-rules.mjs +0 -250
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
- import { formatCliError, isDirectCliRun, parseJsonText } from "../_core-helpers.mjs";
3
- import { runChild as _runChild } from "../_cli-primitives.mjs";
4
- import { resolveProjectSelector, findProject, applyDevloopsBoard } from "./_resolve-project.mjs";
2
+ import { formatCliError, isDirectCliRun } from "../_core-helpers.mjs";
3
+ import { applyDevloopsBoard } from "./_resolve-project.mjs";
5
4
  import { parseArgs } from "node:util";
6
5
  import { JQ_OUTPUT_PARSE_OPTIONS, JQ_OUTPUT_USAGE, emitResult, matchJqOutputToken } from "../lib/jq-output.mjs";
6
+ import { main, classifyExitCode } from "@dev-loops/core/projects/move-queue-item";
7
7
 
8
8
  const USAGE = `Usage: dev-loops queue move --repo <owner/name> --project <number|id|board-uri> --item <number|node-id> --to-column <name>
9
9
  (dev-loops project move … is a back-compat alias)
@@ -92,413 +92,6 @@ function parseCliArgs(argv) {
92
92
  }
93
93
  return args;
94
94
  }
95
- // ── Validation ───────────────────────────────────────────────────────────
96
-
97
- const OWNER_RE = /^[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/;
98
- const REPO_NAME_RE = /^[a-zA-Z0-9](?:[a-zA-Z0-9_.-]*[a-zA-Z0-9])?$/;
99
- const GLOBAL_NODE_ID_RE = /^[A-Za-z0-9_]+$/;
100
-
101
- function validateRepo(repo) {
102
- if (!repo || typeof repo !== "string") {
103
- throw Object.assign(new Error("--repo is required"), { code: "INVALID_REPO" });
104
- }
105
- const trimmed = repo.trim();
106
- if (trimmed !== repo) {
107
- throw Object.assign(new Error(`--repo must not have leading/trailing whitespace, got "${repo}"`), { code: "INVALID_REPO" });
108
- }
109
- const slashIdx = repo.indexOf("/");
110
- if (slashIdx === -1) {
111
- throw Object.assign(new Error(`--repo must be exactly owner/name, got "${repo}"`), { code: "INVALID_REPO" });
112
- }
113
- const owner = repo.slice(0, slashIdx);
114
- const name = repo.slice(slashIdx + 1);
115
- if (!owner || !name || !OWNER_RE.test(owner) || !REPO_NAME_RE.test(name)) {
116
- throw Object.assign(new Error(`--repo must be exactly owner/name, got "${repo}"`), { code: "INVALID_REPO" });
117
- }
118
- return repo;
119
- }
120
-
121
- function parseItemRef(raw) {
122
- if (!raw || typeof raw !== "string" || raw.trim().length === 0) {
123
- throw Object.assign(new Error("--item is required"), { code: "INVALID_ITEM" });
124
- }
125
- const trimmed = raw.trim();
126
- const asNum = Number(trimmed);
127
- if (Number.isInteger(asNum) && asNum > 0 && String(asNum) === trimmed) {
128
- return { kind: "number", value: asNum };
129
- }
130
- if (trimmed === "0") {
131
- throw Object.assign(new Error(`--item must be a positive integer or an item node ID, got "${raw}"`), { code: "INVALID_ITEM" });
132
- }
133
- if (GLOBAL_NODE_ID_RE.test(trimmed)) {
134
- return { kind: "id", value: trimmed };
135
- }
136
- throw Object.assign(new Error(`--item must be a positive integer or an item node ID, got "${raw}"`), { code: "INVALID_ITEM" });
137
- }
138
-
139
- // ── API helpers ──────────────────────────────────────────────────────────
140
-
141
- async function ghGraphql(query, vars, env, runChild = _runChild) {
142
- const fieldArgs = [];
143
- for (const [key, value] of Object.entries(vars)) {
144
- fieldArgs.push("--field", `${key}=${value}`);
145
- }
146
- const result = await runChild(
147
- "gh",
148
- ["api", "graphql", "--field", `query=${query}`, ...fieldArgs],
149
- env,
150
- );
151
- if (result.code !== 0) {
152
- const detail = result.stderr.trim() || `exit code ${result.code}`;
153
- throw Object.assign(new Error(`gh api graphql failed: ${detail}`), { code: "GH_API_ERROR" });
154
- }
155
- const payload = parseJsonText(result.stdout);
156
- if (payload.errors && payload.errors.length > 0) {
157
- throw Object.assign(
158
- new Error(`GraphQL errors: ${payload.errors.map((e) => e.message).join("; ")}`),
159
- { code: "GRAPHQL_ERROR" },
160
- );
161
- }
162
- return payload;
163
- }
164
-
165
- // ── GraphQL fragments ────────────────────────────────────────────────────
166
-
167
- const GET_USER_ID = [
168
- "query($login:String!) {",
169
- " user(login:$login) { id }",
170
- "}"
171
- ].join("\n");
172
-
173
- const GET_ORG_ID = [
174
- "query($login:String!) {",
175
- " organization(login:$login) { id }",
176
- "}"
177
- ].join("\n");
178
-
179
- const LIST_USER_PROJECTS = [
180
- "query($login:String!, $after:String) {",
181
- " user(login:$login) {",
182
- " projectsV2(first:50, after:$after) {",
183
- " pageInfo { hasNextPage endCursor }",
184
- " nodes { id number title url }",
185
- " }",
186
- " }",
187
- "}"
188
- ].join("\n");
189
-
190
- const LIST_ORG_PROJECTS = [
191
- "query($login:String!, $after:String) {",
192
- " organization(login:$login) {",
193
- " projectsV2(first:50, after:$after) {",
194
- " pageInfo { hasNextPage endCursor }",
195
- " nodes { id number title url }",
196
- " }",
197
- " }",
198
- "}"
199
- ].join("\n");
200
-
201
- const GET_PROJECT_FIELDS = [
202
- "query($projectId:ID!, $after:String) {",
203
- " node(id:$projectId) {",
204
- " ... on ProjectV2 {",
205
- " fields(first:50, after:$after) {",
206
- " pageInfo { hasNextPage endCursor }",
207
- " nodes {",
208
- " ... on ProjectV2SingleSelectField {",
209
- " id name",
210
- " options { id name }",
211
- " }",
212
- " }",
213
- " }",
214
- " }",
215
- " }",
216
- "}"
217
- ].join("\n");
218
-
219
- const GET_PROJECT_ITEMS_BY_CONTENT = [
220
- "query($projectId:ID!, $after:String) {",
221
- " node(id:$projectId) {",
222
- " ... on ProjectV2 {",
223
- " items(first:100, after:$after, orderBy:{field:POSITION, direction:ASC}) {",
224
- " pageInfo { hasNextPage endCursor }",
225
- " nodes {",
226
- " id",
227
- " fieldValues(first:20) {",
228
- " nodes {",
229
- " ... on ProjectV2ItemFieldSingleSelectValue {",
230
- " field { ... on ProjectV2SingleSelectField { id name } }",
231
- " name",
232
- " }",
233
- " }",
234
- " }",
235
- " content {",
236
- " ... on Issue { __typename number repository { nameWithOwner } }",
237
- " ... on PullRequest { __typename number repository { nameWithOwner } }",
238
- " }",
239
- " }",
240
- " }",
241
- " }",
242
- " }",
243
- "}"
244
- ].join("\n");
245
-
246
- const UPDATE_ITEM_FIELD = [
247
- "mutation($projectId:ID!, $itemId:ID!, $fieldId:ID!, $optionId:String!) {",
248
- " updateProjectV2ItemFieldValue(input:{projectId:$projectId, itemId:$itemId, fieldId:$fieldId, value:{singleSelectOptionId:$optionId}}) {",
249
- " projectV2Item {",
250
- " id",
251
- " }",
252
- " }",
253
- "}"
254
- ].join("\n");
255
-
256
- // ── Owner resolution ────────────────────────────────────────────────────
257
-
258
- async function resolveOwner(login, env, runChild) {
259
- const userPayload = await ghGraphql(GET_USER_ID, { login }, env, runChild);
260
- if (userPayload?.data?.user?.id) {
261
- return { id: userPayload.data.user.id, kind: "user" };
262
- }
263
- const orgPayload = await ghGraphql(GET_ORG_ID, { login }, env, runChild);
264
- if (orgPayload?.data?.organization?.id) {
265
- return { id: orgPayload.data.organization.id, kind: "org" };
266
- }
267
- throw Object.assign(
268
- new Error(`Could not resolve owner ID for "${login}"`),
269
- { code: "NO_USER_ID" },
270
- );
271
- }
272
-
273
- // ── Paginated project listing ────────────────────────────────────────────
274
-
275
- async function listAllProjects(login, kind, env, runChild) {
276
- const query = kind === "org" ? LIST_ORG_PROJECTS : LIST_USER_PROJECTS;
277
- const projects = [];
278
- let after = null;
279
- while (true) {
280
- const vars = { login };
281
- if (after) vars.after = after;
282
- const payload = await ghGraphql(query, vars, env, runChild);
283
- const connection = kind === "org"
284
- ? payload?.data?.organization?.projectsV2
285
- : payload?.data?.user?.projectsV2;
286
- const nodes = connection?.nodes ?? [];
287
- projects.push(...nodes);
288
- const pageInfo = connection?.pageInfo ?? {};
289
- if (!pageInfo.hasNextPage) break;
290
- if (!pageInfo.endCursor) {
291
- throw Object.assign(
292
- new Error("Invalid projects list payload: hasNextPage is true but endCursor is missing"),
293
- { code: "GH_API_ERROR" },
294
- );
295
- }
296
- after = pageInfo.endCursor;
297
- }
298
- return projects;
299
- }
300
-
301
- // ── Paginated field listing ──────────────────────────────────────────────
302
-
303
- async function listAllFields(projectId, env, runChild) {
304
- const fields = [];
305
- let after = null;
306
- while (true) {
307
- const vars = { projectId };
308
- if (after) vars.after = after;
309
- const payload = await ghGraphql(GET_PROJECT_FIELDS, vars, env, runChild);
310
- const connection = payload?.data?.node?.fields;
311
- const nodes = connection?.nodes ?? [];
312
- fields.push(...nodes);
313
- const pageInfo = connection?.pageInfo ?? {};
314
- if (!pageInfo.hasNextPage) break;
315
- if (!pageInfo.endCursor) {
316
- throw Object.assign(
317
- new Error("Invalid fields payload: hasNextPage is true but endCursor is missing"),
318
- { code: "GH_API_ERROR" },
319
- );
320
- }
321
- after = pageInfo.endCursor;
322
- }
323
- return fields;
324
- }
325
-
326
- // ── Paginated item listing (position order) ──────────────────────────────
327
-
328
- async function fetchAllItems(projectId, env, runChild) {
329
- const items = [];
330
- let after = null;
331
- while (true) {
332
- const vars = { projectId };
333
- if (after) vars.after = after;
334
- const payload = await ghGraphql(GET_PROJECT_ITEMS_BY_CONTENT, vars, env, runChild);
335
- const connection = payload?.data?.node?.items;
336
- const nodes = connection?.nodes ?? [];
337
- items.push(...nodes);
338
- const pageInfo = connection?.pageInfo ?? {};
339
- if (!pageInfo.hasNextPage) break;
340
- if (!pageInfo.endCursor) {
341
- throw Object.assign(
342
- new Error("Invalid items payload: hasNextPage is true but endCursor is missing"),
343
- { code: "GH_API_ERROR" },
344
- );
345
- }
346
- after = pageInfo.endCursor;
347
- }
348
- return items;
349
- }
350
-
351
- function statusOf(node) {
352
- const fvs = node?.fieldValues?.nodes ?? [];
353
- for (const fv of fvs) {
354
- if (fv && fv.field && fv.field.name === "Status") return fv.name;
355
- }
356
- return null;
357
- }
358
-
359
- // ── Exit code classification ────────────────────────────────────────────
360
-
361
- function classifyExitCode(err) {
362
- if (err.code === "INVALID_REPO" || err.code === "INVALID_PROJECT" || err.code === "INVALID_ITEM" ||
363
- err.code === "INVALID_COLUMN" || err.code === "INVALID_ARGS") return 1;
364
- if (err.code === "PROJECT_NOT_FOUND" || err.code === "FIELD_NOT_FOUND" || err.code === "COLUMN_NOT_FOUND" ||
365
- err.code === "ITEM_NOT_FOUND") return 3;
366
- return 2;
367
- }
368
-
369
- // ── Main logic ──────────────────────────────────────────────────────────
370
-
371
- async function main(args, { env = process.env, runChild } = {}) {
372
- const child = runChild ?? _runChild;
373
- const repo = validateRepo(args.repo);
374
- const [owner, repoName] = repo.split("/");
375
- const selector = resolveProjectSelector(args);
376
- const itemRef = parseItemRef(args.item);
377
- const toColumn = (args.toColumn ?? "").trim();
378
- if (!toColumn) {
379
- throw Object.assign(new Error("--to-column is required"), { code: "INVALID_COLUMN" });
380
- }
381
-
382
- // 1. Resolve owner.
383
- // URI refs encode owner+kind directly; skip the API round-trip for owner resolution.
384
- const projectOwner = selector.projectRef?.kind === "uri" ? selector.projectRef.owner : owner;
385
- const ownerKind = selector.projectRef?.kind === "uri"
386
- ? selector.projectRef.ownerKind
387
- : (await resolveOwner(owner, env, child)).kind;
388
-
389
- // 2. Resolve project
390
- const projects = await listAllProjects(projectOwner, ownerKind, env, child);
391
- const project = findProject(projects, selector, projectOwner);
392
-
393
- // 3. Resolve Status field and target column
394
- const fieldNodes = await listAllFields(project.id, env, child);
395
- const statusField = fieldNodes.find((f) => f.name === "Status" && f.options);
396
- if (!statusField) {
397
- throw Object.assign(
398
- new Error(`Status field not found in project "${project.title}" (number ${project.number})`),
399
- { code: "FIELD_NOT_FOUND" },
400
- );
401
- }
402
-
403
- const targetOption = statusField.options.find((o) => o.name === toColumn);
404
- if (!targetOption) {
405
- const available = statusField.options.map((o) => o.name).join(", ");
406
- throw Object.assign(
407
- new Error(`Column "${toColumn}" not found in Status field. Available: ${available}`),
408
- { code: "COLUMN_NOT_FOUND" },
409
- );
410
- }
411
-
412
- // 4. Find the item.
413
- //
414
- // Fetch the full board item list ONCE (paginated, position order) and resolve
415
- // BOTH ref kinds against it. This reuses the proven pattern from
416
- // reorder-queue-item / list-queue-items: a node-id ref matches by item.id, a
417
- // number ref matches by content.number. Both are scoped to the requested repo
418
- // so a cross-project ref fails closed with ITEM_NOT_FOUND. (The previous code
419
- // used `ProjectV2.item` — a field that does not exist — for the node-id path,
420
- // and a single non-paginated `items(first:10)` page for the number path, so it
421
- // could not find items beyond the first page.)
422
- const allItems = await fetchAllItems(project.id, env, child);
423
-
424
- let match;
425
- if (itemRef.kind === "id") {
426
- match = allItems.find(
427
- (it) => it.id === itemRef.value && it.content?.repository?.nameWithOwner === repo,
428
- );
429
- if (!match) {
430
- throw Object.assign(
431
- new Error(`Item "${itemRef.value}" not found in project "${project.title}" for repo "${repo}"`),
432
- { code: "ITEM_NOT_FOUND" },
433
- );
434
- }
435
- } else {
436
- match = allItems.find(
437
- (it) =>
438
- it.content &&
439
- it.content.repository?.nameWithOwner === repo &&
440
- it.content.number === itemRef.value,
441
- );
442
- if (!match) {
443
- throw Object.assign(
444
- new Error(`Item #${itemRef.value} not found in project "${project.title}" for repo "${repo}"`),
445
- { code: "ITEM_NOT_FOUND" },
446
- );
447
- }
448
- }
449
-
450
- const itemId = match.id;
451
- const previousColumn = statusOf(match);
452
- let issueNumber = null;
453
- let prNumber = null;
454
- if (match.content) {
455
- if (match.content.__typename === "PullRequest") {
456
- prNumber = match.content.number;
457
- } else {
458
- issueNumber = match.content.number;
459
- }
460
- }
461
-
462
- // 5. No-op if already at target column
463
- if (previousColumn === toColumn) {
464
- return {
465
- ok: true,
466
- item: {
467
- itemId,
468
- issueNumber,
469
- prNumber,
470
- previousColumn,
471
- newColumn: toColumn,
472
- unchanged: true,
473
- },
474
- };
475
- }
476
-
477
- // 6. Update Status via mutation
478
- const updatePayload = await ghGraphql(UPDATE_ITEM_FIELD, {
479
- projectId: project.id,
480
- itemId,
481
- fieldId: statusField.id,
482
- optionId: targetOption.id,
483
- }, env, child);
484
-
485
- const updated = updatePayload?.data?.updateProjectV2ItemFieldValue?.projectV2Item;
486
- if (!updated) {
487
- throw Object.assign(new Error("Failed to update item field value"), { code: "MUTATION_FAILED" });
488
- }
489
-
490
- return {
491
- ok: true,
492
- item: {
493
- itemId,
494
- issueNumber,
495
- prNumber,
496
- previousColumn,
497
- newColumn: toColumn,
498
- unchanged: false,
499
- },
500
- };
501
- }
502
95
 
503
96
  // ── CLI entrypoint ──────────────────────────────────────────────────────
504
97
 
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { formatCliError, isDirectCliRun, parseJsonText } from "../_core-helpers.mjs";
3
3
  import { runChild as _runChild } from "../_cli-primitives.mjs";
4
- import { resolveProjectSelector, findProject, applyDevloopsBoard } from "./_resolve-project.mjs";
4
+ import { resolveProjectSelector, findProject, applyDevloopsBoard, parseItemRef } from "./_resolve-project.mjs";
5
5
  import { parseArgs } from "node:util";
6
6
  import { JQ_OUTPUT_PARSE_OPTIONS, JQ_OUTPUT_USAGE, emitResult, matchJqOutputToken } from "../lib/jq-output.mjs";
7
7
 
@@ -129,7 +129,6 @@ function parseCliArgs(argv) {
129
129
 
130
130
  const OWNER_RE = /^[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/;
131
131
  const REPO_NAME_RE = /^[a-zA-Z0-9](?:[a-zA-Z0-9_.-]*[a-zA-Z0-9])?$/;
132
- const GLOBAL_NODE_ID_RE = /^[A-Za-z0-9_]+$/;
133
132
 
134
133
  function validateRepo(repo) {
135
134
  if (!repo || typeof repo !== "string") {
@@ -154,24 +153,6 @@ function validateRepo(repo) {
154
153
  return repo;
155
154
  }
156
155
 
157
- function parseItemRef(raw) {
158
- if (!raw || typeof raw !== "string" || raw.trim().length === 0) {
159
- throw Object.assign(new Error("--item is required"), { code: "INVALID_ITEM" });
160
- }
161
- const trimmed = raw.trim();
162
- const asNum = Number(trimmed);
163
- if (Number.isInteger(asNum) && asNum > 0 && String(asNum) === trimmed) {
164
- return { kind: "number", value: asNum };
165
- }
166
- if (trimmed === "0") {
167
- throw Object.assign(new Error(`--item must be a positive integer or an item node ID, got "${raw}"`), { code: "INVALID_ITEM" });
168
- }
169
- if (GLOBAL_NODE_ID_RE.test(trimmed)) {
170
- return { kind: "id", value: trimmed };
171
- }
172
- throw Object.assign(new Error(`--item must be a positive integer or an item node ID, got "${raw}"`), { code: "INVALID_ITEM" });
173
- }
174
-
175
156
  // ── API helpers ──────────────────────────────────────────────────────────
176
157
 
177
158
  async function ghGraphql(query, vars, env, runChild = _runChild) {
@@ -541,7 +522,7 @@ function executePosition(projectId, itemId, afterId) {
541
522
  async function mainFlagForm(args, { env, child, repo, owner, repoName, project }) {
542
523
  const itemRef = parseItemRef(args.item);
543
524
  let afterRef = null;
544
- if (args.after !== undefined) afterRef = parseItemRef(args.after);
525
+ if (args.after !== undefined) afterRef = parseItemRef(args.after, "--after");
545
526
 
546
527
  const item = await resolveProjectItem(project.id, itemRef, owner, repoName, repo, env, child);
547
528
 
@@ -615,7 +596,7 @@ async function mainSubcommand(args, { env, child, repo, project }) {
615
596
  const items = await fetchAllItems(project.id, env, child);
616
597
 
617
598
  // Resolve all referenced items up-front (fail closed before any mutation).
618
- const refs = positional.map((p) => parseItemRef(p));
599
+ const refs = positional.map((p) => parseItemRef(p, "<ref>"));
619
600
  const resolved = refs.map((ref) => resolveFromItems(items, ref, repo));
620
601
 
621
602
  // Reordering positions within a single Status column. The before/after snapshot is scoped