@claudemini/shit-cli 1.0.3
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/.claude/settings.json +81 -0
- package/.claude/settings.local.json +19 -0
- package/COMPARISON.md +92 -0
- package/DESIGN_PHILOSOPHY.md +138 -0
- package/QUICKSTART.md +109 -0
- package/README.md +258 -0
- package/bin/shit.js +61 -0
- package/lib/clean.js +45 -0
- package/lib/config.js +26 -0
- package/lib/extract.js +265 -0
- package/lib/git-shadow.js +136 -0
- package/lib/init.js +83 -0
- package/lib/list.js +62 -0
- package/lib/log.js +66 -0
- package/lib/query.js +110 -0
- package/lib/report.js +185 -0
- package/lib/session.js +184 -0
- package/lib/shadow.js +51 -0
- package/lib/view.js +50 -0
- package/package.json +22 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
{
|
|
2
|
+
"hooks": {
|
|
3
|
+
"SessionStart": [
|
|
4
|
+
{
|
|
5
|
+
"matcher": "",
|
|
6
|
+
"hooks": [
|
|
7
|
+
{
|
|
8
|
+
"type": "command",
|
|
9
|
+
"command": "shit log session-start"
|
|
10
|
+
}
|
|
11
|
+
]
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"SessionEnd": [
|
|
15
|
+
{
|
|
16
|
+
"matcher": "",
|
|
17
|
+
"hooks": [
|
|
18
|
+
{
|
|
19
|
+
"type": "command",
|
|
20
|
+
"command": "shit log session-end"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"UserPromptSubmit": [
|
|
26
|
+
{
|
|
27
|
+
"matcher": "",
|
|
28
|
+
"hooks": [
|
|
29
|
+
{
|
|
30
|
+
"type": "command",
|
|
31
|
+
"command": "shit log user-prompt-submit"
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
"PreToolUse": [
|
|
37
|
+
{
|
|
38
|
+
"matcher": "",
|
|
39
|
+
"hooks": [
|
|
40
|
+
{
|
|
41
|
+
"type": "command",
|
|
42
|
+
"command": "shit log pre-tool-use"
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
"PostToolUse": [
|
|
48
|
+
{
|
|
49
|
+
"matcher": "",
|
|
50
|
+
"hooks": [
|
|
51
|
+
{
|
|
52
|
+
"type": "command",
|
|
53
|
+
"command": "shit log post-tool-use"
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
],
|
|
58
|
+
"Notification": [
|
|
59
|
+
{
|
|
60
|
+
"matcher": "",
|
|
61
|
+
"hooks": [
|
|
62
|
+
{
|
|
63
|
+
"type": "command",
|
|
64
|
+
"command": "shit log notification"
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
"Stop": [
|
|
70
|
+
{
|
|
71
|
+
"matcher": "",
|
|
72
|
+
"hooks": [
|
|
73
|
+
{
|
|
74
|
+
"type": "command",
|
|
75
|
+
"command": "shit log stop"
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"permissions": {
|
|
3
|
+
"allow": [
|
|
4
|
+
"Bash(git remote add:*)",
|
|
5
|
+
"Bash(git push:*)",
|
|
6
|
+
"Bash(npm publish:*)",
|
|
7
|
+
"Bash(npm whoami:*)",
|
|
8
|
+
"WebFetch(domain:www.npmjs.com)",
|
|
9
|
+
"Bash(npm config delete:*)",
|
|
10
|
+
"Bash(sudo chown:*)",
|
|
11
|
+
"Bash(npm cache clean:*)",
|
|
12
|
+
"Bash(npm install:*)",
|
|
13
|
+
"Bash(git add:*)",
|
|
14
|
+
"Bash(git commit -m \"$\\(cat <<''EOF''\n更新包名和版本号\n\n- 包名改为 @cluademini/shit-cli\n- 版本号升至 1.0.3\nEOF\n\\)\")",
|
|
15
|
+
"Bash(git commit:*)",
|
|
16
|
+
"Bash(npm config set:*)"
|
|
17
|
+
]
|
|
18
|
+
}
|
|
19
|
+
}
|
package/COMPARISON.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Project Structure Comparison
|
|
2
|
+
|
|
3
|
+
## Directory Layout
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
your-project/
|
|
7
|
+
├── .claude/ # Claude Code configuration
|
|
8
|
+
│ └── settings.json # Hook configurations
|
|
9
|
+
├── .entire/ # Entire tool (session management)
|
|
10
|
+
│ ├── metadata/
|
|
11
|
+
│ │ └── <session-id>/
|
|
12
|
+
│ │ ├── full.jsonl # Complete transcript
|
|
13
|
+
│ │ ├── prompt.txt # User prompts
|
|
14
|
+
│ │ ├── context.md # Session context
|
|
15
|
+
│ │ └── summary.txt # Session summary
|
|
16
|
+
│ ├── logs/
|
|
17
|
+
│ └── settings.json
|
|
18
|
+
└── .shit-logs/ # shit-cli (hook event logging)
|
|
19
|
+
├── <session-id>/
|
|
20
|
+
│ ├── events.jsonl # Hook events only
|
|
21
|
+
│ ├── prompts.txt # User prompts
|
|
22
|
+
│ ├── context.md # Session context
|
|
23
|
+
│ ├── summary.txt # Session summary
|
|
24
|
+
│ └── metadata.json # Session metadata
|
|
25
|
+
└── index.txt # Global index
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Feature Comparison
|
|
29
|
+
|
|
30
|
+
| Feature | `.entire` | `.shit-logs` |
|
|
31
|
+
|---------|-----------|--------------|
|
|
32
|
+
| **Scope** | Complete session transcript | Hook events only |
|
|
33
|
+
| **Location** | Project root | Project root ✓ |
|
|
34
|
+
| **Session-based** | ✓ | ✓ |
|
|
35
|
+
| **Transcript** | `full.jsonl` (all messages) | `events.jsonl` (hooks only) |
|
|
36
|
+
| **Prompts** | `prompt.txt` | `prompts.txt` |
|
|
37
|
+
| **Context** | `context.md` | `context.md` |
|
|
38
|
+
| **Summary** | `summary.txt` | `summary.txt` |
|
|
39
|
+
| **Checkpoints** | Git shadow branches | Not implemented |
|
|
40
|
+
| **CLI** | `entire` commands | `shit` commands |
|
|
41
|
+
| **Auto-init** | `entire enable` | `shit init` |
|
|
42
|
+
|
|
43
|
+
## Key Differences
|
|
44
|
+
|
|
45
|
+
### `.entire` (Entire Tool)
|
|
46
|
+
- **Purpose**: Complete session management and checkpointing
|
|
47
|
+
- **Data**: Full conversation transcript (user + assistant messages)
|
|
48
|
+
- **Features**: Git integration, checkpoints, session replay
|
|
49
|
+
- **Trigger**: Automatic (entire daemon)
|
|
50
|
+
|
|
51
|
+
### `.shit-logs` (shit-cli)
|
|
52
|
+
- **Purpose**: Hook event logging and analysis
|
|
53
|
+
- **Data**: Hook events only (tool calls, session events)
|
|
54
|
+
- **Features**: Session aggregation, event filtering, cleanup
|
|
55
|
+
- **Trigger**: Hook-based (Claude Code hooks)
|
|
56
|
+
|
|
57
|
+
## Use Cases
|
|
58
|
+
|
|
59
|
+
### Use `.entire` when you need:
|
|
60
|
+
- Complete session history
|
|
61
|
+
- Git-based checkpointing
|
|
62
|
+
- Session replay and analysis
|
|
63
|
+
- Cross-session context
|
|
64
|
+
|
|
65
|
+
### Use `.shit-logs` when you need:
|
|
66
|
+
- Hook event debugging
|
|
67
|
+
- Tool usage analysis
|
|
68
|
+
- Session statistics
|
|
69
|
+
- Lightweight logging
|
|
70
|
+
|
|
71
|
+
## Both Together
|
|
72
|
+
|
|
73
|
+
Running both systems provides:
|
|
74
|
+
- **Complete coverage**: Full transcript + hook events
|
|
75
|
+
- **Different perspectives**: Conversation flow + tool execution
|
|
76
|
+
- **Complementary data**: `.entire` for context, `.shit-logs` for debugging
|
|
77
|
+
|
|
78
|
+
## .gitignore
|
|
79
|
+
|
|
80
|
+
Both directories are typically excluded from git:
|
|
81
|
+
|
|
82
|
+
```gitignore
|
|
83
|
+
# Entire tool
|
|
84
|
+
.entire/store/
|
|
85
|
+
.entire/monitor.pid
|
|
86
|
+
.entire/monitor.sessions.json
|
|
87
|
+
|
|
88
|
+
# shit-cli logs
|
|
89
|
+
.shit-logs/
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Note: `.entire/settings.json` and `.entire/.gitignore` are usually committed.
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# shit-cli Design Philosophy
|
|
2
|
+
|
|
3
|
+
## Core Vision
|
|
4
|
+
|
|
5
|
+
### 1. Human-AI Interaction Memory System
|
|
6
|
+
Long-term memory storage for human-AI interactions, not just temporary logs. Each session is analyzed for semantic meaning — what was the intent, what changed, what's the risk.
|
|
7
|
+
|
|
8
|
+
### 2. Code Review Bot Data Support
|
|
9
|
+
Provide reliable, structured data to support code review automation. The bot doesn't need to parse raw events — it gets pre-classified changes, risk assessments, and review hints.
|
|
10
|
+
|
|
11
|
+
## Architecture
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
Human ↔ AI (Claude Code)
|
|
15
|
+
↓ (hooks)
|
|
16
|
+
Event Ingestion (log.js)
|
|
17
|
+
↓
|
|
18
|
+
Semantic Extraction (extract.js)
|
|
19
|
+
↓
|
|
20
|
+
Session State (session.js) + Reports (report.js)
|
|
21
|
+
↓
|
|
22
|
+
Memory System (.shit-logs + index.json)
|
|
23
|
+
↓
|
|
24
|
+
Code Review Bot / Human Queries
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Three-Layer Architecture
|
|
28
|
+
|
|
29
|
+
1. **Ingestion Layer** — `log.js` reads stdin, parses events, dispatches
|
|
30
|
+
2. **Intelligence Layer** — `extract.js` classifies intent, changes, risk
|
|
31
|
+
3. **Storage Layer** — `session.js` manages state, `report.js` generates outputs
|
|
32
|
+
|
|
33
|
+
## Semantic Model
|
|
34
|
+
|
|
35
|
+
### Intent Extraction
|
|
36
|
+
From user prompts, extract:
|
|
37
|
+
- **Goal**: What the user is trying to accomplish
|
|
38
|
+
- **Type**: bugfix, feature, refactor, debug, test, docs, etc.
|
|
39
|
+
- **Scope**: Which domains are involved (auth, api, database, etc.)
|
|
40
|
+
|
|
41
|
+
### Change Extraction
|
|
42
|
+
From tool events, extract:
|
|
43
|
+
- **Files**: Categorized (source, test, config, doc, script, infra, deps, migration)
|
|
44
|
+
- **Operations**: What was done to each file (read, write, edit)
|
|
45
|
+
- **Commands**: Categorized (test, build, git, deploy, install, lint, database)
|
|
46
|
+
|
|
47
|
+
### Session Classification
|
|
48
|
+
Combining intent + changes:
|
|
49
|
+
- **Type**: Dominant activity category
|
|
50
|
+
- **Risk**: Assessment based on file count, config changes, test coverage
|
|
51
|
+
- **Review Hints**: Actionable flags for code review bots
|
|
52
|
+
|
|
53
|
+
## File Structure
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
.shit-logs/
|
|
57
|
+
├── index.json # Cross-session index (file history, session types)
|
|
58
|
+
└── <session-id>/
|
|
59
|
+
├── events.jsonl # Raw hook events (complete history)
|
|
60
|
+
├── state.json # Incremental processing state
|
|
61
|
+
├── summary.json # Bot data interface (v2 schema)
|
|
62
|
+
├── summary.txt # Human-readable semantic report
|
|
63
|
+
├── prompts.txt # User prompts with timestamps
|
|
64
|
+
└── metadata.json # Lightweight session metadata
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Key Design Decisions
|
|
68
|
+
|
|
69
|
+
### 1. Rule-Based Classification (No AI Dependency)
|
|
70
|
+
Intent and change classification use simple pattern matching rules. This ensures:
|
|
71
|
+
- Zero latency — runs during hook processing
|
|
72
|
+
- Zero cost — no API calls
|
|
73
|
+
- Predictable — deterministic output
|
|
74
|
+
- Offline — works without network
|
|
75
|
+
|
|
76
|
+
### 2. Cross-Session Index
|
|
77
|
+
The `index.json` file enables:
|
|
78
|
+
- File history queries ("how often was this file changed?")
|
|
79
|
+
- Session type filtering ("show all bugfix sessions")
|
|
80
|
+
- Risk tracking over time
|
|
81
|
+
- Bot can query without scanning all sessions
|
|
82
|
+
|
|
83
|
+
### 3. summary.json v2 Schema
|
|
84
|
+
Upgraded from v1 (statistics-only) to v2 (semantic):
|
|
85
|
+
- **v1**: event counts, file lists, tool usage
|
|
86
|
+
- **v2**: intent, type, risk, review_hints, categorized changes/commands
|
|
87
|
+
|
|
88
|
+
### 4. Incremental Processing
|
|
89
|
+
State is maintained incrementally in `state.json`. Each event updates the state, and reports are regenerated from the latest state. This means:
|
|
90
|
+
- Fast processing per event (~5ms)
|
|
91
|
+
- Reports always reflect current session state
|
|
92
|
+
- No need to re-read events.jsonl
|
|
93
|
+
|
|
94
|
+
### 5. Best-Effort Shadow Branches
|
|
95
|
+
Git shadow branches and index updates are best-effort — failures don't affect core logging. This ensures hooks never block Claude Code.
|
|
96
|
+
|
|
97
|
+
## Bot Integration Patterns
|
|
98
|
+
|
|
99
|
+
### Direct File Read
|
|
100
|
+
```javascript
|
|
101
|
+
const summary = JSON.parse(fs.readFileSync('.shit-logs/<id>/summary.json'));
|
|
102
|
+
// Use summary.review_hints for automated review decisions
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Cross-Session Query
|
|
106
|
+
```javascript
|
|
107
|
+
const index = JSON.parse(fs.readFileSync('.shit-logs/index.json'));
|
|
108
|
+
// Find all sessions that touched a specific file
|
|
109
|
+
const sessions = index.file_history['src/auth/service.ts'];
|
|
110
|
+
// Filter by type or risk
|
|
111
|
+
const risky = index.sessions.filter(s => s.risk === 'high');
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### CLI Query (for humans)
|
|
115
|
+
```bash
|
|
116
|
+
shit query --file=src/auth/service.ts # File history
|
|
117
|
+
shit query --type=bugfix --recent=5 # Recent bugfixes
|
|
118
|
+
shit query --risk=high --json # High-risk as JSON
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Comparison with `.entire`
|
|
122
|
+
|
|
123
|
+
| Aspect | `.entire` | `.shit-logs` |
|
|
124
|
+
|--------|-----------|--------------|
|
|
125
|
+
| **Data Source** | Full transcript | Hook events |
|
|
126
|
+
| **Intelligence** | Raw messages | Semantic extraction |
|
|
127
|
+
| **Bot Interface** | Parse messages | Structured JSON (v2) |
|
|
128
|
+
| **Cross-Session** | No | Index with file history |
|
|
129
|
+
| **Review Hints** | No | Tests, risk, coverage |
|
|
130
|
+
| **Purpose** | Conversation memory | Operation intelligence |
|
|
131
|
+
|
|
132
|
+
## Future Enhancements
|
|
133
|
+
|
|
134
|
+
- AI-powered intent extraction (optional, when available)
|
|
135
|
+
- Diff-level change tracking (what exactly changed in each edit)
|
|
136
|
+
- Session linking (detect related sessions across time)
|
|
137
|
+
- Anomaly detection (unusual patterns in session activity)
|
|
138
|
+
- Bot API endpoint (serve session data over HTTP)
|
package/QUICKSTART.md
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Quick Start Guide
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
# Clone or download shit-cli
|
|
7
|
+
cd ~/Desktop/shit-cli
|
|
8
|
+
|
|
9
|
+
# Install globally
|
|
10
|
+
npm link
|
|
11
|
+
|
|
12
|
+
# Or add to PATH
|
|
13
|
+
echo 'export PATH="$HOME/Desktop/shit-cli/bin:$PATH"' >> ~/.zshrc
|
|
14
|
+
source ~/.zshrc
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Setup (One-time)
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Navigate to your project
|
|
21
|
+
cd /path/to/your/project
|
|
22
|
+
|
|
23
|
+
# Initialize hooks
|
|
24
|
+
shit init
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
This creates `.claude/settings.json` with all necessary hooks.
|
|
28
|
+
|
|
29
|
+
## Verify Installation
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# Check if shit is available
|
|
33
|
+
shit help
|
|
34
|
+
|
|
35
|
+
# Should output:
|
|
36
|
+
# shit-cli - Session-based Hook Intelligence Tracker
|
|
37
|
+
# Usage: shit <command> [options]
|
|
38
|
+
# ...
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Usage
|
|
42
|
+
|
|
43
|
+
Once initialized, hooks will automatically log events to `~/.shit-logs/`.
|
|
44
|
+
|
|
45
|
+
### View your sessions
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# List all sessions
|
|
49
|
+
shit list
|
|
50
|
+
|
|
51
|
+
# View specific session
|
|
52
|
+
shit view <session-id>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Clean up old logs
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# Preview what will be deleted
|
|
59
|
+
shit clean --days=7 --dry-run
|
|
60
|
+
|
|
61
|
+
# Actually delete
|
|
62
|
+
shit clean --days=7
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Troubleshooting
|
|
66
|
+
|
|
67
|
+
### Command not found: shit
|
|
68
|
+
|
|
69
|
+
If `npm link` doesn't work, use the full path:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
node ~/Desktop/shit-cli/bin/shit.js init
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Or create an alias:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
echo 'alias shit="node ~/Desktop/shit-cli/bin/shit.js"' >> ~/.zshrc
|
|
79
|
+
source ~/.zshrc
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Hooks not working
|
|
83
|
+
|
|
84
|
+
1. Check if `.claude/settings.json` exists in your project
|
|
85
|
+
2. Verify hooks are registered: `cat .claude/settings.json`
|
|
86
|
+
3. Restart Claude Code
|
|
87
|
+
|
|
88
|
+
### Logs not appearing
|
|
89
|
+
|
|
90
|
+
1. Check log directory: `ls -la ~/.shit-logs/`
|
|
91
|
+
2. Verify hooks are being triggered (check Claude Code output)
|
|
92
|
+
3. Test manually:
|
|
93
|
+
```bash
|
|
94
|
+
echo '{"session_id":"test-123","hook_event_name":"Test"}' | shit log test
|
|
95
|
+
shit list
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Uninstall
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# Remove global link
|
|
102
|
+
npm unlink -g shit-cli
|
|
103
|
+
|
|
104
|
+
# Remove logs
|
|
105
|
+
rm -rf ~/.shit-logs
|
|
106
|
+
|
|
107
|
+
# Remove hooks from project
|
|
108
|
+
# Edit .claude/settings.json and remove shit-related hooks
|
|
109
|
+
```
|
package/README.md
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
# shit-cli
|
|
2
|
+
|
|
3
|
+
**S**ession-based **H**ook **I**ntelligence **T**racker
|
|
4
|
+
|
|
5
|
+
A memory system for human-AI interactions, designed to provide reliable data support for code review automation.
|
|
6
|
+
|
|
7
|
+
## Design Vision
|
|
8
|
+
|
|
9
|
+
1. **Human-AI Interaction Memory System** - Long-term memory, not temporary logs
|
|
10
|
+
2. **Code Review Bot Data Support** - Structured semantic data for intelligent code review
|
|
11
|
+
|
|
12
|
+
See [DESIGN_PHILOSOPHY.md](./DESIGN_PHILOSOPHY.md) for detailed design rationale.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
cd shit-cli
|
|
18
|
+
npm link
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Or use directly:
|
|
22
|
+
```bash
|
|
23
|
+
node bin/shit.js <command>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
### Initialize hooks
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
cd /path/to/your/project
|
|
32
|
+
shit init
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Registers all hooks in `.claude/settings.json` automatically.
|
|
36
|
+
|
|
37
|
+
### List sessions
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
shit list
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Output:
|
|
44
|
+
```
|
|
45
|
+
3 session(s):
|
|
46
|
+
|
|
47
|
+
1. f608c31e [bugfix] risk:medium
|
|
48
|
+
Fix auth timeout by adjusting retry logic
|
|
49
|
+
45min | 42 events | 28 tools | 3 files | 0 errors
|
|
50
|
+
2/27/2026, 3:15:00 PM
|
|
51
|
+
|
|
52
|
+
2. a1b2c3d4 [feature] risk:low
|
|
53
|
+
Add user profile endpoint
|
|
54
|
+
30min | 28 events | 15 tools | 2 files | 0 errors
|
|
55
|
+
2/26/2026, 10:30:00 AM
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### View session details
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
shit view f608c31e-453c-435a-b0e2-3116dc56ad71
|
|
62
|
+
shit view f608c31e-453c-435a-b0e2-3116dc56ad71 --json # Include raw JSON
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Output includes: intent, changes by category, tools, commands, review hints (tests run, build verified, config changed, etc.).
|
|
66
|
+
|
|
67
|
+
### Query session memory
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
shit query --recent=5 # Recent 5 sessions
|
|
71
|
+
shit query --file=src/auth/auth.service.ts # Sessions that modified this file
|
|
72
|
+
shit query --type=bugfix # All bugfix sessions
|
|
73
|
+
shit query --risk=high # High-risk sessions
|
|
74
|
+
shit query --type=feature --json # JSON output for bot consumption
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Shadow branches
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
shit shadow # List shadow branches
|
|
81
|
+
shit shadow info <branch> # Show branch details
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Clean old sessions
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
shit clean --days=7 --dry-run # Preview
|
|
88
|
+
shit clean --days=7 # Delete sessions older than 7 days
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Commands
|
|
92
|
+
|
|
93
|
+
| Command | Description |
|
|
94
|
+
|---------|-------------|
|
|
95
|
+
| `init` | Initialize hooks in .claude/settings.json |
|
|
96
|
+
| `log <hook-type>` | Log a hook event from stdin (called by hooks) |
|
|
97
|
+
| `list` | List all sessions with type, intent, risk |
|
|
98
|
+
| `view <session-id> [--json]` | View semantic session report |
|
|
99
|
+
| `query [options]` | Query session memory across sessions |
|
|
100
|
+
| `shadow [info <branch>]` | List or inspect shadow branches |
|
|
101
|
+
| `clean [--days=N] [--dry-run]` | Clean old sessions |
|
|
102
|
+
| `help` | Show help |
|
|
103
|
+
|
|
104
|
+
## Architecture
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
shit-cli/
|
|
108
|
+
├── bin/shit.js # CLI entry point
|
|
109
|
+
├── lib/
|
|
110
|
+
│ ├── config.js # Shared config: getProjectRoot(), getLogDir(), toRelative()
|
|
111
|
+
│ ├── extract.js # Semantic extraction: intent, changes, classification
|
|
112
|
+
│ ├── report.js # Report generation: summary.json v2, summary.txt, metadata
|
|
113
|
+
│ ├── session.js # Session state management + cross-session index
|
|
114
|
+
│ ├── log.js # Event ingestion dispatcher (stdin → parse → extract → save)
|
|
115
|
+
│ ├── init.js # shit init (hook registration)
|
|
116
|
+
│ ├── list.js # shit list (semantic session listing)
|
|
117
|
+
│ ├── view.js # shit view (semantic report display)
|
|
118
|
+
│ ├── query.js # shit query (cross-session memory queries)
|
|
119
|
+
│ ├── clean.js # shit clean (session cleanup)
|
|
120
|
+
│ ├── shadow.js # shit shadow (branch listing)
|
|
121
|
+
│ └── git-shadow.js # Git plumbing for shadow branches
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Data Model
|
|
125
|
+
|
|
126
|
+
### Session Directory
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
.shit-logs/
|
|
130
|
+
├── index.json # Cross-session index (file history, types)
|
|
131
|
+
└── <session-id>/
|
|
132
|
+
├── events.jsonl # Raw hook events
|
|
133
|
+
├── state.json # Incremental processing state
|
|
134
|
+
├── summary.json # Bot data interface (v2 schema)
|
|
135
|
+
├── summary.txt # Human-readable semantic report
|
|
136
|
+
├── prompts.txt # User prompts with timestamps
|
|
137
|
+
└── metadata.json # Lightweight session metadata
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### summary.json v2 Schema
|
|
141
|
+
|
|
142
|
+
```json
|
|
143
|
+
{
|
|
144
|
+
"version": "2.0",
|
|
145
|
+
"session": {
|
|
146
|
+
"id": "f608c31e...",
|
|
147
|
+
"start": "2026-02-27T10:00:00Z",
|
|
148
|
+
"end": "2026-02-27T10:45:00Z",
|
|
149
|
+
"duration_minutes": 45,
|
|
150
|
+
"type": "bugfix",
|
|
151
|
+
"intent": "Fix authentication timeout issue",
|
|
152
|
+
"risk": "medium",
|
|
153
|
+
"summary": "Fixed: Fix authentication timeout issue"
|
|
154
|
+
},
|
|
155
|
+
"changes": {
|
|
156
|
+
"files": [{
|
|
157
|
+
"path": "src/auth/auth.service.ts",
|
|
158
|
+
"category": "source",
|
|
159
|
+
"operations": ["edit"],
|
|
160
|
+
"editCount": 2,
|
|
161
|
+
"editSummary": "Modified timeout logic"
|
|
162
|
+
}],
|
|
163
|
+
"summary": { "source": 3, "test": 1 }
|
|
164
|
+
},
|
|
165
|
+
"activity": {
|
|
166
|
+
"tools": { "Read": 15, "Edit": 3, "Bash": 5 },
|
|
167
|
+
"commands": {
|
|
168
|
+
"test": ["npm run test"],
|
|
169
|
+
"git": ["git status"]
|
|
170
|
+
},
|
|
171
|
+
"errors": []
|
|
172
|
+
},
|
|
173
|
+
"review_hints": {
|
|
174
|
+
"tests_run": true,
|
|
175
|
+
"build_verified": false,
|
|
176
|
+
"files_without_tests": ["src/auth/auth.service.ts"],
|
|
177
|
+
"large_change": false,
|
|
178
|
+
"config_changed": false,
|
|
179
|
+
"migration_added": false
|
|
180
|
+
},
|
|
181
|
+
"prompts": ["Fix the auth timeout bug", "Run the tests"],
|
|
182
|
+
"scope": ["auth"]
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Cross-Session Index
|
|
187
|
+
|
|
188
|
+
```json
|
|
189
|
+
{
|
|
190
|
+
"project": "my-project",
|
|
191
|
+
"sessions": [{
|
|
192
|
+
"id": "f608c31e...",
|
|
193
|
+
"date": "2026-02-27",
|
|
194
|
+
"type": "bugfix",
|
|
195
|
+
"intent": "Fix auth timeout",
|
|
196
|
+
"files": ["src/auth/auth.service.ts"],
|
|
197
|
+
"duration": 45,
|
|
198
|
+
"risk": "medium"
|
|
199
|
+
}],
|
|
200
|
+
"file_history": {
|
|
201
|
+
"src/auth/auth.service.ts": ["f608c31e...", "a1b2c3d4..."]
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## Session Types
|
|
207
|
+
|
|
208
|
+
| Type | Description |
|
|
209
|
+
|------|-------------|
|
|
210
|
+
| `bugfix` | Bug fixes |
|
|
211
|
+
| `feature` | New features |
|
|
212
|
+
| `refactor` | Code restructuring |
|
|
213
|
+
| `debug` | Investigation/debugging |
|
|
214
|
+
| `test` | Test writing/updates |
|
|
215
|
+
| `docs` | Documentation |
|
|
216
|
+
| `devops` | CI/CD, deployment |
|
|
217
|
+
| `upgrade` | Dependency updates |
|
|
218
|
+
| `config` | Configuration changes |
|
|
219
|
+
| `style` | Formatting, UI |
|
|
220
|
+
| `security` | Security-related |
|
|
221
|
+
| `perf` | Performance optimization |
|
|
222
|
+
| `unknown` | Unclassified |
|
|
223
|
+
|
|
224
|
+
## Risk Levels
|
|
225
|
+
|
|
226
|
+
- **low**: Few files, no config/migration changes, tests run
|
|
227
|
+
- **medium**: Multiple files, some config changes
|
|
228
|
+
- **high**: Many files (>10), migration changes, infra changes without tests
|
|
229
|
+
|
|
230
|
+
## Bot Integration
|
|
231
|
+
|
|
232
|
+
```javascript
|
|
233
|
+
// Read session data
|
|
234
|
+
const summary = JSON.parse(fs.readFileSync('.shit-logs/<id>/summary.json'));
|
|
235
|
+
|
|
236
|
+
// Check review hints
|
|
237
|
+
if (!summary.review_hints.tests_run && summary.changes.files.length > 0) {
|
|
238
|
+
review.warn('Files modified but no tests run');
|
|
239
|
+
}
|
|
240
|
+
if (summary.review_hints.migration_added) {
|
|
241
|
+
review.flag('Database migration requires careful review');
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// Query file history via index
|
|
245
|
+
const index = JSON.parse(fs.readFileSync('.shit-logs/index.json'));
|
|
246
|
+
const history = index.file_history['src/auth/auth.service.ts'];
|
|
247
|
+
if (history.length > 3) {
|
|
248
|
+
review.note('This file has been modified frequently');
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
## Environment Variables
|
|
253
|
+
|
|
254
|
+
- `SHIT_LOG_DIR`: Custom log directory (default: `./.shit-logs` in project root)
|
|
255
|
+
|
|
256
|
+
## License
|
|
257
|
+
|
|
258
|
+
MIT
|