@astryx-vue/cli 0.0.0-stage → 0.1.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 +21 -0
- package/README.md +107 -2
- package/README.zh-CN.md +108 -0
- package/bin/astryx-vue.mjs +10 -0
- package/dist/index.d.ts +63 -0
- package/dist/index.js +37448 -0
- package/package.json +54 -3
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,108 @@
|
|
|
1
|
-
|
|
1
|
+
English | [简体中文](./README.zh-CN.md)
|
|
2
2
|
|
|
3
|
-
|
|
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 -- search dialog --json
|
|
30
|
+
npm run astryx-vue -- manifest --json
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Commands
|
|
34
|
+
|
|
35
|
+
| Command | What it prints |
|
|
36
|
+
| --- | --- |
|
|
37
|
+
| `astryx-vue component --list` | Every documented component |
|
|
38
|
+
| `astryx-vue component <Name>` | Usage, props, slots, events, and notes for one component |
|
|
39
|
+
| `astryx-vue search <query>` | Ranked components and guide topics |
|
|
40
|
+
| `astryx-vue manifest --json` | Commands, options, response types, and exit codes |
|
|
41
|
+
| `astryx-vue init --features agents` | Creates or refreshes the managed block in `AGENTS.md` |
|
|
42
|
+
|
|
43
|
+
Global flags:
|
|
44
|
+
|
|
45
|
+
| Flag | Effect |
|
|
46
|
+
| --- | --- |
|
|
47
|
+
| `--json` | Typed envelope `{ apiVersion, type, data }` on stdout. Errors use `{ apiVersion, error, code, suggestions? }` and a non-zero exit code. |
|
|
48
|
+
| `--dense` | Shorter text. Ignored with `--json`, which stays the full envelope. |
|
|
49
|
+
| `--zh` | Simplified Chinese where the docs have a translation. |
|
|
50
|
+
| `--cwd <dir>` | Directory `init` writes into. |
|
|
51
|
+
|
|
52
|
+
`init` accepts `--agent cursor|claude|codex`. `cursor` and `codex` write `AGENTS.md`. `claude` writes `CLAUDE.md`. The default file is `AGENTS.md`.
|
|
53
|
+
|
|
54
|
+
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
|
+
|
|
56
|
+
## Agent block
|
|
57
|
+
|
|
58
|
+
`init --features agents` writes this managed block:
|
|
59
|
+
|
|
60
|
+
```html
|
|
61
|
+
<!-- Maintained by astryx-vue, do not edit manually -->
|
|
62
|
+
...
|
|
63
|
+
<!-- astryx-vue block end -->
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
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
|
+
|
|
68
|
+
The block tells an agent how to query the CLI. It does not paste the component catalog.
|
|
69
|
+
|
|
70
|
+
## Where the text comes from
|
|
71
|
+
|
|
72
|
+
The CLI does not keep a second copy of the component docs. `packages/cli/scripts/generate-catalog.mjs` reads:
|
|
73
|
+
|
|
74
|
+
- `apps/docs/components/demos/*/meta.ts` for names, groups, and order
|
|
75
|
+
- `apps/docs/docs/{en,zh}/components/<slug>/` for usage, props, slots, and events
|
|
76
|
+
- `apps/docs/components/demo-infra/reference/*.json` for anatomy and accessibility
|
|
77
|
+
- `apps/docs/docs/{en,zh}/guide` and `themes` for search topics
|
|
78
|
+
- `packages/core/package.json` exports when a page does not show an import
|
|
79
|
+
|
|
80
|
+
The result is committed at `packages/cli/src/generated/catalog.json`. After a docs change, regenerate it and commit the diff:
|
|
81
|
+
|
|
82
|
+
```sh
|
|
83
|
+
pnpm --filter @astryx-vue/cli generate
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
`pnpm check` runs `generate:check` and fails if the file is stale.
|
|
87
|
+
|
|
88
|
+
Theme, template, upgrade, doctor, swizzle, and MCP commands are not part of this package.
|
|
89
|
+
|
|
90
|
+
## Related packages
|
|
91
|
+
|
|
92
|
+
| Package | What it is |
|
|
93
|
+
| --- | --- |
|
|
94
|
+
| `@astryx-vue/core` | The Vue components this CLI documents |
|
|
95
|
+
| `@astryx-vue/themes` | Neutral, Butter, Chocolate, Gothic, Matcha, Stone, and Y2K |
|
|
96
|
+
|
|
97
|
+
## Try it in this repo
|
|
98
|
+
|
|
99
|
+
```sh
|
|
100
|
+
pnpm --filter @astryx-vue/cli build
|
|
101
|
+
node packages/cli/bin/astryx-vue.mjs component Button
|
|
102
|
+
node packages/cli/bin/astryx-vue.mjs search installation --type doc
|
|
103
|
+
node packages/cli/bin/astryx-vue.mjs manifest --json
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## License
|
|
107
|
+
|
|
108
|
+
MIT. Astryx is copyright Meta Platforms, Inc. This package is an unofficial port and is not affiliated with or endorsed by Meta.
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
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 -- search dialog --json
|
|
30
|
+
npm run astryx-vue -- manifest --json
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## 命令
|
|
34
|
+
|
|
35
|
+
| 命令 | 输出 |
|
|
36
|
+
| --- | --- |
|
|
37
|
+
| `astryx-vue component --list` | 列出文档里的全部组件 |
|
|
38
|
+
| `astryx-vue component <Name>` | 打印一个组件的用法、props、插槽、事件和补充说明 |
|
|
39
|
+
| `astryx-vue search <query>` | 按相关度搜索组件和指南 |
|
|
40
|
+
| `astryx-vue manifest --json` | 命令、选项、响应类型和退出码 |
|
|
41
|
+
| `astryx-vue init --features agents` | 创建或刷新 `AGENTS.md` 里的托管区块 |
|
|
42
|
+
|
|
43
|
+
全局参数:
|
|
44
|
+
|
|
45
|
+
| 参数 | 作用 |
|
|
46
|
+
| --- | --- |
|
|
47
|
+
| `--json` | 往 stdout 打类型化的包:`{ apiVersion, type, data }`。出错时是 `{ apiVersion, error, code, suggestions? }`,退出码非 0。 |
|
|
48
|
+
| `--dense` | 缩短给人看的文本。和 `--json` 一起用时忽略,JSON 始终是完整内容。 |
|
|
49
|
+
| `--zh` | 文档有简体中文时输出中文。 |
|
|
50
|
+
| `--cwd <dir>` | `init` 写入的目录。 |
|
|
51
|
+
|
|
52
|
+
`init` 可以用 `--agent cursor|claude|codex`。`cursor` 和 `codex` 写 `AGENTS.md`,`claude` 写 `CLAUDE.md`。不传时写 `AGENTS.md`。
|
|
53
|
+
|
|
54
|
+
退出码:`0` 成功,`1` 命令跑了但失败,`2` 用法不对。程序请判断 JSON 里的 `code`,不要依赖 `error` 的句子。
|
|
55
|
+
|
|
56
|
+
## Agent 区块
|
|
57
|
+
|
|
58
|
+
`init --features agents` 写入:
|
|
59
|
+
|
|
60
|
+
```html
|
|
61
|
+
<!-- Maintained by astryx-vue, do not edit manually -->
|
|
62
|
+
...
|
|
63
|
+
<!-- astryx-vue block end -->
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
文件不存在就创建。标记已经在,每次运行都只用新生成的内容替换标记中间的区块,外面的文字不动。文件在但没有标记,就把区块接到末尾。再跑一次仍然重写这块,不会因为标记已经存在就跳过。生成结果和原来一样时,文件字节不变。
|
|
67
|
+
|
|
68
|
+
区块里只说明怎么用 CLI 查组件,不会把整份组件目录贴进去。
|
|
69
|
+
|
|
70
|
+
## 文字从哪来
|
|
71
|
+
|
|
72
|
+
CLI 不另写一套组件说明。`packages/cli/scripts/generate-catalog.mjs` 读取:
|
|
73
|
+
|
|
74
|
+
- `apps/docs/components/demos/*/meta.ts`:名称、分组和顺序
|
|
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
|
|
79
|
+
|
|
80
|
+
生成结果提交在 `packages/cli/src/generated/catalog.json`。文档改了之后重新生成并提交:
|
|
81
|
+
|
|
82
|
+
```sh
|
|
83
|
+
pnpm --filter @astryx-vue/cli generate
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
`pnpm check` 会跑 `generate:check`,文件过期就失败。
|
|
87
|
+
|
|
88
|
+
这个包不做 theme、template、upgrade、doctor、swizzle 和 MCP。
|
|
89
|
+
|
|
90
|
+
## 相关的包
|
|
91
|
+
|
|
92
|
+
| 包 | 是什么 |
|
|
93
|
+
| --- | --- |
|
|
94
|
+
| `@astryx-vue/core` | 这份 CLI 所说明的 Vue 组件 |
|
|
95
|
+
| `@astryx-vue/themes` | Neutral、Butter、Chocolate、Gothic、Matcha、Stone、Y2K |
|
|
96
|
+
|
|
97
|
+
## 在本仓库里试
|
|
98
|
+
|
|
99
|
+
```sh
|
|
100
|
+
pnpm --filter @astryx-vue/cli build
|
|
101
|
+
node packages/cli/bin/astryx-vue.mjs component Button
|
|
102
|
+
node packages/cli/bin/astryx-vue.mjs search installation --type doc
|
|
103
|
+
node packages/cli/bin/astryx-vue.mjs manifest --json
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## 许可证
|
|
107
|
+
|
|
108
|
+
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
|
package/dist/index.d.ts
ADDED
|
@@ -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 };
|