@hasnaxyz/hook-checktasks 0.2.0 → 0.2.1

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 +39 -11
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -325,7 +325,7 @@ async function prompt(question) {
325
325
  });
326
326
  });
327
327
  }
328
- function getAvailableTaskLists() {
328
+ function getAllTaskLists() {
329
329
  const tasksDir = join2(homedir2(), ".claude", "tasks");
330
330
  if (!existsSync2(tasksDir))
331
331
  return [];
@@ -335,6 +335,20 @@ function getAvailableTaskLists() {
335
335
  return [];
336
336
  }
337
337
  }
338
+ function getProjectTaskLists(projectPath) {
339
+ const allLists = getAllTaskLists();
340
+ const dirName = projectPath.split("/").filter(Boolean).pop() || "";
341
+ const projectLists = allLists.filter((list) => {
342
+ const listLower = list.toLowerCase();
343
+ const dirLower = dirName.toLowerCase();
344
+ if (listLower.startsWith(dirLower + "-"))
345
+ return true;
346
+ if (listLower.includes(dirLower))
347
+ return true;
348
+ return false;
349
+ });
350
+ return projectLists;
351
+ }
338
352
  async function resolveTarget(args) {
339
353
  if (args.includes("--global") || args.includes("-g")) {
340
354
  return { path: "global", label: "global (~/.claude/settings.json)" };
@@ -384,20 +398,22 @@ async function resolveTarget(args) {
384
398
  return null;
385
399
  }
386
400
  }
387
- async function promptForConfig(existingConfig = {}) {
401
+ async function promptForConfig(existingConfig = {}, projectPath) {
388
402
  const config = { ...existingConfig };
389
- const availableLists = getAvailableTaskLists();
403
+ const availableLists = projectPath ? getProjectTaskLists(projectPath) : getAllTaskLists();
390
404
  console.log(`
391
405
  ${c.bold("Configuration")}
392
406
  `);
393
407
  console.log(c.bold("Task List ID:"));
394
408
  if (availableLists.length > 0) {
395
- console.log(c.dim(" Available lists:"));
409
+ console.log(c.dim(" Available lists for this project:"));
396
410
  availableLists.forEach((list, i) => {
397
411
  console.log(c.dim(` ${i + 1}. ${list}`));
398
412
  });
413
+ } else {
414
+ console.log(c.dim(" No task lists found for this project"));
399
415
  }
400
- console.log(c.dim(` Leave empty to check ALL task lists
416
+ console.log(c.dim(` Leave empty to check all matching lists
401
417
  `));
402
418
  const currentList = config.taskListId || "(all lists)";
403
419
  const listInput = await prompt(`Task list ID [${c.cyan(currentList)}]: `);
@@ -439,7 +455,8 @@ ${c.bold("hook-checktasks install")}
439
455
  settings = addHook(settings);
440
456
  }
441
457
  const existingConfig = getConfig2(settings);
442
- const config = await promptForConfig(existingConfig);
458
+ const projectPath = target.path === "global" ? undefined : target.path;
459
+ const config = await promptForConfig(existingConfig, projectPath);
443
460
  settings = setConfig(settings, config);
444
461
  writeSettings(settingsPath, settings);
445
462
  console.log();
@@ -470,7 +487,8 @@ ${c.bold("hook-checktasks config")}
470
487
  return;
471
488
  }
472
489
  const existingConfig = getConfig2(settings);
473
- const config = await promptForConfig(existingConfig);
490
+ const projectPath = target.path === "global" ? undefined : target.path;
491
+ const config = await promptForConfig(existingConfig, projectPath);
474
492
  settings = setConfig(settings, config);
475
493
  writeSettings(settingsPath, settings);
476
494
  console.log();
@@ -527,11 +545,21 @@ ${c.bold("hook-checktasks status")}
527
545
  } else {
528
546
  console.log(c.dim("\xB7"), "Project:", c.dim("No .claude/settings.json"));
529
547
  }
530
- const lists = getAvailableTaskLists();
531
- if (lists.length > 0) {
548
+ const projectLists = getProjectTaskLists(cwd);
549
+ if (projectLists.length > 0) {
532
550
  console.log();
533
- console.log(c.bold("Available task lists:"));
534
- lists.forEach((list) => console.log(c.dim(` - ${list}`)));
551
+ console.log(c.bold("Task lists for this project:"));
552
+ projectLists.forEach((list) => console.log(c.dim(` - ${list}`)));
553
+ } else {
554
+ const allLists = getAllTaskLists();
555
+ if (allLists.length > 0) {
556
+ console.log();
557
+ console.log(c.bold("All task lists:"), c.dim("(none match this project)"));
558
+ allLists.slice(0, 10).forEach((list) => console.log(c.dim(` - ${list}`)));
559
+ if (allLists.length > 10) {
560
+ console.log(c.dim(` ... and ${allLists.length - 10} more`));
561
+ }
562
+ }
535
563
  }
536
564
  const envTaskList = process.env.CLAUDE_CODE_TASK_LIST_ID;
537
565
  if (envTaskList) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasnaxyz/hook-checktasks",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Claude Code hook that prevents stopping when there are pending tasks",
5
5
  "type": "module",
6
6
  "bin": {