@hasnaxyz/hook-checktasks 1.0.1 → 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 +29 -9
- package/dist/hook.js +29 -9
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -59,7 +59,8 @@ function getSessionName(transcriptPath) {
|
|
|
59
59
|
return null;
|
|
60
60
|
try {
|
|
61
61
|
const content = readFileSync(transcriptPath, "utf-8");
|
|
62
|
-
let
|
|
62
|
+
let customTitle = null;
|
|
63
|
+
let slug = null;
|
|
63
64
|
let searchStart = 0;
|
|
64
65
|
while (true) {
|
|
65
66
|
const titleIndex = content.indexOf('"custom-title"', searchStart);
|
|
@@ -73,12 +74,18 @@ function getSessionName(transcriptPath) {
|
|
|
73
74
|
try {
|
|
74
75
|
const entry = JSON.parse(line);
|
|
75
76
|
if (entry.type === "custom-title" && entry.customTitle) {
|
|
76
|
-
|
|
77
|
+
customTitle = entry.customTitle;
|
|
77
78
|
}
|
|
78
79
|
} catch {}
|
|
79
80
|
searchStart = titleIndex + 1;
|
|
80
81
|
}
|
|
81
|
-
|
|
82
|
+
if (!customTitle) {
|
|
83
|
+
const slugMatch = content.match(/"slug"\s*:\s*"([^"]+)"/);
|
|
84
|
+
if (slugMatch) {
|
|
85
|
+
slug = slugMatch[1];
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return customTitle || slug;
|
|
82
89
|
} catch {
|
|
83
90
|
return null;
|
|
84
91
|
}
|
|
@@ -140,20 +147,33 @@ function run() {
|
|
|
140
147
|
if (hookInput?.transcript_path) {
|
|
141
148
|
sessionName = getSessionName(hookInput.transcript_path);
|
|
142
149
|
}
|
|
143
|
-
const nameToCheck = sessionName || config.taskListId || "";
|
|
144
150
|
const keywords = config.keywords || ["dev"];
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
+
};
|
|
149
158
|
let listsToCheck = [];
|
|
150
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
|
+
}
|
|
151
165
|
listsToCheck = [config.taskListId];
|
|
152
166
|
} else {
|
|
153
167
|
const projectLists = getProjectTaskLists(cwd);
|
|
154
168
|
if (projectLists.length > 0) {
|
|
155
169
|
if (keywords.length > 0) {
|
|
156
|
-
|
|
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
|
+
}
|
|
157
177
|
} else {
|
|
158
178
|
listsToCheck = projectLists;
|
|
159
179
|
}
|
package/dist/hook.js
CHANGED
|
@@ -55,7 +55,8 @@ function getSessionName(transcriptPath) {
|
|
|
55
55
|
return null;
|
|
56
56
|
try {
|
|
57
57
|
const content = readFileSync(transcriptPath, "utf-8");
|
|
58
|
-
let
|
|
58
|
+
let customTitle = null;
|
|
59
|
+
let slug = null;
|
|
59
60
|
let searchStart = 0;
|
|
60
61
|
while (true) {
|
|
61
62
|
const titleIndex = content.indexOf('"custom-title"', searchStart);
|
|
@@ -69,12 +70,18 @@ function getSessionName(transcriptPath) {
|
|
|
69
70
|
try {
|
|
70
71
|
const entry = JSON.parse(line);
|
|
71
72
|
if (entry.type === "custom-title" && entry.customTitle) {
|
|
72
|
-
|
|
73
|
+
customTitle = entry.customTitle;
|
|
73
74
|
}
|
|
74
75
|
} catch {}
|
|
75
76
|
searchStart = titleIndex + 1;
|
|
76
77
|
}
|
|
77
|
-
|
|
78
|
+
if (!customTitle) {
|
|
79
|
+
const slugMatch = content.match(/"slug"\s*:\s*"([^"]+)"/);
|
|
80
|
+
if (slugMatch) {
|
|
81
|
+
slug = slugMatch[1];
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return customTitle || slug;
|
|
78
85
|
} catch {
|
|
79
86
|
return null;
|
|
80
87
|
}
|
|
@@ -136,20 +143,33 @@ function run() {
|
|
|
136
143
|
if (hookInput?.transcript_path) {
|
|
137
144
|
sessionName = getSessionName(hookInput.transcript_path);
|
|
138
145
|
}
|
|
139
|
-
const nameToCheck = sessionName || config.taskListId || "";
|
|
140
146
|
const keywords = config.keywords || ["dev"];
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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
|
+
};
|
|
145
154
|
let listsToCheck = [];
|
|
146
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
|
+
}
|
|
147
161
|
listsToCheck = [config.taskListId];
|
|
148
162
|
} else {
|
|
149
163
|
const projectLists = getProjectTaskLists(cwd);
|
|
150
164
|
if (projectLists.length > 0) {
|
|
151
165
|
if (keywords.length > 0) {
|
|
152
|
-
|
|
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
|
+
}
|
|
153
173
|
} else {
|
|
154
174
|
listsToCheck = projectLists;
|
|
155
175
|
}
|