@vasm/core 0.6.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 ADDED
@@ -0,0 +1,7 @@
1
+ # @vasm/core
2
+
3
+ ## 0.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Strengthen activation governance and split the published VASMC packages into fixed-version core, CLI, and console artifacts.
package/README.md ADDED
@@ -0,0 +1,150 @@
1
+ # @vasm/core
2
+
3
+ `@vasm/core` 是 VASMC 的确定性编译核心。它承载 VASM 协议解析、Frontmatter 处理、依赖图遍历、`@import` 展开、语言块过滤、工作区构建和输出合并逻辑。
4
+
5
+ 这个包不包含外部模型 SDK,不读取 `llm` 配置,也不执行语义校验或自动翻译。需要人类辅助的 LLM 工具时,请使用 `@vasm/console`;需要给 AI 编辑器生成工作单时,请使用 `@vasm/cli` 的 `vasmc build`。
6
+
7
+ <a name="syntax"></a>
8
+
9
+ ## 🔮 核心语法与引入协议 (Core Syntax)
10
+
11
+ ### 引入语法
12
+
13
+ `[链接文本](vasm:alias "@vasm-directive")`
14
+
15
+ * **链接重写模式 (`@import:link`)**:
16
+ 编译器将 `vasm:alias` 替换为目标文件的本地相对物理路径,保留超链接结构。
17
+ ```markdown
18
+ 请参阅下方的 [代码审查辅助技能](vasm:coder-skill "@import:link")。
19
+ ```
20
+ *构建输出*: `请参阅下方的 [代码审查辅助技能](./skills/coder.md)。`
21
+
22
+ * **内联展开模式 (`@import:inline`)**:
23
+ 编译器读取目标文件的纯文本内容,并直接替换该引用链接。主要用于组装大型 Prompt 上下文。
24
+ ```markdown
25
+ 根据本组织的 [公司开发规范](vasm:company-rules "@import:inline"):
26
+ ```
27
+ *构建输出*: 原始链接被移除,并在原位置插入 `guidelines.md` 的完整文本内容。
28
+
29
+ ### 原生多语种交叉编译 (Cross-Compilation)
30
+
31
+ VASMC 支持使用 AST 指令对 Prompt 进行原生多语言支持:
32
+
33
+ ```markdown
34
+ # 通用系统规则
35
+ 你是一个代码专家。
36
+
37
+ <!-- lang:en -->
38
+ Please explain the code step by step.
39
+ <!-- /lang -->
40
+
41
+ <!-- lang:zh-CN -->
42
+ 请逐步解释代码。
43
+ <!-- /lang -->
44
+ ```
45
+
46
+ 生成时,使用 `--target-langs` 参数指定你需要生成的语言。VASMC 会自动过滤 AST 树,分别输出纯净的各语言产物。
47
+
48
+ ***
49
+
50
+ <a name="publish"></a>
51
+
52
+ ## 📦 发布模块 (Frontmatter 注入)
53
+
54
+ 如果您通过公共 URL 分发提示词模块,强烈建议在 `.md` 文件顶部添加 YAML Frontmatter 块,声明正式别名和嵌套依赖项。
55
+
56
+ 手动注入内容的示例:
57
+
58
+ ```yaml
59
+ ---
60
+ vasm:
61
+ alias: "my-coder-prompt"
62
+ version: "1.0.0"
63
+ dependencies:
64
+ anti-delusion: "https://example.com/system.md"
65
+ compile:
66
+ format: prompt # prompt(AI 消费)| doc(人类文档)
67
+ targetLangs: ["zh-CN"]
68
+ kind: skill # prompt | skill | doc | policy | fragment
69
+ scope:
70
+ domains: ["code-review", "security"]
71
+ filePatterns: ["**/*.ts", "**/*.js"]
72
+ capabilities:
73
+ readFiles: true
74
+ editFiles: false
75
+ runCommands: false
76
+ network: false
77
+ externalModels: false
78
+ publish: false
79
+ activation:
80
+ intent: ["review", "security audit"]
81
+ priority: 80
82
+ conflictsWith: ["general-code-reviewer"]
83
+ trust:
84
+ source: "github:example/coder-prompt"
85
+ license: "MIT"
86
+ vision: |
87
+ 产物应形成一个严格的代码审查专家角色,专注于安全漏洞检测,
88
+ 输出结构化(级别/位置/描述/建议),风格简洁,不扮演开发者。
89
+ fix: suggest # suggest(默认,输出建议)| auto(直接编辑产物并报告)
90
+ ---
91
+
92
+ # 你的 Prompt 正文内容...
93
+ ```
94
+
95
+ *当其他人通过 `vasmc add <your-url>` 安装时,VASMC 会自动解析这些内容并完美还原环境。*
96
+
97
+ > **`vision`**:声明编译产物应达到的语义目标。`vasmc build` 执行时,AI 协调器将对照此目标对产物进行意图对齐验证(语义编译的 Verify Pass)。
98
+ >
99
+ > **`fix`**:控制发现问题时的修复策略——`suggest` 仅列出建议等待用户确认,`auto` 直接修改产物文件并输出变更摘要。仅对 `prompt` 格式文件有效。
100
+ >
101
+ > **Skill 治理字段**:`kind: skill` 会启用更严格的 manifest 诊断。`scope` 描述适用领域和文件范围,`capabilities` 显式声明该 skill 预期使用的能力边界,`activation` 描述何时应被选择以及与哪些 skill 冲突,`trust` 记录供应链来源和许可证。诊断结果会写入 `.vasmc/build-report.yaml`,必要时也会进入 `.vasmc/build-instructions.md` 的 Policy Review 工作项。
102
+
103
+ ### 确定性 Policy Gate
104
+
105
+ AI 侧 `vasmc build` 会为每个 entry 生成 `policy.status`:
106
+
107
+ * `pass`:未发现确定性 policy 风险。
108
+ * `review`:存在需要 AI 或人类阅读的风险信号,例如高危能力声明、过宽 activation、activation 冲突/抢占、疑似 prompt override 语句。
109
+ * `blocked`:存在确定性阻断风险,例如 manifest 结构错误、远程依赖 hash 与 `vasmc-lock.yaml` 不一致、依赖声明了入口 skill 未声明的 capability。
110
+
111
+ 默认情况下,VASMC 只报告风险,不阻断输出:
112
+
113
+ ```yaml
114
+ security:
115
+ mode: review
116
+ ```
117
+
118
+ 如果项目希望启用本地确定性阻断,可以在 `vasmc-build.yaml` 中切换为:
119
+
120
+ ```yaml
121
+ security:
122
+ mode: enforce
123
+ ```
124
+
125
+ `enforce` 只会阻止可执行 skill 类产物被更新;普通文档仍按确定性编译流程输出。被阻断时,`.vasmc/build-report.yaml` 会记录 `status: blocked`,`.vasmc/build-instructions.md` 会生成 **Policy Gate** 工作项。
126
+
127
+ Activation 治理会检查当前 entry 与其依赖图中的 skill:
128
+
129
+ * `activation.intent` 过宽或多个 skill 声明相同 intent,会进入 `review`。
130
+ * 依赖 skill 与入口 skill 共享 intent,会进入 `review`,避免路由含义不清。
131
+ * 依赖 skill 在相同 intent 上拥有更高 priority,会进入 `review`,提示潜在抢占风险。
132
+ * `activation.conflictsWith` 命中入口 skill 或入口声明的冲突对象,会进入 `review`。
133
+
134
+ ### Project Review Pass
135
+
136
+ VASMC 可以在编译完成后生成一个项目上下文索引,让当前 AI 主动结合仓库内容审查编译产物是否贴合项目,而不是只做传统的语法编译:
137
+
138
+ ```yaml
139
+ ai:
140
+ projectReview:
141
+ mode: suggest # off | suggest | patch
142
+ include:
143
+ - "README.md"
144
+ - "docs/**/*.md"
145
+ - "package.json"
146
+ - "vasmc-build.yaml"
147
+ - "skill-src/**/*.vasm.md"
148
+ ```
149
+
150
+ 开启后,`vasmc build` 会生成 `.vasmc/project-review-context.yaml`,并在 `.vasmc/build-instructions.md` 中加入 **Project Review** 工作项。该 pass 不调用模型,也不自动改文件;它只告诉当前 AI 应读取哪些项目文件,并要求 AI 输出源文件级建议。`patch` 模式表示可以给出聚焦的源文件 patch 建议,但仍不得直接编辑生成物。