@slycode/slycode 0.1.1 → 0.1.2

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 (79) hide show
  1. package/dist/web/.next/BUILD_ID +1 -1
  2. package/dist/web/.next/build-manifest.json +2 -2
  3. package/dist/web/.next/server/app/_global-error.html +2 -2
  4. package/dist/web/.next/server/app/_global-error.rsc +1 -1
  5. package/dist/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  6. package/dist/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  7. package/dist/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  8. package/dist/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  9. package/dist/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  10. package/dist/web/.next/server/app/_not-found.html +1 -1
  11. package/dist/web/.next/server/app/_not-found.rsc +1 -1
  12. package/dist/web/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  13. package/dist/web/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  14. package/dist/web/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  15. package/dist/web/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  16. package/dist/web/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  17. package/dist/web/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  18. package/dist/web/.next/server/chunks/[root-of-the-server]__198f01e0._.js +1 -1
  19. package/dist/web/.next/server/chunks/[root-of-the-server]__884d73e4._.js +1 -1
  20. package/dist/web/.next/server/chunks/[root-of-the-server]__aa814a86._.js +1 -1
  21. package/dist/web/.next/server/chunks/[root-of-the-server]__b90bbd70._.js +1 -1
  22. package/dist/web/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_ffc6c790.js +1 -1
  23. package/dist/web/.next/server/pages/404.html +1 -1
  24. package/dist/web/.next/server/pages/500.html +2 -2
  25. package/dist/web/src/app/api/git-status/route.ts +1 -0
  26. package/dist/web/src/app/api/projects/analyze/route.ts +1 -0
  27. package/dist/web/src/app/api/projects/route.ts +1 -0
  28. package/dist/web/src/app/api/transcribe/route.ts +1 -1
  29. package/dist/web/src/app/api/version-check/route.ts +1 -0
  30. package/lib/cli/doctor.d.ts.map +1 -1
  31. package/lib/cli/doctor.js +2 -1
  32. package/lib/cli/doctor.js.map +1 -1
  33. package/lib/cli/start.d.ts.map +1 -1
  34. package/lib/cli/start.js +1 -0
  35. package/lib/cli/start.js.map +1 -1
  36. package/lib/cli/stop.d.ts.map +1 -1
  37. package/lib/cli/stop.js +6 -4
  38. package/lib/cli/stop.js.map +1 -1
  39. package/lib/cli/update.d.ts.map +1 -1
  40. package/lib/cli/update.js +8 -5
  41. package/lib/cli/update.js.map +1 -1
  42. package/package.json +1 -1
  43. package/templates/kanban-seed.json +1 -1
  44. package/templates/tutorial-project/.agents/skills/checkpoint/SKILL.md +43 -0
  45. package/templates/tutorial-project/.agents/skills/context-priming/SKILL.md +152 -0
  46. package/templates/tutorial-project/.agents/skills/context-priming/references/area-index.md +101 -0
  47. package/templates/tutorial-project/.agents/skills/context-priming/references/areas/claude-actions.md +120 -0
  48. package/templates/tutorial-project/.agents/skills/context-priming/references/areas/messaging.md +177 -0
  49. package/templates/tutorial-project/.agents/skills/context-priming/references/areas/scripts-deployment.md +138 -0
  50. package/templates/tutorial-project/.agents/skills/context-priming/references/areas/skills.md +135 -0
  51. package/templates/tutorial-project/.agents/skills/context-priming/references/areas/terminal-bridge.md +232 -0
  52. package/templates/tutorial-project/.agents/skills/context-priming/references/areas/web-frontend.md +252 -0
  53. package/templates/tutorial-project/.agents/skills/context-priming/references/maintenance.md +128 -0
  54. package/templates/tutorial-project/.agents/skills/design/SKILL.md +141 -0
  55. package/templates/tutorial-project/.agents/skills/feature/SKILL.md +159 -0
  56. package/templates/tutorial-project/.agents/skills/implement/SKILL.md +132 -0
  57. package/templates/tutorial-project/.agents/skills/kanban/SKILL.md +264 -0
  58. package/templates/tutorial-project/.claude/skills/checkpoint/SKILL.md +43 -0
  59. package/templates/tutorial-project/.claude/skills/context-priming/SKILL.md +152 -0
  60. package/templates/tutorial-project/.claude/skills/context-priming/references/area-index.md +101 -0
  61. package/templates/tutorial-project/.claude/skills/context-priming/references/areas/claude-actions.md +120 -0
  62. package/templates/tutorial-project/.claude/skills/context-priming/references/areas/messaging.md +177 -0
  63. package/templates/tutorial-project/.claude/skills/context-priming/references/areas/scripts-deployment.md +138 -0
  64. package/templates/tutorial-project/.claude/skills/context-priming/references/areas/skills.md +135 -0
  65. package/templates/tutorial-project/.claude/skills/context-priming/references/areas/terminal-bridge.md +232 -0
  66. package/templates/tutorial-project/.claude/skills/context-priming/references/areas/web-frontend.md +252 -0
  67. package/templates/tutorial-project/.claude/skills/context-priming/references/maintenance.md +128 -0
  68. package/templates/tutorial-project/.claude/skills/design/SKILL.md +141 -0
  69. package/templates/tutorial-project/.claude/skills/feature/SKILL.md +159 -0
  70. package/templates/tutorial-project/.claude/skills/implement/SKILL.md +132 -0
  71. package/templates/tutorial-project/.claude/skills/kanban/SKILL.md +264 -0
  72. package/templates/tutorial-project/CLAUDE.md +16 -0
  73. package/templates/tutorial-project/documentation/designs/example_welcome_dashboard.md +38 -0
  74. package/templates/tutorial-project/documentation/events.json +1 -0
  75. package/templates/tutorial-project/documentation/features/example_in_card_deliverable_feature.md +31 -0
  76. package/templates/tutorial-project/documentation/kanban.json +385 -0
  77. /package/dist/web/.next/static/{cut-BpEHnH8_V_vl0UOOW → 4GrOHGHgp_-wfmjYR4P3O}/_buildManifest.js +0 -0
  78. /package/dist/web/.next/static/{cut-BpEHnH8_V_vl0UOOW → 4GrOHGHgp_-wfmjYR4P3O}/_clientMiddlewareManifest.json +0 -0
  79. /package/dist/web/.next/static/{cut-BpEHnH8_V_vl0UOOW → 4GrOHGHgp_-wfmjYR4P3O}/_ssgManifest.js +0 -0
@@ -0,0 +1,101 @@
1
+ # Area Index
2
+
3
+ Updated: 2026-02-14
4
+
5
+ ## Areas
6
+
7
+ ### web-frontend
8
+ - path: areas/web-frontend.md
9
+ - updated: 2026-02-14
10
+ - load-when: dashboard, kanban, cards, modal, UI components, drag-drop, project page, checklist, command config, health monitor, reconnection, toolkit, assets, search, scaffolding, activity feed, keyboard shortcuts, health score, tab sync, theme, design system, colors, gradient, texture, grain, noise, logo, neon, glow, blend mode, terminal styling, dark mode, light mode, provider selector, provider dropdown
11
+ - notes:
12
+ - CardModal tabs are dynamic: Details, Design?, Feature?, Test?, Checklist?, Terminal
13
+ - Terminal tab auto-connects when session is running
14
+ - HealthMonitor in ProjectHeader shows CPU/memory/terminals, expands on hover
15
+ - ConnectionManager handles SSE reconnection with Page Visibility API
16
+ - Cards with active work show pulsing green glow (active-glow-card CSS class)
17
+ - Commands use startupCommands (session start) and activeCommands (toolbar)
18
+ - ToolkitTab manages cross-project asset deployment (commands/skills/agents)
19
+ - HealthDot on ProjectCard shows 0-100 score (green/amber/red)
20
+ - paths.ts replaces all hardcoded paths with dynamic resolution
21
+ - CardModal has edit session protection (2000ms grace period, last-known-value tracking)
22
+ - Provider selector in ClaudeTerminalPanel pre-fills from stage defaults via /api/providers
23
+ - CardModal detects existing session's provider from session name (projectId:provider:card:cardId)
24
+ - NEVER use dark-end color scales for dark mode vibrant colors — use bright color at low opacity
25
+ - soft-light blend produces warm/red cast on dark backgrounds — use screen or overlay instead
26
+ - drop-shadow filters create rectangular glow on images with opaque backgrounds — incompatible with mix-blend-mode logo transparency
27
+ - Gradient direction: always left (vibrant) to right (soft), never center-out
28
+ - Texture is three layers: fine grain + perlin noise + depth highlight — each with separate light/dark tuning
29
+
30
+ ### terminal-bridge
31
+ - path: areas/terminal-bridge.md
32
+ - updated: 2026-02-14
33
+ - load-when: terminal, Claude panel, xterm, bridge, pty, session, websocket, SSE, spawn, terminal class, security, stats, activity log, stop-all, provider, providers.json, multi-provider, gemini, codex, claude, resume, skip-permissions, YOLO
34
+ - notes:
35
+ - Pass prompts as positional args to Claude CLI, NOT -p flag (-p is print mode)
36
+ - Bridge binds to localhost by default (not 0.0.0.0) for security
37
+ - Command whitelist in bridge-config.json (only 'claude' and 'bash' allowed)
38
+ - CWD validated before spawning PTY (must be absolute path)
39
+ - Activity tracking: lastOutputAt timestamp, 2s threshold for "active" status
40
+ - Grace period (5s) after disconnect prevents idle timeout race condition
41
+ - ActivityTransition logging with trigger details for debugging phantom blips
42
+ - Atomic state saves (temp file + rename) prevent data corruption
43
+ - POST /sessions/:name/stop sends Escape key (soft stop) vs DELETE (kill)
44
+ - Session names now include provider: {projectId}:{provider}:card:{cardId} (with legacy fallback)
45
+ - provider-utils.ts builds command args from providers.json config (flag vs subcommand resume)
46
+ - GUID detection only for Claude; Gemini/Codex use --resume --last
47
+
48
+ ### claude-actions
49
+ - path: areas/claude-actions.md
50
+ - updated: 2026-02-09
51
+ - load-when: actions, prompts, templates, context injection, commands, visibility, command config
52
+ - notes:
53
+ - Unified command system in data/commands.json (v2.0)
54
+ - No 'type' field on Command - filtering by class + sessionState
55
+ - getStartupCommands() for session start, getActiveCommands() for toolbar
56
+ - Session states: new, resume, active, any
57
+ - Groups: Card Actions, Session, Project, Utilities, Problems, Command Assistant
58
+ - Update Priming and Chore Plan are newer commands
59
+
60
+ ### messaging
61
+ - path: areas/messaging.md
62
+ - updated: 2026-02-14
63
+ - load-when: telegram, messaging, voice, TTS, STT, speech, channel, bot, ElevenLabs, Whisper, voice swap, stop command, response mode, tone, command filter, provider, permission mismatch
64
+ - notes:
65
+ - Channel abstraction in types.ts, Telegram is first implementation
66
+ - Voice pipeline: Whisper STT → ElevenLabs v3 TTS with [audio tags]
67
+ - sendTextRaw() bypasses Markdown (preserves [brackets] for voice tags)
68
+ - Chat actions for status indicators (record_voice, typing, upload_voice)
69
+ - Voice search queries both personal (/v2/voices) and community (/v1/shared-voices)
70
+ - State persisted in messaging-state.json (project + voice + responseMode + voiceTone)
71
+ - CLI tool used by messaging skill to send outbound messages
72
+ - "stop" text intercepted and sends Escape to active session (not forwarded as prompt)
73
+ - command-filter.ts provides context-aware command filtering with template resolution
74
+ - kanban-client.ts gives direct access to project card data for prompts
75
+ - Messaging always forces skipPermissions: true (remote can't approve prompts)
76
+ - Permission mismatch detection when session started from web UI without skip-permissions
77
+ - State persists selectedProvider alongside project/voice/mode/tone
78
+
79
+ ### skills
80
+ - path: areas/skills.md
81
+ - updated: 2026-02-09
82
+ - load-when: skills, commands, agents, hooks, slash commands, SKILL.md, scaffolding
83
+ - notes:
84
+ - Skills live in .claude/skills/, commands in .claude/commands/, agents in .claude/agents/
85
+ - 6 skills: context-priming, interactive-explainer, skill-creator, messaging, claude-code-docs-maintainer, kanban
86
+ - 1 agent: doc-updater
87
+ - 10 commands: checkpoint, feature, chore, implement, design, doc-discovery, doc-update, reference-fetch, create-command, problem_summary
88
+ - Scaffold templates in data/scaffold-templates/
89
+
90
+ ### scripts-deployment
91
+ - path: areas/scripts-deployment.md
92
+ - updated: 2026-02-10
93
+ - load-when: setup, scripts, deployment, start, stop, restart, dev, ports, service, systemd, launchd, linger, PID, zombie, sly-start, sly-stop, sly-dev, sly-restart, setup.sh, .env, environment, production, build, tmux, bridge-sessions, XDG_RUNTIME_DIR
94
+ - notes:
95
+ - Two port ranges: dev (3003/4/5) and prod (7591/2/3 = "sly" on keypad)
96
+ - Stop by port, NOT PID files (npm spawns children, PIDs go stale)
97
+ - bridge-sessions.json is critical — crash on read errors, never silently wipe
98
+ - XDG_RUNTIME_DIR must be set for systemctl --user in code-server
99
+ - Build every time on prod start — no stale build risk
100
+ - sly-dev.sh tmux hook calls sly-stop.sh on session close to prevent zombies
101
+ - Global CLIs: sly-kanban, sly-messaging, sly-scaffold (symlinked to ~/bin)
@@ -0,0 +1,120 @@
1
+ # Claude Actions (Commands)
2
+
3
+ Updated: 2026-02-09
4
+
5
+ ## Overview
6
+
7
+ Unified command system for Claude terminals. Commands are defined in `data/sly-actions.json` with visibility controlled by terminal classes and session state. Commands are split into **startup commands** (shown before/during session start) and **active commands** (shown in toolbar while running).
8
+
9
+ ## Key Files
10
+
11
+ - `data/sly-actions.json` - Unified command definitions (prompts, visibility, groups)
12
+ - `documentation/terminal-classes.json` - Terminal class definitions
13
+ - `web/src/lib/sly-actions.ts` - getStartupActions(), getActiveActions(), renderTemplate(), buildPrompt()
14
+ - `web/src/lib/types.ts` - Command, CommandsConfig, TerminalClass types
15
+ - `web/src/app/api/commands/route.ts` - CRUD for sly-actions.json
16
+ - `web/src/app/api/commands/stream/route.ts` - SSE for file change detection
17
+ - `web/src/app/api/terminal-classes/route.ts` - Serves terminal-classes.json
18
+ - `web/src/app/api/claude-actions/route.ts` - Serves commands in ClaudeActionsConfig format
19
+
20
+ ## Data Models
21
+
22
+ ```typescript
23
+ // Unified command (no 'type' field - filtering by class + sessionState)
24
+ Command {
25
+ label: string;
26
+ description: string;
27
+ group?: string; // Card Actions, Session, Project, Utilities, Problems
28
+ cardTypes?: string[]; // Filter: feature/bug/chore
29
+ prompt: string; // Template with {{placeholders}}
30
+ visibleIn: {
31
+ classes: string[]; // Terminal classes where this appears
32
+ projects: string[]; // Specific projects (if scope='specific')
33
+ };
34
+ scope: 'global' | 'specific';
35
+ sessionState: 'new' | 'resume' | 'active' | 'any';
36
+ }
37
+
38
+ // Internal format used by ClaudeTerminalPanel
39
+ ClaudeCommand {
40
+ id: string;
41
+ label: string;
42
+ description: string;
43
+ group?: string;
44
+ cardTypes?: string[];
45
+ prompt: string;
46
+ visibleIn: { classes: string[]; projects: string[] };
47
+ scope: 'global' | 'specific';
48
+ sessionState: 'new' | 'resume' | 'active' | 'any';
49
+ }
50
+
51
+ // Config format served by /api/claude-actions
52
+ ClaudeActionsConfig {
53
+ version: string;
54
+ contextTemplate: { card: string; global: string };
55
+ commands: ClaudeCommand[];
56
+ }
57
+ ```
58
+
59
+ ## Key Functions
60
+
61
+ - `getStartupActions(commands, terminalClass, hasHistory)` - Commands for session start (new/resume/any states)
62
+ - `getActiveActions(commands, terminalClass)` - Commands for toolbar while running (active/any states)
63
+ - `renderTemplate(template, context)` - Handles {{var}}, {{#if}}, {{#each}}
64
+ - `buildPrompt(contextTemplate, actionPrompt, context)` - Combines context + task sections
65
+
66
+ ## Template Syntax
67
+
68
+ - `{{var}}` - Simple substitution
69
+ - `{{obj.prop}}` - Nested property access (e.g., `{{card.title}}`)
70
+ - `{{#if var}}...{{/if}}` - Conditional block
71
+ - `{{#each arr}}...{{this}}...{{/each}}` - Array iteration
72
+
73
+ ## Context Objects
74
+
75
+ Card context: `{ project, projectPath, card, stage, problems[] }`
76
+ Global context: `{ project, projectPath }`
77
+
78
+ ## Command Groups
79
+
80
+ - **Card Actions** - Stage-specific workflows (Onboard, Design Doc, Implement, Debug, etc.)
81
+ - **Session** - Continue, Summarize (for resume state)
82
+ - **Project** - Explore, New Card (for project-level terminals)
83
+ - **Utilities** - Compact, Clear, Checkpoint, Context, Show Card
84
+ - **Problems** - Log Problem, Triage Problems, Fix Issues
85
+ - **Action Assistant** - Configure, Update Priming (for action-assistant terminal class)
86
+
87
+ ### Additional Commands
88
+ - **Chore Plan** - Create maintenance/bug fix plan from card
89
+
90
+ ## Session States
91
+
92
+ - `new` - No history, shown for fresh start
93
+ - `resume` - Has history, shown when resuming (Continue, Summarize)
94
+ - `active` - Shown in toolbar when terminal is running
95
+ - `any` - Always shown regardless of state
96
+
97
+ ## Command Flow
98
+
99
+ 1. **No session**: Show `startupCommands` (new + any states) as buttons
100
+ 2. **Has history**: Show Resume button + `startupCommands` (new + any) for fresh start options
101
+ 3. **Running**: Show `activeCommands` (active + any states) in footer toolbar
102
+
103
+ ## Patterns & Invariants
104
+
105
+ - Commands filtered by: terminalClass + sessionState
106
+ - Startup commands: sessionState in ['new', 'resume', 'any'] based on hasHistory
107
+ - Active commands: sessionState in ['active', 'any']
108
+ - MAX_VISIBLE_ACTIONS = 6, overflow goes to "..." menu
109
+ - Context button (id: 'context') appends card.areas to command
110
+ - Show Card button (id: 'show-card') appends cardId
111
+ - Shift+click on active command inserts without submitting
112
+
113
+ ## When to Expand
114
+
115
+ - Adding new commands → data/sly-actions.json
116
+ - Changing filter logic → getStartupActions/getActiveActions in sly-actions.ts
117
+ - Template issues → renderTemplate() in sly-actions.ts
118
+ - UI for commands → ClaudeTerminalPanel.tsx
119
+ - Terminal class definitions → documentation/terminal-classes.json
120
+ - Command configuration UI → SlyActionConfigModal.tsx
@@ -0,0 +1,177 @@
1
+ # Messaging Service
2
+
3
+ Updated: 2026-02-14
4
+
5
+ ## Overview
6
+
7
+ Multi-channel messaging service for remote AI interaction via Telegram (and future channels). Supports text and voice messages, project selection, voice swapping, response mode/tone preferences, multi-provider support (Claude/Gemini/Codex), stop command for session interruption, permission mismatch detection, context-aware command filtering, and two-way communication with AI sessions through the terminal bridge. Runs as a standalone Node/Express service with a CLI for outbound messages.
8
+
9
+ ## Key Files
10
+
11
+ ### Service Core
12
+ - `messaging/src/index.ts` - Main entry, channel wiring, HTTP server, bot commands, stop interception
13
+ - `messaging/src/types.ts` - Channel interface, configs, bridge types, ResponseMode
14
+ - `messaging/src/state.ts` - StateManager: project selection, voice state, response mode, voice tone, provider selection, persistence
15
+ - `messaging/src/bridge-client.ts` - BridgeClient: session management, provider-aware creation, permission mismatch detection, activity watching, soft stop
16
+
17
+ ### Channels
18
+ - `messaging/src/channels/telegram.ts` - TelegramChannel: bot polling, inline buttons, chat actions
19
+
20
+ ### Voice Pipeline
21
+ - `messaging/src/stt.ts` - Whisper STT via OpenAI API
22
+ - `messaging/src/tts.ts` - ElevenLabs v3 TTS with audio tag support, optional voice override
23
+ - `messaging/src/voices.ts` - Voice search across personal + community library (v2 + v1 APIs)
24
+
25
+ ### Command System
26
+ - `messaging/src/command-filter.ts` - Context-aware command filtering by terminal class, session state, card type
27
+ - `messaging/src/kanban-client.ts` - Direct access to project kanban boards for card metadata
28
+
29
+ ### CLI & Skill
30
+ - `messaging/src/cli.ts` - CLI tool for sending text/voice from Claude skills
31
+ - `.claude/skills/messaging/SKILL.md` - Skill definition (v2.2.0) with mode/tone system and audio tags
32
+
33
+ ### Config
34
+ - `messaging/package.json` - Dependencies: node-telegram-bot-api, openai, express, dotenv
35
+ - `messaging/tsconfig.json` - TypeScript config (ESM, ES2022)
36
+ - `.env` - Runtime config (tokens, API keys, ports)
37
+
38
+ ## Channel Interface
39
+
40
+ ```typescript
41
+ Channel {
42
+ name: string;
43
+ start(): Promise<void>;
44
+ stop(): void;
45
+ onText(handler): void;
46
+ onVoice(handler): void;
47
+ onCommand(command, handler): void;
48
+ onProjectSelect(handler): void;
49
+ sendText(text): Promise<void>; // With Markdown
50
+ sendTextRaw(text): Promise<void>; // Without Markdown (preserves [brackets])
51
+ sendVoice(audio: Buffer): Promise<void>;
52
+ sendProjectList(projects): Promise<void>;
53
+ sendTyping(): Promise<void>;
54
+ sendChatAction(action): Promise<void>;
55
+ sendVoiceList?(voices): Promise<void>; // Optional
56
+ onVoiceSelect?(handler): void; // Optional
57
+ isReady(): boolean;
58
+ }
59
+ ```
60
+
61
+ ## Bot Commands
62
+
63
+ - `/start` - Help text with available commands
64
+ - `/projects` - Inline keyboard for project selection
65
+ - `/select N` - Select project by number
66
+ - `/status` - Current project, voice, response mode, and tone
67
+ - `/voice` - Search/swap TTS voices, reset to default
68
+ - `/voice <name>` - Search voices, auto-select on exact match, inline buttons for multiple
69
+
70
+ ## Message Flow
71
+
72
+ ### Inbound (user → Claude)
73
+ 1. User sends text/voice on Telegram
74
+ 2. **Stop interception**: "stop" text (case-insensitive) sends Escape to active session instead of forwarding
75
+ 3. TelegramChannel routes to handler in index.ts
76
+ 4. Voice: `record_voice` chat action → Whisper transcription → typing indicator
77
+ 5. BridgeClient.ensureSession() creates/finds session (with selected provider, always skipPermissions)
78
+ 6. If permission mismatch (existing session without skipPermissions), warns user and offers restart
79
+ 7. BridgeClient.sendMessage() writes text + CR to PTY
80
+ 8. BridgeClient.watchActivity() polls /stats, sends typing while active
81
+
82
+ ### Outbound (Claude → user)
83
+ 1. Claude skill calls CLI: `tsx cli.ts send "message" [--tts]`
84
+ 2. CLI POSTs to HTTP server `/send` or `/voice`
85
+ 3. `/send` → channel.sendText()
86
+ 4. `/voice` → `upload_voice` chat action → TTS generation → channel.sendVoice() + sendTextRaw()
87
+
88
+ ### Stop Command
89
+ 1. User sends "stop" (exact, case-insensitive)
90
+ 2. BridgeClient.stopSession() calls `POST /sessions/:name/stop` (sends Escape key)
91
+ 3. Returns feedback: "Interrupted active session" or "Already stopped"
92
+ 4. Message NOT forwarded as a prompt
93
+
94
+ ## Response Mode System
95
+
96
+ - **Mode**: `text` | `voice` | `both` - determines response format
97
+ - `text` - Text replies only (default)
98
+ - `voice` - Voice messages with text companion
99
+ - `both` - Both voice and text responses
100
+ - **Tone**: Free-text description of voice style and length
101
+ - Mode shown in message footer: `(Reply using /messaging | Mode: text)`
102
+ - Persisted in messaging-state.json
103
+
104
+ ## Command Filtering
105
+
106
+ - `CommandFilter.loadCommands()` - Hot-reloads commands.json on each call
107
+ - `CommandFilter.filterCommands(terminalClass, sessionState, cardType?)` - Context-aware filtering
108
+ - `CommandFilter.resolveTemplate(prompt, context)` - Template variable resolution
109
+ - `CommandFilter.getTerminalClass(target)` - Maps navigation target to terminal class
110
+ - Supports card context from KanbanClient for prompt templates
111
+
112
+ ## Kanban Client
113
+
114
+ - `KanbanClient.getBoard(projectId)` - Load project's kanban board
115
+ - `KanbanClient.getCard(projectId, cardId)` - Find card with its stage
116
+ - `KanbanClient.getCardsByStage(projectId, stage)` - Cards in a stage
117
+ - Resolves kanban.json paths per project
118
+
119
+ ## Voice System
120
+
121
+ - **STT**: OpenAI Whisper (`whisper-1`), accepts OGG from Telegram
122
+ - **TTS**: ElevenLabs v3 (`eleven_v3`), supports `[tag]` audio tags
123
+ - **Voice selection**: Persisted in messaging-state.json, overrides .env default
124
+ - **Voice search**: Queries both `/v2/voices` (personal) and `/v1/shared-voices` (community), deduplicates
125
+ - **Conversion**: ffmpeg MP3→OGG/Opus for Telegram compatibility
126
+
127
+ ## Provider Support
128
+
129
+ - `StateManager.selectedProvider` - Persisted provider choice (default: 'claude')
130
+ - Session names include provider segment: `{projectId}:{provider}:global`
131
+ - `getLegacySessionName()` provides backward-compat format for existing session lookups
132
+ - Messaging always forces `skipPermissions: true` (remote interaction can't approve prompts)
133
+ - `BridgeClient.ensureSession()` returns `{ session, permissionMismatch? }` — detects sessions started from web UI without skip-permissions
134
+ - `BridgeClient.restartSession()` stops old session and creates fresh one with correct provider + skip-permissions
135
+
136
+ ## State Persistence
137
+
138
+ `messaging-state.json` stores:
139
+ - `selectedProjectId` - Active project
140
+ - `selectedProvider` - Active AI provider (claude/gemini/codex)
141
+ - `voiceId` / `voiceName` - Selected TTS voice (null = use .env default)
142
+ - `responseMode` - text/voice/both preference
143
+ - `voiceTone` - Free-text tone description
144
+
145
+ Projects loaded from `projects/registry.json` at startup.
146
+
147
+ ## HTTP Endpoints
148
+
149
+ - `POST /send` - Send text message to active channel
150
+ - `POST /voice` - Generate TTS and send voice + text to channel
151
+ - `GET /health` - Service health check (channel name, ready state)
152
+
153
+ ## Patterns & Invariants
154
+
155
+ - Chat actions for status: `record_voice` (transcribing), `typing` (processing), `upload_voice` (TTS)
156
+ - Session names include provider: `{projectId}:{provider}:global` (with legacy fallback)
157
+ - Messages include channel header: `[Telegram] text (Reply using /messaging | Mode: text)`
158
+ - Voice messages: `[Telegram/Voice] transcription (Reply using /messaging | Mode: text)`
159
+ - sendTextRaw used for voice text companions (preserves [audio tags]) and voice IDs
160
+ - Authorization: single authorized user ID per Telegram bot
161
+ - Telegram message limit: 4096 chars, auto-split at newline boundaries
162
+ - "stop" text intercepted before forwarding to session (soft stop via Escape key)
163
+ - Card titles truncated to 35 chars in breadcrumb rendering
164
+
165
+ ## When to Expand
166
+
167
+ - Adding new channel → implement Channel interface, add to createChannel() in index.ts
168
+ - Voice issues → tts.ts (generation), voices.ts (search), stt.ts (transcription)
169
+ - Bot command issues → index.ts setupChannel()
170
+ - Bridge routing → bridge-client.ts
171
+ - State persistence → state.ts
172
+ - Telegram-specific behavior → channels/telegram.ts
173
+ - Command filtering → command-filter.ts, kanban-client.ts
174
+ - Stop command → bridge-client.ts stopSession(), index.ts stop interception
175
+ - Response modes → state.ts, SKILL.md mode/tone guidelines
176
+ - Provider selection → state.ts (selectedProvider), bridge-client.ts (ensureSession provider param)
177
+ - Permission mismatch → bridge-client.ts ensureSession/sendMessage permissionMismatch detection
@@ -0,0 +1,138 @@
1
+ # Scripts & Deployment
2
+
3
+ Updated: 2026-02-11
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
+
21
+ ## Port Architecture
22
+
23
+ Two separate port ranges — dev and prod never overlap:
24
+
25
+ | Service | Dev port | Prod port | Env var |
26
+ |---------|----------|-----------|---------|
27
+ | Web | 3003 | 7591 | `WEB_PORT` |
28
+ | Bridge | 3004 | 7592 | `BRIDGE_PORT` |
29
+ | Messaging | 3005 | 7593 | `MESSAGING_SERVICE_PORT` |
30
+
31
+ - **7591/2/3**: "sly" = 759 on a phone keypad
32
+ - **Dev ports**: hardcoded in each service's `package.json` dev scripts
33
+ - **Prod ports**: configured in `.env`, read by `sly-start.sh`, passed as `PORT` env var to `npm start`
34
+ - `BRIDGE_URL` must match bridge port — `sly-start.sh` derives it automatically
35
+ - Next.js reads `PORT` env var natively (no `--port` flag in prod `npm start`)
36
+
37
+ ## Process Management
38
+
39
+ ### Production (`sly-start.sh` / `sly-stop.sh`)
40
+
41
+ - **Start**: runs `npm start` in background with `nohup` (assumes services are already built via `setup.sh`)
42
+ - **Stop**: finds PIDs by port (not PID files — those are unreliable with npm subshells), kills process tree with `pkill -P` + `kill`
43
+ - Ports file at `~/.slycode/ports` records which ports were started for stop to read
44
+ - Health check after start: verifies each port is listening
45
+ - Log files: `~/.slycode/logs/{web,bridge,messaging}.log` with 10MB rotation
46
+
47
+ ### Dev (`sly-dev.sh`)
48
+
49
+ - Creates tmux session "sly" with three horizontal panes
50
+ - Each pane runs `npm run dev` in its service directory
51
+ - `session-closed` hook calls `sly-stop.sh` to prevent zombie processes
52
+ - If session already exists, just attaches
53
+ - Switch panes: `Ctrl-b` + arrows. Zoom: `Ctrl-b z`
54
+
55
+ ### Platform Services (optional, via `setup.sh`)
56
+
57
+ - **Linux**: systemd user services (`~/.config/systemd/user/slycode-{web,bridge,messaging}.service`)
58
+ - **macOS**: launchd user agents (`~/Library/LaunchAgents/com.slycode.{web,bridge,messaging}.plist`)
59
+ - `sly-start.sh` / `sly-stop.sh` detect installed services and use them instead of background processes
60
+ - `setup.sh --service` installs, `setup.sh --remove-service` removes
61
+
62
+ ## Setup Flow (`setup.sh`)
63
+
64
+ 1. Welcome banner (platform, SlyCode root, Node version)
65
+ 2. Create directories (`~/bin`, `~/.slycode/logs`)
66
+ 3. `npm install` in web, bridge, messaging
67
+ 4. Build bridge, messaging, web (web last — heaviest, needs most memory)
68
+ 5. `chmod +x` on CLI scripts
69
+ 6. Symlink CLIs to `~/bin` (sly-kanban, sly-scaffold, sly-messaging)
70
+ 7. Update `registry.json` with correct SlyCode path
71
+ 8. Copy `.env.example` to `.env` if missing
72
+ 9. Prompt: install as system service?
73
+ 10. Linux: check linger, offer to enable
74
+
75
+ **Flags**: `--yes` (non-interactive), `--service` (auto-install services), `--remove-service` (cleanup)
76
+
77
+ ## Global CLIs
78
+
79
+ Symlinked to `~/bin` by `setup.sh`:
80
+
81
+ | Command | Target | Type |
82
+ |---------|--------|------|
83
+ | `sly-kanban` | `scripts/kanban.js` | Standalone Node.js |
84
+ | `sly-scaffold` | `scripts/scaffold.js` | Standalone Node.js |
85
+ | `sly-messaging` | `messaging/dist/cli.js` | Built from TypeScript |
86
+
87
+ ### CLI Port Detection (`sly-messaging`)
88
+
89
+ The CLI auto-detects which mode (dev/prod) the messaging service is running in:
90
+
91
+ 1. Read cached port from `~/.slycode/messaging-port` (if exists), try it first
92
+ 2. Probe dev port (3005) then prod port (7593) via `/health`
93
+ 3. Cache the successful port for next time
94
+
95
+ 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.
96
+
97
+ ## Key Design Decisions
98
+
99
+ ### No hardcoded paths anywhere
100
+ - Web: `web/src/lib/paths.ts` derives SlyCode root from `process.cwd()` (detects `/web` suffix)
101
+ - Bridge: reads `BRIDGE_PORT` from env
102
+ - Messaging: CLI auto-detects service port (dev 3005 / prod 7593) with caching; service reads port from env
103
+ - Skills: reference `sly-kanban` and `sly-messaging` by global command name, not paths
104
+ - Documentation: uses `<slycode-root>` placeholder instead of absolute paths
105
+ - `registry.json`: `setup.sh` updates the SlyCode path entry at install time
106
+
107
+ ### Stop by port, not PID files
108
+ 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.
109
+
110
+ ### Build in setup, not start
111
+ `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.
112
+
113
+ ### XDG_RUNTIME_DIR fix
114
+ 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.
115
+
116
+ ### bridge-sessions.json protection
117
+ - Path resolved via `__dirname` (never relative — avoids reading wrong file from wrong cwd)
118
+ - Only starts fresh on ENOENT (file doesn't exist = first run)
119
+ - Any other read error crashes loudly instead of silently wiping session data
120
+ - Saves are atomic (write `.tmp` then `rename`)
121
+
122
+ ### Bridge CWD validation
123
+ Bridge requires absolute path for session `cwd` — no defaults, no relative paths. This ensures Claude associates sessions with the correct project directory in `~/.claude/projects/`.
124
+
125
+ ## Env Files
126
+
127
+ - **`.env.example`**: template with all config vars, prod port defaults, placeholder secrets
128
+ - **`.env`**: actual config, created from example by `setup.sh`, gitignored
129
+ - `.env` lives at repo root — messaging loads it via `dotenv`, bridge reads env vars, web gets them via `sly-start.sh` exports
130
+
131
+ ## Related Files
132
+
133
+ - `documentation/designs/global_cli_setup.md` — full design document
134
+ - `documentation/features/020_global_cli_setup.md` — 9-phase implementation plan
135
+ - `web/src/lib/paths.ts` — runtime path resolution for web app
136
+ - `bridge/src/session-manager.ts` — session persistence, CWD validation
137
+ - `bridge/bridge-sessions.json` — persisted session state (NEVER wipe)
138
+ - `.env.example` / `.env` — environment configuration
@@ -0,0 +1,135 @@
1
+ # Skills & Infrastructure
2
+
3
+ Updated: 2026-02-09
4
+
5
+ ## Overview
6
+
7
+ ClaudeMaster 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.
8
+
9
+ ## Key Files
10
+
11
+ ### 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 skill
18
+
19
+ ### Agents
20
+ - `.claude/agents/doc-updater.md` - Autonomous documentation maintenance agent
21
+
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
+
34
+ ### Scripts
35
+ - `scripts/setup.sh` - Guided setup: environment, services, global CLI, linger
36
+ - `scripts/sly-start.sh` - Start all services (web, bridge, messaging)
37
+ - `scripts/sly-stop.sh` - Stop all services
38
+ - `scripts/sly-restart.sh` - Restart all services
39
+ - `scripts/sly-dev.sh` - Development mode launcher
40
+ - `scripts/kanban.js` - Kanban CLI tool (installed globally as `sly-kanban`)
41
+ - `scripts/scaffold.js` - Project scaffolding CLI (installed globally as `sly-scaffold`)
42
+
43
+ ### 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`
46
+
47
+ ### Config
48
+ - `.claude/settings.local.json` - Local Claude settings
49
+ - `.mcp.json` - MCP server configuration (Context7, etc.)
50
+ - `.env` / `.env.example` - Environment config with service ports
51
+ - `CLAUDE.md` - Project instructions for Claude
52
+
53
+ ### Documentation
54
+ - `documentation/kanban.json` - Kanban card data
55
+ - `documentation/events.json` - Activity event log (card moves, asset operations, sessions)
56
+ - `documentation/terminal-classes.json` - Terminal class definitions
57
+ - `documentation/features/` - Feature specs (001-020)
58
+ - `documentation/chores/` - Chore plans (active + completed/)
59
+ - `documentation/designs/` - Design documents
60
+ - `documentation/reference/` - Reference documentation
61
+
62
+ ## Skill Structure
63
+
64
+ ```
65
+ .claude/skills/{skill-name}/
66
+ ├── SKILL.md # Main skill definition, invocation rules
67
+ └── references/ # Supporting docs, templates, examples
68
+ ```
69
+
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
+ ```
81
+
82
+ ## Global CLI Commands
83
+
84
+ After `scripts/setup.sh`, these are available globally:
85
+ - `sly-kanban` - Kanban board management
86
+ - `sly-messaging` - Send messages via messaging channels
87
+ - `sly-scaffold` - Project scaffolding
88
+
89
+ ## Service Management
90
+
91
+ - `scripts/sly-start.sh` - Start all services (web on 7591, bridge on 7592, messaging on 7593)
92
+ - `scripts/sly-stop.sh` - Stop all services
93
+ - `scripts/setup.sh --service` - Install as persistent system services
94
+ - `scripts/setup.sh --remove-service` - Remove persistent services
95
+
96
+ ## Environment Variables (.env.example)
97
+
98
+ - **Ports**: WEB_PORT=7591, BRIDGE_PORT=7592, MESSAGING_SERVICE_PORT=7593
99
+ - **Bridge**: BRIDGE_URL for bridge connection
100
+ - **Telegram**: TELEGRAM_BOT_TOKEN, TELEGRAM_AUTHORIZED_USER_ID
101
+ - **STT**: OPENAI_API_KEY (Whisper)
102
+ - **TTS**: ELEVENLABS_API_KEY, ELEVENLABS_VOICE_ID, ELEVENLABS_VOICE_SPEED
103
+
104
+ ## Hooks
105
+
106
+ - `web/src/hooks/useKeyboardShortcuts.ts` - Number keys 1-9 for project navigation, Escape
107
+ - `web/src/hooks/useCommandsConfig.ts` - Polling-based commands config (30s)
108
+ - `web/src/hooks/useConnectionStatus.ts` - SSE connection state
109
+ - `web/src/hooks/usePolling.ts` - Generic polling hook
110
+
111
+ ## Patterns & Invariants
112
+
113
+ - Skills use semantic versioning (MAJOR.MINOR.PATCH)
114
+ - Always update version and date when modifying skills/commands
115
+ - Commands invoked via `/command-name` shorthand
116
+ - CLAUDE.md applies to entire project, overrides defaults
117
+ - MCP servers configured in .mcp.json (Context7 for docs)
118
+ - Event log in documentation/events.json tracks card moves, asset ops, sessions (500 cap)
119
+
120
+ ## Environment
121
+
122
+ - `CLAUDE_ENV` - 'home' or 'work' for environment detection
123
+ - Projects tracked in `projects/registry.json`
124
+
125
+ ## When to Expand
126
+
127
+ - Creating new skill → skill-creator skill, .claude/skills/
128
+ - Creating new command → create-command, .claude/commands/
129
+ - Creating new agent → .claude/agents/
130
+ - Modifying Claude behavior → CLAUDE.md
131
+ - Adding MCP servers → .mcp.json
132
+ - Service management → scripts/sly-*.sh
133
+ - Setup/installation → scripts/setup.sh
134
+ - Project scaffolding → scripts/scaffold.js, data/scaffold-templates/
135
+ - Activity events → documentation/events.json, web/src/lib/event-log.ts