@skitterbyte/skitterspec-azure-boards 2.0.0 → 2.1.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,34 @@
1
1
  # Migration guide
2
2
 
3
+ ## The `chore` spec kind, and per-type bodies (additive — nothing breaks)
4
+
5
+ Specs can now be **chores** (`chore-` prefix, `> **Type:** Chore`) and every
6
+ provider can map spec kinds to its own idiom. Configs without a mapping keep
7
+ working unchanged: an unmapped kind mints the provider's default type exactly
8
+ as before, and `System.Description` stays Azure's body field unless a type is
9
+ mapped away from it. `skitterspec update` ships the new skills and rules.
10
+
11
+ **Create tracker types and states before mapping them.** A mapping names
12
+ something the tracker must already have:
13
+
14
+ - **Azure Boards** — create the custom inherited type (e.g. `Chore`) and its
15
+ states in your process, then set
16
+ `azure.workItemTypeByKind: { "chore": "Chore" }`. To fill a Bug form's Repro
17
+ Steps instead of the hidden Description, set
18
+ `azure.bodyFieldByType: { "Bug": "Microsoft.VSTS.TCM.ReproSteps" }` — it
19
+ applies symmetrically to create, update, read-back and the edited-hash
20
+ compare, so `/spec-status` stays quiet after a push. Bugs minted before the
21
+ mapping keep reading their Description until the next push rewrites them.
22
+ `spec-sync doctor --check-remote` verifies every mapped type exists and
23
+ carries its body field.
24
+ - **GitHub** — `github.labelsByKind: { "chore": "chore" }` adds the kind's
25
+ label beside the spec marker.
26
+ - **Jira** — `jira.issueTypeByKind: { "bug": "Bug", "chore": "Task" }` picks
27
+ the mint type per kind; the type must exist in the project.
28
+ - **Linear** — `linear.labelsByKind: { "chore": "Chore" }` labels the mint;
29
+ the label must already exist on the team (a missing one is a one-line note,
30
+ never a failed push).
31
+
3
32
  ## `@skitterbyte/skitterspec-github` v1 → v2 (tell, don't track)
4
33
 
5
34
  Skitterspec now tells GitHub about **its own** transitions and nothing
@@ -4,6 +4,7 @@
4
4
  "project": "your-project",
5
5
  "workItemType": "Issue",
6
6
  "workItemTypeByKind": {},
7
+ "bodyFieldByType": {},
7
8
  "childType": "Task",
8
9
  "areaPath": ""
9
10
  },
@@ -9,7 +9,8 @@ env-var NAMES — never a credential. Credentials live in the user-level store
9
9
  | `azure.orgUrl` | The organization (`https://dev.azure.com/<org>`). Also keys the credentials-store entry. | `""` |
10
10
  | `azure.project` | The project spec work items land in. | `""` |
11
11
  | `azure.workItemType` | The work item type a spec mints as. Types are process-defined (Basic: `Issue`; Agile: `User Story`; custom anything), so this is config, not a constant. | `"Issue"` |
12
- | `azure.workItemTypeByKind` | The mint type per spec kind — `feature`, `bug`, `hotfix`, read off the spec folder's prefix — falling back to `azure.workItemType`. In Agile/Scrum/CMMI a bug is a type, so `{ "bug": "Bug", "hotfix": "Bug" }` keeps `/spec-bug` and `/spec-hotfix` out of the story backlog. Each named type's states are validated like the base pair's. | `{}` |
12
+ | `azure.workItemTypeByKind` | The mint type per spec kind — `feature`, `bug`, `hotfix`, `chore`, read off the spec folder's prefix — falling back to `azure.workItemType`. In Agile/Scrum/CMMI a bug is a type, so `{ "bug": "Bug", "hotfix": "Bug" }` keeps `/spec-bug` and `/spec-hotfix` out of the story backlog. `chore` wants a custom inherited type — create `Chore` and its states in your process **before** mapping it — so tooling work stays off the customer-facing release ladder. Each named type's states are validated like the base pair's. | `{}` |
13
+ | `azure.bodyFieldByType` | The field a TYPE's body is written to and read from, keyed by work item type name — `{ "Bug": "Microsoft.VSTS.TCM.ReproSteps" }` on Agile/Scrum/CMMI, whose Bug form does not show `System.Description`. Unmapped types keep `System.Description`. The mapping is symmetric — create, update, read-back and the edited-in-Boards hash compare all use it — so a push then an immediate `/spec-status` round-trips clean. Items minted before the mapping read their `System.Description` until the next push rewrites them. `doctor --check-remote` verifies each mapped type exists and carries its field. | `{}` |
13
14
  | `azure.childType` | The type a phase mints as, linked parent/child under the spec's item. | `"Task"` |
14
15
  | `azure.areaPath` | Optional area path for minted items; empty means the project default. | `""` |
15
16
  | `azure.backlogOrderField` | The field `spec-sync list --next` ranks the backlog by, ascending. StackRank is what Basic, Agile and CMMI backlogs drag-order; a Scrum process uses `Microsoft.VSTS.Common.BacklogPriority`. | `Microsoft.VSTS.Common.StackRank` |
@@ -580,7 +580,7 @@ through to a documented conservative default; see the field notes below.
580
580
  - `{repo}` — primary checkout dir basename (e.g. `skitterspec`).
581
581
  - `{repoSlug}` — `{repo}` lower-cased, non-alphanumerics collapsed to `-`
582
582
  (safe for a `COMPOSE_PROJECT_NAME`).
583
- - `{slug}` — the spec slug (folder name minus its `feat-`/`bug-` prefix).
583
+ - `{slug}` — the spec slug (folder name minus its `feat-`/`bug-`/`hotfix-`/`chore-` prefix).
584
584
 
585
585
  ## Pruning orphaned test-DB volumes
586
586
 
@@ -7,7 +7,7 @@ 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) Grill to a clear shared understanding, 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) 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
13
  | `/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) |
@@ -587,23 +587,36 @@ none of them describes.
587
587
  - **Other rules specs must honour:** link the relevant `.claude/rules/*.md`
588
588
  (architecture, code style, testing, database, etc.) rather than restating them.
589
589
 
590
- ## Spec types — Feature, Bug, Hotfix
590
+ ## Spec types — Feature, Chore, Bug, Hotfix
591
591
 
592
- Every spec is one of three types, recorded **both** in the header and the filename:
592
+ Every spec is one of four types, recorded **both** in the header and the filename:
593
593
 
594
- - **Header field:** `> **Type:** Feature`, `> **Type:** Bug`, or
595
- `> **Type:** Hotfix` (authoritative, greppable:
594
+ - **Header field:** `> **Type:** Feature`, `> **Type:** Chore`,
595
+ `> **Type:** Bug`, or `> **Type:** Hotfix` (authoritative, greppable:
596
596
  `grep -rl 'Type:.*Hotfix' specs/`).
597
- - **Filename prefix:** `feat-<name>` for features, `bug-<name>` for bugs,
598
- `hotfix-<name>` for hotfixes (visible in listings; glob-safe — never use
599
- `[BUG]`/`[FEATURE]` brackets).
597
+ - **Filename prefix:** `feat-<name>` for features, `chore-<name>` for chores,
598
+ `bug-<name>` for bugs, `hotfix-<name>` for hotfixes (visible in listings;
599
+ glob-safe — never use `[BUG]`/`[FEATURE]` brackets).
600
+
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
605
+ grilling defined, with a one-line reason, and the user confirms. A chore
606
+ defaults its `Gating:` to `none: not user-facing` (where gating is configured),
607
+ and its commits default to `chore`/`refactor`/`ci` types with **no**
608
+ `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`.
610
+ Where a ticketing provider maps kinds to tracker types (e.g. Azure's
611
+ `workItemTypeByKind`), the chore mapping is what keeps tooling work off the
612
+ customer-facing release ladder.
600
613
 
601
614
  A **Hotfix** is a Bug fixed against a **released tag** rather than `main`: it
602
615
  carries an extra `> **Base version:** <tag>` header, forks its worktree from that
603
616
  tag, and lands by tagging a new patch + cherry-picking onto `main` (never a
604
617
  fast-forward merge). `/spec-live` refuses a hotfix — test it with `/spec-connect`.
605
618
 
606
- All three types share the same lifecycle folders below — type is orthogonal to
619
+ All four types share the same lifecycle folders below — type is orthogonal to
607
620
  status.
608
621
 
609
622
  ## Header fields & State log (audit trail)
@@ -231,8 +231,34 @@ again on the **same** `--since`. Not a fresh one — a pass that arrived during
231
231
  the gap is still inside the original window, and re-arming on a new timestamp
232
232
  would strand exactly that pass.
233
233
 
234
- **Say nothing when you do it.** Nothing happened and the window is unchanged; a
235
- line on every death turns a working loop into a stream of non-events.
234
+ **Say as little as the harness allows when you do it.** Nothing happened and
235
+ the window is unchanged; a line on every death turns a working loop into a
236
+ stream of non-events. Where the harness lets a turn end on the tool call, the
237
+ tool call is the whole turn. Where it insists on visible text — Claude Code
238
+ does, after a monitor event — that text is one fixed line,
239
+ `Still waiting for the verdict.`, and nothing else: not the spec, not the age,
240
+ not the links. The wait's own start line arriving as an event is answered the
241
+ same way.
242
+
243
+ **Every fifth re-arm, show the banner again.** Even one line per re-arm adds
244
+ up: over a long idle they push the verdict line and the banner's links out of
245
+ sight, and a reader who comes back has to scroll for the URL that lets them
246
+ answer. So `review wait` counts the starts on each window, and on every fifth
247
+ re-arm its start line is followed by `re-show: banner (re-arm N)` and the stack.
248
+ Relay that as the run's **verdict line** — copied from the block when it is
249
+ still in context, dropped rather than reconstructed when it is not — and then
250
+ **the banner** in its current state, with its stack copied from the `re-show:`
251
+ lines. Not the table: that would be a second block.
252
+
253
+ **A count here, not an age**, and the bound below is unaffected. What buries
254
+ the banner is how many re-arms have scrolled past it, and a death every five
255
+ minutes and one every forty-five push it up the same distance each. The age of
256
+ the window still decides when to stop.
257
+
258
+ **And it is not a third control after the block.** It is the banner this file
259
+ already defines, repeated in whatever state it is in — past the bound, that is
260
+ the degraded sentence below. No block is repeated, so nothing follows a second
261
+ one, and nothing about the banner's shape changes.
236
262
 
237
263
  **An operator who stopped it is not a death** — re-arming over a deliberate
238
264
  stop makes the wait unstoppable, which is worse than a wait that stops. But a
@@ -142,8 +142,8 @@ because writing it means reading the diff, and that spend is the user's call.
142
142
 
143
143
  **A watch that dies is re-armed on the same window**, silently and bounded by
144
144
  the age of that window — `.claude/rules/spec-reports.md` carries the contract,
145
- including when to stop and what the banner says instead. Do not restate it
146
- here.
145
+ including when to stop, what the banner says instead, and when the
146
+ engine's `re-show:` brings the banner back. Do not restate it here.
147
147
 
148
148
  ```
149
149
  skitterspec spec-env review <name> --claim-since <the timestamp> --json
@@ -198,9 +198,31 @@ not write the spec until this is resolved.
198
198
  Stop grilling when there are no unresolved branches that would change the spec.
199
199
  Briefly play back the agreed understanding before writing.
200
200
 
201
+ ### Propose the kind — feature or chore
202
+
203
+ This skill writes two kinds of spec, and
204
+ **you propose which from what the grilling defined, with a one-line reason; the user confirms or overrides.**
205
+ The
206
+ line that decides it: a **chore** is anything that is not work end users see or
207
+ functions they use within the app — tooling, CI, dependency bumps, internal
208
+ refactors. Everything user-facing is a **feature**. So the proposal reads like
209
+ *"no user-visible surface → chore"* or *"adds an endpoint users call → feature"*.
210
+
211
+ The kind is recorded twice, and both follow from the answer: the folder prefix
212
+ (`feat-` / `chore-`) and the `> **Type:**` header (`Feature` / `Chore`). A chore
213
+ also defaults its `Gating:` to `none: not user-facing` (only when gating is
214
+ configured — offer the default, let the user override it like any other
215
+ answer), and its commits default to `chore`/`refactor`/`ci` types with no
216
+ `Release-Note:` (see `.claude/rules/spec-planning.md`).
217
+
218
+ There is no `/spec-chore` and none should be added: one entry point, one grill,
219
+ and the kind is an output of understanding the work rather than a door the user
220
+ must pick before describing it.
221
+
201
222
  ## Phase B — write the spec
202
223
 
203
- This skill is for **features**. For bugs, use `/spec-bug` (test-first, red→green).
224
+ This skill is for **features and chores**. For bugs, use `/spec-bug`
225
+ (test-first, red→green).
204
226
 
205
227
  ### Write it in its own worktree
206
228
 
@@ -267,8 +289,8 @@ move to, **warn, don't refuse**, and say the trailer for that commit wants
267
289
  that phase's goal, its task checkboxes (tests included), and any phase-specific
268
290
  notes. **Even a single-phase spec gets `01-….md`** — never lump phase tasks
269
291
  into `00-overview.md`. This keeps each phase easy to dive into on its own.
270
- - Choose a short kebab-case name and **prefix it `feat-`** (the bug counterpart
271
- uses `bug-`).
292
+ - Choose a short kebab-case name and **prefix it with the kind** — `feat-` for
293
+ a feature, `chore-` for a chore (the bug counterpart uses `bug-`).
272
294
 
273
295
  Use this template (keep it **as concise as possible** — no filler, no restating
274
296
  the codebase, link rather than duplicate):
@@ -276,8 +298,8 @@ the codebase, link rather than duplicate):
276
298
  ```markdown
277
299
  # <Feature title>
278
300
 
279
- > **Type:** Feature
280
- > **Name:** feat-<kebab-name> (the spec folder name — the handle you paste into `/spec-start`)
301
+ > **Type:** <Feature or Chore — the kind proposed after Phase A>
302
+ > **Name:** <feat- or chore-><kebab-name> (the spec folder name — the handle you paste into `/spec-start`)
281
303
  > **Status:** Ready — not started
282
304
  > **Author:** <git user.name — `git config user.name`>
283
305
  > **Developer:** —
@@ -286,7 +308,8 @@ the codebase, link rather than duplicate):
286
308
  > **Stack:** <worktree — or "worktree + docker" if it touches the DB/stateful
287
309
  > services; only acted on when isolation is enabled — see Phase A item 9>
288
310
  > **Gating:** <flag name — or "none: <one-line reason>". Only when release gating
289
- > is configured; omit the line entirely otherwise. An empty value or a bare
311
+ > is configured; omit the line entirely otherwise. A chore defaults to
312
+ > "none: not user-facing". An empty value or a bare
290
313
  > "none" is not a valid outcome — see Phase A item 10>
291
314
 
292
315
  ## Problem
@@ -548,8 +571,8 @@ the verdict — and the reader's conclusion is about what the page showed them.
548
571
 
549
572
  **A watch that dies is re-armed on the same window**, silently and bounded by
550
573
  the age of that window — `.claude/rules/spec-reports.md` carries the contract,
551
- including when to stop and what the banner says instead. Do not restate it
552
- here.
574
+ including when to stop, what the banner says instead, and when the
575
+ engine's `re-show:` brings the banner back. Do not restate it here.
553
576
 
554
577
  ```
555
578
  skitterspec spec-env review <spec> --docs --claim-since <the timestamp> --json
@@ -97,6 +97,9 @@ these are config rather than constants:
97
97
  Scrum, CMMI): a `/spec-bug` or `/spec-hotfix` minting a `User Story` files
98
98
  the bug in the wrong backlog, and `{ "bug": "Bug", "hotfix": "Bug" }` is the
99
99
  usual answer there. On Basic (no Bug type) say nothing and leave it empty.
100
+ A `chore` mapping needs a custom inherited type — offer it only when the
101
+ project has created one (e.g. `Chore`), and say the type and its states must
102
+ exist in the process before the first push mints with it.
100
103
  - **`intake.bugTypes`** / **`intake.hotfixTypes`** — the same processes route
101
104
  intake by TYPE as well as tag: `bugTypes` defaults to `["Bug"]`, so an
102
105
  untagged Bug-type item reaches `/spec-bug` without anyone remembering a tag
@@ -554,8 +554,8 @@ and the routing on the verdict is `/spec-diff` §2 and §4, as it is everywhere.
554
554
 
555
555
  **A watch that dies is re-armed on the same window**, silently and bounded by
556
556
  the age of that window — `.claude/rules/spec-reports.md` carries the contract,
557
- including when to stop and what the banner says instead. Do not restate it
558
- here.
557
+ including when to stop, what the banner says instead, and when the
558
+ engine's `re-show:` brings the banner back. Do not restate it here.
559
559
 
560
560
  **Why this skill arms as well as waits.** Waiting is what any offer does;
561
561
  **arming** asserts an obligation that outlives the turn, and belongs only to
@@ -507,8 +507,8 @@ reading — and that is the gap the whole gate exists to close.
507
507
 
508
508
  **A watch that dies is re-armed on the same window**, silently and bounded by
509
509
  the age of that window — `.claude/rules/spec-reports.md` carries the contract,
510
- including when to stop and what the banner says instead. Do not restate it
511
- here.
510
+ including when to stop, what the banner says instead, and when the
511
+ engine's `re-show:` brings the banner back. Do not restate it here.
512
512
 
513
513
  Then **end your turn**. Do not poll it and do not hold the turn open: the
514
514
  point is that the reader has the terminal back while they read.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skitterbyte/skitterspec-azure-boards",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Spec-driven development for Claude Code, with one-way Azure Boards 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 Azure DevOps work items with parent/child hierarchy, assignment and a release work item per tag. The repo is canonical; Boards 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
@@ -119,6 +119,9 @@ const {
119
119
  passesSince,
120
120
  waitForPass,
121
121
  WAIT_HEARTBEAT_MS,
122
+ WAIT_RESHOW_EVERY,
123
+ recordWaitStart,
124
+ reshowDue,
122
125
  waitingPasses,
123
126
  describePending,
124
127
  pendingAge,
@@ -903,7 +906,7 @@ function specEnvUp(dir, config, specArg, flags = {}) {
903
906
  try {
904
907
  spec = resolveSpecWithWorktree(dir, config, specArg)
905
908
  } catch (err) {
906
- const specShaped = typeof specArg === 'string' && /^(feat|bug|hotfix)-./.test(specArg)
909
+ const specShaped = typeof specArg === 'string' && /^(feat|bug|hotfix|chore)-./.test(specArg)
907
910
  if (err.code !== 'SPEC_NOT_FOUND' || !docs || !specShaped || config.mode === 'checkout') {
908
911
  throw err
909
912
  }
@@ -2761,6 +2764,74 @@ function resolveHeartbeatMs(flags) {
2761
2764
  return seconds * 1000
2762
2765
  }
2763
2766
 
2767
+ /**
2768
+ * Every this-many re-arms the stack is printed again. Default 5, `0` disables.
2769
+ * A value that is not a whole number takes the DEFAULT rather than disabling
2770
+ * (`.claude/rules/negative-checks.md` rule 4), the same as `--heartbeat`.
2771
+ */
2772
+ function resolveReshowEvery(flags) {
2773
+ if (flags.reshowEvery === undefined || flags.reshowEvery === null) return WAIT_RESHOW_EVERY
2774
+ const n = Number(flags.reshowEvery)
2775
+ if (!Number.isInteger(n) || n < 0) return WAIT_RESHOW_EVERY
2776
+ return n
2777
+ }
2778
+
2779
+ /**
2780
+ * The review server that is running, read and never touched — or null.
2781
+ *
2782
+ * NOT `ensureReviewServer`. That one adopts, and where a server is stale it
2783
+ * replaces it, and a re-show that restarted the server would kill the link
2784
+ * open on the reader's phone in order to remind them of it. This reads the
2785
+ * pidfile and the settings and stops there.
2786
+ *
2787
+ * WHAT WOULD FOOL THIS: a pidfile left by a crash names a pid the OS may have
2788
+ * reused for something else. `isAlive` cannot tell those apart, so the URL it
2789
+ * offers could point at nothing — the same blind spot every adopt has, and the
2790
+ * cost is a dead link in a reminder, never a lost pass.
2791
+ */
2792
+ function readRunningReviewServer(dir, config) {
2793
+ const abs = (rel) => path.resolve(dir, rel)
2794
+ const settingsFile = `${stateDirLabel(config)}/review-serve.json`
2795
+ const proc = serveProcFor(config, abs(settingsFile), { root: dir })
2796
+ const pid = readPid(abs(proc.pidFile))
2797
+ if (!pid || !isAlive(pid)) return null
2798
+ let settings = null
2799
+ try {
2800
+ settings = JSON.parse(fs.readFileSync(abs(settingsFile), 'utf-8'))
2801
+ } catch {
2802
+ return null
2803
+ }
2804
+ if (!settings || !settings.port) return null
2805
+ return {
2806
+ port: settings.port,
2807
+ token: settings.token || null,
2808
+ loopback: settings.host === '127.0.0.1' || settings.host === 'localhost',
2809
+ }
2810
+ }
2811
+
2812
+ /**
2813
+ * The stack a re-show prints: the same tiers and `live` a render reports, from
2814
+ * the same functions, with nothing rendered and nothing started.
2815
+ */
2816
+ function reshowStack(dir, config, spec, out) {
2817
+ const cfg = withSpecRemote(config, out)
2818
+ const up = readRunningReviewServer(dir, cfg)
2819
+ const served = up ? reviewServedUrls(up, offerableLanAddresses(), spec.folder) : null
2820
+ const tiers = reviewTierStack({ served, fileUrl: reviewFileUrl(out), publishedUrl: readReviewUrl(out), config: cfg })
2821
+ let live = null
2822
+ try {
2823
+ const primaryState = assertPrimaryOnMain(cfg, gitReader(dir))
2824
+ live = liveStateFor(
2825
+ spec,
2826
+ liveContext(dir, cfg, spec, { onBase: primaryState.onBase, primaryBranch: primaryState.branch }),
2827
+ )
2828
+ } catch {
2829
+ // Cannot tell whether it is live — print no line rather than a wrong one.
2830
+ live = null
2831
+ }
2832
+ return { tiers, live }
2833
+ }
2834
+
2764
2835
  async function specEnvReviewWait(dir, config, specArg, flags) {
2765
2836
  let spec
2766
2837
  try {
@@ -2794,10 +2865,28 @@ async function specEnvReviewWait(dir, config, specArg, flags) {
2794
2865
  // SAID BEFORE THE FIRST POLL, not after it. The whole point is that a caller
2795
2866
  // knows the wait is running; a line printed on the way out would arrive only
2796
2867
  // for the waits that already worked.
2868
+ //
2869
+ // WHICH START THIS IS, counted per window. A wait that dies is re-armed on the
2870
+ // same `--since`, and every re-arm leaves a trace in the conversation, so
2871
+ // after enough of them the banner and its links have scrolled out of sight.
2872
+ // Every `reshowEvery`th re-arm prints the stack again, read-only, for the
2873
+ // skill to relay as the banner.
2874
+ const reshowEvery = resolveReshowEvery(flags)
2875
+ const started = recordWaitStart(out, spec.folder, flags.since)
2876
+ const rearm = started ? started.rearm : null
2877
+ const reshow = reshowDue(rearm, reshowEvery)
2878
+ const stack = reshow ? reshowStack(dir, config, spec, out) : null
2879
+
2797
2880
  if (!flags.json) {
2798
2881
  process.stdout.write(
2799
2882
  `spec-env review wait: ${spec.folder} — waiting for a verdict sent since ${flags.since}` +
2800
- `${timeoutMs === null ? '' : ` (up to ${flags.timeout}s)`}\n`,
2883
+ `${timeoutMs === null ? '' : ` (up to ${flags.timeout}s)`}` +
2884
+ `${rearm ? ` (re-arm ${rearm})` : ''}\n` +
2885
+ (stack
2886
+ ? ` re-show: banner (re-arm ${rearm})\n` +
2887
+ stack.tiers.map((t) => reviewTierLine(t) + '\n').join('') +
2888
+ (liveStateLine(stack.live) ? `${liveStateLine(stack.live)}\n` : '')
2889
+ : ''),
2801
2890
  )
2802
2891
  }
2803
2892
 
@@ -2827,7 +2916,20 @@ async function specEnvReviewWait(dir, config, specArg, flags) {
2827
2916
  })
2828
2917
 
2829
2918
  if (flags.json) {
2830
- process.stdout.write(`${JSON.stringify({ spec: spec.folder, since: flags.since, ...result }, null, 2)}\n`)
2919
+ process.stdout.write(
2920
+ `${JSON.stringify(
2921
+ {
2922
+ spec: spec.folder,
2923
+ since: flags.since,
2924
+ rearm,
2925
+ reshow,
2926
+ ...(stack ? { tiers: stack.tiers, live: stack.live } : {}),
2927
+ ...result,
2928
+ },
2929
+ null,
2930
+ 2,
2931
+ )}\n`,
2932
+ )
2831
2933
  }
2832
2934
 
2833
2935
  if (result.state === 'arrived') {
@@ -5617,6 +5719,7 @@ async function specEnv(rest) {
5617
5719
  claim: null,
5618
5720
  offered: false,
5619
5721
  heartbeat: null,
5722
+ reshowEvery: null,
5620
5723
  drop: null,
5621
5724
  buttons: null,
5622
5725
  json: false,
@@ -5652,6 +5755,7 @@ async function specEnv(rest) {
5652
5755
  else if (args[i] === '--claim') flags.claim = args[++i]
5653
5756
  else if (args[i] === '--claim-since') flags.claimSince = args[++i]
5654
5757
  else if (args[i] === '--heartbeat') flags.heartbeat = args[++i]
5758
+ else if (args[i] === '--reshow-every') flags.reshowEvery = args[++i]
5655
5759
  else if (args[i] === '--since') flags.since = args[++i]
5656
5760
  else if (args[i] === '--timeout') flags.timeout = args[++i]
5657
5761
  else if (args[i] === '--drop') flags.drop = args[++i]
@@ -5831,6 +5935,7 @@ async function specEnv(rest) {
5831
5935
  ' review skip [spec] "<reason>" move on without one, on the record\n' +
5832
5936
  ' review gate [spec] --offered record that the bypass was offered (spends it)\n' +
5833
5937
  ' review wait [spec] --heartbeat <secs> proof-of-life cadence on stderr; 0 disables\n' +
5938
+ ' review wait [spec] --reshow-every <n> print the stack again every nth re-arm (5); 0 disables\n' +
5834
5939
  ' review wait [spec] --since <iso> block until a verdict arrives ([--timeout <s>])\n' +
5835
5940
  ' review waiting [--json] every pass waiting, across every spec\n' +
5836
5941
  ' review [spec] --claim-since <iso> claim the one pass that arrived since <iso>\n' +
@@ -4,7 +4,8 @@
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-` prefix into `{ type, slug }`, derives the
7
+ * `specs/**`, splits the `feat-`/`bug-`/`hotfix-`/`chore-` prefix into
8
+ * `{ type, slug }`, derives the
8
9
  * git branch from the config's `branch.pattern` (provider-neutral; `{identifier}`
9
10
  * is filled from a tracker id when one is configured, else it falls back to
10
11
  * `{type}/{slug}`), and expands the config's path/name tokens (`{repo}`,
@@ -294,10 +295,10 @@ function phaseIsDone(text) {
294
295
  return /^#\s.*✅\s*$/m.test(text)
295
296
  }
296
297
 
297
- // Split a `feat-`/`bug-`/`hotfix-` prefix. Unknown prefix → type defaults to
298
- // `feat` and the whole folder name is the slug.
298
+ // Split a `feat-`/`bug-`/`hotfix-`/`chore-` prefix. Unknown prefix → type
299
+ // defaults to `feat` and the whole folder name is the slug.
299
300
  function splitPrefix(folder) {
300
- const m = /^(feat|bug|hotfix)-(.+)$/.exec(folder)
301
+ const m = /^(feat|bug|hotfix|chore)-(.+)$/.exec(folder)
301
302
  if (m) return { type: m[1], slug: m[2] }
302
303
  return { type: 'feat', slug: folder }
303
304
  }
@@ -498,6 +499,12 @@ function assertPrimaryOnMain(config, git) {
498
499
  * was actually created against, and re-deriving it would go wrong the moment a
499
500
  * project changed its pattern under a standing branch.
500
501
  *
502
+ * A `chore-foo` SPEC derives the same `chore/foo` branch as `/no-spec foo`
503
+ * does, deliberately left colliding: both cannot exist at once, and git
504
+ * refuses the second `worktree add -b` loudly rather than either lane
505
+ * silently adopting the other's branch (spec feat-chore-kind-bug-bodies,
506
+ * decision 9).
507
+ *
501
508
  * Pure but for `repoInfo`, like `resolveSpec`.
502
509
  */
503
510
  function resolveSpecless(name, dir, config, entry = {}) {
package/src/env/review.js CHANGED
@@ -1282,6 +1282,81 @@ const WAIT_POLL_MS = 400
1282
1282
  // whatever is supervising the process.
1283
1283
  const WAIT_HEARTBEAT_MS = 5 * 60 * 1000
1284
1284
 
1285
+ // Every this-many re-arms on one window, the wait prints the stack again. A
1286
+ // COUNT, not an interval, and deliberately: what buries the banner is how many
1287
+ // re-arms have scrolled past it, and a death every five minutes and one every
1288
+ // forty-five push it up the same distance each. This is not the count
1289
+ // `spec-reports.md` rejects — that one bounded how long to keep waiting, and
1290
+ // the 12-hour age bound below still does.
1291
+ const WAIT_RESHOW_EVERY = 5
1292
+
1293
+ // How old a window may be before its start count is pruned. The same 12 hours
1294
+ // the skills stop re-arming at: past it nobody is counting, so nothing is kept.
1295
+ const WAIT_WINDOW_MAX_MS = 12 * 60 * 60 * 1000
1296
+
1297
+ // Beside the pending store, under gitignored `.spec-env/`.
1298
+ const WAITS_SUFFIX = '.waits.json'
1299
+
1300
+ function reviewWaitsPath(outPath) {
1301
+ return outPath.replace(/\.html$/, '') + WAITS_SUFFIX
1302
+ }
1303
+
1304
+ /**
1305
+ * Record that a wait started on `since`, and say which start this is.
1306
+ * Returns `{ starts, rearm }` — `rearm` is 0 for the first wait on a window —
1307
+ * or `null` when it cannot tell.
1308
+ *
1309
+ * CANNOT-TELL IS NULL, and null means no re-show (`.claude/rules/negative-checks.md`
1310
+ * rule 4). A store that will not parse, a window that is not a timestamp, a
1311
+ * write that failed: each costs the reader one reminder, never a verdict, so
1312
+ * none of them is worth more than silence. An unreadable store is also never
1313
+ * written over — it may be someone's history.
1314
+ *
1315
+ * WHAT WOULD FOOL THIS: it counts STARTS, so anything that runs `review wait`
1316
+ * on the same window counts too — a second session waiting on one spec, or a
1317
+ * person running it by hand. That over-counts, and the cost is a banner shown
1318
+ * a little early, which is the harmless direction.
1319
+ */
1320
+ function recordWaitStart(outPath, specFolder, since, { now = Date.now() } = {}) {
1321
+ if (!Number.isFinite(Date.parse(since))) return null
1322
+ const file = reviewWaitsPath(outPath)
1323
+ let store = { version: 1, spec: specFolder, windows: {} }
1324
+ let raw = null
1325
+ try {
1326
+ raw = fs.readFileSync(file, 'utf8')
1327
+ } catch {}
1328
+ if (raw !== null) {
1329
+ try {
1330
+ const parsed = JSON.parse(raw)
1331
+ if (!parsed || typeof parsed.windows !== 'object' || parsed.windows === null) return null
1332
+ store = { version: parsed.version || 1, spec: parsed.spec || specFolder, windows: parsed.windows }
1333
+ } catch {
1334
+ return null
1335
+ }
1336
+ }
1337
+ const windows = {}
1338
+ for (const [key, count] of Object.entries(store.windows)) {
1339
+ const at = Date.parse(key)
1340
+ if (Number.isFinite(at) && now - at <= WAIT_WINDOW_MAX_MS) windows[key] = count
1341
+ }
1342
+ const prior = Number.isInteger(windows[since]) && windows[since] > 0 ? windows[since] : 0
1343
+ const starts = prior + 1
1344
+ windows[since] = starts
1345
+ try {
1346
+ fs.mkdirSync(path.dirname(file), { recursive: true })
1347
+ fs.writeFileSync(file, JSON.stringify({ ...store, windows }, null, 2) + '\n')
1348
+ } catch {
1349
+ return null
1350
+ }
1351
+ return { starts, rearm: starts - 1 }
1352
+ }
1353
+
1354
+ // Is this re-arm one that re-shows the stack? Pure. The first wait never does —
1355
+ // the banner is right above it — and `every` of 0 turns it off.
1356
+ function reshowDue(rearm, every = WAIT_RESHOW_EVERY) {
1357
+ return Number.isInteger(every) && every > 0 && Number.isInteger(rearm) && rearm > 0 && rearm % every === 0
1358
+ }
1359
+
1285
1360
  /**
1286
1361
  * Block until exactly one pass arrives inside a window. Impure only in that it
1287
1362
  * reads the store and sleeps; it writes nothing and claims nothing.
@@ -2555,6 +2630,10 @@ module.exports = {
2555
2630
  waitingPasses,
2556
2631
  waitForPass,
2557
2632
  WAIT_HEARTBEAT_MS,
2633
+ WAIT_RESHOW_EVERY,
2634
+ recordWaitStart,
2635
+ reshowDue,
2636
+ reviewWaitsPath,
2558
2637
  WAIT_POLL_MS,
2559
2638
  passState,
2560
2639
  describePending,
@@ -68,7 +68,7 @@ function vsspsUrlOf(orgUrl) {
68
68
  * Wrap credential + org/project into the typed ops the engine uses. Injected
69
69
  * `fetch` and `sleep` make every op testable offline.
70
70
  */
71
- function makeApiAdapter({ orgUrl, project, token, fetch: fetchImpl, sleep, maxRetries = MAX_RETRIES }) {
71
+ function makeApiAdapter({ orgUrl, project, token, fetch: fetchImpl, sleep, maxRetries = MAX_RETRIES, bodyFieldByType = {} }) {
72
72
  const doFetch = fetchImpl || globalThis.fetch
73
73
  if (typeof doFetch !== 'function') {
74
74
  throw new Error('no fetch available — Node 18+ is required for the API transport')
@@ -151,6 +151,19 @@ function makeApiAdapter({ orgUrl, project, token, fetch: fetchImpl, sleep, maxRe
151
151
  return m ? m[1] : null
152
152
  }
153
153
 
154
+ // The field a TYPE's body lives in (`azure.bodyFieldByType`), falling back
155
+ // to System.Description. On an Agile/Scrum/CMMI Bug form the Description
156
+ // field is not shown — the body belongs in Repro Steps — so the field is
157
+ // resolved per type and used symmetrically on write AND read: a write-only
158
+ // mapping would make every pushed Bug read back as edited. Type names
159
+ // compare case-insensitively, matching how humans copy them off the form.
160
+ const bodyFields = Object.entries(bodyFieldByType || {}).map(([t, f]) => [String(t).toLowerCase(), f])
161
+ function bodyFieldFor(workItemType) {
162
+ const want = String(workItemType || '').toLowerCase()
163
+ const hit = bodyFields.find(([t]) => t === want)
164
+ return hit ? hit[1] : 'System.Description'
165
+ }
166
+
154
167
  // Text at the boundary: a markdown-format description is entity-DECODED —
155
168
  // Azure encodes stray HTML specials on store (`>` → `&gt;`, `"` → `&quot;`,
156
169
  // observed live), so the decode is the inverse of the store, and what comes
@@ -158,10 +171,21 @@ function makeApiAdapter({ orgUrl, project, token, fetch: fetchImpl, sleep, maxRe
158
171
  // format map is the positive signal that decides — the tag sniff only covers
159
172
  // items too old to carry one.
160
173
  function descriptionText(raw) {
161
- const d = raw.fields && raw.fields['System.Description']
174
+ const field = bodyFieldFor(raw.fields && raw.fields['System.WorkItemType'])
175
+ let d = raw.fields && raw.fields[field]
176
+ let read = field
177
+ // A MAPPED FIELD THAT IS EMPTY FALLS BACK TO System.Description,
178
+ // deliberately: an item minted before the mapping holds its body there,
179
+ // and reading null would accuse it of an edit it never had. The blind
180
+ // spot: a Repro Steps someone deliberately CLEARED in Boards reads as the
181
+ // stale Description until the next push rewrites it.
182
+ if ((d == null || d === '') && field !== 'System.Description') {
183
+ d = raw.fields && raw.fields['System.Description']
184
+ read = 'System.Description'
185
+ }
162
186
  if (d == null) return null
163
187
  const text = String(d)
164
- const fmt = raw.multilineFieldsFormat && raw.multilineFieldsFormat['System.Description']
188
+ const fmt = raw.multilineFieldsFormat && raw.multilineFieldsFormat[read]
165
189
  if (fmt && String(fmt).toLowerCase() === 'markdown') return decodeEntities(text)
166
190
  return looksLikeHtml(text) ? htmlToText(text) : text
167
191
  }
@@ -198,16 +222,16 @@ function makeApiAdapter({ orgUrl, project, token, fetch: fetchImpl, sleep, maxRe
198
222
  * become ops — `undefined` means "say nothing". A null description clears
199
223
  * the field; a null assignee unassigns (Azure clears on empty string).
200
224
  */
201
- function itemPatch(input) {
225
+ function itemPatch(input, bodyField = 'System.Description') {
202
226
  const ops = []
203
227
  const add = (path, value) => ops.push({ op: 'add', path, value })
204
228
  if (input.title !== undefined) add('/fields/System.Title', input.title)
205
229
  if (input.description !== undefined) {
206
- add('/fields/System.Description', input.description == null ? '' : input.description)
230
+ add(`/fields/${bodyField}`, input.description == null ? '' : input.description)
207
231
  // The write format, declared beside the field. One-way by Azure's rule —
208
232
  // a field saved as markdown cannot revert to HTML — which is fine: this
209
233
  // provider never writes HTML.
210
- add('/multilineFieldsFormat/System.Description', 'Markdown')
234
+ add(`/multilineFieldsFormat/${bodyField}`, 'Markdown')
211
235
  }
212
236
  if (input.assigneeId !== undefined) {
213
237
  add('/fields/System.AssignedTo', input.assigneeId == null ? '' : input.assigneeId)
@@ -275,14 +299,14 @@ function makeApiAdapter({ orgUrl, project, token, fetch: fetchImpl, sleep, maxRe
275
299
  const created = await request(
276
300
  'POST',
277
301
  `${projectBase}/wit/workitems/$${encodeURIComponent(workItemType)}`,
278
- { body: itemPatch({ title, description, assigneeId, areaPath }), patch: true },
302
+ { body: itemPatch({ title, description, assigneeId, areaPath }, bodyFieldFor(workItemType)), patch: true },
279
303
  )
280
304
  if (!created || created.id == null) throw new Error('Azure DevOps returned no work item for the create')
281
305
  return { id: String(created.id), identifier: identifierOf(created.id), url: urlOf(created.id) }
282
306
  },
283
307
 
284
308
  async createSubIssue(parentId, { title, description, childType, areaPath }) {
285
- const ops = itemPatch({ title, description, areaPath })
309
+ const ops = itemPatch({ title, description, areaPath }, bodyFieldFor(childType))
286
310
  ops.push({
287
311
  op: 'add',
288
312
  path: '/relations/-',
@@ -298,7 +322,18 @@ function makeApiAdapter({ orgUrl, project, token, fetch: fetchImpl, sleep, maxRe
298
322
  },
299
323
 
300
324
  async updateIssue(id, updates) {
301
- const ops = itemPatch(updates)
325
+ // An update does not know the item's type, and the body field hangs off
326
+ // it — so when a description is being written AND a mapping exists, one
327
+ // field read answers it. With no mapping the read is skipped and the
328
+ // patch is byte-identical to before.
329
+ let bodyField = 'System.Description'
330
+ if (updates.description !== undefined && bodyFields.length) {
331
+ const raw = await request('GET', `${projectBase}/wit/workitems/${encodeURIComponent(numId(id))}`, {
332
+ query: { fields: 'System.WorkItemType' },
333
+ })
334
+ bodyField = bodyFieldFor(raw && raw.fields && raw.fields['System.WorkItemType'])
335
+ }
336
+ const ops = itemPatch(updates, bodyField)
302
337
  if (!ops.length) return {}
303
338
  return request('PATCH', `${projectBase}/wit/workitems/${encodeURIComponent(numId(id))}`, {
304
339
  body: ops,
@@ -404,6 +439,22 @@ function makeApiAdapter({ orgUrl, project, token, fetch: fetchImpl, sleep, maxRe
404
439
  }))
405
440
  },
406
441
 
442
+ /**
443
+ * The field reference names a work item type carries — what `doctor
444
+ * --check-remote` validates `azure.bodyFieldByType` against. `null` means
445
+ * the TYPE is not in the project (a 404), kept distinct from a type with
446
+ * an empty field list, which Azure does not produce.
447
+ */
448
+ async listTypeFields(workItemType) {
449
+ const raw = await request(
450
+ 'GET',
451
+ `${projectBase}/wit/workitemtypes/${encodeURIComponent(workItemType)}/fields`,
452
+ { allow404: true },
453
+ )
454
+ if (raw == null) return null
455
+ return ((raw && raw.value) || []).map((f) => f.referenceName).filter(Boolean)
456
+ },
457
+
407
458
  // The authenticated user, from connectionData — the one identity read
408
459
  // that needs no scope beyond the PAT being valid (phase 1 spike).
409
460
  // A PREVIEW resource: plain 7.1 is refused ("the -preview flag must be
@@ -153,6 +153,7 @@ function specKindOf(snapshotDir) {
153
153
  const name = path.basename(String(snapshotDir || ''))
154
154
  if (name.startsWith('bug-')) return 'bug'
155
155
  if (name.startsWith('hotfix-')) return 'hotfix'
156
+ if (name.startsWith('chore-')) return 'chore'
156
157
  return 'feature'
157
158
  }
158
159
 
@@ -259,6 +260,7 @@ function apiAdapterFor(config, flags) {
259
260
  project: config.azure.project,
260
261
  token: cred.token,
261
262
  fetch: flags.fetch,
263
+ bodyFieldByType: config.azure.bodyFieldByType,
262
264
  }),
263
265
  }
264
266
  }
@@ -361,7 +363,7 @@ const assignment = makeAssignmentCommands({
361
363
  resolveIdentity: (config, env, deps) => resolveIdentity(config, env, deps),
362
364
  resolveCredential: (config, env) => resolveCredential(config, env),
363
365
  makeAdapter: (config, cred, flags) =>
364
- makeApiAdapter({ orgUrl: config.azure.orgUrl, project: config.azure.project, token: cred.token, fetch: flags.fetch }),
366
+ makeApiAdapter({ orgUrl: config.azure.orgUrl, project: config.azure.project, token: cred.token, fetch: flags.fetch, bodyFieldByType: config.azure.bodyFieldByType }),
365
367
  displayNameOf: (u) => displayNameOf(u),
366
368
  usersOverMcp: 'search identities with core_get_identity_ids over MCP, or read them off the org\'s Users page',
367
369
  })
@@ -459,7 +461,7 @@ function companionCoverageNote(dir, config, snapshotDir, out) {
459
461
  const rawField = parsed.branch && parsed.branch.identifierField
460
462
  const field = typeof rawField === 'string' && rawField ? rawField : config.fields.identifier
461
463
 
462
- const slug = path.basename(snapshotDir).replace(/^(feat|bug|hotfix)-/, '')
464
+ const slug = path.basename(snapshotDir).replace(/^(feat|bug|hotfix|chore)-/, '')
463
465
  const basePath = `${config.sync.baseDir}/${identifier}.base.json`
464
466
  const claimed = patterns.some((p) => {
465
467
  if (typeof p !== 'string') return false
@@ -1185,7 +1187,7 @@ async function specSyncInitConfig(dir, flags, out) {
1185
1187
  if (cred.ok) {
1186
1188
  const adapter =
1187
1189
  flags.adapter ||
1188
- makeApiAdapter({ orgUrl: merged.azure.orgUrl, project: merged.azure.project, token: cred.token, fetch: flags.fetch })
1190
+ makeApiAdapter({ orgUrl: merged.azure.orgUrl, project: merged.azure.project, token: cred.token, fetch: flags.fetch, bodyFieldByType: merged.azure.bodyFieldByType })
1189
1191
  let names = null
1190
1192
  try {
1191
1193
  names = (await unionStates(adapter, merged)).map((st) => st.name)
@@ -1300,7 +1302,7 @@ async function specSyncDoctor(dir, flags, out) {
1300
1302
  if (flags.remoteCheck && cred.ok) {
1301
1303
  const adapter =
1302
1304
  flags.adapter ||
1303
- makeApiAdapter({ orgUrl: config.azure.orgUrl, project: config.azure.project, token: cred.token, fetch: flags.fetch })
1305
+ makeApiAdapter({ orgUrl: config.azure.orgUrl, project: config.azure.project, token: cred.token, fetch: flags.fetch, bodyFieldByType: config.azure.bodyFieldByType })
1304
1306
  try {
1305
1307
  const viewer = await adapter.readViewer()
1306
1308
  checks.push(row('remote', 'Azure reachable', 'ok', viewer ? `as ${viewer.name || viewer.id}` : 'yes'))
@@ -1319,6 +1321,41 @@ async function specSyncDoctor(dir, flags, out) {
1319
1321
  )
1320
1322
  : row('states', 'State names', 'ok', 'every configured state exists'),
1321
1323
  )
1324
+ // Every mapped type must exist, and carry the body field configured
1325
+ // for it — a missing type fails the first push, and a missing field
1326
+ // silently drops every Bug's body. NO ROW when nothing is mapped: a
1327
+ // line about an unconfigured surface accuses a healthy project.
1328
+ const mappedTypes = [
1329
+ ...new Set([
1330
+ ...Object.values(config.azure.workItemTypeByKind || {}),
1331
+ ...Object.keys(config.azure.bodyFieldByType || {}),
1332
+ ]),
1333
+ ]
1334
+ if (mappedTypes.length) {
1335
+ const problems = []
1336
+ for (const type of mappedTypes) {
1337
+ const fields = await adapter.listTypeFields(type)
1338
+ if (fields == null) {
1339
+ problems.push(`type "${type}" is not in the project`)
1340
+ continue
1341
+ }
1342
+ const wanted = (config.azure.bodyFieldByType || {})[type]
1343
+ if (wanted && !fields.some((f) => f.toLowerCase() === wanted.toLowerCase())) {
1344
+ problems.push(`type "${type}" has no field ${wanted}`)
1345
+ }
1346
+ }
1347
+ checks.push(
1348
+ problems.length
1349
+ ? row(
1350
+ 'types',
1351
+ 'Mapped types',
1352
+ 'broken',
1353
+ problems.join('; '),
1354
+ `create the type/field in the process, or fix ${CONFIG_FILE} -> azure.workItemTypeByKind / azure.bodyFieldByType`,
1355
+ )
1356
+ : row('types', 'Mapped types', 'ok', 'every mapped type exists and carries its body field'),
1357
+ )
1358
+ }
1322
1359
  // The capability probe Decision 8 names: identity search is the op
1323
1360
  // that fails first on a narrow token. A 401 here is a WARN, not
1324
1361
  // broken — work item sync is whole without it; only `users` search
@@ -45,12 +45,22 @@ const DEFAULT_CONFIG = Object.freeze({
45
45
  // the Basic, Agile and CMMI backlogs drag-order; a Scrum process ranks by
46
46
  // `Microsoft.VSTS.Common.BacklogPriority` instead.
47
47
  backlogOrderField: 'Microsoft.VSTS.Common.StackRank',
48
- // The mint type per SPEC KIND (`feature`/`bug`/`hotfix`, from the spec
49
- // folder's prefix), falling back to `workItemType`. In Agile, Scrum and
50
- // CMMI a bug is a work item TYPE, so `/spec-bug` minting a User Story
48
+ // The mint type per SPEC KIND (`feature`/`bug`/`hotfix`/`chore`, from the
49
+ // spec folder's prefix), falling back to `workItemType`. In Agile, Scrum
50
+ // and CMMI a bug is a work item TYPE, so `/spec-bug` minting a User Story
51
51
  // files it in the wrong backlog; `{ "bug": "Bug", "hotfix": "Bug" }` is
52
- // the usual shape there. Empty means one type for everything, as before.
52
+ // the usual shape there. `chore` wants a custom inherited type (create
53
+ // `Chore` and its states in the process first); unmapped it falls back to
54
+ // `workItemType`. Empty means one type for everything, as before.
53
55
  workItemTypeByKind: Object.freeze({}),
56
+ // The field a TYPE's body is written to and read from, keyed by work item
57
+ // type name — `{ "Bug": "Microsoft.VSTS.TCM.ReproSteps" }` is the shape
58
+ // Agile/Scrum/CMMI want, because their Bug form does not show
59
+ // System.Description at all. Unmapped types keep System.Description. The
60
+ // mapping is symmetric (create, update, read-back, edited-hash compare):
61
+ // a write-only mapping would make `/spec-status` report every Bug as
62
+ // edited. Empty means System.Description everywhere, as before.
63
+ bodyFieldByType: Object.freeze({}),
54
64
  }),
55
65
  // A spec is a WORK ITEM; each phase a CHILD work item under a hierarchy
56
66
  // link. `tasks` selects how the phase's checkboxes reach that child's
@@ -193,12 +203,22 @@ function mergeConfig(base, parsed) {
193
203
  // Only the kinds a spec folder can actually be — an unknown key is
194
204
  // dropped rather than carried into `states` validation it can never pass.
195
205
  const byKind = {}
196
- for (const kind of ['feature', 'bug', 'hotfix']) {
206
+ for (const kind of ['feature', 'bug', 'hotfix', 'chore']) {
197
207
  const value = parsed.azure.workItemTypeByKind[kind]
198
208
  if (typeof value === 'string' && value.trim()) byKind[kind] = value.trim()
199
209
  }
200
210
  base.azure.workItemTypeByKind = byKind
201
211
  }
212
+ if (isObject(parsed.azure.bodyFieldByType)) {
213
+ // Keyed by TYPE name (open — any type a project invents), value a field
214
+ // reference name. Blank values are dropped rather than written as an
215
+ // empty field path.
216
+ const byType = {}
217
+ for (const [type, field] of Object.entries(parsed.azure.bodyFieldByType)) {
218
+ if (typeof field === 'string' && field.trim() && String(type).trim()) byType[String(type).trim()] = field.trim()
219
+ }
220
+ base.azure.bodyFieldByType = byType
221
+ }
202
222
  // A trailing slash on the org would double up in every composed URL.
203
223
  if (base.azure.orgUrl) base.azure.orgUrl = base.azure.orgUrl.replace(/\/+$/, '')
204
224
  }
@@ -299,16 +319,32 @@ function withRuntime(config) {
299
319
  },
300
320
  description(item) {
301
321
  const fields = item && item.fields
302
- if (fields && typeof fields === 'object' && 'System.Description' in fields) {
303
- // null IS an answer on this branch: the field was fetched and the
304
- // description is genuinely empty — clearing one is an edit, not a
305
- // cannot-tell.
306
- const d = fields['System.Description']
307
- if (d == null) return ''
308
- const text = String(d)
309
- const fmt = item.multilineFieldsFormat && item.multilineFieldsFormat['System.Description']
310
- if (fmt && String(fmt).toLowerCase() === 'markdown') return text
311
- return looksLikeHtml(text) ? htmlToText(text) : text
322
+ if (fields && typeof fields === 'object') {
323
+ // The body field hangs off the item's TYPE (azure.bodyFieldByType),
324
+ // same resolution as the adapter's writes — the hash compare must
325
+ // read the field the push wrote or every mapped Bug reads as edited.
326
+ const type = String(fields['System.WorkItemType'] || '').toLowerCase()
327
+ const mapped = Object.entries(config.azure.bodyFieldByType || {}).find(
328
+ ([t]) => t.toLowerCase() === type,
329
+ )
330
+ let field = mapped ? mapped[1] : 'System.Description'
331
+ // An empty mapped field falls back to System.Description — an item
332
+ // minted before the mapping holds its body there (same rule as the
333
+ // adapter's read side).
334
+ if (mapped && (fields[field] == null || fields[field] === '') && fields['System.Description'] != null) {
335
+ field = 'System.Description'
336
+ }
337
+ if (field in fields) {
338
+ // null IS an answer on this branch: the field was fetched and the
339
+ // description is genuinely empty — clearing one is an edit, not a
340
+ // cannot-tell.
341
+ const d = fields[field]
342
+ if (d == null) return ''
343
+ const text = String(d)
344
+ const fmt = item.multilineFieldsFormat && item.multilineFieldsFormat[field]
345
+ if (fmt && String(fmt).toLowerCase() === 'markdown') return text
346
+ return looksLikeHtml(text) ? htmlToText(text) : text
347
+ }
312
348
  }
313
349
  return item && typeof item.description === 'string' ? item.description : undefined
314
350
  },
@@ -70,7 +70,18 @@ function discoverAzure(toolNames) {
70
70
  * shapes the engine consumes. Ops the server cannot express are absent — the
71
71
  * consumer feature-detects, exactly as with the API adapter's extras.
72
72
  */
73
- function makeAdapter({ tools, call, orgUrl, project }) {
73
+ function makeAdapter({ tools, call, orgUrl, project, bodyFieldByType = {} }) {
74
+ // Same resolution as the REST adapter: the field a type's body lives in,
75
+ // System.Description unless azure.bodyFieldByType names one, matched
76
+ // case-insensitively. An MCP update cannot resolve the type (the generic
77
+ // update takes raw fields), so only the creates map here; the REST
78
+ // transport is the one that covers updates.
79
+ const bodyFields = Object.entries(bodyFieldByType || {}).map(([t, f]) => [String(t).toLowerCase(), f])
80
+ const bodyFieldFor = (workItemType) => {
81
+ const want = String(workItemType || '').toLowerCase()
82
+ const hit = bodyFields.find(([t]) => t === want)
83
+ return hit ? hit[1] : 'System.Description'
84
+ }
74
85
  const org = String(orgUrl || '').replace(/\/+$/, '')
75
86
  const urlOf = (id) => (org && project ? `${org}/${encodeURIComponent(project)}/_workitems/edit/${id}` : null)
76
87
  const normalize = (raw) => {
@@ -96,7 +107,7 @@ function makeAdapter({ tools, call, orgUrl, project }) {
96
107
  action: 'create',
97
108
  project,
98
109
  workItemType,
99
- fields: { 'System.Title': title, 'System.Description': description },
110
+ fields: { 'System.Title': title, [bodyFieldFor(workItemType)]: description },
100
111
  format: 'markdown',
101
112
  }),
102
113
  )
@@ -107,7 +118,7 @@ function makeAdapter({ tools, call, orgUrl, project }) {
107
118
  project,
108
119
  parentId: Number(parentId),
109
120
  workItemType: childType,
110
- fields: { 'System.Title': title, 'System.Description': description },
121
+ fields: { 'System.Title': title, [bodyFieldFor(childType)]: description },
111
122
  format: 'markdown',
112
123
  }),
113
124
  )
@@ -405,15 +405,39 @@ function readSnapshot(snapshotDir, config) {
405
405
  return { frontmatter: data, title, sections, phases, body }
406
406
  }
407
407
 
408
+ // The headings a bug-shaped spec's ticket leads with, in this order, when the
409
+ // spec has them. A Bug ticket is read for its repro before anything else, and
410
+ // the feature overview order buries it. Sections a spec does not have are
411
+ // skipped, never invented — a legacy bug spec with feature-shaped sections
412
+ // renders exactly as it always did.
413
+ const BUG_LEAD_SECTIONS = ['Symptom', 'Repro', 'Expected', 'Actual', 'Root cause', 'Failing test (red)', 'Fix']
414
+
415
+ // A spec's kind off its folder prefix — the same convention the providers'
416
+ // `specKindOf` reads, kept local because sync-core depends on no other package.
417
+ function bugShaped(snapshotDir) {
418
+ const name = path.basename(String(snapshotDir || ''))
419
+ return name.startsWith('bug-') || name.startsWith('hotfix-')
420
+ }
421
+
408
422
  // Build the pushed description: the overview prose with local-only sections
409
423
  // removed. Keeps the title line for context. `extraSkip` drops additional
410
424
  // sections (e.g. "Phases" once milestones sync as first-class Linear objects, so
411
425
  // the phase list isn't duplicated in the description — Decision 5).
412
- function buildDescription(title, sections, localOnlySections, extraSkip = [], dialect) {
426
+ // `leadSections` names headings to emit FIRST, in its order, matched
427
+ // case-insensitively; the rest follow in document order. Empty means document
428
+ // order throughout — byte-identical to before the parameter existed.
429
+ function buildDescription(title, sections, localOnlySections, extraSkip = [], dialect, leadSections = []) {
413
430
  const skip = new Set([...(localOnlySections || []), ...extraSkip])
414
431
  const parts = []
415
432
  if (title) parts.push(`# ${title}`)
416
- for (const [heading, content] of Object.entries(sections)) {
433
+ const entries = Object.entries(sections)
434
+ const lead = []
435
+ for (const want of leadSections) {
436
+ const hit = entries.find(([heading]) => heading.toLowerCase() === want.toLowerCase())
437
+ if (hit) lead.push(hit)
438
+ }
439
+ const ordered = [...lead, ...entries.filter((e) => !lead.includes(e))]
440
+ for (const [heading, content] of ordered) {
417
441
  if (skip.has(heading)) continue
418
442
  parts.push(`## ${heading}\n\n${content}`.trim())
419
443
  }
@@ -706,6 +730,10 @@ function normalizeLocal(snapshotDir, config) {
706
730
  config.sync.localOnlySections,
707
731
  phasesCarriedBySubIssues ? ['Phases'] : [],
708
732
  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 : [],
709
737
  ),
710
738
  inlined,
711
739
  tasksMode,