feat(cli): add skill_lookup MCP for non-native agents (#1035)

* test: reproduce issue #752

* fix: expose skill lookup MCP tool (closes #752)

* test: cover ACP skill lookup instructions

* fix: inject ACP skill lookup instruction

* test: narrow skill lookup auto-approval

* fix: restrict skill lookup auto-approval

* test: cover exact skill lookup tool names
This commit is contained in:
SSU-WEI HUANG
2026-07-16 12:31:36 +08:00
committed by GitHub
parent e342d97177
commit f457156bd1
25 changed files with 941 additions and 90 deletions
+12 -2
View File
@@ -10,6 +10,7 @@ import type { PermissionMode } from './types';
import { createKimiBackend } from './utils/kimiBackend';
import { KimiPermissionHandler } from './utils/permissionHandler';
import { resolveKimiRuntimeConfig } from './utils/config';
import { SKILL_LOOKUP_INSTRUCTION } from '@/modules/common/skillLookupInstruction';
class KimiRemoteLauncher extends RemoteLauncherBase {
private readonly session: KimiSession;
@@ -23,6 +24,7 @@ class KimiRemoteLauncher extends RemoteLauncherBase {
private currentBackendModel: string | null = null;
private setModelSupported: boolean | undefined = undefined;
private lastDisplayedToolCall = new Map<string, string>();
private skillLookupInstructionSent = false;
constructor(session: KimiSession, opts: { model?: string }) {
super(process.env.DEBUG ? session.logPath : undefined);
@@ -45,7 +47,9 @@ class KimiRemoteLauncher extends RemoteLauncherBase {
const session = this.session;
const messageBuffer = this.messageBuffer;
const { server: happyServer, mcpServers } = await buildHapiMcpBridge(session.client);
const { server: happyServer, mcpServers } = await buildHapiMcpBridge(session.client, {
skillLookup: { workingDirectory: session.path, flavor: 'kimi' }
});
this.happyServer = happyServer;
const runtimeConfig = resolveKimiRuntimeConfig({ model: this.model });
@@ -156,9 +160,15 @@ class KimiRemoteLauncher extends RemoteLauncherBase {
this.applyDisplayMode(batch.mode.permissionMode, batch.mode.model);
messageBuffer.addMessage(batch.message, 'user');
let messageText = batch.message;
if (!this.skillLookupInstructionSent && !messageText.trimStart().startsWith('/')) {
messageText = `${SKILL_LOOKUP_INSTRUCTION}\n\n${messageText}`;
this.skillLookupInstructionSent = true;
}
const promptContent: PromptContent[] = [{
type: 'text',
text: batch.message
text: messageText
}];
session.onThinkingChange(true);