refactor(extensions): simplify lib helpers, tool registration and kit-doctor

Behavior-preserving cleanups:
- extract shared resolveBaseUrl helper for jira/confluence base-URL logic
- extract shared registerTool helper; port jira/gitlab/confluence tools to it
- make scanSecrets declarative (filter/map)
- collapse ok/warn pair into status() and drop double existsSync in kit-doctor

Typecheck clean; npm test 71 PASS, 0 FAIL.
This commit is contained in:
Aleksey Shakhmatov
2026-08-07 00:24:04 +03:00
parent 88eb02e17f
commit 0c6e590273
9 changed files with 212 additions and 202 deletions
+2 -6
View File
@@ -29,12 +29,8 @@ export const SECRET_PATTERNS: SecretPattern[] = [
/** Return the names of secret patterns found in `text` (empty if none). */
export function scanSecrets(text: string): string[] {
if (!text) return [];
const hits: string[] = [];
for (const p of SECRET_PATTERNS) {
// Use a non-stateful copy (no global flag) to avoid lastIndex surprises.
if (p.re.test(text)) hits.push(p.name);
}
return hits;
// No pattern carries the /g flag, so `test` stays stateless and order is preserved.
return SECRET_PATTERNS.filter((p) => p.re.test(text)).map((p) => p.name);
}
/** Replace every secret occurrence with a labelled placeholder. */