@ultimat3/manifest 31.32.0 → 31.34.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultimat3/manifest",
3
- "version": "31.32.0",
3
+ "version": "31.34.0",
4
4
  "description": "x.manifest.json: deterministic generated facts, contract diff, AGENTS.md budget",
5
5
  "keywords": [
6
6
  "ultimate",
@@ -43,12 +43,12 @@
43
43
  "test": "bun test"
44
44
  },
45
45
  "dependencies": {
46
- "@ultimat3/action": "31.32.0",
47
- "@ultimat3/core": "31.32.0",
48
- "@ultimat3/entity": "31.32.0",
49
- "@ultimat3/jobs": "31.32.0",
50
- "@ultimat3/query": "31.32.0",
51
- "@ultimat3/realtime": "31.32.0",
52
- "@ultimat3/schema": "31.32.0"
46
+ "@ultimat3/action": "31.34.0",
47
+ "@ultimat3/core": "31.34.0",
48
+ "@ultimat3/entity": "31.34.0",
49
+ "@ultimat3/jobs": "31.34.0",
50
+ "@ultimat3/query": "31.34.0",
51
+ "@ultimat3/realtime": "31.34.0",
52
+ "@ultimat3/schema": "31.34.0"
53
53
  }
54
54
  }
package/src/diff-admin.ts CHANGED
@@ -1,9 +1,11 @@
1
- // The admin in a contract diff. An admin's list URLs are bookmarked and its MCP tools are called
2
- // by agents, so what a list ANSWERS is contract: a filter, a sort or a scope that goes away
3
- // refuses a caller it served, a default scope that moves changes what a bare URL lists, and a row
4
- // scope that appears hides rows from actors who saw them. An action is an MCP tool: one that goes
5
- // away, stops taking `ids`, or starts excluding rows (`when`) refuses a call it answered. A
6
- // route's permissions are judged like any operation's; layout and related lists are internal.
1
+ // The admin in a contract diff. An admin's list URLs are bookmarked and its MCP tools are called by
2
+ // agents, so what a list ANSWERS is contract: a filter, a sort or a scope that goes away refuses a
3
+ // caller it served, a default scope that moves changes what a bare URL lists, and a row scope that
4
+ // appears hides rows from actors who saw them.
5
+ //
6
+ // An action is an MCP tool: one that goes away, stops taking `ids`, or starts excluding rows
7
+ // (`when`) refuses a call it answered. A route's permissions are judged like any operation's;
8
+ // layout and related lists are internal.
7
9
 
8
10
  import type { ManifestChange } from './diff-change';
9
11
  import { diffNamedSet, index } from './diff-change';
package/src/docs-scan.ts CHANGED
@@ -10,7 +10,7 @@
10
10
  // the installed version. Same split `agents-md.ts` states: facts are derived, prose is
11
11
  // human-authored — this module derives, and quotes human prose verbatim. It never writes.
12
12
 
13
- // `node:` by necessity, not habit. Bun exposes no native directory listing: `Bun.Glob` walks a
13
+ // why: `node:` by necessity, not habit. Bun exposes no native directory listing: `Bun.Glob` walks a
14
14
  // pattern and yields matches, while this needs the immediate children of the scope directory —
15
15
  // including the ones that turn out not to be packages. And Bun ships no path module at all, so
16
16
  // `basename`/`join` are the only way to build a path without hand-rolling separator handling.
@@ -106,9 +106,9 @@ export function headerComment(source: string): string {
106
106
  for (const line of lines) {
107
107
  const trimmed = line.trim();
108
108
  out.push(
109
- trimmed
109
+ withoutClose(trimmed)
110
110
  .replace(/^\/\*+\s?/, '')
111
- .replace(/\s?\*+\/$/, '')
111
+
112
112
  .replace(/^\*\s?/, ''),
113
113
  );
114
114
  if (trimmed.endsWith('*/')) break;
@@ -294,3 +294,16 @@ function parseJson(text: string): unknown {
294
294
  return undefined;
295
295
  }
296
296
  }
297
+
298
+ /**
299
+ * A block comment's closing `*\/`, with the `*` run and one space before it, as `/\s?\*+\/$/`
300
+ * removed them — in one pass: that pattern retried from every `*` of a long run (CodeQL
301
+ * polynomial-redos, 3.9 s on 100,000).
302
+ */
303
+ export function withoutClose(line: string): string {
304
+ if (!line.endsWith('*/')) return line;
305
+ let end = line.length - 1;
306
+ while (end > 0 && line.charCodeAt(end - 1) === 42) end -= 1;
307
+ if (end > 0 && /\s/.test(line.charAt(end - 1))) end -= 1;
308
+ return line.slice(0, end);
309
+ }
package/src/docs-wiki.ts CHANGED
@@ -28,7 +28,90 @@ export interface WikiHeading {
28
28
  readonly line: number;
29
29
  }
30
30
 
31
- const HEADING = /^ {0,3}(#{1,6})[ \t]+(.*?)(?:[ \t]+#+)?[ \t]*$/;
31
+ // Linear by construction, every reader below (CodeQL js/polynomial-redos, sweep 8b-3): the regexes
32
+ // they replace answered the same strings and retried a run from each of its characters —
33
+ // `/^ {0,3}(#{1,6})[ \t]+(.*?)(?:[ \t]+#+)?[ \t]*$/` took over 15 s on a CRLF heading of 10k
34
+ // spaces, the link pattern over 15 s on 100k `![`, the tag pattern 4.3 s on 100k `<`.
35
+
36
+ const isBlank = (char: string | undefined): boolean => char === ' ' || char === '\t';
37
+ /** What `.` refuses to match without the `s` flag: a heading line holding one is no heading. */
38
+ const LINE_TERMINATOR = /[\n\r\u2028\u2029]/;
39
+
40
+ /**
41
+ * An ATX heading, `#` to `######`: up to three spaces, the marks, a blank, then the text without
42
+ * its closing `#` run (only when a blank precedes it) and without trailing blanks.
43
+ */
44
+ function atxHeading(
45
+ text: string,
46
+ ): { readonly level: number; readonly heading: string } | undefined {
47
+ let at = 0;
48
+ while (at < 3 && text[at] === ' ') at += 1;
49
+ let marks = at;
50
+ while (text[marks] === '#') marks += 1;
51
+ const level = marks - at;
52
+ if (level < 1 || level > 6) return undefined;
53
+ let start = marks;
54
+ while (isBlank(text[start])) start += 1;
55
+ if (start === marks) return undefined;
56
+ const rest = text.slice(start);
57
+ if (LINE_TERMINATOR.test(rest)) return undefined;
58
+ let end = rest.length;
59
+ while (end > 0 && isBlank(rest[end - 1])) end -= 1;
60
+ let closing = end;
61
+ while (closing > 0 && rest[closing - 1] === '#') closing -= 1;
62
+ if (closing === end || closing === 0 || !isBlank(rest[closing - 1])) {
63
+ return { level, heading: rest.slice(0, end) };
64
+ }
65
+ while (isBlank(rest[closing - 1])) closing -= 1;
66
+ return { level, heading: rest.slice(0, closing) };
67
+ }
68
+
69
+ /**
70
+ * `text.replace(/\[([^\]]*)\]\([^)]*\)/g, '$1')`, as one forward walk: a `[` is closed by the
71
+ * first `]` after it, which must be followed by `(` and then a `)`. Every `[` before that `]` shares
72
+ * it, so a failed one skips past it; with no `]` or no `)` left, no later link can close either.
73
+ * An image's `!` stays behind, and the slug's character filter drops it like any other `!`.
74
+ */
75
+ function linksAsText(text: string): string {
76
+ let out = '';
77
+ let kept = 0;
78
+ let from = 0;
79
+ for (;;) {
80
+ const open = text.indexOf('[', from);
81
+ const close = open === -1 ? -1 : text.indexOf(']', open + 1);
82
+ if (close === -1) break;
83
+ if (text[close + 1] !== '(') {
84
+ from = close + 1;
85
+ continue;
86
+ }
87
+ const end = text.indexOf(')', close + 2);
88
+ if (end === -1) break;
89
+ out += text.slice(kept, open) + text.slice(open + 1, close);
90
+ kept = end + 1;
91
+ from = kept;
92
+ }
93
+ return out + text.slice(kept);
94
+ }
95
+
96
+ /** `text.replace(/<[^>]+>/g, '')`, as one forward walk: `<` to the next `>`, never `<>` itself. */
97
+ function withoutTags(text: string): string {
98
+ let out = '';
99
+ let kept = 0;
100
+ let from = 0;
101
+ for (;;) {
102
+ const open = text.indexOf('<', from);
103
+ const close = open === -1 ? -1 : text.indexOf('>', open + 1);
104
+ if (close === -1) break;
105
+ if (close === open + 1) {
106
+ from = close;
107
+ continue;
108
+ }
109
+ out += text.slice(kept, open);
110
+ kept = close + 1;
111
+ from = kept;
112
+ }
113
+ return out + text.slice(kept);
114
+ }
32
115
 
33
116
  /**
34
117
  * GitHub's heading slug: links become their text, tags and backticks drop, then every character
@@ -36,9 +119,7 @@ const HEADING = /^ {0,3}(#{1,6})[ \t]+(.*?)(?:[ \t]+#+)?[ \t]*$/;
36
119
  * rule `scripts/wiki-anchors.ts` holds every wiki link to — the one copy, which it imports.
37
120
  */
38
121
  export const githubSlug = (heading: string): string =>
39
- heading
40
- .replace(/!?\[([^\]]*)\]\([^)]*\)/g, '$1')
41
- .replace(/<[^>]+>/g, '')
122
+ withoutTags(linksAsText(heading))
42
123
  .replaceAll('`', '')
43
124
  .toLowerCase()
44
125
  .replace(/[^\p{L}\p{M}\p{N}\p{Pc} -]/gu, '')
@@ -55,14 +136,14 @@ export function wikiHeadings(markdown: string): readonly WikiHeading[] {
55
136
  return;
56
137
  }
57
138
  if (fenced) return;
58
- const match = HEADING.exec(text);
59
- if (match === null) return;
60
- const heading = match[2] ?? '';
139
+ const match = atxHeading(text);
140
+ if (match === undefined) return;
141
+ const { heading, level } = match;
61
142
  const base = githubSlug(heading);
62
143
  const count = seen.get(base) ?? 0;
63
144
  seen.set(base, count + 1);
64
145
  out.push({
65
- level: (match[1] ?? '#').length,
146
+ level,
66
147
  heading,
67
148
  anchor: count === 0 ? base : `${base}-${count}`,
68
149
  line,
@@ -1,8 +1,10 @@
1
1
  // The admins this process declared, as manifest facts. `@ultimat3/admin` is a tier above this
2
2
  // package and may not be imported, so its mount registry is read off the global symbol registry —
3
3
  // the same seam `@ultimat3/cli` mounts the screens through — and each admin is asked to describe
4
- // ITSELF. What comes back is `unknown` and is read field by field: a description this build does
5
- // not understand is skipped whole, never half-published.
4
+ // ITSELF.
5
+ //
6
+ // What comes back is `unknown` and is read field by field: a description this build does not
7
+ // understand is skipped whole, never half-published.
6
8
 
7
9
  import type {
8
10
  AdminActionFact,