@immediately-run/dibber 0.4.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 +74 -11
- package/SPEC.md +90 -43
- package/SPEC_HISTORY.md +28 -0
- package/config.schema.json +14 -3
- package/package.json +11 -2
- package/skills/dibber-new-ticket/SKILL.md +15 -3
- package/skills/dibber-overview/SKILL.md +26 -7
- package/skills/dibber-work-ticket/SKILL.md +24 -3
- package/src/check.mjs +34 -5
- package/src/cli.mjs +19 -6
- package/src/coordinator.mjs +42 -0
- package/src/init.mjs +2 -2
- package/src/migrate.mjs +77 -0
- package/src/store.mjs +21 -3
- package/src/tickets.mjs +66 -22
- package/ticket.schema.json +6 -6
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,38 @@ 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
|
|
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.
|
|
43
|
+
|
|
44
|
+
## This repository is an example
|
|
45
|
+
|
|
46
|
+
Dibber tracks its own work here. Compare an [open ticket](tickets/DIB-15.md)
|
|
47
|
+
with a [closed ticket](tickets/DIB-10.md). The closed ticket keeps its path
|
|
48
|
+
and links to the pull request that shipped it. The [project page](tickets/projects/wide-audience.md)
|
|
49
|
+
groups the work, and [repository settings](.dibber/config.json) name the
|
|
50
|
+
store and its ID prefix.
|
|
23
51
|
|
|
24
52
|
## A ticket
|
|
25
53
|
|
|
@@ -57,13 +85,13 @@ keeps working.
|
|
|
57
85
|
|
|
58
86
|
- [`SPEC.md`](SPEC.md) — the format, rule by rule (`R-DIB-n`).
|
|
59
87
|
- [`config.schema.json`](config.schema.json) — the schema of a repository's optional
|
|
60
|
-
`.dibber/config.json` (the store's folder and
|
|
88
|
+
`.dibber/config.json` (the store's folder, id prefix and spec version).
|
|
61
89
|
- [`ticket.schema.json`](ticket.schema.json) — the JSON Schema every ticket's frontmatter
|
|
62
90
|
satisfies. A repository can add a stricter schema of its own.
|
|
63
91
|
- [`skills/`](skills/), [`bin/`](bin/), [`src/`](src/) — optional tooling: the `dibber`
|
|
64
92
|
command (`check`, `list`, `new`, `claim`, `done`, `init`) and the agent skills `dibber init`
|
|
65
93
|
installs for Claude Code, Codex, opencode and Antigravity. The format needs none of it.
|
|
66
|
-
- [`tickets/`](tickets/) — Dibber's own work, kept as a Dibber store: an example of what a
|
|
94
|
+
- [`tickets/`](https://immediately.run/present/github/immediately-run/dibber/main/bundle/tickets/) — Dibber's own work, kept as a Dibber store: an example of what a
|
|
67
95
|
Dibber-tracked project looks like.
|
|
68
96
|
|
|
69
97
|
## CLI
|
|
@@ -72,7 +100,9 @@ Use `dibber new --title "…"` to file a ticket. Point `--body-file PATH` at a c
|
|
|
72
100
|
Markdown body. Dibber adds a filing entry if the body has no `## Status` section.
|
|
73
101
|
Repeat `--field KEY=VALUE` to supply declared fields, with YAML values for lists
|
|
74
102
|
and maps. `dibber set ID --field KEY=VALUE` updates fields declared by the store's
|
|
75
|
-
`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.
|
|
76
106
|
|
|
77
107
|
If another tool reserved the ID, pass `dibber new --id ID`. A trusted repository can
|
|
78
108
|
configure its allocator in `.dibber/config.json`:
|
|
@@ -80,24 +110,57 @@ configure its allocator in `.dibber/config.json`:
|
|
|
80
110
|
```json
|
|
81
111
|
{
|
|
82
112
|
"coordinator": {
|
|
83
|
-
"next": ["npx", "@immediately-run/baton", "tickets", "next", "ticket-<prefix>"]
|
|
113
|
+
"next": ["npx", "@immediately-run/baton", "tickets", "next", "ticket-<prefix>"],
|
|
114
|
+
"status": ["npx", "@immediately-run/baton", "tickets", "status", "<ids>", "--coordinator"]
|
|
84
115
|
}
|
|
85
116
|
}
|
|
86
117
|
```
|
|
87
118
|
|
|
88
|
-
`new` runs that command directly and
|
|
89
|
-
|
|
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`.
|
|
123
|
+
Use `--offline` for local allocation when the coordinator is unavailable. With a coordinator,
|
|
124
|
+
new tickets say `status: orchestrator`: their progress and closure are its record.
|
|
125
|
+
`list` runs `coordinator.status`, if it is set, to show where they stand (`--offline` does
|
|
126
|
+
not), and `claim`, `done` and the live statuses are refused. Both commands run code the
|
|
127
|
+
repository names, so use them in repositories you trust. Commit
|
|
90
128
|
ticket changes through your usual Git workflow.
|
|
91
129
|
|
|
130
|
+
## Install the skills in your agent
|
|
131
|
+
|
|
132
|
+
For Claude Code, run `/plugin marketplace add immediately-run/dibber` and then
|
|
133
|
+
`/plugin install dibber@dibber`. Recent versions also support
|
|
134
|
+
`/plugin install dibber --marketplace immediately-run/dibber`.
|
|
135
|
+
|
|
136
|
+
For Codex, add the repository as a plugin marketplace and install Dibber:
|
|
137
|
+
|
|
138
|
+
```sh
|
|
139
|
+
codex plugin marketplace add immediately-run/dibber
|
|
140
|
+
codex plugin add dibber@dibber
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
For opencode or Antigravity, use the cross-harness installer:
|
|
144
|
+
|
|
145
|
+
```sh
|
|
146
|
+
npx skills add immediately-run/dibber --global --agent opencode antigravity
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Run `dibber init` inside a repository to set up its ticket store.
|
|
150
|
+
|
|
92
151
|
## Readers
|
|
93
152
|
|
|
94
|
-
Baton
|
|
95
|
-
reads
|
|
153
|
+
[Baton's Markdown source](https://github.com/immediately-run/baton/blob/main/spec/BATON_SPEC/04-tickets-syncs-board.md#sec-4-2)
|
|
154
|
+
reads tickets to coordinate work. [Dibber Board](https://github.com/immediately-run/dibber-board/blob/main/src/components/roadmapLib.ts)
|
|
155
|
+
renders ticket stores as a wiki with a read-only board. See the [format's Readers section](SPEC.md#readers).
|
|
96
156
|
|
|
97
157
|
## Changing the format
|
|
98
158
|
|
|
99
|
-
By pull request against `SPEC.md`.
|
|
100
|
-
|
|
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).
|
|
101
164
|
|
|
102
165
|
## Licence
|
|
103
166
|
|
package/SPEC.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Dibber — the git-native ticket format
|
|
2
2
|
|
|
3
|
-
**Version:**
|
|
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
|
|
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,17 +26,18 @@ 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
|
|
|
32
34
|
- **R-DIB-1 (a folder of files, one per ticket).** A Dibber store is one folder in a git
|
|
33
35
|
repository: `tickets/` by convention, or the folder the repository's settings name
|
|
34
36
|
([R-DIB-14](#1-the-store)).
|
|
35
|
-
Every `*.md` or `*.mdx` file under it, at any depth, whose frontmatter carries
|
|
36
|
-
`
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
Every `*.md` or `*.mdx` file under it, at any depth, whose frontmatter carries `id` and
|
|
38
|
+
`status` and omits `page` is a ticket. A page may give its role with `page` (`project`,
|
|
39
|
+
`goal`, `doc`, `view`, and so on). An entry with an `id` must have either a ticket's
|
|
40
|
+
`status` or a page marker. A
|
|
39
41
|
ticket is one file, named after its id: `<id>.md`, or `<id>.mdx` (read alike) in a store
|
|
40
42
|
rendered as MDX ([R-DIB-13](#7-a-store-that-is-also-a-wiki)). Plain `.md` is the default,
|
|
41
43
|
since a stray `<` or `{` in prose does not compile as MDX.
|
|
@@ -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`),
|
|
56
|
-
prefix ([R-DIB-4](#2-ids))
|
|
57
|
-
|
|
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,31 @@ 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`.
|
|
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
|
|
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
|
|
77
|
-
|
|
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.
|
|
89
|
+
It may also configure `coordinator.status`, an executable and its arguments that say where
|
|
90
|
+
tickets stand. A reader runs it from the repository root with one argument per ticket id,
|
|
91
|
+
in place of an argument `<ids>` or else at the end. It prints one JSON object:
|
|
92
|
+
`{"tickets": {"<id>": {"state": "<word>", "closed": <boolean>, "reason": "<one line>"}}}`.
|
|
93
|
+
`state` is the coordinator's own word, and `ready` is the one a reader gives a meaning to:
|
|
94
|
+
the coordinator would hand the ticket out now. `closed` says the coordinator finished it.
|
|
95
|
+
A ticket the answer leaves out has no known state. The answer is data: a reader shows it
|
|
96
|
+
and takes nothing else from it. Both commands run code the repository names, so a reader
|
|
97
|
+
runs them only in a repository its user trusts, and always offers a way not to
|
|
98
|
+
(`dibber list --offline`).
|
|
78
99
|
- **Across repositories.** `<repository>:<id>` (`baton:B-111`) names a ticket in another
|
|
79
100
|
repository's store; an unqualified id is always the store's own. What a repository name
|
|
80
101
|
resolves to is the reader's configuration.
|
|
@@ -89,11 +110,12 @@ ticket file.
|
|
|
89
110
|
|---|---|---|
|
|
90
111
|
| `id` | an id ([R-DIB-4](#2-ids)) | the ticket; the file is named after it |
|
|
91
112
|
| `title` | text | its title, conventionally `<id> — <what>` |
|
|
92
|
-
| `status` | a status ([R-DIB-6](#3-frontmatter)) | live, done or withdrawn |
|
|
113
|
+
| `status` | a status ([R-DIB-6](#3-frontmatter)) | live, coordinated, done or withdrawn |
|
|
93
114
|
| `description` | text | one paragraph, what and why, for a list or a search |
|
|
94
115
|
| `depends_on` | a list of ids, local or qualified | tickets this one waits for: it is ready only once each is done or superseded ([R-DIB-8](#4-relations)) |
|
|
95
116
|
| `parent` | a local id | the ticket this one is a child of ([R-DIB-8](#4-relations)) |
|
|
96
117
|
| `order` | a number | rank among ready tickets, lower first |
|
|
118
|
+
| `type` | `task`, `bug`, `feature`, `epic`, or `chore` | the kind of work |
|
|
97
119
|
| `tags` | a list of words | free labels ([R-DIB-9](#5-tags-and-projects)) |
|
|
98
120
|
| `project` | a project page's name | the project the ticket belongs with ([R-DIB-10](#5-tags-and-projects)) |
|
|
99
121
|
| `repos` | a list of repositories | the other repositories its work changes, `owner/name` or a name the reader maps |
|
|
@@ -101,24 +123,37 @@ ticket file.
|
|
|
101
123
|
| `assignee` | a name or handle | who says they are working on it: advisory, never a lock ([Coordination state](#coordination-state)) |
|
|
102
124
|
| `updated` | a date | when the ticket last changed in substance |
|
|
103
125
|
| `not_before` | a date or time | the earliest it should be started |
|
|
104
|
-
|
|
126
|
+
|
|
127
|
+
A store can define its own `priority` in `item.schema.json`. The shared queue rank is `order`.
|
|
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.
|
|
105
132
|
|
|
106
133
|
**Other keys.** A key that only one tool gives a meaning to (a coordinator's workflow name, a
|
|
107
134
|
wiki's layout) is that tool's, documented in its own specification. Dibber does not list them,
|
|
108
135
|
and a reader that does not know one ignores it.
|
|
109
136
|
|
|
110
137
|
- **R-DIB-6 (status).** `status` is the store's word on where the ticket stands, for people and
|
|
111
|
-
for readers that keep no state of their own.
|
|
138
|
+
for readers that keep no state of their own. Importers translate source tracker statuses to
|
|
139
|
+
these canonical values. Its values, in four classes:
|
|
112
140
|
|
|
113
141
|
| Class | Values |
|
|
114
142
|
|---|---|
|
|
115
143
|
| live | `available` (ready to be taken), `in-progress`, `in-review`, `deprioritized` |
|
|
144
|
+
| coordinated | `orchestrator` (live; its progress is a coordinator's record) |
|
|
116
145
|
| closed, done | `done` |
|
|
117
146
|
| closed, withdrawn | `withdrawn`, `superseded` (another ticket replaces it), `deferred` (not now, maybe never) |
|
|
118
147
|
|
|
119
148
|
A coordinator that tracks a ticket's progress itself may weigh `status` as evidence rather than
|
|
120
149
|
take it as its own record; how it does is the coordinator's to specify.
|
|
121
150
|
|
|
151
|
+
**`orchestrator`** says to ask the coordinator. It is valid only in a store whose
|
|
152
|
+
`.dibber/config.json` names a coordinator ([R-DIB-4](#2-ids)).
|
|
153
|
+
- It stays when the coordinator finishes the ticket: closure is then the coordinator's
|
|
154
|
+
record alone, and no tool writes `done` or a live status over it.
|
|
155
|
+
- Withdrawal stays the store's word: `withdrawn`, `superseded` or `deferred` may replace it.
|
|
156
|
+
|
|
122
157
|
## 4. Relations
|
|
123
158
|
|
|
124
159
|
- **R-DIB-7 (one file, one writer).** A change to a ticket changes its own file alone:
|
|
@@ -129,7 +164,9 @@ ticket file.
|
|
|
129
164
|
- **R-DIB-8 (dependencies and children).** `depends_on` is the ticket's whole list of waits on
|
|
130
165
|
other tickets: a dependency written only in prose is one no reader can see. A ticket is ready
|
|
131
166
|
when it is `available` and every ticket it depends on is `done` or `superseded`: a superseded
|
|
132
|
-
ticket's work goes on in the ticket that replaced it, so it no longer holds anyone. A
|
|
167
|
+
ticket's work goes on in the ticket that replaced it, so it no longer holds anyone. A ticket
|
|
168
|
+
that is `orchestrator` is ready only when its coordinator says so, and is never ready to a reader
|
|
169
|
+
that cannot ask; a dependency on one holds until the coordinator says it is closed. A
|
|
133
170
|
`withdrawn` or `deferred` dependency still holds the ticket, since nothing did that work; drop
|
|
134
171
|
it from `depends_on`, or depend on what replaced it. A dependency on
|
|
135
172
|
another repository's ticket is a qualified id; `parent` is always local. A ticket is a child of
|
|
@@ -140,7 +177,7 @@ ticket file.
|
|
|
140
177
|
|
|
141
178
|
- **R-DIB-9 (tags).** Tags are free words. A reader may give some of them a meaning of its own,
|
|
142
179
|
documented in its specification; every other tag is the repository's.
|
|
143
|
-
- **R-DIB-10 (projects).** A project is a page whose frontmatter says `
|
|
180
|
+
- **R-DIB-10 (projects).** A project is a page whose frontmatter says `page: project`, in the
|
|
144
181
|
store's `projects/` folder by convention; a ticket's `project` names it by its `id`. A project groups tickets for
|
|
145
182
|
people: it is not a ticket and holds no state.
|
|
146
183
|
|
|
@@ -169,9 +206,8 @@ ticket file.
|
|
|
169
206
|
## 7. A store that is also a wiki
|
|
170
207
|
|
|
171
208
|
- **R-DIB-13 (rendering is optional).** A store may also be published as pages: a home page, a
|
|
172
|
-
layout, a site descriptor, project pages and views such as a board
|
|
173
|
-
|
|
174
|
-
files.
|
|
209
|
+
layout, a site descriptor, project pages and views such as a board. Readers identify
|
|
210
|
+
these pages by [R-DIB-1](#1-the-store).
|
|
175
211
|
|
|
176
212
|
## Coordination state
|
|
177
213
|
|
|
@@ -192,28 +228,39 @@ record.
|
|
|
192
228
|
|
|
193
229
|
## Versions
|
|
194
230
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
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.
|
|
246
|
+
|
|
247
|
+
A coordinated store moves to `orchestrator` with `dibber migrate --to-orchestrator`, which
|
|
248
|
+
changes the status line of every live ticket and leaves closed ones alone.
|
|
249
|
+
|
|
250
|
+
Run `dibber migrate` to replace old page markers such as `kind: project` on files without
|
|
251
|
+
a status. The migration changes them to `page: project`. It moves a ticket's custom
|
|
252
|
+
`type` value outside the standard vocabulary to `legacy_type`. If the store schema
|
|
253
|
+
requires a custom `type`, update it to describe `legacy_type` before migrating.
|
|
254
|
+
Ticket paths and Markdown bodies stay in place.
|
|
208
255
|
|
|
209
256
|
## Readers
|
|
210
257
|
|
|
211
|
-
|
|
258
|
+
- **[Baton](https://github.com/immediately-run/baton/blob/main/spec/BATON_SPEC/04-tickets-syncs-board.md#sec-4-2)**
|
|
259
|
+
coordinates work and imports ticket metadata through its default Markdown source.
|
|
260
|
+
- **[Dibber Board](https://github.com/immediately-run/dibber-board/blob/main/src/components/roadmapLib.ts)**
|
|
261
|
+
reads ticket frontmatter and renders a read-only board, ticket views and project views
|
|
262
|
+
on the [Grove wiki shell](https://github.com/immediately-run/grove/blob/main/src/GroveWiki.tsx).
|
|
263
|
+
Edits go through the repository.
|
|
212
264
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
([BATON_SPEC R-BTN-74](https://github.com/immediately-run/baton/blob/main/spec/BATON_SPEC/04-tickets-syncs-board.md#sec-4-2)).
|
|
216
|
-
- **[Fieldhouse](https://github.com/immediately-run/fieldhouse)** — a software factory; its homes
|
|
217
|
-
keep their tickets in Dibber stores.
|
|
218
|
-
- **[Grove](https://github.com/immediately-run/grove)** — renders a store as a wiki with a board
|
|
219
|
-
([R-DIB-13](#7-a-store-that-is-also-a-wiki)).
|
|
265
|
+
[Fieldhouse's ticket schema](https://github.com/immediately-run/fieldhouse/blob/main/tickets/item.schema.json)
|
|
266
|
+
shows a project using store-specific ticket fields.
|
package/SPEC_HISTORY.md
ADDED
|
@@ -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`.
|
package/config.schema.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"$id": "https://
|
|
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,13 @@
|
|
|
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."
|
|
39
|
+
},
|
|
40
|
+
"status": {
|
|
41
|
+
"type": "array",
|
|
42
|
+
"minItems": 1,
|
|
43
|
+
"items": { "type": "string" },
|
|
44
|
+
"description": "Executable and arguments that print, as JSON, where the named tickets stand (R-DIB-4). An argument <ids> becomes one argument per id; without it the ids are appended."
|
|
34
45
|
}
|
|
35
46
|
},
|
|
36
47
|
"additionalProperties": false
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@immediately-run/dibber",
|
|
3
|
-
"version": "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": {
|
|
@@ -32,7 +33,7 @@
|
|
|
32
33
|
"test": "node --test",
|
|
33
34
|
"check": "node bin/dibber.mjs check",
|
|
34
35
|
"check:release": "node scripts/check-release.mjs",
|
|
35
|
-
"version": "node scripts/check-release.mjs --sync && git add .claude-plugin",
|
|
36
|
+
"version": "node scripts/check-release.mjs --sync && git add .claude-plugin plugin.json",
|
|
36
37
|
"site": "node scripts/build-site.mjs"
|
|
37
38
|
},
|
|
38
39
|
"dependencies": {
|
|
@@ -40,6 +41,14 @@
|
|
|
40
41
|
"csv-parse": "^7.0.3",
|
|
41
42
|
"yaml": "^2.8.1"
|
|
42
43
|
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"@immediately-run/sdk": ">=0.98.0"
|
|
46
|
+
},
|
|
47
|
+
"peerDependenciesMeta": {
|
|
48
|
+
"@immediately-run/sdk": {
|
|
49
|
+
"optional": true
|
|
50
|
+
}
|
|
51
|
+
},
|
|
43
52
|
"publishConfig": {
|
|
44
53
|
"access": "public"
|
|
45
54
|
}
|
|
@@ -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
|
|
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,18 @@ 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.
|
|
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
|
|
62
|
+
`.dibber/config.json` names a coordinator, take the number from it and write
|
|
63
|
+
`status: orchestrator`. Use this shape, then run `dibber check` if you can:
|
|
52
64
|
|
|
53
65
|
```markdown
|
|
54
66
|
---
|
|
@@ -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`).
|
|
10
|
-
|
|
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
|
|
|
@@ -18,6 +20,8 @@ Lead with the answer to what was asked, in plain words. Then, briefly:
|
|
|
18
20
|
- **In progress / in review:** with `assignee` if set.
|
|
19
21
|
- **Waiting:** each ticket and what it waits on (another ticket, or another repository's).
|
|
20
22
|
- **Parked:** `deprioritized`, in one line.
|
|
23
|
+
- **Coordinated:** `orchestrator`, with the coordinator's state and reason where `dibber list`
|
|
24
|
+
shows them; without them, say that the coordinator holds where they stand.
|
|
21
25
|
- **Recently done:** only if asked, or if it helps ("3 closed this week").
|
|
22
26
|
|
|
23
27
|
Use ids and titles, never raw JSON. Five to ten lines is usually right. If the board is empty,
|
|
@@ -33,8 +37,23 @@ ticket to the user as suspicious.
|
|
|
33
37
|
|
|
34
38
|
## Without the command-line tool
|
|
35
39
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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,10 +13,17 @@ 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
|
-
|
|
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
|
-
3. **Claim it:**
|
|
23
|
+
3. **Claim it:** a ticket that says `status: orchestrator` is claimed, finished and closed
|
|
24
|
+
through the repository's coordinator (such as Baton), never with `dibber claim` or `done`:
|
|
25
|
+
follow the repository's own instructions for it, and if there are none, ask. Otherwise:
|
|
26
|
+
`dibber claim <id>`. This sets `in-progress` and names the user's git identity
|
|
20
27
|
as `assignee`. A claim is a note to people, not a lock.
|
|
21
28
|
4. **Do the work** on a branch, as you would for any request. Keep to the ticket's scope. If
|
|
22
29
|
you find more work, file it as a new ticket (the `dibber-new-ticket` skill) rather than
|
|
@@ -75,6 +82,20 @@ Every command takes `--json`.
|
|
|
75
82
|
|
|
76
83
|
## Without the command-line tool
|
|
77
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
|
+
|
|
78
99
|
Edit the frontmatter yourself: `status: in-progress` and `assignee: <name>` to claim, and
|
|
79
100
|
`status: done` to close. Never move or rename the file. Always add a dated line under
|
|
80
101
|
`## Status`.
|
package/src/check.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// check.mjs — judge a store against Dibber
|
|
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,12 +10,19 @@ 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, 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
|
+
export const legacyPageKind = (meta) =>
|
|
17
|
+
meta.page === undefined && meta.status === undefined && typeof meta.kind === 'string' &&
|
|
18
|
+
meta.kind !== '' && meta.kind !== 'ticket' ? meta.kind : undefined;
|
|
19
|
+
|
|
16
20
|
export const TICKET_SCHEMA = JSON.parse(readFileSync(join(HERE, '..', 'ticket.schema.json'), 'utf8'));
|
|
17
21
|
const CONFIG_SCHEMA = JSON.parse(readFileSync(join(HERE, '..', 'config.schema.json'), 'utf8'));
|
|
18
22
|
|
|
23
|
+
export { SPEC_VERSION };
|
|
24
|
+
const parseVersion = (v) => v.split('.').map(Number);
|
|
25
|
+
|
|
19
26
|
const ajv = new Ajv({ allErrors: true, strict: false });
|
|
20
27
|
const validateTicket = ajv.compile(TICKET_SCHEMA);
|
|
21
28
|
const validateConfig = ajv.compile(CONFIG_SCHEMA);
|
|
@@ -47,6 +54,15 @@ export function checkStore(root) {
|
|
|
47
54
|
if (settings.error) err('R-DIB-14', file, settings.error);
|
|
48
55
|
else if (!validateConfig(settings.raw)) {
|
|
49
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
|
+
}
|
|
50
66
|
}
|
|
51
67
|
}
|
|
52
68
|
if (!store.exists) {
|
|
@@ -65,10 +81,20 @@ export function checkStore(root) {
|
|
|
65
81
|
}
|
|
66
82
|
}
|
|
67
83
|
|
|
84
|
+
for (const page of store.pages) {
|
|
85
|
+
if (legacyPageKind(page.meta)) {
|
|
86
|
+
warn('R-DIB-1', page.file, 'legacy kind page marker; run dibber migrate');
|
|
87
|
+
} else if (page.meta.id !== undefined && page.meta.page === undefined && page.meta.status === undefined) {
|
|
88
|
+
err('R-DIB-5', page.file, 'an entry with an id needs status for a ticket or page for a page');
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
68
92
|
for (const b of store.broken) err('R-DIB-5', b.file, `the frontmatter is not valid YAML (${b.error})`);
|
|
69
93
|
|
|
70
94
|
// Per ticket.
|
|
71
|
-
|
|
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);
|
|
72
98
|
for (const t of store.tickets) {
|
|
73
99
|
const { meta, file } = t;
|
|
74
100
|
const id = meta.id;
|
|
@@ -86,6 +112,9 @@ export function checkStore(root) {
|
|
|
86
112
|
err(rule, file, describeSchemaError(e));
|
|
87
113
|
}
|
|
88
114
|
}
|
|
115
|
+
if (meta.status === COORDINATED && !hasCoordinator(settings)) {
|
|
116
|
+
err('R-DIB-6', file, `\`status: ${COORDINATED}\` needs a \`coordinator\` in .dibber/config.json`);
|
|
117
|
+
}
|
|
89
118
|
if (validateItem && !validateItem(meta)) {
|
|
90
119
|
for (const e of validateItem.errors) err('R-DIB-3', file, `the store's item.schema.json: ${describeSchemaError(e)}`);
|
|
91
120
|
}
|
|
@@ -138,11 +167,11 @@ export function checkStore(root) {
|
|
|
138
167
|
for (const id of [...byId.keys()].sort()) visit(id, []);
|
|
139
168
|
|
|
140
169
|
// Conventions: warnings only.
|
|
141
|
-
const projects = new Set(store.pages.filter((p) => p.meta.
|
|
170
|
+
const projects = new Set(store.pages.filter((p) => (p.meta.page ?? legacyPageKind(p.meta)) === 'project').map((p) => String(p.meta.id)));
|
|
142
171
|
for (const t of store.tickets) {
|
|
143
172
|
const project = t.meta.project;
|
|
144
173
|
if (typeof project === 'string' && !projects.has(project)) {
|
|
145
|
-
warn('R-DIB-10', t.file, `\`project\` names \`${project}\`, but no page in the store has \`
|
|
174
|
+
warn('R-DIB-10', t.file, `\`project\` names \`${project}\`, but no page in the store has \`page: project\` and that id`);
|
|
146
175
|
}
|
|
147
176
|
const m = /^\*\*Depends on:\*\*\s*(.*)$/m.exec(t.body);
|
|
148
177
|
if (m) {
|
package/src/cli.mjs
CHANGED
|
@@ -8,6 +8,7 @@ import { checkStore } from './check.mjs';
|
|
|
8
8
|
import { Refusal, newTicket, setStatus, claim, listTickets, STATUSES } from './tickets.mjs';
|
|
9
9
|
import { init, defaultPrefix } from './init.mjs';
|
|
10
10
|
import { importTickets } from './import.mjs';
|
|
11
|
+
import { migrateStore } from './migrate.mjs';
|
|
11
12
|
import { intakeGitHub } from './intake.mjs';
|
|
12
13
|
|
|
13
14
|
const HELP = `dibber — Git as your issue tracker: an open format built on Markdown (https://github.com/immediately-run/dibber)
|
|
@@ -23,12 +24,18 @@ Usage: dibber <command> [options] (every command takes --json and --root
|
|
|
23
24
|
files out
|
|
24
25
|
check [--strict] check the store against the Dibber spec; --strict fails
|
|
25
26
|
on warnings too
|
|
26
|
-
list [--ready] [--status S] [--all]
|
|
27
|
-
the overview: what is ready, in progress and waiting
|
|
27
|
+
list [--ready] [--status S] [--all] [--offline]
|
|
28
|
+
the overview: what is ready, in progress and waiting;
|
|
29
|
+
--offline does not ask the coordinator
|
|
28
30
|
new --title "…" [--why "…"] [--what "…"] [--criterion "…"]… [--depends-on ID,…]
|
|
29
31
|
[--id ID] [--offline] [--body-file PATH] [--field KEY=VALUE]…
|
|
30
32
|
[--parent ID] [--tags a,b] [--project P] [--order N] [--brief "…"] [--mdx]
|
|
31
|
-
|
|
33
|
+
[--status S]
|
|
34
|
+
file a ticket with the next free id; its status is
|
|
35
|
+
orchestrator with a coordinator, else available
|
|
36
|
+
migrate [--to-orchestrator] update legacy page markers and custom types in place;
|
|
37
|
+
--to-orchestrator hands a coordinated store's live
|
|
38
|
+
tickets to the coordinator
|
|
32
39
|
intake github <issue.json> file a quoted GitHub issue report
|
|
33
40
|
import github|linear|jira <export> [--source-url URL]
|
|
34
41
|
import tickets from a local export
|
|
@@ -81,6 +88,7 @@ function formatList(rows) {
|
|
|
81
88
|
['In review', (r) => r.status === 'in-review'],
|
|
82
89
|
['Waiting', (r) => r.status === 'available' && !r.ready],
|
|
83
90
|
['Parked', (r) => r.status === 'deprioritized'],
|
|
91
|
+
['Coordinated', (r) => r.status === 'orchestrator' && !r.ready && !r.closed],
|
|
84
92
|
['Closed', (r) => r.closed],
|
|
85
93
|
];
|
|
86
94
|
const out = [];
|
|
@@ -92,7 +100,8 @@ function formatList(rows) {
|
|
|
92
100
|
const extra = [];
|
|
93
101
|
if (r.assignee) extra.push(`@${r.assignee}`);
|
|
94
102
|
if (label === 'Waiting') extra.push(`waits on ${r.waits.map((w) => `${w.id} (${w.why})`).join(', ')}`);
|
|
95
|
-
if (label === '
|
|
103
|
+
if (label === 'Coordinated') extra.push(r.coordinator ? [r.coordinator.state, r.coordinator.reason].filter(Boolean).join(': ') : 'coordinated');
|
|
104
|
+
if (label === 'Closed') extra.push(r.coordinator?.state ?? r.status);
|
|
96
105
|
out.push(` ${r.title}${extra.length ? ` — ${extra.join('; ')}` : ''}`);
|
|
97
106
|
}
|
|
98
107
|
out.push('');
|
|
@@ -134,19 +143,23 @@ export async function run(argv, { cwd = process.cwd(), interactive = true } = {}
|
|
|
134
143
|
}
|
|
135
144
|
code = errors.length || (flags.strict && warnings.length) ? 1 : 0;
|
|
136
145
|
} else if (cmd === 'list') {
|
|
137
|
-
const rows = listTickets(root, { ready: flags.ready, status: flags.status, closed: flags.all });
|
|
146
|
+
const rows = listTickets(root, { ready: flags.ready, status: flags.status, closed: flags.all, offline: flags.offline, onError: (m) => stderr.push(`dibber: ${m}`) });
|
|
138
147
|
if (flags.json) json(rows);
|
|
139
148
|
else stdout.push(formatList(rows));
|
|
140
149
|
} else if (cmd === 'new') {
|
|
141
150
|
const r = newTicket(root, {
|
|
142
151
|
id: flags.id, offline: flags.offline, fields: flags.field,
|
|
143
152
|
bodyFile: flags['body-file'] === undefined ? undefined : resolve(cwd, flags['body-file']),
|
|
144
|
-
title: flags.title, why: flags.why, what: flags.what, criteria: flags.criterion ?? [],
|
|
153
|
+
status: flags.status, title: flags.title, why: flags.why, what: flags.what, criteria: flags.criterion ?? [],
|
|
145
154
|
dependsOn: csv(flags['depends-on']), parent: flags.parent, tags: csv(flags.tags), project: flags.project,
|
|
146
155
|
order: flags.order, brief: flags.brief, description: flags.description, assignee: flags.assignee, mdx: flags.mdx,
|
|
147
156
|
});
|
|
148
157
|
if (flags.json) json(r);
|
|
149
158
|
else stdout.push(`filed ${r.id}: ${r.file}${r.offline ? ' (offline allocation)' : ''}`);
|
|
159
|
+
} else if (cmd === 'migrate') {
|
|
160
|
+
const updated = migrateStore(root, { toOrchestrator: flags['to-orchestrator'] });
|
|
161
|
+
if (flags.json) json({ updated });
|
|
162
|
+
else stdout.push(updated.length ? updated.map((path) => `migrated ${path}`).join('\n') : 'No migration needed.');
|
|
150
163
|
} else if (cmd === 'intake') {
|
|
151
164
|
const [source, file] = rest;
|
|
152
165
|
if (source !== 'github' || !file) throw new Refusal('usage: dibber intake github <issue.json>');
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// coordinator.mjs — ask the coordinator where its tickets stand ([DIB-35](../tickets/DIB-35.md)).
|
|
2
|
+
// `coordinator.status` in .dibber/config.json is run from the repository root; its answer is
|
|
3
|
+
// data: checked, bounded and shown, never acted on beyond `state` and `closed`.
|
|
4
|
+
|
|
5
|
+
import { execFileSync } from 'node:child_process';
|
|
6
|
+
|
|
7
|
+
const MAX_TEXT = 200;
|
|
8
|
+
// Text a terminal would act on does not reach one.
|
|
9
|
+
const plain = (v) => (typeof v === 'string' ? v.replace(/[\u0000-\u001f\u007f-\u009f\u202a-\u202e\u2066-\u2069]/g, ' ').trim().slice(0, MAX_TEXT) : '');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The coordinator's state of `ids`: `{ states: Map(id → { state, closed, reason }), error }`.
|
|
13
|
+
* With no query configured, or one that fails, `states` is empty and nothing throws.
|
|
14
|
+
*/
|
|
15
|
+
export function coordinatorStates(root, store, ids) {
|
|
16
|
+
const argv = store.settings.raw?.coordinator?.status;
|
|
17
|
+
const states = new Map();
|
|
18
|
+
if (!ids.length || argv === undefined) return { states, error: null };
|
|
19
|
+
if (!Array.isArray(argv) || !argv[0] || !argv.every((arg) => typeof arg === 'string')) {
|
|
20
|
+
return { states, error: 'coordinator.status must be an executable and its arguments' };
|
|
21
|
+
}
|
|
22
|
+
const args = argv.includes('<ids>') ? argv.flatMap((arg) => (arg === '<ids>' ? ids : [arg])) : [...argv, ...ids];
|
|
23
|
+
let answer;
|
|
24
|
+
try {
|
|
25
|
+
answer = JSON.parse(execFileSync(args[0], args.slice(1), {
|
|
26
|
+
cwd: root, encoding: 'utf8', timeout: 30_000, maxBuffer: 16 * 1024 * 1024, stdio: ['ignore', 'pipe', 'ignore'],
|
|
27
|
+
}));
|
|
28
|
+
} catch {
|
|
29
|
+
return { states, error: 'the coordinator did not answer the status query' };
|
|
30
|
+
}
|
|
31
|
+
const tickets = answer?.tickets;
|
|
32
|
+
if (typeof tickets !== 'object' || tickets === null || Array.isArray(tickets)) {
|
|
33
|
+
return { states, error: 'the coordinator’s status answer has no `tickets` object' };
|
|
34
|
+
}
|
|
35
|
+
for (const id of ids) {
|
|
36
|
+
const t = Object.hasOwn(tickets, id) ? tickets[id] : undefined;
|
|
37
|
+
const state = plain(t?.state);
|
|
38
|
+
if (!state || typeof t.closed !== 'boolean') continue; // not answered: the ticket stays coordinated
|
|
39
|
+
states.set(id, { state, closed: t.closed, reason: plain(t.reason) });
|
|
40
|
+
}
|
|
41
|
+
return { states, error: null };
|
|
42
|
+
}
|
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
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// Upgrade a store in place while preserving ticket paths and bodies ([DIB-27](../tickets/DIB-27.md)).
|
|
2
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { relative } from 'node:path';
|
|
4
|
+
import { checkStore, legacyPageKind, TICKET_SCHEMA } from './check.mjs';
|
|
5
|
+
import { splitFrontmatter, readStore, LIVE, COORDINATED, hasCoordinator, SPEC_VERSION } from './store.mjs';
|
|
6
|
+
import { Refusal } from './tickets.mjs';
|
|
7
|
+
|
|
8
|
+
// Only the status line changes, so a large store's migration reads as one line a ticket.
|
|
9
|
+
function toOrchestrator(store) {
|
|
10
|
+
if (!hasCoordinator(store.settings)) throw new Refusal('--to-orchestrator needs a `coordinator` in .dibber/config.json');
|
|
11
|
+
return store.tickets.filter((t) => LIVE.includes(t.meta.status)).map((entry) => {
|
|
12
|
+
const { body, raw, doc } = splitFrontmatter(entry.text);
|
|
13
|
+
const line = raw.replace(/^status:[^\r\n]*/m, `status: ${COORDINATED}`);
|
|
14
|
+
let text = entry.text.replace(raw, () => line);
|
|
15
|
+
const again = splitFrontmatter(text);
|
|
16
|
+
if (again?.meta?.status !== COORDINATED || JSON.stringify({ ...again.meta, status: 0 }) !== JSON.stringify({ ...entry.meta, status: 0 }) || again.body !== body) {
|
|
17
|
+
doc.set('status', COORDINATED);
|
|
18
|
+
text = `---\n${doc.toString({ lineWidth: 0, flowCollectionPadding: false })}---\n${body}`;
|
|
19
|
+
}
|
|
20
|
+
return { entry, text };
|
|
21
|
+
});
|
|
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
|
+
|
|
30
|
+
export function migrateStore(root, opts = {}) {
|
|
31
|
+
const store = readStore(root);
|
|
32
|
+
if (!store.exists) throw new Refusal(`there is no store at ${store.storeRel}/`);
|
|
33
|
+
const updates = opts.toOrchestrator ? toOrchestrator(store) : [];
|
|
34
|
+
|
|
35
|
+
if (!opts.toOrchestrator) for (const entry of [...store.pages, ...store.tickets]) {
|
|
36
|
+
const { doc, body, meta } = splitFrontmatter(entry.text);
|
|
37
|
+
const kind = legacyPageKind(meta);
|
|
38
|
+
if (kind !== undefined) {
|
|
39
|
+
doc.set('page', kind);
|
|
40
|
+
doc.delete('kind');
|
|
41
|
+
} else if (meta.id !== undefined && meta.status !== undefined && meta.page === undefined) {
|
|
42
|
+
if (!Object.hasOwn(meta, 'type') || TICKET_SCHEMA.properties.type.enum.includes(meta.type)) continue;
|
|
43
|
+
if (Object.hasOwn(meta, 'legacy_type')) {
|
|
44
|
+
throw new Refusal(`${entry.file} already has legacy_type; resolve the two values before migrating`);
|
|
45
|
+
}
|
|
46
|
+
doc.set('legacy_type', doc.get('type', true));
|
|
47
|
+
doc.delete('type');
|
|
48
|
+
} else continue;
|
|
49
|
+
updates.push({ entry, text: `---\n${doc.toString({ lineWidth: 0 })}---\n${body}` });
|
|
50
|
+
}
|
|
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
|
+
|
|
61
|
+
if (!updates.length) return [];
|
|
62
|
+
const written = [];
|
|
63
|
+
try {
|
|
64
|
+
for (const { entry, text } of updates) {
|
|
65
|
+
written.push(entry);
|
|
66
|
+
writeFileSync(entry.path, text);
|
|
67
|
+
}
|
|
68
|
+
const { errors } = checkStore(root);
|
|
69
|
+
if (errors.length) {
|
|
70
|
+
throw new Refusal(errors.map(({ file, message }) => `${file}: ${message}`).join('\n'));
|
|
71
|
+
}
|
|
72
|
+
} catch (error) {
|
|
73
|
+
for (const entry of written) writeFileSync(entry.path, entry.text);
|
|
74
|
+
throw new Refusal(`migration failed: ${error.message}`);
|
|
75
|
+
}
|
|
76
|
+
return updates.map(({ entry }) => entry.file);
|
|
77
|
+
}
|
package/src/store.mjs
CHANGED
|
@@ -7,11 +7,17 @@ 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'];
|
|
15
|
+
/** Live, with its progress in the coordinator's record (R-DIB-6, [DIB-35](../tickets/DIB-35.md)). */
|
|
16
|
+
export const COORDINATED = 'orchestrator';
|
|
11
17
|
export const CLOSED_DONE = ['done'];
|
|
12
18
|
export const CLOSED_WITHDRAWN = ['withdrawn', 'superseded', 'deferred'];
|
|
13
19
|
export const CLOSED = [...CLOSED_DONE, ...CLOSED_WITHDRAWN];
|
|
14
|
-
export const STATUSES = [...LIVE, ...CLOSED];
|
|
20
|
+
export const STATUSES = [...LIVE, COORDINATED, ...CLOSED];
|
|
15
21
|
|
|
16
22
|
export const ID_RE = /^(?:[A-Za-z][A-Za-z0-9]*-(?:[0-9]+|[a-z0-9]{4,})|[A-Z][A-Z0-9]*-[0-9]+[a-z0-9]*)$/;
|
|
17
23
|
export const QUALIFIED_RE = /^([a-z0-9][a-z0-9._-]*):((?:[A-Za-z][A-Za-z0-9]*-(?:[0-9]+|[a-z0-9]{4,})|[A-Z][A-Z0-9]*-[0-9]+[a-z0-9]*))$/;
|
|
@@ -53,6 +59,18 @@ export function readSettings(root) {
|
|
|
53
59
|
};
|
|
54
60
|
}
|
|
55
61
|
|
|
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
|
+
};
|
|
72
|
+
export const hasCoordinator = (settings) => typeof settings.raw?.coordinator === 'object' && settings.raw.coordinator !== null && !Array.isArray(settings.raw.coordinator);
|
|
73
|
+
|
|
56
74
|
function walk(dir, out = []) {
|
|
57
75
|
for (const name of readdirSync(dir).sort()) {
|
|
58
76
|
if (name === 'node_modules' || name === '.git') continue;
|
|
@@ -66,7 +84,7 @@ function walk(dir, out = []) {
|
|
|
66
84
|
|
|
67
85
|
/**
|
|
68
86
|
* Read every Markdown file under the store. A file is a ticket when its frontmatter carries an
|
|
69
|
-
* `id` and
|
|
87
|
+
* `id` and `status` without a `page` marker (R-DIB-1); a file whose frontmatter does not parse is
|
|
70
88
|
* reported as `broken`, since it cannot be told apart.
|
|
71
89
|
*/
|
|
72
90
|
export function readStore(root) {
|
|
@@ -84,7 +102,7 @@ export function readStore(root) {
|
|
|
84
102
|
continue;
|
|
85
103
|
}
|
|
86
104
|
const { meta } = parts;
|
|
87
|
-
const isTicket = meta.id !== undefined &&
|
|
105
|
+
const isTicket = meta.id !== undefined && meta.status !== undefined && meta.page === undefined;
|
|
88
106
|
const closed = CLOSED.includes(meta.status); // closure is the status alone (R-DIB-2)
|
|
89
107
|
const entry = { path, file, closed, meta, body: parts.body, text, ext: extname(path), name: basename(path, extname(path)) };
|
|
90
108
|
(isTicket ? result.tickets : result.pages).push(entry);
|
package/src/tickets.mjs
CHANGED
|
@@ -6,11 +6,12 @@
|
|
|
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, STATUSES, 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
|
+
import { coordinatorStates } from './coordinator.mjs';
|
|
14
15
|
|
|
15
16
|
export class Refusal extends Error {}
|
|
16
17
|
|
|
@@ -53,13 +54,19 @@ export function storePrefix(store) {
|
|
|
53
54
|
return best[0];
|
|
54
55
|
}
|
|
55
56
|
|
|
56
|
-
// Accept a
|
|
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.
|
|
57
61
|
function reservedId(root, store, id) {
|
|
58
|
-
if (!ID_RE.test(id)
|
|
62
|
+
if (!ID_RE.test(id)) throw new Refusal(`invalid reserved id \`${id}\``);
|
|
63
|
+
if (!takesAnyPrefix(store.settings) && id.split('-')[0] !== storePrefix(store)) {
|
|
59
64
|
throw new Refusal(`invalid reserved id \`${id}\` for prefix \`${storePrefix(store)}\``);
|
|
60
65
|
}
|
|
61
|
-
|
|
62
|
-
|
|
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)) {
|
|
63
70
|
throw new Refusal(`ticket id \`${id}\` is already taken`);
|
|
64
71
|
}
|
|
65
72
|
return id;
|
|
@@ -70,19 +77,22 @@ function coordinatorId(root, store, coordinator) {
|
|
|
70
77
|
if (!Array.isArray(argv) || !argv[0] || !argv.every((arg) => typeof arg === 'string')) {
|
|
71
78
|
throw new Refusal('coordinator.next must be an executable and its arguments');
|
|
72
79
|
}
|
|
73
|
-
|
|
74
|
-
const
|
|
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));
|
|
75
83
|
let output;
|
|
76
84
|
try {
|
|
77
85
|
output = execFileSync(command, args, {
|
|
78
86
|
cwd: root, encoding: 'utf8', timeout: 30_000, stdio: ['ignore', 'pipe', 'pipe'],
|
|
79
87
|
});
|
|
80
88
|
} catch {
|
|
81
|
-
throw new Refusal('the coordinator failed to allocate a ticket
|
|
89
|
+
throw new Refusal('the coordinator failed to allocate a ticket id; pass --offline to use local allocation');
|
|
82
90
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return reservedId(root, store, `${
|
|
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');
|
|
86
96
|
}
|
|
87
97
|
|
|
88
98
|
/** Allocate a free numeric or random id across the store and known branches ([DIB-26](../tickets/DIB-26.md)). */
|
|
@@ -128,7 +138,7 @@ function extensionFields(store, entries, readerOnly = false) {
|
|
|
128
138
|
if (separator < 1) throw new Refusal('--field expects key=value');
|
|
129
139
|
const key = entry.slice(0, separator);
|
|
130
140
|
const builtIn = Object.hasOwn(TICKET_SCHEMA.properties, key);
|
|
131
|
-
if (key === 'id' || key === 'status' || key === '
|
|
141
|
+
if (key === 'id' || key === 'status' || key === 'page' || (readerOnly && builtIn)) {
|
|
132
142
|
throw new Refusal(`--field cannot write Dibber-owned key \`${key}\``);
|
|
133
143
|
}
|
|
134
144
|
if (!builtIn && !Object.hasOwn(schema?.properties ?? {}, key)
|
|
@@ -149,8 +159,12 @@ function extensionFields(store, entries, readerOnly = false) {
|
|
|
149
159
|
return { fields, keys: Object.keys(schema?.properties ?? {}) };
|
|
150
160
|
}
|
|
151
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)).
|
|
152
164
|
function orderFields(meta, keys) {
|
|
153
|
-
|
|
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)])]
|
|
154
168
|
.filter((key) => Object.hasOwn(meta, key)).map((key) => [key, meta[key]]));
|
|
155
169
|
}
|
|
156
170
|
|
|
@@ -179,6 +193,10 @@ export function newTicket(root, opts) {
|
|
|
179
193
|
throw new Refusal(`cannot read --body-file: ${error.message}`);
|
|
180
194
|
}
|
|
181
195
|
}
|
|
196
|
+
const coordinated = hasCoordinator(store.settings);
|
|
197
|
+
const initial = opts.status ?? (coordinated ? COORDINATED : 'available');
|
|
198
|
+
if (![...LIVE, COORDINATED].includes(initial)) throw new Refusal(`a new ticket's status is one of ${[...LIVE, COORDINATED].join(', ')}`);
|
|
199
|
+
if (initial === COORDINATED && !coordinated) throw new Refusal(`\`${COORDINATED}\` needs a \`coordinator\` in .dibber/config.json`);
|
|
182
200
|
const id = allocateTicketId(root, store, opts);
|
|
183
201
|
const dependsOn = asList(opts.dependsOn);
|
|
184
202
|
for (const d of dependsOn) {
|
|
@@ -186,7 +204,7 @@ export function newTicket(root, opts) {
|
|
|
186
204
|
if (ID_RE.test(d) && !store.tickets.some((t) => t.meta.id === d)) throw new Refusal(`\`depends_on\` names \`${d}\`, which is not a ticket in this store`);
|
|
187
205
|
}
|
|
188
206
|
if (opts.parent && !store.tickets.some((t) => t.meta.id === opts.parent)) throw new Refusal(`\`parent\` names \`${opts.parent}\`, which is not a ticket in this store`);
|
|
189
|
-
let meta = { id, title: `${id} — ${opts.title}`, status:
|
|
207
|
+
let meta = { id, title: `${id} — ${opts.title}`, status: initial };
|
|
190
208
|
if (opts.description) meta.description = opts.description;
|
|
191
209
|
meta.depends_on = dependsOn;
|
|
192
210
|
if (opts.parent) meta.parent = opts.parent;
|
|
@@ -237,9 +255,17 @@ export function findTicket(store, id) {
|
|
|
237
255
|
* ticket that replaced it ([DIB-20](../tickets/DIB-20.md)). */
|
|
238
256
|
export const SATISFIES_DEPENDENCY = ['done', 'superseded'];
|
|
239
257
|
|
|
240
|
-
/**
|
|
241
|
-
|
|
258
|
+
/**
|
|
259
|
+
* Ready: live, available, and every local dependency done or superseded (R-DIB-8). A coordinated
|
|
260
|
+
* ticket is ready only when `states`, the coordinator's answers, say so; a dependency on one
|
|
261
|
+
* holds until they say it is closed.
|
|
262
|
+
*/
|
|
263
|
+
export function readiness(store, t, states = new Map()) {
|
|
242
264
|
const waits = [];
|
|
265
|
+
if (t.meta.status === COORDINATED) {
|
|
266
|
+
const s = states.get(t.meta.id);
|
|
267
|
+
return { ready: s !== undefined && !s.closed && s.state === 'ready', waits };
|
|
268
|
+
}
|
|
243
269
|
for (const d of asList(t.meta.depends_on)) {
|
|
244
270
|
if (QUALIFIED_RE.test(d)) {
|
|
245
271
|
waits.push({ id: d, why: 'in another repository' });
|
|
@@ -247,7 +273,10 @@ export function readiness(store, t) {
|
|
|
247
273
|
}
|
|
248
274
|
const dep = store.tickets.find((x) => x.meta.id === d);
|
|
249
275
|
if (!dep) waits.push({ id: d, why: 'not found' });
|
|
250
|
-
else if (
|
|
276
|
+
else if (dep.meta.status === COORDINATED) {
|
|
277
|
+
const s = states.get(d);
|
|
278
|
+
if (!s?.closed) waits.push({ id: d, why: s?.state ?? 'coordinated' });
|
|
279
|
+
} else if (!SATISFIES_DEPENDENCY.includes(dep.meta.status)) waits.push({ id: d, why: dep.meta.status });
|
|
251
280
|
}
|
|
252
281
|
return { ready: t.meta.status === 'available' && waits.length === 0, waits };
|
|
253
282
|
}
|
|
@@ -292,6 +321,9 @@ export function setStatus(root, id, status, opts = {}) {
|
|
|
292
321
|
const store = readStore(root);
|
|
293
322
|
const t = findTicket(store, id);
|
|
294
323
|
if (t.closed) throw new Refusal(`\`${id}\` is closed (\`${t.meta.status}\`); file a new ticket instead of reopening it`);
|
|
324
|
+
if (t.meta.status === COORDINATED && status !== undefined && status !== COORDINATED && !CLOSED_WITHDRAWN.includes(status)) {
|
|
325
|
+
throw new Refusal(`\`${id}\` is coordinated: its progress and closure are the coordinator's to record. The store may still say ${CLOSED_WITHDRAWN.join(', ')}`);
|
|
326
|
+
}
|
|
295
327
|
const parts = splitFrontmatter(t.text);
|
|
296
328
|
const doc = parts.doc;
|
|
297
329
|
const { fields } = extensionFields(store, opts.fields, true);
|
|
@@ -314,11 +346,19 @@ export function setStatus(root, id, status, opts = {}) {
|
|
|
314
346
|
return { id, file: t.file, status: status ?? t.meta.status };
|
|
315
347
|
}
|
|
316
348
|
|
|
349
|
+
/** Of `ids`, or of the whole store, the coordinated tickets' ids. */
|
|
350
|
+
function coordinatedIds(store, ids = null) {
|
|
351
|
+
return store.tickets
|
|
352
|
+
.filter((t) => t.meta.status === COORDINATED && ID_RE.test(String(t.meta.id)) && (ids === null || ids.includes(t.meta.id)))
|
|
353
|
+
.map((t) => t.meta.id);
|
|
354
|
+
}
|
|
355
|
+
|
|
317
356
|
/** Claim: available → in-progress, with an advisory assignee. Refuses a ticket that is not ready. */
|
|
318
357
|
export function claim(root, id, opts = {}) {
|
|
319
358
|
const store = readStore(root);
|
|
320
359
|
const t = findTicket(store, id);
|
|
321
|
-
|
|
360
|
+
if (t.meta.status === COORDINATED) throw new Refusal(`\`${id}\` is coordinated; claim it through the coordinator`);
|
|
361
|
+
const { ready, waits } = readiness(store, t, coordinatorStates(root, store, coordinatedIds(store, asList(t.meta.depends_on))).states);
|
|
322
362
|
if (!ready && !opts.force) {
|
|
323
363
|
if (t.meta.status !== 'available') throw new Refusal(`\`${id}\` is \`${t.meta.status}\`, not available`);
|
|
324
364
|
throw new Refusal(`\`${id}\` waits on ${waits.map((w) => `${w.id} (${w.why})`).join(', ')}; pass --force to claim it anyway`);
|
|
@@ -330,11 +370,14 @@ export function claim(root, id, opts = {}) {
|
|
|
330
370
|
/** The overview: every ticket with its readiness, in reading order. */
|
|
331
371
|
export function listTickets(root, filter = {}) {
|
|
332
372
|
const store = readStore(root);
|
|
373
|
+
const { states, error } = filter.offline ? { states: new Map(), error: null } : coordinatorStates(root, store, coordinatedIds(store));
|
|
374
|
+
if (error) filter.onError?.(error);
|
|
375
|
+
const closedNow = (t) => t.closed || (t.meta.status === COORDINATED && states.get(t.meta.id)?.closed === true);
|
|
333
376
|
const rows = store.tickets
|
|
334
|
-
.filter((t) => (filter.closed ? true : !t
|
|
377
|
+
.filter((t) => (filter.closed ? true : !closedNow(t)))
|
|
335
378
|
.sort(byOrderThenId)
|
|
336
379
|
.map((t) => {
|
|
337
|
-
const { ready, waits } = readiness(store, t);
|
|
380
|
+
const { ready, waits } = readiness(store, t, states);
|
|
338
381
|
return {
|
|
339
382
|
id: t.meta.id,
|
|
340
383
|
title: String(t.meta.title ?? ''),
|
|
@@ -347,7 +390,8 @@ export function listTickets(root, filter = {}) {
|
|
|
347
390
|
tags: asList(t.meta.tags),
|
|
348
391
|
order: t.meta.order ?? null,
|
|
349
392
|
file: t.file,
|
|
350
|
-
closed: t
|
|
393
|
+
closed: closedNow(t),
|
|
394
|
+
...(t.meta.status === COORDINATED && { coordinator: states.get(t.meta.id) ?? null }),
|
|
351
395
|
};
|
|
352
396
|
});
|
|
353
397
|
return rows.filter((r) => (!filter.ready || r.ready) && (!filter.status || r.status === filter.status));
|
package/ticket.schema.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"$id": "https://
|
|
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": {
|
|
@@ -21,21 +21,21 @@
|
|
|
21
21
|
"id": { "$ref": "#/definitions/id" },
|
|
22
22
|
"title": { "type": "string", "minLength": 1 },
|
|
23
23
|
"status": {
|
|
24
|
-
"enum": ["available", "in-progress", "in-review", "deprioritized", "done", "withdrawn", "superseded", "deferred"],
|
|
25
|
-
"description": "R-DIB-6: live (available, in-progress, in-review, deprioritized); closed done (done); closed withdrawn (withdrawn, superseded, deferred)."
|
|
24
|
+
"enum": ["available", "in-progress", "in-review", "deprioritized", "orchestrator", "done", "withdrawn", "superseded", "deferred"],
|
|
25
|
+
"description": "R-DIB-6: live (available, in-progress, in-review, deprioritized); coordinated (orchestrator: live, its progress in the coordinator's record); closed done (done); closed withdrawn (withdrawn, superseded, deferred)."
|
|
26
26
|
},
|
|
27
27
|
"description": { "type": "string" },
|
|
28
28
|
"depends_on": { "type": "array", "items": { "$ref": "#/definitions/ref" }, "uniqueItems": true },
|
|
29
29
|
"parent": { "$ref": "#/definitions/id" },
|
|
30
30
|
"order": { "type": "number" },
|
|
31
|
+
"type": { "enum": ["task", "bug", "feature", "epic", "chore"] },
|
|
31
32
|
"tags": { "type": "array", "items": { "type": "string" } },
|
|
32
33
|
"project": { "type": "string" },
|
|
33
34
|
"repos": { "type": "array", "items": { "type": "string" } },
|
|
34
35
|
"prs": { "type": "array", "items": { "type": "string" } },
|
|
35
36
|
"assignee": { "type": "string", "minLength": 1, "description": "Advisory: who says they are working on the ticket (R-DIB-5). Never a lock; a coordinator keeps its own record of who holds a ticket (Coordination state)." },
|
|
36
37
|
"updated": { "type": ["string", "object"] },
|
|
37
|
-
"not_before": { "type": ["string", "object"] }
|
|
38
|
-
"kind": { "const": "ticket", "description": "Optional. A file whose kind is anything else is a page, not a ticket (R-DIB-1)." }
|
|
38
|
+
"not_before": { "type": ["string", "object"] }
|
|
39
39
|
},
|
|
40
40
|
"additionalProperties": true
|
|
41
41
|
}
|