@alis-build/design-system 0.42.1 → 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 +9 -0
- package/check.mjs +67 -9
- package/package.json +1 -1
- package/rules/known-gaps.md +1 -1
- package/rules/terminal.md +2 -0
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
|
-
|
|
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
|
-
|
|
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
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alis-build/design-system",
|
|
3
|
-
"version": "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/known-gaps.md
CHANGED
|
@@ -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
|
-
- **
|
|
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.
|