@hasnaxyz/hook-checktasks 1.0.2 → 1.0.3

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/dist/cli.js CHANGED
@@ -147,20 +147,33 @@ function run() {
147
147
  if (hookInput?.transcript_path) {
148
148
  sessionName = getSessionName(hookInput.transcript_path);
149
149
  }
150
- const nameToCheck = sessionName || config.taskListId || "";
151
150
  const keywords = config.keywords || ["dev"];
152
- const matchesKeyword = keywords.some((keyword) => nameToCheck.toLowerCase().includes(keyword.toLowerCase()));
153
- if (!matchesKeyword && keywords.length > 0 && nameToCheck) {
154
- approve();
155
- }
151
+ const matchesKeywords = (name) => {
152
+ if (!name)
153
+ return false;
154
+ if (keywords.length === 0)
155
+ return true;
156
+ return keywords.some((keyword) => name.toLowerCase().includes(keyword.toLowerCase()));
157
+ };
156
158
  let listsToCheck = [];
157
159
  if (config.taskListId) {
160
+ const taskListMatches = matchesKeywords(config.taskListId);
161
+ const sessionMatches = matchesKeywords(sessionName);
162
+ if (keywords.length > 0 && !taskListMatches && !sessionMatches) {
163
+ approve();
164
+ }
158
165
  listsToCheck = [config.taskListId];
159
166
  } else {
160
167
  const projectLists = getProjectTaskLists(cwd);
161
168
  if (projectLists.length > 0) {
162
169
  if (keywords.length > 0) {
163
- listsToCheck = projectLists.filter((list) => keywords.some((keyword) => list.toLowerCase().includes(keyword.toLowerCase())));
170
+ const sessionMatches = matchesKeywords(sessionName);
171
+ const matchingLists = projectLists.filter((list) => matchesKeywords(list));
172
+ if (sessionMatches || matchingLists.length > 0) {
173
+ listsToCheck = matchingLists.length > 0 ? matchingLists : projectLists;
174
+ } else {
175
+ approve();
176
+ }
164
177
  } else {
165
178
  listsToCheck = projectLists;
166
179
  }
package/dist/hook.js CHANGED
@@ -143,20 +143,33 @@ function run() {
143
143
  if (hookInput?.transcript_path) {
144
144
  sessionName = getSessionName(hookInput.transcript_path);
145
145
  }
146
- const nameToCheck = sessionName || config.taskListId || "";
147
146
  const keywords = config.keywords || ["dev"];
148
- const matchesKeyword = keywords.some((keyword) => nameToCheck.toLowerCase().includes(keyword.toLowerCase()));
149
- if (!matchesKeyword && keywords.length > 0 && nameToCheck) {
150
- approve();
151
- }
147
+ const matchesKeywords = (name) => {
148
+ if (!name)
149
+ return false;
150
+ if (keywords.length === 0)
151
+ return true;
152
+ return keywords.some((keyword) => name.toLowerCase().includes(keyword.toLowerCase()));
153
+ };
152
154
  let listsToCheck = [];
153
155
  if (config.taskListId) {
156
+ const taskListMatches = matchesKeywords(config.taskListId);
157
+ const sessionMatches = matchesKeywords(sessionName);
158
+ if (keywords.length > 0 && !taskListMatches && !sessionMatches) {
159
+ approve();
160
+ }
154
161
  listsToCheck = [config.taskListId];
155
162
  } else {
156
163
  const projectLists = getProjectTaskLists(cwd);
157
164
  if (projectLists.length > 0) {
158
165
  if (keywords.length > 0) {
159
- listsToCheck = projectLists.filter((list) => keywords.some((keyword) => list.toLowerCase().includes(keyword.toLowerCase())));
166
+ const sessionMatches = matchesKeywords(sessionName);
167
+ const matchingLists = projectLists.filter((list) => matchesKeywords(list));
168
+ if (sessionMatches || matchingLists.length > 0) {
169
+ listsToCheck = matchingLists.length > 0 ? matchingLists : projectLists;
170
+ } else {
171
+ approve();
172
+ }
160
173
  } else {
161
174
  listsToCheck = projectLists;
162
175
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasnaxyz/hook-checktasks",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Claude Code hook that prevents stopping when there are pending tasks",
5
5
  "type": "module",
6
6
  "bin": {