0xray 4.0.35 → 4.0.37

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 (173) hide show
  1. package/.grok-plugin/plugin.json +1 -1
  2. package/.xray/features.json +1 -1
  3. package/dist/CHANGELOG.md +25 -0
  4. package/dist/analytics/emerging-pattern-detector.d.ts +12 -1
  5. package/dist/analytics/emerging-pattern-detector.js +37 -12
  6. package/dist/analytics/pattern-learning-engine.js +1 -9
  7. package/dist/analytics/predictive-analytics.js +51 -33
  8. package/dist/analytics/prompt-pattern-analyzer.d.ts +1 -0
  9. package/dist/analytics/prompt-pattern-analyzer.js +39 -20
  10. package/dist/analytics/routing-performance-analyzer.d.ts +2 -0
  11. package/dist/analytics/routing-performance-analyzer.js +89 -37
  12. package/dist/analytics/simple-pattern-analyzer.d.ts +4 -0
  13. package/dist/analytics/simple-pattern-analyzer.js +66 -28
  14. package/dist/architect/architect-tools.d.ts +3 -0
  15. package/dist/architect/architect-tools.js +22 -0
  16. package/dist/cli/commands/grok-install.js +1 -1
  17. package/dist/cli/commands/hermes-install.js +11 -5
  18. package/dist/cli/commands/openclaw-install.js +13 -7
  19. package/dist/cli/commands/opencode-install.js +7 -4
  20. package/dist/cli/commands/suit-monitor.d.ts +30 -0
  21. package/dist/cli/commands/suit-monitor.js +128 -0
  22. package/dist/cli/index.js +52 -15
  23. package/dist/cli/suit-pulse.d.ts +29 -0
  24. package/dist/cli/suit-pulse.js +270 -0
  25. package/dist/delegation/agent-delegator.d.ts +4 -2
  26. package/dist/delegation/agent-delegator.js +46 -27
  27. package/dist/delegation/agent-expertise.js +2 -1
  28. package/dist/delegation/analytics/outcome-tracker.d.ts +6 -0
  29. package/dist/delegation/analytics/outcome-tracker.js +17 -3
  30. package/dist/delegation/ast-code-parser.d.ts +5 -0
  31. package/dist/delegation/ast-code-parser.js +53 -48
  32. package/dist/delegation/codebase-context-analyzer.d.ts +3 -7
  33. package/dist/delegation/codebase-context-analyzer.js +188 -159
  34. package/dist/delegation/session-coordinator.js +3 -2
  35. package/dist/enforcement/loaders/codex-loader.js +18 -14
  36. package/dist/enforcement/validators/architecture-validators.js +115 -9
  37. package/dist/governance/codex-policy.service.d.ts +12 -2
  38. package/dist/governance/codex-policy.service.js +91 -16
  39. package/dist/integrations/grok/hooks/session-start.js +6 -6
  40. package/dist/integrations/grok/plugin/0xray/hooks/hooks.json +6 -6
  41. package/dist/integrations/hooks/goggles-mcp.mjs +10 -3
  42. package/dist/integrations/hooks/goggles-pipeline.mjs +221 -44
  43. package/dist/integrations/hooks/goggles-planes.json +172 -8
  44. package/dist/integrations/hooks/plates.cjs +138 -0
  45. package/dist/integrations/hooks/station-hook-runtime.cjs +63 -5
  46. package/dist/integrations/hooks/write-home.cjs +59 -0
  47. package/dist/integrations/openclaw/plugin/xray-pre-tool/package.json +1 -1
  48. package/dist/mcps/architect-tools.server.d.ts +6 -0
  49. package/dist/mcps/architect-tools.server.js +19 -18
  50. package/dist/mcps/orchestrator/server.d.ts +4 -3
  51. package/dist/mcps/orchestrator/server.js +29 -17
  52. package/dist/memory-routing/lookup-cache.d.ts +8 -0
  53. package/dist/memory-routing/lookup-cache.js +72 -0
  54. package/dist/memory-routing/plates.d.ts +1 -1
  55. package/dist/memory-routing/plates.js +26 -0
  56. package/dist/memory-routing/provider-loader.js +3 -0
  57. package/dist/metrics/agent-metrics.d.ts +14 -5
  58. package/dist/metrics/agent-metrics.js +362 -224
  59. package/dist/nucleus/synthesis-consult-receipt.js +38 -16
  60. package/dist/orchestrator/enhanced-multi-agent-orchestrator.d.ts +5 -0
  61. package/dist/orchestrator/enhanced-multi-agent-orchestrator.js +9 -0
  62. package/dist/orchestrator/multi-agent-orchestration-coordinator.js +1 -2
  63. package/dist/orchestrator/orchestrator.js +1 -2
  64. package/dist/processors/implementations/agents-md-validation-processor.d.ts +0 -1
  65. package/dist/processors/implementations/agents-md-validation-processor.js +0 -11
  66. package/dist/processors/implementations/console-log-guard-processor.js +39 -50
  67. package/dist/processors/implementations/performance-budget-processor.d.ts +0 -5
  68. package/dist/processors/implementations/performance-budget-processor.js +29 -38
  69. package/dist/processors/implementations/storytelling-trigger-processor.d.ts +5 -0
  70. package/dist/processors/implementations/storytelling-trigger-processor.js +69 -16
  71. package/dist/processors/implementations/test-auto-creation-processor.js +39 -36
  72. package/dist/reporting/framework-reporting-system.d.ts +3 -0
  73. package/dist/reporting/framework-reporting-system.js +61 -8
  74. package/dist/reporting/log-parser.js +188 -105
  75. package/dist/reporting/metrics.js +42 -18
  76. package/dist/security/prompt-security-validator.js +8 -7
  77. package/dist/security/security-auditor.d.ts +4 -0
  78. package/dist/security/security-auditor.js +132 -57
  79. package/dist/security/security-hardener.d.ts +2 -0
  80. package/dist/security/security-hardener.js +31 -6
  81. package/dist/security/security-headers.d.ts +2 -0
  82. package/dist/security/security-headers.js +23 -21
  83. package/dist/security/security-scanner.js +18 -4
  84. package/dist/session/session-cleanup-manager.d.ts +2 -0
  85. package/dist/session/session-cleanup-manager.js +29 -8
  86. package/dist/session/session-monitor.d.ts +14 -4
  87. package/dist/session/session-monitor.js +208 -106
  88. package/dist/session/session-state-manager.d.ts +11 -0
  89. package/dist/session/session-state-manager.js +90 -8
  90. package/docs-site/docs/plates/activity-log.md +38 -0
  91. package/docs-site/docs/plates/cursor-compact.md +35 -0
  92. package/docs-site/docs/plates/grok-compact.md +35 -0
  93. package/docs-site/docs/plates/index.md +25 -3
  94. package/docs-site/docs/plates/inference-files.md +35 -0
  95. package/docs-site/docs/plates/kept-line.md +35 -0
  96. package/docs-site/docs/plates/lens-gate.md +35 -0
  97. package/docs-site/docs/plates/lens-page.md +35 -0
  98. package/docs-site/docs/plates/notes-page.md +35 -0
  99. package/docs-site/docs/plates/package-face.md +35 -0
  100. package/docs-site/docs/plates/payload-heat.md +35 -0
  101. package/docs-site/docs/plates/pickup-stamp.md +35 -0
  102. package/docs-site/docs/plates/pre-tool.md +35 -0
  103. package/docs-site/docs/plates/record-map.md +41 -0
  104. package/docs-site/docs/plates/reflection-page.md +35 -0
  105. package/docs-site/docs/plates/review.md +57 -0
  106. package/docs-site/docs/plates/session-capture.md +38 -0
  107. package/docs-site/docs/plates/site-manual.md +35 -0
  108. package/docs-site/docs/plates/stamp-plate.md +35 -0
  109. package/docs-site/docs/plates/station-card.md +35 -0
  110. package/docs-site/docs/plates/station-heat.md +35 -0
  111. package/docs-site/docs/plates/suit-organs.md +38 -0
  112. package/docs-site/docs/plates/suit-settings.md +35 -0
  113. package/docs-site/docs/plates/suit-wear.md +37 -0
  114. package/docs-site/docs/plates/trail-state.md +35 -0
  115. package/docs-site/docs/plates/work-fresh.md +35 -0
  116. package/docs-site/docs/plates/write-home.md +38 -0
  117. package/package.json +4 -2
  118. package/scripts/mjs/run-grok-hook.mjs +50 -0
  119. package/scripts/node/install-bridges.cjs +305 -81
  120. package/scripts/node/postinstall.cjs +14 -3
  121. package/src/integrations/grok/plugin/0xray/hooks/hooks.json +6 -6
  122. package/src/integrations/openclaw/plugin/xray-pre-tool/package.json +1 -1
  123. package/src/mcps/architect-tools.server.ts +25 -20
  124. package/src/mcps/orchestrator/server.ts +33 -19
  125. package/xray/features.json +1 -1
  126. package/vendor/@0xray/repertoire/dist/RepertoireService.d.ts.map +0 -1
  127. package/vendor/@0xray/repertoire/dist/RepertoireService.js.map +0 -1
  128. package/vendor/@0xray/repertoire/dist/governance/ontological-trap-enforcer.d.ts.map +0 -1
  129. package/vendor/@0xray/repertoire/dist/governance/ontological-trap-enforcer.js.map +0 -1
  130. package/vendor/@0xray/repertoire/dist/index.d.ts.map +0 -1
  131. package/vendor/@0xray/repertoire/dist/index.js.map +0 -1
  132. package/vendor/@0xray/repertoire/dist/ingestion/groover-log-ingester.d.ts.map +0 -1
  133. package/vendor/@0xray/repertoire/dist/ingestion/groover-log-ingester.js.map +0 -1
  134. package/vendor/@0xray/repertoire/dist/ingestion/groover-log-parser.d.ts.map +0 -1
  135. package/vendor/@0xray/repertoire/dist/ingestion/groover-log-parser.js.map +0 -1
  136. package/vendor/@0xray/repertoire/dist/ingestion/orchestrator-feedback-ingester.d.ts.map +0 -1
  137. package/vendor/@0xray/repertoire/dist/ingestion/orchestrator-feedback-ingester.js.map +0 -1
  138. package/vendor/@0xray/repertoire/dist/ingestion/xray-session-ingester.d.ts.map +0 -1
  139. package/vendor/@0xray/repertoire/dist/ingestion/xray-session-ingester.js.map +0 -1
  140. package/vendor/@0xray/repertoire/dist/mcp/server.d.ts.map +0 -1
  141. package/vendor/@0xray/repertoire/dist/mcp/server.js.map +0 -1
  142. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/RepertoireOrchestratorBridge.d.ts.map +0 -1
  143. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/RepertoireOrchestratorBridge.js.map +0 -1
  144. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/capability-enhancer.d.ts.map +0 -1
  145. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/capability-enhancer.js.map +0 -1
  146. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/confidence-gate.d.ts.map +0 -1
  147. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/confidence-gate.js.map +0 -1
  148. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/signal-agent-affinity.d.ts.map +0 -1
  149. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/signal-agent-affinity.js.map +0 -1
  150. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/signal-injector.d.ts.map +0 -1
  151. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/signal-injector.js.map +0 -1
  152. package/vendor/@0xray/repertoire/dist/paths.d.ts.map +0 -1
  153. package/vendor/@0xray/repertoire/dist/paths.js.map +0 -1
  154. package/vendor/@0xray/repertoire/dist/provider/memory-routing-provider.d.ts.map +0 -1
  155. package/vendor/@0xray/repertoire/dist/provider/memory-routing-provider.js.map +0 -1
  156. package/vendor/@0xray/repertoire/dist/registry/CuratedSignalsManager.d.ts.map +0 -1
  157. package/vendor/@0xray/repertoire/dist/registry/CuratedSignalsManager.js.map +0 -1
  158. package/vendor/@0xray/repertoire/dist/registry/InferenceStateManager.d.ts.map +0 -1
  159. package/vendor/@0xray/repertoire/dist/registry/InferenceStateManager.js.map +0 -1
  160. package/vendor/@0xray/repertoire/dist/registry/confidence-decay.d.ts.map +0 -1
  161. package/vendor/@0xray/repertoire/dist/registry/confidence-decay.js.map +0 -1
  162. package/vendor/@0xray/repertoire/dist/registry/signal-prune.d.ts.map +0 -1
  163. package/vendor/@0xray/repertoire/dist/registry/signal-prune.js.map +0 -1
  164. package/vendor/@0xray/repertoire/dist/synthesis/concrete-sections.d.ts.map +0 -1
  165. package/vendor/@0xray/repertoire/dist/synthesis/concrete-sections.js.map +0 -1
  166. package/vendor/@0xray/repertoire/dist/synthesis/meta-inference-engine.d.ts.map +0 -1
  167. package/vendor/@0xray/repertoire/dist/synthesis/meta-inference-engine.js.map +0 -1
  168. package/vendor/@0xray/repertoire/dist/synthesis/primitive-confidence-aggregator.d.ts.map +0 -1
  169. package/vendor/@0xray/repertoire/dist/synthesis/primitive-confidence-aggregator.js.map +0 -1
  170. package/vendor/@0xray/repertoire/dist/synthesis/synthesis-prompt-builder.d.ts.map +0 -1
  171. package/vendor/@0xray/repertoire/dist/synthesis/synthesis-prompt-builder.js.map +0 -1
  172. package/vendor/@0xray/repertoire/dist/types.d.ts.map +0 -1
  173. package/vendor/@0xray/repertoire/dist/types.js.map +0 -1
@@ -14,12 +14,38 @@ const PLATE_IDS = Object.freeze([
14
14
  "processor",
15
15
  "reporting",
16
16
  "memory-recall",
17
+ "stamp-plate",
17
18
  "house",
19
+ "review",
18
20
  "goggles",
19
21
  "suit",
20
22
  "kits",
21
23
  "host-pack",
22
24
  "glossary",
25
+ "record-map",
26
+ "write-home",
27
+ "activity-log",
28
+ "session-capture",
29
+ "suit-wear",
30
+ "suit-organs",
31
+ "station-card",
32
+ "notes-page",
33
+ "reflection-page",
34
+ "site-manual",
35
+ "package-face",
36
+ "suit-settings",
37
+ "trail-state",
38
+ "inference-files",
39
+ "grok-compact",
40
+ "payload-heat",
41
+ "station-heat",
42
+ "pickup-stamp",
43
+ "cursor-compact",
44
+ "work-fresh",
45
+ "kept-line",
46
+ "lens-gate",
47
+ "pre-tool",
48
+ "lens-page",
23
49
  ]);
24
50
 
25
51
  /** Id token, then extra phrases. Equal top scores recall nothing. */
@@ -73,6 +99,13 @@ const CUES = {
73
99
  [/GROK_BOT_HOUSE/i, 4],
74
100
  [/setup-house/i, 4],
75
101
  ],
102
+ review: [
103
+ [/review plate/i, 6],
104
+ [/plates\/review\b/i, 6],
105
+ [/re-review/i, 5],
106
+ [/critic\s+FAIL/i, 5],
107
+ [/critic\s+PASS/i, 5],
108
+ ],
76
109
  goggles: [
77
110
  [/\bgoggles\b/i, 6],
78
111
  ],
@@ -91,6 +124,111 @@ const CUES = {
91
124
  glossary: [
92
125
  [/\bglossary\b/i, 6],
93
126
  ],
127
+ "stamp-plate": [
128
+ [/stamp plate/i, 6],
129
+ [/plates\/stamp-plate/i, 6],
130
+ ],
131
+ "record-map": [
132
+ [/record map/i, 6],
133
+ [/five pages the agent/i, 6],
134
+ [/plates\/record-map/i, 6],
135
+ ],
136
+ "write-home": [
137
+ [/write home/i, 6],
138
+ [/\.xray\/logs/i, 6],
139
+ [/plates\/write-home/i, 6],
140
+ ],
141
+ "activity-log": [
142
+ [/activity log pipeline/i, 6],
143
+ [/plates\/activity-log/i, 6],
144
+ ],
145
+ "session-capture": [
146
+ [/session capture/i, 6],
147
+ [/latest-session\.json/i, 5],
148
+ [/plates\/session-capture/i, 6],
149
+ ],
150
+ "suit-wear": [
151
+ [/suit wear/i, 6],
152
+ [/consumer gitignore/i, 5],
153
+ [/plates\/suit-wear/i, 6],
154
+ ],
155
+ "suit-organs": [
156
+ [/suit organs/i, 6],
157
+ [/plates\/suit-organs/i, 6],
158
+ ],
159
+ "station-card": [
160
+ [/station card/i, 6],
161
+ [/plates\/station-card/i, 6],
162
+ ],
163
+ "notes-page": [
164
+ [/notes page/i, 6],
165
+ [/plates\/notes-page/i, 6],
166
+ ],
167
+ "reflection-page": [
168
+ [/reflection page/i, 6],
169
+ [/plates\/reflection-page/i, 6],
170
+ ],
171
+ "site-manual": [
172
+ [/site manual/i, 6],
173
+ [/plates\/site-manual/i, 6],
174
+ ],
175
+ "package-face": [
176
+ [/package face/i, 6],
177
+ [/plates\/package-face/i, 6],
178
+ ],
179
+ "suit-settings": [
180
+ [/suit settings/i, 6],
181
+ [/plates\/suit-settings/i, 6],
182
+ ],
183
+ "trail-state": [
184
+ [/trail state/i, 6],
185
+ [/plates\/trail-state/i, 6],
186
+ ],
187
+ "inference-files": [
188
+ [/inference files/i, 6],
189
+ [/plates\/inference-files/i, 6],
190
+ ],
191
+ "grok-compact": [
192
+ [/grok compact/i, 6],
193
+ [/plates\/grok-compact/i, 6],
194
+ ],
195
+ "payload-heat": [
196
+ [/payload heat/i, 6],
197
+ [/plates\/payload-heat/i, 6],
198
+ ],
199
+ "station-heat": [
200
+ [/station heat/i, 6],
201
+ [/plates\/station-heat/i, 6],
202
+ ],
203
+ "pickup-stamp": [
204
+ [/pickup stamp/i, 6],
205
+ [/plates\/pickup-stamp/i, 6],
206
+ ],
207
+ "cursor-compact": [
208
+ [/cursor compact/i, 6],
209
+ [/plates\/cursor-compact/i, 6],
210
+ ],
211
+ "work-fresh": [
212
+ [/work fresh/i, 6],
213
+ [/freshness line/i, 6],
214
+ [/plates\/work-fresh/i, 6],
215
+ ],
216
+ "kept-line": [
217
+ [/kept line/i, 6],
218
+ [/plates\/kept-line/i, 6],
219
+ ],
220
+ "lens-gate": [
221
+ [/lens gate/i, 6],
222
+ [/plates\/lens-gate/i, 6],
223
+ ],
224
+ "pre-tool": [
225
+ [/pre tool/i, 6],
226
+ [/plates\/pre-tool/i, 6],
227
+ ],
228
+ "lens-page": [
229
+ [/lens page/i, 6],
230
+ [/plates\/lens-page/i, 6],
231
+ ],
94
232
  };
95
233
 
96
234
  function platesDir() {
@@ -526,6 +526,19 @@ function stampNotesPickup(root, line) {
526
526
  return text;
527
527
  }
528
528
 
529
+ function notesMark(root) {
530
+ let body = "";
531
+ const dest = notesPath(root);
532
+ if (existsSync(dest)) {
533
+ try {
534
+ body = readFileSync(dest, "utf8");
535
+ } catch {
536
+ body = "";
537
+ }
538
+ }
539
+ return /^## Working notes\b/m.test(body) ? "Notes: present" : "Notes: THIN";
540
+ }
541
+
529
542
  function readLatestSessionApproaches(root) {
530
543
  const latest = join(root, "docs", "inference", "latest-session.json");
531
544
  if (!existsSync(latest)) return null;
@@ -995,9 +1008,13 @@ function applyStationHeat(root, host, extra = {}, existing = {}) {
995
1008
  const resolved = resolveHeatIntent(root, extra, existing);
996
1009
  const intent = resolved.intent;
997
1010
  const rematch = resolved.rematch;
998
- if (isCompactHook(extra) && intent && (readStationTicketField(root, "Intent") || pickup || clipIntent(extra.intent))) {
999
- const stamped = stampNotesPickup(root, intent);
1000
- if (stamped) pickup = stamped;
1011
+ let notesLine = null;
1012
+ if (isCompactHook(extra)) {
1013
+ if (intent && (readStationTicketField(root, "Intent") || pickup || clipIntent(extra.intent))) {
1014
+ const stamped = stampNotesPickup(root, intent);
1015
+ if (stamped) pickup = stamped;
1016
+ }
1017
+ notesLine = notesMark(root);
1001
1018
  }
1002
1019
  const matchText = clipIntent([intent, pickup, approaches].filter(Boolean).join(" "));
1003
1020
  const git = readGitBrief(root);
@@ -1089,6 +1106,7 @@ function applyStationHeat(root, host, extra = {}, existing = {}) {
1089
1106
  repertoireResume,
1090
1107
  workingLine,
1091
1108
  stationLine,
1109
+ ...(notesLine ? { notesLine } : {}),
1092
1110
  ...compactHold,
1093
1111
  };
1094
1112
  }
@@ -1099,9 +1117,12 @@ const STOCK_STATION_PREFIXES = [
1099
1117
  "intent:",
1100
1118
  "plan:",
1101
1119
  "git:",
1120
+ "fresh:",
1102
1121
  "repertoire:",
1103
1122
  "working:",
1104
1123
  "plate:",
1124
+ "library:",
1125
+ "notes:",
1105
1126
  ];
1106
1127
 
1107
1128
  /** Stock design map. Exact lines so a later heat does not preserve a second copy. */
@@ -1222,10 +1243,45 @@ function extractPreservedStationLines(existing) {
1222
1243
  return preserved;
1223
1244
  }
1224
1245
 
1246
+ function latestFreshLine(existingMd) {
1247
+ const lines = String(existingMd || "").split(/\r?\n/).map((line) => line.trim()).filter((line) => /^Fresh:/.test(line));
1248
+ return lines.length ? lines[lines.length - 1] : "";
1249
+ }
1250
+
1251
+ function withOneFreshLine(stockMd, existingMd) {
1252
+ const stock = String(stockMd || "");
1253
+ if (/^Fresh:/m.test(stock)) return stock;
1254
+ const fresh = latestFreshLine(existingMd);
1255
+ if (!fresh) return stock;
1256
+ const rows = stock.split(/\r?\n/);
1257
+ const at = rows.findIndex((row) => row.startsWith("Repertoire:"));
1258
+ if (at >= 0) rows.splice(at, 0, fresh);
1259
+ else rows.splice(Math.min(rows.length, 6), 0, fresh);
1260
+ return rows.join("\n");
1261
+ }
1262
+
1263
+ function latestNotesLine(existingMd) {
1264
+ const lines = String(existingMd || "").split(/\r?\n/).map((line) => line.trim()).filter((line) => /^Notes:/.test(line));
1265
+ return lines.length ? lines[lines.length - 1] : "";
1266
+ }
1267
+
1268
+ function withOneNotesLine(stockMd, existingMd) {
1269
+ const stock = String(stockMd || "");
1270
+ if (/^Notes:/m.test(stock)) return stock;
1271
+ const notes = latestNotesLine(existingMd);
1272
+ if (!notes) return stock;
1273
+ const rows = stock.split(/\r?\n/);
1274
+ const at = rows.findIndex((row) => row.startsWith("Library:"));
1275
+ if (at >= 0) rows.splice(at + 1, 0, notes);
1276
+ else rows.splice(Math.min(rows.length, 8), 0, notes);
1277
+ return rows.join("\n");
1278
+ }
1279
+
1225
1280
  function mergeStationMarkdown(stockMd, existingMd) {
1281
+ const stockWithFresh = withOneNotesLine(withOneFreshLine(stockMd, existingMd), existingMd);
1226
1282
  const preserved = extractPreservedStationLines(existingMd);
1227
- if (!preserved.length) return stockMd;
1228
- const stock = String(stockMd || "");
1283
+ if (!preserved.length) return stockWithFresh;
1284
+ const stock = stockWithFresh;
1229
1285
  const block = preserved.join("\n");
1230
1286
  const marker = "Continue this card.";
1231
1287
  const idx = stock.indexOf(marker);
@@ -1261,6 +1317,8 @@ function formatStationMarkdown(fields) {
1261
1317
  }
1262
1318
  const plateLine = plateStockLine(fields.intent);
1263
1319
  if (plateLine) lines.push(plateLine);
1320
+ lines.push("Library: record-map — .agents/skills/record-map/SKILL.md");
1321
+ if (fields.notesLine) lines.push(fields.notesLine);
1264
1322
  lines.push("");
1265
1323
  lines.push(...DESIGN_MAP_LINES);
1266
1324
  lines.push("");
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Where the suit writes. One home, under .xray.
3
+ * Readers still open the old path when the new file is not there yet.
4
+ */
5
+ const { existsSync } = require("fs");
6
+ const { join } = require("path");
7
+
8
+ function logsDir(root) {
9
+ return join(root, ".xray", "logs");
10
+ }
11
+
12
+ function activityLog(root) {
13
+ return join(logsDir(root), "activity.log");
14
+ }
15
+
16
+ function inferenceDir(root) {
17
+ return join(root, ".xray", "inference");
18
+ }
19
+
20
+ function latestSession(root) {
21
+ return join(inferenceDir(root), "latest-session.json");
22
+ }
23
+
24
+ function activityLogForRead(root) {
25
+ const next = activityLog(root);
26
+ const prev = join(root, "logs", "framework", "activity.log");
27
+ if (existsSync(next) || !existsSync(prev)) return next;
28
+ return prev;
29
+ }
30
+
31
+ function latestSessionForRead(root) {
32
+ const next = latestSession(root);
33
+ const prev = join(root, "docs", "inference", "latest-session.json");
34
+ if (existsSync(next) || !existsSync(prev)) return next;
35
+ return prev;
36
+ }
37
+
38
+ /** Old feature values that used to scatter writes. */
39
+ function isLegacyLogPath(logPath) {
40
+ if (!logPath) return true;
41
+ const normalized = String(logPath).replace(/\\/g, "/").replace(/\/$/, "");
42
+ return (
43
+ normalized === ".opencode/logs" ||
44
+ normalized === ".opencode" ||
45
+ normalized === "logs" ||
46
+ normalized === "logs/framework" ||
47
+ normalized.endsWith("/logs/framework")
48
+ );
49
+ }
50
+
51
+ module.exports = {
52
+ logsDir,
53
+ activityLog,
54
+ inferenceDir,
55
+ latestSession,
56
+ activityLogForRead,
57
+ latestSessionForRead,
58
+ isLegacyLogPath,
59
+ };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xray-pre-tool",
3
- "version": "4.0.35",
3
+ "version": "4.0.37",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "description": "0xRay constitution + temperament PreToolUse for OpenClaw",
@@ -5,6 +5,12 @@
5
5
  * Provides contextual analysis capabilities via MCP protocol
6
6
  */
7
7
  import { XrayKnowledgeSkillBase } from "./shared/knowledge-skill-base.js";
8
+ export declare function renderArchitectureAssessment(args: Record<string, unknown> | undefined): Promise<{
9
+ content: Array<{
10
+ type: "text";
11
+ text: string;
12
+ }>;
13
+ }>;
8
14
  declare class XrayArchitectToolsServer extends XrayKnowledgeSkillBase {
9
15
  constructor();
10
16
  setupToolHandlers(): void;
@@ -8,7 +8,24 @@ import { CallToolRequestSchema } from "@modelcontextprotocol/sdk/types.js";
8
8
  import { XrayKnowledgeSkillBase } from "./shared/knowledge-skill-base.js";
9
9
  import * as fs from "fs";
10
10
  import { frameworkLogger } from "../core/framework-logger.js";
11
- import { contextAnalysis as architectContextAnalysis, codebaseStructure as architectCodebaseStructure, dependencyAnalysis as architectDependencyAnalysis, architectureAssessment as architectArchitectureAssessment, } from "../architect/architect-tools.js";
11
+ import { contextAnalysis as architectContextAnalysis, codebaseStructure as architectCodebaseStructure, dependencyAnalysis as architectDependencyAnalysis, architectureAssessment as architectArchitectureAssessment, formatConferArchitectureText, } from "../architect/architect-tools.js";
12
+ export async function renderArchitectureAssessment(args) {
13
+ const projectRoot = typeof args?.projectRoot === "string" ? args.projectRoot : "";
14
+ const assessmentType = args?.assessmentType === "quick" || args?.assessmentType === "comprehensive"
15
+ ? args.assessmentType
16
+ : "comprehensive";
17
+ const conferPrompt = typeof args?.conferPrompt === "string" ? args.conferPrompt : "";
18
+ frameworkLogger.log("mcps/architect-tools", "architecture-assessment", "info", { projectRoot });
19
+ const result = await architectArchitectureAssessment(projectRoot, assessmentType);
20
+ return {
21
+ content: [
22
+ {
23
+ type: "text",
24
+ text: formatConferArchitectureText(conferPrompt, result),
25
+ },
26
+ ],
27
+ };
28
+ }
12
29
  class XrayArchitectToolsServer extends XrayKnowledgeSkillBase {
13
30
  constructor() {
14
31
  super("architect-tools", "3.1.0");
@@ -191,23 +208,7 @@ class XrayArchitectToolsServer extends XrayKnowledgeSkillBase {
191
208
  };
192
209
  }
193
210
  async architectureAssessment(args) {
194
- const projectRoot = args?.projectRoot || "";
195
- const assessmentType = args?.assessmentType || "comprehensive";
196
- const conferPrompt = typeof args?.conferPrompt === "string" ? args.conferPrompt : "";
197
- frameworkLogger.log("mcps/architect-tools", "architecture-assessment", "info", { projectRoot });
198
- const result = await architectArchitectureAssessment(projectRoot, assessmentType);
199
- const assessmentJson = JSON.stringify(result, null, 2);
200
- const text = conferPrompt.trim()
201
- ? `${conferPrompt.trim()}\n\n## Architecture assessment\n${assessmentJson}\n\nVerdict: CONDITIONAL\nTop risks: review assessment metrics above\nHardening: address high-complexity or coupling findings before resuming`
202
- : assessmentJson;
203
- return {
204
- content: [
205
- {
206
- type: "text",
207
- text,
208
- },
209
- ],
210
- };
211
+ return renderArchitectureAssessment(args);
211
212
  }
212
213
  }
213
214
  if (import.meta.url === `file://${fs.realpathSync(process.argv[1])}`) {
@@ -12,11 +12,12 @@ export declare class OrchestratorServer {
12
12
  private server;
13
13
  private activeTasks;
14
14
  private taskHistory;
15
- private taskHandler;
16
- private complexityHandler;
15
+ private taskHandlerPromise;
16
+ private complexityHandlerPromise;
17
17
  private statusHandler;
18
- private coordinator;
19
18
  constructor();
19
+ private loadTaskHandler;
20
+ private loadComplexityHandler;
20
21
  /**
21
22
  * Initialize tool definitions
22
23
  */
@@ -9,10 +9,6 @@ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
9
9
  import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
10
10
  import * as fs from 'fs';
11
11
  import { frameworkLogger } from '../../core/framework-logger.js';
12
- import { XrayStateManager } from '../../state/state-manager.js';
13
- import { MultiAgentOrchestrationCoordinator } from '../../orchestrator/multi-agent-orchestration-coordinator.js';
14
- import { TaskHandler } from './handlers/task-handler.js';
15
- import { ComplexityHandler } from './handlers/complexity-handler.js';
16
12
  import { StatusHandler } from './handlers/status-handler.js';
17
13
  import { spawnAside, closeAside, closeAllAsides, addObservations, getActiveAsideCount, getActiveAsideIds, getAsideState, extractGovernanceObservations, } from './aside-context.js';
18
14
  /**
@@ -23,19 +19,11 @@ export class OrchestratorServer {
23
19
  server;
24
20
  activeTasks = new Map();
25
21
  taskHistory = [];
26
- // Handlers
27
- taskHandler;
28
- complexityHandler;
22
+ // Task and complexity handlers import the planner and nucleus. Load on tool call.
23
+ taskHandlerPromise = null;
24
+ complexityHandlerPromise = null;
29
25
  statusHandler;
30
- // Actual orchestration coordinator
31
- coordinator;
32
26
  constructor() {
33
- // Initialize actual coordinator
34
- const stateManager = new XrayStateManager();
35
- this.coordinator = new MultiAgentOrchestrationCoordinator(stateManager);
36
- // Initialize handlers
37
- this.taskHandler = new TaskHandler();
38
- this.complexityHandler = new ComplexityHandler();
39
27
  this.statusHandler = new StatusHandler();
40
28
  // Create MCP server
41
29
  this.server = new Server({
@@ -52,6 +40,28 @@ export class OrchestratorServer {
52
40
  message: '0xRay Orchestrator MCP Server initialized',
53
41
  });
54
42
  }
43
+ loadTaskHandler() {
44
+ if (!this.taskHandlerPromise) {
45
+ this.taskHandlerPromise = import('./handlers/task-handler.js')
46
+ .then(({ TaskHandler }) => new TaskHandler())
47
+ .catch((error) => {
48
+ this.taskHandlerPromise = null;
49
+ throw error;
50
+ });
51
+ }
52
+ return this.taskHandlerPromise;
53
+ }
54
+ loadComplexityHandler() {
55
+ if (!this.complexityHandlerPromise) {
56
+ this.complexityHandlerPromise = import('./handlers/complexity-handler.js')
57
+ .then(({ ComplexityHandler }) => new ComplexityHandler())
58
+ .catch((error) => {
59
+ this.complexityHandlerPromise = null;
60
+ throw error;
61
+ });
62
+ }
63
+ return this.complexityHandlerPromise;
64
+ }
55
65
  /**
56
66
  * Initialize tool definitions
57
67
  */
@@ -268,7 +278,8 @@ export class OrchestratorServer {
268
278
  inheritedContext: { taskCount: orchArgs.tasks?.length ?? 0, executionMode: orchArgs.executionMode ?? 'optimized' },
269
279
  });
270
280
  try {
271
- const result = await this.taskHandler.handleOrchestrateTask(orchArgs, { taskHistory: this.taskHistory, activeTasks: this.activeTasks, asideId: aside.asideId });
281
+ const taskHandler = await this.loadTaskHandler();
282
+ const result = await taskHandler.handleOrchestrateTask(orchArgs, { taskHistory: this.taskHistory, activeTasks: this.activeTasks, asideId: aside.asideId });
272
283
  return result;
273
284
  }
274
285
  finally {
@@ -348,7 +359,8 @@ export class OrchestratorServer {
348
359
  inheritedContext,
349
360
  });
350
361
  try {
351
- const result = await this.complexityHandler.handleAnalyzeComplexity({
362
+ const complexityHandler = await this.loadComplexityHandler();
363
+ const result = await complexityHandler.handleAnalyzeComplexity({
352
364
  ...complexityArgs,
353
365
  ...(sessionId ? { sessionId } : {}),
354
366
  ...(synthesisDue
@@ -0,0 +1,8 @@
1
+ import type { MemoryRoutingProvider } from './types.js';
2
+ export declare function resetOrganFileCacheStats(): void;
3
+ export declare function organFileCacheStats(): {
4
+ hits: number;
5
+ misses: number;
6
+ };
7
+ /** Attach the file cache to a loaded Repertoire provider. Other providers are left alone. */
8
+ export declare function bindOrganFileCache(provider: MemoryRoutingProvider): void;
@@ -0,0 +1,72 @@
1
+ import { statSync } from 'node:fs';
2
+ const boundStores = new WeakSet();
3
+ let cacheHits = 0;
4
+ let cacheMisses = 0;
5
+ export function resetOrganFileCacheStats() {
6
+ cacheHits = 0;
7
+ cacheMisses = 0;
8
+ }
9
+ export function organFileCacheStats() {
10
+ return { hits: cacheHits, misses: cacheMisses };
11
+ }
12
+ function stampFile(filePath) {
13
+ try {
14
+ const info = statSync(filePath);
15
+ const mtimeNs = typeof info.mtimeNs === 'bigint'
16
+ ? info.mtimeNs
17
+ : BigInt(Math.round(info.mtimeMs * 1_000_000));
18
+ return { exists: true, size: info.size, mtimeNs };
19
+ }
20
+ catch {
21
+ return { exists: false, size: 0, mtimeNs: 0n };
22
+ }
23
+ }
24
+ function sameStamp(left, right) {
25
+ return left.exists === right.exists
26
+ && left.size === right.size
27
+ && left.mtimeNs === right.mtimeNs;
28
+ }
29
+ function bindStore(store) {
30
+ if (!store || typeof store !== 'object')
31
+ return;
32
+ if (boundStores.has(store))
33
+ return;
34
+ const organ = store;
35
+ const read = organ.load;
36
+ const filePath = organ.filePath;
37
+ if (typeof read !== 'function' || typeof filePath !== 'string' || filePath.length === 0)
38
+ return;
39
+ boundStores.add(store);
40
+ let filled = false;
41
+ let cached;
42
+ let stamp = null;
43
+ organ.load = () => {
44
+ const before = stampFile(filePath);
45
+ if (filled && stamp && sameStamp(stamp, before)) {
46
+ cacheHits += 1;
47
+ return cached;
48
+ }
49
+ cacheMisses += 1;
50
+ const value = read.call(organ);
51
+ const after = stampFile(filePath);
52
+ if (sameStamp(before, after)) {
53
+ cached = value;
54
+ stamp = after;
55
+ filled = true;
56
+ }
57
+ else {
58
+ filled = false;
59
+ stamp = null;
60
+ }
61
+ return value;
62
+ };
63
+ }
64
+ /** Attach the file cache to a loaded Repertoire provider. Other providers are left alone. */
65
+ export function bindOrganFileCache(provider) {
66
+ const service = provider.service;
67
+ if (!service || typeof service !== 'object')
68
+ return;
69
+ const row = service;
70
+ bindStore(row.signalsManager);
71
+ bindStore(row.stateManager);
72
+ }
@@ -1,4 +1,4 @@
1
- export declare const PLATE_IDS: readonly ["routing", "governance", "boot", "orchestration", "processor", "reporting", "memory-recall", "house", "goggles", "suit", "kits", "host-pack", "glossary"];
1
+ export declare const PLATE_IDS: readonly ["routing", "governance", "boot", "orchestration", "processor", "reporting", "memory-recall", "stamp-plate", "house", "review", "goggles", "suit", "kits", "host-pack", "glossary", "record-map", "write-home", "activity-log", "session-capture", "suit-wear", "suit-organs", "station-card", "notes-page", "reflection-page", "site-manual", "package-face", "suit-settings", "trail-state", "inference-files", "grok-compact", "payload-heat", "station-heat", "pickup-stamp", "cursor-compact", "work-fresh", "kept-line", "lens-gate", "pre-tool", "lens-page"];
2
2
  export type PlateId = (typeof PLATE_IDS)[number];
3
3
  export interface PlateStamp {
4
4
  id: PlateId;
@@ -13,12 +13,38 @@ export const PLATE_IDS = [
13
13
  'processor',
14
14
  'reporting',
15
15
  'memory-recall',
16
+ 'stamp-plate',
16
17
  'house',
18
+ 'review',
17
19
  'goggles',
18
20
  'suit',
19
21
  'kits',
20
22
  'host-pack',
21
23
  'glossary',
24
+ 'record-map',
25
+ 'write-home',
26
+ 'activity-log',
27
+ 'session-capture',
28
+ 'suit-wear',
29
+ 'suit-organs',
30
+ 'station-card',
31
+ 'notes-page',
32
+ 'reflection-page',
33
+ 'site-manual',
34
+ 'package-face',
35
+ 'suit-settings',
36
+ 'trail-state',
37
+ 'inference-files',
38
+ 'grok-compact',
39
+ 'payload-heat',
40
+ 'station-heat',
41
+ 'pickup-stamp',
42
+ 'cursor-compact',
43
+ 'work-fresh',
44
+ 'kept-line',
45
+ 'lens-gate',
46
+ 'pre-tool',
47
+ 'lens-page',
22
48
  ];
23
49
  function isPlateId(value) {
24
50
  return PLATE_IDS.includes(value);
@@ -3,6 +3,7 @@ import { createRequire } from 'node:module';
3
3
  import { resolve, dirname, join } from 'node:path';
4
4
  import { pathToFileURL } from 'node:url';
5
5
  import { frameworkLogger } from '../core/framework-logger.js';
6
+ import { bindOrganFileCache } from './lookup-cache.js';
6
7
  import { createMemoryRoutingProvider as createNullProvider } from './null-provider.js';
7
8
  import { validateMemoryRoutingConfig } from './validate-config.js';
8
9
  // Opening the organ must not merge subject repo-* back onto the project file.
@@ -139,6 +140,7 @@ export function loadMemoryRoutingProviderSync(config, cwd = process.cwd()) {
139
140
  try {
140
141
  const mod = require(resolved.modulePath);
141
142
  const provider = providerFromModule(mod, resolved.modulePath, resolved.effective);
143
+ bindOrganFileCache(provider);
142
144
  if (!provider.isAvailable())
143
145
  return null;
144
146
  return provider;
@@ -179,6 +181,7 @@ export async function loadMemoryRoutingProvider(config, cwd = process.cwd()) {
179
181
  if (!provider?.id || typeof provider.isAvailable !== 'function') {
180
182
  throw new Error(`Invalid memory routing provider from ${modulePath}`);
181
183
  }
184
+ bindOrganFileCache(provider);
182
185
  const availabilityReason = resolveUnavailableReason(provider);
183
186
  if (!provider.isAvailable()) {
184
187
  await frameworkLogger.log('memory-routing', 'provider-unavailable', 'error', {