opencode-onboard 0.4.9 → 0.4.10

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.10",
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,9 @@ 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
+ correctContent.mcp = { ...(correctContent.mcp || {}), ...rogueMcp }
47
47
  }
48
48
 
49
49
  await fse.ensureDir(path.dirname(correctFile))
@@ -93,7 +93,7 @@ export async function installCodegraph(options = {}) {
93
93
  loading('initializing codegraph project index...')
94
94
 
95
95
  try {
96
- const initResult = await execa('codegraph', ['init'], {
96
+ const initResult = await execa('npx', ['codegraph', 'init'], {
97
97
  cwd: process.cwd(),
98
98
  reject: false,
99
99
  stdio: 'pipe',
@@ -35,7 +35,7 @@ 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
41
  codegraph: { command: 'codegraph', args: ['mcp'] }
@@ -55,10 +55,28 @@ 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: 'codegraph', args: ['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', args: ['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).toBe('codegraph')
78
+ })
79
+
62
80
  it('handles JSONC with comments', async () => {
63
81
  const rogueRaw = `{
64
82
  // This is a comment
@@ -77,7 +95,7 @@ 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).toBe('codegraph')
81
99
  })
82
100
 
83
101
  it('handles JSONC with URLs containing //', async () => {
@@ -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).toBe('codegraph')
104
122
  })
105
123
 
106
124
  it('removes unparseable opencode.jsonc, warns, and returns false', async () => {
@@ -125,7 +143,7 @@ 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).toBe('codegraph')
129
147
  expect(fs.existsSync(path.join(tmpDir, 'opencode.jsonc'))).toBe(false)
130
148
  })
131
149
  })