@claude-code-hooks/cli 0.1.6 → 0.1.7
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/package.json +1 -1
- package/src/cli.js +28 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@claude-code-hooks/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Wizard CLI to set up and manage @claude-code-hooks packages for Claude Code.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/beefiker/claude-code-hooks/tree/main/packages/cli",
|
package/src/cli.js
CHANGED
|
@@ -43,7 +43,7 @@ function dieCancelled(msg = 'Cancelled') {
|
|
|
43
43
|
|
|
44
44
|
function usage(exitCode = 0) {
|
|
45
45
|
process.stdout.write(`\
|
|
46
|
-
claude-code-hooks\n\nUsage:\n npx @claude-code-hooks/cli@latest\n\
|
|
46
|
+
claude-code-hooks\n\nUsage:\n claude-code-hooks\n npx @claude-code-hooks/cli@latest\n\nWhat it does:\n - Update Claude Code settings (global), or generate a project-only config + pasteable snippet.\n`);
|
|
47
47
|
process.exit(exitCode);
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -66,7 +66,7 @@ async function ensureProjectOnlyConfig(projectDir, selected, perPackageConfig) {
|
|
|
66
66
|
|
|
67
67
|
async function maybeWriteSnippet(projectDir, snippetObj) {
|
|
68
68
|
const ok = await confirm({
|
|
69
|
-
message: `Write snippet file
|
|
69
|
+
message: `Write snippet file (${pc.bold('claude-code-hooks.snippet.json')}) to this project?`,
|
|
70
70
|
initialValue: false
|
|
71
71
|
});
|
|
72
72
|
if (isCancel(ok)) return;
|
|
@@ -92,20 +92,20 @@ async function main() {
|
|
|
92
92
|
|
|
93
93
|
while (true) {
|
|
94
94
|
action = await select({
|
|
95
|
-
message: `${pc.dim('Step 1/5')}
|
|
95
|
+
message: `${pc.dim('Step 1/5')} Choose an action`,
|
|
96
96
|
options: [
|
|
97
|
-
{ value: 'setup', label: '
|
|
98
|
-
{ value: 'uninstall', label: 'Uninstall
|
|
97
|
+
{ value: 'setup', label: 'Install / update packages' },
|
|
98
|
+
{ value: 'uninstall', label: 'Uninstall (remove managed hooks)' },
|
|
99
99
|
{ value: 'exit', label: 'Exit' }
|
|
100
100
|
]
|
|
101
101
|
});
|
|
102
102
|
if (isCancel(action) || action === 'exit') dieCancelled('Bye');
|
|
103
103
|
|
|
104
104
|
target = await select({
|
|
105
|
-
message: `${pc.dim('Step 2/5')}
|
|
105
|
+
message: `${pc.dim('Step 2/5')} Choose a target`,
|
|
106
106
|
options: [
|
|
107
107
|
{ value: 'global', label: `Global (default): ${pc.dim('~/.claude/settings.json')}` },
|
|
108
|
-
{ value: 'projectOnly', label: `Project-only: write ${pc.bold(CONFIG_FILENAME)} + print snippet` },
|
|
108
|
+
{ value: 'projectOnly', label: `Project-only: write ${pc.bold(CONFIG_FILENAME)} + print a snippet` },
|
|
109
109
|
{ value: '__back__', label: 'Back' }
|
|
110
110
|
]
|
|
111
111
|
});
|
|
@@ -113,18 +113,18 @@ async function main() {
|
|
|
113
113
|
if (target === '__back__') continue;
|
|
114
114
|
|
|
115
115
|
selected = await multiselect({
|
|
116
|
-
message: `${pc.dim('Step 3/5')}
|
|
116
|
+
message: `${pc.dim('Step 3/5')} Select packages`,
|
|
117
117
|
options: [
|
|
118
118
|
{ value: 'security', label: '@claude-code-hooks/security', hint: 'Warn/block risky commands' },
|
|
119
119
|
{ value: 'secrets', label: '@claude-code-hooks/secrets', hint: 'Detect secret-like tokens' },
|
|
120
|
-
{ value: 'sound', label: '@claude-code-hooks/sound', hint: 'Play sounds
|
|
121
|
-
{ value: 'notification', label: '@claude-code-hooks/notification', hint: 'OS notifications
|
|
120
|
+
{ value: 'sound', label: '@claude-code-hooks/sound', hint: 'Play sounds for key events' },
|
|
121
|
+
{ value: 'notification', label: '@claude-code-hooks/notification', hint: 'OS notifications for key events' }
|
|
122
122
|
],
|
|
123
123
|
required: true
|
|
124
124
|
});
|
|
125
125
|
if (isCancel(selected)) dieCancelled();
|
|
126
126
|
|
|
127
|
-
const proceed = await confirm({ message: '
|
|
127
|
+
const proceed = await confirm({ message: 'Configure these packages now?', initialValue: true });
|
|
128
128
|
if (isCancel(proceed)) dieCancelled();
|
|
129
129
|
if (!proceed) continue;
|
|
130
130
|
|
|
@@ -136,8 +136,20 @@ async function main() {
|
|
|
136
136
|
|
|
137
137
|
// ── Step 4/5: configure ──
|
|
138
138
|
note(
|
|
139
|
-
selected
|
|
140
|
-
|
|
139
|
+
selected
|
|
140
|
+
.map(
|
|
141
|
+
(k) =>
|
|
142
|
+
`${pc.bold(k)}: ${pc.dim(
|
|
143
|
+
{
|
|
144
|
+
security: 'Warn/block risky commands',
|
|
145
|
+
secrets: 'Detect secret-like tokens',
|
|
146
|
+
sound: 'Play sounds for key events',
|
|
147
|
+
notification: 'OS notifications for key events'
|
|
148
|
+
}[k] || ''
|
|
149
|
+
)}`
|
|
150
|
+
)
|
|
151
|
+
.join('\n'),
|
|
152
|
+
`${pc.dim('Step 4/5')} Configure packages`
|
|
141
153
|
);
|
|
142
154
|
|
|
143
155
|
if (selected.includes('security')) perPackage.security = await planSecuritySetup({ action, projectDir, ui: 'umbrella' });
|
|
@@ -179,8 +191,8 @@ async function main() {
|
|
|
179
191
|
'Review'
|
|
180
192
|
);
|
|
181
193
|
|
|
182
|
-
const ok = await confirm({ message: 'Apply?', initialValue: true });
|
|
183
|
-
if (isCancel(ok) || !ok) dieCancelled('No changes
|
|
194
|
+
const ok = await confirm({ message: 'Apply changes?', initialValue: true });
|
|
195
|
+
if (isCancel(ok) || !ok) dieCancelled('No changes made');
|
|
184
196
|
|
|
185
197
|
if (target === 'projectOnly') {
|
|
186
198
|
// Write project config
|
|
@@ -209,7 +221,7 @@ async function main() {
|
|
|
209
221
|
|
|
210
222
|
s.stop('Done');
|
|
211
223
|
|
|
212
|
-
note(JSON.stringify(snippetObj, null, 2), 'Paste into ~/.claude/settings.json');
|
|
224
|
+
note(JSON.stringify(snippetObj, null, 2), 'Paste into ~/.claude/settings.json (global)');
|
|
213
225
|
await maybeWriteSnippet(projectDir, snippetObj);
|
|
214
226
|
|
|
215
227
|
outro(`Project config written: ${pc.bold(configFilePath(projectDir))}`);
|