Skip to content

Commit e758c39

Browse files
author
codejunkie99
committed
Merge branch 'feat/data-layer-monitor' into feat/data-flywheel-trainer
# Conflicts: # .agent/AGENTS.md # .agent/skills/_index.md # .agent/skills/_manifest.jsonl # .gitignore # README.md # docs/architecture.md
2 parents 56e0939 + 9f87330 commit e758c39

36 files changed

Lines changed: 1897 additions & 29 deletions

.agent/AGENTS.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,19 @@ are the exact failure mode this layer prevents.
4141
- Load a full `SKILL.md` only when its triggers match the current task
4242
- Every skill has a self-rewrite hook; invoke it after failures
4343

44+
## Design Systems
45+
- If the project root contains `DESIGN.md`, treat it as the source of truth
46+
for visual design decisions and load `skills/design-md/SKILL.md` when a
47+
task mentions `DESIGN.md`, Google Stitch, design tokens, design system,
48+
or visual design. (The skill's `preconditions` field gates loading on
49+
`DESIGN.md` actually existing — keep this rule in lockstep with
50+
`skills/_manifest.jsonl` to avoid same-task / different-harness drift.)
51+
- Prefer exact tokens, component rules, and design rationale from
52+
`DESIGN.md` over invented colors, typography, spacing, shadows, or motion.
53+
- Do not modify `DESIGN.md` unless the user explicitly asks for a design
54+
system change; implementation work consumes the contract, it doesn't
55+
edit it.
56+
4457
## Protocols
4558
- `protocols/permissions.md` — read before any tool call
4659
- `protocols/tool_schemas/` — typed interfaces for external tools
@@ -55,6 +68,9 @@ Daily driver, highest-leverage first:
5568
in one shot (stage + graduate + render). For rules you already know.
5669
- `show.py` — one-screen dashboard of brain state: episodes, candidates,
5770
lessons, failing skills, activity graph.
71+
- `data_layer_export.py` — local cross-harness activity/data-layer export:
72+
agent events, cron timelines, tokens/cost estimates, categories,
73+
harness mix, `dashboard.html`, and `daily-report.md`.
5874
- `data_flywheel_export.py` — local export of approved, redacted runs into
5975
trace records, context cards, eval cases, training-ready JSONL, and
6076
flywheel metrics. It does not train models or call APIs.

.agent/memory/semantic/DECISIONS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,9 @@
1414
**Rationale:** Each layer has different retention and retrieval needs. Flat memory breaks at ~6 weeks.
1515
**Alternatives considered:** Flat directory (fails at scale), vector store (over-engineered for single user).
1616
**Status:** active
17+
18+
## 2026-04-26: Add `design-md` seed skill (DESIGN.md / Google Stitch)
19+
**Decision:** Ship a sixth seed skill, `design-md`, that points coding agents at a root `DESIGN.md` (Google Stitch format) as the visual-system source of truth. Loads only when `DESIGN.md` exists at the project root, default behavior is read-only on the contract file, and validation prefers `npx @google/design.md lint DESIGN.md` over hand-checks.
20+
**Rationale:** `DESIGN.md` is becoming a de facto contract for AI-driven UI work; without an explicit skill, agents invent ad-hoc tokens that drift from the user's design system. Gating on `DESIGN.md`-existence keeps the skill silent on projects that don't use the format.
21+
**Alternatives considered:** Bundle the rules into `git-proxy` or `skillforge` (wrong scope, wrong triggers); leave it to per-project `.agent/skills/` overrides (loses the cross-harness benefit); broader triggers like "UI"/"frontend"/"components"/"styling" (too generic, loads on every UI task even without DESIGN.md).
22+
**Status:** active

.agent/skills/_index.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,29 @@ Triggers: "deploy", "ship", "release", "go live"
2727
Constraints: all tests passing, no unresolved TODOs in diff,
2828
requires human approval for production.
2929

30+
## data-layer
31+
Cross-harness activity monitoring and dashboard exports.
32+
Triggers: "data layer", "dashboard", "agent analytics", "resource usage",
33+
"cron monitoring", "daily report", "tokens"
34+
Constraints: local-only by default; no screenshot delivery without explicit user
35+
approval; do not commit private `.agent/data-layer/` exports.
36+
3037
## data-flywheel
3138
Turns approved, redacted runs into reusable local artifacts: trace records,
3239
context cards, eval cases, training-ready JSONL, and flywheel metrics.
3340
Triggers: "data flywheel", "trace to train", "training traces",
3441
"context cards", "eval cases", "approved runs", "vertical intelligence"
3542
Constraints: local-only by default; human-approved runs only; redaction required
3643
before trainable; does not train models.
44+
45+
## design-md
46+
Uses a root `DESIGN.md` as the portable visual system contract for
47+
Google Stitch workflows. Loads only when `DESIGN.md` exists at the
48+
project root.
49+
Triggers: "DESIGN.md", "design.md", "Google Stitch", "design tokens",
50+
"design system", "visual design"
51+
Preconditions: DESIGN.md exists at project root.
52+
Constraints: prefer DESIGN.md tokens over invented values, do not modify
53+
DESIGN.md unless the user explicitly asks, preserve unknown sections when
54+
an edit IS authorised, validate with `npx @google/design.md lint DESIGN.md`
55+
when available.

.agent/skills/_manifest.jsonl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
{"name":"git-proxy","version":"2026-01-01","triggers":["commit","push","branch","merge","rebase","pull request","PR"],"tools":["bash"],"preconditions":[".git exists"],"constraints":["never force push to main","never force push to protected branches","run tests before push"],"category":"operations"}
44
{"name":"debug-investigator","version":"2026-01-01","triggers":["debug","why is this failing","investigate","stack trace","bug"],"tools":["bash","memory_reflect"],"preconditions":[],"constraints":["reproduce before fixing","fix root cause, not symptoms"],"category":"engineering"}
55
{"name":"deploy-checklist","version":"2026-01-01","triggers":["deploy","ship","release","go live"],"tools":["bash"],"preconditions":[],"constraints":["all tests passing","no unresolved TODOs in diff","requires human approval for production"],"category":"operations"}
6+
{"name":"data-layer","version":"2026-04-25","triggers":["data layer","dashboard","agent analytics","resource usage","cron monitoring","daily report","tokens"],"tools":["bash","git"],"preconditions":[".agent exists"],"constraints":["local-only by default","no screenshot delivery without explicit user approval","do not commit private .agent/data-layer exports"],"category":"operations"}
67
{"name":"data-flywheel","version":"2026-04-25","triggers":["data flywheel","trace to train","training traces","context cards","eval cases","approved runs","vertical intelligence"],"tools":["bash","git"],"preconditions":[".agent exists"],"constraints":["local-only by default","human-approved runs only","redaction required before trainable","do not train models"],"category":"operations"}
8+
{"name":"design-md","version":"2026-04-26","triggers":["DESIGN.md","design.md","Google Stitch","Stitch","design tokens","design system","visual design"],"tools":["bash","memory_reflect"],"preconditions":["DESIGN.md exists at project root"],"constraints":["prefer DESIGN.md tokens over invented values","do not modify DESIGN.md unless the user explicitly asks","preserve unknown sections when an edit IS authorised","validate when tooling is available"],"category":"design"}

.agent/skills/data-layer/SKILL.md

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
---
2+
name: data-layer
3+
version: 2026-04-25
4+
triggers: ["data layer", "dashboard", "agent analytics", "resource usage", "cron monitoring", "daily report", "tokens"]
5+
tools: [bash, git]
6+
preconditions: [".agent exists"]
7+
constraints: ["local-only by default", "do not send screenshots without explicit user approval", "do not commit private .agent/data-layer exports"]
8+
---
9+
10+
# Data Layer - cross-harness monitoring for the portable brain
11+
12+
Use this skill when the user wants to measure agent activity across Claude Code,
13+
Hermes, OpenClaw, Codex, Cursor, OpenCode, Windsurf, Pi, Antigravity, or any
14+
custom loop using `.agent/`.
15+
16+
The goal is local business intelligence for the whole agent suite:
17+
18+
- what harnesses are active
19+
- how many agent events are happening
20+
- when cron/scheduled agents fire
21+
- which crons started/finished and how long they ran
22+
- how many agents are active
23+
- tokens and estimated cost by hour/day/week/month
24+
- resource usage by user-defined category
25+
- workflow success/error rates
26+
- KPI summary rows for cron cadence, run volume, reliability, active agents,
27+
workflow breadth, token usage, and estimated cost
28+
- screenshot-ready daily resource reports
29+
30+
## Hard Rules
31+
32+
- Stay local-first. Do not add telemetry or remote sync.
33+
- Do not store raw prompts, raw code, client names, emails, phone numbers, or
34+
unredacted business records in shared examples.
35+
- Do not commit `.agent/data-layer/` exports unless the user explicitly reviewed
36+
and sanitized them.
37+
- Do not send dashboard screenshots to email, Slack, webhooks, or any other
38+
channel unless the user explicitly approves the destination.
39+
40+
## Inputs
41+
42+
Default inputs:
43+
44+
```text
45+
.agent/memory/episodic/AGENT_LEARNINGS.jsonl
46+
.agent/data-layer/harness-events.jsonl optional
47+
.agent/data-layer/cron-runs.jsonl optional
48+
.agent/data-layer/category-rules.json optional
49+
```
50+
51+
`AGENT_LEARNINGS.jsonl` is the shared activity log. Optional files let users add
52+
events from harnesses that do not automatically write rich events yet.
53+
54+
## Export
55+
56+
Run:
57+
58+
```bash
59+
python3 .agent/tools/data_layer_export.py --window 30d --bucket day
60+
```
61+
62+
Use `--bucket hour`, `--bucket day`, `--bucket week`, or `--bucket month` for
63+
different chart grains.
64+
65+
Outputs go to:
66+
67+
```text
68+
.agent/data-layer/exports/<YYYY-MM-DD>/
69+
```
70+
71+
Key outputs:
72+
73+
- `agent-events.jsonl/csv`
74+
- `cron-runs.jsonl/csv`
75+
- `cron-timeline.json/csv`
76+
- `activity-series.json/csv`
77+
- `category-summary.json/csv`
78+
- `harness-summary.json/csv`
79+
- `workflow-summary.json/csv`
80+
- `kpi-summary.json/csv`
81+
- `dashboard-summary.json`
82+
- `dashboard-report.json`
83+
- `dashboard.html`
84+
- `daily-report.md`
85+
86+
## Categories
87+
88+
Users can define any categories they want in
89+
`.agent/data-layer/category-rules.json`, for example:
90+
91+
```json
92+
{
93+
"default_category": "uncategorized",
94+
"rules": [
95+
{"category": "coding", "skills": ["debug-investigator", "git-proxy"]},
96+
{"category": "admin", "run_types": ["cron"]},
97+
{"category": "financial", "workflows": ["invoice_collection"]},
98+
{"category": "personal", "workflows": ["calendar_coordination"]},
99+
{"category": "work", "phases": ["plan", "review", "qa", "ship"]}
100+
]
101+
}
102+
```
103+
104+
## Daily Screenshot Report
105+
106+
For daily resource management:
107+
108+
1. Run the exporter from a user-approved cron or scheduled agent.
109+
2. Open `dashboard.html`.
110+
3. Capture the Resource Overview, Activity, Tokens, Cron Runs, Task Categories,
111+
Harness Mix, Workflow Outcomes, Cron Gantt, and Cron Timeline sections.
112+
4. Send the screenshot only through an explicitly approved channel.
113+
114+
The exporter creates `daily-report.md` as the text summary. It does not send
115+
anything by itself.
116+
117+
## Self-rewrite hook
118+
119+
If exports are confusing twice in a row, improve category rules, schema names,
120+
or dashboard labels before adding heavier dashboard dependencies.

.agent/skills/design-md/SKILL.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
---
2+
name: design-md
3+
version: 2026-04-26
4+
triggers: ["DESIGN.md", "design.md", "Google Stitch", "Stitch", "design tokens", "design system", "visual design"]
5+
tools: [bash, memory_reflect]
6+
preconditions: ["DESIGN.md exists at project root"]
7+
constraints: ["prefer DESIGN.md tokens over invented values", "do not modify DESIGN.md unless the user explicitly asks", "preserve unknown sections when an edit IS authorised", "validate when tooling is available"]
8+
---
9+
10+
# DESIGN.md — portable visual system contract
11+
12+
Use this skill when a task touches Google Stitch's `DESIGN.md` format or
13+
the project explicitly references its design system / design tokens. The
14+
skill loads only when `DESIGN.md` exists at the project root (see
15+
`preconditions` above), so general UI / frontend / component work that
16+
isn't tied to a `DESIGN.md` won't trip it.
17+
18+
## Source of truth
19+
- `DESIGN.md` is a contract file. Read it before changing visual UI.
20+
- Treat YAML front matter tokens as normative values: colors, typography,
21+
spacing, radius, and component tokens are exact inputs to code.
22+
- Treat the Markdown body as design rationale: it explains mood, hierarchy,
23+
interaction intent, and where tokens should or should not be used.
24+
- If no `DESIGN.md` exists this skill is inactive; for new UI, offer to
25+
create one or ask for a brand/reference, but don't generate one
26+
unprompted.
27+
28+
## Default: read-only
29+
**Do not modify `DESIGN.md` unless the user explicitly asks for a design
30+
system change.** Implementation work consumes the contract; it does not
31+
edit it. Token additions, renames, or section restructures land in their
32+
own commit with a clear message and (ideally) a Stitch round-trip.
33+
34+
## Implementation rules
35+
1. Map tokens into the local styling system already in use: CSS variables,
36+
Tailwind theme values, design-token JSON, component props, or native
37+
styles.
38+
2. Use token references and component patterns from `DESIGN.md` instead of
39+
hard-coded one-off values.
40+
3. Keep accessibility constraints intact. Do not weaken contrast, focus,
41+
reduced-motion, or touch-target guidance unless the user explicitly
42+
asks.
43+
44+
## When an edit IS authorised
45+
1. Preserve unknown headings and extra prose; other agents or Stitch may
46+
own them.
47+
2. Express component variants as related entries
48+
(`button-primary`, `button-primary-hover`, etc.).
49+
3. Land token / structure changes in their own commit, separate from the
50+
feature consuming them.
51+
52+
## Validation
53+
- If Node/npm tooling is available, lint with:
54+
55+
```bash
56+
npx @google/design.md lint DESIGN.md
57+
```
58+
59+
- For design system changes, diff before/after:
60+
61+
```bash
62+
npx @google/design.md diff DESIGN.before.md DESIGN.md
63+
```
64+
65+
- If the CLI is unavailable or network/dependency policy blocks it, the
66+
manual fallback is best-effort only — check for broken `{path.to.token}`
67+
references, missing primary color / typography tokens, duplicate section
68+
headings, and section order. The CLI ALSO checks contrast ratios and
69+
orphaned tokens; the manual fallback does not, so re-run the CLI when
70+
you regain network access.
71+
72+
## Expected sections
73+
The Google draft spec uses YAML front matter plus Markdown sections.
74+
Common sections:
75+
76+
- `## Overview`
77+
- `## Colors`
78+
- `## Typography`
79+
- `## Layout`
80+
- `## Elevation & Depth`
81+
- `## Shapes`
82+
- `## Components`
83+
- `## Do's and Don'ts`
84+
85+
## Self-rewrite hook
86+
After every 5 uses OR on any failure:
87+
1. Read the last N skill-specific episodic entries.
88+
2. If a new failure mode has appeared (e.g. tokens drifting away from
89+
DESIGN.md, accessibility rules being weakened, unauthorised edits to
90+
the contract file), append it to this skill's `KNOWLEDGE.md`.
91+
3. If a constraint was violated, escalate to `semantic/LESSONS.md`.
92+
4. Commit: `skill-update: design-md, <one-line reason>`.

0 commit comments

Comments
 (0)