opencode-onboard 0.4.9 → 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-onboard",
3
- "version": "0.4.9",
3
+ "version": "0.4.11",
4
4
  "description": "Prepare any brownfield codebase for AI agent workflows using OpenCode, OpenSpec, and ensemble orchestration.",
5
5
  "keywords": [
6
6
  "opencode",
@@ -41,9 +41,14 @@ export async function fixCodegraphConfig() {
41
41
  }
42
42
  }
43
43
 
44
- if (rogueContent.mcpServers || rogueContent.mcp) {
45
- const mcpServers = rogueContent.mcpServers || rogueContent.mcp
46
- correctContent.mcpServers = { ...(correctContent.mcpServers || {}), ...mcpServers }
44
+ const rogueMcp = rogueContent.mcpServers || rogueContent.mcp
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
+ }
51
+ correctContent.mcp = { ...(correctContent.mcp || {}), ...rogueMcp }
47
52
  }
48
53
 
49
54
  await fse.ensureDir(path.dirname(correctFile))
@@ -93,7 +98,7 @@ export async function installCodegraph(options = {}) {
93
98
  loading('initializing codegraph project index...')
94
99
 
95
100
  try {
96
- const initResult = await execa('codegraph', ['init'], {
101
+ const initResult = await execa('npx', ['codegraph', 'init'], {
97
102
  cwd: process.cwd(),
98
103
  reject: false,
99
104
  stdio: 'pipe',
@@ -35,10 +35,10 @@ describe('fixCodegraphConfig()', () => {
35
35
  expect(fs.existsSync(path.join(tmpDir, '.opencode', 'opencode.json'))).toBe(false)
36
36
  })
37
37
 
38
- it('merges mcpServers from opencode.jsonc into .opencode/opencode.json', async () => {
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', args: ['mcp'] }
41
+ codegraph: { command: ['codegraph', 'serve', '--mcp'] }
42
42
  }
43
43
  }
44
44
  fs.writeFileSync(path.join(tmpDir, 'opencode.jsonc'), JSON.stringify(rogueContent))
@@ -55,15 +55,33 @@ 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.mcpServers.codegraph).toEqual({ command: 'codegraph', args: ['mcp'] })
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
+ it('handles rogue file with mcp key directly', async () => {
63
+ const rogueContent = {
64
+ mcp: {
65
+ codegraph: { command: ['codegraph', 'serve', '--mcp'] }
66
+ }
67
+ }
68
+ fs.writeFileSync(path.join(tmpDir, 'opencode.jsonc'), JSON.stringify(rogueContent))
69
+ fs.mkdirSync(path.join(tmpDir, '.opencode'), { recursive: true })
70
+ fs.writeFileSync(path.join(tmpDir, '.opencode', 'opencode.json'), '{}')
71
+
72
+ const result = await fixCodegraphConfig()
73
+
74
+ expect(result).toBe(true)
75
+ expect(fs.existsSync(path.join(tmpDir, 'opencode.jsonc'))).toBe(false)
76
+ const readResult = await fse.readJson(path.join(tmpDir, '.opencode', 'opencode.json'))
77
+ expect(readResult.mcp.codegraph.command).toEqual(['npx', 'codegraph', 'serve', '--mcp'])
78
+ })
79
+
62
80
  it('handles JSONC with comments', async () => {
63
81
  const rogueRaw = `{
64
82
  // This is a comment
65
83
  "mcpServers": {
66
- "codegraph": { "command": "codegraph", "args": ["mcp"] }
84
+ "codegraph": { "command": ["codegraph", "serve", "--mcp"] }
67
85
  }
68
86
  }`
69
87
  fs.writeFileSync(path.join(tmpDir, 'opencode.jsonc'), rogueRaw)
@@ -77,14 +95,14 @@ describe('fixCodegraphConfig()', () => {
77
95
  expect(result).toBe(true)
78
96
  expect(fs.existsSync(path.join(tmpDir, 'opencode.jsonc'))).toBe(false)
79
97
  const readResult = await fse.readJson(path.join(opencodeDir, 'opencode.json'))
80
- expect(readResult.mcpServers.codegraph.command).toBe('codegraph')
98
+ expect(readResult.mcp.codegraph.command).toEqual(['npx', 'codegraph', 'serve', '--mcp'])
81
99
  })
82
100
 
83
101
  it('handles JSONC with URLs containing //', async () => {
84
102
  const rogueRaw = `{
85
103
  "url": "https://example.com/path",
86
104
  "mcpServers": {
87
- "codegraph": { "command": "codegraph", "args": ["mcp"] }
105
+ "codegraph": { "command": ["codegraph", "serve", "--mcp"] }
88
106
  }
89
107
  }`
90
108
  fs.writeFileSync(path.join(tmpDir, 'opencode.jsonc'), rogueRaw)
@@ -100,7 +118,7 @@ describe('fixCodegraphConfig()', () => {
100
118
  expect(result).toBe(true)
101
119
  expect(fs.existsSync(path.join(tmpDir, 'opencode.jsonc'))).toBe(false)
102
120
  const readResult = await fse.readJson(path.join(opencodeDir, 'opencode.json'))
103
- expect(readResult.mcpServers.codegraph.command).toBe('codegraph')
121
+ expect(readResult.mcp.codegraph.command).toEqual(['npx', 'codegraph', 'serve', '--mcp'])
104
122
  })
105
123
 
106
124
  it('removes unparseable opencode.jsonc, warns, and returns false', async () => {
@@ -116,7 +134,7 @@ describe('fixCodegraphConfig()', () => {
116
134
  it('creates .opencode/opencode.json if it does not exist', async () => {
117
135
  const rogueContent = {
118
136
  mcpServers: {
119
- codegraph: { command: 'codegraph', args: ['mcp'] }
137
+ codegraph: { command: ['codegraph', 'serve', '--mcp'] }
120
138
  }
121
139
  }
122
140
  fs.writeFileSync(path.join(tmpDir, 'opencode.jsonc'), JSON.stringify(rogueContent))
@@ -125,7 +143,24 @@ describe('fixCodegraphConfig()', () => {
125
143
 
126
144
  expect(result).toBe(true)
127
145
  const readResult = await fse.readJson(path.join(tmpDir, '.opencode', 'opencode.json'))
128
- expect(readResult.mcpServers.codegraph.command).toBe('codegraph')
146
+ expect(readResult.mcp.codegraph.command).toEqual(['npx', 'codegraph', 'serve', '--mcp'])
129
147
  expect(fs.existsSync(path.join(tmpDir, 'opencode.jsonc'))).toBe(false)
130
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
+ })
131
166
  })