@tekmidian/pai 0.3.2 → 0.4.0
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/cli/index.mjs +279 -21
- package/dist/cli/index.mjs.map +1 -1
- package/dist/hooks/capture-all-events.mjs +238 -0
- package/dist/hooks/capture-all-events.mjs.map +7 -0
- package/dist/hooks/capture-session-summary.mjs +198 -0
- package/dist/hooks/capture-session-summary.mjs.map +7 -0
- package/dist/hooks/capture-tool-output.mjs +105 -0
- package/dist/hooks/capture-tool-output.mjs.map +7 -0
- package/dist/hooks/cleanup-session-files.mjs +129 -0
- package/dist/hooks/cleanup-session-files.mjs.map +7 -0
- package/dist/hooks/context-compression-hook.mjs +283 -0
- package/dist/hooks/context-compression-hook.mjs.map +7 -0
- package/dist/hooks/initialize-session.mjs +206 -0
- package/dist/hooks/initialize-session.mjs.map +7 -0
- package/dist/hooks/load-core-context.mjs +110 -0
- package/dist/hooks/load-core-context.mjs.map +7 -0
- package/dist/hooks/load-project-context.mjs +548 -0
- package/dist/hooks/load-project-context.mjs.map +7 -0
- package/dist/hooks/security-validator.mjs +159 -0
- package/dist/hooks/security-validator.mjs.map +7 -0
- package/dist/hooks/stop-hook.mjs +625 -0
- package/dist/hooks/stop-hook.mjs.map +7 -0
- package/dist/hooks/subagent-stop-hook.mjs +152 -0
- package/dist/hooks/subagent-stop-hook.mjs.map +7 -0
- package/dist/hooks/sync-todo-to-md.mjs +322 -0
- package/dist/hooks/sync-todo-to-md.mjs.map +7 -0
- package/dist/hooks/update-tab-on-action.mjs +90 -0
- package/dist/hooks/update-tab-on-action.mjs.map +7 -0
- package/dist/hooks/update-tab-titles.mjs +55 -0
- package/dist/hooks/update-tab-titles.mjs.map +7 -0
- package/package.json +4 -2
- package/scripts/build-hooks.mjs +51 -0
- package/src/hooks/ts/capture-all-events.ts +179 -0
- package/src/hooks/ts/lib/detect-environment.ts +53 -0
- package/src/hooks/ts/lib/metadata-extraction.ts +144 -0
- package/src/hooks/ts/lib/pai-paths.ts +124 -0
- package/src/hooks/ts/lib/project-utils.ts +914 -0
- package/src/hooks/ts/post-tool-use/capture-tool-output.ts +78 -0
- package/src/hooks/ts/post-tool-use/sync-todo-to-md.ts +230 -0
- package/src/hooks/ts/post-tool-use/update-tab-on-action.ts +145 -0
- package/src/hooks/ts/pre-compact/context-compression-hook.ts +155 -0
- package/src/hooks/ts/pre-tool-use/security-validator.ts +258 -0
- package/src/hooks/ts/session-end/capture-session-summary.ts +185 -0
- package/src/hooks/ts/session-start/initialize-session.ts +155 -0
- package/src/hooks/ts/session-start/load-core-context.ts +104 -0
- package/src/hooks/ts/session-start/load-project-context.ts +394 -0
- package/src/hooks/ts/stop/stop-hook.ts +407 -0
- package/src/hooks/ts/subagent-stop/subagent-stop-hook.ts +212 -0
- package/src/hooks/ts/user-prompt/cleanup-session-files.ts +45 -0
- package/src/hooks/ts/user-prompt/update-tab-titles.ts +88 -0
- package/tab-color-command.sh +24 -0
- package/templates/skills/createskill-skill.template.md +78 -0
- package/templates/skills/history-system.template.md +371 -0
- package/templates/skills/hook-system.template.md +913 -0
- package/templates/skills/sessions-skill.template.md +102 -0
- package/templates/skills/skill-system.template.md +214 -0
- package/templates/skills/terminal-tabs.template.md +120 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
<!-- Generated by PAI Setup -->
|
|
2
|
+
---
|
|
3
|
+
name: Sessions
|
|
4
|
+
description: Navigate and manage PAI sessions across all projects. USE WHEN user says "list sessions", "where was I working", "show my sessions", "find session", "continue work from", "switch to project", "open project", "name project", "group projects", "consolidate", "organize projects", "clean up sessions", "work on X", "start working on X", "show me what we did on X", "bring notes together", OR asks about past sessions, previous work, or project navigation.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## How Session Notes Work
|
|
8
|
+
|
|
9
|
+
Session notes track what was done in each Claude session. They live in a `Notes/` directory.
|
|
10
|
+
|
|
11
|
+
**The key concept: notes route to a project.** When the user says "work on PAI" or "start working on myproject", you set the routing so all session notes go to that project's Notes directory. The routing is stored in `~/.claude/session-routing.json`.
|
|
12
|
+
|
|
13
|
+
**Where notes actually live:**
|
|
14
|
+
- Each project has a Notes directory (usually in an Obsidian vault or local Notes folder)
|
|
15
|
+
- Code repos can symlink their `Notes/` to a vault path
|
|
16
|
+
- Claude also keeps internal copies in `~/.claude/projects/*/Notes/` (for search/history)
|
|
17
|
+
- The `pai` CLI manages everything
|
|
18
|
+
|
|
19
|
+
**Project paths** are stored in `~/.claude/session-routing.json` under `project_paths`. Add your own projects by editing that file.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## What the User Might Say → What You Do
|
|
24
|
+
|
|
25
|
+
**"Work on PAI" / "Start working on myproject" / "Let's do PAI stuff"**
|
|
26
|
+
→ Run `pai route <project-name>`. Tell user: "Notes now routing to [path]."
|
|
27
|
+
|
|
28
|
+
**"Show me the sessions where we worked on PAI" / "What did we do on myproject?"**
|
|
29
|
+
→ Run `pai search <project-name>`. Show the matching sessions with dates and summaries.
|
|
30
|
+
|
|
31
|
+
**"Bring the PAI notes together" / "Consolidate PAI sessions"**
|
|
32
|
+
→ Search for all sessions matching the project name across all projects. Read the session notes. Combine them into a coherent summary. Write a consolidated note if asked.
|
|
33
|
+
|
|
34
|
+
**"List sessions" / "Show recent sessions" / "/sessions"**
|
|
35
|
+
→ ALWAYS run `pai session active` FIRST to show currently open Claude Code tabs.
|
|
36
|
+
→ Then run `pai project list` and `pai session list` for the full overview.
|
|
37
|
+
→ Present active sessions PROMINENTLY at the top of your response.
|
|
38
|
+
|
|
39
|
+
**"Where are my notes going?" / "What's the current routing?"**
|
|
40
|
+
→ Run `pai route` (no args) to show current status.
|
|
41
|
+
|
|
42
|
+
**"Stop routing" / "Clear routing" / "Back to default"**
|
|
43
|
+
→ Run `pai route clear`.
|
|
44
|
+
|
|
45
|
+
**"Open the myproject project"**
|
|
46
|
+
→ Run `pai open <project-name> --claude` to open in a new terminal tab.
|
|
47
|
+
|
|
48
|
+
**"Continue work from the myproject project"**
|
|
49
|
+
→ Search for relevant sessions, read the notes and TODO.md, present context summary, continue working here.
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Commands Reference
|
|
54
|
+
|
|
55
|
+
| Command | What it does |
|
|
56
|
+
|---------|-------------|
|
|
57
|
+
| `pai session active` | **Show currently open Claude Code sessions** (checks JSONL timestamps) |
|
|
58
|
+
| `pai session active --minutes 120` | Widen the detection window (default: 60 min) |
|
|
59
|
+
| `pai session active --json` | JSON output for programmatic use |
|
|
60
|
+
| `pai` | Show all projects with session counts |
|
|
61
|
+
| `pai session list` | Detailed session list |
|
|
62
|
+
| `pai search "keyword"` | Find sessions by keyword |
|
|
63
|
+
| `pai route <project>` | Route notes to a project |
|
|
64
|
+
| `pai route` | Show current routing status |
|
|
65
|
+
| `pai route clear` | Stop routing, use defaults |
|
|
66
|
+
| `pai open <project> --claude` | Open project in new tab |
|
|
67
|
+
| `pai name "Name"` | Name the current project |
|
|
68
|
+
| `pai info <number>` | Deep dive into a project |
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Examples
|
|
73
|
+
|
|
74
|
+
**Example 1: "Show me what we did on PAI"**
|
|
75
|
+
```
|
|
76
|
+
→ Run: pai search pai
|
|
77
|
+
→ Show matching sessions with dates
|
|
78
|
+
→ Offer to read specific session notes for details
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**Example 2: "Let's work on myproject"**
|
|
82
|
+
```
|
|
83
|
+
→ Run: pai route myproject
|
|
84
|
+
→ Output: "Notes now routing to .../myproject/Notes"
|
|
85
|
+
→ Read myproject's TODO.md to see pending work
|
|
86
|
+
→ Continue from where we left off
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**Example 3: "Bring all the PAI sessions together"**
|
|
90
|
+
```
|
|
91
|
+
→ Run: pai search pai (find all PAI-related sessions)
|
|
92
|
+
→ Read each session note
|
|
93
|
+
→ Create a consolidated summary
|
|
94
|
+
→ Optionally write it to PAI's Notes directory
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**Example 4: "Where was I working on the appstore?"**
|
|
98
|
+
```
|
|
99
|
+
→ Run: pai search appstore
|
|
100
|
+
→ Show matching projects with session counts
|
|
101
|
+
→ Offer to open or read details
|
|
102
|
+
```
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
<!-- Generated by PAI Setup -->
|
|
2
|
+
# Custom Skill System
|
|
3
|
+
|
|
4
|
+
**The MANDATORY configuration system for ALL PAI skills.**
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## THIS IS THE AUTHORITATIVE SOURCE
|
|
9
|
+
|
|
10
|
+
This document defines the **required structure** for every skill in the PAI system.
|
|
11
|
+
|
|
12
|
+
**ALL skill creation MUST follow this structure.**
|
|
13
|
+
|
|
14
|
+
**"Canonicalize a skill"** = Restructure it to match this exact format, including TitleCase naming.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## TitleCase Naming Convention (MANDATORY)
|
|
19
|
+
|
|
20
|
+
**All naming in the skill system MUST use TitleCase (PascalCase).**
|
|
21
|
+
|
|
22
|
+
| Component | Wrong | Correct |
|
|
23
|
+
|-----------|-------|---------|
|
|
24
|
+
| Skill directory | `createskill`, `create-skill` | `Createskill` |
|
|
25
|
+
| Workflow files | `create.md`, `update-info.md` | `Create.md`, `UpdateInfo.md` |
|
|
26
|
+
| Reference docs | `prosody-guide.md` | `ProsodyGuide.md` |
|
|
27
|
+
| Tool files | `manage-server.ts` | `ManageServer.ts` |
|
|
28
|
+
| YAML name | `name: create-skill` | `name: Createskill` |
|
|
29
|
+
|
|
30
|
+
**Exception:** `SKILL.md` is always uppercase (convention for the main skill file).
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## The Required Structure
|
|
35
|
+
|
|
36
|
+
Every SKILL.md has two parts:
|
|
37
|
+
|
|
38
|
+
### 1. YAML Frontmatter (Single-Line Description)
|
|
39
|
+
|
|
40
|
+
```yaml
|
|
41
|
+
---
|
|
42
|
+
name: SkillName
|
|
43
|
+
description: [What it does]. USE WHEN [intent triggers using OR]. [Additional capabilities].
|
|
44
|
+
---
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**Rules:**
|
|
48
|
+
- `name` uses **TitleCase**
|
|
49
|
+
- `description` is a **single line** (not multi-line with `|`)
|
|
50
|
+
- `USE WHEN` keyword is **MANDATORY** (Claude Code parses this for skill activation)
|
|
51
|
+
- Use intent-based triggers with `OR` for multiple conditions
|
|
52
|
+
- Max 1024 characters (Anthropic hard limit)
|
|
53
|
+
|
|
54
|
+
### 2. Markdown Body
|
|
55
|
+
|
|
56
|
+
```markdown
|
|
57
|
+
# SkillName
|
|
58
|
+
|
|
59
|
+
[Brief description]
|
|
60
|
+
|
|
61
|
+
## Workflow Routing
|
|
62
|
+
|
|
63
|
+
**When executing a workflow, do BOTH of these:**
|
|
64
|
+
|
|
65
|
+
1. **Call the notification script** (for observability tracking):
|
|
66
|
+
```bash
|
|
67
|
+
~/.claude/Tools/SkillWorkflowNotification WORKFLOWNAME SKILLNAME
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
2. **Output the text notification** (for user visibility):
|
|
71
|
+
```
|
|
72
|
+
Running the **WorkflowName** workflow from the **SKILLNAME** skill...
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
This ensures workflows appear in the observability dashboard AND the user sees the announcement.
|
|
76
|
+
|
|
77
|
+
| Workflow | Trigger | File |
|
|
78
|
+
|----------|---------|------|
|
|
79
|
+
| **WorkflowOne** | "trigger phrase" | `workflows/WorkflowOne.md` |
|
|
80
|
+
| **WorkflowTwo** | "another trigger" | `workflows/WorkflowTwo.md` |
|
|
81
|
+
|
|
82
|
+
## Examples
|
|
83
|
+
|
|
84
|
+
**Example 1: [Common use case]**
|
|
85
|
+
```
|
|
86
|
+
User: "[Typical user request]"
|
|
87
|
+
→ Invokes WorkflowOne workflow
|
|
88
|
+
→ [What skill does]
|
|
89
|
+
→ [What user gets back]
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## [Additional Sections]
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Examples Section (REQUIRED)
|
|
98
|
+
|
|
99
|
+
**Every skill MUST have an `## Examples` section** showing 2-3 concrete usage patterns.
|
|
100
|
+
|
|
101
|
+
**Why Examples Matter:**
|
|
102
|
+
- Anthropic research shows examples improve tool selection accuracy from 72% to 90%
|
|
103
|
+
- Descriptions tell Claude WHEN to activate; examples show HOW the skill works
|
|
104
|
+
|
|
105
|
+
**Example Format:**
|
|
106
|
+
```markdown
|
|
107
|
+
## Examples
|
|
108
|
+
|
|
109
|
+
**Example 1: [Use case name]**
|
|
110
|
+
```
|
|
111
|
+
User: "[Actual user request]"
|
|
112
|
+
→ Invokes WorkflowName workflow
|
|
113
|
+
→ [What the skill does]
|
|
114
|
+
→ [What user receives back]
|
|
115
|
+
```
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## Intent Matching, Not String Matching
|
|
121
|
+
|
|
122
|
+
We use **intent matching**, not exact phrase matching.
|
|
123
|
+
|
|
124
|
+
**Example description:**
|
|
125
|
+
```yaml
|
|
126
|
+
description: Complete blog workflow. USE WHEN user mentions doing anything with their blog, website, site, including things like update, proofread, write, edit, publish, preview, blog posts, or website pages.
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**Key Principles:**
|
|
130
|
+
- Use intent language: "user mentions", "user wants to", "including things like"
|
|
131
|
+
- Don't list exact phrases in quotes
|
|
132
|
+
- Cover the domain conceptually
|
|
133
|
+
- Use `OR` to combine multiple trigger conditions
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Directory Structure
|
|
138
|
+
|
|
139
|
+
Every skill follows this structure:
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
SkillName/ # TitleCase directory name
|
|
143
|
+
├── SKILL.md # Main skill file (always uppercase)
|
|
144
|
+
├── ReferenceDoc.md # Optional: Reference docs (TitleCase)
|
|
145
|
+
├── tools/ # CLI tools (ALWAYS present, even if empty)
|
|
146
|
+
│ ├── ToolName.ts # TypeScript CLI tool (TitleCase)
|
|
147
|
+
│ └── ToolName.help.md # Tool documentation (TitleCase)
|
|
148
|
+
└── workflows/
|
|
149
|
+
├── Create.md # Work execution workflow (TitleCase)
|
|
150
|
+
└── Update.md # Work execution workflow (TitleCase)
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## Workflows vs Reference Documentation
|
|
156
|
+
|
|
157
|
+
**CRITICAL DISTINCTION:**
|
|
158
|
+
|
|
159
|
+
### Workflows (`workflows/` directory)
|
|
160
|
+
- Operational procedures (create, update, delete, deploy)
|
|
161
|
+
- Step-by-step execution instructions
|
|
162
|
+
- Actions that change state or produce output
|
|
163
|
+
- Things you "run" or "execute"
|
|
164
|
+
|
|
165
|
+
### Reference Documentation (skill root)
|
|
166
|
+
- Guides and how-to documentation
|
|
167
|
+
- Specifications and schemas
|
|
168
|
+
- Information you "read" or "reference"
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## Complete Checklist
|
|
173
|
+
|
|
174
|
+
Before a skill is complete:
|
|
175
|
+
|
|
176
|
+
### Naming (TitleCase)
|
|
177
|
+
- [ ] Skill directory uses TitleCase
|
|
178
|
+
- [ ] All workflow files use TitleCase
|
|
179
|
+
- [ ] All reference docs use TitleCase
|
|
180
|
+
- [ ] YAML `name:` uses TitleCase
|
|
181
|
+
|
|
182
|
+
### YAML Frontmatter
|
|
183
|
+
- [ ] Single-line description with embedded `USE WHEN` clause
|
|
184
|
+
- [ ] No separate `triggers:` or `workflows:` arrays
|
|
185
|
+
- [ ] Description under 1024 characters
|
|
186
|
+
|
|
187
|
+
### Markdown Body
|
|
188
|
+
- [ ] `## Workflow Routing` section with table format
|
|
189
|
+
- [ ] `## Examples` section with 2-3 concrete patterns
|
|
190
|
+
- [ ] All workflows have routing entries
|
|
191
|
+
|
|
192
|
+
### Structure
|
|
193
|
+
- [ ] `tools/` directory exists (even if empty)
|
|
194
|
+
- [ ] No `backups/` directory inside skill
|
|
195
|
+
- [ ] Workflows contain ONLY execution procedures
|
|
196
|
+
- [ ] Reference docs live at skill root
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## Summary
|
|
201
|
+
|
|
202
|
+
| Component | Purpose | Naming |
|
|
203
|
+
|-----------|---------|--------|
|
|
204
|
+
| **Skill directory** | Contains all skill files | TitleCase (e.g., `Blogging`) |
|
|
205
|
+
| **SKILL.md** | Main skill file | Always uppercase |
|
|
206
|
+
| **Workflow files** | Execution procedures | TitleCase (e.g., `Create.md`) |
|
|
207
|
+
| **Reference docs** | Information to read | TitleCase (e.g., `ApiReference.md`) |
|
|
208
|
+
| **Tool files** | CLI automation | TitleCase (e.g., `ManageServer.ts`) |
|
|
209
|
+
|
|
210
|
+
This system ensures:
|
|
211
|
+
1. Skills invoke properly based on intent (USE WHEN in description)
|
|
212
|
+
2. Specific functionality executes accurately (Workflow Routing in body)
|
|
213
|
+
3. All skills have consistent, predictable structure
|
|
214
|
+
4. **All naming follows TitleCase convention**
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
<!-- Generated by PAI Setup -->
|
|
2
|
+
# Terminal Tab Title System
|
|
3
|
+
|
|
4
|
+
## Overview
|
|
5
|
+
|
|
6
|
+
The PAI system automatically updates your terminal tab title with a 4-word summary of what was done after each task completion. This provides instant visual feedback in your terminal tabs, making it easy to see what each Claude session accomplished.
|
|
7
|
+
|
|
8
|
+
## How It Works
|
|
9
|
+
|
|
10
|
+
The `stop-hook.ts` hook runs after every task completion and:
|
|
11
|
+
|
|
12
|
+
1. **Extracts the task summary** from the COMPLETED line in responses
|
|
13
|
+
2. **Generates a 4-word title** that summarizes what was accomplished
|
|
14
|
+
3. **Updates your terminal tab** using ANSI escape sequences
|
|
15
|
+
|
|
16
|
+
## Features
|
|
17
|
+
|
|
18
|
+
### 4-Word Summary Format
|
|
19
|
+
|
|
20
|
+
The system creates meaningful 4-word summaries by:
|
|
21
|
+
- Using past-tense action verbs (Created, Updated, Fixed, etc.)
|
|
22
|
+
- Extracting key nouns from the task
|
|
23
|
+
- Prioritizing words from the COMPLETED line when available
|
|
24
|
+
- Falling back to the user's original query if needed
|
|
25
|
+
|
|
26
|
+
### Examples
|
|
27
|
+
|
|
28
|
+
| User Query | Tab Title |
|
|
29
|
+
|------------|-----------|
|
|
30
|
+
| "Update the README documentation" | Updated Readme Documentation Done |
|
|
31
|
+
| "Fix the stop-hook" | Fixed Stop Hook Successfully |
|
|
32
|
+
| "Research AI trends" | Researched AI Trends Complete |
|
|
33
|
+
| "Implement new feature" | Implemented New Feature Done |
|
|
34
|
+
|
|
35
|
+
## Terminal Compatibility
|
|
36
|
+
|
|
37
|
+
The tab title system works with terminals that support OSC (Operating System Command) sequences:
|
|
38
|
+
|
|
39
|
+
- **Kitty** - Full support
|
|
40
|
+
- **iTerm2** - Full support
|
|
41
|
+
- **Terminal.app** - Full support
|
|
42
|
+
- **Alacritty** - Full support
|
|
43
|
+
- **VS Code Terminal** - Full support
|
|
44
|
+
|
|
45
|
+
## Implementation Details
|
|
46
|
+
|
|
47
|
+
### Escape Sequences Used
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# OSC 0 - Sets icon and window title
|
|
51
|
+
printf '\033]0;Title Here\007'
|
|
52
|
+
|
|
53
|
+
# OSC 2 - Sets window title
|
|
54
|
+
printf '\033]2;Title Here\007'
|
|
55
|
+
|
|
56
|
+
# OSC 30 - Kitty-specific tab title
|
|
57
|
+
printf '\033]30;Title Here\007'
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Hook Location
|
|
61
|
+
|
|
62
|
+
The terminal tab functionality is implemented in:
|
|
63
|
+
```
|
|
64
|
+
${PAI_DIR}/Hooks/stop-hook.ts
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Key Functions
|
|
68
|
+
|
|
69
|
+
1. **generateTabTitle(prompt, completedLine)** - Creates the 4-word summary
|
|
70
|
+
2. **setTabTitle(title)** - Sends escape sequences to update the tab
|
|
71
|
+
3. **Hook execution** - Runs automatically after every task
|
|
72
|
+
|
|
73
|
+
## Debugging
|
|
74
|
+
|
|
75
|
+
If tab titles aren't updating:
|
|
76
|
+
|
|
77
|
+
1. **Check hook is executable:**
|
|
78
|
+
```bash
|
|
79
|
+
ls -la ${PAI_DIR}/Hooks/stop-hook.ts
|
|
80
|
+
# Should show: -rwxr-xr-x
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
2. **Verify Claude Code settings:**
|
|
84
|
+
- Ensure stop-hook is configured in your Claude Code settings
|
|
85
|
+
- Path should be: `${PAI_DIR}/Hooks/stop-hook.ts`
|
|
86
|
+
|
|
87
|
+
3. **Test manually:**
|
|
88
|
+
```bash
|
|
89
|
+
printf '\033]0;Test Title\007' >&2
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
4. **Check stderr output:**
|
|
93
|
+
The hook logs to stderr with:
|
|
94
|
+
- Tab title changes
|
|
95
|
+
- User queries processed
|
|
96
|
+
- Completed text extracted
|
|
97
|
+
|
|
98
|
+
## Customization
|
|
99
|
+
|
|
100
|
+
To modify the tab title behavior, edit `${PAI_DIR}/Hooks/stop-hook.ts`:
|
|
101
|
+
|
|
102
|
+
- Change word count (currently 4 words)
|
|
103
|
+
- Modify verb tense (currently past tense)
|
|
104
|
+
- Add custom prefixes or suffixes
|
|
105
|
+
- Filter different stop words
|
|
106
|
+
|
|
107
|
+
## Benefits
|
|
108
|
+
|
|
109
|
+
- **Visual Task Tracking** - See what each tab accomplished at a glance
|
|
110
|
+
- **Multi-Session Management** - Easily identify different Claude sessions
|
|
111
|
+
- **Task History** - Tab titles persist as a record of completed work
|
|
112
|
+
- **No Manual Updates** - Fully automatic, runs on every task completion
|
|
113
|
+
|
|
114
|
+
## Integration with Voice System
|
|
115
|
+
|
|
116
|
+
The terminal tab system works alongside the voice notification system:
|
|
117
|
+
- Both extract information from the COMPLETED line
|
|
118
|
+
- Tab gets a 4-word visual summary
|
|
119
|
+
- Voice speaks the completion message
|
|
120
|
+
- Both provide immediate feedback through different channels
|