promptup-plugin 0.1.9 → 0.2.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/dist/db.js CHANGED
@@ -40,6 +40,7 @@ export function initDatabase() {
40
40
  id TEXT PRIMARY KEY,
41
41
  project_path TEXT,
42
42
  transcript_path TEXT,
43
+ branch TEXT,
43
44
  status TEXT DEFAULT 'active',
44
45
  message_count INTEGER DEFAULT 0,
45
46
  started_at TEXT NOT NULL,
@@ -131,6 +132,11 @@ export function initDatabase() {
131
132
  );
132
133
  CREATE INDEX IF NOT EXISTS idx_pr_reports_branch ON pr_reports(branch, repo);
133
134
  `);
135
+ // Migrations — add columns to existing databases
136
+ try {
137
+ instance.exec('ALTER TABLE sessions ADD COLUMN branch TEXT');
138
+ }
139
+ catch { /* column already exists */ }
134
140
  db = instance;
135
141
  }
136
142
  export function closeDatabase() {
@@ -143,11 +149,11 @@ export function closeDatabase() {
143
149
  export function insertSession(session) {
144
150
  const d = getDb();
145
151
  d.prepare(`
146
- INSERT OR IGNORE INTO sessions (id, project_path, transcript_path, status,
152
+ INSERT OR IGNORE INTO sessions (id, project_path, transcript_path, branch, status,
147
153
  message_count, started_at, ended_at, created_at)
148
- VALUES (@id, @project_path, @transcript_path, @status,
154
+ VALUES (@id, @project_path, @transcript_path, @branch, @status,
149
155
  @message_count, @started_at, @ended_at, @created_at)
150
- `).run(session);
156
+ `).run({ branch: null, ...session });
151
157
  }
152
158
  export function getSession(id) {
153
159
  const row = getDb()
@@ -279,10 +285,20 @@ export function insertGitActivity(activity) {
279
285
  });
280
286
  }
281
287
  export function getSessionsByBranch(branch) {
282
- const rows = getDb()
288
+ const d = getDb();
289
+ // Primary: sessions with branch column set directly
290
+ const direct = d
291
+ .prepare('SELECT id FROM sessions WHERE branch = ? ORDER BY created_at')
292
+ .all(branch)
293
+ .map((r) => r.id);
294
+ // Supplement: sessions linked via git_activities
295
+ const fromGit = d
283
296
  .prepare('SELECT DISTINCT session_id FROM git_activities WHERE branch = ? ORDER BY created_at')
284
- .all(branch);
285
- return rows.map((r) => r.session_id);
297
+ .all(branch)
298
+ .map((r) => r.session_id);
299
+ // Merge, deduplicate
300
+ const all = [...new Set([...direct, ...fromGit])];
301
+ return all;
286
302
  }
287
303
  // ─── Session matching ────────────────────────────────────────────────────────
288
304
  export function getSessionsByTimeRange(from, to, projectPath) {
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) {
@@ -280,6 +280,7 @@ export async function generatePRReport(options) {
280
280
  id: sid,
281
281
  project_path: projectPath ?? process.cwd(),
282
282
  transcript_path: latestTranscript,
283
+ branch: branch,
283
284
  status: 'completed',
284
285
  message_count: msgs.length,
285
286
  started_at: msgs[0].created_at,
package/dist/tools.js CHANGED
@@ -17,6 +17,13 @@ import { ulid } from 'ulid';
17
17
  import { readFileSync, existsSync } from 'node:fs';
18
18
  import { join } from 'node:path';
19
19
  import { homedir } from 'node:os';
20
+ import { execSync } from 'node:child_process';
21
+ function detectBranch() {
22
+ try {
23
+ return execSync('git branch --show-current', { encoding: 'utf-8', timeout: 5000 }).trim() || null;
24
+ }
25
+ catch { return null; }
26
+ }
20
27
  import { loadConfig, updateConfig } from './config.js';
21
28
  function textResponse(text, isError = false) {
22
29
  return { content: [{ type: 'text', text }], ...(isError ? { isError } : {}) };
@@ -167,6 +174,7 @@ export async function handleEvaluateSession(args) {
167
174
  id: sessionId,
168
175
  project_path: process.cwd(),
169
176
  transcript_path: transcriptPath,
177
+ branch: detectBranch(),
170
178
  status: 'completed',
171
179
  message_count: messages.length,
172
180
  started_at: firstMsg.created_at,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "promptup-plugin",
3
- "version": "0.1.9",
3
+ "version": "0.2.1",
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",