@skitterbyte/skitterspec-azure-boards 1.1.0 → 1.2.1

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.
@@ -3,6 +3,7 @@
3
3
  "orgUrl": "https://dev.azure.com/your-org",
4
4
  "project": "your-project",
5
5
  "workItemType": "Issue",
6
+ "workItemTypeByKind": {},
6
7
  "childType": "Task",
7
8
  "areaPath": ""
8
9
  },
@@ -15,7 +16,9 @@
15
16
  "intake": {
16
17
  "tag": "",
17
18
  "bugTags": ["bug"],
18
- "hotfixTags": []
19
+ "hotfixTags": [],
20
+ "bugTypes": ["Bug"],
21
+ "hotfixTypes": []
19
22
  },
20
23
  "auth": {
21
24
  "tokenEnv": "AZURE_DEVOPS_EXT_PAT"
@@ -9,11 +9,13 @@ 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
13
  | `azure.childType` | The type a phase mints as, linked parent/child under the spec's item. | `"Task"` |
13
14
  | `azure.areaPath` | Optional area path for minted items; empty means the project default. | `""` |
14
15
  | `mapping.specFolder` / `mapping.phases` / `mapping.tasks` | Spec → work item, phase → child item, tasks → markdown checklist. Same modes as the other providers (`subissue` \| `deferred` \| `inline`; `checklist` \| `none`). | `issue` / `subissue` / `checklist` |
15
16
  | `states.<bucket>` | The Boards STATE name for each lifecycle bucket, per the project's own process. Moves are direct `System.State` writes; a state the process refuses is a named refusal listing the states the type has. `cancelled` defaults to `Done` because the Basic process carries no Cancelled state. | see example |
16
17
  | `intake.tag` / `intake.bugTags` / `intake.hotfixTags` | Intake routes an adopted work item by its tags (Boards has tags, not labels): the inbox filter, and the routes to `/spec-bug` and `/spec-hotfix`. Empty lists route nothing. | `""` / `["bug"]` / `[]` |
18
+ | `intake.bugTypes` / `intake.hotfixTypes` | The same routes, keyed on the item's work item TYPE — in Agile/Scrum/CMMI a bug is a type, not a tag, so an untagged `Bug` still reaches `/spec-bug`. A match on either axis routes, hotfix wins over bug, and an explicit `[]` opts type routing out. | `["Bug"]` / `[]` |
17
19
  | `auth.tokenEnv` | The env-var NAME for the PAT — the official CLI's by default, so a machine set up for `az boards` needs nothing new. Work Items (Read & Write) covers everything but identity search, which wants Identity (Read). | `AZURE_DEVOPS_EXT_PAT` |
18
20
  | `refs.foreignPatterns` | Ref shapes that are KNOWN HISTORY rather than unreferenced commits — a repo migrating off another tracker lists its old key here (e.g. `"ERQ-\\d+"`). | `[]` |
19
21
  | `releases.workItemType` / `releases.series` | The release seam's carrier: one work item of this type per release, found by title, its state moved through each series' `envs` map by `release deployed`. | `"Release"` / `[]` |
@@ -43,26 +43,32 @@ Then:
43
43
  description, tags, reporter, URL. If Azure isn't connected, say so and offer
44
44
  to carry on without it — a spec written from the user's own description is
45
45
  still a spec.
46
- 3. **Route the item to the right skill.** Match the item's TAGS
47
- (case-insensitively — Boards has tags, not labels) against two lists,
48
- **checking `hotfixTags` first**:
49
-
50
- - **`intake.hotfixTags`** → this is broken in **production**, so it needs a
51
- fix against the released version, not `main`. Say so, name the matching
52
- tag, and tell the user to run **`/spec-hotfix <ITEM-REF>`** — then stop.
53
- - **`intake.bugTags`** → a bug report, not a feature request. Say so, name
54
- the tag, and tell the user to run **`/spec-bug <ITEM-REF>`** — then stop,
55
- without authoring a Feature spec.
56
-
57
- **Hotfix wins when an item carries both**, and deliberately: production is the
46
+ 3. **Route the item to the right skill.** Match the item's work item **TYPE**
47
+ against `intake.hotfixTypes`/`intake.bugTypes` and its **TAGS**
48
+ (case-insensitively — Boards has tags, not labels) against
49
+ `intake.hotfixTags`/`intake.bugTags`, **checking the hotfix lists first**.
50
+ A match on *either* axis routes; the type check exists because in the
51
+ Agile, Scrum and CMMI processes a bug is a **type**, not a tag, so a
52
+ support-filed `Bug` with no tags at all still belongs in `/spec-bug`:
53
+
54
+ - **`intake.hotfixTypes` or `intake.hotfixTags`** → this is broken in
55
+ **production**, so it needs a fix against the released version, not
56
+ `main`. Say so, name the matching type or tag, and tell the user to run
57
+ **`/spec-hotfix <ITEM-REF>`** — then stop.
58
+ - **`intake.bugTypes` or `intake.bugTags`** → a bug report, not a feature
59
+ request. Say so, name the matching type or tag, and tell the user to run
60
+ **`/spec-bug <ITEM-REF>`** — then stop, without authoring a Feature spec.
61
+
62
+ **Hotfix wins when an item matches both**, and deliberately: production is the
58
63
  more specific destination, and the two mistakes are not equally costly. Routing
59
64
  a prod issue to `/spec-bug` produces a fix that lands on `main` and never
60
65
  reaches the running version — discovered only when someone asks why it hasn't
61
66
  shipped. The reverse is a hotfix branch for something that could have waited,
62
67
  which is merely wasteful.
63
68
 
64
- With a list unset, nothing routes through it; with both unset every item is
65
- treated as a feature request, exactly as before.
69
+ `bugTypes` defaults to `["Bug"]`; an explicit empty list opts type routing
70
+ out. With a tag list unset, nothing routes through it; with every list
71
+ empty, each item is treated as a feature request, exactly as before.
66
72
 
67
73
  **Which checks run depends on where you are**, because a skip is about not
68
74
  bouncing someone to the skill they are already in — not about ignoring an
@@ -92,6 +92,15 @@ these are config rather than constants:
92
92
  Basic process's); an Agile project usually wants `User Story`.
93
93
  - **`azure.childType`** — the type a phase mints as, created as a hierarchy
94
94
  child. Default **Task**.
95
+ - **`azure.workItemTypeByKind`** — the mint type per spec kind, falling back
96
+ to `workItemType`. Ask it wherever the process HAS a `Bug` type (Agile,
97
+ Scrum, CMMI): a `/spec-bug` or `/spec-hotfix` minting a `User Story` files
98
+ the bug in the wrong backlog, and `{ "bug": "Bug", "hotfix": "Bug" }` is the
99
+ usual answer there. On Basic (no Bug type) say nothing and leave it empty.
100
+ - **`intake.bugTypes`** / **`intake.hotfixTypes`** — the same processes route
101
+ intake by TYPE as well as tag: `bugTypes` defaults to `["Bug"]`, so an
102
+ untagged Bug-type item reaches `/spec-bug` without anyone remembering a tag
103
+ convention. Confirm the default; an explicit `[]` opts type routing out.
95
104
 
96
105
  Offer the defaults and take yes for an answer — this is a confirmation, not an
97
106
  interrogation.
@@ -130,6 +139,7 @@ flag in step 6.
130
139
  skitterspec spec-sync init-config \
131
140
  --org-url https://dev.azure.com/<org> --project <project> \
132
141
  [--work-item-type Issue] [--child-type Task] \
142
+ [--kind-type <kind>=<Type> …] [--bug-type <Type> …] [--hotfix-type <Type> …] \
133
143
  [--state <bucket>=<name> …] [--force] [--json]
134
144
  ```
135
145
 
@@ -147,11 +157,14 @@ right, so don't paraphrase it into "done".
147
157
  **Only when `specs/.core/env.config.json` exists** (per-spec isolation is on).
148
158
  If it is absent, skip this — there is nothing to configure.
149
159
 
150
- **Check before you write — a fresh install may already have this.** When this
160
+ **Check before you write — most projects need nothing here.** When this
151
161
  superset's `init --isolation` wrote the `env.config.json`, both keys below are
152
- seeded; this step is the **retrofit** for a project that adopted isolation
153
- before installing the Azure Boards provider, or ran `/spec-azure-setup` before
154
- adopting it.
162
+ seeded — and even where they are absent, the superset binary now defaults them
163
+ at runtime, so an `env.config.json` that simply omits them already claims the
164
+ snapshot. The one case left is a file that sets them **explicitly to another
165
+ provider's values** (a migration — Linear-era `linear-base`/`linear_identifier`
166
+ is the live example); `spec-sync apply` prints a note naming the exact keys
167
+ whenever the snapshot it wrote is not claimed, so follow that note.
155
168
 
156
169
  `/spec-start` commits an uncommitted spec for you, but only the paths it can
157
170
  prove belong to that spec. Its own folder always does; this repo's per-spec
@@ -42,26 +42,32 @@ Then:
42
42
  description, tags, reporter, URL. If Azure isn't connected, say so and offer
43
43
  to carry on without it — a spec written from the user's own description is
44
44
  still a spec.
45
- 3. **Route the item to the right skill.** Match the item's TAGS
46
- (case-insensitively — Boards has tags, not labels) against two lists,
47
- **checking `hotfixTags` first**:
48
-
49
- - **`intake.hotfixTags`** → this is broken in **production**, so it needs a
50
- fix against the released version, not `main`. Say so, name the matching
51
- tag, and tell the user to run **`/spec-hotfix <ITEM-REF>`** — then stop.
52
- - **`intake.bugTags`** → a bug report, not a feature request. Say so, name
53
- the tag, and tell the user to run **`/spec-bug <ITEM-REF>`** — then stop,
54
- without authoring a Feature spec.
55
-
56
- **Hotfix wins when an item carries both**, and deliberately: production is the
45
+ 3. **Route the item to the right skill.** Match the item's work item **TYPE**
46
+ against `intake.hotfixTypes`/`intake.bugTypes` and its **TAGS**
47
+ (case-insensitively — Boards has tags, not labels) against
48
+ `intake.hotfixTags`/`intake.bugTags`, **checking the hotfix lists first**.
49
+ A match on *either* axis routes; the type check exists because in the
50
+ Agile, Scrum and CMMI processes a bug is a **type**, not a tag, so a
51
+ support-filed `Bug` with no tags at all still belongs in `/spec-bug`:
52
+
53
+ - **`intake.hotfixTypes` or `intake.hotfixTags`** → this is broken in
54
+ **production**, so it needs a fix against the released version, not
55
+ `main`. Say so, name the matching type or tag, and tell the user to run
56
+ **`/spec-hotfix <ITEM-REF>`** — then stop.
57
+ - **`intake.bugTypes` or `intake.bugTags`** → a bug report, not a feature
58
+ request. Say so, name the matching type or tag, and tell the user to run
59
+ **`/spec-bug <ITEM-REF>`** — then stop, without authoring a Feature spec.
60
+
61
+ **Hotfix wins when an item matches both**, and deliberately: production is the
57
62
  more specific destination, and the two mistakes are not equally costly. Routing
58
63
  a prod issue to `/spec-bug` produces a fix that lands on `main` and never
59
64
  reaches the running version — discovered only when someone asks why it hasn't
60
65
  shipped. The reverse is a hotfix branch for something that could have waited,
61
66
  which is merely wasteful.
62
67
 
63
- With a list unset, nothing routes through it; with both unset every item is
64
- treated as a feature request, exactly as before.
68
+ `bugTypes` defaults to `["Bug"]`; an explicit empty list opts type routing
69
+ out. With a tag list unset, nothing routes through it; with every list
70
+ empty, each item is treated as a feature request, exactly as before.
65
71
 
66
72
  **Which checks run depends on where you are**, because a skip is about not
67
73
  bouncing someone to the skill they are already in — not about ignoring an
@@ -49,26 +49,32 @@ Then:
49
49
  description, tags, reporter, URL. If Azure isn't connected, say so and offer
50
50
  to carry on without it — a spec written from the user's own description is
51
51
  still a spec.
52
- 3. **Route the item to the right skill.** Match the item's TAGS
53
- (case-insensitively — Boards has tags, not labels) against two lists,
54
- **checking `hotfixTags` first**:
55
-
56
- - **`intake.hotfixTags`** → this is broken in **production**, so it needs a
57
- fix against the released version, not `main`. Say so, name the matching
58
- tag, and tell the user to run **`/spec-hotfix <ITEM-REF>`** — then stop.
59
- - **`intake.bugTags`** → a bug report, not a feature request. Say so, name
60
- the tag, and tell the user to run **`/spec-bug <ITEM-REF>`** — then stop,
61
- without authoring a Feature spec.
62
-
63
- **Hotfix wins when an item carries both**, and deliberately: production is the
52
+ 3. **Route the item to the right skill.** Match the item's work item **TYPE**
53
+ against `intake.hotfixTypes`/`intake.bugTypes` and its **TAGS**
54
+ (case-insensitively — Boards has tags, not labels) against
55
+ `intake.hotfixTags`/`intake.bugTags`, **checking the hotfix lists first**.
56
+ A match on *either* axis routes; the type check exists because in the
57
+ Agile, Scrum and CMMI processes a bug is a **type**, not a tag, so a
58
+ support-filed `Bug` with no tags at all still belongs in `/spec-bug`:
59
+
60
+ - **`intake.hotfixTypes` or `intake.hotfixTags`** → this is broken in
61
+ **production**, so it needs a fix against the released version, not
62
+ `main`. Say so, name the matching type or tag, and tell the user to run
63
+ **`/spec-hotfix <ITEM-REF>`** — then stop.
64
+ - **`intake.bugTypes` or `intake.bugTags`** → a bug report, not a feature
65
+ request. Say so, name the matching type or tag, and tell the user to run
66
+ **`/spec-bug <ITEM-REF>`** — then stop, without authoring a Feature spec.
67
+
68
+ **Hotfix wins when an item matches both**, and deliberately: production is the
64
69
  more specific destination, and the two mistakes are not equally costly. Routing
65
70
  a prod issue to `/spec-bug` produces a fix that lands on `main` and never
66
71
  reaches the running version — discovered only when someone asks why it hasn't
67
72
  shipped. The reverse is a hotfix branch for something that could have waited,
68
73
  which is merely wasteful.
69
74
 
70
- With a list unset, nothing routes through it; with both unset every item is
71
- treated as a feature request, exactly as before.
75
+ `bugTypes` defaults to `["Bug"]`; an explicit empty list opts type routing
76
+ out. With a tag list unset, nothing routes through it; with every list
77
+ empty, each item is treated as a feature request, exactly as before.
72
78
 
73
79
  **Which checks run depends on where you are**, because a skip is about not
74
80
  bouncing someone to the skill they are already in — not about ignoring an
@@ -21,6 +21,13 @@ if (!existsSync(join(__dirname, '..', 'src'))) {
21
21
  }
22
22
 
23
23
  const { run, HELP } = require('../src/cli.js')
24
+
25
+ // The provider's isolation defaults, registered beneath the project's own
26
+ // env.config.json so `spec-env stage` claims this provider's snapshot sidecar
27
+ // without a hand edit (see common src/env/config.js, setProviderEnvDefaults).
28
+ require('../src/env/config.js').setProviderEnvDefaults(
29
+ require('../src/vendor/azure-boards/config.js').ENV_CONFIG_DEFAULTS,
30
+ )
24
31
  const {
25
32
  PROVIDER_COMMANDS,
26
33
  providerHelpSection,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skitterbyte/skitterspec-azure-boards",
3
- "version": "1.1.0",
3
+ "version": "1.2.1",
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
@@ -4269,7 +4269,7 @@ async function specEnvReview(dir, config, specArg, flags, invokedFrom = dir) {
4269
4269
  // The runners-up sit UNDER the network tier, because that is what they are
4270
4270
  // alternatives to — and virtual adapters are gone from them entirely.
4271
4271
  (served && !served.loopback && (served.alternates || []).length
4272
- ? served.alternates.map((u) => ` also: ${u}\n`).join('')
4272
+ ? served.alternates.map((u) => ` also: ${u}${tailnetLabel(u)}\n`).join('')
4273
4273
  : '') +
4274
4274
  // WHICH TIERS THE WAIT COVERS, once, next to the stack. `local` and
4275
4275
  // `network` are two doors into one room — the page POSTs to
@@ -4572,11 +4572,37 @@ function lanAddresses(nets = require('node:os').networkInterfaces()) {
4572
4572
  * where the opposite hides the only address that works.
4573
4573
  */
4574
4574
  function offerableLanAddresses(nets = require('node:os').networkInterfaces()) {
4575
- return rankLanAddresses(nets)
4575
+ const ranked = rankLanAddresses(nets)
4576
+ // A tailnet address IS reachable from a phone off the LAN, but macOS puts it
4577
+ // on `utunN`, which the virtual filter drops. It is appended after every
4578
+ // other offerable address so the wifi one stays the best guess at home.
4579
+ const tailnet = ranked.filter((e) => VIRTUAL_IFACE.test(e.iface) && isTailnetAddress(e.address))
4580
+ return ranked
4576
4581
  .filter((e) => !VIRTUAL_IFACE.test(e.iface))
4582
+ .concat(tailnet)
4577
4583
  .map((e) => e.address)
4578
4584
  }
4579
4585
 
4586
+ // 100.64.0.0/10 — the CGNAT range Tailscale assigns from.
4587
+ //
4588
+ // WHAT WOULD FOOL THIS: a carrier-grade NAT or another overlay network using
4589
+ // the same range on a utun adapter is offered too. That costs one dud `also:`
4590
+ // line, where filtering it hides the only link a reader off the wifi can open.
4591
+ function isTailnetAddress(address) {
4592
+ const m = /^100\.(\d+)\./.exec(address)
4593
+ return !!m && Number(m[1]) >= 64 && Number(m[1]) <= 127
4594
+ }
4595
+
4596
+ // The suffix on an `also:` line whose host is a tailnet address, so it reads
4597
+ // apart from the LAN one — a reader off the wifi needs to know which to tap.
4598
+ function tailnetLabel(url) {
4599
+ let host = ''
4600
+ try {
4601
+ host = new URL(url).hostname
4602
+ } catch {}
4603
+ return isTailnetAddress(host) ? ' (tailnet)' : ''
4604
+ }
4605
+
4580
4606
  /**
4581
4607
  * Bring the review server up, or adopt the one already running.
4582
4608
  *
@@ -5950,6 +5976,7 @@ module.exports = {
5950
5976
  unknownCommand,
5951
5977
  rankLanAddresses,
5952
5978
  offerableLanAddresses,
5979
+ tailnetLabel,
5953
5980
  reviewTierStack,
5954
5981
  serveProcFor,
5955
5982
  serverScriptOk,
package/src/env/config.js CHANGED
@@ -759,6 +759,48 @@ function mergeConfig(base, parsed) {
759
759
  * It is advisory in the strongest sense: nothing here acts on it, and a config
760
760
  * full of strays loads exactly as it always did.
761
761
  */
762
+ // The isolation keys a ticketing provider needs a project to declare — set
763
+ // once per process by a provider superset's bin, beneath whatever the
764
+ // project's own env.config.json says. They used to reach only the
765
+ // `env.config.json.example` composed at build time, which left every project
766
+ // that adopted a provider over an EXISTING isolation config (or skipped the
767
+ // example) with a `spec.companionPaths` that never claims the provider's
768
+ // snapshot sidecar — `spec-env stage` then classifies the spec's own
769
+ // `<baseDir>/<identifier>.base.json` as foreign and `/commit` leaves it
770
+ // behind. The base distribution registers nothing and behaves as before.
771
+ let providerEnvDefaults = null
772
+ function setProviderEnvDefaults(overrides) {
773
+ providerEnvDefaults = overrides || null
774
+ }
775
+
776
+ // Fill ONLY the keys the project's file does not mention: a key the file sets —
777
+ // including explicitly to '' or [] — is the project's decision and stands
778
+ // ("the two keys are one fix" in scripts/build-dist.test.js is the contract:
779
+ // blanking identifierField must keep disabling the companion expansion).
780
+ function applyProviderEnvDefaults(config, parsed) {
781
+ if (!providerEnvDefaults) return config
782
+ const d = providerEnvDefaults
783
+ const pBranch = parsed && typeof parsed.branch === 'object' && parsed.branch !== null ? parsed.branch : null
784
+ if (
785
+ d.branch &&
786
+ typeof d.branch.identifierField === 'string' &&
787
+ !(pBranch && 'identifierField' in pBranch) &&
788
+ !config.branch.identifierField
789
+ ) {
790
+ config.branch.identifierField = d.branch.identifierField
791
+ }
792
+ const pSpec = parsed && typeof parsed.spec === 'object' && parsed.spec !== null ? parsed.spec : null
793
+ if (
794
+ d.spec &&
795
+ Array.isArray(d.spec.companionPaths) &&
796
+ !(pSpec && 'companionPaths' in pSpec) &&
797
+ !config.spec.companionPaths.length
798
+ ) {
799
+ config.spec.companionPaths = [...d.spec.companionPaths]
800
+ }
801
+ return config
802
+ }
803
+
762
804
  function loadEnvConfig(dir = process.cwd()) {
763
805
  const base = defaults()
764
806
  const file = join(dir, CONFIG_FILE)
@@ -767,7 +809,9 @@ function loadEnvConfig(dir = process.cwd()) {
767
809
  try {
768
810
  raw = readFileSync(file, 'utf-8')
769
811
  } catch (error) {
770
- if (error.code === 'ENOENT') return { config: base, present: false, unknown: [], badReviewers: [] }
812
+ if (error.code === 'ENOENT') {
813
+ return { config: applyProviderEnvDefaults(base, null), present: false, unknown: [], badReviewers: [] }
814
+ }
771
815
  throw error
772
816
  }
773
817
 
@@ -779,7 +823,7 @@ function loadEnvConfig(dir = process.cwd()) {
779
823
  }
780
824
 
781
825
  return {
782
- config: mergeConfig(base, parsed),
826
+ config: applyProviderEnvDefaults(mergeConfig(base, parsed), parsed),
783
827
  present: true,
784
828
  unknown: collectUnknownKeys(parsed),
785
829
  badReviewers: collectBadReviewers(parsed),
@@ -788,6 +832,7 @@ function loadEnvConfig(dir = process.cwd()) {
788
832
 
789
833
  module.exports = {
790
834
  loadEnvConfig,
835
+ setProviderEnvDefaults,
791
836
  resolveServePort,
792
837
  derivedServePort,
793
838
  servePortRoot,
@@ -25,7 +25,7 @@
25
25
  */
26
26
 
27
27
  const { withRateLimitRetry, MAX_RETRIES } = require('../provider-kit/src/http.js')
28
- const { htmlToText, looksLikeHtml } = require('./dialect.js')
28
+ const { htmlToText, looksLikeHtml, decodeEntities } = require('./dialect.js')
29
29
  const { authHeader } = require('./credentials.js')
30
30
 
31
31
  const API_VERSION = '7.1'
@@ -151,16 +151,18 @@ function makeApiAdapter({ orgUrl, project, token, releaseType, fetch: fetchImpl,
151
151
  return m ? m[1] : null
152
152
  }
153
153
 
154
- // Text at the boundary: a markdown-format description passes through
155
- // verbatim, an HTML-era one is reduced to text, and the format map is the
156
- // positive signal that decides — the tag sniff only covers items too old to
157
- // carry one.
154
+ // Text at the boundary: a markdown-format description is entity-DECODED —
155
+ // Azure encodes stray HTML specials on store (`>` → `&gt;`, `"` → `&quot;`,
156
+ // observed live), so the decode is the inverse of the store, and what comes
157
+ // out is the author's text. An HTML-era one is reduced to text, and the
158
+ // format map is the positive signal that decides — the tag sniff only covers
159
+ // items too old to carry one.
158
160
  function descriptionText(raw) {
159
161
  const d = raw.fields && raw.fields['System.Description']
160
162
  if (d == null) return null
161
163
  const text = String(d)
162
164
  const fmt = raw.multilineFieldsFormat && raw.multilineFieldsFormat['System.Description']
163
- if (fmt && String(fmt).toLowerCase() === 'markdown') return text
165
+ if (fmt && String(fmt).toLowerCase() === 'markdown') return decodeEntities(text)
164
166
  return looksLikeHtml(text) ? htmlToText(text) : text
165
167
  }
166
168
 
@@ -379,7 +381,11 @@ function makeApiAdapter({ orgUrl, project, token, releaseType, fetch: fetchImpl,
379
381
  const u = raw && raw.authenticatedUser
380
382
  if (!u || !u.id) return null
381
383
  const email = (u.properties && u.properties.Account && u.properties.Account.$value) || null
382
- return { id: u.id, name: u.providerDisplayName || null, email }
384
+ // The id slot carries the uniqueName/email, because that is what
385
+ // `System.AssignedTo` accepts — Azure refuses the connectionData GUID as
386
+ // an "unknown identity" (live repro, bug-azure-boards-adoption-fixes).
387
+ // The GUID survives only where no account property exists at all.
388
+ return { id: email || u.id, name: u.providerDisplayName || null, email }
383
389
  },
384
390
 
385
391
  /**
@@ -407,14 +413,21 @@ function makeApiAdapter({ orgUrl, project, token, releaseType, fetch: fetchImpl,
407
413
  }
408
414
  throw error
409
415
  }
410
- const users = ((raw && raw.value) || []).slice(0, limit).map((u) => ({
411
- id: u.id,
412
- name: u.providerDisplayName || null,
413
- email: (u.properties && u.properties.Account && u.properties.Account.$value) || null,
414
- // `isActive` is a positive marker where present; absence is not
415
- // deactivation, so the default is active.
416
- active: u.isActive === false ? false : true,
417
- }))
416
+ const users = ((raw && raw.value) || []).slice(0, limit).map((u) => {
417
+ const email = (u.properties && u.properties.Account && u.properties.Account.$value) || null
418
+ return {
419
+ // The assignable value first: `System.AssignedTo` accepts the
420
+ // uniqueName/email and refuses the vssps GUID, and this id is what
421
+ // `/spec-claim --to` stamps. The GUID remains the fallback for an
422
+ // identity with no account property (a group, a service identity).
423
+ id: email || u.id,
424
+ name: u.providerDisplayName || null,
425
+ email,
426
+ // `isActive` is a positive marker where present; absence is not
427
+ // deactivation, so the default is active.
428
+ active: u.isActive === false ? false : true,
429
+ }
430
+ })
418
431
  return { users, nextCursor: null }
419
432
  },
420
433
 
@@ -146,7 +146,21 @@ function stateCheckFailure(config, flags) {
146
146
  // Apply ops: the kit orchestration with Azure's tracker calls. State is moved
147
147
  // by a direct `System.State` write after the create/update, and `transitionTo`
148
148
  // is idempotent when the item already sits on the target.
149
- function applyOps({ adapter, config }) {
149
+ // A spec's KIND, read off its folder prefix — the same convention the
150
+ // lifecycle skills stamp into `> **Type:**`, but greppable with no file read.
151
+ function specKindOf(snapshotDir) {
152
+ const name = path.basename(String(snapshotDir || ''))
153
+ if (name.startsWith('bug-')) return 'bug'
154
+ if (name.startsWith('hotfix-')) return 'hotfix'
155
+ return 'feature'
156
+ }
157
+
158
+ function applyOps({ adapter, config, out, kind = 'feature' }) {
159
+ // The mint type for THIS spec's kind (its folder prefix), falling back to
160
+ // the one configured type. The twin search uses the same type, so a bug
161
+ // never refuses over a feature that happens to share its title.
162
+ const mintType =
163
+ (config.azure.workItemTypeByKind && config.azure.workItemTypeByKind[kind]) || config.azure.workItemType
150
164
  const stateFor = (bucket) => {
151
165
  const name = config.states && config.states[bucket]
152
166
  if (!name) {
@@ -158,11 +172,29 @@ function applyOps({ adapter, config }) {
158
172
  if (!bucket) return
159
173
  await adapter.transitionTo(apiId(idOrIdentifier), stateFor(bucket))
160
174
  }
175
+ // Azure refuses the WHOLE patch over one bad `System.AssignedTo` value
176
+ // ("… is an unknown identity", live repro), which used to take the
177
+ // description and state down with it. A refused assignee is a cosmetic gap
178
+ // `/spec-claim` closes later; the rest of the push is not — so retry the
179
+ // same write once without the assignee and say so. Only that exact refusal
180
+ // is retried: any other error still fails the apply.
181
+ const skippingRefusedAssignee = async (input, send) => {
182
+ const assignee = 'assigneeId' in input ? input.assigneeId : undefined
183
+ try {
184
+ return await send(input)
185
+ } catch (error) {
186
+ if (assignee === undefined || !/unknown identity/i.test(String(error && error.message))) throw error
187
+ const { assigneeId, ...rest } = input
188
+ const result = await send(rest)
189
+ if (out) out.write(` !! assignee skipped: Azure refused '${assignee}' for Assigned To — the rest of the push landed\n`)
190
+ return result
191
+ }
192
+ }
161
193
  return {
162
194
  prevalidateStates: (buckets) => {
163
195
  for (const bucket of buckets) stateFor(bucket)
164
196
  },
165
- searchTwin: (title) => adapter.searchIssues({ query: title, workItemType: config.azure.workItemType }),
197
+ searchTwin: (title) => adapter.searchIssues({ query: title, workItemType: mintType }),
166
198
  twinAdvice: (twin, wanted, specName) =>
167
199
  `${twin.identifier} is already titled "${wanted}" and no spec claims it — ` +
168
200
  `stamp it onto the spec with \`spec-sync stamp ${specName} --issue ${twin.identifier}\`, ` +
@@ -171,13 +203,16 @@ function applyOps({ adapter, config }) {
171
203
  remoteEditedLine: (identifier) =>
172
204
  ` !! ${identifier}'s description was edited on Azure Boards since the last push — this replaces it`,
173
205
  mintIssue: async ({ title, issue }) => {
174
- const created = await adapter.createIssue({
175
- title,
176
- description: issue && issue.description != null ? issue.description : undefined,
177
- assigneeId: issue && issue.assignee ? issue.assignee : undefined,
178
- workItemType: config.azure.workItemType,
179
- areaPath: config.azure.areaPath || undefined,
180
- })
206
+ const created = await skippingRefusedAssignee(
207
+ {
208
+ title,
209
+ description: issue && issue.description != null ? issue.description : undefined,
210
+ assigneeId: issue && issue.assignee ? issue.assignee : undefined,
211
+ workItemType: mintType,
212
+ areaPath: config.azure.areaPath || undefined,
213
+ },
214
+ (input) => adapter.createIssue(input),
215
+ )
181
216
  await settle(created.id, issue && issue.state)
182
217
  return created
183
218
  },
@@ -187,7 +222,9 @@ function applyOps({ adapter, config }) {
187
222
  // Null is meaningful here — it is how Boards unassigns — so the key is
188
223
  // forwarded whenever the plan carries it, never truthiness-tested.
189
224
  if ('assignee' in issue) updates.assigneeId = issue.assignee ?? null
190
- if (Object.keys(updates).length) await adapter.updateIssue(apiId(existing.identifier), updates)
225
+ if (Object.keys(updates).length) {
226
+ await skippingRefusedAssignee(updates, (input) => adapter.updateIssue(apiId(existing.identifier), input))
227
+ }
191
228
  await settle(existing.identifier, issue.state)
192
229
  },
193
230
  mintSubIssue: async (parentId, sub) => {
@@ -356,11 +393,21 @@ const assignment = makeAssignmentCommands({
356
393
  usersOverMcp: 'search identities with core_get_identity_ids over MCP, or read them off the org\'s Users page',
357
394
  })
358
395
 
359
- // The state names BOTH configured types can hold, deduped — one map serves the
396
+ // The state names EVERY configured type can hold, deduped — one map serves the
360
397
  // spec item and its children, so a name only has to exist on one of them to be
361
- // writable somewhere, and validation checks against the union.
398
+ // writable somewhere, and validation checks against the union. The per-kind
399
+ // mint types are in the union too, so a `workItemTypeByKind` entry's states
400
+ // are validated before the first write, exactly like the base pair.
362
401
  async function unionStates(adapter, config) {
363
- const types = [...new Set([config.azure.workItemType, config.azure.childType].filter(Boolean))]
402
+ const types = [
403
+ ...new Set(
404
+ [
405
+ config.azure.workItemType,
406
+ config.azure.childType,
407
+ ...Object.values(config.azure.workItemTypeByKind || {}),
408
+ ].filter(Boolean),
409
+ ),
410
+ ]
364
411
  const byName = new Map()
365
412
  for (const type of types) {
366
413
  for (const s of await adapter.listIssueStates(type)) {
@@ -410,6 +457,52 @@ function specSyncPlan(dir, config, specArg, flags, out, err) {
410
457
  return 0
411
458
  }
412
459
 
460
+ // Does the project's OWN env.config.json claim the snapshot this apply just
461
+ // wrote? If not, `spec-env stage` classifies `<baseDir>/<id>.base.json` as
462
+ // another spec's and `/commit` leaves it behind — found live on a project that
463
+ // adopted this provider over a Linear-era isolation config. One line, after a
464
+ // successful apply, naming the exact keys to set.
465
+ //
466
+ // Fires only on POSITIVE signals: env.config.json present and parseable, the
467
+ // identifier stamped, and an explicit pattern set that provably misses the
468
+ // file. A key the project leaves unset is covered by the provider's runtime
469
+ // env defaults (common src/env/config.js), so absence stays silent — as does
470
+ // a project with no isolation at all (`.claude/rules/negative-checks.md`).
471
+ function companionCoverageNote(dir, config, snapshotDir, out) {
472
+ let parsed
473
+ try {
474
+ parsed = JSON.parse(fs.readFileSync(path.join(dir, 'specs', '.core', 'env.config.json'), 'utf-8'))
475
+ } catch {
476
+ return
477
+ }
478
+ if (!parsed || typeof parsed !== 'object') return
479
+ const overviewFile = (config.snapshot && config.snapshot.overviewFile) || '00-overview.md'
480
+ const identifier = specHelpers.linkedIdentifier(path.join(snapshotDir, overviewFile), config)
481
+ if (!identifier) return
482
+
483
+ const defaultPattern = `${config.sync.baseDir}/{identifier}.base.json`
484
+ const rawPatterns = parsed.spec && parsed.spec.companionPaths
485
+ const patterns = Array.isArray(rawPatterns) ? rawPatterns : [defaultPattern]
486
+ const rawField = parsed.branch && parsed.branch.identifierField
487
+ const field = typeof rawField === 'string' && rawField ? rawField : config.fields.identifier
488
+
489
+ const slug = path.basename(snapshotDir).replace(/^(feat|bug|hotfix)-/, '')
490
+ const basePath = `${config.sync.baseDir}/${identifier}.base.json`
491
+ const claimed = patterns.some((p) => {
492
+ if (typeof p !== 'string') return false
493
+ const expanded = p.split('{identifier}').join(identifier).split('{slug}').join(slug)
494
+ if (expanded !== basePath) return false
495
+ // Stage reads `{identifier}` through branch.identifierField, so a pattern
496
+ // that names the right file through the wrong field still claims nothing.
497
+ return !p.includes('{identifier}') || field === config.fields.identifier
498
+ })
499
+ if (claimed) return
500
+ out.write(
501
+ ` note: ${basePath} is not claimed by env.config.json — spec-env stage and /commit will treat it as another spec's.\n` +
502
+ ` set branch.identifierField: "${config.fields.identifier}" and add "${defaultPattern}" to spec.companionPaths\n`,
503
+ )
504
+ }
505
+
413
506
  async function specSyncApply(dir, config, specArg, flags, out, err) {
414
507
  if (!flags.plan && !flags.all) {
415
508
  out.write(`${PROGRAM} apply: pass --plan <file> (from \`plan --json\`), or --all <bucket>\n`)
@@ -442,7 +535,7 @@ async function specSyncApply(dir, config, specArg, flags, out, err) {
442
535
  snapshotDir,
443
536
  plan,
444
537
  adapter: cred.adapter,
445
- ops: applyOps({ adapter: cred.adapter, config }),
538
+ ops: applyOps({ adapter: cred.adapter, config, out, kind: specKindOf(snapshotDir) }),
446
539
  forceNew: !!flags.forceNew,
447
540
  program: PROGRAM,
448
541
  })
@@ -464,6 +557,7 @@ async function specSyncApply(dir, config, specArg, flags, out, err) {
464
557
  try {
465
558
  const applied = await applyOne(snapshotDir, r.plan)
466
559
  out.write(applied.lines.join('\n') + '\n')
560
+ companionCoverageNote(dir, config, snapshotDir, out)
467
561
  } catch (error) {
468
562
  failed++
469
563
  out.write(` !! ${error.message}\n`)
@@ -494,6 +588,7 @@ async function specSyncApply(dir, config, specArg, flags, out, err) {
494
588
  try {
495
589
  const applied = await applyOne(snapshotDir, plan)
496
590
  out.write(applied.lines.join('\n') + '\n')
591
+ companionCoverageNote(dir, config, snapshotDir, out)
497
592
  return 0
498
593
  } catch (error) {
499
594
  out.write(`${PROGRAM} apply: ${error.message}\n`)
@@ -814,7 +909,16 @@ function specSyncRef(dir, config, specArg, flags, out, err) {
814
909
  return 1
815
910
  }
816
911
  } else {
817
- const branch = currentBranch(dir)
912
+ // `currentBranch` takes a git READER bound to the checkout, not a path.
913
+ const { execFileSync } = require('node:child_process')
914
+ const git = (argv) => {
915
+ try {
916
+ return execFileSync('git', ['-C', dir, ...argv], { stdio: ['ignore', 'pipe', 'ignore'] }).toString().trim()
917
+ } catch {
918
+ return null
919
+ }
920
+ }
921
+ const branch = currentBranch(git)
818
922
  if (!branch) {
819
923
  err.write(`${PROGRAM} ref: not on a branch\n`)
820
924
  return 1
@@ -1033,6 +1137,12 @@ async function specSyncInitConfig(dir, flags, out) {
1033
1137
  const parsed = { azure: { orgUrl: flags.orgUrl, project: flags.project } }
1034
1138
  if (flags.workItemType) parsed.azure.workItemType = flags.workItemType
1035
1139
  if (flags.childType) parsed.azure.childType = flags.childType
1140
+ if (flags.kindTypes && Object.keys(flags.kindTypes).length) parsed.azure.workItemTypeByKind = flags.kindTypes
1141
+ if (flags.bugTypes || flags.hotfixTypes) {
1142
+ parsed.intake = {}
1143
+ if (flags.bugTypes) parsed.intake.bugTypes = flags.bugTypes
1144
+ if (flags.hotfixTypes) parsed.intake.hotfixTypes = flags.hotfixTypes
1145
+ }
1036
1146
  if (flags.stateNames && Object.keys(flags.stateNames).length) {
1037
1147
  for (const bucket of Object.keys(flags.stateNames)) {
1038
1148
  if (!LIFECYCLE_BUCKETS.includes(bucket)) {
@@ -1398,6 +1508,19 @@ function parseArgs(args, sub) {
1398
1508
  '--project': { kind: 'string', name: 'project' },
1399
1509
  '--work-item-type': { kind: 'string', name: 'workItemType' },
1400
1510
  '--child-type': { kind: 'string', name: 'childType' },
1511
+ // `--kind-type bug=Bug`, repeatable — azure.workItemTypeByKind for init-config.
1512
+ '--kind-type': {
1513
+ kind: 'custom',
1514
+ handle: (flags, value) => {
1515
+ const raw = String(value || '').trim()
1516
+ const [kind, ...rest] = raw.split('=')
1517
+ if (rest.length) {
1518
+ flags.kindTypes = { ...(flags.kindTypes || {}), [kind.trim()]: rest.join('=').trim() }
1519
+ }
1520
+ },
1521
+ },
1522
+ '--bug-type': { kind: 'list', name: 'bugTypes' },
1523
+ '--hotfix-type': { kind: 'list', name: 'hotfixTypes' },
1401
1524
  '--state': {
1402
1525
  kind: 'custom',
1403
1526
  handle: (flags, value) => {
@@ -41,6 +41,12 @@ const DEFAULT_CONFIG = Object.freeze({
41
41
  workItemType: 'Issue',
42
42
  childType: 'Task',
43
43
  areaPath: '',
44
+ // The mint type per SPEC KIND (`feature`/`bug`/`hotfix`, from the spec
45
+ // folder's prefix), falling back to `workItemType`. In Agile, Scrum and
46
+ // CMMI a bug is a work item TYPE, so `/spec-bug` minting a User Story
47
+ // files it in the wrong backlog; `{ "bug": "Bug", "hotfix": "Bug" }` is
48
+ // the usual shape there. Empty means one type for everything, as before.
49
+ workItemTypeByKind: Object.freeze({}),
44
50
  }),
45
51
  // A spec is a WORK ITEM; each phase a CHILD work item under a hierarchy
46
52
  // link. `tasks` selects how the phase's checkboxes reach that child's
@@ -59,10 +65,19 @@ const DEFAULT_CONFIG = Object.freeze({
59
65
  complete: 'Done',
60
66
  cancelled: 'Done',
61
67
  }),
62
- // Intake routes an adopted work item by its TAGS (Boards has tags, not
63
- // labels): `tag` is the inbox filter, the other two route to /spec-bug and
64
- // /spec-hotfix. Empty lists route nothing.
65
- intake: Object.freeze({ tag: '', bugTags: Object.freeze(['bug']), hotfixTags: Object.freeze([]) }),
68
+ // Intake routes an adopted work item by its work item TYPE and its TAGS
69
+ // (Boards has tags, not labels): `tag` is the inbox filter, the type and tag
70
+ // lists route to /spec-bug and /spec-hotfix, and hotfix wins over bug.
71
+ // `bugTypes` defaults to Agile/Scrum/CMMI's literal `Bug` type because there
72
+ // a bug IS a type — an explicit empty list opts type routing out. Empty tag
73
+ // lists route nothing, as before.
74
+ intake: Object.freeze({
75
+ tag: '',
76
+ bugTags: Object.freeze(['bug']),
77
+ hotfixTags: Object.freeze([]),
78
+ bugTypes: Object.freeze(['Bug']),
79
+ hotfixTypes: Object.freeze([]),
80
+ }),
66
81
  snapshot: Object.freeze({ overviewFile: '00-overview.md' }),
67
82
  // The frontmatter FIELD VOCABULARY this provider stamps into spec files
68
83
  // (sync-core `src/fields.js`). No legacy keys: this provider has no pre-9.0
@@ -130,6 +145,8 @@ function defaults() {
130
145
  tag: DEFAULT_CONFIG.intake.tag,
131
146
  bugTags: [...DEFAULT_CONFIG.intake.bugTags],
132
147
  hotfixTags: [...DEFAULT_CONFIG.intake.hotfixTags],
148
+ bugTypes: [...DEFAULT_CONFIG.intake.bugTypes],
149
+ hotfixTypes: [...DEFAULT_CONFIG.intake.hotfixTypes],
133
150
  },
134
151
  snapshot: { ...DEFAULT_CONFIG.snapshot },
135
152
  fields: { ...DEFAULT_CONFIG.fields },
@@ -193,6 +210,16 @@ function mergeConfig(base, parsed) {
193
210
  assign(base.azure, parsed.azure, 'workItemType', 'string')
194
211
  assign(base.azure, parsed.azure, 'childType', 'string')
195
212
  assign(base.azure, parsed.azure, 'areaPath', 'string?')
213
+ if (isObject(parsed.azure.workItemTypeByKind)) {
214
+ // Only the kinds a spec folder can actually be — an unknown key is
215
+ // dropped rather than carried into `states` validation it can never pass.
216
+ const byKind = {}
217
+ for (const kind of ['feature', 'bug', 'hotfix']) {
218
+ const value = parsed.azure.workItemTypeByKind[kind]
219
+ if (typeof value === 'string' && value.trim()) byKind[kind] = value.trim()
220
+ }
221
+ base.azure.workItemTypeByKind = byKind
222
+ }
196
223
  // A trailing slash on the org would double up in every composed URL.
197
224
  if (base.azure.orgUrl) base.azure.orgUrl = base.azure.orgUrl.replace(/\/+$/, '')
198
225
  }
@@ -219,6 +246,8 @@ function mergeConfig(base, parsed) {
219
246
  assign(base.intake, parsed.intake, 'tag', 'string?')
220
247
  if (Array.isArray(parsed.intake.bugTags)) base.intake.bugTags = stringList(parsed.intake.bugTags)
221
248
  if (Array.isArray(parsed.intake.hotfixTags)) base.intake.hotfixTags = stringList(parsed.intake.hotfixTags)
249
+ if (Array.isArray(parsed.intake.bugTypes)) base.intake.bugTypes = stringList(parsed.intake.bugTypes)
250
+ if (Array.isArray(parsed.intake.hotfixTypes)) base.intake.hotfixTypes = stringList(parsed.intake.hotfixTypes)
222
251
  }
223
252
 
224
253
  if (isObject(parsed.snapshot)) {
@@ -89,12 +89,29 @@ function htmlToText(html) {
89
89
  .trim()
90
90
  }
91
91
 
92
+ // Azure's storage transform, observed live (phase: bug-azure-boards-adoption-
93
+ // fixes): a markdown description comes back with stray HTML specials
94
+ // entity-encoded, and TAG-SHAPED TOKENS STRIPPED ENTIRELY — `<bucket>` and
95
+ // `<name>` vanish from `specs/<bucket>/<name>/…` even inside a backtick code
96
+ // span. Both transforms are applied to BOTH sides here, so an intact mirror
97
+ // compares clean: decoding is symmetric noise on already-decoded text, and
98
+ // stripping the sent side's tokens matches the sanitiser's deletions.
99
+ //
100
+ // BLIND SPOT, named deliberately: a Boards-side edit that only adds or removes
101
+ // a tag-shaped token is invisible to the compare — the same trade the
102
+ // word-character stream already makes for punctuation, and the same safe
103
+ // direction (`.claude/rules/negative-checks.md` rule 4).
104
+ function azureCanonicalForCompare(text) {
105
+ const decoded = decodeEntities(String(text == null ? '' : text))
106
+ return markdownCanonicalForCompare(decoded.replace(/<\/?[a-zA-Z][a-zA-Z0-9-]*>/g, ''))
107
+ }
108
+
92
109
  const dialect = Object.freeze({
93
110
  canonicalize: canonicalizeMarkdown,
94
111
  // See the header: markdown is stored verbatim, so there is nothing to
95
112
  // reshape for. The hook stays so sync-core can call it unconditionally.
96
113
  flattenTables: (text) => text,
97
- canonicalForCompare: markdownCanonicalForCompare,
114
+ canonicalForCompare: azureCanonicalForCompare,
98
115
  })
99
116
 
100
- module.exports = { dialect, canonicalizeMarkdown, htmlToText, looksLikeHtml }
117
+ module.exports = { dialect, canonicalizeMarkdown, htmlToText, looksLikeHtml, decodeEntities }
@@ -7,9 +7,11 @@
7
7
  *
8
8
  * The answer is DERIVED from the PAT: a Personal Access Token belongs to a
9
9
  * person, and `connectionData` names them without any scope beyond the token
10
- * being valid (phase 1 spike). The id is the IDENTITY id (a GUID) —
11
- * `System.AssignedTo` also accepts the uniqueName/email, but the GUID is the
12
- * one value that survives a display-name change.
10
+ * being valid (phase 1 spike). The id is the uniqueName/email — the one form
11
+ * `System.AssignedTo` accepts. The identity GUID was cached here once, on the
12
+ * belief Azure took both; a live write refused it as an "unknown identity"
13
+ * (bug-azure-boards-adoption-fixes), so the GUID survives only for an
14
+ * identity with no account property at all.
13
15
  */
14
16
 
15
17
  const { resolveIdentity: kitResolveIdentity, defaultDisplayName } = require('../provider-kit/src/identity.js')