freshdags 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- freshdags-0.1.0/LICENSE +21 -0
- freshdags-0.1.0/PKG-INFO +222 -0
- freshdags-0.1.0/Readme.md +198 -0
- freshdags-0.1.0/pyproject.toml +72 -0
- freshdags-0.1.0/pyproject.toml.orig +56 -0
- freshdags-0.1.0/src/freshdags/__init__.py +5 -0
- freshdags-0.1.0/src/freshdags/__main__.py +3 -0
- freshdags-0.1.0/src/freshdags/api.py +115 -0
- freshdags-0.1.0/src/freshdags/cli.py +210 -0
- freshdags-0.1.0/src/freshdags/core.py +416 -0
- freshdags-0.1.0/src/freshdags/errors.py +60 -0
- freshdags-0.1.0/src/freshdags/git.py +45 -0
- freshdags-0.1.0/src/freshdags/models.py +210 -0
- freshdags-0.1.0/src/freshdags/py.typed +0 -0
- freshdags-0.1.0/src/freshdags/render.py +84 -0
freshdags-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Markus Kobold
|
|
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.
|
freshdags-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: freshdags
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Track dependencies between docs and the code they describe, and flag documentation drift.
|
|
5
|
+
Keywords: documentation,drift,dag,git,cli,agents
|
|
6
|
+
Author: Markus Kobold
|
|
7
|
+
Author-email: Markus Kobold <mkcode92@gmail.com>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Topic :: Software Development :: Documentation
|
|
17
|
+
Requires-Dist: pydantic>=2.14.3
|
|
18
|
+
Requires-Dist: typer>=0.29.2
|
|
19
|
+
Requires-Python: >=3.12
|
|
20
|
+
Project-URL: Homepage, https://github.com/mkcode92/freshdags
|
|
21
|
+
Project-URL: Repository, https://github.com/mkcode92/freshdags
|
|
22
|
+
Project-URL: Issues, https://github.com/mkcode92/freshdags/issues
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
# freshdags 🦡✨
|
|
26
|
+
|
|
27
|
+
A small CLI that helps prevent documentation drift — especially in codebases where agents change code faster than anyone re-reads the docs. It works just as well for keeping any file consistent with the specs and invariants it depends on.
|
|
28
|
+
|
|
29
|
+
> **Status:** early. All commands below work, but the file format may still change. Until v0.1.0 is on PyPI, install from GitHub (see below); the pre-commit and CI snippets need that release.
|
|
30
|
+
|
|
31
|
+
## Install
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
uv tool install freshdags # or: pipx install freshdags
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Until the first release on PyPI, install from GitHub instead: `uv tool install git+https://github.com/mkcode92/freshdags`.
|
|
38
|
+
|
|
39
|
+
## Quick start
|
|
40
|
+
|
|
41
|
+
Tell freshdags which docs depend on which files. They must be tracked by git; `git add` new files first:
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
freshdags add docs/api.md src/api/interface.py
|
|
45
|
+
freshdags add README.md docs/api.md
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
This creates `freshdags.json` in the repository root. Commit it with your code.
|
|
49
|
+
|
|
50
|
+
Later, someone changes `src/api/interface.py` and commits. Now:
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
$ freshdags check
|
|
54
|
+
docs/api.md may have drifted
|
|
55
|
+
src/api/interface.py changed since 3f2a91c
|
|
56
|
+
review: git diff 3f2a91c..HEAD -- src/api/interface.py
|
|
57
|
+
then: update docs/api.md, or run: freshdags resolve docs/api.md
|
|
58
|
+
|
|
59
|
+
🦡 1 doc may have drifted. The badger is watching.
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Read the diff, then either:
|
|
63
|
+
|
|
64
|
+
- **update the doc and commit it** — that clears the flag. Because the doc changed, `README.md` is flagged next, and you check it the same way; or
|
|
65
|
+
- **run `freshdags resolve docs/api.md`** if the doc is still correct. Nothing changed, so `README.md` stays fresh.
|
|
66
|
+
|
|
67
|
+
```sh
|
|
68
|
+
$ freshdags check
|
|
69
|
+
🦡✨ All 2 docs are fresh.
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Everyday use
|
|
73
|
+
|
|
74
|
+
**A change was minor and no doc needs updating.** Resolve every drifted doc at once:
|
|
75
|
+
|
|
76
|
+
```sh
|
|
77
|
+
freshdags resolve --all
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**Something changed that git cannot see** — a vendor API, or a behaviour change that did not touch the file a doc depends on:
|
|
81
|
+
|
|
82
|
+
```sh
|
|
83
|
+
freshdags flag ext:stripe-api --note "API v2 released"
|
|
84
|
+
freshdags flag src/api/interface.py --note "timeouts now in seconds"
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**See what depends on what:**
|
|
88
|
+
|
|
89
|
+
```sh
|
|
90
|
+
freshdags show # the whole graph
|
|
91
|
+
freshdags show src/api/interface.py # its sources and dependents
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**Stop drift before it is committed** with [pre-commit](https://pre-commit.com). Add to `.pre-commit-config.yaml`:
|
|
95
|
+
|
|
96
|
+
```yaml
|
|
97
|
+
repos:
|
|
98
|
+
- repo: https://github.com/mkcode92/freshdags
|
|
99
|
+
rev: v0.1.0
|
|
100
|
+
hooks:
|
|
101
|
+
- id: freshdags
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
The hook runs `freshdags check --uncommitted`: the changes you are committing count as a commit made now, so a source change without its doc update fails the commit. It also fails while older drift is still open.
|
|
105
|
+
|
|
106
|
+
**Check a pull request in CI**, for drift that was committed anyway. `check` exits with `1` when something drifted. It needs the git history, so fetch it fully:
|
|
107
|
+
|
|
108
|
+
```yaml
|
|
109
|
+
- uses: actions/checkout@v4
|
|
110
|
+
with:
|
|
111
|
+
fetch-depth: 0
|
|
112
|
+
- uses: astral-sh/setup-uv@v6
|
|
113
|
+
- run: uvx freshdags check
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**Work with agents.** Run `freshdags configure --auto-flag on-change --auto-resolve on-change` (see [Settings](#settings)), so drift shows up as soon as a file is saved, before anything is committed. Agents can read `freshdags check --json`.
|
|
117
|
+
|
|
118
|
+
## What to track
|
|
119
|
+
|
|
120
|
+
**Point docs at interfaces, not implementations.** If a doc depends on implementation details, every refactor flags it and the signal turns into noise. Keep APIs and interfaces in their own files and make docs depend on those.
|
|
121
|
+
|
|
122
|
+
**Not only docs.** "Doc" and "source" are just roles. Any file can depend on any other, in any direction, as long as there are no cycles. That makes freshdags useful for invariant-based coding too, wherever one file must stay consistent with another:
|
|
123
|
+
|
|
124
|
+
- an implementation depends on the spec or invariant it must satisfy;
|
|
125
|
+
- a client depends on the server's API schema;
|
|
126
|
+
- tests depend on the interface they pin down;
|
|
127
|
+
- a migration or config depends on the model it mirrors.
|
|
128
|
+
|
|
129
|
+
**Things outside the repository** are written as `ext:<name>`. They are the only nodes without a tracked file:
|
|
130
|
+
|
|
131
|
+
- **External doc**, e.g. a wiki page that describes repo code: a code change flags it. After updating the page, run `freshdags resolve ext:wiki-api`. Resolve it once right after adding it, since it has no commits.
|
|
132
|
+
- **External source**, e.g. a vendor API: freshdags cannot see it change, so run `freshdags flag ext:stripe-api` when it does.
|
|
133
|
+
|
|
134
|
+
## Commands
|
|
135
|
+
|
|
136
|
+
| Command | Purpose |
|
|
137
|
+
|---|---|
|
|
138
|
+
| `freshdags add DOC SOURCE...` | Record that DOC depends on each SOURCE. Creates `freshdags.json` if needed. Refuses missing or untracked files, self-dependencies and cycles. |
|
|
139
|
+
| `freshdags rm DOC SOURCE...` | Remove those dependencies, and nodes no longer connected to anything. |
|
|
140
|
+
| `freshdags show [NODE]` | Print the graph, or one node's sources and dependents. |
|
|
141
|
+
| `freshdags check [REV] [--json] [--uncommitted]` | List every doc that may have drifted. Without `REV`, uses the current `freshdags.json`, the history up to `HEAD` and, in `on-change` mode, uncommitted changes; with `REV`, evaluates the graph as of that commit. `--uncommitted` counts uncommitted changes as a commit made now, for pre-commit hooks. |
|
|
142
|
+
| `freshdags resolve DOC...` | Mark docs as drift-free after reviewing them. |
|
|
143
|
+
| `freshdags resolve --all` | Resolve every drifted doc, when the change needed no doc update. |
|
|
144
|
+
| `freshdags flag NODE [--note TEXT]` | Record that a source changed, flagging the docs that depend on it. |
|
|
145
|
+
| `freshdags configure [--auto-flag MODE] [--auto-resolve MODE]` | Show the settings, or change them. |
|
|
146
|
+
|
|
147
|
+
**Exit codes:** `0` no drift, `1` drift found, `2` usage or graph-file error.
|
|
148
|
+
|
|
149
|
+
**Verbosity:** by default, commands print only their results (the `check` report, `show`) and errors. The options go before the command, as in `freshdags -q check`. `-v` adds confirmations such as "docs/api.md depends on src/api.py"; `-vv` adds diagnostics like the git commands run. `-q` prints nothing but errors, for hooks and CI that only need the exit code. Confirmations and diagnostics go to stderr, so `--json` output stays clean.
|
|
150
|
+
|
|
151
|
+
## Settings
|
|
152
|
+
|
|
153
|
+
Settings live in `freshdags.json`. Show them with `freshdags configure`, change them with e.g. `freshdags configure --auto-flag on-change --auto-resolve on-change`. They decide what happens automatically; the `flag` and `resolve` commands work in every mode.
|
|
154
|
+
|
|
155
|
+
| Setting | `on-commit` (default) | `on-change` | `off` |
|
|
156
|
+
|---|---|---|---|
|
|
157
|
+
| `auto-flag` | A commit to a source flags its dependents. | Also an uncommitted save. | Only `freshdags flag` marks a source as changed. |
|
|
158
|
+
| `auto-resolve` | A commit to a doc resolves it. | Also an uncommitted save. | Only `freshdags resolve` resolves a doc. |
|
|
159
|
+
|
|
160
|
+
- **`on-change`** suits agents, which see drift before they commit. Uncommitted changes are timed by the file's modification time; files whose content matches `HEAD` are ignored. `check REV` always uses committed history only.
|
|
161
|
+
- **`auto-resolve: on-commit` / `on-change`** means updating a doc resolves it, with no extra step. The trade-off: any edit, even a typo fix, clears the flag. The edit shows up in review next to the source change.
|
|
162
|
+
- **`auto-resolve: off`** makes every resolve an explicit, recorded decision.
|
|
163
|
+
|
|
164
|
+
## How it works
|
|
165
|
+
|
|
166
|
+
freshdags keeps your dependencies as a graph (a DAG) in `freshdags.json`. The rule is: **a doc must be at least as new as each of its sources.** If a source changed after the doc was last up to date, the doc is flagged until someone resolves it.
|
|
167
|
+
|
|
168
|
+
- **Times come from git:** a file's change time is the **author date** of the last commit that touched it. Author dates survive rebases, so rewriting a branch does not raise false flags. Because commits are the source of truth, a doc can be updated in a later commit of the same pull request.
|
|
169
|
+
- **A doc is up to date** from the commit that created it, from its last commit or save (as `auto-resolve` allows), or from its last `resolve` — whichever is latest. The `git diff` hint in `check` starts at that commit.
|
|
170
|
+
- **Changes ripple, resolves do not.** A real change to a doc flags the docs that depend on it. Resolving a doc only states that it is still correct, so its dependents stay as they are.
|
|
171
|
+
|
|
172
|
+
### The graph file
|
|
173
|
+
|
|
174
|
+
`freshdags.json` is written by the tool; you should not need to edit it by hand. Keys are sorted so diffs stay small. A source appears only in `depends_on` lists, unless it carries a `flagged` record. Only the latest `resolved` and `flagged` record per node is kept; git holds the history.
|
|
175
|
+
|
|
176
|
+
```json
|
|
177
|
+
{
|
|
178
|
+
"nodes": {
|
|
179
|
+
"docs/api.md": {
|
|
180
|
+
"depends_on": ["ext:stripe-api", "src/api/interface.py"],
|
|
181
|
+
"resolved": { "at": "2026-11-19T10:00:00Z", "by": "Jane Doe", "commit": "3f2a91c..." }
|
|
182
|
+
},
|
|
183
|
+
"ext:stripe-api": {
|
|
184
|
+
"flagged": { "at": "2026-11-01T00:00:00Z", "by": "Jane Doe", "note": "API v2 released" }
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
"settings": { "auto-flag": "on-commit", "auto-resolve": "on-commit" },
|
|
188
|
+
"version": 1
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
**Format versions.** `version` changes only when the format changes in a breaking way. A newer freshdags reads older files and upgrades them; the next command that writes the file saves the new format, which shows up as a normal diff. An older freshdags refuses a newer file and asks you to upgrade.
|
|
193
|
+
|
|
194
|
+
## Known limitations
|
|
195
|
+
|
|
196
|
+
- `resolve` and `flag` record the current wall-clock time, while commits carry the author's machine time. Clock skew between machines can misorder events that happen within minutes of each other.
|
|
197
|
+
- In `on-change` mode, file modification times are compared with commit author dates, with the same caveat.
|
|
198
|
+
|
|
199
|
+
## Planned
|
|
200
|
+
|
|
201
|
+
- `--base REV` for `check`, to report only drift introduced by a pull request
|
|
202
|
+
- `show --format dot` for drawing the graph with Graphviz
|
|
203
|
+
- Directory and glob sources, so a per-directory README tracks new files automatically
|
|
204
|
+
- A ready-made snippet for `AGENTS.md` / `CLAUDE.md`
|
|
205
|
+
|
|
206
|
+
## Development
|
|
207
|
+
|
|
208
|
+
Requires [uv](https://docs.astral.sh/uv/).
|
|
209
|
+
|
|
210
|
+
```sh
|
|
211
|
+
uv sync
|
|
212
|
+
uv run pre-commit install # freshdags checks its own docs before each commit
|
|
213
|
+
uv run freshdags --help
|
|
214
|
+
uv run pytest
|
|
215
|
+
uv run ruff check . && uv run ruff format --check .
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
**Releasing:** bump `version` in `pyproject.toml`, commit, and push a tag like `v0.1.0`. The publish workflow checks that the tag matches the version, builds, and uploads to PyPI.
|
|
219
|
+
|
|
220
|
+
## License
|
|
221
|
+
|
|
222
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
# freshdags 🦡✨
|
|
2
|
+
|
|
3
|
+
A small CLI that helps prevent documentation drift — especially in codebases where agents change code faster than anyone re-reads the docs. It works just as well for keeping any file consistent with the specs and invariants it depends on.
|
|
4
|
+
|
|
5
|
+
> **Status:** early. All commands below work, but the file format may still change. Until v0.1.0 is on PyPI, install from GitHub (see below); the pre-commit and CI snippets need that release.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
uv tool install freshdags # or: pipx install freshdags
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Until the first release on PyPI, install from GitHub instead: `uv tool install git+https://github.com/mkcode92/freshdags`.
|
|
14
|
+
|
|
15
|
+
## Quick start
|
|
16
|
+
|
|
17
|
+
Tell freshdags which docs depend on which files. They must be tracked by git; `git add` new files first:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
freshdags add docs/api.md src/api/interface.py
|
|
21
|
+
freshdags add README.md docs/api.md
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
This creates `freshdags.json` in the repository root. Commit it with your code.
|
|
25
|
+
|
|
26
|
+
Later, someone changes `src/api/interface.py` and commits. Now:
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
$ freshdags check
|
|
30
|
+
docs/api.md may have drifted
|
|
31
|
+
src/api/interface.py changed since 3f2a91c
|
|
32
|
+
review: git diff 3f2a91c..HEAD -- src/api/interface.py
|
|
33
|
+
then: update docs/api.md, or run: freshdags resolve docs/api.md
|
|
34
|
+
|
|
35
|
+
🦡 1 doc may have drifted. The badger is watching.
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Read the diff, then either:
|
|
39
|
+
|
|
40
|
+
- **update the doc and commit it** — that clears the flag. Because the doc changed, `README.md` is flagged next, and you check it the same way; or
|
|
41
|
+
- **run `freshdags resolve docs/api.md`** if the doc is still correct. Nothing changed, so `README.md` stays fresh.
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
$ freshdags check
|
|
45
|
+
🦡✨ All 2 docs are fresh.
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Everyday use
|
|
49
|
+
|
|
50
|
+
**A change was minor and no doc needs updating.** Resolve every drifted doc at once:
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
freshdags resolve --all
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Something changed that git cannot see** — a vendor API, or a behaviour change that did not touch the file a doc depends on:
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
freshdags flag ext:stripe-api --note "API v2 released"
|
|
60
|
+
freshdags flag src/api/interface.py --note "timeouts now in seconds"
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**See what depends on what:**
|
|
64
|
+
|
|
65
|
+
```sh
|
|
66
|
+
freshdags show # the whole graph
|
|
67
|
+
freshdags show src/api/interface.py # its sources and dependents
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**Stop drift before it is committed** with [pre-commit](https://pre-commit.com). Add to `.pre-commit-config.yaml`:
|
|
71
|
+
|
|
72
|
+
```yaml
|
|
73
|
+
repos:
|
|
74
|
+
- repo: https://github.com/mkcode92/freshdags
|
|
75
|
+
rev: v0.1.0
|
|
76
|
+
hooks:
|
|
77
|
+
- id: freshdags
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
The hook runs `freshdags check --uncommitted`: the changes you are committing count as a commit made now, so a source change without its doc update fails the commit. It also fails while older drift is still open.
|
|
81
|
+
|
|
82
|
+
**Check a pull request in CI**, for drift that was committed anyway. `check` exits with `1` when something drifted. It needs the git history, so fetch it fully:
|
|
83
|
+
|
|
84
|
+
```yaml
|
|
85
|
+
- uses: actions/checkout@v4
|
|
86
|
+
with:
|
|
87
|
+
fetch-depth: 0
|
|
88
|
+
- uses: astral-sh/setup-uv@v6
|
|
89
|
+
- run: uvx freshdags check
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**Work with agents.** Run `freshdags configure --auto-flag on-change --auto-resolve on-change` (see [Settings](#settings)), so drift shows up as soon as a file is saved, before anything is committed. Agents can read `freshdags check --json`.
|
|
93
|
+
|
|
94
|
+
## What to track
|
|
95
|
+
|
|
96
|
+
**Point docs at interfaces, not implementations.** If a doc depends on implementation details, every refactor flags it and the signal turns into noise. Keep APIs and interfaces in their own files and make docs depend on those.
|
|
97
|
+
|
|
98
|
+
**Not only docs.** "Doc" and "source" are just roles. Any file can depend on any other, in any direction, as long as there are no cycles. That makes freshdags useful for invariant-based coding too, wherever one file must stay consistent with another:
|
|
99
|
+
|
|
100
|
+
- an implementation depends on the spec or invariant it must satisfy;
|
|
101
|
+
- a client depends on the server's API schema;
|
|
102
|
+
- tests depend on the interface they pin down;
|
|
103
|
+
- a migration or config depends on the model it mirrors.
|
|
104
|
+
|
|
105
|
+
**Things outside the repository** are written as `ext:<name>`. They are the only nodes without a tracked file:
|
|
106
|
+
|
|
107
|
+
- **External doc**, e.g. a wiki page that describes repo code: a code change flags it. After updating the page, run `freshdags resolve ext:wiki-api`. Resolve it once right after adding it, since it has no commits.
|
|
108
|
+
- **External source**, e.g. a vendor API: freshdags cannot see it change, so run `freshdags flag ext:stripe-api` when it does.
|
|
109
|
+
|
|
110
|
+
## Commands
|
|
111
|
+
|
|
112
|
+
| Command | Purpose |
|
|
113
|
+
|---|---|
|
|
114
|
+
| `freshdags add DOC SOURCE...` | Record that DOC depends on each SOURCE. Creates `freshdags.json` if needed. Refuses missing or untracked files, self-dependencies and cycles. |
|
|
115
|
+
| `freshdags rm DOC SOURCE...` | Remove those dependencies, and nodes no longer connected to anything. |
|
|
116
|
+
| `freshdags show [NODE]` | Print the graph, or one node's sources and dependents. |
|
|
117
|
+
| `freshdags check [REV] [--json] [--uncommitted]` | List every doc that may have drifted. Without `REV`, uses the current `freshdags.json`, the history up to `HEAD` and, in `on-change` mode, uncommitted changes; with `REV`, evaluates the graph as of that commit. `--uncommitted` counts uncommitted changes as a commit made now, for pre-commit hooks. |
|
|
118
|
+
| `freshdags resolve DOC...` | Mark docs as drift-free after reviewing them. |
|
|
119
|
+
| `freshdags resolve --all` | Resolve every drifted doc, when the change needed no doc update. |
|
|
120
|
+
| `freshdags flag NODE [--note TEXT]` | Record that a source changed, flagging the docs that depend on it. |
|
|
121
|
+
| `freshdags configure [--auto-flag MODE] [--auto-resolve MODE]` | Show the settings, or change them. |
|
|
122
|
+
|
|
123
|
+
**Exit codes:** `0` no drift, `1` drift found, `2` usage or graph-file error.
|
|
124
|
+
|
|
125
|
+
**Verbosity:** by default, commands print only their results (the `check` report, `show`) and errors. The options go before the command, as in `freshdags -q check`. `-v` adds confirmations such as "docs/api.md depends on src/api.py"; `-vv` adds diagnostics like the git commands run. `-q` prints nothing but errors, for hooks and CI that only need the exit code. Confirmations and diagnostics go to stderr, so `--json` output stays clean.
|
|
126
|
+
|
|
127
|
+
## Settings
|
|
128
|
+
|
|
129
|
+
Settings live in `freshdags.json`. Show them with `freshdags configure`, change them with e.g. `freshdags configure --auto-flag on-change --auto-resolve on-change`. They decide what happens automatically; the `flag` and `resolve` commands work in every mode.
|
|
130
|
+
|
|
131
|
+
| Setting | `on-commit` (default) | `on-change` | `off` |
|
|
132
|
+
|---|---|---|---|
|
|
133
|
+
| `auto-flag` | A commit to a source flags its dependents. | Also an uncommitted save. | Only `freshdags flag` marks a source as changed. |
|
|
134
|
+
| `auto-resolve` | A commit to a doc resolves it. | Also an uncommitted save. | Only `freshdags resolve` resolves a doc. |
|
|
135
|
+
|
|
136
|
+
- **`on-change`** suits agents, which see drift before they commit. Uncommitted changes are timed by the file's modification time; files whose content matches `HEAD` are ignored. `check REV` always uses committed history only.
|
|
137
|
+
- **`auto-resolve: on-commit` / `on-change`** means updating a doc resolves it, with no extra step. The trade-off: any edit, even a typo fix, clears the flag. The edit shows up in review next to the source change.
|
|
138
|
+
- **`auto-resolve: off`** makes every resolve an explicit, recorded decision.
|
|
139
|
+
|
|
140
|
+
## How it works
|
|
141
|
+
|
|
142
|
+
freshdags keeps your dependencies as a graph (a DAG) in `freshdags.json`. The rule is: **a doc must be at least as new as each of its sources.** If a source changed after the doc was last up to date, the doc is flagged until someone resolves it.
|
|
143
|
+
|
|
144
|
+
- **Times come from git:** a file's change time is the **author date** of the last commit that touched it. Author dates survive rebases, so rewriting a branch does not raise false flags. Because commits are the source of truth, a doc can be updated in a later commit of the same pull request.
|
|
145
|
+
- **A doc is up to date** from the commit that created it, from its last commit or save (as `auto-resolve` allows), or from its last `resolve` — whichever is latest. The `git diff` hint in `check` starts at that commit.
|
|
146
|
+
- **Changes ripple, resolves do not.** A real change to a doc flags the docs that depend on it. Resolving a doc only states that it is still correct, so its dependents stay as they are.
|
|
147
|
+
|
|
148
|
+
### The graph file
|
|
149
|
+
|
|
150
|
+
`freshdags.json` is written by the tool; you should not need to edit it by hand. Keys are sorted so diffs stay small. A source appears only in `depends_on` lists, unless it carries a `flagged` record. Only the latest `resolved` and `flagged` record per node is kept; git holds the history.
|
|
151
|
+
|
|
152
|
+
```json
|
|
153
|
+
{
|
|
154
|
+
"nodes": {
|
|
155
|
+
"docs/api.md": {
|
|
156
|
+
"depends_on": ["ext:stripe-api", "src/api/interface.py"],
|
|
157
|
+
"resolved": { "at": "2026-11-19T10:00:00Z", "by": "Jane Doe", "commit": "3f2a91c..." }
|
|
158
|
+
},
|
|
159
|
+
"ext:stripe-api": {
|
|
160
|
+
"flagged": { "at": "2026-11-01T00:00:00Z", "by": "Jane Doe", "note": "API v2 released" }
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
"settings": { "auto-flag": "on-commit", "auto-resolve": "on-commit" },
|
|
164
|
+
"version": 1
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
**Format versions.** `version` changes only when the format changes in a breaking way. A newer freshdags reads older files and upgrades them; the next command that writes the file saves the new format, which shows up as a normal diff. An older freshdags refuses a newer file and asks you to upgrade.
|
|
169
|
+
|
|
170
|
+
## Known limitations
|
|
171
|
+
|
|
172
|
+
- `resolve` and `flag` record the current wall-clock time, while commits carry the author's machine time. Clock skew between machines can misorder events that happen within minutes of each other.
|
|
173
|
+
- In `on-change` mode, file modification times are compared with commit author dates, with the same caveat.
|
|
174
|
+
|
|
175
|
+
## Planned
|
|
176
|
+
|
|
177
|
+
- `--base REV` for `check`, to report only drift introduced by a pull request
|
|
178
|
+
- `show --format dot` for drawing the graph with Graphviz
|
|
179
|
+
- Directory and glob sources, so a per-directory README tracks new files automatically
|
|
180
|
+
- A ready-made snippet for `AGENTS.md` / `CLAUDE.md`
|
|
181
|
+
|
|
182
|
+
## Development
|
|
183
|
+
|
|
184
|
+
Requires [uv](https://docs.astral.sh/uv/).
|
|
185
|
+
|
|
186
|
+
```sh
|
|
187
|
+
uv sync
|
|
188
|
+
uv run pre-commit install # freshdags checks its own docs before each commit
|
|
189
|
+
uv run freshdags --help
|
|
190
|
+
uv run pytest
|
|
191
|
+
uv run ruff check . && uv run ruff format --check .
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
**Releasing:** bump `version` in `pyproject.toml`, commit, and push a tag like `v0.1.0`. The publish workflow checks that the tag matches the version, builds, and uploads to PyPI.
|
|
195
|
+
|
|
196
|
+
## License
|
|
197
|
+
|
|
198
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "freshdags"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Track dependencies between docs and the code they describe, and flag documentation drift."
|
|
5
|
+
readme = "Readme.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
requires-python = ">=3.12"
|
|
9
|
+
dependencies = [
|
|
10
|
+
"pydantic>=2.14.3",
|
|
11
|
+
"typer>=0.29.2",
|
|
12
|
+
]
|
|
13
|
+
keywords = [
|
|
14
|
+
"documentation",
|
|
15
|
+
"drift",
|
|
16
|
+
"dag",
|
|
17
|
+
"git",
|
|
18
|
+
"cli",
|
|
19
|
+
"agents",
|
|
20
|
+
]
|
|
21
|
+
classifiers = [
|
|
22
|
+
"Development Status :: 2 - Pre-Alpha",
|
|
23
|
+
"Environment :: Console",
|
|
24
|
+
"Intended Audience :: Developers",
|
|
25
|
+
"Programming Language :: Python :: 3",
|
|
26
|
+
"Programming Language :: Python :: 3.12",
|
|
27
|
+
"Programming Language :: Python :: 3.13",
|
|
28
|
+
"Topic :: Software Development :: Documentation",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[[project.authors]]
|
|
32
|
+
name = "Markus Kobold"
|
|
33
|
+
email = "mkcode92@gmail.com"
|
|
34
|
+
|
|
35
|
+
[project.urls]
|
|
36
|
+
Homepage = "https://github.com/mkcode92/freshdags"
|
|
37
|
+
Repository = "https://github.com/mkcode92/freshdags"
|
|
38
|
+
Issues = "https://github.com/mkcode92/freshdags/issues"
|
|
39
|
+
|
|
40
|
+
[project.scripts]
|
|
41
|
+
freshdags = "freshdags.cli:app"
|
|
42
|
+
|
|
43
|
+
[build-system]
|
|
44
|
+
requires = ["uv_build>=0.12.23,<0.13.0"]
|
|
45
|
+
build-backend = "uv_build"
|
|
46
|
+
|
|
47
|
+
[dependency-groups]
|
|
48
|
+
dev = [
|
|
49
|
+
"pre-commit>=4.7.0",
|
|
50
|
+
"pytest>=9.2.0",
|
|
51
|
+
"ruff>=0.17.5",
|
|
52
|
+
"time-machine>=3.6.0",
|
|
53
|
+
]
|
|
54
|
+
|
|
55
|
+
[tool.ruff]
|
|
56
|
+
line-length = 100
|
|
57
|
+
target-version = "py312"
|
|
58
|
+
|
|
59
|
+
[tool.ruff.lint]
|
|
60
|
+
select = [
|
|
61
|
+
"E",
|
|
62
|
+
"F",
|
|
63
|
+
"W",
|
|
64
|
+
"I",
|
|
65
|
+
"UP",
|
|
66
|
+
"B",
|
|
67
|
+
"SIM",
|
|
68
|
+
]
|
|
69
|
+
|
|
70
|
+
[tool.pytest.ini_options]
|
|
71
|
+
testpaths = ["tests"]
|
|
72
|
+
pythonpath = ["tests"]
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "freshdags"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Track dependencies between docs and the code they describe, and flag documentation drift."
|
|
5
|
+
readme = "Readme.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
authors = [
|
|
9
|
+
{ name = "Markus Kobold", email = "mkcode92@gmail.com" }
|
|
10
|
+
]
|
|
11
|
+
requires-python = ">=3.12"
|
|
12
|
+
dependencies = [
|
|
13
|
+
"pydantic>=2.14.3",
|
|
14
|
+
"typer>=0.29.2",
|
|
15
|
+
]
|
|
16
|
+
keywords = ["documentation", "drift", "dag", "git", "cli", "agents"]
|
|
17
|
+
classifiers = [
|
|
18
|
+
"Development Status :: 2 - Pre-Alpha",
|
|
19
|
+
"Environment :: Console",
|
|
20
|
+
"Intended Audience :: Developers",
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Programming Language :: Python :: 3.13",
|
|
24
|
+
"Topic :: Software Development :: Documentation",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[project.urls]
|
|
28
|
+
Homepage = "https://github.com/mkcode92/freshdags"
|
|
29
|
+
Repository = "https://github.com/mkcode92/freshdags"
|
|
30
|
+
Issues = "https://github.com/mkcode92/freshdags/issues"
|
|
31
|
+
|
|
32
|
+
[project.scripts]
|
|
33
|
+
freshdags = "freshdags.cli:app"
|
|
34
|
+
|
|
35
|
+
[build-system]
|
|
36
|
+
requires = ["uv_build>=0.12.23,<0.13.0"]
|
|
37
|
+
build-backend = "uv_build"
|
|
38
|
+
|
|
39
|
+
[dependency-groups]
|
|
40
|
+
dev = [
|
|
41
|
+
"pre-commit>=4.7.0",
|
|
42
|
+
"pytest>=9.2.0",
|
|
43
|
+
"ruff>=0.17.5",
|
|
44
|
+
"time-machine>=3.6.0",
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
[tool.ruff]
|
|
48
|
+
line-length = 100
|
|
49
|
+
target-version = "py312"
|
|
50
|
+
|
|
51
|
+
[tool.ruff.lint]
|
|
52
|
+
select = ["E", "F", "W", "I", "UP", "B", "SIM"]
|
|
53
|
+
|
|
54
|
+
[tool.pytest.ini_options]
|
|
55
|
+
testpaths = ["tests"]
|
|
56
|
+
pythonpath = ["tests"]
|