@handsupmin/gc-tree 1.1.5 → 1.1.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.
- package/dist/src/hook.js +18 -31
- package/package.json +1 -1
package/dist/src/hook.js
CHANGED
|
@@ -197,7 +197,6 @@ export async function dispatchGcTreeHook({ event, home, payload, }) {
|
|
|
197
197
|
const prompt = normalizeText(payload.user_prompt || payload.prompt || '');
|
|
198
198
|
if (!prompt)
|
|
199
199
|
return null;
|
|
200
|
-
const branchStatus = await statusForBranch(home, gcBranch);
|
|
201
200
|
const previousCache = await readHookCache(home, sessionId);
|
|
202
201
|
const promptSignature = hashQuery(`${event}:${gcBranch}:${currentRepo || ''}:${repoScopeStatus}:${prompt}`);
|
|
203
202
|
if (previousCache?.last_prompt_signature === promptSignature &&
|
|
@@ -221,47 +220,35 @@ export async function dispatchGcTreeHook({ event, home, payload, }) {
|
|
|
221
220
|
cached: previousCache?.branch_excluded === true,
|
|
222
221
|
});
|
|
223
222
|
}
|
|
224
|
-
else if (
|
|
225
|
-
const wasCached = cache.branch_empty;
|
|
226
|
-
cache.branch_empty = true;
|
|
227
|
-
additionalContext = buildEmptyBranchContext({ gcBranch, currentRepo, cached: wasCached });
|
|
228
|
-
}
|
|
229
|
-
else if (repoScopeStatus === 'unmapped' && currentRepo && cache.unmapped_shown_repos.includes(currentRepo)) {
|
|
230
|
-
// Already showed context for this unmapped repo this session — skip silently.
|
|
223
|
+
else if (repoScopeStatus === 'unmapped' && currentRepo) {
|
|
231
224
|
cache.updated_at = now.toISOString();
|
|
232
225
|
await writeHookCache(home, cache);
|
|
233
226
|
return null;
|
|
234
227
|
}
|
|
235
228
|
else {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
additionalContext = buildNoMatchContext({ gcBranch, currentRepo, cached: true });
|
|
229
|
+
const branchStatus = await statusForBranch(home, gcBranch);
|
|
230
|
+
if (branchStatus.doc_count === 0) {
|
|
231
|
+
const wasCached = cache.branch_empty;
|
|
232
|
+
cache.branch_empty = true;
|
|
233
|
+
additionalContext = buildEmptyBranchContext({ gcBranch, currentRepo, cached: wasCached });
|
|
242
234
|
}
|
|
243
235
|
else {
|
|
244
|
-
const
|
|
245
|
-
const
|
|
246
|
-
if (
|
|
247
|
-
|
|
248
|
-
// Unmapped + no strong match: skip silently, no noise.
|
|
249
|
-
cache.updated_at = now.toISOString();
|
|
250
|
-
await writeHookCache(home, cache);
|
|
251
|
-
return null;
|
|
252
|
-
}
|
|
253
|
-
cache.no_match_signatures = [...new Set([...cache.no_match_signatures, signature])];
|
|
254
|
-
additionalContext = buildNoMatchContext({ gcBranch, currentRepo, cached: false });
|
|
236
|
+
const query = currentRepo ? `${currentRepo} ${prompt}` : prompt;
|
|
237
|
+
const signature = hashQuery(query);
|
|
238
|
+
if (cache.no_match_signatures.includes(signature)) {
|
|
239
|
+
additionalContext = buildNoMatchContext({ gcBranch, currentRepo, cached: true });
|
|
255
240
|
}
|
|
256
241
|
else {
|
|
257
|
-
|
|
258
|
-
|
|
242
|
+
const result = await resolveContext({ home, branch: gcBranch, query });
|
|
243
|
+
const effectiveMatches = result.matches;
|
|
244
|
+
if (effectiveMatches.length === 0) {
|
|
245
|
+
cache.no_match_signatures = [...new Set([...cache.no_match_signatures, signature])];
|
|
246
|
+
additionalContext = buildNoMatchContext({ gcBranch, currentRepo, cached: false });
|
|
259
247
|
}
|
|
260
|
-
else
|
|
261
|
-
|
|
262
|
-
|
|
248
|
+
else {
|
|
249
|
+
cache.no_match_signatures = cache.no_match_signatures.filter((entry) => entry !== signature);
|
|
250
|
+
additionalContext = buildMatchContext({ gcBranch, currentRepo, repoScopeStatus, matches: effectiveMatches });
|
|
263
251
|
}
|
|
264
|
-
additionalContext = buildMatchContext({ gcBranch, currentRepo, repoScopeStatus, matches: effectiveMatches });
|
|
265
252
|
}
|
|
266
253
|
}
|
|
267
254
|
if (cache.prompt_count > 0 && cache.prompt_count % SELF_REVIEW_INTERVAL === 0) {
|