Skip to content

Commit f2bfbdc

Browse files
fix: Linux release desktop configuration and complete TMP schema implementation
1 parent b98068e commit f2bfbdc

11 files changed

Lines changed: 6415 additions & 26 deletions

File tree

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ input_classifier/models/**/*tokenizer.json linguist-generated=true
2020
# 用法:本地需先注册驱动 `git config merge.openwarp-ours.driver true`
2121
# CI / 新克隆者执行 `script/setup-merge-drivers.sh` 自动配置
2222
.github/workflows/openwarp_release.yml merge=openwarp-ours
23-
app/channels/oss/dev.openwarp.OpenWarp.desktop merge=openwarp-ours
23+
app/channels/oss/dev.goldcoders.waz.desktop merge=openwarp-ours
2424
lib/rust-genai/** merge=openwarp-ours
2525

2626
# openWarp 自治区(BYOP / cloud 清理 / i18n / footer 删改 等已永久分叉)
File renamed without changes.
Lines changed: 151 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,172 @@
11
Generate a Token Model Protocol (TMP) JSON schema for the CLI tool "{{ tool }}".
22

3-
A TMP schema defines the subcommand structure, parameters (flags and arguments), primitive token types, descriptions, and dynamic resolvers for a CLI tool.
3+
Your task is to dynamically discover the full CLI structure of "{{ tool }}" by running its help commands, then produce an exhaustive TMP v2 JSON schema. Do NOT rely on training knowledge alone — actually run the tool to discover its interface.
44

5-
Please design a comprehensive and detailed schema file for "{{ tool }}", mapping its most common subcommands, options, and parameters.
5+
## Step 1: Discover the help system
66

7-
## Schema Specification and Format
8-
The output MUST be a valid JSON object matching the following structure:
7+
Try each method in order and use the first one that succeeds:
8+
9+
1. `{{ tool }} --help`
10+
2. `{{ tool }} -h`
11+
3. `man {{ tool }}`
12+
4. `{{ tool }}` (with no arguments — some tools print usage on bare invocation)
13+
14+
Record which method produced output. If none work, fall back to your training knowledge and set `discovery_method` to `"none"`.
15+
16+
Also discover the tool version by trying `{{ tool }} --version` or `{{ tool }} -V`.
17+
18+
## Step 2: Discover the tool's description
19+
20+
From the help output, extract a concise one-line description of what "{{ tool }}" does (the first sentence or tagline).
21+
22+
## Step 3: Recursively discover ALL subcommands (max 3 levels deep)
23+
24+
Parse the top-level help output for a list of subcommands or command groups.
25+
26+
For each subcommand found:
27+
- Run `{{ tool }} <subcommand> --help` (or `-h` if `--help` is not supported)
28+
- Parse the output for nested subcommands
29+
- For nested subcommands, run `{{ tool }} <subcommand> <nested> --help`
30+
- Continue up to 3 levels deep (e.g. `{{ tool }} remote add --help`)
31+
32+
If "{{ tool }}" has no subcommands (e.g. simple tools like `cat`, `echo`, `grep`), create a single command entry with `"command": "{{ tool }}"`.
33+
34+
## Step 4: Extract ALL flags, options, and arguments
35+
36+
For every command and subcommand, parse the help output exhaustively. For each parameter:
37+
38+
1. **Name**: derive from the long flag (e.g. `--output` → `"output"`) or positional name
39+
2. **Flag**: the long form (e.g. `--output`)
40+
3. **Aliases**: short forms (e.g. `["-o"]`)
41+
4. **Required vs optional**: mark as `required: true` if the help text indicates it is mandatory or if it is a positional argument without a default
42+
5. **Token type** — apply these rules:
43+
- `"Boolean"`: flags that take no value (e.g. `--release`, `--verbose`, `--force`)
44+
- `"String"`: flags that accept a free-form string value
45+
- `"Enum"`: flags with a known, finite set of valid values (e.g. `--format json|yaml|toml`)
46+
- `"File"`: flags that accept a file or directory path (look for hints like `<FILE>`, `<PATH>`, `<DIR>`)
47+
- `"Number"`: flags that accept a numeric value (e.g. `--jobs <N>`, `--depth <NUM>`)
48+
6. **Default**: extract the default value if documented (e.g. `[default: 4]`)
49+
7. **Values**: for `Enum` types, list all valid values as an array (e.g. `["json", "yaml", "toml"]`)
50+
8. **Description**: the help text for this parameter
51+
52+
Every flag that appears in `--help` output MUST appear in the schema. Be exhaustive.
53+
54+
## Step 5: Map data sources
55+
56+
For parameters that accept dynamic values, attach a `data_source` object.
57+
58+
### Built-in resolvers (use when applicable):
59+
60+
| Resolver | Provides |
61+
|----------|----------|
62+
| `cargo:bins` | Binary target names from Cargo workspace |
63+
| `cargo:examples` | Example target names |
64+
| `cargo:packages` | Package names in workspace |
65+
| `cargo:features` | Feature flags |
66+
| `cargo:profiles` | Build profiles |
67+
| `cargo:tests` | Test target names |
68+
| `cargo:benches` | Benchmark target names |
69+
| `git:branches` | Git branch names |
70+
| `git:remotes` | Git remote names |
71+
| `git:status_files` | Files with uncommitted changes |
72+
| `git:tags` | Git tags |
73+
| `npm:scripts` | npm script names from package.json |
74+
75+
### Command-based resolvers:
76+
77+
For dynamic values not covered by built-in resolvers, specify a shell command that produces one value per line:
78+
79+
```json
80+
"data_source": {
81+
"resolver": null,
82+
"command": "docker image ls --format '{{"{{"}}.Repository{{"}}"}}:{{"{{"}}.Tag{{"}}"}}'",
83+
"parse": "lines",
84+
"fallback": {
85+
"command": "docker image ls -q"
86+
}
87+
}
88+
```
89+
90+
Use fallback chains when multiple sources exist. Set `data_source` to `null` for parameters that take literal user input.
91+
92+
## Step 6: Determine metadata
93+
94+
- `requires_binary`: set to `"{{ tool }}"` (the binary that must be on PATH)
95+
- `requires_file`: set to a project file if relevant (e.g. `"Cargo.toml"` for cargo, `"package.json"` for npm), otherwise `null`
96+
- `keywords`: 3-6 descriptive keywords for the tool
97+
98+
## Output format
99+
100+
Output a single valid JSON object with this exact structure. Do NOT wrap it in markdown code blocks. Do NOT add conversational commentary. Output ONLY the raw JSON.
101+
102+
```
9103
{
10104
"meta": {
105+
"schema_version": 2,
11106
"tool": "{{ tool }}",
12-
"description": "Short description of what the tool does."
107+
"version": 0,
108+
"description": "<one-line description of the tool>",
109+
"generated_by": "ai",
110+
"generated_with": "waz-agent",
111+
"verified": false,
112+
"coverage": "full",
113+
"discovery_method": "<help|man|none>",
114+
"requires_file": "<filename or null>",
115+
"requires_binary": "{{ tool }}",
116+
"keywords": ["<keyword1>", "<keyword2>", "..."]
13117
},
14118
"commands": [
15119
{
16120
"command": "{{ tool }} <subcommand>",
17-
"description": "Short description of the subcommand.",
121+
"description": "<what this subcommand does>",
18122
"group": "{{ tool }}",
19-
"verified": true,
123+
"verified": false,
20124
"tokens": [
21125
{
22-
"name": "parameter_name",
23-
"description": "What this flag/argument does.",
126+
"name": "<param_name>",
127+
"description": "<what it does>",
24128
"required": false,
25-
"token_type": "Enum" | "Boolean" | "String" | "File" | "Number",
26-
"flag": "--flag-name" (optional),
27-
"data_source": { (optional)
28-
"resolver": "git:branches" | "git:status_files" | "cargo:packages" | "npm:scripts" | etc.
29-
}
129+
"token_type": "String",
130+
"flag": "--flag-name",
131+
"aliases": ["-f"],
132+
"default": null,
133+
"values": null,
134+
"data_source": null
30135
}
31136
]
32137
}
33138
]
34139
}
140+
```
141+
142+
### Field notes:
143+
- `command`: full invocation prefix, e.g. `"{{ tool }} build"`, `"{{ tool }} remote add"`, or just `"{{ tool }}"` for tools without subcommands
144+
- `group`: always `"{{ tool }}"`
145+
- `verified`: always `false` (this is AI-generated)
146+
- `token_type`: one of `"String"`, `"Boolean"`, `"Enum"`, `"File"`, `"Number"`
147+
- `aliases`: array of short flags, e.g. `["-f"]`, or `[]` if none
148+
- `values`: array of valid values for `Enum` type, or `null`
149+
- `data_source`: resolver object or `null`. Structure when present:
150+
```
151+
{
152+
"resolver": "<built_in_resolver or null>",
153+
"command": "<shell_command or null>",
154+
"parse": "lines",
155+
"fallback": {
156+
"command": "<fallback_command or null>"
157+
}
158+
}
159+
```
160+
161+
## Step 7: Save the schema
162+
163+
After generating the JSON, save it to `~/.waz/schemas/{{ tool }}.json`. Create the `~/.waz/schemas/` directory if it does not exist.
164+
165+
## Important reminders
35166

36-
## Guidelines
37-
1. The JSON must be valid and ready to be saved to `.waz/schemas/{{ tool }}.json`.
38-
2. Do not wrap the JSON in markdown code blocks or add conversational commentary; output ONLY the raw, clean JSON content.
39-
3. Make sure to define the correct `token_type` for each parameter. Use "Boolean" for flags that take no values (like --force or -f), "Enum" for parameters with specific values, "File" for paths/files, and "String" for generic text.
167+
- Actually run `{{ tool }} --help` and subcommand help — do not guess from memory
168+
- Every flag from the help output must appear in the schema — be exhaustive
169+
- The JSON must be valid and parseable
170+
- For tools with many subcommands (e.g. `git`, `docker`, `cargo`), this will require many help invocations — that is expected
171+
- Omit `data_source` (set to `null`) when the parameter takes literal user input with no dynamic completion
172+
- Group related subcommands logically but keep every subcommand as its own entry in the `commands` array

app/src/ai/agent_providers/tools/tmp_ai_tests.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ fn test_token_to_json_schema() {
4747
default: None,
4848
flag: None,
4949
values: None,
50+
aliases: vec![],
5051
data_source: None,
5152
};
5253
let schema_str = token_to_json_schema(&t_string);
@@ -61,6 +62,7 @@ fn test_token_to_json_schema() {
6162
default: Some("true".to_string()),
6263
flag: Some("--release".to_string()),
6364
values: None,
65+
aliases: vec![],
6466
data_source: None,
6567
};
6668
let schema_bool = token_to_json_schema(&t_bool);
@@ -75,6 +77,7 @@ fn test_token_to_json_schema() {
7577
default: Some("fast".to_string()),
7678
flag: None,
7779
values: Some(vec!["fast".to_string(), "slow".to_string()]),
80+
aliases: vec![],
7881
data_source: None,
7982
};
8083
let schema_enum = token_to_json_schema(&t_enum);
@@ -99,6 +102,7 @@ fn test_command_to_json_schema() {
99102
default: None,
100103
flag: Some("-p".to_string()),
101104
values: None,
105+
aliases: vec![],
102106
data_source: None,
103107
},
104108
TokenDef {
@@ -109,6 +113,7 @@ fn test_command_to_json_schema() {
109113
default: None,
110114
flag: Some("--release".to_string()),
111115
values: None,
116+
aliases: vec![],
112117
data_source: None,
113118
},
114119
],
@@ -138,6 +143,7 @@ fn test_validate_tmp_arguments() {
138143
default: None,
139144
flag: Some("-p".to_string()),
140145
values: None,
146+
aliases: vec![],
141147
data_source: None,
142148
},
143149
TokenDef {
@@ -148,6 +154,7 @@ fn test_validate_tmp_arguments() {
148154
default: None,
149155
flag: None,
150156
values: Some(vec!["dev".to_string(), "release".to_string()]),
157+
aliases: vec![],
151158
data_source: None,
152159
},
153160
],
@@ -214,6 +221,7 @@ fn test_compile_tmp_command() {
214221
default: None,
215222
flag: Some("-p".to_string()),
216223
values: None,
224+
aliases: vec![],
217225
data_source: None,
218226
},
219227
TokenDef {
@@ -224,6 +232,7 @@ fn test_compile_tmp_command() {
224232
default: Some("false".to_string()),
225233
flag: Some("--release".to_string()),
226234
values: None,
235+
aliases: vec![],
227236
data_source: None,
228237
},
229238
TokenDef {
@@ -234,6 +243,7 @@ fn test_compile_tmp_command() {
234243
default: None,
235244
flag: Some("-j".to_string()),
236245
values: None,
246+
aliases: vec![],
237247
data_source: None,
238248
},
239249
],

app/src/terminal/input_test.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7017,6 +7017,7 @@ fn test_tmp_path_completions() {
70177017
default: None,
70187018
values: None,
70197019
flag: None,
7020+
aliases: vec![],
70207021
data_source: None,
70217022
}
70227023
],
@@ -7133,6 +7134,7 @@ fn test_tmp_form_panel_confirm_and_shift_tab() {
71337134
default: None,
71347135
values: None,
71357136
flag: None,
7137+
aliases: vec![],
71367138
data_source: None,
71377139
}
71387140
],

0 commit comments

Comments
 (0)