catalyst-core-internal 0.1.2 → 0.1.3
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/README.md +4 -4
- package/bin/catalyst.js +8 -1
- package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/BridgeMessageValidator.kt +3 -11
- package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/CustomWebview.kt +12 -1
- package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/MainActivity.kt +18 -3
- package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/plugins/CatalystPlugin.kt +5 -0
- package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/plugins/GeneratedPluginIndex.kt +6 -0
- package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/plugins/PluginBridge.kt +240 -0
- package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/SecurityBridgeTest.kt +199 -0
- package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/plugins/PluginBridgeTest.kt +121 -0
- package/dist/native/bridge/hooks.js +4 -4
- package/dist/native/bridge/useBaseHook.js +5 -4
- package/dist/native/bridge/utils/NativeBridge.js +4 -4
- package/dist/native/buildAppAndroid.js +2 -2
- package/dist/native/buildAppIos.js +10 -17
- package/dist/native/internal-plugins/device-info-plugin/android/DeviceInfoPlugin.kt +43 -0
- package/dist/native/internal-plugins/device-info-plugin/ios/DeviceInfoPlugin.swift +28 -0
- package/dist/native/internal-plugins/device-info-plugin/manifest.json +19 -0
- package/dist/native/internalPluginUtils.js +1 -0
- package/dist/native/iosnativeWebView/Sources/Core/Plugins/CatalystPlugin.swift +5 -0
- package/dist/native/iosnativeWebView/Sources/Core/Plugins/GeneratedPluginIndex.swift +6 -0
- package/dist/native/iosnativeWebView/Sources/Core/Plugins/PluginBridge.swift +364 -0
- package/dist/native/iosnativeWebView/Sources/Core/Utils/CacheManager.swift +13 -2
- package/dist/native/iosnativeWebView/Sources/Core/WebView/NativeBridge.swift +13 -2
- package/dist/native/iosnativeWebView/Sources/Core/WebView/WeakScriptMessageHandler.swift +14 -0
- package/dist/native/iosnativeWebView/Sources/Core/WebView/WebView.swift +6 -0
- package/dist/native/iosnativeWebView/iosnativeWebView.xcodeproj/project.pbxproj +4 -0
- package/dist/native/iosnativeWebView/iosnativeWebView.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +36 -0
- package/dist/native/iosnativeWebView/iosnativeWebView.xctestplan +1 -0
- package/dist/native/iosnativeWebView/iosnativeWebViewTests/BridgeCommandHandlerSecurityTests.swift +212 -0
- package/dist/native/iosnativeWebView/iosnativeWebViewTests/FrameworkServerUtilsTests.swift +14 -4
- package/dist/native/iosnativeWebView/iosnativeWebViewTests/PluginBridgeTests.swift +160 -0
- package/dist/native/iosnativeWebView/iosnativeWebViewTests/ScreenSecureManagerTests.swift +121 -0
- package/dist/native/iosnativeWebView/iosnativeWebViewTests/WebViewTests.swift +9 -21
- package/dist/native/plugin-bridge/PluginBridge.js +1 -0
- package/dist/native/pluginComposerAndroid.js +9 -0
- package/dist/native/pluginComposerIos.js +7 -0
- package/dist/scripts/plugins.js +1 -0
- package/package.json +3 -2
- package/mcp_v2/conversion-tasks.json +0 -371
- package/mcp_v2/knowledge-base.json +0 -1450
- package/mcp_v2/lib/helpers.js +0 -145
- package/mcp_v2/mcp.js +0 -366
- package/mcp_v2/package.json +0 -13
- package/mcp_v2/schema.sql +0 -88
- package/mcp_v2/setup.js +0 -262
- package/mcp_v2/tools/build.js +0 -449
- package/mcp_v2/tools/config.js +0 -262
- package/mcp_v2/tools/conversion.js +0 -492
- package/mcp_v2/tools/debug.js +0 -62
- package/mcp_v2/tools/knowledge.js +0 -213
- package/mcp_v2/tools/sync.js +0 -21
- package/mcp_v2/tools/tasks.js +0 -844
package/mcp_v2/setup.js
DELETED
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Catalyst MCP v2 — setup.js
|
|
4
|
-
* Run once: npx catalyst-mcp-setup (or node setup.js from mcp_v2/)
|
|
5
|
-
*
|
|
6
|
-
* Steps:
|
|
7
|
-
* 1. Verify this is a valid catalyst-core project
|
|
8
|
-
* 2. Create context.db, run schema.sql
|
|
9
|
-
* 3. Seed framework_knowledge from knowledge-base.json (static rows)
|
|
10
|
-
* 4. Seed known_errors from knowledge-base.json known_errors section
|
|
11
|
-
* 5. Run sync_catalyst_docs once (dynamic sitemap rows)
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
const fs = require('fs');
|
|
15
|
-
const path = require('path');
|
|
16
|
-
const Database = require('better-sqlite3');
|
|
17
|
-
const https = require('https');
|
|
18
|
-
const crypto = require('crypto');
|
|
19
|
-
|
|
20
|
-
const MCP_DIR = __dirname;
|
|
21
|
-
const DB_PATH = path.join(MCP_DIR, 'context.db');
|
|
22
|
-
const SCHEMA_PATH = path.join(MCP_DIR, 'schema.sql');
|
|
23
|
-
const KB_PATH = path.join(MCP_DIR, 'knowledge-base.json');
|
|
24
|
-
const SITEMAP_URL = 'https://catalyst.1mg.com/public_docs/sitemap.xml';
|
|
25
|
-
|
|
26
|
-
// ── 1. Find & validate catalyst project ──────────────────────────────────────
|
|
27
|
-
|
|
28
|
-
function findCatalystRoot() {
|
|
29
|
-
let dir = process.cwd();
|
|
30
|
-
while (dir !== path.parse(dir).root) {
|
|
31
|
-
const pkgPath = path.join(dir, 'package.json');
|
|
32
|
-
if (fs.existsSync(pkgPath)) {
|
|
33
|
-
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
34
|
-
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
35
|
-
if (deps['catalyst-core']) {
|
|
36
|
-
return { dir, pkg, version: deps['catalyst-core'] };
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
dir = path.dirname(dir);
|
|
40
|
-
}
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// ── 2. DB init ────────────────────────────────────────────────────────────────
|
|
45
|
-
|
|
46
|
-
function initDb() {
|
|
47
|
-
const schema = fs.readFileSync(SCHEMA_PATH, 'utf8');
|
|
48
|
-
const db = new Database(DB_PATH);
|
|
49
|
-
db.exec(schema);
|
|
50
|
-
return db;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// ── 3 & 4. Seed from knowledge-base.json ─────────────────────────────────────
|
|
54
|
-
|
|
55
|
-
function seedKnowledgeBase(db, projectInfo) {
|
|
56
|
-
const kb = JSON.parse(fs.readFileSync(KB_PATH, 'utf8'));
|
|
57
|
-
|
|
58
|
-
// DELETE existing static rows so re-runs reflect updated knowledge-base.json
|
|
59
|
-
db.prepare(`DELETE FROM framework_knowledge WHERE source = 'static'`).run();
|
|
60
|
-
db.prepare(`DELETE FROM known_errors`).run();
|
|
61
|
-
|
|
62
|
-
const insertKnowledge = db.prepare(`
|
|
63
|
-
INSERT INTO framework_knowledge (section, title, content, layer, source, tags, github_files)
|
|
64
|
-
VALUES (@section, @title, @content, @layer, @source, @tags, @github_files)
|
|
65
|
-
`);
|
|
66
|
-
|
|
67
|
-
const insertError = db.prepare(`
|
|
68
|
-
INSERT INTO known_errors (symptom, cause, fix, layer, tags)
|
|
69
|
-
VALUES (@symptom, @cause, @fix, @layer, @tags)
|
|
70
|
-
`);
|
|
71
|
-
|
|
72
|
-
let knowledgeCount = 0;
|
|
73
|
-
let errorCount = 0;
|
|
74
|
-
|
|
75
|
-
const seedAll = db.transaction(() => {
|
|
76
|
-
for (const entry of kb) {
|
|
77
|
-
if (entry.section === 'known_errors') {
|
|
78
|
-
// known_errors entries encode symptom/cause/fix in content as:
|
|
79
|
-
// "Symptom: ... Cause: ... Fix: ..."
|
|
80
|
-
const content = entry.content || '';
|
|
81
|
-
const symptomMatch = content.match(/Symptom:\s*([^.]+\.?)/i);
|
|
82
|
-
const causeMatch = content.match(/Cause:\s*([^.]+\.?)/i);
|
|
83
|
-
const fixMatch = content.match(/Fix:\s*([\s\S]+)/i);
|
|
84
|
-
insertError.run({
|
|
85
|
-
symptom: symptomMatch ? symptomMatch[1].trim() : entry.title,
|
|
86
|
-
cause: causeMatch ? causeMatch[1].trim() : '',
|
|
87
|
-
fix: fixMatch ? fixMatch[1].trim() : '',
|
|
88
|
-
layer: entry.layer,
|
|
89
|
-
tags: JSON.stringify(entry.tags || []),
|
|
90
|
-
});
|
|
91
|
-
errorCount++;
|
|
92
|
-
} else {
|
|
93
|
-
insertKnowledge.run({
|
|
94
|
-
section: entry.section,
|
|
95
|
-
title: entry.title,
|
|
96
|
-
content: entry.content,
|
|
97
|
-
layer: entry.layer,
|
|
98
|
-
source: 'static',
|
|
99
|
-
tags: JSON.stringify(entry.tags || []),
|
|
100
|
-
github_files: entry.github_files ? JSON.stringify(entry.github_files) : null,
|
|
101
|
-
});
|
|
102
|
-
knowledgeCount++;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
seedAll();
|
|
108
|
-
console.log(` ✓ Seeded ${knowledgeCount} knowledge entries`);
|
|
109
|
-
console.log(` ✓ Seeded ${errorCount} known_errors entries`);
|
|
110
|
-
|
|
111
|
-
// Store project context
|
|
112
|
-
db.prepare(`
|
|
113
|
-
INSERT OR REPLACE INTO project_context (id, repo_path, package_name, catalyst_version, detected_at)
|
|
114
|
-
VALUES (1, @repo_path, @package_name, @catalyst_version, datetime('now'))
|
|
115
|
-
`).run({
|
|
116
|
-
repo_path: projectInfo.dir,
|
|
117
|
-
package_name: projectInfo.pkg.name || 'unknown',
|
|
118
|
-
catalyst_version: projectInfo.version,
|
|
119
|
-
});
|
|
120
|
-
console.log(` ✓ Project context stored (${projectInfo.pkg.name}, catalyst-core@${projectInfo.version})`);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// ── 5. sync_catalyst_docs (initial run) ───────────────────────────────────────
|
|
124
|
-
|
|
125
|
-
function fetchUrl(url) {
|
|
126
|
-
return new Promise((resolve, reject) => {
|
|
127
|
-
const mod = url.startsWith('https') ? https : require('http');
|
|
128
|
-
mod.get(url, (res) => {
|
|
129
|
-
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
130
|
-
return fetchUrl(res.headers.location).then(resolve).catch(reject);
|
|
131
|
-
}
|
|
132
|
-
let data = '';
|
|
133
|
-
res.on('data', (chunk) => (data += chunk));
|
|
134
|
-
res.on('end', () => resolve(data));
|
|
135
|
-
}).on('error', reject);
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function parseSitemapUrls(xml) {
|
|
140
|
-
const matches = xml.match(/<loc>(.*?)<\/loc>/g) || [];
|
|
141
|
-
return matches.map((m) => m.replace(/<\/?loc>/g, '').trim());
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
function stripHtml(html) {
|
|
145
|
-
// Very simple strip — good enough for catalyst docs
|
|
146
|
-
return html
|
|
147
|
-
.replace(/<script[\s\S]*?<\/script>/gi, '')
|
|
148
|
-
.replace(/<style[\s\S]*?<\/style>/gi, '')
|
|
149
|
-
.replace(/<[^>]+>/g, ' ')
|
|
150
|
-
.replace(/\s+/g, ' ')
|
|
151
|
-
.trim();
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function contentHash(text) {
|
|
155
|
-
return crypto.createHash('sha256').update(text).digest('hex').slice(0, 16);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
async function syncCatalystDocs(db) {
|
|
159
|
-
console.log('\n Fetching sitemap...');
|
|
160
|
-
let xml;
|
|
161
|
-
try {
|
|
162
|
-
xml = await fetchUrl(SITEMAP_URL);
|
|
163
|
-
} catch (e) {
|
|
164
|
-
console.warn(` ⚠ Could not fetch sitemap (${e.message}). Skipping live docs sync.`);
|
|
165
|
-
console.warn(' You can run sync later via the sync_catalyst_docs MCP tool.');
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
const urls = parseSitemapUrls(xml);
|
|
170
|
-
console.log(` Found ${urls.length} URLs in sitemap`);
|
|
171
|
-
|
|
172
|
-
const insertKnowledge = db.prepare(`
|
|
173
|
-
INSERT INTO framework_knowledge (section, title, content, layer, source, tags, url)
|
|
174
|
-
VALUES (@section, @title, @content, @layer, 'sitemap', '[]', @url)
|
|
175
|
-
`);
|
|
176
|
-
|
|
177
|
-
const insertSnapshot = db.prepare(`
|
|
178
|
-
INSERT INTO doc_snapshots (url, content_hash, slot) VALUES (@url, @hash, 'curr')
|
|
179
|
-
`);
|
|
180
|
-
|
|
181
|
-
const insertLink = db.prepare(`
|
|
182
|
-
INSERT INTO linkage_map (url, knowledge_id) VALUES (@url, @knowledge_id)
|
|
183
|
-
`);
|
|
184
|
-
|
|
185
|
-
let synced = 0;
|
|
186
|
-
let failed = 0;
|
|
187
|
-
|
|
188
|
-
for (const url of urls) {
|
|
189
|
-
try {
|
|
190
|
-
const html = await fetchUrl(url);
|
|
191
|
-
const text = stripHtml(html);
|
|
192
|
-
const hash = contentHash(text);
|
|
193
|
-
|
|
194
|
-
// Extract a title from <title> tag if present
|
|
195
|
-
const titleMatch = html.match(/<title[^>]*>(.*?)<\/title>/i);
|
|
196
|
-
const title = titleMatch ? titleMatch[1].trim() : url.split('/').pop() || url;
|
|
197
|
-
|
|
198
|
-
// Truncate content to 2000 chars to keep DB lean
|
|
199
|
-
const content = text.slice(0, 2000);
|
|
200
|
-
|
|
201
|
-
const result = db.transaction(() => {
|
|
202
|
-
const row = insertKnowledge.run({ section: 'sitemap', title, content, layer: 'Component', url });
|
|
203
|
-
insertSnapshot.run({ url, hash });
|
|
204
|
-
insertLink.run({ url, knowledge_id: row.lastInsertRowid });
|
|
205
|
-
})();
|
|
206
|
-
|
|
207
|
-
synced++;
|
|
208
|
-
process.stdout.write(`\r Synced ${synced}/${urls.length} pages...`);
|
|
209
|
-
} catch (e) {
|
|
210
|
-
failed++;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
console.log(`\n ✓ Synced ${synced} pages (${failed} failed)`);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
// ── Main ──────────────────────────────────────────────────────────────────────
|
|
218
|
-
|
|
219
|
-
async function main() {
|
|
220
|
-
console.log('Catalyst MCP v2 — Setup\n');
|
|
221
|
-
|
|
222
|
-
// 1. Validate catalyst project
|
|
223
|
-
const projectInfo = findCatalystRoot();
|
|
224
|
-
if (!projectInfo) {
|
|
225
|
-
console.error('✗ No catalyst-core dependency found in any package.json above this directory.');
|
|
226
|
-
console.error(' Run setup from inside your catalyst project.');
|
|
227
|
-
process.exit(1);
|
|
228
|
-
}
|
|
229
|
-
console.log(`✓ Catalyst project: ${projectInfo.pkg.name || projectInfo.dir}`);
|
|
230
|
-
console.log(` catalyst-core@${projectInfo.version}`);
|
|
231
|
-
|
|
232
|
-
// 2. Init DB
|
|
233
|
-
console.log('\nInitializing context.db...');
|
|
234
|
-
const db = initDb();
|
|
235
|
-
console.log(` ✓ DB created at ${DB_PATH}`);
|
|
236
|
-
|
|
237
|
-
// 3 & 4. Seed static knowledge
|
|
238
|
-
console.log('\nSeeding knowledge-base.json...');
|
|
239
|
-
seedKnowledgeBase(db, projectInfo);
|
|
240
|
-
|
|
241
|
-
// 5. Initial sitemap sync — disabled (slow, use sync_catalyst_docs MCP tool manually)
|
|
242
|
-
// console.log('\nRunning initial sync_catalyst_docs...');
|
|
243
|
-
// await syncCatalystDocs(db);
|
|
244
|
-
|
|
245
|
-
db.close();
|
|
246
|
-
console.log('\n✓ Setup complete. MCP is ready.\n');
|
|
247
|
-
const mcpConfig = JSON.stringify({
|
|
248
|
-
"catalyst-mcp": {
|
|
249
|
-
"command": "node",
|
|
250
|
-
"args": [path.join(MCP_DIR, 'mcp.js')],
|
|
251
|
-
"disabledTools": [],
|
|
252
|
-
"disabled": false
|
|
253
|
-
}
|
|
254
|
-
}, null, 2);
|
|
255
|
-
console.log('Add to your MCP config (Claude, Cursor, Windsurf, or any MCP-compatible client):');
|
|
256
|
-
console.log(mcpConfig);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
main().catch((e) => {
|
|
260
|
-
console.error('Setup failed:', e.message);
|
|
261
|
-
process.exit(1);
|
|
262
|
-
});
|