@immediately-run/dibber 0.5.0 → 0.6.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/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  **Git as your issue tracker. An open format built on Markdown.**
4
4
 
5
+ [Docs](https://immediately.run/present/github/immediately-run/dibber/main/bundle/docs) · [Spec](SPEC.md) · [Board](https://immediately.run/present/github/immediately-run/dibber/main/bundle/tickets/) · [Website](https://immediately-run.github.io/dibber/)
6
+
5
7
  Dibber is a format for keeping a project's tickets in its own
6
8
  repository: one Markdown file per ticket, YAML frontmatter for its fields, the body for the
7
9
  record of the work, and a status that says when it's closed. No server, no database, no tool
@@ -14,12 +16,30 @@ call dibs on a piece of work — though making the dibs stick, one holder at a t
14
16
  coordinator such as [Baton](https://github.com/immediately-run/baton): a file in git can say who
15
17
  is on it, but cannot stop two people writing their names at once.
16
18
 
19
+ ## Light on your agent's context
20
+
21
+ A coding agent pays for every line it reads. Dibber keeps that to what the agent needs:
22
+
23
+ - **One ticket, one file.** Working on a ticket means opening that ticket, not a long shared
24
+ list or other tickets' history.
25
+ - **Finished work stays out of the way.** A closed ticket keeps its file, so links to it never
26
+ break. But `dibber list` and the agent skills skip closed tickets, so an agent asking "what's
27
+ next?" sees only open work. In a project that has been running for a while, that is a small
28
+ part of the folder.
29
+ - **Works without the tool.** Each ticket states its status on one line at the top, so a plain
30
+ `grep` finds the open tickets even where `dibber` isn't installed.
31
+
32
+ If you're coming from Backlog.md or a similar tool because past tickets keep filling your
33
+ agent's context, this is the difference you'll notice.
34
+
17
35
  ## Status
18
36
 
19
37
  Dibber is in active development, and its work is tracked in Dibber itself. The
20
38
  [board](https://immediately.run/present/github/immediately-run/dibber/main/bundle/tickets/)
21
39
  shows every ticket by status — what is ready, in progress and in review, and what is done —
22
- read straight from `tickets/`.
40
+ read straight from `tickets/`. The
41
+ [docs wiki](https://immediately.run/present/github/immediately-run/dibber/main/bundle/docs)
42
+ shows the guides in [`docs/`](docs/) the same way.
23
43
 
24
44
  ## This repository is an example
25
45
 
@@ -65,7 +85,7 @@ keeps working.
65
85
 
66
86
  - [`SPEC.md`](SPEC.md) — the format, rule by rule (`R-DIB-n`).
67
87
  - [`config.schema.json`](config.schema.json) — the schema of a repository's optional
68
- `.dibber/config.json` (the store's folder and id prefix).
88
+ `.dibber/config.json` (the store's folder, id prefix and spec version).
69
89
  - [`ticket.schema.json`](ticket.schema.json) — the JSON Schema every ticket's frontmatter
70
90
  satisfies. A repository can add a stricter schema of its own.
71
91
  - [`skills/`](skills/), [`bin/`](bin/), [`src/`](src/) — optional tooling: the `dibber`
@@ -80,7 +100,9 @@ Use `dibber new --title "…"` to file a ticket. Point `--body-file PATH` at a c
80
100
  Markdown body. Dibber adds a filing entry if the body has no `## Status` section.
81
101
  Repeat `--field KEY=VALUE` to supply declared fields, with YAML values for lists
82
102
  and maps. `dibber set ID --field KEY=VALUE` updates fields declared by the store's
83
- `item.schema.json`. You can also give `set` a status.
103
+ `item.schema.json`. You can also give `set` a status. For a worked example, see
104
+ [Keep where a ticket stands at the top](docs/current-state-field.md): a one-line field of your
105
+ own that tells an agent reading a ticket's first lines where the work stands.
84
106
 
85
107
  If another tool reserved the ID, pass `dibber new --id ID`. A trusted repository can
86
108
  configure its allocator in `.dibber/config.json`:
@@ -94,7 +116,10 @@ configure its allocator in `.dibber/config.json`:
94
116
  }
95
117
  ```
96
118
 
97
- `new` runs that command directly and takes the decimal number from its last line.
119
+ `new` runs that command directly and reads its last line: a whole id (`B-483`), taken as it
120
+ is, or a decimal number, which gets the store's prefix. The coordinator allocates ids, so a
121
+ coordinated store takes them whatever their prefix, and `dibber check` does not compare them
122
+ with `prefix`.
98
123
  Use `--offline` for local allocation when the coordinator is unavailable. With a coordinator,
99
124
  new tickets say `status: orchestrator`: their progress and closure are its record.
100
125
  `list` runs `coordinator.status`, if it is set, to show where they stand (`--offline` does
@@ -131,8 +156,11 @@ renders ticket stores as a wiki with a read-only board. See the [format's Reader
131
156
 
132
157
  ## Changing the format
133
158
 
134
- By pull request against `SPEC.md`. During active development, changes apply in place.
135
- Breaking changes ship with a migration. See [Versions](SPEC.md#versions).
159
+ By pull request against `SPEC.md`. The spec has its own version, `MAJOR.MINOR`, separate from
160
+ the `dibber` command's. A store can say which version it follows, with `spec` in
161
+ `.dibber/config.json`, and `dibber check` holds it to that version. A change that breaks
162
+ existing stores is a new major version and ships with a `dibber migrate` step. See
163
+ [Versions](SPEC.md#versions) and [the history](SPEC_HISTORY.md).
136
164
 
137
165
  ## Licence
138
166
 
package/SPEC.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Dibber — the git-native ticket format
2
2
 
3
- **Version:** Dibber 1 · **Status:** current
3
+ **Version:** 1.1 · **Status:** current · **History:** [SPEC_HISTORY.md](SPEC_HISTORY.md)
4
4
 
5
5
  **Dibber** is a way of keeping tickets in a git repository: one Markdown file per ticket, its
6
6
  frontmatter the ticket's fields, its body the record of the work, and a closed ticket kept where
@@ -15,7 +15,8 @@ ticket, where it stands in a workflow, how many times a step ran. A coordinator
15
15
  keeps them itself ([Coordination state](#coordination-state)).
16
16
 
17
17
  **How to read this page.** The rules are numbered `R-DIB-n` and cited by id; an id is never
18
- reused. The page states the current version only. Tools that read the format are listed under
18
+ reused. The page states the current version only ([Versions](#versions)); what changed between
19
+ versions is in [SPEC_HISTORY.md](SPEC_HISTORY.md). Tools that read the format are listed under
19
20
  [Readers](#readers); none of them owns it.
20
21
 
21
22
  ## Dibber alone, or with a coordinator
@@ -25,7 +26,8 @@ at a time, with the person as the only scheduler. Several runners, several peopl
25
26
  providers, budgets, retries) need a coordinator as well, such as
26
27
  [Baton](https://github.com/immediately-run/baton). The coordinator allocates ids, holds claims
27
28
  and runs the work, and the tickets stay Dibber: moving from one setup to the other changes no
28
- ticket file.
29
+ ticket file (a store leaving a coordinator may need `prefix` dropped:
30
+ [R-DIB-14](#1-the-store)).
29
31
 
30
32
  ## 1. The store
31
33
 
@@ -52,9 +54,14 @@ ticket file.
52
54
  satisfy as well.
53
55
  - **R-DIB-14 (the repository's settings).** A repository may keep Dibber's settings in
54
56
  `.dibber/config.json` at its root, satisfying [`config.schema.json`](config.schema.json):
55
- `store`, the store's folder relative to the root (default `tickets`), and `prefix`, the id
56
- prefix ([R-DIB-4](#2-ids)). A reader takes both from there when the file exists. Without it,
57
- the store is `tickets/` and the prefix is the one the store's ids share. A coordinator's own
57
+ `store`, the store's folder relative to the root (default `tickets`), `prefix`, the id
58
+ prefix ([R-DIB-4](#2-ids)), and `spec`, the version of this specification the store follows
59
+ ([R-DIB-15](#versions)). A reader takes both from there when the file exists. Without it,
60
+ the store is `tickets/` and the prefix is the one the store's ids share. When `config.json`
61
+ names a `prefix`, every ticket's id uses it, unless `config.json` also names a coordinator
62
+ ([R-DIB-4](#2-ids)): the coordinator then allocates ids, and the store takes them as it gives
63
+ them, whatever their prefix. Ids are never renamed, so a store holding ids under other prefixes
64
+ that leaves its coordinator drops `prefix` as well. A coordinator's own
58
65
  settings may name them too, but never disagree with `.dibber/config.json`. `.dibber/` holds
59
66
  Dibber's per-repository files, and a reader ignores any file there and any key in
60
67
  `config.json` that it does not know.
@@ -64,17 +71,21 @@ ticket file.
64
71
  - **R-DIB-4 (ids are never reused).** An id has a prefix of letters and digits starting
65
72
  with a letter, a dash, and either a decimal number or at least four lowercase base-36
66
73
  characters. An id is never reused or renamed, regardless of status. Readers also accept
67
- legacy split ids such as `R3-51a` and `R3-274e1`. Writers do not allocate split ids.
74
+ legacy split ids such as `R3-51a` and `R3-274e1`. Dibber's own allocation never makes split
75
+ ids; an id a coordinator gives is taken as it is.
68
76
  - **Allocation.** Set `ids` in `.dibber/config.json` to `random` for random suffixes.
69
77
  They are checked against the store and known branches and need no renumbering.
70
78
  The default, `numeric`, uses the next number above the highest taken across the store
71
79
  and known branches when writing without a coordinator. When a coordinator is in use,
72
- it allocates the number. If a numeric collision gets through, the second to merge
80
+ it allocates the id, or the number the prefix goes in front of. A writer refuses an id that
81
+ differs from a taken one only in case, since the two files collide on a case-insensitive
82
+ file system. If a numeric collision gets through, the second to merge
73
83
  renumbers and updates every reference and header that names the old id.
74
84
  - **Coordinator.** A trusted repository may configure `coordinator.next` in
75
85
  `.dibber/config.json` as an executable followed by its arguments. The writer runs it
76
- from the repository root, expands `<prefix>` in each argument, and takes the decimal
77
- number from the final line of stdout. An explicit offline mode uses local allocation.
86
+ from the repository root, expands `<prefix>` in each argument, and reads the final line
87
+ of stdout: a whole id, which the writer takes as it is, or a decimal number, which gets the
88
+ prefix. An explicit offline mode uses local allocation.
78
89
  It may also configure `coordinator.status`, an executable and its arguments that say where
79
90
  tickets stand. A reader runs it from the repository root with one argument per ticket id,
80
91
  in place of an argument `<ids>` or else at the end. It prints one JSON object:
@@ -115,6 +126,10 @@ ticket file.
115
126
 
116
127
  A store can define its own `priority` in `item.schema.json`. The shared queue rank is `order`.
117
128
 
129
+ `id` and `status` are each written on one line of the frontmatter, as plain values
130
+ (`status: done`), so a tool that reads lines, such as `grep`, can find them without a YAML
131
+ parser.
132
+
118
133
  **Other keys.** A key that only one tool gives a meaning to (a coordinator's workflow name, a
119
134
  wiki's layout) is that tool's, documented in its own specification. Dibber does not list them,
120
135
  and a reader that does not know one ignores it.
@@ -213,8 +228,21 @@ record.
213
228
 
214
229
  ## Versions
215
230
 
216
- During active development, this specification changes in place. A change that breaks
217
- existing stores ships with a `dibber migrate` step.
231
+ - **R-DIB-15 (versions).** This specification has a version of its own, `MAJOR.MINOR`, separate
232
+ from the version of any tool that reads it. The page states the current version, and
233
+ [SPEC_HISTORY.md](SPEC_HISTORY.md) lists every version with its date and the rules it added,
234
+ changed or retired. Each version's text is pinned by the git tag `spec-v<MAJOR.MINOR>`.
235
+ - **Major:** a store that was valid becomes invalid, or reads differently. A major version
236
+ ships with a `dibber migrate` step that moves a store to it.
237
+ - **Minor:** an addition that leaves every valid store valid and read the same way, such as an
238
+ optional key, a convention or a warning.
239
+ - **Neither:** a wording fix that changes no rule.
240
+
241
+ A store says which version it follows with `spec` in `.dibber/config.json`
242
+ ([R-DIB-14](#1-the-store)). A reader holds the store to that version. A store whose major
243
+ version is older than the reader's must be migrated, and a store that names a newer version
244
+ than the reader knows asks for a newer reader. A store without `spec` is read against the
245
+ reader's version.
218
246
 
219
247
  A coordinated store moves to `orchestrator` with `dibber migrate --to-orchestrator`, which
220
248
  changes the status line of every live ticket and leaves closed ones alone.
@@ -0,0 +1,28 @@
1
+ # Dibber specification history
2
+
3
+ Every version of [the Dibber specification](SPEC.md), newest first. Each version's text is
4
+ pinned by its git tag, `spec-v<version>`. How versions are numbered is
5
+ [R-DIB-15](SPEC.md#versions).
6
+
7
+ ## 1.1 — 2026-12-05
8
+
9
+ A store with a coordinator takes ids as the coordinator gives them
10
+ ([DIB-41](tickets/DIB-41.md)). Every store valid at 1.0 stays valid and reads the same.
11
+
12
+ - **Rules:** R-DIB-4 (the id shape, Allocation and Coordinator bullets) and R-DIB-14 amended.
13
+ - **Added at 1.1:** in a store whose `.dibber/config.json` names a coordinator, ids need not
14
+ use `prefix`; `coordinator.next` may print a whole id on its final line, taken as it is; a
15
+ writer refuses an id that differs from a taken one only in case. A coordinated store that
16
+ names `"spec": "1.0"` is still held to its prefix.
17
+ - **Tag:** `spec-v1.1`.
18
+
19
+ ## 1.0 — 2026-12-03
20
+
21
+ The first numbered version: the specification as it stood when versions began. Before it, the
22
+ text changed in place, and the tickets that changed it are its record: DIB-1 to DIB-36 in
23
+ [`tickets/`](tickets/).
24
+
25
+ - **Rules:** R-DIB-1 to R-DIB-15.
26
+ - **Added at 1.0:** R-DIB-15 (versions), the `spec` key in `.dibber/config.json` (R-DIB-14),
27
+ and the rule that `id` and `status` are each written on one line (R-DIB-5).
28
+ - **Tag:** `spec-v1.0`.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
- "$id": "https://github.com/immediately-run/dibber/config.schema.json",
4
- "title": "Dibber 1 — repository settings (.dibber/config.json)",
3
+ "$id": "https://raw.githubusercontent.com/immediately-run/dibber/spec-v1.1/config.schema.json",
4
+ "title": "Dibber 1.1 — repository settings (.dibber/config.json)",
5
5
  "description": "A repository's Dibber settings (SPEC.md R-DIB-14). Keys this schema does not name are allowed: they belong to a tool.",
6
6
  "type": "object",
7
7
  "properties": {
@@ -17,6 +17,11 @@
17
17
  "pattern": "^[A-Za-z][A-Za-z0-9]*$",
18
18
  "description": "The id prefix (R-DIB-4): letters and digits, starting with a letter, without the dash."
19
19
  },
20
+ "spec": {
21
+ "type": "string",
22
+ "pattern": "^[0-9]+\\.[0-9]+$",
23
+ "description": "The version of the Dibber specification the store follows, MAJOR.MINOR (R-DIB-15). Without it, a reader reads the store against its own version."
24
+ },
20
25
  "ids": {
21
26
  "enum": ["numeric", "random"],
22
27
  "default": "numeric",
@@ -30,7 +35,7 @@
30
35
  "type": "array",
31
36
  "minItems": 1,
32
37
  "items": { "type": "string" },
33
- "description": "Executable and arguments that print the next ticket number."
38
+ "description": "Executable and arguments that print the next ticket id, or a bare number that takes the prefix, on their last line."
34
39
  },
35
40
  "status": {
36
41
  "type": "array",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@immediately-run/dibber",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Git as your issue tracker, in an open format built on Markdown: the Dibber format's validator and command-line tool, plus agent skills.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -23,6 +23,7 @@
23
23
  "ticket.schema.json",
24
24
  "config.schema.json",
25
25
  "SPEC.md",
26
+ "SPEC_HISTORY.md",
26
27
  "NOTICE"
27
28
  ],
28
29
  "engines": {
@@ -13,7 +13,8 @@ https://github.com/immediately-run/dibber/blob/main/SPEC.md
13
13
  ## Steps
14
14
 
15
15
  1. **Understand the request.** Ask only for what you cannot work out from the conversation and
16
- the code. One question at most, and none if the intent is clear.
16
+ the code. One question at most, and none if the intent is clear. If it may already be filed,
17
+ look among the live tickets (`dibber list --json`), not the whole store.
17
18
  2. **Write it to be done by someone else**, possibly another agent session with no memory of
18
19
  this one:
19
20
  - **Title:** what to do, short and imperative: "Add a dark mode toggle".
@@ -39,7 +40,7 @@ https://github.com/immediately-run/dibber/blob/main/SPEC.md
39
40
  Use `dibber` if it is installed, otherwise `npx -y @immediately-run/dibber`. It picks the
40
41
  next free id, writes the file and checks it. If an allocator reserved the id, pass
41
42
  `--id`. In a trusted repository with `coordinator.next` configured, the command
42
- asks the coordinator for a number. Use `--offline` to explicitly allocate locally.
43
+ asks the coordinator for an id. Use `--offline` to explicitly allocate locally.
43
44
  Use `--body-file PATH` for a complete Markdown body and repeat `--field KEY=VALUE`
44
45
  for fields declared in the store schema.
45
46
  4. **Tell the user** the id and title in one line, and stop. Filing a ticket is not starting the
@@ -48,7 +49,16 @@ https://github.com/immediately-run/dibber/blob/main/SPEC.md
48
49
  ## Without the command-line tool
49
50
 
50
51
  Write `tickets/<ID>.md` yourself. The id is the store's prefix and one more than the highest
51
- number in `tickets/`, at any depth, closed tickets included. In a store whose
52
+ number in `tickets/`, at any depth, closed tickets included. Read it from the file names
53
+ (`find tickets -name 'APP-*.md*'`), never by opening the files. To check that the work isn't
54
+ filed already, read the live tickets' titles only:
55
+
56
+ ```sh
57
+ grep -rm1 --include='*.md' --include='*.mdx' '^status:' tickets/ \
58
+ | grep -E ':status: *"?(available|in-progress|in-review|deprioritized|orchestrator)"? *$' \
59
+ | cut -d: -f1 \
60
+ | xargs grep -hm1 '^title:'
61
+ ``` In a store whose
52
62
  `.dibber/config.json` names a coordinator, take the number from it and write
53
63
  `status: orchestrator`. Use this shape, then run `dibber check` if you can:
54
64
 
@@ -6,8 +6,10 @@ description: Summarize the Dibber board, meaning the tickets in the repository's
6
6
  # Summarize the Dibber board
7
7
 
8
8
  Run `dibber list --json` (use `dibber` if it is installed, otherwise
9
- `npx -y @immediately-run/dibber`). Add `--all` to include closed tickets, for
10
- "what did we finish?".
9
+ `npx -y @immediately-run/dibber`). It lists live tickets only, which is all a summary needs:
10
+ closed tickets stay in the store, often most of it, and reading them only fills your context.
11
+ Add `--all` only when the user asks about finished work ("what did we finish?"). Don't open
12
+ ticket files to summarize.
11
13
 
12
14
  ## Report
13
15
 
@@ -35,9 +37,23 @@ ticket to the user as suspicious.
35
37
 
36
38
  ## Without the command-line tool
37
39
 
38
- Read the frontmatter of every `*.md` and `*.mdx` file under `tickets/`. A file is a ticket if it
39
- has an `id` and `status` and omits `page`. Whether it is open or closed is its `status`, one
40
- of available, in-progress, in-review, deprioritized (live) or done, withdrawn,
41
- superseded, deferred (closed), or orchestrator (live, where it stands is the coordinator's
42
- record; never ready from the files). Any other ticket is ready when it is `available` and every id in its
43
- `depends_on` is done or superseded.
40
+ Start from the live tickets, so closed ones never reach your context. One `grep` on each file's
41
+ first `status:` line, the frontmatter's, lists them, and `awk` prints their frontmatter alone:
42
+
43
+ ```sh
44
+ grep -rm1 --include='*.md' --include='*.mdx' '^status:' tickets/ \
45
+ | grep -E ':status: *"?(available|in-progress|in-review|deprioritized|orchestrator)"? *$' \
46
+ | cut -d: -f1 \
47
+ | xargs awk 'FNR == 1 { fm = 0 } /^---[ \t]*$/ { fm++; next } fm == 1 { print FILENAME ": " $0 }'
48
+ ```
49
+
50
+ Use the store's folder from `.dibber/config.json` in place of `tickets/` if it names one. Skip a
51
+ file whose frontmatter has `page:`: it is a page, not a ticket. Open a ticket's file only when
52
+ the summary needs its body.
53
+
54
+ The live statuses are available, in-progress, in-review, deprioritized, and orchestrator (live,
55
+ where it stands is the coordinator's record; never ready from the files). The closed ones are
56
+ done, withdrawn, superseded and deferred. A ticket is ready when it is `available` and every id
57
+ in its `depends_on` is done or superseded. Read a dependency's state from its `status:` line
58
+ alone (`grep -m1 '^status:' tickets/APP-3.md`), never by opening it. For finished work, run the
59
+ same `grep` with the closed statuses, and report titles only.
@@ -13,8 +13,12 @@ Every command takes `--json`.
13
13
 
14
14
  1. **Choose.** If the user named a ticket, use it. Otherwise run `dibber list --ready --json`
15
15
  and take the first one: lowest `order`, then lowest id. If nothing is ready, say what is
16
- waiting and on what (`dibber list`), and stop.
17
- 2. **Read the whole ticket file**, then the code it touches. If the ticket is unclear or seems
16
+ waiting and on what (`dibber list`), and stop. Without the command-line tool, choose from
17
+ the live tickets only (see the end of this skill). Never read the store's files one by one:
18
+ most of them are usually closed.
19
+ 2. **Read the whole ticket file**, then the code it touches. Read only this ticket: for each
20
+ ticket in its `depends_on`, its `status:` line is enough
21
+ (`grep -m1 '^status:' tickets/APP-3.md`). If the ticket is unclear or seems
18
22
  wrong, ask the user before building. Don't guess.
19
23
  3. **Claim it:** a ticket that says `status: orchestrator` is claimed, finished and closed
20
24
  through the repository's coordinator (such as Baton), never with `dibber claim` or `done`:
@@ -78,6 +82,20 @@ Every command takes `--json`.
78
82
 
79
83
  ## Without the command-line tool
80
84
 
85
+ To choose, list the live tickets from each file's first `status:` line, so closed tickets never
86
+ reach your context:
87
+
88
+ ```sh
89
+ grep -rm1 --include='*.md' --include='*.mdx' '^status:' tickets/ \
90
+ | grep -E ':status: *"?(available|in-progress|in-review|deprioritized|orchestrator)"? *$' \
91
+ | cut -d: -f1 \
92
+ | xargs awk 'FNR == 1 { fm = 0 } /^---[ \t]*$/ { fm++; next } fm == 1 { print FILENAME ": " $0 }'
93
+ ```
94
+
95
+ Use the store's folder from `.dibber/config.json` in place of `tickets/` if it names one. A
96
+ ticket is ready when it is `available` and each id in its `depends_on` has `status: done` or
97
+ `superseded` (`grep -m1 '^status:'` on that ticket's file).
98
+
81
99
  Edit the frontmatter yourself: `status: in-progress` and `assignee: <name>` to claim, and
82
100
  `status: done` to close. Never move or rename the file. Always add a dated line under
83
101
  `## Status`.
package/src/check.mjs CHANGED
@@ -1,4 +1,4 @@
1
- // check.mjs — judge a store against Dibber 1: every rule that can be checked from the files.
1
+ // check.mjs — judge a store against the Dibber spec (SPEC_VERSION): every rule that can be checked from the files.
2
2
  // Tickets: [DIB-6](../tickets/DIB-6.md), [DIB-5](../tickets/DIB-5.md), [DIB-24](../tickets/DIB-24.md).
3
3
  // Each problem names the rule it breaks (R-DIB-n), the file, and what to do, in plain words.
4
4
  //
@@ -10,7 +10,7 @@ import { join, dirname } from 'node:path';
10
10
  import { fileURLToPath } from 'node:url';
11
11
  import Ajv from 'ajv';
12
12
  import { SKILL_HOMES, skillInstallProblem } from './init.mjs';
13
- import { readStore, rel, CLOSED, STATUSES, COORDINATED, hasCoordinator, ID_RE, QUALIFIED_RE, asList } from './store.mjs';
13
+ import { SPEC_VERSION, readStore, rel, CLOSED, STATUSES, COORDINATED, hasCoordinator, takesAnyPrefix, ID_RE, QUALIFIED_RE, asList } from './store.mjs';
14
14
 
15
15
  const HERE = dirname(fileURLToPath(import.meta.url));
16
16
  export const legacyPageKind = (meta) =>
@@ -20,6 +20,9 @@ export const legacyPageKind = (meta) =>
20
20
  export const TICKET_SCHEMA = JSON.parse(readFileSync(join(HERE, '..', 'ticket.schema.json'), 'utf8'));
21
21
  const CONFIG_SCHEMA = JSON.parse(readFileSync(join(HERE, '..', 'config.schema.json'), 'utf8'));
22
22
 
23
+ export { SPEC_VERSION };
24
+ const parseVersion = (v) => v.split('.').map(Number);
25
+
23
26
  const ajv = new Ajv({ allErrors: true, strict: false });
24
27
  const validateTicket = ajv.compile(TICKET_SCHEMA);
25
28
  const validateConfig = ajv.compile(CONFIG_SCHEMA);
@@ -51,6 +54,15 @@ export function checkStore(root) {
51
54
  if (settings.error) err('R-DIB-14', file, settings.error);
52
55
  else if (!validateConfig(settings.raw)) {
53
56
  for (const e of validateConfig.errors) err('R-DIB-14', file, describeSchemaError(e));
57
+ } else if (settings.raw.spec !== undefined) {
58
+ // R-DIB-15: the store is held to the version it names.
59
+ const [major, minor] = parseVersion(settings.raw.spec);
60
+ const [ownMajor, ownMinor] = parseVersion(SPEC_VERSION);
61
+ if (major < ownMajor) {
62
+ err('R-DIB-15', file, `the store follows Dibber spec ${settings.raw.spec}, a major version behind ${SPEC_VERSION}: run \`dibber migrate\` to move it`);
63
+ } else if (major > ownMajor || (major === ownMajor && minor > ownMinor)) {
64
+ warn('R-DIB-15', file, `the store follows Dibber spec ${settings.raw.spec}, newer than the ${SPEC_VERSION} this dibber knows: update dibber`);
65
+ }
54
66
  }
55
67
  }
56
68
  if (!store.exists) {
@@ -80,7 +92,9 @@ export function checkStore(root) {
80
92
  for (const b of store.broken) err('R-DIB-5', b.file, `the frontmatter is not valid YAML (${b.error})`);
81
93
 
82
94
  // Per ticket.
83
- const prefixOK = settings.prefix && !settings.error && validateConfig(settings.raw ?? {});
95
+ // A coordinator allocates ids, so its store takes them as it gives them, whatever their prefix
96
+ // ([DIB-41](../tickets/DIB-41.md)).
97
+ const prefixOK = settings.prefix && !settings.error && validateConfig(settings.raw ?? {}) && !takesAnyPrefix(settings);
84
98
  for (const t of store.tickets) {
85
99
  const { meta, file } = t;
86
100
  const id = meta.id;
package/src/init.mjs CHANGED
@@ -7,7 +7,7 @@ import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, rmSync, wr
7
7
  import { basename, dirname, join, relative } from 'node:path';
8
8
  import { fileURLToPath } from 'node:url';
9
9
  import { Refusal, nextId, today } from './tickets.mjs';
10
- import { readStore } from './store.mjs';
10
+ import { readStore, SPEC_VERSION } from './store.mjs';
11
11
 
12
12
  const HERE = dirname(fileURLToPath(import.meta.url));
13
13
  export const PACKAGE_ROOT = join(HERE, '..');
@@ -141,7 +141,7 @@ export function init(root, opts = {}) {
141
141
  if (opts.ids !== undefined && !['numeric', 'random'].includes(opts.ids)) throw new Refusal('--ids must be numeric or random');
142
142
 
143
143
  const configPath = join(root, '.dibber', 'config.json');
144
- const defaults = { store: storeRel, prefix, ...(opts.ids && { ids: opts.ids }) };
144
+ const defaults = { store: storeRel, prefix, spec: SPEC_VERSION, ...(opts.ids && { ids: opts.ids }) };
145
145
  let config = defaults;
146
146
  if (existsSync(configPath)) {
147
147
  try { config = { ...config, ...JSON.parse(readFileSync(configPath, 'utf8')) }; } catch {}
package/src/migrate.mjs CHANGED
@@ -1,7 +1,8 @@
1
1
  // Upgrade a store in place while preserving ticket paths and bodies ([DIB-27](../tickets/DIB-27.md)).
2
- import { writeFileSync } from 'node:fs';
2
+ import { readFileSync, writeFileSync } from 'node:fs';
3
+ import { relative } from 'node:path';
3
4
  import { checkStore, legacyPageKind, TICKET_SCHEMA } from './check.mjs';
4
- import { splitFrontmatter, readStore, LIVE, COORDINATED, hasCoordinator } from './store.mjs';
5
+ import { splitFrontmatter, readStore, LIVE, COORDINATED, hasCoordinator, SPEC_VERSION } from './store.mjs';
5
6
  import { Refusal } from './tickets.mjs';
6
7
 
7
8
  // Only the status line changes, so a large store's migration reads as one line a ticket.
@@ -20,6 +21,12 @@ function toOrchestrator(store) {
20
21
  });
21
22
  }
22
23
 
24
+ const olderThan = (a, b) => {
25
+ const [am, an] = a.split('.').map(Number);
26
+ const [bm, bn] = b.split('.').map(Number);
27
+ return am < bm || (am === bm && an < bn);
28
+ };
29
+
23
30
  export function migrateStore(root, opts = {}) {
24
31
  const store = readStore(root);
25
32
  if (!store.exists) throw new Refusal(`there is no store at ${store.storeRel}/`);
@@ -42,6 +49,15 @@ export function migrateStore(root, opts = {}) {
42
49
  updates.push({ entry, text: `---\n${doc.toString({ lineWidth: 0 })}---\n${body}` });
43
50
  }
44
51
 
52
+ // R-DIB-15: a migrated store follows this reader's version ([DIB-38](../tickets/DIB-38.md)).
53
+ const { settings } = store;
54
+ if (!opts.toOrchestrator && settings.path && !settings.error && typeof settings.raw?.spec === 'string' &&
55
+ /^[0-9]+\.[0-9]+$/.test(settings.raw.spec) && olderThan(settings.raw.spec, SPEC_VERSION)) {
56
+ const text = readFileSync(settings.path, 'utf8');
57
+ const entry = { path: settings.path, text, file: relative(root, settings.path) };
58
+ updates.push({ entry, text: JSON.stringify({ ...settings.raw, spec: SPEC_VERSION }, null, 2) + '\n' });
59
+ }
60
+
45
61
  if (!updates.length) return [];
46
62
  const written = [];
47
63
  try {
package/src/store.mjs CHANGED
@@ -7,6 +7,10 @@ import { join, relative, sep, extname, basename } from 'node:path';
7
7
  import { parseDocument } from 'yaml';
8
8
 
9
9
  /** The statuses of R-DIB-6, by class. */
10
+ // The specification version this reader implements (R-DIB-15, [DIB-38](../tickets/DIB-38.md)).
11
+ // Bump it with SPEC.md's header, both schemas' $id and SPEC_HISTORY.md: a test keeps them in step.
12
+ export const SPEC_VERSION = '1.1';
13
+
10
14
  export const LIVE = ['available', 'in-progress', 'in-review', 'deprioritized'];
11
15
  /** Live, with its progress in the coordinator's record (R-DIB-6, [DIB-35](../tickets/DIB-35.md)). */
12
16
  export const COORDINATED = 'orchestrator';
@@ -56,6 +60,15 @@ export function readSettings(root) {
56
60
  }
57
61
 
58
62
  /** The settings name a coordinator (R-DIB-14). */
63
+ // A coordinated store takes its coordinator's ids whatever their prefix, from spec 1.1 on: a store
64
+ // that names an older version is held to it (R-DIB-15, [DIB-41](../tickets/DIB-41.md)).
65
+ export const takesAnyPrefix = (settings) => {
66
+ if (!hasCoordinator(settings)) return false;
67
+ const spec = settings.raw?.spec;
68
+ if (typeof spec !== 'string' || !/^\d+\.\d+$/.test(spec)) return true;
69
+ const [major, minor] = spec.split('.').map(Number);
70
+ return major > 1 || (major === 1 && minor >= 1);
71
+ };
59
72
  export const hasCoordinator = (settings) => typeof settings.raw?.coordinator === 'object' && settings.raw.coordinator !== null && !Array.isArray(settings.raw.coordinator);
60
73
 
61
74
  function walk(dir, out = []) {
package/src/tickets.mjs CHANGED
@@ -6,10 +6,10 @@
6
6
 
7
7
  import { randomInt } from 'node:crypto';
8
8
  import { execFileSync } from 'node:child_process';
9
- import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
9
+ import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs';
10
10
  import { basename, dirname, join } from 'node:path';
11
11
  import { Document, parseDocument, visit } from 'yaml';
12
- import { readStore, splitFrontmatter, rel, LIVE, CLOSED, CLOSED_WITHDRAWN, COORDINATED, STATUSES, hasCoordinator, ID_RE, QUALIFIED_RE, idNumber, asList, byOrderThenId } from './store.mjs';
12
+ import { readStore, splitFrontmatter, rel, LIVE, CLOSED, CLOSED_WITHDRAWN, COORDINATED, STATUSES, hasCoordinator, takesAnyPrefix, ID_RE, QUALIFIED_RE, idNumber, asList, byOrderThenId } from './store.mjs';
13
13
  import { checkStore, TICKET_SCHEMA } from './check.mjs';
14
14
  import { coordinatorStates } from './coordinator.mjs';
15
15
 
@@ -54,13 +54,19 @@ export function storePrefix(store) {
54
54
  return best[0];
55
55
  }
56
56
 
57
- // Accept a coordinator's reservation only if it is a free id in this store ([DIB-33](../tickets/DIB-33.md)).
57
+ // Accept a reservation only if it is a free id in this store ([DIB-33](../tickets/DIB-33.md)).
58
+ // A coordinated store takes any well-formed id; others need the store's prefix ([DIB-41](../tickets/DIB-41.md)).
59
+ // An id that differs from a taken one only in case is taken too: the two files would collide on a
60
+ // case-insensitive file system.
58
61
  function reservedId(root, store, id) {
59
- if (!ID_RE.test(id) || id.split('-')[0] !== storePrefix(store)) {
62
+ if (!ID_RE.test(id)) throw new Refusal(`invalid reserved id \`${id}\``);
63
+ if (!takesAnyPrefix(store.settings) && id.split('-')[0] !== storePrefix(store)) {
60
64
  throw new Refusal(`invalid reserved id \`${id}\` for prefix \`${storePrefix(store)}\``);
61
65
  }
62
- if (store.tickets.some((t) => t.meta.id === id) || idsOnBranches(root, store.storeRel).includes(id)
63
- || ['.md', '.mdx'].some((ext) => existsSync(join(store.storeDir, id + ext)))) {
66
+ const folded = id.toLowerCase();
67
+ const taken = [...store.tickets.map((t) => String(t.meta.id)), ...idsOnBranches(root, store.storeRel),
68
+ ...(existsSync(store.storeDir) ? readdirSync(store.storeDir).map((name) => name.replace(/\.mdx?$/, '')) : [])];
69
+ if (taken.some((other) => other.toLowerCase() === folded)) {
64
70
  throw new Refusal(`ticket id \`${id}\` is already taken`);
65
71
  }
66
72
  return id;
@@ -71,19 +77,22 @@ function coordinatorId(root, store, coordinator) {
71
77
  if (!Array.isArray(argv) || !argv[0] || !argv.every((arg) => typeof arg === 'string')) {
72
78
  throw new Refusal('coordinator.next must be an executable and its arguments');
73
79
  }
74
- const prefix = storePrefix(store);
75
- const [command, ...args] = argv.map((arg) => arg.replaceAll('<prefix>', prefix));
80
+ // The prefix only when it is needed: a coordinator that prints whole ids needs none (DIB-41).
81
+ const prefixOf = () => storePrefix(store);
82
+ const [command, ...args] = argv.map((arg) => (arg.includes('<prefix>') ? arg.replaceAll('<prefix>', prefixOf()) : arg));
76
83
  let output;
77
84
  try {
78
85
  output = execFileSync(command, args, {
79
86
  cwd: root, encoding: 'utf8', timeout: 30_000, stdio: ['ignore', 'pipe', 'pipe'],
80
87
  });
81
88
  } catch {
82
- throw new Refusal('the coordinator failed to allocate a ticket number; pass --offline to use local allocation');
89
+ throw new Refusal('the coordinator failed to allocate a ticket id; pass --offline to use local allocation');
83
90
  }
84
- const number = output.trimEnd().split(/\r?\n/).at(-1).trim();
85
- if (!/^[0-9]+$/.test(number)) throw new Refusal('the coordinator must print a decimal ticket number on its last line');
86
- return reservedId(root, store, `${prefix}-${number}`);
91
+ // The last line is a whole id, taken as it is, or a bare number, which gets the prefix (DIB-41).
92
+ const last = output.trimEnd().split(/\r?\n/).at(-1).trim();
93
+ if (/^[0-9]+$/.test(last)) return reservedId(root, store, `${prefixOf()}-${last}`);
94
+ if (ID_RE.test(last)) return reservedId(root, store, last);
95
+ throw new Refusal('the coordinator must print a ticket id or a decimal ticket number on its last line');
87
96
  }
88
97
 
89
98
  /** Allocate a free numeric or random id across the store and known branches ([DIB-26](../tickets/DIB-26.md)). */
@@ -150,8 +159,12 @@ function extensionFields(store, entries, readerOnly = false) {
150
159
  return { fields, keys: Object.keys(schema?.properties ?? {}) };
151
160
  }
152
161
 
162
+ // A store schema that lists `id` orders the whole frontmatter (DIB-33). One that declares only
163
+ // its own keys puts them after Dibber's, so `id`, `title` and `status` lead ([DIB-40](../tickets/DIB-40.md)).
153
164
  function orderFields(meta, keys) {
154
- return Object.fromEntries([...new Set([...keys, ...Object.keys(meta)])]
165
+ const dibber = Object.keys(meta).filter((key) => Object.hasOwn(TICKET_SCHEMA.properties, key));
166
+ const order = keys.includes('id') ? keys : [...dibber, ...keys];
167
+ return Object.fromEntries([...new Set([...order, ...Object.keys(meta)])]
155
168
  .filter((key) => Object.hasOwn(meta, key)).map((key) => [key, meta[key]]));
156
169
  }
157
170
 
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
- "$id": "https://github.com/immediately-run/dibber/ticket.schema.json",
4
- "title": "Dibber 1 — ticket frontmatter",
3
+ "$id": "https://raw.githubusercontent.com/immediately-run/dibber/spec-v1.1/ticket.schema.json",
4
+ "title": "Dibber 1.1 — ticket frontmatter",
5
5
  "description": "The frontmatter every Dibber ticket satisfies (SPEC.md R-DIB-3, R-DIB-5). Keys this schema does not name are allowed: they belong to a repository or a tool. A store may add a stricter item.schema.json of its own.",
6
6
  "type": "object",
7
7
  "definitions": {