0xray 2.0.1 → 2.1.1

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 (286) hide show
  1. package/.opencode/codex.codex +1 -1
  2. package/.opencode/commands/dependency-audit.md +3 -3
  3. package/.opencode/enforcer-config.json +2 -2
  4. package/.opencode/hooks/post-commit +1 -1
  5. package/.opencode/init.sh +2 -2
  6. package/AGENTS.md +1 -1
  7. package/README.md +2 -2
  8. package/dist/AGENTS.md +1 -1
  9. package/dist/CHANGELOG.md +10 -0
  10. package/dist/README.md +2 -2
  11. package/dist/analytics/routing-refiner.js +1 -1
  12. package/dist/benchmark/performance-benchmark.d.ts +2 -2
  13. package/dist/benchmark/performance-benchmark.js +3 -3
  14. package/dist/cli/commands/hermes-install.js +4 -4
  15. package/dist/cli/commands/mcp-install.js +1 -1
  16. package/dist/cli/commands/openclaw-install.js +1 -1
  17. package/dist/cli/commands/plugin-commands.js +2 -2
  18. package/dist/cli/commands/publish-agent.js +5 -5
  19. package/dist/cli/commands/skill-install.js +1 -1
  20. package/dist/cli/commands/status.js +3 -3
  21. package/dist/cli/commands/storyteller.js +2 -2
  22. package/dist/cli/index.js +8 -8
  23. package/dist/cli/server.js +1 -1
  24. package/dist/core/agent-spawn-gate.d.ts +1 -1
  25. package/dist/core/agent-spawn-gate.js +1 -1
  26. package/dist/core/boot-orchestrator.d.ts +4 -4
  27. package/dist/core/boot-orchestrator.js +27 -27
  28. package/dist/core/bridge.mjs +22 -22
  29. package/dist/core/codex-formatter.js +2 -2
  30. package/dist/core/codex-injector.d.ts +4 -3
  31. package/dist/core/codex-injector.js +11 -10
  32. package/dist/core/config-loader.d.ts +5 -4
  33. package/dist/core/config-loader.js +4 -2
  34. package/dist/core/config-paths.d.ts +9 -8
  35. package/dist/core/config-paths.js +24 -23
  36. package/dist/core/context-loader.d.ts +4 -3
  37. package/dist/core/context-loader.js +7 -5
  38. package/dist/core/features-config.js +1 -1
  39. package/dist/core/index.d.ts +1 -1
  40. package/dist/core/index.js +1 -1
  41. package/dist/core/orchestrator.d.ts +1 -0
  42. package/dist/core/orchestrator.js +3 -2
  43. package/dist/core/system-prompt-generator.js +2 -2
  44. package/dist/core/xray-activation.d.ts +4 -4
  45. package/dist/core/xray-activation.js +29 -24
  46. package/dist/delegation/agent-delegator.d.ts +3 -3
  47. package/dist/delegation/agent-delegator.js +3 -3
  48. package/dist/delegation/metrics-aggregator.d.ts +11 -11
  49. package/dist/delegation/session-coordinator.d.ts +3 -3
  50. package/dist/delegation/voting-coordinator.d.ts +3 -3
  51. package/dist/enforcement/enforcer-tools.js +2 -2
  52. package/dist/enforcement/loaders/codex-loader.d.ts +1 -1
  53. package/dist/enforcement/loaders/codex-loader.js +2 -2
  54. package/dist/index.d.ts +5 -5
  55. package/dist/index.js +6 -6
  56. package/dist/inference/deploy-verifier.js +1 -1
  57. package/dist/inference/inference-cycle.js +7 -7
  58. package/dist/integrations/base/README.md +2 -2
  59. package/dist/integrations/governance/index.js +1 -1
  60. package/dist/integrations/grok/grok-cli.d.ts +1 -1
  61. package/dist/integrations/grok/grok-cli.js +6 -6
  62. package/dist/integrations/grok/hooks/pre-tool-use.js +1 -1
  63. package/dist/integrations/grok/plugin/0xray/.mcp.json +3 -3
  64. package/dist/integrations/grok/plugin/0xray/hooks/hooks.json +2 -2
  65. package/dist/integrations/hermes-agent/__init__.py +77 -71
  66. package/dist/integrations/hermes-agent/__pycache__/__init__.cpython-313.pyc +0 -0
  67. package/dist/integrations/hermes-agent/__pycache__/conftest.cpython-313-pytest-9.0.2.pyc +0 -0
  68. package/dist/integrations/hermes-agent/__pycache__/schemas.cpython-313.pyc +0 -0
  69. package/dist/integrations/hermes-agent/__pycache__/test_plugin.cpython-313-pytest-9.0.2.pyc +0 -0
  70. package/dist/integrations/hermes-agent/__pycache__/test_plugin.cpython-313.pyc +0 -0
  71. package/dist/integrations/hermes-agent/__pycache__/tools.cpython-313.pyc +0 -0
  72. package/dist/integrations/hermes-agent/after-install.md +14 -14
  73. package/dist/integrations/hermes-agent/bridge.mjs +14 -14
  74. package/dist/integrations/hermes-agent/logs/framework/routing-outcomes.json +1 -0
  75. package/dist/integrations/hermes-agent/plugin.yaml +5 -5
  76. package/dist/integrations/hermes-agent/schemas.py +12 -12
  77. package/dist/integrations/hermes-agent/test_plugin.py +128 -125
  78. package/dist/integrations/hermes-agent/tools.py +85 -23
  79. package/dist/integrations/openclaw/README.md +16 -16
  80. package/dist/integrations/openclaw/api-server.d.ts +4 -4
  81. package/dist/integrations/openclaw/api-server.js +9 -9
  82. package/dist/integrations/openclaw/config.js +1 -1
  83. package/dist/integrations/openclaw/hooks/{strray-hooks.d.ts → xray-hooks.d.ts} +4 -4
  84. package/dist/integrations/openclaw/index.d.ts +4 -4
  85. package/dist/integrations/openclaw/index.js +4 -4
  86. package/dist/integrations/openclaw/types.d.ts +1 -1
  87. package/dist/integrations/plugins/plugin-registry.js +2 -2
  88. package/dist/mcps/architect-tools.server.d.ts +2 -2
  89. package/dist/mcps/architect-tools.server.js +4 -4
  90. package/dist/mcps/auto-format.server.d.ts +2 -2
  91. package/dist/mcps/auto-format.server.js +4 -4
  92. package/dist/mcps/boot-orchestrator.server.d.ts +2 -2
  93. package/dist/mcps/boot-orchestrator.server.js +4 -4
  94. package/dist/mcps/config/server-config-registry.d.ts +1 -1
  95. package/dist/mcps/config/server-config-registry.js +7 -7
  96. package/dist/mcps/connection/mcp-connection.js +1 -1
  97. package/dist/mcps/enforcer-tools.server.d.ts +2 -2
  98. package/dist/mcps/enforcer-tools.server.js +4 -4
  99. package/dist/mcps/estimation.server.js +1 -1
  100. package/dist/mcps/framework-compliance-audit.server.d.ts +2 -2
  101. package/dist/mcps/framework-compliance-audit.server.js +4 -4
  102. package/dist/mcps/framework-help.server.js +7 -7
  103. package/dist/mcps/governance.server.js +1 -1
  104. package/dist/mcps/in-process-skill-registry.js +6 -6
  105. package/dist/mcps/knowledge-skills/api-design.server.d.ts +2 -2
  106. package/dist/mcps/knowledge-skills/api-design.server.js +4 -4
  107. package/dist/mcps/knowledge-skills/architecture-patterns.server.d.ts +2 -2
  108. package/dist/mcps/knowledge-skills/architecture-patterns.server.js +4 -4
  109. package/dist/mcps/knowledge-skills/bug-triage-specialist.server.js +1 -1
  110. package/dist/mcps/knowledge-skills/code-analyzer.server.js +1 -1
  111. package/dist/mcps/knowledge-skills/code-review.server.d.ts +2 -2
  112. package/dist/mcps/knowledge-skills/code-review.server.js +4 -4
  113. package/dist/mcps/knowledge-skills/content-creator.server.js +1 -1
  114. package/dist/mcps/knowledge-skills/database-design.server.d.ts +2 -2
  115. package/dist/mcps/knowledge-skills/database-design.server.js +4 -4
  116. package/dist/mcps/knowledge-skills/devops-deployment.server.d.ts +2 -2
  117. package/dist/mcps/knowledge-skills/devops-deployment.server.js +4 -4
  118. package/dist/mcps/knowledge-skills/git-workflow.server.d.ts +2 -2
  119. package/dist/mcps/knowledge-skills/git-workflow.server.js +4 -4
  120. package/dist/mcps/knowledge-skills/growth-strategist.server.js +1 -1
  121. package/dist/mcps/knowledge-skills/log-monitor.server.js +1 -1
  122. package/dist/mcps/knowledge-skills/mobile-development.server.d.ts +2 -2
  123. package/dist/mcps/knowledge-skills/mobile-development.server.js +4 -4
  124. package/dist/mcps/knowledge-skills/multimodal-looker.server.js +1 -1
  125. package/dist/mcps/knowledge-skills/performance-optimization.server.d.ts +2 -2
  126. package/dist/mcps/knowledge-skills/performance-optimization.server.js +4 -4
  127. package/dist/mcps/knowledge-skills/project-analysis.server.js +1 -1
  128. package/dist/mcps/knowledge-skills/refactoring-strategies.server.d.ts +2 -2
  129. package/dist/mcps/knowledge-skills/refactoring-strategies.server.js +4 -4
  130. package/dist/mcps/knowledge-skills/security-audit.server.d.ts +2 -2
  131. package/dist/mcps/knowledge-skills/security-audit.server.js +4 -4
  132. package/dist/mcps/knowledge-skills/seo-consultant.server.js +1 -1
  133. package/dist/mcps/knowledge-skills/session-management.server.js +1 -1
  134. package/dist/mcps/knowledge-skills/skill-invocation.server.js +1 -1
  135. package/dist/mcps/knowledge-skills/strategist.server.js +1 -1
  136. package/dist/mcps/knowledge-skills/tech-writer.server.d.ts +2 -2
  137. package/dist/mcps/knowledge-skills/tech-writer.server.js +5 -5
  138. package/dist/mcps/knowledge-skills/testing-best-practices.server.d.ts +2 -2
  139. package/dist/mcps/knowledge-skills/testing-best-practices.server.js +4 -4
  140. package/dist/mcps/knowledge-skills/testing-strategy.server.d.ts +2 -2
  141. package/dist/mcps/knowledge-skills/testing-strategy.server.js +4 -4
  142. package/dist/mcps/knowledge-skills/ui-ux-design.server.d.ts +2 -2
  143. package/dist/mcps/knowledge-skills/ui-ux-design.server.js +6 -6
  144. package/dist/mcps/lint.server.d.ts +2 -2
  145. package/dist/mcps/lint.server.js +6 -6
  146. package/dist/mcps/mcp-client.js +3 -3
  147. package/dist/mcps/model-health-check.server.d.ts +2 -2
  148. package/dist/mcps/model-health-check.server.js +4 -4
  149. package/dist/mcps/orchestrator/server.js +2 -2
  150. package/dist/mcps/performance-analysis.server.d.ts +2 -2
  151. package/dist/mcps/performance-analysis.server.js +4 -4
  152. package/dist/mcps/processor-pipeline.server.d.ts +2 -2
  153. package/dist/mcps/processor-pipeline.server.js +4 -4
  154. package/dist/mcps/registry.json +1 -1
  155. package/dist/mcps/researcher.server.d.ts +3 -3
  156. package/dist/mcps/researcher.server.js +5 -5
  157. package/dist/mcps/security-scan.server.d.ts +2 -2
  158. package/dist/mcps/security-scan.server.js +4 -4
  159. package/dist/mcps/simulation/server-simulations.js +3 -3
  160. package/dist/mcps/state-manager.server.js +1 -1
  161. package/dist/metrics/agent-metrics.d.ts +4 -4
  162. package/dist/metrics/agent-metrics.js +1 -1
  163. package/dist/orchestrator/enhanced-multi-agent-orchestrator.d.ts +2 -2
  164. package/dist/orchestrator/enhanced-multi-agent-orchestrator.js +2 -2
  165. package/dist/orchestrator/intelligent-commit-batcher.d.ts +1 -1
  166. package/dist/orchestrator/intelligent-commit-batcher.js +3 -3
  167. package/dist/orchestrator/multi-agent-orchestration-coordinator.d.ts +3 -3
  168. package/dist/orchestrator/multi-agent-orchestration-coordinator.js +9 -9
  169. package/dist/orchestrator/orchestrator.d.ts +3 -2
  170. package/dist/orchestrator/orchestrator.js +8 -6
  171. package/dist/orchestrator/universal-registry-bridge.js +1 -1
  172. package/dist/plugin/xray-codex-injection.d.ts +1 -1
  173. package/dist/plugin/xray-codex-injection.js +8 -7
  174. package/dist/postprocessor/PostProcessor.d.ts +2 -2
  175. package/dist/postprocessor/PostProcessor.js +1 -1
  176. package/dist/postprocessor/monitoring/MonitoringEngine.d.ts +2 -2
  177. package/dist/postprocessor/services/RegressionAnalysisService.js +2 -2
  178. package/dist/postprocessor/triggers/GitHookTrigger.js +14 -14
  179. package/dist/processors/implementations/agents-md-validation-processor.js +2 -2
  180. package/dist/processors/implementations/inference-improvement-processor.js +2 -2
  181. package/dist/processors/implementations/log-protection-processor.d.ts +1 -1
  182. package/dist/processors/implementations/log-protection-processor.js +2 -2
  183. package/dist/processors/implementations/publish-preflight-processor.d.ts +1 -1
  184. package/dist/processors/implementations/publish-preflight-processor.js +3 -3
  185. package/dist/processors/implementations/regression-testing-processor.js +2 -2
  186. package/dist/processors/implementations/session-summary-processor.js +2 -2
  187. package/dist/processors/implementations/storytelling-trigger-processor.js +2 -2
  188. package/dist/processors/processor-manager.d.ts +2 -2
  189. package/dist/public/about.html +6 -6
  190. package/dist/public/enterprise.html +1 -1
  191. package/dist/public/features.html +2 -2
  192. package/dist/public/index.html +4 -4
  193. package/dist/reporting/report-formatter.js +1 -1
  194. package/dist/scripts/activate-kernel-pipeline.js +2 -2
  195. package/dist/scripts/pre-command +1 -1
  196. package/dist/services/inference-tuner.js +2 -2
  197. package/dist/session/session-cleanup-manager.d.ts +3 -3
  198. package/dist/session/session-monitor.d.ts +3 -3
  199. package/dist/session/session-state-manager.d.ts +3 -3
  200. package/dist/skills/hermes-agent/SKILL.md +12 -12
  201. package/dist/skills/registry.json +1 -1
  202. package/dist/skills/storyteller/SKILL.md +1 -1
  203. package/dist/skills/xray-orchestrator/SKILL.md +141 -0
  204. package/dist/skills/xray-orchestrator/index.d.ts +13 -0
  205. package/dist/skills/xray-orchestrator/index.js +224 -0
  206. package/dist/state/index.d.ts +2 -1
  207. package/dist/state/index.js +2 -1
  208. package/dist/state/state-manager.d.ts +2 -2
  209. package/dist/state/state-manager.js +5 -4
  210. package/dist/utils/import-resolver.js +1 -1
  211. package/dist/utils/path-resolver.js +2 -2
  212. package/dist/utils/token-manager.js +1 -1
  213. package/dist/validation/estimation-validator.js +1 -1
  214. package/package.json +2 -2
  215. package/scripts/hooks/pre-command +1 -1
  216. package/scripts/hooks/run-hook.js +2 -2
  217. package/scripts/node/auto-reflection-generator.mjs +2 -2
  218. package/scripts/node/postinstall.cjs +1 -1
  219. package/scripts/node/pre-publish-guard.js +16 -10
  220. package/scripts/node/release.js +6 -6
  221. package/scripts/node/release.mjs +11 -11
  222. package/scripts/node/universal-version-manager.js +2 -2
  223. package/scripts/node/version-manager.mjs +1 -1
  224. package/src/integrations/grok/plugin/0xray/.mcp.json +3 -3
  225. package/src/integrations/grok/plugin/0xray/hooks/hooks.json +2 -2
  226. package/src/mcps/architect-tools.server.ts +4 -4
  227. package/src/mcps/auto-format.server.ts +4 -4
  228. package/src/mcps/boot-orchestrator.server.ts +4 -4
  229. package/src/mcps/config/server-config-registry.ts +7 -7
  230. package/src/mcps/connection/mcp-connection.ts +1 -1
  231. package/src/mcps/enforcer-tools.server.ts +4 -4
  232. package/src/mcps/estimation.server.ts +1 -1
  233. package/src/mcps/framework-compliance-audit.server.ts +4 -4
  234. package/src/mcps/framework-help.server.ts +7 -7
  235. package/src/mcps/governance.server.ts +1 -1
  236. package/src/mcps/in-process-skill-registry.ts +6 -6
  237. package/src/mcps/knowledge-skills/api-design.server.test.ts +8 -8
  238. package/src/mcps/knowledge-skills/api-design.server.ts +4 -4
  239. package/src/mcps/knowledge-skills/architecture-patterns.server.ts +4 -4
  240. package/src/mcps/knowledge-skills/bug-triage-specialist.server.ts +1 -1
  241. package/src/mcps/knowledge-skills/code-analyzer.server.ts +1 -1
  242. package/src/mcps/knowledge-skills/code-review.server.ts +4 -4
  243. package/src/mcps/knowledge-skills/content-creator.server.ts +1 -1
  244. package/src/mcps/knowledge-skills/database-design.server.ts +4 -4
  245. package/src/mcps/knowledge-skills/devops-deployment.server.ts +4 -4
  246. package/src/mcps/knowledge-skills/git-workflow.server.ts +4 -4
  247. package/src/mcps/knowledge-skills/growth-strategist.server.ts +1 -1
  248. package/src/mcps/knowledge-skills/log-monitor.server.ts +1 -1
  249. package/src/mcps/knowledge-skills/mobile-development.server.ts +4 -4
  250. package/src/mcps/knowledge-skills/multimodal-looker.server.ts +1 -1
  251. package/src/mcps/knowledge-skills/performance-optimization.server.ts +4 -4
  252. package/src/mcps/knowledge-skills/project-analysis.server.ts +1 -1
  253. package/src/mcps/knowledge-skills/refactoring-strategies.server.ts +4 -4
  254. package/src/mcps/knowledge-skills/security-audit.server.test.ts +23 -23
  255. package/src/mcps/knowledge-skills/security-audit.server.ts +4 -4
  256. package/src/mcps/knowledge-skills/seo-consultant.server.ts +1 -1
  257. package/src/mcps/knowledge-skills/session-management.server.ts +1 -1
  258. package/src/mcps/knowledge-skills/skill-invocation.server.ts +1 -1
  259. package/src/mcps/knowledge-skills/strategist.server.ts +1 -1
  260. package/src/mcps/knowledge-skills/tech-writer.server.ts +5 -5
  261. package/src/mcps/knowledge-skills/testing-best-practices.server.test.ts +28 -28
  262. package/src/mcps/knowledge-skills/testing-best-practices.server.ts +4 -4
  263. package/src/mcps/knowledge-skills/testing-strategy.server.test.ts +19 -19
  264. package/src/mcps/knowledge-skills/testing-strategy.server.ts +4 -4
  265. package/src/mcps/knowledge-skills/ui-ux-design.server.ts +6 -6
  266. package/src/mcps/lint.server.ts +6 -6
  267. package/src/mcps/mcp-client.ts +3 -3
  268. package/src/mcps/model-health-check.server.ts +4 -4
  269. package/src/mcps/orchestrator/server.ts +2 -2
  270. package/src/mcps/performance-analysis.server.ts +4 -4
  271. package/src/mcps/processor-pipeline.server.ts +4 -4
  272. package/src/mcps/registry.json +1 -1
  273. package/src/mcps/researcher.server.ts +5 -5
  274. package/src/mcps/security-scan.server.ts +4 -4
  275. package/src/mcps/simulation/server-simulations.ts +3 -3
  276. package/src/mcps/state-manager.server.ts +1 -1
  277. package/src/opencode/codex.codex +1 -1
  278. package/src/opencode/commands/dependency-audit.md +3 -3
  279. package/src/opencode/enforcer-config.json +2 -2
  280. package/src/skills/hermes-agent/SKILL.md +12 -12
  281. package/src/skills/registry.json +1 -1
  282. package/src/skills/storyteller/SKILL.md +1 -1
  283. package/src/skills/xray-orchestrator/SKILL.md +141 -0
  284. package/src/skills/xray-orchestrator/index.ts +268 -0
  285. package/scripts/validate-stringray-comprehensive.js +0 -636
  286. /package/dist/integrations/openclaw/hooks/{strray-hooks.js → xray-hooks.js} +0 -0
@@ -0,0 +1,268 @@
1
+ /**
2
+ * xray Orchestrator Skill
3
+ *
4
+ * OpenClaw skill that provides xray orchestration commands.
5
+ *
6
+ * @version 1.0.0
7
+ * @since 2026-03-14
8
+ */
9
+
10
+ const API_BASE = process.env.XRAY_API_URL || 'http://localhost:18431';
11
+ const API_KEY = process.env.XRAY_API_KEY;
12
+
13
+ interface ParsedArgs extends Record<string, unknown> {
14
+ _?: string[];
15
+ }
16
+
17
+ function parseArgs(input: string): { command: string; args: ParsedArgs } {
18
+ const parts = input.trim().split(/\s+/);
19
+ const command = parts[0] || '';
20
+ const args: ParsedArgs = {};
21
+
22
+ for (const part of parts.slice(1)) {
23
+ if (part.startsWith('--')) {
24
+ const key = part.slice(2);
25
+ args[key] = true;
26
+ } else if (part.includes(':')) {
27
+ const colonIdx = part.indexOf(':');
28
+ const key = part.slice(0, colonIdx);
29
+ const value = part.slice(colonIdx + 1);
30
+ if (key && value) args[key] = value;
31
+ } else if (!args._) {
32
+ args._ = [];
33
+ args._.push(part);
34
+ } else {
35
+ args._.push(part);
36
+ }
37
+ }
38
+
39
+ return { command, args };
40
+ }
41
+
42
+ async function callAPI(endpoint: string, data?: Record<string, unknown>): Promise<Record<string, unknown>> {
43
+ const headers: Record<string, string> = {
44
+ 'Content-Type': 'application/json',
45
+ };
46
+
47
+ if (API_KEY) {
48
+ headers['Authorization'] = `Bearer ${API_KEY}`;
49
+ }
50
+
51
+ const response = await fetch(`${API_BASE}${endpoint}`, {
52
+ method: data ? 'POST' : 'GET',
53
+ headers,
54
+ body: data ? JSON.stringify(data) : null,
55
+ });
56
+
57
+ if (!response.ok) {
58
+ const error = await response.json().catch(() => ({ error: 'Unknown error' }));
59
+ throw new Error(error.error || `HTTP ${response.status}`);
60
+ }
61
+
62
+ return response.json();
63
+ }
64
+
65
+ export async function handleSkill(input: string): Promise<string> {
66
+ const { command, args } = parseArgs(input);
67
+
68
+ try {
69
+ switch (command.toLowerCase()) {
70
+ // xray primary
71
+ case 'xray':
72
+ case 'xray-status':
73
+ return await handleStatus();
74
+
75
+ case 'xray-analyze':
76
+ return await handleAnalyze(args);
77
+
78
+ case 'xray-code':
79
+ return await handleCodeReview(args);
80
+
81
+ case 'xray-file':
82
+ return await handleFileRead(args);
83
+
84
+ case 'xray-exec':
85
+ return await handleExec(args);
86
+
87
+ case 'xray-help':
88
+ return handleHelp(args._ as string | undefined);
89
+
90
+ default:
91
+ return formatHelp();
92
+ }
93
+ } catch (error) {
94
+ const message = error instanceof Error ? error.message : String(error);
95
+ return `❌ Error: ${message}`;
96
+ }
97
+ }
98
+
99
+ async function handleStatus(): Promise<string> {
100
+ const health = await callAPI('/health') as { status: string; version: string; uptime: number };
101
+
102
+ return `🤖 xray Status
103
+
104
+ • Status: ${health.status}
105
+ • Version: ${health.version}
106
+ • Uptime: ${formatUptime(health.uptime)}
107
+
108
+ Use /xray-help for available commands.`;
109
+ }
110
+
111
+ async function handleAnalyze(args: Record<string, unknown>): Promise<string> {
112
+ const filePath = (args._ as string[])?.[0];
113
+
114
+ if (!filePath) {
115
+ return '❌ Usage: /xray-analyze <file-path>';
116
+ }
117
+
118
+ const result = await callAPI('/api/agent/invoke', {
119
+ command: 'analyze',
120
+ args: { filePath },
121
+ }) as { success: boolean; result?: unknown; error?: string };
122
+
123
+ if (!result.success) {
124
+ return `❌ Analysis failed: ${result.error}`;
125
+ }
126
+
127
+ return `✅ Analysis complete for ${filePath}\n\n${JSON.stringify(result.result, null, 2)}`;
128
+ }
129
+
130
+ async function handleCodeReview(args: Record<string, unknown>): Promise<string> {
131
+ const filePath = (args._ as string[])?.[0];
132
+ const fix = args.fix === true;
133
+
134
+ if (!filePath) {
135
+ return '❌ Usage: /xray-code <file-path> [--fix]';
136
+ }
137
+
138
+ const result = await callAPI('/api/agent/invoke', {
139
+ command: 'code-review',
140
+ args: { filePath, fix },
141
+ }) as { success: boolean; result?: unknown; error?: string };
142
+
143
+ if (!result.success) {
144
+ return `❌ Code review failed: ${result.error}`;
145
+ }
146
+
147
+ return `✅ Code review complete for ${filePath}\n\n${JSON.stringify(result.result, null, 2)}`;
148
+ }
149
+
150
+ async function handleFileRead(args: Record<string, unknown>): Promise<string> {
151
+ const rest = args._ as string[] | undefined;
152
+ const filePath = rest?.[0];
153
+ const range = rest?.[1];
154
+
155
+ if (!filePath) {
156
+ return '❌ Usage: /xray-file <file-path> [line-start:line-end]';
157
+ }
158
+
159
+ let lineRange: { start?: number; end?: number } | undefined;
160
+ if (range?.includes(':')) {
161
+ const [rawStart, rawEnd] = range.split(':');
162
+ lineRange = {};
163
+ if (rawStart) lineRange.start = Number(rawStart);
164
+ if (rawEnd) lineRange.end = Number(rawEnd);
165
+ }
166
+
167
+ const result = await callAPI('/api/agent/invoke', {
168
+ command: 'read',
169
+ args: { filePath, ...lineRange },
170
+ }) as { success: boolean; result?: unknown; error?: string };
171
+
172
+ if (!result.success) {
173
+ return `❌ File read failed: ${result.error}`;
174
+ }
175
+
176
+ return `📄 ${filePath}\n\`\`\`\n${result.result}\n\`\`\``;
177
+ }
178
+
179
+ async function handleExec(args: Record<string, unknown>): Promise<string> {
180
+ const command = (args._ as string[])?.[0];
181
+
182
+ if (!command) {
183
+ return '❌ Usage: /xray-exec <command>';
184
+ }
185
+
186
+ const result = await callAPI('/api/agent/invoke', {
187
+ command: 'exec',
188
+ args: { command },
189
+ }) as { success: boolean; result?: unknown; error?: string };
190
+
191
+ if (!result.success) {
192
+ return `❌ Execution failed: ${result.error}`;
193
+ }
194
+
195
+ return `✅ Command executed\n\n${JSON.stringify(result.result, null, 2)}`;
196
+ }
197
+
198
+ function handleHelp(command?: string): string {
199
+ if (command) {
200
+ switch (command) {
201
+ case 'xray-analyze':
202
+ return `📖 /xray-analyze <file-path>
203
+
204
+ Analyze code in a file.
205
+
206
+ Example: /xray-analyze src/index.ts`;
207
+
208
+ case 'xray-code':
209
+ return `📖 /xray-code <file-path> [--fix]
210
+
211
+ Perform code review on a file.
212
+ Use --fix to attempt automatic fixes.
213
+
214
+ Example: /xray-code src/utils/helper.ts
215
+ Example: /xray-code src/utils/helper.ts --fix`;
216
+
217
+ case 'xray-file':
218
+ return `📖 /xray-file <file-path> [line-start:line-end]
219
+
220
+ Read a file.
221
+ Optionally specify line range.
222
+
223
+ Example: /xray-file src/index.ts
224
+ Example: /xray-file src/index.ts 1:50`;
225
+
226
+ case 'xray-exec':
227
+ return `📖 /xray-exec <command>
228
+
229
+ Execute an arbitrary command.
230
+
231
+ Example: /xray-exec list files src/`;
232
+
233
+ default:
234
+ return `Unknown command: ${command}`;
235
+ }
236
+ }
237
+
238
+ return formatHelp();
239
+ }
240
+
241
+ function formatHelp(): string {
242
+ return `🤖 xray Orchestrator
243
+
244
+ Available Commands:
245
+ • /xray - Show status
246
+ • /xray-analyze <file> - Analyze code
247
+ • /xray-code <file> [--fix] - Code review
248
+ • /xray-file <file> [lines] - Read file
249
+ • /xray-exec <command> - Execute command
250
+ • /xray-help [command] - Show help
251
+
252
+ Use /xray-help <command> for detailed usage.`;
253
+ }
254
+
255
+ function formatUptime(ms: number): string {
256
+ const seconds = Math.floor(ms / 1000);
257
+ const minutes = Math.floor(seconds / 60);
258
+ const hours = Math.floor(minutes / 60);
259
+ const days = Math.floor(hours / 24);
260
+
261
+ if (days > 0) return `${days}d ${hours % 24}h`;
262
+ if (hours > 0) return `${hours}h ${minutes % 60}m`;
263
+ if (minutes > 0) return `${minutes}m`;
264
+ return `${seconds}s`;
265
+ }
266
+
267
+ // Export for OpenClaw
268
+ export default { handleSkill };