@hasnaxyz/hook-checktasks 0.2.3 → 0.2.4

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.
Files changed (2) hide show
  1. package/dist/cli.js +58 -8
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -239,12 +239,16 @@ ${c.bold("USAGE:")}
239
239
 
240
240
  ${c.bold("OPTIONS:")}
241
241
  ${c.dim("(no args)")} Auto-detect: if in git repo \u2192 install there, else \u2192 prompt
242
- --global, -g Apply to ~/.claude/settings.json
243
- /path/to/repo Apply to specific project path
242
+ --global, -g Apply to ~/.claude/settings.json
243
+ --task-list-id, -t <id> Task list ID (non-interactive)
244
+ --keywords, -k <k1,k2> Keywords, comma-separated (non-interactive)
245
+ --yes, -y Non-interactive mode, use defaults
246
+ /path/to/repo Apply to specific project path
244
247
 
245
248
  ${c.bold("EXAMPLES:")}
246
249
  hook-checktasks install ${c.dim("# Install with config prompts")}
247
250
  hook-checktasks install --global ${c.dim("# Global install")}
251
+ hook-checktasks install -t myproject-dev -y ${c.dim("# Non-interactive")}
248
252
  hook-checktasks config ${c.dim("# Update task list ID, keywords")}
249
253
  hook-checktasks status ${c.dim("# Check what's installed")}
250
254
 
@@ -365,6 +369,24 @@ function getProjectTaskLists2(projectPath) {
365
369
  });
366
370
  return projectLists;
367
371
  }
372
+ function parseInstallArgs(args) {
373
+ const options = {};
374
+ for (let i = 0;i < args.length; i++) {
375
+ const arg = args[i];
376
+ if (arg === "--global" || arg === "-g") {
377
+ options.global = true;
378
+ } else if (arg === "--yes" || arg === "-y") {
379
+ options.yes = true;
380
+ } else if (arg === "--task-list-id" || arg === "-t") {
381
+ options.taskListId = args[++i];
382
+ } else if (arg === "--keywords" || arg === "-k") {
383
+ options.keywords = args[++i]?.split(",").map((k) => k.trim().toLowerCase()).filter(Boolean);
384
+ } else if (!arg.startsWith("-")) {
385
+ options.path = arg;
386
+ }
387
+ }
388
+ return options;
389
+ }
368
390
  async function resolveTarget(args) {
369
391
  if (args.includes("--global") || args.includes("-g")) {
370
392
  return { path: "global", label: "global (~/.claude/settings.json)" };
@@ -457,22 +479,50 @@ async function install(args) {
457
479
  console.log(`
458
480
  ${c.bold("hook-checktasks install")}
459
481
  `);
460
- const target = await resolveTarget(args);
482
+ const options = parseInstallArgs(args);
483
+ let target = null;
484
+ if (options.global) {
485
+ target = { path: "global", label: "global (~/.claude/settings.json)" };
486
+ } else if (options.path) {
487
+ const fullPath = resolve(options.path);
488
+ if (!existsSync2(fullPath)) {
489
+ console.log(c.red("\u2717"), `Path does not exist: ${fullPath}`);
490
+ return;
491
+ }
492
+ target = { path: fullPath, label: `project (${fullPath})` };
493
+ } else if (options.yes) {
494
+ const cwd = process.cwd();
495
+ target = { path: cwd, label: `project (${cwd})` };
496
+ } else {
497
+ target = await resolveTarget(args);
498
+ }
461
499
  if (!target)
462
500
  return;
463
501
  const settingsPath = getSettingsPath(target.path);
464
502
  let settings = readSettings2(settingsPath);
465
503
  if (hookExists(settings)) {
466
504
  console.log(c.yellow("!"), `Hook already installed in ${target.label}`);
467
- const update = await prompt("Update configuration? (y/n): ");
468
- if (update.toLowerCase() !== "y")
469
- return;
505
+ if (!options.yes) {
506
+ const update = await prompt("Update configuration? (y/n): ");
507
+ if (update.toLowerCase() !== "y")
508
+ return;
509
+ }
470
510
  } else {
471
511
  settings = addHook(settings);
472
512
  }
473
513
  const existingConfig = getConfig2(settings);
474
- const projectPath = target.path === "global" ? undefined : target.path;
475
- const config = await promptForConfig(existingConfig, projectPath);
514
+ let config;
515
+ if (options.yes || options.taskListId || options.keywords) {
516
+ config = {
517
+ ...existingConfig,
518
+ taskListId: options.taskListId || existingConfig.taskListId,
519
+ keywords: options.keywords || existingConfig.keywords || ["dev"],
520
+ enabled: true
521
+ };
522
+ } else {
523
+ const projectPath = target.path === "global" ? undefined : target.path;
524
+ config = await promptForConfig(existingConfig, projectPath);
525
+ }
476
526
  settings = setConfig(settings, config);
477
527
  writeSettings(settingsPath, settings);
478
528
  console.log();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasnaxyz/hook-checktasks",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Claude Code hook that prevents stopping when there are pending tasks",
5
5
  "type": "module",
6
6
  "bin": {