opencode-onboard 0.4.10 → 0.4.11
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/package.json
CHANGED
|
@@ -43,6 +43,11 @@ export async function fixCodegraphConfig() {
|
|
|
43
43
|
|
|
44
44
|
const rogueMcp = rogueContent.mcpServers || rogueContent.mcp
|
|
45
45
|
if (rogueMcp) {
|
|
46
|
+
for (const entry of Object.values(rogueMcp)) {
|
|
47
|
+
if (Array.isArray(entry.command) && entry.command[0] === 'codegraph') {
|
|
48
|
+
entry.command = ['npx', ...entry.command]
|
|
49
|
+
}
|
|
50
|
+
}
|
|
46
51
|
correctContent.mcp = { ...(correctContent.mcp || {}), ...rogueMcp }
|
|
47
52
|
}
|
|
48
53
|
|
|
@@ -38,7 +38,7 @@ describe('fixCodegraphConfig()', () => {
|
|
|
38
38
|
it('merges mcpServers from opencode.jsonc into .opencode/opencode.json as mcp', async () => {
|
|
39
39
|
const rogueContent = {
|
|
40
40
|
mcpServers: {
|
|
41
|
-
codegraph: { command: 'codegraph',
|
|
41
|
+
codegraph: { command: ['codegraph', 'serve', '--mcp'] }
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
fs.writeFileSync(path.join(tmpDir, 'opencode.jsonc'), JSON.stringify(rogueContent))
|
|
@@ -55,14 +55,14 @@ describe('fixCodegraphConfig()', () => {
|
|
|
55
55
|
expect(result).toBe(true)
|
|
56
56
|
expect(fs.existsSync(path.join(tmpDir, 'opencode.jsonc'))).toBe(false)
|
|
57
57
|
const readResult = await fse.readJson(path.join(opencodeDir, 'opencode.json'))
|
|
58
|
-
expect(readResult.mcp.codegraph).toEqual({ command: 'codegraph',
|
|
58
|
+
expect(readResult.mcp.codegraph).toEqual({ command: ['npx', 'codegraph', 'serve', '--mcp'] })
|
|
59
59
|
expect(readResult.plugin).toEqual(["opencode-plugin-openspec@latest"])
|
|
60
60
|
})
|
|
61
61
|
|
|
62
62
|
it('handles rogue file with mcp key directly', async () => {
|
|
63
63
|
const rogueContent = {
|
|
64
64
|
mcp: {
|
|
65
|
-
codegraph: { command: 'codegraph',
|
|
65
|
+
codegraph: { command: ['codegraph', 'serve', '--mcp'] }
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
fs.writeFileSync(path.join(tmpDir, 'opencode.jsonc'), JSON.stringify(rogueContent))
|
|
@@ -74,14 +74,14 @@ describe('fixCodegraphConfig()', () => {
|
|
|
74
74
|
expect(result).toBe(true)
|
|
75
75
|
expect(fs.existsSync(path.join(tmpDir, 'opencode.jsonc'))).toBe(false)
|
|
76
76
|
const readResult = await fse.readJson(path.join(tmpDir, '.opencode', 'opencode.json'))
|
|
77
|
-
expect(readResult.mcp.codegraph.command).
|
|
77
|
+
expect(readResult.mcp.codegraph.command).toEqual(['npx', 'codegraph', 'serve', '--mcp'])
|
|
78
78
|
})
|
|
79
79
|
|
|
80
80
|
it('handles JSONC with comments', async () => {
|
|
81
81
|
const rogueRaw = `{
|
|
82
82
|
// This is a comment
|
|
83
83
|
"mcpServers": {
|
|
84
|
-
"codegraph": { "command": "codegraph", "
|
|
84
|
+
"codegraph": { "command": ["codegraph", "serve", "--mcp"] }
|
|
85
85
|
}
|
|
86
86
|
}`
|
|
87
87
|
fs.writeFileSync(path.join(tmpDir, 'opencode.jsonc'), rogueRaw)
|
|
@@ -95,14 +95,14 @@ describe('fixCodegraphConfig()', () => {
|
|
|
95
95
|
expect(result).toBe(true)
|
|
96
96
|
expect(fs.existsSync(path.join(tmpDir, 'opencode.jsonc'))).toBe(false)
|
|
97
97
|
const readResult = await fse.readJson(path.join(opencodeDir, 'opencode.json'))
|
|
98
|
-
expect(readResult.mcp.codegraph.command).
|
|
98
|
+
expect(readResult.mcp.codegraph.command).toEqual(['npx', 'codegraph', 'serve', '--mcp'])
|
|
99
99
|
})
|
|
100
100
|
|
|
101
101
|
it('handles JSONC with URLs containing //', async () => {
|
|
102
102
|
const rogueRaw = `{
|
|
103
103
|
"url": "https://example.com/path",
|
|
104
104
|
"mcpServers": {
|
|
105
|
-
"codegraph": { "command": "codegraph", "
|
|
105
|
+
"codegraph": { "command": ["codegraph", "serve", "--mcp"] }
|
|
106
106
|
}
|
|
107
107
|
}`
|
|
108
108
|
fs.writeFileSync(path.join(tmpDir, 'opencode.jsonc'), rogueRaw)
|
|
@@ -118,7 +118,7 @@ describe('fixCodegraphConfig()', () => {
|
|
|
118
118
|
expect(result).toBe(true)
|
|
119
119
|
expect(fs.existsSync(path.join(tmpDir, 'opencode.jsonc'))).toBe(false)
|
|
120
120
|
const readResult = await fse.readJson(path.join(opencodeDir, 'opencode.json'))
|
|
121
|
-
expect(readResult.mcp.codegraph.command).
|
|
121
|
+
expect(readResult.mcp.codegraph.command).toEqual(['npx', 'codegraph', 'serve', '--mcp'])
|
|
122
122
|
})
|
|
123
123
|
|
|
124
124
|
it('removes unparseable opencode.jsonc, warns, and returns false', async () => {
|
|
@@ -134,7 +134,7 @@ describe('fixCodegraphConfig()', () => {
|
|
|
134
134
|
it('creates .opencode/opencode.json if it does not exist', async () => {
|
|
135
135
|
const rogueContent = {
|
|
136
136
|
mcpServers: {
|
|
137
|
-
codegraph: { command: 'codegraph',
|
|
137
|
+
codegraph: { command: ['codegraph', 'serve', '--mcp'] }
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
fs.writeFileSync(path.join(tmpDir, 'opencode.jsonc'), JSON.stringify(rogueContent))
|
|
@@ -143,7 +143,24 @@ describe('fixCodegraphConfig()', () => {
|
|
|
143
143
|
|
|
144
144
|
expect(result).toBe(true)
|
|
145
145
|
const readResult = await fse.readJson(path.join(tmpDir, '.opencode', 'opencode.json'))
|
|
146
|
-
expect(readResult.mcp.codegraph.command).
|
|
146
|
+
expect(readResult.mcp.codegraph.command).toEqual(['npx', 'codegraph', 'serve', '--mcp'])
|
|
147
147
|
expect(fs.existsSync(path.join(tmpDir, 'opencode.jsonc'))).toBe(false)
|
|
148
148
|
})
|
|
149
|
+
|
|
150
|
+
it('does not prepend npx to non-codegraph commands', async () => {
|
|
151
|
+
const rogueContent = {
|
|
152
|
+
mcpServers: {
|
|
153
|
+
myMcp: { command: ['my-own-mcp', 'serve'] }
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
fs.writeFileSync(path.join(tmpDir, 'opencode.jsonc'), JSON.stringify(rogueContent))
|
|
157
|
+
fs.mkdirSync(path.join(tmpDir, '.opencode'), { recursive: true })
|
|
158
|
+
fs.writeFileSync(path.join(tmpDir, '.opencode', 'opencode.json'), '{}')
|
|
159
|
+
|
|
160
|
+
const result = await fixCodegraphConfig()
|
|
161
|
+
|
|
162
|
+
expect(result).toBe(true)
|
|
163
|
+
const readResult = await fse.readJson(path.join(tmpDir, '.opencode', 'opencode.json'))
|
|
164
|
+
expect(readResult.mcp.myMcp.command).toEqual(['my-own-mcp', 'serve'])
|
|
165
|
+
})
|
|
149
166
|
})
|