Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/empty-a2ui-cli-prompt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---

---

No package release is required because this change wires A2UI prompt/catalog generation tooling for the GenUI workspace without changing published runtime behavior.
2 changes: 2 additions & 0 deletions biome.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@

// REPL examples use Lynx platform globals and are not subject to lint rules
"packages/repl/src/examples/**",
// REPL generated artifacts can exceed Biome's file-size limit
"packages/repl/src/generated/**",
],
"rules": {
// We are migrating from ESLint to Biome
Expand Down
11 changes: 10 additions & 1 deletion packages/genui/a2ui-catalog-extractor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ It can also wrap those generated components with a `catalogId`,
- It does not ask you to write JSON Schema in comments.
- It does not expand arbitrary imported type aliases or external
interfaces.
- It does not call an LLM or choose a model.

The package consumes TypeDoc reflection data. This keeps the implementation
small, but it also means catalog-facing shapes should be written inline in
Expand All @@ -53,7 +54,7 @@ the marked interface.

### Package manager

Install it as a development dependency:
Install the extractor as a development dependency:

```bash
pnpm add -D @lynx-js/a2ui-catalog-extractor
Expand Down Expand Up @@ -385,8 +386,16 @@ export interface CardProps {

## CLI Reference

The package exposes the standalone `a2ui-catalog-extractor` binary. The
separate `@lynx-js/a2ui-cli` package also exposes this flow as
`a2ui-cli generate catalog`.

### Generate catalog artifacts

```bash
a2ui-catalog-extractor [options]
# or
a2ui-cli generate catalog [options]
```

| Option | Description | Default |
Expand Down
10 changes: 9 additions & 1 deletion packages/genui/a2ui-catalog-extractor/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
{
"name": "@lynx-js/a2ui-catalog-extractor",
"version": "0.0.0",
"private": true,
"description": "TypeDoc-driven A2UI catalog extractor for TypeScript interfaces.",
"repository": {
"type": "git",
"url": "https://github.com/lynx-family/lynx-stack.git",
"directory": "packages/genui/a2ui-catalog-extractor"
},
"license": "Apache-2.0",
"type": "module",
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"./cli": {
"types": "./dist/cli.d.ts",
"default": "./dist/cli.js"
},
"./skill": "./skills/a2ui-catalog-extractor/SKILL.md",
"./package.json": "./package.json"
},
Expand Down
11 changes: 10 additions & 1 deletion packages/genui/a2ui-catalog-extractor/readme.zh_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ agent 哪些 props 合法、哪些 props 必填、哪些 enum 值可用,以及
- 它不直接使用 TypeScript compiler API。
- 它不要求你在注释里写 JSON Schema。
- 它不会展开任意导入的 type alias 或外部 interface。
- 它不会调用 LLM,也不会替你选择模型。

这个包消费 TypeDoc reflection 数据。这样实现更小,但也意味着面向 catalog
的类型形状应该直接内联写在被标记的 interface 中。
Expand All @@ -50,7 +51,7 @@ agent 哪些 props 合法、哪些 props 必填、哪些 enum 值可用,以及

### 包管理器

把它安装为开发依赖
把 extractor 安装为开发依赖

```bash
pnpm add -D @lynx-js/a2ui-catalog-extractor
Expand Down Expand Up @@ -377,8 +378,16 @@ export interface CardProps {

## CLI 参考

这个包暴露独立的 `a2ui-catalog-extractor` binary。单独的
`@lynx-js/a2ui-cli` 包也把这个流程暴露为
`a2ui-cli generate catalog`。

### 生成 catalog artifacts

```bash
a2ui-catalog-extractor [options]
# 或
a2ui-cli generate catalog [options]
```

| 选项 | 说明 | 默认值 |
Expand Down
8 changes: 5 additions & 3 deletions packages/genui/a2ui-catalog-extractor/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ Options:
--typedoc-json <file>
Read an existing TypeDoc JSON project instead of
running TypeDoc conversion.
--out-dir <dir> Output directory for component catalog.json files.
--version Print the package version.
--help Print this help message.
--out-dir <dir> Output directory for component catalog.json files.
--version Print the package version.
--help Print this help message.

Defaults:
--catalog-dir src/catalog
Expand All @@ -55,6 +55,8 @@ export function parseCliArgs(args: string[]): CliOptions {
for (let index = 0; index < args.length; index += 1) {
const arg = args[index]!;
switch (arg) {
case 'catalog-extractor':
break;
case '--catalog-dir':
options.catalogDirs.push(readValue(args, ++index, arg));
break;
Expand Down
23 changes: 23 additions & 0 deletions packages/genui/a2ui-cli/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# a2ui-cli

Keep this package as the single public CLI entry point for A2UI setup. It should
orchestrate other packages instead of implementing catalog extraction or prompt
construction itself.

`generate catalog` should delegate to `@lynx-js/a2ui-catalog-extractor`.
`generate prompt` should delegate to `@lynx-js/a2ui-prompt`.

Do not require users to pass `--catalog-dir` for the common prompt path. A prompt
without `--catalog-dir` should use the built-in A2UI basic catalog from
`@lynx-js/a2ui-prompt`; use `--catalog-dir` only for custom generated catalog
artifacts.

When `--catalog-dir` is provided, empty catalog directories should fail clearly
instead of producing a prompt with an empty component catalog.

The executable file is `bin/cli.js`; keep `package.json` `bin.a2ui-cli` pointed
at that path.

When testing local CLI changes, run the bin directly with Node. If testing
changes in `@lynx-js/a2ui-prompt`, rebuild that package first because this CLI
imports it through package exports.
65 changes: 65 additions & 0 deletions packages/genui/a2ui-cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# A2UI CLI

`@lynx-js/a2ui-cli` provides one command line entry point for A2UI agent setup.
It can generate catalog artifacts from TypeScript catalog definitions and build
a system prompt for an A2UI generation agent.

## Usage

Generate a system prompt with the built-in A2UI basic catalog:

```bash
npx @lynx-js/a2ui-cli@latest generate prompt --out dist/a2ui-system-prompt.txt
```

Generate catalog artifacts for a custom catalog:

```bash
npx @lynx-js/a2ui-cli@latest generate catalog \
--catalog-dir src/catalog \
--source src/functions \
--out-dir dist/catalog
```

Generate a system prompt for a custom catalog:

```bash
npx @lynx-js/a2ui-cli@latest generate prompt \
--catalog-dir dist/catalog \
--catalog-id https://example.com/catalogs/custom/v1/catalog.json \
--out dist/a2ui-system-prompt.txt
```

`generate prompt` uses the built-in A2UI basic catalog by default. Pass
`--catalog-dir` only when generating a prompt for custom generated catalog
artifacts. When `--catalog-dir` is provided, the directory must contain files
like `<Component>/catalog.json`.

## Commands

### `generate catalog`

Delegates catalog extraction to `@lynx-js/a2ui-catalog-extractor`.

Useful options:

- `--catalog-dir <dir>`: directory to scan for TypeScript component catalog
interfaces. Defaults to `src/catalog`.
- `--source <path>`: source file or directory to scan for catalog functions.
Repeatable.
- `--typedoc-json <file>`: read an existing TypeDoc JSON project.
- `--out-dir <dir>`: output directory for generated catalog artifacts. Defaults
to `dist/catalog`.

### `generate prompt`

Delegates prompt construction to `@lynx-js/a2ui-prompt`.

Useful options:

- `--catalog-dir <dir>`: generated catalog artifact directory. Omit this option
to use the built-in A2UI basic catalog.
- `--catalog-id <id>`: catalog id to require in `createSurface` messages.
Defaults to the built-in A2UI basic catalog id.
- `--out <file>`: write the prompt to a file instead of stdout.
- `--appendix <text>`: append extra instructions to the generated prompt.
Loading
Loading