@astryx-vue/cli 0.1.0 → 0.3.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 +114 -18
- package/README.zh-CN.md +137 -41
- package/dist/index.d.ts +3 -2
- package/dist/index.js +65024 -22922
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,33 +12,50 @@ Guide: <https://astryx-vue.pages.dev/en/guide/cli>
|
|
|
12
12
|
pnpm add -D @astryx-vue/cli
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
##
|
|
15
|
+
## Running it
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
The package declares a `bin`, so installing it puts the command on `node_modules/.bin`. Use it directly:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
npx astryx-vue component Button
|
|
21
|
+
pnpm exec astryx-vue search dialog --json
|
|
22
|
+
npx astryx-vue manifest --json
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Without installing it, run `npx @astryx-vue/cli …` for a one-off. The scope is required: the bare `astryx-vue` name on npm is not this package, so `npx astryx-vue` fails on a machine where nothing is installed, and that name could later belong to someone else.
|
|
26
|
+
|
|
27
|
+
A script alias is optional. It is useful only when an agent shell does not have `node_modules/.bin` on `PATH`:
|
|
18
28
|
|
|
19
29
|
```json
|
|
20
30
|
{
|
|
21
31
|
"scripts": {
|
|
22
|
-
"astryx-vue": "
|
|
32
|
+
"astryx-vue": "astryx-vue"
|
|
23
33
|
}
|
|
24
34
|
}
|
|
25
35
|
```
|
|
26
36
|
|
|
27
37
|
```sh
|
|
28
38
|
npm run astryx-vue -- component Button
|
|
29
|
-
npm run astryx-vue -- search dialog --json
|
|
30
|
-
npm run astryx-vue -- manifest --json
|
|
31
39
|
```
|
|
32
40
|
|
|
33
41
|
## Commands
|
|
34
42
|
|
|
35
43
|
| Command | What it prints |
|
|
36
44
|
| --- | --- |
|
|
45
|
+
| `astryx-vue build "<idea>"` | The closest page template, two alternatives, and the components to use |
|
|
46
|
+
| `astryx-vue template --list` | Every page template, grouped by category, with the ones a project cannot copy marked |
|
|
47
|
+
| `astryx-vue template <slug>` | One template's description, components, and source |
|
|
48
|
+
| `astryx-vue template <slug> --skeleton` | Only the layout skeleton: component tags and layout attributes |
|
|
49
|
+
| `astryx-vue template <slug> <path>` | Writes the template to a file, or to `<path>/<Name>.vue` for a directory |
|
|
37
50
|
| `astryx-vue component --list` | Every documented component |
|
|
38
|
-
| `astryx-vue component <Name>` | Usage, props, slots, events, and notes for one component |
|
|
39
|
-
| `astryx-vue
|
|
40
|
-
| `astryx-vue
|
|
41
|
-
| `astryx-vue
|
|
51
|
+
| `astryx-vue component <Name>` | Usage, props, slots, events, examples, and notes for one component |
|
|
52
|
+
| `astryx-vue composable --list` | Every documented composable, the `use*` functions |
|
|
53
|
+
| `astryx-vue composable <Name>` | Parameters, return values, usage, and examples for one composable |
|
|
54
|
+
| `astryx-vue docs` | Every guide and theme topic |
|
|
55
|
+
| `astryx-vue docs <topic>` | One topic's page text, such as `docs guide/dark-mode` or `docs themes/tokens` |
|
|
56
|
+
| `astryx-vue search <query>` | Ranked components, composables, docs topics, and templates |
|
|
57
|
+
| `astryx-vue manifest --json` | Commands, options, response types, error codes, and exit codes |
|
|
58
|
+
| `astryx-vue init --features agents` | Creates or refreshes the managed block in an agent file |
|
|
42
59
|
|
|
43
60
|
Global flags:
|
|
44
61
|
|
|
@@ -47,12 +64,71 @@ Global flags:
|
|
|
47
64
|
| `--json` | Typed envelope `{ apiVersion, type, data }` on stdout. Errors use `{ apiVersion, error, code, suggestions? }` and a non-zero exit code. |
|
|
48
65
|
| `--dense` | Shorter text. Ignored with `--json`, which stays the full envelope. |
|
|
49
66
|
| `--zh` | Simplified Chinese where the docs have a translation. |
|
|
50
|
-
| `--cwd <dir>` |
|
|
67
|
+
| `--cwd <dir>` | Project directory. Defaults to the working directory; `template` and `init` write inside it. |
|
|
68
|
+
|
|
69
|
+
A composable takes `useClipboard` or `use-clipboard`. `component useClipboard` still prints it, and adds a line that points at the `composable` command. `component --list` lists components only. `search --type` accepts `component`, `composable`, `doc`, or `template`; composable hits carry `domain: "composable"` and a `command` that points at `composable <Name>`. A query that hits a name outranks one that only hits page text.
|
|
70
|
+
|
|
71
|
+
`docs` takes a topic id, the same id with `themes/` instead of `theme/`, or a bare name that matches one topic, such as `dark-mode`. `--json` returns `docs.list` or `docs.detail`, and `docs.detail` includes the page `body`.
|
|
72
|
+
|
|
73
|
+
## Templates
|
|
74
|
+
|
|
75
|
+
`template --list` prints all 53 playground pages. `--type page` is the only kind today; `--type block` answers with a note instead of an error.
|
|
76
|
+
|
|
77
|
+
Every template carries a hand-written one-sentence description and a keyword list in English and Chinese, in `src/generate/template-meta.ts`. The component list is extracted from the page's `@astryx-vue/core` imports, so it cannot drift from the source.
|
|
78
|
+
|
|
79
|
+
Some pages import a package a project cannot install: five use `@astryx-vue/playground-charts`, a path alias that only exists inside the docs playground. Those are marked `isReady: false` with the reason. A page is ready when every non-relative import it really performs is `vue` or `@astryx-vue/core`; text inside a code sample the page displays, such as `@astryxdesign/core`, is page content and does not count. `--list` and `template <slug>` still show them; copying is refused with `ERR_TEMPLATE_NOT_READY`.
|
|
80
|
+
|
|
81
|
+
`template <slug> <path>` writes one file:
|
|
82
|
+
|
|
83
|
+
- a path that ends in a file name, or that already names a file, is the target file;
|
|
84
|
+
- anything else is a directory and receives `<PascalCaseSlug>.vue`;
|
|
85
|
+
- an existing file is only replaced with `--overwrite` (or `-f`), otherwise `ERR_FILE_EXISTS`;
|
|
86
|
+
- a path outside the project directory is refused with `ERR_PATH_TRAVERSAL`.
|
|
87
|
+
|
|
88
|
+
Copying rewrites the playground's `/template-assets/…` photo paths to an inline grey placeholder and reports how many it replaced, so the file renders without the docs site. It does not copy any asset and does not install anything: it names the packages the project's `package.json` does not list, plus an install command with the lockfile's package manager.
|
|
51
89
|
|
|
52
|
-
`
|
|
90
|
+
`--skeleton` prints the component tags with layout attributes only: `gap`, `padding`, `width`, `maxWidth`, `height`, `columns`, `axis`, `justify`, `align`, `density`, `variant`, `hasDivider`, and the `rowGap`/`columnGap`/`contentPadding`/`minHeight` variants. Text, bindings other than layout, event handlers, and native HTML wrappers are dropped, so a page positioned with plain `<div>` reads flatter than it renders. The skeleton is a structure reference, not a compilable file.
|
|
91
|
+
|
|
92
|
+
## Build
|
|
93
|
+
|
|
94
|
+
`build "<idea>"` ranks the templates locally: field-weighted keyword matching over slug, title, description, keywords, and the components a page uses, with rare words counting more than common ones. No network, no model, same answer every run. Chinese is matched by character pairs, so no spaces are needed.
|
|
95
|
+
|
|
96
|
+
- `TEMPLATE` is the closest page. `OTHER TEMPLATES` is the next two. A page that cannot be copied keeps its place only when it answers the idea clearly better, and it is marked with the reason.
|
|
97
|
+
- `COMPONENTS` (up to 6) and `COMPOSABLES` (up to 4) come from the same ranking `search` uses, so the two commands cannot disagree. When the idea names fewer pieces than the limit, the recommended page's own components fill the rest, marked as such.
|
|
98
|
+
- A weak match is dropped rather than padded. An idea nothing matches returns no template and says so.
|
|
99
|
+
- `build` with no idea prints the workflow: find a template, copy it, then look up each component before writing code.
|
|
100
|
+
|
|
101
|
+
## JSON envelopes
|
|
102
|
+
|
|
103
|
+
Success responses are `{ apiVersion: 1, type, data }`. Template and build responses also carry `package: "@astryx-vue/cli"`.
|
|
104
|
+
|
|
105
|
+
| Type | Command |
|
|
106
|
+
| --- | --- |
|
|
107
|
+
| `template.list`, `template.show`, `template.skeleton`, `template.copy` | `template` |
|
|
108
|
+
| `build.help`, `build.kit` | `build` |
|
|
109
|
+
| `component.list`, `component.detail` | `component` |
|
|
110
|
+
| `composable.list`, `composable.detail` | `composable` |
|
|
111
|
+
| `docs.list`, `docs.detail` | `docs` |
|
|
112
|
+
| `search` | `search` |
|
|
113
|
+
| `manifest` | `manifest` |
|
|
114
|
+
| `init.run` | `init` |
|
|
115
|
+
| `help`, `version` | `--help`, `--version`, or no arguments with `--json` |
|
|
53
116
|
|
|
54
117
|
Exit codes are `0` for success, `1` when the command ran but failed, and `2` for invalid usage. Branch on `code` in the JSON envelope, not on the message text.
|
|
55
118
|
|
|
119
|
+
| Code | When |
|
|
120
|
+
| --- | --- |
|
|
121
|
+
| `ERR_UNKNOWN_TEMPLATE` | No template matches the slug. Up to five close slugs come back as suggestions. |
|
|
122
|
+
| `ERR_TEMPLATE_NOT_READY` | The template imports a package the project cannot install. |
|
|
123
|
+
| `ERR_FILE_EXISTS` | The target file exists and `--overwrite` was not passed. |
|
|
124
|
+
| `ERR_PATH_TRAVERSAL` | A target path resolves outside the project directory. |
|
|
125
|
+
| `ERR_INVALID_ARGUMENT` | Two modes were combined, a value is outside its choices, or the idea is blank. |
|
|
126
|
+
| `ERR_UNKNOWN_COMPONENT`, `ERR_UNKNOWN_COMPOSABLE`, `ERR_UNKNOWN_TOPIC` | No record matches the name. |
|
|
127
|
+
| `ERR_UNKNOWN_AGENT` | `--agent` is not `cursor`, `claude`, `codex`, `hermes`, or `all`. |
|
|
128
|
+
| `ERR_UNKNOWN_FEATURE` | `--features` names something other than `agents`. |
|
|
129
|
+
|
|
130
|
+
`manifest --json` carries the same list per command, so an agent can read the codes without this table.
|
|
131
|
+
|
|
56
132
|
## Agent block
|
|
57
133
|
|
|
58
134
|
`init --features agents` writes this managed block:
|
|
@@ -65,27 +141,42 @@ Exit codes are `0` for success, `1` when the command ran but failed, and `2` for
|
|
|
65
141
|
|
|
66
142
|
If the file is missing, the command creates it. If the markers are already there, every run replaces only the block with freshly generated text. Other text stays. If the file exists without the markers, the block is appended. A second run still rewrites the block; it does not skip because the markers are already present. When the generated text matches, the bytes stay the same.
|
|
67
143
|
|
|
68
|
-
The block
|
|
144
|
+
The block teaches the three-step workflow (`build` to pick a page, `template` to copy it, `component`/`composable`/`docs` before writing code), lists the lookup commands, and says how to run the binary. It does not paste the component catalog.
|
|
145
|
+
|
|
146
|
+
Where it writes:
|
|
147
|
+
|
|
148
|
+
- no `--agent`: the first agent file the project already has, in the order `AGENTS.md`, `CLAUDE.md`, `.cursorrules`, `.hermes.md`, `HERMES.md`; `AGENTS.md` when none exists;
|
|
149
|
+
- `--agent cursor` or `--agent codex`: `AGENTS.md`;
|
|
150
|
+
- `--agent claude`: `CLAUDE.md`;
|
|
151
|
+
- `--agent hermes`: `.hermes.md`, or `HERMES.md` when the project already has that file;
|
|
152
|
+
- `--agent all`: every known file that exists, or `AGENTS.md` when none does;
|
|
153
|
+
- `--agent-docs-path <file>`: exactly that file, relative to the project directory. Missing directories are created; a path outside the project is refused with `ERR_PATH_TRAVERSAL`.
|
|
69
154
|
|
|
70
155
|
## Where the text comes from
|
|
71
156
|
|
|
72
157
|
The CLI does not keep a second copy of the component docs. `packages/cli/scripts/generate-catalog.mjs` reads:
|
|
73
158
|
|
|
74
159
|
- `apps/docs/components/demos/*/meta.ts` for names, groups, and order
|
|
75
|
-
- `apps/docs/docs/{en,zh}/components/<slug>/` for usage, props, slots, and
|
|
160
|
+
- `apps/docs/docs/{en,zh}/components/<slug>/` for usage, props, slots, events, and example titles
|
|
161
|
+
- `apps/docs/components/demos/<slug>/*.vue` for the example source those pages point at
|
|
76
162
|
- `apps/docs/components/demo-infra/reference/*.json` for anatomy and accessibility
|
|
77
|
-
- `apps/docs/docs/{en,zh}/guide` and `themes` for search topics
|
|
163
|
+
- `apps/docs/docs/{en,zh}/guide` and `themes` for search topics and topic bodies
|
|
164
|
+
- `apps/docs/components/playground/pages/*.vue` for the template sources, and `templateManifest.ts` for their titles and categories
|
|
78
165
|
- `packages/core/package.json` exports when a page does not show an import
|
|
79
166
|
|
|
80
|
-
The
|
|
167
|
+
The template descriptions and keywords are hand-written in `packages/cli/src/generate/template-meta.ts`. They are source data, not a generated file.
|
|
168
|
+
|
|
169
|
+
Example titles and descriptions are kept once per language, but the example code is stored once for both: both pages point at the same `.vue` file. The generator stops with an error naming the component and the example number if the two pages ever show different code, so one language cannot silently borrow the other's snippet. `examplesFor()` in `packages/cli/src/catalog.ts` is the only place that picks a language back out.
|
|
170
|
+
|
|
171
|
+
The result is committed at `packages/cli/src/generated/catalog.json`. `pnpm --filter @astryx-vue/cli build` regenerates it and bundles it into `dist`, which is what the published tarball runs. After a docs or template change, regenerate it and commit the diff:
|
|
81
172
|
|
|
82
173
|
```sh
|
|
83
174
|
pnpm --filter @astryx-vue/cli generate
|
|
84
175
|
```
|
|
85
176
|
|
|
86
|
-
`pnpm check` runs `generate:check` and
|
|
177
|
+
`pnpm check` runs `generate:check`. That fails when `catalog.json` is stale, when a PascalCase `@astryx-vue/core` export is not imported by any documented component, and when a playground page has no metadata in `template-meta.ts`. `./icons`, `./locale`, CSS, and the package root are not component exports.
|
|
87
178
|
|
|
88
|
-
Theme,
|
|
179
|
+
Theme, upgrade, doctor, swizzle, and MCP commands are not part of this package.
|
|
89
180
|
|
|
90
181
|
## Related packages
|
|
91
182
|
|
|
@@ -99,7 +190,12 @@ Theme, template, upgrade, doctor, swizzle, and MCP commands are not part of this
|
|
|
99
190
|
```sh
|
|
100
191
|
pnpm --filter @astryx-vue/cli build
|
|
101
192
|
node packages/cli/bin/astryx-vue.mjs component Button
|
|
102
|
-
node packages/cli/bin/astryx-vue.mjs
|
|
193
|
+
node packages/cli/bin/astryx-vue.mjs composable useClipboard
|
|
194
|
+
node packages/cli/bin/astryx-vue.mjs docs guide/dark-mode --dense
|
|
195
|
+
node packages/cli/bin/astryx-vue.mjs template --list
|
|
196
|
+
node packages/cli/bin/astryx-vue.mjs template login-card --skeleton
|
|
197
|
+
node packages/cli/bin/astryx-vue.mjs build "login page with SSO"
|
|
198
|
+
node packages/cli/bin/astryx-vue.mjs search login --type template
|
|
103
199
|
node packages/cli/bin/astryx-vue.mjs manifest --json
|
|
104
200
|
```
|
|
105
201
|
|
package/README.zh-CN.md
CHANGED
|
@@ -2,60 +2,136 @@
|
|
|
2
2
|
|
|
3
3
|
# @astryx-vue/cli
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
面向 agent 的查询工具,服务 [astryx-vue](https://github.com/astryx-vue/astryx-vue)——Astryx 的非官方 Vue 3 实现。与 Meta 无关。
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
命令名是 `astryx-vue`。它不是 Meta 的 CLI,也不提供裸命令 `astryx`。
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
说明页:<https://astryx-vue.pages.dev/guide/cli>
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
12
|
pnpm add -D @astryx-vue/cli
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
##
|
|
15
|
+
## 怎么运行
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
包里声明了 `bin`,装完命令就在 `node_modules/.bin` 里,直接用:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
npx astryx-vue component Button
|
|
21
|
+
pnpm exec astryx-vue search dialog --json
|
|
22
|
+
npx astryx-vue manifest --json
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
不安装、只想临时用,运行 `npx @astryx-vue/cli …`。scope 不能省:npm 上裸名 `astryx-vue` 不是这个包,在没装过的机器上 `npx astryx-vue` 会失败,而且这个名字将来也可能被别人占用。
|
|
26
|
+
|
|
27
|
+
脚本别名是可选项。只有当 agent 的外壳没有把 `node_modules/.bin` 放进 `PATH` 时才有用:
|
|
18
28
|
|
|
19
29
|
```json
|
|
20
30
|
{
|
|
21
31
|
"scripts": {
|
|
22
|
-
"astryx-vue": "
|
|
32
|
+
"astryx-vue": "astryx-vue"
|
|
23
33
|
}
|
|
24
34
|
}
|
|
25
35
|
```
|
|
26
36
|
|
|
27
37
|
```sh
|
|
28
38
|
npm run astryx-vue -- component Button
|
|
29
|
-
npm run astryx-vue -- search dialog --json
|
|
30
|
-
npm run astryx-vue -- manifest --json
|
|
31
39
|
```
|
|
32
40
|
|
|
33
41
|
## 命令
|
|
34
42
|
|
|
35
43
|
| 命令 | 输出 |
|
|
36
44
|
| --- | --- |
|
|
37
|
-
| `astryx-vue
|
|
38
|
-
| `astryx-vue
|
|
39
|
-
| `astryx-vue
|
|
40
|
-
| `astryx-vue
|
|
41
|
-
| `astryx-vue
|
|
45
|
+
| `astryx-vue build "<想法>"` | 最接近的页面模板、两个备选,以及要用的组件 |
|
|
46
|
+
| `astryx-vue template --list` | 全部页面模板,按分类分组,标出项目装不上的那些 |
|
|
47
|
+
| `astryx-vue template <slug>` | 一个模板的说明、组件和源码 |
|
|
48
|
+
| `astryx-vue template <slug> --skeleton` | 只输出骨架:组件标签和布局属性 |
|
|
49
|
+
| `astryx-vue template <slug> <path>` | 把模板写到文件,或写到目录下的 `<Name>.vue` |
|
|
50
|
+
| `astryx-vue component --list` | 全部有文档的组件 |
|
|
51
|
+
| `astryx-vue component <Name>` | 一个组件的用法、props、插槽、事件、示例和备注 |
|
|
52
|
+
| `astryx-vue composable --list` | 全部有文档的组合式函数,即 `use*` 函数 |
|
|
53
|
+
| `astryx-vue composable <Name>` | 一个组合式函数的参数、返回值、用法和示例 |
|
|
54
|
+
| `astryx-vue docs` | 全部指南和主题 |
|
|
55
|
+
| `astryx-vue docs <topic>` | 一篇正文,例如 `docs guide/dark-mode` 或 `docs themes/tokens` |
|
|
56
|
+
| `astryx-vue search <query>` | 排好序的组件、组合式函数、文档主题和模板 |
|
|
57
|
+
| `astryx-vue manifest --json` | 命令、选项、响应类型、错误码和退出码 |
|
|
58
|
+
| `astryx-vue init --features agents` | 创建或刷新 agent 文件里的受管理区块 |
|
|
59
|
+
|
|
60
|
+
全局选项:
|
|
61
|
+
|
|
62
|
+
| 选项 | 作用 |
|
|
63
|
+
| --- | --- |
|
|
64
|
+
| `--json` | 在 stdout 输出类型化信封 `{ apiVersion, type, data }`。出错时是 `{ apiVersion, error, code, suggestions? }`,退出码非 0。 |
|
|
65
|
+
| `--dense` | 缩短给人看的文本。和 `--json` 一起时忽略,信封始终完整。 |
|
|
66
|
+
| `--zh` | 文档有中文版时用简体中文。 |
|
|
67
|
+
| `--cwd <dir>` | 项目目录,默认当前工作目录;`template` 和 `init` 只往这里面写。 |
|
|
42
68
|
|
|
43
|
-
|
|
69
|
+
组合式函数可写 `useClipboard` 或 `use-clipboard`。`component useClipboard` 也能查到,并多印一行指向 `composable` 命令。`component --list` 只列组件。`search --type` 接受 `component`、`composable`、`doc`、`template`;组合式函数命中的结果是 `domain: "composable"`,`command` 指向 `composable <Name>`。命中名字的结果排在只命中正文的结果前面。
|
|
44
70
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
71
|
+
`docs` 接受主题 id、把 `theme/` 换成 `themes/` 的写法,或能唯一匹配某个主题的裸名,例如 `dark-mode`。`--json` 返回 `docs.list` 或 `docs.detail`,`docs.detail` 里有整页 `body`。
|
|
72
|
+
|
|
73
|
+
## 模板
|
|
74
|
+
|
|
75
|
+
`template --list` 列出全部 53 个演练场页面。目前 `--type` 只有 `page` 一种;`--type block` 会给一句说明,不报错。
|
|
76
|
+
|
|
77
|
+
每个模板都有一句手写说明和中英两套关键词,放在 `src/generate/template-meta.ts`。组件清单从页面里 `@astryx-vue/core` 的 import 自动提取,不会和源码脱节。
|
|
78
|
+
|
|
79
|
+
有些页面引用了用户项目装不上的包:5 个用 `@astryx-vue/playground-charts`(只存在于文档站演练场的路径别名)。这些标为 `isReady: false` 并写明原因。判断标准是页面真正执行的导入:只要非相对导入都是 `vue` 或 `@astryx-vue/core` 就算可复制;页面里展示的示例代码文本(例如 `@astryxdesign/core`)属于页面内容,不算导入。`--list` 和 `template <slug>` 照样能看,复制会被拒绝,报 `ERR_TEMPLATE_NOT_READY`。
|
|
80
|
+
|
|
81
|
+
`template <slug> <path>` 只写一个文件:
|
|
82
|
+
|
|
83
|
+
- 以文件名结尾的路径,或本身就指向一个文件的路径,就写这个文件;
|
|
84
|
+
- 其余都当作目录,写入 `<PascalCaseSlug>.vue`;
|
|
85
|
+
- 已存在的文件要加 `--overwrite`(或 `-f`)才覆盖,否则报 `ERR_FILE_EXISTS`;
|
|
86
|
+
- 越出项目目录的路径报 `ERR_PATH_TRAVERSAL`。
|
|
51
87
|
|
|
52
|
-
|
|
88
|
+
复制时会把演练场的 `/template-assets/…` 图片地址换成一个内联的灰色占位图,并报告替换了多少处,这样文件不依赖文档站也能渲染。它不复制任何资源文件,也不安装任何东西:只列出项目 `package.json` 里没有的包,再按锁文件对应的包管理器给一条安装命令。
|
|
53
89
|
|
|
54
|
-
|
|
90
|
+
`--skeleton` 只输出组件标签和布局属性:`gap`、`padding`、`width`、`maxWidth`、`height`、`columns`、`axis`、`justify`、`align`、`density`、`variant`、`hasDivider`,以及 `rowGap`/`columnGap`/`contentPadding`/`minHeight`。文字、布局以外的绑定、事件处理函数和原生 HTML 包裹层都会丢掉,所以用 `<div>` 定位置的页面看起来会比实际更平。骨架是结构参考,不是能直接编译的文件。
|
|
55
91
|
|
|
56
|
-
##
|
|
92
|
+
## build
|
|
57
93
|
|
|
58
|
-
`
|
|
94
|
+
`build "<想法>"` 在本地给模板打分:对 slug、标题、说明、关键词和页面用到的组件做字段加权关键词匹配,越少见的词权重越高。没有网络,没有模型,同一句话每次结果一样。中文按字符二元组匹配,不需要空格分词。
|
|
95
|
+
|
|
96
|
+
- `TEMPLATE` 是最接近的页面,`OTHER TEMPLATES` 是接下来两个。不能复制的页面只有在明显更贴合时才排到前面,并标出原因。
|
|
97
|
+
- `COMPONENTS`(最多 6 个)和 `COMPOSABLES`(最多 4 个)用的是 `search` 那套排序,两个命令不会互相矛盾。想法里点到的部件不够时,用推荐页面自己用到的组件补齐,并标出来源。
|
|
98
|
+
- 命中太弱的直接丢掉,不凑数。完全没命中时不给模板,并说明这一点。
|
|
99
|
+
- 不带想法时 `build` 打印工作流:先找模板,再复制,最后写代码前逐个查组件。
|
|
100
|
+
|
|
101
|
+
## JSON 信封
|
|
102
|
+
|
|
103
|
+
成功响应是 `{ apiVersion: 1, type, data }`。`template` 和 `build` 的响应还带 `package: "@astryx-vue/cli"`。
|
|
104
|
+
|
|
105
|
+
| 类型 | 命令 |
|
|
106
|
+
| --- | --- |
|
|
107
|
+
| `template.list`、`template.show`、`template.skeleton`、`template.copy` | `template` |
|
|
108
|
+
| `build.help`、`build.kit` | `build` |
|
|
109
|
+
| `component.list`、`component.detail` | `component` |
|
|
110
|
+
| `composable.list`、`composable.detail` | `composable` |
|
|
111
|
+
| `docs.list`、`docs.detail` | `docs` |
|
|
112
|
+
| `search` | `search` |
|
|
113
|
+
| `manifest` | `manifest` |
|
|
114
|
+
| `init.run` | `init` |
|
|
115
|
+
| `help`、`version` | `--help`、`--version`,或带 `--json` 不带参数 |
|
|
116
|
+
|
|
117
|
+
退出码:成功 `0`,命令跑了但没成功 `1`,用法错误 `2`。分支判断请用信封里的 `code`,不要匹配消息文本。
|
|
118
|
+
|
|
119
|
+
| 错误码 | 什么时候出现 |
|
|
120
|
+
| --- | --- |
|
|
121
|
+
| `ERR_UNKNOWN_TEMPLATE` | 没有模板匹配这个 slug。会附带最多 5 个相近的 slug。 |
|
|
122
|
+
| `ERR_TEMPLATE_NOT_READY` | 模板引用了项目装不上的包。 |
|
|
123
|
+
| `ERR_FILE_EXISTS` | 目标文件已存在,且没加 `--overwrite`。 |
|
|
124
|
+
| `ERR_PATH_TRAVERSAL` | 目标路径越出了项目目录。 |
|
|
125
|
+
| `ERR_INVALID_ARGUMENT` | 两个模式混用、取值不在选项内,或想法是空白串。 |
|
|
126
|
+
| `ERR_UNKNOWN_COMPONENT`、`ERR_UNKNOWN_COMPOSABLE`、`ERR_UNKNOWN_TOPIC` | 没有记录匹配这个名字。 |
|
|
127
|
+
| `ERR_UNKNOWN_AGENT` | `--agent` 不是 `cursor`、`claude`、`codex`、`hermes` 或 `all`。 |
|
|
128
|
+
| `ERR_UNKNOWN_FEATURE` | `--features` 写了 `agents` 以外的东西。 |
|
|
129
|
+
|
|
130
|
+
`manifest --json` 按命令携带同一份错误码列表,agent 不用读这张表。
|
|
131
|
+
|
|
132
|
+
## agent 区块
|
|
133
|
+
|
|
134
|
+
`init --features agents` 写入这个受管理区块:
|
|
59
135
|
|
|
60
136
|
```html
|
|
61
137
|
<!-- Maintained by astryx-vue, do not edit manually -->
|
|
@@ -63,35 +139,50 @@ npm run astryx-vue -- manifest --json
|
|
|
63
139
|
<!-- astryx-vue block end -->
|
|
64
140
|
```
|
|
65
141
|
|
|
66
|
-
|
|
142
|
+
文件不存在就创建。已经有标记时,每次只替换区块内容,其余文字保持不动。文件存在但没有标记时,把区块追加到末尾。第二次运行仍然重写区块,不会因为标记已存在就跳过;生成内容一致时字节不变。
|
|
143
|
+
|
|
144
|
+
区块里写的是三步工作流(用 `build` 挑页面,用 `template` 复制,写代码前用 `component`/`composable`/`docs` 查),加上查询命令清单和怎么运行这个命令。它不会把组件目录贴进来。
|
|
145
|
+
|
|
146
|
+
写到哪里:
|
|
147
|
+
|
|
148
|
+
- 不加 `--agent`:项目里已经有的第一个 agent 文件,顺序是 `AGENTS.md`、`CLAUDE.md`、`.cursorrules`、`.hermes.md`、`HERMES.md`;都没有就写 `AGENTS.md`;
|
|
149
|
+
- `--agent cursor` 或 `--agent codex`:`AGENTS.md`;
|
|
150
|
+
- `--agent claude`:`CLAUDE.md`;
|
|
151
|
+
- `--agent hermes`:`.hermes.md`;项目里已有 `HERMES.md` 时写它;
|
|
152
|
+
- `--agent all`:已经存在的全部已知文件;一个都没有就写 `AGENTS.md`;
|
|
153
|
+
- `--agent-docs-path <file>`:就写这个文件,相对项目目录解析。缺的目录会自动创建,越出项目目录报 `ERR_PATH_TRAVERSAL`。
|
|
154
|
+
|
|
155
|
+
## 文本从哪来
|
|
67
156
|
|
|
68
|
-
|
|
157
|
+
CLI 不另存一份组件文档。`packages/cli/scripts/generate-catalog.mjs` 读:
|
|
69
158
|
|
|
70
|
-
|
|
159
|
+
- `apps/docs/components/demos/*/meta.ts`:名字、分组和顺序
|
|
160
|
+
- `apps/docs/docs/{en,zh}/components/<slug>/`:用法、props、插槽、事件和示例标题
|
|
161
|
+
- `apps/docs/components/demos/<slug>/*.vue`:那些页面指向的示例源码
|
|
162
|
+
- `apps/docs/components/demo-infra/reference/*.json`:anatomy 和无障碍信息
|
|
163
|
+
- `apps/docs/docs/{en,zh}/guide` 和 `themes`:搜索主题和正文
|
|
164
|
+
- `apps/docs/components/playground/pages/*.vue`:模板源码;`templateManifest.ts`:模板标题和分类
|
|
165
|
+
- 页面里没写 import 时,用 `packages/core/package.json` 的 exports 推断
|
|
71
166
|
|
|
72
|
-
|
|
167
|
+
模板的说明和关键词是手写的,在 `packages/cli/src/generate/template-meta.ts`,属于源数据,不是生成物。
|
|
73
168
|
|
|
74
|
-
|
|
75
|
-
- `apps/docs/docs/{en,zh}/components/<slug>/`:用法、props、插槽、事件
|
|
76
|
-
- `apps/docs/components/demo-infra/reference/*.json`:结构和无障碍要求
|
|
77
|
-
- `apps/docs/docs/{en,zh}/guide` 与 `themes`:搜索用的主题
|
|
78
|
-
- 页面里没有 import 时,再用 `packages/core/package.json` 的 exports
|
|
169
|
+
示例的标题和说明按语言各存一份,但示例代码两种语言只存一份:两个页面指向的是同一个 `.vue` 文件。以后要是一个页面改了代码、另一个没改,生成时直接报错并指出是哪个组件的第几个示例,不会让一种语言悄悄用上另一种的代码。取回某种语言的示例只走 `packages/cli/src/catalog.ts` 里的 `examplesFor()`。
|
|
79
170
|
|
|
80
|
-
|
|
171
|
+
结果提交在 `packages/cli/src/generated/catalog.json`。`pnpm --filter @astryx-vue/cli build` 会重新生成并打进 `dist`,也就是 npm 包实际运行的那份。文档或模板改过之后,重新生成并提交 diff:
|
|
81
172
|
|
|
82
173
|
```sh
|
|
83
174
|
pnpm --filter @astryx-vue/cli generate
|
|
84
175
|
```
|
|
85
176
|
|
|
86
|
-
`pnpm check` 会跑 `generate:check
|
|
177
|
+
`pnpm check` 会跑 `generate:check`。它会在这几种情况下失败:`catalog.json` 过期、某个 PascalCase 的 `@astryx-vue/core` 导出没有任何组件文档引用、或者某个演练场页面在 `template-meta.ts` 里没有元数据。`./icons`、`./locale`、CSS 和包根不算组件导出。
|
|
87
178
|
|
|
88
|
-
|
|
179
|
+
主题、升级、doctor、swizzle 和 MCP 命令不在这个包里。
|
|
89
180
|
|
|
90
|
-
##
|
|
181
|
+
## 相关包
|
|
91
182
|
|
|
92
183
|
| 包 | 是什么 |
|
|
93
184
|
| --- | --- |
|
|
94
|
-
| `@astryx-vue/core` |
|
|
185
|
+
| `@astryx-vue/core` | 这个 CLI 记录的那些 Vue 组件 |
|
|
95
186
|
| `@astryx-vue/themes` | Neutral、Butter、Chocolate、Gothic、Matcha、Stone、Y2K |
|
|
96
187
|
|
|
97
188
|
## 在本仓库里试
|
|
@@ -99,10 +190,15 @@ pnpm --filter @astryx-vue/cli generate
|
|
|
99
190
|
```sh
|
|
100
191
|
pnpm --filter @astryx-vue/cli build
|
|
101
192
|
node packages/cli/bin/astryx-vue.mjs component Button
|
|
102
|
-
node packages/cli/bin/astryx-vue.mjs
|
|
193
|
+
node packages/cli/bin/astryx-vue.mjs composable useClipboard
|
|
194
|
+
node packages/cli/bin/astryx-vue.mjs docs guide/dark-mode --dense
|
|
195
|
+
node packages/cli/bin/astryx-vue.mjs template --list
|
|
196
|
+
node packages/cli/bin/astryx-vue.mjs template login-card --skeleton
|
|
197
|
+
node packages/cli/bin/astryx-vue.mjs build "登录页"
|
|
198
|
+
node packages/cli/bin/astryx-vue.mjs search login --type template
|
|
103
199
|
node packages/cli/bin/astryx-vue.mjs manifest --json
|
|
104
200
|
```
|
|
105
201
|
|
|
106
|
-
##
|
|
202
|
+
## 许可
|
|
107
203
|
|
|
108
|
-
MIT。Astryx
|
|
204
|
+
MIT。Astryx 版权归 Meta Platforms, Inc.。这个包是非官方实现,与 Meta 无关,也未获其背书。
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
//#region src/agents.d.ts
|
|
2
2
|
export declare const MANAGED_BLOCK_START = "<!-- Maintained by astryx-vue, do not edit manually -->";
|
|
3
3
|
export declare const MANAGED_BLOCK_END = "<!-- astryx-vue block end -->";
|
|
4
|
-
|
|
4
|
+
/** Targets `init --agent` accepts. `all` and the absent target follow the project. */
|
|
5
|
+
type AgentName = 'agents' | 'cursor' | 'claude' | 'codex' | 'hermes' | 'all';
|
|
5
6
|
type BlockAction = 'created' | 'updated' | 'appended';
|
|
6
|
-
export declare function agentFile(agent: AgentName): string;
|
|
7
|
+
export declare function agentFile(agent: Exclude<AgentName, 'all'>): string;
|
|
7
8
|
export declare function applyManagedBlock(existing: string | null, inner: string): {
|
|
8
9
|
content: string;
|
|
9
10
|
action: BlockAction;
|