debrief-cli 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- debrief/__init__.py +0 -0
- debrief/build_artifact.py +83 -0
- debrief/classify.py +812 -0
- debrief/cli.py +291 -0
- debrief/compare_definitions.py +147 -0
- debrief/compare_llm.py +250 -0
- debrief/config.py +204 -0
- debrief/db.py +341 -0
- debrief/export.py +156 -0
- debrief/export_site.py +661 -0
- debrief/github.py +540 -0
- debrief/normalize.py +635 -0
- debrief/paths.py +17 -0
- debrief/prune.py +117 -0
- debrief/recommend.py +271 -0
- debrief/relay.py +83 -0
- debrief/runner.py +163 -0
- debrief/scrape.py +208 -0
- debrief/site/app.js +1613 -0
- debrief/site/index.html +32 -0
- debrief/site/method.js +117 -0
- debrief/site/style.css +520 -0
- debrief/skills.py +107 -0
- debrief/sources.py +341 -0
- debrief/synthesize.py +1052 -0
- debrief/verify_evidence.py +154 -0
- debrief_cli-0.1.0.dist-info/METADATA +205 -0
- debrief_cli-0.1.0.dist-info/RECORD +31 -0
- debrief_cli-0.1.0.dist-info/WHEEL +4 -0
- debrief_cli-0.1.0.dist-info/entry_points.txt +2 -0
- debrief_cli-0.1.0.dist-info/licenses/LICENSE +21 -0
debrief/__init__.py
ADDED
|
File without changes
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"""Build the debrief site as a Claude artifact in ARTIFACT_OUT.
|
|
2
|
+
|
|
3
|
+
The host wraps the page in its own html/head/body, so page.html holds only the title, the
|
|
4
|
+
Google Fonts links, the inlined CSS, the body markup and the inlined scripts. The exported
|
|
5
|
+
data/ is copied next to it. Run debrief.export_site first.
|
|
6
|
+
|
|
7
|
+
uv run python -m debrief.build_artifact
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import argparse
|
|
11
|
+
import re
|
|
12
|
+
import shutil
|
|
13
|
+
import sys
|
|
14
|
+
from pathlib import Path
|
|
15
|
+
|
|
16
|
+
from debrief.paths import ARTIFACT_OUT as OUT
|
|
17
|
+
from debrief.paths import SITE_OUT
|
|
18
|
+
from debrief.paths import SITE_SRC as SITE
|
|
19
|
+
|
|
20
|
+
MAX_FILES = 255
|
|
21
|
+
MAX_FILE_BYTES = 16_000_000 # decimal, to stay on the safe side of the host limit
|
|
22
|
+
MAX_TOTAL_BYTES = 64_000_000
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def one(pattern: str, text: str, what: str) -> str:
|
|
26
|
+
m = re.search(pattern, text, re.DOTALL | re.IGNORECASE)
|
|
27
|
+
if not m:
|
|
28
|
+
sys.exit(f"build_artifact: no {what} in site/index.html")
|
|
29
|
+
return m.group(1)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def inline_script(path: Path) -> str:
|
|
33
|
+
# "</script" inside JS would end the tag early; "<\/script" means the same thing in a JS string.
|
|
34
|
+
js = re.sub(r"</(script)", r"<\\/\1", path.read_text(), flags=re.IGNORECASE)
|
|
35
|
+
return f"<script>\n{js}\n</script>"
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def build_page() -> str:
|
|
39
|
+
html = (SITE / "index.html").read_text()
|
|
40
|
+
head = one(r"<head>(.*?)</head>", html, "<head>")
|
|
41
|
+
body = one(r"<body[^>]*>(.*?)</body>", html, "<body>")
|
|
42
|
+
title = one(r"(<title>.*?</title>)", head, "<title>")
|
|
43
|
+
fonts = [tag for tag in re.findall(r"<link\b[^>]*>", head, re.IGNORECASE) if "fonts.g" in tag]
|
|
44
|
+
scripts = re.findall(r'<script src="([^"]+)"></script>', body)
|
|
45
|
+
if scripts != ["method.js", "app.js"]:
|
|
46
|
+
sys.exit(f"build_artifact: expected method.js then app.js, found {scripts}")
|
|
47
|
+
markup = re.sub(r"\s*<script\b[^>]*></script>", "", body).strip()
|
|
48
|
+
css = (SITE / "style.css").read_text()
|
|
49
|
+
parts = [title, *fonts, f"<style>\n{css}\n</style>", markup, *(inline_script(SITE / s) for s in scripts)]
|
|
50
|
+
return "\n".join(parts) + "\n"
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def main(argv: list[str] | None = None) -> None:
|
|
54
|
+
argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter).parse_args(argv)
|
|
55
|
+
if not (SITE_OUT / "data" / "index.json").exists():
|
|
56
|
+
sys.exit(f"build_artifact: {SITE_OUT / 'data' / 'index.json'} missing; run debrief.export_site first")
|
|
57
|
+
if OUT.exists():
|
|
58
|
+
shutil.rmtree(OUT)
|
|
59
|
+
OUT.mkdir(parents=True)
|
|
60
|
+
(OUT / "page.html").write_text(build_page())
|
|
61
|
+
shutil.copytree(SITE_OUT / "data", OUT / "data")
|
|
62
|
+
|
|
63
|
+
files = sorted(p for p in OUT.rglob("*") if p.is_file())
|
|
64
|
+
sizes = {p: p.stat().st_size for p in files}
|
|
65
|
+
total = sum(sizes.values())
|
|
66
|
+
largest = max(sizes, key=sizes.get)
|
|
67
|
+
print(f"{len(files)} files, {total:,} bytes ({total / 1e6:.1f} MB)")
|
|
68
|
+
print(f"largest: {largest.relative_to(OUT)} at {sizes[largest]:,} bytes ({sizes[largest] / 1e6:.1f} MB)")
|
|
69
|
+
|
|
70
|
+
errors = []
|
|
71
|
+
if len(files) > MAX_FILES:
|
|
72
|
+
errors.append(f"{len(files)} files exceeds the {MAX_FILES}-file limit")
|
|
73
|
+
errors += [f"{p.relative_to(OUT)} is {n:,} bytes, over the {MAX_FILE_BYTES:,}-byte file limit"
|
|
74
|
+
for p, n in sizes.items() if n > MAX_FILE_BYTES]
|
|
75
|
+
if total > MAX_TOTAL_BYTES:
|
|
76
|
+
errors.append(f"{total:,} bytes exceeds the {MAX_TOTAL_BYTES:,}-byte total limit")
|
|
77
|
+
if errors:
|
|
78
|
+
sys.exit("build_artifact: over limits:\n " + "\n ".join(errors))
|
|
79
|
+
print(f"wrote {OUT}")
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
if __name__ == "__main__":
|
|
83
|
+
main()
|