@hasnaxyz/hook-checktasks 1.0.3 → 1.0.6

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 +10 -22
  2. package/dist/hook.js +9 -22
  3. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- import { createRequire } from "node:module";
4
3
  var __defProp = Object.defineProperty;
5
4
  var __export = (target, all) => {
6
5
  for (var name in all)
@@ -12,7 +11,6 @@ var __export = (target, all) => {
12
11
  });
13
12
  };
14
13
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
15
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
16
14
 
17
15
  // src/hook.ts
18
16
  var exports_hook = {};
@@ -148,32 +146,24 @@ function run() {
148
146
  sessionName = getSessionName(hookInput.transcript_path);
149
147
  }
150
148
  const keywords = config.keywords || ["dev"];
151
- const matchesKeywords = (name) => {
152
- if (!name)
153
- return false;
149
+ const sessionMatchesKeywords = () => {
154
150
  if (keywords.length === 0)
155
151
  return true;
156
- return keywords.some((keyword) => name.toLowerCase().includes(keyword.toLowerCase()));
152
+ if (!sessionName)
153
+ return false;
154
+ return keywords.some((keyword) => sessionName.toLowerCase().includes(keyword.toLowerCase()));
157
155
  };
156
+ if (!sessionMatchesKeywords()) {
157
+ approve();
158
+ }
158
159
  let listsToCheck = [];
159
160
  if (config.taskListId) {
160
- const taskListMatches = matchesKeywords(config.taskListId);
161
- const sessionMatches = matchesKeywords(sessionName);
162
- if (keywords.length > 0 && !taskListMatches && !sessionMatches) {
163
- approve();
164
- }
165
161
  listsToCheck = [config.taskListId];
166
162
  } else {
167
163
  const projectLists = getProjectTaskLists(cwd);
168
164
  if (projectLists.length > 0) {
169
165
  if (keywords.length > 0) {
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
- }
166
+ listsToCheck = projectLists.filter((list) => keywords.some((keyword) => list.toLowerCase().includes(keyword.toLowerCase())));
177
167
  } else {
178
168
  listsToCheck = projectLists;
179
169
  }
@@ -206,7 +196,7 @@ function run() {
206
196
  const prompt = `
207
197
  STOP BLOCKED: You have ${remainingCount} tasks remaining${listInfo} (${allPending.length} pending, ${allInProgress.length} in progress, ${allCompleted.length} completed).
208
198
 
209
- DO NOT STOP. DO NOT ASK QUESTIONS. DO NOT WAIT FOR USER INPUT.
199
+ DO NOT STOP. DO NOT ASK QUESTIONS. DO NOT WAIT FOR USER INPUT.
210
200
 
211
201
  You MUST continue working AUTONOMOUSLY until ALL tasks are completed.
212
202
 
@@ -237,9 +227,7 @@ START WORKING NOW. Use TaskList tool in your next response.
237
227
  approve();
238
228
  }
239
229
  var CONFIG_KEY = "checkTasksConfig";
240
- var init_hook = __esm(() => {
241
- if (false) {}
242
- });
230
+ var init_hook = () => {};
243
231
 
244
232
  // src/cli.ts
245
233
  import { existsSync as existsSync2, readFileSync as readFileSync2, writeFileSync, mkdirSync, readdirSync as readdirSync2 } from "fs";
package/dist/hook.js CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env bun
2
- import { createRequire } from "node:module";
3
2
  var __defProp = Object.defineProperty;
4
3
  var __export = (target, all) => {
5
4
  for (var name in all)
@@ -11,7 +10,6 @@ var __export = (target, all) => {
11
10
  });
12
11
  };
13
12
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
14
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
15
13
 
16
14
  // src/hook.ts
17
15
  import { readdirSync, readFileSync, existsSync } from "fs";
@@ -144,32 +142,24 @@ function run() {
144
142
  sessionName = getSessionName(hookInput.transcript_path);
145
143
  }
146
144
  const keywords = config.keywords || ["dev"];
147
- const matchesKeywords = (name) => {
148
- if (!name)
149
- return false;
145
+ const sessionMatchesKeywords = () => {
150
146
  if (keywords.length === 0)
151
147
  return true;
152
- return keywords.some((keyword) => name.toLowerCase().includes(keyword.toLowerCase()));
148
+ if (!sessionName)
149
+ return false;
150
+ return keywords.some((keyword) => sessionName.toLowerCase().includes(keyword.toLowerCase()));
153
151
  };
152
+ if (!sessionMatchesKeywords()) {
153
+ approve();
154
+ }
154
155
  let listsToCheck = [];
155
156
  if (config.taskListId) {
156
- const taskListMatches = matchesKeywords(config.taskListId);
157
- const sessionMatches = matchesKeywords(sessionName);
158
- if (keywords.length > 0 && !taskListMatches && !sessionMatches) {
159
- approve();
160
- }
161
157
  listsToCheck = [config.taskListId];
162
158
  } else {
163
159
  const projectLists = getProjectTaskLists(cwd);
164
160
  if (projectLists.length > 0) {
165
161
  if (keywords.length > 0) {
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
- }
162
+ listsToCheck = projectLists.filter((list) => keywords.some((keyword) => list.toLowerCase().includes(keyword.toLowerCase())));
173
163
  } else {
174
164
  listsToCheck = projectLists;
175
165
  }
@@ -202,7 +192,7 @@ function run() {
202
192
  const prompt = `
203
193
  STOP BLOCKED: You have ${remainingCount} tasks remaining${listInfo} (${allPending.length} pending, ${allInProgress.length} in progress, ${allCompleted.length} completed).
204
194
 
205
- DO NOT STOP. DO NOT ASK QUESTIONS. DO NOT WAIT FOR USER INPUT.
195
+ DO NOT STOP. DO NOT ASK QUESTIONS. DO NOT WAIT FOR USER INPUT.
206
196
 
207
197
  You MUST continue working AUTONOMOUSLY until ALL tasks are completed.
208
198
 
@@ -232,9 +222,6 @@ START WORKING NOW. Use TaskList tool in your next response.
232
222
  }
233
223
  approve();
234
224
  }
235
- if (__require.main == __require.module) {
236
- run();
237
- }
238
225
  export {
239
226
  run
240
227
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasnaxyz/hook-checktasks",
3
- "version": "1.0.3",
3
+ "version": "1.0.6",
4
4
  "description": "Claude Code hook that prevents stopping when there are pending tasks",
5
5
  "type": "module",
6
6
  "bin": {