mirror of
https://github.com/Kaelio/ktx.git
synced 2026-06-22 08:38:08 +02:00
* docs(specs): design research-agent MCP tools and ktx mcp daemon Adds the 2026-05-14 design spec for exposing four new MCP tools (discover_data, entity_details, dictionary_search, sql_execution), shipping a ktx-research skill, and introducing an HTTP-only ktx mcp daemon so external agents can use KTX as a research-capable context layer. * Refine research-agent MCP tools spec after adversarial review iteration 1 * Refine research-agent MCP tools spec after adversarial review iteration 2 * Refine research-agent MCP tools spec after adversarial review iteration 3 * Refine spec: drop connectionName compat carve-out and ground summary/snippet provenance per kind * feat(daemon): validate read-only SQL with sqlglot * feat(context): expose read-only SQL validation port * feat(context): register MCP sql execution tool * feat(context): execute MCP SQL through validated connector path * test(context): update SQL analysis port fixtures * docs: add research-agent MCP sql execution foundation plan * feat(context): add scan-backed entity details service * feat(context): register MCP entity details tool * feat(context): expose local MCP entity details * test(context): align entity details scan fixtures * docs: add research-agent MCP entity_details plan * feat(context): add dictionary search service * feat(context): register MCP dictionary search tool * feat(context): expose local MCP dictionary search * docs: add research-agent MCP dictionary_search plan * feat: add MCP discover data service * feat: expose discover data MCP tool * feat: wire local discover data MCP port * docs: add research-agent MCP discover_data plan * feat(cli): add mcp http security helpers * feat(cli): host mcp over streamable http * feat(cli): manage mcp daemon lifecycle * feat(cli): add ktx mcp commands * fix(cli): stabilize mcp daemon verification * docs: add research-agent MCP http daemon plan * feat(cli): install KTX research skill * feat(cli): configure MCP clients in setup agents * feat(cli): support Claude local MCP setup scope * docs: add research-agent MCP setup-agents plan * refactor(context): use connectionId in warehouse verification tools * docs(context): update ingest verification prompts for connectionId * docs: add research-agent MCP ingest contract convergence plan * chore: build runtime artifacts in conductor setup --------- Co-authored-by: Andrey Avtomonov <7889985+andreybavt@users.noreply.github.com>
108 lines
4.6 KiB
TypeScript
108 lines
4.6 KiB
TypeScript
import { readFile } from 'node:fs/promises';
|
|
import { join } from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
import { describe, expect, it } from 'vitest';
|
|
import { PromptService } from '../prompts/index.js';
|
|
import { SkillsRegistryService } from '../skills/index.js';
|
|
|
|
const promptsDir = fileURLToPath(new URL('../../prompts', import.meta.url));
|
|
const skillsDir = fileURLToPath(new URL('../../skills', import.meta.url));
|
|
|
|
const adapterSkillNames = [
|
|
'live_database_ingest',
|
|
'lookml_ingest',
|
|
'metabase_ingest',
|
|
'metricflow_ingest',
|
|
'notion_synthesize',
|
|
'historic_sql_table_digest',
|
|
'historic_sql_patterns',
|
|
'ingest_triage',
|
|
'wiki_capture',
|
|
'sl_capture',
|
|
] as const;
|
|
|
|
const adapterReconcileSkillNames = [
|
|
'ingest_triage',
|
|
'wiki_capture',
|
|
'sl_capture',
|
|
] as const;
|
|
|
|
const pageTriagePromptNames = ['skills/page_triage_classifier', 'skills/light_extraction'] as const;
|
|
|
|
function forbiddenProductPattern() {
|
|
return new RegExp([['Kae', 'lio'].join(''), ['kae', 'lio'].join(''), ['KAE', 'LIO_'].join('')].join('|'));
|
|
}
|
|
|
|
describe('ingest runtime assets', () => {
|
|
it('resolves every reusable ingest skill from packaged KTX assets without server fallback', async () => {
|
|
const registry = new SkillsRegistryService({ skillsDir });
|
|
const expected = [...new Set([...adapterSkillNames, ...adapterReconcileSkillNames])].sort();
|
|
|
|
const skills = await registry.listSkills(expected, 'memory_agent');
|
|
|
|
expect(skills.map((skill) => skill.name).sort()).toEqual(expected);
|
|
for (const skill of skills) {
|
|
expect(skill.path.startsWith(skillsDir)).toBe(true);
|
|
const body = await readFile(join(skill.path, 'SKILL.md'), 'utf-8');
|
|
expect(body).not.toMatch(forbiddenProductPattern());
|
|
}
|
|
});
|
|
|
|
it('loads page-triage and light-extraction prompts from packaged KTX prompt assets', async () => {
|
|
const prompts = new PromptService({ promptsDir, partials: [] });
|
|
|
|
for (const promptName of pageTriagePromptNames) {
|
|
const prompt = await prompts.loadPrompt(promptName);
|
|
expect(prompt.trim().length).toBeGreaterThan(100);
|
|
expect(prompt).not.toMatch(forbiddenProductPattern());
|
|
}
|
|
|
|
await expect(prompts.loadPrompt('skills/page_triage_classifier')).resolves.toContain('# Page Triage Classifier');
|
|
await expect(prompts.loadPrompt('skills/light_extraction')).resolves.toContain('# Light Context Extraction');
|
|
});
|
|
|
|
it('packages historic-SQL table digest guidance from KTX assets', async () => {
|
|
const registry = new SkillsRegistryService({ skillsDir });
|
|
const skills = await registry.listSkills(['historic_sql_table_digest'], 'memory_agent');
|
|
|
|
expect(skills.map((skill) => skill.name)).toEqual(['historic_sql_table_digest']);
|
|
|
|
const body = await readFile(join(skills[0]!.path, 'SKILL.md'), 'utf-8');
|
|
expect(body).toContain('# Historic SQL Table Digest');
|
|
expect(body).toContain('tables/<schema>.<name>.json');
|
|
expect(body).toContain('tableUsageOutputSchema');
|
|
expect(body).toContain('emit_historic_sql_evidence');
|
|
expect(body).toContain('Do not call wiki_write');
|
|
expect(body).toContain('Do not call sl_write_source');
|
|
expect(body).not.toMatch(forbiddenProductPattern());
|
|
});
|
|
|
|
it('packages historic-SQL patterns guidance from KTX assets', async () => {
|
|
const registry = new SkillsRegistryService({ skillsDir });
|
|
const skills = await registry.listSkills(['historic_sql_patterns'], 'memory_agent');
|
|
|
|
expect(skills.map((skill) => skill.name)).toEqual(['historic_sql_patterns']);
|
|
|
|
const body = await readFile(join(skills[0]!.path, 'SKILL.md'), 'utf-8');
|
|
expect(body).toContain('# Historic SQL Patterns');
|
|
expect(body).toContain('patterns-input/part-0001.json');
|
|
expect(body).toContain('patternsArraySchema');
|
|
expect(body).toContain('emit_historic_sql_evidence');
|
|
expect(body).toContain('cross-table');
|
|
expect(body).not.toMatch(forbiddenProductPattern());
|
|
});
|
|
|
|
it('packages identifier verification prompt assets', async () => {
|
|
const shared = await readFile(join(skillsDir, '_shared', 'identifier-verification.md'), 'utf-8');
|
|
const legacyConnectionPrefix = ['connection', 'Name'].join('');
|
|
|
|
expect(shared).toContain('## Identifier Verification Protocol');
|
|
expect(shared).toContain('discover_data');
|
|
expect(shared).toContain('entity_details');
|
|
expect(shared).toContain('sql_execution');
|
|
expect(shared).toContain('sql_execution({connectionId, sql: "SELECT DISTINCT');
|
|
expect(shared).toContain('sql_execution({connectionId, sql: "SELECT 1 FROM');
|
|
expect(shared).not.toContain(`entity_details({${legacyConnectionPrefix}`);
|
|
expect(shared).not.toContain(`sql_execution({${legacyConnectionPrefix}`);
|
|
});
|
|
});
|