@skitterbyte/skitterspec-github 2.1.0 → 2.3.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.
package/MIGRATION.md CHANGED
@@ -1,5 +1,47 @@
1
1
  # Migration guide
2
2
 
3
+ ## `issue` and `incident` spec kinds, per-type states, incident log (additive — nothing breaks)
4
+
5
+ Specs can now be **issues** (`issue-` prefix — non-code work done as recorded
6
+ manual steps) and **incidents** (`incident-` prefix, captured live by the new
7
+ `/spec-incident` skill; `/spec-complete` ends one by writing `incident-log.md`
8
+ and posting it onto the tracker item as a comment, via the new
9
+ `spec-sync comment <spec> --file <f>` verb). A lifecycle bucket can map to a
10
+ different state per work item type (`statesByType` on Azure Boards and Jira)
11
+ or per spec kind (`statesByKind` on GitHub and Linear), both top-level beside
12
+ `states`, with `null` meaning "send no state" — and the pre-write check now
13
+ validates each type's effective states against **that type's own** list, so a
14
+ state only one type lacks refuses before anything is written. On Azure and
15
+ Jira, `spec-sync states --json` now prints a per-type map
16
+ (`{ "<type>": [names] }`); a flat array from an older file is still accepted
17
+ and checked as the union. A fix spec can carry
18
+ `> **Incident:** incident-<name>` (linked as related on push) and
19
+ `> **Severity:**` (`1 - Critical` … `4 - Low`). Configs without any of the new
20
+ keys behave exactly as before, and `skitterspec update` ships the new skill
21
+ and rules.
22
+
23
+ Consumer config, by provider:
24
+
25
+ - **Azure Boards** —
26
+ `azure.workItemTypeByKind: { "issue": "Issue", "incident": "Incident" }`,
27
+ plus
28
+ `statesByType: { "Issue": { "complete": "Closed" }, "Incident": { "backlog": null, "complete": "Closed" } }`.
29
+ Severity writes the built-in `Microsoft.VSTS.Common.Severity` — nothing to
30
+ configure; a type without the field skips it with a note. The incident link
31
+ is `System.LinkTypes.Related`.
32
+ - **GitHub** — `github.labelsByKind` accepts the new kinds;
33
+ `statesByKind: { "issue": { "complete": "Done" } }` routes a kind's board
34
+ Status (`null` sends none); `github.severityLabels: { "2": "sev-high" }`
35
+ maps the header's leading digit to a label. The incident rides in the
36
+ generated body as a `Related incident: #N` line.
37
+ - **Jira** — `jira.issueTypeByKind` accepts the new kinds; `statesByType`
38
+ keys by issue type; `jira.severityField` names the field to write (e.g.
39
+ `customfield_10900`). The incident link is a `Relates` issue link, added
40
+ once.
41
+ - **Linear** — `linear.labelsByKind` accepts the new kinds; `statesByKind`
42
+ keys by spec kind; `linear.severityLabels` maps digits to team labels. The
43
+ incident link is a related-issue relation.
44
+
3
45
  ## The `chore` spec kind, and per-type bodies (additive — nothing breaks)
4
46
 
5
47
  Specs can now be **chores** (`chore-` prefix, `> **Type:** Chore`) and every
@@ -44,8 +44,10 @@ phase will read as deployed. See "Releases and deploys" below.
44
44
  | `github.statusField` | `Status` | The single-select carrying workflow state. |
45
45
  | `github.labels.spec` / `.phase` | `spec` / `phase` | Labels that tell a spec issue from a phase. Empty string = no label. |
46
46
  | `github.issueTypes.spec` / `.phase` | — | Issue type names. **Org-owned repos only** — naming one on a personal repo is refused by GitHub. |
47
- | `github.labelsByKind` | `{}` | One extra label per spec kind (`feature`/`bug`/`hotfix`/`chore`, from the folder prefix), applied beside `labels.spec` — `{ "chore": "chore" }` keeps tooling work filterable. Unmapped kinds add nothing. |
47
+ | `github.labelsByKind` | `{}` | One extra label per spec kind (`feature`/`bug`/`hotfix`/`chore`/`issue`/`incident`, from the folder prefix), applied beside `labels.spec` — `{ "chore": "chore" }` keeps tooling work filterable. Unmapped kinds add nothing. |
48
48
  | `states.<bucket>` | see table | Board Status option per lifecycle bucket — a string, or an array whose first name is written and whose rest are read-only aliases. |
49
+ | `statesByKind.<kind>.<bucket>` | see table | Per-KIND override laid over `states` (GitHub has no work item types, so the spec's kind keys it) — `{ "issue": { "complete": "Done" } }`. A bucket set to `null` sends no Status; open/close still follows the bucket. |
50
+ | `github.severityLabels.<digit>` | `{}` | A label per `Severity:` header digit (`"2 - High"` → `"2"`) — `{ "2": "sev-high" }`, applied at mint. Unset, the header stays repo-only. A fix spec's `Incident:` header rides in the generated body as a `Related incident: #N` line. |
49
51
  | `intake.label` | — | The label `/spec --from-issue` lists. |
50
52
  | `intake.bugLabels` / `.hotfixLabels` | `["bug"]` / `[]` | Labels that route an adopted issue to `/spec-bug` / `/spec-hotfix`. |
51
53
  | `auth.tokenEnv` | `GITHUB_TOKEN` | Env var holding the token; `GH_TOKEN` is read after it. |
@@ -7,9 +7,10 @@ and lifecycle stay consistent. Each sets a status on the spec header
7
7
 
8
8
  | Skill | Purpose | Status | Folder |
9
9
  |-------|---------|--------|--------|
10
- | `/spec` | (Feature/Chore) Grill to a clear shared understanding, propose the kind, write a groomed spec in its own worktree, then land it on the verdict | `Ready` (or `Draft`) | `specs/backlog/` (on the base branch, by a fast-forward) |
10
+ | `/spec` | (Feature/Chore/Issue) Grill to a clear shared understanding, propose the kind, write a groomed spec in its own worktree, then land it on the verdict | `Ready` (or `Draft`) | `specs/backlog/` (on the base branch, by a fast-forward) |
11
11
  | `/spec-bug` | (Bug) Reproduce with a failing test, capture spec, drive red→green | `In Progress` | `specs/in-progress/` |
12
12
  | `/spec-hotfix` | (Hotfix) Fork a worktree from a release tag, red→green, land by tag + cherry-pick | `In Progress` | `specs/in-progress/` |
13
+ | `/spec-incident` | (Incident) Capture a live outage as a record written during it — grill, write in flight, fixes as separate linked specs | `In Progress` | `specs/in-progress/` |
13
14
  | `/no-spec` | Work that genuinely has no spec — its own branch, worktree, page and land. Writes no spec and moves nothing through the lifecycle | `—` | (none) |
14
15
  | `/spec-review` | Re-validate a spec against the codebase; refresh stale parts | `—` | (unchanged) |
15
16
  | `/spec-start` | Put a spec in flight — provision its branch, then build phase 1 | `In Progress` | `specs/in-progress/` |
@@ -587,26 +588,34 @@ none of them describes.
587
588
  - **Other rules specs must honour:** link the relevant `.claude/rules/*.md`
588
589
  (architecture, code style, testing, database, etc.) rather than restating them.
589
590
 
590
- ## Spec types — Feature, Chore, Bug, Hotfix
591
+ ## Spec types — Feature, Chore, Issue, Bug, Hotfix, Incident
591
592
 
592
- Every spec is one of four types, recorded **both** in the header and the filename:
593
+ Every spec is one of six types, recorded **both** in the header and the filename:
593
594
 
594
595
  - **Header field:** `> **Type:** Feature`, `> **Type:** Chore`,
595
- `> **Type:** Bug`, or `> **Type:** Hotfix` (authoritative, greppable:
596
+ `> **Type:** Issue`, `> **Type:** Bug`, `> **Type:** Hotfix`, or
597
+ `> **Type:** Incident` (authoritative, greppable:
596
598
  `grep -rl 'Type:.*Hotfix' specs/`).
597
599
  - **Filename prefix:** `feat-<name>` for features, `chore-<name>` for chores,
598
- `bug-<name>` for bugs, `hotfix-<name>` for hotfixes (visible in listings;
600
+ `issue-<name>` for issues, `bug-<name>` for bugs, `hotfix-<name>` for
601
+ hotfixes, `incident-<name>` for incidents (visible in listings;
599
602
  glob-safe — never use `[BUG]`/`[FEATURE]` brackets).
600
603
 
601
- A **Chore** is work no end user sees — tooling, CI, dependency bumps, internal
602
- refactors. The line: anything that is not work end users see or functions they
603
- use within the app is a chore; everything user-facing is a feature. There is no
604
- separate entry skill — `/spec` **proposes** feature or chore from what the
604
+ A **Chore** is code work no end user sees — tooling, CI, dependency bumps,
605
+ internal refactors. An **Issue** is work with **no code change at all** —
606
+ in-app configuration, a data fix, a support task — written as a spec of manual
607
+ steps so there is a record and a history; everything user-facing that changes
608
+ code is a feature. There is no
609
+ separate entry skill for either — `/spec` **proposes** feature, chore or issue
610
+ from what the
605
611
  grilling defined, with a one-line reason, and the user confirms. A chore
606
612
  defaults its `Gating:` to `none: not user-facing` (where gating is configured),
607
613
  and its commits default to `chore`/`refactor`/`ci` types with **no**
608
614
  `Release-Note:` footer — a chore is by definition not user-visible, so it has
609
- no release note to write. Feature specs keep `feat`; bug specs keep `fix`.
615
+ no release note to write. An issue defaults its `Gating:` to `none: no code`
616
+ and its commits to `docs` with no `Release-Note:`, and it closes when the spec
617
+ completes — nothing is released. Feature specs keep `feat`; bug specs keep
618
+ `fix`.
610
619
  Where a ticketing provider maps kinds to tracker types (e.g. Azure's
611
620
  `workItemTypeByKind`), the chore mapping is what keeps tooling work off the
612
621
  customer-facing release ladder.
@@ -616,14 +625,75 @@ carries an extra `> **Base version:** <tag>` header, forks its worktree from tha
616
625
  tag, and lands by tagging a new patch + cherry-picking onto `main` (never a
617
626
  fast-forward merge). `/spec-live` refuses a hotfix — test it with `/spec-connect`.
618
627
 
619
- All four types share the same lifecycle folders below — type is orthogonal to
628
+ An **Incident** is an outage or degradation of a live service, captured by
629
+ **`/spec-incident`** during the outage, so it starts straight in
630
+ `specs/in-progress/`. It is a record, not delivery work: its fixes are
631
+ separate hotfix, bug, chore or issue specs, each carrying
632
+ `> **Incident:** incident-<name>` so the push links them, and they are never
633
+ its phases. It carries `> **Severity:**` (Azure's literal values,
634
+ `1 - Critical` … `4 - Low`) and a `## Timeline` appended to as the incident
635
+ unfolds; `/spec-complete` writes `incident-log.md` from it and pushes the log
636
+ onto the tracker item as a comment.
637
+
638
+ ### Kind routing — any door, the right spec
639
+
640
+ `/spec` is the default door, so the kind of work someone describes does not
641
+ always match the skill they typed — especially for someone new, for whom
642
+ "spec it" is the reflex. Every entry skill therefore
643
+ **watches its grill for the signals that mark the other kinds**, and proposes a
644
+ hand-off the moment one appears — never at the end of a grill already shaping
645
+ the wrong spec:
646
+
647
+ | In | Watches for | Hands to |
648
+ |----|-------------|----------|
649
+ | `/spec` | defect · defect on a released version · live outage | `/spec-bug` · `/spec-hotfix` · `/spec-incident` |
650
+ | `/spec-bug` | on a released version · live outage · not a defect | `/spec-hotfix` · `/spec-incident` · `/spec` |
651
+ | `/spec-hotfix` | live outage · not on a released version · not a defect | `/spec-incident` · `/spec-bug` · `/spec` |
652
+ | `/spec-incident` | no live outage to record | defect → `/spec-bug` (on a released version → `/spec-hotfix`), else `/spec` |
653
+
654
+ Feature, chore and issue all route to `/spec` — one door for the three kinds it
655
+ writes, where its kind proposal picks between them. Example signals, weighed in
656
+ context rather than matched as keywords: a **defect** is behaviour differing
657
+ from intended — "it's broken", a failing flow, a stack trace of a failure;
658
+ **on a released version** is that defect where what is deployed is named — "in
659
+ prod", "since v2.1"; a **live outage** is a service down or degraded
660
+ **right now**, users affected as we speak; **not a defect** is an ask for new or
661
+ changed behaviour rather than for restoring intended behaviour.
662
+
663
+ Three rules, the same in every skill:
664
+
665
+ - **Always confirm; never silently switch.** Name the signal in the user's own
666
+ words and propose the destination with a one-line reason; the user confirms
667
+ or declines. A decline ends the matter — the grill carries on where it was,
668
+ and the same signal is not raised again. A signal is a question, never a
669
+ verdict: a pasted stack trace in "handle this error nicely" is a feature
670
+ request, not a bug report.
671
+ - **Precedence: incident > hotfix > bug.** One description can carry several
672
+ signals; propose the most specific destination — the same reasoning the
673
+ intake label routing documents for hotfix-over-bug.
674
+ - **Hand off in-session, carrying the context.** On a confirmed switch the
675
+ current skill invokes the destination skill directly and seeds it with
676
+ everything the grilling has already established — symptom, version, impact,
677
+ repro material, decisions so far — so the destination grills only what it
678
+ still needs ("seed, don't skip, the grill", the principle issue adoption
679
+ already uses). Stop-and-retype is the **label** routing's shape, and right
680
+ there because it fires before any grilling; mid-grill it would throw away
681
+ the answers already given.
682
+
683
+ This is judgment, not configuration: the signals are examples, there is no
684
+ list to maintain, and nothing here reads a label. A ticketing provider's
685
+ intake label routing (`intake.bugLabels` / `intake.hotfixLabels`) is a
686
+ separate, earlier check and is unchanged by this.
687
+
688
+ All six types share the same lifecycle folders below — type is orthogonal to
620
689
  status.
621
690
 
622
691
  ## Header fields & State log (audit trail)
623
692
 
624
693
  Every spec header carries:
625
694
 
626
- - `> **Name:**` — the spec's folder name (`feat-`/`bug-`/`hotfix-<kebab-name>`).
695
+ - `> **Name:**` — the spec's folder name
696
+ (`feat-`/`chore-`/`issue-`/`bug-`/`hotfix-`/`incident-<kebab-name>`).
627
697
  It's the handle you pass to `/spec-start` and the other lifecycle skills, surfaced
628
698
  in the header so it's copy-pasteable without digging for the folder name.
629
699
  - `> **Author:**` — who created the spec (set at `/spec` / `/spec-bug`, defaults
@@ -634,6 +704,14 @@ Every spec header carries:
634
704
  **only when `specs/.core/gating.config.json` exists**: a flag name, or
635
705
  `none: <one-line reason>`. Absent entirely in a project that has not adopted
636
706
  gating.
707
+ - `> **Severity:**` — on bug, hotfix and incident specs, optional except where
708
+ `/spec-incident` grills it: Azure's literal values
709
+ (`1 - Critical` … `4 - Low`). The push writes it where the provider has a
710
+ home for it; absent, nothing is sent.
711
+ - `> **Incident:**` — on a spec that is a **fix** for an open incident:
712
+ `incident-<name>`. The push links the two as related on the tracker
713
+ (one-way; the repo owns the link), and `/spec-complete` on the incident
714
+ counts the spec among its fixes. Absent on everything else.
637
715
 
638
716
  Every spec also has a **State log** table — the audit trail of folder/status
639
717
  transitions. Each lifecycle skill appends exactly one row when it changes state:
@@ -668,7 +746,7 @@ When asked for a plan, implementation strategy, or feature breakdown:
668
746
 
669
747
  ```
670
748
  specs/backlog/ Ready (or Draft) specs (/spec)
671
- specs/in-progress/ under active implementation (/spec-start, /spec-bug)
749
+ specs/in-progress/ under active implementation (/spec-start, /spec-bug, /spec-incident)
672
750
  specs/complete/ finished (/spec-complete)
673
751
  specs/cancelled/ abandoned, with a reason on the header (/spec-cancel)
674
752
  specs/.core/ project rules — ALWAYS APPLY, never moved
@@ -191,31 +191,78 @@ not write the spec until this is resolved.
191
191
  Stop grilling when there are no unresolved branches that would change the spec.
192
192
  Briefly play back the agreed understanding before writing.
193
193
 
194
- ### Propose the kind — feature or chore
195
-
196
- This skill writes two kinds of spec, and
194
+ ### Watch for the other doors — bug, hotfix, incident
195
+
196
+ `/spec` is the default door, so work that belongs to another skill arrives here
197
+ described in the user's own words — no issue, no labels for Phase 0 to route
198
+ on. While grilling, watch for the signals that mark the other kinds and raise
199
+ the hand-off **the moment one appears**, not at the end of the grill: for a
200
+ live outage especially, finishing a feature grill first is actively harmful,
201
+ because `/spec-incident` exists to be written *during* the outage.
202
+
203
+ - **Defect** — behaviour differing from intended ("it's broken", a failing
204
+ flow, a stack trace of a failure) → propose **`/spec-bug`**.
205
+ - **Defect on a released version** — the defect is on what is deployed ("in
206
+ prod", "since v2.1") → propose **`/spec-hotfix`**.
207
+ - **Live outage** — a service down or degraded **right now**, users affected
208
+ as we speak → propose **`/spec-incident`**.
209
+
210
+ **Always confirm; never silently switch.** Name the signal in the user's own
211
+ words, propose the destination with a one-line reason, and let them decide. A
212
+ decline carries the grill on where it was, and the same signal is not raised
213
+ again. A signal is a question, never a verdict: a pasted stack trace in
214
+ "handle this error nicely" is a feature request. When one description carries
215
+ several signals, propose the most specific destination —
216
+ **incident > hotfix > bug**.
217
+
218
+ **On a confirmed switch, hand off in-session and carry the context.** Invoke
219
+ the destination skill directly and seed it with everything the grilling has
220
+ already established — symptom, version, impact, repro material, decisions so
221
+ far — so it grills only what it still needs ("seed, don't skip, the grill",
222
+ exactly as issue adoption does). Do not stop and tell the user to retype: that
223
+ shape belongs to Phase 0's label routing, which fires before any grilling has
224
+ happened and so has nothing to lose. The full routing matrix lives in
225
+ `.claude/rules/spec-planning.md`.
226
+
227
+ ### Propose the kind — feature, chore or issue
228
+
229
+ This skill writes three kinds of spec, and
197
230
  **you propose which from what the grilling defined, with a one-line reason; the user confirms or overrides.**
198
231
  The
199
- line that decides it: a **chore** is anything that is not work end users see or
200
- functions they use within the app — tooling, CI, dependency bumps, internal
201
- refactors. Everything user-facing is a **feature**. So the proposal reads like
202
- *"no user-visible surface → chore"* or *"adds an endpoint users call → feature"*.
232
+ lines that decide it: a **chore** is code work no end user sees — tooling, CI,
233
+ dependency bumps, internal refactors. An **issue** is work with
234
+ **no code change at all** — in-app configuration, a data fix, a support task —
235
+ written as a spec of manual steps so there is a record and a history.
236
+ Everything user-facing that changes code is a **feature**. So the proposal
237
+ reads like *"no user-visible surface → chore"*, *"no code change, manual
238
+ steps → issue"* or *"adds an endpoint users call → feature"*.
203
239
 
204
240
  The kind is recorded twice, and both follow from the answer: the folder prefix
205
- (`feat-` / `chore-`) and the `> **Type:**` header (`Feature` / `Chore`). A chore
241
+ (`feat-` / `chore-` / `issue-`) and the `> **Type:**` header
242
+ (`Feature` / `Chore` / `Issue`). A chore
206
243
  also defaults its `Gating:` to `none: not user-facing` (only when gating is
207
244
  configured — offer the default, let the user override it like any other
208
245
  answer), and its commits default to `chore`/`refactor`/`ci` types with no
209
- `Release-Note:` (see `.claude/rules/spec-planning.md`).
210
-
211
- There is no `/spec-chore` and none should be added: one entry point, one grill,
212
- and the kind is an output of understanding the work rather than a door the user
213
- must pick before describing it.
246
+ `Release-Note:` (see `.claude/rules/spec-planning.md`). An issue defaults its
247
+ `Gating:` to `none: no code`, and its commits to `docs` with no
248
+ `Release-Note:` — its phases are manual steps, not code, though `/spec-start`
249
+ still gives it a worktree, because the document needs one and the history is
250
+ the point.
251
+
252
+ There is no `/spec-chore` or `/spec-issue` and none should be added: one entry
253
+ point, one grill, and the kind is an output of understanding the work rather
254
+ than a door the user must pick before describing it. The kinds with their own
255
+ doors — bug, hotfix, and the **incident**, an outage or degradation of a live
256
+ service that needs a different grill and starts mid-flight — are the watch's
257
+ business above: when the grilling uncovers one, hand off to **`/spec-bug`**,
258
+ **`/spec-hotfix`** or **`/spec-incident`** rather than writing it here, and it
259
+ is never too late to propose that — reaching this proposal with the signal
260
+ unraised is a missed watch, not a reason to write the wrong kind.
214
261
 
215
262
  ## Phase B — write the spec
216
263
 
217
- This skill is for **features and chores**. For bugs, use `/spec-bug`
218
- (test-first, red→green).
264
+ This skill is for **features, chores and issues**. For bugs, use `/spec-bug`
265
+ (test-first, red→green); for a live outage, `/spec-incident`.
219
266
 
220
267
  ### Write it in its own worktree
221
268
 
@@ -283,7 +330,8 @@ move to, **warn, don't refuse**, and say the trailer for that commit wants
283
330
  notes. **Even a single-phase spec gets `01-….md`** — never lump phase tasks
284
331
  into `00-overview.md`. This keeps each phase easy to dive into on its own.
285
332
  - Choose a short kebab-case name and **prefix it with the kind** — `feat-` for
286
- a feature, `chore-` for a chore (the bug counterpart uses `bug-`).
333
+ a feature, `chore-` for a chore, `issue-` for an issue (the bug counterpart
334
+ uses `bug-`, the incident one `incident-`).
287
335
 
288
336
  Use this template (keep it **as concise as possible** — no filler, no restating
289
337
  the codebase, link rather than duplicate):
@@ -291,8 +339,8 @@ the codebase, link rather than duplicate):
291
339
  ```markdown
292
340
  # <Feature title>
293
341
 
294
- > **Type:** <Feature or Chore — the kind proposed after Phase A>
295
- > **Name:** <feat- or chore-><kebab-name> (the spec folder name — the handle you paste into `/spec-start`)
342
+ > **Type:** <Feature, Chore or Issue — the kind proposed after Phase A>
343
+ > **Name:** <feat-, chore- or issue-><kebab-name> (the spec folder name — the handle you paste into `/spec-start`)
296
344
  > **Status:** Ready — not started
297
345
  > **Author:** <git user.name — `git config user.name`>
298
346
  > **Developer:** —
@@ -300,6 +348,10 @@ the codebase, link rather than duplicate):
300
348
  > **Area:** <comma-separated files/modules this touches>
301
349
  > **Stack:** <worktree — or "worktree + docker" if it touches the DB/stateful
302
350
  > services; only acted on when isolation is enabled — see Phase A item 9>
351
+ > **Incident:** <incident-<name> — only when this spec is a fix for an open
352
+ > incident spec; the next push links the two as related on the tracker, and
353
+ > `/spec-complete` on the incident counts this spec among its fixes. Omit the
354
+ > line entirely otherwise>
303
355
  > **Gating:** <flag name — or "none: <one-line reason>". Only when release gating
304
356
  > is configured; omit the line entirely otherwise. A chore defaults to
305
357
  > "none: not user-facing". An empty value or a bare
@@ -153,6 +153,38 @@ Bugs are concrete — confirm, don't over-grill. Establish:
153
153
  against the broken one (the bug usually lives in the differential). Do NOT
154
154
  patch a symptom before you understand the cause.
155
155
 
156
+ ### Watch for the other doors — hotfix, incident, or not a bug at all
157
+
158
+ The investigation above is where mis-entry shows, so watch it for the signals
159
+ that mark the other kinds and raise the hand-off the moment one appears —
160
+ before the failing test is written, while nothing is on disk
161
+ (`.claude/rules/spec-planning.md` carries the full routing matrix):
162
+
163
+ - **On a released version** — the defect is on what is deployed ("in prod",
164
+ "since v2.1") → propose **`/spec-hotfix`**. This is the escalation that must
165
+ not be missed: a fix built here lands on `main` and never reaches the
166
+ running version.
167
+ - **Live outage** — a service down or degraded **right now** → propose
168
+ **`/spec-incident`**; the record comes first, and the fix returns as a
169
+ linked spec.
170
+ - **Not a defect** — the ask is new or changed behaviour, not restoring
171
+ intended behaviour → propose **`/spec`**, whose kind proposal picks feature,
172
+ chore or issue from there.
173
+
174
+ **Always confirm; never silently switch** — name the signal in the user's own
175
+ words with a one-line reason, and a decline carries this skill on where it
176
+ was, the same signal not raised again. When several signals appear at once,
177
+ propose the most specific destination — incident over hotfix.
178
+ **On a confirmed switch, hand off in-session and carry the context**: invoke
179
+ the destination skill directly and seed it with what §1 established — symptom,
180
+ repro, root-cause notes, any version named — so it grills only what it still
181
+ needs.
182
+
183
+ **Once the failing test exists, the repro is evidence, not a question to re-litigate**
184
+ — but evidence can still escalate: a red test that also fails at
185
+ the released tag is the hotfix signal with proof attached, and the hand-off
186
+ carries the failing test across.
187
+
156
188
  ## 2. Isolate the fix in a worktree — when isolation is enabled
157
189
 
158
190
  **Only when per-spec isolation is enabled** (`specs/.core/env.config.json`
@@ -272,6 +304,10 @@ because work is already underway. Keep it lean:
272
304
  > **Developer:** <git user.name — you, since you're fixing it now>
273
305
  > **Raised:** <YYYY-MM-DD (today)>
274
306
  > **Area:** <files/modules>
307
+ > **Severity:** <Azure's literal values, "1 - Critical" … "4 - Low" — optional;
308
+ > the push writes it where the provider has a home for it. Omit otherwise>
309
+ > **Incident:** <incident-<name> — only when this bug is a fix for an open
310
+ > incident spec; the next push links the two as related. Omit otherwise>
275
311
  > **Gating:** <flag name — or "none: <one-line reason>". Only when release gating
276
312
  > is configured; omit the line entirely otherwise>
277
313
 
@@ -42,6 +42,45 @@ Before marking complete, confirm the work is actually finished:
42
42
  is its own, and step 4 commits that.
43
43
 
44
44
 
45
+ ### An incident spec — the log, and the open-fix check
46
+
47
+ **Only for `Type: Incident` specs** (folder prefix `incident-`); every other
48
+ kind skips this in silence.
49
+
50
+ 1. **Check for open linked fixes.** Grep `specs/backlog/` and
51
+ `specs/in-progress/` for specs carrying `> **Incident:** <this spec's name>`.
52
+ Any hit is a fix still open: **refuse**, naming each one, and offer to
53
+ complete anyway with it listed as outstanding in the log — the operator
54
+ answers; record the choice in the spec's Changelog either way.
55
+ BLIND SPOT, named: a fix spec authored but not yet landed on the base branch
56
+ is invisible to this grep — acceptable, because `/spec`'s committing
57
+ verdicts land authored specs on the base
58
+ (`.claude/rules/negative-checks.md`).
59
+ 2. **Write `incident-log.md`** into the spec folder — the stakeholder- and
60
+ support-facing record, built from the spec and its linked fixes:
61
+ summary · severity · timeline (started, detected, mitigated, resolved) ·
62
+ impact (who, what, for how long) · root cause · the fixes (each linked
63
+ spec, its ticket, and the release it shipped in — `spec-sync released`
64
+ answers that where a provider is installed; a fix completed but not yet
65
+ released is listed as such) · what went well and what didn't · follow-ups,
66
+ each offered as a `/spec` on the spot.
67
+ 3. **Push the log onto the incident item as a comment** (only when a provider
68
+ is installed and the spec is linked):
69
+
70
+ ```
71
+ skitterspec spec-sync comment <spec> --file specs/in-progress/<spec>/incident-log.md
72
+ ```
73
+
74
+ A comment, deliberately: the item's description is generated from the spec,
75
+ so a log written there would be clobbered by the next push — comments are
76
+ the one surface one-way sync never touches. The command exits 0 on every
77
+ cannot-tell (unlinked, offline, no credentials) and says so; relay the line
78
+ and finish either way — the log in the repo is the record.
79
+
80
+ Completion then proceeds as normal: the per-type state map decides what the
81
+ tracker is sent (an Incident completes to whatever `statesByType` names for
82
+ it), and steps 3–7 below are unchanged.
83
+
45
84
  ### Release gating (only when configured)
46
85
 
47
86
  **Only when `specs/.core/gating.config.json` exists.** Run
@@ -180,6 +180,27 @@ Hotfixes are concrete — confirm, don't over-grill. Establish:
180
180
  - **Root cause:** read the code **at the base tag** and trace it to `file:line`.
181
181
  The fix belongs on the tag's line, so reason about that code, not `main`'s.
182
182
 
183
+ ### Watch for the other doors — incident, bug, or not a defect
184
+
185
+ This is the most specific defect door, so most mis-entries route *down*
186
+ (`.claude/rules/spec-planning.md` carries the full routing matrix):
187
+
188
+ - **Live outage** — the released version is not just wrong but down or
189
+ degraded **right now** → propose **`/spec-incident`**; the record comes
190
+ first, and the fix returns here as a linked hotfix spec.
191
+ - **Not on a released version** — §1 cannot name a deployed tag the defect is
192
+ on (it exists only on `main`, or prod runs something newer that is fine) →
193
+ propose **`/spec-bug`**; a hotfix branch for something `main` can carry is
194
+ waste, not safety.
195
+ - **Not a defect** — the ask is new or changed behaviour, not restoring
196
+ intended behaviour → propose **`/spec`**.
197
+
198
+ **Always confirm; never silently switch** — name the signal in the user's own
199
+ words with a one-line reason; a decline carries this skill on where it was.
200
+ **On a confirmed switch, hand off in-session and carry the context**
201
+ established so far — the symptom, the repro, any version discussion — so the
202
+ destination grills only what it still needs.
203
+
183
204
  ## 3. Provision the worktree from the tag, then write in it
184
205
 
185
206
  **Provision before you write, not after.** §1 settled the tag and the name and
@@ -296,6 +317,10 @@ is usually a single-pass fix, so the `## Fix` block can live directly in
296
317
  > **Base version:** <tag prod is running, e.g. v33.16.4>
297
318
  > **Raised:** <YYYY-MM-DD (today)>
298
319
  > **Area:** <files/modules>
320
+ > **Severity:** <Azure's literal values, "1 - Critical" … "4 - Low" — optional;
321
+ > the push writes it where the provider has a home for it. Omit otherwise>
322
+ > **Incident:** <incident-<name> — only when this hotfix is a fix for an open
323
+ > incident spec; the next push links the two as related. Omit otherwise>
299
324
  > **Gating:** <pre-filled "none: hotfix — restoring released behaviour"; only
300
325
  > when release gating is configured, and overridable — see below>
301
326
 
@@ -0,0 +1,164 @@
1
+ ---
2
+ name: spec-incident
3
+ description: Capture a live incident — an outage or degradation of a running service — as an Incident-type spec written during the outage. Grills for what is down, since when, who is affected, severity and what was tried, then writes the spec straight into specs/in-progress/ with a Timeline appended to as it unfolds. Fixes are separate linked specs, never phases. Use when the user says "/spec-incident", "we have an outage", "prod is down and I need an incident record", or asks to track an incident.
4
+ ---
5
+
6
+ # /spec-incident — capture a live incident
7
+
8
+ > Stay silent while this runs — speak only to ask something you cannot answer
9
+ > yourself, or to report a failure at the moment it happens. Read
10
+ > `.claude/rules/spec-reports.md` before reporting; it defines the block this
11
+ > skill ends with.
12
+
13
+ An **incident** is an outage or degradation of a live service. It is not
14
+ delivery work: the fixes are separate hotfix, bug, chore or issue specs, each
15
+ linked back to it, and this spec is the **record** — what happened, when, to
16
+ whom, and what was done. It is written **during** the outage, so it starts in
17
+ `specs/in-progress/`, there is no backlog stop and no review page to wait on:
18
+ speed matters, and the record is reviewed at completion, when
19
+ `/spec-complete` writes the incident log from it.
20
+
21
+ **This skill is not the response.** Mitigating comes first, and nothing here
22
+ blocks it — the grill is short, the spec is small, and everything else is
23
+ appended as it happens.
24
+
25
+ ## 1. Grill — short, and only what the record needs
26
+
27
+ Ask for exactly these, batched, with nothing speculative:
28
+
29
+ 1. **What is down or degraded** — the service, and how it is failing.
30
+ 2. **Since when** — first report, and detection time where they differ.
31
+ 3. **Who is affected** — which users or systems, and how badly.
32
+ 4. **Severity** — Azure's literal values: `1 - Critical`, `2 - High`,
33
+ `3 - Medium`, `4 - Low`. Propose one from the impact described; the user
34
+ confirms.
35
+ 5. **What has been tried** — anything already attempted, and its effect.
36
+
37
+ A root cause is **not** grilled: nobody has it yet, and the Timeline is where
38
+ the investigation lands as it happens.
39
+
40
+ ### No live outage to record — route to the right door
41
+
42
+ This is the costliest door to enter wrongly — no backlog stop, no review page,
43
+ straight into `specs/in-progress/` — so the grill's own answers are also its
44
+ exit. When items 1 and 2 establish there is **no outage to record** — nothing
45
+ is down or degraded, it never was live, or it is a risk rather than an event —
46
+ propose the right door instead of writing an incident
47
+ (`.claude/rules/spec-planning.md` carries the full routing matrix):
48
+
49
+ - a **defect** → **`/spec-bug`**, or **`/spec-hotfix`** when it is on a
50
+ released version;
51
+ - anything else → **`/spec`**, whose kind proposal picks feature, chore or
52
+ issue from there.
53
+
54
+ **A past outage someone wants a record of stays an incident**: "it is over" is
55
+ not "it never happened" — the signal is *no outage to record*, not *no outage
56
+ now*. This check is the grill's existing questions read honestly, never an
57
+ extra round trip, and the hand-off contract is the same as everywhere else:
58
+ confirm first, naming the signal in the user's own words; a decline carries
59
+ this skill on; on a confirmed switch invoke the destination skill in-session,
60
+ seeded with everything already established.
61
+
62
+ ## 2. Write it, in flight
63
+
64
+ Pick a short kebab name prefixed `incident-` (e.g. `incident-api-outage`).
65
+
66
+ **With per-spec isolation** (`specs/.core/env.config.json` present), provision
67
+ before writing, exactly as `/spec` Phase B does: run
68
+ `skitterspec spec-env up <name> --docs`, run the commands it prints, `cd` into
69
+ the worktree, and confirm with a bare `skitterspec spec-env resolve` naming
70
+ this spec. Without isolation, write where you stand.
71
+
72
+ The spec is a folder in **`specs/in-progress/`** — never backlog — with
73
+ `00-overview.md` and one phase file:
74
+
75
+ ```markdown
76
+ # Incident: <short title>
77
+
78
+ > **Type:** Incident
79
+ > **Name:** incident-<kebab-name>
80
+ > **Status:** In Progress — live (started <YYYY-MM-DD>)
81
+ > **Author:** <git user.name>
82
+ > **Developer:** <git user.name — whoever is running the incident>
83
+ > **Raised:** <YYYY-MM-DD (today)>
84
+ > **Severity:** <1 - Critical … 4 - Low>
85
+ > **Gating:** <pre-filled "none: incident record, no code"; only when release
86
+ > gating is configured, omit otherwise>
87
+
88
+ ## Impact
89
+
90
+ <who is affected, what is failing, since when — from the grill>
91
+
92
+ ## Timeline
93
+
94
+ - <YYYY-MM-DD HH:MM> — <first report / detected / what was tried / what changed>
95
+
96
+ ## Fixes
97
+
98
+ <one line per fix spec as they are opened — see step 4. "None yet" until then.>
99
+
100
+ ## State log
101
+
102
+ | Date | Status | Folder | By |
103
+ |------|--------|--------|----|
104
+ | <YYYY-MM-DD> | In Progress | in-progress | <author> |
105
+
106
+ ## Changelog
107
+
108
+ - <YYYY-MM-DD> — Incident captured.
109
+ ```
110
+
111
+ The phase file `01-response.md` holds the response as tasks — mitigate,
112
+ diagnose, open fix specs, verify recovery — manual steps, not code. Commits in
113
+ this spec default to `docs` with no `Release-Note:`.
114
+
115
+ ## 3. Link to the tracker (only if a provider is installed)
116
+
117
+ Run the provider's linking push exactly as `/spec` Phase E describes — the
118
+ spec is already in `in-progress`, so the mint lands in the incident's
119
+ in-flight state (with Azure's `statesByType`, an Incident is created Active
120
+ and never sent New; the `Severity:` header is written where the provider has a
121
+ home for it). No provider, or an unreachable tracker, is one line and the
122
+ record stands in the repo.
123
+
124
+ ## 4. Run the incident from the spec
125
+
126
+ - **Append to the Timeline** as things happen — dated lines, cheap and often.
127
+ - **Fixes are separate specs**: a prod-version fix is `/spec-hotfix`, a
128
+ mainline defect `/spec-bug`, tooling `/spec` (chore), manual remediation
129
+ `/spec` (issue). Each fix spec carries `> **Incident:** incident-<name>` in
130
+ its header, which the next push turns into a related link on the tracker.
131
+ They are never phases of this spec.
132
+ - **Mid-incident board states stay manual**: skitterspec writes states at
133
+ lifecycle moves only, so moving the ticket to a Mitigated-style state during
134
+ the outage is done on the board, and the next push leaves it until the spec
135
+ itself moves.
136
+
137
+ ## 5. End of the outage is not the end of the spec
138
+
139
+ When the service is recovered, say so in the Timeline and keep the spec in
140
+ flight until the record is complete — root cause written, fixes linked.
141
+ `/spec-complete` is the ending: it writes `incident-log.md` from this spec and
142
+ its linked fixes, refuses while a linked fix is still open (and offers to
143
+ complete anyway with it listed as outstanding), and pushes the log onto the
144
+ incident item as a comment.
145
+
146
+ ## Report
147
+
148
+ End with the block defined in `.claude/rules/spec-reports.md`. That file
149
+ carries the shape; this section carries only what is specific here.
150
+
151
+ **Verdicts**
152
+
153
+ - `✅` — the incident spec is written, in flight, and (where a provider is
154
+ installed) linked.
155
+ - `⚠️` — written and in flight, with something worth knowing (a mint that
156
+ failed, a worktree that could not be provisioned so it was written in
157
+ place).
158
+ - `⏸` — the grill could not establish what is down, so nothing was written.
159
+
160
+ **Fields:** `Tracker` · `Branch` · `Spec` · `Built` · `Worktree` ·
161
+ `Follow-ups` · `Next`
162
+
163
+ `Next` is the response itself — the first task of `01-response.md` — never a
164
+ review page: nothing here waits on a verdict while a service is down.
@@ -27,8 +27,9 @@ clobber customised content. Finish with a summary of created vs already-present.
27
27
  > **Leave alone**. Non-interactively it only adds what's missing; `--resync` /
28
28
  > `--reset` (reset needs `--yes`) drive the stronger actions.
29
29
 
30
- The system is **thirteen skills**: `spec` (feature), `spec-bug` (bug),
30
+ The system is **fourteen skills**: `spec` (feature, chore or issue), `spec-bug` (bug),
31
31
  `spec-hotfix` (a bug fixed on a released tag),
32
+ `spec-incident` (a live outage, recorded as it happens),
32
33
  `no-spec` (work that genuinely has none — off the base branch all the same),
33
34
  `spec-review`, `spec-start`,
34
35
  `spec-next`, `spec-diff` (read a spec's diff as a page),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skitterbyte/skitterspec-github",
3
- "version": "2.1.0",
3
+ "version": "2.3.0",
4
4
  "description": "Spec-driven development for Claude Code, with one-way GitHub sync — a superset of @skitterbyte/skitterspec: the base filesystem workflow plus /spec-status · /spec-push · /spec-claim and the spec-sync CLI, mirroring specs to GitHub Issues, sub-issues and a Projects v2 board, with GitHub Releases. The repo is canonical; GitHub is a generated mirror. Install this OR the base OR one other superset — exactly one.",
5
5
  "keywords": [
6
6
  "claude",
package/src/cli.js CHANGED
@@ -906,7 +906,7 @@ function specEnvUp(dir, config, specArg, flags = {}) {
906
906
  try {
907
907
  spec = resolveSpecWithWorktree(dir, config, specArg)
908
908
  } catch (err) {
909
- const specShaped = typeof specArg === 'string' && /^(feat|bug|hotfix|chore)-./.test(specArg)
909
+ const specShaped = typeof specArg === 'string' && /^(feat|bug|hotfix|chore|issue|incident)-./.test(specArg)
910
910
  if (err.code !== 'SPEC_NOT_FOUND' || !docs || !specShaped || config.mode === 'checkout') {
911
911
  throw err
912
912
  }
@@ -4,7 +4,7 @@
4
4
  * Pure spec/branch resolution for per-spec isolation.
5
5
  *
6
6
  * Given a spec argument (a folder name or path) it locates the spec folder under
7
- * `specs/**`, splits the `feat-`/`bug-`/`hotfix-`/`chore-` prefix into
7
+ * `specs/**`, splits the `feat-`/`bug-`/`hotfix-`/`chore-`/`issue-`/`incident-` prefix into
8
8
  * `{ type, slug }`, derives the
9
9
  * git branch from the config's `branch.pattern` (provider-neutral; `{identifier}`
10
10
  * is filled from a tracker id when one is configured, else it falls back to
@@ -295,10 +295,11 @@ function phaseIsDone(text) {
295
295
  return /^#\s.*✅\s*$/m.test(text)
296
296
  }
297
297
 
298
- // Split a `feat-`/`bug-`/`hotfix-`/`chore-` prefix. Unknown prefix → type
299
- // defaults to `feat` and the whole folder name is the slug.
298
+ // Split a `feat-`/`bug-`/`hotfix-`/`chore-`/`issue-`/`incident-` prefix.
299
+ // Unknown prefix → type defaults to `feat` and the whole folder name is the
300
+ // slug.
300
301
  function splitPrefix(folder) {
301
- const m = /^(feat|bug|hotfix|chore)-(.+)$/.exec(folder)
302
+ const m = /^(feat|bug|hotfix|chore|issue|incident)-(.+)$/.exec(folder)
302
303
  if (m) return { type: m[1], slug: m[2] }
303
304
  return { type: 'feat', slug: folder }
304
305
  }
@@ -28,6 +28,8 @@ const {
28
28
  validateStates,
29
29
  stateSuggestions,
30
30
  stateNamesFor,
31
+ effectiveStates,
32
+ specHeaders,
31
33
  remoteDescriptionEdited,
32
34
  writeFrontmatter,
33
35
  stampSubIssueId,
@@ -145,12 +147,19 @@ function specKindOf(snapshotDir) {
145
147
  if (name.startsWith('bug-')) return 'bug'
146
148
  if (name.startsWith('hotfix-')) return 'hotfix'
147
149
  if (name.startsWith('chore-')) return 'chore'
150
+ if (name.startsWith('issue-')) return 'issue'
151
+ if (name.startsWith('incident-')) return 'incident'
148
152
  return 'feature'
149
153
  }
150
154
 
151
- function applyOps({ adapter, config, kind = 'feature' }) {
155
+ function applyOps({ adapter, config, kind = 'feature', snapshotDir = null }) {
156
+ // Per-kind resolution: GitHub has no work item types, so statesByKind keys
157
+ // the override by the SPEC's kind. Null means "send no Status for this
158
+ // bucket" — the open/close half of settle still runs, since closing is
159
+ // derived from the bucket, not from the Status column.
152
160
  const statusFor = (bucket) => {
153
- const name = config.states && config.states[bucket]
161
+ const name = effectiveStates(config, config.statesByKind, kind)[bucket]
162
+ if (name === null) return null
154
163
  if (!name) {
155
164
  throw new Error(`no state configured for the "${bucket}" bucket — fix ${CONFIG_FILE} -> states`)
156
165
  }
@@ -160,7 +169,8 @@ function applyOps({ adapter, config, kind = 'feature' }) {
160
169
  if (!bucket) return
161
170
  const issue = issueOrRef && issueOrRef.nodeId ? issueOrRef : await adapter.readIssue(issueOrRef)
162
171
  if (!issue) throw new Error(`no GitHub issue found for ${issueOrRef}`)
163
- const changed = await adapter.setStatus(issue, statusFor(bucket))
172
+ const status = statusFor(bucket)
173
+ const changed = status === null ? { changed: false } : await adapter.setStatus(issue, status)
164
174
  const reason = closeReasonForBucket(bucket)
165
175
  const wantOpen = !reason
166
176
  if (issue.open === wantOpen) return
@@ -202,6 +212,15 @@ function applyOps({ adapter, config, kind = 'feature' }) {
202
212
  if (kindLabel && !spec.labels.some((l) => l.toLowerCase() === kindLabel.toLowerCase())) {
203
213
  spec.labels = [...spec.labels, kindLabel]
204
214
  }
215
+ // The `Severity:` header's label (github.severityLabels, keyed by the
216
+ // leading digit — "2 - High" → "2"). Opt-in: unset, the header stays
217
+ // repo-only and the payload is byte-identical to before.
218
+ const severity = snapshotDir ? specHeaders(snapshotDir, config).severity : null
219
+ const severityDigit = severity ? (/^([1-4])/.exec(severity) || [])[1] : null
220
+ const severityLabel = severityDigit ? (config.github.severityLabels || {})[severityDigit] : null
221
+ if (severityLabel && !spec.labels.some((l) => l.toLowerCase() === severityLabel.toLowerCase())) {
222
+ spec.labels = [...spec.labels, severityLabel]
223
+ }
205
224
  return {
206
225
  prevalidateStates: (buckets) => {
207
226
  for (const bucket of buckets) statusFor(bucket)
@@ -396,7 +415,7 @@ async function specSyncApply(dir, config, specArg, flags, out, err) {
396
415
  snapshotDir,
397
416
  plan,
398
417
  adapter: cred.adapter,
399
- ops: applyOps({ adapter: cred.adapter, config, kind: specKindOf(snapshotDir) }),
418
+ ops: applyOps({ adapter: cred.adapter, config, kind: specKindOf(snapshotDir), snapshotDir }),
400
419
  forceNew: !!flags.forceNew,
401
420
  program: PROGRAM,
402
421
  })
@@ -1032,6 +1051,49 @@ async function specSyncPreserve(dir, config, specArg, flags, out) {
1032
1051
  }
1033
1052
  }
1034
1053
 
1054
+ // `comment <spec> --file <f>` — post a file's markdown onto the spec's issue
1055
+ // as a comment: the one surface one-way sync never touches, so no later push
1056
+ // can clobber it. `/spec-complete` posts an incident's log through this.
1057
+ // Misuse (no readable file) exits 1; every cannot-tell exits 0 and says so.
1058
+ async function specSyncComment(dir, config, specArg, flags, out) {
1059
+ const snapshotDir = resolveOrExit(specArg, dir, out)
1060
+ if (!snapshotDir) return 1
1061
+ const done = (msg) => {
1062
+ out.write(`${PROGRAM} comment: ${msg}\n`)
1063
+ return 0
1064
+ }
1065
+ if (!flags.file) {
1066
+ out.write(`${PROGRAM} comment: pass --file <markdown file to post>\n`)
1067
+ return 1
1068
+ }
1069
+ let body
1070
+ try {
1071
+ body = fs.readFileSync(flags.file, 'utf-8')
1072
+ } catch (error) {
1073
+ out.write(`${PROGRAM} comment: cannot read --file: ${error.message}\n`)
1074
+ return 1
1075
+ }
1076
+ if (!body.trim()) {
1077
+ out.write(`${PROGRAM} comment: --file is empty — nothing to post\n`)
1078
+ return 1
1079
+ }
1080
+ const overviewFile = (config.snapshot && config.snapshot.overviewFile) || '00-overview.md'
1081
+ const identifier = specHelpers.linkedIdentifier(path.join(snapshotDir, overviewFile), config)
1082
+ if (!identifier) return done(`${path.basename(snapshotDir)} is not linked — nothing posted`)
1083
+ const cred = apiAdapterFor(config, flags)
1084
+ const transport = kit.resolveTransport(flags, config, cred.ok)
1085
+ if (transport === 'mcp') {
1086
+ return done(`transport = mcp — post the file's contents onto ${identifier} with add_issue_comment yourself`)
1087
+ }
1088
+ if (!cred.ok) return done(`no token — ${cred.error.split('\n')[0]}; nothing posted`)
1089
+ try {
1090
+ await cred.adapter.createComment(identifier, body)
1091
+ return done(`${identifier} — comment posted (${body.length} characters)`)
1092
+ } catch (error) {
1093
+ return done(`could not reach GitHub (${String(error.message).split('\n')[0]}); nothing posted`)
1094
+ }
1095
+ }
1096
+
1035
1097
  // ---------------------------------------------------------------------------
1036
1098
  // Credentials: `status` is a READINESS check (exit 1 with none); `set`
1037
1099
  // prompts for the token hidden; `unset` removes the owner's entry.
@@ -1380,6 +1442,7 @@ const USAGE = `Usage: ${BIN} spec-sync <subcommand>
1380
1442
  ref [<spec>] the Refs: trailer value for this branch
1381
1443
  released [<range>] issues a commit range contains
1382
1444
  preserve <spec> [--text <f>] keep an adopted issue's original report
1445
+ comment <spec> --file <f> post a file onto the issue as a comment
1383
1446
  assign <spec> --to <login> | --release stamp who is building it
1384
1447
  whoami [--set <login>] [--unset] who you are on GitHub (cached)
1385
1448
  users [<query>] the repo's assignable people
@@ -1461,6 +1524,8 @@ async function specSync(rest, io = {}) {
1461
1524
  return specSyncReleased(dir, config, positional[0], flags, out)
1462
1525
  case 'preserve':
1463
1526
  return specSyncPreserve(dir, config, positional[0], flags, out)
1527
+ case 'comment':
1528
+ return specSyncComment(dir, config, positional[0], flags, out)
1464
1529
  case 'release':
1465
1530
  return kit.refuseRemovedVerb(out, PROGRAM, 'release')
1466
1531
  case 'assign':
@@ -1495,6 +1560,7 @@ function parseArgs(args, sub) {
1495
1560
  '--stored': { kind: 'path' },
1496
1561
  '--remote': { kind: 'path' },
1497
1562
  '--text': { kind: 'path' },
1563
+ '--file': { kind: 'path' },
1498
1564
  '--workspace-states': { kind: 'path', name: 'workspaceStates' },
1499
1565
  '--skip-state-check': { kind: 'boolean', name: 'skipStateCheck' },
1500
1566
  '--via': { kind: 'string' },
@@ -59,6 +59,7 @@ const DEFAULT_CONFIG = Object.freeze({
59
59
  // `{ "chore": "chore" }` keeps tooling work filterable out of release
60
60
  // views. Empty means no kind label, as before.
61
61
  labelsByKind: Object.freeze({}),
62
+ severityLabels: Object.freeze({}),
62
63
  }),
63
64
  // A spec is a GitHub ISSUE; each phase a SUB-ISSUE of it, carrying the
64
65
  // phase's checkboxes in its body as a task list (rendered live by GitHub —
@@ -123,9 +124,10 @@ const LIFECYCLE_BUCKETS = Object.freeze(Object.keys(DEFAULT_CONFIG.states))
123
124
  function defaults() {
124
125
  const g = DEFAULT_CONFIG.github
125
126
  return {
126
- github: { ...g, labels: { ...g.labels }, issueTypes: { ...g.issueTypes }, labelsByKind: { ...g.labelsByKind } },
127
+ github: { ...g, labels: { ...g.labels }, issueTypes: { ...g.issueTypes }, labelsByKind: { ...g.labelsByKind }, severityLabels: { ...g.severityLabels } },
127
128
  mapping: { ...DEFAULT_CONFIG.mapping },
128
129
  states: { ...DEFAULT_CONFIG.states },
130
+ statesByKind: {},
129
131
  stateAliases: {},
130
132
  snapshot: { ...DEFAULT_CONFIG.snapshot },
131
133
  fields: { ...DEFAULT_CONFIG.fields },
@@ -151,7 +153,7 @@ function defaults() {
151
153
  }
152
154
 
153
155
  const { isObject, stringList, assign } = kitConfig
154
- const { mergeStates, mergeFieldOwnership, mergePhaseMapping, mergeReleaseIgnorePaths, mergeKeyedFields } =
156
+ const { mergeStates, mergeStateOverrides, mergeFieldOwnership, mergePhaseMapping, mergeReleaseIgnorePaths, mergeKeyedFields } =
155
157
  kitConfig.makeMergeHelpers({
156
158
  configFile: CONFIG_FILE,
157
159
  ownership: OWNERSHIP,
@@ -195,12 +197,21 @@ function mergeConfig(base, parsed) {
195
197
  // Only the kinds a spec folder can actually be — an unknown key is
196
198
  // dropped, matching Azure's workItemTypeByKind validation.
197
199
  const byKind = {}
198
- for (const kind of ['feature', 'bug', 'hotfix', 'chore']) {
200
+ for (const kind of ['feature', 'bug', 'hotfix', 'chore', 'issue', 'incident']) {
199
201
  const value = parsed.github.labelsByKind[kind]
200
202
  if (typeof value === 'string' && value.trim()) byKind[kind] = value.trim()
201
203
  }
202
204
  base.github.labelsByKind = byKind
203
205
  }
206
+ if (isObject(parsed.github.severityLabels)) {
207
+ // Keyed by the Severity header's leading digit ("2 - High" → "2").
208
+ const bySeverity = {}
209
+ for (const digit of ['1', '2', '3', '4']) {
210
+ const value = parsed.github.severityLabels[digit]
211
+ if (typeof value === 'string' && value.trim()) bySeverity[digit] = value.trim()
212
+ }
213
+ base.github.severityLabels = bySeverity
214
+ }
204
215
  }
205
216
 
206
217
  if (isObject(parsed.mapping)) {
@@ -213,6 +224,7 @@ function mergeConfig(base, parsed) {
213
224
  }
214
225
 
215
226
  mergeStates(base, parsed)
227
+ mergeStateOverrides(base, parsed, 'statesByKind')
216
228
 
217
229
  if (isObject(parsed.snapshot)) {
218
230
  assign(base.snapshot, parsed.snapshot, 'overviewFile', 'string')
@@ -193,8 +193,52 @@ function makeMergeHelpers({ configFile, ownership, lifecycleBuckets, phaseMappin
193
193
  base.stateAliases = aliases
194
194
  }
195
195
 
196
+ // Merge (and validate) a per-type/kind state override table — `statesByType`
197
+ // keyed by work item / issue type (Azure, Jira), `statesByKind` keyed by spec
198
+ // kind (GitHub, Linear). Each entry is a PARTIAL bucket map laid over
199
+ // `states` for that type/kind: a bucket set to null means "send no state for
200
+ // this bucket", and a bucket the entry lacks falls through to `states`.
201
+ // An unknown bucket is refused — a typo'd bucket would silently change
202
+ // nothing at push time. Call after mergeStates, so buckets are final.
203
+ function mergeStateOverrides(base, parsed, key) {
204
+ const value = parsed[key]
205
+ if (!isObject(value)) return
206
+ const table = {}
207
+ for (const [name, entry] of Object.entries(value)) {
208
+ if (!isObject(entry)) {
209
+ throw new Error(
210
+ `Invalid ${configFile}: ${key}.${JSON.stringify(name)} = ${JSON.stringify(entry)} ` +
211
+ '(expected an object mapping lifecycle buckets to a state name, or null to send no state)',
212
+ )
213
+ }
214
+ const row = {}
215
+ for (const [bucket, state] of Object.entries(entry)) {
216
+ if (!(bucket in base.states)) {
217
+ throw new Error(
218
+ `Invalid ${configFile}: ${key}.${JSON.stringify(name)}.${bucket} — not a lifecycle bucket ` +
219
+ `(${Object.keys(base.states).join(', ')})`,
220
+ )
221
+ }
222
+ if (state === null) {
223
+ row[bucket] = null
224
+ continue
225
+ }
226
+ if (typeof state !== 'string' || !state.trim()) {
227
+ throw new Error(
228
+ `Invalid ${configFile}: ${key}.${JSON.stringify(name)}.${bucket} = ${JSON.stringify(state)} ` +
229
+ '(expected a state name, or null to send no state)',
230
+ )
231
+ }
232
+ row[bucket] = state.trim()
233
+ }
234
+ if (Object.keys(row).length) table[name] = row
235
+ }
236
+ base[key] = table
237
+ }
238
+
196
239
  return {
197
240
  mergeStates,
241
+ mergeStateOverrides,
198
242
  mergeFieldOwnership,
199
243
  mergePhaseMapping,
200
244
  mergeReleaseIgnorePaths,
@@ -13,7 +13,7 @@
13
13
  * stored matches what was sent — it merges nothing (see `src/verify.js`).
14
14
  */
15
15
 
16
- const { ownsField, normalizeLocal, LIFECYCLE_BUCKETS, lintPhases, readSnapshot, parseFrontmatter, remoteWorkflowState, remoteStateReading, stateNamesFor, titleFromText, validateStates, stateSuggestions, phaseModeFor } = require('./src/normalize.js')
16
+ const { ownsField, normalizeLocal, LIFECYCLE_BUCKETS, lintPhases, readSnapshot, parseFrontmatter, remoteWorkflowState, remoteStateReading, stateNamesFor, titleFromText, validateStates, stateSuggestions, effectiveStates, specHeaders, linkedIncident, phaseModeFor } = require('./src/normalize.js')
17
17
  const { planChanges, snapshotOf, isEmptyPlan, hashField, stableStringify, remoteDescriptionEdited, remoteSubIssueEdited } = require('./src/compare.js')
18
18
  const { readBase, writeBase } = require('./src/base.js')
19
19
  const { push, recordPush, projectionOf } = require('./src/push.js')
@@ -46,6 +46,9 @@ module.exports = {
46
46
  titleFromText,
47
47
  validateStates,
48
48
  stateSuggestions,
49
+ effectiveStates,
50
+ specHeaders,
51
+ linkedIncident,
49
52
  hashField,
50
53
  stableStringify,
51
54
  readBase,
@@ -405,6 +405,60 @@ function readSnapshot(snapshotDir, config) {
405
405
  return { frontmatter: data, title, sections, phases, body }
406
406
  }
407
407
 
408
+ // The spec's own `> **Severity:**` and `> **Incident:**` headers, off the
409
+ // overview's blockquote block. They are PUSH-TIME EXTRAS, deliberately not
410
+ // keys on `normalizeLocal`'s field set: severity lands in a provider-specific
411
+ // home (a field, a label) and the incident link as a typed relation, so
412
+ // neither belongs in the synced-field hashes a stored base compares.
413
+ function specHeaders(snapshotDir, config) {
414
+ const overviewFile = (config && config.snapshot && config.snapshot.overviewFile) || '00-overview.md'
415
+ let raw
416
+ try {
417
+ raw = fs.readFileSync(path.join(snapshotDir, overviewFile), 'utf-8')
418
+ } catch {
419
+ return { severity: null, incident: null }
420
+ }
421
+ const read = (name) => {
422
+ const m = new RegExp(`^>\\s*\\*\\*${name}:\\*\\*\\s*(.+)$`, 'm').exec(raw)
423
+ return m ? m[1].trim() : null
424
+ }
425
+ return { severity: read('Severity'), incident: read('Incident') }
426
+ }
427
+
428
+ // Resolve a fix spec's `> **Incident:**` header to the incident spec it names:
429
+ // its folder in any lifecycle bucket, and the tracker identifier stamped on it
430
+ // (via the provider's own `fields.identifier`). `identifier: null` means the
431
+ // incident exists but is not linked yet — report and carry on, never fail the
432
+ // push over it. No header at all returns null.
433
+ function linkedIncident(snapshotDir, config) {
434
+ const { incident } = specHeaders(snapshotDir, config)
435
+ if (!incident) return null
436
+ const root = path.resolve(snapshotDir, '..', '..', '..')
437
+ const overviewFile = (config && config.snapshot && config.snapshot.overviewFile) || '00-overview.md'
438
+ for (const bucket of ['in-progress', 'backlog', 'complete', 'cancelled']) {
439
+ const file = path.join(root, 'specs', bucket, incident, overviewFile)
440
+ if (!fs.existsSync(file)) continue
441
+ const { data } = parseFrontmatter(fs.readFileSync(file, 'utf-8'))
442
+ const idField = config && config.fields && config.fields.identifier
443
+ const identifier = idField && data[idField] != null ? String(data[idField]) : null
444
+ return { name: incident, identifier, found: true }
445
+ }
446
+ // A FOLDER NOT ON DISK IS NOT PROOF THE INCIDENT DOES NOT EXIST — buckets
447
+ // are branch-local truth, so an incident on its own unlanded branch is
448
+ // invisible here. The caller reports "not linked yet" and carries on.
449
+ return { name: incident, identifier: null, found: false }
450
+ }
451
+
452
+ // The one-line cross-reference a fix spec's body carries to its incident. Part
453
+ // of the PROJECTION (not appended at send time), so the stored base, the plan
454
+ // and what the tracker holds all hash the same bytes — and on GitHub the
455
+ // `#N` identifier backlinks on the incident's own timeline.
456
+ function relatedIncidentLine(snapshotDir, config) {
457
+ const incident = linkedIncident(snapshotDir, config)
458
+ if (!incident) return ''
459
+ return `\n\nRelated incident: ${incident.identifier || incident.name}`
460
+ }
461
+
408
462
  // The headings a bug-shaped spec's ticket leads with, in this order, when the
409
463
  // spec has them. A Bug ticket is read for its repro before anything else, and
410
464
  // the feature overview order buries it. Sections a spec does not have are
@@ -723,23 +777,24 @@ function normalizeLocal(snapshotDir, config) {
723
777
  const phasesCarriedBySubIssues =
724
778
  syncsSubIssues && phaseModeFor(workflowState, config) !== 'inline' && withheld === 0
725
779
  const extracted = {
726
- description: withInlinePhases(
727
- buildDescription(
728
- title,
729
- sections,
780
+ description:
781
+ withInlinePhases(
782
+ buildDescription(
783
+ title,
784
+ sections,
785
+ config.sync.localOnlySections,
786
+ phasesCarriedBySubIssues ? ['Phases'] : [],
787
+ dialect,
788
+ // A bug or hotfix spec's ticket leads with the bug sections — a
789
+ // different render of the same overview, so the Bug form opens on the
790
+ // repro rather than the feature-shaped prose.
791
+ bugShaped(snapshotDir) ? BUG_LEAD_SECTIONS : [],
792
+ ),
793
+ inlined,
794
+ tasksMode,
730
795
  config.sync.localOnlySections,
731
- phasesCarriedBySubIssues ? ['Phases'] : [],
732
796
  dialect,
733
- // A bug or hotfix spec's ticket leads with the bug sections — a
734
- // different render of the same overview, so the Bug form opens on the
735
- // repro rather than the feature-shaped prose.
736
- bugShaped(snapshotDir) ? BUG_LEAD_SECTIONS : [],
737
- ),
738
- inlined,
739
- tasksMode,
740
- config.sync.localOnlySections,
741
- dialect,
742
- ),
797
+ ) + relatedIncidentLine(snapshotDir, config),
743
798
  // Sub-issue projection: one per phase. `ref` is the phase-file basename — the
744
799
  // local handle the push skill stamps a newly-created sub-issue id back into.
745
800
  // `state` is the phase's status bucket (from its heading emoji), mapped to a
@@ -786,7 +841,14 @@ function phasesWithheld(snapshotDir, config) {
786
841
  function stateNamesFor(bucket, config) {
787
842
  const primary = config && config.states && config.states[bucket]
788
843
  const aliases = (config && config.stateAliases && config.stateAliases[bucket]) || []
789
- return [primary, ...(Array.isArray(aliases) ? aliases : [])].filter((n) => typeof n === 'string' && n)
844
+ // Override values read as the bucket they override — so a `/spec-status`
845
+ // against a type completed to "Closed" still reads as `complete`.
846
+ const overrides = stateOverrideTables(config).flatMap((table) =>
847
+ Object.values(table).map((entry) => entry && entry[bucket]),
848
+ )
849
+ return [...new Set([primary, ...(Array.isArray(aliases) ? aliases : []), ...overrides])].filter(
850
+ (n) => typeof n === 'string' && n,
851
+ )
790
852
  }
791
853
 
792
854
  // Map a remote workflow-state name back to the local lifecycle bucket (the
@@ -922,11 +984,39 @@ function titleFromText(text, max = 100) {
922
984
  return stripTitleMarkup(title)
923
985
  }
924
986
 
925
- // Every state NAME the config points at: the lifecycle bucket map.
987
+ // Per-type/kind state OVERRIDES: `table` maps a work item type (Azure, Jira)
988
+ // or a spec kind (GitHub, Linear) to a partial bucket map laid over
989
+ // `config.states`. A bucket mapped to null means "send no state for this
990
+ // bucket"; a bucket the entry lacks falls through to the base map. With no
991
+ // table, or no entry for `key`, this is exactly `config.states`.
992
+ function effectiveStates(config, table, key) {
993
+ const out = { ...((config && config.states) || {}) }
994
+ const over = (table && key && table[key]) || null
995
+ if (over) for (const [bucket, value] of Object.entries(over)) out[bucket] = value
996
+ return out
997
+ }
998
+
999
+ // The per-type/kind override tables a provider config may carry. Readers that
1000
+ // scan "every configured state name" scan these too, so an override value is
1001
+ // validated and recognised exactly like a base one.
1002
+ function stateOverrideTables(config) {
1003
+ return [config && config.statesByType, config && config.statesByKind].filter(Boolean)
1004
+ }
1005
+
1006
+ // Every state NAME the config points at: the lifecycle bucket map, plus any
1007
+ // per-type/kind override values (null entries carry no name).
926
1008
  function configuredStateNames(config) {
927
1009
  // The WRITTEN names only. An alias is never written, so one the workspace
928
1010
  // lacks cannot strand a push; `stateSuggestions` still names it in reports.
929
- return Object.values((config && config.states) || {}).filter((v) => typeof v === 'string')
1011
+ const names = Object.values((config && config.states) || {}).filter((v) => typeof v === 'string')
1012
+ for (const table of stateOverrideTables(config)) {
1013
+ for (const entry of Object.values(table)) {
1014
+ for (const value of Object.values(entry || {})) {
1015
+ if (typeof value === 'string') names.push(value)
1016
+ }
1017
+ }
1018
+ }
1019
+ return [...new Set(names)]
930
1020
  }
931
1021
 
932
1022
  // Which configured state NAMES are absent from the live workspace. The skill
@@ -977,6 +1067,7 @@ module.exports = {
977
1067
  ownsField,
978
1068
  stateSuggestions,
979
1069
  configuredStateNames,
1070
+ effectiveStates,
980
1071
  normalizeLocal,
981
1072
  assigneeFor,
982
1073
  phaseProjection,
@@ -996,4 +1087,6 @@ module.exports = {
996
1087
  remoteWorkflowState,
997
1088
  remoteStateReading,
998
1089
  stateNamesFor,
1090
+ specHeaders,
1091
+ linkedIncident,
999
1092
  }