secfoo 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.
Potentially problematic release.
This version of secfoo might be problematic. Click here for more details.
- secfoo/__about__.py +1 -0
- secfoo/__init__.py +3 -0
- secfoo/agents/__init__.py +4 -0
- secfoo/agents/antigravity.py +47 -0
- secfoo/agents/base.py +113 -0
- secfoo/agents/claude.py +36 -0
- secfoo/agents/cursor.py +26 -0
- secfoo/agents/gemini.py +38 -0
- secfoo/agents/registry.py +22 -0
- secfoo/cli.py +243 -0
- secfoo/config.py +21 -0
- secfoo/report/__init__.py +3 -0
- secfoo/report/markdown.py +43 -0
- secfoo/runner.py +197 -0
- secfoo/skills/__init__.py +11 -0
- secfoo/skills/definitions/deployment-readiness.md +42 -0
- secfoo/skills/definitions/prompt-review.md +44 -0
- secfoo/skills/definitions/responsible-ai-compliance.md +41 -0
- secfoo/skills/definitions/threat-assessment.md +41 -0
- secfoo/skills/loader.py +77 -0
- secfoo/skills/renderer.py +149 -0
- secfoo/storage/__init__.py +4 -0
- secfoo/storage/models.py +33 -0
- secfoo/storage/repository.py +154 -0
- secfoo/storage/schema.sql +30 -0
- secfoo/targets/__init__.py +19 -0
- secfoo/targets/github.py +35 -0
- secfoo/targets/resolver.py +50 -0
- secfoo/web/__init__.py +0 -0
- secfoo/web/app.py +19 -0
- secfoo/web/routes/__init__.py +0 -0
- secfoo/web/routes/overview.py +20 -0
- secfoo/web/routes/projects.py +22 -0
- secfoo/web/routes/runs.py +41 -0
- secfoo/web/static/design-system/README.md +108 -0
- secfoo/web/static/design-system/base.css +91 -0
- secfoo/web/static/design-system/components/alerts.css +49 -0
- secfoo/web/static/design-system/components/badges.css +48 -0
- secfoo/web/static/design-system/components/buttons.css +120 -0
- secfoo/web/static/design-system/components/cards.css +72 -0
- secfoo/web/static/design-system/components/forms.css +108 -0
- secfoo/web/static/design-system/components/modal.css +63 -0
- secfoo/web/static/design-system/components/navigation.css +79 -0
- secfoo/web/static/design-system/components/tables.css +38 -0
- secfoo/web/static/design-system/components/tabs.css +40 -0
- secfoo/web/static/design-system/demo.html +222 -0
- secfoo/web/static/design-system/design-system.css +18 -0
- secfoo/web/static/design-system/tokens.css +146 -0
- secfoo/web/templates/base.html +31 -0
- secfoo/web/templates/overview.html +48 -0
- secfoo/web/templates/project.html +25 -0
- secfoo/web/templates/run_detail.html +50 -0
- secfoo/web/templating.py +38 -0
- secfoo-0.1.0.dist-info/METADATA +73 -0
- secfoo-0.1.0.dist-info/RECORD +58 -0
- secfoo-0.1.0.dist-info/WHEEL +4 -0
- secfoo-0.1.0.dist-info/entry_points.txt +2 -0
- secfoo-0.1.0.dist-info/licenses/LICENSE +202 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import sqlite3
|
|
5
|
+
import uuid
|
|
6
|
+
from datetime import datetime, timezone
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
from secfoo.config import DB_PATH, ensure_store_dirs
|
|
10
|
+
from secfoo.storage.models import ProjectRecord, RunRecord
|
|
11
|
+
|
|
12
|
+
SCHEMA_PATH = Path(__file__).parent / "schema.sql"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _now() -> str:
|
|
16
|
+
return datetime.now(timezone.utc).isoformat()
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class RunRepository:
|
|
20
|
+
def __init__(self, db_path: Path | None = None) -> None:
|
|
21
|
+
ensure_store_dirs()
|
|
22
|
+
self.db_path = db_path or DB_PATH
|
|
23
|
+
self.db_path.parent.mkdir(parents=True, exist_ok=True)
|
|
24
|
+
self._conn = sqlite3.connect(self.db_path)
|
|
25
|
+
self._conn.row_factory = sqlite3.Row
|
|
26
|
+
self._conn.execute("PRAGMA foreign_keys = ON")
|
|
27
|
+
# Skills run concurrently in separate threads, each with its own
|
|
28
|
+
# connection to this same file; a busy_timeout makes a writer wait
|
|
29
|
+
# for a lock instead of immediately raising "database is locked".
|
|
30
|
+
self._conn.execute("PRAGMA busy_timeout = 5000")
|
|
31
|
+
self._conn.executescript(SCHEMA_PATH.read_text())
|
|
32
|
+
self._conn.commit()
|
|
33
|
+
|
|
34
|
+
def close(self) -> None:
|
|
35
|
+
self._conn.close()
|
|
36
|
+
|
|
37
|
+
def __enter__(self) -> "RunRepository":
|
|
38
|
+
return self
|
|
39
|
+
|
|
40
|
+
def __exit__(self, *exc: object) -> None:
|
|
41
|
+
self.close()
|
|
42
|
+
|
|
43
|
+
# ---------- projects ----------
|
|
44
|
+
|
|
45
|
+
def upsert_project(self, identifier: str, display_name: str, kind: str) -> int:
|
|
46
|
+
now = _now()
|
|
47
|
+
cur = self._conn.execute("SELECT id FROM projects WHERE identifier = ?", (identifier,))
|
|
48
|
+
row = cur.fetchone()
|
|
49
|
+
if row is not None:
|
|
50
|
+
self._conn.execute(
|
|
51
|
+
"UPDATE projects SET last_run_at = ? WHERE id = ?", (now, row["id"])
|
|
52
|
+
)
|
|
53
|
+
self._conn.commit()
|
|
54
|
+
return row["id"]
|
|
55
|
+
|
|
56
|
+
cur = self._conn.execute(
|
|
57
|
+
"INSERT INTO projects (identifier, display_name, kind, first_seen_at, last_run_at) "
|
|
58
|
+
"VALUES (?, ?, ?, ?, ?)",
|
|
59
|
+
(identifier, display_name, kind, now, now),
|
|
60
|
+
)
|
|
61
|
+
self._conn.commit()
|
|
62
|
+
return cur.lastrowid
|
|
63
|
+
|
|
64
|
+
def list_projects(self) -> list[ProjectRecord]:
|
|
65
|
+
rows = self._conn.execute("SELECT * FROM projects ORDER BY last_run_at DESC").fetchall()
|
|
66
|
+
return [ProjectRecord(**dict(row)) for row in rows]
|
|
67
|
+
|
|
68
|
+
def get_project(self, project_id: int) -> ProjectRecord | None:
|
|
69
|
+
row = self._conn.execute("SELECT * FROM projects WHERE id = ?", (project_id,)).fetchone()
|
|
70
|
+
return ProjectRecord(**dict(row)) if row else None
|
|
71
|
+
|
|
72
|
+
# ---------- runs ----------
|
|
73
|
+
|
|
74
|
+
def create_run(
|
|
75
|
+
self,
|
|
76
|
+
*,
|
|
77
|
+
project_id: int,
|
|
78
|
+
skill_id: str,
|
|
79
|
+
skill_name: str,
|
|
80
|
+
agent_id: str,
|
|
81
|
+
confluence_urls: list[str],
|
|
82
|
+
) -> str:
|
|
83
|
+
run_uuid = str(uuid.uuid4())
|
|
84
|
+
self._conn.execute(
|
|
85
|
+
"INSERT INTO runs (run_uuid, project_id, skill_id, skill_name, agent_id, "
|
|
86
|
+
"confluence_urls, status, started_at) VALUES (?, ?, ?, ?, ?, ?, 'running', ?)",
|
|
87
|
+
(run_uuid, project_id, skill_id, skill_name, agent_id, json.dumps(confluence_urls), _now()),
|
|
88
|
+
)
|
|
89
|
+
self._conn.commit()
|
|
90
|
+
return run_uuid
|
|
91
|
+
|
|
92
|
+
def complete_run(
|
|
93
|
+
self,
|
|
94
|
+
run_uuid: str,
|
|
95
|
+
*,
|
|
96
|
+
status: str,
|
|
97
|
+
exit_code: int | None,
|
|
98
|
+
duration_seconds: float | None,
|
|
99
|
+
report_path: str | None,
|
|
100
|
+
prompt_path: str | None,
|
|
101
|
+
stderr_excerpt: str | None,
|
|
102
|
+
) -> None:
|
|
103
|
+
self._conn.execute(
|
|
104
|
+
"UPDATE runs SET status = ?, exit_code = ?, finished_at = ?, duration_seconds = ?, "
|
|
105
|
+
"report_path = ?, prompt_path = ?, stderr_excerpt = ? WHERE run_uuid = ?",
|
|
106
|
+
(
|
|
107
|
+
status,
|
|
108
|
+
exit_code,
|
|
109
|
+
_now(),
|
|
110
|
+
duration_seconds,
|
|
111
|
+
report_path,
|
|
112
|
+
prompt_path,
|
|
113
|
+
stderr_excerpt,
|
|
114
|
+
run_uuid,
|
|
115
|
+
),
|
|
116
|
+
)
|
|
117
|
+
self._conn.commit()
|
|
118
|
+
|
|
119
|
+
def _row_to_run(self, row: sqlite3.Row) -> RunRecord:
|
|
120
|
+
data = dict(row)
|
|
121
|
+
confluence_urls = json.loads(data.pop("confluence_urls") or "[]")
|
|
122
|
+
project_display_name = data.pop("display_name", None)
|
|
123
|
+
return RunRecord(confluence_urls=confluence_urls, project_display_name=project_display_name, **data)
|
|
124
|
+
|
|
125
|
+
def list_runs(
|
|
126
|
+
self,
|
|
127
|
+
*,
|
|
128
|
+
project_id: int | None = None,
|
|
129
|
+
limit: int = 200,
|
|
130
|
+
status: str | None = None,
|
|
131
|
+
) -> list[RunRecord]:
|
|
132
|
+
query = (
|
|
133
|
+
"SELECT runs.*, projects.display_name FROM runs "
|
|
134
|
+
"JOIN projects ON projects.id = runs.project_id WHERE 1=1"
|
|
135
|
+
)
|
|
136
|
+
params: list[object] = []
|
|
137
|
+
if project_id is not None:
|
|
138
|
+
query += " AND runs.project_id = ?"
|
|
139
|
+
params.append(project_id)
|
|
140
|
+
if status is not None:
|
|
141
|
+
query += " AND runs.status = ?"
|
|
142
|
+
params.append(status)
|
|
143
|
+
query += " ORDER BY runs.started_at DESC LIMIT ?"
|
|
144
|
+
params.append(limit)
|
|
145
|
+
rows = self._conn.execute(query, params).fetchall()
|
|
146
|
+
return [self._row_to_run(row) for row in rows]
|
|
147
|
+
|
|
148
|
+
def get_run(self, run_uuid: str) -> RunRecord | None:
|
|
149
|
+
row = self._conn.execute(
|
|
150
|
+
"SELECT runs.*, projects.display_name FROM runs "
|
|
151
|
+
"JOIN projects ON projects.id = runs.project_id WHERE runs.run_uuid = ?",
|
|
152
|
+
(run_uuid,),
|
|
153
|
+
).fetchone()
|
|
154
|
+
return self._row_to_run(row) if row else None
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
CREATE TABLE IF NOT EXISTS projects (
|
|
2
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
3
|
+
identifier TEXT NOT NULL UNIQUE, -- resolved local path OR github URL
|
|
4
|
+
display_name TEXT NOT NULL,
|
|
5
|
+
kind TEXT NOT NULL CHECK (kind IN ('local','github')),
|
|
6
|
+
first_seen_at TEXT NOT NULL,
|
|
7
|
+
last_run_at TEXT NOT NULL
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
CREATE TABLE IF NOT EXISTS runs (
|
|
11
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
12
|
+
run_uuid TEXT NOT NULL UNIQUE,
|
|
13
|
+
project_id INTEGER NOT NULL REFERENCES projects(id),
|
|
14
|
+
skill_id TEXT NOT NULL,
|
|
15
|
+
skill_name TEXT NOT NULL,
|
|
16
|
+
agent_id TEXT NOT NULL,
|
|
17
|
+
confluence_urls TEXT NOT NULL DEFAULT '[]',
|
|
18
|
+
status TEXT NOT NULL CHECK (status IN
|
|
19
|
+
('pending','running','success','failed','timeout','binary_not_found')),
|
|
20
|
+
exit_code INTEGER,
|
|
21
|
+
started_at TEXT NOT NULL,
|
|
22
|
+
finished_at TEXT,
|
|
23
|
+
duration_seconds REAL,
|
|
24
|
+
report_path TEXT,
|
|
25
|
+
prompt_path TEXT,
|
|
26
|
+
stderr_excerpt TEXT
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
CREATE INDEX IF NOT EXISTS idx_runs_project_id ON runs(project_id);
|
|
30
|
+
CREATE INDEX IF NOT EXISTS idx_runs_started_at ON runs(started_at DESC);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from secfoo.targets.github import clone_shallow
|
|
2
|
+
from secfoo.targets.resolver import (
|
|
3
|
+
ResolvedTarget,
|
|
4
|
+
TargetKind,
|
|
5
|
+
TargetResolutionError,
|
|
6
|
+
is_github_url,
|
|
7
|
+
looks_like_url,
|
|
8
|
+
resolve_target,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
__all__ = [
|
|
12
|
+
"ResolvedTarget",
|
|
13
|
+
"TargetKind",
|
|
14
|
+
"TargetResolutionError",
|
|
15
|
+
"is_github_url",
|
|
16
|
+
"looks_like_url",
|
|
17
|
+
"resolve_target",
|
|
18
|
+
"clone_shallow",
|
|
19
|
+
]
|
secfoo/targets/github.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import shutil
|
|
4
|
+
import subprocess
|
|
5
|
+
import tempfile
|
|
6
|
+
from collections.abc import Iterator
|
|
7
|
+
from contextlib import contextmanager
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
from secfoo.targets.resolver import TargetResolutionError
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@contextmanager
|
|
14
|
+
def clone_shallow(url: str, *, timeout: int = 600) -> Iterator[Path]:
|
|
15
|
+
"""Shallow-clone `url` into a temp dir for the duration of the `with`
|
|
16
|
+
block, then remove it unconditionally -- including when the caller's
|
|
17
|
+
block raises.
|
|
18
|
+
"""
|
|
19
|
+
tmp_dir = Path(tempfile.mkdtemp(prefix="secfoo-clone-"))
|
|
20
|
+
try:
|
|
21
|
+
try:
|
|
22
|
+
subprocess.run(
|
|
23
|
+
["git", "clone", "--depth", "1", url, str(tmp_dir)],
|
|
24
|
+
check=True,
|
|
25
|
+
capture_output=True,
|
|
26
|
+
text=True,
|
|
27
|
+
timeout=timeout,
|
|
28
|
+
)
|
|
29
|
+
except subprocess.CalledProcessError as exc:
|
|
30
|
+
raise TargetResolutionError(f"git clone failed for {url}: {exc.stderr}") from exc
|
|
31
|
+
except subprocess.TimeoutExpired as exc:
|
|
32
|
+
raise TargetResolutionError(f"git clone timed out after {timeout}s for {url}") from exc
|
|
33
|
+
yield tmp_dir
|
|
34
|
+
finally:
|
|
35
|
+
shutil.rmtree(tmp_dir, ignore_errors=True)
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import re
|
|
4
|
+
from dataclasses import dataclass
|
|
5
|
+
from enum import Enum
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
_GITHUB_URL_RE = re.compile(r"^(https?://github\.com/|git@github\.com:)", re.IGNORECASE)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class TargetResolutionError(RuntimeError):
|
|
12
|
+
pass
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class TargetKind(str, Enum):
|
|
16
|
+
LOCAL = "local"
|
|
17
|
+
GITHUB = "github"
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@dataclass
|
|
21
|
+
class ResolvedTarget:
|
|
22
|
+
kind: TargetKind
|
|
23
|
+
path: Path | None # None for GITHUB until clone_shallow() fills it in
|
|
24
|
+
display_name: str # cwd path OR the github URL -- used as the storage project identifier
|
|
25
|
+
is_temporary: bool
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def is_github_url(value: str) -> bool:
|
|
29
|
+
return bool(_GITHUB_URL_RE.match(value.strip()))
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def resolve_target(target: str | None, *, cwd: Path | None = None) -> ResolvedTarget:
|
|
33
|
+
cwd = cwd or Path.cwd()
|
|
34
|
+
|
|
35
|
+
if target is None:
|
|
36
|
+
resolved = cwd.resolve()
|
|
37
|
+
return ResolvedTarget(TargetKind.LOCAL, resolved, str(resolved), False)
|
|
38
|
+
|
|
39
|
+
target = target.strip()
|
|
40
|
+
if is_github_url(target):
|
|
41
|
+
return ResolvedTarget(TargetKind.GITHUB, None, target, True)
|
|
42
|
+
|
|
43
|
+
path = Path(target).expanduser().resolve()
|
|
44
|
+
if not path.is_dir():
|
|
45
|
+
raise TargetResolutionError(f"Not a directory: {path}")
|
|
46
|
+
return ResolvedTarget(TargetKind.LOCAL, path, str(path), False)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def looks_like_url(value: str) -> bool:
|
|
50
|
+
return bool(re.match(r"^https?://", value.strip(), re.IGNORECASE))
|
secfoo/web/__init__.py
ADDED
|
File without changes
|
secfoo/web/app.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from fastapi import FastAPI
|
|
6
|
+
from fastapi.staticfiles import StaticFiles
|
|
7
|
+
|
|
8
|
+
from secfoo.web.routes import overview, projects, runs
|
|
9
|
+
|
|
10
|
+
STATIC_DIR = Path(__file__).parent / "static"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def create_app() -> FastAPI:
|
|
14
|
+
app = FastAPI(title="secfoo dashboard")
|
|
15
|
+
app.mount("/static", StaticFiles(directory=str(STATIC_DIR)), name="static")
|
|
16
|
+
app.include_router(overview.router)
|
|
17
|
+
app.include_router(projects.router)
|
|
18
|
+
app.include_router(runs.router)
|
|
19
|
+
return app
|
|
File without changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from fastapi import APIRouter, Request
|
|
4
|
+
|
|
5
|
+
from secfoo.storage.repository import RunRepository
|
|
6
|
+
from secfoo.web.templating import templates
|
|
7
|
+
|
|
8
|
+
router = APIRouter()
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@router.get("/")
|
|
12
|
+
def overview(request: Request):
|
|
13
|
+
with RunRepository() as repo:
|
|
14
|
+
projects = repo.list_projects()
|
|
15
|
+
recent_runs = repo.list_runs(limit=25)
|
|
16
|
+
return templates.TemplateResponse(
|
|
17
|
+
request,
|
|
18
|
+
"overview.html",
|
|
19
|
+
{"projects": projects, "recent_runs": recent_runs},
|
|
20
|
+
)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from fastapi import APIRouter, HTTPException, Request
|
|
4
|
+
|
|
5
|
+
from secfoo.storage.repository import RunRepository
|
|
6
|
+
from secfoo.web.templating import templates
|
|
7
|
+
|
|
8
|
+
router = APIRouter()
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@router.get("/projects/{project_id}")
|
|
12
|
+
def project_detail(request: Request, project_id: int):
|
|
13
|
+
with RunRepository() as repo:
|
|
14
|
+
project = repo.get_project(project_id)
|
|
15
|
+
if project is None:
|
|
16
|
+
raise HTTPException(status_code=404, detail="Project not found")
|
|
17
|
+
runs = repo.list_runs(project_id=project_id, limit=200)
|
|
18
|
+
return templates.TemplateResponse(
|
|
19
|
+
request,
|
|
20
|
+
"project.html",
|
|
21
|
+
{"project": project, "runs": runs},
|
|
22
|
+
)
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from fastapi import APIRouter, HTTPException, Request
|
|
6
|
+
from fastapi.responses import FileResponse
|
|
7
|
+
|
|
8
|
+
from secfoo.report.markdown import render_report_html
|
|
9
|
+
from secfoo.storage.repository import RunRepository
|
|
10
|
+
from secfoo.web.templating import templates
|
|
11
|
+
|
|
12
|
+
router = APIRouter()
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@router.get("/runs/{run_uuid}")
|
|
16
|
+
def run_detail(request: Request, run_uuid: str):
|
|
17
|
+
with RunRepository() as repo:
|
|
18
|
+
record = repo.get_run(run_uuid)
|
|
19
|
+
if record is None:
|
|
20
|
+
raise HTTPException(status_code=404, detail="Run not found")
|
|
21
|
+
|
|
22
|
+
report_html = ""
|
|
23
|
+
if record.report_path and Path(record.report_path).exists():
|
|
24
|
+
text = Path(record.report_path).read_text()
|
|
25
|
+
if text.strip():
|
|
26
|
+
report_html = render_report_html(text)
|
|
27
|
+
|
|
28
|
+
return templates.TemplateResponse(
|
|
29
|
+
request,
|
|
30
|
+
"run_detail.html",
|
|
31
|
+
{"run": record, "report_html": report_html},
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@router.get("/runs/{run_uuid}/report.md")
|
|
36
|
+
def run_report_download(run_uuid: str):
|
|
37
|
+
with RunRepository() as repo:
|
|
38
|
+
record = repo.get_run(run_uuid)
|
|
39
|
+
if record is None or not record.report_path or not Path(record.report_path).exists():
|
|
40
|
+
raise HTTPException(status_code=404, detail="Report not found")
|
|
41
|
+
return FileResponse(record.report_path, media_type="text/markdown", filename=f"{run_uuid}.md")
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# Design System
|
|
2
|
+
|
|
3
|
+
An original, framework-agnostic design system: design tokens (color, type,
|
|
4
|
+
spacing, radius, shadow, motion) plus a component library (buttons, forms,
|
|
5
|
+
cards, navigation, badges, alerts, tabs, tables, modal).
|
|
6
|
+
|
|
7
|
+
Open [`demo.html`](./demo.html) in a browser to see every token and
|
|
8
|
+
component rendered as a live style guide.
|
|
9
|
+
|
|
10
|
+
## Provenance
|
|
11
|
+
|
|
12
|
+
This system was built by studying the general visual language of a few
|
|
13
|
+
public B2B websites (color families, spacing rhythm, rounded "pill" button
|
|
14
|
+
shapes, soft shadows) as creative reference — the kind of research any
|
|
15
|
+
designer does by looking at sites they like. Nothing here is copied:
|
|
16
|
+
|
|
17
|
+
- All color values, spacing scale, type scale, and component CSS were
|
|
18
|
+
written from scratch with original names and values.
|
|
19
|
+
- No third-party CSS, class names, markup, images, icons, or logos were
|
|
20
|
+
reused.
|
|
21
|
+
- The reference sites used a commercially licensed font (Avenir LT Std);
|
|
22
|
+
this system uses **Inter** (open-source, SIL license) instead — swap it
|
|
23
|
+
for any font you're licensed to use.
|
|
24
|
+
|
|
25
|
+
General visual concepts like "a blue/teal palette" or "rounded buttons" are
|
|
26
|
+
not protectable by copyright, so this gives you a safe, original foundation.
|
|
27
|
+
If you want extra distance from any reference aesthetic, the easiest levers
|
|
28
|
+
are: change `--color-primary-*` hue, swap `--radius-pill` for a smaller
|
|
29
|
+
radius, and pick a different typeface.
|
|
30
|
+
|
|
31
|
+
## File structure
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
design-system/
|
|
35
|
+
├── tokens.css Design tokens (colors, type, spacing, radius, shadow, motion)
|
|
36
|
+
├── base.css Reset + base element styles wired to tokens
|
|
37
|
+
├── components/
|
|
38
|
+
│ ├── buttons.css
|
|
39
|
+
│ ├── forms.css
|
|
40
|
+
│ ├── cards.css
|
|
41
|
+
│ ├── navigation.css
|
|
42
|
+
│ ├── badges.css
|
|
43
|
+
│ ├── alerts.css
|
|
44
|
+
│ ├── tabs.css
|
|
45
|
+
│ ├── tables.css
|
|
46
|
+
│ └── modal.css
|
|
47
|
+
├── design-system.css Single entry point that imports everything
|
|
48
|
+
├── demo.html Live style guide
|
|
49
|
+
└── README.md
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Usage
|
|
53
|
+
|
|
54
|
+
Link the single entry point:
|
|
55
|
+
|
|
56
|
+
```html
|
|
57
|
+
<link rel="stylesheet" href="design-system/design-system.css" />
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Or import only what you need (e.g. tokens + buttons):
|
|
61
|
+
|
|
62
|
+
```html
|
|
63
|
+
<link rel="stylesheet" href="design-system/tokens.css" />
|
|
64
|
+
<link rel="stylesheet" href="design-system/components/buttons.css" />
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Example: button
|
|
68
|
+
|
|
69
|
+
```html
|
|
70
|
+
<button class="btn btn--primary btn--lg">Get started</button>
|
|
71
|
+
<button class="btn btn--outline btn--md">Learn more</button>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Example: card
|
|
75
|
+
|
|
76
|
+
```html
|
|
77
|
+
<div class="card card--interactive">
|
|
78
|
+
<span class="card__eyebrow">Category</span>
|
|
79
|
+
<h4 class="card__title">Title</h4>
|
|
80
|
+
<p class="card__body">Description text.</p>
|
|
81
|
+
</div>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Dark mode: add `data-theme="dark"` to `<html>` or any container — the
|
|
85
|
+
`--color-*` role tokens (`--color-bg`, `--color-text`, etc.) repoint
|
|
86
|
+
automatically (see bottom of `tokens.css`).
|
|
87
|
+
|
|
88
|
+
## Porting to another format later
|
|
89
|
+
|
|
90
|
+
Since everything reads from CSS custom properties in `tokens.css`, porting
|
|
91
|
+
is mostly a find-and-map exercise:
|
|
92
|
+
|
|
93
|
+
- **Tailwind**: map each token into `theme.extend` in `tailwind.config.js`
|
|
94
|
+
(e.g. `colors.primary[700] = '#124a60'`, `borderRadius.pill = '999px'`).
|
|
95
|
+
Component classes (`.btn--primary`) become `@apply` recipes or React
|
|
96
|
+
components using the mapped utility classes.
|
|
97
|
+
- **React/Vue component library**: turn each `components/*.css` file into a
|
|
98
|
+
component + its scoped styles (CSS Modules, styled-components, vanilla-
|
|
99
|
+
extract, etc.), importing `tokens.css` as the shared variable layer.
|
|
100
|
+
- **Figma variables / design tokens JSON**: the flat key-value shape of
|
|
101
|
+
`tokens.css` maps directly to a Style Dictionary or Figma Tokens JSON
|
|
102
|
+
file — one variable per custom property.
|
|
103
|
+
- **Native (iOS/Android)**: `tokens.css` is your naming reference; generate
|
|
104
|
+
a `Colors.swift` / `colors.xml` etc. from the same hex values.
|
|
105
|
+
|
|
106
|
+
Ask me when you're ready to convert and I can generate the port directly
|
|
107
|
+
(Tailwind config, React components, or a tokens.json) instead of doing it
|
|
108
|
+
by hand.
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Base / Reset
|
|
3
|
+
------------
|
|
4
|
+
Minimal modern reset + base element styling wired to design tokens.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
*, *::before, *::after {
|
|
8
|
+
box-sizing: border-box;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
html {
|
|
12
|
+
-webkit-text-size-adjust: 100%;
|
|
13
|
+
text-size-adjust: 100%;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
body {
|
|
17
|
+
margin: 0;
|
|
18
|
+
font: var(--text-body);
|
|
19
|
+
color: var(--color-text);
|
|
20
|
+
background-color: var(--color-bg);
|
|
21
|
+
-webkit-font-smoothing: antialiased;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
img, picture, video, canvas, svg {
|
|
25
|
+
display: block;
|
|
26
|
+
max-width: 100%;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
h1, h2, h3, h4, h5, h6, p, figure {
|
|
30
|
+
margin: 0 0 var(--space-4) 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
h1 { font: var(--text-h1); }
|
|
34
|
+
h2 { font: var(--text-h2); }
|
|
35
|
+
h3 { font: var(--text-h3); }
|
|
36
|
+
h4 { font: var(--text-h4); }
|
|
37
|
+
|
|
38
|
+
.ds-display { font: var(--text-display); }
|
|
39
|
+
.ds-body-lg { font: var(--text-body-lg); }
|
|
40
|
+
.ds-body { font: var(--text-body); }
|
|
41
|
+
.ds-body-sm { font: var(--text-body-sm); }
|
|
42
|
+
.ds-caption { font: var(--text-caption); color: var(--color-text-muted); }
|
|
43
|
+
.ds-overline {
|
|
44
|
+
font: var(--text-overline);
|
|
45
|
+
letter-spacing: var(--overline-letter-spacing);
|
|
46
|
+
text-transform: uppercase;
|
|
47
|
+
color: var(--color-primary-600);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
a {
|
|
51
|
+
color: var(--color-link);
|
|
52
|
+
text-decoration-thickness: 1px;
|
|
53
|
+
text-underline-offset: 2px;
|
|
54
|
+
}
|
|
55
|
+
a:hover { color: var(--color-link-hover); }
|
|
56
|
+
|
|
57
|
+
ul, ol {
|
|
58
|
+
margin: 0 0 var(--space-4) 0;
|
|
59
|
+
padding-inline-start: var(--space-6);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
button, input, textarea, select {
|
|
63
|
+
font: inherit;
|
|
64
|
+
color: inherit;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/* Consistent, visible focus state across every interactive element */
|
|
68
|
+
:focus-visible {
|
|
69
|
+
outline: none;
|
|
70
|
+
box-shadow: var(--shadow-focus);
|
|
71
|
+
border-radius: var(--radius-sm);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.ds-container {
|
|
75
|
+
width: 100%;
|
|
76
|
+
max-width: var(--container-max);
|
|
77
|
+
margin-inline: auto;
|
|
78
|
+
padding-inline: var(--space-6);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.ds-visually-hidden {
|
|
82
|
+
position: absolute;
|
|
83
|
+
width: 1px;
|
|
84
|
+
height: 1px;
|
|
85
|
+
padding: 0;
|
|
86
|
+
margin: -1px;
|
|
87
|
+
overflow: hidden;
|
|
88
|
+
clip: rect(0, 0, 0, 0);
|
|
89
|
+
white-space: nowrap;
|
|
90
|
+
border: 0;
|
|
91
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Alerts / Inline notifications
|
|
3
|
+
-----------------------------
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
.alert {
|
|
7
|
+
display: flex;
|
|
8
|
+
gap: var(--space-3);
|
|
9
|
+
align-items: flex-start;
|
|
10
|
+
padding: var(--space-4) var(--space-5);
|
|
11
|
+
border-radius: var(--radius-md);
|
|
12
|
+
border: 1px solid transparent;
|
|
13
|
+
font: var(--text-body-sm);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.alert__icon {
|
|
17
|
+
flex-shrink: 0;
|
|
18
|
+
width: 1.25rem;
|
|
19
|
+
height: 1.25rem;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.alert__title {
|
|
23
|
+
font-weight: var(--font-weight-bold);
|
|
24
|
+
margin-bottom: var(--space-1);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.alert--info {
|
|
28
|
+
background-color: var(--color-info-bg);
|
|
29
|
+
border-color: var(--color-primary-200);
|
|
30
|
+
color: var(--color-primary-800);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.alert--success {
|
|
34
|
+
background-color: var(--color-success-bg);
|
|
35
|
+
border-color: #a9dcbb;
|
|
36
|
+
color: var(--color-success);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.alert--warning {
|
|
40
|
+
background-color: var(--color-warning-bg);
|
|
41
|
+
border-color: #f0d795;
|
|
42
|
+
color: var(--color-warning);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.alert--error {
|
|
46
|
+
background-color: var(--color-error-bg);
|
|
47
|
+
border-color: #f0b3af;
|
|
48
|
+
color: var(--color-error);
|
|
49
|
+
}
|