catalyst-core-internal 0.1.4 → 0.1.5

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.
Files changed (41) hide show
  1. package/bin/catalyst.js +1 -8
  2. package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/BridgeMessageValidator.kt +1 -1
  3. package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/CustomWebview.kt +1 -12
  4. package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/MainActivity.kt +3 -18
  5. package/dist/native/buildAppAndroid.js +2 -2
  6. package/dist/native/buildAppIos.js +17 -10
  7. package/dist/native/iosnativeWebView/Sources/Core/WebView/NativeBridge.swift +2 -13
  8. package/dist/native/iosnativeWebView/Sources/Core/WebView/WebView.swift +0 -6
  9. package/dist/native/iosnativeWebView/iosnativeWebView.xcodeproj/project.pbxproj +0 -4
  10. package/mcp_v2/conversion-tasks.json +326 -0
  11. package/mcp_v2/knowledge-base.json +1068 -0
  12. package/mcp_v2/lib/helpers.js +159 -0
  13. package/mcp_v2/mcp.js +562 -0
  14. package/mcp_v2/package.json +13 -0
  15. package/mcp_v2/schema.sql +88 -0
  16. package/mcp_v2/setup.js +276 -0
  17. package/mcp_v2/tools/build.js +686 -0
  18. package/mcp_v2/tools/config.js +453 -0
  19. package/mcp_v2/tools/conversion.js +799 -0
  20. package/mcp_v2/tools/debug.js +113 -0
  21. package/mcp_v2/tools/knowledge.js +219 -0
  22. package/mcp_v2/tools/sync.js +23 -0
  23. package/mcp_v2/tools/tasks.js +945 -0
  24. package/package.json +2 -3
  25. package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/plugins/CatalystPlugin.kt +0 -7
  26. package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/plugins/GeneratedPluginIndex.kt +0 -6
  27. package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/plugins/PluginBridge.kt +0 -253
  28. package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/plugins/PluginBridgeTest.kt +0 -139
  29. package/dist/native/internal-plugins/device-info-plugin/android/DeviceInfoPlugin.kt +0 -43
  30. package/dist/native/internal-plugins/device-info-plugin/ios/DeviceInfoPlugin.swift +0 -28
  31. package/dist/native/internal-plugins/device-info-plugin/manifest.json +0 -19
  32. package/dist/native/internalPluginUtils.js +0 -1
  33. package/dist/native/iosnativeWebView/Sources/Core/Plugins/CatalystPlugin.swift +0 -5
  34. package/dist/native/iosnativeWebView/Sources/Core/Plugins/GeneratedPluginIndex.swift +0 -6
  35. package/dist/native/iosnativeWebView/Sources/Core/Plugins/PluginBridge.swift +0 -364
  36. package/dist/native/iosnativeWebView/Sources/Core/WebView/WeakScriptMessageHandler.swift +0 -14
  37. package/dist/native/iosnativeWebView/iosnativeWebViewTests/PluginBridgeTests.swift +0 -160
  38. package/dist/native/plugin-bridge/PluginBridge.js +0 -1
  39. package/dist/native/pluginComposerAndroid.js +0 -9
  40. package/dist/native/pluginComposerIos.js +0 -7
  41. package/dist/scripts/plugins.js +0 -1
@@ -0,0 +1,159 @@
1
+ "use strict"
2
+ const fs = require("fs")
3
+ const path = require("path")
4
+
5
+ /**
6
+ * Parse a semver-like version string into comparable parts.
7
+ * Handles: "0.0.3-canary.3", "0.1.0-canary.4", "^0.1.0-canary.4"
8
+ * Returns { major, minor, patch, pre, preNum } or null if unparseable.
9
+ */
10
+ function parseVersion(v) {
11
+ if (!v) return null
12
+ const clean = v.replace(/^[\^~]/, "")
13
+ const m = clean.match(/^(\d+)\.(\d+)\.(\d+)(?:-(\w+)\.(\d+))?/)
14
+ if (!m) return null
15
+ return {
16
+ major: +m[1],
17
+ minor: +m[2],
18
+ patch: +m[3],
19
+ pre: m[4] || null,
20
+ preNum: m[5] ? +m[5] : 0,
21
+ raw: clean,
22
+ }
23
+ }
24
+
25
+ /**
26
+ * Returns true if version a is older than version b.
27
+ * Only works for matching pre-release labels (e.g. both "canary").
28
+ */
29
+ function versionOlderThan(a, b) {
30
+ const pa = parseVersion(a)
31
+ const pb = parseVersion(b)
32
+ if (!pa || !pb) return false
33
+ if (pa.major !== pb.major) return pa.major < pb.major
34
+ if (pa.minor !== pb.minor) return pa.minor < pb.minor
35
+ if (pa.patch !== pb.patch) return pa.patch < pb.patch
36
+ if (pa.pre && pb.pre && pa.pre === pb.pre) return pa.preNum < pb.preNum
37
+ return false
38
+ }
39
+
40
+ /**
41
+ * Walk up the directory tree looking for a package.json that depends on catalyst-core.
42
+ * Returns { dir, pkg, catalystVersion, installedVersion, versionMeta } or null.
43
+ */
44
+ function findCatalystRoot() {
45
+ // Walk up from __dirname first (mcp always lives inside the project at .catalyst/mcp/),
46
+ // then fall back to cwd. This ensures the right root is found regardless of what
47
+ // cwd the editor/IDE sets when spawning the MCP process.
48
+ const startDirs = [path.resolve(__dirname, "..", ".."), process.cwd()]
49
+
50
+ for (const start of startDirs) {
51
+ let dir = start
52
+ while (dir !== path.parse(dir).root) {
53
+ const pkgPath = path.join(dir, "package.json")
54
+ if (fs.existsSync(pkgPath)) {
55
+ try {
56
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"))
57
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies }
58
+ if (deps["catalyst-core"]) {
59
+ const nmPath = path.join(dir, "node_modules", "catalyst-core")
60
+ const installed = fs.existsSync(nmPath)
61
+ // Read the actual installed version from node_modules
62
+ let installedVersion = null
63
+ if (installed) {
64
+ try {
65
+ const nmPkg = JSON.parse(
66
+ fs.readFileSync(path.join(nmPath, "package.json"), "utf8")
67
+ )
68
+ installedVersion = nmPkg.version || null
69
+ } catch {
70
+ /* ignore */
71
+ }
72
+ }
73
+ const declaredRef = deps["catalyst-core"]
74
+ const isGithubRef = declaredRef.startsWith("github:") || declaredRef.includes("#")
75
+ return {
76
+ dir,
77
+ pkg,
78
+ catalystVersion: declaredRef, // what package.json says (may be github ref)
79
+ installedVersion, // what's actually in node_modules e.g. "0.0.3-canary.3"
80
+ notInstalled: !installed,
81
+ versionMeta: {
82
+ declaredRef,
83
+ isGithubRef,
84
+ installedVersion,
85
+ parsed: parseVersion(installedVersion),
86
+ },
87
+ }
88
+ }
89
+ } catch {
90
+ // Malformed package.json — skip, keep walking up
91
+ }
92
+ }
93
+ dir = path.dirname(dir)
94
+ }
95
+ }
96
+ return null
97
+ }
98
+
99
+ /**
100
+ * File-system helpers scoped to a project root.
101
+ */
102
+ function makeProjectHelpers(root) {
103
+ function fileExists(rel) {
104
+ return fs.existsSync(path.join(root, rel))
105
+ }
106
+
107
+ function readJson(rel) {
108
+ try {
109
+ return JSON.parse(fs.readFileSync(path.join(root, rel), "utf8"))
110
+ } catch {
111
+ return null
112
+ }
113
+ }
114
+
115
+ function readText(rel) {
116
+ try {
117
+ return fs.readFileSync(path.join(root, rel), "utf8")
118
+ } catch {
119
+ return null
120
+ }
121
+ }
122
+
123
+ /**
124
+ * Walk src/**\/*.{js,jsx,ts,tsx} and return relative paths that match pattern.
125
+ */
126
+ function grepSrc(pattern) {
127
+ const re = new RegExp(pattern)
128
+ const matches = []
129
+ function walk(dir) {
130
+ let entries
131
+ try {
132
+ entries = fs.readdirSync(dir, { withFileTypes: true })
133
+ } catch {
134
+ return
135
+ }
136
+ for (const e of entries) {
137
+ if (e.name === "node_modules" || e.name === ".git") continue
138
+ const full = path.join(dir, e.name)
139
+ if (e.isDirectory()) {
140
+ walk(full)
141
+ } else if (/\.(js|jsx|ts|tsx)$/.test(e.name)) {
142
+ try {
143
+ if (re.test(fs.readFileSync(full, "utf8"))) {
144
+ matches.push(path.relative(root, full))
145
+ }
146
+ } catch {
147
+ // Ignore unreadable files during source scan.
148
+ }
149
+ }
150
+ }
151
+ }
152
+ walk(path.join(root, "src"))
153
+ return matches
154
+ }
155
+
156
+ return { fileExists, readJson, readText, grepSrc }
157
+ }
158
+
159
+ module.exports = { findCatalystRoot, makeProjectHelpers, versionOlderThan, parseVersion }