@plexor-dev/claude-code-plugin 0.1.0-beta.11 → 0.1.0-beta.12

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 (2) hide show
  1. package/hooks/intercept.js +42 -25
  2. package/package.json +1 -1
@@ -157,55 +157,59 @@ class PlexorClient {
157
157
  async function main() {
158
158
  const startTime = Date.now();
159
159
 
160
+ let input;
161
+ let request;
162
+
160
163
  try {
161
- const input = await readStdin();
162
- const request = JSON.parse(input);
164
+ input = await readStdin();
165
+ request = JSON.parse(input);
163
166
 
164
- // CRITICAL: Skip optimization for agentic/tool-using requests
165
- // Modifying messages breaks the agent loop and causes infinite loops
166
- if (isAgenticRequest(request)) {
167
- logger.debug('Agentic request detected, passing through unchanged');
167
+ // CRITICAL: Check for slash commands FIRST (before agentic check)
168
+ // Slash commands like /plexor-status should pass through unchanged
169
+ // Must check before isAgenticRequest since all Claude Code requests have tools
170
+ if (isSlashCommand(request)) {
171
+ logger.debug('Slash command detected, passing through unchanged');
168
172
  recordPassthrough();
169
173
  return output({
170
174
  ...request,
171
175
  plexor_cwd: process.cwd(),
172
176
  _plexor: {
173
- source: 'passthrough_agentic',
174
- reason: 'tool_use_detected',
177
+ source: 'passthrough_slash_command',
178
+ reason: 'slash_command_detected',
175
179
  cwd: process.cwd(),
176
180
  latency_ms: Date.now() - startTime
177
181
  }
178
182
  });
179
183
  }
180
184
 
181
- // CRITICAL: Skip optimization for slash commands (Issue #683)
182
- // Slash commands like /plexor-status should pass through unchanged
183
- if (isSlashCommand(request)) {
184
- logger.debug('Slash command detected, passing through unchanged');
185
+ // CRITICAL: Skip optimization for CLI commands requiring tool execution
186
+ // Azure CLI, AWS CLI, kubectl, etc. need tools to be preserved
187
+ if (requiresToolExecution(request)) {
188
+ logger.debug('CLI tool execution detected, passing through unchanged');
185
189
  recordPassthrough();
186
190
  return output({
187
191
  ...request,
188
192
  plexor_cwd: process.cwd(),
189
193
  _plexor: {
190
- source: 'passthrough_slash_command',
191
- reason: 'slash_command_detected',
194
+ source: 'passthrough_cli',
195
+ reason: 'cli_tool_execution_detected',
192
196
  cwd: process.cwd(),
193
197
  latency_ms: Date.now() - startTime
194
198
  }
195
199
  });
196
200
  }
197
201
 
198
- // CRITICAL: Skip optimization for CLI commands requiring tool execution (Issue #683)
199
- // Azure CLI, AWS CLI, kubectl, etc. need tools to be preserved
200
- if (requiresToolExecution(request)) {
201
- logger.debug('CLI tool execution detected, passing through unchanged');
202
+ // CRITICAL: Skip optimization for agentic/tool-using requests
203
+ // Modifying messages breaks the agent loop and causes infinite loops
204
+ if (isAgenticRequest(request)) {
205
+ logger.debug('Agentic request detected, passing through unchanged');
202
206
  recordPassthrough();
203
207
  return output({
204
208
  ...request,
205
209
  plexor_cwd: process.cwd(),
206
210
  _plexor: {
207
- source: 'passthrough_cli',
208
- reason: 'cli_tool_execution_detected',
211
+ source: 'passthrough_agentic',
212
+ reason: 'tool_use_detected',
209
213
  cwd: process.cwd(),
210
214
  latency_ms: Date.now() - startTime
211
215
  }
@@ -307,17 +311,30 @@ async function main() {
307
311
  logger.error(`[Plexor] Error: ${error.message}`);
308
312
  logger.debug(error.stack);
309
313
 
310
- try {
311
- const input = await readStdin();
312
- const request = JSON.parse(input);
314
+ // Use already-parsed request if available, otherwise pass through raw
315
+ if (request) {
313
316
  return output({
314
317
  ...request,
315
318
  _plexor: {
316
319
  error: error.message,
317
- source: 'passthrough'
320
+ source: 'passthrough_error'
318
321
  }
319
322
  });
320
- } catch {
323
+ } else if (input) {
324
+ // Try to parse the input we already read
325
+ try {
326
+ const req = JSON.parse(input);
327
+ return output({
328
+ ...req,
329
+ _plexor: {
330
+ error: error.message,
331
+ source: 'passthrough_error'
332
+ }
333
+ });
334
+ } catch {
335
+ process.exit(1);
336
+ }
337
+ } else {
321
338
  process.exit(1);
322
339
  }
323
340
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plexor-dev/claude-code-plugin",
3
- "version": "0.1.0-beta.11",
3
+ "version": "0.1.0-beta.12",
4
4
  "description": "LLM cost optimization plugin for Claude Code - Save up to 90% on AI costs",
5
5
  "main": "lib/constants.js",
6
6
  "scripts": {