@slycode/slycode 0.1.14 → 0.1.15

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 (81) hide show
  1. package/dist/bridge/session-manager.js +1 -8
  2. package/dist/bridge/session-manager.js.map +1 -1
  3. package/dist/store/skills/context-priming/references/area-index.md +121 -68
  4. package/{templates/store/skills/context-priming/references → dist/store/skills/context-priming}/references/areas/feature-guide.md +44 -18
  5. package/dist/store/skills/context-priming/references/areas/messaging.md +108 -34
  6. package/dist/store/skills/context-priming/references/areas/scripts-deployment.md +61 -16
  7. package/dist/store/skills/context-priming/references/areas/skills.md +99 -38
  8. package/{templates/updates/skills/context-priming/references → dist/store/skills/context-priming}/references/areas/terminal-actions.md +1 -1
  9. package/dist/store/skills/context-priming/references/areas/terminal-bridge.md +74 -42
  10. package/dist/store/skills/context-priming/references/areas/web-frontend.md +259 -74
  11. package/dist/web/.next/BUILD_ID +1 -1
  12. package/dist/web/.next/build-manifest.json +2 -2
  13. package/dist/web/.next/server/app/_global-error.html +2 -2
  14. package/dist/web/.next/server/app/_global-error.rsc +1 -1
  15. package/dist/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  16. package/dist/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  17. package/dist/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  18. package/dist/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  19. package/dist/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  20. package/dist/web/.next/server/app/_not-found.html +1 -1
  21. package/dist/web/.next/server/app/_not-found.rsc +1 -1
  22. package/dist/web/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  23. package/dist/web/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  24. package/dist/web/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  25. package/dist/web/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  26. package/dist/web/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  27. package/dist/web/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  28. package/dist/web/.next/server/pages/404.html +1 -1
  29. package/dist/web/.next/server/pages/500.html +2 -2
  30. package/lib/cli/sync.d.ts +7 -0
  31. package/lib/cli/sync.d.ts.map +1 -1
  32. package/lib/cli/sync.js +32 -0
  33. package/lib/cli/sync.js.map +1 -1
  34. package/lib/cli/update.d.ts.map +1 -1
  35. package/lib/cli/update.js +9 -0
  36. package/lib/cli/update.js.map +1 -1
  37. package/package.json +1 -1
  38. package/templates/kanban-seed.json +1 -1
  39. package/templates/store/skills/context-priming/references/area-index.md +121 -68
  40. package/templates/{updates/skills/context-priming/references → store/skills/context-priming}/references/areas/feature-guide.md +44 -18
  41. package/templates/store/skills/context-priming/references/areas/messaging.md +108 -34
  42. package/templates/store/skills/context-priming/references/areas/scripts-deployment.md +61 -16
  43. package/templates/store/skills/context-priming/references/areas/skills.md +99 -38
  44. package/{dist/store/skills/context-priming/references → templates/store/skills/context-priming}/references/areas/terminal-actions.md +1 -1
  45. package/templates/store/skills/context-priming/references/areas/terminal-bridge.md +74 -42
  46. package/templates/store/skills/context-priming/references/areas/web-frontend.md +259 -74
  47. package/templates/updates/skills/context-priming/references/area-index.md +121 -68
  48. package/{dist/store/skills/context-priming/references → templates/updates/skills/context-priming}/references/areas/feature-guide.md +44 -18
  49. package/templates/updates/skills/context-priming/references/areas/messaging.md +108 -34
  50. package/templates/updates/skills/context-priming/references/areas/scripts-deployment.md +61 -16
  51. package/templates/updates/skills/context-priming/references/areas/skills.md +99 -38
  52. package/templates/{store/skills/context-priming/references → updates/skills/context-priming}/references/areas/terminal-actions.md +1 -1
  53. package/templates/updates/skills/context-priming/references/areas/terminal-bridge.md +74 -42
  54. package/templates/updates/skills/context-priming/references/areas/web-frontend.md +259 -74
  55. package/dist/store/skills/context-priming/references/areas/claude-actions.md +0 -120
  56. package/dist/store/skills/context-priming/references/references/area-index.md +0 -152
  57. package/dist/store/skills/context-priming/references/references/areas/messaging.md +0 -251
  58. package/dist/store/skills/context-priming/references/references/areas/scripts-deployment.md +0 -183
  59. package/dist/store/skills/context-priming/references/references/areas/skills.md +0 -196
  60. package/dist/store/skills/context-priming/references/references/areas/terminal-bridge.md +0 -263
  61. package/dist/store/skills/context-priming/references/references/areas/web-frontend.md +0 -437
  62. package/dist/store/skills/context-priming/references/references/maintenance.md +0 -128
  63. package/templates/store/skills/context-priming/references/areas/claude-actions.md +0 -120
  64. package/templates/store/skills/context-priming/references/references/area-index.md +0 -152
  65. package/templates/store/skills/context-priming/references/references/areas/messaging.md +0 -251
  66. package/templates/store/skills/context-priming/references/references/areas/scripts-deployment.md +0 -183
  67. package/templates/store/skills/context-priming/references/references/areas/skills.md +0 -196
  68. package/templates/store/skills/context-priming/references/references/areas/terminal-bridge.md +0 -263
  69. package/templates/store/skills/context-priming/references/references/areas/web-frontend.md +0 -437
  70. package/templates/store/skills/context-priming/references/references/maintenance.md +0 -128
  71. package/templates/updates/skills/context-priming/references/areas/claude-actions.md +0 -120
  72. package/templates/updates/skills/context-priming/references/references/area-index.md +0 -152
  73. package/templates/updates/skills/context-priming/references/references/areas/messaging.md +0 -251
  74. package/templates/updates/skills/context-priming/references/references/areas/scripts-deployment.md +0 -183
  75. package/templates/updates/skills/context-priming/references/references/areas/skills.md +0 -196
  76. package/templates/updates/skills/context-priming/references/references/areas/terminal-bridge.md +0 -263
  77. package/templates/updates/skills/context-priming/references/references/areas/web-frontend.md +0 -437
  78. package/templates/updates/skills/context-priming/references/references/maintenance.md +0 -128
  79. /package/dist/web/.next/static/{wMUaNt62q8VYjpVs4m1_t → sAL_sqPSOaOIrKiwdPzL2}/_buildManifest.js +0 -0
  80. /package/dist/web/.next/static/{wMUaNt62q8VYjpVs4m1_t → sAL_sqPSOaOIrKiwdPzL2}/_clientMiddlewareManifest.json +0 -0
  81. /package/dist/web/.next/static/{wMUaNt62q8VYjpVs4m1_t → sAL_sqPSOaOIrKiwdPzL2}/_ssgManifest.js +0 -0
@@ -1,35 +1,37 @@
1
1
  # Skills & Infrastructure
2
2
 
3
- Updated: 2026-02-09
3
+ Updated: 2026-03-14
4
4
 
5
5
  ## Overview
6
6
 
7
- SlyCode is the central hub for reusable Claude Code assets. Skills provide specialized capabilities, commands are user-invocable shortcuts, agents handle autonomous workflows, and hooks execute on events. Includes global CLI setup, service management scripts, and project scaffolding. This repo tests new skills before deploying to other projects.
7
+ SlyCode is the central hub for reusable AI coding assets (skills, agents, configs). All commands have been converted to skills — everything is now a skill with SKILL.md. Agents handle autonomous workflows, and hooks execute on events. Includes global CLI setup, service management scripts, and project scaffolding. This repo tests new skills before deploying to other projects.
8
8
 
9
9
  ## Key Files
10
10
 
11
- ### Skills
11
+ ### Skills (17 total — all commands converted to skills)
12
12
  - `.claude/skills/context-priming/` - Dynamic codebase context loader
13
13
  - `.claude/skills/interactive-explainer/` - Creates visual HTML explainers
14
14
  - `.claude/skills/skill-creator/` - Guide for creating new skills
15
15
  - `.claude/skills/messaging/` - Send text/voice responses to messaging channels (v2.2.0)
16
16
  - `.claude/skills/claude-code-docs-maintainer/` - Maintains Claude Code documentation
17
- - `.claude/skills/kanban/` - Kanban board management skill
17
+ - `.claude/skills/kanban/` - Kanban board management (v1.4.0), notes + automation subcommands, multiline description support
18
+ - `.claude/skills/checkpoint/` - Git checkpoint creation
19
+ - `.claude/skills/feature/` - Create feature specifications
20
+ - `.claude/skills/chore/` - Create chore/maintenance plans
21
+ - `.claude/skills/implement/` - Execute plans
22
+ - `.claude/skills/design/` - Start iterative design document
23
+ - `.claude/skills/doc-discovery/` - Documentation discovery
24
+ - `.claude/skills/doc-update/` - Documentation updates
25
+ - `.claude/skills/reference-fetch/` - Fetch external docs
26
+ - `.claude/skills/create-command/` - Meta-command for new commands
27
+ - `.claude/skills/problem_summary/` - Summarize debugging issues
28
+ - `.claude/skills/convert-asset/` - Convert store asset between provider formats
18
29
 
19
30
  ### Agents
20
31
  - `.claude/agents/doc-updater.md` - Autonomous documentation maintenance agent
21
32
 
22
- ### Commands
23
- - `.claude/commands/checkpoint.md` - Git checkpoint creation
24
- - `.claude/commands/feature.md` - Create feature specifications
25
- - `.claude/commands/chore.md` - Create chore/maintenance plans
26
- - `.claude/commands/implement.md` - Execute plans
27
- - `.claude/commands/design.md` - Start iterative design document
28
- - `.claude/commands/doc-discovery.md` - Documentation discovery
29
- - `.claude/commands/doc-update.md` - Documentation updates
30
- - `.claude/commands/reference-fetch.md` - Fetch external docs
31
- - `.claude/commands/create-command.md` - Meta-command for new commands
32
- - `.claude/commands/problem_summary.md` - Summarize debugging issues
33
+ ### Commands (REMOVED)
34
+ - `.claude/commands/` directory no longer exists — all converted to `.claude/skills/*/SKILL.md`
33
35
 
34
36
  ### Scripts
35
37
  - `scripts/setup.sh` - Guided setup: environment, services, global CLI, linger
@@ -37,24 +39,69 @@ SlyCode is the central hub for reusable Claude Code assets. Skills provide speci
37
39
  - `scripts/sly-stop.sh` - Stop all services
38
40
  - `scripts/sly-restart.sh` - Restart all services
39
41
  - `scripts/sly-dev.sh` - Development mode launcher
40
- - `sly-kanban` - Kanban CLI tool (installed globally as `sly-kanban`)
41
- - `scripts/scaffold.js` - Project scaffolding CLI (installed globally as `sly-scaffold`)
42
+ - `sly-kanban` - Kanban CLI tool (installed globally as `sly-kanban`), board/reorder/notes/automation subcommands, last_modified_by tracking. Sequential card numbers (auto-backfilled on first run, `nextCardNumber` on kanban root). Notes: summarize subcommand (oldest/summarize), 100 hard cap, 30 soft suggestion threshold. Archive safeguard: automation cards cannot be archived (bulk `archive done` skips them with count, individual archive rejects with error). `automation enable` no longer recalculates nextRun locally (moved server-side to web scheduler/kanban API).
43
+ - `scripts/scaffold.js` - Project scaffolding CLI (installed globally as `sly-scaffold`), multi-provider support (Claude/Codex/Gemini), provider overlay templates, purpose-grouped scaffold plan, overwrite protection, clean output (suppresses zero-count copied/created lines, reports new vs existing doc dirs)
44
+ - `scripts/migrate-store.sh` - Migrates store from provider-split to canonical flat layout
45
+ - `scripts/migrate-sly-actions.js` - One-time v2→v3 sly-actions.json migration (sessionState→placement, visibleIn.classes→classAssignments) [historical]
46
+ - `scripts/convert-actions-to-md.js` - One-time v3→v4 migration: converts sly-actions.json to individual .md files in store/actions/
47
+
48
+ ### Store (Canonical Layout)
49
+ - `store/skills/` - 17 canonical skill definitions (single source of truth, includes dummy)
50
+ - `store/actions/` - Individual action .md files (v4.0 format: YAML frontmatter + prompt body)
51
+ - `store/agents/` - Agent definitions (doc-updater.md)
52
+ - `store/mcp/` - MCP module configs (context7.json)
53
+ - `store/.backups/` - Backup copies created when accepting updates
54
+ - `store/.ignored-updates.json` - Tracks dismissed update versions
55
+ - `.agents/skills/` - Codex-format copies deployed to SlyCode (7 skills: chore, context-priming, design, feature, implement, kanban, messaging)
56
+
57
+ ### Update Delivery
58
+ - `updates/skills/` - Staged skill updates awaiting acceptance
59
+ - `updates/actions/` - Staged action updates (content-hash based comparison)
60
+ - `updates/agents/` - Staged agent updates
61
+ - `updates/claude/` - Provider-specific update overrides
62
+ - Workflow: updates/ → accept → store/ (with backup) → deploy to projects
63
+ - Actions use additive class merge on accept: keeps user's class customizations, adds new upstream classes
64
+
65
+ ### NPM Distribution
66
+ - `packages/slycode/` - Main npm package (`@slycode/slycode` v0.1.11): `slycode` CLI with workspace, start, stop, service, doctor, skills, sync, update, config, uninstall subcommands
67
+ - `packages/create-slycode/` - Scaffold tool (`@slycode/create-slycode` v0.1.11): `create-slycode` for initializing new workspaces. Setup wizard prompts for timezone (auto-detects via `Intl.DateTimeFormat`, writes `TZ=` to .env for cron scheduling). System service prompt skipped on Windows. Tutorial content seeded into workspace root (not a separate `slycode_tutorial/` subdirectory). Kanban seed uses correct stage-based format (`project_id`, `stages`, `last_updated`). Registry seeds workspace root as default project (id: `slycode`).
68
+ - Both packages under `@slycode` npm scope. Template paths resolve via `node_modules/@slycode/slycode/templates/`.
69
+ - `slycode config [key] [value]` - View/modify slycode.config.js via CLI
70
+ - `slycode uninstall` - Remove services and CLI tools (preserves workspace)
71
+ - `slycode sync` - Refresh workspace updates/ from package templates
72
+ - `slycode update` - Platform-aware restart (systemd/launchd/Windows Task Scheduler/background)
73
+ - `slycode start` auto-refreshes updates on startup + npm version check (3s timeout)
74
+
75
+ ### Build Pipeline
76
+ - `build/build-package.ts` - Full build script: builds services, syncs updates, copies templates to packages/slycode/. Copies `data/scaffold-templates/`, `store/`, `updates/actions/` to dist/ for runtime access. Also copies store/actions/ to packages/slycode/templates/store/actions/ for scaffold seeding. Removed sly-actions.json template (actions now individual .md files).
77
+ - `build/sync-updates.ts` - Sync manifest skills + actions from store/ to updates/ (enforces manifest as authority). Returns `{ skills: SyncResult, actions: SyncResult }`.
78
+ - `build/store-manifest.js` - Curated list of skills and actions included in npm package and updates
42
79
 
43
80
  ### Scaffold Templates
44
- - `data/scaffold-templates/` - Templates for project scaffolding
45
- - `claude-md.md`, `kanban.json`, `mcp.json`, `gitignore`, `archive-readme.md`, `seed-cards.json`
81
+ - `data/scaffold-templates/` - Blessed defaults for new workspaces. Sourced by build pipeline instead of `data/*.json` (working copies may have local changes).
82
+ - `base-instructions.md` (provider-neutral, replaces claude-md.md), `kanban.json`, `mcp.json`, `gitignore`, `archive-readme.md`, `seed-cards.json`, `events.json`
83
+ - `providers.json` — seeded into new workspaces by create-slycode (sly-actions.json removed — actions now in store/actions/*.md)
84
+ - `overlays/` - Provider-specific instruction overlays (`claude.md`, `codex.md`, `gemini.md`)
85
+ - To update templates: manually copy `data/*.json` → `data/scaffold-templates/*.json`
46
86
 
47
87
  ### Config
48
88
  - `.claude/settings.local.json` - Local Claude settings
49
89
  - `.mcp.json` - MCP server configuration (Context7, etc.)
50
90
  - `.env` / `.env.example` - Environment config with service ports
51
91
  - `CLAUDE.md` - Project instructions for Claude
92
+ - `AGENTS.md` - Project instructions for Codex provider (mirrors CLAUDE.md content)
93
+
94
+ ### Licensing
95
+ - `LICENSE` - Business Source License 1.1 (BUSL-1.1)
96
+ - `LICENSING.md` - Human-readable licensing guide (open-core model)
97
+ - All package.json files set `"license": "BUSL-1.1"` (web, bridge, messaging, slycode, create-slycode)
98
+ - Design doc: `documentation/designs/open_core_licensing.md`
52
99
 
53
100
  ### Documentation
54
101
  - `documentation/kanban.json` - Kanban card data
55
102
  - `documentation/events.json` - Activity event log (card moves, asset operations, sessions)
56
103
  - `documentation/terminal-classes.json` - Terminal class definitions
57
- - `documentation/features/` - Feature specs (001-020)
104
+ - `documentation/features/` - Feature specs (001-049)
58
105
  - `documentation/chores/` - Chore plans (active + completed/)
59
106
  - `documentation/designs/` - Design documents
60
107
  - `documentation/reference/` - Reference documentation
@@ -67,17 +114,7 @@ SlyCode is the central hub for reusable Claude Code assets. Skills provide speci
67
114
  └── references/ # Supporting docs, templates, examples
68
115
  ```
69
116
 
70
- ## Command Structure
71
-
72
- ```markdown
73
- ---
74
- version: X.Y.Z
75
- updated: YYYY-MM-DD
76
- allowed-tools: [Tool1, Tool2]
77
- ---
78
- # Command Name
79
- Instructions for Claude when command is invoked
80
- ```
117
+ All user-invocable operations are now skills (no separate commands directory).
81
118
 
82
119
  ## Global CLI Commands
83
120
 
@@ -95,27 +132,46 @@ After `scripts/setup.sh`, these are available globally:
95
132
 
96
133
  ## Environment Variables (.env.example)
97
134
 
135
+ - **TZ**: IANA timezone for cron schedule evaluation (e.g., Australia/Melbourne). Defaults to UTC if unset.
98
136
  - **Ports**: WEB_PORT=7591, BRIDGE_PORT=7592, MESSAGING_SERVICE_PORT=7593
99
137
  - **Bridge**: BRIDGE_URL for bridge connection
100
138
  - **Telegram**: TELEGRAM_BOT_TOKEN, TELEGRAM_AUTHORIZED_USER_ID
101
- - **STT**: OPENAI_API_KEY (Whisper)
139
+ - **STT**: STT_BACKEND (openai|local), OPENAI_API_KEY (Whisper API), WHISPER_CLI_PATH + WHISPER_MODEL_PATH (local whisper.cpp)
102
140
  - **TTS**: ELEVENLABS_API_KEY, ELEVENLABS_VOICE_ID, ELEVENLABS_VOICE_SPEED
103
141
 
104
142
  ## Hooks
105
143
 
106
144
  - `web/src/hooks/useKeyboardShortcuts.ts` - Number keys 1-9 for project navigation, Escape
107
- - `web/src/hooks/useCommandsConfig.ts` - Polling-based commands config (30s)
145
+ - `web/src/hooks/useSlyActionsConfig.ts` - Polling-based commands config (30s)
108
146
  - `web/src/hooks/useConnectionStatus.ts` - SSE connection state
109
147
  - `web/src/hooks/usePolling.ts` - Generic polling hook
110
148
 
111
149
  ## Patterns & Invariants
112
150
 
113
151
  - Skills use semantic versioning (MAJOR.MINOR.PATCH)
114
- - Always update version and date when modifying skills/commands
115
- - Commands invoked via `/command-name` shorthand
152
+ - Always update version and date when modifying skills
153
+ - Skills invoked via `/skill-name` shorthand (commands no longer exist as separate entity)
116
154
  - CLAUDE.md applies to entire project, overrides defaults
117
155
  - MCP servers configured in .mcp.json (Context7 for docs)
118
156
  - Event log in documentation/events.json tracks card moves, asset ops, sessions (500 cap)
157
+ - Store uses canonical flat layout: `store/skills/`, `store/actions/`, `store/agents/`, `store/mcp/` (no provider subdirectories)
158
+ - Skill import defaults to SKILL.md-only (via `skillMainOnly` flag on store POST) to avoid overwriting references/. Full folder import available via ImportDialog.
159
+ - Assets deployed from store to projects (including SlyCode itself)
160
+ - Codex-format skills live in `.agents/skills/`, Claude in `.claude/skills/`
161
+ - Update delivery: `updates/` → accept → `store/` (with backup) → deploy to projects
162
+ - `store/.ignored-updates.json` tracks dismissed update versions per asset
163
+ - Scaffold uses overwrite protection: copyDirRecursive defaults to skip-existing, all template files check existence. Tutorial content seeded into workspace root via `seedTutorialWorkspaceContent()` (not separate subdirectory).
164
+ - CLAUDE.release.md + templates/CLAUDE.md: AI-operated CLI policy — treat CLI tools as AI-operated, don't instruct users to run CLI commands, execute and report results plainly
165
+ - Scaffold uses multi-provider overlays: base-instructions.md + overlays/{provider}.md for provider-specific setup
166
+ - Scaffold groups items by purpose: AI Config, Project Management, Documentation, Skills, Configuration
167
+ - Build pipeline: sync-updates.ts enforces store-manifest.js as authority for both skills and actions, removes non-manifest items from updates/. build-package.ts copies scaffold-templates/, store/, and updates/actions/ to dist/ for prod runtime access. Templates (skills, actions, tutorial-project) removed from packages/slycode/templates/ — build pipeline is the sole delivery mechanism.
168
+ - Scaffold seeds `providers.json` from `data/scaffold-templates/` into new workspaces (create-slycode). Actions delivered via updates/actions/ instead of scaffold template.
169
+ - kanban.js stamps `last_modified_by: 'cli'` on all write operations and `source: 'cli'` on events. Uses dynamic `PROJECT_NAME` (from workspace basename) for event project field and session names — no hardcoded 'claude-master'.
170
+ - kanban.js has `board` (--all/--stages/--inflight/--compact), `reorder` (positional card IDs or --top/--bottom/--position), `notes` (add/list/search/edit/delete/clear/oldest/summarize), and `automation` (configure/enable/disable/run/status/list) subcommands
171
+ - Card numbers: `backfillCardNumbers()` sorts all cards by created_at and assigns sequential numbers. `ensureCardNumbers()` auto-runs on first create. Verbose format shows `(#0001)`. Search includes automation cards when query is provided (only bare search excludes them).
172
+ - Notes summarization: `notes oldest [N]` shows oldest N notes, `notes summarize "text" --count N --agent "Name"` replaces oldest N with a summary note (marked `summary: true`, tracks `summarizedCount` and `dateRange`). Hard cap 100 notes, soft suggestion at 30.
173
+ - `kanban reorder` sets order 10,20,30... on listed cards; unlisted cards keep relative order but sort after prioritized ones
174
+ - Automation uses card description as prompt (no separate --prompt option). `automation run` sends card description to bridge session.
119
175
 
120
176
  ## Environment
121
177
 
@@ -125,11 +181,16 @@ After `scripts/setup.sh`, these are available globally:
125
181
  ## When to Expand
126
182
 
127
183
  - Creating new skill → skill-creator skill, .claude/skills/
128
- - Creating new command → create-command, .claude/commands/
184
+ - Creating new command → create-command skill, creates a new skill in .claude/skills/
129
185
  - Creating new agent → .claude/agents/
130
- - Modifying Claude behavior CLAUDE.md
186
+ - Cross-provider assetsstore/, .agents/skills/, convert-asset skill
187
+ - Skill updates → updates/ directory, web UpdatesView, store/.ignored-updates.json
188
+ - NPM distribution → packages/slycode/, packages/create-slycode/
189
+ - Store migration → scripts/migrate-store.sh
190
+ - Modifying agent behavior → CLAUDE.md
131
191
  - Adding MCP servers → .mcp.json
132
192
  - Service management → scripts/sly-*.sh
133
193
  - Setup/installation → scripts/setup.sh
134
- - Project scaffolding → scripts/scaffold.js, data/scaffold-templates/
194
+ - Project scaffolding → scripts/scaffold.js, data/scaffold-templates/, data/scaffold-templates/overlays/
195
+ - Build pipeline → build/build-package.ts, build/sync-updates.ts, build/store-manifest.js
135
196
  - Activity events → documentation/events.json, web/src/lib/event-log.ts
@@ -105,7 +105,7 @@ Global context: `{ project, projectPath }`
105
105
  - **Chore** - Create maintenance/bug fix plan from card
106
106
  - **Analyse Implementation** - Detailed analysis with findings table and problem logging
107
107
  - **Test Review** - Interactive test review for testing lane (checklist assessment, implicit testing, max 3 questions per Q&A round, area context priming)
108
- - **Convert Asset** - Cross-provider asset conversion (global scope, placement: startup)
108
+ - **Convert Asset** - Cross-provider asset conversion (scoped to claude-master project only, placement: startup)
109
109
  - **Organise Backlog** - Uses `kanban board` for snapshot and `kanban reorder` for reprioritisation
110
110
 
111
111
  ## Placement
@@ -1,56 +1,63 @@
1
1
  # Terminal Bridge
2
2
 
3
- Updated: 2026-02-14
3
+ Updated: 2026-03-14
4
4
 
5
5
  ## Overview
6
6
 
7
- PTY bridge server manages AI coding sessions across multiple providers (Claude, Gemini, Codex). Express server spawns/manages PTY processes, streams output via SSE. Provider-agnostic command building via data-driven config (`providers.json`). Includes security hardening (command whitelist, CWD validation, localhost binding), activity tracking with transition logging for debugging, atomic state persistence, bulk session management, and graceful idle timeout handling. React components connect through Next.js API proxy.
7
+ PTY bridge server manages AI coding sessions across multiple providers (Claude, Gemini, Codex). Express server spawns/manages PTY processes, streams output via SSE. Provider-agnostic command building via data-driven config (`providers.json`). Includes security hardening (command whitelist, CWD validation, localhost binding), activity tracking with transition logging for debugging, atomic state persistence, bulk session management, graceful idle timeout handling, and image delivery to PTY sessions. React components connect through Next.js API proxy.
8
8
 
9
9
  ## Key Files
10
10
 
11
11
  ### Bridge Server (Node/Express)
12
12
  - `bridge/src/index.ts` - Express server entry, routes setup, localhost binding
13
- - `bridge/src/session-manager.ts` - Session lifecycle, PTY spawning, provider resolution, activity tracking, atomic state saving
14
- - `bridge/src/provider-utils.ts` - Provider config loading, command building, session detection helpers
15
- - `bridge/src/pty-handler.ts` - PTY process wrapper, output buffering
16
- - `bridge/src/api.ts` - REST endpoints for session CRUD, /stats, stop-all, activity-log
13
+ - `bridge/src/session-manager.ts` - Session lifecycle, PTY spawning, provider resolution, activity tracking, atomic state saving, deferred prompt delivery (Windows)
14
+ - `bridge/src/provider-utils.ts` - Provider config loading, command building, session detection helpers, instruction file check/create
15
+ - `bridge/src/pty-handler.ts` - PTY process wrapper, output buffering, Windows .cmd extension resolution
16
+ - `bridge/src/api.ts` - REST endpoints for session CRUD, /stats, stop-all, activity-log, image upload, instruction file check
17
+ - `bridge/src/screenshot-utils.ts` - Screenshot saving, retention (10-file cap), .gitignore management
17
18
  - `bridge/src/websocket.ts` - WebSocket upgrade handling (legacy, SSE preferred)
18
- - `bridge/src/claude-utils.ts` - Claude session ID detection from ~/.claude/projects/
19
- - `bridge/src/types.ts` - Session, BridgeConfig, BridgeStats, ActivityTransition, provider interfaces
19
+ - `bridge/src/claude-utils.ts` - Provider-agnostic session ID detection (Claude/Codex/Gemini) with unified dispatchers
20
+ - `bridge/src/types.ts` - Session (incl. pendingPrompt, pendingPromptTimer), BridgeConfig, BridgeStats, ActivityTransition, provider interfaces
20
21
 
21
22
  ### Configuration
22
23
  - `bridge/bridge-config.json` - Runtime config: allowedCommands (claude, codex, gemini, bash), CORS origins
23
24
  - `data/providers.json` - Provider registry: CLI commands, permission flags, resume types, prompt handling, stage defaults
24
25
  - `documentation/terminal-classes.json` - Terminal class definitions for command visibility
25
- - `data/commands.json` - Unified command configuration with visibility per class
26
-
27
26
  ### Web Components
28
- - `web/src/components/Terminal.tsx` - xterm.js terminal, SSE via ConnectionManager
29
- - `web/src/components/ClaudeTerminalPanel.tsx` - Terminal panel with startupCommands/activeCommands
27
+ - `web/src/components/Terminal.tsx` - xterm.js terminal, SSE via ConnectionManager, resize broadcast with echo-loop suppression, paste interception via `attachCustomKeyEventHandler`
28
+ - `web/src/components/ClaudeTerminalPanel.tsx` - Terminal panel with startupActions/activeActions
30
29
  - `web/src/components/GlobalClaudePanel.tsx` - Floating panel for project-wide session
31
30
  - `web/src/app/api/bridge/[...path]/route.ts` - Next.js proxy to bridge server
32
31
 
33
32
  ## Key Functions
34
33
 
35
- - `SessionManager.createSession()` - Resolves provider, builds command via `buildProviderCommand()`, validates CWD, spawns PTY
34
+ - `SessionManager.getSessionCwd()` - Returns CWD for a session (running or persisted), used by image upload endpoint
35
+ - `SessionManager.createSession()` - Resolves provider, builds command via `buildProviderCommand()`, validates CWD, spawns PTY. Uses `creating` placeholder as mutex to prevent concurrent creation (returns 202 for duplicate requests).
36
36
  - `SessionManager.resolveSessionName()` - Checks both new (with provider) and legacy session name formats
37
- - `SessionManager.stopSession()` - Graceful SIGINT, waits for exit
37
+ - `SessionManager.stopSession()` - Graceful SIGINT, waits for exit, removes session from in-memory map (frees slot; data preserved in persistedState for resume)
38
38
  - `SessionManager.stopAllSessions()` - Bulk stop all running/detached sessions, returns count
39
39
  - `SessionManager.getStats()` - Returns BridgeStats with activity info
40
+ - `SessionManager.getGroupStatus(group)` - Returns status of all sessions in a group
41
+ - `SessionManager.relinkSession(name)` - Re-detect session ID from most recent provider session file
40
42
  - `SessionManager.checkIdleSessions()` - Idle timeout with grace period after disconnect
41
43
  - `buildProviderCommand()` - Assembles { command, args } from provider config, handles flag vs subcommand resume
42
44
  - `getProvider()` - Loads provider config by ID from providers.json (30s cache)
43
- - `supportsSessionDetection()` - Check if provider supports GUID-based session detection
45
+ - `checkInstructionFile(providerId, cwd)` - Checks if provider's instruction file exists. Priority scan: primary file → alt file → sibling copy source → no action needed
46
+ - `ensureInstructionFile(providerId, cwd)` - Creates missing instruction file by copying from sibling (never throws, logs warnings)
47
+ - `supportsSessionDetection()` - Check if provider supports session detection (all three now do)
48
+ - `getProviderSessionDir()` - Provider-agnostic session directory resolver
49
+ - `listProviderSessionFiles()` - Provider-agnostic session file listing
50
+ - `detectNewProviderSessionId()` - Provider-agnostic new session detection dispatcher
51
+ - `getMostRecentProviderSessionId()` - Find most recent session file (used by relink)
44
52
  - `Terminal.connectSSE()` - Via ConnectionManager for auto-reconnection
45
53
 
46
54
  ## Data Models
47
55
 
48
56
  ```typescript
49
57
  SessionInfo {
50
- name, status (running|stopped|detached), pid, connectedClients,
51
- hasHistory, claudeSessionId, lastOutputAt,
52
- provider?, skipPermissions?,
53
- lastOutputSnippet?, lastOutputRawHex?, lastOutputDataLength?
58
+ name, group, status (running|stopped|detached|creating), pid, connectedClients,
59
+ hasHistory, resumed, lastActive, lastOutputAt?,
60
+ claudeSessionId?, provider?, skipPermissions?
54
61
  }
55
62
 
56
63
  BridgeStats {
@@ -61,20 +68,19 @@ BridgeStats {
61
68
  }
62
69
 
63
70
  SessionActivity {
64
- name, status, lastOutputAt, isActive
71
+ name, status, lastOutputAt, isActive,
72
+ activityStartedAt?, lastOutputSnippet?
65
73
  }
66
74
 
67
75
  ActivityTransition {
68
76
  timestamp: string;
69
- from: string; // Previous state
70
- to: string; // New state
77
+ became: 'active' | 'inactive';
71
78
  lastOutputAt: string;
72
- outputAge: number;
73
- trigger?: { // Debug info for phantom blips
74
- snippet: string;
75
- hex: string;
76
- dataLength: number;
77
- }
79
+ activityStartedAt: string;
80
+ outputAgeMs: number;
81
+ triggerSnippet: string;
82
+ triggerRawHex: string;
83
+ triggerDataLength: number;
78
84
  }
79
85
 
80
86
  BridgeConfig {
@@ -91,9 +97,11 @@ CreateSessionRequest {
91
97
  provider?: string; // Provider id from providers.json
92
98
  skipPermissions?: boolean; // Whether to add permission-skip flag
93
99
  command?: string; // Legacy: direct command (backward compat)
94
- cwd: string;
95
- prompt?: string;
100
+ cwd?: string;
96
101
  fresh?: boolean;
102
+ idleTimeout?: number;
103
+ prompt?: string;
104
+ createInstructionFile?: boolean; // Opt-in: copy sibling instruction file if missing
97
105
  }
98
106
 
99
107
  PersistedSession {
@@ -107,7 +115,9 @@ ProviderConfig {
107
115
  id, displayName, command, install,
108
116
  permissions: { flag, label, default },
109
117
  resume: { supported, type ('flag'|'subcommand'), flag?, subcommand?, lastFlag?, detectSession, sessionDir? },
110
- prompt: { type ('positional'|'flag'), interactive?, nonInteractive? }
118
+ prompt: { type ('positional'|'flag'), interactive?, nonInteractive? },
119
+ instructionFile?: string, // e.g. "CLAUDE.md" for Claude, "AGENTS.md" for Codex
120
+ altInstructionFile?: string // e.g. "CODEX.md" for Codex (provider-specific alt)
111
121
  }
112
122
 
113
123
  ProvidersData {
@@ -123,7 +133,7 @@ ProvidersData {
123
133
  ## Security Hardening
124
134
 
125
135
  - **Localhost binding**: HOST defaults to `localhost` (not `0.0.0.0`)
126
- - **Command whitelist**: Only commands in `bridge-config.json` allowedCommands can be spawned (claude, codex, gemini, bash)
136
+ - **Command whitelist**: Only commands in `bridge-config.json` allowedCommands can be spawned (claude, codex, gemini, bash — all four in both config and hardcoded defaults)
127
137
  - **Provider validation**: Provider ID must exist in providers.json; resolved command must be in allowedCommands
128
138
  - **CWD validation**: Requires absolute path, verifies exists and is accessible before spawning PTY
129
139
  - **CORS origins**: Configured in bridge-config.json, not wide-open
@@ -146,9 +156,12 @@ ProvidersData {
146
156
 
147
157
  ## Race Condition Handling
148
158
 
159
+ - **Creation mutex**: `creating` status placeholder prevents concurrent createSession() for same name. API returns 202 for idempotent duplicate requests. Placeholder cleaned up on failure.
160
+ - **GUID detection cancellation**: `guidDetectionCancelled` flag on Session prevents detection from overwriting state after session stops/exits.
149
161
  - **Disconnect grace period**: 5 seconds before session eligible for idle timeout
150
162
  - **Status transitions**: Protected against reconnect during disconnect
151
163
  - **SSE cleanup**: Proper client tracking on connection/disconnection
164
+ - **SSE heartbeat**: 15-second comment heartbeats (`: heartbeat\n\n`) keep connections alive through proxies (Tailscale, Next.js). Started per-client on SSE connect, cleared on disconnect.
152
165
 
153
166
  ## Terminal Classes
154
167
 
@@ -162,15 +175,15 @@ Controls which commands appear in each context:
162
175
 
163
176
  ### Supported Providers
164
177
  - **Claude Code** (`claude`) — Positional prompts, `--resume <GUID>` with auto-detection, `--dangerously-skip-permissions`
165
- - **Codex CLI** (`codex`) — Positional prompts, `codex resume --last` (subcommand-style), `--yolo`
166
- - **Gemini CLI** (`gemini`) — Flag-based prompts (`-i`/`-p`), `--resume` (no GUID), `--yolo`
178
+ - **Codex CLI** (`codex`) — Positional prompts, `codex resume --last [PROMPT]` (subcommand-style), `--yolo`, session detection via rollout files
179
+ - **Gemini CLI** (`gemini`) — Flag-based prompts (`-i`/`-p`), `--resume` (no GUID), `--yolo`, session detection via chat JSON files
167
180
 
168
181
  ### Command Building (`buildProviderCommand`)
169
182
  - Returns `{ command, args }` tuple (command can change for Codex resume: `codex resume`)
170
183
  - Permission flag added if `skipPermissions: true`
171
184
  - Resume: flag-type appends `--resume [GUID]`; subcommand-type prepends `resume [GUID|--last]`
172
185
  - Prompt: positional appends as final arg; flag-type uses `-i <prompt>` (interactive)
173
- - No prompt on resume (user types into running session instead)
186
+ - Prompt works alongside resume: Claude accepts positional after `--resume`, Codex accepts positional after `resume --last`
174
187
 
175
188
  ### Session Name Format
176
189
  - **New format**: `{projectId}:{provider}:card:{cardId}` or `{projectId}:{provider}:global`
@@ -178,11 +191,14 @@ Controls which commands appear in each context:
178
191
  - `resolveSessionName()` checks new format first, falls back to legacy via `toLegacySessionName()`
179
192
  - Old sessions without provider field default to `provider: "claude"`
180
193
 
181
- ### GUID Detection (Claude only)
182
- - `supportsSessionDetection()` checks `provider.resume.detectSession`
183
- - Watches `~/.claude/projects/` for new `.jsonl` files after spawn
194
+ ### Session Detection (All Providers)
195
+ - `supportsSessionDetection()` checks `provider.resume.detectSession` — all three providers have `detectSession: true`
196
+ - Provider-agnostic dispatchers route to provider-specific logic:
197
+ - **Claude**: Watches `~/.claude/projects/<cwd>/` for new `.jsonl` files, extracts GUID from filename
198
+ - **Codex**: Watches `~/.codex/sessions/YYYY/MM/DD/` for new rollout files, extracts UUID from filename
199
+ - **Gemini**: Watches `~/.gemini/tmp/<SHA256(cwd)>/chats/` for new session JSON files
184
200
  - `getClaimedGuids()` excludes GUIDs already used by other sessions
185
- - Gemini/Codex use `--resume --last` (no GUID tracking)
201
+ - Detection timeout: 60 seconds (Gemini CLI takes ~30s to create session files)
186
202
 
187
203
  ### Stage-Based Defaults
188
204
  - `providers.json` `defaults.stages` maps each kanban stage → `{ provider, skipPermissions }`
@@ -196,24 +212,37 @@ Controls which commands appear in each context:
196
212
  - Claude prompts passed as positional arg, NOT `-p` flag (that's print mode)
197
213
  - Resume behavior is provider-specific: flag vs subcommand, GUID vs latest
198
214
  - SSE streams through `/api/bridge/sessions/{name}/stream` proxy
199
- - Bridge runs on port 3456 (localhost), proxied through Next.js
215
+ - Bridge port from BRIDGE_PORT env var (default 7592 prod, 3004 dev), localhost binding, proxied through Next.js
216
+ - Stopped sessions removed from in-memory `sessions` map (frees slot); session data preserved in `persistedState` for future resume. `getSessionInfo()` falls back to persistedState when session not in map.
200
217
  - Idle timeout: 4 hours default, checked every 60 seconds
201
- - Atomic state saves prevent data corruption
218
+ - Atomic state saves with unique temp file names (`.tmp.${pid}.${Date.now()}`) prevent race conditions
202
219
  - Provider config cached 30s in provider-utils.ts
220
+ - Bracketed paste mode (`\x1b[200~...\x1b[201~`) for multi-line prompt input, 150ms delay before Enter
221
+ - lastActive timestamp preserved on resume (not overwritten with current time)
222
+ - Image delivery: saves to `screenshots/` in session CWD, timestamped filenames, 10-file retention, auto-.gitignore
223
+ - Screenshot reference injected as `[Screenshot: screenshots/<filename>]` text into PTY (not auto-submitted)
224
+ - Instruction file fallback: `checkInstructionFile()` scans for sibling instruction files (CLAUDE.md, AGENTS.md, CODEX.md, GEMINI.md) in priority order. `ensureInstructionFile()` copies when requested. Creation is opt-in only (`createInstructionFile: true` in CreateSessionRequest).
225
+ - Resize broadcast: PTY resize events broadcast via SSE to all connected tabs. Terminal.tsx guards resize POSTs (only visible tabs), uses `suppressResizePost` flag to prevent ResizeObserver echo loop when adapting to another tab's resize. Skips resize on reconnect.
226
+ - **Windows ConPTY support**: On Windows, CLI tools are installed as `.cmd` batch wrappers — `pty-handler.ts` auto-appends `.cmd` extension. cmd.exe mangles multi-line CLI args (newlines become command separators), so prompts are deferred: stripped from spawn args and delivered via bracketed paste after provider output settles (1.5s quiet, 30s max timeout). ConPTY silently truncates PTY writes >~4KB, so large prompts are chunked (1024-byte chunks with 500ms delay, surrogate-pair-safe boundaries). Session tracks `pendingPrompt` and `pendingPromptTimer` for debounced delivery.
203
227
 
204
228
  ## API Endpoints
205
229
 
206
230
  - `GET /sessions` - List all sessions
207
231
  - `GET /sessions/:name` - Get session info
208
- - `POST /sessions` - Create session (validates command + CWD)
232
+ - `POST /sessions` - Create session (validates command + CWD, returns 202 if already creating)
209
233
  - `DELETE /sessions/:name` - Stop or delete session
210
234
  - `POST /sessions/:name/input` - Send input to PTY
211
235
  - `POST /sessions/:name/resize` - Resize terminal
236
+ - `POST /sessions/:name/image` - Upload image to session's screenshots/ dir (multipart, 10MB limit), returns filename
237
+ - `POST /sessions/:name/action` - Structured actions: compact, clear, interrupt
238
+ - `POST /sessions/:name/relink` - Re-detect session ID from most recent provider session file
212
239
  - `POST /sessions/:name/stop` - Send Escape key to active session (soft stop)
213
240
  - `GET /sessions/:name/stream` - SSE output stream
241
+ - `GET /groups/:group/status` - Group-level session status aggregation
214
242
  - `POST /sessions/stop-all` - Bulk stop all running sessions
215
243
  - `GET /stats` - BridgeStats with activity info
216
244
  - `GET /activity-log/:name` - Activity transition history for debugging
245
+ - `GET /check-instruction-file?provider=X&cwd=Y` - Check if instruction file exists, returns { needed, targetFile?, copySource? }
217
246
 
218
247
  ## When to Expand
219
248
 
@@ -228,5 +257,8 @@ Controls which commands appear in each context:
228
257
  - Connection problems → api/bridge proxy, connection-manager.ts
229
258
  - Idle timeout issues → session-manager.ts checkIdleSessions()
230
259
  - Bulk operations → stopAllSessions(), /sessions/stop-all
260
+ - Image delivery → screenshot-utils.ts (saving/retention), api.ts (image endpoint), ClaudeTerminalPanel.tsx (paste handling)
231
261
  - State corruption → session-manager.ts loadState/saveState
232
262
  - Session name resolution → session-manager.ts resolveSessionName(), toLegacySessionName()
263
+ - Instruction file issues → provider-utils.ts checkInstructionFile/ensureInstructionFile, api.ts check-instruction-file endpoint
264
+ - Terminal resize sync → Terminal.tsx sendResize(), SSE resize event handling