konoha-mcp 2.1.9 → 2.1.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.
@@ -44,6 +44,13 @@ function isCommandCodeInstalled() {
44
44
  );
45
45
  }
46
46
 
47
+ function validateAgentName(name, targetDir) {
48
+ if (typeof name !== 'string' || !/^[a-zA-Z0-9_-]+$/.test(name)) return false;
49
+ const target = path.resolve(targetDir, `${name}.md`);
50
+ const parent = path.resolve(targetDir);
51
+ return target.startsWith(parent + path.sep);
52
+ }
53
+
47
54
 
48
55
  function resolveRtkRuleTemplate() {
49
56
  const candidates = [
@@ -127,7 +134,7 @@ function resolveAislopMcpConfig() {
127
134
  type: 'stdio',
128
135
  command: binPath,
129
136
  args: [],
130
- autoApprove: ['*', 'aislop_scan', 'aislop_fix', 'aislop_why', 'aislop_baseline'],
137
+ autoApprove: ['aislop_scan', 'aislop_fix', 'aislop_why', 'aislop_baseline'],
131
138
  auto_approve: true
132
139
  };
133
140
  }
@@ -136,8 +143,8 @@ function resolveAislopMcpConfig() {
136
143
  return {
137
144
  type: 'stdio',
138
145
  command: isWin ? 'npx.cmd' : 'npx',
139
- args: ['-y', '--prefer-offline', '-p', 'aislop', 'aislop-mcp'],
140
- autoApprove: ['*', 'aislop_scan', 'aislop_fix', 'aislop_why', 'aislop_baseline'],
146
+ args: ['-y', '--prefer-offline', '-p', 'aislop@0.18.1', 'aislop-mcp'],
147
+ autoApprove: ['aislop_scan', 'aislop_fix', 'aislop_why', 'aislop_baseline'],
141
148
  auto_approve: true
142
149
  };
143
150
  }
@@ -165,8 +172,8 @@ function buildStdioMcpServers(options = {}) {
165
172
  semble: {
166
173
  type: 'stdio',
167
174
  command: uvxCmd,
168
- args: ['--from', 'semble[mcp]@latest', 'semble', '--content', 'all'],
169
- autoApprove: ['*', 'search', 'find_related'],
175
+ args: ['--from', 'semble[mcp]==0.6.2', 'semble', '--content', 'all'],
176
+ autoApprove: ['search', 'find_related'],
170
177
  auto_approve: true
171
178
  }
172
179
  } : {}),
@@ -175,7 +182,9 @@ function buildStdioMcpServers(options = {}) {
175
182
  if (fileExists(FILE_TOOLS_MCP_PATH)) {
176
183
  const entry = deployUtils.buildKonohaFilesMcpEntry(client);
177
184
  if (entry) {
178
- entry.autoApprove = ['*'];
185
+ entry.autoApprove = deployUtils.KONOHA_CANONICAL_TOOLS
186
+ ? [...deployUtils.KONOHA_CANONICAL_TOOLS]
187
+ : [];
179
188
  entry.auto_approve = true;
180
189
  servers['konoha'] = entry;
181
190
  }
@@ -298,12 +307,18 @@ function registerCommandCodeGlobalMcp(pythonCmd, serverPath, uvxCmd, silent = tr
298
307
  return true;
299
308
  }
300
309
 
310
+ function buildClientToolGrants(prefix) {
311
+ const tools = deployUtils.KONOHA_CANONICAL_TOOLS || [];
312
+ const sep = prefix === 'mcp__' ? '__' : ':';
313
+ const konohaGrants = tools.map(t => `${prefix}konoha${sep}${t}`);
314
+ const sembleGrants = ['search', 'find_related'].map(t => `${prefix}semble${sep}${t}`);
315
+ const aislopGrants = ['aislop_scan', 'aislop_fix', 'aislop_why', 'aislop_baseline'].map(t => `${prefix}aislop${sep}${t}`);
316
+ return [...konohaGrants, ...sembleGrants, ...aislopGrants];
317
+ }
318
+
301
319
  function registerClaudeCodePermissions(silent = true) {
302
320
  const grants = [
303
- 'mcp__konoha__*',
304
- 'mcp__semble__*',
305
- 'mcp__aislop__*',
306
- 'Bash(*)',
321
+ ...buildClientToolGrants('mcp__'),
307
322
  'Bash(rtk *)',
308
323
  'Bash(rtk:*)',
309
324
  'Bash(rtk)',
@@ -349,14 +364,11 @@ function registerClaudeCodePermissions(silent = true) {
349
364
  }
350
365
 
351
366
  const autoApproveGrants = [
352
- 'mcp__konoha__*',
353
- 'mcp__semble__*',
354
- 'mcp__aislop__*',
367
+ ...buildClientToolGrants('mcp__'),
355
368
  'Bash(rtk *)',
356
369
  'Bash(rtk:*)',
357
370
  'Bash(rtk)',
358
- 'Bash(konoha *)',
359
- '*'
371
+ 'Bash(konoha *)'
360
372
  ];
361
373
  if (!config.autoApprove || !Array.isArray(config.autoApprove)) {
362
374
  config.autoApprove = autoApproveGrants;
@@ -370,11 +382,12 @@ function registerClaudeCodePermissions(silent = true) {
370
382
  }
371
383
  }
372
384
 
385
+ const defaultAllowedTools = [
386
+ ...buildClientToolGrants('mcp__'),
387
+ 'Bash'
388
+ ];
373
389
  if (!config.allowedTools || !Array.isArray(config.allowedTools)) {
374
- config.allowedTools = ['*'];
375
- updated = true;
376
- } else if (!config.allowedTools.includes('*')) {
377
- config.allowedTools.push('*');
390
+ config.allowedTools = defaultAllowedTools;
378
391
  updated = true;
379
392
  }
380
393
 
@@ -385,15 +398,6 @@ function registerClaudeCodePermissions(silent = true) {
385
398
  }
386
399
  }
387
400
 
388
- if (config.defaultMode !== 'bypassPermissions') {
389
- config.defaultMode = 'bypassPermissions';
390
- updated = true;
391
- }
392
- if (config.permissionMode !== 'bypassPermissions') {
393
- config.permissionMode = 'bypassPermissions';
394
- updated = true;
395
- }
396
-
397
401
  return updated;
398
402
  },
399
403
  silent
@@ -537,7 +541,7 @@ function deployCommandCodeRules(silent = true) {
537
541
  fs.writeFileSync(ruleDest, contractContent, 'utf8');
538
542
 
539
543
  for (const agent of agents) {
540
- if (!agent || !agent.name || agent.name.startsWith('mcp_') || agent.name.startsWith('cli-test-')) continue;
544
+ if (!agent || !agent.name || !validateAgentName(agent.name, agentsDir) || agent.name.startsWith('mcp_') || agent.name.startsWith('cli-test-')) continue;
541
545
  const subagentMd = generateGenericSubagentMd(agent, 'commandcode');
542
546
  fs.writeFileSync(path.join(agentsDir, `${agent.name}.md`), subagentMd, 'utf8');
543
547
  }
@@ -588,7 +592,7 @@ function ensureClaudeCodeSetup(options = {}) {
588
592
  const claudeAgentsDir = path.join(HOME, '.claude', 'agents');
589
593
  ensureDir(claudeAgentsDir);
590
594
  for (const agent of agents) {
591
- if (!agent || !agent.name || agent.name.startsWith('mcp_') || agent.name.startsWith('cli-test-')) continue;
595
+ if (!agent || !agent.name || !validateAgentName(agent.name, claudeAgentsDir) || agent.name.startsWith('mcp_') || agent.name.startsWith('cli-test-')) continue;
592
596
  const mdContent = generateClaudeCodeSubagent(agent);
593
597
  const targetPath = path.join(claudeAgentsDir, agent.name + '.md');
594
598
  fs.writeFileSync(targetPath, mdContent);
@@ -624,12 +628,8 @@ function registerCommandCodePermissions(silent = true) {
624
628
  if (!config.permissions) config.permissions = {};
625
629
  const allow = Array.isArray(config.permissions.allow) ? config.permissions.allow : [];
626
630
  const grants = [
627
- 'mcp__konoha__*',
628
- 'mcp__semble__*',
629
- 'mcp__aislop__*',
630
- 'mcp:konoha:*',
631
- 'mcp:semble:*',
632
- 'mcp:aislop:*',
631
+ ...buildClientToolGrants('mcp__'),
632
+ ...buildClientToolGrants('mcp:'),
633
633
  'Shell(rtk *)',
634
634
  'Shell(rtk)',
635
635
  'Bash(rtk *)',
@@ -639,8 +639,7 @@ function registerCommandCodePermissions(silent = true) {
639
639
  'rtk',
640
640
  'rtk *',
641
641
  'command(rtk *)',
642
- 'command(rtk)',
643
- '*'
642
+ 'command(rtk)'
644
643
  ];
645
644
  let updated = false;
646
645
  for (const grant of grants) {
@@ -652,38 +651,34 @@ function registerCommandCodePermissions(silent = true) {
652
651
  config.permissions.allow = allow;
653
652
 
654
653
  const _autoApproveGrants = [
655
- 'mcp__konoha__*',
656
- 'mcp__semble__*',
657
- 'mcp__aislop__*',
658
- 'mcp:konoha:*',
659
- 'mcp:semble:*',
660
- 'mcp:aislop:*',
654
+ ...buildClientToolGrants('mcp__'),
655
+ ...buildClientToolGrants('mcp:'),
661
656
  'Shell(rtk *)',
662
657
  'Shell(rtk)',
663
658
  'Bash(rtk *)',
664
659
  'Bash(rtk)',
665
660
  'rtk',
666
- 'rtk *',
667
- '*'
661
+ 'rtk *'
668
662
  ];
669
663
  if (!config.autoApprove || !Array.isArray(config.autoApprove)) {
670
- config.autoApprove = ['*'];
671
- updated = true;
672
- } else if (!config.autoApprove.includes('*')) {
673
- config.autoApprove.push('*');
664
+ config.autoApprove = _autoApproveGrants;
674
665
  updated = true;
666
+ } else {
667
+ for (const g of _autoApproveGrants) {
668
+ if (!config.autoApprove.includes(g)) {
669
+ config.autoApprove.push(g);
670
+ updated = true;
671
+ }
672
+ }
675
673
  }
676
674
 
675
+ const defaultAllowedTools = [
676
+ ...buildClientToolGrants('mcp__'),
677
+ 'Bash',
678
+ 'Shell'
679
+ ];
677
680
  if (!config.allowedTools || !Array.isArray(config.allowedTools)) {
678
- config.allowedTools = ['*'];
679
- updated = true;
680
- } else if (!config.allowedTools.includes('*')) {
681
- config.allowedTools.push('*');
682
- updated = true;
683
- }
684
-
685
- if (config.permissionMode !== 'allowAll') {
686
- config.permissionMode = 'allowAll';
681
+ config.allowedTools = defaultAllowedTools;
687
682
  updated = true;
688
683
  }
689
684
 
@@ -136,7 +136,7 @@ function registerOpenCodeMcp(pythonCmd, serverPath, uvxCmd, silent = true) {
136
136
  if (uvxAvailable) {
137
137
  config.mcp['semble'] = {
138
138
  type: 'local',
139
- command: [uvxCmd || 'uvx', '--from', 'semble[mcp]@latest', 'semble', '--content', 'all'],
139
+ command: [uvxCmd || 'uvx', '--from', 'semble[mcp]==0.6.2', 'semble', '--content', 'all'],
140
140
  environment: {
141
141
  ACTIVE_CLIENT: 'opencode',
142
142
  OPENCODE_CLIENT: '1',
@@ -148,7 +148,7 @@ function registerOpenCodeMcp(pythonCmd, serverPath, uvxCmd, silent = true) {
148
148
 
149
149
  // Aislop MCP registration
150
150
  const npxCmd = process.platform === 'win32' ? 'npx.cmd' : 'npx';
151
- let aislopCommand = [npxCmd, '-y', '--prefer-offline', '-p', 'aislop', 'aislop-mcp'];
151
+ let aislopCommand = [npxCmd, '-y', '--prefer-offline', '-p', 'aislop@0.18.1', 'aislop-mcp'];
152
152
  try {
153
153
  const whichCmd = process.platform === 'win32' ? 'where' : 'which';
154
154
  const whichRes = spawnSync(whichCmd, ['aislop-mcp'], { encoding: 'utf-8', shell: process.platform === 'win32', timeout: 3000 });
package/src/pi_manager.js CHANGED
@@ -528,12 +528,12 @@ function registerPiMcp(pythonCmd, serverPath, uvxCmd, silent = true) {
528
528
  if (uvxAvailable) {
529
529
  config.mcpServers['semble'] = {
530
530
  command: uvxCmd || 'uvx',
531
- args: ['--from', 'semble[mcp]@latest', 'semble', '--content', 'all']
531
+ args: ['--from', 'semble[mcp]==0.6.2', 'semble', '--content', 'all']
532
532
  };
533
533
  }
534
534
  config.mcpServers['aislop'] = {
535
535
  command: process.platform === 'win32' ? 'npx.cmd' : 'npx',
536
- args: ['-y', '-p', 'aislop', 'aislop-mcp']
536
+ args: ['-y', '-p', 'aislop@0.18.1', 'aislop-mcp']
537
537
  };
538
538
 
539
539
  fs.writeFileSync(PI_MCP_CONFIG, JSON.stringify(config, null, 2) + '\n', 'utf-8');
@@ -50,9 +50,9 @@ function getSembleStatus() {
50
50
 
51
51
  return {
52
52
  name: 'Semble MCP',
53
- package: 'semble[mcp]@latest',
53
+ package: 'semble[mcp]==0.6.2',
54
54
  engine: 'Semantic Code Search (Neural Embedding + Vector Index)',
55
- command: `${uvxCmd} --from semble[mcp]@latest semble`,
55
+ command: `${uvxCmd} --from semble[mcp]==0.6.2 semble`,
56
56
  configured,
57
57
  available: isUvxUsable(uvxCmd),
58
58
  features: ['search', 'find_related'],
@@ -76,7 +76,7 @@ function getSembleSavings() {
76
76
  const candidates = [
77
77
  { cmd: 'semble', args: ['savings'], timeout: 1500 },
78
78
  { cmd: uvxCmd, args: ['semble', 'savings'], timeout: 2000 },
79
- { cmd: uvxCmd, args: ['--from', 'semble[mcp]@latest', 'semble', 'savings'], timeout: 3000 }
79
+ { cmd: uvxCmd, args: ['--from', 'semble[mcp]==0.6.2', 'semble', 'savings'], timeout: 3000 }
80
80
  ];
81
81
 
82
82
  for (const c of candidates) {
@@ -171,7 +171,7 @@ function searchSemble(query, searchPath = process.cwd(), topK = 5) {
171
171
  const k = Math.min(Math.max(parseInt(topK, 10) || 5, 1), 20);
172
172
 
173
173
  try {
174
- const res = spawnSync(uvxCmd, ['--from', 'semble[mcp]@latest', 'semble', 'search', query.trim(), searchPath, '-k', String(k)], {
174
+ const res = spawnSync(uvxCmd, ['--from', 'semble[mcp]==0.6.2', 'semble', 'search', query.trim(), searchPath, '-k', String(k)], {
175
175
  encoding: 'utf-8',
176
176
  timeout: 8000,
177
177
  shell: process.platform === 'win32'