hotdocs 0.1.0a1__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.
- hotdocs/__init__.py +3 -0
- hotdocs/__main__.py +5 -0
- hotdocs/_entry.py +46 -0
- hotdocs/_tool/AUTHORING.md +185 -0
- hotdocs/_tool/QUICKSTART.md +308 -0
- hotdocs/_tool/SPEC_GUIDELINES.md +815 -0
- hotdocs/_tool/agent-skills/README.md +10 -0
- hotdocs/_tool/agent-skills/hotdocs-asset-kind/SKILL.md +121 -0
- hotdocs/_tool/examples/slugify/specs/components/slugify/acceptance/AC-SLUG-001.md +14 -0
- hotdocs/_tool/examples/slugify/specs/components/slugify/acceptance/AC-SLUG-002.md +14 -0
- hotdocs/_tool/examples/slugify/specs/components/slugify/acceptance/AC-SLUG-003.md +10 -0
- hotdocs/_tool/examples/slugify/specs/components/slugify/acceptance/AC-SLUG-004.md +18 -0
- hotdocs/_tool/examples/slugify/specs/components/slugify/component.md +51 -0
- hotdocs/_tool/examples/slugify/specs/components/slugify/constraints.md +3 -0
- hotdocs/_tool/examples/slugify/specs/components/slugify/interface/library.md +10 -0
- hotdocs/_tool/examples/slugify/specs/components/slugify/requirements/R-SLUG-001.md +5 -0
- hotdocs/_tool/examples/slugify/specs/components/slugify/requirements/R-SLUG-002.md +7 -0
- hotdocs/_tool/examples/slugify/specs/components/slugify/requirements/R-SLUG-003.md +5 -0
- hotdocs/_tool/examples/slugify/specs/components/slugify/requirements/R-SLUG-004.md +6 -0
- hotdocs/_tool/examples/slugify/specs/product/slugs.md +22 -0
- hotdocs/_tool/gen/README.md +24 -0
- hotdocs/_tool/gen/agentic-generator/.provenance.json +379 -0
- hotdocs/_tool/gen/agentic-generator/agentic_generator.py +427 -0
- hotdocs/_tool/gen/cache-manager/.provenance.json +458 -0
- hotdocs/_tool/gen/cache-manager/cache_manager.py +254 -0
- hotdocs/_tool/gen/capability-scenario-verifier/.provenance.json +469 -0
- hotdocs/_tool/gen/capability-scenario-verifier/capability_scenario_verifier.py +534 -0
- hotdocs/_tool/gen/citation-checker/.provenance.json +370 -0
- hotdocs/_tool/gen/citation-checker/citation_checker.py +219 -0
- hotdocs/_tool/gen/component-gate-runner/.provenance.json +375 -0
- hotdocs/_tool/gen/component-gate-runner/component_gate_runner.py +556 -0
- hotdocs/_tool/gen/corpus-graph-builder/.provenance.json +381 -0
- hotdocs/_tool/gen/corpus-graph-builder/corpus_graph_builder/__init__.py +192 -0
- hotdocs/_tool/gen/corpus-graph-builder/corpus_graph_builder/cli.py +51 -0
- hotdocs/_tool/gen/corpus-loader/.provenance.json +331 -0
- hotdocs/_tool/gen/corpus-loader/corpus_loader.py +249 -0
- hotdocs/_tool/gen/decision-drift-detector/.provenance.json +382 -0
- hotdocs/_tool/gen/decision-drift-detector/decision_drift_detector.py +338 -0
- hotdocs/_tool/gen/docs-site-renderer/.provenance.json +381 -0
- hotdocs/_tool/gen/docs-site-renderer/docs_site_renderer/__init__.py +188 -0
- hotdocs/_tool/gen/docs-site-renderer/docs_site_renderer/cli.py +69 -0
- hotdocs/_tool/gen/docs-site-renderer/static/app.js +111 -0
- hotdocs/_tool/gen/generation-loop/.provenance.json +341 -0
- hotdocs/_tool/gen/generation-loop/generation_loop.py +287 -0
- hotdocs/_tool/gen/generator/.provenance.json +600 -0
- hotdocs/_tool/gen/generator/generator.py +469 -0
- hotdocs/_tool/gen/graph-query-engine/.provenance.json +385 -0
- hotdocs/_tool/gen/graph-query-engine/graph_query_engine.py +230 -0
- hotdocs/_tool/gen/hotdocs-cli/.provenance.json +371 -0
- hotdocs/_tool/gen/hotdocs-cli/hotdocs_cli.py +339 -0
- hotdocs/_tool/gen/hotdocs-init/.provenance.json +342 -0
- hotdocs/_tool/gen/hotdocs-init/hotdocs_init.py +463 -0
- hotdocs/_tool/gen/impact-analyzer/.provenance.json +418 -0
- hotdocs/_tool/gen/impact-analyzer/impact_analyzer.py +350 -0
- hotdocs/_tool/gen/kind-javascript/.provenance.json +482 -0
- hotdocs/_tool/gen/kind-javascript/kind_javascript.py +371 -0
- hotdocs/_tool/gen/kind-python/.provenance.json +433 -0
- hotdocs/_tool/gen/kind-python/kind_python.py +371 -0
- hotdocs/_tool/gen/license-scanner/.provenance.json +508 -0
- hotdocs/_tool/gen/license-scanner/license_scanner.py +388 -0
- hotdocs/_tool/gen/llm-endpoint/.provenance.json +494 -0
- hotdocs/_tool/gen/llm-endpoint/llm_endpoint.py +638 -0
- hotdocs/_tool/gen/llm-tool-endpoint/.provenance.json +409 -0
- hotdocs/_tool/gen/llm-tool-endpoint/llm_tool_endpoint.py +465 -0
- hotdocs/_tool/gen/provenance-checker/.provenance.json +495 -0
- hotdocs/_tool/gen/provenance-checker/provenance_checker.py +492 -0
- hotdocs/_tool/gen/provenance-tracker/.provenance.json +354 -0
- hotdocs/_tool/gen/provenance-tracker/provenance_tracker.py +423 -0
- hotdocs/_tool/gen/provenance-tracker-ui/.provenance.json +376 -0
- hotdocs/_tool/gen/provenance-tracker-ui/provenance_tracker_ui.py +309 -0
- hotdocs/_tool/gen/provenance-tracker-ui/static/app.js +23 -0
- hotdocs/_tool/gen/provenance-writer/.provenance.json +602 -0
- hotdocs/_tool/gen/provenance-writer/provenance_writer.py +315 -0
- hotdocs/_tool/gen/review-packet-builder/.provenance.json +378 -0
- hotdocs/_tool/gen/review-packet-builder/review_packet_builder.py +299 -0
- hotdocs/_tool/gen/secret-scanner/.provenance.json +558 -0
- hotdocs/_tool/gen/secret-scanner/secret_scanner.py +553 -0
- hotdocs/_tool/gen/size-checker/.provenance.json +393 -0
- hotdocs/_tool/gen/size-checker/size_checker.py +248 -0
- hotdocs/_tool/gen/spec-bundle-assembler/.provenance.json +573 -0
- hotdocs/_tool/gen/spec-bundle-assembler/spec_bundle_assembler.py +472 -0
- hotdocs/_tool/gen/spec-completeness-assistant/.provenance.json +357 -0
- hotdocs/_tool/gen/spec-completeness-assistant/spec_completeness_assistant.py +412 -0
- hotdocs/_tool/gen/spec-linter/.provenance.json +741 -0
- hotdocs/_tool/gen/spec-linter/spec_linter.py +894 -0
- hotdocs/_tool/gen/spec-reviewer/.provenance.json +342 -0
- hotdocs/_tool/gen/spec-reviewer/spec_reviewer.py +527 -0
- hotdocs/_tool/gen/spec-scaffolder/.provenance.json +397 -0
- hotdocs/_tool/gen/spec-scaffolder/spec_scaffolder.py +535 -0
- hotdocs/_tool/gen/surface-checker/.provenance.json +334 -0
- hotdocs/_tool/gen/surface-checker/surface_checker.py +322 -0
- hotdocs/_tool/gen/test-author/.provenance.json +506 -0
- hotdocs/_tool/gen/test-author/test_author.py +465 -0
- hotdocs/_tool/gen/test-probe/.provenance.json +379 -0
- hotdocs/_tool/gen/test-probe/test_probe.py +424 -0
- hotdocs/_tool/gen/verifier-orchestrator/.provenance.json +655 -0
- hotdocs/_tool/gen/verifier-orchestrator/verifier_orchestrator.py +878 -0
- hotdocs/_tool/pipeline/README.md +26 -0
- hotdocs/_tool/pipeline/criterion-compiler/.sealed-provenance.json +17 -0
- hotdocs/_tool/pipeline/criterion-compiler/criterion_compiler.py +529 -0
- hotdocs/_tool/pyproject.toml +38 -0
- hotdocs/_tool/requirements.txt +6 -0
- hotdocs/_tool/specs/architecture/asset-kind-javascript.md +106 -0
- hotdocs/_tool/specs/architecture/asset-kind-python.md +115 -0
- hotdocs/_tool/specs/architecture/asset-kinds.md +240 -0
- hotdocs/_tool/specs/architecture/cli-conventions.md +47 -0
- hotdocs/_tool/specs/architecture/step-phrase-grammar.md +84 -0
- hotdocs-0.1.0a1.dist-info/METADATA +140 -0
- hotdocs-0.1.0a1.dist-info/RECORD +113 -0
- hotdocs-0.1.0a1.dist-info/WHEEL +5 -0
- hotdocs-0.1.0a1.dist-info/entry_points.txt +2 -0
- hotdocs-0.1.0a1.dist-info/licenses/LICENSE +190 -0
- hotdocs-0.1.0a1.dist-info/top_level.txt +1 -0
hotdocs/__init__.py
ADDED
hotdocs/__main__.py
ADDED
hotdocs/_entry.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""hotdocs_entry.py — the console entry point behind the `hotdocs` command.
|
|
3
|
+
|
|
4
|
+
HAND-AUTHORED REPO TOOL, not a spec-driven component (SPEC_GUIDELINES.md
|
|
5
|
+
§1's `tools/` entry). It does one thing: load the `hotdocs-cli`
|
|
6
|
+
component's module by path from the tool root's `gen/hotdocs-cli/` and
|
|
7
|
+
hand `argv` to its `run`, passing the tool root every project's
|
|
8
|
+
components fall back to (D199). The tool root is the `_tool/` directory
|
|
9
|
+
beside this file in an installed package (`tools/build_dist.py`, D358),
|
|
10
|
+
else this repository, for an editable install (`pip install -e <repo>`).
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import importlib.util
|
|
16
|
+
import sys
|
|
17
|
+
from pathlib import Path
|
|
18
|
+
|
|
19
|
+
_PACKAGED = Path(__file__).resolve().parent / "_tool"
|
|
20
|
+
TOOL_ROOT = _PACKAGED if _PACKAGED.is_dir() else Path(__file__).resolve().parents[1]
|
|
21
|
+
_MODULE_PATH = TOOL_ROOT / "gen" / "hotdocs-cli" / "hotdocs_cli.py"
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def main(argv: list[str] | None = None) -> int:
|
|
25
|
+
if not _MODULE_PATH.is_file():
|
|
26
|
+
print(
|
|
27
|
+
f"hotdocs: the hotdocs-cli component is missing from the tool root "
|
|
28
|
+
f"({_MODULE_PATH}). Reinstall the hotdocs package, or use an editable "
|
|
29
|
+
f"install of a complete checkout: `pip install -e <path to the "
|
|
30
|
+
f"hotdocs repository>`.",
|
|
31
|
+
file=sys.stderr,
|
|
32
|
+
)
|
|
33
|
+
return 2
|
|
34
|
+
spec = importlib.util.spec_from_file_location("hotdocs_cli", _MODULE_PATH)
|
|
35
|
+
module = importlib.util.module_from_spec(spec)
|
|
36
|
+
sys.modules["hotdocs_cli"] = module
|
|
37
|
+
spec.loader.exec_module(module)
|
|
38
|
+
args = sys.argv[1:] if argv is None else argv
|
|
39
|
+
# `run` is the injectable form; a hotdocs-cli generated before it
|
|
40
|
+
# existed takes the same keywords on `main`.
|
|
41
|
+
entry = getattr(module, "run", None) or module.main
|
|
42
|
+
return int(entry(args, tool_root=TOOL_ROOT) or 0)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
if __name__ == "__main__":
|
|
46
|
+
sys.exit(main())
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
# Writing specs that generate well
|
|
2
|
+
|
|
3
|
+
`QUICKSTART.md` gets a component generated. This guide is about writing the
|
|
4
|
+
spec so it generates *correctly the first time*, from a model that has never
|
|
5
|
+
seen your codebase and cannot ask you anything. `SPEC_GUIDELINES.md` is the
|
|
6
|
+
normative reference; this is the practical companion. In an installed
|
|
7
|
+
package, `SPEC_GUIDELINES.md` and the `specs/architecture/` documents this
|
|
8
|
+
guide names for the tool's own rules sit beside it, not in your project.
|
|
9
|
+
|
|
10
|
+
## 1. Each model sees only part of your spec
|
|
11
|
+
|
|
12
|
+
Three models read your spec, and none sees all of it.
|
|
13
|
+
|
|
14
|
+
| Who | Sees | Never sees |
|
|
15
|
+
| --- | --- | --- |
|
|
16
|
+
| The generator, writing `gen/<component>/` | `component.md`, `requirements/`, `interface/` (with any `Implements:` documents), `constraints.md`, its dependencies' `interface/`, the glossary | `acceptance/`, any test |
|
|
17
|
+
| A test author, writing one criterion's test | that one criterion, the requirement it `Covers:`, the component's `interface/` (with `Implements:` documents), its dependencies' `interface/`, the glossary | other criteria, other requirements, `constraints.md`, the code |
|
|
18
|
+
| The judge, for an `llm-judge` criterion | the criterion, its requirement, the interface, the code | other criteria |
|
|
19
|
+
|
|
20
|
+
Two rules follow, and most failed generations break one of them.
|
|
21
|
+
|
|
22
|
+
- **Every behavior a criterion expects must be stated in a requirement or
|
|
23
|
+
the interface.** The generator never sees criteria, so a value, error or
|
|
24
|
+
edge case that only a criterion mentions is one the code will not have.
|
|
25
|
+
Since D252 the generator is told to implement exactly what the spec says
|
|
26
|
+
and nothing more, so an unstated behavior is a guaranteed failure, not a
|
|
27
|
+
lucky guess.
|
|
28
|
+
- **Every rule a test needs must be stated where that test's author can see
|
|
29
|
+
it:** in the criterion itself, its covered requirement, or the interface.
|
|
30
|
+
A rule written in another requirement, in `constraints.md` or in a
|
|
31
|
+
decision record is invisible to the test author.
|
|
32
|
+
|
|
33
|
+
`hotdocs spec check` looks for both problems before you generate.
|
|
34
|
+
|
|
35
|
+
## 2. Where shared rules go
|
|
36
|
+
|
|
37
|
+
A rule that many criteria need, such as a reply format, a fixture layout,
|
|
38
|
+
or the CLI's exit-code conventions, belongs in a document under
|
|
39
|
+
`specs/architecture/`. Name it on the component's `interface/library.md`:
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
Implements: `specs/architecture/cli-conventions.md`
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The document is then part of the interface every generator and test author
|
|
46
|
+
sees, and it does not count toward the component's word cap.
|
|
47
|
+
|
|
48
|
+
Watch for criteria that combine requirements. A criterion that checks the
|
|
49
|
+
order of several checks' findings, or that "only one finding" appears,
|
|
50
|
+
depends on every rule that could add one, yet its test author sees only
|
|
51
|
+
the one requirement it covers. Summarize how the pieces fit together (the
|
|
52
|
+
checks in order, what triggers each, exact messages) in a section of the
|
|
53
|
+
interface. When the tool's own `test-probe` and `surface-checker` were
|
|
54
|
+
first reviewed with `hotdocs spec check`, most of the gaps it found were
|
|
55
|
+
of this kind.
|
|
56
|
+
|
|
57
|
+
## 3. Choosing a criterion's kind
|
|
58
|
+
|
|
59
|
+
| Kind | Use when | The test is |
|
|
60
|
+
| --- | --- | --- |
|
|
61
|
+
| `compiled` | The behavior fits the step grammar (`specs/architecture/step-phrase-grammar.md`): call a function with literal inputs, compare a result field or the whole result with a literal | compiled deterministically; no model involved |
|
|
62
|
+
| `generated-test` | Setup or assertions the grammar can't express: files on disk, several calls, exceptions, CLI exit codes | written by a test author from the criterion |
|
|
63
|
+
| `llm-judge` | A quality, not a runtime behavior: documentation tone, a design rule | a model's verdict with rationale |
|
|
64
|
+
|
|
65
|
+
Prefer `compiled`, then `generated-test`. Use `llm-judge` sparingly: it is
|
|
66
|
+
the least reproducible.
|
|
67
|
+
|
|
68
|
+
## 4. Writing a criterion a test author can implement
|
|
69
|
+
|
|
70
|
+
A good criterion names concrete inputs and exact outputs, and its covered
|
|
71
|
+
requirement names every behavior it checks.
|
|
72
|
+
|
|
73
|
+
**Vague:**
|
|
74
|
+
|
|
75
|
+
```gherkin
|
|
76
|
+
Given a bad title
|
|
77
|
+
When slugify runs
|
|
78
|
+
Then it fails gracefully
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**Testable:**
|
|
82
|
+
|
|
83
|
+
```gherkin
|
|
84
|
+
Given the title "" (an empty string)
|
|
85
|
+
When slugify(title) is called
|
|
86
|
+
Then it raises ValueError, its message containing "empty"
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
and the requirement says: *"`slugify` MUST raise `ValueError` with a
|
|
90
|
+
message containing `empty` when `title` is empty."*
|
|
91
|
+
|
|
92
|
+
Checklist:
|
|
93
|
+
|
|
94
|
+
- **Concrete values.** Literal inputs and exact expected outputs, not
|
|
95
|
+
"a valid input" or "the correct result".
|
|
96
|
+
- **Exact shapes.** If a result is a dict, a JSON document or a file,
|
|
97
|
+
state its keys and types in `interface/data/<Type>.md`, and have the
|
|
98
|
+
criterion assert specific fields.
|
|
99
|
+
- **Errors by name.** Name the exception class, error category or exit
|
|
100
|
+
code in a requirement, not only in a criterion.
|
|
101
|
+
- **Fixtures stated.** If tests must build files on disk, describe the
|
|
102
|
+
layout in a "Test fixtures" section of `interface/library.md`: what a
|
|
103
|
+
minimal valid input tree looks like, which files are required.
|
|
104
|
+
- **One behavior per criterion,** with Given, When and Then each present.
|
|
105
|
+
`hotdocs lint` fails a criterion missing any of them.
|
|
106
|
+
- **Cover edges.** Empty input, maximum size, unicode, an absent optional
|
|
107
|
+
argument, each failure mode. A generated-test criterion can carry several
|
|
108
|
+
scenarios; one per edge is clearer.
|
|
109
|
+
|
|
110
|
+
### Examples from the tool's own rebuild
|
|
111
|
+
|
|
112
|
+
Each of these failed a real generation and was fixed in the spec:
|
|
113
|
+
|
|
114
|
+
| What went wrong | Fix |
|
|
115
|
+
| --- | --- |
|
|
116
|
+
| A test needed the compiled step grammar but its author never saw it, so it guessed six phrasings | `Implements: specs/architecture/step-phrase-grammar.md` on the interface |
|
|
117
|
+
| A criterion expected a reply format stated only in one requirement; other criteria's authors faked replies wrongly | The format moved to `interface/library.md` |
|
|
118
|
+
| A criterion expected a command to print its usage error; no requirement said so, and the generated code exited silently | The requirement now says every usage error prints one line to stderr |
|
|
119
|
+
| A decision's `supersedes` was written as a list in one spec and a single id in another; the test followed the wrong one | Both state the scalar form |
|
|
120
|
+
| A criterion said "within a minute"; a test author built a fixture too slow for the verifier's limit | The criterion states the exact bound and fixture size |
|
|
121
|
+
|
|
122
|
+
## 5. Files in other languages
|
|
123
|
+
|
|
124
|
+
When a component produces something other than Python, such as the
|
|
125
|
+
JavaScript a page runs, declare it as an asset (`assets:
|
|
126
|
+
[javascript:static/app.js]` in `component.md`) instead of keeping it in
|
|
127
|
+
Python strings. Then:
|
|
128
|
+
|
|
129
|
+
- list its interface the way the kind's definition asks: for
|
|
130
|
+
`javascript`, one `export function` signature per line in a fenced
|
|
131
|
+
block of the interface file;
|
|
132
|
+
- write criteria that call it through the `asset_runner` fixture with
|
|
133
|
+
concrete JSON arguments and an exact expected result, so its tests can
|
|
134
|
+
be mutation-tested on the asset itself;
|
|
135
|
+
- keep the asset's logic in pure functions over JSON values, and leave
|
|
136
|
+
wiring (event handlers, the DOM) thin, since only functions a criterion
|
|
137
|
+
can call are checked.
|
|
138
|
+
|
|
139
|
+
The kind's definition (`specs/architecture/asset-kind-<kind>.md`) gives
|
|
140
|
+
its test author and its generator their own guidance, so a criterion only
|
|
141
|
+
needs the facts specific to this component. `QUICKSTART.md` §5 covers
|
|
142
|
+
declaring assets, `hotdocs kind new` and the project Python environment.
|
|
143
|
+
|
|
144
|
+
## 6. Size limits
|
|
145
|
+
|
|
146
|
+
The linter fails a component's docs above 4,000 words, any single
|
|
147
|
+
requirement or criterion file above 500 words, and a `Purpose` section above
|
|
148
|
+
150 words. It warns well before. When a component nears the cap:
|
|
149
|
+
|
|
150
|
+
- move rationale and history into decision records,
|
|
151
|
+
- move shared rules into `specs/architecture/` documents,
|
|
152
|
+
- or split it: a second component with its own interface, which the first
|
|
153
|
+
lists in `depends_on`.
|
|
154
|
+
|
|
155
|
+
`hotdocs lint` also warns when several size dimensions are high at once:
|
|
156
|
+
that is a decomposition signal, not just a length problem.
|
|
157
|
+
|
|
158
|
+
## 7. Recording decisions
|
|
159
|
+
|
|
160
|
+
A decision record (`specs/decisions/D<N>.md`) explains why the spec says
|
|
161
|
+
what it says. Records are immutable once ratified: a change is a new
|
|
162
|
+
record, which may name the old one in `supersedes`.
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
hotdocs decision new "Slugs are lowercase ASCII" # writes a draft with the next id
|
|
166
|
+
hotdocs decision ratify D7 # status: ratified
|
|
167
|
+
git commit ... # commit the record with the spec change
|
|
168
|
+
hotdocs decision record-commit D7 # fills last_ratified_commit, then commit again
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
`last_ratified_commit` names the commit that landed the record, so it is
|
|
172
|
+
filled in by a follow-up commit. Cite a decision from a spec by its id in
|
|
173
|
+
backticks, such as `` `D7` ``.
|
|
174
|
+
|
|
175
|
+
## 8. Checking before you generate
|
|
176
|
+
|
|
177
|
+
```
|
|
178
|
+
hotdocs lint # structure, coverage, sizes, citations
|
|
179
|
+
hotdocs spec check comp-slugify # can each criterion's test author write it?
|
|
180
|
+
hotdocs assist --changed=comp-slugify # completeness, redundancy, blast radius
|
|
181
|
+
hotdocs impact --changed=comp-slugify # what else the change touches
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
`spec check` and `assist` use your configured model when one is set in
|
|
185
|
+
`hotdocs.toml`; pass `--no-model` to run only their deterministic checks.
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
# Quickstart
|
|
2
|
+
|
|
3
|
+
hotdocs turns written specs into verified code: you write what a
|
|
4
|
+
component must do and how to check it, `hotdocs generate` has a model write
|
|
5
|
+
the code and its tests, and `hotdocs verify` says whether everything is
|
|
6
|
+
ready. A component's code is Python; it can also declare files of other
|
|
7
|
+
kinds, such as a JavaScript module (section 5).
|
|
8
|
+
|
|
9
|
+
## 1. Install
|
|
10
|
+
|
|
11
|
+
You need Python 3.11 or newer and a model provider: the `claude` command
|
|
12
|
+
signed in, or an API key in an environment variable (Anthropic, OpenAI,
|
|
13
|
+
Gemini, any OpenAI-compatible server, or a local Ollama). Node 24 or
|
|
14
|
+
newer is needed only if a component declares a JavaScript asset.
|
|
15
|
+
|
|
16
|
+
From PyPI, as an isolated command-line tool:
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
pipx install --pip-args=--pre hotdocs # or: uv tool install --prerelease=allow hotdocs
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Releases are alpha pre-releases for now, which pip skips unless asked.
|
|
23
|
+
|
|
24
|
+
With Homebrew, from the tap: `brew install <owner>/hotdocs/hotdocs`
|
|
25
|
+
(`packaging/homebrew/hotdocs.rb`). Either way the tool's own components
|
|
26
|
+
ship inside the package, read-only, and every project uses them from there.
|
|
27
|
+
This guide, `AUTHORING.md` and `agent-skills/` ship there too: `hotdocs
|
|
28
|
+
init` ends by printing this guide's path, and the other two sit beside it.
|
|
29
|
+
So do the documents they refer to that a project has no copy of
|
|
30
|
+
(`SPEC_GUIDELINES.md`, and under `specs/architecture/` the asset-kind
|
|
31
|
+
documents, `step-phrase-grammar.md` and `cli-conventions.md`), at those
|
|
32
|
+
paths from this guide's directory.
|
|
33
|
+
|
|
34
|
+
To work on hotdocs itself, install a checkout instead:
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
git clone <this repository> hotdocs && cd hotdocs
|
|
38
|
+
python3 -m venv .venv && . .venv/bin/activate
|
|
39
|
+
pip install -e .
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The editable install matters here: the tool's components are files in the
|
|
43
|
+
checkout, so `git pull` updates the tool for every project that uses this
|
|
44
|
+
environment. Keep it active in each project, or put its `bin/` on `PATH`.
|
|
45
|
+
|
|
46
|
+
Dependencies are pinned exactly in `requirements.txt`, which both installs
|
|
47
|
+
use and `hotdocs init` checks. `hotdocs lint` and the graph views load
|
|
48
|
+
DuckDB's `yaml` extension on first use, which needs network access once.
|
|
49
|
+
|
|
50
|
+
## 2. Create a project
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
mkdir myproject && cd myproject
|
|
54
|
+
hotdocs init --example
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
`init` creates `specs/`, `gen/` and `verification/`, records the tool
|
|
58
|
+
version in `.hotdocs-tool.json`, and asks which model provider to use
|
|
59
|
+
(`--provider claude-cli --yes` skips the questions). It tests the
|
|
60
|
+
connection, never asks for an API key, and stores only the *name* of the
|
|
61
|
+
environment variable that holds it in `hotdocs.toml`. `--example` adds a
|
|
62
|
+
tiny `slugify` component to start from.
|
|
63
|
+
|
|
64
|
+
Your `gen/` holds only your own components; the tool's stay in the tool, so
|
|
65
|
+
a component of yours may not reuse one of the tool's names (`hotdocs lint`
|
|
66
|
+
says so). `init` also writes an empty `.secret-allowlist.json`. To allow a
|
|
67
|
+
flagged string that is not a secret, add it to that file and record the
|
|
68
|
+
file's hash in a ratified decision (`allowlist_sha256` in its frontmatter):
|
|
69
|
+
the scanner honors a non-empty list only while its hash matches.
|
|
70
|
+
|
|
71
|
+
Run `init` again any time; it never overwrites. `hotdocs init --reconfigure`
|
|
72
|
+
changes only the provider.
|
|
73
|
+
|
|
74
|
+
Running `hotdocs` from inside a Claude Code session (an agent driving it)
|
|
75
|
+
with `claude-cli`: Claude Code sets `ANTHROPIC_API_KEY` for the commands
|
|
76
|
+
it starts, and that key does not work for a separate `claude -p` call.
|
|
77
|
+
Use your claude.ai login instead with `hotdocs init --provider claude-cli
|
|
78
|
+
--auth login`, or add `auth = "login"` to the `[llm]` table of
|
|
79
|
+
`hotdocs.toml`. Make the project a git repository: `hotdocs impact` and
|
|
80
|
+
`hotdocs assist` diff against its default branch (`origin/HEAD`'s target,
|
|
81
|
+
else `main`, else `master`).
|
|
82
|
+
|
|
83
|
+
## 3. Generate and verify
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
hotdocs lint # is the spec well-formed?
|
|
87
|
+
hotdocs generate comp-slugify # model writes code and tests, then checks them
|
|
88
|
+
hotdocs verify # is everything ready?
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
`generate` writes `gen/slugify/` and `verification/slugify/`. Never edit
|
|
92
|
+
`gen/` by hand: change the spec and generate again.
|
|
93
|
+
|
|
94
|
+
`generate` makes up to three attempts: when a candidate fails, the next
|
|
95
|
+
attempt is told which requirement ids failed (never the tests
|
|
96
|
+
themselves). `--max-attempts=1` makes one. With `--mode=agentic` the model
|
|
97
|
+
instead works in a sandbox: it writes the module, imports it, writes and
|
|
98
|
+
runs its own tests, and revises before finishing. Agentic mode needs a
|
|
99
|
+
provider with tool use (`anthropic`, `openai`, `openai-compatible` or
|
|
100
|
+
`claude-cli`) and an OS sandbox (`sandbox-exec` on macOS, `bwrap` on
|
|
101
|
+
Linux); without one the model's code is not run unless you pass
|
|
102
|
+
`--allow-unisolated-exec`. Defaults can go in `hotdocs.toml`:
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
[generate]
|
|
106
|
+
max_attempts = 3
|
|
107
|
+
mode = "single"
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Other commands you will reach for: `hotdocs spec check comp-slugify` (can
|
|
111
|
+
each criterion's test be written from what its author sees?),
|
|
112
|
+
`hotdocs impact --changed=comp-slugify` (what a spec change touches),
|
|
113
|
+
`hotdocs assist --changed=comp-slugify` (a model's review of the change:
|
|
114
|
+
lint findings, blast radius, a completeness score, overlaps),
|
|
115
|
+
`hotdocs decision new "<title>"` (record why), `hotdocs component new
|
|
116
|
+
<name>` (lay out a component), `hotdocs track ui build` (a readiness page)
|
|
117
|
+
and `hotdocs docs-site build` (a browsable site of the specs, written to
|
|
118
|
+
`dist/`). Those last two read `verification/corpus-graph.json`, so run
|
|
119
|
+
`hotdocs corpus-graph build` first, and again after the specs change.
|
|
120
|
+
Verbs that can use a model take the one in `hotdocs.toml`, saying so on
|
|
121
|
+
stderr; `--no-model` skips it. `hotdocs` alone lists every verb, and
|
|
122
|
+
`hotdocs <verb> --help` prints one verb's usage.
|
|
123
|
+
|
|
124
|
+
## 4. Write your own component
|
|
125
|
+
|
|
126
|
+
A component is a directory of small files, as in the example
|
|
127
|
+
(`specs/components/slugify/`):
|
|
128
|
+
|
|
129
|
+
- `component.md` — the id (`comp-<name>`), owners, and the capability it
|
|
130
|
+
`realizes`;
|
|
131
|
+
- `requirements/R-<NAME>-001.md` — one requirement per file, each with
|
|
132
|
+
`MUST`;
|
|
133
|
+
- `interface/library.md` — the exact function signatures;
|
|
134
|
+
- `acceptance/AC-<NAME>-001.md` — a `Covers:` line naming a requirement and
|
|
135
|
+
a Given/When/Then with concrete values;
|
|
136
|
+
- `constraints.md`.
|
|
137
|
+
|
|
138
|
+
A component realizes a capability: what the product does for its user,
|
|
139
|
+
one file in `specs/product/`. Lay out both:
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
hotdocs capability new slugs # specs/product/slugs.md, id P-SLUGS
|
|
143
|
+
hotdocs component new slugify --realizes=P-SLUGS
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Without `--realizes`, `component new` writes `realizes: []`, which
|
|
147
|
+
`hotdocs lint` rejects. A finished capability file looks like the
|
|
148
|
+
example's `specs/product/slugs.md`:
|
|
149
|
+
|
|
150
|
+
```
|
|
151
|
+
---
|
|
152
|
+
id: P-SLUGS
|
|
153
|
+
title: Titles Become URL Slugs
|
|
154
|
+
status: draft
|
|
155
|
+
owners: [web-team]
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
# Titles Become URL Slugs
|
|
159
|
+
|
|
160
|
+
## Purpose
|
|
161
|
+
|
|
162
|
+
A page title can be turned into a URL-safe slug.
|
|
163
|
+
|
|
164
|
+
### CS-SLUGS-001
|
|
165
|
+
Covers: P-SLUGS
|
|
166
|
+
Kind: generated-test
|
|
167
|
+
|
|
168
|
+
(a Given/When/Then in a `gherkin` block, as in an acceptance criterion)
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
A capability needs at least one scenario: `hotdocs verify` never reports
|
|
172
|
+
one without as ready, and says it `has no capability scenarios`. A
|
|
173
|
+
scenario is checked against the generated code of every component that
|
|
174
|
+
realizes the capability, so `hotdocs verify` runs it only with a model.
|
|
175
|
+
|
|
176
|
+
Run `hotdocs lint` after every change, and `hotdocs spec check
|
|
177
|
+
comp-<name>` before generating. The most useful habit: state concrete
|
|
178
|
+
inputs and outputs in each acceptance criterion, and name every function the
|
|
179
|
+
code must provide. What you leave implicit, the model guesses.
|
|
180
|
+
|
|
181
|
+
Two rules matter most, because the model that writes the code never sees
|
|
182
|
+
the acceptance criteria, and the model that writes each criterion's test
|
|
183
|
+
sees only that criterion, its covered requirement and the interface:
|
|
184
|
+
|
|
185
|
+
- every behavior a criterion checks must also be stated in a requirement;
|
|
186
|
+
- every fact a test needs (a value, a file layout, an error) must be in the
|
|
187
|
+
criterion, its requirement or the interface.
|
|
188
|
+
|
|
189
|
+
A component's docs are capped at 4,000 words and each file at 500.
|
|
190
|
+
`AUTHORING.md` covers all of this in depth: criterion kinds, writing
|
|
191
|
+
testable criteria, shared rules in `specs/architecture/`, decision
|
|
192
|
+
records, and when to split a component.
|
|
193
|
+
|
|
194
|
+
## 5. Other languages and files: asset kinds
|
|
195
|
+
|
|
196
|
+
A component's Python code is its implicit `python` asset. Anything else it
|
|
197
|
+
produces is declared in `component.md`'s frontmatter, one line, as
|
|
198
|
+
`<kind>:<path>` relative to the component's `gen/` directory:
|
|
199
|
+
|
|
200
|
+
```
|
|
201
|
+
assets: [javascript:static/app.js]
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
Every declared asset also needs an interface file,
|
|
205
|
+
`interface/assets/<file name>.md` (for `static/app.js`,
|
|
206
|
+
`interface/assets/app.js.md`), stating its surface in the kind's
|
|
207
|
+
notation. For `javascript` that is one export per line in a fenced block,
|
|
208
|
+
followed by what each function takes and returns:
|
|
209
|
+
|
|
210
|
+
```
|
|
211
|
+
export function filterNodes(nodes, query)
|
|
212
|
+
export function init(document)
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Without that file every attempt fails the surface check, and `hotdocs
|
|
216
|
+
generate` reports `surface_check_failed` with the file it expected.
|
|
217
|
+
|
|
218
|
+
Each kind has a definition (`specs/architecture/asset-kind-<kind>.md`:
|
|
219
|
+
layout, environment, how criteria call it, how its tests are
|
|
220
|
+
strength-checked, and guidance for the model) and an adapter component,
|
|
221
|
+
`comp-kind-<kind>`, that the pipeline runs. The built-in kinds are
|
|
222
|
+
`python` and `javascript` (one ES module of pure functions over JSON
|
|
223
|
+
values, run in Node 24 or newer); their definitions ship with the tool,
|
|
224
|
+
beside this guide, not in a project. A criterion calls an exported function
|
|
225
|
+
through the `asset_runner` fixture, and its tests are mutation-tested on
|
|
226
|
+
the JavaScript itself. Never hide another language inside Python strings:
|
|
227
|
+
declare it as an asset. An undeclared kind fails `hotdocs lint`.
|
|
228
|
+
|
|
229
|
+
To add a kind, `hotdocs kind new <kind> --realizes=P-<CAPABILITY>` lays
|
|
230
|
+
out its definition, its adapter component and a draft decision; as with
|
|
231
|
+
`component new`, without `--realizes` the adapter fails `hotdocs lint`. The
|
|
232
|
+
`hotdocs-asset-kind` skill in `agent-skills/` walks an agent through
|
|
233
|
+
filling them in.
|
|
234
|
+
|
|
235
|
+
**The Python environment.** By default a project's code runs in the
|
|
236
|
+
environment `hotdocs` runs in. To give it its own, commit
|
|
237
|
+
`environments/python/requirements.lock` (it must pin `pytest`): `hotdocs`
|
|
238
|
+
builds `.hotdocs/env/python/` from it on first use, so the code cannot
|
|
239
|
+
import a package the project never declared. To require a Python version,
|
|
240
|
+
put a prefix such as `3.14` in `environments/python/python-version`.
|
|
241
|
+
Provenance records the Python version and a fingerprint of the installed
|
|
242
|
+
packages, so a component generated under one environment misses under
|
|
243
|
+
another, with the reason `environment differs`. `hotdocs generate` then
|
|
244
|
+
re-verifies the committed code first and regenerates only if that fails.
|
|
245
|
+
|
|
246
|
+
## 6. Reading a failure
|
|
247
|
+
|
|
248
|
+
`hotdocs generate` lists each attempt and, if none passed, ends with
|
|
249
|
+
`blocked` and a reason:
|
|
250
|
+
|
|
251
|
+
- `model_call_error` — no usable code was produced. A network, auth,
|
|
252
|
+
rate-limit or timeout error is not retried: run it again later.
|
|
253
|
+
`truncated_response` means the reply was cut off: raise the provider's
|
|
254
|
+
output limit (below). For `empty_response` the message shows the start
|
|
255
|
+
of what the model replied, which often names a detail the spec left
|
|
256
|
+
out.
|
|
257
|
+
- `surface_check_failed` — the code did not import, used a name a
|
|
258
|
+
dependency lacks, mishandled an unknown command-line argument, or an
|
|
259
|
+
asset lacks an export its interface lists or has no interface file. A
|
|
260
|
+
`surface:` line gives each finding.
|
|
261
|
+
- An environment failure (`javascript needs node >= 24`, `python
|
|
262
|
+
environment: needs Python 3.14, found 3.12.4`) stops at once with no
|
|
263
|
+
retry: fix the machine or the pin, then run it again.
|
|
264
|
+
- `test_authoring_failed` — code was produced but a criterion's test
|
|
265
|
+
could not be written (a model call dropped twice): run it again;
|
|
266
|
+
nothing shows the code wrong.
|
|
267
|
+
- `verification_failed` — a criterion failed on every attempt. The output
|
|
268
|
+
names each failing criterion and why; a failure marked as the test's
|
|
269
|
+
own means its test could not be written soundly. Nearly always the
|
|
270
|
+
cause is in the spec: a missing detail, or an example that contradicts
|
|
271
|
+
a requirement. Run `hotdocs spec check` on it and fix the spec; the
|
|
272
|
+
next `generate` writes a fresh test for any criterion you changed.
|
|
273
|
+
|
|
274
|
+
`hotdocs track feedback comp-<name>` lists the failing requirement ids
|
|
275
|
+
from the last attempt, and `--retry-feedback=R-...` passes them to the
|
|
276
|
+
next `generate`.
|
|
277
|
+
|
|
278
|
+
A `mutation_error` line means every criterion passed, but the generated
|
|
279
|
+
tests failed (or hung) when rerun in the mutation sandbox, a temporary
|
|
280
|
+
copy of `gen/` whose working directory is not the repository root. A test
|
|
281
|
+
that reads files relative to the current directory is the usual cause.
|
|
282
|
+
|
|
283
|
+
`hotdocs verify` without `--model` reports every component and lists a
|
|
284
|
+
capability that needs a fresh run as `needs a fresh run; pass --model`.
|
|
285
|
+
With a model, a capability that does not pass is listed with the ids of
|
|
286
|
+
its failed scenarios, or as having none.
|
|
287
|
+
|
|
288
|
+
## 7. Known limits
|
|
289
|
+
|
|
290
|
+
- The secret scan finds API keys, tokens and other high-entropy or
|
|
291
|
+
provider-shaped strings, not ordinary passwords: a low-entropy value like
|
|
292
|
+
`password = "hunter2"` passes. Keep passwords out of the repository.
|
|
293
|
+
- With the `claude-cli` provider, a large component's reply can outgrow
|
|
294
|
+
the command's defaults and fail as `truncated_response`. Set
|
|
295
|
+
`CLAUDE_CODE_MAX_OUTPUT_TOKENS=128000` and bound thinking with
|
|
296
|
+
`MAX_THINKING_TOKENS` (the tool's own rebuild used `32000`).
|
|
297
|
+
- The live-provider tests are opt-in and cost real tokens:
|
|
298
|
+
`HOTDOCS_LIVE=1 pytest verification/llm-endpoint/test_live_providers.py
|
|
299
|
+
verification/llm-tool-endpoint/test_live_tool_loop.py
|
|
300
|
+
verification/agentic-generator/test_live_slugify.py`.
|
|
301
|
+
- `hotdocs assist` and `hotdocs impact` need a git repository; without a
|
|
302
|
+
default branch or a merge-base every file counts as changed.
|
|
303
|
+
- `hotdocs <verb> --help` prints the verb's summary and usage line, not a
|
|
304
|
+
description of each flag; this guide and `AUTHORING.md` hold those.
|
|
305
|
+
- `license_scan not evaluated: no-reference-corpus` in `hotdocs
|
|
306
|
+
generate`'s output is expected in a new project: the license scan
|
|
307
|
+
compares generated code with a reference corpus of licensed code, and
|
|
308
|
+
none is configured. It never blocks.
|