chewcw-work-queue 0.3.0__py3-none-any.whl
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.
- chewcw_work_queue-0.3.0.dist-info/METADATA +138 -0
- chewcw_work_queue-0.3.0.dist-info/RECORD +16 -0
- chewcw_work_queue-0.3.0.dist-info/WHEEL +5 -0
- chewcw_work_queue-0.3.0.dist-info/entry_points.txt +2 -0
- chewcw_work_queue-0.3.0.dist-info/licenses/LICENSE +21 -0
- chewcw_work_queue-0.3.0.dist-info/top_level.txt +1 -0
- work_queue/__init__.py +1 -0
- work_queue/__main__.py +5 -0
- work_queue/artefacts.py +192 -0
- work_queue/cli.py +100 -0
- work_queue/commands.py +623 -0
- work_queue/docs/pipeline.md +183 -0
- work_queue/gates.py +128 -0
- work_queue/gh.py +111 -0
- work_queue/labels.py +139 -0
- work_queue/verify.py +242 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: chewcw-work-queue
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: One script that owns every GitHub label write for the agent work queue
|
|
5
|
+
Author: chew cw
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/chewcw/skills/tree/main/dev-tools/work-queue
|
|
8
|
+
Project-URL: Repository, https://github.com/chewcw/skills
|
|
9
|
+
Project-URL: Issues, https://github.com/chewcw/skills/issues
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Classifier: Topic :: Software Development :: Bug Tracking
|
|
13
|
+
Requires-Python: >=3.9
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Dynamic: license-file
|
|
17
|
+
|
|
18
|
+
# work-queue
|
|
19
|
+
|
|
20
|
+
The one place that writes a GitHub label for the agent queue. Python 3, standard library only,
|
|
21
|
+
`gh` as the transport, no third-party dependency.
|
|
22
|
+
|
|
23
|
+
## Install
|
|
24
|
+
|
|
25
|
+
From a checkout, without installing anything:
|
|
26
|
+
|
|
27
|
+
bin/work-queue --version
|
|
28
|
+
|
|
29
|
+
As a command on `PATH`, editable, so a checkout edit takes effect immediately:
|
|
30
|
+
|
|
31
|
+
uv tool install --editable ./work-queue
|
|
32
|
+
|
|
33
|
+
From a private or public remote, with no release needed:
|
|
34
|
+
|
|
35
|
+
uv tool install "git+ssh://git@github.com/<owner>/dev-tools.git#subdirectory=work-queue"
|
|
36
|
+
|
|
37
|
+
Pin a tag or a commit when you need a fixed version. The ref goes after the repository and
|
|
38
|
+
before the fragment:
|
|
39
|
+
|
|
40
|
+
uv tool install "git+ssh://git@github.com/<owner>/dev-tools.git@work-queue-v0.2.0#subdirectory=work-queue"
|
|
41
|
+
|
|
42
|
+
`pipx install .` works the same way if you prefer pipx.
|
|
43
|
+
|
|
44
|
+
`uv tool install` writes its shim to `~/.local/bin`. If a non-interactive shell cannot find
|
|
45
|
+
`work-queue`, that directory is the reason — it has to be on `PATH`.
|
|
46
|
+
|
|
47
|
+
### Without installing anything
|
|
48
|
+
|
|
49
|
+
`uvx` runs the tool in a throwaway environment, the way `npx` does:
|
|
50
|
+
|
|
51
|
+
uvx --from "git+ssh://git@github.com/<owner>/dev-tools.git@work-queue-v0.2.0#subdirectory=work-queue" work-queue docs
|
|
52
|
+
|
|
53
|
+
It is the right form for a one-off. It is the wrong form for the queue itself, which is called
|
|
54
|
+
dozens of times per session and whose gates must not change between two calls: an unpinned `uvx`
|
|
55
|
+
gives you whatever the machine cached, so the gate that refuses a move may not be the one the
|
|
56
|
+
skill described.
|
|
57
|
+
|
|
58
|
+
The tool drives `gh`, so `gh` must be installed and authenticated. Every command that writes exits
|
|
59
|
+
2 with the reason when it is not.
|
|
60
|
+
|
|
61
|
+
## Commands
|
|
62
|
+
|
|
63
|
+
work-queue docs print the pipeline reference: labels, rules, gates
|
|
64
|
+
work-queue init create or repair the label vocabulary
|
|
65
|
+
work-queue list --stage LABEL open issues at that rung, frontier only
|
|
66
|
+
work-queue claim --stage LABEL take one item, print its artefact
|
|
67
|
+
work-queue record --issue N --artefact PATH name the file a claim produced
|
|
68
|
+
work-queue kind --issue N --to kind:bug|kind:feature|kind:task
|
|
69
|
+
work-queue move --issue N --to LABEL
|
|
70
|
+
work-queue park --issue N --to human:triage|human:info --reason TEXT
|
|
71
|
+
work-queue close --issue N --reason done|wontfix|dup|deferred
|
|
72
|
+
work-queue reopen --issue N --reason TEXT
|
|
73
|
+
work-queue icebox deferred work, one line per issue
|
|
74
|
+
work-queue verify drift, one line per finding
|
|
75
|
+
work-queue reconcile repair drift from the artefacts
|
|
76
|
+
work-queue triage --issue N context for the router; decides nothing
|
|
77
|
+
work-queue promote --file F turn an inbox capture into an issue
|
|
78
|
+
work-queue migrate --map FILE one-shot old->new label mapping
|
|
79
|
+
|
|
80
|
+
Exit codes: 0 ok, 1 refused (gate or lost claim), 2 gh missing, not authenticated, or no repo
|
|
81
|
+
resolved, 3 a label did not land or drift was found.
|
|
82
|
+
|
|
83
|
+
The vocabulary is not repeated here. `work-queue docs` is the single description of it, and it
|
|
84
|
+
ships inside the package so an installed copy can print it.
|
|
85
|
+
|
|
86
|
+
## Installing into a repo
|
|
87
|
+
|
|
88
|
+
Once per target repo:
|
|
89
|
+
|
|
90
|
+
work-queue init
|
|
91
|
+
|
|
92
|
+
Then copy `assets/triage-label.yml` to `.github/workflows/triage-label.yml` in the target repo.
|
|
93
|
+
It is the fail-closed step: every issue opened without an `agent:` or `human:` label gets
|
|
94
|
+
`human:triage`, so nothing unvetted can be built. Issues created already labelled are left alone.
|
|
95
|
+
|
|
96
|
+
## Configuration
|
|
97
|
+
|
|
98
|
+
| Variable | Default | What it changes |
|
|
99
|
+
|---|---|---|
|
|
100
|
+
| `GH_REPO` | the repo `gh` resolves | which repo is operated on |
|
|
101
|
+
| `QUEUE_MAX_ISSUES` | `800` | page size, and when the truncation warning fires |
|
|
102
|
+
| `QUEUE_SPECS_DIR` | `.ai/specs` | where spec files live |
|
|
103
|
+
| `QUEUE_PLANS_DIR` | `.ai/plans` | where plan directories live |
|
|
104
|
+
| `QUEUE_PLAN_INDEX` | `00-index.md` | the plan index filename |
|
|
105
|
+
| `QUEUE_SEAL_FILE` | `SEAL.sha256` | the seal filename |
|
|
106
|
+
| `QUEUE_SEAL_TOOL` | detected | override the sha tool used to verify a seal |
|
|
107
|
+
| `QUEUE_INBOX_DIR` | `.ai/inbox` | where un-tracked captures wait |
|
|
108
|
+
| `QUEUE_EXTRA_LABELS` | empty | comma-separated labels the repo already uses |
|
|
109
|
+
|
|
110
|
+
The seal check uses `sha256sum` when it exists and `shasum -a 256` otherwise, so a macOS machine
|
|
111
|
+
can verify a plan.
|
|
112
|
+
|
|
113
|
+
## Drift
|
|
114
|
+
|
|
115
|
+
`verify` reports V1–V12; `reconcile` repairs what needs no human judgement. A missing `kind:` is
|
|
116
|
+
reported and never guessed, because deciding what the work is takes a person.
|
|
117
|
+
|
|
118
|
+
## Testing
|
|
119
|
+
|
|
120
|
+
tests/test.sh
|
|
121
|
+
|
|
122
|
+
Self-contained: it builds a scratch repo and a fake `gh`, asserts on printed output and exit codes,
|
|
123
|
+
and touches no network. Needs `bash`, `python3` and `jq`.
|
|
124
|
+
|
|
125
|
+
## Releasing
|
|
126
|
+
|
|
127
|
+
1. Bump `__version__` in `work_queue/__init__.py`. That is the only place the version lives;
|
|
128
|
+
`pyproject.toml` reads it from there.
|
|
129
|
+
2. Commit, then tag that commit with the tool's name in front:
|
|
130
|
+
`git tag work-queue-v<version> && git push origin work-queue-v<version>`.
|
|
131
|
+
3. No release artifact is needed:
|
|
132
|
+
`pipx install "git+https://…/dev-tools.git@work-queue-v<version>#subdirectory=work-queue"`
|
|
133
|
+
resolves the tag.
|
|
134
|
+
|
|
135
|
+
Tags are per tool, never per repo: a second tool at its own `0.1.0` gets `other-tool-v0.1.0`, and
|
|
136
|
+
neither tag blocks the other. The prefix must match the tool's directory name, and the version in
|
|
137
|
+
the tag must match `__version__` — a tag is also the integrity check, because a commit cannot
|
|
138
|
+
change.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
chewcw_work_queue-0.3.0.dist-info/licenses/LICENSE,sha256=QBQwy4ElpLkIZquE7kVGN3XKYBPXMKXiRsgjT9slTNU,1064
|
|
2
|
+
work_queue/__init__.py,sha256=VrXpHDu3erkzwl_WXrqINBm9xWkcyUy53IQOj042dOs,22
|
|
3
|
+
work_queue/__main__.py,sha256=E6Gls0DNz8GQK2K-kOUIx8cYhgANW_CH54VKrfCfs14,52
|
|
4
|
+
work_queue/artefacts.py,sha256=Ceca1I4EsCava14GeZDfJ8RV51LuluVfdPLF8a7L5oU,4808
|
|
5
|
+
work_queue/cli.py,sha256=tpO4lYE_GwKuYfx4oUCx0Kww0H12VH_LFM3xxMp80KQ,3061
|
|
6
|
+
work_queue/commands.py,sha256=awBm_CG28blyPvrMWJNV5wdQW6eM1Nv5i6r-aNkkpYs,21757
|
|
7
|
+
work_queue/gates.py,sha256=qU6E_Dc1LAOdMQGas5rH96qbhpoTxS2CVTNaYG-eti4,4695
|
|
8
|
+
work_queue/gh.py,sha256=IzAyX2Qr9_6OvL6eLH3R0tZmMiKmMk38yX_OK8gj6lM,3058
|
|
9
|
+
work_queue/labels.py,sha256=SFuGTAQYBZLIfPrecJVauQ6hRh0CSXPCuihh4oFlhqY,4298
|
|
10
|
+
work_queue/verify.py,sha256=a5yz3VP6Ms0c_WSUXNu7_D4J0B1HaEsXBhB-yP7jsdg,9786
|
|
11
|
+
work_queue/docs/pipeline.md,sha256=EXRO8PRtjYoZCMSBzkUgqC68ceVuV8LUQD4_IYl63wE,12576
|
|
12
|
+
chewcw_work_queue-0.3.0.dist-info/METADATA,sha256=AuZmzCMm--sqRSLwI0jUIfKPgigcnC2G_TohmMJR6ec,5979
|
|
13
|
+
chewcw_work_queue-0.3.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
14
|
+
chewcw_work_queue-0.3.0.dist-info/entry_points.txt,sha256=3uwEqqxNT6sZQNdVi4Snq1At6eYUWHr5H7O_L4kU5fE,51
|
|
15
|
+
chewcw_work_queue-0.3.0.dist-info/top_level.txt,sha256=WlZ0vql3CH8NnOVHauWNI4qoFSsXNxolLRyuUDatX0A,11
|
|
16
|
+
chewcw_work_queue-0.3.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 chew cw
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
work_queue
|
work_queue/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.3.0"
|
work_queue/__main__.py
ADDED
work_queue/artefacts.py
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"""Readers for the files the queue keeps: specs, plans, seals, inbox captures.
|
|
2
|
+
|
|
3
|
+
The label is a cache of these files, so every path they live in is one knob.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import os
|
|
7
|
+
import shutil
|
|
8
|
+
import subprocess
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
PATHS_FILE = ".ai-paths"
|
|
13
|
+
|
|
14
|
+
# config key -> environment variable. The names `ai-path env` prints.
|
|
15
|
+
_ENV = {
|
|
16
|
+
"specs": "QUEUE_SPECS_DIR",
|
|
17
|
+
"plans": "QUEUE_PLANS_DIR",
|
|
18
|
+
"plan_index": "QUEUE_PLAN_INDEX",
|
|
19
|
+
"seal": "QUEUE_SEAL_FILE",
|
|
20
|
+
"inbox": "QUEUE_INBOX_DIR",
|
|
21
|
+
"intent": "AI_INTENT_DIR",
|
|
22
|
+
"retros": "AI_RETROS_DIR",
|
|
23
|
+
"sdd": "AI_SDD_DIR",
|
|
24
|
+
"out-of-scope": "AI_OUT_OF_SCOPE_DIR",
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _paths_file():
|
|
29
|
+
override = os.environ.get("AI_PATHS_FILE", "")
|
|
30
|
+
return Path(override).expanduser() if override else Path(PATHS_FILE)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _file_values():
|
|
34
|
+
"""`key = value` lines. A blank value is not a value."""
|
|
35
|
+
values = {}
|
|
36
|
+
try:
|
|
37
|
+
text = _paths_file().read_text()
|
|
38
|
+
except OSError:
|
|
39
|
+
return values
|
|
40
|
+
for line in text.splitlines():
|
|
41
|
+
line = line.split("#", 1)[0].strip()
|
|
42
|
+
if "=" not in line:
|
|
43
|
+
continue
|
|
44
|
+
key, value = line.split("=", 1)
|
|
45
|
+
if key.strip() and value.strip():
|
|
46
|
+
values[key.strip()] = value.strip()
|
|
47
|
+
return values
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _setting(key, default):
|
|
51
|
+
from_env = os.environ.get(_ENV.get(key, ""), "")
|
|
52
|
+
if from_env:
|
|
53
|
+
return from_env
|
|
54
|
+
return _file_values().get(key, "") or default
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def specs_dir():
|
|
58
|
+
return _setting("specs", ".ai/specs")
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def plans_dir():
|
|
62
|
+
return _setting("plans", ".ai/plans")
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def plan_index_name():
|
|
66
|
+
return _setting("plan_index", "00-index.md")
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def seal_name():
|
|
70
|
+
return _setting("seal", "SEAL.sha256")
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def inbox_dir():
|
|
74
|
+
return _setting("inbox", ".ai/inbox")
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def sdd_dir():
|
|
78
|
+
return _setting("sdd", ".ai/sdd")
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def intent_dir():
|
|
82
|
+
return _setting("intent", ".ai/intent")
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def retros_dir():
|
|
86
|
+
return _setting("retros", ".ai/retros")
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def out_of_scope_dir():
|
|
90
|
+
return _setting("out-of-scope", ".ai/out-of-scope")
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def frontmatter_field(path, key):
|
|
94
|
+
"""Value of `key` in a leading --- block, trimmed. Empty when absent."""
|
|
95
|
+
try:
|
|
96
|
+
lines = Path(path).read_text().splitlines()
|
|
97
|
+
except OSError:
|
|
98
|
+
return ""
|
|
99
|
+
if not lines or lines[0].strip() != "---":
|
|
100
|
+
return ""
|
|
101
|
+
for line in lines[1:]:
|
|
102
|
+
if line.strip() == "---":
|
|
103
|
+
break
|
|
104
|
+
if ":" not in line:
|
|
105
|
+
continue
|
|
106
|
+
name, value = line.split(":", 1)
|
|
107
|
+
if name == key:
|
|
108
|
+
return value.strip()
|
|
109
|
+
return ""
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def _numbered_files(pattern):
|
|
113
|
+
for path in sorted(Path().glob(pattern)):
|
|
114
|
+
if not path.is_file():
|
|
115
|
+
continue
|
|
116
|
+
issue = frontmatter_field(path, "issue")
|
|
117
|
+
if not issue or issue == "0":
|
|
118
|
+
continue
|
|
119
|
+
yield issue, path
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def spec_index():
|
|
123
|
+
"""(issue, path, status) for every spec file that names an issue."""
|
|
124
|
+
out = []
|
|
125
|
+
pattern = f"{specs_dir()}/*.md"
|
|
126
|
+
for issue, path in _numbered_files(pattern):
|
|
127
|
+
out.append((issue, str(path), frontmatter_field(path, "status") or "unknown"))
|
|
128
|
+
return out
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def plan_index():
|
|
132
|
+
"""(issue, plan directory) for every plan index that names an issue."""
|
|
133
|
+
pattern = f"{plans_dir()}/*/{plan_index_name()}"
|
|
134
|
+
return [(issue, str(path.parent)) for issue, path in _numbered_files(pattern)]
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def spec_path_for(n):
|
|
138
|
+
for issue, path, _status in spec_index():
|
|
139
|
+
if issue == str(n):
|
|
140
|
+
return path
|
|
141
|
+
return ""
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def plan_dir_for(n):
|
|
145
|
+
for issue, path in plan_index():
|
|
146
|
+
if issue == str(n):
|
|
147
|
+
return path
|
|
148
|
+
return ""
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def seal_tool():
|
|
152
|
+
"""sha256sum on GNU, shasum -a 256 on macOS. An override makes the choice testable."""
|
|
153
|
+
override = os.environ.get("QUEUE_SEAL_TOOL")
|
|
154
|
+
if override:
|
|
155
|
+
return override.split()
|
|
156
|
+
if shutil.which("sha256sum"):
|
|
157
|
+
return ["sha256sum"]
|
|
158
|
+
if shutil.which("shasum"):
|
|
159
|
+
return ["shasum", "-a", "256"]
|
|
160
|
+
return []
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def seal_ok(plan_dir):
|
|
164
|
+
if not plan_dir:
|
|
165
|
+
return False
|
|
166
|
+
directory = Path(plan_dir)
|
|
167
|
+
tool = seal_tool()
|
|
168
|
+
if not tool or not shutil.which(tool[0]):
|
|
169
|
+
return False
|
|
170
|
+
if not (directory / seal_name()).is_file():
|
|
171
|
+
return False
|
|
172
|
+
r = subprocess.run(
|
|
173
|
+
tool + ["-c", seal_name()],
|
|
174
|
+
cwd=str(directory),
|
|
175
|
+
capture_output=True,
|
|
176
|
+
text=True,
|
|
177
|
+
)
|
|
178
|
+
return r.returncode == 0
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
def body_without_frontmatter(path):
|
|
182
|
+
"""Every line after the leading --- block, and nothing before it."""
|
|
183
|
+
try:
|
|
184
|
+
lines = Path(path).read_text().splitlines(keepends=True)
|
|
185
|
+
except OSError:
|
|
186
|
+
return ""
|
|
187
|
+
if not lines or lines[0].strip() != "---":
|
|
188
|
+
return "".join(lines)
|
|
189
|
+
for i, line in enumerate(lines[1:], start=1):
|
|
190
|
+
if line.strip() == "---":
|
|
191
|
+
return "".join(lines[i + 1 :])
|
|
192
|
+
return "".join(lines)
|
work_queue/cli.py
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
|
|
3
|
+
from . import __version__, gh, labels
|
|
4
|
+
from . import commands, verify
|
|
5
|
+
|
|
6
|
+
# One line each, taken from the usage block of the shell script this replaces.
|
|
7
|
+
USAGE = {
|
|
8
|
+
"init": "init",
|
|
9
|
+
"list": "list --stage LABEL [--json]",
|
|
10
|
+
"claim": "claim --stage LABEL [--issue N] [--harness NAME] [--session NAME]",
|
|
11
|
+
"record": "record --issue N --artefact PATH",
|
|
12
|
+
"icebox": "icebox",
|
|
13
|
+
"move": "move --issue N --to LABEL [gates]",
|
|
14
|
+
"park": "park --issue N --to human:triage|human:info --reason TEXT",
|
|
15
|
+
"kind": "kind --issue N --to kind:bug|kind:feature|kind:task",
|
|
16
|
+
"close": "close --issue N --reason done|wontfix|dup [--note TEXT] [--of N] [--concept SLUG]",
|
|
17
|
+
"reopen": "reopen --issue N --reason TEXT",
|
|
18
|
+
"verify": "verify [--json]",
|
|
19
|
+
"reconcile": "reconcile",
|
|
20
|
+
"triage": "triage --issue N",
|
|
21
|
+
"migrate": "migrate --map FILE",
|
|
22
|
+
"promote": "promote --file F",
|
|
23
|
+
"docs": "docs print the pipeline reference",
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def usage() -> str:
|
|
28
|
+
lines = ["usage: work-queue <command> [options]", "", "commands:"]
|
|
29
|
+
lines += [f" {line}" for line in USAGE.values()]
|
|
30
|
+
return "\n".join(lines)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def docs_text():
|
|
34
|
+
"""The pipeline reference, read from the package so an installed copy can print it."""
|
|
35
|
+
from importlib import resources
|
|
36
|
+
|
|
37
|
+
return resources.files("work_queue").joinpath("docs/pipeline.md").read_text()
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def cmd_docs(args, dry):
|
|
41
|
+
sys.stdout.write(docs_text())
|
|
42
|
+
return 0
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def cmd_init(args, dry):
|
|
46
|
+
gh.need_gh()
|
|
47
|
+
labels.ensure_labels(dry)
|
|
48
|
+
print("vocabulary ready: " + " ".join(labels.vocab_names()) + " ")
|
|
49
|
+
return 0
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
DISPATCH = {}
|
|
53
|
+
DISPATCH["init"] = cmd_init
|
|
54
|
+
DISPATCH["docs"] = cmd_docs
|
|
55
|
+
DISPATCH["list"] = commands.cmd_list
|
|
56
|
+
DISPATCH["claim"] = commands.cmd_claim
|
|
57
|
+
DISPATCH["record"] = commands.cmd_record
|
|
58
|
+
DISPATCH["move"] = commands.cmd_move
|
|
59
|
+
DISPATCH["close"] = commands.cmd_close
|
|
60
|
+
DISPATCH["reopen"] = commands.cmd_reopen
|
|
61
|
+
DISPATCH["park"] = commands.cmd_park
|
|
62
|
+
DISPATCH["kind"] = commands.cmd_kind
|
|
63
|
+
DISPATCH["verify"] = verify.cmd_verify
|
|
64
|
+
DISPATCH["reconcile"] = verify.cmd_reconcile
|
|
65
|
+
DISPATCH["promote"] = commands.cmd_promote
|
|
66
|
+
DISPATCH["icebox"] = commands.cmd_icebox
|
|
67
|
+
DISPATCH["triage"] = commands.cmd_triage
|
|
68
|
+
DISPATCH["migrate"] = commands.cmd_migrate
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def main(argv=None):
|
|
72
|
+
args = list(sys.argv[1:] if argv is None else argv)
|
|
73
|
+
if not args:
|
|
74
|
+
print(usage(), file=sys.stderr)
|
|
75
|
+
return 1
|
|
76
|
+
if args[0] in ("-h", "--help"):
|
|
77
|
+
print(usage())
|
|
78
|
+
return 0
|
|
79
|
+
if args[0] == "--version":
|
|
80
|
+
print(__version__)
|
|
81
|
+
return 0
|
|
82
|
+
|
|
83
|
+
# --dry-run is accepted anywhere in the argument list and never reaches a subcommand.
|
|
84
|
+
dry = False
|
|
85
|
+
rest = []
|
|
86
|
+
for a in args:
|
|
87
|
+
if a == "--dry-run":
|
|
88
|
+
dry = True
|
|
89
|
+
else:
|
|
90
|
+
rest.append(a)
|
|
91
|
+
if not rest:
|
|
92
|
+
print(usage(), file=sys.stderr)
|
|
93
|
+
return 1
|
|
94
|
+
sub, rest = rest[0], rest[1:]
|
|
95
|
+
|
|
96
|
+
handler = DISPATCH.get(sub)
|
|
97
|
+
if handler is None:
|
|
98
|
+
print(f"error: unknown command: {sub}", file=sys.stderr)
|
|
99
|
+
return 1
|
|
100
|
+
return handler(rest, dry)
|