stringray-ai 1.0.18 → 1.0.19

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stringray-ai",
3
- "version": "1.0.18",
3
+ "version": "1.0.19",
4
4
  "description": "⚡ StringRay ⚡: Bulletproof AI orchestration with systematic error prevention. Zero dead ends. Ship clean, tested, optimized code — every time.",
5
5
  "type": "module",
6
6
  "main": "./dist/plugin/index.js",
@@ -102,6 +102,7 @@
102
102
  "dist/processors",
103
103
  "dist/state",
104
104
  "dist/utils",
105
+ "scripts/postinstall.cjs",
105
106
  "scripts/test-stringray-plugin.mjs",
106
107
  "scripts/test-path-resolver.mjs",
107
108
  "scripts/validate-codex.js",
@@ -0,0 +1,245 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * StrRay Plugin Post-Installation Setup
5
+ */
6
+
7
+ const fs = require('fs');
8
+ const path = require('path');
9
+ const os = require('os');
10
+
11
+ // Copy .mcp.json to project root if it doesn't exist
12
+ // Find the package root relative to this script
13
+ const packageRoot = path.join(__dirname, '..');
14
+ const mcpConfigSource = path.join(packageRoot, '.mcp.json');
15
+ const mcpConfigDest = path.join(process.cwd(), '.mcp.json');
16
+
17
+ console.log('Postinstall running...');
18
+ console.log('Script dir:', __dirname);
19
+ console.log('Package root:', packageRoot);
20
+ console.log('Source:', mcpConfigSource);
21
+ console.log('Destination:', mcpConfigDest);
22
+ console.log('Source exists:', fs.existsSync(mcpConfigSource));
23
+
24
+ try {
25
+ if (fs.existsSync(mcpConfigSource)) {
26
+ fs.copyFileSync(mcpConfigSource, mcpConfigDest);
27
+ console.log('✅ StrRay MCP configuration installed');
28
+ } else {
29
+ console.warn('Warning: MCP config not found at', mcpConfigSource);
30
+ // Try alternative locations
31
+ const altSource = path.join(packageRoot, 'node_modules', 'stringray-ai', '.mcp.json');
32
+ if (fs.existsSync(altSource)) {
33
+ fs.copyFileSync(altSource, mcpConfigDest);
34
+ console.log('✅ StrRay MCP configuration installed (alt location)');
35
+ }
36
+ }
37
+ } catch (error) {
38
+ console.warn('Warning: Could not copy MCP config:', error.message);
39
+ }
40
+
41
+ // Create a marker file to prove the script ran
42
+ const markerPath = path.join(os.tmpdir(), 'stringray-postinstall-ran');
43
+ try {
44
+ fs.writeFileSync(markerPath, new Date().toISOString());
45
+ console.log('✅ StrRay Plugin postinstall executed successfully');
46
+ } catch (error) {
47
+ // If we can't write to tmp, that's okay - just log
48
+ console.log('✅ StrRay Plugin installed');
49
+ }
50
+
51
+ // Exit successfully to not break npm install
52
+ process.exit(0);
53
+
54
+ function getOhMyOpenCodeConfigPath() {
55
+ // Try to find oh-my-opencode config in current project
56
+ const projectConfig = path.join(process.cwd(), '.opencode', 'oh-my-opencode.json');
57
+ if (fs.existsSync(projectConfig)) {
58
+ return projectConfig;
59
+ }
60
+
61
+ // Try to find global oh-my-opencode config
62
+ const homeDir = os.homedir();
63
+ const globalConfig = path.join(homeDir, '.config', 'opencode', 'opencode.json');
64
+ if (fs.existsSync(globalConfig)) {
65
+ return globalConfig;
66
+ }
67
+
68
+ // Create project-level config if neither exists
69
+ return projectConfig;
70
+ }
71
+
72
+ function loadConfig(configPath) {
73
+ try {
74
+ if (fs.existsSync(configPath)) {
75
+ const content = fs.readFileSync(configPath, 'utf-8');
76
+ return JSON.parse(content);
77
+ }
78
+ } catch (error) {
79
+ console.warn(`Warning: Could not load config from ${configPath}:`, error.message);
80
+ }
81
+ return {};
82
+ }
83
+
84
+ function saveConfig(configPath, config) {
85
+ // Ensure directory exists
86
+ const dir = path.dirname(configPath);
87
+ if (!fs.existsSync(dir)) {
88
+ fs.mkdirSync(dir, { recursive: true });
89
+ }
90
+
91
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
92
+ }
93
+
94
+ function configureStrRayPlugin() {
95
+ const configPath = getOhMyOpenCodeConfigPath();
96
+
97
+ console.log(`🔧 Configuring StrRay plugin for oh-my-opencode at: ${configPath}`);
98
+
99
+ let config = loadConfig(configPath);
100
+
101
+ // Initialize basic config structure if needed (only valid opencode keys)
102
+ if (!config.model) {
103
+ config.model = "opencode/grok-code";
104
+ }
105
+
106
+ // Add plugin to the plugin array
107
+ if (!config.plugin) {
108
+ config.plugin = [];
109
+ }
110
+
111
+ const pluginPath = "stringray/dist/plugin/stringray-codex-injection.js";
112
+
113
+ if (!config.plugin.includes(pluginPath)) {
114
+ config.plugin.push(pluginPath);
115
+ console.log(`✅ Added StrRay plugin to configuration`);
116
+ } else {
117
+ console.log(`ℹ️ StrRay plugin already configured`);
118
+ }
119
+
120
+ // Add StrRay agent configurations
121
+ if (!config.agent) {
122
+ config.agent = {};
123
+ }
124
+
125
+ // Add StrRay-specific agents (only valid opencode agent config)
126
+ const stringrayAgents = {
127
+ "orchestrator": { "model": "opencode/grok-code" },
128
+ "enhanced-orchestrator": { "model": "opencode/grok-code" },
129
+ "enforcer": { "model": "opencode/grok-code" },
130
+ "architect": { "model": "opencode/grok-code" },
131
+ "test-architect": { "model": "opencode/grok-code" },
132
+ "bug-triage-specialist": { "model": "opencode/grok-code" },
133
+ "code-reviewer": { "model": "opencode/grok-code" },
134
+ "security-auditor": { "model": "opencode/grok-code" },
135
+ "refactorer": { "model": "opencode/grok-code" }
136
+ };
137
+
138
+ let agentsAdded = 0;
139
+ for (const [agentName, agentConfig] of Object.entries(stringrayAgents)) {
140
+ if (!config.agent[agentName]) {
141
+ config.agent[agentName] = agentConfig;
142
+ agentsAdded++;
143
+ }
144
+ }
145
+
146
+ if (agentsAdded > 0) {
147
+ console.log(`✅ Added ${agentsAdded} StrRay agents to configuration`);
148
+ }
149
+
150
+ saveConfig(configPath, config);
151
+
152
+ console.log(`🎉 StrRay plugin installation complete!`);
153
+ console.log(`\n📋 Next Steps:`);
154
+ console.log(`1. Restart oh-my-opencode to load the plugin`);
155
+ console.log(`2. Run 'opencode agent list' to see StrRay agents`);
156
+ console.log(`3. Try '@enforcer analyze this code' to test the plugin`);
157
+ console.log(`\n📖 Documentation: https://github.com/strray-framework/strray-plugin`);
158
+
159
+ // Add StrRay-specific settings
160
+ if (!config.settings) {
161
+ config.settings = {};
162
+ }
163
+
164
+ if (!config.settings.multi_agent_orchestration) {
165
+ config.settings.multi_agent_orchestration = {
166
+ enabled: true,
167
+ max_concurrent_agents: 5,
168
+ coordination_model: "async-multi-agent"
169
+ };
170
+ console.log(`✅ Enabled StrRay multi-agent orchestration`);
171
+ }
172
+
173
+ // Add Claude Code compatibility
174
+ if (!config.claude_code) {
175
+ config.claude_code = {
176
+ mcp: true,
177
+ commands: true,
178
+ skills: true,
179
+ agents: true,
180
+ hooks: true,
181
+ plugins: true
182
+ };
183
+ console.log(`✅ Enabled Claude Code compatibility`);
184
+ }
185
+
186
+ saveConfig(configPath, config);
187
+
188
+ // Create StrRay-specific configuration file separately
189
+ createStrRayConfig();
190
+
191
+ console.log(`🎉 StrRay plugin installation complete!`);
192
+ console.log(`\n📋 Next Steps:`);
193
+ console.log(`1. Restart oh-my-opencode to load the plugin`);
194
+ console.log(`2. Run 'opencode agent list' to see StrRay agents`);
195
+ console.log(`3. Try '@enforcer analyze this code' to test the plugin`);
196
+ console.log(`\n📖 Documentation: https://github.com/strray-framework/strray-plugin`);
197
+ }
198
+
199
+ function createStrRayConfig() {
200
+ // Create StrRay-specific configuration in a separate file
201
+ const stringrayConfigPath = path.join(os.homedir(), ".strray", "config.json");
202
+ const stringrayDir = path.dirname(stringrayConfigPath);
203
+
204
+ if (!fs.existsSync(stringrayDir)) {
205
+ fs.mkdirSync(stringrayDir, { recursive: true });
206
+ }
207
+
208
+ const stringrayConfig = {
209
+ enabled: true,
210
+ maxConcurrentAgents: 5,
211
+ codexEnforcement: true,
212
+ mcpAutoRegistration: false,
213
+ version: "1.0.4"
214
+ };
215
+
216
+ try {
217
+ fs.writeFileSync(stringrayConfigPath, JSON.stringify(stringrayConfig, null, 2));
218
+ console.log(`✅ Created StrRay configuration at ${stringrayConfigPath}`);
219
+ } catch (error) {
220
+ console.warn(`⚠️ Could not create StrRay config: ${error.message}`);
221
+ }
222
+ }
223
+
224
+ // Run the configuration
225
+ console.log('🚀 [StrRay Postinstall] Starting StrRay plugin postinstall configuration...');
226
+ console.log('🚀 [StrRay Postinstall] Node version:', process.version);
227
+ console.log('🚀 [StrRay Postinstall] Platform:', process.platform);
228
+ console.log('🚀 [StrRay Postinstall] Working directory:', process.cwd());
229
+ console.log('🚀 [StrRay Postinstall] Environment variables:');
230
+ console.log(' - npm_config_global:', process.env.npm_config_global);
231
+ console.log(' - npm_lifecycle_event:', process.env.npm_lifecycle_event);
232
+ console.log(' - npm_package_name:', process.env.npm_package_name);
233
+
234
+ try {
235
+ configureStrRayPlugin();
236
+ console.log('✅ [StrRay Postinstall] StrRay plugin postinstall completed successfully');
237
+ process.exit(0);
238
+ } catch (error) {
239
+ console.error('❌ [StrRay Postinstall] StrRay plugin installation failed:', error.message);
240
+ console.error('❌ [StrRay Postinstall] Stack trace:', error.stack);
241
+ console.log('\n🔧 [StrRay Postinstall] Manual Configuration:');
242
+ console.log('Add the following to your .opencode/oh-my-opencode.json:');
243
+ console.log(`"plugin": ["stringray/dist/plugin/stringray-codex-injection.js"]`);
244
+ process.exit(1);
245
+ }