@astryxdesign/cli 0.7.3-canary.fba04ed → 0.7.4-canary.10b832e
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 +115 -0
- package/README.md +5 -5
- package/api/build/kit/weights.d.mts +8 -22
- package/api/build/kit/weights.mjs +87 -8
- package/api/build/kit/weights.test.mjs +96 -0
- package/api/discover/_adapter.mjs +22 -10
- package/api/discover/_catalog-view.d.mts +2 -0
- package/api/discover/_catalog-view.mjs +1 -0
- package/api/discover/_catalog-view.test.mjs +1 -0
- package/api/discover/detail/detail.mjs +1 -0
- package/api/discover/detail/detail.test.mjs +3 -0
- package/api/discover/detail/doc/doc.mjs +5 -1
- package/api/discover/detail/doc/doc.test.mjs +1 -0
- package/api/discover/detail/item/item.mjs +2 -0
- package/api/discover/detail/item/item.test.mjs +2 -0
- package/api/discover/discover.doc.mjs +4 -4
- package/api/discover/discover.type.d.mts +20 -0
- package/api/discover/discover.type.mjs +5 -0
- package/api/discover/list/list.test.mjs +2 -0
- package/api/discover/search/search.d.mts +3 -2
- package/api/discover/search/search.mjs +26 -7
- package/api/discover/search/search.test.mjs +67 -0
- package/api/doctor/_adapter.d.mts +40 -0
- package/api/doctor/_adapter.mjs +171 -1
- package/api/doctor/built-checks.d.mts +85 -0
- package/api/doctor/built-checks.mjs +837 -0
- package/api/doctor/built-checks.test.mjs +531 -0
- package/api/doctor/doctor.d.mts +6 -5
- package/api/doctor/doctor.doc.mjs +10 -0
- package/api/doctor/doctor.mjs +18 -3
- package/api/doctor/doctor.type.d.mts +6 -0
- package/api/doctor/doctor.type.mjs +3 -0
- package/api/integration/pack-check.mjs +6 -1
- package/api/integration/pack-check.test.mjs +14 -0
- package/api/theme/palette/generate/generate.d.mts +8 -0
- package/api/theme/palette/generate/generate.mjs +38 -11
- package/api/theme/palette/generate/generate.test.mjs +83 -4
- package/api/theme/palette/generate/generator.d.mts +6 -0
- package/api/theme/palette/generate/generator.mjs +6 -0
- package/api/theme/theme.type.d.mts +12 -1
- package/api/theme/theme.type.mjs +7 -1
- package/api/theme/themePaletteGenerate.doc.mjs +1 -1
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherReviewFlow.doc.mjs +1 -1
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherShowcase.doc.mjs +1 -1
- package/assets/templates/themes/butter/butterPaletteRefs.generated.ts +54 -0
- package/assets/templates/themes/butter/butterPalettes.generated.receipt.json +1499 -0
- package/assets/templates/themes/butter/butterPalettes.generated.ts +550 -0
- package/assets/templates/themes/butter/butterTheme.ts +274 -234
- package/assets/templates/themes/butter/palette.config.json +484 -0
- package/assets/templates/themes/gothic/gothicPaletteRefs.generated.ts +41 -0
- package/assets/templates/themes/gothic/gothicPalettes.generated.receipt.json +979 -0
- package/assets/templates/themes/gothic/gothicPalettes.generated.ts +271 -0
- package/assets/templates/themes/gothic/gothicTheme.ts +130 -160
- package/assets/templates/themes/gothic/palette.config.json +371 -0
- package/assets/templates/themes/matcha/matchaPaletteRefs.generated.ts +51 -0
- package/assets/templates/themes/matcha/matchaPalettes.generated.receipt.json +1502 -0
- package/assets/templates/themes/matcha/matchaPalettes.generated.ts +501 -0
- package/assets/templates/themes/matcha/matchaPalettes.ts +21 -0
- package/assets/templates/themes/matcha/matchaTheme.ts +164 -103
- package/assets/templates/themes/matcha/palette.config.json +448 -0
- package/assets/templates/themes/stone/palette.config.json +262 -0
- package/assets/templates/themes/stone/stonePaletteRefs.generated.ts +51 -0
- package/assets/templates/themes/stone/stonePalettes.generated.receipt.json +840 -0
- package/assets/templates/themes/stone/stonePalettes.generated.ts +501 -0
- package/assets/templates/themes/stone/stoneTheme.ts +190 -207
- package/assets/templates/themes/y2k/palette.config.json +166 -0
- package/assets/templates/themes/y2k/y2kPaletteRefs.generated.ts +54 -0
- package/assets/templates/themes/y2k/y2kPalettes.generated.receipt.json +872 -0
- package/assets/templates/themes/y2k/y2kPalettes.generated.ts +550 -0
- package/assets/templates/themes/y2k/y2kPalettes.ts +257 -0
- package/assets/templates/themes/y2k/y2kTheme.ts +164 -391
- package/clients/cli/commands/discover.mjs +1 -1
- package/clients/cli/commands/discover.sources.test.mjs +6 -0
- package/clients/cli/commands/doctor.doc.mjs +12 -0
- package/clients/cli/commands/doctor.mjs +23 -8
- package/foundation/response/error-codes.test.mjs +9 -0
- package/foundation/response/response-types.doc.mjs +5 -5
- package/foundation/response/response-types.doc.test.mjs +29 -0
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,120 @@
|
|
|
1
1
|
# @xds/cli
|
|
2
2
|
|
|
3
|
+
# 0.7.3
|
|
4
|
+
|
|
5
|
+
#### New Features
|
|
6
|
+
|
|
7
|
+
- `astryx build` names the right block first far more often. It ranks every block in the catalog by what the request means, read from each block's own name, description, and component, so a block that word matching missed can still come first, with its own score and reason; and the block picker's fixed values are refitted on a larger, more varied set of written example requests, which helps most with requests worded in a product's own terms. A block the request names by its exact name, and a block from an integration, keep their place. The kit never lists more blocks than before, and its fields, page call, start template, and alternatives are unchanged.
|
|
8
|
+
- `astryx search` puts the entry you are after first more often: it orders the matches inside each score band, every result keeps its match score and reason, and a query that is an entry's exact name still answers with that entry first ([#7752](https://github.com/facebook/astryx/pull/7752)).
|
|
9
|
+
- `astryx doctor integration validate` and `astryx integration check` check the component names a package's docs and blocks give, and list what they find as notes beside validate's issues, each with its fix. Nothing counts a note and `integration check --strict` does not fail on them; they become failing warnings in the next minor release:
|
|
10
|
+
- `doc_name_mismatch` lists a component doc whose `name` is not the name the component is listed under when the module its printed import names (the doc's `import`, the published subpath, or the package root) provably does not export that name, so `astryx component` would print a broken import. The `Fix:` proposes the file name when that module exports it, otherwise the component it exports. A name that module's exports cannot prove or rule out (a re-export from another package, `export =`, a destructured binding, a namespace, an import that resolves to no file, or, when no import can be resolved, a source that only exports a default) is listed as not checked, with the reason, in validate's new `docNames` report.
|
|
11
|
+
- `unknown_block_component` lists a name a template's `exampleFor` or `componentsUsed` gives that neither the package nor Core has (every doc `astryx component` resolves in Core counts) and the template does not import it. Imports the template's local helpers make count too, including through a barrel such as `parts/index.ts`. A name is judged only where the template reaches components solely through named imports and re-exports from Core, React, StyleX, local helpers read in full, or the package's own name (followed through its `exports` like a helper). Anything else is listed as not checked in validate's new `blockComponents` report: an import from another package, which may render other components; any `default` binding other than React's or StyleX's; a namespace import; an alias of or member read off an imported binding; a component held in a variable; `require()`; a dynamic `import()`; a file that does not parse cleanly; a local module this check cannot read; and, without Core installed, any name only Core could resolve.
|
|
12
|
+
|
|
13
|
+
`integration check --strict` does not fail on anything listed as not checked.
|
|
14
|
+
|
|
15
|
+
- New `@astryxdesign/cli/host` entry for tools that carry the CLI: `runHostedCli` runs the CLI once per process, with the command name that tool's users type (printed commands start with it) and, when the tool skipped the project's own CLI, the reason, so that CLI is never run.
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
import {runHostedCli} from '@astryxdesign/cli/host';
|
|
19
|
+
|
|
20
|
+
const result = await runHostedCli({
|
|
21
|
+
argv: ['search', 'button'],
|
|
22
|
+
cliCommand: 'acme astryx',
|
|
23
|
+
});
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
- `astryx doctor integration validate` now notes, from source and without a build, what an integration package tells apps to import that they cannot import, the way it lists an ignored `cliCommand`. Each note is in `data.notes` and names its fix, such as the exact `exports` entry to add. Notes are listed only: neither `doctor integration validate` nor `astryx integration check --strict` counts or fails on them in 0.7.3, and they become failing warnings in the next minor release, so fix them now. It notes:
|
|
27
|
+
- a component's import (the doc's `import`, or the one the CLI derives when the doc has none) or a template's public import whose subpath package.json `exports` does not declare, or that names another package. A subpath is not declared by a missing key, a key whose only conditions an ES module import does not load (such as `require` or `types`), an `exports` that is a single string, a wildcard that does not match, or an empty `exports` map;
|
|
28
|
+
- a component example that imports a subpath the package does not declare;
|
|
29
|
+
- a template that imports a relative path outside the templates root, or a path its own package or Core does not export.
|
|
30
|
+
|
|
31
|
+
A subpath is judged from its `exports` declaration alone, never by its target file, so `exports` may point at build output that does not exist yet; whether that module exports the names an import asks for is the next entry's check. Wildcards and condition objects with `import` or `default` pass. An import of a subpath whose `exports` entry has only `types` targets, or that an ES module import reaches only through `types` (such as `types` beside `require`), is never judged as a run-time import: it passes when it is `import type`, when every binding is an inline `type`, or when every name it imports is one the `types` file declares as a type, and is listed under `unchecked` otherwise. A `types` target under `require` does not count, and a package with no `exports` keeps its deep paths to files it ships. What it cannot judge (in a package with no `exports`, a deep path into build output not built yet, such as `dist/`; a template import of Core when `@astryxdesign/core` is not installed beside the package; every import of the package's own name when package.json has no `name`) is listed under `unchecked` in a new `publicImports` report on the result (`{status: 'checked', findings: [], unchecked: [{file, specifier, reason}]}`), which `integration check` counts as not compared.
|
|
32
|
+
|
|
33
|
+
- `astryx doctor integration validate` now also notes, from source and without a build, an import that names something its module does not export (in `data.notes`, each with its fix). These notes are listed only in 0.7.3 too, and become failing warnings in the next minor release. It notes:
|
|
34
|
+
- a component's import (the doc's `import`, or the one the CLI derives) that leads to a module that does not export the component, naming the subpath that does or the `exports` entry to add;
|
|
35
|
+
- a component example or a template that imports a name the package does not export;
|
|
36
|
+
- a template source with no default export (`astryx template` still copies it, but its public import and anything that renders it get nothing), suggesting an exported PascalCase function, class or `const`, never a hook such as `useAccount`, a helper such as `formatBalance`, an ALL-CAPS constant or a type; with none, the fix stays generic.
|
|
37
|
+
|
|
38
|
+
A name is judged only when a file the `exports` entry names is there to read in full. `export *` is followed, cycles included; a built module's declaration file (`x.d.ts` beside `x.js`, and the `.d.ts` files its `export *` names) is read for the types it exports; `export import Alias = Inner.Value` counts as an export; TypeScript source resolves a `./x.js` specifier to `./x.ts`; and a declaration file that is a module exports every top-level declaration unless it has an export list, `export *`, `export =` or a default export of an expression, as TypeScript does. Whatever the reader does not fully model is listed under `unchecked` in the `publicImports` report instead of as a note: a file the `exports` entry names that does not exist yet; a module whose list cannot be read in full (CommonJS, `export *` from another package); a declaration file with no import or export (a global script); a name missing from a JavaScript module with no declaration file, which may be a type; and every name it would report, other than a component doc's own component, while a TypeScript file in the package (outside `node_modules`) has a parsed `declare module` block for a relative path, the package's own name or a subpath of it, since that can add names to the module. The reason names that file; `declare global`, a wildcard spec such as `'*.css'`, another package's name and a `declare module` in a comment do not count, and a file with `declare module` in its text that cannot be parsed counts. `astryx docs authoring/ship/checks` explains each check.
|
|
39
|
+
|
|
40
|
+
- A failed `astryx component`, `template` or `docs` lookup lists the entry you most likely meant first. Components that tie on match score are ordered by how early the name you typed appears in their keywords and by how close their names are, instead of alphabetically; among the suggestions offered, a component one of whose other names was typed (including another library's name for it, such as `MUI TextField`, with or without the library's name) comes first; a compound name that does not exist (a family part named with other words, or without one of its family's words) suggests the real part or its family. Templates are ordered by how closely their id or title matches the name you typed, and unknown docs routes by how closely the route matches. Suggestion lists never get longer, every suggestion is a real entry, and a name that resolved before still resolves to the same entry.
|
|
41
|
+
- Integration docs that tell readers to run an Astryx command through a package runner now get a `runner_command` note from `doctor integration validate` (and so `integration check`) in `data.notes`, with its file, line and the bare `astryx <command>` to write instead. A note fails nothing, so `integration check --strict` exits as before. The unscoped name after a download runner (`npx astryx`) always counts, because it fetches an unrelated package; the scoped `npx @astryxdesign/cli`, for install steps, does not.
|
|
42
|
+
|
|
43
|
+
#### Fixes
|
|
44
|
+
|
|
45
|
+
- `astryx build` starts from a page template its word weights do not list (an integration's template, or one added since the weights were fit) only when the request names as many words of that template's own display name, category and keywords (search's stopwords aside) as of the best listed template, or names that template's family (the first part of its category) before the listed template's family and at most two fewer of its words; otherwise it starts from that listed template and offers the other as the first alternative.
|
|
46
|
+
- The CLI finds the project's `@astryxdesign/core` from any folder inside the project, so `component`, `hook`, `build`, `search`, `swizzle`, `theme targets` and `doctor` now work five or more folders deep, in workspace members whose Core the workspace installs at its root, and in Yarn Plug'n'Play projects. They still search the folders they searched before, and past them continue up to the workspace root of the nearest folder whose package.json declares an Astryx package.
|
|
47
|
+
- `upgrade --from` run from any folder in a project upgrades that project: the nearest folder whose package.json declares an Astryx package or that an Astryx workspace lists, found without passing a repository root or counting the home folder. It targets only the project's own Core (the one in its `node_modules`, or for a member its workspace lists, the one the workspace installs), scans the project's `src` by default, reads a `--path` you type from the folder you ran in, names the files in its `--json` result relative to that folder, refreshes the project's agent docs, and names the project root and the source folder it scans before it changes anything. With no such project, `upgrade` reads only the current folder, as before.
|
|
48
|
+
- An `upgrade` run in a folder that installs Core but declares no Astryx package now upgrades the Astryx project above it instead of that folder alone, since such a folder was never a separate upgrade root. To keep a sub-folder that installs Core its own project, declare an Astryx package in that folder's package.json.
|
|
49
|
+
- A `packages/core` folder that holds another package is no longer read as Core, and an integration named in `astryx.config` now loads when the workspace installs it at its root, as an autolinked one already did.
|
|
50
|
+
- The CLI's install advice no longer adds a package to a `package.json` that is not an Astryx project's. This covers the daily hint, the setup reminder, the update notice, `astryx doctor`'s version-alignment and integration fixes, and `astryx discover`'s install command for an integration installed for the computer. The project is the nearest folder whose `package.json` declares an Astryx package, or a member its workspace lists, never the home folder and never past a repository root.
|
|
51
|
+
- From a folder inside such a project whose own `package.json` is not the project's, such as a tool folder that installs its own `@astryxdesign/core`, the daily hint that matches a project's CLI to its Core, the setup reminder and `astryx doctor`'s version-alignment fix used to name a command that added the CLI to that folder's `package.json`, making it a separate Astryx project. They still compare the CLI with the Core the run reads, and when the two differ they say to run from the project's folder, or to declare an Astryx package in that folder; the update notice upgrades the project from its folder, with the project's release.
|
|
52
|
+
- For an integration installed for the computer, `astryx discover` gives no install command from such a folder, and `astryx doctor`'s fix says to run from the project's folder, where the command adds it for the project; in a folder that belongs to no project, neither names a command.
|
|
53
|
+
- In a folder that belongs to no Astryx project, the hint, the setup reminder and the update notice no longer print, and `astryx doctor`'s fix says how to reach a project.
|
|
54
|
+
- Unchanged: the official packages `astryx discover` lists and the theme packages `astryx doctor` suggests still use the folder the command runs in; a member its workspace lists keeps its own advice; in a folder whose `package.json` declares an Astryx package, the advice is the same. No JSON shape or exit code changes.
|
|
55
|
+
- `astryx doctor integration validate`, `astryx integration check` and `astryx integration verify` catch more package mistakes, and each new finding ends in a `Fix:` that clears it. Findings that 0.7.2 did not fail on are listed as notes beside validate's issues, which nothing counts, until the next minor:
|
|
56
|
+
- Two docs for one component (`AcmeWidget.doc.mjs` and `AcmeWidget.doc.js`) are listed as `duplicate_component_doc`, naming the one read; discovery now always reads the same one.
|
|
57
|
+
- A component doc whose file name differs from its source only in letter case is one finding that says which file to rename: an error where the pair fails (Linux), a listed `source_without_component_doc` where it still pairs (a case-insensitive disk); a hidden doc that does not pair keeps the source warning it had.
|
|
58
|
+
- A root reached through a symlinked folder is listed as `symlinked_root`: npm pack does not follow it.
|
|
59
|
+
- An absolute root says roots are relative and gives the relative path; a root that is a file is reported by every check instead of crashing it.
|
|
60
|
+
- A package.json without `name` or `version` is listed with a fix, instead of a crash; `verify` fails on it. A package whose `name` and manifest `providerId` give no provider ID is listed as `no_provider_id`.
|
|
61
|
+
- A contribution file Astryx cannot read is listed as `unreadable_file`, before npm pack fails on it.
|
|
62
|
+
|
|
63
|
+
`astryx integration check --strict` does not fail on these pairing, root and package.json notes either; they become failures in the next minor. `astryx integration verify` still fails on a package.json npm cannot pack.
|
|
64
|
+
|
|
65
|
+
- `astryx doctor integration validate`, `astryx integration check` and `astryx integration verify` say more plainly what is wrong in findings they already reported, and how to fix it:
|
|
66
|
+
- An empty doc or manifest, or one with no default export, says so and names what it does export, instead of "(root): Invalid input".
|
|
67
|
+
- A manifest key one or two letters off a known key asks "did you mean `components`?" before suggesting a newer CLI.
|
|
68
|
+
- A theme descriptor named for the built file (`ocean.doc.mjs` beside a built `ocean.js` that lacks the `ocean` export) says it must share its stem with the `defineTheme` source, naming that source when the built module's `Source:` line or the source's `defineTheme` name confirms it.
|
|
69
|
+
- A template doc with no source, a theme descriptor with no source, a theme source with no descriptor, and a component whose source is `.jsx` get a `Fix:`.
|
|
70
|
+
- A theme source named for its theme (`brand.ts`) beside the module the build writes (`brand.js`) is told to take the `brandTheme` stem.
|
|
71
|
+
- `verify` names packed files by their path in the package, not the scratch copy's; says npm pack does not follow a symlinked root instead of asking for a `files` entry; and, when a theme's `defineTheme` name differs from the files its package exports, says a rebuild writes files under the new name.
|
|
72
|
+
- Integration authors now learn when the running CLI is outside their package's `@astryxdesign/cli` peer range: `astryx doctor integration validate` and `astryx integration check` list a `cli_peer_version` note naming the package, the range and the running version. Below the range the note gives the project's commands to install a newer `@astryxdesign/core` and `@astryxdesign/cli` together (as dev dependencies in the package's own folder) and then run `astryx upgrade --from <version> --apply`. Above the range it asks for a release of an installed package that supports this CLI, or asks the author of the package in the current folder to test with this CLI and widen the range. A note fails nothing: `--strict`, `integration verify`, `doctor`, and exit codes are unchanged.
|
|
73
|
+
- `astryx component <Member> --package @astryxdesign/core` now answers with that member, as the unscoped lookup does. A Core component documented in its family's doc (HStack and VStack in the Stack doc) used to come back as the family doc, named after the family and with no props.
|
|
74
|
+
- The agent guide that global mode writes to the home folder now tells agents to deliver a page built with Astryx, not only how to find things. Before, agents that found the right template could still build the page with a tool that cannot install packages and deliver a page with no Astryx in it. The guide now tells agents to work in a project folder (creating one if there is none); add `@astryxdesign/core` and `@astryxdesign/cli` to a new project or one without Core, or, in a project that already has `@astryxdesign/core`, the CLI at the same version; run `astryx init` there; follow the same template-first workflow and self-check the project agent docs give; and end by building the project and delivering that build. The guide stays version-free and names only commands every release keeps. The project agent docs are unchanged, and so is what `@astryxdesign/core`'s install script prints: its copy of the shared agent-docs file only gains the same workflow lines.
|
|
75
|
+
- Agents that follow the guide global mode writes to the home folder now know what to do when `astryx` is not found: run the command that installed the CLI for the computer first, with the same package manager and folder, such as `npm i -g @astryxdesign/cli` or `pnpm add -g @astryxdesign/cli`. On machines that keep the home folder but reset system folders on restart, the guide outlived the CLI installed for the computer and told agents to run a command that was gone. Outside a project, when the guide names `astryx` and no `astryx` command is on the search path, apart from a package runner's own copy, `astryx doctor` now says so and names the install step the guide records, or npm's when it records none. The global-mode guide for CI and containers explains how to keep the CLI across restarts. A guide written for a host's own command is unchanged. No JSON shape or exit code changes.
|
|
76
|
+
- The butter, stone, and y2k themes no longer show the secondary hover fill on a disabled `ComplexSelector` trigger, whether the trigger is natively disabled or exposes `aria-disabled="true"`, the focusable form every disabled control now uses. Before, the guard only recognized a natively disabled trigger. The themes `astryx theme eject` copies carry the same guard.
|
|
77
|
+
- Apps that use Core's prebuilt CSS without a StyleX build step now get the default data colors: the prebuilt CSS defines the canonical `dataVars` defaults, so compiled imports and raw CSS references paint correctly.
|
|
78
|
+
- `astryx init` writes the agent docs at the project root, in files the project commits, so Codex, Gemini CLI, Copilot CLI and Claude Code all read the block from the project root or any folder below it ([#7497](https://github.com/facebook/astryx/pull/7497)). It no longer writes agent docs into a project's subfolder, the home folder, or a settings folder in it such as `~/.gemini`.
|
|
79
|
+
- `AGENTS.md` holds the block, created when missing. Before, a project with only `CLAUDE.md` got the block only there, so Codex and Gemini CLI never saw it.
|
|
80
|
+
- Claude Code skips `AGENTS.md` in a folder that has a `CLAUDE.md` or `.claude/CLAUDE.md`, so the Claude Code file the project already has keeps a full copy: root `CLAUDE.md`, else `.claude/CLAUDE.md`. It keeps the copy even when it imports `AGENTS.md`, because Claude Code does not follow that import in a session started in a subfolder; started at the root, Claude Code then reads two. When both exist, the copy goes in root `CLAUDE.md`, which projects commit even when they ignore `.claude/`, and a block in `.claude/CLAUDE.md` is removed. Init creates no Claude file. `astryx upgrade` refreshes every copy, except in a project at the top of a home settings folder (see the next entry).
|
|
81
|
+
- Gemini CLI reads only `GEMINI.md`: init adds a one-line import, `@./AGENTS.md`, creating `GEMINI.md` when it is missing. It adds none when `GEMINI.md` already imports `AGENTS.md`, inline or on its own line. It adds the import even when the project's `.gemini/settings.json` has Gemini read `AGENTS.md` through `context.fileName`: Gemini loads those settings only when it starts at the project root, so a session started in a subfolder would otherwise get no copy. Started at the root, Gemini then reads two.
|
|
82
|
+
- The project root is the nearest folder at or above where init runs whose `package.json` declares an `@astryxdesign` package, else the nearest with any `package.json`. The search stops at a repository root and never counts the home folder. With no `package.json` found, init writes where it runs, as before. `docsWritten` still lists each file relative to where init ran, for example `../../AGENTS.md`.
|
|
83
|
+
- A `GEMINI.md` that resolves outside the project, for example a link to a shared file, is skipped and reported in `docsError` with one note (not an error line), in the default layout and in a project's own layout; the rest is written and init exits 0.
|
|
84
|
+
- The managed block belongs to Astryx: init and `astryx upgrade` write, refresh, and remove only the block, whatever ignore rules or generated markers say, as 0.7.1 did, and never change the text around it. Every write stays inside the project: run in the folder 0.7.1 wrote, an agent file 0.7.1 wrote there whose path leaves the project still refuses the run with exit 1. The project's Claude Code file (root `CLAUDE.md`, or `.claude/CLAUDE.md` when there is no root one) that resolves outside the project and is a block-less import of an existing `AGENTS.md`, which 0.7.1 left alone, is skipped and reported in `docsError` with one note, and init exits 0. Run from a folder below the project root, where 0.7.1 wrote in that folder instead, a project-root file whose path leaves the project is skipped and reported in `docsError` with one note, the rest is written, and init exits 0.
|
|
85
|
+
- While root `CLAUDE.md` is untracked and ignored by the repository's ignore rules (any ignore file from the repository root down, such as a monorepo's root `.gitignore`, the local exclude file, or configured excludes; init asks git, Sapling or Mercurial), a `.claude/CLAUDE.md` the project commits gets the copy too, so a fresh clone still gives Claude Code a copy; `--agent claude` and `--agent all` write it there as well. A file the repository tracks counts as committed whatever the ignore rules say, as git and Mercurial ignore only untracked files, and when the repository cannot answer, the copy is kept, on the first run as on later ones. Such a copy that resolves outside the project refuses the run with exit 1 where 0.7.1 wrote it too; one 0.7.1 did not write (the one `--agent claude` adds, or a block-less import of an existing `AGENTS.md`) is skipped and reported in `docsError` with one note, and init exits 0. So is a `.claude/CLAUDE.md` whose block `--agent claude` would remove beside a `CLAUDE.md`, since 0.7.1's `claude` preset wrote only `CLAUDE.md` there. Beside a committed root `CLAUDE.md`, with `.claude` linked outside the project, three cases that 0.7.1 refused now exit 0 with nothing written: the default with a `.claude/CLAUDE.md` of plain text, and `--agent all` with one of plain text or a block-less import of `AGENTS.md`; root `CLAUDE.md` holds the copy, so no write leaves the project. In a project that keeps its own layout, a `GEMINI.md` that imports no agent file now gets a copy, as the other agent files do.
|
|
86
|
+
- The copy in `.claude/CLAUDE.md` is removed only once root `CLAUDE.md` holds the same block, and only the managed block between its markers: the rest of the file stays, and the file is deleted only when nothing but whitespace is left. `astryx init --remove-agents` deletes a file it created only when nothing but whitespace or init's own heading is left; 0.7.0 also deleted a file whose remaining text had a heading and any line with the word "guidance".
|
|
87
|
+
- `astryx init --remove-agents` removes the block at the project root, where `init` writes it, and in the folder it runs in. Run from a subfolder, it removes what `init` wrote at the root, and a block an earlier version left in that subfolder; a root agent file with a block that resolves outside the project is left as it is with a note, and the run exits 0, as 0.7.1 did when it touched only the subfolder. Exit codes and the JSON shape are unchanged.
|
|
88
|
+
- `--agent claude` and `--agent all` never leave a block in both `CLAUDE.md` and `.claude/CLAUDE.md`, unless the project ignores `CLAUDE.md`: when `CLAUDE.md` gets the block, a block in `.claude/CLAUDE.md` is removed. `--agent all` keeps the `GEMINI.md` import. The `--agent` help and the working-with-AI guide say so. `--agent-docs-path` writes where init runs, as before.
|
|
89
|
+
- `astryx doctor` fails when the `GEMINI.md` import points at an `AGENTS.md` with no block. The setup check in the CLI and in `@astryxdesign/core` no longer counts that import as set up, and looks at `GEMINI.md`. The reminder to run `init` that commands print looks at the project root too, so it stops once `init` has run in a nested package.
|
|
90
|
+
- `astryx init` and `astryx upgrade` no longer write agent docs into your home folder, or into a settings folder in it such as `~/.gemini` or `~/.claude` outside a project. Agents read the files in those folders in every project, so a block there reached unrelated work. This follows the CLI's existing rules that no command writes agent docs into those folders and that a write outside a command's own folder is refused before anything is written.
|
|
91
|
+
- **Refused by `init`:** the home folder itself, and the top of any folder in it whose name starts with a dot (every such folder is a settings folder), even when it holds a `package.json`. A folder below it with its own `package.json` is a project and is set up normally, such as an agent worktree in `~/.codex/worktrees/` or `~/.cursor/worktrees/`, and `astryx upgrade` refreshes it. With `--agent-docs-path`, each file's own folder is checked: from the home folder, `notes/AI.md` is written as before, while `AI.md` or `.claude/CLAUDE.md` is refused.
|
|
92
|
+
- **What `init` does instead:** it writes no agent docs, reports `docsError` as `install-failed` with the reason, and exits 0, as before.
|
|
93
|
+
- **Refused by `upgrade`:** refreshing a block in a project whose root is the home folder or the top of a settings folder, such as `~/.dotfiles` with a `package.json`, with or without `--apply`. It leaves the block as it is, sets `agentDocs.action` to `error` (never `would-refresh`), and warns with the folder and why; its other steps and its exit status are as before. With no block there, it gives the same reason instead of suggesting `astryx init`. `astryx doctor`'s agent-docs fix does the same, and the setup reminder after each command stays quiet.
|
|
94
|
+
- **Migration:** run `astryx init` from the project's own folder, or add the block to the file by hand. Move a project rooted at the home folder or a settings folder into a folder of its own, or update or remove its block by hand. To remove a block an earlier version wrote into `~/.claude/CLAUDE.md`, run `astryx init --remove-agents` in the home folder.
|
|
95
|
+
- Repeated searches in one process answer faster: `astryx search` reuses its entry index while the catalog is unchanged, and ties that reuse to one list of the fields the index reads, so the index is never reused after any of them changes. Every answer is unchanged.
|
|
96
|
+
- Tools that bundle the CLI into a server function no longer pack their whole project folder into it: one path in `integration check`'s import checks was built in a way file tracers cannot follow. The path and its results are unchanged.
|
|
97
|
+
- `search()` from `@astryxdesign/cli/api` answers faster when one process searches again: it reuses the components, docs, templates and themes it gathered for the same folder and `type` while no file it read, and no folder it listed, has changed since (a linked workspace package included). To see those reads, the first such search in a process wraps `node:fs`'s read functions for that process; outside a search they behave exactly as before. Results are unchanged. Short-lived runs are unaffected: each `astryx search` command gathers once, as before ([#7830](https://github.com/facebook/astryx/pull/7830)).
|
|
98
|
+
- `astryx search` and `astryx build` find a block by its authored display name when that name has two words or more and holds every word of the component the block shows: a query naming it, such as "rich text editor" for an integration's Rich Text Editor block, ranks it first. A display name that labels only the variant, such as "Inside a card", is not read.
|
|
99
|
+
|
|
100
|
+
#### Documentation
|
|
101
|
+
|
|
102
|
+
- `astryx docs cli/commands/postinstall` now documents the hidden `postinstall` hook, `astryx docs cli/commands` lists it, and `astryx postinstall --help` shows its exit code and an example. The summary of `astryx docs cli/commands/manifest` (text and `--json`) drops its final period, so it matches the description the manifest has always printed. What each command prints when it runs, its JSON and its exit codes are unchanged.
|
|
103
|
+
- Everything an integration author reads now lives under one home, `astryx docs authoring`: the integration guides' routes moved from `cli/integrations/…` to `authoring/…` (for example, `cli/integrations/quick-start` is now `authoring/quick-start`), beside the field reference at `astryx docs authoring/field-reference`. `astryx docs authoring <name>` still opens one field reference section, and an old `cli/integrations/…` route's error names its new route. The loose topics now sit in Guides or Foundations instead of Unorganized, under the same names: `astryx docs getting-started` still opens, and its Up is `astryx docs guides`.
|
|
104
|
+
- A new guide, `astryx docs is-my-code-good`, checks component use, icons, custom styles, layout, assets, and code health from source and rendered evidence, in one page you can share. It includes an agent prompt and requires missing evidence to stay visible. The template grading rubric now links each category to these shared criteria instead of repeating them, and keeps its own weights, counting rules, and version 1.4.
|
|
105
|
+
- Questions like "add an integration" or "install a package" now find a guide for app builders first.
|
|
106
|
+
Added a "Use integrations" guide (`use-integrations.doc.mjs`) that covers discovering, installing, and using integration packages in an app; open it with `astryx docs use-integrations`. Search ranks it above authoring and API-function docs for those questions, while queries like "build an integration" still rank authoring content first.
|
|
107
|
+
|
|
108
|
+
#### Contributors
|
|
109
|
+
|
|
110
|
+
Thanks to everyone who contributed to this release:
|
|
111
|
+
|
|
112
|
+
- @cixzhang
|
|
113
|
+
- @ejhammond
|
|
114
|
+
- @josephfarina
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
3
118
|
# 0.7.2
|
|
4
119
|
|
|
5
120
|
#### New Components
|
package/README.md
CHANGED
|
@@ -489,10 +489,10 @@ Every response has a `type` discriminant. The full set is below (generated from
|
|
|
489
489
|
| `docs.node` | One node of the docs tree, read by its route: its id, kind, package, title, summary, and breadcrumb, plus a namespace's slots with their children (one level down, each naming its package) or a typed doc's content, and links ({up, previous, next, related}: the commands that open its parent, its neighbors, and the docs it names). |
|
|
490
490
|
| `blog.list` | The feed URL plus every post parsed from the RSS feed, each with slug, title, description, date, type, authors, link, and plaintext URL. |
|
|
491
491
|
| `blog.detail` | One post's metadata plus the feed URL and the post's full plaintext body. |
|
|
492
|
-
| `discover.list` | What the project has, the integrations it loads and the official packages it declares, official packages first (name, category, components, version, a list per other kind they add, and latest when a source knows it); meta.available lists what the project could add, the official packages first, each with the command that adds it, and meta.sources reports each source, the official list last; when it lists no integration it carries meta.configured to tell "nothing configured" from "nothing discovered".
|
|
493
|
-
| `discover.detail` | One package, for an @scope/name or @scope/name@version query: what the shown version adds, whether the project has it, and, when a source knows the package, its versions, latest release, and the command that adds it.
|
|
494
|
-
| `discover.detail.doc` | The validated ComponentDoc for one installed component, for an @scope/name/Component query.
|
|
495
|
-
| `discover.item` | One item that is not an installed component, for an @scope/name/<item> query: its kind, name, package, version, and whether the project has the package.
|
|
492
|
+
| `discover.list` | What the project has, the integrations it loads and the official packages it declares, official packages first (package, the npm package and always equal to name; name, category, components, version, a list per other kind they add, and latest when a source knows it); meta.available lists what the project could add, the official packages first, each with its package and the command that adds it, and meta.sources reports each source, the official list last; when it lists no integration it carries meta.configured to tell "nothing configured" from "nothing discovered". |
|
|
493
|
+
| `discover.detail` | One package, for an @scope/name or @scope/name@version query: its package (the npm package the result is about), what the shown version adds, whether the project has it, and, when a source knows the package, its versions, latest release, and the command that adds it. |
|
|
494
|
+
| `discover.detail.doc` | The validated ComponentDoc for one installed component, for an @scope/name/Component query, plus package, the npm package that owns the component. |
|
|
495
|
+
| `discover.item` | One item that is not an installed component, for an @scope/name/<item> query: its kind, name, package, version, and whether the project has the package. The envelope's package names the same package. |
|
|
496
496
|
| `discover.search` | The echoed query plus every matching item and package across all packages, each with its kind and whether the project has it, even when only one matches; total is set when --limit cut the list. |
|
|
497
497
|
| `search` | The echoed query, `matchCount` (total matches, before `limit`), and results, a ranked SearchResultEntry[] bounded by `limit`: each {domain, name, package, score, reason, description, command} (package is the npm package that owns the result), plus import (components, hooks), title, parent (the command that opens the level above), and, for a hit on one section, section (docs), or displayName and kind (templates). When a search with no `type` could not obtain @astryxdesign/core, `meta.partial` is {skipped, reason}: the domains it skipped (component, hook, template) and why. |
|
|
498
498
|
| `build.help` | The how-to-build-a-page playbook, emitted when no query is given: `playbook: true`, a title, the ordered steps (title, commands, optional returns), the on-system rules, and related lookups. Commands are bare subcommands for the caller to render with its own invocation. |
|
|
@@ -517,7 +517,7 @@ Every response has a `type` discriminant. The full set is below (generated from
|
|
|
517
517
|
| `theme.eject` | A local source-fork receipt with the resolved slug, displayName, source theme maintained flag, source-selector package, outputDir, source entry, exportName, and every file written, including the descriptor. The written local descriptor always uses maintained: false. |
|
|
518
518
|
| `theme.template` | A write receipt for the annotated theme template: the path (relative to cwd), whether it was written, and the reason it was not. `exists` when a file was already there, which is a success. |
|
|
519
519
|
| `theme.targets` | The whole themeable surface: the echoed filter, componentCount, and targets, one per theming target — {key, className, component, props, states}, where props and states are its legal override keys. |
|
|
520
|
-
| `theme.palette.generate` | An author-reviewable OKLCH palette candidate,
|
|
520
|
+
| `theme.palette.generate` | An author-reviewable OKLCH palette response: recipe (`astryx-oklch-v1`), status (`candidate`), familyCount, stopCount, modes, candidate (`TonalPaletteCandidate`), and generationReceipt. The generationReceipt contains schemaVersion (1), recipe, generatorVersion (`palette-generator-v1`), candidateFormatVersion (`palette-typescript-v1` or `palette-json-v1`), candidateSha256, optional preview, resolved request, and diagnostics. File-write fields are output, receipt, preview, written, and reason (`exists` or null). |
|
|
521
521
|
| `upgrade.list` | Every available codemod, oldest→newest, as {name, package, title, version, optional}; returned for --list without running anything. |
|
|
522
522
|
| `upgrade.registry` | The copied-composition receipt for --registry: applied, ok, the counts (found, current, wouldUpdate, updated, wouldMerge, merged, wouldRefreshReceipt, receiptsRefreshed, conflicts, missing, invalid, failed), and items. |
|
|
523
523
|
| `upgrade.status` | A short-circuit outcome with no codemods run (up_to_date, no_codemods, or config_fixable), each carrying the agent-docs summary. no_codemods and config_fixable carry cliBehindCore ({cliVersion, command}) when the installed Core is newer than the CLI, which then has no codemods for the releases after its own version. |
|
|
@@ -18,36 +18,16 @@ export function weightWords(idea: string): string[];
|
|
|
18
18
|
* @param {string} idea
|
|
19
19
|
* @param {import('./rank.mjs').RankedPage[]} ranked the ranker's output for the idea
|
|
20
20
|
* @param {import('./rank.mjs').RankedPage | null} pick the ranker's own start
|
|
21
|
-
* @param {
|
|
21
|
+
* @param {DescribedTemplate[]} catalog the project's ready page templates
|
|
22
22
|
* @param {{weights?: WeightsFile | null, newPage?: boolean}} [options]
|
|
23
23
|
* `newPage`: the idea asks for a new page (rank.mjs `asksForNewPage`)
|
|
24
24
|
* @returns {string | null | undefined} a template id, null for the app shell,
|
|
25
25
|
* undefined without weights
|
|
26
26
|
*/
|
|
27
|
-
export function weighStart(idea: string, ranked: import("./rank.mjs").RankedPage[], pick: import("./rank.mjs").RankedPage | null, catalog: {
|
|
28
|
-
name: string;
|
|
29
|
-
}[], { weights, newPage }?: {
|
|
27
|
+
export function weighStart(idea: string, ranked: import("./rank.mjs").RankedPage[], pick: import("./rank.mjs").RankedPage | null, catalog: DescribedTemplate[], { weights, newPage }?: {
|
|
30
28
|
weights?: WeightsFile | null;
|
|
31
29
|
newPage?: boolean;
|
|
32
30
|
}): string | null | undefined;
|
|
33
|
-
/**
|
|
34
|
-
* @file Word weights for `build`'s START (spec:AST-048): a checked-in table of
|
|
35
|
-
* per-template word weights, blended with the page ranker's own scores, picks
|
|
36
|
-
* the template an idea starts from.
|
|
37
|
-
*
|
|
38
|
-
* @input An idea, the ranker's output for it (`rankPages`, `pickStart`), the
|
|
39
|
-
* project's ready page templates, and the weights (`weights.json` beside this
|
|
40
|
-
* file, read by the adapter): the candidates (the app shell as `SHELL`, then page template ids), one or more
|
|
41
|
-
* word tables (stemmed words, a bias per candidate, and one row of weights
|
|
42
|
-
* per word, a character per candidate) and the blend numbers.
|
|
43
|
-
* @output `weighStart(idea, ranked, pick, catalog)`: the template id to start
|
|
44
|
-
* from, null for the app shell, or undefined when no table is available, in
|
|
45
|
-
* which case the ranker's own pick stands.
|
|
46
|
-
* @position Beside rank.mjs (api/build/kit/); kit.mjs calls it for every
|
|
47
|
-
* whole page (a part or an edit follows the ranker's placement rules). The
|
|
48
|
-
* ranker's pick of a template the tables do not list stands, so a new
|
|
49
|
-
* template can start a build.
|
|
50
|
-
*/
|
|
51
31
|
/** The app shell, as one candidate. */
|
|
52
32
|
export const SHELL: "SHELL";
|
|
53
33
|
export type WeightTable = {
|
|
@@ -80,3 +60,9 @@ export type WeightsFile = {
|
|
|
80
60
|
*/
|
|
81
61
|
blend: number[];
|
|
82
62
|
};
|
|
63
|
+
export type DescribedTemplate = {
|
|
64
|
+
name: string;
|
|
65
|
+
displayName?: string | undefined;
|
|
66
|
+
category?: string | undefined;
|
|
67
|
+
keywords?: string[] | undefined;
|
|
68
|
+
};
|
|
@@ -14,11 +14,13 @@
|
|
|
14
14
|
* from, null for the app shell, or undefined when no table is available, in
|
|
15
15
|
* which case the ranker's own pick stands.
|
|
16
16
|
* @position Beside rank.mjs (api/build/kit/); kit.mjs calls it for every
|
|
17
|
-
* whole page (a part or an edit follows the ranker's placement rules).
|
|
18
|
-
*
|
|
19
|
-
* template can start a build.
|
|
17
|
+
* whole page (a part or an edit follows the ranker's placement rules). A
|
|
18
|
+
* template the tables do not list competes on its own descriptor's words
|
|
19
|
+
* (`ownWords`), so a new template can start a build.
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
+
import {STOPWORDS} from '../../search/search.mjs';
|
|
23
|
+
|
|
22
24
|
/** The app shell, as one candidate. */
|
|
23
25
|
export const SHELL = 'SHELL';
|
|
24
26
|
const SHELL_FAMILY = 'Shell';
|
|
@@ -225,12 +227,65 @@ function memberFeatures(v) {
|
|
|
225
227
|
]);
|
|
226
228
|
}
|
|
227
229
|
|
|
230
|
+
/**
|
|
231
|
+
* @typedef {object} DescribedTemplate
|
|
232
|
+
* @property {string} name
|
|
233
|
+
* @property {string} [displayName]
|
|
234
|
+
* @property {string} [category]
|
|
235
|
+
* @property {string[]} [keywords]
|
|
236
|
+
*/
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* How many of the idea's stemmed words a template's own descriptor names: its
|
|
240
|
+
* display name, its category, and its keywords, less search's stopwords.
|
|
241
|
+
* @param {string} name
|
|
242
|
+
* @param {DescribedTemplate[]} catalog
|
|
243
|
+
* @param {Set<string>} words the idea's stemmed words, less search's stopwords
|
|
244
|
+
*/
|
|
245
|
+
function ownWords(name, catalog, words) {
|
|
246
|
+
const t = catalog.find(c => c.name === name);
|
|
247
|
+
if (!t) return 0;
|
|
248
|
+
// Search's stopwords are no evidence: "to" in a "to-do list" keyword must
|
|
249
|
+
// not answer the "to" of "rows to track orders".
|
|
250
|
+
const own = new Set(
|
|
251
|
+
weightWords(
|
|
252
|
+
[t.displayName ?? '', t.category ?? '', ...(t.keywords ?? [])].join(' '),
|
|
253
|
+
)
|
|
254
|
+
.filter(w => !STOPWORDS.has(w))
|
|
255
|
+
.map(stem),
|
|
256
|
+
);
|
|
257
|
+
let n = 0;
|
|
258
|
+
for (const w of words) if (own.has(w)) n++;
|
|
259
|
+
return n;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/** How many fewer own words a template whose family the idea names first may
|
|
263
|
+
* name than the listed template it competes with, and still start. */
|
|
264
|
+
const FAMILY_SLACK = 2;
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Where the idea first names a template's family, the part of its category
|
|
268
|
+
* before ` - ` ("Dashboard" in "Dashboard - Analytics"): the index of that
|
|
269
|
+
* word among the idea's stemmed words, or Infinity when it does not.
|
|
270
|
+
* @param {string} name
|
|
271
|
+
* @param {DescribedTemplate[]} catalog
|
|
272
|
+
* @param {string[]} order the idea's stemmed words, in order
|
|
273
|
+
*/
|
|
274
|
+
function familyAt(name, catalog, order) {
|
|
275
|
+
const t = catalog.find(c => c.name === name);
|
|
276
|
+
const family = weightWords(String(t?.category ?? '').split(' - ')[0]).map(
|
|
277
|
+
stem,
|
|
278
|
+
);
|
|
279
|
+
const at = family.length ? order.findIndex(w => family.includes(w)) : -1;
|
|
280
|
+
return at < 0 ? Infinity : at;
|
|
281
|
+
}
|
|
282
|
+
|
|
228
283
|
/**
|
|
229
284
|
* Where an idea starts, by the blended weights.
|
|
230
285
|
* @param {string} idea
|
|
231
286
|
* @param {import('./rank.mjs').RankedPage[]} ranked the ranker's output for the idea
|
|
232
287
|
* @param {import('./rank.mjs').RankedPage | null} pick the ranker's own start
|
|
233
|
-
* @param {
|
|
288
|
+
* @param {DescribedTemplate[]} catalog the project's ready page templates
|
|
234
289
|
* @param {{weights?: WeightsFile | null, newPage?: boolean}} [options]
|
|
235
290
|
* `newPage`: the idea asks for a new page (rank.mjs `asksForNewPage`)
|
|
236
291
|
* @returns {string | null | undefined} a template id, null for the app shell,
|
|
@@ -292,10 +347,34 @@ export function weighStart(
|
|
|
292
347
|
pick && pick.family !== SHELL_FAMILY && cands.includes(pick.name)
|
|
293
348
|
? pick.name
|
|
294
349
|
: null;
|
|
295
|
-
//
|
|
296
|
-
|
|
297
|
-
//
|
|
298
|
-
|
|
350
|
+
// A template the ranker placed by its frame stays (spec:AST-048/FR3).
|
|
351
|
+
if (kept && pick?.containerMatched) return kept;
|
|
352
|
+
// The tables cannot judge a template they do not list (an integration's
|
|
353
|
+
// template, or one added since they were fit), so its own descriptor
|
|
354
|
+
// decides: the ranker's pick stands when the idea names as many words of its
|
|
355
|
+
// display name, category and keywords as of the tables' first listed
|
|
356
|
+
// template's, or names its family first and nearly as many; otherwise that
|
|
357
|
+
// listed template starts. Nothing learned about the template is involved,
|
|
358
|
+
// so a new template competes on its own words.
|
|
359
|
+
if (kept && !position.has(kept)) {
|
|
360
|
+
const listed = best(c => c !== SHELL && position.has(c));
|
|
361
|
+
if (!listed) return kept;
|
|
362
|
+
// The idea's own words, less search's stopwords: "basically" must not
|
|
363
|
+
// answer the "Basic" of a category.
|
|
364
|
+
const content = weightWords(idea).filter(w => !STOPWORDS.has(w));
|
|
365
|
+
const said = new Set(content.map(stem));
|
|
366
|
+
const mine = ownWords(kept, catalog, said);
|
|
367
|
+
const theirs = ownWords(listed, catalog, said);
|
|
368
|
+
if (mine >= theirs) return kept;
|
|
369
|
+
// An idea that names the template's family before the listed one's
|
|
370
|
+
// ("a dashboard with a data table") is that family's page, unless it
|
|
371
|
+
// names far more of the listed template's words.
|
|
372
|
+
const order = content.map(stem);
|
|
373
|
+
return familyAt(kept, catalog, order) < familyAt(listed, catalog, order) &&
|
|
374
|
+
mine >= theirs - FAMILY_SLACK
|
|
375
|
+
? kept
|
|
376
|
+
: listed;
|
|
377
|
+
}
|
|
299
378
|
const top = best(() => true);
|
|
300
379
|
if (top !== SHELL) return top;
|
|
301
380
|
// An idea that asks for a new page keeps the ranker's template rather than
|
|
@@ -125,6 +125,102 @@ describe('weighStart', () => {
|
|
|
125
125
|
expect(start).toBe('fresh');
|
|
126
126
|
});
|
|
127
127
|
|
|
128
|
+
describe('a template the tables do not list (cold start)', () => {
|
|
129
|
+
// A made-up family the tables have never seen, described only by its own
|
|
130
|
+
// descriptor, next to listed templates with descriptors of their own.
|
|
131
|
+
const catalog = [
|
|
132
|
+
{name: 'board', displayName: 'Kanban Board', keywords: ['kanban']},
|
|
133
|
+
{name: 'charts', displayName: 'Charts', category: 'Charts - Overview'},
|
|
134
|
+
{name: 'grid', displayName: 'Grid'},
|
|
135
|
+
{
|
|
136
|
+
name: 'gauge-fleet',
|
|
137
|
+
displayName: 'Fleet Gauges',
|
|
138
|
+
category: 'Gauges - Fleet',
|
|
139
|
+
keywords: ['gauges', 'fleet', 'meters'],
|
|
140
|
+
},
|
|
141
|
+
];
|
|
142
|
+
|
|
143
|
+
it('starts from it when the idea names its own words', () => {
|
|
144
|
+
const ranked = [page('gauge-fleet', 9, 'Gauges'), ...RANKED];
|
|
145
|
+
const start = weighStart(
|
|
146
|
+
'fleet gauges with meters per kanban lane',
|
|
147
|
+
ranked,
|
|
148
|
+
ranked[0],
|
|
149
|
+
catalog,
|
|
150
|
+
{weights: WEIGHTS},
|
|
151
|
+
);
|
|
152
|
+
expect(start).toBe('gauge-fleet');
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('starts from it when the idea names its family first', () => {
|
|
156
|
+
const ranked = [page('gauge-fleet', 9, 'Gauges'), ...RANKED];
|
|
157
|
+
const start = weighStart(
|
|
158
|
+
'gauges page with a kanban board',
|
|
159
|
+
ranked,
|
|
160
|
+
ranked[0],
|
|
161
|
+
catalog,
|
|
162
|
+
{weights: WEIGHTS},
|
|
163
|
+
);
|
|
164
|
+
expect(start).toBe('gauge-fleet');
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it("never counts a stopword from another template's keywords", () => {
|
|
168
|
+
// "side" in grid's "side by side" keyword is one of search's stopwords;
|
|
169
|
+
// it must not answer the idea's "sides", which is not.
|
|
170
|
+
const own = [
|
|
171
|
+
{name: 'board'},
|
|
172
|
+
{name: 'charts'},
|
|
173
|
+
{
|
|
174
|
+
name: 'grid',
|
|
175
|
+
displayName: 'Grid',
|
|
176
|
+
keywords: ['side by side', 'orders'],
|
|
177
|
+
},
|
|
178
|
+
{name: 'fold', displayName: 'Folding Rows'},
|
|
179
|
+
];
|
|
180
|
+
const ranked = [page('fold', 9, 'Fold'), ...RANKED];
|
|
181
|
+
const start = weighStart(
|
|
182
|
+
'rows on two sides with orders on cards',
|
|
183
|
+
ranked,
|
|
184
|
+
ranked[0],
|
|
185
|
+
own,
|
|
186
|
+
{weights: WEIGHTS},
|
|
187
|
+
);
|
|
188
|
+
expect(start).toBe('fold');
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it("never counts a stopword from the idea's words", () => {
|
|
192
|
+
// "basically" is one of search's stopwords and stems to "basic", the
|
|
193
|
+
// word of grid's category; it must not tip the count to grid.
|
|
194
|
+
const own = [
|
|
195
|
+
{name: 'board'},
|
|
196
|
+
{name: 'charts'},
|
|
197
|
+
{name: 'grid', displayName: 'Grid', category: 'Grid - Basic'},
|
|
198
|
+
{name: 'fold', displayName: 'Folding Rows'},
|
|
199
|
+
];
|
|
200
|
+
const ranked = [page('fold', 9, 'Fold'), ...RANKED];
|
|
201
|
+
const start = weighStart(
|
|
202
|
+
'basically a grid of rows on cards',
|
|
203
|
+
ranked,
|
|
204
|
+
ranked[0],
|
|
205
|
+
own,
|
|
206
|
+
{weights: WEIGHTS},
|
|
207
|
+
);
|
|
208
|
+
expect(start).toBe('fold');
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
it('yields to the listed template whose own words the idea names more', () => {
|
|
212
|
+
const ranked = [page('gauge-fleet', 9, 'Gauges'), ...RANKED];
|
|
213
|
+
const start = weighStart(
|
|
214
|
+
'a kanban board with a fleet column',
|
|
215
|
+
ranked,
|
|
216
|
+
ranked[0],
|
|
217
|
+
catalog,
|
|
218
|
+
{weights: WEIGHTS},
|
|
219
|
+
);
|
|
220
|
+
expect(start).toBe('board');
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
|
|
128
224
|
it("keeps the ranker's template for an idea that asks for a new page", () => {
|
|
129
225
|
const start = weighStart('the existing page', RANKED, RANKED[0], CATALOG, {
|
|
130
226
|
weights: WEIGHTS,
|