@astryx-vue/cli 0.0.0-stage → 0.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 astryx-vue contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,121 @@
1
- # Temporary Holding Version
1
+ English | [简体中文](./README.zh-CN.md)
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ # @astryx-vue/cli
4
+
5
+ Agent-friendly lookup for [astryx-vue](https://github.com/astryx-vue/astryx-vue), an unofficial Vue 3 port of Astryx. Not affiliated with Meta.
6
+
7
+ The binary is `astryx-vue`. This package is not Meta's CLI, and it does not provide the bare `astryx` command.
8
+
9
+ Guide: <https://astryx-vue.pages.dev/en/guide/cli>
10
+
11
+ ```sh
12
+ pnpm add -D @astryx-vue/cli
13
+ ```
14
+
15
+ ## Script alias
16
+
17
+ Agents should call a project script so the binary path stays stable:
18
+
19
+ ```json
20
+ {
21
+ "scripts": {
22
+ "astryx-vue": "node node_modules/@astryx-vue/cli/bin/astryx-vue.mjs"
23
+ }
24
+ }
25
+ ```
26
+
27
+ ```sh
28
+ npm run astryx-vue -- component Button
29
+ npm run astryx-vue -- composable useClipboard
30
+ npm run astryx-vue -- docs guide/dark-mode
31
+ npm run astryx-vue -- search dialog --json
32
+ npm run astryx-vue -- manifest --json
33
+ ```
34
+
35
+ ## Commands
36
+
37
+ | Command | What it prints |
38
+ | --- | --- |
39
+ | `astryx-vue component --list` | Every documented component |
40
+ | `astryx-vue component <Name>` | Usage, props, slots, events, examples, and notes for one component |
41
+ | `astryx-vue composable --list` | Every documented composable, the `use*` functions |
42
+ | `astryx-vue composable <Name>` | Parameters, return values, usage, and examples for one composable |
43
+ | `astryx-vue docs` | Every guide and theme topic |
44
+ | `astryx-vue docs <topic>` | One topic's page text, such as `docs guide/dark-mode` or `docs themes/tokens` |
45
+ | `astryx-vue search <query>` | Ranked components, composables, and docs topics |
46
+ | `astryx-vue manifest --json` | Commands, options, response types, and exit codes |
47
+ | `astryx-vue init --features agents` | Creates or refreshes the managed block in `AGENTS.md` |
48
+
49
+ Global flags:
50
+
51
+ | Flag | Effect |
52
+ | --- | --- |
53
+ | `--json` | Typed envelope `{ apiVersion, type, data }` on stdout. Errors use `{ apiVersion, error, code, suggestions? }` and a non-zero exit code. |
54
+ | `--dense` | Shorter text. Ignored with `--json`, which stays the full envelope. |
55
+ | `--zh` | Simplified Chinese where the docs have a translation. |
56
+ | `--cwd <dir>` | Directory `init` writes into. |
57
+
58
+ 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`, or `doc`; composable hits carry `domain: "composable"` and a `command` that points at `composable <Name>`.
59
+
60
+ `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`.
61
+
62
+ `init` accepts `--agent cursor|claude|codex`. `cursor` and `codex` write `AGENTS.md`. `claude` writes `CLAUDE.md`. The default file is `AGENTS.md`.
63
+
64
+ 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.
65
+
66
+ ## Agent block
67
+
68
+ `init --features agents` writes this managed block:
69
+
70
+ ```html
71
+ <!-- Maintained by astryx-vue, do not edit manually -->
72
+ ...
73
+ <!-- astryx-vue block end -->
74
+ ```
75
+
76
+ 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.
77
+
78
+ The block tells an agent how to query the CLI. It does not paste the component catalog.
79
+
80
+ ## Where the text comes from
81
+
82
+ The CLI does not keep a second copy of the component docs. `packages/cli/scripts/generate-catalog.mjs` reads:
83
+
84
+ - `apps/docs/components/demos/*/meta.ts` for names, groups, and order
85
+ - `apps/docs/docs/{en,zh}/components/<slug>/` for usage, props, slots, events, and example titles
86
+ - `apps/docs/components/demos/<slug>/*.vue` for the example source those pages point at
87
+ - `apps/docs/components/demo-infra/reference/*.json` for anatomy and accessibility
88
+ - `apps/docs/docs/{en,zh}/guide` and `themes` for search topics and topic bodies
89
+ - `packages/core/package.json` exports when a page does not show an import
90
+
91
+ 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 change, regenerate it and commit the diff:
92
+
93
+ ```sh
94
+ pnpm --filter @astryx-vue/cli generate
95
+ ```
96
+
97
+ `pnpm check` runs `generate:check`. That fails when `catalog.json` is stale, and when a PascalCase `@astryx-vue/core` export is not imported by any documented component. `./icons`, `./locale`, CSS, and the package root are not component exports.
98
+
99
+ Theme, template, upgrade, doctor, swizzle, and MCP commands are not part of this package.
100
+
101
+ ## Related packages
102
+
103
+ | Package | What it is |
104
+ | --- | --- |
105
+ | `@astryx-vue/core` | The Vue components this CLI documents |
106
+ | `@astryx-vue/themes` | Neutral, Butter, Chocolate, Gothic, Matcha, Stone, and Y2K |
107
+
108
+ ## Try it in this repo
109
+
110
+ ```sh
111
+ pnpm --filter @astryx-vue/cli build
112
+ node packages/cli/bin/astryx-vue.mjs component Button
113
+ node packages/cli/bin/astryx-vue.mjs composable useClipboard
114
+ node packages/cli/bin/astryx-vue.mjs docs guide/dark-mode --dense
115
+ node packages/cli/bin/astryx-vue.mjs search installation --type doc
116
+ node packages/cli/bin/astryx-vue.mjs manifest --json
117
+ ```
118
+
119
+ ## License
120
+
121
+ MIT. Astryx is copyright Meta Platforms, Inc. This package is an unofficial port and is not affiliated with or endorsed by Meta.
@@ -0,0 +1,121 @@
1
+ [English](./README.md) | 简体中文
2
+
3
+ # @astryx-vue/cli
4
+
5
+ 给 [astryx-vue](https://github.com/astryx-vue/astryx-vue) 用的命令行。人和 agent 都可以用它查组件文档。这是 Astryx 的非官方 Vue 3 移植,与 Meta 没有隶属关系。
6
+
7
+ 可执行文件名是 `astryx-vue`。这不是 Meta 的 CLI,也不提供裸命令 `astryx`。
8
+
9
+ 说明:<https://astryx-vue.pages.dev/guide/cli>
10
+
11
+ ```sh
12
+ pnpm add -D @astryx-vue/cli
13
+ ```
14
+
15
+ ## 脚本别名
16
+
17
+ 建议在项目里加一个脚本,agent 就不用自己猜二进制路径:
18
+
19
+ ```json
20
+ {
21
+ "scripts": {
22
+ "astryx-vue": "node node_modules/@astryx-vue/cli/bin/astryx-vue.mjs"
23
+ }
24
+ }
25
+ ```
26
+
27
+ ```sh
28
+ npm run astryx-vue -- component Button
29
+ npm run astryx-vue -- composable useClipboard
30
+ npm run astryx-vue -- docs guide/dark-mode
31
+ npm run astryx-vue -- search dialog --json
32
+ npm run astryx-vue -- manifest --json
33
+ ```
34
+
35
+ ## 命令
36
+
37
+ | 命令 | 输出 |
38
+ | --- | --- |
39
+ | `astryx-vue component --list` | 列出文档里的全部组件 |
40
+ | `astryx-vue component <Name>` | 打印一个组件的用法、props、插槽、事件、示例和补充说明 |
41
+ | `astryx-vue composable --list` | 列出文档里的全部组合式函数 |
42
+ | `astryx-vue composable <Name>` | 打印一个组合式函数的参数、返回值、用法和示例 |
43
+ | `astryx-vue docs` | 列出全部指南和主题 |
44
+ | `astryx-vue docs <topic>` | 打印一篇正文,例如 `docs guide/dark-mode` 或 `docs themes/tokens` |
45
+ | `astryx-vue search <query>` | 按相关度搜索组件、组合式函数和文档主题 |
46
+ | `astryx-vue manifest --json` | 命令、选项、响应类型和退出码 |
47
+ | `astryx-vue init --features agents` | 创建或刷新 `AGENTS.md` 里的托管区块 |
48
+
49
+ 全局参数:
50
+
51
+ | 参数 | 作用 |
52
+ | --- | --- |
53
+ | `--json` | 往 stdout 打类型化的包:`{ apiVersion, type, data }`。出错时是 `{ apiVersion, error, code, suggestions? }`,退出码非 0。 |
54
+ | `--dense` | 缩短给人看的文本。和 `--json` 一起用时忽略,JSON 始终是完整内容。 |
55
+ | `--zh` | 文档有简体中文时输出中文。 |
56
+ | `--cwd <dir>` | `init` 写入的目录。 |
57
+
58
+ 组合式函数可以写 `useClipboard`,也可以写 `use-clipboard`。`component useClipboard` 仍然能查到,末尾会多一行提示,让你改用 `composable` 命令。`component --list` 只列组件。`search --type` 接受 `component`、`composable` 或 `doc`;组合式函数的结果 `domain` 是 `composable`,`command` 指向 `composable <Name>`。
59
+
60
+ `docs` 接受主题 id,也接受把 `theme/` 换成 `themes/` 的写法,或能唯一对上的短名字,例如 `dark-mode`。`--json` 返回 `docs.list` 或 `docs.detail`,`docs.detail` 里带正文 `body`。
61
+
62
+ `init` 可以用 `--agent cursor|claude|codex`。`cursor` 和 `codex` 写 `AGENTS.md`,`claude` 写 `CLAUDE.md`。不传时写 `AGENTS.md`。
63
+
64
+ 退出码:`0` 成功,`1` 命令跑了但失败,`2` 用法不对。程序请判断 JSON 里的 `code`,不要依赖 `error` 的句子。
65
+
66
+ ## Agent 区块
67
+
68
+ `init --features agents` 写入:
69
+
70
+ ```html
71
+ <!-- Maintained by astryx-vue, do not edit manually -->
72
+ ...
73
+ <!-- astryx-vue block end -->
74
+ ```
75
+
76
+ 文件不存在就创建。标记已经在,每次运行都只用新生成的内容替换标记中间的区块,外面的文字不动。文件在但没有标记,就把区块接到末尾。再跑一次仍然重写这块,不会因为标记已经存在就跳过。生成结果和原来一样时,文件字节不变。
77
+
78
+ 区块里只说明怎么用 CLI 查组件,不会把整份组件目录贴进去。
79
+
80
+ ## 文字从哪来
81
+
82
+ CLI 不另写一套组件说明。`packages/cli/scripts/generate-catalog.mjs` 读取:
83
+
84
+ - `apps/docs/components/demos/*/meta.ts`:名称、分组和顺序
85
+ - `apps/docs/docs/{en,zh}/components/<slug>/`:用法、props、插槽、事件和示例标题
86
+ - `apps/docs/components/demos/<slug>/*.vue`:页面对应的示例源码
87
+ - `apps/docs/components/demo-infra/reference/*.json`:结构和无障碍要求
88
+ - `apps/docs/docs/{en,zh}/guide` 与 `themes`:搜索用的主题,以及主题正文
89
+ - 页面里没有 import 时,再用 `packages/core/package.json` 的 exports
90
+
91
+ 生成结果提交在 `packages/cli/src/generated/catalog.json`。`pnpm --filter @astryx-vue/cli build` 会重新生成,并打进 `dist`。发布出去的包跑的就是这份。文档改了之后重新生成并提交:
92
+
93
+ ```sh
94
+ pnpm --filter @astryx-vue/cli generate
95
+ ```
96
+
97
+ `pnpm check` 会跑 `generate:check`。`catalog.json` 过期会失败。`@astryx-vue/core` 里大写开头的导出没有被任何已文档化的组件 import,也会失败。`./icons`、`./locale`、CSS 和包根不算组件导出。
98
+
99
+ 这个包不做 theme、template、upgrade、doctor、swizzle 和 MCP。
100
+
101
+ ## 相关的包
102
+
103
+ | 包 | 是什么 |
104
+ | --- | --- |
105
+ | `@astryx-vue/core` | 这份 CLI 所说明的 Vue 组件 |
106
+ | `@astryx-vue/themes` | Neutral、Butter、Chocolate、Gothic、Matcha、Stone、Y2K |
107
+
108
+ ## 在本仓库里试
109
+
110
+ ```sh
111
+ pnpm --filter @astryx-vue/cli build
112
+ node packages/cli/bin/astryx-vue.mjs component Button
113
+ node packages/cli/bin/astryx-vue.mjs composable useClipboard
114
+ node packages/cli/bin/astryx-vue.mjs docs guide/dark-mode --dense
115
+ node packages/cli/bin/astryx-vue.mjs search installation --type doc
116
+ node packages/cli/bin/astryx-vue.mjs manifest --json
117
+ ```
118
+
119
+ ## 许可证
120
+
121
+ MIT。Astryx 的版权属于 Meta Platforms, Inc.。这个包是非官方移植,与 Meta 没有隶属或背书关系。
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env node
2
+ import process from 'node:process'
3
+ import { runCli } from '../dist/index.js'
4
+
5
+ const result = await runCli(process.argv.slice(2))
6
+ if (result.stdout)
7
+ process.stdout.write(result.stdout)
8
+ if (result.stderr)
9
+ process.stderr.write(result.stderr)
10
+ process.exitCode = result.exitCode
@@ -0,0 +1,63 @@
1
+ //#region src/agents.d.ts
2
+ export declare const MANAGED_BLOCK_START = "<!-- Maintained by astryx-vue, do not edit manually -->";
3
+ export declare const MANAGED_BLOCK_END = "<!-- astryx-vue block end -->";
4
+ type AgentName = 'agents' | 'cursor' | 'claude' | 'codex';
5
+ type BlockAction = 'created' | 'updated' | 'appended';
6
+ export declare function agentFile(agent: AgentName): string;
7
+ export declare function applyManagedBlock(existing: string | null, inner: string): {
8
+ content: string;
9
+ action: BlockAction;
10
+ };
11
+ //#endregion
12
+ //#region src/cli.d.ts
13
+ interface CliIO {
14
+ cwd?: string;
15
+ }
16
+ interface CliResult {
17
+ exitCode: number;
18
+ stdout: string;
19
+ stderr: string;
20
+ }
21
+ export declare function runCli(argv: readonly string[], io?: CliIO): Promise<CliResult>;
22
+ //#endregion
23
+ //#region src/error.d.ts
24
+ interface Suggestion {
25
+ name: string;
26
+ reason: string;
27
+ }
28
+ export declare class CliError extends Error {
29
+ readonly code: string;
30
+ readonly exitCode: number;
31
+ readonly suggestions: Suggestion[];
32
+ constructor(message: string, code: string, exitCode?: number, suggestions?: Suggestion[]);
33
+ }
34
+ //#endregion
35
+ //#region src/envelope.d.ts
36
+ interface ErrorEnvelope {
37
+ apiVersion: number;
38
+ error: string;
39
+ code: string;
40
+ suggestions?: {
41
+ name: string;
42
+ reason: string;
43
+ }[];
44
+ }
45
+ interface SuccessEnvelope<TType extends string = string, TData = unknown> {
46
+ apiVersion: number;
47
+ type: TType;
48
+ package?: string;
49
+ data: TData;
50
+ }
51
+ type AnyEnvelope = SuccessEnvelope | ErrorEnvelope;
52
+ export declare function successEnvelope<TType extends string, TData>(type: TType, data: TData, packageName?: string): SuccessEnvelope<TType, TData>;
53
+ export declare function errorEnvelope(error: CliError): ErrorEnvelope;
54
+ export declare function isError(value: unknown): value is ErrorEnvelope;
55
+ export declare function parseResponse(raw: string): AnyEnvelope;
56
+ export declare function assertResponse<TType extends string>(raw: unknown, type: TType): SuccessEnvelope<TType>;
57
+ //#endregion
58
+ //#region src/spec.d.ts
59
+ export declare const API_VERSION = 1;
60
+ export declare const BINARY = "astryx-vue";
61
+ export declare const PACKAGE_NAME = "@astryx-vue/cli";
62
+ //#endregion
63
+ export type { AnyEnvelope, CliIO, CliResult, ErrorEnvelope, SuccessEnvelope, Suggestion };