cc-hub-cli 1.0.1 → 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/README.md +157 -1
- package/dist/index.js +7 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1 +1,157 @@
|
|
|
1
|
-
# cc-hub
|
|
1
|
+
# cc-hub
|
|
2
|
+
|
|
3
|
+
Manage Claude CLI profiles, hooks, and sessions — one tool, all in one place.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g cc-hub-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Add a profile
|
|
15
|
+
cc-hub profile add flow -m anthropic.claude-4-6-sonnet -t eyJ... -u https://example.com/api
|
|
16
|
+
|
|
17
|
+
# Set as default
|
|
18
|
+
cc-hub profile default flow
|
|
19
|
+
|
|
20
|
+
# Launch Claude Code with it
|
|
21
|
+
cc-hub run
|
|
22
|
+
|
|
23
|
+
# Or launch with a specific profile
|
|
24
|
+
cc-hub run flow
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Commands
|
|
28
|
+
|
|
29
|
+
### Profiles
|
|
30
|
+
|
|
31
|
+
Manage multiple Claude API configurations (model, token, URL).
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
cc-hub profile add <name> -m <model> -t <token> -u <url> # Add or update
|
|
35
|
+
cc-hub profile update <name> -m <model> # Update fields
|
|
36
|
+
cc-hub profile list # List all (tokens masked)
|
|
37
|
+
cc-hub profile view <name> # View details (token visible)
|
|
38
|
+
cc-hub profile view <name> -j # View as JSON
|
|
39
|
+
cc-hub profile remove <name> # Remove
|
|
40
|
+
cc-hub profile default <name> # Set default
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Run / Use
|
|
44
|
+
|
|
45
|
+
Launch Claude Code with a profile's credentials injected as environment variables.
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# Set a profile as default
|
|
49
|
+
cc-hub use <name>
|
|
50
|
+
|
|
51
|
+
# Launch using the default profile
|
|
52
|
+
cc-hub run [extra args...]
|
|
53
|
+
|
|
54
|
+
# Launch with a specific profile
|
|
55
|
+
cc-hub run <name> [extra args...]
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
`run` execs into the `claude` CLI with `ANTHROPIC_AUTH_TOKEN`, `ANTHROPIC_BASE_URL`, and `--model` set from the profile.
|
|
59
|
+
|
|
60
|
+
### Hook
|
|
61
|
+
|
|
62
|
+
Manage Claude Code hooks in `~/.claude/settings.json`.
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
cc-hub hook list # List all hooks
|
|
66
|
+
cc-hub hook add -e <event> -c <command> [-m <matcher>] [-a] # Add a hook
|
|
67
|
+
cc-hub hook remove -i <index> # Remove by index
|
|
68
|
+
cc-hub hook enable -i <index> [-i <index>] # Enable disabled hooks
|
|
69
|
+
cc-hub hook disable -i <index> [-i <index>] # Disable active hooks
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**Events:** `PreToolUse`, `PostToolUse`, `Notification`, `Stop`, `UserPromptSubmit`, `PermissionRequest`
|
|
73
|
+
|
|
74
|
+
**Examples:**
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
# Desktop notification when Claude finishes
|
|
78
|
+
cc-hub hook add -e Stop -c 'osascript -e "display notification \"Done\""'
|
|
79
|
+
|
|
80
|
+
# Hook only for Bash tool usage
|
|
81
|
+
cc-hub hook add -e PreToolUse -m Bash -c 'echo "Running bash..."'
|
|
82
|
+
|
|
83
|
+
# Async hook
|
|
84
|
+
cc-hub hook add -e PostToolUse -c 'my-logger.sh' -a
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Disabled hooks are kept in a pool and can be re-enabled later with `hook enable`.
|
|
88
|
+
|
|
89
|
+
### Session
|
|
90
|
+
|
|
91
|
+
Browse and search Claude Code session history from `~/.claude/projects/`.
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
cc-hub session list [-n <limit>] [-s] [-j] # List projects
|
|
95
|
+
cc-hub session show <project> [-v] # Show sessions for a project
|
|
96
|
+
cc-hub session search <query> [-p <project>] [-n <n>] [-i] # Search conversation history
|
|
97
|
+
cc-hub session ps # Show active processes
|
|
98
|
+
cc-hub session stats # Summary statistics
|
|
99
|
+
cc-hub session clean [-d <days>] [--dry-run] # Delete old sessions
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Examples:**
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
# List recent projects
|
|
106
|
+
cc-hub session list -n 10
|
|
107
|
+
|
|
108
|
+
# Show sessions with first message preview
|
|
109
|
+
cc-hub session show cc-hub -v
|
|
110
|
+
|
|
111
|
+
# Case-insensitive search
|
|
112
|
+
cc-hub session search "authentication" -i
|
|
113
|
+
|
|
114
|
+
# Preview what would be cleaned up
|
|
115
|
+
cc-hub session clean -d 60 --dry-run
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Shell Completion
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# zsh — add to ~/.zshrc
|
|
122
|
+
eval "$(cc-hub complete zsh)"
|
|
123
|
+
|
|
124
|
+
# bash — add to ~/.bashrc
|
|
125
|
+
eval "$(cc-hub complete bash)"
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Completes subcommands, profile names, and event types.
|
|
129
|
+
|
|
130
|
+
## Configuration
|
|
131
|
+
|
|
132
|
+
cc-hub reads from these paths (overridable via environment variables):
|
|
133
|
+
|
|
134
|
+
| File | Default | Env Override |
|
|
135
|
+
|---|---|---|
|
|
136
|
+
| Profiles | `~/.claude/profiles.json` | `CLAUDE_PROFILES_FILE` |
|
|
137
|
+
| Settings | `~/.claude/settings.json` | `CLAUDE_SETTINGS_FILE` |
|
|
138
|
+
| Claude dir | `~/.claude` | `CLAUDE_DIR` |
|
|
139
|
+
|
|
140
|
+
### Profile storage format
|
|
141
|
+
|
|
142
|
+
```json
|
|
143
|
+
{
|
|
144
|
+
"profiles": {
|
|
145
|
+
"flow": {
|
|
146
|
+
"model": "anthropic.claude-4-6-sonnet",
|
|
147
|
+
"token": "eyJ...",
|
|
148
|
+
"url": "https://example.com/api"
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
"default": "flow"
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## License
|
|
156
|
+
|
|
157
|
+
MIT
|
package/dist/index.js
CHANGED
|
@@ -152,25 +152,20 @@ function execClaude(profileName, p, extraArgs) {
|
|
|
152
152
|
process.exit(result.status ?? 1);
|
|
153
153
|
}
|
|
154
154
|
function useCommand() {
|
|
155
|
-
return new Command("use").description("
|
|
155
|
+
return new Command("use").description("Set a profile as the default").argument("<name>", "Profile name").action((name) => {
|
|
156
156
|
ensureProfilesFile();
|
|
157
157
|
const data = readJson(PROFILES_FILE);
|
|
158
|
-
|
|
159
|
-
if (!p) {
|
|
158
|
+
if (!data.profiles[name]) {
|
|
160
159
|
console.error(`Profile '${name}' not found.`);
|
|
161
160
|
process.exit(1);
|
|
162
161
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
console.log(`Default profile set to '${name}'.`);
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
execClaude(name, p, args);
|
|
162
|
+
data.default = name;
|
|
163
|
+
writeJson(PROFILES_FILE, data);
|
|
164
|
+
console.log(`Default profile set to '${name}'.`);
|
|
170
165
|
});
|
|
171
166
|
}
|
|
172
167
|
function runCommand() {
|
|
173
|
-
return new Command("run").description("Launch Claude Code using the default or a specified profile").argument("[args...]", "Optional profile name followed by extra arguments").action((args) => {
|
|
168
|
+
return new Command("run").description("Launch Claude Code using the default or a specified profile").allowUnknownOption().argument("[args...]", "Optional profile name followed by extra arguments").action((args) => {
|
|
174
169
|
ensureProfilesFile();
|
|
175
170
|
const data = readJson(PROFILES_FILE);
|
|
176
171
|
let profileName = "";
|
|
@@ -853,7 +848,7 @@ for name in data.get('profiles', {}):
|
|
|
853
848
|
esac
|
|
854
849
|
}
|
|
855
850
|
|
|
856
|
-
_cc-hub
|
|
851
|
+
compdef _cc-hub cc-hub
|
|
857
852
|
`;
|
|
858
853
|
var BASH_COMPLETION = `_cc-hub_profiles() {
|
|
859
854
|
local profiles_file="\${CLAUDE_PROFILES_FILE:-$HOME/.claude/profiles.json}"
|