tokensafe-ui 0.1.16 → 0.1.17

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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createTokensafeMcpServer
3
- } from "./chunk-4SGTSB7N.js";
3
+ } from "./chunk-6BEDZVKQ.js";
4
4
 
5
5
  // src/mcp.ts
6
6
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  buildDependencyGraph,
3
3
  observeDiff
4
- } from "./chunk-6SMML66I.js";
4
+ } from "./chunk-ELRFTCSR.js";
5
5
  import {
6
6
  applyPatch
7
7
  } from "./chunk-N7XIVYCL.js";
@@ -9,7 +9,7 @@ import {
9
9
  activeInstances,
10
10
  testAction,
11
11
  testEffect
12
- } from "./chunk-XS6EEO46.js";
12
+ } from "./chunk-OSRTCWKW.js";
13
13
 
14
14
  // ../mcp/dist/index.js
15
15
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  activeInstances
3
- } from "./chunk-XS6EEO46.js";
3
+ } from "./chunk-OSRTCWKW.js";
4
4
 
5
5
  // ../observer/dist/index.js
6
6
  import fs from "fs";
@@ -1711,8 +1711,12 @@ function renderVNode(node, instance) {
1711
1711
  for (const item of val) {
1712
1712
  if (item !== null && item !== void 0 && typeof item !== "boolean") {
1713
1713
  const rendered = renderVNode(item, instance);
1714
+ if (rendered.nodeType === 11) {
1715
+ currentNodes.push(...Array.from(rendered.childNodes));
1716
+ } else {
1717
+ currentNodes.push(rendered);
1718
+ }
1714
1719
  endAnchor.parentNode?.insertBefore(rendered, endAnchor);
1715
- currentNodes.push(rendered);
1716
1720
  }
1717
1721
  }
1718
1722
  return;
@@ -1723,8 +1727,12 @@ function renderVNode(node, instance) {
1723
1727
  }
1724
1728
  currentNodes = [];
1725
1729
  const rendered = renderVNode(val, instance);
1730
+ if (rendered.nodeType === 11) {
1731
+ currentNodes = Array.from(rendered.childNodes);
1732
+ } else {
1733
+ currentNodes = [rendered];
1734
+ }
1726
1735
  endAnchor.parentNode?.insertBefore(rendered, endAnchor);
1727
- currentNodes.push(rendered);
1728
1736
  return;
1729
1737
  }
1730
1738
  if (val === null || val === void 0 || typeof val === "boolean") {
@@ -0,0 +1,43 @@
1
+ // ../oumv/dist/chunk-CMTT7FY2.js
2
+ var registry = /* @__PURE__ */ new Map();
3
+ function componentKey(component) {
4
+ if (typeof component === "string") return component;
5
+ return component?.id || component?.name || component?.displayName || component?.__tokensafe_id__ || "anonymous-component";
6
+ }
7
+ function defineOUMVComponent(component, contract) {
8
+ const record = {
9
+ ...contract,
10
+ componentId: componentKey(component),
11
+ componentName: componentKey(component),
12
+ evidence: {
13
+ provenance: "contract",
14
+ sourceAdapter: "tokensafe-ui-contracts",
15
+ confidence: "confirmed"
16
+ }
17
+ };
18
+ registry.set(record.componentId, record);
19
+ try {
20
+ if (component && typeof component === "object") {
21
+ component.__oumv_contract__ = record;
22
+ }
23
+ } catch {
24
+ }
25
+ return component;
26
+ }
27
+ function getOUMVComponentContract(component) {
28
+ const key = componentKey(component);
29
+ return registry.get(key) || (component && typeof component === "object" ? component.__oumv_contract__ : void 0);
30
+ }
31
+ function listOUMVComponentContracts() {
32
+ return Array.from(registry.values());
33
+ }
34
+ function resetOUMVComponentContracts() {
35
+ registry.clear();
36
+ }
37
+
38
+ export {
39
+ defineOUMVComponent,
40
+ getOUMVComponentContract,
41
+ listOUMVComponentContracts,
42
+ resetOUMVComponentContracts
43
+ };
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  atomicApplySourceEdit,
3
3
  validateWorkspacePath
4
- } from "./chunk-4SGTSB7N.js";
4
+ } from "./chunk-6BEDZVKQ.js";
5
5
  import {
6
6
  buildDependencyGraph,
7
7
  observe
8
- } from "./chunk-6SMML66I.js";
8
+ } from "./chunk-ELRFTCSR.js";
9
9
  import {
10
10
  testAction
11
- } from "./chunk-XS6EEO46.js";
11
+ } from "./chunk-OSRTCWKW.js";
12
12
 
13
13
  // ../oumv/dist/chunk-ONAJHNWR.js
14
14
  import fs from "fs";
@@ -1029,9 +1029,133 @@ actions: [${actions.join(", ")}]
1029
1029
  }
1030
1030
 
1031
1031
  // ../oumv/dist/index.js
1032
+ import fs22 from "fs";
1033
+ import path22 from "path";
1034
+ import crypto3 from "crypto";
1032
1035
  import fs3 from "fs";
1033
1036
  import path3 from "path";
1034
- import crypto3 from "crypto";
1037
+ import * as parser3 from "@babel/parser";
1038
+ function scanSourceForComponents(source, filePath) {
1039
+ const components = [];
1040
+ try {
1041
+ const ast = parser3.parse(source, {
1042
+ sourceType: "module",
1043
+ plugins: ["jsx", "typescript"]
1044
+ });
1045
+ const isPascalCase = (name) => /^[A-Z][a-zA-Z0-9_]*$/.test(name);
1046
+ for (const node of ast.program.body) {
1047
+ if (node.type === "FunctionDeclaration" && node.id && isPascalCase(node.id.name)) {
1048
+ const name = node.id.name;
1049
+ components.push({
1050
+ id: `frontend.component:${name}`,
1051
+ name,
1052
+ filePath,
1053
+ lineStart: node.loc?.start.line ?? 1,
1054
+ lineEnd: node.loc?.end.line ?? 1,
1055
+ actionTriggers: extractActionTriggersFromNode(node),
1056
+ isDefaultExport: false
1057
+ });
1058
+ }
1059
+ if (node.type === "ExportNamedDeclaration" && node.declaration) {
1060
+ if (node.declaration.type === "FunctionDeclaration" && node.declaration.id && isPascalCase(node.declaration.id.name)) {
1061
+ const name = node.declaration.id.name;
1062
+ components.push({
1063
+ id: `frontend.component:${name}`,
1064
+ name,
1065
+ filePath,
1066
+ lineStart: node.loc?.start.line ?? 1,
1067
+ lineEnd: node.loc?.end.line ?? 1,
1068
+ actionTriggers: extractActionTriggersFromNode(node.declaration),
1069
+ isDefaultExport: false
1070
+ });
1071
+ } else if (node.declaration.type === "VariableDeclaration") {
1072
+ for (const decl of node.declaration.declarations) {
1073
+ if (decl.id.type === "Identifier" && isPascalCase(decl.id.name)) {
1074
+ const name = decl.id.name;
1075
+ components.push({
1076
+ id: `frontend.component:${name}`,
1077
+ name,
1078
+ filePath,
1079
+ lineStart: node.loc?.start.line ?? 1,
1080
+ lineEnd: node.loc?.end.line ?? 1,
1081
+ actionTriggers: decl.init ? extractActionTriggersFromNode(decl.init) : [],
1082
+ isDefaultExport: false
1083
+ });
1084
+ }
1085
+ }
1086
+ }
1087
+ }
1088
+ if (node.type === "ExportDefaultDeclaration") {
1089
+ let name = "DefaultExport";
1090
+ if (node.declaration.type === "FunctionDeclaration" && node.declaration.id) {
1091
+ name = node.declaration.id.name;
1092
+ } else if (node.declaration.type === "Identifier") {
1093
+ name = node.declaration.name;
1094
+ } else {
1095
+ const basename = path3.basename(filePath, path3.extname(filePath));
1096
+ if (isPascalCase(basename)) {
1097
+ name = basename;
1098
+ }
1099
+ }
1100
+ components.push({
1101
+ id: `frontend.component:${name}`,
1102
+ name,
1103
+ filePath,
1104
+ lineStart: node.loc?.start.line ?? 1,
1105
+ lineEnd: node.loc?.end.line ?? 1,
1106
+ actionTriggers: extractActionTriggersFromNode(node.declaration),
1107
+ isDefaultExport: true
1108
+ });
1109
+ }
1110
+ }
1111
+ } catch {
1112
+ }
1113
+ return components;
1114
+ }
1115
+ function extractActionTriggersFromNode(node) {
1116
+ const triggers = /* @__PURE__ */ new Set();
1117
+ const str = JSON.stringify(node);
1118
+ const eventRegex = /"(onClick|onSubmit|onChange|onInput|onKeyDown|onBlur)"/g;
1119
+ let match;
1120
+ while ((match = eventRegex.exec(str)) !== null) {
1121
+ triggers.add(match[1]);
1122
+ }
1123
+ return Array.from(triggers);
1124
+ }
1125
+ function scanProjectStaticResources(projectRoot) {
1126
+ const components = [];
1127
+ const routes = [];
1128
+ let totalFiles = 0;
1129
+ function walk(dir) {
1130
+ if (!fs3.existsSync(dir)) return;
1131
+ const entries = fs3.readdirSync(dir, { withFileTypes: true });
1132
+ for (const entry of entries) {
1133
+ if (entry.name.startsWith(".") || entry.name === "node_modules" || entry.name === "dist") {
1134
+ continue;
1135
+ }
1136
+ const fullPath = path3.join(dir, entry.name);
1137
+ if (entry.isDirectory()) {
1138
+ walk(fullPath);
1139
+ } else if (entry.isFile() && /\.(tsx|jsx|ts|js)$/.test(entry.name)) {
1140
+ totalFiles++;
1141
+ const relPath = path3.relative(projectRoot, fullPath);
1142
+ const source = fs3.readFileSync(fullPath, "utf-8");
1143
+ const found = scanSourceForComponents(source, relPath);
1144
+ components.push(...found);
1145
+ if (relPath.includes("app/") && relPath.endsWith("page.tsx")) {
1146
+ const routeSegment = relPath.replace(/^.*app\//, "").replace(/\/page\.tsx$/, "");
1147
+ routes.push({
1148
+ id: `frontend.route:/${routeSegment}`,
1149
+ path: `/${routeSegment}`,
1150
+ filePath: relPath
1151
+ });
1152
+ }
1153
+ }
1154
+ }
1155
+ }
1156
+ walk(projectRoot);
1157
+ return { components, routes, totalScannedFiles: totalFiles };
1158
+ }
1035
1159
  function createAgentDomAdapter(config = {}) {
1036
1160
  const projectRoot = config.projectRoot || process.cwd();
1037
1161
  return {
@@ -1082,13 +1206,23 @@ function createAgentDomAdapter(config = {}) {
1082
1206
  status: detached
1083
1207
  `;
1084
1208
  }
1085
- return {
1209
+ const result = {
1086
1210
  level: params.level,
1087
1211
  format,
1088
1212
  payload,
1089
1213
  tokenEstimate: Math.ceil(payload.length / 4),
1090
1214
  timestamp: Date.now()
1091
1215
  };
1216
+ if (params.level === "L2" || params.level === "L3") {
1217
+ const { listOUMVComponentContracts: listOUMVComponentContracts2 } = await import("./contracts-BANQPXNR-H5GPURH3.js");
1218
+ const contracts = listOUMVComponentContracts2().filter(
1219
+ (c) => !params.componentId || c.componentId === params.componentId
1220
+ );
1221
+ if (contracts.length > 0) {
1222
+ result.contracts = contracts;
1223
+ }
1224
+ }
1225
+ return result;
1092
1226
  },
1093
1227
  async understand(params) {
1094
1228
  const graph = buildDependencyGraph();
@@ -1106,14 +1240,14 @@ status: detached
1106
1240
  },
1107
1241
  async getSource(params) {
1108
1242
  const resolved = validateWorkspacePath(params.filePath, projectRoot);
1109
- if (!fs3.existsSync(resolved)) {
1243
+ if (!fs22.existsSync(resolved)) {
1110
1244
  throw new Error(`File not found: ${resolved}`);
1111
1245
  }
1112
- const source = fs3.readFileSync(resolved, "utf-8");
1246
+ const source = fs22.readFileSync(resolved, "utf-8");
1113
1247
  const version = "sha256:" + crypto3.createHash("sha256").update(source).digest("hex");
1114
1248
  return {
1115
1249
  componentId: params.componentId,
1116
- filePath: path3.relative(projectRoot, resolved),
1250
+ filePath: path22.relative(projectRoot, resolved),
1117
1251
  version,
1118
1252
  source
1119
1253
  };
@@ -1126,7 +1260,7 @@ status: detached
1126
1260
  });
1127
1261
  return {
1128
1262
  success: true,
1129
- filePath: path3.relative(projectRoot, res.filePath),
1263
+ filePath: path22.relative(projectRoot, res.filePath),
1130
1264
  version: res.version,
1131
1265
  message: res.message
1132
1266
  };
@@ -1147,5 +1281,7 @@ export {
1147
1281
  connectRedux,
1148
1282
  createReactAdapter,
1149
1283
  createVueAdapter,
1284
+ scanSourceForComponents,
1285
+ scanProjectStaticResources,
1150
1286
  createAgentDomAdapter
1151
1287
  };
package/dist/cli.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  startMcpServer
3
- } from "./chunk-2GDYBD6T.js";
4
- import "./chunk-4SGTSB7N.js";
5
- import "./chunk-6SMML66I.js";
3
+ } from "./chunk-22RTKSQM.js";
4
+ import "./chunk-6BEDZVKQ.js";
5
+ import "./chunk-ELRFTCSR.js";
6
6
  import "./chunk-N7XIVYCL.js";
7
- import "./chunk-XS6EEO46.js";
7
+ import "./chunk-OSRTCWKW.js";
8
8
 
9
9
  // src/cli.ts
10
10
  function parseCliArgs(argv) {
@@ -0,0 +1,12 @@
1
+ import {
2
+ defineOUMVComponent,
3
+ getOUMVComponentContract,
4
+ listOUMVComponentContracts,
5
+ resetOUMVComponentContracts
6
+ } from "./chunk-V3WONI5V.js";
7
+ export {
8
+ defineOUMVComponent,
9
+ getOUMVComponentContract,
10
+ listOUMVComponentContracts,
11
+ resetOUMVComponentContracts
12
+ };
package/dist/index.cjs CHANGED
@@ -1799,8 +1799,12 @@ function renderVNode(node, instance) {
1799
1799
  for (const item of val) {
1800
1800
  if (item !== null && item !== void 0 && typeof item !== "boolean") {
1801
1801
  const rendered = renderVNode(item, instance);
1802
+ if (rendered.nodeType === 11) {
1803
+ currentNodes.push(...Array.from(rendered.childNodes));
1804
+ } else {
1805
+ currentNodes.push(rendered);
1806
+ }
1802
1807
  endAnchor.parentNode?.insertBefore(rendered, endAnchor);
1803
- currentNodes.push(rendered);
1804
1808
  }
1805
1809
  }
1806
1810
  return;
@@ -1811,8 +1815,12 @@ function renderVNode(node, instance) {
1811
1815
  }
1812
1816
  currentNodes = [];
1813
1817
  const rendered = renderVNode(val, instance);
1818
+ if (rendered.nodeType === 11) {
1819
+ currentNodes = Array.from(rendered.childNodes);
1820
+ } else {
1821
+ currentNodes = [rendered];
1822
+ }
1814
1823
  endAnchor.parentNode?.insertBefore(rendered, endAnchor);
1815
- currentNodes.push(rendered);
1816
1824
  return;
1817
1825
  }
1818
1826
  if (val === null || val === void 0 || typeof val === "boolean") {
package/dist/index.js CHANGED
@@ -60,7 +60,7 @@ import {
60
60
  useRef,
61
61
  useState,
62
62
  z3
63
- } from "./chunk-XS6EEO46.js";
63
+ } from "./chunk-OSRTCWKW.js";
64
64
  export {
65
65
  ErrorBoundary,
66
66
  For,
package/dist/mcp.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  startMcpServer
3
- } from "./chunk-2GDYBD6T.js";
3
+ } from "./chunk-22RTKSQM.js";
4
4
  import {
5
5
  MCP_SERVER_VERSION,
6
6
  atomicApplySourceEdit,
@@ -10,10 +10,10 @@ import {
10
10
  inspectComponentContract,
11
11
  validateSourceSyntaxAndTypes,
12
12
  validateWorkspacePath
13
- } from "./chunk-4SGTSB7N.js";
14
- import "./chunk-6SMML66I.js";
13
+ } from "./chunk-6BEDZVKQ.js";
14
+ import "./chunk-ELRFTCSR.js";
15
15
  import "./chunk-N7XIVYCL.js";
16
- import "./chunk-XS6EEO46.js";
16
+ import "./chunk-OSRTCWKW.js";
17
17
  export {
18
18
  MCP_SERVER_VERSION,
19
19
  atomicApplySourceEdit,
package/dist/observer.js CHANGED
@@ -4,8 +4,8 @@ import {
4
4
  getSemanticSnapshot,
5
5
  observe,
6
6
  observeDiff
7
- } from "./chunk-6SMML66I.js";
8
- import "./chunk-XS6EEO46.js";
7
+ } from "./chunk-ELRFTCSR.js";
8
+ import "./chunk-OSRTCWKW.js";
9
9
  export {
10
10
  OBSERVER_VERSION,
11
11
  buildDependencyGraph,
package/dist/oumv.cjs CHANGED
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __esm = (fn, res) => function __init() {
9
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
+ };
8
11
  var __export = (target, all) => {
9
12
  for (var name in all)
10
13
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -27,6 +30,64 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
30
  ));
28
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
32
 
33
+ // ../oumv/dist/chunk-CMTT7FY2.js
34
+ function componentKey(component) {
35
+ if (typeof component === "string") return component;
36
+ return component?.id || component?.name || component?.displayName || component?.__tokensafe_id__ || "anonymous-component";
37
+ }
38
+ function defineOUMVComponent(component, contract) {
39
+ const record = {
40
+ ...contract,
41
+ componentId: componentKey(component),
42
+ componentName: componentKey(component),
43
+ evidence: {
44
+ provenance: "contract",
45
+ sourceAdapter: "tokensafe-ui-contracts",
46
+ confidence: "confirmed"
47
+ }
48
+ };
49
+ registry.set(record.componentId, record);
50
+ try {
51
+ if (component && typeof component === "object") {
52
+ component.__oumv_contract__ = record;
53
+ }
54
+ } catch {
55
+ }
56
+ return component;
57
+ }
58
+ function getOUMVComponentContract(component) {
59
+ const key = componentKey(component);
60
+ return registry.get(key) || (component && typeof component === "object" ? component.__oumv_contract__ : void 0);
61
+ }
62
+ function listOUMVComponentContracts() {
63
+ return Array.from(registry.values());
64
+ }
65
+ function resetOUMVComponentContracts() {
66
+ registry.clear();
67
+ }
68
+ var registry;
69
+ var init_chunk_CMTT7FY2 = __esm({
70
+ "../oumv/dist/chunk-CMTT7FY2.js"() {
71
+ "use strict";
72
+ registry = /* @__PURE__ */ new Map();
73
+ }
74
+ });
75
+
76
+ // ../oumv/dist/contracts-BANQPXNR.js
77
+ var contracts_BANQPXNR_exports = {};
78
+ __export(contracts_BANQPXNR_exports, {
79
+ defineOUMVComponent: () => defineOUMVComponent,
80
+ getOUMVComponentContract: () => getOUMVComponentContract,
81
+ listOUMVComponentContracts: () => listOUMVComponentContracts,
82
+ resetOUMVComponentContracts: () => resetOUMVComponentContracts
83
+ });
84
+ var init_contracts_BANQPXNR = __esm({
85
+ "../oumv/dist/contracts-BANQPXNR.js"() {
86
+ "use strict";
87
+ init_chunk_CMTT7FY2();
88
+ }
89
+ });
90
+
30
91
  // src/oumv.ts
31
92
  var oumv_exports = {};
32
93
  __export(oumv_exports, {
@@ -37,9 +98,15 @@ __export(oumv_exports, {
37
98
  createAgentDomAdapter: () => createAgentDomAdapter,
38
99
  createReactAdapter: () => createReactAdapter,
39
100
  createVueAdapter: () => createVueAdapter,
101
+ defineOUMVComponent: () => defineOUMVComponent,
102
+ getOUMVComponentContract: () => getOUMVComponentContract,
40
103
  isReducerLike: () => isReducerLike,
41
104
  isReduxStore: () => isReduxStore,
42
- isZustandStore: () => isZustandStore
105
+ isZustandStore: () => isZustandStore,
106
+ listOUMVComponentContracts: () => listOUMVComponentContracts,
107
+ resetOUMVComponentContracts: () => resetOUMVComponentContracts,
108
+ scanProjectStaticResources: () => scanProjectStaticResources,
109
+ scanSourceForComponents: () => scanSourceForComponents
43
110
  });
44
111
  module.exports = __toCommonJS(oumv_exports);
45
112
 
@@ -3641,9 +3708,134 @@ actions: [${actions.join(", ")}]
3641
3708
  }
3642
3709
 
3643
3710
  // ../oumv/dist/index.js
3711
+ init_chunk_CMTT7FY2();
3644
3712
  var import_fs7 = __toESM(require("fs"), 1);
3645
3713
  var import_path7 = __toESM(require("path"), 1);
3646
3714
  var import_crypto5 = __toESM(require("crypto"), 1);
3715
+ var import_fs8 = __toESM(require("fs"), 1);
3716
+ var import_path8 = __toESM(require("path"), 1);
3717
+ var parser6 = __toESM(require("@babel/parser"), 1);
3718
+ function scanSourceForComponents(source, filePath) {
3719
+ const components = [];
3720
+ try {
3721
+ const ast = parser6.parse(source, {
3722
+ sourceType: "module",
3723
+ plugins: ["jsx", "typescript"]
3724
+ });
3725
+ const isPascalCase = (name) => /^[A-Z][a-zA-Z0-9_]*$/.test(name);
3726
+ for (const node of ast.program.body) {
3727
+ if (node.type === "FunctionDeclaration" && node.id && isPascalCase(node.id.name)) {
3728
+ const name = node.id.name;
3729
+ components.push({
3730
+ id: `frontend.component:${name}`,
3731
+ name,
3732
+ filePath,
3733
+ lineStart: node.loc?.start.line ?? 1,
3734
+ lineEnd: node.loc?.end.line ?? 1,
3735
+ actionTriggers: extractActionTriggersFromNode(node),
3736
+ isDefaultExport: false
3737
+ });
3738
+ }
3739
+ if (node.type === "ExportNamedDeclaration" && node.declaration) {
3740
+ if (node.declaration.type === "FunctionDeclaration" && node.declaration.id && isPascalCase(node.declaration.id.name)) {
3741
+ const name = node.declaration.id.name;
3742
+ components.push({
3743
+ id: `frontend.component:${name}`,
3744
+ name,
3745
+ filePath,
3746
+ lineStart: node.loc?.start.line ?? 1,
3747
+ lineEnd: node.loc?.end.line ?? 1,
3748
+ actionTriggers: extractActionTriggersFromNode(node.declaration),
3749
+ isDefaultExport: false
3750
+ });
3751
+ } else if (node.declaration.type === "VariableDeclaration") {
3752
+ for (const decl of node.declaration.declarations) {
3753
+ if (decl.id.type === "Identifier" && isPascalCase(decl.id.name)) {
3754
+ const name = decl.id.name;
3755
+ components.push({
3756
+ id: `frontend.component:${name}`,
3757
+ name,
3758
+ filePath,
3759
+ lineStart: node.loc?.start.line ?? 1,
3760
+ lineEnd: node.loc?.end.line ?? 1,
3761
+ actionTriggers: decl.init ? extractActionTriggersFromNode(decl.init) : [],
3762
+ isDefaultExport: false
3763
+ });
3764
+ }
3765
+ }
3766
+ }
3767
+ }
3768
+ if (node.type === "ExportDefaultDeclaration") {
3769
+ let name = "DefaultExport";
3770
+ if (node.declaration.type === "FunctionDeclaration" && node.declaration.id) {
3771
+ name = node.declaration.id.name;
3772
+ } else if (node.declaration.type === "Identifier") {
3773
+ name = node.declaration.name;
3774
+ } else {
3775
+ const basename = import_path8.default.basename(filePath, import_path8.default.extname(filePath));
3776
+ if (isPascalCase(basename)) {
3777
+ name = basename;
3778
+ }
3779
+ }
3780
+ components.push({
3781
+ id: `frontend.component:${name}`,
3782
+ name,
3783
+ filePath,
3784
+ lineStart: node.loc?.start.line ?? 1,
3785
+ lineEnd: node.loc?.end.line ?? 1,
3786
+ actionTriggers: extractActionTriggersFromNode(node.declaration),
3787
+ isDefaultExport: true
3788
+ });
3789
+ }
3790
+ }
3791
+ } catch {
3792
+ }
3793
+ return components;
3794
+ }
3795
+ function extractActionTriggersFromNode(node) {
3796
+ const triggers = /* @__PURE__ */ new Set();
3797
+ const str = JSON.stringify(node);
3798
+ const eventRegex = /"(onClick|onSubmit|onChange|onInput|onKeyDown|onBlur)"/g;
3799
+ let match;
3800
+ while ((match = eventRegex.exec(str)) !== null) {
3801
+ triggers.add(match[1]);
3802
+ }
3803
+ return Array.from(triggers);
3804
+ }
3805
+ function scanProjectStaticResources(projectRoot) {
3806
+ const components = [];
3807
+ const routes = [];
3808
+ let totalFiles = 0;
3809
+ function walk(dir) {
3810
+ if (!import_fs8.default.existsSync(dir)) return;
3811
+ const entries = import_fs8.default.readdirSync(dir, { withFileTypes: true });
3812
+ for (const entry of entries) {
3813
+ if (entry.name.startsWith(".") || entry.name === "node_modules" || entry.name === "dist") {
3814
+ continue;
3815
+ }
3816
+ const fullPath = import_path8.default.join(dir, entry.name);
3817
+ if (entry.isDirectory()) {
3818
+ walk(fullPath);
3819
+ } else if (entry.isFile() && /\.(tsx|jsx|ts|js)$/.test(entry.name)) {
3820
+ totalFiles++;
3821
+ const relPath = import_path8.default.relative(projectRoot, fullPath);
3822
+ const source = import_fs8.default.readFileSync(fullPath, "utf-8");
3823
+ const found = scanSourceForComponents(source, relPath);
3824
+ components.push(...found);
3825
+ if (relPath.includes("app/") && relPath.endsWith("page.tsx")) {
3826
+ const routeSegment = relPath.replace(/^.*app\//, "").replace(/\/page\.tsx$/, "");
3827
+ routes.push({
3828
+ id: `frontend.route:/${routeSegment}`,
3829
+ path: `/${routeSegment}`,
3830
+ filePath: relPath
3831
+ });
3832
+ }
3833
+ }
3834
+ }
3835
+ }
3836
+ walk(projectRoot);
3837
+ return { components, routes, totalScannedFiles: totalFiles };
3838
+ }
3647
3839
  function createAgentDomAdapter(config = {}) {
3648
3840
  const projectRoot = config.projectRoot || process.cwd();
3649
3841
  return {
@@ -3694,13 +3886,23 @@ function createAgentDomAdapter(config = {}) {
3694
3886
  status: detached
3695
3887
  `;
3696
3888
  }
3697
- return {
3889
+ const result = {
3698
3890
  level: params.level,
3699
3891
  format,
3700
3892
  payload,
3701
3893
  tokenEstimate: Math.ceil(payload.length / 4),
3702
3894
  timestamp: Date.now()
3703
3895
  };
3896
+ if (params.level === "L2" || params.level === "L3") {
3897
+ const { listOUMVComponentContracts: listOUMVComponentContracts2 } = await Promise.resolve().then(() => (init_contracts_BANQPXNR(), contracts_BANQPXNR_exports));
3898
+ const contracts = listOUMVComponentContracts2().filter(
3899
+ (c) => !params.componentId || c.componentId === params.componentId
3900
+ );
3901
+ if (contracts.length > 0) {
3902
+ result.contracts = contracts;
3903
+ }
3904
+ }
3905
+ return result;
3704
3906
  },
3705
3907
  async understand(params) {
3706
3908
  const graph = buildDependencyGraph();
@@ -3757,7 +3959,13 @@ status: detached
3757
3959
  createAgentDomAdapter,
3758
3960
  createReactAdapter,
3759
3961
  createVueAdapter,
3962
+ defineOUMVComponent,
3963
+ getOUMVComponentContract,
3760
3964
  isReducerLike,
3761
3965
  isReduxStore,
3762
- isZustandStore
3966
+ isZustandStore,
3967
+ listOUMVComponentContracts,
3968
+ resetOUMVComponentContracts,
3969
+ scanProjectStaticResources,
3970
+ scanSourceForComponents
3763
3971
  });