axiom-mcp 2.19.6
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/LICENSE +21 -0
- package/README.md +409 -0
- package/dist/bundle.json +609177 -0
- package/dist/catalog/index.d.ts +26 -0
- package/dist/catalog/index.d.ts.map +1 -0
- package/dist/catalog/index.js +173 -0
- package/dist/catalog/index.js.map +1 -0
- package/dist/config.d.ts +31 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +60 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +130 -0
- package/dist/index.js.map +1 -0
- package/dist/loader/dev-loader.d.ts +55 -0
- package/dist/loader/dev-loader.d.ts.map +1 -0
- package/dist/loader/dev-loader.js +223 -0
- package/dist/loader/dev-loader.js.map +1 -0
- package/dist/loader/parser.d.ts +117 -0
- package/dist/loader/parser.d.ts.map +1 -0
- package/dist/loader/parser.js +204 -0
- package/dist/loader/parser.js.map +1 -0
- package/dist/loader/prod-loader.d.ts +42 -0
- package/dist/loader/prod-loader.d.ts.map +1 -0
- package/dist/loader/prod-loader.js +144 -0
- package/dist/loader/prod-loader.js.map +1 -0
- package/dist/loader/types.d.ts +55 -0
- package/dist/loader/types.d.ts.map +1 -0
- package/dist/loader/types.js +2 -0
- package/dist/loader/types.js.map +1 -0
- package/dist/loader/xcode-docs.d.ts +18 -0
- package/dist/loader/xcode-docs.d.ts.map +1 -0
- package/dist/loader/xcode-docs.js +91 -0
- package/dist/loader/xcode-docs.js.map +1 -0
- package/dist/prompts/handler.d.ts +57 -0
- package/dist/prompts/handler.d.ts.map +1 -0
- package/dist/prompts/handler.js +95 -0
- package/dist/prompts/handler.js.map +1 -0
- package/dist/resources/handler.d.ts +51 -0
- package/dist/resources/handler.d.ts.map +1 -0
- package/dist/resources/handler.js +99 -0
- package/dist/resources/handler.js.map +1 -0
- package/dist/scripts/bundle.d.ts +13 -0
- package/dist/scripts/bundle.d.ts.map +1 -0
- package/dist/scripts/bundle.js +137 -0
- package/dist/scripts/bundle.js.map +1 -0
- package/dist/search/index.d.ts +65 -0
- package/dist/search/index.d.ts.map +1 -0
- package/dist/search/index.js +227 -0
- package/dist/search/index.js.map +1 -0
- package/dist/tools/handler.d.ts +40 -0
- package/dist/tools/handler.d.ts.map +1 -0
- package/dist/tools/handler.js +265 -0
- package/dist/tools/handler.js.map +1 -0
- package/package.json +53 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { readFile } from 'fs/promises';
|
|
2
|
+
import { deserializeIndex, search, buildIndex } from '../search/index.js';
|
|
3
|
+
import { buildCatalog } from '../catalog/index.js';
|
|
4
|
+
import { detectXcode, loadAppleDocs } from './xcode-docs.js';
|
|
5
|
+
/**
|
|
6
|
+
* Production mode loader - reads from pre-generated bundle.json
|
|
7
|
+
*/
|
|
8
|
+
export class ProdLoader {
|
|
9
|
+
bundlePath;
|
|
10
|
+
logger;
|
|
11
|
+
config;
|
|
12
|
+
skillsCache = new Map();
|
|
13
|
+
commandsCache = new Map();
|
|
14
|
+
agentsCache = new Map();
|
|
15
|
+
searchIdx = null;
|
|
16
|
+
loaded = false;
|
|
17
|
+
constructor(bundlePath, logger, config) {
|
|
18
|
+
this.bundlePath = bundlePath;
|
|
19
|
+
this.logger = logger;
|
|
20
|
+
this.config = config;
|
|
21
|
+
}
|
|
22
|
+
async ensureLoaded() {
|
|
23
|
+
if (this.loaded)
|
|
24
|
+
return;
|
|
25
|
+
this.logger.info(`Loading bundle from: ${this.bundlePath}`);
|
|
26
|
+
try {
|
|
27
|
+
const content = await readFile(this.bundlePath, 'utf-8');
|
|
28
|
+
const bundle = JSON.parse(content);
|
|
29
|
+
this.logger.info(`Bundle version: ${bundle.version}`);
|
|
30
|
+
this.logger.info(`Bundle generated: ${bundle.generatedAt}`);
|
|
31
|
+
for (const [name, skill] of Object.entries(bundle.skills)) {
|
|
32
|
+
// Default source for bundles generated before source tracking was added
|
|
33
|
+
if (!skill.source)
|
|
34
|
+
skill.source = 'axiom';
|
|
35
|
+
this.skillsCache.set(name, skill);
|
|
36
|
+
}
|
|
37
|
+
for (const [name, command] of Object.entries(bundle.commands)) {
|
|
38
|
+
this.commandsCache.set(name, command);
|
|
39
|
+
}
|
|
40
|
+
for (const [name, agent] of Object.entries(bundle.agents)) {
|
|
41
|
+
this.agentsCache.set(name, agent);
|
|
42
|
+
}
|
|
43
|
+
// Load pre-computed search index or build one
|
|
44
|
+
if (bundle.searchIndex) {
|
|
45
|
+
this.searchIdx = deserializeIndex(bundle.searchIndex);
|
|
46
|
+
this.logger.info(`Search index loaded from bundle: ${this.searchIdx.docCount} documents`);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
this.searchIdx = buildIndex(this.skillsCache);
|
|
50
|
+
this.logger.info(`Search index built at startup: ${this.searchIdx.docCount} documents`);
|
|
51
|
+
}
|
|
52
|
+
this.logger.info(`Loaded ${this.skillsCache.size} skills`);
|
|
53
|
+
this.logger.info(`Loaded ${this.commandsCache.size} commands`);
|
|
54
|
+
this.logger.info(`Loaded ${this.agentsCache.size} agents`);
|
|
55
|
+
// Overlay Apple docs at runtime (not bundled)
|
|
56
|
+
if (this.config?.enableAppleDocs !== false) {
|
|
57
|
+
const xcodeConfig = await detectXcode(this.config?.xcodePath);
|
|
58
|
+
if (xcodeConfig) {
|
|
59
|
+
const appleDocs = await loadAppleDocs(xcodeConfig, this.logger);
|
|
60
|
+
for (const [name, skill] of appleDocs) {
|
|
61
|
+
this.skillsCache.set(name, skill);
|
|
62
|
+
}
|
|
63
|
+
// Rebuild search index to include Apple docs
|
|
64
|
+
this.searchIdx = buildIndex(this.skillsCache);
|
|
65
|
+
this.logger.info(`Loaded ${appleDocs.size} Apple docs, search index rebuilt`);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
this.logger.info('Xcode not found, skipping Apple docs');
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
this.loaded = true;
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
this.logger.error('Failed to load bundle:', error);
|
|
75
|
+
throw error;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async loadSkills() {
|
|
79
|
+
await this.ensureLoaded();
|
|
80
|
+
return this.skillsCache;
|
|
81
|
+
}
|
|
82
|
+
async loadCommands() {
|
|
83
|
+
await this.ensureLoaded();
|
|
84
|
+
return this.commandsCache;
|
|
85
|
+
}
|
|
86
|
+
async loadAgents() {
|
|
87
|
+
await this.ensureLoaded();
|
|
88
|
+
return this.agentsCache;
|
|
89
|
+
}
|
|
90
|
+
async getSkill(name) {
|
|
91
|
+
await this.ensureLoaded();
|
|
92
|
+
return this.skillsCache.get(name);
|
|
93
|
+
}
|
|
94
|
+
async getCommand(name) {
|
|
95
|
+
await this.ensureLoaded();
|
|
96
|
+
return this.commandsCache.get(name);
|
|
97
|
+
}
|
|
98
|
+
async getAgent(name) {
|
|
99
|
+
await this.ensureLoaded();
|
|
100
|
+
return this.agentsCache.get(name);
|
|
101
|
+
}
|
|
102
|
+
async getSkillSections(name, sectionNames) {
|
|
103
|
+
await this.ensureLoaded();
|
|
104
|
+
const skill = this.skillsCache.get(name);
|
|
105
|
+
if (!skill)
|
|
106
|
+
return undefined;
|
|
107
|
+
if (!sectionNames || sectionNames.length === 0) {
|
|
108
|
+
return { skill, content: skill.content, sections: skill.sections };
|
|
109
|
+
}
|
|
110
|
+
const lines = skill.content.split('\n');
|
|
111
|
+
const matchedSections = [];
|
|
112
|
+
const contentParts = [];
|
|
113
|
+
for (const section of skill.sections) {
|
|
114
|
+
const matches = sectionNames.some(filter => section.heading.toLowerCase().includes(filter.toLowerCase()));
|
|
115
|
+
if (matches) {
|
|
116
|
+
matchedSections.push(section);
|
|
117
|
+
contentParts.push(lines.slice(section.startLine, section.endLine + 1).join('\n'));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
skill,
|
|
122
|
+
content: contentParts.join('\n\n'),
|
|
123
|
+
sections: matchedSections,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
async searchSkills(query, options) {
|
|
127
|
+
await this.ensureLoaded();
|
|
128
|
+
return search(this.searchIdx, query, options, this.skillsCache);
|
|
129
|
+
}
|
|
130
|
+
async getCatalog(category) {
|
|
131
|
+
await this.ensureLoaded();
|
|
132
|
+
return buildCatalog(this.skillsCache, this.agentsCache, category);
|
|
133
|
+
}
|
|
134
|
+
getSkills() {
|
|
135
|
+
return this.skillsCache;
|
|
136
|
+
}
|
|
137
|
+
getCommands() {
|
|
138
|
+
return this.commandsCache;
|
|
139
|
+
}
|
|
140
|
+
getAgents() {
|
|
141
|
+
return this.agentsCache;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=prod-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prod-loader.js","sourceRoot":"","sources":["../../src/loader/prod-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAKvC,OAAO,EAAe,gBAAgB,EAAE,MAAM,EAAE,UAAU,EAAgC,MAAM,oBAAoB,CAAC;AACrH,OAAO,EAAE,YAAY,EAAiB,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAY7D;;GAEG;AACH,MAAM,OAAO,UAAU;IAQX;IACA;IACA;IATF,WAAW,GAAG,IAAI,GAAG,EAAiB,CAAC;IACvC,aAAa,GAAG,IAAI,GAAG,EAAmB,CAAC;IAC3C,WAAW,GAAG,IAAI,GAAG,EAAiB,CAAC;IACvC,SAAS,GAAuB,IAAI,CAAC;IACrC,MAAM,GAAG,KAAK,CAAC;IAEvB,YACU,UAAkB,EAClB,MAAc,EACd,MAAe;QAFf,eAAU,GAAV,UAAU,CAAQ;QAClB,WAAM,GAAN,MAAM,CAAQ;QACd,WAAM,GAAN,M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AChB,KAAa,EACb,OAAoF;QAEpF,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;QAC1B,OAAO,MAAM,CAAC,IAAI,CAAC,SAAU,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IACnE,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,QAAiB;QAChC,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;QAC1B,OAAO,YAAY,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IACpE,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;CACF"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Skill, Command, Agent, SkillSection } from './parser.js';
|
|
2
|
+
import type { SearchResult } from '../search/index.js';
|
|
3
|
+
import type { CatalogResult } from '../catalog/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* Common interface for both DevLoader and ProdLoader
|
|
6
|
+
* Ensures both loaders provide the same methods to handlers
|
|
7
|
+
*/
|
|
8
|
+
export interface Loader {
|
|
9
|
+
/**
|
|
10
|
+
* Load all skills
|
|
11
|
+
*/
|
|
12
|
+
loadSkills(): Promise<Map<string, Skill>>;
|
|
13
|
+
/**
|
|
14
|
+
* Load all commands
|
|
15
|
+
*/
|
|
16
|
+
loadCommands(): Promise<Map<string, Command>>;
|
|
17
|
+
/**
|
|
18
|
+
* Load all agents
|
|
19
|
+
*/
|
|
20
|
+
loadAgents(): Promise<Map<string, Agent>>;
|
|
21
|
+
/**
|
|
22
|
+
* Get a specific skill by name
|
|
23
|
+
*/
|
|
24
|
+
getSkill(name: string): Promise<Skill | undefined>;
|
|
25
|
+
/**
|
|
26
|
+
* Get a specific command by name
|
|
27
|
+
*/
|
|
28
|
+
getCommand(name: string): Promise<Command | undefined>;
|
|
29
|
+
/**
|
|
30
|
+
* Get a specific agent by name
|
|
31
|
+
*/
|
|
32
|
+
getAgent(name: string): Promise<Agent | undefined>;
|
|
33
|
+
/**
|
|
34
|
+
* Get skill content filtered to specific sections
|
|
35
|
+
*/
|
|
36
|
+
getSkillSections(name: string, sectionNames?: string[]): Promise<{
|
|
37
|
+
skill: Skill;
|
|
38
|
+
content: string;
|
|
39
|
+
sections: SkillSection[];
|
|
40
|
+
} | undefined>;
|
|
41
|
+
/**
|
|
42
|
+
* Search skills using BM25
|
|
43
|
+
*/
|
|
44
|
+
searchSkills(query: string, options?: {
|
|
45
|
+
limit?: number;
|
|
46
|
+
skillType?: string;
|
|
47
|
+
category?: string;
|
|
48
|
+
source?: string;
|
|
49
|
+
}): Promise<SearchResult[]>;
|
|
50
|
+
/**
|
|
51
|
+
* Get the catalog (skills organized by category)
|
|
52
|
+
*/
|
|
53
|
+
getCatalog(category?: string): Promise<CatalogResult>;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/loader/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB;;OAEG;IACH,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;IAE1C;;OAEG;IACH,YAAY,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAE9C;;OAEG;IACH,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;IAE1C;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC;IAEnD;;OAEG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAAC;IAEvD;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC;IAEnD;;OAEG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,KAAK,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,YAAY,EAAE,CAAA;KAAE,GAAG,SAAS,CAAC,CAAC;IAE1I;;OAEG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;IAE3I;;OAEG;IACH,UAAU,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CACvD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/loader/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Skill } from './parser.js';
|
|
2
|
+
import { Logger } from '../config.js';
|
|
3
|
+
export interface XcodeDocsConfig {
|
|
4
|
+
xcodePath: string;
|
|
5
|
+
additionalDocsPath: string | null;
|
|
6
|
+
diagnosticsPath: string | null;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Detect Xcode installation and resolve paths to Apple's for-LLM documentation.
|
|
10
|
+
* Returns null if Xcode is not found or doc paths are missing.
|
|
11
|
+
*/
|
|
12
|
+
export declare function detectXcode(overridePath?: string): Promise<XcodeDocsConfig | null>;
|
|
13
|
+
/**
|
|
14
|
+
* Load Apple's for-LLM documentation from Xcode installation.
|
|
15
|
+
* Reads AdditionalDocumentation (guides) and Swift diagnostics.
|
|
16
|
+
*/
|
|
17
|
+
export declare function loadAppleDocs(config: XcodeDocsConfig, logger: Logger): Promise<Map<string, Skill>>;
|
|
18
|
+
//# sourceMappingURL=xcode-docs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xcode-docs.d.ts","sourceRoot":"","sources":["../../src/loader/xcode-docs.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAcD;;;GAGG;AACH,wBAAsB,WAAW,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAsBxF;AAED;;;GAGG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,eAAe,EACvB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAgD7B"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { readdir, readFile, stat } from 'fs/promises';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { parseAppleDoc } from './parser.js';
|
|
4
|
+
const DEFAULT_XCODE_PATH = '/Applications/Xcode.app';
|
|
5
|
+
const ADDITIONAL_DOCS_SUBPATH = 'Contents/PlugIns/IDEIntelligenceChat.framework/Versions/A/Resources/AdditionalDocumentation';
|
|
6
|
+
const DIAGNOSTICS_SUBPATH = 'Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/share/doc/swift/diagnostics';
|
|
7
|
+
async function isDirectory(path) {
|
|
8
|
+
try {
|
|
9
|
+
return (await stat(path)).isDirectory();
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Detect Xcode installation and resolve paths to Apple's for-LLM documentation.
|
|
17
|
+
* Returns null if Xcode is not found or doc paths are missing.
|
|
18
|
+
*/
|
|
19
|
+
export async function detectXcode(overridePath) {
|
|
20
|
+
const xcodePath = overridePath || DEFAULT_XCODE_PATH;
|
|
21
|
+
if (!await isDirectory(xcodePath)) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
const additionalDocsPath = join(xcodePath, ADDITIONAL_DOCS_SUBPATH);
|
|
25
|
+
const diagnosticsPath = join(xcodePath, DIAGNOSTICS_SUBPATH);
|
|
26
|
+
const hasAdditional = await isDirectory(additionalDocsPath);
|
|
27
|
+
const hasDiagnostics = await isDirectory(diagnosticsPath);
|
|
28
|
+
if (!hasAdditional && !hasDiagnostics) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
xcodePath,
|
|
33
|
+
additionalDocsPath: hasAdditional ? additionalDocsPath : null,
|
|
34
|
+
diagnosticsPath: hasDiagnostics ? diagnosticsPath : null,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Load Apple's for-LLM documentation from Xcode installation.
|
|
39
|
+
* Reads AdditionalDocumentation (guides) and Swift diagnostics.
|
|
40
|
+
*/
|
|
41
|
+
export async function loadAppleDocs(config, logger) {
|
|
42
|
+
const docs = new Map();
|
|
43
|
+
// Load AdditionalDocumentation guides
|
|
44
|
+
if (config.additionalDocsPath !== null) {
|
|
45
|
+
try {
|
|
46
|
+
const files = (await readdir(config.additionalDocsPath)).filter(f => f.endsWith('.md'));
|
|
47
|
+
let loaded = 0;
|
|
48
|
+
for (const file of files) {
|
|
49
|
+
try {
|
|
50
|
+
const content = await readFile(join(config.additionalDocsPath, file), 'utf-8');
|
|
51
|
+
const skill = parseAppleDoc(content, file, 'guide');
|
|
52
|
+
docs.set(skill.name, skill);
|
|
53
|
+
loaded++;
|
|
54
|
+
logger.debug(`Loaded Apple guide: ${skill.name}`);
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
logger.warn(`Failed to parse Apple guide: ${file}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
logger.info(`Loaded ${loaded}/${files.length} Apple guides from AdditionalDocumentation`);
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
logger.debug('Could not read AdditionalDocumentation directory');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// Load Swift diagnostics
|
|
67
|
+
if (config.diagnosticsPath !== null) {
|
|
68
|
+
try {
|
|
69
|
+
const files = (await readdir(config.diagnosticsPath)).filter(f => f.endsWith('.md'));
|
|
70
|
+
let loaded = 0;
|
|
71
|
+
for (const file of files) {
|
|
72
|
+
try {
|
|
73
|
+
const content = await readFile(join(config.diagnosticsPath, file), 'utf-8');
|
|
74
|
+
const skill = parseAppleDoc(content, file, 'diagnostic');
|
|
75
|
+
docs.set(skill.name, skill);
|
|
76
|
+
loaded++;
|
|
77
|
+
logger.debug(`Loaded Apple diagnostic: ${skill.name}`);
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
logger.warn(`Failed to parse Apple diagnostic: ${file}`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
logger.info(`Loaded ${loaded}/${files.length} Apple diagnostics from Xcode toolchain`);
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
logger.debug('Could not read diagnostics directory');
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return docs;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=xcode-docs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xcode-docs.js","sourceRoot":"","sources":["../../src/loader/xcode-docs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAS,MAAM,aAAa,CAAC;AASnD,MAAM,kBAAkB,GAAG,yBAAyB,CAAC;AACrD,MAAM,uBAAuB,GAAG,6FAA6F,CAAC;AAC9H,MAAM,mBAAmB,GAAG,wFAAwF,CAAC;AAErH,KAAK,UAAU,WAAW,CAAC,IAAY;IACrC,IAAI,CAAC;QACH,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IAC1C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,YAAqB;IACrD,MAAM,SAAS,GAAG,YAAY,IAAI,kBAAkB,CAAC;IAErD,IAAI,CAAC,MAAM,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,kBAAkB,GAAG,IAAI,CAAC,SAAS,EAAE,uBAAuB,CAAC,CAAC;IACpE,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;IAE7D,MAAM,aAAa,GAAG,MAAM,WAAW,CAAC,kBAAkB,CAAC,CAAC;IAC5D,MAAM,cAAc,GAAG,MAAM,WAAW,CAAC,eAAe,CAAC,CAAC;IAE1D,IAAI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IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Loader } from '../loader/types.js';
|
|
2
|
+
import { Logger } from '../config.js';
|
|
3
|
+
/**
|
|
4
|
+
* MCP Prompt representation
|
|
5
|
+
*/
|
|
6
|
+
export interface McpPrompt {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
arguments?: Array<{
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
required: boolean;
|
|
13
|
+
}>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* MCP Prompts handler
|
|
17
|
+
* Implements prompts/list and prompts/get for commands
|
|
18
|
+
*/
|
|
19
|
+
export declare class PromptsHandler {
|
|
20
|
+
private loader;
|
|
21
|
+
private logger;
|
|
22
|
+
constructor(loader: Loader, logger: Logger);
|
|
23
|
+
/**
|
|
24
|
+
* Handle prompts/list request
|
|
25
|
+
* Returns all available commands as prompts
|
|
26
|
+
*/
|
|
27
|
+
listPrompts(): Promise<{
|
|
28
|
+
prompts: McpPrompt[];
|
|
29
|
+
}>;
|
|
30
|
+
/**
|
|
31
|
+
* Handle prompts/get request
|
|
32
|
+
* Returns a specific command prompt with arguments substituted
|
|
33
|
+
*/
|
|
34
|
+
getPrompt(name: string, args?: Record<string, string>): Promise<{
|
|
35
|
+
description?: string;
|
|
36
|
+
messages: Array<{
|
|
37
|
+
role: string;
|
|
38
|
+
content: {
|
|
39
|
+
type: string;
|
|
40
|
+
text: string;
|
|
41
|
+
};
|
|
42
|
+
}>;
|
|
43
|
+
}>;
|
|
44
|
+
/**
|
|
45
|
+
* Convert a Command to an MCP Prompt
|
|
46
|
+
*/
|
|
47
|
+
private commandToPrompt;
|
|
48
|
+
/**
|
|
49
|
+
* Substitute argument placeholders in command content
|
|
50
|
+
*
|
|
51
|
+
* Supports:
|
|
52
|
+
* - {{argument_name}} - Simple substitution
|
|
53
|
+
* - Default values from MCP annotations
|
|
54
|
+
*/
|
|
55
|
+
private substituteArguments;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/prompts/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAGtC;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,KAAK,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,OAAO,CAAC;KACnB,CAAC,CAAC;CACJ;AAED;;;GAGG;AACH,qBAAa,cAAc;IAEvB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,MAAM;gBADN,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM;IAGxB;;;OAGG;IACG,WAAW,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,SAAS,EAAE,CAAA;KAAE,CAAC;IAetD;;;OAGG;IACG,SAAS,CACb,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC5B,OAAO,CAAC;QAAE,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE;gBAAE,IAAI,EAAE,MAAM,CAAC;gBAAC,IAAI,EAAE,MAAM,CAAA;aAAE,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC;IA4BhH;;OAEG;IACH,OAAO,CAAC,eAAe;IAkBvB;;;;;;OAMG;IACH,OAAO,CAAC,mBAAmB;CAoB5B"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Prompts handler
|
|
3
|
+
* Implements prompts/list and prompts/get for commands
|
|
4
|
+
*/
|
|
5
|
+
export class PromptsHandler {
|
|
6
|
+
loader;
|
|
7
|
+
logger;
|
|
8
|
+
constructor(loader, logger) {
|
|
9
|
+
this.loader = loader;
|
|
10
|
+
this.logger = logger;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Handle prompts/list request
|
|
14
|
+
* Returns all available commands as prompts
|
|
15
|
+
*/
|
|
16
|
+
async listPrompts() {
|
|
17
|
+
this.logger.debug('Handling prompts/list');
|
|
18
|
+
const commands = await this.loader.loadCommands();
|
|
19
|
+
const prompts = [];
|
|
20
|
+
for (const [name, command] of commands) {
|
|
21
|
+
prompts.push(this.commandToPrompt(command));
|
|
22
|
+
}
|
|
23
|
+
this.logger.info(`Returning ${prompts.length} prompts`);
|
|
24
|
+
return { prompts };
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Handle prompts/get request
|
|
28
|
+
* Returns a specific command prompt with arguments substituted
|
|
29
|
+
*/
|
|
30
|
+
async getPrompt(name, args) {
|
|
31
|
+
this.logger.debug(`Handling prompts/get: ${name}`);
|
|
32
|
+
const command = await this.loader.getCommand(name);
|
|
33
|
+
if (!command) {
|
|
34
|
+
throw new Error(`Command not found: ${name}`);
|
|
35
|
+
}
|
|
36
|
+
// Substitute arguments in command content
|
|
37
|
+
const content = this.substituteArguments(command, args || {});
|
|
38
|
+
this.logger.info(`Returning prompt: ${name}`);
|
|
39
|
+
return {
|
|
40
|
+
description: command.description,
|
|
41
|
+
messages: [
|
|
42
|
+
{
|
|
43
|
+
role: 'user',
|
|
44
|
+
content: {
|
|
45
|
+
type: 'text',
|
|
46
|
+
text: content
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Convert a Command to an MCP Prompt
|
|
54
|
+
*/
|
|
55
|
+
commandToPrompt(command) {
|
|
56
|
+
const prompt = {
|
|
57
|
+
name: command.name,
|
|
58
|
+
description: command.description
|
|
59
|
+
};
|
|
60
|
+
// Add arguments from MCP annotations if present
|
|
61
|
+
if (command.mcp?.arguments) {
|
|
62
|
+
prompt.arguments = command.mcp.arguments.map(arg => ({
|
|
63
|
+
name: arg.name,
|
|
64
|
+
description: arg.description,
|
|
65
|
+
required: arg.required
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
return prompt;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Substitute argument placeholders in command content
|
|
72
|
+
*
|
|
73
|
+
* Supports:
|
|
74
|
+
* - {{argument_name}} - Simple substitution
|
|
75
|
+
* - Default values from MCP annotations
|
|
76
|
+
*/
|
|
77
|
+
substituteArguments(command, args) {
|
|
78
|
+
let content = command.content;
|
|
79
|
+
// Apply defaults from MCP annotations
|
|
80
|
+
if (command.mcp?.arguments) {
|
|
81
|
+
for (const argDef of command.mcp.arguments) {
|
|
82
|
+
if (!args[argDef.name] && argDef.default) {
|
|
83
|
+
args[argDef.name] = argDef.default;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// Substitute placeholders
|
|
88
|
+
for (const [key, value] of Object.entries(args)) {
|
|
89
|
+
const placeholder = new RegExp(`{{\\s*${key}\\s*}}`, 'g');
|
|
90
|
+
content = content.replace(placeholder, value);
|
|
91
|
+
}
|
|
92
|
+
return content;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../src/prompts/handler.ts"],"names":[],"mappings":"AAiBA;;;GAGG;AACH,MAAM,OAAO,cAAc;IAEf;IACA;IAFV,YACU,MAAc,EACd,MAAc;QADd,WAAM,GAAN,MAAM,CAAQ;QACd,WAAM,GAAN,MAAM,CAAQ;IACrB,CAAC;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D,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Loader } from '../loader/types.js';
|
|
2
|
+
import { Logger } from '../config.js';
|
|
3
|
+
/**
|
|
4
|
+
* MCP Resource representation
|
|
5
|
+
*/
|
|
6
|
+
export interface McpResource {
|
|
7
|
+
uri: string;
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
mimeType: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* MCP Resources handler
|
|
14
|
+
* Implements resources/list and resources/read for skills
|
|
15
|
+
*/
|
|
16
|
+
export declare class ResourcesHandler {
|
|
17
|
+
private loader;
|
|
18
|
+
private logger;
|
|
19
|
+
constructor(loader: Loader, logger: Logger);
|
|
20
|
+
/**
|
|
21
|
+
* Handle resources/list request
|
|
22
|
+
* Returns all available skills as resources
|
|
23
|
+
*/
|
|
24
|
+
listResources(): Promise<{
|
|
25
|
+
resources: McpResource[];
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Handle resources/read request
|
|
29
|
+
* Returns the full content of a specific skill
|
|
30
|
+
*/
|
|
31
|
+
readResource(uri: string): Promise<{
|
|
32
|
+
contents: Array<{
|
|
33
|
+
uri: string;
|
|
34
|
+
mimeType: string;
|
|
35
|
+
text: string;
|
|
36
|
+
}>;
|
|
37
|
+
}>;
|
|
38
|
+
/**
|
|
39
|
+
* Convert a Skill to an MCP Resource
|
|
40
|
+
*/
|
|
41
|
+
private skillToResource;
|
|
42
|
+
/**
|
|
43
|
+
* Format skill name for display (kebab-case to Title Case)
|
|
44
|
+
*/
|
|
45
|
+
private formatSkillName;
|
|
46
|
+
/**
|
|
47
|
+
* Format skill content with frontmatter metadata preserved as human-readable header
|
|
48
|
+
*/
|
|
49
|
+
private formatSkillContent;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/resources/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAGtC;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,qBAAa,gBAAgB;IAEzB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,MAAM;gBADN,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM;IAGxB;;;OAGG;IACG,aAAa,IAAI,OAAO,CAAC;QAAE,SAAS,EAAE,WAAW,EAAE,CAAA;KAAE,CAAC;IAe5D;;;OAGG;IACG,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,QAAQ,EAAE,KAAK,CAAC;YAAE,GAAG,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC;IA2B9G;;OAEG;IACH,OAAO,CAAC,eAAe;IASvB;;OAEG;IACH,OAAO,CAAC,eAAe;IAOvB;;OAEG;IACH,OAAO,CAAC,kBAAkB;CA+B3B"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Resources handler
|
|
3
|
+
* Implements resources/list and resources/read for skills
|
|
4
|
+
*/
|
|
5
|
+
export class ResourcesHandler {
|
|
6
|
+
loader;
|
|
7
|
+
logger;
|
|
8
|
+
constructor(loader, logger) {
|
|
9
|
+
this.loader = loader;
|
|
10
|
+
this.logger = logger;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Handle resources/list request
|
|
14
|
+
* Returns all available skills as resources
|
|
15
|
+
*/
|
|
16
|
+
async listResources() {
|
|
17
|
+
this.logger.debug('Handling resources/list');
|
|
18
|
+
const skills = await this.loader.loadSkills();
|
|
19
|
+
const resources = [];
|
|
20
|
+
for (const [name, skill] of skills) {
|
|
21
|
+
resources.push(this.skillToResource(skill));
|
|
22
|
+
}
|
|
23
|
+
this.logger.info(`Returning ${resources.length} resources`);
|
|
24
|
+
return { resources };
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Handle resources/read request
|
|
28
|
+
* Returns the full content of a specific skill
|
|
29
|
+
*/
|
|
30
|
+
async readResource(uri) {
|
|
31
|
+
this.logger.debug(`Handling resources/read: ${uri}`);
|
|
32
|
+
// Extract skill name from URI (axiom://skill/{name})
|
|
33
|
+
const match = uri.match(/^axiom:\/\/skill\/(.+)$/);
|
|
34
|
+
if (!match) {
|
|
35
|
+
throw new Error(`Invalid resource URI: ${uri}`);
|
|
36
|
+
}
|
|
37
|
+
const skillName = match[1];
|
|
38
|
+
const skill = await this.loader.getSkill(skillName);
|
|
39
|
+
if (!skill) {
|
|
40
|
+
throw new Error(`Skill not found: ${skillName}`);
|
|
41
|
+
}
|
|
42
|
+
this.logger.info(`Returning skill content: ${skillName} (${skill.content.length} bytes)`);
|
|
43
|
+
return {
|
|
44
|
+
contents: [{
|
|
45
|
+
uri,
|
|
46
|
+
mimeType: 'text/markdown',
|
|
47
|
+
text: this.formatSkillContent(skill)
|
|
48
|
+
}]
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Convert a Skill to an MCP Resource
|
|
53
|
+
*/
|
|
54
|
+
skillToResource(skill) {
|
|
55
|
+
return {
|
|
56
|
+
uri: `axiom://skill/${skill.name}`,
|
|
57
|
+
name: this.formatSkillName(skill.name),
|
|
58
|
+
description: skill.description,
|
|
59
|
+
mimeType: 'text/markdown'
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Format skill name for display (kebab-case to Title Case)
|
|
64
|
+
*/
|
|
65
|
+
formatSkillName(name) {
|
|
66
|
+
return name
|
|
67
|
+
.split('-')
|
|
68
|
+
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
|
69
|
+
.join(' ');
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Format skill content with frontmatter metadata preserved as human-readable header
|
|
73
|
+
*/
|
|
74
|
+
formatSkillContent(skill) {
|
|
75
|
+
const header = [
|
|
76
|
+
`# ${this.formatSkillName(skill.name)}`,
|
|
77
|
+
'',
|
|
78
|
+
skill.description,
|
|
79
|
+
''
|
|
80
|
+
];
|
|
81
|
+
if (skill.mcp) {
|
|
82
|
+
header.push('## Metadata');
|
|
83
|
+
if (skill.mcp.category) {
|
|
84
|
+
header.push(`- **Category**: ${skill.mcp.category}`);
|
|
85
|
+
}
|
|
86
|
+
if (skill.mcp.tags && skill.mcp.tags.length > 0) {
|
|
87
|
+
header.push(`- **Tags**: ${skill.mcp.tags.join(', ')}`);
|
|
88
|
+
}
|
|
89
|
+
if (skill.mcp.related && skill.mcp.related.length > 0) {
|
|
90
|
+
header.push(`- **Related Skills**: ${skill.mcp.related.join(', ')}`);
|
|
91
|
+
}
|
|
92
|
+
header.push('');
|
|
93
|
+
}
|
|
94
|
+
header.push('---');
|
|
95
|
+
header.push('');
|
|
96
|
+
return header.join('\n') + skill.content;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=handler.js.map
|