Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/adrs/ADR-0003-claude-code-marketplace.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Claude Code's plugin marketplace provides a tested distribution primitive: a roo

Adopt the Claude Code marketplace pattern inside the lionagi repository. The structure is:

```
```text
.claude-plugin/marketplace.json # root manifest
marketplace/<plugin>/.claude-plugin/plugin.json # per-plugin manifest
marketplace/<plugin>/skills/ # bundled skills (added in later plays)
Expand Down Expand Up @@ -75,12 +75,14 @@ shipped in Phase 0 and why the remaining four were removed or deferred.
## Consequences

**Positive**

- Users install only the capability slices they need, keeping Claude Code context lean.
- Each plugin can version independently; `studio` can ship a breaking MCP config change without bumping `devx`.
- MCP server configuration can be bundled per plugin (`studio`, `mcp-bundle`) once the FastAPI backend route set is stable.
- Clear ownership boundary: each plugin directory is a self-contained unit that external contributors or downstream forks can understand and extend.

**Negative**

- More manifests to maintain: root `marketplace.json` plus four `plugin.json` files (v2) must stay in sync as plugin names or descriptions change.
- Skills authored in `firm/resources/skills/` (canonical) must be copied or symlinked into `marketplace/<plugin>/skills/` for external installs — two places to update per skill change.
- The `plugin.json` schema is not yet finalized by Anthropic; field names or required keys may shift before GA, requiring a sweep across all four manifests.
Expand Down
8 changes: 8 additions & 0 deletions docs/adrs/ADR-0004-filesystem-data-layer.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
**Status**: Accepted
**Date**: 2026-05-19 (revised 2026-05-20)

---

> **Related update**: [ADR-0033](ADR-0033-unified-entity-state-model.md) and [ADR-0034](ADR-0034-frontend-data-and-state-architecture.md) formalize how data flows from the filesystem layer through SQLite into the frontend. The hybrid filesystem-as-source-of-truth model here remains accurate; ADR-0033 adds `NormalizedState` as the read-side projection, and ADR-0034 specifies the sync contract for frontend consumption.

---

## Context

Lion Studio's backend serves runs, agents, playbooks, plugins, shows, and sessions.
Expand Down Expand Up @@ -100,12 +106,14 @@ into SQLite at any time.
## Consequences

**Positive**

- Authored content stays in git-friendly files editable by any tool.
- Operational queries are fast (SQLite indexes, JOINs, aggregates).
- No external database process — SQLite is embedded.
- CLI and Studio share the same data without coordination protocol.

**Negative**

- Two data sources means two things to keep in sync.
- Import commands needed for historical data migration.
- Contributors must know which data lives where.
Expand Down
8 changes: 8 additions & 0 deletions docs/adrs/ADR-0006-sse-live-streaming.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
**Status**: Accepted
**Date**: 2026-05-19 (revised 2026-05-20)

---

> **Related update**: This ADR defines the SSE transport. [ADR-0034](ADR-0034-frontend-data-and-state-architecture.md) §"SSE architecture" defines the higher-level event taxonomy, dispatch strategy, and integration with TanStack Query cache. ADR-0034 is the canonical owner of event names and envelope structure; this ADR remains authoritative for the wire protocol and reconnect mechanics.

---

## Context

Lion Studio needs live updates for three surfaces: session message streams
Expand Down Expand Up @@ -81,12 +87,14 @@ stop reconnecting.
## Consequences

**Positive**

- `EventSource` is native in all modern browsers; no client library.
- Starlette `StreamingResponse` integrates with the existing FastAPI stack.
- One-way constraint prevents bidirectional state complexity.
- No WebSocket server, connection upgrade, or ping/pong management.

**Negative**

- SSE is strictly server-to-client. Any client-to-server action requires a
separate REST endpoint.
- HTTP/1.1 browser connection limits (6 per origin) constrain concurrent SSE
Expand Down
4 changes: 3 additions & 1 deletion docs/adrs/ADR-0007-plugin-auto-discovery.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ discovers those by scanning `skills/` and `agents/` subdirectories.
`plugin.json` for every lionagi marketplace plugin does NOT enumerate `skills` or `agents` arrays.
The Claude Code plugin loader auto-discovers skill and agent files from the directory layout:

```
```text
marketplace/<plugin>/
.claude-plugin/plugin.json # metadata only — no skills/agents arrays
skills/ # auto-discovered by CC loader
Expand All @@ -32,11 +32,13 @@ arrays) would create a redundancy that lags the actual directory contents.
## Consequences

**Positive**

- Adding a skill file to `skills/` is immediately effective; no manifest update required.
- Manifest stays small and readable — metadata only.
- Consistent with the only production reference implementation available at time of decision.

**Negative**

- Auto-discovery behavior is undocumented by Anthropic and may change before GA. If the CC
loader stops auto-discovering from directory layout, all four plugins break silently — there
is no explicit manifest to fall back on.
Expand Down
13 changes: 12 additions & 1 deletion docs/adrs/ADR-0009-sqlite-state-layer.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
**Status**: Accepted
**Date**: 2026-05-20

---

> **Related update**: This ADR establishes SQLite as the current persistent state layer. [ADR-0033](ADR-0033-unified-entity-state-model.md) introduces `NormalizedState` (lifecycle × health × delivery) as the contract for entity state; the SQLite schema here is the current materialization of that contract. [ADR-0034](ADR-0034-frontend-data-and-state-architecture.md) §"Backend-frontend sync contract" specifies how this layer's reads flow to the frontend. The schema extensions for the new dimensions are in ADR-0033 Appendix A. SQLite-specific details remain authoritative; future stores (Postgres, distributed) will materialize the same NormalizedState model differently.

---

## Context

Lion Studio's filesystem-only backend (ADR-0004) works for post-hoc review but
Expand Down Expand Up @@ -129,7 +135,7 @@ Branch config (provider, model, system_prompt, tools, effort) lives in
> stored in `node_metadata` JSON on the branch row, not as top-level columns. A
> dedicated branch fork protocol may promote these to first-class columns in a
> future migration if query patterns require it.

>
> **`system_msg_id` is first-class.** Unlike fork pointers, the system prompt
> reference is promoted to a top-level column because (a) every live persist
> path writes it during branch initialization, (b) the Studio inbox/branch view
Expand Down Expand Up @@ -174,6 +180,7 @@ grep, git, symlinks). ADR-0004 remains valid for these.
### Supporting code changes (same session)

**`Branch.to_dict()` streamlined** (commits 7ac31109, a36b5542):

- Added `mode` parameter: `"python"` (default), `"json"`, `"db"`.
- `mode="db"` renames `metadata` → `node_metadata`.
- Optional flags: `include_logs`, `include_log_config`,
Expand All @@ -182,6 +189,7 @@ grep, git, symlinks). ADR-0004 remains valid for these.
- `parse_model` only included when it differs from `chat_model`.

**`create_message()` extracted** (commit 8f6c6d94):

- `MessageManager.create_message()` is now a `@staticmethod` — can be used
without a MessageManager instance.
- Standalone `create_message()` function exported from
Expand All @@ -190,6 +198,7 @@ grep, git, symlinks). ADR-0004 remains valid for these.
insertion and system message replacement.

**`iModel.to_dict()` slimmed** (commits 7ac31109, a36b5542):

- `request_options` excluded by default (bulk, not useful for persistence).
- `processor_config` excluded by default.

Expand Down Expand Up @@ -218,6 +227,7 @@ on legacy versions) can drop the autocheckpoint setting or run
## Consequences

**Positive**

- Session/branch/message model has a persistent representation that mirrors the
runtime 1:1. Round-trip `to_dict(mode="db")` → INSERT → SELECT → `from_dict()`
is lossless.
Expand All @@ -230,6 +240,7 @@ on legacy versions) can drop the autocheckpoint setting or run
- Agent/playbook file-based contract preserved.

**Negative**

- `aiosqlite` is now a mandatory dependency (promoted from `lionagi[sqlite]` optional).
- JSON array for progression ordering limits query-side operations (no
`WHERE message_id IN progression` without JSON parsing).
Expand Down
9 changes: 8 additions & 1 deletion docs/adrs/ADR-0010-plugin-aware-studio.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ A new service scans two locations for plugins:
| Third-party | `~/.claude/plugins/cache/*/*/` | No (read-only) |

For each plugin directory, the service:

- Reads `.claude-plugin/plugin.json` for metadata (name, version, description)
- Falls back to directory name if no manifest exists
- Enumerates `skills/*/SKILL.md`, `agents/*.md`, `hooks/hooks.json`, `.mcp.json`
Expand All @@ -43,7 +44,7 @@ list for repo plugins. Third-party plugins are discovered by directory scan.

### 2. API surface

```
```text
GET /api/plugins/ → list all plugins with component counts
GET /api/plugins/{name} → plugin detail: metadata + component lists
GET /api/plugins/{name}/skills/{skill} → skill content (read-only)
Expand All @@ -62,6 +63,7 @@ Navigation changes from `Playbooks | Agents | Skills | Runs | Shows` to
name or `Lion Marketplace`), component counts (N skills, M agents).

**Plugin detail page**: tabbed layout:

- **Skills** tab: two-pane list+detail, read-only SKILL.md viewer
- **Agents** tab: agent names/descriptions with `Open in Agents →` cross-links
- **Hooks** tab: `hooks.json` viewer (read-only)
Expand Down Expand Up @@ -94,11 +96,13 @@ Plugin components need explicit navigation to their editable counterparts and
clear source/editability indicators:

**Cross-links from plugin detail tabs**:

- Agent tab: `Open in Agents →` link per agent (routes to `/agents/{name}`)
- Skill tab: `View source` link, `Copy path` action
- All tabs: `Open raw` for filesystem path

**Source badges on plugin list and detail**:

| Badge | Meaning |
|-------|---------|
| `Lion Marketplace` | From `marketplace/`, writable |
Expand All @@ -119,19 +123,22 @@ font with code fences in monospace, not the current all-monospace treatment.
### 6. Deferred: CLI sync, monitors, themes, LSP

These are not part of this ADR:

- `li plugin sync` CLI (marketplace → CC plugin install) — separate feature
- Monitors, themes, LSP components — surface in Studio when usage warrants
- Model-agnostic abstraction — current format is CC-native; abstract later

## Consequences

**Positive**

- Skills and agents gain context: users see which plugin provides each capability.
- Editing flows through existing definitions versioning — no new persistence layer.
- Third-party plugin visibility without management complexity.
- Direct alignment with CC's plugin model — what you see in Studio is what CC loads.

**Negative**

- Plugin discovery adds startup scan cost (~22ms for 4 plugins, negligible).
- Two navigation paths to the same skill (Plugins → devx → commit vs. direct URL).
- `plugin.json` may not exist for all marketplace plugins yet — fallback to dir name.
Expand Down
17 changes: 14 additions & 3 deletions docs/adrs/ADR-0011-shows-data-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
**Date**: 2026-05-20
**Extends**: ADR-0009 (SQLite state layer), ADR-0010 (plugin-aware Studio)

---

> **Related update**: The shows/plays schema defined here stores structural and operational state. [ADR-0033](ADR-0033-unified-entity-state-model.md) adds `NormalizedState` columns (health, delivery, reason_codes) additively to these tables. The lifecycle vocabularies for Shows and Plays in ADR-0033 §"Per-entity lifecycle vocabularies" are derived from this ADR's status enums. This ADR remains authoritative for the table structure and cardinality; ADR-0033 governs the meaning of state values written to those tables.

---

## Context

Shows (multi-play DAGs orchestrated by the `show` skill) currently exist only
Expand Down Expand Up @@ -140,7 +146,7 @@ accessible: `plays.session_id` → `sessions` → `branches` → `progressions`

### Read path (Studio API)

```
```text
GET /api/shows/ → SELECT from shows table (fast, no filesystem)
GET /api/shows/{topic} → shows row + plays rows + _show.md from disk
GET /api/shows/{topic}/plays/{name}
Expand Down Expand Up @@ -250,7 +256,7 @@ ADR-0012), not `/sessions/{session_id}`.
The plays table uses a single **State** column with a primary lifecycle pill
plus optional secondary badges for gate and integration:

```
```json
[completed] [passed] [merged] ← full provenance
[completed] ← no gate, no merge
[awaiting gate] ← running_complete
Expand All @@ -263,6 +269,7 @@ a single compound pill (hard to scan because dimensions aren't visually
separable).

**Badge colors**:

- Lifecycle: pending (amber), running (blue), awaiting_gate (amber),
completed (green), failed (red), aborted (gray)
- Gate: passed (green outline), failed (red outline), skipped (gray outline)
Expand All @@ -279,7 +286,7 @@ lifecycle + gate + review badges per ADR-0012's status vocabulary.
The PlayDag renders as a **compact dependency graph strip above the plays
table**, not a competing primary view:

```
```text
Dependency graph [Hide graph]
┌────────────────────────────────────────────────────────────────────┐
│ compact PlayDag, fitView, 150–170px tall │
Expand All @@ -290,6 +297,7 @@ Dependency graph [Hide graph]
```

Height scales with play count:

- ≤4 plays: 112px
- 5–20 plays: 160px
- 21+ plays: 220px with scroll/pan
Expand All @@ -301,6 +309,7 @@ a plain status table and loses the orchestration identity of the page.
### Show status provenance (added post-review)

Show status includes provenance to address trust concerns:

- `active` — at least one play running or pending
- `completed` — all plays merged and final gate passed (or inferred from filesystem)
- `aborted` — `_ABORT` file exists
Expand All @@ -317,6 +326,7 @@ indicate confidence level.
## Consequences

**Positive**

- Show → play → session → message drill-down via foreign keys.
- Fast list/filter queries without filesystem scanning.
- Structural queries: blocked plays, critical path, cross-show stats.
Expand All @@ -326,6 +336,7 @@ indicate confidence level.
- Status normalization eliminates contradictory displays across pages.

**Negative**

- Dual write: every `_meta.json` update must also update SQLite. If the
show skill crashes between writes, they can drift. Mitigation: the
`li state import-shows` command can re-sync from filesystem at any time.
Expand Down
Loading
Loading