grounded-kb 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.
- grounded_kb-0.1.0/LICENSE +21 -0
- grounded_kb-0.1.0/PKG-INFO +75 -0
- grounded_kb-0.1.0/README.md +46 -0
- grounded_kb-0.1.0/pyproject.toml +69 -0
- grounded_kb-0.1.0/pyproject.toml.orig +57 -0
- grounded_kb-0.1.0/src/kb/__init__.py +3 -0
- grounded_kb-0.1.0/src/kb/agents/__init__.py +0 -0
- grounded_kb-0.1.0/src/kb/agents/claude_code.py +37 -0
- grounded_kb-0.1.0/src/kb/agents/codex.py +40 -0
- grounded_kb-0.1.0/src/kb/agents/generic.py +49 -0
- grounded_kb-0.1.0/src/kb/agents/registry.py +17 -0
- grounded_kb-0.1.0/src/kb/agents/settings.py +44 -0
- grounded_kb-0.1.0/src/kb/baseline.py +117 -0
- grounded_kb-0.1.0/src/kb/check.py +72 -0
- grounded_kb-0.1.0/src/kb/cli.py +429 -0
- grounded_kb-0.1.0/src/kb/code/__init__.py +0 -0
- grounded_kb-0.1.0/src/kb/code/python_pack.py +70 -0
- grounded_kb-0.1.0/src/kb/code/registry.py +75 -0
- grounded_kb-0.1.0/src/kb/config/__init__.py +0 -0
- grounded_kb-0.1.0/src/kb/config/codeowners.py +20 -0
- grounded_kb-0.1.0/src/kb/config/edit.py +123 -0
- grounded_kb-0.1.0/src/kb/config/load.py +29 -0
- grounded_kb-0.1.0/src/kb/config/schema.py +101 -0
- grounded_kb-0.1.0/src/kb/config/validate.py +72 -0
- grounded_kb-0.1.0/src/kb/context.py +380 -0
- grounded_kb-0.1.0/src/kb/gates/__init__.py +0 -0
- grounded_kb-0.1.0/src/kb/gates/anchors.py +74 -0
- grounded_kb-0.1.0/src/kb/gates/base.py +27 -0
- grounded_kb-0.1.0/src/kb/gates/decisions.py +25 -0
- grounded_kb-0.1.0/src/kb/gates/ids.py +123 -0
- grounded_kb-0.1.0/src/kb/gates/quotes.py +61 -0
- grounded_kb-0.1.0/src/kb/gates/sources.py +180 -0
- grounded_kb-0.1.0/src/kb/gates/triage.py +21 -0
- grounded_kb-0.1.0/src/kb/gitfiles.py +203 -0
- grounded_kb-0.1.0/src/kb/hooks.py +85 -0
- grounded_kb-0.1.0/src/kb/ingest/__init__.py +0 -0
- grounded_kb-0.1.0/src/kb/ingest/brief.py +265 -0
- grounded_kb-0.1.0/src/kb/ingest/report.py +211 -0
- grounded_kb-0.1.0/src/kb/ingest/templates/brief.md +52 -0
- grounded_kb-0.1.0/src/kb/init/__init__.py +0 -0
- grounded_kb-0.1.0/src/kb/init/scaffold.py +251 -0
- grounded_kb-0.1.0/src/kb/init/templates/agents_block.md +3 -0
- grounded_kb-0.1.0/src/kb/init/templates/github_workflow.yml +30 -0
- grounded_kb-0.1.0/src/kb/init/templates/gitlab_ci.yml +24 -0
- grounded_kb-0.1.0/src/kb/init/templates/kb_readme.md +69 -0
- grounded_kb-0.1.0/src/kb/issues.py +26 -0
- grounded_kb-0.1.0/src/kb/markers.py +51 -0
- grounded_kb-0.1.0/src/kb/modules.py +119 -0
- grounded_kb-0.1.0/src/kb/ports/__init__.py +0 -0
- grounded_kb-0.1.0/src/kb/ports/agents.py +36 -0
- grounded_kb-0.1.0/src/kb/ports/code.py +24 -0
- grounded_kb-0.1.0/src/kb/quotes/__init__.py +0 -0
- grounded_kb-0.1.0/src/kb/quotes/match.py +42 -0
- grounded_kb-0.1.0/src/kb/records/__init__.py +0 -0
- grounded_kb-0.1.0/src/kb/records/ids.py +59 -0
- grounded_kb-0.1.0/src/kb/records/io.py +92 -0
- grounded_kb-0.1.0/src/kb/records/lifecycle.py +27 -0
- grounded_kb-0.1.0/src/kb/records/models.py +156 -0
- grounded_kb-0.1.0/src/kb/records/repo.py +163 -0
- grounded_kb-0.1.0/src/kb/rules.py +9 -0
- grounded_kb-0.1.0/src/kb/safepath.py +58 -0
- grounded_kb-0.1.0/src/kb/safewrite.py +58 -0
- grounded_kb-0.1.0/src/kb/sources/__init__.py +0 -0
- grounded_kb-0.1.0/src/kb/sources/guard.py +134 -0
- grounded_kb-0.1.0/src/kb/sources/readers/__init__.py +60 -0
- grounded_kb-0.1.0/src/kb/sources/readers/docx.py +250 -0
- grounded_kb-0.1.0/src/kb/sources/readers/pdf.py +185 -0
- grounded_kb-0.1.0/src/kb/sources/readers/text.py +17 -0
- grounded_kb-0.1.0/src/kb/sources/segment.py +115 -0
- grounded_kb-0.1.0/src/kb/sources/store.py +233 -0
- grounded_kb-0.1.0/src/kb/status.py +83 -0
- grounded_kb-0.1.0/src/kb/textblocks.py +45 -0
- grounded_kb-0.1.0/src/kb/textfmt.py +21 -0
- grounded_kb-0.1.0/src/kb/trace.py +115 -0
- grounded_kb-0.1.0/src/kb/yamlio.py +35 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 mrashidramzan1996
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: grounded-kb
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Git-native knowledge base where every product fact rests on a verbatim quote or a code anchor, checked for any coding agent
|
|
5
|
+
Keywords: knowledge-base,requirements,traceability,ai-agents,claude-code,codex,cli
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Environment :: Console
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Operating System :: POSIX
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Topic :: Software Development :: Documentation
|
|
15
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
16
|
+
Requires-Dist: pathspec>=1.1.1
|
|
17
|
+
Requires-Dist: pdfplumber>=0.11.11
|
|
18
|
+
Requires-Dist: pydantic>=2.14.4
|
|
19
|
+
Requires-Dist: python-docx>=1.2.0
|
|
20
|
+
Requires-Dist: ruamel-yaml>=0.19.1
|
|
21
|
+
Requires-Dist: tree-sitter>=0.27.0
|
|
22
|
+
Requires-Dist: tree-sitter-python>=0.25.0
|
|
23
|
+
Requires-Dist: typer>=0.29.2
|
|
24
|
+
Requires-Python: >=3.12
|
|
25
|
+
Project-URL: Homepage, https://github.com/mrashidramzan1996/grounded-kb
|
|
26
|
+
Project-URL: Repository, https://github.com/mrashidramzan1996/grounded-kb
|
|
27
|
+
Project-URL: Issues, https://github.com/mrashidramzan1996/grounded-kb/issues
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
# grounded-kb
|
|
31
|
+
|
|
32
|
+
`kb` is a git-native knowledge base for a software repository. Product documents (PDF, Word, Markdown) are stored as
|
|
33
|
+
sources; your own coding agent drafts requirements, decisions and invariants from them, each resting on a verbatim
|
|
34
|
+
quote; deterministic gates (`kb check`) keep every record grounded and every marker in the code pointing at a real
|
|
35
|
+
record. Nothing calls a model: the tool reads, masks, segments, checks and reports.
|
|
36
|
+
|
|
37
|
+
Platform: POSIX only (macOS, Linux). It relies on `O_NOFOLLOW` / `dir_fd` file access and POSIX shell hooks; Windows
|
|
38
|
+
is not supported.
|
|
39
|
+
|
|
40
|
+
## Install
|
|
41
|
+
|
|
42
|
+
Python 3.12 or later and [uv](https://docs.astral.sh/uv/). Either from PyPI or from a pinned git tag:
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
uv tool install grounded-kb # from PyPI
|
|
46
|
+
uv tool install 'git+https://github.com/mrashidramzan1996/grounded-kb@v0.1.0' # a pinned tag
|
|
47
|
+
kb version
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
For CI, `kb init --install-spec 'grounded-kb==0.1.0'` (or the pinned git spec above) writes it into the workflow;
|
|
51
|
+
without `--install-spec` the CI job only warns.
|
|
52
|
+
|
|
53
|
+
## Use (Phase 1)
|
|
54
|
+
|
|
55
|
+
| Command | What it does |
|
|
56
|
+
| --- | --- |
|
|
57
|
+
| `kb init` | Scaffold `kb.config.yaml`, the agent rules in `AGENTS.md` / `CLAUDE.md`, a CODEOWNERS block, a `.gitignore` block for `.kb/` and CI. Modules come only from CODEOWNERS directory rules; owners and approvers stay TODO. |
|
|
58
|
+
| `kb source add <doc>…` | Read, mask (secrets, emails), segment and store documents under `kb/sources/`. |
|
|
59
|
+
| `kb source sync` | Re-read every stored source from its original (segment ids stay stable). |
|
|
60
|
+
| `kb ingest [paths]` | Store the sources and write a drafting brief to `.kb/cache/ingest/brief.md` for your coding agent. Files no reader takes are skipped. |
|
|
61
|
+
| `kb ingest --report [--strict]` | Gate what the agent drafted since `kb ingest` ran: accepted, rejected, flagged, sources, untriaged segments, proposed modules. |
|
|
62
|
+
| `kb module add MOD-x --owner <@handle\|TODO>` | Add a module without paths. |
|
|
63
|
+
| `kb module paths MOD-x --accept` | Write the paths suggested from `r[impl ID]` markers (or `--set GLOB`). |
|
|
64
|
+
| `kb check [--strict] [--changed] [--base REF]` | Run every gate: config, records, quotes, anchors, sources (re-derived from the originals), modules, triage. |
|
|
65
|
+
| `kb context --paths F / --module M / --id X` | The live requirements, decisions and invariants governing what you are about to touch. |
|
|
66
|
+
| `kb trace <ID>` | The evidence chain of a record, its quotes re-checked. |
|
|
67
|
+
| `kb status` | Per module: how many live requirements are built (`r[impl]`) and tested (`r[verify]`). |
|
|
68
|
+
| `kb baseline freeze v1` | Record the agreed requirement set on the default branch's tip (refused while `kb check` reports errors). |
|
|
69
|
+
| `kb agents install claude-code / codex / generic` | Wire the session-start and stop hooks, or a git pre-commit hook. |
|
|
70
|
+
| `kb hook <event>` | The hook entry point the agents call; it blocks only on errors new since the default branch. |
|
|
71
|
+
|
|
72
|
+
Exit codes: 0 ok, 1 policy failure, 2 usage, config or tool error. `--format json` goes to stdout, messages to stderr.
|
|
73
|
+
|
|
74
|
+
The walk-through on a sample repository is in [`docs/phases/phase1-demo.md`](docs/phases/phase1-demo.md); the
|
|
75
|
+
design is in [`kb_spec.md`](kb_spec.md).
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# grounded-kb
|
|
2
|
+
|
|
3
|
+
`kb` is a git-native knowledge base for a software repository. Product documents (PDF, Word, Markdown) are stored as
|
|
4
|
+
sources; your own coding agent drafts requirements, decisions and invariants from them, each resting on a verbatim
|
|
5
|
+
quote; deterministic gates (`kb check`) keep every record grounded and every marker in the code pointing at a real
|
|
6
|
+
record. Nothing calls a model: the tool reads, masks, segments, checks and reports.
|
|
7
|
+
|
|
8
|
+
Platform: POSIX only (macOS, Linux). It relies on `O_NOFOLLOW` / `dir_fd` file access and POSIX shell hooks; Windows
|
|
9
|
+
is not supported.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
Python 3.12 or later and [uv](https://docs.astral.sh/uv/). Either from PyPI or from a pinned git tag:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
uv tool install grounded-kb # from PyPI
|
|
17
|
+
uv tool install 'git+https://github.com/mrashidramzan1996/grounded-kb@v0.1.0' # a pinned tag
|
|
18
|
+
kb version
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
For CI, `kb init --install-spec 'grounded-kb==0.1.0'` (or the pinned git spec above) writes it into the workflow;
|
|
22
|
+
without `--install-spec` the CI job only warns.
|
|
23
|
+
|
|
24
|
+
## Use (Phase 1)
|
|
25
|
+
|
|
26
|
+
| Command | What it does |
|
|
27
|
+
| --- | --- |
|
|
28
|
+
| `kb init` | Scaffold `kb.config.yaml`, the agent rules in `AGENTS.md` / `CLAUDE.md`, a CODEOWNERS block, a `.gitignore` block for `.kb/` and CI. Modules come only from CODEOWNERS directory rules; owners and approvers stay TODO. |
|
|
29
|
+
| `kb source add <doc>…` | Read, mask (secrets, emails), segment and store documents under `kb/sources/`. |
|
|
30
|
+
| `kb source sync` | Re-read every stored source from its original (segment ids stay stable). |
|
|
31
|
+
| `kb ingest [paths]` | Store the sources and write a drafting brief to `.kb/cache/ingest/brief.md` for your coding agent. Files no reader takes are skipped. |
|
|
32
|
+
| `kb ingest --report [--strict]` | Gate what the agent drafted since `kb ingest` ran: accepted, rejected, flagged, sources, untriaged segments, proposed modules. |
|
|
33
|
+
| `kb module add MOD-x --owner <@handle\|TODO>` | Add a module without paths. |
|
|
34
|
+
| `kb module paths MOD-x --accept` | Write the paths suggested from `r[impl ID]` markers (or `--set GLOB`). |
|
|
35
|
+
| `kb check [--strict] [--changed] [--base REF]` | Run every gate: config, records, quotes, anchors, sources (re-derived from the originals), modules, triage. |
|
|
36
|
+
| `kb context --paths F / --module M / --id X` | The live requirements, decisions and invariants governing what you are about to touch. |
|
|
37
|
+
| `kb trace <ID>` | The evidence chain of a record, its quotes re-checked. |
|
|
38
|
+
| `kb status` | Per module: how many live requirements are built (`r[impl]`) and tested (`r[verify]`). |
|
|
39
|
+
| `kb baseline freeze v1` | Record the agreed requirement set on the default branch's tip (refused while `kb check` reports errors). |
|
|
40
|
+
| `kb agents install claude-code / codex / generic` | Wire the session-start and stop hooks, or a git pre-commit hook. |
|
|
41
|
+
| `kb hook <event>` | The hook entry point the agents call; it blocks only on errors new since the default branch. |
|
|
42
|
+
|
|
43
|
+
Exit codes: 0 ok, 1 policy failure, 2 usage, config or tool error. `--format json` goes to stdout, messages to stderr.
|
|
44
|
+
|
|
45
|
+
The walk-through on a sample repository is in [`docs/phases/phase1-demo.md`](docs/phases/phase1-demo.md); the
|
|
46
|
+
design is in [`kb_spec.md`](kb_spec.md).
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "grounded-kb"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Git-native knowledge base where every product fact rests on a verbatim quote or a code anchor, checked for any coding agent"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
keywords = [
|
|
9
|
+
"knowledge-base",
|
|
10
|
+
"requirements",
|
|
11
|
+
"traceability",
|
|
12
|
+
"ai-agents",
|
|
13
|
+
"claude-code",
|
|
14
|
+
"codex",
|
|
15
|
+
"cli",
|
|
16
|
+
]
|
|
17
|
+
classifiers = [
|
|
18
|
+
"Development Status :: 3 - Alpha",
|
|
19
|
+
"Environment :: Console",
|
|
20
|
+
"Intended Audience :: Developers",
|
|
21
|
+
"Operating System :: POSIX",
|
|
22
|
+
"Programming Language :: Python :: 3",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Topic :: Software Development :: Documentation",
|
|
25
|
+
"Topic :: Software Development :: Quality Assurance",
|
|
26
|
+
]
|
|
27
|
+
requires-python = ">=3.12"
|
|
28
|
+
dependencies = [
|
|
29
|
+
"pathspec>=1.1.1",
|
|
30
|
+
"pdfplumber>=0.11.11",
|
|
31
|
+
"pydantic>=2.14.4",
|
|
32
|
+
"python-docx>=1.2.0",
|
|
33
|
+
"ruamel-yaml>=0.19.1",
|
|
34
|
+
"tree-sitter>=0.27.0",
|
|
35
|
+
"tree-sitter-python>=0.25.0",
|
|
36
|
+
"typer>=0.29.2",
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
[project.urls]
|
|
40
|
+
Homepage = "https://github.com/mrashidramzan1996/grounded-kb"
|
|
41
|
+
Repository = "https://github.com/mrashidramzan1996/grounded-kb"
|
|
42
|
+
Issues = "https://github.com/mrashidramzan1996/grounded-kb/issues"
|
|
43
|
+
|
|
44
|
+
[project.scripts]
|
|
45
|
+
kb = "kb.cli:app"
|
|
46
|
+
|
|
47
|
+
[build-system]
|
|
48
|
+
requires = ["uv_build>=0.12.6,<0.13.0"]
|
|
49
|
+
build-backend = "uv_build"
|
|
50
|
+
|
|
51
|
+
[tool.uv.build-backend]
|
|
52
|
+
module-name = "kb"
|
|
53
|
+
|
|
54
|
+
[tool.pytest.ini_options]
|
|
55
|
+
addopts = "--import-mode=importlib"
|
|
56
|
+
pythonpath = ["tests"]
|
|
57
|
+
testpaths = ["tests"]
|
|
58
|
+
markers = ["slow: builds the wheel and installs it into a throwaway venv (runs in the full suite)"]
|
|
59
|
+
norecursedirs = [
|
|
60
|
+
"fixtures",
|
|
61
|
+
".*",
|
|
62
|
+
"__pycache__",
|
|
63
|
+
]
|
|
64
|
+
|
|
65
|
+
[dependency-groups]
|
|
66
|
+
dev = [
|
|
67
|
+
"fpdf2>=2.9.0",
|
|
68
|
+
"pytest>=9.2.0",
|
|
69
|
+
]
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "grounded-kb"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Git-native knowledge base where every product fact rests on a verbatim quote or a code anchor, checked for any coding agent"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
keywords = ["knowledge-base", "requirements", "traceability", "ai-agents", "claude-code", "codex", "cli"]
|
|
9
|
+
classifiers = [
|
|
10
|
+
"Development Status :: 3 - Alpha",
|
|
11
|
+
"Environment :: Console",
|
|
12
|
+
"Intended Audience :: Developers",
|
|
13
|
+
"Operating System :: POSIX",
|
|
14
|
+
"Programming Language :: Python :: 3",
|
|
15
|
+
"Programming Language :: Python :: 3.12",
|
|
16
|
+
"Topic :: Software Development :: Documentation",
|
|
17
|
+
"Topic :: Software Development :: Quality Assurance",
|
|
18
|
+
]
|
|
19
|
+
requires-python = ">=3.12"
|
|
20
|
+
dependencies = [
|
|
21
|
+
"pathspec>=1.1.1",
|
|
22
|
+
"pdfplumber>=0.11.11",
|
|
23
|
+
"pydantic>=2.14.4",
|
|
24
|
+
"python-docx>=1.2.0",
|
|
25
|
+
"ruamel-yaml>=0.19.1",
|
|
26
|
+
"tree-sitter>=0.27.0",
|
|
27
|
+
"tree-sitter-python>=0.25.0",
|
|
28
|
+
"typer>=0.29.2",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[project.urls]
|
|
32
|
+
Homepage = "https://github.com/mrashidramzan1996/grounded-kb"
|
|
33
|
+
Repository = "https://github.com/mrashidramzan1996/grounded-kb"
|
|
34
|
+
Issues = "https://github.com/mrashidramzan1996/grounded-kb/issues"
|
|
35
|
+
|
|
36
|
+
[project.scripts]
|
|
37
|
+
kb = "kb.cli:app"
|
|
38
|
+
|
|
39
|
+
[build-system]
|
|
40
|
+
requires = ["uv_build>=0.12.6,<0.13.0"]
|
|
41
|
+
build-backend = "uv_build"
|
|
42
|
+
|
|
43
|
+
[tool.uv.build-backend]
|
|
44
|
+
module-name = "kb"
|
|
45
|
+
|
|
46
|
+
[tool.pytest.ini_options]
|
|
47
|
+
addopts = "--import-mode=importlib"
|
|
48
|
+
pythonpath = ["tests"]
|
|
49
|
+
testpaths = ["tests"]
|
|
50
|
+
markers = ["slow: builds the wheel and installs it into a throwaway venv (runs in the full suite)"]
|
|
51
|
+
norecursedirs = ["fixtures", ".*", "__pycache__"]
|
|
52
|
+
|
|
53
|
+
[dependency-groups]
|
|
54
|
+
dev = [
|
|
55
|
+
"fpdf2>=2.9.0",
|
|
56
|
+
"pytest>=9.2.0",
|
|
57
|
+
]
|
|
File without changes
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"""Claude Code hooks.
|
|
2
|
+
|
|
3
|
+
Sources (fetched 2026-11-23): https://code.claude.com/docs/en/hooks
|
|
4
|
+
- SessionStart: plain text on stdout is added to Claude's context.
|
|
5
|
+
- Stop input has `stop_hook_active` (true when Claude is already continuing because of a stop hook).
|
|
6
|
+
- Stop decision output, exit 0: {"decision": "block", "reason": "..."} keeps Claude working; no output lets it stop.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import json
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
from kb.agents.settings import merge_hooks
|
|
13
|
+
from kb.ports.agents import EventKind, HookEvent, HookResult
|
|
14
|
+
|
|
15
|
+
REASON_CODES = 3
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def block_reason(result: HookResult) -> str:
|
|
19
|
+
codes = list(dict.fromkeys(i.code for i in result.errors))[:REASON_CODES]
|
|
20
|
+
return f"kb check: {len(result.errors)} errors — {', '.join(codes)}; run `kb check --changed`"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class ClaudeCode:
|
|
24
|
+
name = "claude-code"
|
|
25
|
+
|
|
26
|
+
def install(self, root: Path) -> list[str]:
|
|
27
|
+
return merge_hooks(root, ".claude/settings.json", self.name)
|
|
28
|
+
|
|
29
|
+
def parse(self, event: EventKind, payload: dict) -> HookEvent:
|
|
30
|
+
return HookEvent(event, self.name, stop_active=payload.get("stop_hook_active") is True)
|
|
31
|
+
|
|
32
|
+
def respond(self, event: HookEvent, result: HookResult) -> tuple[str, int]:
|
|
33
|
+
if event.kind == "session_start":
|
|
34
|
+
return result.brief, 0
|
|
35
|
+
if event.kind == "stop" and result.errors and not event.stop_active:
|
|
36
|
+
return json.dumps({"decision": "block", "reason": block_reason(result)}, ensure_ascii=False), 0
|
|
37
|
+
return "", 0
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"""Codex hooks.
|
|
2
|
+
|
|
3
|
+
Sources (fetched 2026-11-23): https://developers.openai.com/codex/hooks, redirecting to
|
|
4
|
+
https://learn.chatgpt.com/docs/hooks
|
|
5
|
+
- Config: `.codex/hooks.json`, {"hooks": {"<Event>": [{"matcher"?, "hooks": [{"type": "command", "command": ...}]}]}}.
|
|
6
|
+
- SessionStart input: session_id, transcript_path, cwd, hook_event_name, model, permission_mode, source.
|
|
7
|
+
Plain text on stdout is added as developer context.
|
|
8
|
+
- Stop input adds turn_id, `stop_hook_active` (this turn was already continued by Stop) and last_assistant_message.
|
|
9
|
+
- Stop output: JSON is required on exit 0 (plain text is invalid). {"decision": "block", "reason": "..."} makes Codex
|
|
10
|
+
continue with `reason` as the new prompt; {} lets it stop. No hookSpecificOutput is defined for Stop.
|
|
11
|
+
- Non-managed hooks run only after review and trust in `/hooks`; a changed hook must be re-trusted.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
import json
|
|
15
|
+
from pathlib import Path
|
|
16
|
+
|
|
17
|
+
from kb.agents.claude_code import block_reason
|
|
18
|
+
from kb.agents.settings import merge_hooks
|
|
19
|
+
from kb.ports.agents import EventKind, HookEvent, HookResult
|
|
20
|
+
|
|
21
|
+
TRUST_NOTICE = "Codex runs project hooks only in a trusted project, after you review them in `/hooks`."
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class Codex:
|
|
25
|
+
name = "codex"
|
|
26
|
+
|
|
27
|
+
def install(self, root: Path) -> list[str]:
|
|
28
|
+
return merge_hooks(root, ".codex/hooks.json", self.name) + [TRUST_NOTICE]
|
|
29
|
+
|
|
30
|
+
def parse(self, event: EventKind, payload: dict) -> HookEvent:
|
|
31
|
+
return HookEvent(event, self.name, stop_active=payload.get("stop_hook_active") is True)
|
|
32
|
+
|
|
33
|
+
def respond(self, event: HookEvent, result: HookResult) -> tuple[str, int]:
|
|
34
|
+
if event.kind == "session_start":
|
|
35
|
+
return result.brief, 0
|
|
36
|
+
if event.kind == "stop":
|
|
37
|
+
if result.errors and not event.stop_active:
|
|
38
|
+
return json.dumps({"decision": "block", "reason": block_reason(result)}, ensure_ascii=False), 0
|
|
39
|
+
return "{}", 0
|
|
40
|
+
return "", 0
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"""Any other agent, or a human: a git pre-commit hook running `kb check --changed --strict`."""
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from kb.gitfiles import GitError, git_common_dir, git_path
|
|
6
|
+
from kb.ports.agents import EventKind, HookEvent, HookResult
|
|
7
|
+
from kb.safewrite import WriteRefused, check_target, write_atomic
|
|
8
|
+
|
|
9
|
+
# `if` (not `&&`): when kb isn't installed the hook must succeed, or every commit would be blocked.
|
|
10
|
+
HOOK_LINE = "if command -v kb >/dev/null 2>&1; then kb hook pre-commit || exit $?; fi"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def hooks_dir(root: Path) -> Path:
|
|
14
|
+
"""Where git looks for hooks (honours worktrees and core.hooksPath). Refuses a directory outside the
|
|
15
|
+
repository (and its .git): a global core.hooksPath would make every repository run kb."""
|
|
16
|
+
try:
|
|
17
|
+
directory, common = git_path(root, "hooks"), git_common_dir(root)
|
|
18
|
+
except (OSError, GitError) as e:
|
|
19
|
+
raise WriteRefused(f"{root} is not a git repository; cannot install a git hook") from e
|
|
20
|
+
if not (directory.is_relative_to(Path(root).resolve()) or directory.is_relative_to(common)):
|
|
21
|
+
raise WriteRefused(
|
|
22
|
+
f"git's hooks directory {directory} is outside this repository (a global core.hooksPath?), so "
|
|
23
|
+
f"other repositories would run it; nothing written. To use it anyway, add this line to "
|
|
24
|
+
f"{directory / 'pre-commit'} yourself: {HOOK_LINE}"
|
|
25
|
+
)
|
|
26
|
+
return directory
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class Generic:
|
|
30
|
+
name = "generic"
|
|
31
|
+
|
|
32
|
+
def install(self, root: Path) -> list[str]:
|
|
33
|
+
directory = hooks_dir(root)
|
|
34
|
+
shown = (directory / "pre-commit").as_posix()
|
|
35
|
+
if check_target(directory, "pre-commit", "file"):
|
|
36
|
+
return [f"{shown} exists; add this line to it:", HOOK_LINE]
|
|
37
|
+
write_atomic(directory, "pre-commit", f"#!/bin/sh\n{HOOK_LINE}\n", mode=0o755)
|
|
38
|
+
return [f"wrote {shown}"]
|
|
39
|
+
|
|
40
|
+
def parse(self, event: EventKind, payload: dict) -> HookEvent:
|
|
41
|
+
return HookEvent(event, self.name)
|
|
42
|
+
|
|
43
|
+
def respond(self, event: HookEvent, result: HookResult) -> tuple[str, int]:
|
|
44
|
+
if event.kind == "session_start":
|
|
45
|
+
return result.brief, 0
|
|
46
|
+
if event.kind == "pre_commit" and result.errors:
|
|
47
|
+
lines = [f"{i.severity} {i.code} {i.path or '-'} {i.record or '-'}: {' '.join(i.message.split())}" for i in result.errors]
|
|
48
|
+
return "\n".join(lines) + "\n", 1
|
|
49
|
+
return "", 0
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from kb.agents.claude_code import ClaudeCode
|
|
2
|
+
from kb.agents.codex import Codex
|
|
3
|
+
from kb.agents.generic import Generic
|
|
4
|
+
from kb.ports.agents import AgentIntegration
|
|
5
|
+
|
|
6
|
+
_AGENTS: dict[str, AgentIntegration] = {a.name: a for a in (ClaudeCode(), Codex(), Generic())}
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def agent_names() -> list[str]:
|
|
10
|
+
return list(_AGENTS)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def get_agent(name: str) -> AgentIntegration:
|
|
14
|
+
try:
|
|
15
|
+
return _AGENTS[name]
|
|
16
|
+
except KeyError:
|
|
17
|
+
raise KeyError(f"unknown agent {name!r}: use {', '.join(_AGENTS)}") from None
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"""Merging kb hook entries into an agent's JSON hooks file (Claude Code settings, Codex hooks.json)."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from kb.safewrite import WriteRefused, check_target, read_text, write_atomic
|
|
7
|
+
|
|
8
|
+
EVENTS = {"SessionStart": "session-start", "Stop": "stop"}
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def hook_command(event: str, agent: str) -> str:
|
|
12
|
+
# kb missing must never break the session, so the command is a no-op then
|
|
13
|
+
return f"command -v kb >/dev/null 2>&1 && kb hook {event} --agent {agent} || true"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _has(groups: list, command: str) -> bool:
|
|
17
|
+
return any(isinstance(g, dict) and any(isinstance(h, dict) and h.get("command") == command for h in g.get("hooks", [])) for g in groups)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def merge_hooks(root: Path, rel: str, agent: str) -> list[str]:
|
|
21
|
+
"""Add the SessionStart and Stop entries to `rel`, keeping every other key and entry. Idempotent.
|
|
22
|
+
Raises WriteRefused (nothing written) for a symlinked or non-regular target or content that is not a JSON object."""
|
|
23
|
+
exists = check_target(root, rel, "file")
|
|
24
|
+
try:
|
|
25
|
+
data = json.loads(read_text(root, rel)) if exists else {}
|
|
26
|
+
except ValueError as e:
|
|
27
|
+
raise WriteRefused(f"{rel} is not valid JSON: {e}") from e
|
|
28
|
+
if not isinstance(data, dict):
|
|
29
|
+
raise WriteRefused(f"{rel} is not a JSON object")
|
|
30
|
+
hooks = data.setdefault("hooks", {})
|
|
31
|
+
if not isinstance(hooks, dict):
|
|
32
|
+
raise WriteRefused(f"{rel}: 'hooks' is not an object")
|
|
33
|
+
for name, event in EVENTS.items():
|
|
34
|
+
groups = hooks.setdefault(name, [])
|
|
35
|
+
if not isinstance(groups, list):
|
|
36
|
+
raise WriteRefused(f"{rel}: hooks.{name} is not a list")
|
|
37
|
+
command = hook_command(event, agent)
|
|
38
|
+
if not _has(groups, command):
|
|
39
|
+
groups.append({"hooks": [{"type": "command", "command": command}]})
|
|
40
|
+
text = json.dumps(data, indent=2) + "\n"
|
|
41
|
+
if exists and read_text(root, rel) == text:
|
|
42
|
+
return [f"{rel} already up to date"]
|
|
43
|
+
write_atomic(root, rel, text)
|
|
44
|
+
return [f"wrote {rel}"]
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"""`kb baseline freeze`: record the agreed set of live requirements at HEAD."""
|
|
2
|
+
|
|
3
|
+
import hashlib
|
|
4
|
+
import os
|
|
5
|
+
import re
|
|
6
|
+
from datetime import datetime, timezone
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
from kb.check import run_check
|
|
10
|
+
from kb.gitfiles import (
|
|
11
|
+
commit_time, create_tag, delete_tag, find_default_branch, head_commit, is_dirty, require_commit, rev_parse, tag_exists,
|
|
12
|
+
)
|
|
13
|
+
from kb.records.lifecycle import live_ids
|
|
14
|
+
from kb.records.models import Requirement
|
|
15
|
+
from kb.records.repo import KbRepo
|
|
16
|
+
from kb.yamlio import dump_yaml
|
|
17
|
+
|
|
18
|
+
_VERSION = re.compile(r"v\d+")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class BaselineError(Exception):
|
|
22
|
+
pass
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _load_problems(repo: KbRepo) -> list[str]:
|
|
26
|
+
problems = [f"{i.path}: {i.message}" for i in repo.errors]
|
|
27
|
+
by_id: dict[str, list[str]] = {}
|
|
28
|
+
for rid, path in repo.id_paths:
|
|
29
|
+
by_id.setdefault(rid, []).append(path)
|
|
30
|
+
problems += [f"{rid} is defined in {', '.join(paths)}" for rid, paths in sorted(by_id.items()) if len(paths) > 1]
|
|
31
|
+
return problems
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
_SHOWN_ERRORS = 5
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _on_default_branch_tip(root: Path) -> None:
|
|
38
|
+
branch = find_default_branch(root)
|
|
39
|
+
if branch is None or rev_parse(root, branch) != head_commit(root):
|
|
40
|
+
where = f"the tip of the default branch ({branch})" if branch else "on a default branch (main, master or origin/HEAD)"
|
|
41
|
+
raise BaselineError(
|
|
42
|
+
f"HEAD is not {where}: a baseline records what was approved by merging (A-2). "
|
|
43
|
+
"Freeze it on the default branch after the merge, or pass --allow-branch to freeze this commit anyway"
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _gate_errors(root: Path) -> None:
|
|
48
|
+
errors = [i for i in run_check(root).issues if i.severity == "error"]
|
|
49
|
+
if errors:
|
|
50
|
+
shown = [f"{i.code} {i.path or '-'} {i.record or '-'}: {' '.join(i.message.split())}" for i in errors[:_SHOWN_ERRORS]]
|
|
51
|
+
more = [f"... and {len(errors) - _SHOWN_ERRORS} more"] if len(errors) > _SHOWN_ERRORS else []
|
|
52
|
+
raise BaselineError(f"kb check reports {len(errors)} errors; fix them before freezing a baseline:\n" + "\n".join(shown + more))
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def freeze_baseline(root: Path, version: str, *, allow_branch: bool = False) -> Path:
|
|
56
|
+
"""Write kb/baseline/<version>.yaml (uncommitted) and tag HEAD as kb-baseline-<version>.
|
|
57
|
+
Refuses unless HEAD is the default branch's tip (or allow_branch) and `kb check` reports no error.
|
|
58
|
+
Nothing is left behind if any step fails."""
|
|
59
|
+
root = Path(root)
|
|
60
|
+
if not _VERSION.fullmatch(version):
|
|
61
|
+
raise BaselineError(f"version must look like v1, v2, ...: got {version!r}")
|
|
62
|
+
for rel in ("kb", "kb/baseline"):
|
|
63
|
+
if (root / rel).is_symlink():
|
|
64
|
+
raise BaselineError(f"{rel} must not be a symlink")
|
|
65
|
+
folder = root / "kb/baseline"
|
|
66
|
+
if folder.exists() and not folder.is_dir():
|
|
67
|
+
raise BaselineError("kb/baseline exists and is not a directory")
|
|
68
|
+
final = folder / f"{version}.yaml"
|
|
69
|
+
tag = f"kb-baseline-{version}"
|
|
70
|
+
if tag_exists(root, tag):
|
|
71
|
+
raise BaselineError(f"tag {tag} already exists")
|
|
72
|
+
if final.exists():
|
|
73
|
+
raise BaselineError(f"kb/baseline/{version}.yaml already exists")
|
|
74
|
+
if is_dirty(root, "kb/"):
|
|
75
|
+
raise BaselineError("kb/ has uncommitted changes; commit them before freezing a baseline")
|
|
76
|
+
|
|
77
|
+
require_commit(root)
|
|
78
|
+
if not allow_branch:
|
|
79
|
+
_on_default_branch_tip(root)
|
|
80
|
+
repo = KbRepo.load(root)
|
|
81
|
+
if problems := _load_problems(repo):
|
|
82
|
+
raise BaselineError("KB files have problems (run `kb check`):\n" + "\n".join(problems))
|
|
83
|
+
_gate_errors(root)
|
|
84
|
+
live = live_ids(repo)
|
|
85
|
+
reqs = [
|
|
86
|
+
{"id": rid, "hash": hashlib.sha256(repo.raw[repo.paths[rid]]).hexdigest()}
|
|
87
|
+
for rid in sorted(live)
|
|
88
|
+
if isinstance(repo.records[rid], Requirement)
|
|
89
|
+
]
|
|
90
|
+
frozen_at = datetime.fromtimestamp(commit_time(root, "HEAD"), timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
|
|
91
|
+
text = dump_yaml({"version": version, "commit": head_commit(root), "frozen_at": frozen_at, "requirements": reqs})
|
|
92
|
+
|
|
93
|
+
made_dir = not folder.exists()
|
|
94
|
+
made_tag = False
|
|
95
|
+
tmp = folder / f".{version}.yaml.tmp"
|
|
96
|
+
try:
|
|
97
|
+
folder.mkdir(parents=True, exist_ok=True)
|
|
98
|
+
fd = os.open(tmp, os.O_WRONLY | os.O_CREAT | os.O_EXCL | os.O_NOFOLLOW, 0o644)
|
|
99
|
+
with os.fdopen(fd, "w", encoding="utf-8") as f:
|
|
100
|
+
f.write(text)
|
|
101
|
+
create_tag(root, tag)
|
|
102
|
+
made_tag = True
|
|
103
|
+
os.link(tmp, final) # fails if final exists
|
|
104
|
+
tmp.unlink()
|
|
105
|
+
except BaseException as e:
|
|
106
|
+
tmp.unlink(missing_ok=True)
|
|
107
|
+
if made_tag:
|
|
108
|
+
delete_tag(root, tag)
|
|
109
|
+
if made_dir:
|
|
110
|
+
try:
|
|
111
|
+
folder.rmdir()
|
|
112
|
+
except OSError:
|
|
113
|
+
pass
|
|
114
|
+
if isinstance(e, FileExistsError):
|
|
115
|
+
raise BaselineError(f"kb/baseline/{version}.yaml already exists") from e
|
|
116
|
+
raise
|
|
117
|
+
return final
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
from kb.config.load import load_config
|
|
5
|
+
from kb.config.validate import validate_config
|
|
6
|
+
from kb.gates.anchors import anchor_gate
|
|
7
|
+
from kb.gates.base import GateContext, run_gates
|
|
8
|
+
from kb.gates.decisions import decision_guard
|
|
9
|
+
from kb.gates.ids import id_gate
|
|
10
|
+
from kb.gates.quotes import quote_gate
|
|
11
|
+
from kb.gates.sources import source_gate
|
|
12
|
+
from kb.gates.triage import triage_gate
|
|
13
|
+
from kb.config.load import ConfigError
|
|
14
|
+
from kb.gitfiles import GitError, changed_since, checkout_at, merge_base, repo_files, resolve_base
|
|
15
|
+
from kb.issues import Issue
|
|
16
|
+
from kb.modules import module_paths_gate, suggest_paths
|
|
17
|
+
from kb.records.repo import KbRepo
|
|
18
|
+
|
|
19
|
+
# id_gate must always run: KbRepo does not enforce that a file name matches its record id.
|
|
20
|
+
DEFAULT_GATES = [id_gate, quote_gate, anchor_gate, source_gate, module_paths_gate, triage_gate]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@dataclass
|
|
24
|
+
class CheckReport:
|
|
25
|
+
issues: list[Issue]
|
|
26
|
+
mode: str
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def run_check(root: Path, *, base: str | None = None, changed_only: bool = False) -> CheckReport:
|
|
30
|
+
"""Every Phase 1 gate. Raises ConfigError / GitError; the caller maps them to exit 2.
|
|
31
|
+
|
|
32
|
+
The base is where the branch forked from `base`, or with changed_only and no `base`, from the default
|
|
33
|
+
branch. With changed_only, file-level checks (unassigned / doubly-assigned files, marker issues, module
|
|
34
|
+
path suggestions) look only at files changed against it; record-level gates still cover the whole KB.
|
|
35
|
+
When no base resolves (no default branch yet), every file is checked and every source re-derived."""
|
|
36
|
+
root = Path(root)
|
|
37
|
+
config = load_config(root / "kb.config.yaml")
|
|
38
|
+
repo = KbRepo.load(root)
|
|
39
|
+
# decision_guard and the source gate compare with where the branch forked, not the tip of the base branch
|
|
40
|
+
base_ref = merge_base(root, base) if base else resolve_base(root) if changed_only else None
|
|
41
|
+
changed = changed_since(root, base_ref) if changed_only and base_ref else None
|
|
42
|
+
base_repo = KbRepo.at_ref(root, base_ref) if base_ref else None
|
|
43
|
+
ctx = GateContext(root, config, repo, base_repo, base_ref)
|
|
44
|
+
gates = list(DEFAULT_GATES) + ([decision_guard] if base_ref else [])
|
|
45
|
+
# a change to the config or to kb/ can break file-level checks on untouched files: then check every file
|
|
46
|
+
narrow = changed is not None and not any(p == "kb.config.yaml" or p.startswith("kb/") for p in changed)
|
|
47
|
+
if narrow:
|
|
48
|
+
changed = [p for p in changed if (root / p).exists()]
|
|
49
|
+
issues = validate_config(config, changed if narrow else repo_files(root))
|
|
50
|
+
issues += run_gates(ctx, gates)
|
|
51
|
+
if narrow:
|
|
52
|
+
touched = set(changed)
|
|
53
|
+
suggested = set(suggest_paths(root, config, repo, changed))
|
|
54
|
+
issues = [
|
|
55
|
+
i
|
|
56
|
+
for i in issues
|
|
57
|
+
if not (i.code == "marker.unknown_id" and i.path not in touched)
|
|
58
|
+
and not (i.code == "module.paths_suggested" and i.record not in suggested)
|
|
59
|
+
]
|
|
60
|
+
return CheckReport(sorted(issues, key=lambda i: (*i.sort_key, i.message)), config.policy.mode)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def errors_at(root: Path, commit: str) -> list[Issue]:
|
|
64
|
+
"""The errors `kb check` reported at `commit`, from a temporary checkout of it. No config there: none."""
|
|
65
|
+
with checkout_at(Path(root), commit) as tree:
|
|
66
|
+
if not (tree / "kb.config.yaml").exists():
|
|
67
|
+
return []
|
|
68
|
+
try:
|
|
69
|
+
report = run_check(tree, base=commit)
|
|
70
|
+
except (ConfigError, GitError):
|
|
71
|
+
return [] # nothing at the base can excuse an error now
|
|
72
|
+
return [i for i in report.issues if i.severity == "error"]
|