@alis-build/design-system 0.42.0 → 0.43.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/README.md CHANGED
@@ -146,6 +146,15 @@ export default {
146
146
  Its baseline, `alisx-words-baseline.json`, works as the styles one does. A
147
147
  use that must stay is marked on its line or the line above:
148
148
  `alisx-words-ignore -- the reason`.
149
+ - `alisx-check words --text <file>` reads a words file instead of markup: the
150
+ plain text a terminal app writes out of everything it says, in blocks headed
151
+ `== kind place · area`, then one `field<TAB>text` line per thing read.
152
+ `code` and `alias` lines, backticked spans (one a wrapped line carries on),
153
+ printf verbs (`%s`) and placeholders (`<id>`) are code. The baseline counts
154
+ each place, so the block that gains a retired name is the one that fails.
155
+ The file is generated, so there is no ignore: change the words at their source.
156
+ - In both, a retired name written with a capital ("Read only") is a label, and
157
+ counts only with its capital: "read only the parts that matter" is English.
149
158
  - Each stops with exit code 2, never passes, when it could not run as set up: a
150
159
  rule stylelint rejected, a file that didn't parse, no files matched.
151
160
 
package/check.mjs CHANGED
@@ -31,7 +31,16 @@
31
31
  // capital (rules/words.md). Code words (ideas.length, 'ideate-project')
32
32
  // are not read. The baseline works as it does for styles (default
33
33
  // alisx-words-baseline.json). A line marked alisx-words-ignore with a
34
- // reason, or the line under it, is skipped.
34
+ // reason, or the line under it, is skipped. A retired name written with a
35
+ // capital (Read only) is a label, and counts only when it has the capital:
36
+ // "read only the parts that matter" is English.
37
+ //
38
+ // alisx-check words --text <file…> [--baseline <file>] [--update]
39
+ // Reads plain text written as a words file instead of markup: blocks headed
40
+ // `== kind place · area`, then one `field<TAB>text` line per thing a
41
+ // person reads. Lines of the field code or alias are code, and so is what
42
+ // is in backticks, a printf verb (%s) or a placeholder (<id>). The baseline
43
+ // counts each block's place, so one gaining a retired name fails.
35
44
  import { existsSync, mkdtempSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from 'node:fs'
36
45
  import { spawnSync } from 'node:child_process'
37
46
  import { tmpdir } from 'node:os'
@@ -41,14 +50,15 @@ import { fileURLToPath } from 'node:url'
41
50
  const here = dirname(fileURLToPath(import.meta.url))
42
51
  const { version } = JSON.parse(readFileSync(join(here, 'package.json'), 'utf8'))
43
52
  const usage =
44
- 'usage: alisx-check names <path…> [--prefix app-] [--declared <path>] [--allow <property>]\n alisx-check styles <glob…> [--baseline <file>] [--update]\n alisx-check words <path…> [--baseline <file>] [--update]'
53
+ 'usage: alisx-check names <path…> [--prefix app-] [--declared <path>] [--allow <property>]\n alisx-check styles <glob…> [--baseline <file>] [--update]\n alisx-check words [--text] <path…> [--baseline <file>] [--update]'
45
54
  const [command, ...argv] = process.argv.slice(2)
46
55
 
47
56
  const paths = []
48
- const options = { prefix: [], allow: [], declared: [], baseline: command === 'words' ? 'alisx-words-baseline.json' : 'alisx-style-baseline.json', update: false }
57
+ const options = { prefix: [], allow: [], declared: [], baseline: command === 'words' ? 'alisx-words-baseline.json' : 'alisx-style-baseline.json', update: false, text: false }
49
58
  for (let i = 0; i < argv.length; i++) {
50
59
  const arg = argv[i]
51
60
  if (arg === '--update') options.update = true
61
+ else if (arg === '--text' && command === 'words') options.text = true
52
62
  else if (arg === '--baseline' || arg === '--prefix' || arg === '--allow' || arg === '--declared') {
53
63
  const value = argv[++i]
54
64
  // --allow takes a property, which itself starts with two dashes.
@@ -250,11 +260,13 @@ function words() {
250
260
  if (missing.length) stop(`alisx-check words: no such path: ${missing.join(', ')}`)
251
261
  const files = paths
252
262
  .flatMap((path) => walk(resolve(path)))
253
- .filter((file) => sources.includes(extname(file)) && !/\.(spec|test)\.[cm]?[jt]sx?$|\.d\.ts$/.test(file))
263
+ .filter((file) => options.text || (sources.includes(extname(file)) && !/\.(spec|test)\.[cm]?[jt]sx?$|\.d\.ts$/.test(file)))
254
264
  if (!files.length) stop(`alisx-check words: no source files under ${paths.join(', ')}.`)
255
265
 
266
+ // A words file is counted by the place each block names, a source file whole.
256
267
  const root = dirname(resolve(options.baseline))
257
268
  const key = (file) => relative(root, file).split(sep).join('/')
269
+ const fileOf = (path) => path.split(' › ')[0]
258
270
  const now = {}
259
271
  const found = {}
260
272
  for (const file of files) {
@@ -265,13 +277,17 @@ function words() {
265
277
  lines.forEach((line, i) => {
266
278
  if (/alisx-words-ignore\s+--\s*\S/.test(line)) ignored.add(i + 1).add(i + 2)
267
279
  })
268
- for (const { start, value } of readable(text, extname(file))) {
280
+ const pieces = options.text ? plain(text) : readable(text, extname(file)).map((piece) => ({ ...piece, place: '' }))
281
+ if (options.text && !pieces.length) stop(`alisx-check words: ${key(file)} has no == blocks, so it is not a words file.`)
282
+ for (const { start, value, place } of pieces) {
269
283
  let rest = value
270
284
  for (const { text: word, name, pattern } of retired)
271
285
  rest = rest.replace(pattern, (match, offset) => {
286
+ // A label's capital is part of it: "Read only" is a role, "read only" English.
287
+ if (/[A-Z]/.test(word[0]) && match[0] !== word[0]) return match
272
288
  const line = lineOf(start + offset)
273
289
  if (!ignored.has(line)) {
274
- const path = key(file)
290
+ const path = place ? `${key(file)} › ${place}` : key(file)
275
291
  now[path] ??= {}
276
292
  now[path][word] = (now[path][word] ?? 0) + 1
277
293
  ;(found[path] ??= []).push({ word, name, line, text: lines[line - 1].trim() })
@@ -292,12 +308,12 @@ function words() {
292
308
  }
293
309
  }
294
310
  const read = new Set(files.map(key))
295
- const unseen = Object.fromEntries(Object.entries(baseline?.files ?? {}).filter(([path]) => !read.has(path) && existsSync(join(root, path))))
311
+ const unseen = Object.fromEntries(Object.entries(baseline?.files ?? {}).filter(([path]) => !read.has(fileOf(path)) && existsSync(join(root, fileOf(path)))))
296
312
 
297
313
  if (options.update) {
298
314
  const counts = Object.fromEntries(Object.entries({ ...unseen, ...now }).sort(([a], [b]) => a.localeCompare(b)))
299
315
  writeFileSync(options.baseline, `${JSON.stringify({ version, files: counts }, null, 2)}\n`)
300
- console.log(`alisx-check words: recorded ${total(counts)} retired names across ${Object.keys(counts).length} files in ${options.baseline}, against @alis-build/design-system@${version}.`)
316
+ console.log(`alisx-check words: recorded ${total(counts)} retired names across ${Object.keys(counts).length} ${options.text ? 'places' : 'files'} in ${options.baseline}, against @alis-build/design-system@${version}.`)
301
317
  return
302
318
  }
303
319
 
@@ -325,7 +341,10 @@ function words() {
325
341
  for (const use of uses.slice(0, 20)) console.error(` ${use.line} ${use.text.length > 120 ? `${use.text.slice(0, 117)}…` : use.text}`)
326
342
  if (uses.length > 20) console.error(` … and ${uses.length - 20} more`)
327
343
  }
328
- console.error('\nThe names are in words.json in @alis-build/design-system; rules/words.md says how to use them. A use that\nmust stay is marked on its line, with the reason:\n\n <!-- alisx-words-ignore -- why it stays -->\n')
344
+ if (options.text)
345
+ console.error('\nThe names are in words.json in @alis-build/design-system; rules/words.md says how to use them. A words\nfile is generated: change the words where they are written, and generate it again.\n')
346
+ else
347
+ console.error('\nThe names are in words.json in @alis-build/design-system; rules/words.md says how to use them. A use that\nmust stay is marked on its line, with the reason:\n\n <!-- alisx-words-ignore -- why it stays -->\n')
329
348
  process.exit(1)
330
349
  }
331
350
 
@@ -370,6 +389,45 @@ function readable(text, ext) {
370
389
  return pieces
371
390
  }
372
391
 
392
+ // The text in a words file a person reads, each line with where it starts and
393
+ // the place its block names. A code span that a long line wrapped carries on
394
+ // to the next line of its block.
395
+ function plain(text) {
396
+ const pieces = []
397
+ const code = /`[^`]*`|%[-+#0]*\d*(?:\.\d+)?[a-zA-Z]|<[A-Za-z][^<>]*>/g
398
+ let place = ''
399
+ let open = false
400
+ let at = 0
401
+ for (const line of text.split('\n')) {
402
+ const start = at
403
+ at += line.length + 1
404
+ const header = /^== +(\S+) +(.*?)(?: +hidden)? +· +\S+\s*$/.exec(line)
405
+ if (header) {
406
+ place = `${header[1]} ${header[2].replace(/\s+/g, ' ')}`
407
+ open = false
408
+ continue
409
+ }
410
+ const tab = line.indexOf('\t')
411
+ if (!place || tab < 0 || /^(?:code|alias)\b/.test(line)) continue
412
+ let value = line.slice(tab + 1)
413
+ // Still inside a span from the line above: code up to its closing tick.
414
+ if (open) {
415
+ const close = value.indexOf('`')
416
+ if (close < 0) continue
417
+ value = ' '.repeat(close + 1) + value.slice(close + 1)
418
+ open = false
419
+ }
420
+ value = value.replace(code, (match) => ' '.repeat(match.length))
421
+ const tick = value.indexOf('`')
422
+ if (tick >= 0) {
423
+ value = value.slice(0, tick)
424
+ open = true
425
+ }
426
+ if (/[A-Za-z]/.test(value)) pieces.push({ start: start + tab + 1, value, place })
427
+ }
428
+ return pieces
429
+ }
430
+
373
431
  // Code with each console.…(…) call blanked, keeping every offset.
374
432
  function unlogged(code) {
375
433
  let out = code
@@ -6,7 +6,7 @@ A dialog: `surface-container-high` (white in light) at `elevation-3`, an object-
6
6
 
7
7
  - Actions are [AppButton](AppButton.md)s on the trailing edge, affirmative last. A dialog is a screen of its own, so the affirmative is filled when it commits (`app-btn--filled`, with `app-btn--error` when it destroys) and the rest, Cancel always among them, are text. An affirmative that only opens, copies or reads stays text, so the whole dialog is text. The affirmative names the outcome ("Delete environment", not "OK"). A dialog is never heavier than what it interrupts, and never dark.
8
8
  - **Confirm** what is hard to undo or reaches past the user: deleting, sending to people, deploying to production. Restate it in the title as a question ("Delete staging?") and say what goes with it in the body.
9
- - **Signed out** is the one dialog with no Cancel: there is nothing to go back to. It sits over the screen as it was, Escape and the scrim don't close it, and signing in returns to the same screen ([errors.md](../rules/errors.md)).
9
+ - **Signed out** is the one dialog with no Cancel: there is nothing to go back to. It sits over the screen as it was, Escape and the scrim don't close it, and Sign in again opens sign-in in a new tab, so nothing underneath reloads ([errors.md](../rules/errors.md)).
10
10
  - **Asking for access** ([access.md](../rules/access.md) § Asking for more) is a form in a dialog. The title asks for the role ("Ask for Editor access?"), the body names who will be asked ("Ruan Spies, the Owner of Renewal calls, will be asked."), one field takes an optional note ("Note for Ruan (optional)"), and Send request is the filled affirmative. After it sends, the control that opened it is replaced by "Request sent".
11
11
  - **Sharing, seen by someone who can't change it**, lists the people with their roles as text (no role menus, no Remove), says what each role can do in the words of `words.json`, and has one line, "Only Owners can change Sharing.". Its actions are Close and, when they may ask, Request Editor access, both text: neither commits.
12
12
  - **A form in a dialog** (Invite people) follows the form rules: fields 24 apart, validated on submit, and persistent (Escape and the scrim don't close it). The dialog is the confirmation, so its affirmative ("Send 3 invites") needs no second one; it is the dialog's filled button.
@@ -87,6 +87,7 @@ A dialog: `surface-container-high` (white in light) at `elevation-3`, an object-
87
87
  - **Close** on Escape, on a press of the scrim itself (`mousedown` whose target is the `.app-scrim`, not the dialog), and on Cancel. A persistent dialog (a form) ignores Escape and the scrim.
88
88
  - **On close**: remove the scrim and return focus to the remembered element if it is still in the document.
89
89
  - Mount one dialog at a time.
90
+ - **Signed out**: Sign in again opens sign-in in a new tab from the click itself; where the tab is blocked, reload through sign-in instead. Close the dialog when that tab reports back, or when the window regains focus and the session is back. Back as someone else, reload the page.
90
91
  - **Asking for access**: Send request shows its work on the button; on success close the dialog, return focus to where the request's state now stands, and replace the control that opened it with that state. A failure stays in the dialog as an error alert at its top, with the note still there ([errors.md](../rules/errors.md)).
91
92
 
92
93
  ## Classes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alis-build/design-system",
3
- "version": "0.42.0",
3
+ "version": "0.43.0",
4
4
  "description": "The AlisX design system for coding agents: tokens, product CSS, component markup, capability marks, words and rules.",
5
5
  "keywords": ["alisx", "design-system", "design-tokens", "css"],
6
6
  "homepage": "https://alisx.com",
package/rules/errors.md CHANGED
@@ -151,8 +151,11 @@ short:
151
151
  - **Signed out.** An [AppDialog](../components/AppDialog.md) over the screen as
152
152
  it was: "You're signed out", "Sign in again to pick up where you left off.",
153
153
  and one text action, Sign in again. It is the one dialog with no Cancel: there
154
- is nothing to go back to. Signing in returns to the same screen, with what was
155
- typed still there.
154
+ is nothing to go back to. Sign in again opens sign-in in a new tab and the
155
+ screen underneath never reloads, so what was typed is still there and what
156
+ failed keeps its own notice with Try again. The dialog closes by itself once
157
+ they're signed in, from that tab or any other. Back as someone else, the page
158
+ reloads: what is on it is the other person's.
156
159
  - **A new version is waiting.** The one snackbar that stays: "A new version is
157
160
  ready." with Reload. It never interrupts and never reloads by itself.
158
161
 
@@ -18,7 +18,7 @@ What the system doesn't decide yet, in one place. When you hit one, take the qui
18
18
  - **Withdrawing a request, turning requests off, and approval chains.** A person can't withdraw a request they made, Owners can't choose whether anyone may ask, and a request that needs several approvers in turn has no pattern ([AppAsk](../components/AppAsk.md) § Who asks, [access.md](access.md) § Asking for more). An approval chain would be its own component: its parts and interaction differ.
19
19
  - **An account's own roles, and seats.** `words.json` names the roles on a thing (Owner, Editor, Viewer); an account's roles (an admin, a builder, a curator) and its seats are not in it yet. Say what the person needs in the screen's own words ("ask an admin of Acme"), and add the entries with the first change.
20
20
  - **Admin's words.** `words.json` names what Alis Ideate, Build and every product share; Admin's own things are not in it yet. Name them as the screen already does, and add the entry with the first change ([words.md](words.md)).
21
- - **Checking a terminal's words.** `alisx-check words` reads markup; the CLI's help, `alis docs` and its TUI are plain text, so nothing checks them yet. Until it does, review them by eye against `words.json` ([terminal.md](terminal.md)).
21
+ - **A terminal's drawn text.** `alisx-check words --text` reads the CLI's words file: its help, `alis docs`, the TUI's views and actions, tips, the tour and errors. Text the TUI writes straight into a screen (column headers, intros, empty states) is not in that file yet; review it by eye against `words.json` ([terminal.md](terminal.md)).
22
22
  - **A log viewer.** "View logs" goes to the logs' own screen; there is no pattern for showing logs inside a pane.
23
23
  - **Each product's destinations** (the rows under its heading in the rail) are product content, not part of this system. Use the capability marks for the tools they name.
24
24
 
package/rules/terminal.md CHANGED
@@ -69,3 +69,5 @@ A command or a flag is a label: it takes its name from `words.json`.
69
69
  3. Would an agent reading the help or a hint learn the right name?
70
70
  4. Did a renamed command keep its old name as a hidden alias, and did a guard's
71
71
  or a script's name stay put?
72
+ 5. Did you generate the CLI's words file again? `alisx-check words --text` reads
73
+ it against `words.json`, and a place that gains a retired name fails.