diffdesk 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.
Files changed (59) hide show
  1. diffdesk/__init__.py +3 -0
  2. diffdesk/agent.py +414 -0
  3. diffdesk/agent_guide.md +112 -0
  4. diffdesk/cli.py +329 -0
  5. diffdesk/config.py +130 -0
  6. diffdesk/gitio.py +391 -0
  7. diffdesk/index.py +635 -0
  8. diffdesk/mcp.py +472 -0
  9. diffdesk/server.py +750 -0
  10. diffdesk/static/app.js +402 -0
  11. diffdesk/static/index.html +129 -0
  12. diffdesk/static/js/api.js +58 -0
  13. diffdesk/static/js/boot.js +12 -0
  14. diffdesk/static/js/diffview.js +359 -0
  15. diffdesk/static/js/dom.js +82 -0
  16. diffdesk/static/js/editor-cm.js +225 -0
  17. diffdesk/static/js/editor-monaco.js +116 -0
  18. diffdesk/static/js/flow.js +227 -0
  19. diffdesk/static/js/hunks.js +40 -0
  20. diffdesk/static/js/markdown.js +102 -0
  21. diffdesk/static/js/settings.js +228 -0
  22. diffdesk/static/js/subject.js +127 -0
  23. diffdesk/static/js/tree.js +492 -0
  24. diffdesk/static/js/treemap.js +217 -0
  25. diffdesk/static/style.css +508 -0
  26. diffdesk/static/vendor/LICENSES.txt +603 -0
  27. diffdesk/static/vendor/codemirror.js +24 -0
  28. diffdesk/static/vendor/fonts/KaTeX_AMS-Regular.woff2 +0 -0
  29. diffdesk/static/vendor/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
  30. diffdesk/static/vendor/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
  31. diffdesk/static/vendor/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
  32. diffdesk/static/vendor/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
  33. diffdesk/static/vendor/fonts/KaTeX_Main-Bold.woff2 +0 -0
  34. diffdesk/static/vendor/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
  35. diffdesk/static/vendor/fonts/KaTeX_Main-Italic.woff2 +0 -0
  36. diffdesk/static/vendor/fonts/KaTeX_Main-Regular.woff2 +0 -0
  37. diffdesk/static/vendor/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
  38. diffdesk/static/vendor/fonts/KaTeX_Math-Italic.woff2 +0 -0
  39. diffdesk/static/vendor/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
  40. diffdesk/static/vendor/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
  41. diffdesk/static/vendor/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
  42. diffdesk/static/vendor/fonts/KaTeX_Script-Regular.woff2 +0 -0
  43. diffdesk/static/vendor/fonts/KaTeX_Size1-Regular.woff2 +0 -0
  44. diffdesk/static/vendor/fonts/KaTeX_Size2-Regular.woff2 +0 -0
  45. diffdesk/static/vendor/fonts/KaTeX_Size3-Regular.woff2 +0 -0
  46. diffdesk/static/vendor/fonts/KaTeX_Size4-Regular.woff2 +0 -0
  47. diffdesk/static/vendor/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
  48. diffdesk/static/vendor/fonts/OFL.txt +102 -0
  49. diffdesk/static/vendor/katex.css +2 -0
  50. diffdesk/static/vendor/katex.js +258 -0
  51. diffdesk/static/vendor/marked.js +72 -0
  52. diffdesk/subject.schema.json +59 -0
  53. diffdesk-0.1.0.dist-info/METADATA +520 -0
  54. diffdesk-0.1.0.dist-info/RECORD +59 -0
  55. diffdesk-0.1.0.dist-info/WHEEL +4 -0
  56. diffdesk-0.1.0.dist-info/entry_points.txt +2 -0
  57. diffdesk-0.1.0.dist-info/licenses/LICENSE +21 -0
  58. diffdesk-0.1.0.dist-info/licenses/src/diffdesk/static/vendor/LICENSES.txt +603 -0
  59. diffdesk-0.1.0.dist-info/licenses/src/diffdesk/static/vendor/fonts/OFL.txt +102 -0
diffdesk/__init__.py ADDED
@@ -0,0 +1,3 @@
1
+ """diffdesk: a local, file-based review desk for commits made by agents or people."""
2
+
3
+ __version__ = "0.1.0"
diffdesk/agent.py ADDED
@@ -0,0 +1,414 @@
1
+ """Functions for coding agents: write a subject for a commit and read reviews back.
2
+
3
+ The ``diffdesk add``, ``diffdesk reviews`` and ``diffdesk guide`` commands use
4
+ these functions. Each function checks its own input, so other front ends can
5
+ call it directly.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import json
11
+ import os
12
+ import re
13
+ from collections.abc import Iterable
14
+ from pathlib import Path
15
+ from typing import Any
16
+
17
+ from . import gitio
18
+ from .config import Config
19
+ from .gitio import GitError, InvalidInput
20
+ from .index import (
21
+ DEFAULT_PACKAGE,
22
+ STATUSES,
23
+ Index,
24
+ check_name,
25
+ parse_subject,
26
+ write_atomic,
27
+ )
28
+
29
+ PACKAGE_DIR = Path(__file__).resolve().parent
30
+ SCHEMA_PATH = PACKAGE_DIR / "subject.schema.json"
31
+ GUIDE_PATH = PACKAGE_DIR / "agent_guide.md"
32
+
33
+ _TYPES: dict[str, Any] = {
34
+ "string": lambda v: isinstance(v, str),
35
+ "number": lambda v: isinstance(v, int | float) and not isinstance(v, bool),
36
+ "integer": lambda v: isinstance(v, int) and not isinstance(v, bool),
37
+ "boolean": lambda v: isinstance(v, bool),
38
+ "null": lambda v: v is None,
39
+ "array": lambda v: isinstance(v, list),
40
+ "object": lambda v: isinstance(v, dict),
41
+ }
42
+
43
+
44
+ def schema_errors(
45
+ value: Any, schema: dict[str, Any], root: dict[str, Any], where: str
46
+ ) -> list[str]:
47
+ """Check `value` against a JSON Schema and return the problems found.
48
+
49
+ Only the keywords that ``subject.schema.json`` uses are supported:
50
+ ``$ref`` (inside the same document), ``type``, ``enum``, ``minLength``,
51
+ ``pattern``, ``items``, ``required``, ``properties`` and
52
+ ``additionalProperties``. Other keywords are ignored.
53
+
54
+ Parameters
55
+ ----------
56
+ value : Any
57
+ Decoded JSON value.
58
+ schema : dict
59
+ Schema (or subschema) to check against.
60
+ root : dict
61
+ The whole schema document, for ``$ref``.
62
+ where : str
63
+ Location of `value`, used in the messages (for example ``$.files[0]``).
64
+
65
+ Returns
66
+ -------
67
+ list of str
68
+ One message per problem. Empty if `value` is valid.
69
+ """
70
+ errors: list[str] = []
71
+ if "$ref" in schema:
72
+ target: Any = root
73
+ for part in schema["$ref"].removeprefix("#/").split("/"):
74
+ target = target[part]
75
+ errors += schema_errors(value, target, root, where)
76
+ types = schema.get("type")
77
+ if types is not None:
78
+ types = [types] if isinstance(types, str) else types
79
+ if not any(_TYPES[t](value) for t in types):
80
+ return [
81
+ *errors,
82
+ f"{where}: must be {' or '.join(types)}, not {json.dumps(value)[:60]}",
83
+ ]
84
+ if "enum" in schema and value not in schema["enum"]:
85
+ errors.append(f"{where}: must be one of {schema['enum']}")
86
+ if isinstance(value, str):
87
+ if len(value) < schema.get("minLength", 0):
88
+ errors.append(f"{where}: must not be empty")
89
+ if "pattern" in schema and not re.search(schema["pattern"], value):
90
+ errors.append(f"{where}: {value!r} does not match {schema['pattern']}")
91
+ if isinstance(value, list) and "items" in schema:
92
+ for i, item in enumerate(value):
93
+ errors += schema_errors(item, schema["items"], root, f"{where}[{i}]")
94
+ if isinstance(value, dict):
95
+ errors += [
96
+ f"{where}: missing field '{key}'"
97
+ for key in schema.get("required", [])
98
+ if key not in value
99
+ ]
100
+ props = schema.get("properties", {})
101
+ for key, item in value.items():
102
+ if key in props:
103
+ errors += schema_errors(item, props[key], root, f"{where}.{key}")
104
+ elif schema.get("additionalProperties", True) is False:
105
+ errors.append(f"{where}: unknown field '{key}'")
106
+ return errors
107
+
108
+
109
+ def subject_files(folder: Path) -> list[Path]:
110
+ """Return every ``*.json`` file below `folder`, without hidden files and folders.
111
+
112
+ The files are sorted by their path text, as the index sorts them, so both
113
+ take the same file as the first of two duplicates. Sorting `Path` objects
114
+ would ignore case on Windows.
115
+ """
116
+ found: list[Path] = []
117
+ for dirpath, dirnames, filenames in os.walk(folder):
118
+ dirnames[:] = [d for d in dirnames if not d.startswith(".")]
119
+ found += [
120
+ Path(dirpath, f) for f in filenames if f.endswith(".json") and not f.startswith(".")
121
+ ]
122
+ return sorted(found, key=str)
123
+
124
+
125
+ def validate_subjects(config: Config) -> dict[str, Any]:
126
+ """Check every subject file of a review root.
127
+
128
+ Each file must be JSON that matches ``subject.schema.json``, with both or
129
+ neither of ``base`` and ``head``, and no two files may hold the same
130
+ package and ID. An ID used in more than one package is a warning.
131
+
132
+ Parameters
133
+ ----------
134
+ config : Config
135
+ Settings of the review root.
136
+
137
+ Returns
138
+ -------
139
+ dict
140
+ ``files``: number of subject files. ``problems`` and ``warnings``:
141
+ lists of messages. A problem starts with the file path relative to
142
+ the root.
143
+ """
144
+ schema = json.loads(SCHEMA_PATH.read_text(encoding="utf-8"))
145
+ problems: list[str] = []
146
+ warnings: list[str] = []
147
+ owners: dict[tuple[str, str], Path] = {}
148
+ packages_of: dict[str, list[str]] = {}
149
+ files = subject_files(config.subjects)
150
+ for path in files:
151
+ rel = (
152
+ path.relative_to(config.root).as_posix() if path.is_relative_to(config.root) else path
153
+ )
154
+ try:
155
+ data = json.loads(path.read_bytes())
156
+ except (OSError, ValueError) as exc:
157
+ problems.append(f"{rel}: cannot read JSON: {exc}")
158
+ continue
159
+ errors = schema_errors(data, schema, schema, "$")
160
+ if isinstance(data, dict) and (data.get("base") is None) != (data.get("head") is None):
161
+ errors.append("'base' and 'head' must both be set or both be null")
162
+ problems += [f"{rel}: {e}" for e in errors]
163
+ parts = path.relative_to(config.subjects).parts
164
+ try:
165
+ subject = parse_subject(path, parts[0] if len(parts) > 1 else DEFAULT_PACKAGE)
166
+ except ValueError as exc:
167
+ if not errors:
168
+ problems.append(f"{rel}: {exc}")
169
+ continue
170
+ if subject.key in owners:
171
+ first = owners[subject.key].relative_to(config.root).as_posix()
172
+ problems.append(f"{rel}: same package and ID as {first}")
173
+ continue
174
+ owners[subject.key] = path
175
+ packages_of.setdefault(subject.id, []).append(subject.package)
176
+ for sid, packages in sorted(packages_of.items()):
177
+ if len(packages) > 1:
178
+ warnings.append(
179
+ f"ID {sid} is used in packages {', '.join(packages)}; "
180
+ "API calls for it need 'package'"
181
+ )
182
+ return {"files": len(files), "problems": problems, "warnings": warnings}
183
+
184
+
185
+ def create_subject(
186
+ config: Config,
187
+ *,
188
+ repo: str | Path,
189
+ subject_id: str,
190
+ title: str,
191
+ commit: str | None = None,
192
+ base: str | None = None,
193
+ head: str | None = None,
194
+ package: str | None = None,
195
+ summary: str | None = None,
196
+ why: str | None = None,
197
+ priority: str | None = None,
198
+ recommended: str | None = None,
199
+ tags: Iterable[str] | None = None,
200
+ branch: str | None = None,
201
+ force: bool = False,
202
+ ) -> tuple[Path, dict[str, Any]]:
203
+ """Write ``<subjects>/<package>/<subject_id>.json`` for a commit or a commit range.
204
+
205
+ The full commit IDs, the absolute path of the work tree and the list of
206
+ changed files come from git. A renamed file is listed with its old and
207
+ its new path, and a deleted file with its old path, because the diff is
208
+ made without rename detection.
209
+
210
+ Parameters
211
+ ----------
212
+ config : Config
213
+ Settings of the review root. The root folder must exist.
214
+ repo : str or Path
215
+ A folder inside the git work tree.
216
+ subject_id : str
217
+ Subject ID: letters, digits, ``.``, ``_`` and ``-``, starting with a
218
+ letter or digit, without ``..``.
219
+ title : str
220
+ One-line title.
221
+ commit : str, optional
222
+ Commit to review against its first parent. Default: ``HEAD`` if
223
+ `base` and `head` are not given. A commit without a parent is
224
+ compared with the empty tree.
225
+ base, head : str, optional
226
+ Old and new side of the diff. Give both or neither, and not with
227
+ `commit`.
228
+ package : str, optional
229
+ Package name. Default: the name of the work tree folder.
230
+ summary, why, priority, recommended, branch : str, optional
231
+ Subject fields of the same name. A field that is `None` is left out.
232
+ tags : iterable of str, optional
233
+ Free labels.
234
+ force : bool, optional
235
+ Replace the subject file if it exists. Default: `False`.
236
+
237
+ Returns
238
+ -------
239
+ path : Path
240
+ Absolute path of the written file.
241
+ subject : dict
242
+ The subject as written.
243
+
244
+ Raises
245
+ ------
246
+ InvalidInput
247
+ If an argument is not valid, `repo` is not inside a git work tree, a
248
+ revision is not a commit, the file would be outside the review root,
249
+ or the subject does not match ``subject.schema.json``.
250
+ FileNotFoundError
251
+ If the review root does not exist.
252
+ FileExistsError
253
+ If the subject file exists and `force` is `False`, or another file
254
+ holds a subject with the same package and ID.
255
+ GitError
256
+ If git fails.
257
+ """
258
+ if not config.root.is_dir():
259
+ raise FileNotFoundError(f"Review root not found: {config.root} (run 'diffdesk init')")
260
+ sid = check_name(subject_id, "subject ID")
261
+ if commit is not None and (base is not None or head is not None):
262
+ raise InvalidInput("Give a commit, or a base and a head, not both")
263
+ if (base is None) != (head is None):
264
+ raise InvalidInput("Give both a base and a head")
265
+
266
+ top = gitio.toplevel(str(Path(repo).resolve()))
267
+ if top is None:
268
+ raise InvalidInput(f"Not inside a git work tree: {repo}")
269
+ repo_path = Path(top).resolve()
270
+ work_tree = str(repo_path)
271
+ if package is None:
272
+ try:
273
+ package = check_name(repo_path.name, "package")
274
+ except InvalidInput:
275
+ raise InvalidInput(
276
+ f"Folder name {repo_path.name!r} is not a valid package name; give a package"
277
+ ) from None
278
+ else:
279
+ package = check_name(package, "package")
280
+
281
+ target = (config.subjects / package / f"{sid}.json").resolve()
282
+ if not target.is_relative_to(config.root):
283
+ raise InvalidInput(f"Subject file would be outside the review root: {target}")
284
+ if target.exists() and not force:
285
+ raise FileExistsError(f"Subject file exists: {target}. Use --force to replace it.")
286
+ for path in subject_files(config.subjects):
287
+ if path.resolve() == target:
288
+ continue
289
+ parts = path.relative_to(config.subjects).parts
290
+ try:
291
+ other = parse_subject(path, parts[0] if len(parts) > 1 else DEFAULT_PACKAGE)
292
+ except (OSError, ValueError):
293
+ continue
294
+ if other.key == (package, sid):
295
+ raise FileExistsError(f"{path} already holds subject {sid!r} of package {package!r}")
296
+
297
+ revs = ["HEAD" if commit is None else commit] if base is None else [base, head]
298
+ shas = gitio.resolve(work_tree, [gitio.check_ref(r) for r in revs], "commit")
299
+ missing = [rev for rev, sha in shas.items() if sha is None]
300
+ if missing:
301
+ raise InvalidInput(f"Not a commit in {work_tree}: {', '.join(missing)}")
302
+ if base is None:
303
+ head_sha = shas[revs[0]]
304
+ parent = gitio.resolve(work_tree, [f"{head_sha}^"], "commit")[f"{head_sha}^"]
305
+ base_sha = parent or gitio.empty_tree(work_tree)
306
+ else:
307
+ base_sha, head_sha = shas[base], shas[head]
308
+ counts = gitio.numstat_many(work_tree, [(base_sha, head_sha)])[(base_sha, head_sha)]
309
+ if counts is None:
310
+ raise GitError(f"Cannot list the files changed between {base_sha} and {head_sha}")
311
+ files = [gitio.check_path(p) for p in sorted(counts)]
312
+
313
+ subject: dict[str, Any] = {"id": sid, "package": package, "title": title}
314
+ optional = {"priority": priority, "recommended": recommended, "summary": summary, "why": why}
315
+ subject.update({key: value for key, value in optional.items() if value is not None})
316
+ subject.update(repo=work_tree, base=base_sha, head=head_sha, files=files)
317
+ if branch is not None:
318
+ subject["branch"] = branch
319
+ if tags:
320
+ subject["tags"] = list(tags)
321
+ schema = json.loads(SCHEMA_PATH.read_text(encoding="utf-8"))
322
+ errors = schema_errors(subject, schema, schema, "$")
323
+ if errors:
324
+ raise InvalidInput("; ".join(errors))
325
+
326
+ write_atomic(target, (json.dumps(subject, indent=2, ensure_ascii=False) + "\n").encode())
327
+ return target, subject
328
+
329
+
330
+ def collect_reviews(
331
+ config: Config,
332
+ *,
333
+ statuses: Iterable[str] | None = None,
334
+ package: str | None = None,
335
+ subject_id: str | None = None,
336
+ ) -> list[dict[str, Any]]:
337
+ """Return the review state of each subject, in the order of the browser tree.
338
+
339
+ Parameters
340
+ ----------
341
+ config : Config
342
+ Settings of the review root.
343
+ statuses : iterable of str, optional
344
+ Keep only subjects with one of these statuses (see
345
+ ``index.STATUSES``). Default: every status.
346
+ package : str, optional
347
+ Keep only subjects of this package.
348
+ subject_id : str, optional
349
+ Keep only subjects with this ID (one per package that uses it).
350
+
351
+ Returns
352
+ -------
353
+ list of dict
354
+ One dict per subject: ``id``, ``package``, ``title``, ``status``,
355
+ and from the last review record ``verdict``, ``comment`` and ``at``
356
+ (all `None` if there is no record; ``at`` falls back to the
357
+ ``time`` field of old records). Then ``history_count`` (number of
358
+ review records), ``repo`` and ``head`` of the subject, and ``edits``:
359
+ ``[{path, edit_file}]``, where ``path`` is the file path in the
360
+ repository and ``edit_file`` the absolute path of the saved edit.
361
+
362
+ Raises
363
+ ------
364
+ InvalidInput
365
+ If a status is not one of ``index.STATUSES``.
366
+ ValueError
367
+ If ``reviews.json`` is not a JSON list.
368
+ """
369
+ wanted = set(statuses or ())
370
+ unknown = wanted - set(STATUSES)
371
+ if unknown:
372
+ raise InvalidInput(f"Unknown status {sorted(unknown)}; use {list(STATUSES)}")
373
+ snap = Index(config).snapshot()
374
+ result: list[dict[str, Any]] = []
375
+ for s in snap.subjects:
376
+ status = snap.status[s.key]
377
+ if (
378
+ (wanted and status not in wanted)
379
+ or (package and s.package != package)
380
+ or (subject_id and s.id != subject_id)
381
+ ):
382
+ continue
383
+ edits: list[dict[str, str]] = []
384
+ if s.key in snap.edited:
385
+ folder = config.edits / s.package / s.id
386
+ for dirpath, _dirnames, filenames in os.walk(folder):
387
+ for name in filenames:
388
+ # Temporary files of `write_atomic`.
389
+ if name.startswith(".") and name.endswith(".tmp"):
390
+ continue
391
+ edit_file = Path(dirpath, name)
392
+ edits.append(
393
+ {
394
+ "path": edit_file.relative_to(folder).as_posix(),
395
+ "edit_file": str(edit_file),
396
+ }
397
+ )
398
+ rec = snap.review.get(s.key) or {}
399
+ result.append(
400
+ {
401
+ "id": s.id,
402
+ "package": s.package,
403
+ "title": s.title,
404
+ "status": status,
405
+ "verdict": rec.get("verdict"),
406
+ "comment": rec.get("comment"),
407
+ "at": rec.get("at", rec.get("time")),
408
+ "history_count": snap.history_count.get(s.key, 0),
409
+ "repo": s.repo,
410
+ "head": s.head,
411
+ "edits": sorted(edits, key=lambda e: e["path"]),
412
+ }
413
+ )
414
+ return result
@@ -0,0 +1,112 @@
1
+ # diffdesk: guide for coding agents
2
+
3
+ diffdesk is a local review desk for commits. For each change, you make a commit
4
+ and write one subject file: the commit range and your reasons. A person reads
5
+ the reasons and the diff in the browser. The person accepts the change, rejects
6
+ it, or asks for a change. The person can also write a comment and edit the new
7
+ version of a file. You read the verdicts and the edits back with one command.
8
+
9
+ ## Steps
10
+
11
+ `REVIEW_ROOT` is optional: without it, diffdesk uses `$DIFFDESK_ROOT`, else the current folder.
12
+
13
+ 1. Make one commit for each change. Do not put unrelated changes in one commit.
14
+
15
+ 2. Write a subject for the commit:
16
+
17
+ diffdesk add REVIEW_ROOT --repo REPO --id FIX-12 \
18
+ --title "Keep the last page in the pager" \
19
+ --summary "The loop stopped one page early; it now includes the last page." \
20
+ --why-file why.md
21
+
22
+ - By default the diff is `HEAD^..HEAD`. Use `--commit REV` for another commit, or
23
+ `--base REV --head REV` for a range.
24
+ - diffdesk gets the full commit IDs, the repository path and the changed
25
+ files from git, and checks the subject against the schema.
26
+ - `--why-file -` reads the reasons from standard input. `--why TEXT` gives
27
+ them on the command line.
28
+ - Other options: `--package`, `--priority`, `--recommended`, `--tag`
29
+ (repeatable), `--branch`, `--json` (print the subject).
30
+ - diffdesk does not replace an existing subject. If you rewrite the commit
31
+ (rebase or amend), run the same command with `--force` to point the
32
+ subject at the new commit.
33
+
34
+ 3. Ask the person to review: `diffdesk serve REVIEW_ROOT --open`.
35
+
36
+ 4. Read the requests:
37
+
38
+ diffdesk reviews REVIEW_ROOT --status change --status rejected
39
+
40
+ 5. For each request, read the comment and the edits. Make a new commit and add
41
+ a new subject for it. Name the old subject ID in `why`.
42
+
43
+ ## Write a good `why`
44
+
45
+ `why` is Markdown. LaTeX in `$...$` is allowed. Use these headings:
46
+
47
+ - **Problem**: what is wrong, and where (file, function, input).
48
+ - **Evidence**: how you know. For example a failing test, an error message,
49
+ or a measurement.
50
+ - **Fix logic**: why this change removes the problem.
51
+ - **Test**: the command you ran and its result.
52
+ - **Tradeoffs**: what the change costs, what it does not fix, and the other
53
+ options that you did not use.
54
+
55
+ ## Output of `diffdesk reviews`
56
+
57
+ A JSON list with one object for each subject:
58
+
59
+ | Field | Meaning |
60
+ | --- | --- |
61
+ | `id`, `package`, `title` | The subject. |
62
+ | `status` | `pending`, `accepted`, `rejected` or `change` (the last verdict). |
63
+ | `verdict`, `comment`, `at` | The last review record: `accept`, `reject` or `change`, the comment, and the time. `null` if there is no record. |
64
+ | `history_count` | Number of review records for the subject. |
65
+ | `repo`, `head` | Work tree and new-side commit of the subject. |
66
+ | `edits` | `[{path, edit_file}]`: the file path in the repository and the absolute path of the saved edit. |
67
+
68
+ Filters: `--status` (repeatable), `--package`, `--id`. `--format text` prints a
69
+ short table for people.
70
+
71
+ ## Edits
72
+
73
+ An edit file holds the full new content of one file, as the person changed it.
74
+ It is not a patch. To see what the person changed, compare it with the version
75
+ of that file at the subject's `head`:
76
+
77
+ git -C REPO show SHA:PATH > head-version
78
+ git diff --no-index head-version EDIT_FILE
79
+
80
+ Here `SHA` is the `head` value of the subject, `PATH` is `path`, and
81
+ `EDIT_FILE` is `edit_file`.
82
+
83
+ ## Review root
84
+
85
+ REVIEW_ROOT/
86
+ diffdesk.toml optional settings
87
+ subjects/<package>/<ID>.json subjects (written by diffdesk add)
88
+ reviews.json verdicts, oldest first (written by the browser)
89
+ edits/<package>/<ID>/<path> edited files (written by the browser)
90
+ .diffdesk-cache/ cache, safe to delete
91
+
92
+ ## Subject fields
93
+
94
+ Only `id` and `title` are required. `diffdesk validate REVIEW_ROOT` checks
95
+ every subject file.
96
+
97
+ | Field | Meaning |
98
+ | --- | --- |
99
+ | `id` | Letters, digits, `.`, `_`, `-`. Starts with a letter or digit. No `..`. Unique inside its package. |
100
+ | `title` | One-line title. |
101
+ | `package` | Same rules as `id`. Default: the folder below `subjects/`. |
102
+ | `priority`, `origin`, `recommended` | For example `P1`; `new`; `accept`, `reject` or `user-decision`. |
103
+ | `summary` | One sentence: what is wrong and what the change does. |
104
+ | `why` | Markdown with the reasons. |
105
+ | `repo` | Absolute path of the git work tree. |
106
+ | `base`, `head` | Old and new side of the diff (commit IDs). |
107
+ | `files` | Paths to review, relative to `repo`. Empty: every changed file. |
108
+ | `tests` | Test command and result. |
109
+ | `decisions`, `refs`, `tags`, `depends_on` | Lists of strings: decision IDs, documents, labels, subject IDs. |
110
+ | `branch`, `order`, `senior_verdict` | Branch for the tree, position in the branch, verdict of a second reviewer. |
111
+
112
+ Other fields are kept and shown in a "More" table.