@hasnaxyz/hook-checktasks 0.2.0 → 0.2.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.
Files changed (3) hide show
  1. package/dist/cli.js +61 -17
  2. package/dist/hook.js +22 -6
  3. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -83,7 +83,7 @@ function getSessionName(transcriptPath) {
83
83
  return null;
84
84
  }
85
85
  }
86
- function getTaskLists() {
86
+ function getAllTaskLists() {
87
87
  const tasksDir = join(homedir(), ".claude", "tasks");
88
88
  if (!existsSync(tasksDir))
89
89
  return [];
@@ -93,6 +93,20 @@ function getTaskLists() {
93
93
  return [];
94
94
  }
95
95
  }
96
+ function getProjectTaskLists(cwd) {
97
+ const allLists = getAllTaskLists();
98
+ const dirName = cwd.split("/").filter(Boolean).pop() || "";
99
+ const projectLists = allLists.filter((list) => {
100
+ const listLower = list.toLowerCase();
101
+ const dirLower = dirName.toLowerCase();
102
+ if (listLower.startsWith(dirLower + "-"))
103
+ return true;
104
+ if (listLower === dirLower)
105
+ return true;
106
+ return false;
107
+ });
108
+ return projectLists;
109
+ }
96
110
  function getTasksFromList(listId) {
97
111
  const tasksDir = join(homedir(), ".claude", "tasks", listId);
98
112
  if (!existsSync(tasksDir))
@@ -136,11 +150,13 @@ function run() {
136
150
  if (config.taskListId) {
137
151
  listsToCheck = [config.taskListId];
138
152
  } else {
139
- const allLists = getTaskLists();
140
- if (keywords.length > 0) {
141
- listsToCheck = allLists.filter((list) => keywords.some((keyword) => list.toLowerCase().includes(keyword.toLowerCase())));
142
- } else {
143
- listsToCheck = allLists;
153
+ const projectLists = getProjectTaskLists(cwd);
154
+ if (projectLists.length > 0) {
155
+ if (keywords.length > 0) {
156
+ listsToCheck = projectLists.filter((list) => keywords.some((keyword) => list.toLowerCase().includes(keyword.toLowerCase())));
157
+ } else {
158
+ listsToCheck = projectLists;
159
+ }
144
160
  }
145
161
  }
146
162
  if (listsToCheck.length === 0) {
@@ -325,7 +341,7 @@ async function prompt(question) {
325
341
  });
326
342
  });
327
343
  }
328
- function getAvailableTaskLists() {
344
+ function getAllTaskLists2() {
329
345
  const tasksDir = join2(homedir2(), ".claude", "tasks");
330
346
  if (!existsSync2(tasksDir))
331
347
  return [];
@@ -335,6 +351,20 @@ function getAvailableTaskLists() {
335
351
  return [];
336
352
  }
337
353
  }
354
+ function getProjectTaskLists2(projectPath) {
355
+ const allLists = getAllTaskLists2();
356
+ const dirName = projectPath.split("/").filter(Boolean).pop() || "";
357
+ const projectLists = allLists.filter((list) => {
358
+ const listLower = list.toLowerCase();
359
+ const dirLower = dirName.toLowerCase();
360
+ if (listLower.startsWith(dirLower + "-"))
361
+ return true;
362
+ if (listLower.includes(dirLower))
363
+ return true;
364
+ return false;
365
+ });
366
+ return projectLists;
367
+ }
338
368
  async function resolveTarget(args) {
339
369
  if (args.includes("--global") || args.includes("-g")) {
340
370
  return { path: "global", label: "global (~/.claude/settings.json)" };
@@ -384,20 +414,22 @@ async function resolveTarget(args) {
384
414
  return null;
385
415
  }
386
416
  }
387
- async function promptForConfig(existingConfig = {}) {
417
+ async function promptForConfig(existingConfig = {}, projectPath) {
388
418
  const config = { ...existingConfig };
389
- const availableLists = getAvailableTaskLists();
419
+ const availableLists = projectPath ? getProjectTaskLists2(projectPath) : getAllTaskLists2();
390
420
  console.log(`
391
421
  ${c.bold("Configuration")}
392
422
  `);
393
423
  console.log(c.bold("Task List ID:"));
394
424
  if (availableLists.length > 0) {
395
- console.log(c.dim(" Available lists:"));
425
+ console.log(c.dim(" Available lists for this project:"));
396
426
  availableLists.forEach((list, i) => {
397
427
  console.log(c.dim(` ${i + 1}. ${list}`));
398
428
  });
429
+ } else {
430
+ console.log(c.dim(" No task lists found for this project"));
399
431
  }
400
- console.log(c.dim(` Leave empty to check ALL task lists
432
+ console.log(c.dim(` Leave empty to check all matching lists
401
433
  `));
402
434
  const currentList = config.taskListId || "(all lists)";
403
435
  const listInput = await prompt(`Task list ID [${c.cyan(currentList)}]: `);
@@ -439,7 +471,8 @@ ${c.bold("hook-checktasks install")}
439
471
  settings = addHook(settings);
440
472
  }
441
473
  const existingConfig = getConfig2(settings);
442
- const config = await promptForConfig(existingConfig);
474
+ const projectPath = target.path === "global" ? undefined : target.path;
475
+ const config = await promptForConfig(existingConfig, projectPath);
443
476
  settings = setConfig(settings, config);
444
477
  writeSettings(settingsPath, settings);
445
478
  console.log();
@@ -470,7 +503,8 @@ ${c.bold("hook-checktasks config")}
470
503
  return;
471
504
  }
472
505
  const existingConfig = getConfig2(settings);
473
- const config = await promptForConfig(existingConfig);
506
+ const projectPath = target.path === "global" ? undefined : target.path;
507
+ const config = await promptForConfig(existingConfig, projectPath);
474
508
  settings = setConfig(settings, config);
475
509
  writeSettings(settingsPath, settings);
476
510
  console.log();
@@ -527,11 +561,21 @@ ${c.bold("hook-checktasks status")}
527
561
  } else {
528
562
  console.log(c.dim("\xB7"), "Project:", c.dim("No .claude/settings.json"));
529
563
  }
530
- const lists = getAvailableTaskLists();
531
- if (lists.length > 0) {
564
+ const projectLists = getProjectTaskLists2(cwd);
565
+ if (projectLists.length > 0) {
532
566
  console.log();
533
- console.log(c.bold("Available task lists:"));
534
- lists.forEach((list) => console.log(c.dim(` - ${list}`)));
567
+ console.log(c.bold("Task lists for this project:"));
568
+ projectLists.forEach((list) => console.log(c.dim(` - ${list}`)));
569
+ } else {
570
+ const allLists = getAllTaskLists2();
571
+ if (allLists.length > 0) {
572
+ console.log();
573
+ console.log(c.bold("All task lists:"), c.dim("(none match this project)"));
574
+ allLists.slice(0, 10).forEach((list) => console.log(c.dim(` - ${list}`)));
575
+ if (allLists.length > 10) {
576
+ console.log(c.dim(` ... and ${allLists.length - 10} more`));
577
+ }
578
+ }
535
579
  }
536
580
  const envTaskList = process.env.CLAUDE_CODE_TASK_LIST_ID;
537
581
  if (envTaskList) {
package/dist/hook.js CHANGED
@@ -79,7 +79,7 @@ function getSessionName(transcriptPath) {
79
79
  return null;
80
80
  }
81
81
  }
82
- function getTaskLists() {
82
+ function getAllTaskLists() {
83
83
  const tasksDir = join(homedir(), ".claude", "tasks");
84
84
  if (!existsSync(tasksDir))
85
85
  return [];
@@ -89,6 +89,20 @@ function getTaskLists() {
89
89
  return [];
90
90
  }
91
91
  }
92
+ function getProjectTaskLists(cwd) {
93
+ const allLists = getAllTaskLists();
94
+ const dirName = cwd.split("/").filter(Boolean).pop() || "";
95
+ const projectLists = allLists.filter((list) => {
96
+ const listLower = list.toLowerCase();
97
+ const dirLower = dirName.toLowerCase();
98
+ if (listLower.startsWith(dirLower + "-"))
99
+ return true;
100
+ if (listLower === dirLower)
101
+ return true;
102
+ return false;
103
+ });
104
+ return projectLists;
105
+ }
92
106
  function getTasksFromList(listId) {
93
107
  const tasksDir = join(homedir(), ".claude", "tasks", listId);
94
108
  if (!existsSync(tasksDir))
@@ -132,11 +146,13 @@ function run() {
132
146
  if (config.taskListId) {
133
147
  listsToCheck = [config.taskListId];
134
148
  } else {
135
- const allLists = getTaskLists();
136
- if (keywords.length > 0) {
137
- listsToCheck = allLists.filter((list) => keywords.some((keyword) => list.toLowerCase().includes(keyword.toLowerCase())));
138
- } else {
139
- listsToCheck = allLists;
149
+ const projectLists = getProjectTaskLists(cwd);
150
+ if (projectLists.length > 0) {
151
+ if (keywords.length > 0) {
152
+ listsToCheck = projectLists.filter((list) => keywords.some((keyword) => list.toLowerCase().includes(keyword.toLowerCase())));
153
+ } else {
154
+ listsToCheck = projectLists;
155
+ }
140
156
  }
141
157
  }
142
158
  if (listsToCheck.length === 0) {
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.2",
4
4
  "description": "Claude Code hook that prevents stopping when there are pending tasks",
5
5
  "type": "module",
6
6
  "bin": {