waymark-cli 0.1.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.
- waymark/__init__.py +3 -0
- waymark/__main__.py +8 -0
- waymark/adapters/__init__.py +102 -0
- waymark/adapters/claude_code.py +238 -0
- waymark/assets/__init__.py +43 -0
- waymark/assets/agents/wm-implementer.md +45 -0
- waymark/assets/agents/wm-reviewer.md +43 -0
- waymark/assets/skills/wm-apply/SKILL.md +58 -0
- waymark/assets/skills/wm-archive/SKILL.md +32 -0
- waymark/assets/skills/wm-explore/SKILL.md +34 -0
- waymark/assets/skills/wm-kickoff/SKILL.md +34 -0
- waymark/assets/skills/wm-onboard/SKILL.md +27 -0
- waymark/assets/skills/wm-pr/SKILL.md +24 -0
- waymark/assets/skills/wm-propose/SKILL.md +32 -0
- waymark/assets/skills/wm-update/SKILL.md +31 -0
- waymark/cli.py +537 -0
- waymark/hooks/__init__.py +6 -0
- waymark/hooks/commands.py +190 -0
- waymark/hooks/decide.py +314 -0
- waymark/hooks/events.py +79 -0
- waymark/py.typed +0 -0
- waymark/record/__init__.py +5 -0
- waymark/record/atlas.py +156 -0
- waymark/record/changes.py +202 -0
- waymark/record/charter.py +75 -0
- waymark/record/commits.py +78 -0
- waymark/record/config.py +215 -0
- waymark/record/deltas.py +318 -0
- waymark/record/design.py +80 -0
- waymark/record/edits.py +95 -0
- waymark/record/evidence.py +58 -0
- waymark/record/explorations.py +66 -0
- waymark/record/files.py +75 -0
- waymark/record/fingerprint.py +73 -0
- waymark/record/git.py +167 -0
- waymark/record/githooks.py +106 -0
- waymark/record/links.py +104 -0
- waymark/record/milestones.py +84 -0
- waymark/record/moves.py +60 -0
- waymark/record/names.py +39 -0
- waymark/record/outline.py +144 -0
- waymark/record/pointer.py +56 -0
- waymark/record/problems.py +20 -0
- waymark/record/project.py +118 -0
- waymark/record/proposal.py +171 -0
- waymark/record/record.py +340 -0
- waymark/record/registry.py +158 -0
- waymark/record/specs.py +227 -0
- waymark/record/state.py +472 -0
- waymark/record/store.py +88 -0
- waymark/record/tasks.py +415 -0
- waymark/record/templates/charter.md +45 -0
- waymark/record/templates/ci-workflow.yml +29 -0
- waymark/record/templates/config-atlas.toml +8 -0
- waymark/record/templates/config.toml +19 -0
- waymark/record/templates/delta.md +29 -0
- waymark/record/templates/design.md +20 -0
- waymark/record/templates/exploration.md +22 -0
- waymark/record/templates/goal.md +13 -0
- waymark/record/templates/hook-commit-msg +8 -0
- waymark/record/templates/hook-pre-commit +8 -0
- waymark/record/templates/proposal.md +18 -0
- waymark/record/templates/roadmap.md +4 -0
- waymark/record/templates/tasks.md +10 -0
- waymark/record/templates.py +30 -0
- waymark/record/terms.py +51 -0
- waymark/record/text.py +197 -0
- waymark/services/__init__.py +1 -0
- waymark/services/atlas.py +162 -0
- waymark/services/check.py +129 -0
- waymark/services/ci.py +44 -0
- waymark/services/common.py +154 -0
- waymark/services/context.py +296 -0
- waymark/services/doctor.py +367 -0
- waymark/services/githooks.py +132 -0
- waymark/services/instructions.py +304 -0
- waymark/services/integration.py +170 -0
- waymark/services/lifecycle.py +454 -0
- waymark/services/migrations.py +90 -0
- waymark/services/pr.py +177 -0
- waymark/services/references.py +27 -0
- waymark/services/setup.py +127 -0
- waymark/views/__init__.py +5 -0
- waymark/views/payloads.py +568 -0
- waymark/views/render.py +506 -0
- waymark/views/schemas.py +413 -0
- waymark/views/style.py +102 -0
- waymark_cli-0.1.0.dist-info/METADATA +313 -0
- waymark_cli-0.1.0.dist-info/RECORD +92 -0
- waymark_cli-0.1.0.dist-info/WHEEL +4 -0
- waymark_cli-0.1.0.dist-info/entry_points.txt +2 -0
- waymark_cli-0.1.0.dist-info/licenses/LICENSE +21 -0
waymark/views/render.py
ADDED
|
@@ -0,0 +1,506 @@
|
|
|
1
|
+
"""Rendering payloads: as JSON, and as styled text.
|
|
2
|
+
|
|
3
|
+
Both read the same payload. JSON is never styled, and it is written with
|
|
4
|
+
ASCII escapes so that any console can carry it unharmed. Keys starting with
|
|
5
|
+
an underscore hold values local to this machine, such as a folder; the text
|
|
6
|
+
shows them and the JSON leaves them out.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import json
|
|
10
|
+
from collections.abc import Callable
|
|
11
|
+
from typing import Any
|
|
12
|
+
|
|
13
|
+
from waymark.views.payloads import Payload
|
|
14
|
+
from waymark.views.style import BOLD, CYAN, DIM, GREEN, RED, YELLOW, Style
|
|
15
|
+
|
|
16
|
+
_NAME_WIDTH = 24
|
|
17
|
+
_PHASE_WIDTH = 10
|
|
18
|
+
_INBOX_TITLES = {
|
|
19
|
+
"accept": "To accept",
|
|
20
|
+
"spec-gap": "Spec gaps",
|
|
21
|
+
"verdict": "Verdicts that came back",
|
|
22
|
+
"blocked": "Blocked items",
|
|
23
|
+
"conflict": "Conflicts",
|
|
24
|
+
"archive": "To archive",
|
|
25
|
+
"question": "Open questions",
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def public(value: Any) -> Any:
|
|
30
|
+
"""A payload without its machine-local values: what its JSON holds."""
|
|
31
|
+
if isinstance(value, dict):
|
|
32
|
+
return {key: public(item) for key, item in value.items() if not key.startswith("_")}
|
|
33
|
+
if isinstance(value, list):
|
|
34
|
+
return [public(item) for item in value]
|
|
35
|
+
return value
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def to_json(payload: Payload) -> str:
|
|
39
|
+
"""A payload as JSON text, without its machine-local values."""
|
|
40
|
+
return json.dumps(public(payload), indent=2, ensure_ascii=True)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _indent(text: str, prefix: str = " ") -> list[str]:
|
|
44
|
+
return [f"{prefix}{line}" if line else "" for line in text.split("\n")]
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _next_step(change: Payload, style: Style) -> str:
|
|
48
|
+
step = change["next_step"]
|
|
49
|
+
label = step["kind"] + (f" {step['item']}" if step["item"] else "")
|
|
50
|
+
if step["human"]:
|
|
51
|
+
return style.paint(f"{style.symbol('human')} {label} (you)", YELLOW)
|
|
52
|
+
return f"{style.symbol('arrow')} {label}"
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def _change_line(change: Payload, style: Style) -> str:
|
|
56
|
+
name = style.paint(f"{change['name']:<{_NAME_WIDTH}}", BOLD)
|
|
57
|
+
phase = f"{change['phase']:<{_PHASE_WIDTH}}"
|
|
58
|
+
bar = style.bar(change["ticked"], change["total"])
|
|
59
|
+
progress = f"{change['ticked']}/{change['total']}"
|
|
60
|
+
return f" {name} {phase} {bar} {progress:<6} {_next_step(change, style)}"
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def _branch_lines(change: Payload, style: Style) -> list[str]:
|
|
64
|
+
"""Each repo's branch under an atlas change, and a warning for each one that differs."""
|
|
65
|
+
if not change["repos"]:
|
|
66
|
+
return []
|
|
67
|
+
shown = ", ".join(
|
|
68
|
+
f"{repo['name']} {repo['branch'] or 'no branch'}"
|
|
69
|
+
if repo["found"]
|
|
70
|
+
else f"{repo['name']} (not here)"
|
|
71
|
+
for repo in change["repos"]
|
|
72
|
+
)
|
|
73
|
+
lines = [style.paint(f" branches: {shown}", DIM)]
|
|
74
|
+
for repo in change["repos"]:
|
|
75
|
+
if repo["warn"]:
|
|
76
|
+
text = (
|
|
77
|
+
f" {style.symbol('warning')} {repo['name']} is on "
|
|
78
|
+
f"{repo['branch'] or 'no branch'}, not on {change['name']}"
|
|
79
|
+
)
|
|
80
|
+
lines.append(style.paint(text, YELLOW))
|
|
81
|
+
return lines
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def status(payload: Payload, style: Style) -> str:
|
|
85
|
+
"""The status view as text."""
|
|
86
|
+
lines: list[str] = []
|
|
87
|
+
if payload["pinned_version"] and not payload["writable"]:
|
|
88
|
+
note = (
|
|
89
|
+
f"{style.symbol('warning')} This is wm {payload['wm_version']}; the project is pinned "
|
|
90
|
+
f"to {payload['pinned_version']}. Reading works; writing is refused."
|
|
91
|
+
)
|
|
92
|
+
lines += [style.paint(note, YELLOW), ""]
|
|
93
|
+
lines.append(style.rule("Changes in flight"))
|
|
94
|
+
if payload["changes"]:
|
|
95
|
+
for change in payload["changes"]:
|
|
96
|
+
lines.append(_change_line(change, style))
|
|
97
|
+
lines += _branch_lines(change, style)
|
|
98
|
+
lines += [
|
|
99
|
+
style.paint(f" {style.symbol('warning')} {conflict['message']}", YELLOW)
|
|
100
|
+
for conflict in change["conflicts"]
|
|
101
|
+
]
|
|
102
|
+
else:
|
|
103
|
+
lines.append(" None. Start one with: wm new change <name>")
|
|
104
|
+
if payload["milestones"]:
|
|
105
|
+
lines += ["", style.rule("Open milestones")]
|
|
106
|
+
for milestone in payload["milestones"]:
|
|
107
|
+
name = style.paint(f"{milestone['name']:<{_NAME_WIDTH}}", BOLD)
|
|
108
|
+
bar = style.bar(milestone["archived"], milestone["total"])
|
|
109
|
+
detail = f"{milestone['archived']}/{milestone['total']} changes archived"
|
|
110
|
+
if milestone["planned"]:
|
|
111
|
+
detail += f", {milestone['planned']} not proposed yet"
|
|
112
|
+
lines.append(f" {name} {bar} {detail}")
|
|
113
|
+
lines.append("")
|
|
114
|
+
needs = payload["needs_human"]
|
|
115
|
+
if needs:
|
|
116
|
+
text = (
|
|
117
|
+
f"{style.symbol('human')} {needs} "
|
|
118
|
+
f"{'thing needs' if needs == 1 else 'things need'} you: wm inbox"
|
|
119
|
+
)
|
|
120
|
+
lines.append(style.paint(text, YELLOW))
|
|
121
|
+
else:
|
|
122
|
+
lines.append(style.paint(f"{style.symbol('done')} Nothing needs you.", GREEN))
|
|
123
|
+
if payload["git_hooks"] == "not-set":
|
|
124
|
+
text = (
|
|
125
|
+
f"{style.symbol('warning')} This clone doesn't run the committed git hooks: "
|
|
126
|
+
"wm git-hooks"
|
|
127
|
+
)
|
|
128
|
+
lines.append(style.paint(text, YELLOW))
|
|
129
|
+
if payload["problems"]:
|
|
130
|
+
count = payload["problems"]
|
|
131
|
+
plural = "s" if count != 1 else ""
|
|
132
|
+
text = f"{style.symbol('error')} {count} problem{plural} in the record: wm check"
|
|
133
|
+
lines.append(style.paint(text, RED))
|
|
134
|
+
if payload["recently_archived"]:
|
|
135
|
+
lines += ["", style.rule("Recently archived")]
|
|
136
|
+
lines += [
|
|
137
|
+
f" {style.paint(entry['date'], DIM)} {entry['name']}"
|
|
138
|
+
for entry in payload["recently_archived"]
|
|
139
|
+
]
|
|
140
|
+
return "\n".join(lines)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def inbox(payload: Payload, style: Style) -> str:
|
|
144
|
+
"""The inbox view as text."""
|
|
145
|
+
entries = payload["entries"]
|
|
146
|
+
if not entries:
|
|
147
|
+
return style.paint(f"{style.symbol('done')} Nothing needs you.", GREEN)
|
|
148
|
+
lines: list[str] = []
|
|
149
|
+
for kind, title in _INBOX_TITLES.items():
|
|
150
|
+
group = [entry for entry in entries if entry["kind"] == kind]
|
|
151
|
+
if not group:
|
|
152
|
+
continue
|
|
153
|
+
if lines:
|
|
154
|
+
lines.append("")
|
|
155
|
+
lines.append(style.rule(title))
|
|
156
|
+
for entry in group:
|
|
157
|
+
subject = entry["change"] or entry["exploration"]
|
|
158
|
+
where = f"{subject} {entry['item']}" if entry["item"] else subject
|
|
159
|
+
lines.append(f" {style.symbol('human')} {style.paint(where, BOLD)}")
|
|
160
|
+
lines += _indent(entry["summary"], " ")
|
|
161
|
+
if entry["command"]:
|
|
162
|
+
lines.append(style.paint(f" {style.symbol('arrow')} {entry['command']}", CYAN))
|
|
163
|
+
return "\n".join(lines)
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def check(payload: Payload, style: Style) -> str:
|
|
167
|
+
"""The health check as text: one line per finding, then the counts."""
|
|
168
|
+
lines: list[str] = []
|
|
169
|
+
for finding in payload["findings"]:
|
|
170
|
+
where = finding["path"] + (f":{finding['line']}" if finding["line"] else "")
|
|
171
|
+
severity = style.paint(
|
|
172
|
+
finding["severity"], RED if finding["severity"] == "error" else YELLOW
|
|
173
|
+
)
|
|
174
|
+
lines.append(f"{severity}: {where}: {finding['code']}: {finding['message']}")
|
|
175
|
+
if payload["findings"]:
|
|
176
|
+
lines.append(f"{payload['errors']} error(s), {payload['warnings']} warning(s).")
|
|
177
|
+
else:
|
|
178
|
+
lines.append(style.paint(f"{style.symbol('done')} The record is healthy.", GREEN))
|
|
179
|
+
return "\n".join(lines)
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def ls(payload: Payload, style: Style) -> str:
|
|
183
|
+
"""One line per entry."""
|
|
184
|
+
source = f" in the atlas {payload['from']}" if payload["from"] else ""
|
|
185
|
+
if not payload["entries"]:
|
|
186
|
+
return f"No {payload['kind']}s{source}."
|
|
187
|
+
width = max(len(entry["name"]) for entry in payload["entries"])
|
|
188
|
+
states = max(len(entry["state"]) for entry in payload["entries"])
|
|
189
|
+
lines: list[str] = []
|
|
190
|
+
for entry in payload["entries"]:
|
|
191
|
+
name = style.paint(entry["name"].ljust(width), BOLD)
|
|
192
|
+
detail = style.paint(entry["detail"], DIM)
|
|
193
|
+
lines.append(f"{name} {entry['state'].ljust(states)} {detail}".rstrip())
|
|
194
|
+
return "\n".join(lines)
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
def _titled(title: str, text: str | None, style: Style) -> list[str]:
|
|
198
|
+
if not text:
|
|
199
|
+
return []
|
|
200
|
+
return ["", style.paint(title, BOLD), *_indent(text, " ")]
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
def _item_lines(item: Payload, style: Style) -> list[str]:
|
|
204
|
+
mark = style.symbol("done") if item["ticked"] else style.symbol("todo")
|
|
205
|
+
tags = [f"review: {item['level']}"] if item["level"] else []
|
|
206
|
+
if item["reviewed"]:
|
|
207
|
+
tags.append("reviewed")
|
|
208
|
+
if item["repo"]:
|
|
209
|
+
tags.append(f"repo: {item['repo']}")
|
|
210
|
+
head = f" {mark} {style.paint(item['number'], BOLD)} {item['title']}"
|
|
211
|
+
lines = [head + (style.paint(f" ({', '.join(tags)})", DIM) if tags else "")]
|
|
212
|
+
for label, key in (("Criteria", "criteria"), ("Verify", "verify")):
|
|
213
|
+
if item[key]:
|
|
214
|
+
lines.append(f" {label}: {item[key]}".replace("\n", "\n "))
|
|
215
|
+
for label, key, color in (
|
|
216
|
+
("Blocked", "blocked", YELLOW),
|
|
217
|
+
("Spec gap", "spec_gap", YELLOW),
|
|
218
|
+
("Needs you", "needs_human", YELLOW),
|
|
219
|
+
):
|
|
220
|
+
if item[key]:
|
|
221
|
+
lines.append(style.paint(f" {label}: {item[key]}", color))
|
|
222
|
+
lines += [f" Note: {note}" for note in item["notes"]]
|
|
223
|
+
for record in item["records"]:
|
|
224
|
+
verdict = f" {record['verdict']}" if record["verdict"] else ""
|
|
225
|
+
text = f": {record['text']}" if record["text"] else ""
|
|
226
|
+
lines.append(style.paint(f" ({record['kind']}) {record['date']}{verdict}{text}", DIM))
|
|
227
|
+
return lines
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def _delta_names(delta: Payload) -> str:
|
|
231
|
+
parts = [
|
|
232
|
+
f"{label} {', '.join(delta[key])}"
|
|
233
|
+
for label, key in (("adds", "added"), ("modifies", "modified"), ("removes", "removed"))
|
|
234
|
+
if delta[key]
|
|
235
|
+
]
|
|
236
|
+
return "; ".join(parts) or "purpose or repos only"
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
def show_change(payload: Payload, style: Style) -> str: # noqa: PLR0912 - one part per section
|
|
240
|
+
"""Everything about one change, as text."""
|
|
241
|
+
lines = [style.rule(f"Change: {payload['name']}")]
|
|
242
|
+
state = payload["state"]
|
|
243
|
+
if payload["archived_on"]:
|
|
244
|
+
lines.append(f" Archived on {payload['archived_on']}")
|
|
245
|
+
if state:
|
|
246
|
+
lines.append(_change_line(state, style))
|
|
247
|
+
lines += _branch_lines(state, style)
|
|
248
|
+
facts = [f"Owner: {payload['owner'] or 'none'}"]
|
|
249
|
+
if state and state["short_path"]:
|
|
250
|
+
facts.append("short path")
|
|
251
|
+
if payload["accepted"]:
|
|
252
|
+
facts.append(f"accepted {payload['accepted']['date']} by {payload['accepted']['by']}")
|
|
253
|
+
if state and state["acceptance"] == "withdrawn":
|
|
254
|
+
facts.append("acceptance withdrawn")
|
|
255
|
+
if payload["synced_on"]:
|
|
256
|
+
facts.append(f"synced {payload['synced_on']}")
|
|
257
|
+
lines.append(f" {'; '.join(facts)}")
|
|
258
|
+
if state and state["next_step"]["reason"]:
|
|
259
|
+
lines.append(f" {state['next_step']['reason']}")
|
|
260
|
+
for conflict in state["conflicts"] if state else []:
|
|
261
|
+
lines.append(style.paint(f" {style.symbol('warning')} {conflict['message']}", YELLOW))
|
|
262
|
+
for title, text in (payload["proposal"] or {}).items():
|
|
263
|
+
lines += _titled(title, text, style)
|
|
264
|
+
lines += _titled("Outcome", payload["outcome"], style)
|
|
265
|
+
if payload["deltas"]:
|
|
266
|
+
lines += ["", style.paint("Deltas", BOLD)]
|
|
267
|
+
lines += [f" {delta['spec']}: {_delta_names(delta)}" for delta in payload["deltas"]]
|
|
268
|
+
if payload["design"]:
|
|
269
|
+
decisions = ", ".join(payload["design"]["decisions"]) or "none"
|
|
270
|
+
lines += ["", style.paint("Design", BOLD), f" Decisions: {decisions}"]
|
|
271
|
+
if payload["items"]:
|
|
272
|
+
lines += ["", style.paint("Tasks", BOLD)]
|
|
273
|
+
for item in payload["items"]:
|
|
274
|
+
lines += _item_lines(item, style)
|
|
275
|
+
if payload["problems"]:
|
|
276
|
+
lines += ["", style.paint("Problems", BOLD)]
|
|
277
|
+
lines += [
|
|
278
|
+
style.paint(f" {p['path']}:{p['line']}: {p['message']}", RED)
|
|
279
|
+
for p in payload["problems"]
|
|
280
|
+
]
|
|
281
|
+
return "\n".join(lines)
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
def show_spec(payload: Payload, style: Style) -> str:
|
|
285
|
+
"""A spec with its pending deltas and its history, as text."""
|
|
286
|
+
source = f" (from the atlas {payload['from']}, read only)" if payload["from"] else ""
|
|
287
|
+
lines = [style.rule(f"Spec: {payload['name']}{source}"), f" {payload['title']}"]
|
|
288
|
+
if payload["repos"]:
|
|
289
|
+
lines.append(f" Repos: {', '.join(payload['repos'])}")
|
|
290
|
+
lines += _titled("Purpose", payload["purpose"], style)
|
|
291
|
+
lines += ["", style.paint("Requirements", BOLD)]
|
|
292
|
+
for requirement in payload["requirements"]:
|
|
293
|
+
lines.append(f" {style.symbol('bullet')} {style.paint(requirement['name'], BOLD)}")
|
|
294
|
+
lines += _indent(requirement["statement"], " ")
|
|
295
|
+
for scenario in requirement["scenarios"]:
|
|
296
|
+
lines.append(style.paint(f" Scenario: {scenario['name']}", DIM))
|
|
297
|
+
lines += [f" {step['keyword']} {step['text']}" for step in scenario["steps"]]
|
|
298
|
+
if not payload["requirements"]:
|
|
299
|
+
lines.append(" None.")
|
|
300
|
+
if payload["pending"]:
|
|
301
|
+
lines += ["", style.paint("Pending deltas from active changes", BOLD)]
|
|
302
|
+
lines += [f" {delta['change']}: {_delta_names(delta)}" for delta in payload["pending"]]
|
|
303
|
+
if payload["history"]:
|
|
304
|
+
lines += ["", style.paint("History", BOLD)]
|
|
305
|
+
for entry in payload["history"]:
|
|
306
|
+
lines.append(f" {style.paint(entry['date'], DIM)} {entry['change']}")
|
|
307
|
+
lines += _indent(entry["outcome"] or "", " ") if entry["outcome"] else []
|
|
308
|
+
return "\n".join(lines)
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
def show_milestone(payload: Payload, style: Style) -> str:
|
|
312
|
+
"""A milestone with its roadmap, as text."""
|
|
313
|
+
lines = [style.rule(f"Milestone: {payload['name']}")]
|
|
314
|
+
bar = style.bar(payload["archived"], payload["total"])
|
|
315
|
+
lines.append(f" {bar} {payload['archived']}/{payload['total']} changes archived")
|
|
316
|
+
for title, text in (payload["goal"] or {}).items():
|
|
317
|
+
lines += _titled(title, text, style)
|
|
318
|
+
lines += ["", style.paint("Roadmap", BOLD)]
|
|
319
|
+
for line in payload["lines"]:
|
|
320
|
+
mark = style.symbol("done") if line["status"] == "archived" else style.symbol("todo")
|
|
321
|
+
status_text = style.paint(f"({line['status']})", DIM)
|
|
322
|
+
lines.append(f" {mark} {line['change'] or line['text']} {status_text}")
|
|
323
|
+
if not payload["lines"]:
|
|
324
|
+
lines.append(" Empty.")
|
|
325
|
+
return "\n".join(lines)
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
def show_exploration(payload: Payload, style: Style) -> str:
|
|
329
|
+
"""An exploration, as text."""
|
|
330
|
+
lines = [style.rule(f"Exploration: {payload['name']}"), f" {payload['title']}"]
|
|
331
|
+
detail = f": {payload['detail']}" if payload["detail"] else ""
|
|
332
|
+
lines.append(f" {payload['status']}{detail}")
|
|
333
|
+
for title, text in payload["sections"].items():
|
|
334
|
+
lines += _titled(title, text, style)
|
|
335
|
+
return "\n".join(lines)
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
def _fenced(text: str) -> list[str]:
|
|
339
|
+
"""Record text quoted whole, so its own headings don't mix with the pack's."""
|
|
340
|
+
return ["````markdown", *text.split("\n"), "````"]
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
def instructions(payload: Payload, style: Style) -> str:
|
|
344
|
+
"""Instructions for one step, as text an agent or a person can follow."""
|
|
345
|
+
subject = f" for {payload['change']}" if payload["change"] else ""
|
|
346
|
+
item = f" {payload['item']}" if payload["item"] else ""
|
|
347
|
+
lines = [style.rule(f"Step: {payload['step']}{item}{subject}")]
|
|
348
|
+
if not payload["ready"]:
|
|
349
|
+
lines.append(
|
|
350
|
+
style.paint(f" {style.symbol('warning')} Not yet: {payload['reason']}", YELLOW)
|
|
351
|
+
)
|
|
352
|
+
elif payload["reason"]:
|
|
353
|
+
lines.append(f" {payload['reason']}")
|
|
354
|
+
if payload["guidance"]:
|
|
355
|
+
lines += ["", style.paint("What to do", BOLD)]
|
|
356
|
+
lines += [f" {style.symbol('bullet')} {text}" for text in payload["guidance"]]
|
|
357
|
+
if payload["commands"]:
|
|
358
|
+
lines += ["", style.paint("Commands", BOLD)]
|
|
359
|
+
lines += [style.paint(f" {command}", CYAN) for command in payload["commands"]]
|
|
360
|
+
lines += _titled("Rules for this step", payload["rules"], style)
|
|
361
|
+
lines += _titled("Project context", payload["context"], style)
|
|
362
|
+
if payload["read"]:
|
|
363
|
+
lines += ["", style.paint("Read first", BOLD)]
|
|
364
|
+
lines += [f" {path}" for path in payload["read"]]
|
|
365
|
+
for output in payload["outputs"]:
|
|
366
|
+
state = "exists; revise it" if output["exists"] else "to write"
|
|
367
|
+
lines += ["", style.paint(f"Write: {output['path']}", BOLD) + f" ({state})"]
|
|
368
|
+
if output["template"]:
|
|
369
|
+
lines += [" Template:", *_indent(output["template"].rstrip("\n"), " | ")]
|
|
370
|
+
lines += ["", f"{style.paint('Unlocks', BOLD)}: {payload['unlocks']}"]
|
|
371
|
+
return "\n".join(lines)
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
def _pack_item(item: Payload) -> list[str]:
|
|
375
|
+
lines = [f"**{item['number']} {item['title']}**", ""]
|
|
376
|
+
for label, key in (("Criteria", "criteria"), ("Verify", "verify")):
|
|
377
|
+
if item[key]:
|
|
378
|
+
lines.append(f"- {label}: {item[key]}")
|
|
379
|
+
if item["repo"]:
|
|
380
|
+
folder = item["_local"]["repo_folder"]
|
|
381
|
+
where = f"its folder on this machine is {folder}" if folder else "not found on this machine"
|
|
382
|
+
lines.append(f"- Repo: {item['repo']} ({where})")
|
|
383
|
+
lines.append(f"- Review level: {item['review_level']}")
|
|
384
|
+
lines += [f"- Decided by the human: {text}" for text in item["resolutions"]]
|
|
385
|
+
for review in item["reviews"]:
|
|
386
|
+
lines.append(f"- Earlier review ({review['date']}, {review['verdict']}): {review['text']}")
|
|
387
|
+
lines += [f"- Note from earlier work: {note}" for note in item["notes"]]
|
|
388
|
+
return lines
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
def context_delegated(payload: Payload, _: Style) -> str:
|
|
392
|
+
"""An implementer's or reviewer's context pack, as markdown."""
|
|
393
|
+
role = payload["for"]
|
|
394
|
+
item = payload["item"]
|
|
395
|
+
lines = [f"# Context pack: {role} {payload['change']} {item['number']}", ""]
|
|
396
|
+
lines += ["## Your item", "", *_pack_item(item)]
|
|
397
|
+
if payload["context"]:
|
|
398
|
+
lines += ["", "## Project context", "", payload["context"]]
|
|
399
|
+
if payload["rules"]:
|
|
400
|
+
lines += ["", "## Rules for this step", "", payload["rules"]]
|
|
401
|
+
if payload["proposal"]:
|
|
402
|
+
lines += ["", "## Proposal"]
|
|
403
|
+
for title, text in payload["proposal"].items():
|
|
404
|
+
lines += ["", f"### {title}", "", text]
|
|
405
|
+
if payload["deltas"]:
|
|
406
|
+
lines += ["", "## Deltas"]
|
|
407
|
+
for delta in payload["deltas"]:
|
|
408
|
+
lines += ["", f"### Spec: {delta['spec']}", "", *_fenced(delta["text"])]
|
|
409
|
+
if payload["requirements"]:
|
|
410
|
+
lines += ["", "## Requirements as they stand today"]
|
|
411
|
+
for requirement in payload["requirements"]:
|
|
412
|
+
title = f"### {requirement['spec']}: {requirement['name']}"
|
|
413
|
+
lines += ["", title, "", *_fenced(requirement["text"])]
|
|
414
|
+
if payload["design"]:
|
|
415
|
+
lines += ["", "## Design", "", *_fenced(payload["design"])]
|
|
416
|
+
lines += ["", "## How to finish", "", payload["ends_with"]]
|
|
417
|
+
return "\n".join(lines)
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
def context_explore(payload: Payload, _: Style) -> str:
|
|
421
|
+
"""The explore context pack, as markdown."""
|
|
422
|
+
lines = ["# Context pack: explore"]
|
|
423
|
+
for title, text in payload["charter"].items():
|
|
424
|
+
if text:
|
|
425
|
+
lines += ["", f"## {title}", "", text]
|
|
426
|
+
if payload["rules"]:
|
|
427
|
+
lines += ["", "## Rules for this step", "", payload["rules"]]
|
|
428
|
+
lines += ["", "## Specs", ""]
|
|
429
|
+
for spec in payload["specs"]:
|
|
430
|
+
names = ", ".join(spec["requirements"]) or "no requirements"
|
|
431
|
+
lines.append(f"- {spec['name']}: {spec['purpose']} ({names})")
|
|
432
|
+
if not payload["specs"]:
|
|
433
|
+
lines.append("None yet.")
|
|
434
|
+
lines += ["", "## Changes in flight", ""]
|
|
435
|
+
lines += [
|
|
436
|
+
f"- {change['name']} ({change['phase']}): {change['title']}"
|
|
437
|
+
for change in payload["changes"]
|
|
438
|
+
] or ["None."]
|
|
439
|
+
if payload["milestones"]:
|
|
440
|
+
lines += ["", "## Open milestones", ""]
|
|
441
|
+
lines += [
|
|
442
|
+
f"- {m['name']}: {m['archived']}/{m['total']} changes archived"
|
|
443
|
+
for m in payload["milestones"]
|
|
444
|
+
]
|
|
445
|
+
for reference in payload["references"]:
|
|
446
|
+
lines += ["", f"## Specs in the atlas {reference['atlas']} (read only)", ""]
|
|
447
|
+
if not reference["found"]:
|
|
448
|
+
lines.append("Not found on this machine; wm doctor says why.")
|
|
449
|
+
for spec in reference["specs"]:
|
|
450
|
+
lines.append(f"- {spec['name']}: {spec['purpose']}")
|
|
451
|
+
if reference["found"]:
|
|
452
|
+
lines += ["", f"Read one with: wm show <spec> --from {reference['atlas']}"]
|
|
453
|
+
if payload["explorations"]:
|
|
454
|
+
lines += ["", "## Explorations", ""]
|
|
455
|
+
for exploration in payload["explorations"]:
|
|
456
|
+
detail = f": {exploration['detail']}" if exploration["detail"] else ""
|
|
457
|
+
lines.append(
|
|
458
|
+
f"- {exploration['name']} ({exploration['status']}{detail}): {exploration['title']}"
|
|
459
|
+
)
|
|
460
|
+
return "\n".join(lines)
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
def doctor(payload: Payload, style: Style) -> str:
|
|
464
|
+
"""What a doctor found: one line per check, then the verdict."""
|
|
465
|
+
marks = {"ok": ("done", GREEN), "warning": ("warning", YELLOW), "error": ("error", RED)}
|
|
466
|
+
lines: list[str] = []
|
|
467
|
+
for check in payload["checks"]:
|
|
468
|
+
symbol, color = marks[check["status"]]
|
|
469
|
+
head = style.paint(f"{style.symbol(symbol)} {check['name']}", color)
|
|
470
|
+
lines.append(f"{head}: {check['message']}")
|
|
471
|
+
if check["_folder"]:
|
|
472
|
+
lines.append(style.paint(f" {check['_folder']}", DIM))
|
|
473
|
+
errors = sum(1 for check in payload["checks"] if check["status"] == "error")
|
|
474
|
+
warnings = sum(1 for check in payload["checks"] if check["status"] == "warning")
|
|
475
|
+
lines.append(f"{errors} error(s), {warnings} warning(s). Nothing was changed.")
|
|
476
|
+
return "\n".join(lines)
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
def pr(payload: Payload, style: Style) -> str:
|
|
480
|
+
"""A pull request's title and description, ready to paste or hand to the host's tool."""
|
|
481
|
+
where = f" in {payload['repo']}" if payload["repo"] else ""
|
|
482
|
+
head = style.rule(f"Pull request for {payload['change']}{where}, from {payload['branch']}")
|
|
483
|
+
return "\n".join([head, "", f"Title: {payload['title']}", "", payload["body"].rstrip("\n")])
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
_RENDERERS: dict[str, Callable[[Payload, Style], str]] = {
|
|
487
|
+
"wm.status": status,
|
|
488
|
+
"wm.inbox": inbox,
|
|
489
|
+
"wm.check": check,
|
|
490
|
+
"wm.ls": ls,
|
|
491
|
+
"wm.show.change": show_change,
|
|
492
|
+
"wm.show.spec": show_spec,
|
|
493
|
+
"wm.show.milestone": show_milestone,
|
|
494
|
+
"wm.show.exploration": show_exploration,
|
|
495
|
+
"wm.instructions": instructions,
|
|
496
|
+
"wm.context.explore": context_explore,
|
|
497
|
+
"wm.context.implement": context_delegated,
|
|
498
|
+
"wm.context.review": context_delegated,
|
|
499
|
+
"wm.doctor": doctor,
|
|
500
|
+
"wm.pr": pr,
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
def to_text(payload: Payload, style: Style) -> str:
|
|
505
|
+
"""A payload as styled text, chosen by its schema."""
|
|
506
|
+
return _RENDERERS[payload["schema"]](payload, style)
|