pi-spine 2.34.0 → 2.35.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.
@@ -11,7 +11,7 @@ Options:
11
11
  --batch ID Target batch (default: active batch)
12
12
  --dry-run Show the merge plan without changing anything
13
13
  --force-integrate Bypass the gate (requires SPINE_ALLOW_FORCE=1)
14
- --no-github-sync Skip the opt-in post-integrate GitHub issue sync (#383)
14
+ --no-issue-sync Skip the opt-in post-integrate GitHub issue sync (#383)
15
15
  --json Machine-readable output
16
16
  --help, -h Show this help without changing state
17
17
  `;
@@ -25,8 +25,8 @@ Options:
25
25
  */
26
26
  function appendGithubSyncLines(lines, sync) {
27
27
  if (sync.skipped) {
28
- if (sync.reason === "no_github_sync_flag") {
29
- lines.push("", " GitHub: sync skipped (--no-github-sync)");
28
+ if (sync.reason === "no_issue_sync_flag") {
29
+ lines.push("", " GitHub: sync skipped (--no-issue-sync)");
30
30
  }
31
31
  return;
32
32
  }
@@ -110,7 +110,7 @@ export function runSpineIntegrate(options) {
110
110
  const { projectRoot, args } = options;
111
111
  const parsed = parseStrictArgs(args, {
112
112
  valued: ["--batch"],
113
- boolean: ["--dry-run", "--force-integrate", "--json", "--no-github-sync"],
113
+ boolean: ["--dry-run", "--force-integrate", "--json", "--no-issue-sync"],
114
114
  });
115
115
  const flags = parsed.flags;
116
116
  if (parsed.help) {
@@ -143,7 +143,7 @@ export function runSpineIntegrate(options) {
143
143
  dryRun: flags.has("--dry-run"),
144
144
  batchId: parsed.values.get("--batch") ?? null,
145
145
  forceIntegrate: flags.has("--force-integrate"),
146
- noGithubSync: flags.has("--no-github-sync"),
146
+ noIssueSync: flags.has("--no-issue-sync"),
147
147
  });
148
148
 
149
149
  return {
@@ -124,7 +124,20 @@ async function main() {
124
124
  const json = argv.includes('--json');
125
125
 
126
126
  // SP-889 (#386): board selection — GitHub label/milestone → pending task IDs.
127
- const board = parseBoardSelectArgs(argv);
127
+ // SP-894 (#387): parseBoardSelectArgs throws fail-closed on the retired
128
+ // --github-label spelling; surface it with the standard error style.
129
+ let board;
130
+ try {
131
+ board = parseBoardSelectArgs(argv);
132
+ } catch (err) {
133
+ const msg = err?.message ?? String(err);
134
+ if (err?.suggestedCommand) {
135
+ console.error(`Error: ${msg}\nSuggested: ${err.suggestedCommand}`);
136
+ } else {
137
+ console.error(`Error: ${msg}`);
138
+ }
139
+ process.exit(1);
140
+ }
128
141
  if (board.labels.length > 0 || (board.milestone !== null && board.milestone !== '')) {
129
142
  try {
130
143
  const { output } = await runBoardSelect({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-spine",
3
- "version": "2.34.0",
3
+ "version": "2.35.0",
4
4
  "description": "Orchestration spine for long-running pi development",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -546,11 +546,11 @@ Packet shape decides most of a batch's token spend. Each choice below removes LL
546
546
 
547
547
  ## Thin packets (issue narrative vs packet Contract) — #385 / #382
548
548
 
549
- **Dual-layer seam:** GitHub Issues hold goals and discussion (human/intake SoR). Packets under `paths.tasksRoot` hold Contract, File Scope, Steps, Do NOT, and STATUS (agent/engine SoR). Do **not** paste full issue threads into worker context.
549
+ **Dual-layer seam:** the issue tracker (GitHub provider by default) holds goals and discussion (human/intake SoR). Packets under `paths.tasksRoot` hold Contract, File Scope, Steps, Do NOT, and STATUS (agent/engine SoR). Do **not** paste full issue threads into worker context.
550
550
 
551
551
  | Layer | Keep here | Do not dump here |
552
552
  |-------|-----------|------------------|
553
- | GitHub issue | Narrative, ACs discussion, comments, board labels | Machine Contract / File Scope as the only source of truth |
553
+ | Issue tracker entry (GitHub by default) | Narrative, ACs discussion, comments, board labels | Machine Contract / File Scope as the only source of truth |
554
554
  | Packet `## Mission` | One short paragraph + `Closes #N` / `Partial #N` pointing at the issue | Multi-page issue body or all comment history |
555
555
  | Packet Contract / File Scope / Steps / Do NOT | Complete, local, authoritative for the batch | “See issue for File Scope” without listing paths |
556
556
  | Context to Read First | Few high-signal paths the worker needs | Unbounded “read all comments on #N” or pasted mega-dumps |
@@ -560,16 +560,16 @@ Packet shape decides most of a batch's token spend. Each choice below removes LL
560
560
  ```markdown
561
561
  ## Mission
562
562
 
563
- Closes #384 — Scaffold SP-* packets from a GitHub issue via `spine tasks from-issue`. Keep Contract stubs incomplete until the operator fills File Scope.
563
+ Closes #384 — Scaffold SP-* packets from an issue-tracker issue via `spine tasks from-issue`. Keep Contract stubs incomplete until the operator fills File Scope.
564
564
  ```
565
565
 
566
566
  **Fat-context anti-pattern:** Pasting the entire issue body plus comment thread into Context to Read First or Mission. Prefer the `#N` link and a one-line pointer; use `neverLoad` for docs that must stay out of worker context.
567
567
 
568
568
  **Advisory validate (deferred):** A warn-only `spine tasks validate` heuristic for mega Context dumps is **deferred** — hard to distinguish legitimate multi-doc Context from dumps without false positives, and hard-fail on any issue link is explicitly out of scope for #385. Authors rely on this DoR item until a later advisory lands.
569
569
 
570
- ## Hydrate from a GitHub issue — `spine tasks from-issue` (#384 / #382)
570
+ ## Hydrate from a tracker issue — `spine tasks from-issue` (#384 / #382)
571
571
 
572
- Thin CLI path from an open issue to a stub packet. Fetches the issue title via `gh issue view --json`, scaffolds `{tasksRoot}/SP-###-<slug>/`, and stops before inventing Contract content:
572
+ Thin CLI path from an open issue-tracker issue (GitHub provider by default) to a stub packet. Fetches the issue title via `gh issue view --json`, scaffolds `{tasksRoot}/SP-###-<slug>/`, and stops before inventing Contract content:
573
573
 
574
574
  ```bash
575
575
  spine tasks from-issue 384 # Mission "Closes #384" (default)
@@ -622,9 +622,9 @@ Before reporting launch commands:
622
622
  - [ ] No LLM step waits on a long-running command — split authoring (`llm`) from running (`execute`) ([#276](https://github.com/beettlle/pi-spine/issues/276))
623
623
  - [ ] Size S/M/L — split if XL
624
624
  - [ ] PROMPT.md from template: Mission, Dependencies, Context, File Scope, Contract (SP-\*), Steps, Do NOT, Git Commit Convention, Amendments
625
- - [ ] Mission uses `Closes #N` or `Partial #N` on first line when tracking GitHub issues ([#147](https://github.com/beettlle/pi-spine/issues/147))
625
+ - [ ] Mission uses `Closes #N` or `Partial #N` on first line when tracking issue-tracker issues (GitHub by default) ([#147](https://github.com/beettlle/pi-spine/issues/147))
626
626
  - [ ] Thin packet: short Mission + `#N` pointer; Contract/File Scope/Steps/Do NOT complete locally — no pasted issue-thread mega-dumps in Context ([#385](https://github.com/beettlle/pi-spine/issues/385) / [Thin packets](#thin-packets-issue-narrative-vs-packet-contract--385--382))
627
- - [ ] Issue intake via `spine tasks from-issue`: Contract / File Scope / Steps filled and `spine tasks validate <id>` passing before plan/batch ([#384](https://github.com/beettlle/pi-spine/issues/384) / [Hydrate](#hydrate-from-a-github-issue--spine-tasks-from-issue-384--382))
627
+ - [ ] Issue intake via `spine tasks from-issue`: Contract / File Scope / Steps filled and `spine tasks validate <id>` passing before plan/batch ([#384](https://github.com/beettlle/pi-spine/issues/384) / [Hydrate](#hydrate-from-a-tracker-issue--spine-tasks-from-issue-384--382))
628
628
  - [ ] Split-successor tasks include `Parent split: SP-###` in Context to Read First ([#146](https://github.com/beettlle/pi-spine/issues/146))
629
629
  - [ ] `## Do NOT` bans `.spine/`, `AGENTS.md`, `CLAUDE.md`, `.gitnexus/` ([#149](https://github.com/beettlle/pi-spine/issues/149))
630
630
  - [ ] Level 2+ only when operator environment supports cross-model review ([#150](https://github.com/beettlle/pi-spine/issues/150))
@@ -79,7 +79,7 @@ START
79
79
  ## Wave picker algorithm
80
80
 
81
81
  1. Run `spine plan pending` (or `spine plan all` / explicit task scope).
82
- - **Board-driven alternative (SP-889 / #386):** when the operator names a GitHub label or milestone, resolve the scope first — `node bin/spine-plan.mjs --github-label <label> --print-ids` (Mission `Closes`/`Partial` links → pending task IDs, selection only, no auto-start) — then plan that ID list to confirm wave structure.
82
+ - **Board-driven alternative (SP-889 / #386):** when the operator names an issue-tracker label or milestone (GitHub provider by default), resolve the scope first — `node bin/spine-plan.mjs --issue-label <label> --print-ids` (Mission `Closes`/`Partial` links → pending task IDs, selection only, no auto-start) — then plan that ID list to confirm wave structure.
83
83
  2. Parse wave index and task list:
84
84
  - **JSON:** `spine plan pending --json` → `waveCount`, per-wave `tasks[]`
85
85
  - **Text:** read wave headers from CLI output
@@ -407,9 +407,9 @@ git push origin main
407
407
 
408
408
  Do not let `main` drift far ahead of `origin` between waves — v2.12.1 ran **24 commits ahead** of `origin` at Phase 5 (F8, [#249](https://github.com/beettlle/pi-spine/issues/249)). Local-only releases may defer this push; record the deferral in the manifest publish checklist.
409
409
 
410
- ### 4.3c Close GitHub issues for landed tasks (blocking hygiene)
410
+ ### 4.3c Close tracker issues for landed tasks (blocking hygiene)
411
411
 
412
- > **Automated sync (SP-887 / #383):** repos with `integrations.github.syncOnLand: true` get the `Closes #N` / `Partial #N` actions below applied automatically by `spine integrate` (close = comment + close; partial = comment only; journal `github.issue_synced` / `github.issue_sync_failed`; escape hatch `spine integrate --no-github-sync`). The default is **off** — when disabled or soft-failed (missing `gh`/auth), perform this §4.3c sweep manually.
412
+ > **Automated sync (SP-887 / #383):** repos with `integrations.issues.syncOnLand: true` get the `Closes #N` / `Partial #N` actions below applied automatically by `spine integrate` (close = comment + close; partial = comment only; journal `issues.synced` / `issues.sync_failed`; escape hatch `spine integrate --no-issue-sync`). The default is **off** — when disabled or soft-failed (missing `gh`/auth), perform this §4.3c sweep manually.
413
413
 
414
414
  After §4.3a is green (and §4.3b push when remote publish is the goal), **close every open issue fully resolved by tasks that just landed** — same wave, same land loop. Do not wait for Phase 6 or npm publish.
415
415
 
@@ -27,7 +27,7 @@ import { isLiveEngineInActivePhase } from "./lifecycle-archive.mjs";
27
27
  import { appendJournalEvent } from "./journal.mjs";
28
28
  import { countCommitsAhead } from "./lane-commit.mjs";
29
29
  import { inspectGitState, loadBatchStateFile, parseBatchState } from "./reconcile.mjs";
30
- import { syncIssuesAfterIntegrate } from "../integrations/github/sync-on-land.mjs";
30
+ import { syncIssuesAfterIntegrate } from "../integrations/issues/sync-on-land.mjs";
31
31
 
32
32
  /**
33
33
  * @param {string} projectRoot
@@ -100,7 +100,7 @@ function postMergeCompletionSuggestion(raw) {
100
100
  * @param {boolean} [ctx.dryRun]
101
101
  * @param {string|null} [ctx.batchId]
102
102
  * @param {string|null} [ctx.batchStatePath]
103
- * @param {boolean} [ctx.noGithubSync] Skip the opt-in post-integrate GitHub issue sync (#383).
103
+ * @param {boolean} [ctx.noIssueSync] Skip the opt-in post-integrate GitHub issue sync (#383).
104
104
  */
105
105
  export function integrateOrchToBase(ctx) {
106
106
  const { projectRoot, dryRun = false } = ctx;
@@ -423,7 +423,7 @@ export function integrateOrchToBase(ctx) {
423
423
  batch,
424
424
  config,
425
425
  mergeCommit,
426
- noGithubSync: Boolean(ctx.noGithubSync),
426
+ noIssueSync: Boolean(ctx.noIssueSync),
427
427
  });
428
428
 
429
429
  const waiting = postMergeCompletionSuggestion(loaded.raw);
@@ -6,7 +6,7 @@
6
6
  * `spine plan` / `spine batch start`. Never starts batches, never polls, and
7
7
  * never mutates issue state; re-run when the board changes.
8
8
  *
9
- * CLI surface: `node bin/spine-plan.mjs --github-label <label>… [--milestone <m>] [--print-ids]`.
9
+ * CLI surface: `node bin/spine-plan.mjs --issue-label <label>… [--milestone <m>] [--print-ids]`.
10
10
  */
11
11
 
12
12
  import { spawnSync } from "node:child_process";
@@ -14,7 +14,7 @@ import fs from "node:fs";
14
14
  import path from "node:path";
15
15
 
16
16
  import { compareTaskIds, discoverTasks } from "../tasks/packet/discover.mjs";
17
- import { parseMissionIssueLinks } from "../integrations/github/mission-issue-links.mjs";
17
+ import { parseMissionIssueLinks } from "../integrations/issues/mission-issue-links.mjs";
18
18
  import { loadSpineConfig } from "../config/spine-config-load.mjs";
19
19
  import { resolveTasksRootPath } from "../config/env-overrides.mjs";
20
20
  import { missingConfigHint } from "../config/missing-config-hint.mjs";
@@ -54,10 +54,17 @@ const MISSION_SECTION_RE = /^## Mission\s*\n([\s\S]*?)(?=^## |\s*$)/m;
54
54
  */
55
55
 
56
56
  /** argv flags that select a board rather than a scope. */
57
- const BOARD_LABEL_FLAG = "--github-label";
57
+ const BOARD_LABEL_FLAG = "--issue-label";
58
58
  const BOARD_MILESTONE_FLAG = "--milestone";
59
59
  const BOARD_PRINT_IDS_FLAG = "--print-ids";
60
60
 
61
+ /**
62
+ * Pre-SP-894 (#387) label flag spelling. Rejected fail-closed in
63
+ * `parseBoardSelectArgs` — no silent alias: scripts using the old flag
64
+ * must move to `--issue-label`.
65
+ */
66
+ const LEGACY_BOARD_LABEL_FLAG = "--github-label";
67
+
61
68
  /**
62
69
  * @param {string} filePath
63
70
  * @returns {string}
@@ -90,9 +97,11 @@ export function defaultRunGh(projectRoot, args) {
90
97
  }
91
98
 
92
99
  /**
93
- * Parse the board-select argv subset: repeatable `--github-label <label>`
94
- * (also `--github-label=<label>`), optional `--milestone <m>` (title or
95
- * number), and `--print-ids`. Unknown flags pass through in `rest`.
100
+ * Parse the board-select argv subset: repeatable `--issue-label <label>`
101
+ * (also `--issue-label=<label>`), optional `--milestone <m>` (title or
102
+ * number), and `--print-ids`. Unknown flags pass through in `rest`, except
103
+ * the retired `--github-label` spelling, which throws fail-closed (no
104
+ * silent alias; SP-894 / #387).
96
105
  *
97
106
  * @param {string[]} argv
98
107
  * @returns {{ labels: string[], milestone: string | null, printIds: boolean, rest: string[] }}
@@ -109,6 +118,13 @@ export function parseBoardSelectArgs(argv) {
109
118
  let pendingFlag = null;
110
119
 
111
120
  for (const arg of argv) {
121
+ if (arg === LEGACY_BOARD_LABEL_FLAG || arg.startsWith(`${LEGACY_BOARD_LABEL_FLAG}=`)) {
122
+ // SP-894 (#387): fail closed — the old flag spelling is rejected,
123
+ // never aliased; scripts must move to --issue-label.
124
+ const err = new Error("Unknown option: --github-label (renamed to --issue-label; old flag not accepted)");
125
+ err.suggestedCommand = "spine plan --issue-label <label>";
126
+ throw err;
127
+ }
112
128
  if (pendingFlag !== null && !arg.startsWith("--")) {
113
129
  if (pendingFlag === BOARD_LABEL_FLAG) {
114
130
  labels.push(arg);
@@ -145,7 +161,7 @@ export function parseBoardSelectArgs(argv) {
145
161
 
146
162
  /**
147
163
  * `gh issue list` argv for the open-issue board pull. Fields `number`,
148
- * `labels`, `milestone` are filtered in-memory so multiple `--github-label`
164
+ * `labels`, `milestone` are filtered in-memory so multiple `--issue-label`
149
165
  * values keep documented any-match semantics regardless of gh's own
150
166
  * repeated-flag behavior.
151
167
  *
@@ -261,9 +277,9 @@ export function resolveBoardTaskIds({
261
277
  const requestedMilestone = milestone == null ? null : String(milestone).trim();
262
278
  if (requestedLabels.length === 0 && (requestedMilestone === null || requestedMilestone === "")) {
263
279
  const err = new Error(
264
- "Board selection needs at least one --github-label <label> or --milestone <title|number>",
280
+ "Board selection needs at least one --issue-label <label> or --milestone <title|number>",
265
281
  );
266
- err.suggestedCommand = "spine plan --github-label <label>";
282
+ err.suggestedCommand = "spine plan --issue-label <label>";
267
283
  throw err;
268
284
  }
269
285
 
@@ -424,7 +440,7 @@ export function formatBoardSelection({ filters, boardIssueCount, taskIds, readEr
424
440
 
425
441
  /**
426
442
  * Full board-select CLI path: resolve + format. Used by `bin/spine-plan.mjs`
427
- * when `--github-label` / `--milestone` are present.
443
+ * when `--issue-label` / `--milestone` are present.
428
444
  *
429
445
  * @param {object} [params]
430
446
  * @param {string} [params.projectRoot]
@@ -64,13 +64,16 @@ export const INTEGRATE_DEFAULTS = Object.freeze({
64
64
  });
65
65
 
66
66
  /**
67
- * Third-party integrations (SP-887 / #383). Everything is opt-in: the section
68
- * only exists so `syncOnLand` reads as an explicit, documented default rather
69
- * than an accidental undefined.
67
+ * Third-party integrations (SP-887 / #383; forge-neutral rename SP-890 / #387).
68
+ * The section is the `issues` umbrella with a `provider` field: only the default
69
+ * provider `"github"` has a working backend today, and `syncOnLand` stays opt-in
70
+ * so the key reads as an explicit, documented default rather than an accidental
71
+ * undefined. The legacy `integrations.github` key is rejected fail-closed at
72
+ * validation time — no silent alias.
70
73
  *
71
- * @type {Readonly<{ github: Readonly<{ syncOnLand: boolean }> }>} */
74
+ * @type {Readonly<{ issues: Readonly<{ provider: string; syncOnLand: boolean }> }>} */
72
75
  export const INTEGRATIONS_DEFAULTS = Object.freeze({
73
- github: Object.freeze({ syncOnLand: false }),
76
+ issues: Object.freeze({ provider: "github", syncOnLand: false }),
74
77
  });
75
78
 
76
79
  /** @type {Readonly<{ review: typeof REVIEW_DEFAULTS; handoff: typeof HANDOFF_DEFAULTS; metrics: typeof METRICS_DEFAULTS; contract: typeof CONTRACT_DEFAULTS; lanes: typeof LANES_DEFAULTS; integrate: typeof INTEGRATE_DEFAULTS; integrations: typeof INTEGRATIONS_DEFAULTS; orchestrator: typeof ORCHESTRATOR_DEFAULTS }>} */
@@ -219,12 +219,14 @@ export function resolveSequenceStallMs({ config = {} } = {}) {
219
219
  return DEFAULT_SEQUENCE_STALL_MS;
220
220
  }
221
221
 
222
- // --- Integrations (SP-887 / #383) ---
222
+ // --- Integrations (SP-887 / #383; forge-neutral rename SP-890 / #387) ---
223
223
 
224
224
  /**
225
- * Validate `integrations.github.syncOnLand` (opt-in GitHub issue sync on land).
226
- * Structural only: the boolean flag must be a boolean when set. Absent values
227
- * are valid (defaults to false via INTEGRATIONS_DEFAULTS).
225
+ * Validate `integrations.issues` (forge-neutral issue-tracker section, #387).
226
+ * Structural only: `provider` must be a string when set (defaults to "github"
227
+ * via INTEGRATIONS_DEFAULTS) and `syncOnLand` must be a boolean when set
228
+ * (defaults to false). Absent values are valid. The legacy `integrations.github`
229
+ * key is rejected fail-closed — no silent alias (#387).
228
230
  *
229
231
  * @param {Record<string, any>} config
230
232
  * @returns {null | { code: string; message: string; suggestedCommand: string }}
@@ -241,22 +243,36 @@ export function validateIntegrationsConfig(config) {
241
243
  suggestedCommand: "spine init --force",
242
244
  };
243
245
  }
244
- const github = integrations.github;
245
- if (github == null) {
246
+ if ("github" in integrations) {
247
+ return {
248
+ code: "CONFIG_INTEGRATIONS_INVALID",
249
+ message: 'integrations.github is no longer supported — rename it to integrations.issues (the default provider remains "github")',
250
+ suggestedCommand: 'Edit .spine/spine-config.json: rename integrations.github to integrations.issues, e.g. "issues": { "provider": "github", "syncOnLand": true }',
251
+ };
252
+ }
253
+ const issues = integrations.issues;
254
+ if (issues == null) {
246
255
  return null;
247
256
  }
248
- if (!isPlainObject(github)) {
257
+ if (!isPlainObject(issues)) {
258
+ return {
259
+ code: "CONFIG_INTEGRATIONS_INVALID",
260
+ message: "integrations.issues must be an object when set",
261
+ suggestedCommand: "Edit .spine/spine-config.json: integrations.issues must be an object",
262
+ };
263
+ }
264
+ if (issues.provider != null && typeof issues.provider !== "string") {
249
265
  return {
250
266
  code: "CONFIG_INTEGRATIONS_INVALID",
251
- message: "integrations.github must be an object when set",
252
- suggestedCommand: "Edit .spine/spine-config.json: integrations.github must be an object",
267
+ message: "integrations.issues.provider must be a string when set",
268
+ suggestedCommand: 'Edit .spine/spine-config.json: set integrations.issues.provider to "github"',
253
269
  };
254
270
  }
255
- if (github.syncOnLand != null && typeof github.syncOnLand !== "boolean") {
271
+ if (issues.syncOnLand != null && typeof issues.syncOnLand !== "boolean") {
256
272
  return {
257
273
  code: "CONFIG_INTEGRATIONS_INVALID",
258
- message: "integrations.github.syncOnLand must be a boolean when set",
259
- suggestedCommand: "Edit .spine/spine-config.json: set integrations.github.syncOnLand to true or false",
274
+ message: "integrations.issues.syncOnLand must be a boolean when set",
275
+ suggestedCommand: "Edit .spine/spine-config.json: set integrations.issues.syncOnLand to true or false",
260
276
  };
261
277
  }
262
278
  return null;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Default GitHub provider for opt-in issue sync on land (#387, SP-892).
3
+ *
4
+ * Holds the `gh` CLI runner extracted from
5
+ * `src/integrations/github/sync-on-land.mjs`: array-args spawn (no shell),
6
+ * piped output, hard timeout, and the `{ status, stdout, stderr, error }`
7
+ * result shape. Sync callers keep the soft-fail contract — a missing,
8
+ * hung, or failing `gh` never throws from here; the caller inspects the
9
+ * result. Future non-github providers live alongside this module.
10
+ */
11
+
12
+ import { spawnSync } from "node:child_process";
13
+
14
+ /** Hard timeout per `gh` call so a hung CLI cannot stall the integrate path. */
15
+ export const GH_CALL_TIMEOUT_MS = 30_000;
16
+
17
+ /**
18
+ * @typedef {object} GhRunResult
19
+ * @property {number | null} status
20
+ * @property {string} [stdout]
21
+ * @property {string} [stderr]
22
+ * @property {Error | null} [error]
23
+ */
24
+
25
+ /**
26
+ * Default `gh` runner: array-args spawn (no shell), piped output, hard timeout.
27
+ *
28
+ * @param {string} projectRoot
29
+ * @param {string[]} args
30
+ * @param {object} [deps]
31
+ * @param {typeof import("node:child_process").spawnSync} [deps.spawn] Injectable spawn (tests stub this).
32
+ * @returns {GhRunResult}
33
+ */
34
+ export function defaultRunGh(projectRoot, args, { spawn = spawnSync } = {}) {
35
+ const result = spawn("gh", args, {
36
+ cwd: projectRoot,
37
+ encoding: "utf-8",
38
+ stdio: ["ignore", "pipe", "pipe"],
39
+ timeout: GH_CALL_TIMEOUT_MS,
40
+ });
41
+ return {
42
+ status: result.status ?? null,
43
+ stdout: typeof result.stdout === "string" ? result.stdout : "",
44
+ stderr: typeof result.stderr === "string" ? result.stderr : "",
45
+ error: result.error ?? null,
46
+ };
47
+ }
@@ -3,16 +3,16 @@
3
3
  *
4
4
  * After a successful integrate (`.DONE` tasks on the batch base), comment on
5
5
  * and close issues referenced by task Mission `Closes #N` / `Partial #N`
6
- * links (format per #147). Strictly opt-in via `integrations.github.syncOnLand`
6
+ * links (format per #147). Strictly opt-in via `integrations.issues.syncOnLand`
7
7
  * (default off); every failure path is soft — integrate results never change
8
8
  * because `gh` is missing, unauthenticated, or a single issue call fails.
9
9
  */
10
10
 
11
11
  import fs from "node:fs";
12
12
  import path from "node:path";
13
- import { spawnSync } from "node:child_process";
14
13
 
15
14
  import { parseMissionIssueLinks } from "./mission-issue-links.mjs";
15
+ import { defaultRunGh } from "./providers/github.mjs";
16
16
  import { commandExists } from "../../util/command-exists.mjs";
17
17
  import { appendJournalEvent } from "../../batch/journal.mjs";
18
18
  import { resolveTasksRootPath } from "../../config/env-overrides.mjs";
@@ -20,32 +20,27 @@ import { resolveTasksRootPath } from "../../config/env-overrides.mjs";
20
20
  /** Terminal-success statuses whose `.DONE` landed work on the batch base. */
21
21
  const DONE_ON_BASE_STATUSES = new Set(["completed", "succeeded"]);
22
22
 
23
- /** Hard timeout per `gh` call so a hung CLI cannot stall the integrate path. */
24
- const GH_CALL_TIMEOUT_MS = 30_000;
25
-
26
23
  /** Directory (relative to projectRoot) for temp comment body files. */
27
- const BODY_DIR = path.join(".spine", "github-sync");
24
+ const BODY_DIR = path.join(".spine", "issues-sync");
28
25
 
29
26
  /**
30
27
  * @typedef {import("./mission-issue-links.mjs").MissionIssueLinks} MissionIssueLinks
31
28
  */
32
29
 
33
30
  /**
34
- * @typedef {object} GhRunResult
35
- * @property {number | null} status
36
- * @property {string} [stdout]
37
- * @property {string} [stderr]
38
- * @property {Error | null} [error]
31
+ * @typedef {import("./providers/github.mjs").GhRunResult} GhRunResult
39
32
  */
40
33
 
41
34
  /**
42
- * Resolve the opt-in flag. Missing/invalid config disables sync (default off).
35
+ * Resolve the opt-in flag (forge-neutral `integrations.issues` since SP-890/#387;
36
+ * legacy `integrations.github` is rejected at config validation). Missing/invalid
37
+ * config disables sync (default off).
43
38
  *
44
39
  * @param {Record<string, any> | null | undefined} config Effective spine config.
45
- * @returns {boolean} True only when `integrations.github.syncOnLand === true`.
40
+ * @returns {boolean} True only when `integrations.issues.syncOnLand === true`.
46
41
  */
47
- export function resolveGithubSyncOnLandConfig(config) {
48
- return config?.integrations?.github?.syncOnLand === true;
42
+ export function resolveIssueSyncOnLandConfig(config) {
43
+ return config?.integrations?.issues?.syncOnLand === true;
49
44
  }
50
45
 
51
46
  /**
@@ -72,28 +67,6 @@ export function collectDoneOnBaseTasks(batch) {
72
67
  return done;
73
68
  }
74
69
 
75
- /**
76
- * Default `gh` runner: array-args spawn (no shell), piped output, hard timeout.
77
- *
78
- * @param {string} projectRoot
79
- * @param {string[]} args
80
- * @returns {GhRunResult}
81
- */
82
- function defaultRunGh(projectRoot, args) {
83
- const result = spawnSync("gh", args, {
84
- cwd: projectRoot,
85
- encoding: "utf-8",
86
- stdio: ["ignore", "pipe", "pipe"],
87
- timeout: GH_CALL_TIMEOUT_MS,
88
- });
89
- return {
90
- status: result.status ?? null,
91
- stdout: typeof result.stdout === "string" ? result.stdout : "",
92
- stderr: typeof result.stderr === "string" ? result.stderr : "",
93
- error: result.error ?? null,
94
- };
95
- }
96
-
97
70
  /**
98
71
  * @param {string} filePath
99
72
  * @returns {string}
@@ -160,7 +133,7 @@ export function buildLandCommentBody({ taskId, batchId, mergeCommit, action }) {
160
133
  `Landed on \`main\` by **${taskId}** (batch \`${batchId}\`).`,
161
134
  "",
162
135
  commitLine +
163
- "- Closed automatically by spine (`integrations.github.syncOnLand`).",
136
+ "- Closed automatically by spine (`integrations.issues.syncOnLand`).",
164
137
  "",
165
138
  ].join("\n");
166
139
  }
@@ -168,7 +141,7 @@ export function buildLandCommentBody({ taskId, batchId, mergeCommit, action }) {
168
141
  `Partially addressed on \`main\` by **${taskId}** (batch \`${batchId}\`) — issue left open.`,
169
142
  "",
170
143
  commitLine +
171
- "- Commented automatically by spine (`integrations.github.syncOnLand`).",
144
+ "- Commented automatically by spine (`integrations.issues.syncOnLand`).",
172
145
  "",
173
146
  ].join("\n");
174
147
  }
@@ -204,7 +177,7 @@ function writeCommentBodyFile({ projectRoot, batchId, issue, body }) {
204
177
  * Integrate entry point (#383): resolve the `.DONE`-on-base task set and
205
178
  * tasksRoot from batch state + effective config, then run the sync. Best-effort
206
179
  * only — never throws into the integrate success path; internal errors journal
207
- * as `github.issue_sync_failed` instead of failing the integrate.
180
+ * as `issues.sync_failed` instead of failing the integrate.
208
181
  *
209
182
  * @param {object} params
210
183
  * @param {string} params.projectRoot
@@ -212,7 +185,7 @@ function writeCommentBodyFile({ projectRoot, batchId, issue, body }) {
212
185
  * @param {object} params.batch Parsed batch state.
213
186
  * @param {Record<string, any> | null | undefined} params.config Effective spine config (null → sync disabled).
214
187
  * @param {string | null} [params.mergeCommit] Integrate merge commit.
215
- * @param {boolean} [params.noGithubSync] `--no-github-sync` escape hatch.
188
+ * @param {boolean} [params.noIssueSync] `--no-issue-sync` escape hatch.
216
189
  * @param {(projectRoot: string, args: string[]) => GhRunResult} [params.runGh] Injectable gh runner.
217
190
  * @param {(cmd: string) => boolean} [params.ghPresent] Injectable gh probe.
218
191
  * @param {JournalAppendFn} [params.journalAppend] Injectable journal appender.
@@ -225,7 +198,7 @@ export function syncIssuesAfterIntegrate({
225
198
  batch,
226
199
  config,
227
200
  mergeCommit = null,
228
- noGithubSync = false,
201
+ noIssueSync = false,
229
202
  runGh,
230
203
  ghPresent,
231
204
  journalAppend,
@@ -239,7 +212,7 @@ export function syncIssuesAfterIntegrate({
239
212
  tasksRoot: config ? resolveTasksRootPath(projectRoot, config) : null,
240
213
  config,
241
214
  mergeCommit,
242
- noGithubSync,
215
+ noIssueSync,
243
216
  runGh,
244
217
  ghPresent,
245
218
  journalAppend,
@@ -249,7 +222,7 @@ export function syncIssuesAfterIntegrate({
249
222
  const message = err instanceof Error ? err.message : String(err);
250
223
  try {
251
224
  const journal = journalAppend ?? appendJournalEvent;
252
- journal(projectRoot, batchId, "github.issue_sync_failed", {
225
+ journal(projectRoot, batchId, "issues.sync_failed", {
253
226
  reason: "internal_error",
254
227
  error: message.slice(0, 500),
255
228
  hint: "spine status --diagnose",
@@ -274,7 +247,7 @@ export function syncIssuesAfterIntegrate({
274
247
  * @param {Record<string, any> | null | undefined} params.config Effective config.
275
248
  * @param {string | null} [params.mergeCommit] Integrate merge commit.
276
249
  * @param {boolean} [params.dryRun] Plan only — no gh calls, no journal.
277
- * @param {boolean} [params.noGithubSync] `--no-github-sync` escape hatch.
250
+ * @param {boolean} [params.noIssueSync] `--no-issue-sync` escape hatch.
278
251
  * @param {(projectRoot: string, args: string[]) => GhRunResult} [params.runGh] Injectable gh runner.
279
252
  * @param {(cmd: string) => boolean} [params.ghPresent] Injectable gh probe.
280
253
  * @param {JournalAppendFn} [params.journalAppend] Injectable journal appender.
@@ -299,7 +272,7 @@ export function syncIssuesOnLand({
299
272
  config,
300
273
  mergeCommit = null,
301
274
  dryRun = false,
302
- noGithubSync = false,
275
+ noIssueSync = false,
303
276
  runGh,
304
277
  ghPresent,
305
278
  journalAppend,
@@ -328,10 +301,10 @@ export function syncIssuesOnLand({
328
301
  planned,
329
302
  });
330
303
 
331
- if (noGithubSync) {
332
- return skip("no_github_sync_flag");
304
+ if (noIssueSync) {
305
+ return skip("no_issue_sync_flag");
333
306
  }
334
- if (!resolveGithubSyncOnLandConfig(config)) {
307
+ if (!resolveIssueSyncOnLandConfig(config)) {
335
308
  return skip("sync_disabled");
336
309
  }
337
310
  if (!tasksRoot) {
@@ -350,7 +323,7 @@ export function syncIssuesOnLand({
350
323
  });
351
324
  } catch (err) {
352
325
  const message = err instanceof Error ? err.message : String(err);
353
- journal(projectRoot, batchId, "github.issue_sync_failed", {
326
+ journal(projectRoot, batchId, "issues.sync_failed", {
354
327
  reason: "parse_error",
355
328
  error: message.slice(0, 500),
356
329
  hint: "spine status --diagnose",
@@ -359,7 +332,7 @@ export function syncIssuesOnLand({
359
332
  }
360
333
  planned.push(...collection.links);
361
334
  for (const readError of collection.readErrors) {
362
- journal(projectRoot, batchId, "github.issue_sync_failed", {
335
+ journal(projectRoot, batchId, "issues.sync_failed", {
363
336
  reason: "prompt_unreadable",
364
337
  error: readError.slice(0, 500),
365
338
  hint: "spine status --diagnose",
@@ -384,17 +357,17 @@ export function syncIssuesOnLand({
384
357
  }
385
358
 
386
359
  if (!present("gh")) {
387
- journal(projectRoot, batchId, "github.issue_sync_failed", {
360
+ journal(projectRoot, batchId, "issues.sync_failed", {
388
361
  reason: "gh_missing",
389
- hint: "Install GitHub CLI (https://cli.github.com/) or disable integrations.github.syncOnLand",
362
+ hint: "Install GitHub CLI (https://cli.github.com/) or disable integrations.issues.syncOnLand",
390
363
  });
391
- return skip("gh_missing", "Install GitHub CLI (https://cli.github.com/) or disable integrations.github.syncOnLand");
364
+ return skip("gh_missing", "Install GitHub CLI (https://cli.github.com/) or disable integrations.issues.syncOnLand");
392
365
  }
393
366
 
394
367
  const auth = run(projectRoot, ["auth", "status"]);
395
368
  if ((auth.status ?? 1) !== 0) {
396
369
  const stderr = (auth.stderr ?? "").trim().slice(0, 500);
397
- journal(projectRoot, batchId, "github.issue_sync_failed", {
370
+ journal(projectRoot, batchId, "issues.sync_failed", {
398
371
  reason: "gh_auth",
399
372
  error: stderr,
400
373
  hint: "Run `gh auth login`, then re-run `spine integrate` (or close manually per the release-operator runbook §4.3c)",
@@ -411,7 +384,7 @@ export function syncIssuesOnLand({
411
384
  } catch (err) {
412
385
  const message = err instanceof Error ? err.message : String(err);
413
386
  failures.push({ taskId, issue, action, error: message });
414
- journal(projectRoot, batchId, "github.issue_sync_failed", {
387
+ journal(projectRoot, batchId, "issues.sync_failed", {
415
388
  issue,
416
389
  action,
417
390
  taskId,
@@ -425,7 +398,7 @@ export function syncIssuesOnLand({
425
398
  if ((comment.status ?? 1) !== 0) {
426
399
  const stderr = (comment.stderr ?? comment.stdout ?? "").trim().slice(0, 500) || "gh issue comment failed";
427
400
  failures.push({ taskId, issue, action, error: stderr });
428
- journal(projectRoot, batchId, "github.issue_sync_failed", {
401
+ journal(projectRoot, batchId, "issues.sync_failed", {
429
402
  issue,
430
403
  action,
431
404
  taskId,
@@ -443,7 +416,7 @@ export function syncIssuesOnLand({
443
416
  if ((close.status ?? 1) !== 0) {
444
417
  const stderr = (close.stderr ?? close.stdout ?? "").trim().slice(0, 500) || "gh issue close failed";
445
418
  failures.push({ taskId, issue, action, error: stderr });
446
- journal(projectRoot, batchId, "github.issue_sync_failed", {
419
+ journal(projectRoot, batchId, "issues.sync_failed", {
447
420
  issue,
448
421
  action,
449
422
  taskId,
@@ -458,7 +431,7 @@ export function syncIssuesOnLand({
458
431
  }
459
432
  bodyFile.cleanup();
460
433
  synced.push({ taskId, issue, action, closed });
461
- journal(projectRoot, batchId, "github.issue_synced", {
434
+ journal(projectRoot, batchId, "issues.synced", {
462
435
  issue,
463
436
  action,
464
437
  taskId,