@utilix-tech/sdk 0.65.0 → 0.67.0

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/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  Full release notes for all Utilix surfaces (browser tools, REST API, SDKs, MCP server) live at [utilix.tech/changelog](https://utilix.tech/changelog). This file tracks just this package.
4
4
 
5
+ ## 0.67.0
6
+ - Add `analyzeRegexGroups` (regex-groups): parse a regex pattern's capture groups (numbered and named) and backreferences, flagging any backreference pointing at a group that doesn't exist or hasn't finished being defined yet at that point in the pattern.
7
+
8
+ ## 0.66.0
9
+ - Add `buildXRobotsTag`, `parseXRobotsTag` (x-robots-tag-builder): build an X-Robots-Tag response header from flag directives (noindex, nofollow, etc.) plus max-snippet/max-image-preview/max-video-preview/unavailable_after value directives, optionally scoped to a crawler user-agent, or parse an existing header into the same shape.
10
+ - Add `lookupOpcode`, `listOpcodes` (websocket-opcode-reference): look up what a WebSocket frame opcode means per RFC 6455's 4-bit opcode space, or list every opcode.
11
+
5
12
  ## 0.65.0
6
13
  - Add `buildHsts`, `parseHsts` (hsts-header-builder): build a Strict-Transport-Security response header from a max-age plus includeSubDomains/preload flags, flagging combinations that won't qualify for browser HSTS preload lists, or parse an existing header into the same shape.
7
14
  - Add `alignMarkdownTables` (markdown-table-aligner): reformat every GitHub-Flavored-Markdown pipe table in a document so each column's pipes line up visually, preserving left/center/right alignment markers and skipping tables inside fenced code blocks.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @utilix-tech/sdk
2
2
 
3
- **678 developer utility functions for Node.js: runs locally, no API key required.**
3
+ **684 developer utility functions for Node.js: runs locally, no API key required.**
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/@utilix-tech/sdk?style=flat-square&color=cb3837)](https://www.npmjs.com/package/@utilix-tech/sdk)
6
6
  [![npm downloads](https://img.shields.io/npm/dm/@utilix-tech/sdk?style=flat-square)](https://www.npmjs.com/package/@utilix-tech/sdk)
@@ -725,7 +725,7 @@ generateCspHeader({ "default-src": ["'self'"], "script-src": ["'self'", "cdn.exa
725
725
  ```ts
726
726
  import { formatSql, minifySql, testRegex, formatHtml, formatGql,
727
727
  detectDialect, splitStatements, lookupMime, parseGithubUrl,
728
- detectRedos, testGitignorePatterns, validateEditorConfig,
728
+ detectRedos, analyzeRegexGroups, testGitignorePatterns, validateEditorConfig,
729
729
  validateTsconfig, validatePackageExports } from "@utilix-tech/sdk/code";
730
730
 
731
731
  // SQL
@@ -763,6 +763,10 @@ parseGithubUrl("https://github.com/facebook/react/pull/1234");
763
763
  detectRedos("(a+)+");
764
764
  // { risk: "high", safe: false, findings: [{ type: "nested-quantifier", ... }] }
765
765
 
766
+ // Regex capture group & backreference visualizer
767
+ analyzeRegexGroups("(a)(b)\\3");
768
+ // { groups: [{ index: 1, ... }, { index: 2, ... }], issues: [{ severity: "error", message: "Backreference \\3 ... doesn't exist ..." }] }
769
+
766
770
  // Test paths against a .gitignore file's patterns
767
771
  testGitignorePatterns("node_modules/\n*.log", ["node_modules/foo.js", "debug.log", "src/index.js"]);
768
772
  // [{ path: "node_modules/foo.js", ignored: true, matchedPattern: "node_modules/", matchedLine: 1 }, ...]
@@ -30,6 +30,7 @@ __export(network_exports, {
30
30
  buildRetryAfterHeader: () => buildRetryAfterHeader,
31
31
  buildVaryHeader: () => buildVaryHeader,
32
32
  buildXContentTypeOptionsHeader: () => buildXContentTypeOptionsHeader,
33
+ buildXRobotsTag: () => buildXRobotsTag,
33
34
  checkSetCookieHeader: () => checkSetCookieHeader,
34
35
  countryCodeToFlag: () => countryCodeToFlag,
35
36
  extractMultipartBoundary: () => extractMultipartBoundary,
@@ -47,7 +48,9 @@ __export(network_exports, {
47
48
  isValidIpv4: () => isValidIpv4,
48
49
  isValidIpv6: () => isValidIpv6,
49
50
  listCloseCodes: () => listCloseCodes,
51
+ listOpcodes: () => listOpcodes,
50
52
  lookupCloseCode: () => lookupCloseCode,
53
+ lookupOpcode: () => lookupOpcode,
51
54
  parseAcceptLanguage: () => parseAcceptLanguage,
52
55
  parseClientHintHeaders: () => parseClientHintHeaders,
53
56
  parseContentDisposition: () => parseContentDisposition,
@@ -65,6 +68,7 @@ __export(network_exports, {
65
68
  parseUserAgent: () => parseUserAgent,
66
69
  parseVaryHeader: () => parseVaryHeader,
67
70
  parseXContentTypeOptionsHeader: () => parseXContentTypeOptionsHeader,
71
+ parseXRobotsTag: () => parseXRobotsTag,
68
72
  searchHeaders: () => searchHeaders,
69
73
  searchStatusCodes: () => searchStatusCodes,
70
74
  splitSitemap: () => splitSitemap,
@@ -3247,5 +3251,161 @@ function parseHsts(raw) {
3247
3251
  if (maxAge === null) return { error: "max-age directive is required" };
3248
3252
  return buildHsts({ maxAge, includeSubDomains, preload });
3249
3253
  }
3254
+ var X_ROBOTS_TAG_FLAGS = /* @__PURE__ */ new Set(["noindex", "nofollow", "noarchive", "nosnippet", "notranslate", "noimageindex", "none", "all", "indexifembedded"]);
3255
+ var X_ROBOTS_TAG_FLAG_NOTES = {
3256
+ noindex: "Do not show this page in search results.",
3257
+ nofollow: "Do not follow, or pass ranking credit through, any links on this page.",
3258
+ noarchive: "Do not show a cached copy of this page in search results.",
3259
+ nosnippet: "Do not show a text snippet or video preview for this page in search results.",
3260
+ notranslate: "Do not offer a translation of this page in search results.",
3261
+ noimageindex: "Do not index images on this page.",
3262
+ none: "Shorthand for noindex plus nofollow combined.",
3263
+ all: "Explicitly allow indexing and following, the default with no directives at all.",
3264
+ indexifembedded: "Allow indexing of this page's content when embedded via iframe in another page, even if this page also carries noindex. Only Google supports this directive."
3265
+ };
3266
+ var X_ROBOTS_TAG_VALUED_DIRECTIVES = /* @__PURE__ */ new Set(["max-snippet", "max-image-preview", "max-video-preview", "unavailable_after"]);
3267
+ function _isXRobotsTagFlag(value) {
3268
+ return X_ROBOTS_TAG_FLAGS.has(value);
3269
+ }
3270
+ function buildXRobotsTag(options) {
3271
+ if (!options || typeof options !== "object") return { error: "At least one directive is required" };
3272
+ const { flags = [], maxSnippet, maxImagePreview, maxVideoPreview, unavailableAfter, userAgent } = options;
3273
+ if (!Array.isArray(flags)) return { error: "flags must be an array of directive names" };
3274
+ for (const flag of flags) {
3275
+ if (typeof flag !== "string" || !_isXRobotsTagFlag(flag)) return { error: `Unknown directive "${flag}"` };
3276
+ }
3277
+ if (maxSnippet !== void 0 && (typeof maxSnippet !== "number" || !Number.isInteger(maxSnippet) || maxSnippet < -1)) {
3278
+ return { error: "maxSnippet must be an integer >= -1" };
3279
+ }
3280
+ if (maxVideoPreview !== void 0 && (typeof maxVideoPreview !== "number" || !Number.isInteger(maxVideoPreview) || maxVideoPreview < -1)) {
3281
+ return { error: "maxVideoPreview must be an integer >= -1" };
3282
+ }
3283
+ if (maxImagePreview !== void 0 && !["none", "standard", "large"].includes(maxImagePreview)) {
3284
+ return { error: 'maxImagePreview must be one of "none", "standard", "large"' };
3285
+ }
3286
+ if (unavailableAfter !== void 0 && (typeof unavailableAfter !== "string" || unavailableAfter.trim() === "" || Number.isNaN(Date.parse(unavailableAfter)))) {
3287
+ return { error: "unavailableAfter must be a valid, parseable date string" };
3288
+ }
3289
+ const uniqueFlags = Array.from(new Set(flags));
3290
+ if (uniqueFlags.length === 0 && maxSnippet === void 0 && maxImagePreview === void 0 && maxVideoPreview === void 0 && unavailableAfter === void 0) {
3291
+ return { error: "At least one directive is required" };
3292
+ }
3293
+ const warnings = [];
3294
+ if (uniqueFlags.includes("none") && (uniqueFlags.includes("noindex") || uniqueFlags.includes("nofollow"))) {
3295
+ warnings.push('"none" already implies noindex and nofollow; combining it with either is redundant.');
3296
+ }
3297
+ if (uniqueFlags.includes("all") && uniqueFlags.some((f) => f !== "all" && f !== "indexifembedded")) {
3298
+ warnings.push('"all" explicitly allows indexing and following, which contradicts any restrictive directive combined with it.');
3299
+ }
3300
+ const directives = [...uniqueFlags];
3301
+ const notes = uniqueFlags.map((f) => `${f}: ${X_ROBOTS_TAG_FLAG_NOTES[f]}`);
3302
+ if (maxSnippet !== void 0) {
3303
+ directives.push(`max-snippet: ${maxSnippet}`);
3304
+ notes.push(`max-snippet: ${maxSnippet === 0 ? "Show no text snippet at all." : maxSnippet === -1 ? "No limit on snippet length." : `Limit the text snippet to at most ${maxSnippet} characters.`}`);
3305
+ }
3306
+ if (maxImagePreview !== void 0) {
3307
+ directives.push(`max-image-preview: ${maxImagePreview}`);
3308
+ notes.push(`max-image-preview: Limit any image preview shown in search results to the "${maxImagePreview}" size.`);
3309
+ }
3310
+ if (maxVideoPreview !== void 0) {
3311
+ directives.push(`max-video-preview: ${maxVideoPreview}`);
3312
+ notes.push(`max-video-preview: ${maxVideoPreview === 0 ? "Show no video preview at all, a static image only." : maxVideoPreview === -1 ? "No limit on video preview length." : `Limit the video preview to at most ${maxVideoPreview} seconds.`}`);
3313
+ }
3314
+ if (unavailableAfter !== void 0) {
3315
+ directives.push(`unavailable_after: ${unavailableAfter}`);
3316
+ notes.push(`unavailable_after: Stop showing this page in search results after this date.`);
3317
+ }
3318
+ const directivesJoined = directives.join(", ");
3319
+ const header = userAgent ? `${userAgent}: ${directivesJoined}` : directivesJoined;
3320
+ return {
3321
+ header,
3322
+ headerName: "X-Robots-Tag",
3323
+ snippet: `X-Robots-Tag: ${header}`,
3324
+ directives,
3325
+ notes,
3326
+ warnings
3327
+ };
3328
+ }
3329
+ function parseXRobotsTag(raw) {
3330
+ if (!raw || raw.trim() === "") return { error: "Input is empty" };
3331
+ let withoutLabel = raw.trim().replace(/^x-robots-tag:\s*/i, "");
3332
+ let userAgent;
3333
+ const firstColon = withoutLabel.indexOf(":");
3334
+ const firstComma = withoutLabel.indexOf(",");
3335
+ if (firstColon !== -1 && (firstComma === -1 || firstColon < firstComma)) {
3336
+ const candidate = withoutLabel.slice(0, firstColon).trim();
3337
+ const candidateLower = candidate.toLowerCase();
3338
+ if (candidate !== "" && !X_ROBOTS_TAG_VALUED_DIRECTIVES.has(candidateLower) && !_isXRobotsTagFlag(candidateLower)) {
3339
+ userAgent = candidate;
3340
+ withoutLabel = withoutLabel.slice(firstColon + 1).trim();
3341
+ }
3342
+ }
3343
+ const tokens = withoutLabel.split(",").map((t) => t.trim()).filter((t) => t !== "");
3344
+ if (tokens.length === 0) return { error: "No directives found" };
3345
+ const flags = [];
3346
+ let maxSnippet;
3347
+ let maxImagePreview;
3348
+ let maxVideoPreview;
3349
+ let unavailableAfter;
3350
+ for (const token of tokens) {
3351
+ const eq = token.indexOf(":");
3352
+ const name = (eq === -1 ? token : token.slice(0, eq)).trim().toLowerCase();
3353
+ const value = eq === -1 ? "" : token.slice(eq + 1).trim();
3354
+ if (eq === -1) {
3355
+ if (!_isXRobotsTagFlag(name)) return { error: `Unrecognized directive "${token}"` };
3356
+ flags.push(name);
3357
+ continue;
3358
+ }
3359
+ if (name === "max-snippet") {
3360
+ const n = Number(value);
3361
+ if (value === "" || !Number.isInteger(n) || n < -1) return { error: `max-snippet value "${value}" is not a valid integer >= -1` };
3362
+ maxSnippet = n;
3363
+ } else if (name === "max-image-preview") {
3364
+ if (!["none", "standard", "large"].includes(value)) return { error: `max-image-preview value "${value}" must be one of "none", "standard", "large"` };
3365
+ maxImagePreview = value;
3366
+ } else if (name === "max-video-preview") {
3367
+ const n = Number(value);
3368
+ if (value === "" || !Number.isInteger(n) || n < -1) return { error: `max-video-preview value "${value}" is not a valid integer >= -1` };
3369
+ maxVideoPreview = n;
3370
+ } else if (name === "unavailable_after") {
3371
+ if (value === "" || Number.isNaN(Date.parse(value))) return { error: `unavailable_after value "${value}" is not a valid, parseable date` };
3372
+ unavailableAfter = value;
3373
+ } else {
3374
+ return { error: `Unrecognized directive "${token}"` };
3375
+ }
3376
+ }
3377
+ return buildXRobotsTag({ flags, maxSnippet, maxImagePreview, maxVideoPreview, unavailableAfter, userAgent });
3378
+ }
3379
+ var WELL_KNOWN_OPCODES = {
3380
+ 0: { name: "Continuation Frame", description: "Continues a fragmented message whose first frame was a text or binary frame sent with the FIN bit unset.", category: "data" },
3381
+ 1: { name: "Text Frame", description: "Carries a UTF-8 encoded text payload.", category: "data" },
3382
+ 2: { name: "Binary Frame", description: "Carries an arbitrary binary payload.", category: "data" },
3383
+ 8: { name: "Connection Close", description: "Initiates or acknowledges closing the connection, optionally carrying a 2-byte close code and a UTF-8 reason in its payload.", category: "control" },
3384
+ 9: { name: "Ping", description: "A control frame used to check the connection is alive; the receiver should reply with a Pong carrying the same application data.", category: "control" },
3385
+ 10: { name: "Pong", description: "Sent in response to a Ping (or unprompted as a heartbeat), carrying the same application data as the Ping it answers.", category: "control" }
3386
+ };
3387
+ var RESERVED_NON_CONTROL_OPCODES = /* @__PURE__ */ new Set([3, 4, 5, 6, 7]);
3388
+ function _describeOpcode(opcode) {
3389
+ const known = WELL_KNOWN_OPCODES[opcode];
3390
+ const hex = `0x${opcode.toString(16).toUpperCase()}`;
3391
+ if (known) {
3392
+ return { opcode, hex, name: known.name, description: known.description, category: known.category, isControl: known.category === "control" };
3393
+ }
3394
+ if (RESERVED_NON_CONTROL_OPCODES.has(opcode)) {
3395
+ return { opcode, hex, name: "Reserved (non-control)", description: "Reserved for future non-control frame types by a later revision of the WebSocket protocol. No meaning is defined yet; a compliant endpoint must fail the connection if it receives one.", category: "reserved-non-control", isControl: false };
3396
+ }
3397
+ return { opcode, hex, name: "Reserved (control)", description: "Reserved for future control frame types by a later revision of the WebSocket protocol. No meaning is defined yet; a compliant endpoint must fail the connection if it receives one.", category: "reserved-control", isControl: true };
3398
+ }
3399
+ function listOpcodes() {
3400
+ const result = [];
3401
+ for (let opcode = 0; opcode <= 15; opcode++) result.push(_describeOpcode(opcode));
3402
+ return result;
3403
+ }
3404
+ function lookupOpcode(opcode) {
3405
+ if (typeof opcode !== "number" || !Number.isInteger(opcode) || opcode < 0 || opcode > 15) {
3406
+ return { error: "opcode must be an integer between 0 and 15 (0x0-0xF); the frame opcode is only a 4-bit field" };
3407
+ }
3408
+ return _describeOpcode(opcode);
3409
+ }
3250
3410
 
3251
- export { CLIENT_HINTS, DNS_RECORD_TYPES, HTTP_HEADERS, LINK_REL_VALUES, PERMISSIONS_POLICY_FEATURES, REFERRER_POLICY_VALUES, STATUS_CODES, X_CONTENT_TYPE_OPTIONS_HEADER, analyzeEmailHeaders, assessContentTypeRisk, buildAcceptLanguage, buildCacheControl, buildClientHints, buildContentDisposition, buildDnsQueryUrl, buildGeoUrl, buildHsts, buildLinkHeader, buildMapUrl, buildPermissionsPolicy, buildPreferHeader, buildPriorityHeader, buildRangeHeader, buildReferrerPolicy, buildRetryAfterHeader, buildVaryHeader, buildXContentTypeOptionsHeader, checkSetCookieHeader, countryCodeToFlag, extractMultipartBoundary, formatCoordinates, formatTtl, getByCategory, getHeader, getHeadersByCategory, getStatusByCategory, getStatusCode, isClientError, isServerError, isSuccess, isValidIp, isValidIpv4, isValidIpv6, listCloseCodes, lookupCloseCode, network_exports, parseAcceptLanguage, parseClientHintHeaders, parseContentDisposition, parseContentRangeHeader, parseDnsResponse, parseGeoResponse, parseHar, parseHsts, parseIpv6Address, parseMultipartFormData, parsePermissionsPolicy, parsePreferHeader, parsePriorityHeader, parseRetryAfterHeader, parseUserAgent, parseVaryHeader, parseXContentTypeOptionsHeader, searchHeaders, searchStatusCodes, splitSitemap, statusCodeToText, typeNumberToLabel, validateDomain, validateHeaderName, validateHeaderValue, validateManifest, validateRobotsTxt, validateSitemap };
3411
+ export { CLIENT_HINTS, DNS_RECORD_TYPES, HTTP_HEADERS, LINK_REL_VALUES, PERMISSIONS_POLICY_FEATURES, REFERRER_POLICY_VALUES, STATUS_CODES, X_CONTENT_TYPE_OPTIONS_HEADER, analyzeEmailHeaders, assessContentTypeRisk, buildAcceptLanguage, buildCacheControl, buildClientHints, buildContentDisposition, buildDnsQueryUrl, buildGeoUrl, buildHsts, buildLinkHeader, buildMapUrl, buildPermissionsPolicy, buildPreferHeader, buildPriorityHeader, buildRangeHeader, buildReferrerPolicy, buildRetryAfterHeader, buildVaryHeader, buildXContentTypeOptionsHeader, buildXRobotsTag, checkSetCookieHeader, countryCodeToFlag, extractMultipartBoundary, formatCoordinates, formatTtl, getByCategory, getHeader, getHeadersByCategory, getStatusByCategory, getStatusCode, isClientError, isServerError, isSuccess, isValidIp, isValidIpv4, isValidIpv6, listCloseCodes, listOpcodes, lookupCloseCode, lookupOpcode, network_exports, parseAcceptLanguage, parseClientHintHeaders, parseContentDisposition, parseContentRangeHeader, parseDnsResponse, parseGeoResponse, parseHar, parseHsts, parseIpv6Address, parseMultipartFormData, parsePermissionsPolicy, parsePreferHeader, parsePriorityHeader, parseRetryAfterHeader, parseUserAgent, parseVaryHeader, parseXContentTypeOptionsHeader, parseXRobotsTag, searchHeaders, searchStatusCodes, splitSitemap, statusCodeToText, typeNumberToLabel, validateDomain, validateHeaderName, validateHeaderValue, validateManifest, validateRobotsTxt, validateSitemap };
@@ -10,6 +10,7 @@ __export(code_exports, {
10
10
  MIME_TABLE: () => MIME_TABLE,
11
11
  OPERATIONS: () => OPERATIONS,
12
12
  SQL_DEFAULT_OPTIONS: () => SQL_DEFAULT_OPTIONS,
13
+ analyzeRegexGroups: () => analyzeRegexGroups,
13
14
  auditDependencyRanges: () => auditDependencyRanges,
14
15
  buildDockerPull: () => buildDockerPull,
15
16
  buildDockerRun: () => buildDockerRun,
@@ -3485,5 +3486,113 @@ function auditDependencyRanges(packageJsonText) {
3485
3486
  issues
3486
3487
  };
3487
3488
  }
3489
+ function analyzeRegexGroups(pattern) {
3490
+ let valid = true;
3491
+ let compileError;
3492
+ try {
3493
+ new RegExp(pattern);
3494
+ } catch (e) {
3495
+ valid = false;
3496
+ compileError = e instanceof Error ? e.message : String(e);
3497
+ }
3498
+ const groups = [];
3499
+ const openStack = [];
3500
+ const backreferences = [];
3501
+ const issues = [];
3502
+ let groupCount = 0;
3503
+ let inClass = false;
3504
+ for (let i = 0; i < pattern.length; i++) {
3505
+ const ch = pattern[i];
3506
+ if (ch === "\\" && i + 1 < pattern.length) {
3507
+ const next = pattern[i + 1];
3508
+ if (!inClass && /[1-9]/.test(next)) {
3509
+ let j = i + 1;
3510
+ while (j < pattern.length && /[0-9]/.test(pattern[j])) j++;
3511
+ const raw = pattern.slice(i, j);
3512
+ const target = parseInt(pattern.slice(i + 1, j), 10);
3513
+ backreferences.push({ raw, target, start: i, resolved: false, definedBeforeUse: false });
3514
+ i = j - 1;
3515
+ continue;
3516
+ }
3517
+ if (!inClass && next === "k" && pattern[i + 2] === "<") {
3518
+ const close = pattern.indexOf(">", i + 3);
3519
+ if (close !== -1) {
3520
+ const name = pattern.slice(i + 3, close);
3521
+ const raw = pattern.slice(i, close + 1);
3522
+ backreferences.push({ raw, target: name, start: i, resolved: false, definedBeforeUse: false });
3523
+ i = close;
3524
+ continue;
3525
+ }
3526
+ }
3527
+ i++;
3528
+ continue;
3529
+ }
3530
+ if (ch === "[" && !inClass) {
3531
+ inClass = true;
3532
+ continue;
3533
+ }
3534
+ if (ch === "]" && inClass) {
3535
+ inClass = false;
3536
+ continue;
3537
+ }
3538
+ if (inClass) continue;
3539
+ if (ch === "(") {
3540
+ if (pattern[i + 1] === "?") {
3541
+ const c2 = pattern[i + 2];
3542
+ if (c2 === ":" || c2 === "=" || c2 === "!") {
3543
+ openStack.push({ index: -1, name: null, start: i });
3544
+ continue;
3545
+ }
3546
+ if (c2 === "<" && (pattern[i + 3] === "=" || pattern[i + 3] === "!")) {
3547
+ openStack.push({ index: -1, name: null, start: i });
3548
+ continue;
3549
+ }
3550
+ if (c2 === "<") {
3551
+ const close = pattern.indexOf(">", i + 3);
3552
+ const name = close !== -1 ? pattern.slice(i + 3, close) : null;
3553
+ groupCount++;
3554
+ openStack.push({ index: groupCount, name, start: i });
3555
+ if (close !== -1) i = close;
3556
+ continue;
3557
+ }
3558
+ openStack.push({ index: -1, name: null, start: i });
3559
+ continue;
3560
+ }
3561
+ groupCount++;
3562
+ openStack.push({ index: groupCount, name: null, start: i });
3563
+ continue;
3564
+ }
3565
+ if (ch === ")") {
3566
+ const open = openStack.pop();
3567
+ if (open && open.index !== -1) {
3568
+ groups.push({ index: open.index, name: open.name, start: open.start, end: i });
3569
+ }
3570
+ continue;
3571
+ }
3572
+ }
3573
+ for (const open of openStack) {
3574
+ if (open.index !== -1) groups.push({ index: open.index, name: open.name, start: open.start, end: -1 });
3575
+ }
3576
+ groups.sort((a, b) => a.index - b.index);
3577
+ const byIndex = new Map(groups.map((g) => [g.index, g]));
3578
+ const byName = new Map(groups.filter((g) => g.name !== null).map((g) => [g.name, g]));
3579
+ for (const b of backreferences) {
3580
+ const g = typeof b.target === "number" ? byIndex.get(b.target) : byName.get(b.target);
3581
+ if (!g) {
3582
+ b.resolved = false;
3583
+ b.definedBeforeUse = false;
3584
+ const label = typeof b.target === "number" ? `group ${b.target}` : `named group "${b.target}"`;
3585
+ issues.push({ severity: "error", message: `Backreference ${b.raw} at position ${b.start} points to ${label}, which doesn't exist in this pattern.` });
3586
+ } else {
3587
+ b.resolved = true;
3588
+ b.definedBeforeUse = g.end !== -1 && g.end < b.start;
3589
+ if (!b.definedBeforeUse) {
3590
+ const label = `group ${g.index}${g.name ? ` ("${g.name}")` : ""}`;
3591
+ issues.push({ severity: "error", message: `Backreference ${b.raw} at position ${b.start} references ${label}, which hasn't finished being defined yet at that point in the pattern.` });
3592
+ }
3593
+ }
3594
+ }
3595
+ return { pattern, valid, ...compileError ? { compileError } : {}, groups, backreferences, issues };
3596
+ }
3488
3597
 
3489
- export { ALL_FLAGS, CHEATSHEET, DEFAULT_COMMIT_TYPES, MIME_TABLE, OPERATIONS, SQL_DEFAULT_OPTIONS, auditDependencyRanges, buildDockerPull, buildDockerRun, buildGitCommand, code_exports, collapseHtmlWhitespace, collapseJsWhitespace, countProperties, countRules, detectDialect, detectOperationType, detectRedos, envToExport, envToJson, formatCss, formatGql, formatHtml, formatSql, getEndpointsByTag, getHtmlStats, getJsStats, getMethodColor, isValidTag, lintConventionalCommit, lookupMime, minifyCss, minifyGql, minifyHtml, minifyJs, minifySql, normalizeRef, parseDockerImage, parseEnv, parseGitCommand, parseGithubUrl, parseSpec, removeConsoleCalls, removeEmptyAttributes, removeHtmlComments, removeJsComments, removeRedundantAttributes, searchCheatsheet, searchEndpoints, splitStatements, testGitignorePatterns, testPattern, testRegex, validateEditorConfig, validateEnvKey, validatePackageExports, validateTsconfig };
3598
+ export { ALL_FLAGS, CHEATSHEET, DEFAULT_COMMIT_TYPES, MIME_TABLE, OPERATIONS, SQL_DEFAULT_OPTIONS, analyzeRegexGroups, auditDependencyRanges, buildDockerPull, buildDockerRun, buildGitCommand, code_exports, collapseHtmlWhitespace, collapseJsWhitespace, countProperties, countRules, detectDialect, detectOperationType, detectRedos, envToExport, envToJson, formatCss, formatGql, formatHtml, formatSql, getEndpointsByTag, getHtmlStats, getJsStats, getMethodColor, isValidTag, lintConventionalCommit, lookupMime, minifyCss, minifyGql, minifyHtml, minifyJs, minifySql, normalizeRef, parseDockerImage, parseEnv, parseGitCommand, parseGithubUrl, parseSpec, removeConsoleCalls, removeEmptyAttributes, removeHtmlComments, removeJsComments, removeRedundantAttributes, searchCheatsheet, searchEndpoints, splitStatements, testGitignorePatterns, testPattern, testRegex, validateEditorConfig, validateEnvKey, validatePackageExports, validateTsconfig };
@@ -26,6 +26,7 @@
26
26
  * - tsconfig-validator (validateTsconfig)
27
27
  * - package-json-exports-validator (validatePackageExports)
28
28
  * - package-json-dependency-auditor (auditDependencyRanges)
29
+ * - regex-groups (analyzeRegexGroups)
29
30
  */
30
31
  type RegexFlag = 'g' | 'i' | 'm' | 's' | 'u';
31
32
  declare const ALL_FLAGS: RegexFlag[];
@@ -511,6 +512,41 @@ interface DependencyAuditResult {
511
512
  declare function auditDependencyRanges(packageJsonText: string): DependencyAuditResult | {
512
513
  error: string;
513
514
  };
515
+ interface RegexGroupInfo {
516
+ index: number;
517
+ name: string | null;
518
+ start: number;
519
+ end: number;
520
+ }
521
+ interface RegexBackreferenceInfo {
522
+ raw: string;
523
+ target: number | string;
524
+ start: number;
525
+ resolved: boolean;
526
+ definedBeforeUse: boolean;
527
+ }
528
+ interface RegexGroupIssue {
529
+ severity: 'error' | 'warning';
530
+ message: string;
531
+ }
532
+ interface RegexGroupAnalysis {
533
+ pattern: string;
534
+ valid: boolean;
535
+ compileError?: string;
536
+ groups: RegexGroupInfo[];
537
+ backreferences: RegexBackreferenceInfo[];
538
+ issues: RegexGroupIssue[];
539
+ }
540
+ /**
541
+ * Parse a regex pattern's capture groups (numbered and named) and
542
+ * backreferences, and flag any backreference that points at a group which
543
+ * doesn't exist or hasn't finished being defined yet at that point in the
544
+ * pattern (a forward reference or a self-reference). Pass the pattern body
545
+ * only, no delimiters or flags. This is a structural, non-AI check, distinct
546
+ * from the ReDoS Detector (backtracking risk) and Regex Explainer (AI)
547
+ * (plain-English breakdown).
548
+ */
549
+ declare function analyzeRegexGroups(pattern: string): RegexGroupAnalysis;
514
550
 
515
551
  declare const code_ALL_FLAGS: typeof ALL_FLAGS;
516
552
  type code_ApiEndpoint = ApiEndpoint;
@@ -562,8 +598,12 @@ type code_ParsedSpec = ParsedSpec;
562
598
  type code_RedosFinding = RedosFinding;
563
599
  type code_RedosResult = RedosResult;
564
600
  type code_RedosSeverity = RedosSeverity;
601
+ type code_RegexBackreferenceInfo = RegexBackreferenceInfo;
565
602
  type code_RegexError = RegexError;
566
603
  type code_RegexFlag = RegexFlag;
604
+ type code_RegexGroupAnalysis = RegexGroupAnalysis;
605
+ type code_RegexGroupInfo = RegexGroupInfo;
606
+ type code_RegexGroupIssue = RegexGroupIssue;
567
607
  type code_RegexMatch = RegexMatch;
568
608
  type code_RegexResult = RegexResult;
569
609
  type code_RegexSuccess = RegexSuccess;
@@ -575,6 +615,7 @@ type code_SqlFormatOptions = SqlFormatOptions;
575
615
  type code_TestPatternResult = TestPatternResult;
576
616
  type code_TsconfigIssue = TsconfigIssue;
577
617
  type code_TsconfigValidationResult = TsconfigValidationResult;
618
+ declare const code_analyzeRegexGroups: typeof analyzeRegexGroups;
578
619
  declare const code_auditDependencyRanges: typeof auditDependencyRanges;
579
620
  declare const code_buildDockerPull: typeof buildDockerPull;
580
621
  declare const code_buildDockerRun: typeof buildDockerRun;
@@ -626,7 +667,7 @@ declare const code_validateEnvKey: typeof validateEnvKey;
626
667
  declare const code_validatePackageExports: typeof validatePackageExports;
627
668
  declare const code_validateTsconfig: typeof validateTsconfig;
628
669
  declare namespace code {
629
- export { code_ALL_FLAGS as ALL_FLAGS, type code_ApiEndpoint as ApiEndpoint, type code_ApiInfo as ApiInfo, code_CHEATSHEET as CHEATSHEET, type code_CheatsheetEntry as CheatsheetEntry, type code_ConventionalCommitFinding as ConventionalCommitFinding, type code_ConventionalCommitFooter as ConventionalCommitFooter, type code_ConventionalCommitOptions as ConventionalCommitOptions, type code_ConventionalCommitParsed as ConventionalCommitParsed, type code_ConventionalCommitResult as ConventionalCommitResult, type code_ConventionalCommitSeverity as ConventionalCommitSeverity, type code_CssResult as CssResult, code_DEFAULT_COMMIT_TYPES as DEFAULT_COMMIT_TYPES, type code_DependencyAuditDuplicate as DependencyAuditDuplicate, type code_DependencyAuditEntry as DependencyAuditEntry, type code_DependencyAuditIssue as DependencyAuditIssue, type code_DependencyAuditResult as DependencyAuditResult, type code_DependencyRangeType as DependencyRangeType, type code_DependencySection as DependencySection, type code_DockerImageRef as DockerImageRef, type code_EditorConfigIssue as EditorConfigIssue, type code_EditorConfigProperty as EditorConfigProperty, type code_EditorConfigSection as EditorConfigSection, type code_EditorConfigValidationResult as EditorConfigValidationResult, type code_EnvEntry as EnvEntry, type code_EnvParseResult as EnvParseResult, type code_ExportsIssue as ExportsIssue, type code_ExportsShape as ExportsShape, type code_ExportsValidationResult as ExportsValidationResult, type code_GitCommandConfig as GitCommandConfig, type code_GitCommandResult as GitCommandResult, type code_GitOperation as GitOperation, type code_GithubUrlInfo as GithubUrlInfo, type code_GithubUrlType as GithubUrlType, type code_GitignoreTestResult as GitignoreTestResult, type code_GqlFormatResult as GqlFormatResult, type code_HtmlFormatResult as HtmlFormatResult, type code_HtmlMinifyOptions as HtmlMinifyOptions, type code_HtmlMinifyResult as HtmlMinifyResult, type code_JsMinifyOptions as JsMinifyOptions, type code_JsMinifyResult as JsMinifyResult, code_MIME_TABLE as MIME_TABLE, type code_MatchResult as MatchResult, type code_MimeEntry as MimeEntry, type code_MimeLookupResult as MimeLookupResult, code_OPERATIONS as OPERATIONS, type code_ParsedSpec as ParsedSpec, type code_RedosFinding as RedosFinding, type code_RedosResult as RedosResult, type code_RedosSeverity as RedosSeverity, type code_RegexError as RegexError, type code_RegexFlag as RegexFlag, type code_RegexMatch as RegexMatch, type code_RegexResult as RegexResult, type code_RegexSuccess as RegexSuccess, code_SQL_DEFAULT_OPTIONS as SQL_DEFAULT_OPTIONS, type code_Segment as Segment, type code_SpecVersion as SpecVersion, type code_SqlDialect as SqlDialect, type code_SqlFormatOptions as SqlFormatOptions, type code_TestPatternResult as TestPatternResult, type code_TsconfigIssue as TsconfigIssue, type code_TsconfigValidationResult as TsconfigValidationResult, code_auditDependencyRanges as auditDependencyRanges, code_buildDockerPull as buildDockerPull, code_buildDockerRun as buildDockerRun, code_buildGitCommand as buildGitCommand, code_collapseHtmlWhitespace as collapseHtmlWhitespace, code_collapseJsWhitespace as collapseJsWhitespace, code_countProperties as countProperties, code_countRules as countRules, code_detectDialect as detectDialect, code_detectOperationType as detectOperationType, code_detectRedos as detectRedos, code_envToExport as envToExport, code_envToJson as envToJson, code_formatCss as formatCss, code_formatGql as formatGql, code_formatHtml as formatHtml, code_formatSql as formatSql, code_getEndpointsByTag as getEndpointsByTag, code_getHtmlStats as getHtmlStats, code_getJsStats as getJsStats, code_getMethodColor as getMethodColor, code_isValidTag as isValidTag, code_lintConventionalCommit as lintConventionalCommit, code_lookupMime as lookupMime, code_minifyCss as minifyCss, code_minifyGql as minifyGql, code_minifyHtml as minifyHtml, code_minifyJs as minifyJs, code_minifySql as minifySql, code_normalizeRef as normalizeRef, code_parseDockerImage as parseDockerImage, code_parseEnv as parseEnv, code_parseGitCommand as parseGitCommand, code_parseGithubUrl as parseGithubUrl, code_parseSpec as parseSpec, code_removeConsoleCalls as removeConsoleCalls, code_removeEmptyAttributes as removeEmptyAttributes, code_removeHtmlComments as removeHtmlComments, code_removeJsComments as removeJsComments, code_removeRedundantAttributes as removeRedundantAttributes, code_searchCheatsheet as searchCheatsheet, code_searchEndpoints as searchEndpoints, code_splitStatements as splitStatements, code_testGitignorePatterns as testGitignorePatterns, code_testPattern as testPattern, code_testRegex as testRegex, code_validateEditorConfig as validateEditorConfig, code_validateEnvKey as validateEnvKey, code_validatePackageExports as validatePackageExports, code_validateTsconfig as validateTsconfig };
670
+ export { code_ALL_FLAGS as ALL_FLAGS, type code_ApiEndpoint as ApiEndpoint, type code_ApiInfo as ApiInfo, code_CHEATSHEET as CHEATSHEET, type code_CheatsheetEntry as CheatsheetEntry, type code_ConventionalCommitFinding as ConventionalCommitFinding, type code_ConventionalCommitFooter as ConventionalCommitFooter, type code_ConventionalCommitOptions as ConventionalCommitOptions, type code_ConventionalCommitParsed as ConventionalCommitParsed, type code_ConventionalCommitResult as ConventionalCommitResult, type code_ConventionalCommitSeverity as ConventionalCommitSeverity, type code_CssResult as CssResult, code_DEFAULT_COMMIT_TYPES as DEFAULT_COMMIT_TYPES, type code_DependencyAuditDuplicate as DependencyAuditDuplicate, type code_DependencyAuditEntry as DependencyAuditEntry, type code_DependencyAuditIssue as DependencyAuditIssue, type code_DependencyAuditResult as DependencyAuditResult, type code_DependencyRangeType as DependencyRangeType, type code_DependencySection as DependencySection, type code_DockerImageRef as DockerImageRef, type code_EditorConfigIssue as EditorConfigIssue, type code_EditorConfigProperty as EditorConfigProperty, type code_EditorConfigSection as EditorConfigSection, type code_EditorConfigValidationResult as EditorConfigValidationResult, type code_EnvEntry as EnvEntry, type code_EnvParseResult as EnvParseResult, type code_ExportsIssue as ExportsIssue, type code_ExportsShape as ExportsShape, type code_ExportsValidationResult as ExportsValidationResult, type code_GitCommandConfig as GitCommandConfig, type code_GitCommandResult as GitCommandResult, type code_GitOperation as GitOperation, type code_GithubUrlInfo as GithubUrlInfo, type code_GithubUrlType as GithubUrlType, type code_GitignoreTestResult as GitignoreTestResult, type code_GqlFormatResult as GqlFormatResult, type code_HtmlFormatResult as HtmlFormatResult, type code_HtmlMinifyOptions as HtmlMinifyOptions, type code_HtmlMinifyResult as HtmlMinifyResult, type code_JsMinifyOptions as JsMinifyOptions, type code_JsMinifyResult as JsMinifyResult, code_MIME_TABLE as MIME_TABLE, type code_MatchResult as MatchResult, type code_MimeEntry as MimeEntry, type code_MimeLookupResult as MimeLookupResult, code_OPERATIONS as OPERATIONS, type code_ParsedSpec as ParsedSpec, type code_RedosFinding as RedosFinding, type code_RedosResult as RedosResult, type code_RedosSeverity as RedosSeverity, type code_RegexBackreferenceInfo as RegexBackreferenceInfo, type code_RegexError as RegexError, type code_RegexFlag as RegexFlag, type code_RegexGroupAnalysis as RegexGroupAnalysis, type code_RegexGroupInfo as RegexGroupInfo, type code_RegexGroupIssue as RegexGroupIssue, type code_RegexMatch as RegexMatch, type code_RegexResult as RegexResult, type code_RegexSuccess as RegexSuccess, code_SQL_DEFAULT_OPTIONS as SQL_DEFAULT_OPTIONS, type code_Segment as Segment, type code_SpecVersion as SpecVersion, type code_SqlDialect as SqlDialect, type code_SqlFormatOptions as SqlFormatOptions, type code_TestPatternResult as TestPatternResult, type code_TsconfigIssue as TsconfigIssue, type code_TsconfigValidationResult as TsconfigValidationResult, code_analyzeRegexGroups as analyzeRegexGroups, code_auditDependencyRanges as auditDependencyRanges, code_buildDockerPull as buildDockerPull, code_buildDockerRun as buildDockerRun, code_buildGitCommand as buildGitCommand, code_collapseHtmlWhitespace as collapseHtmlWhitespace, code_collapseJsWhitespace as collapseJsWhitespace, code_countProperties as countProperties, code_countRules as countRules, code_detectDialect as detectDialect, code_detectOperationType as detectOperationType, code_detectRedos as detectRedos, code_envToExport as envToExport, code_envToJson as envToJson, code_formatCss as formatCss, code_formatGql as formatGql, code_formatHtml as formatHtml, code_formatSql as formatSql, code_getEndpointsByTag as getEndpointsByTag, code_getHtmlStats as getHtmlStats, code_getJsStats as getJsStats, code_getMethodColor as getMethodColor, code_isValidTag as isValidTag, code_lintConventionalCommit as lintConventionalCommit, code_lookupMime as lookupMime, code_minifyCss as minifyCss, code_minifyGql as minifyGql, code_minifyHtml as minifyHtml, code_minifyJs as minifyJs, code_minifySql as minifySql, code_normalizeRef as normalizeRef, code_parseDockerImage as parseDockerImage, code_parseEnv as parseEnv, code_parseGitCommand as parseGitCommand, code_parseGithubUrl as parseGithubUrl, code_parseSpec as parseSpec, code_removeConsoleCalls as removeConsoleCalls, code_removeEmptyAttributes as removeEmptyAttributes, code_removeHtmlComments as removeHtmlComments, code_removeJsComments as removeJsComments, code_removeRedundantAttributes as removeRedundantAttributes, code_searchCheatsheet as searchCheatsheet, code_searchEndpoints as searchEndpoints, code_splitStatements as splitStatements, code_testGitignorePatterns as testGitignorePatterns, code_testPattern as testPattern, code_testRegex as testRegex, code_validateEditorConfig as validateEditorConfig, code_validateEnvKey as validateEnvKey, code_validatePackageExports as validatePackageExports, code_validateTsconfig as validateTsconfig };
630
671
  }
631
672
 
632
- export { type RegexMatch as $, ALL_FLAGS as A, type GitCommandResult as B, CHEATSHEET as C, DEFAULT_COMMIT_TYPES as D, type EditorConfigIssue as E, type GitOperation as F, type GitCommandConfig as G, type GithubUrlInfo as H, type GithubUrlType as I, type GitignoreTestResult as J, type GqlFormatResult as K, type HtmlFormatResult as L, type HtmlMinifyOptions as M, type HtmlMinifyResult as N, type JsMinifyOptions as O, type JsMinifyResult as P, MIME_TABLE as Q, type MatchResult as R, type MimeEntry as S, type MimeLookupResult as T, OPERATIONS as U, type ParsedSpec as V, type RedosFinding as W, type RedosResult as X, type RedosSeverity as Y, type RegexError as Z, type RegexFlag as _, type ApiEndpoint as a, type RegexResult as a0, type RegexSuccess as a1, SQL_DEFAULT_OPTIONS as a2, type Segment as a3, type SpecVersion as a4, type SqlDialect as a5, type SqlFormatOptions as a6, type TestPatternResult as a7, type TsconfigIssue as a8, type TsconfigValidationResult as a9, minifyHtml as aA, minifyJs as aB, minifySql as aC, normalizeRef as aD, parseDockerImage as aE, parseEnv as aF, parseGitCommand as aG, parseGithubUrl as aH, parseSpec as aI, removeConsoleCalls as aJ, removeEmptyAttributes as aK, removeHtmlComments as aL, removeJsComments as aM, removeRedundantAttributes as aN, searchCheatsheet as aO, searchEndpoints as aP, splitStatements as aQ, testGitignorePatterns as aR, testPattern as aS, testRegex as aT, validateEditorConfig as aU, validateEnvKey as aV, validatePackageExports as aW, validateTsconfig as aX, auditDependencyRanges as aa, buildDockerPull as ab, buildDockerRun as ac, buildGitCommand as ad, collapseHtmlWhitespace as ae, collapseJsWhitespace as af, countProperties as ag, countRules as ah, detectDialect as ai, detectOperationType as aj, detectRedos as ak, envToExport as al, envToJson as am, formatCss as an, formatGql as ao, formatHtml as ap, formatSql as aq, getEndpointsByTag as ar, getHtmlStats as as, getJsStats as at, getMethodColor as au, isValidTag as av, lintConventionalCommit as aw, lookupMime as ax, minifyCss as ay, minifyGql as az, type ApiInfo as b, code as c, type CheatsheetEntry as d, type ConventionalCommitFinding as e, type ConventionalCommitFooter as f, type ConventionalCommitOptions as g, type ConventionalCommitParsed as h, type ConventionalCommitResult as i, type ConventionalCommitSeverity as j, type CssResult as k, type DependencyAuditDuplicate as l, type DependencyAuditEntry as m, type DependencyAuditIssue as n, type DependencyAuditResult as o, type DependencyRangeType as p, type DependencySection as q, type DockerImageRef as r, type EditorConfigProperty as s, type EditorConfigSection as t, type EditorConfigValidationResult as u, type EnvEntry as v, type EnvParseResult as w, type ExportsIssue as x, type ExportsShape as y, type ExportsValidationResult as z };
673
+ export { type RegexFlag as $, ALL_FLAGS as A, type GitCommandResult as B, CHEATSHEET as C, DEFAULT_COMMIT_TYPES as D, type EditorConfigIssue as E, type GitOperation as F, type GitCommandConfig as G, type GithubUrlInfo as H, type GithubUrlType as I, type GitignoreTestResult as J, type GqlFormatResult as K, type HtmlFormatResult as L, type HtmlMinifyOptions as M, type HtmlMinifyResult as N, type JsMinifyOptions as O, type JsMinifyResult as P, MIME_TABLE as Q, type MatchResult as R, type MimeEntry as S, type MimeLookupResult as T, OPERATIONS as U, type ParsedSpec as V, type RedosFinding as W, type RedosResult as X, type RedosSeverity as Y, type RegexBackreferenceInfo as Z, type RegexError as _, type ApiEndpoint as a, validatePackageExports as a$, type RegexGroupAnalysis as a0, type RegexGroupInfo as a1, type RegexGroupIssue as a2, type RegexMatch as a3, type RegexResult as a4, type RegexSuccess as a5, SQL_DEFAULT_OPTIONS as a6, type Segment as a7, type SpecVersion as a8, type SqlDialect as a9, isValidTag as aA, lintConventionalCommit as aB, lookupMime as aC, minifyCss as aD, minifyGql as aE, minifyHtml as aF, minifyJs as aG, minifySql as aH, normalizeRef as aI, parseDockerImage as aJ, parseEnv as aK, parseGitCommand as aL, parseGithubUrl as aM, parseSpec as aN, removeConsoleCalls as aO, removeEmptyAttributes as aP, removeHtmlComments as aQ, removeJsComments as aR, removeRedundantAttributes as aS, searchCheatsheet as aT, searchEndpoints as aU, splitStatements as aV, testGitignorePatterns as aW, testPattern as aX, testRegex as aY, validateEditorConfig as aZ, validateEnvKey as a_, type SqlFormatOptions as aa, type TestPatternResult as ab, type TsconfigIssue as ac, type TsconfigValidationResult as ad, analyzeRegexGroups as ae, auditDependencyRanges as af, buildDockerPull as ag, buildDockerRun as ah, buildGitCommand as ai, collapseHtmlWhitespace as aj, collapseJsWhitespace as ak, countProperties as al, countRules as am, detectDialect as an, detectOperationType as ao, detectRedos as ap, envToExport as aq, envToJson as ar, formatCss as as, formatGql as at, formatHtml as au, formatSql as av, getEndpointsByTag as aw, getHtmlStats as ax, getJsStats as ay, getMethodColor as az, type ApiInfo as b, validateTsconfig as b0, code as c, type CheatsheetEntry as d, type ConventionalCommitFinding as e, type ConventionalCommitFooter as f, type ConventionalCommitOptions as g, type ConventionalCommitParsed as h, type ConventionalCommitResult as i, type ConventionalCommitSeverity as j, type CssResult as k, type DependencyAuditDuplicate as l, type DependencyAuditEntry as m, type DependencyAuditIssue as n, type DependencyAuditResult as o, type DependencyRangeType as p, type DependencySection as q, type DockerImageRef as r, type EditorConfigProperty as s, type EditorConfigSection as t, type EditorConfigValidationResult as u, type EnvEntry as v, type EnvParseResult as w, type ExportsIssue as x, type ExportsShape as y, type ExportsValidationResult as z };
@@ -26,6 +26,7 @@
26
26
  * - tsconfig-validator (validateTsconfig)
27
27
  * - package-json-exports-validator (validatePackageExports)
28
28
  * - package-json-dependency-auditor (auditDependencyRanges)
29
+ * - regex-groups (analyzeRegexGroups)
29
30
  */
30
31
  type RegexFlag = 'g' | 'i' | 'm' | 's' | 'u';
31
32
  declare const ALL_FLAGS: RegexFlag[];
@@ -511,6 +512,41 @@ interface DependencyAuditResult {
511
512
  declare function auditDependencyRanges(packageJsonText: string): DependencyAuditResult | {
512
513
  error: string;
513
514
  };
515
+ interface RegexGroupInfo {
516
+ index: number;
517
+ name: string | null;
518
+ start: number;
519
+ end: number;
520
+ }
521
+ interface RegexBackreferenceInfo {
522
+ raw: string;
523
+ target: number | string;
524
+ start: number;
525
+ resolved: boolean;
526
+ definedBeforeUse: boolean;
527
+ }
528
+ interface RegexGroupIssue {
529
+ severity: 'error' | 'warning';
530
+ message: string;
531
+ }
532
+ interface RegexGroupAnalysis {
533
+ pattern: string;
534
+ valid: boolean;
535
+ compileError?: string;
536
+ groups: RegexGroupInfo[];
537
+ backreferences: RegexBackreferenceInfo[];
538
+ issues: RegexGroupIssue[];
539
+ }
540
+ /**
541
+ * Parse a regex pattern's capture groups (numbered and named) and
542
+ * backreferences, and flag any backreference that points at a group which
543
+ * doesn't exist or hasn't finished being defined yet at that point in the
544
+ * pattern (a forward reference or a self-reference). Pass the pattern body
545
+ * only, no delimiters or flags. This is a structural, non-AI check, distinct
546
+ * from the ReDoS Detector (backtracking risk) and Regex Explainer (AI)
547
+ * (plain-English breakdown).
548
+ */
549
+ declare function analyzeRegexGroups(pattern: string): RegexGroupAnalysis;
514
550
 
515
551
  declare const code_ALL_FLAGS: typeof ALL_FLAGS;
516
552
  type code_ApiEndpoint = ApiEndpoint;
@@ -562,8 +598,12 @@ type code_ParsedSpec = ParsedSpec;
562
598
  type code_RedosFinding = RedosFinding;
563
599
  type code_RedosResult = RedosResult;
564
600
  type code_RedosSeverity = RedosSeverity;
601
+ type code_RegexBackreferenceInfo = RegexBackreferenceInfo;
565
602
  type code_RegexError = RegexError;
566
603
  type code_RegexFlag = RegexFlag;
604
+ type code_RegexGroupAnalysis = RegexGroupAnalysis;
605
+ type code_RegexGroupInfo = RegexGroupInfo;
606
+ type code_RegexGroupIssue = RegexGroupIssue;
567
607
  type code_RegexMatch = RegexMatch;
568
608
  type code_RegexResult = RegexResult;
569
609
  type code_RegexSuccess = RegexSuccess;
@@ -575,6 +615,7 @@ type code_SqlFormatOptions = SqlFormatOptions;
575
615
  type code_TestPatternResult = TestPatternResult;
576
616
  type code_TsconfigIssue = TsconfigIssue;
577
617
  type code_TsconfigValidationResult = TsconfigValidationResult;
618
+ declare const code_analyzeRegexGroups: typeof analyzeRegexGroups;
578
619
  declare const code_auditDependencyRanges: typeof auditDependencyRanges;
579
620
  declare const code_buildDockerPull: typeof buildDockerPull;
580
621
  declare const code_buildDockerRun: typeof buildDockerRun;
@@ -626,7 +667,7 @@ declare const code_validateEnvKey: typeof validateEnvKey;
626
667
  declare const code_validatePackageExports: typeof validatePackageExports;
627
668
  declare const code_validateTsconfig: typeof validateTsconfig;
628
669
  declare namespace code {
629
- export { code_ALL_FLAGS as ALL_FLAGS, type code_ApiEndpoint as ApiEndpoint, type code_ApiInfo as ApiInfo, code_CHEATSHEET as CHEATSHEET, type code_CheatsheetEntry as CheatsheetEntry, type code_ConventionalCommitFinding as ConventionalCommitFinding, type code_ConventionalCommitFooter as ConventionalCommitFooter, type code_ConventionalCommitOptions as ConventionalCommitOptions, type code_ConventionalCommitParsed as ConventionalCommitParsed, type code_ConventionalCommitResult as ConventionalCommitResult, type code_ConventionalCommitSeverity as ConventionalCommitSeverity, type code_CssResult as CssResult, code_DEFAULT_COMMIT_TYPES as DEFAULT_COMMIT_TYPES, type code_DependencyAuditDuplicate as DependencyAuditDuplicate, type code_DependencyAuditEntry as DependencyAuditEntry, type code_DependencyAuditIssue as DependencyAuditIssue, type code_DependencyAuditResult as DependencyAuditResult, type code_DependencyRangeType as DependencyRangeType, type code_DependencySection as DependencySection, type code_DockerImageRef as DockerImageRef, type code_EditorConfigIssue as EditorConfigIssue, type code_EditorConfigProperty as EditorConfigProperty, type code_EditorConfigSection as EditorConfigSection, type code_EditorConfigValidationResult as EditorConfigValidationResult, type code_EnvEntry as EnvEntry, type code_EnvParseResult as EnvParseResult, type code_ExportsIssue as ExportsIssue, type code_ExportsShape as ExportsShape, type code_ExportsValidationResult as ExportsValidationResult, type code_GitCommandConfig as GitCommandConfig, type code_GitCommandResult as GitCommandResult, type code_GitOperation as GitOperation, type code_GithubUrlInfo as GithubUrlInfo, type code_GithubUrlType as GithubUrlType, type code_GitignoreTestResult as GitignoreTestResult, type code_GqlFormatResult as GqlFormatResult, type code_HtmlFormatResult as HtmlFormatResult, type code_HtmlMinifyOptions as HtmlMinifyOptions, type code_HtmlMinifyResult as HtmlMinifyResult, type code_JsMinifyOptions as JsMinifyOptions, type code_JsMinifyResult as JsMinifyResult, code_MIME_TABLE as MIME_TABLE, type code_MatchResult as MatchResult, type code_MimeEntry as MimeEntry, type code_MimeLookupResult as MimeLookupResult, code_OPERATIONS as OPERATIONS, type code_ParsedSpec as ParsedSpec, type code_RedosFinding as RedosFinding, type code_RedosResult as RedosResult, type code_RedosSeverity as RedosSeverity, type code_RegexError as RegexError, type code_RegexFlag as RegexFlag, type code_RegexMatch as RegexMatch, type code_RegexResult as RegexResult, type code_RegexSuccess as RegexSuccess, code_SQL_DEFAULT_OPTIONS as SQL_DEFAULT_OPTIONS, type code_Segment as Segment, type code_SpecVersion as SpecVersion, type code_SqlDialect as SqlDialect, type code_SqlFormatOptions as SqlFormatOptions, type code_TestPatternResult as TestPatternResult, type code_TsconfigIssue as TsconfigIssue, type code_TsconfigValidationResult as TsconfigValidationResult, code_auditDependencyRanges as auditDependencyRanges, code_buildDockerPull as buildDockerPull, code_buildDockerRun as buildDockerRun, code_buildGitCommand as buildGitCommand, code_collapseHtmlWhitespace as collapseHtmlWhitespace, code_collapseJsWhitespace as collapseJsWhitespace, code_countProperties as countProperties, code_countRules as countRules, code_detectDialect as detectDialect, code_detectOperationType as detectOperationType, code_detectRedos as detectRedos, code_envToExport as envToExport, code_envToJson as envToJson, code_formatCss as formatCss, code_formatGql as formatGql, code_formatHtml as formatHtml, code_formatSql as formatSql, code_getEndpointsByTag as getEndpointsByTag, code_getHtmlStats as getHtmlStats, code_getJsStats as getJsStats, code_getMethodColor as getMethodColor, code_isValidTag as isValidTag, code_lintConventionalCommit as lintConventionalCommit, code_lookupMime as lookupMime, code_minifyCss as minifyCss, code_minifyGql as minifyGql, code_minifyHtml as minifyHtml, code_minifyJs as minifyJs, code_minifySql as minifySql, code_normalizeRef as normalizeRef, code_parseDockerImage as parseDockerImage, code_parseEnv as parseEnv, code_parseGitCommand as parseGitCommand, code_parseGithubUrl as parseGithubUrl, code_parseSpec as parseSpec, code_removeConsoleCalls as removeConsoleCalls, code_removeEmptyAttributes as removeEmptyAttributes, code_removeHtmlComments as removeHtmlComments, code_removeJsComments as removeJsComments, code_removeRedundantAttributes as removeRedundantAttributes, code_searchCheatsheet as searchCheatsheet, code_searchEndpoints as searchEndpoints, code_splitStatements as splitStatements, code_testGitignorePatterns as testGitignorePatterns, code_testPattern as testPattern, code_testRegex as testRegex, code_validateEditorConfig as validateEditorConfig, code_validateEnvKey as validateEnvKey, code_validatePackageExports as validatePackageExports, code_validateTsconfig as validateTsconfig };
670
+ export { code_ALL_FLAGS as ALL_FLAGS, type code_ApiEndpoint as ApiEndpoint, type code_ApiInfo as ApiInfo, code_CHEATSHEET as CHEATSHEET, type code_CheatsheetEntry as CheatsheetEntry, type code_ConventionalCommitFinding as ConventionalCommitFinding, type code_ConventionalCommitFooter as ConventionalCommitFooter, type code_ConventionalCommitOptions as ConventionalCommitOptions, type code_ConventionalCommitParsed as ConventionalCommitParsed, type code_ConventionalCommitResult as ConventionalCommitResult, type code_ConventionalCommitSeverity as ConventionalCommitSeverity, type code_CssResult as CssResult, code_DEFAULT_COMMIT_TYPES as DEFAULT_COMMIT_TYPES, type code_DependencyAuditDuplicate as DependencyAuditDuplicate, type code_DependencyAuditEntry as DependencyAuditEntry, type code_DependencyAuditIssue as DependencyAuditIssue, type code_DependencyAuditResult as DependencyAuditResult, type code_DependencyRangeType as DependencyRangeType, type code_DependencySection as DependencySection, type code_DockerImageRef as DockerImageRef, type code_EditorConfigIssue as EditorConfigIssue, type code_EditorConfigProperty as EditorConfigProperty, type code_EditorConfigSection as EditorConfigSection, type code_EditorConfigValidationResult as EditorConfigValidationResult, type code_EnvEntry as EnvEntry, type code_EnvParseResult as EnvParseResult, type code_ExportsIssue as ExportsIssue, type code_ExportsShape as ExportsShape, type code_ExportsValidationResult as ExportsValidationResult, type code_GitCommandConfig as GitCommandConfig, type code_GitCommandResult as GitCommandResult, type code_GitOperation as GitOperation, type code_GithubUrlInfo as GithubUrlInfo, type code_GithubUrlType as GithubUrlType, type code_GitignoreTestResult as GitignoreTestResult, type code_GqlFormatResult as GqlFormatResult, type code_HtmlFormatResult as HtmlFormatResult, type code_HtmlMinifyOptions as HtmlMinifyOptions, type code_HtmlMinifyResult as HtmlMinifyResult, type code_JsMinifyOptions as JsMinifyOptions, type code_JsMinifyResult as JsMinifyResult, code_MIME_TABLE as MIME_TABLE, type code_MatchResult as MatchResult, type code_MimeEntry as MimeEntry, type code_MimeLookupResult as MimeLookupResult, code_OPERATIONS as OPERATIONS, type code_ParsedSpec as ParsedSpec, type code_RedosFinding as RedosFinding, type code_RedosResult as RedosResult, type code_RedosSeverity as RedosSeverity, type code_RegexBackreferenceInfo as RegexBackreferenceInfo, type code_RegexError as RegexError, type code_RegexFlag as RegexFlag, type code_RegexGroupAnalysis as RegexGroupAnalysis, type code_RegexGroupInfo as RegexGroupInfo, type code_RegexGroupIssue as RegexGroupIssue, type code_RegexMatch as RegexMatch, type code_RegexResult as RegexResult, type code_RegexSuccess as RegexSuccess, code_SQL_DEFAULT_OPTIONS as SQL_DEFAULT_OPTIONS, type code_Segment as Segment, type code_SpecVersion as SpecVersion, type code_SqlDialect as SqlDialect, type code_SqlFormatOptions as SqlFormatOptions, type code_TestPatternResult as TestPatternResult, type code_TsconfigIssue as TsconfigIssue, type code_TsconfigValidationResult as TsconfigValidationResult, code_analyzeRegexGroups as analyzeRegexGroups, code_auditDependencyRanges as auditDependencyRanges, code_buildDockerPull as buildDockerPull, code_buildDockerRun as buildDockerRun, code_buildGitCommand as buildGitCommand, code_collapseHtmlWhitespace as collapseHtmlWhitespace, code_collapseJsWhitespace as collapseJsWhitespace, code_countProperties as countProperties, code_countRules as countRules, code_detectDialect as detectDialect, code_detectOperationType as detectOperationType, code_detectRedos as detectRedos, code_envToExport as envToExport, code_envToJson as envToJson, code_formatCss as formatCss, code_formatGql as formatGql, code_formatHtml as formatHtml, code_formatSql as formatSql, code_getEndpointsByTag as getEndpointsByTag, code_getHtmlStats as getHtmlStats, code_getJsStats as getJsStats, code_getMethodColor as getMethodColor, code_isValidTag as isValidTag, code_lintConventionalCommit as lintConventionalCommit, code_lookupMime as lookupMime, code_minifyCss as minifyCss, code_minifyGql as minifyGql, code_minifyHtml as minifyHtml, code_minifyJs as minifyJs, code_minifySql as minifySql, code_normalizeRef as normalizeRef, code_parseDockerImage as parseDockerImage, code_parseEnv as parseEnv, code_parseGitCommand as parseGitCommand, code_parseGithubUrl as parseGithubUrl, code_parseSpec as parseSpec, code_removeConsoleCalls as removeConsoleCalls, code_removeEmptyAttributes as removeEmptyAttributes, code_removeHtmlComments as removeHtmlComments, code_removeJsComments as removeJsComments, code_removeRedundantAttributes as removeRedundantAttributes, code_searchCheatsheet as searchCheatsheet, code_searchEndpoints as searchEndpoints, code_splitStatements as splitStatements, code_testGitignorePatterns as testGitignorePatterns, code_testPattern as testPattern, code_testRegex as testRegex, code_validateEditorConfig as validateEditorConfig, code_validateEnvKey as validateEnvKey, code_validatePackageExports as validatePackageExports, code_validateTsconfig as validateTsconfig };
630
671
  }
631
672
 
632
- export { type RegexMatch as $, ALL_FLAGS as A, type GitCommandResult as B, CHEATSHEET as C, DEFAULT_COMMIT_TYPES as D, type EditorConfigIssue as E, type GitOperation as F, type GitCommandConfig as G, type GithubUrlInfo as H, type GithubUrlType as I, type GitignoreTestResult as J, type GqlFormatResult as K, type HtmlFormatResult as L, type HtmlMinifyOptions as M, type HtmlMinifyResult as N, type JsMinifyOptions as O, type JsMinifyResult as P, MIME_TABLE as Q, type MatchResult as R, type MimeEntry as S, type MimeLookupResult as T, OPERATIONS as U, type ParsedSpec as V, type RedosFinding as W, type RedosResult as X, type RedosSeverity as Y, type RegexError as Z, type RegexFlag as _, type ApiEndpoint as a, type RegexResult as a0, type RegexSuccess as a1, SQL_DEFAULT_OPTIONS as a2, type Segment as a3, type SpecVersion as a4, type SqlDialect as a5, type SqlFormatOptions as a6, type TestPatternResult as a7, type TsconfigIssue as a8, type TsconfigValidationResult as a9, minifyHtml as aA, minifyJs as aB, minifySql as aC, normalizeRef as aD, parseDockerImage as aE, parseEnv as aF, parseGitCommand as aG, parseGithubUrl as aH, parseSpec as aI, removeConsoleCalls as aJ, removeEmptyAttributes as aK, removeHtmlComments as aL, removeJsComments as aM, removeRedundantAttributes as aN, searchCheatsheet as aO, searchEndpoints as aP, splitStatements as aQ, testGitignorePatterns as aR, testPattern as aS, testRegex as aT, validateEditorConfig as aU, validateEnvKey as aV, validatePackageExports as aW, validateTsconfig as aX, auditDependencyRanges as aa, buildDockerPull as ab, buildDockerRun as ac, buildGitCommand as ad, collapseHtmlWhitespace as ae, collapseJsWhitespace as af, countProperties as ag, countRules as ah, detectDialect as ai, detectOperationType as aj, detectRedos as ak, envToExport as al, envToJson as am, formatCss as an, formatGql as ao, formatHtml as ap, formatSql as aq, getEndpointsByTag as ar, getHtmlStats as as, getJsStats as at, getMethodColor as au, isValidTag as av, lintConventionalCommit as aw, lookupMime as ax, minifyCss as ay, minifyGql as az, type ApiInfo as b, code as c, type CheatsheetEntry as d, type ConventionalCommitFinding as e, type ConventionalCommitFooter as f, type ConventionalCommitOptions as g, type ConventionalCommitParsed as h, type ConventionalCommitResult as i, type ConventionalCommitSeverity as j, type CssResult as k, type DependencyAuditDuplicate as l, type DependencyAuditEntry as m, type DependencyAuditIssue as n, type DependencyAuditResult as o, type DependencyRangeType as p, type DependencySection as q, type DockerImageRef as r, type EditorConfigProperty as s, type EditorConfigSection as t, type EditorConfigValidationResult as u, type EnvEntry as v, type EnvParseResult as w, type ExportsIssue as x, type ExportsShape as y, type ExportsValidationResult as z };
673
+ export { type RegexFlag as $, ALL_FLAGS as A, type GitCommandResult as B, CHEATSHEET as C, DEFAULT_COMMIT_TYPES as D, type EditorConfigIssue as E, type GitOperation as F, type GitCommandConfig as G, type GithubUrlInfo as H, type GithubUrlType as I, type GitignoreTestResult as J, type GqlFormatResult as K, type HtmlFormatResult as L, type HtmlMinifyOptions as M, type HtmlMinifyResult as N, type JsMinifyOptions as O, type JsMinifyResult as P, MIME_TABLE as Q, type MatchResult as R, type MimeEntry as S, type MimeLookupResult as T, OPERATIONS as U, type ParsedSpec as V, type RedosFinding as W, type RedosResult as X, type RedosSeverity as Y, type RegexBackreferenceInfo as Z, type RegexError as _, type ApiEndpoint as a, validatePackageExports as a$, type RegexGroupAnalysis as a0, type RegexGroupInfo as a1, type RegexGroupIssue as a2, type RegexMatch as a3, type RegexResult as a4, type RegexSuccess as a5, SQL_DEFAULT_OPTIONS as a6, type Segment as a7, type SpecVersion as a8, type SqlDialect as a9, isValidTag as aA, lintConventionalCommit as aB, lookupMime as aC, minifyCss as aD, minifyGql as aE, minifyHtml as aF, minifyJs as aG, minifySql as aH, normalizeRef as aI, parseDockerImage as aJ, parseEnv as aK, parseGitCommand as aL, parseGithubUrl as aM, parseSpec as aN, removeConsoleCalls as aO, removeEmptyAttributes as aP, removeHtmlComments as aQ, removeJsComments as aR, removeRedundantAttributes as aS, searchCheatsheet as aT, searchEndpoints as aU, splitStatements as aV, testGitignorePatterns as aW, testPattern as aX, testRegex as aY, validateEditorConfig as aZ, validateEnvKey as a_, type SqlFormatOptions as aa, type TestPatternResult as ab, type TsconfigIssue as ac, type TsconfigValidationResult as ad, analyzeRegexGroups as ae, auditDependencyRanges as af, buildDockerPull as ag, buildDockerRun as ah, buildGitCommand as ai, collapseHtmlWhitespace as aj, collapseJsWhitespace as ak, countProperties as al, countRules as am, detectDialect as an, detectOperationType as ao, detectRedos as ap, envToExport as aq, envToJson as ar, formatCss as as, formatGql as at, formatHtml as au, formatSql as av, getEndpointsByTag as aw, getHtmlStats as ax, getJsStats as ay, getMethodColor as az, type ApiInfo as b, validateTsconfig as b0, code as c, type CheatsheetEntry as d, type ConventionalCommitFinding as e, type ConventionalCommitFooter as f, type ConventionalCommitOptions as g, type ConventionalCommitParsed as h, type ConventionalCommitResult as i, type ConventionalCommitSeverity as j, type CssResult as k, type DependencyAuditDuplicate as l, type DependencyAuditEntry as m, type DependencyAuditIssue as n, type DependencyAuditResult as o, type DependencyRangeType as p, type DependencySection as q, type DockerImageRef as r, type EditorConfigProperty as s, type EditorConfigSection as t, type EditorConfigValidationResult as u, type EnvEntry as v, type EnvParseResult as w, type ExportsIssue as x, type ExportsShape as y, type ExportsValidationResult as z };