@vasm/cli 0.5.1 → 0.7.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/CHANGELOG.md +7 -0
- package/README.md +321 -62
- package/dist/index.js +192 -419
- package/package.json +9 -43
- package/LICENSE +0 -21
package/CHANGELOG.md
ADDED
package/README.md
CHANGED
|
@@ -1,97 +1,356 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @vasm/cli
|
|
2
2
|
|
|
3
|
-
[
|
|
3
|
+
[🌍 English](#en) | [🇨🇳 中文](#zh-cn)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
<a name="en"></a>
|
|
8
|
+
|
|
9
|
+
## 🌍 English
|
|
10
|
+
|
|
11
|
+
`@vasm/cli` publishes the `vasmc` command. It is the AI-facing VASMC entrypoint: it compiles `.vasm.md` sources into clean Markdown outputs and, during `build`, emits structured `.vasmc/build-report.yaml` actions so the active VASM skill can continue semantic work.
|
|
12
|
+
|
|
13
|
+
`vasmc` only performs deterministic work: dependency sync, AST assembly, language-block filtering, output writes, policy diagnostics, content signal collection, and report action generation.
|
|
14
|
+
|
|
15
|
+
### Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install -g @vasm/cli
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### 1. Initialize A Project
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
vasmc init
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Declare dependencies in `vasmc.yaml`:
|
|
28
|
+
|
|
29
|
+
```yaml
|
|
30
|
+
dependencies:
|
|
31
|
+
company-rules: "https://example.com/guidelines.md"
|
|
32
|
+
coder-skill:
|
|
33
|
+
url: "https://example.com/coder-skill.md"
|
|
34
|
+
dest: "./skills/coder.md"
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Or register one from the command line:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
vasmc add https://example.com/coder-skill.md --alias coder-skill --dest ./skills/coder.md
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### 2. Sync And Lock
|
|
44
|
+
|
|
45
|
+
Add `.vasmc/` to `.gitignore`; it is an internal cache directory. Commit `vasmc-lock.yaml` so build inputs stay deterministic.
|
|
46
|
+
|
|
47
|
+
```gitignore
|
|
48
|
+
.vasmc/
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Install missing dependencies and update the lockfile:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
vasmc sync
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Force refresh when needed:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
vasmc update <alias>
|
|
61
|
+
vasmc update
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### 3. AI Build
|
|
65
|
+
|
|
66
|
+
Compile one entry and generate a structured build report:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
vasmc build main.vasm.md -o ./dist
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Compile the workspace through `vasmc-build.yaml`:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
vasmc build
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
`vasmc build` is the AI-side compiler entrypoint. It writes deterministic Markdown outputs and `.vasmc/build-report.yaml`. If a target language is missing, `vasmc` does not call an external model; instead, it records actions for the current AI to handle Verify, Translate, Refresh Translation, Diff, Policy Review, Policy Gate, Project Review, and Tree-Shake tasks as needed. For `informational` outputs, existing target-language sections can be preserved and marked for refresh review instead of being dropped.
|
|
79
|
+
|
|
80
|
+
Useful build controls:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
vasmc build --dry-run
|
|
84
|
+
vasmc build main.vasm.md --dry-run --force
|
|
85
|
+
vasmc build --dry-run --report-out .vasmc/plan.yaml
|
|
86
|
+
vasmc build --force
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
`--dry-run` emits a YAML report plan to stdout and does not write compiled outputs, `.vasmc/build-report.yaml`, project-review context, history cache, or build-state. `--report-out` explicitly writes that report plan to a chosen file. `--force` ignores build-state and rebuilds unchanged entries.
|
|
90
|
+
|
|
91
|
+
For a pure expanded draft without workspace routing or report actions:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
vasmc expand main.vasm.md --target-lang zh-CN --stdout
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
`expand` performs deterministic import expansion and language-block filtering only. It does not update outputs, build-state, or build reports unless `--output` is explicitly provided.
|
|
98
|
+
|
|
99
|
+
### 4. Read The Build Report
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
cat .vasmc/build-report.yaml
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
After every `vasmc build`, an AI editor should immediately read `.vasmc/build-report.yaml`; the VASM skill interprets `entries[].actions` and top-level `actions`. The report records entries, outputs, compiled files, minimal-token variants, manifest summaries, dependencies, `policy.status`, policy diagnostics, and content signals. If `ai.projectReview` is enabled, `.vasmc/project-review-context.yaml` lists files the AI can inspect for project-aware suggestions.
|
|
106
|
+
|
|
107
|
+
### 5. Other Deterministic Commands
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
vasmc graph main.vasm.md
|
|
111
|
+
vasmc seal my-prompt.md --alias my-custom-name
|
|
112
|
+
vasmc seal "prompts/**/*.md" --format executable
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
`seal` injects VASM frontmatter into ordinary Markdown and renames files to `.vasm.md`. Use `--format informational` for documents such as README, HELP, and DESIGN. Use `--format executable` for system prompts and skills consumed by AI. Use `--format integrative` for composition guidance.
|
|
116
|
+
|
|
117
|
+
### Workspace Builds
|
|
118
|
+
|
|
119
|
+
```yaml
|
|
120
|
+
includes:
|
|
121
|
+
- "src/**/*.vasm.md"
|
|
122
|
+
|
|
123
|
+
output:
|
|
124
|
+
dir: "./dist"
|
|
125
|
+
|
|
126
|
+
baseDir: "./src"
|
|
127
|
+
|
|
128
|
+
compile:
|
|
129
|
+
informational:
|
|
130
|
+
targetLangs: ["en", "zh-CN"]
|
|
131
|
+
executable:
|
|
132
|
+
targetLangs: ["en"]
|
|
133
|
+
integrative:
|
|
134
|
+
targetLangs: ["en"]
|
|
135
|
+
|
|
136
|
+
routing:
|
|
137
|
+
- match: "src/agents/*.vasm.md"
|
|
138
|
+
dest: "./dist/agents/"
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
CLI overrides are also supported:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
vasmc build --out-dir ./doc --base-dir ./src
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
---
|
|
6
148
|
|
|
7
149
|
<a name="zh-cn"></a>
|
|
8
150
|
|
|
9
151
|
## 🇨🇳 中文
|
|
10
152
|
|
|
11
|
-
|
|
153
|
+
<a name="cli-zh-cn"></a>
|
|
154
|
+
|
|
155
|
+
## 🛠️ @vasm/cli:AI 编译与报告
|
|
12
156
|
|
|
13
|
-
|
|
157
|
+
`@vasm/cli` 提供 `vasmc` 命令,是 VASMC 的 AI-facing 编译入口。它只做确定性工作:依赖同步、AST 组装、语言块过滤、产物写入,以及生成给当前 AI 使用的结构化 report actions。
|
|
14
158
|
|
|
15
|
-
|
|
159
|
+
### 安装
|
|
16
160
|
|
|
17
|
-
|
|
161
|
+
```bash
|
|
162
|
+
npm install -g @vasm/cli
|
|
163
|
+
```
|
|
18
164
|
|
|
19
|
-
###
|
|
165
|
+
### 1. 初始化项目
|
|
20
166
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
* **交叉编译**: AST 级语言块过滤 (`<!-- lang:xx -->`) 生成各语种产物;未覆盖语种可自动唤起 LLM 交叉编译回译。
|
|
25
|
-
* **双模式引入**:
|
|
26
|
-
* `@import:link` — 别名重写为本地相对路径(保留超链接结构)。
|
|
27
|
-
* `@import:inline` — 内联展开远程内容(组装大型 Prompt 上下文)。
|
|
167
|
+
```bash
|
|
168
|
+
vasmc init
|
|
169
|
+
```
|
|
28
170
|
|
|
29
|
-
|
|
171
|
+
在工程根目录建立一个 `vasmc.yaml` 来声明依赖:
|
|
30
172
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
| `vasmc seal` | 确定性工具 | 为普通 Markdown 注入 Frontmatter |
|
|
39
|
-
| `vasmc sync` | 确定性工具 | 安装并锁定所有依赖 |
|
|
173
|
+
```yaml
|
|
174
|
+
dependencies:
|
|
175
|
+
company-rules: "https://example.com/guidelines.md"
|
|
176
|
+
coder-skill:
|
|
177
|
+
url: "https://example.com/coder-skill.md"
|
|
178
|
+
dest: "./skills/coder.md"
|
|
179
|
+
```
|
|
40
180
|
|
|
41
|
-
|
|
181
|
+
也可以直接使用命令行注册依赖:
|
|
42
182
|
|
|
43
183
|
```bash
|
|
44
|
-
|
|
45
|
-
vasmc init # 生成 vasmc-build.yaml
|
|
46
|
-
vasmc add https://example.com/skill.md --alias my-skill
|
|
47
|
-
vasmc build # 编译工作区
|
|
184
|
+
vasmc add https://example.com/coder-skill.md --alias coder-skill --dest ./skills/coder.md
|
|
48
185
|
```
|
|
49
186
|
|
|
50
|
-
|
|
187
|
+
### 2. 同步与锁定
|
|
51
188
|
|
|
52
|
-
|
|
189
|
+
将 `.vasmc/` 加入 `.gitignore`。这是 VASMC 的内部缓存目录。`vasmc-lock.yaml` 应提交到版本控制,它确保构建输入确定。
|
|
53
190
|
|
|
54
|
-
|
|
191
|
+
```gitignore
|
|
192
|
+
.vasmc/
|
|
193
|
+
```
|
|
55
194
|
|
|
56
|
-
|
|
195
|
+
安装所有缺失依赖并生成或更新锁文件:
|
|
57
196
|
|
|
58
|
-
|
|
197
|
+
```bash
|
|
198
|
+
vasmc sync
|
|
199
|
+
```
|
|
59
200
|
|
|
60
|
-
|
|
201
|
+
需要强制刷新时:
|
|
61
202
|
|
|
62
|
-
|
|
203
|
+
```bash
|
|
204
|
+
vasmc update <alias>
|
|
205
|
+
vasmc update
|
|
206
|
+
```
|
|
63
207
|
|
|
64
|
-
|
|
208
|
+
### 3. AI 编译
|
|
65
209
|
|
|
66
|
-
|
|
210
|
+
一对一编译并生成结构化报告:
|
|
67
211
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
* **Cross-Compilation**: AST-level language block filtering (`<!-- lang:xx -->`) generates artifacts for various languages; uncovered languages can automatically trigger LLM cross-compilation back-translation.
|
|
72
|
-
* **Dual-Mode Import**:
|
|
73
|
-
* `@import:link` — Alias rewritten to local relative paths (preserving hyperlink structure).
|
|
74
|
-
* `@import:inline` — Inline expansion of remote content (assembling large Prompt contexts).
|
|
212
|
+
```bash
|
|
213
|
+
vasmc build main.vasm.md -o ./dist
|
|
214
|
+
```
|
|
75
215
|
|
|
76
|
-
|
|
216
|
+
工作区编译并生成结构化报告:
|
|
77
217
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
| `vasmc diff` | LLM-Enhanced Tool | Semantic difference analysis between versions |
|
|
84
|
-
| `vasmc graph` | Deterministic Tool | ASCII dependency graph visualization |
|
|
85
|
-
| `vasmc seal` | Deterministic Tool | Inject Frontmatter into standard Markdown |
|
|
86
|
-
| `vasmc sync` | Deterministic Tool | Install and lock all dependencies |
|
|
218
|
+
```bash
|
|
219
|
+
vasmc build
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
`vasmc build` 是 AI 侧唯一编译入口。它会执行确定性的 AST 组装、语言块过滤和产物写入;如果目标语言缺失,它不会调用外部模型自动补全,而是在 `.vasmc/build-report.yaml` 的 `actions` 中记录后续工作,让当前 AI 通过 VASM skill 接管 Verify、Translate、Refresh Translation、Diff、Policy Review、Policy Gate、Project Review 和 Tree-Shake 等语义任务。对于 `informational` 输出,如果既有合并文档中已有旧目标语种段,VASMC 会保留它们并要求 AI 检查是否需要刷新。
|
|
87
223
|
|
|
88
|
-
|
|
224
|
+
常用控制参数:
|
|
89
225
|
|
|
90
226
|
```bash
|
|
91
|
-
|
|
92
|
-
vasmc
|
|
93
|
-
vasmc
|
|
94
|
-
vasmc build
|
|
227
|
+
vasmc build --dry-run
|
|
228
|
+
vasmc build main.vasm.md --dry-run --force
|
|
229
|
+
vasmc build --dry-run --report-out .vasmc/plan.yaml
|
|
230
|
+
vasmc build --force
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
`--dry-run` 会把 YAML report plan 输出到 stdout,不写编译产物、默认 `.vasmc/build-report.yaml`、project-review context、history cache 或 build-state。`--report-out` 表示显式把这份 plan 写入指定文件。`--force` 会忽略 build-state,强制重新生成未变化的 entry。
|
|
234
|
+
|
|
235
|
+
如果只需要一份展开稿,不想走 workspace routing 或 report actions:
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
vasmc expand main.vasm.md --target-lang zh-CN --stdout
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
`expand` 只做确定性的 import 展开和语言块筛选。除非显式传 `--output`,否则它不会写产物、build-state 或 build report。
|
|
242
|
+
|
|
243
|
+
### 4. 构建报告
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
cat .vasmc/build-report.yaml
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
每次执行 `vasmc build` 后,AI 编辑器都应立即读取 `.vasmc/build-report.yaml`,并由 VASM skill 按 report 中的 `actions` 顺序执行。report 会记录本次构建涉及的入口、产物、`compiledFiles`、`minimalTokenVariant`、manifest 摘要、依赖、`policy.status`、policy diagnostics 和 content signals,供 AI 做上下文与边界审查。若启用 `ai.projectReview`,`.vasmc/project-review-context.yaml` 会列出可供 AI 做项目感知建议的文件索引。
|
|
250
|
+
|
|
251
|
+
### 5. 其他确定性命令
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
vasmc graph main.vasm.md
|
|
255
|
+
vasmc seal my-prompt.md --alias my-custom-name
|
|
256
|
+
vasmc seal "prompts/**/*.md" --format executable
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
`seal` 会为普通 Markdown 注入 VASM Frontmatter,并将文件重命名为 `.vasm.md`。对于 README、HELP、DESIGN 等信息文档,请显式使用 `--format informational`;对于 System Prompt、Skill 等 AI 消费文件,请使用 `--format executable`;对于整合指导文件,请使用 `--format integrative`。
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
<a name="workspace-zh-cn"></a>
|
|
264
|
+
|
|
265
|
+
### 🗂️ 工作区批量编译
|
|
266
|
+
|
|
267
|
+
```yaml
|
|
268
|
+
includes:
|
|
269
|
+
- "src/**/*.vasm.md"
|
|
270
|
+
|
|
271
|
+
output:
|
|
272
|
+
dir: "./dist"
|
|
273
|
+
|
|
274
|
+
baseDir: "./src"
|
|
275
|
+
|
|
276
|
+
compile:
|
|
277
|
+
informational:
|
|
278
|
+
targetLangs: ["zh-CN"]
|
|
279
|
+
executable:
|
|
280
|
+
targetLangs: ["zh-CN"]
|
|
281
|
+
integrative:
|
|
282
|
+
targetLangs: ["zh-CN"]
|
|
283
|
+
|
|
284
|
+
routing:
|
|
285
|
+
- match: "src/agents/*.vasm.md"
|
|
286
|
+
dest: "./dist/agents/"
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
也支持 CLI 临时覆盖:
|
|
290
|
+
|
|
291
|
+
```bash
|
|
292
|
+
vasmc build --out-dir ./doc --base-dir ./src
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
注意:`--out-dir` 不是 dry-run。只要 source 命中 `routing`,最终写入路径仍由 `routing.dest` 决定。
|
|
296
|
+
|
|
297
|
+
<a name="cli-ai-build-zh-cn"></a>
|
|
298
|
+
|
|
299
|
+
## 🤖 AI Build 工作流
|
|
300
|
+
|
|
301
|
+
使用 AI 编辑器处理 VASM 项目时,VASMC 只负责确定性组装;语义校验、翻译、Diff 和裁剪由当前 AI 完成。当前 AI 助手应使用 AI 侧 build 执行编译:
|
|
302
|
+
|
|
303
|
+
```bash
|
|
304
|
+
vasmc build [file]
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
> **AI 编辑器始终使用 `vasmc build`。**
|
|
308
|
+
> 在 `@vasm/cli` 中,`build` 会同时产出确定性 Markdown 和 `.vasmc/build-report.yaml` 结构化 actions。
|
|
309
|
+
|
|
310
|
+
在该模式下,VASMC 执行 AST 静态组装,并在项目隐藏目录输出结构化报告:
|
|
311
|
+
|
|
312
|
+
**`.vasmc/build-report.yaml`**
|
|
313
|
+
|
|
314
|
+
**`.vasmc/project-review-context.yaml`**(仅在 `ai.projectReview` 开启时生成)
|
|
315
|
+
|
|
316
|
+
### AI 助手操作规程
|
|
317
|
+
|
|
318
|
+
每当你执行了 `vasmc build` 命令后,**立即读取 `.vasmc/build-report.yaml`**,并按 `entries[].actions` 与顶层 `actions` 顺序执行以下任务(具体步骤由编译器按需记录):
|
|
319
|
+
|
|
320
|
+
1. **Semantic Verify**:当 action 为 `verify` 时,读取 `minimalTokenVariant.path`,检查语义冲突、人格分裂、逻辑冗余和系统破坏风险四类问题。
|
|
321
|
+
2. **Integration Review**:当 action 为 `integration_review` 时,把目标文件当作组合指导,而不是最终可执行 prompt,检查组合边界是否清楚。
|
|
322
|
+
3. **Translation**:当 action 为 `translate` 时,将 `target` 文件翻译到 `targets` 指定的其他语种,**严格保留** Markdown AST 结构。
|
|
323
|
+
4. **Refresh Translation**:当 action 为 `refresh_translation` 时,检查 informational 输出中被保留的旧目标语种段是否仍匹配新 source,只更新过期译文。
|
|
324
|
+
5. **Semantic Diff**:当 action 为 `diff` 时,读取 `history` 中的历史备份文件,向用户说明本次编译在底层结构上影响了什么。
|
|
325
|
+
6. **Policy Review**:当 action 为 `policy_review` 时,检查 manifest、lockfile、format 边界 diagnostics,以及 `policy.contentSignals` 中需要语义判断的词面线索。
|
|
326
|
+
7. **Policy Gate**:当 action 为 `policy_gate` 时,说明确定性 policy 已发现阻断风险;在 `security.mode: enforce` 下,VASMC 不会更新 blocked 的 `executable` 或 `integrative` 输出。
|
|
327
|
+
8. **Project Review**:当顶层 action 为 `project_review` 时,读取 `.vasmc/project-review-context.yaml` 和 `.vasmc/build-report.yaml`,结合项目文件给出源文件级建议或 patch 建议,不能直接编辑生成物。
|
|
328
|
+
9. **Tree-Shake**:当 action 为 `tree_shake` 且用户明确表达了优化 Prompt 的意图时,才执行裁剪分析。
|
|
329
|
+
|
|
330
|
+
VASMC 负责确定性组装、路由和报告;当前 AI 负责语义判断、翻译和冲突处理。
|
|
331
|
+
|
|
332
|
+
### Policy 状态
|
|
333
|
+
|
|
334
|
+
`.vasmc/build-report.yaml` 中每个 entry 都包含 `policy.status`:
|
|
335
|
+
|
|
336
|
+
- `pass`:无确定性风险信号。
|
|
337
|
+
- `review`:允许输出,但 AI 必须审查 report 中的 diagnostics。
|
|
338
|
+
- `blocked`:存在可确定的阻断风险,例如 manifest 结构错误、format 边界错误或 lockfile hash 失配。默认 `review` 模式只报告;`enforce` 模式会阻止 blocked 的 `executable` 和 `integrative` 输出被更新。
|
|
339
|
+
|
|
340
|
+
`policy.contentSignals` 不改变 `policy.status`,也不会触发 enforce 阻断。AI 应判断 signal evidence 是 active instruction、prohibition、example 还是 documentation。
|
|
341
|
+
|
|
342
|
+
### Project Review
|
|
343
|
+
|
|
344
|
+
项目可以在 `vasmc-build.yaml` 中开启项目感知审查:
|
|
345
|
+
|
|
346
|
+
```yaml
|
|
347
|
+
ai:
|
|
348
|
+
projectReview:
|
|
349
|
+
mode: suggest
|
|
350
|
+
include:
|
|
351
|
+
- "README.md"
|
|
352
|
+
- "docs/**/*.md"
|
|
353
|
+
- "package.json"
|
|
95
354
|
```
|
|
96
355
|
|
|
97
|
-
|
|
356
|
+
这是 AI pass,不是编译器自动重写。VASMC 只生成上下文索引和 report action;当前 AI 根据索引读取项目文件,检查 prompt/skill 是否缺少项目实际命令、目录、术语、约束,`intent` 或 `compile.format` 是否准确,以及是否存在重复 fragment。
|