@vibe-forge/workspace-assets 0.8.0 → 0.9.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.
@@ -0,0 +1,204 @@
1
+ import { join } from 'node:path'
2
+ import { fileURLToPath } from 'node:url'
3
+
4
+ import { describe, expect, it } from 'vitest'
5
+
6
+ import type { Config } from '@vibe-forge/types'
7
+
8
+ import { buildAdapterAssetPlan, resolvePromptAssetSelection, resolveWorkspaceAssetBundle } from '#~/index.js'
9
+
10
+ import { serializeWorkspaceAssetsSnapshot } from './snapshot'
11
+ import { createWorkspace, installPluginPackage, writeDocument } from './test-helpers'
12
+
13
+ const resolveSnapshotPath = (name: string) => (
14
+ fileURLToPath(new URL(`./__snapshots__/${name}.snapshot.json`, import.meta.url))
15
+ )
16
+
17
+ describe('workspace assets snapshots', () => {
18
+ it('projects a rich workspace bundle, prompt selection, and adapter plans', async () => {
19
+ const workspace = await createWorkspace()
20
+
21
+ const projectConfig: Config = {
22
+ plugins: [
23
+ {
24
+ id: 'logger'
25
+ },
26
+ {
27
+ id: 'demo',
28
+ scope: 'demo'
29
+ }
30
+ ],
31
+ mcpServers: {
32
+ docs: {
33
+ command: 'npx',
34
+ args: ['docs-server']
35
+ }
36
+ },
37
+ defaultIncludeMcpServers: ['docs', 'demo/browser']
38
+ }
39
+
40
+ const userConfig: Config = {
41
+ plugins: [
42
+ {
43
+ id: 'telemetry',
44
+ options: {
45
+ mode: 'summary'
46
+ }
47
+ }
48
+ ],
49
+ mcpServers: {
50
+ notes: {
51
+ command: 'node',
52
+ args: ['tools/notes-mcp.js']
53
+ }
54
+ },
55
+ defaultExcludeMcpServers: ['notes']
56
+ }
57
+
58
+ await installPluginPackage(workspace, '@vibe-forge/plugin-demo', {
59
+ 'package.json': JSON.stringify({
60
+ name: '@vibe-forge/plugin-demo',
61
+ version: '1.0.0'
62
+ }, null, 2),
63
+ 'hooks.js': 'module.exports = {}\n',
64
+ 'rules/security.md': [
65
+ '---',
66
+ 'description: 插件安全规则',
67
+ '---',
68
+ '上线前要检查权限与密钥暴露。'
69
+ ].join('\n'),
70
+ 'specs/release/index.md': [
71
+ '---',
72
+ 'description: 插件发布流程',
73
+ '---',
74
+ '插件 release 不应直接替代项目 release。'
75
+ ].join('\n'),
76
+ 'skills/audit/SKILL.md': [
77
+ '---',
78
+ 'description: 审计输出',
79
+ '---',
80
+ '检查最终输出是否覆盖风险项。'
81
+ ].join('\n'),
82
+ 'mcp/browser.json': JSON.stringify(
83
+ {
84
+ name: 'browser',
85
+ command: 'npx',
86
+ args: ['browser-mcp']
87
+ },
88
+ null,
89
+ 2
90
+ ),
91
+ 'opencode/agents/release-helper.md': '# release-helper\n',
92
+ 'opencode/commands/review.md': '# review\n',
93
+ 'opencode/modes/strict.md': '# strict\n',
94
+ 'opencode/plugins/demo-plugin.js': 'export default {}\n'
95
+ })
96
+ await installPluginPackage(workspace, '@vibe-forge/plugin-logger', {
97
+ 'package.json': JSON.stringify({
98
+ name: '@vibe-forge/plugin-logger',
99
+ version: '1.0.0'
100
+ }, null, 2),
101
+ 'hooks.js': 'module.exports = {}\n'
102
+ })
103
+ await installPluginPackage(workspace, '@vibe-forge/plugin-telemetry', {
104
+ 'package.json': JSON.stringify({
105
+ name: '@vibe-forge/plugin-telemetry',
106
+ version: '1.0.0'
107
+ }, null, 2),
108
+ 'hooks.js': 'module.exports = {}\n'
109
+ })
110
+
111
+ await writeDocument(
112
+ join(workspace, '.ai/rules/review.md'),
113
+ [
114
+ '---',
115
+ 'description: 项目评审规则',
116
+ 'always: true',
117
+ '---',
118
+ '必须检查发布改动的回归风险。'
119
+ ].join('\n')
120
+ )
121
+ await writeDocument(
122
+ join(workspace, '.ai/specs/release/index.md'),
123
+ [
124
+ '---',
125
+ 'description: 正式发布流程',
126
+ 'rules:',
127
+ ' - .ai/rules/review.md',
128
+ 'skills:',
129
+ ' - research',
130
+ 'mcpServers:',
131
+ ' include:',
132
+ ' - docs',
133
+ ' - demo/browser',
134
+ ' exclude:',
135
+ ' - demo/browser',
136
+ 'tools:',
137
+ ' include:',
138
+ ' - Read',
139
+ ' - Edit',
140
+ '---',
141
+ '执行正式发布,并整理变更摘要。'
142
+ ].join('\n')
143
+ )
144
+ await writeDocument(
145
+ join(workspace, '.ai/entities/architect/README.md'),
146
+ [
147
+ '---',
148
+ 'description: 负责拆解方案的实体',
149
+ '---',
150
+ '把发布任务拆解成执行步骤。'
151
+ ].join('\n')
152
+ )
153
+ await writeDocument(
154
+ join(workspace, '.ai/skills/research/SKILL.md'),
155
+ [
156
+ '---',
157
+ 'description: 检索资料',
158
+ '---',
159
+ '先阅读 README.md,再补充结论。'
160
+ ].join('\n')
161
+ )
162
+
163
+ const bundle = await resolveWorkspaceAssetBundle({
164
+ cwd: workspace,
165
+ configs: [projectConfig, userConfig],
166
+ useDefaultVibeForgeMcpServer: false
167
+ })
168
+ const [resolution, options] = await resolvePromptAssetSelection({
169
+ bundle,
170
+ type: 'spec',
171
+ name: 'release',
172
+ input: {
173
+ skills: {
174
+ include: ['research']
175
+ }
176
+ }
177
+ })
178
+
179
+ const adapters = ['claude-code', 'codex', 'opencode'] as const
180
+ const plans = adapters.map(adapter => (
181
+ buildAdapterAssetPlan({
182
+ adapter,
183
+ bundle,
184
+ options: {
185
+ promptAssetIds: options.promptAssetIds,
186
+ mcpServers: options.mcpServers,
187
+ skills: {
188
+ include: ['research']
189
+ }
190
+ }
191
+ })
192
+ ))
193
+
194
+ await expect(serializeWorkspaceAssetsSnapshot({
195
+ cwd: workspace,
196
+ bundle,
197
+ selection: {
198
+ resolution,
199
+ options
200
+ },
201
+ plans
202
+ })).toMatchFileSnapshot(resolveSnapshotPath('workspace-assets-rich'))
203
+ })
204
+ })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibe-forge/workspace-assets",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "Workspace asset resolution and adapter asset planning for Vibe Forge",
5
5
  "imports": {
6
6
  "#~/*.js": {
@@ -27,11 +27,11 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "fast-glob": "^3.3.3",
30
+ "front-matter": "^4.0.2",
30
31
  "js-yaml": "^4.1.1",
31
- "@vibe-forge/config": "^0.8.0",
32
- "@vibe-forge/definition-loader": "^0.8.0",
33
- "@vibe-forge/utils": "^0.8.0",
34
- "@vibe-forge/types": "^0.8.0"
32
+ "@vibe-forge/types": "^0.9.0",
33
+ "@vibe-forge/utils": "^0.9.0",
34
+ "@vibe-forge/config": "^0.9.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/js-yaml": "^4.0.9"