@immediately-run/dibber 0.4.0 → 0.5.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 +43 -8
- package/SPEC.md +51 -32
- package/config.schema.json +6 -0
- package/package.json +10 -2
- package/skills/dibber-new-ticket/SKILL.md +3 -1
- package/skills/dibber-overview/SKILL.md +5 -2
- package/skills/dibber-work-ticket/SKILL.md +4 -1
- package/src/check.mjs +18 -3
- package/src/cli.mjs +19 -6
- package/src/coordinator.mjs +42 -0
- package/src/migrate.mjs +61 -0
- package/src/store.mjs +8 -3
- package/src/tickets.mjs +41 -10
- package/ticket.schema.json +4 -4
package/README.md
CHANGED
|
@@ -19,7 +19,15 @@ is on it, but cannot stop two people writing their names at once.
|
|
|
19
19
|
Dibber is in active development, and its work is tracked in Dibber itself. The
|
|
20
20
|
[board](https://immediately.run/present/github/immediately-run/dibber/main/bundle/tickets/)
|
|
21
21
|
shows every ticket by status — what is ready, in progress and in review, and what is done —
|
|
22
|
-
read straight from
|
|
22
|
+
read straight from `tickets/`.
|
|
23
|
+
|
|
24
|
+
## This repository is an example
|
|
25
|
+
|
|
26
|
+
Dibber tracks its own work here. Compare an [open ticket](tickets/DIB-15.md)
|
|
27
|
+
with a [closed ticket](tickets/DIB-10.md). The closed ticket keeps its path
|
|
28
|
+
and links to the pull request that shipped it. The [project page](tickets/projects/wide-audience.md)
|
|
29
|
+
groups the work, and [repository settings](.dibber/config.json) name the
|
|
30
|
+
store and its ID prefix.
|
|
23
31
|
|
|
24
32
|
## A ticket
|
|
25
33
|
|
|
@@ -63,7 +71,7 @@ keeps working.
|
|
|
63
71
|
- [`skills/`](skills/), [`bin/`](bin/), [`src/`](src/) — optional tooling: the `dibber`
|
|
64
72
|
command (`check`, `list`, `new`, `claim`, `done`, `init`) and the agent skills `dibber init`
|
|
65
73
|
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
|
|
74
|
+
- [`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
75
|
Dibber-tracked project looks like.
|
|
68
76
|
|
|
69
77
|
## CLI
|
|
@@ -80,24 +88,51 @@ configure its allocator in `.dibber/config.json`:
|
|
|
80
88
|
```json
|
|
81
89
|
{
|
|
82
90
|
"coordinator": {
|
|
83
|
-
"next": ["npx", "@immediately-run/baton", "tickets", "next", "ticket-<prefix>"]
|
|
91
|
+
"next": ["npx", "@immediately-run/baton", "tickets", "next", "ticket-<prefix>"],
|
|
92
|
+
"status": ["npx", "@immediately-run/baton", "tickets", "status", "<ids>", "--coordinator"]
|
|
84
93
|
}
|
|
85
94
|
}
|
|
86
95
|
```
|
|
87
96
|
|
|
88
97
|
`new` runs that command directly and takes the decimal number from its last line.
|
|
89
|
-
Use `--offline` for local allocation when the coordinator is unavailable.
|
|
98
|
+
Use `--offline` for local allocation when the coordinator is unavailable. With a coordinator,
|
|
99
|
+
new tickets say `status: orchestrator`: their progress and closure are its record.
|
|
100
|
+
`list` runs `coordinator.status`, if it is set, to show where they stand (`--offline` does
|
|
101
|
+
not), and `claim`, `done` and the live statuses are refused. Both commands run code the
|
|
102
|
+
repository names, so use them in repositories you trust. Commit
|
|
90
103
|
ticket changes through your usual Git workflow.
|
|
91
104
|
|
|
105
|
+
## Install the skills in your agent
|
|
106
|
+
|
|
107
|
+
For Claude Code, run `/plugin marketplace add immediately-run/dibber` and then
|
|
108
|
+
`/plugin install dibber@dibber`. Recent versions also support
|
|
109
|
+
`/plugin install dibber --marketplace immediately-run/dibber`.
|
|
110
|
+
|
|
111
|
+
For Codex, add the repository as a plugin marketplace and install Dibber:
|
|
112
|
+
|
|
113
|
+
```sh
|
|
114
|
+
codex plugin marketplace add immediately-run/dibber
|
|
115
|
+
codex plugin add dibber@dibber
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
For opencode or Antigravity, use the cross-harness installer:
|
|
119
|
+
|
|
120
|
+
```sh
|
|
121
|
+
npx skills add immediately-run/dibber --global --agent opencode antigravity
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Run `dibber init` inside a repository to set up its ticket store.
|
|
125
|
+
|
|
92
126
|
## Readers
|
|
93
127
|
|
|
94
|
-
Baton
|
|
95
|
-
reads
|
|
128
|
+
[Baton's Markdown source](https://github.com/immediately-run/baton/blob/main/spec/BATON_SPEC/04-tickets-syncs-board.md#sec-4-2)
|
|
129
|
+
reads tickets to coordinate work. [Dibber Board](https://github.com/immediately-run/dibber-board/blob/main/src/components/roadmapLib.ts)
|
|
130
|
+
renders ticket stores as a wiki with a read-only board. See the [format's Readers section](SPEC.md#readers).
|
|
96
131
|
|
|
97
132
|
## Changing the format
|
|
98
133
|
|
|
99
|
-
By pull request against `SPEC.md`.
|
|
100
|
-
|
|
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).
|
|
101
136
|
|
|
102
137
|
## Licence
|
|
103
138
|
|
package/SPEC.md
CHANGED
|
@@ -32,10 +32,10 @@ ticket file.
|
|
|
32
32
|
- **R-DIB-1 (a folder of files, one per ticket).** A Dibber store is one folder in a git
|
|
33
33
|
repository: `tickets/` by convention, or the folder the repository's settings name
|
|
34
34
|
([R-DIB-14](#1-the-store)).
|
|
35
|
-
Every `*.md` or `*.mdx` file under it, at any depth, whose frontmatter carries
|
|
36
|
-
`
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
Every `*.md` or `*.mdx` file under it, at any depth, whose frontmatter carries `id` and
|
|
36
|
+
`status` and omits `page` is a ticket. A page may give its role with `page` (`project`,
|
|
37
|
+
`goal`, `doc`, `view`, and so on). An entry with an `id` must have either a ticket's
|
|
38
|
+
`status` or a page marker. A
|
|
39
39
|
ticket is one file, named after its id: `<id>.md`, or `<id>.mdx` (read alike) in a store
|
|
40
40
|
rendered as MDX ([R-DIB-13](#7-a-store-that-is-also-a-wiki)). Plain `.md` is the default,
|
|
41
41
|
since a stray `<` or `{` in prose does not compile as MDX.
|
|
@@ -75,6 +75,16 @@ ticket file.
|
|
|
75
75
|
`.dibber/config.json` as an executable followed by its arguments. The writer runs it
|
|
76
76
|
from the repository root, expands `<prefix>` in each argument, and takes the decimal
|
|
77
77
|
number from the final line of stdout. An explicit offline mode uses local allocation.
|
|
78
|
+
It may also configure `coordinator.status`, an executable and its arguments that say where
|
|
79
|
+
tickets stand. A reader runs it from the repository root with one argument per ticket id,
|
|
80
|
+
in place of an argument `<ids>` or else at the end. It prints one JSON object:
|
|
81
|
+
`{"tickets": {"<id>": {"state": "<word>", "closed": <boolean>, "reason": "<one line>"}}}`.
|
|
82
|
+
`state` is the coordinator's own word, and `ready` is the one a reader gives a meaning to:
|
|
83
|
+
the coordinator would hand the ticket out now. `closed` says the coordinator finished it.
|
|
84
|
+
A ticket the answer leaves out has no known state. The answer is data: a reader shows it
|
|
85
|
+
and takes nothing else from it. Both commands run code the repository names, so a reader
|
|
86
|
+
runs them only in a repository its user trusts, and always offers a way not to
|
|
87
|
+
(`dibber list --offline`).
|
|
78
88
|
- **Across repositories.** `<repository>:<id>` (`baton:B-111`) names a ticket in another
|
|
79
89
|
repository's store; an unqualified id is always the store's own. What a repository name
|
|
80
90
|
resolves to is the reader's configuration.
|
|
@@ -89,11 +99,12 @@ ticket file.
|
|
|
89
99
|
|---|---|---|
|
|
90
100
|
| `id` | an id ([R-DIB-4](#2-ids)) | the ticket; the file is named after it |
|
|
91
101
|
| `title` | text | its title, conventionally `<id> — <what>` |
|
|
92
|
-
| `status` | a status ([R-DIB-6](#3-frontmatter)) | live, done or withdrawn |
|
|
102
|
+
| `status` | a status ([R-DIB-6](#3-frontmatter)) | live, coordinated, done or withdrawn |
|
|
93
103
|
| `description` | text | one paragraph, what and why, for a list or a search |
|
|
94
104
|
| `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
105
|
| `parent` | a local id | the ticket this one is a child of ([R-DIB-8](#4-relations)) |
|
|
96
106
|
| `order` | a number | rank among ready tickets, lower first |
|
|
107
|
+
| `type` | `task`, `bug`, `feature`, `epic`, or `chore` | the kind of work |
|
|
97
108
|
| `tags` | a list of words | free labels ([R-DIB-9](#5-tags-and-projects)) |
|
|
98
109
|
| `project` | a project page's name | the project the ticket belongs with ([R-DIB-10](#5-tags-and-projects)) |
|
|
99
110
|
| `repos` | a list of repositories | the other repositories its work changes, `owner/name` or a name the reader maps |
|
|
@@ -101,24 +112,33 @@ ticket file.
|
|
|
101
112
|
| `assignee` | a name or handle | who says they are working on it: advisory, never a lock ([Coordination state](#coordination-state)) |
|
|
102
113
|
| `updated` | a date | when the ticket last changed in substance |
|
|
103
114
|
| `not_before` | a date or time | the earliest it should be started |
|
|
104
|
-
|
|
115
|
+
|
|
116
|
+
A store can define its own `priority` in `item.schema.json`. The shared queue rank is `order`.
|
|
105
117
|
|
|
106
118
|
**Other keys.** A key that only one tool gives a meaning to (a coordinator's workflow name, a
|
|
107
119
|
wiki's layout) is that tool's, documented in its own specification. Dibber does not list them,
|
|
108
120
|
and a reader that does not know one ignores it.
|
|
109
121
|
|
|
110
122
|
- **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.
|
|
123
|
+
for readers that keep no state of their own. Importers translate source tracker statuses to
|
|
124
|
+
these canonical values. Its values, in four classes:
|
|
112
125
|
|
|
113
126
|
| Class | Values |
|
|
114
127
|
|---|---|
|
|
115
128
|
| live | `available` (ready to be taken), `in-progress`, `in-review`, `deprioritized` |
|
|
129
|
+
| coordinated | `orchestrator` (live; its progress is a coordinator's record) |
|
|
116
130
|
| closed, done | `done` |
|
|
117
131
|
| closed, withdrawn | `withdrawn`, `superseded` (another ticket replaces it), `deferred` (not now, maybe never) |
|
|
118
132
|
|
|
119
133
|
A coordinator that tracks a ticket's progress itself may weigh `status` as evidence rather than
|
|
120
134
|
take it as its own record; how it does is the coordinator's to specify.
|
|
121
135
|
|
|
136
|
+
**`orchestrator`** says to ask the coordinator. It is valid only in a store whose
|
|
137
|
+
`.dibber/config.json` names a coordinator ([R-DIB-4](#2-ids)).
|
|
138
|
+
- It stays when the coordinator finishes the ticket: closure is then the coordinator's
|
|
139
|
+
record alone, and no tool writes `done` or a live status over it.
|
|
140
|
+
- Withdrawal stays the store's word: `withdrawn`, `superseded` or `deferred` may replace it.
|
|
141
|
+
|
|
122
142
|
## 4. Relations
|
|
123
143
|
|
|
124
144
|
- **R-DIB-7 (one file, one writer).** A change to a ticket changes its own file alone:
|
|
@@ -129,7 +149,9 @@ ticket file.
|
|
|
129
149
|
- **R-DIB-8 (dependencies and children).** `depends_on` is the ticket's whole list of waits on
|
|
130
150
|
other tickets: a dependency written only in prose is one no reader can see. A ticket is ready
|
|
131
151
|
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
|
|
152
|
+
ticket's work goes on in the ticket that replaced it, so it no longer holds anyone. A ticket
|
|
153
|
+
that is `orchestrator` is ready only when its coordinator says so, and is never ready to a reader
|
|
154
|
+
that cannot ask; a dependency on one holds until the coordinator says it is closed. A
|
|
133
155
|
`withdrawn` or `deferred` dependency still holds the ticket, since nothing did that work; drop
|
|
134
156
|
it from `depends_on`, or depend on what replaced it. A dependency on
|
|
135
157
|
another repository's ticket is a qualified id; `parent` is always local. A ticket is a child of
|
|
@@ -140,7 +162,7 @@ ticket file.
|
|
|
140
162
|
|
|
141
163
|
- **R-DIB-9 (tags).** Tags are free words. A reader may give some of them a meaning of its own,
|
|
142
164
|
documented in its specification; every other tag is the repository's.
|
|
143
|
-
- **R-DIB-10 (projects).** A project is a page whose frontmatter says `
|
|
165
|
+
- **R-DIB-10 (projects).** A project is a page whose frontmatter says `page: project`, in the
|
|
144
166
|
store's `projects/` folder by convention; a ticket's `project` names it by its `id`. A project groups tickets for
|
|
145
167
|
people: it is not a ticket and holds no state.
|
|
146
168
|
|
|
@@ -169,9 +191,8 @@ ticket file.
|
|
|
169
191
|
## 7. A store that is also a wiki
|
|
170
192
|
|
|
171
193
|
- **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.
|
|
194
|
+
layout, a site descriptor, project pages and views such as a board. Readers identify
|
|
195
|
+
these pages by [R-DIB-1](#1-the-store).
|
|
175
196
|
|
|
176
197
|
## Coordination state
|
|
177
198
|
|
|
@@ -192,28 +213,26 @@ record.
|
|
|
192
213
|
|
|
193
214
|
## Versions
|
|
194
215
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
store moves to
|
|
216
|
+
During active development, this specification changes in place. A change that breaks
|
|
217
|
+
existing stores ships with a `dibber migrate` step.
|
|
218
|
+
|
|
219
|
+
A coordinated store moves to `orchestrator` with `dibber migrate --to-orchestrator`, which
|
|
220
|
+
changes the status line of every live ticket and leaves closed ones alone.
|
|
199
221
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
valid before stays valid; a reader that took closure from the `archive/` path reads `status`
|
|
206
|
-
instead, as R-DIB-6 always said it should, and a reader that counts only `done` holds a ticket
|
|
207
|
-
on a superseded dependency longer than it need, never starting work too early.
|
|
222
|
+
Run `dibber migrate` to replace old page markers such as `kind: project` on files without
|
|
223
|
+
a status. The migration changes them to `page: project`. It moves a ticket's custom
|
|
224
|
+
`type` value outside the standard vocabulary to `legacy_type`. If the store schema
|
|
225
|
+
requires a custom `type`, update it to describe `legacy_type` before migrating.
|
|
226
|
+
Ticket paths and Markdown bodies stay in place.
|
|
208
227
|
|
|
209
228
|
## Readers
|
|
210
229
|
|
|
211
|
-
|
|
230
|
+
- **[Baton](https://github.com/immediately-run/baton/blob/main/spec/BATON_SPEC/04-tickets-syncs-board.md#sec-4-2)**
|
|
231
|
+
coordinates work and imports ticket metadata through its default Markdown source.
|
|
232
|
+
- **[Dibber Board](https://github.com/immediately-run/dibber-board/blob/main/src/components/roadmapLib.ts)**
|
|
233
|
+
reads ticket frontmatter and renders a read-only board, ticket views and project views
|
|
234
|
+
on the [Grove wiki shell](https://github.com/immediately-run/grove/blob/main/src/GroveWiki.tsx).
|
|
235
|
+
Edits go through the repository.
|
|
212
236
|
|
|
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)).
|
|
237
|
+
[Fieldhouse's ticket schema](https://github.com/immediately-run/fieldhouse/blob/main/tickets/item.schema.json)
|
|
238
|
+
shows a project using store-specific ticket fields.
|
package/config.schema.json
CHANGED
|
@@ -31,6 +31,12 @@
|
|
|
31
31
|
"minItems": 1,
|
|
32
32
|
"items": { "type": "string" },
|
|
33
33
|
"description": "Executable and arguments that print the next ticket number."
|
|
34
|
+
},
|
|
35
|
+
"status": {
|
|
36
|
+
"type": "array",
|
|
37
|
+
"minItems": 1,
|
|
38
|
+
"items": { "type": "string" },
|
|
39
|
+
"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
40
|
}
|
|
35
41
|
},
|
|
36
42
|
"additionalProperties": false
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@immediately-run/dibber",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.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",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"test": "node --test",
|
|
33
33
|
"check": "node bin/dibber.mjs check",
|
|
34
34
|
"check:release": "node scripts/check-release.mjs",
|
|
35
|
-
"version": "node scripts/check-release.mjs --sync && git add .claude-plugin",
|
|
35
|
+
"version": "node scripts/check-release.mjs --sync && git add .claude-plugin plugin.json",
|
|
36
36
|
"site": "node scripts/build-site.mjs"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
@@ -40,6 +40,14 @@
|
|
|
40
40
|
"csv-parse": "^7.0.3",
|
|
41
41
|
"yaml": "^2.8.1"
|
|
42
42
|
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"@immediately-run/sdk": ">=0.98.0"
|
|
45
|
+
},
|
|
46
|
+
"peerDependenciesMeta": {
|
|
47
|
+
"@immediately-run/sdk": {
|
|
48
|
+
"optional": true
|
|
49
|
+
}
|
|
50
|
+
},
|
|
43
51
|
"publishConfig": {
|
|
44
52
|
"access": "public"
|
|
45
53
|
}
|
|
@@ -48,7 +48,9 @@ https://github.com/immediately-run/dibber/blob/main/SPEC.md
|
|
|
48
48
|
## Without the command-line tool
|
|
49
49
|
|
|
50
50
|
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.
|
|
51
|
+
number in `tickets/`, at any depth, closed tickets included. In a store whose
|
|
52
|
+
`.dibber/config.json` names a coordinator, take the number from it and write
|
|
53
|
+
`status: orchestrator`. Use this shape, then run `dibber check` if you can:
|
|
52
54
|
|
|
53
55
|
```markdown
|
|
54
56
|
---
|
|
@@ -18,6 +18,8 @@ Lead with the answer to what was asked, in plain words. Then, briefly:
|
|
|
18
18
|
- **In progress / in review:** with `assignee` if set.
|
|
19
19
|
- **Waiting:** each ticket and what it waits on (another ticket, or another repository's).
|
|
20
20
|
- **Parked:** `deprioritized`, in one line.
|
|
21
|
+
- **Coordinated:** `orchestrator`, with the coordinator's state and reason where `dibber list`
|
|
22
|
+
shows them; without them, say that the coordinator holds where they stand.
|
|
21
23
|
- **Recently done:** only if asked, or if it helps ("3 closed this week").
|
|
22
24
|
|
|
23
25
|
Use ids and titles, never raw JSON. Five to ten lines is usually right. If the board is empty,
|
|
@@ -34,7 +36,8 @@ ticket to the user as suspicious.
|
|
|
34
36
|
## Without the command-line tool
|
|
35
37
|
|
|
36
38
|
Read the frontmatter of every `*.md` and `*.mdx` file under `tickets/`. A file is a ticket if it
|
|
37
|
-
has an `id` and
|
|
39
|
+
has an `id` and `status` and omits `page`. Whether it is open or closed is its `status`, one
|
|
38
40
|
of available, in-progress, in-review, deprioritized (live) or done, withdrawn,
|
|
39
|
-
superseded, deferred (closed)
|
|
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
|
|
40
43
|
`depends_on` is done or superseded.
|
|
@@ -16,7 +16,10 @@ Every command takes `--json`.
|
|
|
16
16
|
waiting and on what (`dibber list`), and stop.
|
|
17
17
|
2. **Read the whole ticket file**, then the code it touches. If the ticket is unclear or seems
|
|
18
18
|
wrong, ask the user before building. Don't guess.
|
|
19
|
-
3. **Claim it:**
|
|
19
|
+
3. **Claim it:** a ticket that says `status: orchestrator` is claimed, finished and closed
|
|
20
|
+
through the repository's coordinator (such as Baton), never with `dibber claim` or `done`:
|
|
21
|
+
follow the repository's own instructions for it, and if there are none, ask. Otherwise:
|
|
22
|
+
`dibber claim <id>`. This sets `in-progress` and names the user's git identity
|
|
20
23
|
as `assignee`. A claim is a note to people, not a lock.
|
|
21
24
|
4. **Do the work** on a branch, as you would for any request. Keep to the ticket's scope. If
|
|
22
25
|
you find more work, file it as a new ticket (the `dibber-new-ticket` skill) rather than
|
package/src/check.mjs
CHANGED
|
@@ -10,9 +10,13 @@ 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 { readStore, rel, CLOSED, STATUSES, COORDINATED, hasCoordinator, 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
|
|
|
@@ -65,6 +69,14 @@ export function checkStore(root) {
|
|
|
65
69
|
}
|
|
66
70
|
}
|
|
67
71
|
|
|
72
|
+
for (const page of store.pages) {
|
|
73
|
+
if (legacyPageKind(page.meta)) {
|
|
74
|
+
warn('R-DIB-1', page.file, 'legacy kind page marker; run dibber migrate');
|
|
75
|
+
} else if (page.meta.id !== undefined && page.meta.page === undefined && page.meta.status === undefined) {
|
|
76
|
+
err('R-DIB-5', page.file, 'an entry with an id needs status for a ticket or page for a page');
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
68
80
|
for (const b of store.broken) err('R-DIB-5', b.file, `the frontmatter is not valid YAML (${b.error})`);
|
|
69
81
|
|
|
70
82
|
// Per ticket.
|
|
@@ -86,6 +98,9 @@ export function checkStore(root) {
|
|
|
86
98
|
err(rule, file, describeSchemaError(e));
|
|
87
99
|
}
|
|
88
100
|
}
|
|
101
|
+
if (meta.status === COORDINATED && !hasCoordinator(settings)) {
|
|
102
|
+
err('R-DIB-6', file, `\`status: ${COORDINATED}\` needs a \`coordinator\` in .dibber/config.json`);
|
|
103
|
+
}
|
|
89
104
|
if (validateItem && !validateItem(meta)) {
|
|
90
105
|
for (const e of validateItem.errors) err('R-DIB-3', file, `the store's item.schema.json: ${describeSchemaError(e)}`);
|
|
91
106
|
}
|
|
@@ -138,11 +153,11 @@ export function checkStore(root) {
|
|
|
138
153
|
for (const id of [...byId.keys()].sort()) visit(id, []);
|
|
139
154
|
|
|
140
155
|
// Conventions: warnings only.
|
|
141
|
-
const projects = new Set(store.pages.filter((p) => p.meta.
|
|
156
|
+
const projects = new Set(store.pages.filter((p) => (p.meta.page ?? legacyPageKind(p.meta)) === 'project').map((p) => String(p.meta.id)));
|
|
142
157
|
for (const t of store.tickets) {
|
|
143
158
|
const project = t.meta.project;
|
|
144
159
|
if (typeof project === 'string' && !projects.has(project)) {
|
|
145
|
-
warn('R-DIB-10', t.file, `\`project\` names \`${project}\`, but no page in the store has \`
|
|
160
|
+
warn('R-DIB-10', t.file, `\`project\` names \`${project}\`, but no page in the store has \`page: project\` and that id`);
|
|
146
161
|
}
|
|
147
162
|
const m = /^\*\*Depends on:\*\*\s*(.*)$/m.exec(t.body);
|
|
148
163
|
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/migrate.mjs
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// Upgrade a store in place while preserving ticket paths and bodies ([DIB-27](../tickets/DIB-27.md)).
|
|
2
|
+
import { writeFileSync } from 'node:fs';
|
|
3
|
+
import { checkStore, legacyPageKind, TICKET_SCHEMA } from './check.mjs';
|
|
4
|
+
import { splitFrontmatter, readStore, LIVE, COORDINATED, hasCoordinator } from './store.mjs';
|
|
5
|
+
import { Refusal } from './tickets.mjs';
|
|
6
|
+
|
|
7
|
+
// Only the status line changes, so a large store's migration reads as one line a ticket.
|
|
8
|
+
function toOrchestrator(store) {
|
|
9
|
+
if (!hasCoordinator(store.settings)) throw new Refusal('--to-orchestrator needs a `coordinator` in .dibber/config.json');
|
|
10
|
+
return store.tickets.filter((t) => LIVE.includes(t.meta.status)).map((entry) => {
|
|
11
|
+
const { body, raw, doc } = splitFrontmatter(entry.text);
|
|
12
|
+
const line = raw.replace(/^status:[^\r\n]*/m, `status: ${COORDINATED}`);
|
|
13
|
+
let text = entry.text.replace(raw, () => line);
|
|
14
|
+
const again = splitFrontmatter(text);
|
|
15
|
+
if (again?.meta?.status !== COORDINATED || JSON.stringify({ ...again.meta, status: 0 }) !== JSON.stringify({ ...entry.meta, status: 0 }) || again.body !== body) {
|
|
16
|
+
doc.set('status', COORDINATED);
|
|
17
|
+
text = `---\n${doc.toString({ lineWidth: 0, flowCollectionPadding: false })}---\n${body}`;
|
|
18
|
+
}
|
|
19
|
+
return { entry, text };
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function migrateStore(root, opts = {}) {
|
|
24
|
+
const store = readStore(root);
|
|
25
|
+
if (!store.exists) throw new Refusal(`there is no store at ${store.storeRel}/`);
|
|
26
|
+
const updates = opts.toOrchestrator ? toOrchestrator(store) : [];
|
|
27
|
+
|
|
28
|
+
if (!opts.toOrchestrator) for (const entry of [...store.pages, ...store.tickets]) {
|
|
29
|
+
const { doc, body, meta } = splitFrontmatter(entry.text);
|
|
30
|
+
const kind = legacyPageKind(meta);
|
|
31
|
+
if (kind !== undefined) {
|
|
32
|
+
doc.set('page', kind);
|
|
33
|
+
doc.delete('kind');
|
|
34
|
+
} else if (meta.id !== undefined && meta.status !== undefined && meta.page === undefined) {
|
|
35
|
+
if (!Object.hasOwn(meta, 'type') || TICKET_SCHEMA.properties.type.enum.includes(meta.type)) continue;
|
|
36
|
+
if (Object.hasOwn(meta, 'legacy_type')) {
|
|
37
|
+
throw new Refusal(`${entry.file} already has legacy_type; resolve the two values before migrating`);
|
|
38
|
+
}
|
|
39
|
+
doc.set('legacy_type', doc.get('type', true));
|
|
40
|
+
doc.delete('type');
|
|
41
|
+
} else continue;
|
|
42
|
+
updates.push({ entry, text: `---\n${doc.toString({ lineWidth: 0 })}---\n${body}` });
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!updates.length) return [];
|
|
46
|
+
const written = [];
|
|
47
|
+
try {
|
|
48
|
+
for (const { entry, text } of updates) {
|
|
49
|
+
written.push(entry);
|
|
50
|
+
writeFileSync(entry.path, text);
|
|
51
|
+
}
|
|
52
|
+
const { errors } = checkStore(root);
|
|
53
|
+
if (errors.length) {
|
|
54
|
+
throw new Refusal(errors.map(({ file, message }) => `${file}: ${message}`).join('\n'));
|
|
55
|
+
}
|
|
56
|
+
} catch (error) {
|
|
57
|
+
for (const entry of written) writeFileSync(entry.path, entry.text);
|
|
58
|
+
throw new Refusal(`migration failed: ${error.message}`);
|
|
59
|
+
}
|
|
60
|
+
return updates.map(({ entry }) => entry.file);
|
|
61
|
+
}
|
package/src/store.mjs
CHANGED
|
@@ -8,10 +8,12 @@ import { parseDocument } from 'yaml';
|
|
|
8
8
|
|
|
9
9
|
/** The statuses of R-DIB-6, by class. */
|
|
10
10
|
export const LIVE = ['available', 'in-progress', 'in-review', 'deprioritized'];
|
|
11
|
+
/** Live, with its progress in the coordinator's record (R-DIB-6, [DIB-35](../tickets/DIB-35.md)). */
|
|
12
|
+
export const COORDINATED = 'orchestrator';
|
|
11
13
|
export const CLOSED_DONE = ['done'];
|
|
12
14
|
export const CLOSED_WITHDRAWN = ['withdrawn', 'superseded', 'deferred'];
|
|
13
15
|
export const CLOSED = [...CLOSED_DONE, ...CLOSED_WITHDRAWN];
|
|
14
|
-
export const STATUSES = [...LIVE, ...CLOSED];
|
|
16
|
+
export const STATUSES = [...LIVE, COORDINATED, ...CLOSED];
|
|
15
17
|
|
|
16
18
|
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
19
|
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 +55,9 @@ export function readSettings(root) {
|
|
|
53
55
|
};
|
|
54
56
|
}
|
|
55
57
|
|
|
58
|
+
/** The settings name a coordinator (R-DIB-14). */
|
|
59
|
+
export const hasCoordinator = (settings) => typeof settings.raw?.coordinator === 'object' && settings.raw.coordinator !== null && !Array.isArray(settings.raw.coordinator);
|
|
60
|
+
|
|
56
61
|
function walk(dir, out = []) {
|
|
57
62
|
for (const name of readdirSync(dir).sort()) {
|
|
58
63
|
if (name === 'node_modules' || name === '.git') continue;
|
|
@@ -66,7 +71,7 @@ function walk(dir, out = []) {
|
|
|
66
71
|
|
|
67
72
|
/**
|
|
68
73
|
* Read every Markdown file under the store. A file is a ticket when its frontmatter carries an
|
|
69
|
-
* `id` and
|
|
74
|
+
* `id` and `status` without a `page` marker (R-DIB-1); a file whose frontmatter does not parse is
|
|
70
75
|
* reported as `broken`, since it cannot be told apart.
|
|
71
76
|
*/
|
|
72
77
|
export function readStore(root) {
|
|
@@ -84,7 +89,7 @@ export function readStore(root) {
|
|
|
84
89
|
continue;
|
|
85
90
|
}
|
|
86
91
|
const { meta } = parts;
|
|
87
|
-
const isTicket = meta.id !== undefined &&
|
|
92
|
+
const isTicket = meta.id !== undefined && meta.status !== undefined && meta.page === undefined;
|
|
88
93
|
const closed = CLOSED.includes(meta.status); // closure is the status alone (R-DIB-2)
|
|
89
94
|
const entry = { path, file, closed, meta, body: parts.body, text, ext: extname(path), name: basename(path, extname(path)) };
|
|
90
95
|
(isTicket ? result.tickets : result.pages).push(entry);
|
package/src/tickets.mjs
CHANGED
|
@@ -9,8 +9,9 @@ import { execFileSync } from 'node:child_process';
|
|
|
9
9
|
import { existsSync, mkdirSync, readFileSync, 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, 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
|
|
|
@@ -128,7 +129,7 @@ function extensionFields(store, entries, readerOnly = false) {
|
|
|
128
129
|
if (separator < 1) throw new Refusal('--field expects key=value');
|
|
129
130
|
const key = entry.slice(0, separator);
|
|
130
131
|
const builtIn = Object.hasOwn(TICKET_SCHEMA.properties, key);
|
|
131
|
-
if (key === 'id' || key === 'status' || key === '
|
|
132
|
+
if (key === 'id' || key === 'status' || key === 'page' || (readerOnly && builtIn)) {
|
|
132
133
|
throw new Refusal(`--field cannot write Dibber-owned key \`${key}\``);
|
|
133
134
|
}
|
|
134
135
|
if (!builtIn && !Object.hasOwn(schema?.properties ?? {}, key)
|
|
@@ -179,6 +180,10 @@ export function newTicket(root, opts) {
|
|
|
179
180
|
throw new Refusal(`cannot read --body-file: ${error.message}`);
|
|
180
181
|
}
|
|
181
182
|
}
|
|
183
|
+
const coordinated = hasCoordinator(store.settings);
|
|
184
|
+
const initial = opts.status ?? (coordinated ? COORDINATED : 'available');
|
|
185
|
+
if (![...LIVE, COORDINATED].includes(initial)) throw new Refusal(`a new ticket's status is one of ${[...LIVE, COORDINATED].join(', ')}`);
|
|
186
|
+
if (initial === COORDINATED && !coordinated) throw new Refusal(`\`${COORDINATED}\` needs a \`coordinator\` in .dibber/config.json`);
|
|
182
187
|
const id = allocateTicketId(root, store, opts);
|
|
183
188
|
const dependsOn = asList(opts.dependsOn);
|
|
184
189
|
for (const d of dependsOn) {
|
|
@@ -186,7 +191,7 @@ export function newTicket(root, opts) {
|
|
|
186
191
|
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
192
|
}
|
|
188
193
|
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:
|
|
194
|
+
let meta = { id, title: `${id} — ${opts.title}`, status: initial };
|
|
190
195
|
if (opts.description) meta.description = opts.description;
|
|
191
196
|
meta.depends_on = dependsOn;
|
|
192
197
|
if (opts.parent) meta.parent = opts.parent;
|
|
@@ -237,9 +242,17 @@ export function findTicket(store, id) {
|
|
|
237
242
|
* ticket that replaced it ([DIB-20](../tickets/DIB-20.md)). */
|
|
238
243
|
export const SATISFIES_DEPENDENCY = ['done', 'superseded'];
|
|
239
244
|
|
|
240
|
-
/**
|
|
241
|
-
|
|
245
|
+
/**
|
|
246
|
+
* Ready: live, available, and every local dependency done or superseded (R-DIB-8). A coordinated
|
|
247
|
+
* ticket is ready only when `states`, the coordinator's answers, say so; a dependency on one
|
|
248
|
+
* holds until they say it is closed.
|
|
249
|
+
*/
|
|
250
|
+
export function readiness(store, t, states = new Map()) {
|
|
242
251
|
const waits = [];
|
|
252
|
+
if (t.meta.status === COORDINATED) {
|
|
253
|
+
const s = states.get(t.meta.id);
|
|
254
|
+
return { ready: s !== undefined && !s.closed && s.state === 'ready', waits };
|
|
255
|
+
}
|
|
243
256
|
for (const d of asList(t.meta.depends_on)) {
|
|
244
257
|
if (QUALIFIED_RE.test(d)) {
|
|
245
258
|
waits.push({ id: d, why: 'in another repository' });
|
|
@@ -247,7 +260,10 @@ export function readiness(store, t) {
|
|
|
247
260
|
}
|
|
248
261
|
const dep = store.tickets.find((x) => x.meta.id === d);
|
|
249
262
|
if (!dep) waits.push({ id: d, why: 'not found' });
|
|
250
|
-
else if (
|
|
263
|
+
else if (dep.meta.status === COORDINATED) {
|
|
264
|
+
const s = states.get(d);
|
|
265
|
+
if (!s?.closed) waits.push({ id: d, why: s?.state ?? 'coordinated' });
|
|
266
|
+
} else if (!SATISFIES_DEPENDENCY.includes(dep.meta.status)) waits.push({ id: d, why: dep.meta.status });
|
|
251
267
|
}
|
|
252
268
|
return { ready: t.meta.status === 'available' && waits.length === 0, waits };
|
|
253
269
|
}
|
|
@@ -292,6 +308,9 @@ export function setStatus(root, id, status, opts = {}) {
|
|
|
292
308
|
const store = readStore(root);
|
|
293
309
|
const t = findTicket(store, id);
|
|
294
310
|
if (t.closed) throw new Refusal(`\`${id}\` is closed (\`${t.meta.status}\`); file a new ticket instead of reopening it`);
|
|
311
|
+
if (t.meta.status === COORDINATED && status !== undefined && status !== COORDINATED && !CLOSED_WITHDRAWN.includes(status)) {
|
|
312
|
+
throw new Refusal(`\`${id}\` is coordinated: its progress and closure are the coordinator's to record. The store may still say ${CLOSED_WITHDRAWN.join(', ')}`);
|
|
313
|
+
}
|
|
295
314
|
const parts = splitFrontmatter(t.text);
|
|
296
315
|
const doc = parts.doc;
|
|
297
316
|
const { fields } = extensionFields(store, opts.fields, true);
|
|
@@ -314,11 +333,19 @@ export function setStatus(root, id, status, opts = {}) {
|
|
|
314
333
|
return { id, file: t.file, status: status ?? t.meta.status };
|
|
315
334
|
}
|
|
316
335
|
|
|
336
|
+
/** Of `ids`, or of the whole store, the coordinated tickets' ids. */
|
|
337
|
+
function coordinatedIds(store, ids = null) {
|
|
338
|
+
return store.tickets
|
|
339
|
+
.filter((t) => t.meta.status === COORDINATED && ID_RE.test(String(t.meta.id)) && (ids === null || ids.includes(t.meta.id)))
|
|
340
|
+
.map((t) => t.meta.id);
|
|
341
|
+
}
|
|
342
|
+
|
|
317
343
|
/** Claim: available → in-progress, with an advisory assignee. Refuses a ticket that is not ready. */
|
|
318
344
|
export function claim(root, id, opts = {}) {
|
|
319
345
|
const store = readStore(root);
|
|
320
346
|
const t = findTicket(store, id);
|
|
321
|
-
|
|
347
|
+
if (t.meta.status === COORDINATED) throw new Refusal(`\`${id}\` is coordinated; claim it through the coordinator`);
|
|
348
|
+
const { ready, waits } = readiness(store, t, coordinatorStates(root, store, coordinatedIds(store, asList(t.meta.depends_on))).states);
|
|
322
349
|
if (!ready && !opts.force) {
|
|
323
350
|
if (t.meta.status !== 'available') throw new Refusal(`\`${id}\` is \`${t.meta.status}\`, not available`);
|
|
324
351
|
throw new Refusal(`\`${id}\` waits on ${waits.map((w) => `${w.id} (${w.why})`).join(', ')}; pass --force to claim it anyway`);
|
|
@@ -330,11 +357,14 @@ export function claim(root, id, opts = {}) {
|
|
|
330
357
|
/** The overview: every ticket with its readiness, in reading order. */
|
|
331
358
|
export function listTickets(root, filter = {}) {
|
|
332
359
|
const store = readStore(root);
|
|
360
|
+
const { states, error } = filter.offline ? { states: new Map(), error: null } : coordinatorStates(root, store, coordinatedIds(store));
|
|
361
|
+
if (error) filter.onError?.(error);
|
|
362
|
+
const closedNow = (t) => t.closed || (t.meta.status === COORDINATED && states.get(t.meta.id)?.closed === true);
|
|
333
363
|
const rows = store.tickets
|
|
334
|
-
.filter((t) => (filter.closed ? true : !t
|
|
364
|
+
.filter((t) => (filter.closed ? true : !closedNow(t)))
|
|
335
365
|
.sort(byOrderThenId)
|
|
336
366
|
.map((t) => {
|
|
337
|
-
const { ready, waits } = readiness(store, t);
|
|
367
|
+
const { ready, waits } = readiness(store, t, states);
|
|
338
368
|
return {
|
|
339
369
|
id: t.meta.id,
|
|
340
370
|
title: String(t.meta.title ?? ''),
|
|
@@ -347,7 +377,8 @@ export function listTickets(root, filter = {}) {
|
|
|
347
377
|
tags: asList(t.meta.tags),
|
|
348
378
|
order: t.meta.order ?? null,
|
|
349
379
|
file: t.file,
|
|
350
|
-
closed: t
|
|
380
|
+
closed: closedNow(t),
|
|
381
|
+
...(t.meta.status === COORDINATED && { coordinator: states.get(t.meta.id) ?? null }),
|
|
351
382
|
};
|
|
352
383
|
});
|
|
353
384
|
return rows.filter((r) => (!filter.ready || r.ready) && (!filter.status || r.status === filter.status));
|
package/ticket.schema.json
CHANGED
|
@@ -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
|
}
|