@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,43 @@
1
+ ---
2
+ name: checkpoint
3
+ version: 1.3.1
4
+ updated: 2026-02-22
5
+ allowed-tools: Bash, Read
6
+ argument-hint: [optional commit message]
7
+ description: Create a git checkpoint of ALL recent changes
8
+ ---
9
+
10
+ # Git Checkpoint Creation
11
+
12
+ Create a checkpoint commit of ALL uncommitted changes in the repository.
13
+
14
+ ## Process
15
+
16
+ 1. **Check status**: Run `git status --short` to see all changes
17
+ 2. **Analyze changes**: For each modified/added file, briefly review what changed using `git diff <file> | head -50` or read new files
18
+ 3. **Stage everything**: Run `git add -A` to stage ALL changes (modified, new, and deleted files)
19
+ 4. **Write commit message**: Based on analysis, write a clear commit message that:
20
+ - Has a concise summary line (under 72 chars)
21
+ - Lists key changes as bullet points
22
+ - Groups related changes together
23
+ 5. **Commit**: Create the commit with the message
24
+
25
+ ## Important Rules
26
+
27
+ - **Commit EVERYTHING**: Do not selectively pick files. All uncommitted changes should be included.
28
+ - **Analyze first**: Read diffs or file contents to understand what changed before writing the commit message.
29
+ - **Be descriptive**: The commit message should explain WHAT was done, not just list file names.
30
+ - **No AI attribution**: Do not include "Co-Authored-By: Claude" or similar.
31
+
32
+ ## Example Commit Message Format
33
+
34
+ ```
35
+ Summary of changes in imperative mood
36
+
37
+ - Add feature X with support for Y
38
+ - Fix bug in Z where condition was wrong
39
+ - Update config to enable new option
40
+ - Refactor module for better performance
41
+ ```
42
+
43
+ If an optional message argument is provided, use it as the summary line.
@@ -0,0 +1,152 @@
1
+ ---
2
+ name: context-priming
3
+ version: 1.1.1
4
+ updated: 2026-02-22
5
+ description: Dynamic context provider for codebase knowledge. This skill should be used when working on code, answering questions about architecture, or making changes that require understanding of project structure. Maintains area-specific reference files that are loaded on demand. Self-updating based on observed drift between references and actual code. Load this skill early in work sessions - it contains essential workflow and update protocols.
6
+ ---
7
+
8
+ # Context Priming
9
+
10
+ Provide dynamic, accurate context about this project's architecture and code. Load knowledge on demand, update when drift is observed, self-improve based on experience.
11
+
12
+ ## When to Invoke
13
+
14
+ **Load context when:**
15
+ - Starting work requiring codebase knowledge not in current conversation
16
+ - Making changes to unfamiliar areas
17
+ - Answering questions about project architecture or patterns
18
+ - User asks about functionality and current context is insufficient
19
+
20
+ **Do NOT load when:**
21
+ - Information is clearly present from last 3-5 exchanges
22
+ - Task is trivial and doesn't require architectural understanding
23
+ - Already loaded relevant areas in this session (unless significant time/work has passed)
24
+
25
+ ## How to Use
26
+
27
+ 1. **Load area-index.md first** - understand available areas, their update dates, load-when triggers
28
+ 2. **Load relevant area(s)** - based on current task and index guidance
29
+ 3. **Follow area's "when to expand"** - each area indicates when to open specific files
30
+ 4. **Evaluate freshness** - compare area's `updated` date against today (from system prompt); consider git activity if concerned
31
+
32
+ ## Callouts
33
+
34
+ Prefix operational updates with `Priming:` to signal skill activity. Keep brief - one line.
35
+
36
+ **When to call out:**
37
+ - Loading an area: `Priming: Loading backend - API work detected.`
38
+ - Loading multiple: `Priming: This spans backend and database areas, loading both.`
39
+ - Staleness concern: `Priming: backend looks stale (Nov 20), will verify as I go.`
40
+ - Making a note: `Priming: Quick note added - auth order matters.`
41
+ - Skipping load: `Priming: Already have frontend context from earlier.`
42
+
43
+ **Don't call out:** Every file read, minor internal decisions, routine checks.
44
+
45
+ ## Update Behavior
46
+
47
+ | Situation | Action |
48
+ |-----------|--------|
49
+ | Loaded info contradicts code in misleading way | Update reference in stride |
50
+ | Minor drift, no practical impact | Let it slide |
51
+ | Unsure if update needed | Note concern, ask at end of task |
52
+ | Multiple areas need restructuring | Consult user before proceeding |
53
+ | New feature added affecting an area | Update area reference |
54
+ | User says "context priming needs to know this" | Capture in relevant area |
55
+ | User says "you should have known this" | Analyze failure, propose fix (see below) |
56
+
57
+ **Small updates**: Make concisely, in stride, no announcement needed.
58
+ **Large restructuring/defrag**: Consult first. See `references/maintenance.md`.
59
+
60
+ ## "You Should Have Known" Response
61
+
62
+ When user indicates priming failed:
63
+
64
+ 1. **Identify cause**: Which of these?
65
+ - Area not loaded when it should have been (bad load-when criteria)
66
+ - Area loaded but info missing (incomplete reference)
67
+ - Info existed but outdated (stale reference)
68
+ - Area doesn't exist (missing area)
69
+ - Judgment call to skip loading was wrong (bad heuristic)
70
+
71
+ 2. **Propose fix** based on cause:
72
+ - Content/index updates → do in stride
73
+ - SKILL.md or maintenance.md changes → explain problem, propose change, await approval
74
+
75
+ 3. **Surface immediately** - don't wait for task end. User will indicate if disruptive.
76
+
77
+ ## Permission Model
78
+
79
+ | File | Permission |
80
+ |------|------------|
81
+ | references/areas/*.md | Update in stride |
82
+ | references/area-index.md | Update in stride |
83
+ | Add/remove/split areas | Suggest, light confirmation |
84
+ | SKILL.md | Explain, propose, await approval |
85
+ | references/maintenance.md | Explain, propose, await approval |
86
+
87
+ ## Git Usage
88
+
89
+ Use `git diff` or `git log` sparingly:
90
+ - Before major refactors to verify scope
91
+ - When user questions accuracy of loaded info
92
+ - To check activity since area's last update date when staleness suspected
93
+
94
+ Not for routine small changes.
95
+
96
+ ## Context Compaction
97
+
98
+ No direct visibility into remaining context space. When user flags compaction is imminent, or after long exploration sessions: consider if valuable learnings should be captured before context is summarized.
99
+
100
+ ## Self-Improvement
101
+
102
+ Area notes (in area-index.md) capture learnings:
103
+ - Up to 10 notes per area, quality over quantity
104
+ - Format: actionable guidance ("when X, do Y" or "don't assume Z")
105
+ - Remove notes that no longer apply
106
+ - If skill behavior is flawed, suggest improvement to user
107
+
108
+ If suggestion timing/frequency becomes disruptive, user will indicate - adjust accordingly.
109
+
110
+ ## Operational Principles
111
+
112
+ - Concise updates: prefer short phrase tweaks over paragraph additions
113
+ - Don't bloat references - information density is the goal
114
+ - When on fence about loading, lean toward loading
115
+ - Trust the index's load-when triggers; refine them when wrong
116
+ - No hardcoded "status" - freshness is evaluated dynamically
117
+
118
+ ## Skill Location & Cross-Provider Note
119
+
120
+ **Canonical path (relative to project root):**
121
+ ```
122
+ .claude/skills/context-priming/
123
+ ├── SKILL.md # This file
124
+ ├── references/
125
+ │ ├── area-index.md # Index of all areas (load first)
126
+ │ ├── maintenance.md # Defrag, pruning, area separation doctrine
127
+ │ └── areas/
128
+ │ └── [name].md # Deep reference per area
129
+ ```
130
+
131
+ **Resolution order — try these paths in order, use the first that exists:**
132
+
133
+ 1. **Primary:** `<project-root>/.claude/skills/context-priming/` — the canonical, most up-to-date copy. Always check here first.
134
+ 2. **Fallback:** The directory containing this SKILL.md (i.e. your own skill folder). If there is no `.claude/` directory in the project, the references were likely copied alongside this file.
135
+
136
+ This matters when the skill is deployed to another provider (Codex at `.agents/skills/`, Gemini at `.gemini/skills/`). Those folders may contain just this SKILL.md for discovery, with the area files living in `.claude/`. But if the project has no `.claude/` directory at all (e.g. a pure Codex or Gemini project), fall back to reading from your own skill directory.
137
+
138
+ **Resolved paths (primary):**
139
+ - **Area index:** `<project-root>/.claude/skills/context-priming/references/area-index.md`
140
+ - **Area files:** `<project-root>/.claude/skills/context-priming/references/areas/<name>.md`
141
+ - **Maintenance:** `<project-root>/.claude/skills/context-priming/references/maintenance.md`
142
+
143
+ **Resolved paths (fallback — relative to this SKILL.md):**
144
+ - **Area index:** `./references/area-index.md`
145
+ - **Area files:** `./references/areas/<name>.md`
146
+ - **Maintenance:** `./references/maintenance.md`
147
+
148
+ ## Files
149
+
150
+ - `references/area-index.md` - compact index of all areas
151
+ - `references/maintenance.md` - defrag, pruning, area separation doctrine
152
+ - `references/areas/[name].md` - deep reference per area
@@ -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