@0001-labs/idv1 2.0.3 → 3.0.1

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/README.md CHANGED
@@ -29,7 +29,7 @@ const parsed = parseCode(candidate)
29
29
 
30
30
  ## The idv1 command
31
31
 
32
- A codebase keeps a `.id` file of plain lines, one entry a line, read by the shape of its first word. The first five lines name the shapes in pattern order (`LLNNNN`, `NNLLLL`, `LLLLNN`, `LLNNXX`, `XXXXXX`); a line left as its pattern keeps no name, and a shape name is a label, not a taxonomy reservation. After them, two capitals are a namespace; a six-character pattern holding one lowercase pair is a taxonomy, and carries its shape; three codes with an `r` relation between them are a fact; anything else is an id and its name, with ` @ path` when it lives in a folder. Blank lines and `#` comments are free. `readDirectory` still reads the JSON form; `writeDirectory` writes this one.
32
+ A codebase keeps its vocabulary in a `.id` file of plain lines. The first five name the shapes in pattern order (`LLNNNN`, `NNLLLL`, `LLLLNN`, `LLNNXX`, `XXXXXX`); a line left as its pattern keeps no name, and a shape name is a label, not a taxonomy reservation. After them, two capitals and a name are a namespace, and a six-character pattern holding one lowercase pair and a name is a taxonomy, which carries its shape. Blank lines and `#` comments are free. Codes themselves live with their records, in a column beside the database's own key, never in `.id`.
33
33
 
34
34
  ```text
35
35
  User
@@ -42,33 +42,28 @@ SH Shop
42
42
 
43
43
  coNNXX Component
44
44
  NNsvLL Service
45
-
46
- SHop01 Shop @ .
47
- co12Ca Cart @ src/cart
48
- 02svSt Stripe
49
-
50
- SHop01 rHasPt co12Ca
51
45
  ```
52
46
 
53
47
  ```sh
54
- npx idv1 directory
55
- npx idv1 status
56
- npx idv1 health
57
- npx idv1 resolve co14Ch
48
+ npx idv1 directory # the vocabulary, and whether it is healthy
49
+ npx idv1 health # exits 1 with each problem
50
+ npx idv1 resolve co12Ca # the shape, taxonomy and namespace a code reads as
58
51
  ```
59
52
 
60
- The same operations are exported: `readDirectory`, `directoryHealth`, `resolveCode`, `taxonomyOf`, `describeDirectory`, `describeStatus` and `runDirectoryCommand`.
53
+ The same operations are exported: `readDirectory`, `writeDirectory`, `directoryHealth`, `resolveCode`, `taxonomyOf`, `describeDirectory` and `runDirectoryCommand`.
61
54
 
62
55
  The package ships TypeScript source. Bundlers and `tsx` read it directly. Plain Node 22.18 or later imports `@0001-labs/idv1/register` first, then dynamically imports the package.
63
56
 
64
57
  ## Explorer utility
65
58
 
66
- Import `createExplorer` and `mountExplorer` from `@0001-labs/idv1/explorer`, and `@0001-labs/idv1/explorer.css` for the browser view. Supply `ExplorerData`: namespace names, shapes, taxonomies, identifiers, nodes and links. The utility owns drill-down, counts, identifier resolution, taxonomy highlighting, keyboard navigation and URL history.
59
+ Import `createExplorer` and `mountExplorer` from `@0001-labs/idv1/explorer`, and `@0001-labs/idv1/explorer.css` for the browser view. Supply `ExplorerData`: namespace names, shapes, taxonomies, identifiers, nodes and links. The root lists the shapes by their plural names, then namespaces, taxonomies and identifiers. The utility owns drill-down, counts, identifier resolution, taxonomy highlighting, keyboard navigation and URL history.
67
60
 
68
61
  Optional `collections` carry source records and lazy `load` functions. Records may link to host details with `href`. The utility contains no application records or network requests. `createExplorer(data)` returns `entries(path)`, `title(path)`, `stepName(path, depth)` and `load(path)`. `mountExplorer(element, data)` renders it and returns a cleanup function. Theme it with `--idv1-explorer-*` CSS variables; the host owns loading and authorization.
69
62
 
70
63
  ## Upgrading from 1.x
71
64
 
65
+ Release 3 keeps `.id` to vocabulary: `Directory` holds shapes, namespaces and taxonomies; `Part`, facts and `idv1 status` are gone, and `idv1 health` names every other line it finds. `readDirectory` still reads the JSON form.
66
+
72
67
  Release 2 changes API names, not code grammar, scan payloads or capacity. Replace semantic shape arguments with patterns, `parseCode(...).kind` with `.shape`, and `codeKind` with `codeShape`. Use `codeCandidate(shape)` and `isCodeOf(shape, value)` in place of per-kind wrappers. Regex constants are pattern-named, such as `LLNNXX_CODE`; `blockedLLLLNNCode` replaces the semantic name of its filter. `.id` part and taxonomy `shape` values use patterns. Keep application words in the optional `shapes` map.
73
68
 
74
69
  ## Documentation
package/bin/idv1.mjs CHANGED
@@ -12,6 +12,6 @@ if (!existsSync(file)) {
12
12
  console.error('No .id file here or above. See https://idv1.0001.dev/docs/annotate')
13
13
  process.exit(2)
14
14
  }
15
- const { code, out } = runDirectoryCommand(command, args, readFileSync(file, 'utf8'), path => existsSync(join(dir, path)))
15
+ const { code, out } = runDirectoryCommand(command, args, readFileSync(file, 'utf8'))
16
16
  console.log(out)
17
17
  process.exit(code)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0001-labs/idv1",
3
- "version": "2.0.3",
3
+ "version": "3.0.1",
4
4
  "description": "Six-character IDs for agents: five shapes, taxonomy and namespaces, and a CLI that reads a codebase's .id file.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/src/idv1.ts CHANGED
@@ -1,143 +1,90 @@
1
1
  import { JUNCTION_SEPARATOR, parseCode, type CodeShape } from './identifier'
2
- import { blockedCodeLetters, blockedLLLLNNCode } from './util/blockedWords'
3
2
  import { namespaceHealth, namespaceOf, type Namespace } from './namespace'
4
3
  import { taxonomyHealth, taxonomyOf, type Taxonomy } from './taxonomy'
5
4
 
6
- export type Part = { id: string; shape: CodeShape; name: string; path: string | null }
7
5
  export type ShapeNames = Partial<Record<CodeShape, string>>
8
- export type Directory = { shapes?: ShapeNames; namespaces: Namespace[]; taxonomies: Taxonomy[]; parts: Part[]; facts: string[] }
9
- export type Resolved = { id: string; shape: CodeShape | null; namespace?: Namespace; taxonomy?: Taxonomy; part?: Part; facts: string[] }
6
+ export type Directory = { shapes: ShapeNames; namespaces: Namespace[]; taxonomies: Taxonomy[]; unread?: string[] }
7
+ export type Resolved = { id: string; shape: CodeShape | null; namespace?: Namespace; taxonomy?: Taxonomy }
10
8
 
11
9
  const SHAPES: CodeShape[] = ['LLNNNN', 'NNLLLL', 'LLLLNN', 'LLNNXX', 'XXXXXX']
12
- const list = <T>(value: unknown): T[] => (Array.isArray(value) ? value : []) as T[]
13
-
14
- export const patternShape = (pattern: string) => parseCode(pattern.replace(/N/g, '1').replace(/[LXOP]/g, 'a'))?.shape ?? null
15
10
  const NAMESPACE_KEY = /^[A-Z]{2}$/
16
11
  const TAXONOMY_KEY = /^(?=[NLXOP]*[a-z]{2}[NLXOP]*$).{6}$/
17
- const RELATION = /^r[A-Z][A-Za-z]{4}$/
18
- const FACT = /^[A-Za-z0-9]{6} r[A-Z][A-Za-z]{4} [A-Za-z0-9]{6}$/
12
+ const list = <T>(value: unknown): T[] => (Array.isArray(value) ? value : []) as T[]
13
+ export const patternShape = (pattern: string) => parseCode(pattern.replace(/N/g, '1').replace(/[LXOP]/g, 'a'))?.shape ?? null
19
14
 
20
15
  export function readDirectory(text: string): Directory {
21
16
  if (text.trimStart().startsWith('{')) {
22
- const value = JSON.parse(text) as Partial<Directory>
23
- return { shapes: value.shapes ?? {}, namespaces: list(value.namespaces), taxonomies: list(value.taxonomies), parts: list(value.parts), facts: list(value.facts) }
17
+ const value = JSON.parse(text) as Partial<Directory> & { parts?: { id: string }[]; facts?: string[] }
18
+ return { shapes: value.shapes ?? {}, namespaces: list(value.namespaces), taxonomies: list(value.taxonomies), unread: [...list<{ id: string }>(value.parts).map(part => part.id), ...list<string>(value.facts)] }
24
19
  }
25
- const directory: Directory = { shapes: {}, namespaces: [], taxonomies: [], parts: [], facts: [] }
20
+ const directory: Directory = { shapes: {}, namespaces: [], taxonomies: [], unread: [] }
26
21
  text.split('\n').map(line => line.trim()).filter(line => line && !line.startsWith('#')).forEach((line, index) => {
27
22
  const [key, ...rest] = line.split(' '), name = rest.join(' ')
28
- if (index < SHAPES.length) { if (line !== SHAPES[index]) directory.shapes![SHAPES[index]] = line }
23
+ if (index < SHAPES.length) { if (line !== SHAPES[index]) directory.shapes[SHAPES[index]] = line }
29
24
  else if (NAMESPACE_KEY.test(key)) directory.namespaces.push({ shorthand: key, name })
30
25
  else if (TAXONOMY_KEY.test(key)) directory.taxonomies.push({ shorthand: key.replace(/[^a-z]/g, ''), name, shape: patternShape(key)!, pattern: key })
31
- else if (FACT.test(line)) directory.facts.push(line)
32
- else { const [label, path] = name.split(' @ '); directory.parts.push({ id: key, shape: parseCode(key)?.shape!, name: label, path: path ?? null }) }
26
+ else directory.unread!.push(line)
33
27
  })
34
28
  return directory
35
29
  }
36
30
 
37
31
  export function writeDirectory(directory: Directory): string {
38
32
  return [
39
- SHAPES.map(shape => directory.shapes?.[shape] ?? shape),
33
+ SHAPES.map(shape => directory.shapes[shape] ?? shape),
40
34
  directory.namespaces.map(({ shorthand, name }) => `${shorthand} ${name}`),
41
35
  directory.taxonomies.map(({ pattern, name }) => `${pattern.replace(/\s/g, '')} ${name}`),
42
- directory.parts.map(({ id, name, path }) => `${id} ${name}${path ? ` @ ${path}` : ''}`),
43
- directory.facts,
44
36
  ].filter(lines => lines.length).map(lines => lines.join('\n')).join('\n\n') + '\n'
45
37
  }
46
38
 
47
- export function directoryHealth(directory: Directory, exists: (path: string) => boolean = () => true): string[] {
39
+ export function directoryHealth(directory: Directory): string[] {
48
40
  const problems: string[] = []
49
- for (const [shape, name] of Object.entries(directory.shapes ?? {})) if (!SHAPES.includes(shape as CodeShape) || typeof name !== 'string' || !name.trim()) problems.push(`Invalid shape name: ${shape}`)
41
+ for (const [shape, name] of Object.entries(directory.shapes)) if (!SHAPES.includes(shape as CodeShape) || typeof name !== 'string' || !name.trim()) problems.push(`Invalid shape name: ${shape}`)
50
42
  const seen = (values: string[], what: string) => values.forEach((value, index) => { if (values.indexOf(value) !== index) problems.push(`${what} ${value} is declared twice`) })
51
43
  problems.push(...namespaceHealth(directory.namespaces), ...taxonomyHealth(directory.taxonomies))
52
44
  seen(directory.namespaces.map(namespace => namespace.shorthand), 'Namespace')
53
45
  seen(directory.taxonomies.map(taxonomy => taxonomy.shorthand), 'Taxonomy')
54
- seen(directory.parts.map(part => part.id), 'Id')
55
- const ids = new Set(directory.parts.map(part => part.id))
56
- for (const part of directory.parts) {
57
- const shape = parseCode(part.id)?.shape
58
- if (shape !== part.shape) problems.push(`${part.id} reads as ${shape ?? 'no shape'}, not ${part.shape}`)
59
- else if (shape === 'LLLLNN' ? blockedLLLLNNCode(part.id) : blockedCodeLetters(part.id)) problems.push(`${part.id} uses blocked letters or digits`)
60
- if (!part.name) problems.push(`${part.id} has no name`)
61
- if (TAXONOMY_KEY.test(part.id) || FACT.test(`${part.id} ${part.name}`)) problems.push(`${part.id} would read back as a taxonomy or a fact`)
62
- if (part.path && !exists(part.path)) problems.push(`${part.id}: ${part.path} is gone`)
63
- }
64
- for (const fact of directory.facts) {
65
- const [subject, relation, object, extra] = fact.split(' ')
66
- if (extra !== undefined || !RELATION.test(relation ?? '')) problems.push(`Not a fact: ${fact}`)
67
- else for (const id of [subject, object]) if (!ids.has(id)) problems.push(`Unknown id ${id} in: ${fact}`)
68
- }
46
+ for (const line of directory.unread ?? []) problems.push(`Not vocabulary: ${line} (codes and links live with their records)`)
69
47
  return problems
70
48
  }
71
49
 
72
50
  export function resolveCode(directory: Directory, value: string): Resolved[] {
73
51
  const qualified = /^-([A-Z]{2})-(.+)$/.exec(value)
74
- const ids = (qualified ? qualified[2] : value).split(JUNCTION_SEPARATOR)
75
- return ids.map(id => {
52
+ return (qualified ? qualified[2] : value).split(JUNCTION_SEPARATOR).map(id => {
76
53
  const shape = parseCode(id)?.shape ?? null
77
- const namespace = namespaceOf(directory, id, qualified?.[1])
78
- const facts = directory.facts.filter(fact => { const [subject, , object] = fact.split(' '); return subject === id || object === id })
79
- return { id, shape, namespace, taxonomy: shape ? taxonomyOf(directory, id) : undefined, part: directory.parts.find(part => part.id === id), facts }
54
+ return { id, shape, namespace: namespaceOf(directory, id, qualified?.[1]), taxonomy: shape ? taxonomyOf(directory, id) : undefined }
80
55
  })
81
56
  }
82
57
 
83
- const nameOf = (directory: Directory, id: string) => directory.parts.find(part => part.id === id)?.name ?? id
84
- const readFact = (directory: Directory, fact: string) => { const [subject, relation, object] = fact.split(' '); return `${subject} ${relation} ${object} ${nameOf(directory, subject)} → ${nameOf(directory, object)}` }
58
+ const shapeName = (directory: Directory, shape: CodeShape) => directory.shapes[shape] ? `${shape} · ${directory.shapes[shape]}` : shape
85
59
 
86
60
  export function describeResolved(directory: Directory, resolved: Resolved[]): string {
87
- return resolved.map(({ id, shape, namespace, taxonomy, part, facts }) => [
88
- `${id} ${part?.name ?? (shape ? 'not in .id' : 'not a code')}`,
89
- ` shape ${shape ?? '—'}`,
61
+ return resolved.map(({ id, shape, namespace, taxonomy }) => [
62
+ `${id}${shape ? '' : ' not a code'}`,
63
+ ...(shape ? [` shape ${shapeName(directory, shape)}`] : []),
90
64
  ...(taxonomy ? [` taxonomy ${taxonomy.shorthand} · ${taxonomy.name}`] : []),
91
65
  ...(namespace ? [` namespace ${namespace.shorthand} · ${namespace.name}`] : []),
92
- ...(part?.path ? [` path ${part.path}`] : []),
93
- ...facts.map(fact => ` fact ${readFact(directory, fact)}`),
94
66
  ].join('\n')).join('\n\n')
95
67
  }
96
68
 
97
- export function describeStatus(directory: Directory, problems: string[]): string {
98
- const count = (n: number, one: string, many = `${one}s`) => `${n} ${n === 1 ? one : many}`
99
- const shapes = SHAPES.map(shape => [shape, directory.parts.filter(part => part.shape === shape).length] as const).filter(([, n]) => n)
69
+ export function describeDirectory(directory: Directory, problems: string[] = directoryHealth(directory)): string {
100
70
  return [
101
- `${count(directory.parts.length, 'part')} · ${count(directory.facts.length, 'fact')} · ${count(directory.namespaces.length, 'namespace')} · ${count(directory.taxonomies.length, 'taxonomy', 'taxonomies')}`,
102
- problems.length ? `${count(problems.length, 'problem')}: run idv1 health` : 'healthy',
103
- '',
104
- ...shapes.map(([shape, n]) => ` ${shape.padEnd(9)}${n} ${directory.shapes?.[shape] ?? shape}`),
105
- ...directory.taxonomies.map(taxonomy => ` ${taxonomy.shorthand.padEnd(9)}${directory.parts.filter(part => taxonomyOf(directory, part.id) === taxonomy).length} ${taxonomy.name}`),
106
- ].join('\n')
107
- }
108
-
109
- export function describeDirectory(directory: Directory): string {
110
- const contains = directory.facts.map(fact => fact.split(' ')).filter(([, relation]) => relation === 'rHasPt')
111
- const children = (id: string) => contains.filter(([subject]) => subject === id).map(([, , object]) => object)
112
- const roots = directory.parts.filter(part => !contains.some(([, , object]) => object === part.id))
113
- const line = (part: Part | undefined, id: string, depth: number) => `${' '.repeat(depth)}${id} ${part?.name ?? '?'}${part && taxonomyOf(directory, id) ? ` (${taxonomyOf(directory, id)!.name})` : ''}${part?.path ? ` ${part.path}` : ''}`
114
- const tree = (id: string, depth: number, trail: Set<string>): string[] => trail.has(id) ? [] : [line(directory.parts.find(part => part.id === id), id, depth), ...children(id).flatMap(child => tree(child, depth + 1, new Set([...trail, id])))]
115
- return [
116
- 'Shapes',
117
- ...SHAPES.map(shape => ` ${shape} ${directory.shapes?.[shape] ?? shape}`),
118
- '',
119
- 'Namespaces',
120
- ...directory.namespaces.map(({ shorthand, name }) => ` ${shorthand} ${name}`),
71
+ ...SHAPES.map(shape => `${shape} ${directory.shapes[shape] ?? ''}`.trimEnd()),
121
72
  '',
122
- 'Taxonomies',
123
- ...directory.taxonomies.map(({ shorthand, name, shape, pattern }) => ` ${shorthand} ${name} ${shape} ${pattern}`),
73
+ ...directory.namespaces.map(({ shorthand, name }) => `${shorthand} ${name}`),
124
74
  '',
125
- 'Parts',
126
- ...roots.flatMap(part => tree(part.id, 1, new Set())),
75
+ ...directory.taxonomies.map(({ pattern, name }) => `${pattern} ${name}`),
127
76
  '',
128
- 'Facts',
129
- ...directory.facts.filter(fact => fact.split(' ')[1] !== 'rHasPt').map(fact => ` ${readFact(directory, fact)}`),
77
+ problems.length ? `${problems.length} problem${problems.length === 1 ? '' : 's'}: run idv1 health` : 'healthy',
130
78
  ].join('\n')
131
79
  }
132
80
 
133
- export function runDirectoryCommand(command: string | undefined, args: string[], text: string, exists?: (path: string) => boolean): { code: number; out: string } {
81
+ export function runDirectoryCommand(command: string | undefined, args: string[], text: string): { code: number; out: string } {
134
82
  const directory = readDirectory(text)
135
- const problems = directoryHealth(directory, exists)
83
+ const problems = directoryHealth(directory)
136
84
  switch (command) {
137
85
  case 'health': return { code: problems.length ? 1 : 0, out: problems.length ? problems.join('\n') : 'healthy' }
138
- case 'status': return { code: 0, out: describeStatus(directory, problems) }
139
- case 'resolve': return args.length ? { code: 0, out: args.map(value => describeResolved(directory, resolveCode(directory, value))).join('\n\n') } : { code: 2, out: 'idv1 resolve <id | junction | -NS-id>' }
140
- case 'directory': case undefined: return { code: 0, out: describeDirectory(directory) }
141
- default: return { code: 2, out: 'idv1 directory | status | health | resolve <id>' }
86
+ case 'resolve': return args.length ? { code: 0, out: args.map(value => describeResolved(directory, resolveCode(directory, value))).join('\n\n') } : { code: 2, out: 'idv1 resolve <code | junction | -NS-code>' }
87
+ case 'directory': case undefined: return { code: 0, out: describeDirectory(directory, problems) }
88
+ default: return { code: 2, out: 'idv1 directory | health | resolve <code>' }
142
89
  }
143
90
  }
@@ -5,6 +5,7 @@
5
5
  .explorer-row { display: grid; grid-template-columns: calc(8 * var(--cell)) minmax(0, 1fr) auto calc(4 * var(--cell)); column-gap: calc(var(--unit) / 2); margin: 0; color: inherit; text-decoration: none; }
6
6
  .explorer-step, .explorer-title, .explorer-row > span, p.explorer-row { box-sizing: border-box; display: block; height: var(--unit); padding-top: calc(var(--unit) / 5); line-height: calc(var(--unit) * 4 / 5); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: inherit; text-decoration: none; }
7
7
  .explorer-row > .explorer-mono { font-family: var(--idv1-explorer-mono, monospace); font-variant-numeric: tabular-nums; white-space: pre; text-overflow: clip; letter-spacing: calc(var(--cell) - 1ch); padding-inline-start: calc((var(--cell) - 1ch) / 2); box-shadow: inset 0 0 0 1px var(--rule); background-image: linear-gradient(to right, var(--rule) 2px, transparent 2px), linear-gradient(to right, color-mix(in oklab, var(--ink) 9%, transparent) 1px, transparent 1px); background-size: var(--unit) 100%, var(--cell) 100%; }
8
+ .explorer-gap { margin-block-start: var(--unit); }
8
9
  .explorer-title { margin-inline-start: auto; }
9
10
  .explorer-dim, .explorer-step:not(:last-of-type) { color: color-mix(in oklab, var(--ink) 55%, transparent); }
10
11
  .explorer :is(a:hover, a:focus-visible) { background-color: color-mix(in oklab, var(--ink) 14%, transparent); outline: none; }
@@ -18,7 +18,7 @@ export type ExplorerData = {
18
18
  type Node = ExplorerNode;
19
19
  type Taxonomy = ExplorerTaxonomy;
20
20
  type Identifier = ExplorerIdentifier;
21
- export type ExplorerEntry = { path: string[]; id: string; label: string; kind: string; count: number; href?: string };
21
+ export type ExplorerEntry = { path: string[]; id: string; label: string; kind: string; count: number; href?: string; gap?: true };
22
22
  type Entry = ExplorerEntry;
23
23
 
24
24
  export function createExplorer(data: ExplorerData) {
@@ -56,8 +56,9 @@ export function createExplorer(data: ExplorerData) {
56
56
  const target = entry && 'on' in entry && entry.on ? `-${entry.namespace}-${entry.on}` : id;
57
57
  return [...nodes.values()].filter(node => node.qualifiedId === target);
58
58
  };
59
- const lists: Record<string, string> = { shapes: 'Shapes', namespaces: 'Namespaces', taxonomies: 'Taxonomies', identifiers: 'Identifiers' };
59
+ const lists: Record<string, string> = { namespaces: 'Namespaces', taxonomies: 'Taxonomies', identifiers: 'Identifiers' };
60
60
  const shapeName = (name: string) => shapes.find(kind => kind.name === name)?.label ?? name;
61
+ const plural = (word: string) => word === word.toUpperCase() ? word : word.replace(/([^aeiou])y$/i, '$1ie').replace(/(s|x|ch|sh)$/i, '$1e') + 's';
61
62
  const ofShape = (name: string) => [...nodes.values()].filter(node => node.shape === name);
62
63
  const scope = (path: string[]) => { const at = path.at(-1); return !at || lists[at] ? data.namespace : at.length === 2 ? at : at.includes(':') ? '' : nodes.get(at)?.namespace ?? ''; };
63
64
  const idIn = (id: string, namespace: string) => id.length > 2 && id.slice(1, 3) === namespace ? id.slice(4) : short(id);
@@ -86,8 +87,8 @@ export function createExplorer(data: ExplorerData) {
86
87
  function entries(path: string[]): Entry[] {
87
88
  const at = path.at(-1);
88
89
  if (!at) return [
89
- { path: ['shapes'], id: '', label: 'Shapes', kind: '', count: shapes.length },
90
- { path: ['namespaces'], id: '', label: 'Namespaces', kind: '', count: namespaces().length },
90
+ ...shapes.map(kind => ({ path: [`sh:${kind.name}`], id: kind.pattern, label: plural(kind.label), kind: '', count: ofShape(kind.name).length })),
91
+ { path: ['namespaces'], id: '', label: 'Namespaces', kind: '', count: namespaces().length, gap: true as const },
91
92
  { path: ['taxonomies'], id: '', label: 'Taxonomies', kind: '', count: taxonomy.length },
92
93
  { path: ['identifiers'], id: '', label: 'Identifiers', kind: '', count: identifiers.length },
93
94
  ...recordEntries([], data.collections ?? []),
@@ -96,7 +97,6 @@ export function createExplorer(data: ExplorerData) {
96
97
  if (at === 'namespaces') return namespaces().map(namespace => ({
97
98
  path: [namespace], id: namespace, label: owner(namespace)?.name ?? namespace, kind: 'Namespace', count: topLevel(namespace).length,
98
99
  }));
99
- if (at === 'shapes') return shapes.map(kind => ({ path: [`sh:${kind.name}`], id: kind.pattern, label: kind.label, kind: 'Shape', count: ofShape(kind.name).length }));
100
100
  if (at === 'taxonomies') return taxonomy.map(entry => ({
101
101
  path: [`tx:${entry.tag}`], id: entry.pattern, label: entry.name, kind: shapeName(entry.shape), count: tagged(entry).length,
102
102
  }));
@@ -110,13 +110,13 @@ export function createExplorer(data: ExplorerData) {
110
110
  return rowsOf(path, (children.get(at) ?? []).flatMap(id => nodes.get(id) ?? []));
111
111
  }
112
112
 
113
- const stepName = (path: string[], depth: number) => { const step = path[depth - 1]; return record(path.slice(0, depth))?.label ?? lists[step] ?? (step.startsWith('sh:') ? shapeName(step.slice(3)) : step.startsWith('tx:') ? step.slice(3) : step.startsWith('id:') ? idIn(step.slice(3), scope(path.slice(0, depth - 1))) : idIn(step, scope(path.slice(0, depth - 1)))); };
113
+ const stepName = (path: string[], depth: number) => { const step = path[depth - 1]; return record(path.slice(0, depth))?.label ?? lists[step] ?? (step.startsWith('sh:') ? plural(shapeName(step.slice(3))) : step.startsWith('tx:') ? step.slice(3) : step.startsWith('id:') ? idIn(step.slice(3), scope(path.slice(0, depth - 1))) : idIn(step, scope(path.slice(0, depth - 1)))); };
114
114
  function title(path: string[]) {
115
115
  const at = path.at(-1);
116
116
  if (!at) return data.name;
117
117
  if (lists[at]) return lists[at];
118
118
  if (at.startsWith('rc:')) return record(path)?.label ?? '';
119
- if (at.startsWith('sh:')) return `${shapeName(at.slice(3))} · Shape`;
119
+ if (at.startsWith('sh:')) return plural(shapeName(at.slice(3)));
120
120
  if (at.startsWith('tx:')) return `${taxonomy.find(entry => entry.tag === at.slice(3))?.name ?? at.slice(3)} · Taxonomy`;
121
121
  if (at.startsWith('id:')) return `${identifiers.find(entry => identifierKey(entry) === at.slice(3))?.name ?? at.slice(3)} · Identifier`;
122
122
  if (at.length === 2) return `${owner(at)?.name ?? at} · Namespace`;
@@ -172,7 +172,7 @@ export function mountExplorer(surface: HTMLElement, data: ExplorerData) {
172
172
  pathLine.replaceChildren(...[data.name, ...path].map((step, depth) =>
173
173
  link(path.slice(0, depth), 'explorer-step', [[`${depth ? stepName(path, depth) : step} /`, '']])), corner);
174
174
  const list = entries(path);
175
- rows.replaceChildren(...list.map(entry => link(entry.path, 'explorer-row', [
175
+ rows.replaceChildren(...list.map(entry => link(entry.path, entry.gap ? 'explorer-row explorer-gap' : 'explorer-row', [
176
176
  [entry.id.padEnd(8), 'explorer-mono'],
177
177
  [entry.label, ''],
178
178
  [entry.kind, 'explorer-dim'],