@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.
- package/dist/bridge/session-manager.js +1 -8
- package/dist/bridge/session-manager.js.map +1 -1
- package/dist/store/skills/context-priming/references/area-index.md +121 -68
- package/{templates/store/skills/context-priming/references → dist/store/skills/context-priming}/references/areas/feature-guide.md +44 -18
- package/dist/store/skills/context-priming/references/areas/messaging.md +108 -34
- package/dist/store/skills/context-priming/references/areas/scripts-deployment.md +61 -16
- package/dist/store/skills/context-priming/references/areas/skills.md +99 -38
- package/{templates/updates/skills/context-priming/references → dist/store/skills/context-priming}/references/areas/terminal-actions.md +1 -1
- package/dist/store/skills/context-priming/references/areas/terminal-bridge.md +74 -42
- package/dist/store/skills/context-priming/references/areas/web-frontend.md +259 -74
- package/dist/web/.next/BUILD_ID +1 -1
- package/dist/web/.next/build-manifest.json +2 -2
- package/dist/web/.next/server/app/_global-error.html +2 -2
- package/dist/web/.next/server/app/_global-error.rsc +1 -1
- package/dist/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/dist/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/dist/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/dist/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/dist/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/dist/web/.next/server/app/_not-found.html +1 -1
- package/dist/web/.next/server/app/_not-found.rsc +1 -1
- package/dist/web/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/dist/web/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/dist/web/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/dist/web/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/dist/web/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/dist/web/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/dist/web/.next/server/pages/404.html +1 -1
- package/dist/web/.next/server/pages/500.html +2 -2
- package/lib/cli/sync.d.ts +7 -0
- package/lib/cli/sync.d.ts.map +1 -1
- package/lib/cli/sync.js +32 -0
- package/lib/cli/sync.js.map +1 -1
- package/lib/cli/update.d.ts.map +1 -1
- package/lib/cli/update.js +9 -0
- package/lib/cli/update.js.map +1 -1
- package/package.json +1 -1
- package/templates/kanban-seed.json +1 -1
- package/templates/store/skills/context-priming/references/area-index.md +121 -68
- package/templates/{updates/skills/context-priming/references → store/skills/context-priming}/references/areas/feature-guide.md +44 -18
- package/templates/store/skills/context-priming/references/areas/messaging.md +108 -34
- package/templates/store/skills/context-priming/references/areas/scripts-deployment.md +61 -16
- package/templates/store/skills/context-priming/references/areas/skills.md +99 -38
- package/{dist/store/skills/context-priming/references → templates/store/skills/context-priming}/references/areas/terminal-actions.md +1 -1
- package/templates/store/skills/context-priming/references/areas/terminal-bridge.md +74 -42
- package/templates/store/skills/context-priming/references/areas/web-frontend.md +259 -74
- package/templates/updates/skills/context-priming/references/area-index.md +121 -68
- package/{dist/store/skills/context-priming/references → templates/updates/skills/context-priming}/references/areas/feature-guide.md +44 -18
- package/templates/updates/skills/context-priming/references/areas/messaging.md +108 -34
- package/templates/updates/skills/context-priming/references/areas/scripts-deployment.md +61 -16
- package/templates/updates/skills/context-priming/references/areas/skills.md +99 -38
- package/templates/{store/skills/context-priming/references → updates/skills/context-priming}/references/areas/terminal-actions.md +1 -1
- package/templates/updates/skills/context-priming/references/areas/terminal-bridge.md +74 -42
- package/templates/updates/skills/context-priming/references/areas/web-frontend.md +259 -74
- package/dist/store/skills/context-priming/references/areas/claude-actions.md +0 -120
- package/dist/store/skills/context-priming/references/references/area-index.md +0 -152
- package/dist/store/skills/context-priming/references/references/areas/messaging.md +0 -251
- package/dist/store/skills/context-priming/references/references/areas/scripts-deployment.md +0 -183
- package/dist/store/skills/context-priming/references/references/areas/skills.md +0 -196
- package/dist/store/skills/context-priming/references/references/areas/terminal-bridge.md +0 -263
- package/dist/store/skills/context-priming/references/references/areas/web-frontend.md +0 -437
- package/dist/store/skills/context-priming/references/references/maintenance.md +0 -128
- package/templates/store/skills/context-priming/references/areas/claude-actions.md +0 -120
- package/templates/store/skills/context-priming/references/references/area-index.md +0 -152
- package/templates/store/skills/context-priming/references/references/areas/messaging.md +0 -251
- package/templates/store/skills/context-priming/references/references/areas/scripts-deployment.md +0 -183
- package/templates/store/skills/context-priming/references/references/areas/skills.md +0 -196
- package/templates/store/skills/context-priming/references/references/areas/terminal-bridge.md +0 -263
- package/templates/store/skills/context-priming/references/references/areas/web-frontend.md +0 -437
- package/templates/store/skills/context-priming/references/references/maintenance.md +0 -128
- package/templates/updates/skills/context-priming/references/areas/claude-actions.md +0 -120
- package/templates/updates/skills/context-priming/references/references/area-index.md +0 -152
- package/templates/updates/skills/context-priming/references/references/areas/messaging.md +0 -251
- package/templates/updates/skills/context-priming/references/references/areas/scripts-deployment.md +0 -183
- package/templates/updates/skills/context-priming/references/references/areas/skills.md +0 -196
- package/templates/updates/skills/context-priming/references/references/areas/terminal-bridge.md +0 -263
- package/templates/updates/skills/context-priming/references/references/areas/web-frontend.md +0 -437
- package/templates/updates/skills/context-priming/references/references/maintenance.md +0 -128
- /package/dist/web/.next/static/{wMUaNt62q8VYjpVs4m1_t → sAL_sqPSOaOIrKiwdPzL2}/_buildManifest.js +0 -0
- /package/dist/web/.next/static/{wMUaNt62q8VYjpVs4m1_t → sAL_sqPSOaOIrKiwdPzL2}/_clientMiddlewareManifest.json +0 -0
- /package/dist/web/.next/static/{wMUaNt62q8VYjpVs4m1_t → sAL_sqPSOaOIrKiwdPzL2}/_ssgManifest.js +0 -0
package/templates/updates/skills/context-priming/references/references/areas/scripts-deployment.md
DELETED
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
# Scripts & Deployment
|
|
2
|
-
|
|
3
|
-
Updated: 2026-03-13
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
SlyCode has a two-tier deployment model: **dev** (individual services via tmux) and **prod** (background processes with builds). All scripts live in `scripts/`. A guided installer (`setup.sh`) handles first-time and repeat setup. No hardcoded paths — everything is derived at runtime.
|
|
8
|
-
|
|
9
|
-
## Scripts
|
|
10
|
-
|
|
11
|
-
| Script | Purpose |
|
|
12
|
-
|--------|---------|
|
|
13
|
-
| `setup.sh` | Interactive guided installer — deps, builds, CLI symlinks, optional services, linger |
|
|
14
|
-
| `sly-start.sh` | Build all services then start in production (background processes or systemd/launchd) |
|
|
15
|
-
| `sly-stop.sh` | Stop production services by finding processes on their ports |
|
|
16
|
-
| `sly-restart.sh` | Stop then start (delegates to sly-stop + sly-start) |
|
|
17
|
-
| `sly-dev.sh` | Tmux session "sly" with three side-by-side panes running `npm run dev` |
|
|
18
|
-
| `kanban.js` | Kanban CLI (standalone Node.js, no build needed) |
|
|
19
|
-
| `scaffold.js` | Project scaffolding CLI (standalone Node.js) |
|
|
20
|
-
| `migrate-store.sh` | Migrate store from provider-split to canonical flat layout |
|
|
21
|
-
|
|
22
|
-
## Port Architecture
|
|
23
|
-
|
|
24
|
-
Two separate port ranges — dev and prod never overlap:
|
|
25
|
-
|
|
26
|
-
| Service | Dev port | Prod port | Env var |
|
|
27
|
-
|---------|----------|-----------|---------|
|
|
28
|
-
| Web | 3003 | 7591 | `WEB_PORT` |
|
|
29
|
-
| Bridge | 3004 | 7592 | `BRIDGE_PORT` |
|
|
30
|
-
| Messaging | 3005 | 7593 | `MESSAGING_SERVICE_PORT` |
|
|
31
|
-
|
|
32
|
-
- **7591/2/3**: "sly" = 759 on a phone keypad
|
|
33
|
-
- **Dev ports**: hardcoded in each service's `package.json` dev scripts
|
|
34
|
-
- **Prod ports**: configured in `slycode.config.js` (loaded by `start.ts`), or `.env` fallback, passed as `PORT` env var
|
|
35
|
-
- `BRIDGE_URL` must match bridge port — `sly-start.sh` derives it automatically
|
|
36
|
-
- Next.js reads `PORT` env var natively (no `--port` flag in prod `npm start`)
|
|
37
|
-
|
|
38
|
-
## Process Management
|
|
39
|
-
|
|
40
|
-
### Production (`sly-start.sh` / `sly-stop.sh`)
|
|
41
|
-
|
|
42
|
-
- **Start**: `slycode start` spawns services with `cwd: workspace` (ensures services inherit correct working directory). Sets `SLYCODE_HOME` env var for prod path resolution.
|
|
43
|
-
- **Stop**: finds PIDs by port (not PID files — those are unreliable with npm subshells), kills process tree with `pkill -P` + `kill`
|
|
44
|
-
- Ports file at `~/.slycode/ports` records which ports were started for stop to read
|
|
45
|
-
- Health check after start: verifies each port is listening
|
|
46
|
-
- Log files: `~/.slycode/logs/{web,bridge,messaging}.log` with 10MB rotation
|
|
47
|
-
|
|
48
|
-
### Dev (`sly-dev.sh`)
|
|
49
|
-
|
|
50
|
-
- Creates tmux session "sly" with three horizontal panes
|
|
51
|
-
- Each pane runs `npm run dev` in its service directory
|
|
52
|
-
- `session-closed` hook calls `sly-stop.sh` to prevent zombie processes
|
|
53
|
-
- If session already exists, just attaches
|
|
54
|
-
- Switch panes: `Ctrl-b` + arrows. Zoom: `Ctrl-b z`
|
|
55
|
-
|
|
56
|
-
### Platform Services (optional, via `setup.sh`)
|
|
57
|
-
|
|
58
|
-
- **Linux**: systemd user services (`~/.config/systemd/user/slycode-{web,bridge,messaging}.service`)
|
|
59
|
-
- **macOS**: launchd user agents (`~/Library/LaunchAgents/com.slycode.{web,bridge,messaging}.plist`)
|
|
60
|
-
- `sly-start.sh` / `sly-stop.sh` detect installed services and use them instead of background processes
|
|
61
|
-
- `setup.sh --service` installs, `setup.sh --remove-service` removes
|
|
62
|
-
|
|
63
|
-
## Setup Flow (`setup.sh`)
|
|
64
|
-
|
|
65
|
-
1. Welcome banner (platform, SlyCode root, Node version)
|
|
66
|
-
2. Check build tools (`check_build_tools()` — gcc, make, g++ for node-pty compilation)
|
|
67
|
-
3. Create directories (`~/bin`, `~/.slycode/logs`)
|
|
68
|
-
4. `npm install` in web, bridge, messaging
|
|
69
|
-
5. Build bridge, messaging, web (web last — heaviest, needs most memory)
|
|
70
|
-
6. `chmod +x` on CLI scripts
|
|
71
|
-
7. Symlink CLIs to `~/bin` (sly-kanban, sly-scaffold, sly-messaging)
|
|
72
|
-
8. Update `registry.json` with correct SlyCode path
|
|
73
|
-
9. Copy `.env.example` to `.env` if missing
|
|
74
|
-
10. Prompt: install as system service?
|
|
75
|
-
11. Linux: check linger, offer to enable
|
|
76
|
-
|
|
77
|
-
**Flags**: `--yes` (non-interactive), `--service` (auto-install services), `--remove-service` (cleanup)
|
|
78
|
-
|
|
79
|
-
## Global CLIs
|
|
80
|
-
|
|
81
|
-
Symlinked to `~/bin` by `setup.sh`:
|
|
82
|
-
|
|
83
|
-
| Command | Target | Type |
|
|
84
|
-
|---------|--------|------|
|
|
85
|
-
| `sly-kanban` | `sly-kanban` | Standalone Node.js |
|
|
86
|
-
| `sly-scaffold` | `scripts/scaffold.js` | Standalone Node.js |
|
|
87
|
-
| `sly-messaging` | `messaging/dist/cli.js` | Built from TypeScript |
|
|
88
|
-
|
|
89
|
-
### CLI Port Detection (`sly-messaging`)
|
|
90
|
-
|
|
91
|
-
The CLI auto-detects which mode (dev/prod) the messaging service is running in:
|
|
92
|
-
|
|
93
|
-
1. Read cached port from `~/.slycode/messaging-port` (if exists), try it first
|
|
94
|
-
2. Probe dev port (3005) then prod port (7593) via `/health`
|
|
95
|
-
3. Cache the successful port for next time
|
|
96
|
-
|
|
97
|
-
This means `sly-messaging` works regardless of whether you started with `sly-dev.sh` or `sly-start.sh`. After the first successful call, subsequent calls skip probing entirely.
|
|
98
|
-
|
|
99
|
-
## Key Design Decisions
|
|
100
|
-
|
|
101
|
-
### No hardcoded paths anywhere
|
|
102
|
-
- Web: `web/src/lib/paths.ts` — centralized `getSlycodeRoot()` (via `SLYCODE_HOME` → cwd fallback) and `getPackageDir()` (detects `node_modules/slycode/dist/` for prod). All 10+ API routes import from paths.ts — no local `getRepoRoot()` helpers. `legacy root env var` env var removed.
|
|
103
|
-
- Bridge: reads `BRIDGE_PORT` from env
|
|
104
|
-
- Messaging: uses `SLYCODE_HOME` env var for workspace resolution (replaces `__dirname`-relative paths that broke in prod npm packages). CLI auto-detects service port (dev 3005 / prod 7593) with caching.
|
|
105
|
-
- Skills: reference `sly-kanban` and `sly-messaging` by global command name, not paths
|
|
106
|
-
- Documentation: uses `<slycode-root>` placeholder instead of absolute paths
|
|
107
|
-
- `registry.json`: `setup.sh` updates the SlyCode path entry at install time
|
|
108
|
-
|
|
109
|
-
### Stop by port, not PID files
|
|
110
|
-
PID files are unreliable because `npm start` spawns child processes — the recorded PID is the npm wrapper which dies, leaving orphaned node/next-server children. Port-based discovery always finds the actual listening process.
|
|
111
|
-
|
|
112
|
-
### Build in setup, not start
|
|
113
|
-
`sly-start.sh` does NOT build — it assumes services are already built. Builds happen in `setup.sh` (which users rerun when code changes). This keeps start fast and avoids memory-heavy builds blocking service startup.
|
|
114
|
-
|
|
115
|
-
### XDG_RUNTIME_DIR fix
|
|
116
|
-
Code-server terminals don't set `XDG_RUNTIME_DIR`, breaking `systemctl --user`. All scripts set it to `/run/user/$(id -u)` if missing and the directory exists. Safe, standard, no side effects.
|
|
117
|
-
|
|
118
|
-
### bridge-sessions.json protection
|
|
119
|
-
- Path resolved via `__dirname` (never relative — avoids reading wrong file from wrong cwd)
|
|
120
|
-
- Only starts fresh on ENOENT (file doesn't exist = first run)
|
|
121
|
-
- Any other read error crashes loudly instead of silently wiping session data
|
|
122
|
-
- Saves are atomic (write `.tmp` then `rename`)
|
|
123
|
-
|
|
124
|
-
### Bridge CWD validation
|
|
125
|
-
Bridge requires absolute path for session `cwd` — no defaults, no relative paths. This ensures the AI CLI associates sessions with the correct project directory.
|
|
126
|
-
|
|
127
|
-
## Env Files
|
|
128
|
-
|
|
129
|
-
- **`.env.example`**: template with all config vars, prod port defaults, placeholder secrets, TZ timezone var, DEV_HOSTNAME (Tailscale hostname for Next.js dev origins)
|
|
130
|
-
- **`.env`**: actual config, created from example by `setup.sh`, gitignored
|
|
131
|
-
- `.env` lives at repo root — messaging loads it via `dotenv`, bridge reads env vars, web gets them via `sly-start.sh` exports
|
|
132
|
-
|
|
133
|
-
## slycode.config.js
|
|
134
|
-
|
|
135
|
-
Workspace-level configuration file loaded by `packages/slycode/src/config/loader.ts`:
|
|
136
|
-
|
|
137
|
-
```js
|
|
138
|
-
module.exports = {
|
|
139
|
-
ports: { web: 7591, bridge: 7592, messaging: 7593 },
|
|
140
|
-
services: { web: true, bridge: true, messaging: true },
|
|
141
|
-
host: '127.0.0.1', // Only web binds to this; bridge+messaging always localhost
|
|
142
|
-
};
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
- `slycode config [key] [value]` — View/modify config via CLI
|
|
146
|
-
- Defaults: ports 7591/7592/7593, all services enabled, host `127.0.0.1`
|
|
147
|
-
- Only web binds to `config.host`; bridge and messaging are always `127.0.0.1`
|
|
148
|
-
|
|
149
|
-
## NPM Distribution (`packages/`)
|
|
150
|
-
|
|
151
|
-
- `packages/slycode/` (v0.1.0) — Main npm package providing `slycode` CLI
|
|
152
|
-
- Subcommands: workspace, start, stop, service, doctor, skills, sync, update, config, uninstall
|
|
153
|
-
- `slycode skills list|check|add|reset` for skill management
|
|
154
|
-
- `slycode config [key] [value]` for slycode.config.js management
|
|
155
|
-
- `slycode uninstall` for removing services and CLI tools
|
|
156
|
-
- Platform-specific service management (Linux systemd, macOS launchd, Windows Task Scheduler)
|
|
157
|
-
- Templates in `templates/` use flat canonical store layout, includes `tutorial-project/` template
|
|
158
|
-
- `files` in package.json: `bin/`, `data/`, `lib/`, `dist/`, `templates/`. Dependencies include `multer` (bridge image upload).
|
|
159
|
-
- Default host: `127.0.0.1` (configurable via slycode.config.js)
|
|
160
|
-
- `packages/create-slycode/` (v0.1.0) — Scaffold tool for initializing new SlyCode workspaces
|
|
161
|
-
- Exports `create-slycode` CLI command
|
|
162
|
-
- Setup wizard prompts for timezone (auto-detects system TZ, writes `TZ=` to .env for cron scheduling)
|
|
163
|
-
- Seeds `providers.json` and `sly-actions.json` from package templates during workspace creation
|
|
164
|
-
- Tutorial content seeded into workspace root via `seedTutorialWorkspaceContent()` (not a separate `slycode_tutorial/` subdirectory)
|
|
165
|
-
- Registry seeds workspace root as default project (id: `slycode`, path: workspace dir)
|
|
166
|
-
- Kanban seed uses correct stage-based format (`project_id`, `stages`, `last_updated`)
|
|
167
|
-
- `build/build-package.ts` — Full build pipeline: builds services, syncs store→updates, copies templates, scaffold-templates/, store/, and store/actions/ to templates/store/actions/ for scaffold seeding. Preserves tutorial-project template during wipe/rebuild.
|
|
168
|
-
- `build/sync-updates.ts` — Sync manifest skills from store/ to updates/ (enforces manifest as authority)
|
|
169
|
-
- `build/store-manifest.js` — Curated list of skills included in package distribution
|
|
170
|
-
|
|
171
|
-
### slycode CLI new subcommands
|
|
172
|
-
- `slycode sync` — Refresh workspace updates/ from package templates
|
|
173
|
-
- `slycode update` — Platform-aware restart (systemd/launchd/Windows Task Scheduler/background)
|
|
174
|
-
- `slycode start` — Auto-refreshes updates + npm version check (3s timeout). Passes workspace as `cwd` to spawned services and sets `SLYCODE_HOME` env var (fixes prod path resolution where Next.js server.js does `process.chdir(__dirname)`).
|
|
175
|
-
|
|
176
|
-
## Related Files
|
|
177
|
-
|
|
178
|
-
- `documentation/designs/global_cli_setup.md` — full design document
|
|
179
|
-
- `documentation/features/020_global_cli_setup.md` — 9-phase implementation plan
|
|
180
|
-
- `web/src/lib/paths.ts` — runtime path resolution for web app
|
|
181
|
-
- `bridge/src/session-manager.ts` — session persistence, CWD validation
|
|
182
|
-
- `bridge/bridge-sessions.json` — persisted session state (NEVER wipe)
|
|
183
|
-
- `.env.example` / `.env` — environment configuration
|
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
# Skills & Infrastructure
|
|
2
|
-
|
|
3
|
-
Updated: 2026-03-13
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
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
|
-
|
|
9
|
-
## Key Files
|
|
10
|
-
|
|
11
|
-
### Skills (17 total — all commands converted to skills)
|
|
12
|
-
- `.claude/skills/context-priming/` - Dynamic codebase context loader
|
|
13
|
-
- `.claude/skills/interactive-explainer/` - Creates visual HTML explainers
|
|
14
|
-
- `.claude/skills/skill-creator/` - Guide for creating new skills
|
|
15
|
-
- `.claude/skills/messaging/` - Send text/voice responses to messaging channels (v2.2.0)
|
|
16
|
-
- `.claude/skills/claude-code-docs-maintainer/` - Maintains Claude Code documentation
|
|
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
|
|
29
|
-
|
|
30
|
-
### Agents
|
|
31
|
-
- `.claude/agents/doc-updater.md` - Autonomous documentation maintenance agent
|
|
32
|
-
|
|
33
|
-
### Commands (REMOVED)
|
|
34
|
-
- `.claude/commands/` directory no longer exists — all converted to `.claude/skills/*/SKILL.md`
|
|
35
|
-
|
|
36
|
-
### Scripts
|
|
37
|
-
- `scripts/setup.sh` - Guided setup: environment, services, global CLI, linger
|
|
38
|
-
- `scripts/sly-start.sh` - Start all services (web, bridge, messaging)
|
|
39
|
-
- `scripts/sly-stop.sh` - Stop all services
|
|
40
|
-
- `scripts/sly-restart.sh` - Restart all services
|
|
41
|
-
- `scripts/sly-dev.sh` - Development mode launcher
|
|
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 (v0.1.0): `slycode` CLI with workspace, start, stop, service, doctor, skills, sync, update, config, uninstall subcommands
|
|
67
|
-
- `packages/create-slycode/` - Scaffold tool: `create-slycode` for initializing new workspaces. Setup wizard prompts for timezone (auto-detects via `Intl.DateTimeFormat`, writes `TZ=` to .env for cron scheduling). 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
|
-
- Templates removed from `packages/slycode/templates/` (skills, actions, tutorial-project all deleted — content now delivered via build pipeline and updates/ only)
|
|
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
|
|
79
|
-
|
|
80
|
-
### Scaffold Templates
|
|
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`
|
|
86
|
-
|
|
87
|
-
### Config
|
|
88
|
-
- `.claude/settings.local.json` - Local Claude settings
|
|
89
|
-
- `.mcp.json` - MCP server configuration (Context7, etc.)
|
|
90
|
-
- `.env` / `.env.example` - Environment config with service ports
|
|
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`
|
|
99
|
-
|
|
100
|
-
### Documentation
|
|
101
|
-
- `documentation/kanban.json` - Kanban card data
|
|
102
|
-
- `documentation/events.json` - Activity event log (card moves, asset operations, sessions)
|
|
103
|
-
- `documentation/terminal-classes.json` - Terminal class definitions
|
|
104
|
-
- `documentation/features/` - Feature specs (001-049)
|
|
105
|
-
- `documentation/chores/` - Chore plans (active + completed/)
|
|
106
|
-
- `documentation/designs/` - Design documents
|
|
107
|
-
- `documentation/reference/` - Reference documentation
|
|
108
|
-
|
|
109
|
-
## Skill Structure
|
|
110
|
-
|
|
111
|
-
```
|
|
112
|
-
.claude/skills/{skill-name}/
|
|
113
|
-
├── SKILL.md # Main skill definition, invocation rules
|
|
114
|
-
└── references/ # Supporting docs, templates, examples
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
All user-invocable operations are now skills (no separate commands directory).
|
|
118
|
-
|
|
119
|
-
## Global CLI Commands
|
|
120
|
-
|
|
121
|
-
After `scripts/setup.sh`, these are available globally:
|
|
122
|
-
- `sly-kanban` - Kanban board management
|
|
123
|
-
- `sly-messaging` - Send messages via messaging channels
|
|
124
|
-
- `sly-scaffold` - Project scaffolding
|
|
125
|
-
|
|
126
|
-
## Service Management
|
|
127
|
-
|
|
128
|
-
- `scripts/sly-start.sh` - Start all services (web on 7591, bridge on 7592, messaging on 7593)
|
|
129
|
-
- `scripts/sly-stop.sh` - Stop all services
|
|
130
|
-
- `scripts/setup.sh --service` - Install as persistent system services
|
|
131
|
-
- `scripts/setup.sh --remove-service` - Remove persistent services
|
|
132
|
-
|
|
133
|
-
## Environment Variables (.env.example)
|
|
134
|
-
|
|
135
|
-
- **TZ**: IANA timezone for cron schedule evaluation (e.g., Australia/Melbourne). Defaults to UTC if unset.
|
|
136
|
-
- **Ports**: WEB_PORT=7591, BRIDGE_PORT=7592, MESSAGING_SERVICE_PORT=7593
|
|
137
|
-
- **Bridge**: BRIDGE_URL for bridge connection
|
|
138
|
-
- **Telegram**: TELEGRAM_BOT_TOKEN, TELEGRAM_AUTHORIZED_USER_ID
|
|
139
|
-
- **STT**: STT_BACKEND (openai|local), OPENAI_API_KEY (Whisper API), WHISPER_CLI_PATH + WHISPER_MODEL_PATH (local whisper.cpp)
|
|
140
|
-
- **TTS**: ELEVENLABS_API_KEY, ELEVENLABS_VOICE_ID, ELEVENLABS_VOICE_SPEED
|
|
141
|
-
|
|
142
|
-
## Hooks
|
|
143
|
-
|
|
144
|
-
- `web/src/hooks/useKeyboardShortcuts.ts` - Number keys 1-9 for project navigation, Escape
|
|
145
|
-
- `web/src/hooks/useSlyActionsConfig.ts` - Polling-based commands config (30s)
|
|
146
|
-
- `web/src/hooks/useConnectionStatus.ts` - SSE connection state
|
|
147
|
-
- `web/src/hooks/usePolling.ts` - Generic polling hook
|
|
148
|
-
|
|
149
|
-
## Patterns & Invariants
|
|
150
|
-
|
|
151
|
-
- Skills use semantic versioning (MAJOR.MINOR.PATCH)
|
|
152
|
-
- Always update version and date when modifying skills
|
|
153
|
-
- Skills invoked via `/skill-name` shorthand (commands no longer exist as separate entity)
|
|
154
|
-
- CLAUDE.md applies to entire project, overrides defaults
|
|
155
|
-
- MCP servers configured in .mcp.json (Context7 for docs)
|
|
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.
|
|
175
|
-
|
|
176
|
-
## Environment
|
|
177
|
-
|
|
178
|
-
- `CLAUDE_ENV` - 'home' or 'work' for environment detection
|
|
179
|
-
- Projects tracked in `projects/registry.json`
|
|
180
|
-
|
|
181
|
-
## When to Expand
|
|
182
|
-
|
|
183
|
-
- Creating new skill → skill-creator skill, .claude/skills/
|
|
184
|
-
- Creating new command → create-command skill, creates a new skill in .claude/skills/
|
|
185
|
-
- Creating new agent → .claude/agents/
|
|
186
|
-
- Cross-provider assets → store/, .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
|
|
191
|
-
- Adding MCP servers → .mcp.json
|
|
192
|
-
- Service management → scripts/sly-*.sh
|
|
193
|
-
- Setup/installation → scripts/setup.sh
|
|
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
|
|
196
|
-
- Activity events → documentation/events.json, web/src/lib/event-log.ts
|
package/templates/updates/skills/context-priming/references/references/areas/terminal-bridge.md
DELETED
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
# Terminal Bridge
|
|
2
|
-
|
|
3
|
-
Updated: 2026-03-12
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
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, graceful idle timeout handling, and image delivery to PTY sessions. React components connect through Next.js API proxy.
|
|
8
|
-
|
|
9
|
-
## Key Files
|
|
10
|
-
|
|
11
|
-
### Bridge Server (Node/Express)
|
|
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, instruction file check/create
|
|
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, image upload, instruction file check
|
|
17
|
-
- `bridge/src/screenshot-utils.ts` - Screenshot saving, retention (10-file cap), .gitignore management
|
|
18
|
-
- `bridge/src/websocket.ts` - WebSocket upgrade handling (legacy, SSE preferred)
|
|
19
|
-
- `bridge/src/claude-utils.ts` - Provider-agnostic session ID detection (Claude/Codex/Gemini) with unified dispatchers
|
|
20
|
-
- `bridge/src/types.ts` - Session, BridgeConfig, BridgeStats, ActivityTransition, provider interfaces
|
|
21
|
-
|
|
22
|
-
### Configuration
|
|
23
|
-
- `bridge/bridge-config.json` - Runtime config: allowedCommands (claude, codex, gemini, bash), CORS origins
|
|
24
|
-
- `data/providers.json` - Provider registry: CLI commands, permission flags, resume types, prompt handling, stage defaults
|
|
25
|
-
- `documentation/terminal-classes.json` - Terminal class definitions for command visibility
|
|
26
|
-
### Web Components
|
|
27
|
-
- `web/src/components/Terminal.tsx` - xterm.js terminal, SSE via ConnectionManager, resize broadcast with echo-loop suppression
|
|
28
|
-
- `web/src/components/ClaudeTerminalPanel.tsx` - Terminal panel with startupActions/activeActions
|
|
29
|
-
- `web/src/components/GlobalClaudePanel.tsx` - Floating panel for project-wide session
|
|
30
|
-
- `web/src/app/api/bridge/[...path]/route.ts` - Next.js proxy to bridge server
|
|
31
|
-
|
|
32
|
-
## Key Functions
|
|
33
|
-
|
|
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
|
-
- `SessionManager.resolveSessionName()` - Checks both new (with provider) and legacy session name formats
|
|
37
|
-
- `SessionManager.stopSession()` - Graceful SIGINT, waits for exit, removes session from in-memory map (frees slot; data preserved in persistedState for resume)
|
|
38
|
-
- `SessionManager.stopAllSessions()` - Bulk stop all running/detached sessions, returns count
|
|
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
|
|
42
|
-
- `SessionManager.checkIdleSessions()` - Idle timeout with grace period after disconnect
|
|
43
|
-
- `buildProviderCommand()` - Assembles { command, args } from provider config, handles flag vs subcommand resume
|
|
44
|
-
- `getProvider()` - Loads provider config by ID from providers.json (30s cache)
|
|
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)
|
|
52
|
-
- `Terminal.connectSSE()` - Via ConnectionManager for auto-reconnection
|
|
53
|
-
|
|
54
|
-
## Data Models
|
|
55
|
-
|
|
56
|
-
```typescript
|
|
57
|
-
SessionInfo {
|
|
58
|
-
name, group, status (running|stopped|detached|creating), pid, connectedClients,
|
|
59
|
-
hasHistory, resumed, lastActive, lastOutputAt?,
|
|
60
|
-
claudeSessionId?, provider?, skipPermissions?
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
BridgeStats {
|
|
64
|
-
bridgeTerminals: number; // Total PTY sessions
|
|
65
|
-
connectedClients: number; // Total SSE/WS connections
|
|
66
|
-
activelyWorking: number; // Sessions with output in last 2s
|
|
67
|
-
sessions: SessionActivity[]; // Per-session activity
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
SessionActivity {
|
|
71
|
-
name, status, lastOutputAt, isActive,
|
|
72
|
-
activityStartedAt?, lastOutputSnippet?
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
ActivityTransition {
|
|
76
|
-
timestamp: string;
|
|
77
|
-
became: 'active' | 'inactive';
|
|
78
|
-
lastOutputAt: string;
|
|
79
|
-
activityStartedAt: string;
|
|
80
|
-
outputAgeMs: number;
|
|
81
|
-
triggerSnippet: string;
|
|
82
|
-
triggerRawHex: string;
|
|
83
|
-
triggerDataLength: number;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
BridgeConfig {
|
|
87
|
-
host, port, sessionFile, defaultIdleTimeout, maxSessions
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
BridgeRuntimeConfig {
|
|
91
|
-
allowedCommands: string[]; // e.g., ['claude', 'codex', 'gemini', 'bash']
|
|
92
|
-
cors: { origins: string[] }
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
CreateSessionRequest {
|
|
96
|
-
name: string;
|
|
97
|
-
provider?: string; // Provider id from providers.json
|
|
98
|
-
skipPermissions?: boolean; // Whether to add permission-skip flag
|
|
99
|
-
command?: string; // Legacy: direct command (backward compat)
|
|
100
|
-
cwd?: string;
|
|
101
|
-
fresh?: boolean;
|
|
102
|
-
idleTimeout?: number;
|
|
103
|
-
prompt?: string;
|
|
104
|
-
createInstructionFile?: boolean; // Opt-in: copy sibling instruction file if missing
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
PersistedSession {
|
|
108
|
-
claudeSessionId?, cwd, createdAt, lastActive,
|
|
109
|
-
provider?: string; // Defaults to 'claude' for old sessions
|
|
110
|
-
skipPermissions?: boolean; // Defaults to true for old sessions
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// Provider config types (provider-utils.ts)
|
|
114
|
-
ProviderConfig {
|
|
115
|
-
id, displayName, command, install,
|
|
116
|
-
permissions: { flag, label, default },
|
|
117
|
-
resume: { supported, type ('flag'|'subcommand'), flag?, subcommand?, lastFlag?, detectSession, sessionDir? },
|
|
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)
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
ProvidersData {
|
|
124
|
-
providers: Record<string, ProviderConfig>;
|
|
125
|
-
defaults: {
|
|
126
|
-
stages: Record<string, { provider, skipPermissions }>;
|
|
127
|
-
global: { provider, skipPermissions };
|
|
128
|
-
projects: Record<string, { provider, skipPermissions }>;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
## Security Hardening
|
|
134
|
-
|
|
135
|
-
- **Localhost binding**: HOST defaults to `localhost` (not `0.0.0.0`)
|
|
136
|
-
- **Command whitelist**: Only commands in `bridge-config.json` allowedCommands can be spawned (claude, codex, gemini, bash)
|
|
137
|
-
- **Provider validation**: Provider ID must exist in providers.json; resolved command must be in allowedCommands
|
|
138
|
-
- **CWD validation**: Requires absolute path, verifies exists and is accessible before spawning PTY
|
|
139
|
-
- **CORS origins**: Configured in bridge-config.json, not wide-open
|
|
140
|
-
|
|
141
|
-
## Activity Tracking
|
|
142
|
-
|
|
143
|
-
- `lastOutputAt` timestamp updated on every PTY output
|
|
144
|
-
- `isActive` = output within last 2 seconds (with 1s debounce)
|
|
145
|
-
- `activelyWorking` count in BridgeStats for health monitor
|
|
146
|
-
- Cards with active sessions show pulsing green glow in UI
|
|
147
|
-
- **Activity transitions**: Logged with trigger details (snippet, hex, data length) for debugging phantom blips
|
|
148
|
-
- `GET /activity-log/:name` endpoint exposes transition history per session
|
|
149
|
-
|
|
150
|
-
## State Persistence
|
|
151
|
-
|
|
152
|
-
- Session state saved to bridge-sessions.json via atomic writes (temp file + rename)
|
|
153
|
-
- State file uses `__dirname` resolution for reliable file location
|
|
154
|
-
- Missing file (ENOENT) handled gracefully; corrupt JSON throws fatal error
|
|
155
|
-
- Prevents silent data loss from corrupted state
|
|
156
|
-
|
|
157
|
-
## Race Condition Handling
|
|
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.
|
|
161
|
-
- **Disconnect grace period**: 5 seconds before session eligible for idle timeout
|
|
162
|
-
- **Status transitions**: Protected against reconnect during disconnect
|
|
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.
|
|
165
|
-
|
|
166
|
-
## Terminal Classes
|
|
167
|
-
|
|
168
|
-
Controls which commands appear in each context:
|
|
169
|
-
- `global-terminal` - Dashboard terminal (future)
|
|
170
|
-
- `project-terminal` - Project-level panel at bottom
|
|
171
|
-
- `backlog`, `design`, `implementation`, `testing`, `done` - Card terminals by stage
|
|
172
|
-
- `action-assistant` - Terminal in SlyActionConfigModal
|
|
173
|
-
|
|
174
|
-
## Multi-Provider System
|
|
175
|
-
|
|
176
|
-
### Supported Providers
|
|
177
|
-
- **Claude Code** (`claude`) — Positional prompts, `--resume <GUID>` with auto-detection, `--dangerously-skip-permissions`
|
|
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
|
|
180
|
-
|
|
181
|
-
### Command Building (`buildProviderCommand`)
|
|
182
|
-
- Returns `{ command, args }` tuple (command can change for Codex resume: `codex resume`)
|
|
183
|
-
- Permission flag added if `skipPermissions: true`
|
|
184
|
-
- Resume: flag-type appends `--resume [GUID]`; subcommand-type prepends `resume [GUID|--last]`
|
|
185
|
-
- Prompt: positional appends as final arg; flag-type uses `-i <prompt>` (interactive)
|
|
186
|
-
- Prompt works alongside resume: Claude accepts positional after `--resume`, Codex accepts positional after `resume --last`
|
|
187
|
-
|
|
188
|
-
### Session Name Format
|
|
189
|
-
- **New format**: `{projectId}:{provider}:card:{cardId}` or `{projectId}:{provider}:global`
|
|
190
|
-
- **Legacy format**: `{projectId}:card:{cardId}` or `{projectId}:global`
|
|
191
|
-
- `resolveSessionName()` checks new format first, falls back to legacy via `toLegacySessionName()`
|
|
192
|
-
- Old sessions without provider field default to `provider: "claude"`
|
|
193
|
-
|
|
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
|
|
200
|
-
- `getClaimedGuids()` excludes GUIDs already used by other sessions
|
|
201
|
-
- Detection timeout: 60 seconds (Gemini CLI takes ~30s to create session files)
|
|
202
|
-
|
|
203
|
-
### Stage-Based Defaults
|
|
204
|
-
- `providers.json` `defaults.stages` maps each kanban stage → `{ provider, skipPermissions }`
|
|
205
|
-
- UI pre-fills provider dropdown from stage default
|
|
206
|
-
- `defaults.global` for project-level terminals
|
|
207
|
-
- `defaults.projects` reserved for per-project overrides (future)
|
|
208
|
-
|
|
209
|
-
## Patterns & Invariants
|
|
210
|
-
|
|
211
|
-
- Session names include provider segment: `{projectId}:{provider}:card:{cardId}` (new) or legacy `{projectId}:card:{cardId}`
|
|
212
|
-
- Claude prompts passed as positional arg, NOT `-p` flag (that's print mode)
|
|
213
|
-
- Resume behavior is provider-specific: flag vs subcommand, GUID vs latest
|
|
214
|
-
- SSE streams through `/api/bridge/sessions/{name}/stream` proxy
|
|
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.
|
|
217
|
-
- Idle timeout: 4 hours default, checked every 60 seconds
|
|
218
|
-
- Atomic state saves with unique temp file names (`.tmp.${pid}.${Date.now()}`) prevent race conditions
|
|
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
|
-
|
|
227
|
-
## API Endpoints
|
|
228
|
-
|
|
229
|
-
- `GET /sessions` - List all sessions
|
|
230
|
-
- `GET /sessions/:name` - Get session info
|
|
231
|
-
- `POST /sessions` - Create session (validates command + CWD, returns 202 if already creating)
|
|
232
|
-
- `DELETE /sessions/:name` - Stop or delete session
|
|
233
|
-
- `POST /sessions/:name/input` - Send input to PTY
|
|
234
|
-
- `POST /sessions/:name/resize` - Resize terminal
|
|
235
|
-
- `POST /sessions/:name/image` - Upload image to session's screenshots/ dir (multipart, 10MB limit), returns filename
|
|
236
|
-
- `POST /sessions/:name/action` - Structured actions: compact, clear, interrupt
|
|
237
|
-
- `POST /sessions/:name/relink` - Re-detect session ID from most recent provider session file
|
|
238
|
-
- `POST /sessions/:name/stop` - Send Escape key to active session (soft stop)
|
|
239
|
-
- `GET /sessions/:name/stream` - SSE output stream
|
|
240
|
-
- `GET /groups/:group/status` - Group-level session status aggregation
|
|
241
|
-
- `POST /sessions/stop-all` - Bulk stop all running sessions
|
|
242
|
-
- `GET /stats` - BridgeStats with activity info
|
|
243
|
-
- `GET /activity-log/:name` - Activity transition history for debugging
|
|
244
|
-
- `GET /check-instruction-file?provider=X&cwd=Y` - Check if instruction file exists, returns { needed, targetFile?, copySource? }
|
|
245
|
-
|
|
246
|
-
## When to Expand
|
|
247
|
-
|
|
248
|
-
- Session not starting → session-manager.ts createSession(), check command whitelist + provider validation
|
|
249
|
-
- Adding new provider → data/providers.json, bridge-config.json allowedCommands
|
|
250
|
-
- Provider command issues → provider-utils.ts buildProviderCommand()
|
|
251
|
-
- Resume not working → provider-utils.ts (flag vs subcommand), claude-utils.ts (GUID detection)
|
|
252
|
-
- Security concerns → bridge-config.json, session-manager.ts validation
|
|
253
|
-
- Activity tracking issues → session-manager.ts handlePtyOutput(), getStats(), ActivityTransition
|
|
254
|
-
- Phantom activity blips → activity-log endpoint, transition trigger data
|
|
255
|
-
- Terminal display issues → Terminal.tsx, xterm setup
|
|
256
|
-
- Connection problems → api/bridge proxy, connection-manager.ts
|
|
257
|
-
- Idle timeout issues → session-manager.ts checkIdleSessions()
|
|
258
|
-
- Bulk operations → stopAllSessions(), /sessions/stop-all
|
|
259
|
-
- Image delivery → screenshot-utils.ts (saving/retention), api.ts (image endpoint), ClaudeTerminalPanel.tsx (paste handling)
|
|
260
|
-
- State corruption → session-manager.ts loadState/saveState
|
|
261
|
-
- Session name resolution → session-manager.ts resolveSessionName(), toLegacySessionName()
|
|
262
|
-
- Instruction file issues → provider-utils.ts checkInstructionFile/ensureInstructionFile, api.ts check-instruction-file endpoint
|
|
263
|
-
- Terminal resize sync → Terminal.tsx sendResize(), SSE resize event handling
|