jfl 0.3.0 → 0.4.3

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.
Files changed (104) hide show
  1. package/README.md +469 -36
  2. package/dist/commands/ci-setup.d.ts +5 -0
  3. package/dist/commands/ci-setup.d.ts.map +1 -0
  4. package/dist/commands/ci-setup.js +82 -0
  5. package/dist/commands/ci-setup.js.map +1 -0
  6. package/dist/commands/context-hub.d.ts.map +1 -1
  7. package/dist/commands/context-hub.js +154 -0
  8. package/dist/commands/context-hub.js.map +1 -1
  9. package/dist/commands/flows.d.ts +4 -1
  10. package/dist/commands/flows.d.ts.map +1 -1
  11. package/dist/commands/flows.js +160 -1
  12. package/dist/commands/flows.js.map +1 -1
  13. package/dist/commands/init.d.ts.map +1 -1
  14. package/dist/commands/init.js +42 -0
  15. package/dist/commands/init.js.map +1 -1
  16. package/dist/commands/peter.d.ts +2 -1
  17. package/dist/commands/peter.d.ts.map +1 -1
  18. package/dist/commands/peter.js +415 -2
  19. package/dist/commands/peter.js.map +1 -1
  20. package/dist/commands/pi.d.ts +21 -0
  21. package/dist/commands/pi.d.ts.map +1 -0
  22. package/dist/commands/pi.js +154 -0
  23. package/dist/commands/pi.js.map +1 -0
  24. package/dist/commands/portfolio.d.ts.map +1 -1
  25. package/dist/commands/portfolio.js +22 -69
  26. package/dist/commands/portfolio.js.map +1 -1
  27. package/dist/commands/predict.d.ts +6 -0
  28. package/dist/commands/predict.d.ts.map +1 -0
  29. package/dist/commands/predict.js +234 -0
  30. package/dist/commands/predict.js.map +1 -0
  31. package/dist/commands/synopsis.d.ts +44 -0
  32. package/dist/commands/synopsis.d.ts.map +1 -1
  33. package/dist/commands/synopsis.js +1 -1
  34. package/dist/commands/synopsis.js.map +1 -1
  35. package/dist/commands/update.d.ts.map +1 -1
  36. package/dist/commands/update.js +107 -5
  37. package/dist/commands/update.js.map +1 -1
  38. package/dist/commands/viz.d.ts +7 -0
  39. package/dist/commands/viz.d.ts.map +1 -0
  40. package/dist/commands/viz.js +460 -0
  41. package/dist/commands/viz.js.map +1 -0
  42. package/dist/dashboard/index.d.ts +4 -5
  43. package/dist/dashboard/index.d.ts.map +1 -1
  44. package/dist/dashboard/index.js +57 -146
  45. package/dist/dashboard/index.js.map +1 -1
  46. package/dist/dashboard-static/assets/index-B6kRK9Rq.js +116 -0
  47. package/dist/dashboard-static/assets/index-BpdKJPLu.css +1 -0
  48. package/dist/dashboard-static/index.html +16 -0
  49. package/dist/index.js +126 -19
  50. package/dist/index.js.map +1 -1
  51. package/dist/lib/flow-engine.d.ts +3 -0
  52. package/dist/lib/flow-engine.d.ts.map +1 -1
  53. package/dist/lib/flow-engine.js +70 -1
  54. package/dist/lib/flow-engine.js.map +1 -1
  55. package/dist/lib/hub-client.d.ts +80 -0
  56. package/dist/lib/hub-client.d.ts.map +1 -0
  57. package/dist/lib/hub-client.js +46 -0
  58. package/dist/lib/hub-client.js.map +1 -0
  59. package/dist/lib/predictor.d.ts +99 -0
  60. package/dist/lib/predictor.d.ts.map +1 -0
  61. package/dist/lib/predictor.js +394 -0
  62. package/dist/lib/predictor.js.map +1 -0
  63. package/dist/lib/service-gtm.d.ts +86 -51
  64. package/dist/lib/service-gtm.d.ts.map +1 -1
  65. package/dist/lib/service-gtm.js +417 -242
  66. package/dist/lib/service-gtm.js.map +1 -1
  67. package/dist/lib/telemetry-agent.d.ts +57 -0
  68. package/dist/lib/telemetry-agent.d.ts.map +1 -0
  69. package/dist/lib/telemetry-agent.js +268 -0
  70. package/dist/lib/telemetry-agent.js.map +1 -0
  71. package/dist/lib/telemetry-digest.d.ts.map +1 -1
  72. package/dist/lib/telemetry-digest.js +17 -17
  73. package/dist/lib/telemetry-digest.js.map +1 -1
  74. package/dist/lib/telemetry.d.ts +1 -0
  75. package/dist/lib/telemetry.d.ts.map +1 -1
  76. package/dist/lib/telemetry.js +14 -6
  77. package/dist/lib/telemetry.js.map +1 -1
  78. package/dist/mcp/context-hub-mcp.js +0 -0
  79. package/dist/mcp/service-registry-mcp.js +0 -0
  80. package/dist/types/map.d.ts +1 -1
  81. package/dist/types/map.d.ts.map +1 -1
  82. package/dist/types/map.js.map +1 -1
  83. package/dist/utils/jfl-paths.d.ts +1 -0
  84. package/dist/utils/jfl-paths.d.ts.map +1 -1
  85. package/dist/utils/jfl-paths.js +1 -0
  86. package/dist/utils/jfl-paths.js.map +1 -1
  87. package/package.json +7 -2
  88. package/scripts/generate-changesets.sh +113 -0
  89. package/scripts/pp-branch-pr.sh +115 -0
  90. package/template/.github/workflows/jfl-eval.yml +448 -0
  91. package/template/.github/workflows/jfl-review.yml +371 -0
  92. package/template/.jfl/flows/self-driving.yaml +190 -0
  93. package/dist/dashboard/components.d.ts +0 -7
  94. package/dist/dashboard/components.d.ts.map +0 -1
  95. package/dist/dashboard/components.js +0 -575
  96. package/dist/dashboard/components.js.map +0 -1
  97. package/dist/dashboard/pages.d.ts +0 -7
  98. package/dist/dashboard/pages.d.ts.map +0 -1
  99. package/dist/dashboard/pages.js +0 -1580
  100. package/dist/dashboard/pages.js.map +0 -1
  101. package/dist/dashboard/styles.d.ts +0 -7
  102. package/dist/dashboard/styles.d.ts.map +0 -1
  103. package/dist/dashboard/styles.js +0 -1110
  104. package/dist/dashboard/styles.js.map +0 -1
package/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # JFL - Just Fucking Launch
2
2
 
3
- **The context layer for AI-native teams.**
3
+ [![npm version](https://img.shields.io/npm/v/jfl.svg)](https://www.npmjs.com/package/jfl)
4
4
 
5
- JFL provides persistent context for AI workflows. Agents read what happened in previous sessions, understand decisions made, and access project knowledge — eliminating the cold-start problem where each AI interaction begins from zero.
5
+ **The engineering intelligence platform.**
6
+
7
+ JFL provides persistent context, autonomous agents, and self-driving improvement loops for any project. Agents read past sessions, understand decisions, track eval scores, and propose improvements — all backed by structured files in git.
6
8
 
7
9
  Context lives in git as structured files (markdown, JSONL). Any AI tool can integrate via MCP.
8
10
 
@@ -16,8 +18,9 @@ AI agents are stateless. Each session starts from scratch:
16
18
  - Previous decisions aren't remembered
17
19
  - Work from other sessions isn't visible
18
20
  - Context has to be re-explained every time
21
+ - Agent improvements aren't measured or tracked
19
22
 
20
- JFL provides a shared context layer that accumulates over time and is accessible to any AI tool.
23
+ JFL provides a shared context layer that accumulates over time, measures agent performance, and enables autonomous improvement loops — accessible to any AI tool.
21
24
 
22
25
  ---
23
26
 
@@ -55,28 +58,37 @@ That's it. SessionStart hooks handle repo sync, session branching, Context Hub s
55
58
 
56
59
  ## Architecture
57
60
 
58
- JFL workspaces are **context layers**, not code repos. Product code lives in separate service repos that register with the GTM.
61
+ JFL supports a three-level hierarchy: **Portfolio > GTM > Services**. Portfolios coordinate multiple products. GTMs are context layers for individual products. Services are the repos that do the actual work.
59
62
 
60
63
  ```
61
- my-project/ <- GTM workspace (strategy, context, orchestration)
64
+ visa-portfolio/ <- Portfolio (strategy, cross-product RL, data flow)
62
65
  ├── .jfl/
63
- │ ├── config.json <- Project config (team, services, ports)
64
- │ ├── journal/ <- Session journals (JSONL, one file per session)
65
- │ ├── memory.db <- Indexed memory (TF-IDF + embeddings)
66
- ├── agents/ <- Narrowly-scoped agent manifests + policies
67
- ├── flows/ <- Per-agent flow definitions (auto-loaded)
68
- ├── service-events.jsonl <- Event bus file-drop
69
- └── services.json <- Registered services
70
- ├── knowledge/ <- Strategy docs (VISION, ROADMAP, THESIS, etc.)
71
- ├── content/ <- Generated content
72
- ├── suggestions/ <- Per-contributor workspaces
73
- ├── .claude/
74
- │ ├── settings.json <- Claude Code hooks (SessionStart, Stop, etc.)
75
- ├── agents/ <- Service agent definitions
76
- └── skills/ <- Slash commands (/hud, /content, etc.)
77
- ├── scripts/session/ <- Session management (init, sync, cleanup)
78
- ├── CLAUDE.md <- AI instructions
79
- └── .mcp.json <- MCP server config (Context Hub)
66
+ │ ├── config.json <- type: "portfolio", registered child GTMs
67
+ │ ├── eval.jsonl <- Aggregated eval data from all children
68
+ │ ├── flows.yaml <- Cross-product event routing
69
+ └── journal/ <- Portfolio-level + synced child journals
70
+
71
+ ├── productrank-gtm/ <- GTM workspace (registered as child)
72
+ ├── .jfl/
73
+ │ │ ├── config.json <- type: "gtm", portfolio_parent, registered services
74
+ │ │ ├── eval.jsonl <- Eval entries from arena competitions
75
+ │ │ ├── journal/ <- Session journals + synced service journals
76
+ │ │ ├── agents/ <- Agent manifests + policies
77
+ ├── flows/ <- Per-agent flow definitions
78
+ │ └── service-events.jsonl
79
+ ├── knowledge/ <- Strategy docs (VISION, ROADMAP, THESIS, etc.)
80
+ ├── content/ <- Generated content
81
+ ├── suggestions/ <- Per-contributor workspaces
82
+ │ ├── .claude/
83
+ │ │ ├── settings.json <- Claude Code hooks
84
+ │ │ ├── agents/ <- Service agent definitions
85
+ │ │ └── skills/ <- Slash commands (/hud, /content, etc.)
86
+ │ ├── scripts/session/ <- Session management
87
+ │ ├── CLAUDE.md <- AI instructions
88
+ │ └── .mcp.json <- MCP server config
89
+
90
+ └── seo-agent/ <- Another GTM (registered as child)
91
+ └── ...
80
92
 
81
93
  my-api/ <- Service repo (registered in GTM)
82
94
  ├── src/
@@ -89,7 +101,8 @@ my-api/ <- Service repo (registered in GTM)
89
101
  - Services work independently
90
102
  - Multiple services register to one GTM
91
103
  - `jfl update` updates tooling without touching service code
92
- - Journal entries sync from services to parent GTM
104
+ - Eval data dual-writes up the chain (service > GTM > portfolio)
105
+ - Cross-product event routing at portfolio level
93
106
 
94
107
  ---
95
108
 
@@ -106,14 +119,14 @@ jfl context-hub stop # Stop daemon
106
119
  jfl context-hub restart # Restart daemon
107
120
  jfl context-hub doctor # Diagnose all projects (OK/ZOMBIE/DOWN/STALE)
108
121
  jfl context-hub ensure-all # Start for all GTM projects
109
- jfl context-hub dashboard # Live event + context dashboard
122
+ jfl context-hub dashboard # Open web dashboard (opens browser)
110
123
  jfl context-hub install-daemon # Auto-start on boot (launchd/systemd)
111
124
  jfl context-hub uninstall-daemon # Remove auto-start
112
125
  jfl context-hub query # Query context from CLI
113
126
  jfl context-hub serve # Run in foreground (daemon mode)
114
127
  ```
115
128
 
116
- **Per-project ports** assigned automatically (or set in `.jfl/config.json` `contextHub.port`).
129
+ **Per-project ports** assigned automatically (or set in `.jfl/config.json` > `contextHub.port`).
117
130
 
118
131
  **MCP Tools** (available to Claude Code and any MCP client):
119
132
 
@@ -126,9 +139,38 @@ jfl context-hub serve # Run in foreground (daemon mode)
126
139
  | `memory_search` | Search indexed journal memories |
127
140
  | `memory_status` | Memory system statistics |
128
141
  | `memory_add` | Add manual memory entry |
142
+ | `events_publish` | Publish event to MAP event bus |
143
+ | `events_recent` | Get recent events (with pattern filter) |
144
+ | `query_experiment_history` | Query RL trajectories for agent experiments |
129
145
 
130
146
  **Resilience:** 5-layer system — MCP auto-recovery on ECONNREFUSED, health-check-before-ensure hooks, `ensure-all` for batch startup, `doctor` diagnostics, launchd/systemd daemon with keepalive.
131
147
 
148
+ ### Dashboard
149
+
150
+ A pre-built Vite + Preact + Tailwind SPA served by Context Hub at `/dashboard/`. Auto-detects workspace type and adapts layout.
151
+
152
+ **Pages:**
153
+
154
+ | Page | What It Shows |
155
+ |------|--------------|
156
+ | **Overview** | Activity charts, product cards, metric cards |
157
+ | **Journal** | Searchable journal entries with type filters |
158
+ | **Events** | Live event feed with pattern filter presets (eval, session, flow, etc.) |
159
+ | **Services** | Registered services with type badges, context scope visualization, data flows |
160
+ | **Flows** | Flow definitions and execution history |
161
+ | **Health** | System metrics, context sources, memory index, tracked projects |
162
+ | **Agents** | Eval leaderboards grouped by product domain |
163
+ | **Experiments** | Experiment runs with dot plots — green (improved) / gray (no change) / red (regression) |
164
+ | **Telemetry** | Cost breakdown, command usage, error rates, hub health metrics |
165
+ | **Topology** | Service dependency graph and event flow visualization |
166
+
167
+ **Features:** Sidebar with structured sections (Workspace / Infra / Eval), inline SVG icons, agent leaderboard in sidebar, sparkline charts, real-time polling.
168
+
169
+ ```bash
170
+ jfl context-hub dashboard # Opens /dashboard/ in browser
171
+ jfl viz dash # Terminal equivalent (no browser needed)
172
+ ```
173
+
132
174
  ### MAP Event Bus
133
175
 
134
176
  Metrics, Agents, Pipeline — an in-process event bus inside Context Hub.
@@ -138,10 +180,207 @@ Metrics, Agents, Pipeline — an in-process event bus inside Context Hub.
138
180
  - **Journal bridge** — watches `.jfl/journal/`, emits events on new entries
139
181
  - **Pattern-matching subscriptions** (glob support)
140
182
  - **Transports:** SSE, WebSocket, HTTP polling
141
- - **Event types:** `session:started`, `session:ended`, `task:completed`, `journal:entry`, `service:healthy`, `custom`, and more
183
+ - **Cross-product routing** portfolio flows route events between child GTMs
184
+ - **Event types:** `session:started`, `session:ended`, `eval:scored`, `journal:entry`, `flow:triggered`, `agent:iteration-complete`, `portfolio:phone-home`, `review:findings`, `telemetry:insight`, `peter:pr-proposed`, and more
142
185
 
143
186
  Services emit events by appending to `.jfl/service-events.jsonl` — no auth needed, Context Hub watches the file automatically.
144
187
 
188
+ ### Eval Framework
189
+
190
+ Track agent performance over time. Eval entries dual-write up the parent chain (service > GTM > portfolio) so every level has visibility.
191
+
192
+ ```bash
193
+ jfl eval list # List recent eval entries
194
+ jfl eval list -a shadow # Filter by agent
195
+ jfl eval trajectory -a shadow # Composite score over time (with sparkline)
196
+ jfl eval log -a shadow -m '{"composite":0.69}' # Log an eval entry
197
+ jfl eval compare # Side-by-side agent comparison
198
+ jfl eval tuples # Extract (state, action, reward) training tuples
199
+ ```
200
+
201
+ **Eval entries** are JSONL with agent name, metrics, composite score, model version, and deltas:
202
+
203
+ ```json
204
+ {
205
+ "v": 1, "ts": "2026-03-05T15:22:47Z",
206
+ "agent": "productrank-shadow",
207
+ "dataset": "vibe-50-v1",
208
+ "model_version": "shadow-0.3.1",
209
+ "metrics": {"ndcg@10": 0.59, "mrr": 0.77, "precision@5": 0.43},
210
+ "composite": 0.6935,
211
+ "delta": {"composite": -0.029}
212
+ }
213
+ ```
214
+
215
+ **Leaderboard:** Agents grouped by metric domain. ProductRank agents scored on ndcg@10, mrr, precision@5. SEO agents scored on avg_rank, keywords_ranked. Dashboard Agents page shows leaderboards per domain.
216
+
217
+ **Training tuples** extracted from journals for fine-tuning: `(state, action, reward)` — maps codebase state + experiment action to eval score delta.
218
+
219
+ **API endpoints** on Context Hub:
220
+ - `GET /api/eval/leaderboard` — all agents ranked by composite
221
+ - `GET /api/eval/trajectory?agent=X&metric=composite` — score trajectory with timestamps
222
+
223
+ ### Self-Driving Loop
224
+
225
+ The autonomous improvement cycle. Agents detect issues, create fixes, and the system auto-merges if eval scores improve.
226
+
227
+ ```
228
+ Telemetry Agent detects issue
229
+ → telemetry:insight event
230
+ → Flow engine routes to Peter Parker
231
+ → PP creates fix PR (pp/ branch)
232
+ → GitHub Action runs eval + AI review
233
+ → eval:scored event posted to hub
234
+ → Auto-merge if improved / flag if regressed
235
+ → Training tuple logged
236
+ → Cycle repeats
237
+ ```
238
+
239
+ **9 declarative flows** in `.jfl/flows/self-driving.yaml`:
240
+
241
+ | Flow | Trigger | Action |
242
+ |------|---------|--------|
243
+ | `auto-merge-on-improvement` | `eval:scored` (improved) | `gh pr merge` + journal milestone |
244
+ | `flag-regression` | `eval:scored` (regressed) | `gh pr review --request-changes` |
245
+ | `log-training-tuple` | `eval:scored` | Log (state, action, reward) to journal |
246
+ | `log-quality-training-tuple` | `eval:scored` | Enriched tuple with AI quality dimensions |
247
+ | `block-merge-on-blockers` | `review:findings` (red) | `gh pr review --request-changes` |
248
+ | `log-review-training-data` | `review:findings` | Log review results as training data |
249
+ | `pp-address-review-blockers` | `review:findings` (red) | Spawn PP to fix (gated, max 3 iterations) |
250
+ | `insight-triggers-pp` | `telemetry:insight` (high) | Spawn PP to create fix PR |
251
+ | `predict-before-pr` | `peter:pr-proposed` | Run Stratus prediction before acting |
252
+
253
+ **Review gate:** Eval checks for AI review blockers before auto-merging. If the AI review requested changes (red findings), eval holds the merge even if tests improved. PRs must pass both eval AND review to auto-merge.
254
+
255
+ **CI Workflows** that close the loop:
256
+
257
+ - **`jfl-eval.yml`** — Runs on PP pull requests (`pp/` prefix). Checks out main for baseline, runs tests on PR, computes delta, runs AI quality assessment, posts `eval:scored` event to hub, comments on PR with eval results.
258
+ - **`jfl-review.yml`** — Context-aware AI code review on PP PRs. Gathers project context + knowledge docs, reviews diff for bugs/security/architecture, extracts structured findings (red/yellow/blue severity), posts `review:findings` event to hub.
259
+
260
+ ### Stratus Prediction Engine
261
+
262
+ Predict eval score deltas before executing changes using the Stratus world model (JEPA rollout + chat ensemble).
263
+
264
+ ```bash
265
+ jfl predict run --proposal "Fix auth timeout" --goal "improve test pass rate" --type fix --scope small
266
+ jfl predict resolve --id <id> --actual-delta 0.05 --actual-score 0.92 --eval-run <run-id>
267
+ jfl predict accuracy # Direction accuracy, mean delta error, calibration
268
+ jfl predict history # Recent predictions with sparkline trend
269
+ ```
270
+
271
+ **Dual Stratus strategy:**
272
+ - **Rollout API** (`/v1/rollout`) — JEPA world model, ~1.6s, ~$0.001. Fast state prediction for health trajectory.
273
+ - **Chat API** (`/v1/chat/completions`) — Full reasoning, ~28s, ~$0.05. Human-readable insights when patterns detected.
274
+
275
+ ### RL Infrastructure
276
+
277
+ JFL generalizes the Karpathy nanochat pattern: structured journals are the replay buffer, eval scores are rewards, agents learn in-context from past trajectories.
278
+
279
+ ```
280
+ Agent LLM (Policy) > reads trajectories, proposes experiments
281
+ Stratus (World Model) > predicts outcomes, filters bad proposals
282
+ Journals (Replay Buffer) > structured experiment history
283
+ Eval Framework (Reward) > composite scores, score deltas
284
+ Event Bus (Nervous System) > connects everything
285
+ Telemetry Agent > autonomous health monitoring + anomaly detection
286
+ ```
287
+
288
+ **JournalEntry type** — canonical schema with 6 RL fields: `hypothesis`, `outcome`, `score_delta`, `eval_snapshot`, `diff_hash`, `context_entries`.
289
+
290
+ **TrajectoryLoader** — query, filter, and render experiment trajectories for agent context windows. Supports filtering by session, agent, outcome, score range.
291
+
292
+ **Peter Parker** — model-routed orchestrator with cost/balanced/quality profiles. Routes tasks to haiku/sonnet/opus based on complexity. Subscribes to event bus for reactive dispatch. Creates PRs on `pp/` branches.
293
+
294
+ **Flow Engine** — declarative trigger-action automation in `.jfl/flows.yaml` and `.jfl/flows/*.yaml`:
295
+
296
+ ```yaml
297
+ - name: eval-scored-trigger-analysis
298
+ trigger:
299
+ pattern: "eval:scored"
300
+ gate:
301
+ requires_approval: true
302
+ actions:
303
+ - type: spawn
304
+ command: "claude -p 'Analyze the latest eval results'"
305
+ ```
306
+
307
+ Flow actions: `log`, `emit`, `journal`, `webhook`, `command`, `spawn`. Gates: `after` (time-gated), `before` (deadline), `requires_approval`.
308
+
309
+ **MCP tool:** `query_experiment_history` — agents query past experiment trajectories to inform next proposals.
310
+
311
+ ### Telemetry Agent
312
+
313
+ Autonomous monitoring agent that runs inside Context Hub on a configurable interval.
314
+
315
+ - Analyzes local telemetry events for patterns
316
+ - Detects anomalies: cost spikes (2x baseline), error spikes (3x baseline)
317
+ - Calls Stratus rollout API for JEPA health trajectory prediction
318
+ - Tracks `brain_goal_proximity` over time (product health score)
319
+ - Emits `telemetry:insight` events that trigger the self-driving loop
320
+ - State persisted at `.jfl/telemetry-agent-state.json`
321
+
322
+ **Insight types:** `anomaly`, `regression`, `cost_spike`, `pattern`, `stratus_prediction`
323
+
324
+ ### Terminal Visualizations
325
+
326
+ Headless dashboard data rendered in the terminal via `jfl viz`. No browser needed — same data as the web dashboard.
327
+
328
+ ```bash
329
+ jfl viz dash # Composite: leaderboard + flows + events + status
330
+ jfl viz experiments # Experiment runs with dot plot and sparklines
331
+ jfl viz leaderboard # Ranked agents with bar chart
332
+ jfl viz flows # Flow definitions and pending executions
333
+ jfl viz events # Recent event stream with type coloring
334
+ jfl viz status # Hub health and sources
335
+ ```
336
+
337
+ All subcommands support `--json` for programmatic consumption. Uses kuva for rich terminal plots with ASCII fallback.
338
+
339
+ ### Portfolio Management
340
+
341
+ Coordinate multiple GTM workspaces under one portfolio.
342
+
343
+ ```bash
344
+ jfl portfolio register /path/to/gtm # Register a GTM in this portfolio
345
+ jfl portfolio list # List child GTMs with health
346
+ jfl portfolio unregister <name> # Remove a GTM
347
+ jfl portfolio status # Portfolio health + eval summary
348
+ jfl portfolio phone-home # Report GTM health to portfolio parent
349
+ ```
350
+
351
+ **Portfolio Context Hub** operates in fan-out mode:
352
+ - Connects to child GTM hubs via SSE
353
+ - Bridges child events into portfolio event bus
354
+ - Fans out search queries across all child hubs
355
+ - Aggregates eval leaderboard across products
356
+ - Enforces context scope (produces/consumes/denied) between GTMs
357
+
358
+ **Cross-product flows** defined in `.jfl/flows.yaml`:
359
+
360
+ ```yaml
361
+ - name: tool-trends-to-seo
362
+ trigger:
363
+ pattern: "discovery:tool-trend"
364
+ source: "productrank-gtm"
365
+ actions:
366
+ - type: webhook
367
+ url: "http://localhost:{{child.seo-agent.port}}/api/events"
368
+ ```
369
+
370
+ Template variables: `{{child.NAME.port}}`, `{{child.NAME.token}}`
371
+
372
+ **Context scope** — each child GTM declares what events it produces and consumes. Portfolio enforces boundaries:
373
+
374
+ ```json
375
+ {
376
+ "context_scope": {
377
+ "produces": ["discovery:tool-trend", "eval:*"],
378
+ "consumes": ["strategy:*", "seo:serp-data"],
379
+ "denied": []
380
+ }
381
+ }
382
+ ```
383
+
145
384
  ### Memory System
146
385
 
147
386
  Hybrid search over all journal entries with TF-IDF (40%) + semantic embeddings (60%).
@@ -164,6 +403,7 @@ Automatic session isolation for parallel work:
164
403
  - **Multiple concurrent sessions:** Isolated git worktrees prevent conflicts
165
404
  - **Auto-commit:** Saves work every 2 minutes (knowledge, journal, suggestions)
166
405
  - **Crash recovery:** Detects uncommitted work in stale sessions, auto-commits on next start
406
+ - **Cleanup guard:** Prevents `rm -rf` on main branch when no worktrees exist
167
407
 
168
408
  ```bash
169
409
  # Hooks handle everything automatically. Manual control:
@@ -212,6 +452,18 @@ jfl services # Interactive TUI (no args)
212
452
  - Service entry in `.jfl/services.json`
213
453
  - Config in service repo (`.jfl/config.json` with `gtm_parent`)
214
454
 
455
+ **Context scoping:** Each service declares what events it produces and consumes. The GTM enforces scope — teams can't read each other's journals unless explicitly granted.
456
+
457
+ ```json
458
+ {
459
+ "context_scope": {
460
+ "produces": ["eval:submission", "journal:my-team*"],
461
+ "consumes": ["eval:scored", "leaderboard:updated"],
462
+ "denied": ["journal:other-team*"]
463
+ }
464
+ }
465
+ ```
466
+
215
467
  **Phone-home on session end:** When a service session ends, it syncs to the parent GTM:
216
468
  - Journal entries copied to `GTM/.jfl/journal/service-{name}-*.jsonl`
217
469
  - Comprehensive sync payload (git stats, health, environment)
@@ -242,6 +494,7 @@ jfl services # Interactive TUI (no args)
242
494
  | `jfl validate-settings [--fix] [--json]` | Validate and repair .claude/settings.json |
243
495
  | `jfl preferences [--clear-ai] [--show]` | Manage JFL preferences |
244
496
  | `jfl profile [action]` | Manage profile (show, edit, export, import, generate) |
497
+ | `jfl ci setup` | Deploy eval + review CI workflows to project |
245
498
  | `jfl test` | Test onboarding flow (isolated environment) |
246
499
 
247
500
  ### Context Hub
@@ -254,12 +507,52 @@ jfl services # Interactive TUI (no args)
254
507
  | `jfl context-hub status` | Health check |
255
508
  | `jfl context-hub doctor [--clean]` | Diagnose all projects |
256
509
  | `jfl context-hub ensure-all` | Start for all GTM projects |
257
- | `jfl context-hub dashboard` | Live event/context dashboard |
510
+ | `jfl context-hub dashboard` | Open web dashboard in browser |
258
511
  | `jfl context-hub query` | Query context from CLI |
259
512
  | `jfl context-hub serve` | Run in foreground (daemon mode) |
260
513
  | `jfl context-hub install-daemon` | Auto-start on boot |
261
514
  | `jfl context-hub uninstall-daemon` | Remove auto-start |
262
515
 
516
+ ### Eval Framework
517
+
518
+ | Command | Description |
519
+ |---------|-------------|
520
+ | `jfl eval list [-a agent] [-l limit]` | List recent eval entries |
521
+ | `jfl eval trajectory -a <agent>` | Composite score trajectory with sparkline |
522
+ | `jfl eval log -a <agent> -m <metrics>` | Log an eval entry |
523
+ | `jfl eval compare --agents <a,b>` | Side-by-side agent comparison |
524
+ | `jfl eval tuples [--team N] [--since date]` | Extract training tuples from journals |
525
+
526
+ ### Prediction
527
+
528
+ | Command | Description |
529
+ |---------|-------------|
530
+ | `jfl predict run --proposal <text> --goal <text>` | Predict eval delta for proposed change |
531
+ | `jfl predict resolve --id <id> --actual-delta <n>` | Resolve prediction with actual results |
532
+ | `jfl predict accuracy` | Prediction accuracy stats (direction, delta error, calibration) |
533
+ | `jfl predict history [--limit N]` | Recent predictions with sparkline |
534
+
535
+ ### Visualization
536
+
537
+ | Command | Description |
538
+ |---------|-------------|
539
+ | `jfl viz dash` | Composite terminal dashboard (default) |
540
+ | `jfl viz experiments [--agent name]` | Experiment runs with dot plot and sparklines |
541
+ | `jfl viz leaderboard` | Ranked agent leaderboard with bar chart |
542
+ | `jfl viz flows [--pending]` | Flow definitions and pending executions |
543
+ | `jfl viz events [--pattern glob] [--limit N]` | Recent events with type coloring |
544
+ | `jfl viz status` | Hub health, children, sources |
545
+
546
+ ### Portfolio
547
+
548
+ | Command | Description |
549
+ |---------|-------------|
550
+ | `jfl portfolio register <path>` | Register GTM workspace in portfolio |
551
+ | `jfl portfolio list` | List child GTMs with health status |
552
+ | `jfl portfolio unregister <name>` | Remove GTM from portfolio |
553
+ | `jfl portfolio status` | Portfolio health and eval summary |
554
+ | `jfl portfolio phone-home` | Report GTM health to portfolio parent |
555
+
263
556
  ### Memory
264
557
 
265
558
  | Command | Description |
@@ -296,12 +589,35 @@ jfl services # Interactive TUI (no args)
296
589
  | `jfl agent init <name> [-d desc]` | Scaffold agent (manifest + policy + lifecycle flows) |
297
590
  | `jfl agent list` | List registered agents |
298
591
  | `jfl agent status <name>` | Show agent health and config |
592
+ | `jfl peter setup [--cost\|--balanced\|--quality]` | Configure model routing profile |
593
+ | `jfl peter run [--task text]` | Run orchestrator (interactive or headless) |
594
+ | `jfl peter pr --task <text>` | Run agent, create PR on pp/ branch, emit event |
595
+ | `jfl peter experiment` | Proactive: analyze trajectory, pick highest-value task, execute |
596
+ | `jfl peter status` | Show config and recent events |
597
+ | `jfl peter dashboard` | Live event stream TUI |
299
598
  | `jfl ralph [args]` | Ralph-tui agent loop orchestrator |
300
- | `jfl peter [action]` | Peter Parker model-routed orchestrator (setup, run, status) |
301
599
  | `jfl orchestrate [name] [--list] [--create <n>]` | Multi-service orchestration workflows |
302
600
  | `jfl dashboard` | Interactive service monitoring TUI |
303
601
  | `jfl events [-p pattern]` | Live MAP event bus dashboard |
304
602
 
603
+ ### Hooks & Flows
604
+
605
+ | Command | Description |
606
+ |---------|-------------|
607
+ | `jfl hooks init` | Generate HTTP hooks + default flows |
608
+ | `jfl hooks status` | Check hooks and hub connectivity |
609
+ | `jfl hooks remove` | Remove HTTP hooks |
610
+ | `jfl hooks deploy` | Deploy hooks to all registered services |
611
+ | `jfl flows list` | List configured event-action flows |
612
+ | `jfl flows add` | Interactive flow builder |
613
+ | `jfl flows test <name>` | Test a flow with synthetic event |
614
+ | `jfl flows enable/disable <name>` | Toggle flows |
615
+ | `jfl flows approve [--flow name] [--all]` | Approve gated flow executions |
616
+ | `jfl scope list` | View service context scopes |
617
+ | `jfl scope set` | Set scope declarations |
618
+ | `jfl scope test` | Test scope enforcement |
619
+ | `jfl scope viz` | ASCII scope graph with access matrix |
620
+
305
621
  ### Platform
306
622
 
307
623
  | Command | Description |
@@ -312,6 +628,8 @@ jfl services # Interactive TUI (no args)
312
628
  | `jfl deploy [-f]` | Deploy to JFL platform |
313
629
  | `jfl agents [action]` | Manage parallel agents (list, create, start, stop, destroy) |
314
630
  | `jfl feedback [action]` | Rate session (0-5), view or sync |
631
+ | `jfl pi [--yolo] [--mode interactive\|rpc\|headless]` | Launch JFL in Pi runtime |
632
+ | `jfl pi agents run [--team yaml]` | Spawn agent team as Pi subprocesses |
315
633
 
316
634
  ### Telemetry & Intelligence
317
635
 
@@ -319,7 +637,7 @@ jfl services # Interactive TUI (no args)
319
637
  |---------|-------------|
320
638
  | `jfl telemetry status` | Show telemetry status |
321
639
  | `jfl telemetry show` | Show queued events |
322
- | `jfl telemetry digest [--hours N] [--format json] [--platform]` | Cost breakdown, health analysis, suggestions |
640
+ | `jfl telemetry digest [--hours N] [--format json] [--plots]` | Cost breakdown, health analysis, terminal charts |
323
641
  | `jfl telemetry reset` | Reset install ID |
324
642
  | `jfl telemetry track --category <c> --event <e>` | Emit event from shell scripts |
325
643
  | `jfl improve [--dry-run] [--auto] [--hours N]` | Self-improvement loop: analyze, suggest, create issues |
@@ -327,7 +645,7 @@ jfl services # Interactive TUI (no args)
327
645
 
328
646
  **Model cost tracking:** Every Stratus API call emits token counts and estimated cost. Covers claude-opus-4-6, claude-sonnet-4-6, claude-sonnet-4-5, claude-haiku-3-5, gpt-4o.
329
647
 
330
- **`jfl telemetry digest`** analyzes local events: per-model cost tables, command stats, error rates, hub/memory/session health. Flags issues like high MCP latency, cost concentration, crash rates.
648
+ **`jfl telemetry digest`** analyzes local events: per-model cost tables, command stats, error rates, hub/memory/session health. `--plots` renders bar charts via kuva (falls back to ASCII).
331
649
 
332
650
  **`jfl improve`** generates actionable suggestions from the digest. `--dry-run` previews, `--auto` creates GitHub issues tagged `[jfl-improve]`.
333
651
 
@@ -418,6 +736,7 @@ Pre-installed slash commands for Claude Code:
418
736
  | `/remotion-best-practices` | Remotion video creation in React |
419
737
  | `/geo` | GEO-first SEO analysis for AI search engines |
420
738
  | `/geo-audit` | Full website GEO+SEO audit with parallel agents |
739
+ | `/viz` | Terminal data visualization via kuva |
421
740
 
422
741
  ```bash
423
742
  # Install more skills
@@ -461,14 +780,16 @@ Every session MUST write journal entries. Hooks enforce this.
461
780
  "summary": "Built jfl onboard command that registers service repos in GTM",
462
781
  "detail": "Creates agent definition, skill wrapper, services.json entry...",
463
782
  "files": ["src/commands/onboard.ts"],
464
- "incomplete": ["peer sync not wired"],
465
- "next": "Wire phone-home on session end"
783
+ "hypothesis": "Structured onboarding reduces setup errors",
784
+ "outcome": "confirmed",
785
+ "score_delta": 0.12,
786
+ "eval_snapshot": {"composite": 0.85}
466
787
  }
467
788
  ```
468
789
 
469
790
  **Write entries when:** Feature completed, decision made, bug fixed, milestone reached, session ending.
470
791
 
471
- Entries become searchable via `jfl memory search` and MCP `memory_search` tool.
792
+ Entries become searchable via `jfl memory search` and MCP `memory_search` tool. RL fields (`hypothesis`, `outcome`, `score_delta`, `eval_snapshot`, `diff_hash`, `context_entries`) enable trajectory-based learning.
472
793
 
473
794
  ---
474
795
 
@@ -482,19 +803,78 @@ SessionStart hook fires You work normally Stop hook fire
482
803
  ├─ Create session branch ├─ Journal entries auto-tracked ├─ Auto-commit changes
483
804
  ├─ Recover crashed sessions ├─ Auto-commit every 2 min ├─ Merge to main
484
805
  ├─ Health-check Context Hub ├─ Events flow to MAP bus └─ Cleanup branch
485
- └─ Start auto-commit └─ Memory indexes continuously
806
+ └─ Start auto-commit ├─ Memory indexes continuously
807
+ ├─ Telemetry agent monitors
808
+ └─ Flows react to events
486
809
 
487
810
  Context Hub (always running)
488
811
  ├─ Serves MCP tools to Claude Code
489
812
  ├─ Aggregates journal + knowledge + code
490
813
  ├─ Bridges service events from file-drop
491
- └─ Watches journal/ for live entries
814
+ ├─ Watches journal/ for live entries
815
+ ├─ Portfolio mode: fans out to child hubs
816
+ ├─ Flow engine: reactive trigger→action
817
+ ├─ Telemetry agent: health monitoring
818
+ └─ Web dashboard at /dashboard/
492
819
  ```
493
820
 
494
821
  **Everything is files.** No proprietary database. No lock-in. Context is git-native — version controlled, portable, model-agnostic.
495
822
 
496
823
  ---
497
824
 
825
+ ## CI/CD
826
+
827
+ Two GitHub Actions workflows handle quality and releases. Two additional workflows close the self-driving loop.
828
+
829
+ ### CI — `.github/workflows/ci.yml`
830
+
831
+ Runs on every push and PR to `main`:
832
+
833
+ - TypeScript strict mode type checking
834
+ - Full test suite (~365 tests across 17 test files)
835
+ - Coverage report uploaded as artifact
836
+
837
+ ### Release — `.github/workflows/release.yml`
838
+
839
+ Fires after CI passes on `main`. Two paths:
840
+
841
+ 1. **Version bumped** (package.json differs from npm): Build, publish with provenance, create git tag, create GitHub Release with auto-generated notes.
842
+ 2. **Version matches npm**: Generate changesets from conventional commits, create "Version Packages" PR via changesets/action.
843
+
844
+ ```bash
845
+ # Option A: Manual changeset
846
+ npx changeset # pick bump level, write summary
847
+
848
+ # Option B: Just use conventional commits — auto-generated on CI
849
+ # feat: = minor, fix: = patch, feat!: = major
850
+
851
+ # Push to main → CI runs → Release publishes or creates Version PR
852
+ ```
853
+
854
+ **Secrets required:** `NPM_TOKEN` (granular access token scoped to jfl package). Provenance attestation via npm Trusted Publisher (OIDC).
855
+
856
+ ### Eval — `.github/workflows/jfl-eval.yml`
857
+
858
+ Runs on PRs from Peter Parker (`pp/` prefix) or `run-eval` label:
859
+
860
+ - Baseline test pass rate from `main`
861
+ - PR test pass rate
862
+ - AI quality assessment (correctness, coverage, architecture, value)
863
+ - Posts `eval:scored` event to Context Hub
864
+ - Comments on PR with eval results
865
+
866
+ ### AI Review — `.github/workflows/jfl-review.yml`
867
+
868
+ Runs on PRs from Peter Parker (`pp/` prefix) or `ai-review` label:
869
+
870
+ - Gathers project context (config, knowledge docs, journal)
871
+ - Context-aware diff review (bugs, security, architecture, tests)
872
+ - Structured findings with severity (red/yellow/blue)
873
+ - Posts `review:findings` event to Context Hub
874
+ - Comments on PR with findings
875
+
876
+ ---
877
+
498
878
  ## Auto-Update
499
879
 
500
880
  JFL checks for npm updates on session start (24-hour cache):
@@ -530,6 +910,58 @@ jfl wallet # Wallet and day pass status
530
910
 
531
911
  ## What's New
532
912
 
913
+ **0.4.3**
914
+ - Feat: **Self-driving loop proven end-to-end** — eval CI auto-merges improved PRs, requests changes on regressions. First auto-merged PP PR (#16) in 90 seconds
915
+ - Feat: **`jfl peter experiment`** — proactive experiment selection. Analyzes trajectory history + eval trends, uses Stratus to rank proposals (heuristic fallback), picks highest-value task, spawns PP to execute
916
+ - Feat: **`jfl ci setup`** — deploys eval + review CI workflows to any project with secret setup instructions
917
+ - Feat: **Review gate** — eval checks for AI review blockers before auto-merging. PRs must pass both eval AND review
918
+ - Feat: **Cron triggers** in flow engine — `cron:daily`, `cron:hourly`, `cron:every-30-minutes` patterns for proactive flows
919
+ - Feat: **`jfl update` syncs flows** — new flow files deployed on update (merge-only, never overwrites customizations)
920
+ - Fix: Eval CI self-sufficient — commits eval entries + service events to PR branch, no hub dependency for core loop
921
+ - Test: 274 tests (up from 266)
922
+
923
+ **0.4.2**
924
+ - Fix: HTTP hook port correction — `jfl init` and `jfl update` now detect and fix hooks pointing to wrong Context Hub port
925
+ - Fix: Release pipeline — direct publish when version bumped, changeset generation when version matches npm
926
+ - Fix: npm auth — NPM_TOKEN required (OIDC trusted publisher is for provenance only)
927
+ - Feat: Telemetry archive path fix — telemetry data properly flows to digest
928
+
929
+ **0.4.1**
930
+ - Feat: **Self-driving loop** — 9 declarative flows in `self-driving.yaml` for autonomous improvement (auto-merge, flag regression, training tuples, review response, telemetry-to-PP dispatch, Stratus prediction gate)
931
+ - Feat: **`jfl predict`** — Stratus prediction engine with run/resolve/accuracy/history subcommands
932
+ - Feat: **`jfl viz`** — terminal visualizations (experiments, leaderboard, flows, events, status, dash)
933
+ - Feat: **`jfl-eval.yml`** — CI workflow for eval on Peter Parker PRs (baseline comparison, AI quality scoring, event posting)
934
+ - Feat: **`jfl-review.yml`** — CI workflow for context-aware AI code review (structured findings, severity levels, event posting)
935
+ - Feat: **Telemetry agent** — autonomous monitoring in Context Hub (anomaly detection, Stratus JEPA health prediction, insight events)
936
+ - Feat: **`spawn` action type** in flow engine — spawn detached subprocesses with cleaned environment
937
+ - Feat: **`flows approve`** subcommand — approve gated flow executions (interactive or batch)
938
+ - Feat: Dashboard pages: **Experiments** (dot plots, sparklines), **Telemetry** (cost/usage/health), **Topology** (service dependency graph)
939
+ - Feat: **`jfl pi`** — Pi AI runtime integration with extensions, skills, and agent team spawning
940
+ - Feat: MCP tools: `events_publish`, `events_recent` for MAP event bus interaction
941
+
942
+ **0.4.0**
943
+ - Feat: **Peter Parker `pr` subcommand** — run agent, commit, push `pp/` branch, create PR, emit `pr:created` event
944
+ - Feat: **Peter Parker `dashboard`** — live event stream TUI
945
+ - Feat: Richer eval composite with AI quality dimensions (correctness, coverage, architecture, value)
946
+ - Feat: `scope viz` — ASCII scope graph with access matrix and flow visualization
947
+ - Feat: Context-aware AI review with structured findings + severity levels
948
+ - Fix: Baseline eval uses clean checkout (git checkout --force + clean)
949
+ - Test: Predictor unit tests, hub-client test coverage
950
+
951
+ **0.3.0**
952
+ - Feat: **Portfolio workspace type** — `jfl portfolio register/list/unregister/status/phone-home`. Portfolios contain multiple GTM workspaces with cross-product event routing via SSE, context scope enforcement (produces/consumes/denied), fan-out queries to child hubs, and portfolio-level leaderboard aggregation
953
+ - Feat: **Dashboard V2** — pre-built Vite + Preact + Tailwind SPA served at `/dashboard/`. Pages: Overview (activity charts, metric cards), Journal (search + type filters), Events (pattern filter presets), Services (type badges, context scope, data flows), Flows (definitions + execution history), Health (system metrics, memory index), Agents (eval leaderboards grouped by domain)
954
+ - Feat: **Eval framework** — `jfl eval list/trajectory/log/compare/tuples`. Track agent metrics over time with composite scores, dual-write up parent chain, extract (state, action, reward) training tuples. Agents grouped by metric domain (ProductRank: ndcg@10/mrr/precision@5, SEO: avg_rank/keywords_ranked)
955
+ - Feat: **RL infrastructure (Phase 1)** — `JournalEntry` type with 6 RL fields, `TrajectoryLoader` for querying experiment history, `query_experiment_history` MCP tool
956
+ - Feat: **Flow engine** — declarative trigger-action automation in `.jfl/flows.yaml`. Actions: log, emit, journal, webhook, command, spawn. Gates: time-gated, deadline, requires_approval. Template interpolation with `{{child.NAME.port}}`
957
+ - Feat: **HTTP hooks** — Claude Code lifecycle hooks (PostToolUse, Stop, PreCompact, SubagentStart/Stop) POST to Context Hub. `jfl hooks init/status/remove/deploy`
958
+ - Feat: **Context scope enforcement** — produces/consumes/denied patterns. Event bus filters by scope declarations. `jfl scope list/set/test`
959
+ - Feat: CI/CD pipeline — GitHub Actions CI (strict TypeScript + Jest gate) + CD via Changesets with auto-generation from conventional commits
960
+ - Feat: Service agent templates (CLAUDE.md, settings.json, knowledge docs)
961
+ - Feat: Session cleanup guard — prevents `rm -rf` on main when no worktrees exist
962
+ - Fix: TypeScript strict mode build errors resolved
963
+ - Test: ~365 tests across 17 test files (up from 237)
964
+
533
965
  **0.2.5**
534
966
  - Feat: Docker-style grouped `jfl --help` — 5 groups (Getting Started, Daily Use, Management, Platform, Advanced), ~30 lines down from 52
535
967
  - Feat: `jfl doctor [--fix]` — unified project health checker (9 checks: .jfl dir, config, Context Hub, hooks, memory, journal, agents, flows, git). Auto-repairs hooks, config, and journal with `--fix`
@@ -583,6 +1015,7 @@ jfl wallet # Wallet and day pass status
583
1015
 
584
1016
  ```bash
585
1017
  OPENAI_API_KEY=sk-... # Optional: enables semantic embeddings for memory search
1018
+ STRATUS_API_KEY=stratus_... # Optional: enables Stratus prediction engine + telemetry agent
586
1019
  CONTEXT_HUB_PORT=4242 # Override per-project port
587
1020
  CRM_SHEET_ID=your-sheet-id # Google Sheets CRM integration
588
1021
  JFL_PLATFORM_URL=... # JFL platform URL (default: jfl.run)
@@ -600,4 +1033,4 @@ MIT License - see LICENSE file.
600
1033
 
601
1034
  Built by [@tagga](https://x.com/taggaoyl) (Alec Taggart)
602
1035
 
603
- Powered by [Claude](https://claude.ai) (Anthropic), [x402](https://x402.org) (crypto micropayments), Commander.js, sql.js, and more.
1036
+ Powered by [Claude](https://claude.ai) (Anthropic), [Stratus](https://stratus.run) (JEPA world model), [x402](https://x402.org) (crypto micropayments), Commander.js, sql.js, and more.