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.
- package/.opencode/codex.codex +1 -1
- package/.opencode/commands/dependency-audit.md +3 -3
- package/.opencode/enforcer-config.json +2 -2
- package/.opencode/hooks/post-commit +1 -1
- package/.opencode/init.sh +2 -2
- package/AGENTS.md +1 -1
- package/README.md +2 -2
- package/dist/AGENTS.md +1 -1
- package/dist/CHANGELOG.md +10 -0
- package/dist/README.md +2 -2
- package/dist/analytics/routing-refiner.js +1 -1
- package/dist/benchmark/performance-benchmark.d.ts +2 -2
- package/dist/benchmark/performance-benchmark.js +3 -3
- package/dist/cli/commands/hermes-install.js +4 -4
- package/dist/cli/commands/mcp-install.js +1 -1
- package/dist/cli/commands/openclaw-install.js +1 -1
- package/dist/cli/commands/plugin-commands.js +2 -2
- package/dist/cli/commands/publish-agent.js +5 -5
- package/dist/cli/commands/skill-install.js +1 -1
- package/dist/cli/commands/status.js +3 -3
- package/dist/cli/commands/storyteller.js +2 -2
- package/dist/cli/index.js +8 -8
- package/dist/cli/server.js +1 -1
- package/dist/core/agent-spawn-gate.d.ts +1 -1
- package/dist/core/agent-spawn-gate.js +1 -1
- package/dist/core/boot-orchestrator.d.ts +4 -4
- package/dist/core/boot-orchestrator.js +27 -27
- package/dist/core/bridge.mjs +22 -22
- package/dist/core/codex-formatter.js +2 -2
- package/dist/core/codex-injector.d.ts +4 -3
- package/dist/core/codex-injector.js +11 -10
- package/dist/core/config-loader.d.ts +5 -4
- package/dist/core/config-loader.js +4 -2
- package/dist/core/config-paths.d.ts +9 -8
- package/dist/core/config-paths.js +24 -23
- package/dist/core/context-loader.d.ts +4 -3
- package/dist/core/context-loader.js +7 -5
- package/dist/core/features-config.js +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/orchestrator.d.ts +1 -0
- package/dist/core/orchestrator.js +3 -2
- package/dist/core/system-prompt-generator.js +2 -2
- package/dist/core/xray-activation.d.ts +4 -4
- package/dist/core/xray-activation.js +29 -24
- package/dist/delegation/agent-delegator.d.ts +3 -3
- package/dist/delegation/agent-delegator.js +3 -3
- package/dist/delegation/metrics-aggregator.d.ts +11 -11
- package/dist/delegation/session-coordinator.d.ts +3 -3
- package/dist/delegation/voting-coordinator.d.ts +3 -3
- package/dist/enforcement/enforcer-tools.js +2 -2
- package/dist/enforcement/loaders/codex-loader.d.ts +1 -1
- package/dist/enforcement/loaders/codex-loader.js +2 -2
- package/dist/index.d.ts +5 -5
- package/dist/index.js +6 -6
- package/dist/inference/deploy-verifier.js +1 -1
- package/dist/inference/inference-cycle.js +7 -7
- package/dist/integrations/base/README.md +2 -2
- package/dist/integrations/governance/index.js +1 -1
- package/dist/integrations/grok/grok-cli.d.ts +1 -1
- package/dist/integrations/grok/grok-cli.js +6 -6
- package/dist/integrations/grok/hooks/pre-tool-use.js +1 -1
- package/dist/integrations/grok/plugin/0xray/.mcp.json +3 -3
- package/dist/integrations/grok/plugin/0xray/hooks/hooks.json +2 -2
- package/dist/integrations/hermes-agent/__init__.py +77 -71
- package/dist/integrations/hermes-agent/__pycache__/__init__.cpython-313.pyc +0 -0
- package/dist/integrations/hermes-agent/__pycache__/conftest.cpython-313-pytest-9.0.2.pyc +0 -0
- package/dist/integrations/hermes-agent/__pycache__/schemas.cpython-313.pyc +0 -0
- package/dist/integrations/hermes-agent/__pycache__/test_plugin.cpython-313-pytest-9.0.2.pyc +0 -0
- package/dist/integrations/hermes-agent/__pycache__/test_plugin.cpython-313.pyc +0 -0
- package/dist/integrations/hermes-agent/__pycache__/tools.cpython-313.pyc +0 -0
- package/dist/integrations/hermes-agent/after-install.md +14 -14
- package/dist/integrations/hermes-agent/bridge.mjs +14 -14
- package/dist/integrations/hermes-agent/logs/framework/routing-outcomes.json +1 -0
- package/dist/integrations/hermes-agent/plugin.yaml +5 -5
- package/dist/integrations/hermes-agent/schemas.py +12 -12
- package/dist/integrations/hermes-agent/test_plugin.py +128 -125
- package/dist/integrations/hermes-agent/tools.py +85 -23
- package/dist/integrations/openclaw/README.md +16 -16
- package/dist/integrations/openclaw/api-server.d.ts +4 -4
- package/dist/integrations/openclaw/api-server.js +9 -9
- package/dist/integrations/openclaw/config.js +1 -1
- package/dist/integrations/openclaw/hooks/{strray-hooks.d.ts → xray-hooks.d.ts} +4 -4
- package/dist/integrations/openclaw/index.d.ts +4 -4
- package/dist/integrations/openclaw/index.js +4 -4
- package/dist/integrations/openclaw/types.d.ts +1 -1
- package/dist/integrations/plugins/plugin-registry.js +2 -2
- package/dist/mcps/architect-tools.server.d.ts +2 -2
- package/dist/mcps/architect-tools.server.js +4 -4
- package/dist/mcps/auto-format.server.d.ts +2 -2
- package/dist/mcps/auto-format.server.js +4 -4
- package/dist/mcps/boot-orchestrator.server.d.ts +2 -2
- package/dist/mcps/boot-orchestrator.server.js +4 -4
- package/dist/mcps/config/server-config-registry.d.ts +1 -1
- package/dist/mcps/config/server-config-registry.js +7 -7
- package/dist/mcps/connection/mcp-connection.js +1 -1
- package/dist/mcps/enforcer-tools.server.d.ts +2 -2
- package/dist/mcps/enforcer-tools.server.js +4 -4
- package/dist/mcps/estimation.server.js +1 -1
- package/dist/mcps/framework-compliance-audit.server.d.ts +2 -2
- package/dist/mcps/framework-compliance-audit.server.js +4 -4
- package/dist/mcps/framework-help.server.js +7 -7
- package/dist/mcps/governance.server.js +1 -1
- package/dist/mcps/in-process-skill-registry.js +6 -6
- package/dist/mcps/knowledge-skills/api-design.server.d.ts +2 -2
- package/dist/mcps/knowledge-skills/api-design.server.js +4 -4
- package/dist/mcps/knowledge-skills/architecture-patterns.server.d.ts +2 -2
- package/dist/mcps/knowledge-skills/architecture-patterns.server.js +4 -4
- package/dist/mcps/knowledge-skills/bug-triage-specialist.server.js +1 -1
- package/dist/mcps/knowledge-skills/code-analyzer.server.js +1 -1
- package/dist/mcps/knowledge-skills/code-review.server.d.ts +2 -2
- package/dist/mcps/knowledge-skills/code-review.server.js +4 -4
- package/dist/mcps/knowledge-skills/content-creator.server.js +1 -1
- package/dist/mcps/knowledge-skills/database-design.server.d.ts +2 -2
- package/dist/mcps/knowledge-skills/database-design.server.js +4 -4
- package/dist/mcps/knowledge-skills/devops-deployment.server.d.ts +2 -2
- package/dist/mcps/knowledge-skills/devops-deployment.server.js +4 -4
- package/dist/mcps/knowledge-skills/git-workflow.server.d.ts +2 -2
- package/dist/mcps/knowledge-skills/git-workflow.server.js +4 -4
- package/dist/mcps/knowledge-skills/growth-strategist.server.js +1 -1
- package/dist/mcps/knowledge-skills/log-monitor.server.js +1 -1
- package/dist/mcps/knowledge-skills/mobile-development.server.d.ts +2 -2
- package/dist/mcps/knowledge-skills/mobile-development.server.js +4 -4
- package/dist/mcps/knowledge-skills/multimodal-looker.server.js +1 -1
- package/dist/mcps/knowledge-skills/performance-optimization.server.d.ts +2 -2
- package/dist/mcps/knowledge-skills/performance-optimization.server.js +4 -4
- package/dist/mcps/knowledge-skills/project-analysis.server.js +1 -1
- package/dist/mcps/knowledge-skills/refactoring-strategies.server.d.ts +2 -2
- package/dist/mcps/knowledge-skills/refactoring-strategies.server.js +4 -4
- package/dist/mcps/knowledge-skills/security-audit.server.d.ts +2 -2
- package/dist/mcps/knowledge-skills/security-audit.server.js +4 -4
- package/dist/mcps/knowledge-skills/seo-consultant.server.js +1 -1
- package/dist/mcps/knowledge-skills/session-management.server.js +1 -1
- package/dist/mcps/knowledge-skills/skill-invocation.server.js +1 -1
- package/dist/mcps/knowledge-skills/strategist.server.js +1 -1
- package/dist/mcps/knowledge-skills/tech-writer.server.d.ts +2 -2
- package/dist/mcps/knowledge-skills/tech-writer.server.js +5 -5
- package/dist/mcps/knowledge-skills/testing-best-practices.server.d.ts +2 -2
- package/dist/mcps/knowledge-skills/testing-best-practices.server.js +4 -4
- package/dist/mcps/knowledge-skills/testing-strategy.server.d.ts +2 -2
- package/dist/mcps/knowledge-skills/testing-strategy.server.js +4 -4
- package/dist/mcps/knowledge-skills/ui-ux-design.server.d.ts +2 -2
- package/dist/mcps/knowledge-skills/ui-ux-design.server.js +6 -6
- package/dist/mcps/lint.server.d.ts +2 -2
- package/dist/mcps/lint.server.js +6 -6
- package/dist/mcps/mcp-client.js +3 -3
- package/dist/mcps/model-health-check.server.d.ts +2 -2
- package/dist/mcps/model-health-check.server.js +4 -4
- package/dist/mcps/orchestrator/server.js +2 -2
- package/dist/mcps/performance-analysis.server.d.ts +2 -2
- package/dist/mcps/performance-analysis.server.js +4 -4
- package/dist/mcps/processor-pipeline.server.d.ts +2 -2
- package/dist/mcps/processor-pipeline.server.js +4 -4
- package/dist/mcps/registry.json +1 -1
- package/dist/mcps/researcher.server.d.ts +3 -3
- package/dist/mcps/researcher.server.js +5 -5
- package/dist/mcps/security-scan.server.d.ts +2 -2
- package/dist/mcps/security-scan.server.js +4 -4
- package/dist/mcps/simulation/server-simulations.js +3 -3
- package/dist/mcps/state-manager.server.js +1 -1
- package/dist/metrics/agent-metrics.d.ts +4 -4
- package/dist/metrics/agent-metrics.js +1 -1
- package/dist/orchestrator/enhanced-multi-agent-orchestrator.d.ts +2 -2
- package/dist/orchestrator/enhanced-multi-agent-orchestrator.js +2 -2
- package/dist/orchestrator/intelligent-commit-batcher.d.ts +1 -1
- package/dist/orchestrator/intelligent-commit-batcher.js +3 -3
- package/dist/orchestrator/multi-agent-orchestration-coordinator.d.ts +3 -3
- package/dist/orchestrator/multi-agent-orchestration-coordinator.js +9 -9
- package/dist/orchestrator/orchestrator.d.ts +3 -2
- package/dist/orchestrator/orchestrator.js +8 -6
- package/dist/orchestrator/universal-registry-bridge.js +1 -1
- package/dist/plugin/xray-codex-injection.d.ts +1 -1
- package/dist/plugin/xray-codex-injection.js +8 -7
- package/dist/postprocessor/PostProcessor.d.ts +2 -2
- package/dist/postprocessor/PostProcessor.js +1 -1
- package/dist/postprocessor/monitoring/MonitoringEngine.d.ts +2 -2
- package/dist/postprocessor/services/RegressionAnalysisService.js +2 -2
- package/dist/postprocessor/triggers/GitHookTrigger.js +14 -14
- package/dist/processors/implementations/agents-md-validation-processor.js +2 -2
- package/dist/processors/implementations/inference-improvement-processor.js +2 -2
- package/dist/processors/implementations/log-protection-processor.d.ts +1 -1
- package/dist/processors/implementations/log-protection-processor.js +2 -2
- package/dist/processors/implementations/publish-preflight-processor.d.ts +1 -1
- package/dist/processors/implementations/publish-preflight-processor.js +3 -3
- package/dist/processors/implementations/regression-testing-processor.js +2 -2
- package/dist/processors/implementations/session-summary-processor.js +2 -2
- package/dist/processors/implementations/storytelling-trigger-processor.js +2 -2
- package/dist/processors/processor-manager.d.ts +2 -2
- package/dist/public/about.html +6 -6
- package/dist/public/enterprise.html +1 -1
- package/dist/public/features.html +2 -2
- package/dist/public/index.html +4 -4
- package/dist/reporting/report-formatter.js +1 -1
- package/dist/scripts/activate-kernel-pipeline.js +2 -2
- package/dist/scripts/pre-command +1 -1
- package/dist/services/inference-tuner.js +2 -2
- package/dist/session/session-cleanup-manager.d.ts +3 -3
- package/dist/session/session-monitor.d.ts +3 -3
- package/dist/session/session-state-manager.d.ts +3 -3
- package/dist/skills/hermes-agent/SKILL.md +12 -12
- package/dist/skills/registry.json +1 -1
- package/dist/skills/storyteller/SKILL.md +1 -1
- package/dist/skills/xray-orchestrator/SKILL.md +141 -0
- package/dist/skills/xray-orchestrator/index.d.ts +13 -0
- package/dist/skills/xray-orchestrator/index.js +224 -0
- package/dist/state/index.d.ts +2 -1
- package/dist/state/index.js +2 -1
- package/dist/state/state-manager.d.ts +2 -2
- package/dist/state/state-manager.js +5 -4
- package/dist/utils/import-resolver.js +1 -1
- package/dist/utils/path-resolver.js +2 -2
- package/dist/utils/token-manager.js +1 -1
- package/dist/validation/estimation-validator.js +1 -1
- package/package.json +2 -2
- package/scripts/hooks/pre-command +1 -1
- package/scripts/hooks/run-hook.js +2 -2
- package/scripts/node/auto-reflection-generator.mjs +2 -2
- package/scripts/node/postinstall.cjs +1 -1
- package/scripts/node/pre-publish-guard.js +16 -10
- package/scripts/node/release.js +6 -6
- package/scripts/node/release.mjs +11 -11
- package/scripts/node/universal-version-manager.js +2 -2
- package/scripts/node/version-manager.mjs +1 -1
- package/src/integrations/grok/plugin/0xray/.mcp.json +3 -3
- package/src/integrations/grok/plugin/0xray/hooks/hooks.json +2 -2
- package/src/mcps/architect-tools.server.ts +4 -4
- package/src/mcps/auto-format.server.ts +4 -4
- package/src/mcps/boot-orchestrator.server.ts +4 -4
- package/src/mcps/config/server-config-registry.ts +7 -7
- package/src/mcps/connection/mcp-connection.ts +1 -1
- package/src/mcps/enforcer-tools.server.ts +4 -4
- package/src/mcps/estimation.server.ts +1 -1
- package/src/mcps/framework-compliance-audit.server.ts +4 -4
- package/src/mcps/framework-help.server.ts +7 -7
- package/src/mcps/governance.server.ts +1 -1
- package/src/mcps/in-process-skill-registry.ts +6 -6
- package/src/mcps/knowledge-skills/api-design.server.test.ts +8 -8
- package/src/mcps/knowledge-skills/api-design.server.ts +4 -4
- package/src/mcps/knowledge-skills/architecture-patterns.server.ts +4 -4
- package/src/mcps/knowledge-skills/bug-triage-specialist.server.ts +1 -1
- package/src/mcps/knowledge-skills/code-analyzer.server.ts +1 -1
- package/src/mcps/knowledge-skills/code-review.server.ts +4 -4
- package/src/mcps/knowledge-skills/content-creator.server.ts +1 -1
- package/src/mcps/knowledge-skills/database-design.server.ts +4 -4
- package/src/mcps/knowledge-skills/devops-deployment.server.ts +4 -4
- package/src/mcps/knowledge-skills/git-workflow.server.ts +4 -4
- package/src/mcps/knowledge-skills/growth-strategist.server.ts +1 -1
- package/src/mcps/knowledge-skills/log-monitor.server.ts +1 -1
- package/src/mcps/knowledge-skills/mobile-development.server.ts +4 -4
- package/src/mcps/knowledge-skills/multimodal-looker.server.ts +1 -1
- package/src/mcps/knowledge-skills/performance-optimization.server.ts +4 -4
- package/src/mcps/knowledge-skills/project-analysis.server.ts +1 -1
- package/src/mcps/knowledge-skills/refactoring-strategies.server.ts +4 -4
- package/src/mcps/knowledge-skills/security-audit.server.test.ts +23 -23
- package/src/mcps/knowledge-skills/security-audit.server.ts +4 -4
- package/src/mcps/knowledge-skills/seo-consultant.server.ts +1 -1
- package/src/mcps/knowledge-skills/session-management.server.ts +1 -1
- package/src/mcps/knowledge-skills/skill-invocation.server.ts +1 -1
- package/src/mcps/knowledge-skills/strategist.server.ts +1 -1
- package/src/mcps/knowledge-skills/tech-writer.server.ts +5 -5
- package/src/mcps/knowledge-skills/testing-best-practices.server.test.ts +28 -28
- package/src/mcps/knowledge-skills/testing-best-practices.server.ts +4 -4
- package/src/mcps/knowledge-skills/testing-strategy.server.test.ts +19 -19
- package/src/mcps/knowledge-skills/testing-strategy.server.ts +4 -4
- package/src/mcps/knowledge-skills/ui-ux-design.server.ts +6 -6
- package/src/mcps/lint.server.ts +6 -6
- package/src/mcps/mcp-client.ts +3 -3
- package/src/mcps/model-health-check.server.ts +4 -4
- package/src/mcps/orchestrator/server.ts +2 -2
- package/src/mcps/performance-analysis.server.ts +4 -4
- package/src/mcps/processor-pipeline.server.ts +4 -4
- package/src/mcps/registry.json +1 -1
- package/src/mcps/researcher.server.ts +5 -5
- package/src/mcps/security-scan.server.ts +4 -4
- package/src/mcps/simulation/server-simulations.ts +3 -3
- package/src/mcps/state-manager.server.ts +1 -1
- package/src/opencode/codex.codex +1 -1
- package/src/opencode/commands/dependency-audit.md +3 -3
- package/src/opencode/enforcer-config.json +2 -2
- package/src/skills/hermes-agent/SKILL.md +12 -12
- package/src/skills/registry.json +1 -1
- package/src/skills/storyteller/SKILL.md +1 -1
- package/src/skills/xray-orchestrator/SKILL.md +141 -0
- package/src/skills/xray-orchestrator/index.ts +268 -0
- package/scripts/validate-stringray-comprehensive.js +0 -636
- /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 };
|