promptup-plugin 0.1.9 → 0.2.0

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/dist/evaluator.js +14 -11
  2. package/package.json +1 -1
package/dist/evaluator.js CHANGED
@@ -7,6 +7,9 @@
7
7
  * STANDALONE copy — no imports from @promptup/shared or session-watcher.
8
8
  */
9
9
  import { spawn } from 'node:child_process';
10
+ import { writeFileSync, unlinkSync } from 'node:fs';
11
+ import { tmpdir } from 'node:os';
12
+ import { join } from 'node:path';
10
13
  import { ulid } from 'ulid';
11
14
  import { BASE_DIMENSIONS, BASE_DIMENSION_KEYS, DOMAIN_DIMENSIONS, DOMAIN_DIMENSION_KEYS, WEIGHT_PROFILES, } from './shared/dimensions.js';
12
15
  import { computeCompositeScore, computeDomainComposite, computeTechComposite, computeOverallComposite, computeGrandComposite, computeRiskFlagsWithHistory, } from './shared/scoring.js';
@@ -183,12 +186,18 @@ Return ONLY valid JSON with no markdown formatting, no code fences, no extra tex
183
186
  }
184
187
  function runClaudeCode(prompt, timeoutMs = 180_000) {
185
188
  return new Promise((resolve, reject) => {
189
+ // Write prompt to temp file to avoid stdin piping conflicts.
190
+ // The MCP server uses stdio for its protocol — spawning claude -p
191
+ // with piped stdin from within an MCP server causes hangs because
192
+ // the child's stdin competes with the parent's MCP pipe.
193
+ const tmpFile = join(tmpdir(), `promptup-eval-${Date.now()}.txt`);
194
+ writeFileSync(tmpFile, prompt, 'utf-8');
186
195
  // Strip CLAUDECODE env var to allow spawning from within a Claude Code session
187
196
  const env = { ...process.env };
188
197
  delete env.CLAUDECODE;
189
198
  delete env.CLAUDE_CODE;
190
- const proc = spawn('claude', ['-p', '--output-format', 'text', '--no-session-persistence'], {
191
- stdio: ['pipe', 'pipe', 'pipe'],
199
+ const proc = spawn('bash', ['-c', `cat "${tmpFile}" | claude -p --output-format text --no-session-persistence`], {
200
+ stdio: ['ignore', 'pipe', 'pipe'],
192
201
  env,
193
202
  });
194
203
  let stdout = '';
@@ -197,10 +206,12 @@ function runClaudeCode(prompt, timeoutMs = 180_000) {
197
206
  proc.stderr.on('data', (chunk) => { stderr += chunk.toString(); });
198
207
  const timer = setTimeout(() => {
199
208
  proc.kill('SIGTERM');
209
+ try { unlinkSync(tmpFile); } catch {}
200
210
  reject(new Error(`[timeout] Claude Code timed out after ${timeoutMs}ms (prompt size: ${prompt.length} chars)`));
201
211
  }, timeoutMs);
202
212
  proc.on('close', (code) => {
203
213
  clearTimeout(timer);
214
+ try { unlinkSync(tmpFile); } catch {}
204
215
  if (code === 0) {
205
216
  resolve(stdout.trim());
206
217
  }
@@ -210,17 +221,9 @@ function runClaudeCode(prompt, timeoutMs = 180_000) {
210
221
  });
211
222
  proc.on('error', (err) => {
212
223
  clearTimeout(timer);
224
+ try { unlinkSync(tmpFile); } catch {}
213
225
  reject(new Error(`[spawn] Could not start claude: ${err.message}`));
214
226
  });
215
- // Write prompt to stdin with backpressure handling
216
- const ok = proc.stdin.write(prompt);
217
- if (!ok) {
218
- // Buffer is full — wait for drain before closing
219
- proc.stdin.once('drain', () => { proc.stdin.end(); });
220
- }
221
- else {
222
- proc.stdin.end();
223
- }
224
227
  });
225
228
  }
226
229
  function parseClaudeResponse(raw) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "promptup-plugin",
3
- "version": "0.1.9",
3
+ "version": "0.2.0",
4
4
  "description": "AI coding skill evaluator for Claude Code — 11-dimension scoring, decision intelligence, PR reports",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",