ticket-docket 1.0.1__tar.gz → 1.3.0__tar.gz
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.
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/PKG-INFO +27 -18
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/README.md +24 -16
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/pyproject.toml +1 -0
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/src/docket/__init__.py +1 -1
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/src/docket/cli/commands.py +33 -4
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/src/docket/cli/grammar.py +19 -10
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/src/docket/core/graph.py +109 -7
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/src/docket/core/ids.py +9 -12
- ticket_docket-1.3.0/src/docket/core/mermaid.py +269 -0
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/src/docket/core/store.py +12 -9
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/src/docket/core/ticket.py +18 -1
- ticket_docket-1.3.0/src/docket/core/titles.py +114 -0
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/src/docket/core/validate.py +30 -0
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/src/docket/server.py +29 -4
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/src/docket/templates/CLAUDE.md +16 -3
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/tests/test_cli.py +235 -53
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/tests/test_graph.py +157 -2
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/tests/test_ids.py +5 -6
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/tests/test_mermaid.py +117 -32
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/tests/test_server.py +121 -20
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/tests/test_store.py +41 -17
- ticket_docket-1.3.0/tests/test_titles.py +137 -0
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/tests/test_validate.py +49 -0
- ticket_docket-1.0.1/src/docket/core/mermaid.py +0 -164
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/.gitignore +0 -0
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/LICENSE +0 -0
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/scripts/bumpVersion.py +0 -0
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/src/docket/cli/__init__.py +0 -0
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/src/docket/cli/__main__.py +0 -0
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/src/docket/cli/output.py +0 -0
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/src/docket/core/__init__.py +0 -0
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/src/docket/core/atomic.py +0 -0
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/src/docket/core/config.py +0 -0
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/src/docket/core/deploy.py +0 -0
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/src/docket/core/errors.py +0 -0
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/src/docket/core/fields.py +0 -0
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/src/docket/core/inputs.py +0 -0
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/src/docket/core/lock.py +0 -0
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/src/docket/py.typed +0 -0
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/src/docket/templates/docket.toml +0 -0
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/tests/concurrencyWorker.py +0 -0
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/tests/conftest.py +0 -0
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/tests/test_atomic.py +0 -0
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/tests/test_bumpVersion.py +0 -0
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/tests/test_concurrency.py +0 -0
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/tests/test_config.py +0 -0
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/tests/test_deploy.py +0 -0
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/tests/test_inputs.py +0 -0
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/tests/test_lock.py +0 -0
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/tests/test_packaging.py +0 -0
- {ticket_docket-1.0.1 → ticket_docket-1.3.0}/tests/test_ticket.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: ticket-docket
|
|
3
|
-
Version: 1.0
|
|
3
|
+
Version: 1.3.0
|
|
4
4
|
Summary: A per-repo ticketing system that is plain markdown for humans and structured MCP for agents
|
|
5
5
|
Project-URL: Homepage, https://github.com/Sorcerio/Docket
|
|
6
6
|
Project-URL: Repository, https://github.com/Sorcerio/Docket
|
|
@@ -25,19 +25,21 @@ Requires-Dist: mcp<3,>=2
|
|
|
25
25
|
Requires-Dist: pyyaml>=6.0.3
|
|
26
26
|
Requires-Dist: rich-argparse>=1.8.0
|
|
27
27
|
Requires-Dist: rich>=15.0.0
|
|
28
|
+
Requires-Dist: textcase>=0.4.5
|
|
28
29
|
Requires-Dist: tomlkit>=0.15.1
|
|
29
30
|
Description-Content-Type: text/markdown
|
|
30
31
|
|
|
31
32
|
# docket
|
|
32
33
|
|
|
34
|
+

|
|
35
|
+
|
|
33
36
|
[](https://github.com/Sorcerio/Docket/actions/workflows/test.yml)
|
|
34
37
|
[](https://pypi.org/project/ticket-docket/)
|
|
35
38
|
|
|
36
39
|
Markdown tickets that live in your repo. You read them in a text editor or CLI. Your agent reads them over MCP.
|
|
37
40
|
|
|
38
|
-

|
|
39
|
-
|
|
40
41
|
* [docket](#docket)
|
|
42
|
+
* [Demo](#demo)
|
|
41
43
|
* [Start Here](#start-here)
|
|
42
44
|
* [A Ticket](#a-ticket)
|
|
43
45
|
* [CLI](#cli)
|
|
@@ -52,6 +54,10 @@ Markdown tickets that live in your repo. You read them in a text editor or CLI.
|
|
|
52
54
|
|
|
53
55
|
---
|
|
54
56
|
|
|
57
|
+
## Demo
|
|
58
|
+
|
|
59
|
+

|
|
60
|
+
|
|
55
61
|
## Start Here
|
|
56
62
|
|
|
57
63
|
```bash
|
|
@@ -81,7 +87,7 @@ File: `docs/tickets/todo/CORE-14_skirmishSetup.md`
|
|
|
81
87
|
```markdown
|
|
82
88
|
---
|
|
83
89
|
id: CORE-14
|
|
84
|
-
title: Skirmish
|
|
90
|
+
title: Skirmish Setup
|
|
85
91
|
status: todo
|
|
86
92
|
priority: 1
|
|
87
93
|
requires: [CORE-9, GEN-3]
|
|
@@ -94,7 +100,7 @@ Goal: a screen where the player sets up one battle and plays it.
|
|
|
94
100
|
| Field | Notes |
|
|
95
101
|
|---|---|
|
|
96
102
|
| `id` | `<KEY>-<NUM>`. Must match the filename prefix. |
|
|
97
|
-
| `title` | Free text. Changing it does not rename the file. |
|
|
103
|
+
| `title` | Free text, converted to title case on write. Changing it does not rename the file. |
|
|
98
104
|
| `status` | `todo`, `wip`, or `done`. Fixed vocabulary. |
|
|
99
105
|
| `priority` | Integer, `0` most urgent. Ceiling configurable. |
|
|
100
106
|
| `requires` | Ids this depends on. Never lists what it blocks. |
|
|
@@ -112,6 +118,7 @@ A ticket id is the command:
|
|
|
112
118
|
```bash
|
|
113
119
|
docket CORE-14 # show it, dependency context and all
|
|
114
120
|
docket CORE-14 status # bare word, for a pipe
|
|
121
|
+
docket CORE-14 ready # true or false. Every dependency done?
|
|
115
122
|
docket CORE-14 done # todo, wip, or done. The file follows
|
|
116
123
|
docket CORE-14 set [-t TEXT] [-p N] [-r A,B|none] [-ra A,B] [-rr A,B]
|
|
117
124
|
docket CORE-14 meta [KEY [VALUE]] [-c]
|
|
@@ -121,28 +128,31 @@ Everything else works on the set:
|
|
|
121
128
|
|
|
122
129
|
```bash
|
|
123
130
|
docket new CORE "Skirmish setup" [-r CORE-9,GEN-3] [-p 1] [-b TEXT]
|
|
124
|
-
docket list [-s todo] [-k CORE] [-m 2]
|
|
125
|
-
docket graph [-i CORE-14 | -k GEN] [-o FILE]
|
|
131
|
+
docket list [-s todo] [-k CORE] [-m 2] [-r]
|
|
132
|
+
docket graph [-i CORE-14 | -k GEN | -s todo] [-o FILE]
|
|
126
133
|
docket key list | add KEY "desc" [-r TEXT] | remove KEY
|
|
127
134
|
docket validate | deploy PATH | upgrade PATH
|
|
128
135
|
```
|
|
129
136
|
|
|
130
137
|
`-r` replaces the dependency list. `-ra` and `-rr` edit the one already there. Both in one call is refused.
|
|
131
138
|
|
|
139
|
+
A ticket is ready when every id in its `requires` names a ticket that is `done`. A missing dependency blocks, and a `done` ticket is never ready, so `docket list -r` is the set you can pick up right now.
|
|
140
|
+
|
|
132
141
|
Every short flag has a long form (`-k/--key`, `-p/--priority`, `-m/--priority-max`, and so on). `--help` lists your actual keys and priority range.
|
|
133
142
|
|
|
134
143
|
## MCP
|
|
135
144
|
|
|
136
|
-
`docket-mcp` is a stdio server.
|
|
145
|
+
`docket-mcp` is a stdio server. Eleven tools, each returning JSON as text.
|
|
137
146
|
|
|
138
147
|
| Tool | Purpose |
|
|
139
148
|
|---|---|
|
|
140
149
|
| `list_tickets(status?, key?, priority_max?)` | Summaries only, never bodies. |
|
|
141
150
|
| `read_ticket(id)` | Full body plus both dependency directions. |
|
|
151
|
+
| `check_ready(id)` | Whether every dependency is done, and what is blocking. |
|
|
142
152
|
| `create_ticket(key, title, body?, requires?, priority?)` | Allocates the id, writes the file. |
|
|
143
153
|
| `update_ticket(id, title?, priority?, requires?, requires_add?, requires_remove?)` | Those three fields only. |
|
|
144
154
|
| `set_status(id, status)` | Writes frontmatter and moves the file together. |
|
|
145
|
-
| `graph(id?, key?)` | Mermaid source. |
|
|
155
|
+
| `graph(id?, key?, status?)` | Mermaid source. |
|
|
146
156
|
| `list_keys()` | The registered keys. |
|
|
147
157
|
| `add_key(key, description, rationale)` | After the agent has asked the user. |
|
|
148
158
|
| `validate()` | Structured findings. |
|
|
@@ -189,15 +199,14 @@ Config value `lockTimeout` is how long a process waits before giving up. Hitting
|
|
|
189
199
|
|
|
190
200
|
## Validation
|
|
191
201
|
|
|
192
|
-
`docket validate`
|
|
193
|
-
|
|
194
|
-
- A `requires` entry naming an id that does not exist, or a dependency cycle
|
|
195
|
-
- Two tickets sharing an id, or an unregistered key
|
|
196
|
-
- An id disagreeing with its filename prefix, or a status disagreeing with its directory
|
|
197
|
-
- A priority outside the band, or a status outside the vocabulary
|
|
198
|
-
- A file under a status directory that cannot be read as a ticket
|
|
202
|
+
`docket validate` presents an error or warning when:
|
|
199
203
|
|
|
200
|
-
|
|
204
|
+
- A `requires` entry naming an id that does not exist, or a dependency cycle.
|
|
205
|
+
- Two tickets sharing an id, or an unregistered key.
|
|
206
|
+
- An id disagreeing with its filename prefix, or a status disagreeing with its directory.
|
|
207
|
+
- A priority outside the band, or a status outside the vocabulary.
|
|
208
|
+
- A file under a status directory that cannot be read as a ticket.
|
|
209
|
+
- A ticket's title is not in the valid title format.
|
|
201
210
|
|
|
202
211
|
## Docket Runs on Docket
|
|
203
212
|
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
# docket
|
|
2
2
|
|
|
3
|
+

|
|
4
|
+
|
|
3
5
|
[](https://github.com/Sorcerio/Docket/actions/workflows/test.yml)
|
|
4
6
|
[](https://pypi.org/project/ticket-docket/)
|
|
5
7
|
|
|
6
8
|
Markdown tickets that live in your repo. You read them in a text editor or CLI. Your agent reads them over MCP.
|
|
7
9
|
|
|
8
|
-

|
|
9
|
-
|
|
10
10
|
* [docket](#docket)
|
|
11
|
+
* [Demo](#demo)
|
|
11
12
|
* [Start Here](#start-here)
|
|
12
13
|
* [A Ticket](#a-ticket)
|
|
13
14
|
* [CLI](#cli)
|
|
@@ -22,6 +23,10 @@ Markdown tickets that live in your repo. You read them in a text editor or CLI.
|
|
|
22
23
|
|
|
23
24
|
---
|
|
24
25
|
|
|
26
|
+
## Demo
|
|
27
|
+
|
|
28
|
+

|
|
29
|
+
|
|
25
30
|
## Start Here
|
|
26
31
|
|
|
27
32
|
```bash
|
|
@@ -51,7 +56,7 @@ File: `docs/tickets/todo/CORE-14_skirmishSetup.md`
|
|
|
51
56
|
```markdown
|
|
52
57
|
---
|
|
53
58
|
id: CORE-14
|
|
54
|
-
title: Skirmish
|
|
59
|
+
title: Skirmish Setup
|
|
55
60
|
status: todo
|
|
56
61
|
priority: 1
|
|
57
62
|
requires: [CORE-9, GEN-3]
|
|
@@ -64,7 +69,7 @@ Goal: a screen where the player sets up one battle and plays it.
|
|
|
64
69
|
| Field | Notes |
|
|
65
70
|
|---|---|
|
|
66
71
|
| `id` | `<KEY>-<NUM>`. Must match the filename prefix. |
|
|
67
|
-
| `title` | Free text. Changing it does not rename the file. |
|
|
72
|
+
| `title` | Free text, converted to title case on write. Changing it does not rename the file. |
|
|
68
73
|
| `status` | `todo`, `wip`, or `done`. Fixed vocabulary. |
|
|
69
74
|
| `priority` | Integer, `0` most urgent. Ceiling configurable. |
|
|
70
75
|
| `requires` | Ids this depends on. Never lists what it blocks. |
|
|
@@ -82,6 +87,7 @@ A ticket id is the command:
|
|
|
82
87
|
```bash
|
|
83
88
|
docket CORE-14 # show it, dependency context and all
|
|
84
89
|
docket CORE-14 status # bare word, for a pipe
|
|
90
|
+
docket CORE-14 ready # true or false. Every dependency done?
|
|
85
91
|
docket CORE-14 done # todo, wip, or done. The file follows
|
|
86
92
|
docket CORE-14 set [-t TEXT] [-p N] [-r A,B|none] [-ra A,B] [-rr A,B]
|
|
87
93
|
docket CORE-14 meta [KEY [VALUE]] [-c]
|
|
@@ -91,28 +97,31 @@ Everything else works on the set:
|
|
|
91
97
|
|
|
92
98
|
```bash
|
|
93
99
|
docket new CORE "Skirmish setup" [-r CORE-9,GEN-3] [-p 1] [-b TEXT]
|
|
94
|
-
docket list [-s todo] [-k CORE] [-m 2]
|
|
95
|
-
docket graph [-i CORE-14 | -k GEN] [-o FILE]
|
|
100
|
+
docket list [-s todo] [-k CORE] [-m 2] [-r]
|
|
101
|
+
docket graph [-i CORE-14 | -k GEN | -s todo] [-o FILE]
|
|
96
102
|
docket key list | add KEY "desc" [-r TEXT] | remove KEY
|
|
97
103
|
docket validate | deploy PATH | upgrade PATH
|
|
98
104
|
```
|
|
99
105
|
|
|
100
106
|
`-r` replaces the dependency list. `-ra` and `-rr` edit the one already there. Both in one call is refused.
|
|
101
107
|
|
|
108
|
+
A ticket is ready when every id in its `requires` names a ticket that is `done`. A missing dependency blocks, and a `done` ticket is never ready, so `docket list -r` is the set you can pick up right now.
|
|
109
|
+
|
|
102
110
|
Every short flag has a long form (`-k/--key`, `-p/--priority`, `-m/--priority-max`, and so on). `--help` lists your actual keys and priority range.
|
|
103
111
|
|
|
104
112
|
## MCP
|
|
105
113
|
|
|
106
|
-
`docket-mcp` is a stdio server.
|
|
114
|
+
`docket-mcp` is a stdio server. Eleven tools, each returning JSON as text.
|
|
107
115
|
|
|
108
116
|
| Tool | Purpose |
|
|
109
117
|
|---|---|
|
|
110
118
|
| `list_tickets(status?, key?, priority_max?)` | Summaries only, never bodies. |
|
|
111
119
|
| `read_ticket(id)` | Full body plus both dependency directions. |
|
|
120
|
+
| `check_ready(id)` | Whether every dependency is done, and what is blocking. |
|
|
112
121
|
| `create_ticket(key, title, body?, requires?, priority?)` | Allocates the id, writes the file. |
|
|
113
122
|
| `update_ticket(id, title?, priority?, requires?, requires_add?, requires_remove?)` | Those three fields only. |
|
|
114
123
|
| `set_status(id, status)` | Writes frontmatter and moves the file together. |
|
|
115
|
-
| `graph(id?, key?)` | Mermaid source. |
|
|
124
|
+
| `graph(id?, key?, status?)` | Mermaid source. |
|
|
116
125
|
| `list_keys()` | The registered keys. |
|
|
117
126
|
| `add_key(key, description, rationale)` | After the agent has asked the user. |
|
|
118
127
|
| `validate()` | Structured findings. |
|
|
@@ -159,15 +168,14 @@ Config value `lockTimeout` is how long a process waits before giving up. Hitting
|
|
|
159
168
|
|
|
160
169
|
## Validation
|
|
161
170
|
|
|
162
|
-
`docket validate`
|
|
163
|
-
|
|
164
|
-
- A `requires` entry naming an id that does not exist, or a dependency cycle
|
|
165
|
-
- Two tickets sharing an id, or an unregistered key
|
|
166
|
-
- An id disagreeing with its filename prefix, or a status disagreeing with its directory
|
|
167
|
-
- A priority outside the band, or a status outside the vocabulary
|
|
168
|
-
- A file under a status directory that cannot be read as a ticket
|
|
171
|
+
`docket validate` presents an error or warning when:
|
|
169
172
|
|
|
170
|
-
|
|
173
|
+
- A `requires` entry naming an id that does not exist, or a dependency cycle.
|
|
174
|
+
- Two tickets sharing an id, or an unregistered key.
|
|
175
|
+
- An id disagreeing with its filename prefix, or a status disagreeing with its directory.
|
|
176
|
+
- A priority outside the band, or a status outside the vocabulary.
|
|
177
|
+
- A file under a status directory that cannot be read as a ticket.
|
|
178
|
+
- A ticket's title is not in the valid title format.
|
|
171
179
|
|
|
172
180
|
## Docket Runs on Docket
|
|
173
181
|
|
|
@@ -18,7 +18,7 @@ from docket.cli.grammar import EXIT_INVALID, EXIT_OK, EXIT_USAGE, OUT_ARGUMENT,
|
|
|
18
18
|
from docket.cli.output import STATUS_STYLES, Output, buildContextTable, relativeToRoot
|
|
19
19
|
from docket.core.config import Config
|
|
20
20
|
from docket.core.deploy import DeployReport, deploy, upgrade
|
|
21
|
-
from docket.core.graph import ResolvedGraph, dependencyContext, resolveGraph, subgraphForId, subgraphForKey
|
|
21
|
+
from docket.core.graph import Readiness, ResolvedGraph, dependencyContext, readyTickets, resolveGraph, subgraphForId, subgraphForKey, subgraphForStatus, ticketReadiness
|
|
22
22
|
from docket.core.inputs import requireWritableFile, writeFile
|
|
23
23
|
from docket.core.mermaid import renderGraph
|
|
24
24
|
from docket.core.store import Store, TicketResult, TicketSet
|
|
@@ -49,6 +49,7 @@ def commandTicket(args: argparse.Namespace, store: Store, output: Output) -> int
|
|
|
49
49
|
None: commandShow,
|
|
50
50
|
"show": commandShow,
|
|
51
51
|
"status": commandStatusRead,
|
|
52
|
+
"ready": commandReady,
|
|
52
53
|
"set": commandSet,
|
|
53
54
|
"meta": commandMeta,
|
|
54
55
|
}
|
|
@@ -133,7 +134,12 @@ def commandList(args: argparse.Namespace, store: Store, output: Output) -> int:
|
|
|
133
134
|
if key is not None:
|
|
134
135
|
store.config.requireKnownKey(key)
|
|
135
136
|
|
|
136
|
-
|
|
137
|
+
loaded: TicketSet = store.loadAll()
|
|
138
|
+
tickets: list[Ticket] = loaded.filtered(status=status, key=key, priorityMax=priorityMax)
|
|
139
|
+
|
|
140
|
+
# Readiness is judged against the whole set rather than the narrowed one, since a dependency may well have been filtered out of the listing.
|
|
141
|
+
if args.ready:
|
|
142
|
+
tickets = readyTickets(loaded, tickets)
|
|
137
143
|
|
|
138
144
|
if not tickets:
|
|
139
145
|
output.print("[dim]No tickets matched.[/dim]")
|
|
@@ -225,6 +231,26 @@ def commandStatusRead(args: argparse.Namespace, store: Store, output: Output) ->
|
|
|
225
231
|
return EXIT_OK
|
|
226
232
|
|
|
227
233
|
|
|
234
|
+
def commandReady(args: argparse.Namespace, store: Store, output: Output) -> int:
|
|
235
|
+
"""
|
|
236
|
+
Print whether a ticket's dependencies are all done, and nothing else.
|
|
237
|
+
|
|
238
|
+
This goes out raw for the same reason `status` does. What is blocking is deliberately left to `show`, which already tables both dependency directions with their statuses.
|
|
239
|
+
|
|
240
|
+
args: The parsed arguments.
|
|
241
|
+
store: The store to read from.
|
|
242
|
+
output: Where to write.
|
|
243
|
+
|
|
244
|
+
Returns the process exit code, which reports whether the question could be answered rather than what the answer was.
|
|
245
|
+
"""
|
|
246
|
+
|
|
247
|
+
readiness: Readiness = ticketReadiness(store.loadAll(), args.id)
|
|
248
|
+
|
|
249
|
+
output.raw(f"{'true' if readiness.isReady else 'false'}\n")
|
|
250
|
+
|
|
251
|
+
return EXIT_OK
|
|
252
|
+
|
|
253
|
+
|
|
228
254
|
def commandMeta(args: argparse.Namespace, store: Store, output: Output) -> int:
|
|
229
255
|
"""
|
|
230
256
|
Inspect and manage a ticket's metadata map.
|
|
@@ -299,17 +325,20 @@ def commandGraph(args: argparse.Namespace, store: Store, output: Output) -> int:
|
|
|
299
325
|
Returns the process exit code.
|
|
300
326
|
"""
|
|
301
327
|
|
|
302
|
-
ticketId, key = resolveGraphScope(args.scope, args.id, args.key)
|
|
328
|
+
ticketId, key, status = resolveGraphScope(args.scope, args.id, args.key, args.status)
|
|
303
329
|
|
|
304
330
|
graph: ResolvedGraph = resolveGraph(store.loadAll())
|
|
305
331
|
|
|
306
|
-
# Scope the graph when asked. At most one of the
|
|
332
|
+
# Scope the graph when asked. At most one of the three survives resolution.
|
|
307
333
|
if ticketId is not None:
|
|
308
334
|
graph = subgraphForId(graph, ticketId)
|
|
309
335
|
elif key is not None:
|
|
310
336
|
# For the same reason as `list`, an unregistered key here would render an empty graph rather than admitting the key does not exist.
|
|
311
337
|
store.config.requireKnownKey(key)
|
|
312
338
|
graph = subgraphForKey(graph, key)
|
|
339
|
+
elif status is not None:
|
|
340
|
+
# No equivalent check, because the vocabulary is fixed and both spellings are checked against it before they arrive. An empty result here is a true answer rather than a typo.
|
|
341
|
+
graph = subgraphForStatus(graph, status)
|
|
313
342
|
|
|
314
343
|
source: str = renderGraph(graph)
|
|
315
344
|
|
|
@@ -184,34 +184,40 @@ def resolveListFilters(tokens: list[str], status: Optional[str], key: Optional[s
|
|
|
184
184
|
return resolved[TOKEN_STATUS], resolved[TOKEN_KEY], None if ceiling is None else int(ceiling)
|
|
185
185
|
|
|
186
186
|
|
|
187
|
-
def resolveGraphScope(scope: Optional[str], ticketId: Optional[str], key: Optional[str]) -> tuple[Optional[str], Optional[str]]:
|
|
187
|
+
def resolveGraphScope(scope: Optional[str], ticketId: Optional[str], key: Optional[str], status: Optional[str]) -> tuple[Optional[str], Optional[str], Optional[str]]:
|
|
188
188
|
"""
|
|
189
189
|
Resolve the graph's scope from its bare token and its flags together.
|
|
190
190
|
|
|
191
|
-
An id and a
|
|
191
|
+
An id, a key, and a status are told apart by shape, which is what makes `docket graph CORE-14`, `docket graph GEN`, and `docket graph todo` all unambiguous. The flags stay for the explicit form, and combining the two spellings is refused, since `argparse` can enforce that the flags exclude each other but cannot reach across to a positional.
|
|
192
|
+
|
|
193
|
+
The three scopes remain exclusive rather than composing. A graph is scoped to one thing, and narrowing an already narrowed graph is what `list`'s filters are for.
|
|
192
194
|
|
|
193
195
|
scope: The bare scope token, or `None`.
|
|
194
196
|
ticketId: The id named by `--id`, or `None`.
|
|
195
197
|
key: The key named by `--key`, or `None`.
|
|
198
|
+
status: The status named by `--status`, or `None`.
|
|
196
199
|
|
|
197
|
-
Returns the resolved `(id, key)`
|
|
200
|
+
Returns the resolved `(id, key, status)` triple, at most one of which is set.
|
|
198
201
|
"""
|
|
199
202
|
|
|
200
203
|
if scope is None:
|
|
201
|
-
return ticketId, key
|
|
204
|
+
return ticketId, key, status
|
|
202
205
|
|
|
203
|
-
if ticketId is not None or key is not None:
|
|
204
|
-
raise ConflictingArgumentsError(f"'{scope}' already scopes the graph, so it cannot be combined with -i/--id or -
|
|
206
|
+
if ticketId is not None or key is not None or status is not None:
|
|
207
|
+
raise ConflictingArgumentsError(f"'{scope}' already scopes the graph, so it cannot be combined with -i/--id, -k/--key, or -s/--status.")
|
|
205
208
|
|
|
206
209
|
kind: Optional[str] = classifyToken(scope)
|
|
207
210
|
|
|
208
211
|
if kind == TOKEN_ID:
|
|
209
|
-
return scope, None
|
|
212
|
+
return scope, None, None
|
|
210
213
|
|
|
211
214
|
if kind == TOKEN_KEY:
|
|
212
|
-
return None, scope
|
|
215
|
+
return None, scope, None
|
|
216
|
+
|
|
217
|
+
if kind == TOKEN_STATUS:
|
|
218
|
+
return None, None, scope
|
|
213
219
|
|
|
214
|
-
raise InvalidArgumentError(f"Cannot read '{scope}' as a scope. Expected a ticket id, for example 'CORE-14', or a
|
|
220
|
+
raise InvalidArgumentError(f"Cannot read '{scope}' as a scope. Expected a ticket id, for example 'CORE-14', a key, or a status ({', '.join(STATUSES)}).")
|
|
215
221
|
|
|
216
222
|
|
|
217
223
|
def buildParser(config: Optional[Config] = None) -> argparse.ArgumentParser:
|
|
@@ -251,12 +257,14 @@ def buildParser(config: Optional[Config] = None) -> argparse.ArgumentParser:
|
|
|
251
257
|
listParser.add_argument("-s", "--status", choices=STATUSES, help="Keep only tickets with this status.")
|
|
252
258
|
listParser.add_argument("-k", "--key", help=f"Keep only tickets carrying this key. {keyOptions}")
|
|
253
259
|
listParser.add_argument("-m", "--priority-max", type=int, dest="priorityMax", help=f"Keep only tickets at or below this priority number. {priorityOptions}")
|
|
260
|
+
listParser.add_argument("-r", "--ready", action="store_true", help="Keep only tickets whose dependencies are all done. A done ticket is never ready, so this never shows one.")
|
|
254
261
|
|
|
255
262
|
graphParser: argparse.ArgumentParser = commands.add_parser("graph", help="Render the dependency graph as mermaid source.", formatter_class=RichHelpFormatter)
|
|
256
|
-
graphParser.add_argument("scope", nargs="?", metavar="SCOPE", help="What to scope to, read from its own shape: a ticket id, or a
|
|
263
|
+
graphParser.add_argument("scope", nargs="?", metavar="SCOPE", help=f"What to scope to, read from its own shape: a ticket id, a key, or a status ({', '.join(STATUSES)}). The flags below are the same three, named explicitly.")
|
|
257
264
|
graphScope = graphParser.add_mutually_exclusive_group()
|
|
258
265
|
graphScope.add_argument("-i", "--id", help="Scope to one ticket's ancestors and descendants.")
|
|
259
266
|
graphScope.add_argument("-k", "--key", help=f"Scope to one key, plus its immediate cross-key neighbors. {keyOptions}")
|
|
267
|
+
graphScope.add_argument("-s", "--status", choices=STATUSES, help="Scope to the tickets with this status alone. Nothing outside it is borrowed, so an edge survives only when both of its ends carry the status.")
|
|
260
268
|
graphParser.add_argument("-o", "--out", help="Write to a file rather than to stdout.")
|
|
261
269
|
|
|
262
270
|
keyParser: argparse.ArgumentParser = commands.add_parser("key", help="Inspect and manage the key registry.", formatter_class=RichHelpFormatter)
|
|
@@ -309,6 +317,7 @@ def buildTicketParser(commands: argparse._SubParsersAction, priorityOptions: str
|
|
|
309
317
|
|
|
310
318
|
ticketCommands.add_parser("show", help="Show the ticket with its resolved dependency context. This is what a bare id does.", formatter_class=RichHelpFormatter)
|
|
311
319
|
ticketCommands.add_parser("status", help="Print the ticket's status and nothing else, for a pipe to read.", formatter_class=RichHelpFormatter)
|
|
320
|
+
ticketCommands.add_parser("ready", help="Print whether every dependency is done, as a bare true or false, for a pipe to read.", formatter_class=RichHelpFormatter)
|
|
312
321
|
|
|
313
322
|
# One parser per status is what makes 'docket CORE-14 done' work. It also puts the whole vocabulary into the error when a command is misspelled, which a single `choices` list on a value argument could not do.
|
|
314
323
|
for status in STATUSES:
|
|
@@ -58,6 +58,25 @@ class Edge:
|
|
|
58
58
|
toId: str
|
|
59
59
|
|
|
60
60
|
|
|
61
|
+
@dataclass(frozen=True)
|
|
62
|
+
class Readiness:
|
|
63
|
+
"""
|
|
64
|
+
Whether one ticket can be worked on now, and what stands in the way when it cannot.
|
|
65
|
+
|
|
66
|
+
This is derived from the set on every read and never stored, for the same reason a reverse edge is. A stored answer would go stale the moment a dependency was closed.
|
|
67
|
+
"""
|
|
68
|
+
|
|
69
|
+
# MARK: Properties
|
|
70
|
+
|
|
71
|
+
id: str
|
|
72
|
+
|
|
73
|
+
# Whether every dependency is done and there is still work left to do.
|
|
74
|
+
isReady: bool
|
|
75
|
+
|
|
76
|
+
# The resolved records of everything holding this ticket back, in the same shape `dependencyContext` returns. Empty on a ticket that is itself done, since nothing is blocking it.
|
|
77
|
+
blockedBy: tuple[dict[str, object], ...] = ()
|
|
78
|
+
|
|
79
|
+
|
|
61
80
|
@dataclass
|
|
62
81
|
class ResolvedGraph:
|
|
63
82
|
"""
|
|
@@ -212,6 +231,23 @@ def subgraphForKey(graph: ResolvedGraph, key: str) -> ResolvedGraph:
|
|
|
212
231
|
return scoped
|
|
213
232
|
|
|
214
233
|
|
|
234
|
+
def subgraphForStatus(graph: ResolvedGraph, status: str) -> ResolvedGraph:
|
|
235
|
+
"""
|
|
236
|
+
Scope a graph to the tickets carrying one status, and nothing else.
|
|
237
|
+
|
|
238
|
+
Nothing is borrowed from outside, unlike the key scope. A key has a boundary worth drawing, since the work either side of it is still related, but the tickets around a status are only the same work at a different moment, so pulling them in would put every other status back on the page. An edge therefore survives only when both of its ends carry the status, which is what lets the result read as the ordering within that status alone.
|
|
239
|
+
|
|
240
|
+
graph: The graph to scope.
|
|
241
|
+
status: The status to scope to.
|
|
242
|
+
|
|
243
|
+
Returns the scoped graph.
|
|
244
|
+
"""
|
|
245
|
+
|
|
246
|
+
members: set[str] = {node.id for node in graph.nodes.values() if node.status == status}
|
|
247
|
+
|
|
248
|
+
return _restrict(graph, members, scope=status)
|
|
249
|
+
|
|
250
|
+
|
|
215
251
|
def dependencyContext(ticketSet: TicketSet, ticketId: str) -> dict[str, list[dict[str, object]]]:
|
|
216
252
|
"""
|
|
217
253
|
Resolve the context a raw ticket file deliberately does not carry.
|
|
@@ -230,14 +266,47 @@ def dependencyContext(ticketSet: TicketSet, ticketId: str) -> dict[str, list[dic
|
|
|
230
266
|
# A dependency naming a missing id still has to appear, since hiding it would make a broken link invisible to the reader.
|
|
231
267
|
requires: list[dict[str, object]] = []
|
|
232
268
|
for requiredId in ticket.requires:
|
|
233
|
-
requires.append(_contextEntry(
|
|
269
|
+
requires.append(_contextEntry(ticketSet, requiredId))
|
|
234
270
|
|
|
271
|
+
# The reverse direction is the one thing here the set alone cannot answer, which is what the graph is resolved for.
|
|
235
272
|
node: Optional[GraphNode] = graph.nodes.get(ticketId)
|
|
236
|
-
requiredBy: list[dict[str, object]] = [_contextEntry(
|
|
273
|
+
requiredBy: list[dict[str, object]] = [_contextEntry(ticketSet, dependentId) for dependentId in (node.requiredBy if node is not None else ())]
|
|
237
274
|
|
|
238
275
|
return {"requires": requires, "requiredBy": requiredBy}
|
|
239
276
|
|
|
240
277
|
|
|
278
|
+
def ticketReadiness(ticketSet: TicketSet, ticketId: str) -> Readiness:
|
|
279
|
+
"""
|
|
280
|
+
Decide whether one ticket can be worked on now.
|
|
281
|
+
|
|
282
|
+
Ready means every id in `requires` names a ticket that is done. Only the direct dependencies are consulted, because a done ticket is taken at its word. A done dependency with unfinished dependencies of its own is an inconsistency, and reporting that is `validate`'s job rather than this one's.
|
|
283
|
+
|
|
284
|
+
A dependency naming a ticket that does not exist blocks, since a link the reader cannot follow is not the same as clear road. A cycle blocks without a special case, because no ticket in one is ever done.
|
|
285
|
+
|
|
286
|
+
ticketSet: The loaded tickets.
|
|
287
|
+
ticketId: The ticket to judge.
|
|
288
|
+
|
|
289
|
+
Returns the readiness of that ticket.
|
|
290
|
+
"""
|
|
291
|
+
|
|
292
|
+
return _readinessOf(ticketSet, ticketSet.get(ticketId))
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
def readyTickets(ticketSet: TicketSet, tickets: Iterable[Ticket]) -> list[Ticket]:
|
|
296
|
+
"""
|
|
297
|
+
Select the tickets that can be worked on now, keeping the order they arrived in.
|
|
298
|
+
|
|
299
|
+
The whole set is needed to judge any one ticket, so the candidates are passed separately from the set they are judged against. That is what lets a caller filter an already narrowed listing.
|
|
300
|
+
|
|
301
|
+
ticketSet: The loaded tickets, which every dependency is looked up in.
|
|
302
|
+
tickets: The candidates to filter.
|
|
303
|
+
|
|
304
|
+
Returns the ready candidates.
|
|
305
|
+
"""
|
|
306
|
+
|
|
307
|
+
return [ticket for ticket in tickets if _readinessOf(ticketSet, ticket).isReady]
|
|
308
|
+
|
|
309
|
+
|
|
241
310
|
def findCycles(graph: ResolvedGraph) -> list[list[str]]:
|
|
242
311
|
"""
|
|
243
312
|
Find every dependency cycle, reporting one representative per strongly connected component.
|
|
@@ -312,21 +381,54 @@ def findCycles(graph: ResolvedGraph) -> list[list[str]]:
|
|
|
312
381
|
return sorted(cycles)
|
|
313
382
|
|
|
314
383
|
|
|
315
|
-
def
|
|
384
|
+
def _readinessOf(ticketSet: TicketSet, ticket: Ticket) -> Readiness:
|
|
385
|
+
"""
|
|
386
|
+
Judge one already-loaded ticket, which is what both public entry points do their work through.
|
|
387
|
+
|
|
388
|
+
ticketSet: The loaded tickets, which every dependency is looked up in.
|
|
389
|
+
ticket: The ticket to judge.
|
|
390
|
+
|
|
391
|
+
Returns the readiness of that ticket.
|
|
392
|
+
"""
|
|
393
|
+
|
|
394
|
+
# A finished ticket has no work left to be ready for, so it is not ready and nothing is holding it back.
|
|
395
|
+
if ticket.isDone:
|
|
396
|
+
return Readiness(id=ticket.id, isReady=False)
|
|
397
|
+
|
|
398
|
+
blockers: list[dict[str, object]] = [_contextEntry(ticketSet, requiredId) for requiredId in ticket.requires if not _isSatisfied(ticketSet, requiredId)]
|
|
399
|
+
|
|
400
|
+
return Readiness(id=ticket.id, isReady=not blockers, blockedBy=tuple(blockers))
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
def _isSatisfied(ticketSet: TicketSet, requiredId: str) -> bool:
|
|
404
|
+
"""
|
|
405
|
+
Report whether one dependency is met.
|
|
406
|
+
|
|
407
|
+
requiredId: The id the depending ticket names.
|
|
408
|
+
|
|
409
|
+
Returns `True` only when the id names a ticket that exists and is done.
|
|
410
|
+
"""
|
|
411
|
+
|
|
412
|
+
required: Optional[Ticket] = ticketSet.tickets.get(requiredId)
|
|
413
|
+
|
|
414
|
+
return required is not None and required.isDone
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
def _contextEntry(ticketSet: TicketSet, ticketId: str) -> dict[str, object]:
|
|
316
418
|
"""
|
|
317
419
|
Build one resolved dependency record.
|
|
318
420
|
|
|
319
|
-
|
|
421
|
+
ticketSet: The loaded tickets to look the ticket up in.
|
|
320
422
|
ticketId: The id to describe.
|
|
321
423
|
|
|
322
424
|
Returns the record, flagged when the id names nothing that exists.
|
|
323
425
|
"""
|
|
324
426
|
|
|
325
|
-
|
|
326
|
-
if
|
|
427
|
+
ticket: Optional[Ticket] = ticketSet.tickets.get(ticketId)
|
|
428
|
+
if ticket is None:
|
|
327
429
|
return {"id": ticketId, "title": None, "status": None, "priority": None, "exists": False}
|
|
328
430
|
|
|
329
|
-
return {"id":
|
|
431
|
+
return {"id": ticket.id, "title": ticket.title, "status": ticket.status, "priority": ticket.priority, "exists": True}
|
|
330
432
|
|
|
331
433
|
|
|
332
434
|
def _reachable(graph: ResolvedGraph, startId: str, forward: bool) -> set[str]:
|
|
@@ -10,6 +10,8 @@ import re
|
|
|
10
10
|
import unicodedata
|
|
11
11
|
from typing import Iterable, Optional
|
|
12
12
|
|
|
13
|
+
import textcase
|
|
14
|
+
|
|
13
15
|
from docket.core.errors import InvalidIdError, InvalidKeyError
|
|
14
16
|
|
|
15
17
|
# MARK: Constants
|
|
@@ -167,6 +169,8 @@ def slugify(title: str) -> str:
|
|
|
167
169
|
A title is untrusted input, so this works from an allowlist of characters rather than a blocklist.
|
|
168
170
|
Path separators, `..`, quotes, and control characters are discarded as a consequence of that rule rather than by explicit rejection.
|
|
169
171
|
|
|
172
|
+
The slug is cut at the cap wherever that lands, mid-word included, since the id prefix is what makes the filename unique.
|
|
173
|
+
|
|
170
174
|
title: The ticket title to convert.
|
|
171
175
|
|
|
172
176
|
Returns the slug, or `untitled` when nothing survives.
|
|
@@ -177,23 +181,16 @@ def slugify(title: str) -> str:
|
|
|
177
181
|
asciiOnly: str = normalized.encode("ascii", "ignore").decode("ascii")
|
|
178
182
|
|
|
179
183
|
# Split on every run of non-alphanumeric characters, which is what makes traversal impossible by construction.
|
|
184
|
+
# This is also what feeds the casing below a clean word list, since the runs it drops are the boundaries camel case would otherwise have to find for itself.
|
|
180
185
|
tokens: list[str] = [token for token in SLUG_SEPARATOR_PATTERN.split(asciiOnly) if token]
|
|
181
186
|
if not tokens:
|
|
182
187
|
return SLUG_FALLBACK
|
|
183
188
|
|
|
184
|
-
#
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
# Append tokens while they fit, so truncation lands on a word boundary wherever possible.
|
|
189
|
-
slug: str = ""
|
|
190
|
-
for part in parts:
|
|
191
|
-
if slug and len(slug) + len(part) > SLUG_MAX_LENGTH:
|
|
192
|
-
break
|
|
193
|
-
|
|
194
|
-
slug += part
|
|
189
|
+
# The tokens are already alphanumeric, so the split boundary is narrowed to whitespace and punctuation stripping is left off. Neither has anything left to do, and both would only risk splitting a token that survived the allowlist.
|
|
190
|
+
# An acronym like `HTTP` becomes `Http` rather than shouting, which is what camel case does to a token that is not the first.
|
|
191
|
+
slug: str = textcase.camel(" ".join(tokens), boundaries=[textcase.SPACE], strip_punctuation=False)
|
|
195
192
|
|
|
196
|
-
#
|
|
193
|
+
# Cut at the cap wherever it lands. The id prefix is what makes the filename unique, so a slug ending mid-word costs nothing.
|
|
197
194
|
return slug[:SLUG_MAX_LENGTH]
|
|
198
195
|
|
|
199
196
|
|