@hopla/claude-setup 1.3.1 → 1.3.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.
- package/cli.js +58 -18
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -218,6 +218,14 @@ const HOPLA_PERMISSIONS = [
|
|
|
218
218
|
"Bash(echo *)",
|
|
219
219
|
];
|
|
220
220
|
|
|
221
|
+
const PLANNING_PERMISSIONS = [
|
|
222
|
+
"Bash(git branch*)",
|
|
223
|
+
"Bash(git log*)",
|
|
224
|
+
"Bash(git status*)",
|
|
225
|
+
];
|
|
226
|
+
|
|
227
|
+
const ALL_HOPLA_PERMISSIONS = new Set([...HOPLA_PERMISSIONS, ...PLANNING_PERMISSIONS]);
|
|
228
|
+
|
|
221
229
|
async function setupPermissions() {
|
|
222
230
|
const settingsPath = path.join(CLAUDE_DIR, "settings.json");
|
|
223
231
|
|
|
@@ -233,30 +241,62 @@ async function setupPermissions() {
|
|
|
233
241
|
if (!settings.permissions) settings.permissions = {};
|
|
234
242
|
if (!settings.permissions.allow) settings.permissions.allow = [];
|
|
235
243
|
|
|
236
|
-
|
|
237
|
-
const existing = new Set(settings.permissions.allow);
|
|
238
|
-
const toAdd = HOPLA_PERMISSIONS.filter((p) => !existing.has(p));
|
|
244
|
+
const targetPermissions = PLANNING ? PLANNING_PERMISSIONS : HOPLA_PERMISSIONS;
|
|
239
245
|
|
|
240
|
-
if (
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
246
|
+
if (PLANNING) {
|
|
247
|
+
// Replace: remove all hopla-owned permissions, then add planning-only ones
|
|
248
|
+
const cleaned = settings.permissions.allow.filter((p) => !ALL_HOPLA_PERMISSIONS.has(p));
|
|
249
|
+
const toAdd = targetPermissions.filter((p) => !cleaned.includes(p));
|
|
250
|
+
const toRemove = settings.permissions.allow.filter((p) => ALL_HOPLA_PERMISSIONS.has(p) && !targetPermissions.includes(p));
|
|
244
251
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
}
|
|
252
|
+
if (toAdd.length === 0 && toRemove.length === 0) {
|
|
253
|
+
log(`${GREEN}✓${RESET} Permissions already configured.\n`);
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
250
256
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
257
|
+
log(`${CYAN}Configuring permissions (planning mode)...${RESET}`);
|
|
258
|
+
log(` The following changes will be made to ~/.claude/settings.json:\n`);
|
|
259
|
+
for (const p of toRemove) {
|
|
260
|
+
log(` ${RED}-${RESET} ${p}`);
|
|
261
|
+
}
|
|
262
|
+
for (const p of toAdd) {
|
|
263
|
+
log(` ${CYAN}+${RESET} ${p}`);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
const ok = await confirm(`\n Apply these permission changes? (y/N) `);
|
|
267
|
+
if (!ok) {
|
|
268
|
+
log(` ${YELLOW}↷${RESET} Skipped — you can edit ~/.claude/settings.json manually\n`);
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
settings.permissions.allow = [...cleaned, ...targetPermissions];
|
|
273
|
+
} else {
|
|
274
|
+
// Merge: add missing ones
|
|
275
|
+
const existing = new Set(settings.permissions.allow);
|
|
276
|
+
const toAdd = targetPermissions.filter((p) => !existing.has(p));
|
|
277
|
+
|
|
278
|
+
if (toAdd.length === 0) {
|
|
279
|
+
log(`${GREEN}✓${RESET} Permissions already configured.\n`);
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
log(`${CYAN}Configuring permissions...${RESET}`);
|
|
284
|
+
log(` The following will be added to ~/.claude/settings.json:\n`);
|
|
285
|
+
for (const p of toAdd) {
|
|
286
|
+
log(` ${CYAN}+${RESET} ${p}`);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
const ok = await confirm(`\n Add these permissions? (y/N) `);
|
|
290
|
+
if (!ok) {
|
|
291
|
+
log(` ${YELLOW}↷${RESET} Skipped — you can add them manually to ~/.claude/settings.json\n`);
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
settings.permissions.allow = [...settings.permissions.allow, ...toAdd];
|
|
255
296
|
}
|
|
256
297
|
|
|
257
|
-
settings.permissions.allow = [...settings.permissions.allow, ...toAdd];
|
|
258
298
|
fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + "\n");
|
|
259
|
-
log(` ${GREEN}✓${RESET} Permissions
|
|
299
|
+
log(` ${GREEN}✓${RESET} Permissions configured.\n`);
|
|
260
300
|
}
|
|
261
301
|
|
|
262
302
|
const run = UNINSTALL ? uninstall : install;
|