e2e-agent-runner 1.5.2 → 1.5.4

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/claude.mjs CHANGED
@@ -16,6 +16,16 @@ export function parsePhaseMarker(text) {
16
16
  return m.length ? m[m.length - 1][1].toLowerCase() : null;
17
17
  }
18
18
 
19
+ /** 자식 프로세스(claude·deploy_command)에 물려줄 env — 러너 토큰(E2E_RUNNER_TOKEN)은
20
+ * 머신 신원 그 자체(단계 클레임 = 임의 커맨드 실행 권한)라 제외한다. discover/qa/improve
21
+ * 페이즈의 claude 는 브라우저 MCP 로 외부 사이트를 직접 보므로, 주입된 지시가
22
+ * process.env 에서 토큰을 읽어 유출하는 경로를 차단한다. */
23
+ export function childEnv() {
24
+ const env = { ...process.env };
25
+ delete env.E2E_RUNNER_TOKEN;
26
+ return env;
27
+ }
28
+
19
29
  /** `claude --version` 프로브 — 시작 시 1회(미설치 시 heartbeat ok:false 로 알림). */
20
30
  export function probeClaude() {
21
31
  return new Promise((resolve) => {
@@ -92,7 +102,7 @@ export function runClaude(opts) {
92
102
  // 종료시킨다. detached 로 파이프(stdio)는 그대로 동작한다.
93
103
  // stdin 은 닫는다 — 파이프로 열려 있으면 claude -p 가 입력을 3s 기다린 뒤 경고하고 진행한다.
94
104
  const child = spawn(CLAUDE_BIN, args, {
95
- cwd, env: process.env, detached: process.platform !== 'win32', stdio: ['ignore', 'pipe', 'pipe'],
105
+ cwd, env: childEnv(), detached: process.platform !== 'win32', stdio: ['ignore', 'pipe', 'pipe'],
96
106
  });
97
107
  let settled = false;
98
108
  let cancelled = false;
package/git.mjs CHANGED
@@ -69,12 +69,7 @@ export async function probeFolder(cwd) {
69
69
  const inside = await run(cwd, 'rev-parse', '--is-inside-work-tree');
70
70
  if (inside !== 'true') return { ...base, ok: false, error: 'git 저장소가 아닙니다.', code: 'not_git' };
71
71
  const branch = await run(cwd, 'rev-parse', '--abbrev-ref', 'HEAD');
72
- let remote = null;
73
- try {
74
- remote = await run(cwd, 'remote', 'get-url', 'origin');
75
- } catch {
76
- /* origin 없음 — 로컬 전용 저장소 */
77
- }
72
+ const remote = await originUrl(cwd); // origin 없으면 null(로컬 전용 저장소)
78
73
  const dirty = await run(cwd, 'status', '--porcelain');
79
74
  const dirtyCount = dirty ? dirty.split('\n').filter(Boolean).length : 0;
80
75
  return { ...base, ok: true, branch, remote, clean: dirtyCount === 0, dirty_count: dirtyCount };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "e2e-agent-runner",
3
- "version": "1.5.2",
3
+ "version": "1.5.4",
4
4
  "description": "suseona e2e 작업 에이전트 로컬 러너 — 내 컴퓨터의 Claude Code 로 구현→테스트→리뷰→배포와 웹사이트 기능 지도 추출·QA·개선 사이클을 자동 수행",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
package/runner.mjs CHANGED
@@ -16,7 +16,7 @@ import { existsSync, readFileSync } from 'node:fs';
16
16
  import { fileURLToPath } from 'node:url';
17
17
  import { dirname, join } from 'node:path';
18
18
  import { api, runnerIdFromToken, sleep } from './api.mjs';
19
- import { parsePhaseMarker, probeClaude, runClaude } from './claude.mjs';
19
+ import { childEnv, parsePhaseMarker, probeClaude, runClaude } from './claude.mjs';
20
20
  import { collectArtifact, countRouteFiles, porcelain, prepareDiscover } from './discover.mjs';
21
21
  import {
22
22
  advanceBase, commitCount, deleteTaskBranch, ensureTaskBranch, ensureWorktree, escapeTaskBranch, GitError,
@@ -249,6 +249,24 @@ function worktreeNote(project, base, branch) {
249
249
  return `\n\n[러너 알림] 이 폴더는 이 작업 전용 git 워크트리입니다 — base \`${base}\` 에서 만든 \`${branch}\` 체크아웃. 커밋·빌드·테스트·배포는 모두 이 폴더에서 수행한다(의존성 설치가 필요하면 먼저 설치). 사용자의 원본 폴더(${project.folder_path})는 작업 중인 변경이 있을 수 있어 수정하지 않는다(읽기 참고는 가능).`;
250
250
  }
251
251
 
252
+ /** implement 종결 메타 수집 — 커밋 수 + (커밋 있을 때만)브랜치 팁 sha·origin URL.
253
+ * 두 실행 모드(워크트리·인플레이스)가 공유한다. 실패는 미보고(서버 폴백 동작). */
254
+ async function captureTaskMeta(repoPath, cwd, base) {
255
+ let commits;
256
+ let branchTip = null;
257
+ let remoteUrl = null;
258
+ try {
259
+ commits = await commitCount(cwd, base);
260
+ if (commits > 0) {
261
+ branchTip = await headSha(cwd);
262
+ remoteUrl = await originUrl(repoPath); // 무변경 과제는 링크 자체가 무의미 — 조회 생략
263
+ }
264
+ } catch {
265
+ /* 커밋 수 계산 실패 — 미보고 시 서버는 기존 전체 파이프라인으로 동작 */
266
+ }
267
+ return { commits, branchTip, remoteUrl };
268
+ }
269
+
252
270
  /** implement — git 프리플라이트 → (이전 작업 브랜치 탈출) → 작업 브랜치 → claude(신규 세션).
253
271
  * base_branch 를 서버에 보고(유실 방지: EventBuffer 가 재전송한다).
254
272
  * 종결 시 작업 브랜치의 커밋 수(base..HEAD)를 함께 보고 — 0이면 서버가 무변경 단축한다.
@@ -269,17 +287,7 @@ async function runImplement({ step, task, project, buf, cancelled }) {
269
287
  cwd: wt,
270
288
  promptAddon: worktreeNote(project, base, branch),
271
289
  });
272
- let commits;
273
- let branchTip = null;
274
- let remoteUrl = null;
275
- try {
276
- commits = await commitCount(wt, base);
277
- if (commits > 0) branchTip = await headSha(wt);
278
- } catch {
279
- /* 커밋 수 계산 실패 — 미보고 시 서버는 기존 전체 파이프라인으로 동작 */
280
- }
281
- remoteUrl = await originUrl(project.folder_path);
282
- return { ...result, commits, branchTip, remoteUrl };
290
+ return { ...result, ...(await captureTaskMeta(project.folder_path, wt, base)) };
283
291
  }
284
292
  await preflight(project.folder_path, { requireClean: true });
285
293
  const base = await escapeTaskBranch(project.folder_path);
@@ -287,17 +295,7 @@ async function runImplement({ step, task, project, buf, cancelled }) {
287
295
  buf.taskMeta = { base_branch: base, branch };
288
296
  log(`브랜치 준비: ${branch} (base ${base})`);
289
297
  const result = await runPhase({ step, task, project, buf, cancelled, extraMeta: buf.taskMeta });
290
- let commits;
291
- let branchTip = null;
292
- let remoteUrl = null;
293
- try {
294
- commits = await commitCount(project.folder_path, base);
295
- if (commits > 0) branchTip = await headSha(project.folder_path);
296
- } catch {
297
- /* 커밋 수 계산 실패 — 미보고 시 서버는 기존 전체 파이프라인으로 동작 */
298
- }
299
- remoteUrl = await originUrl(project.folder_path);
300
- return { ...result, commits, branchTip, remoteUrl };
298
+ return { ...result, ...(await captureTaskMeta(project.folder_path, project.folder_path, base)) };
301
299
  }
302
300
 
303
301
  /** discover — 기능 지도 추출·QA 페이즈(qa_run/qa_plan/qa_verify)·개선 사이클 페이즈(imp_analyze/imp_verify) — 읽기 전용. 브랜치·프리플라이트
@@ -423,8 +421,8 @@ async function runDeploy({ step, task, project, buf, cancelled }) {
423
421
 
424
422
  if (WORKTREE) {
425
423
  const { wt } = await ensureWorktree(project.folder_path, task.id, base, { reset: false });
426
- await mergeToBaseWorktree(wt, base, branch);
427
- log(`병합 완료(워크트리 detach): ${branch} → ${base}`);
424
+ const mergeSha = await mergeToBaseWorktree(wt, base, branch);
425
+ log(`병합 완료(워크트리 detach): ${branch} → ${base} (${mergeSha.slice(0, 8)})`);
428
426
  buf.push(step.id, 'status', { event: 'merged', base, branch, worktree: wt });
429
427
 
430
428
  const deployCwd = wt;
@@ -440,6 +438,9 @@ async function runDeploy({ step, task, project, buf, cancelled }) {
440
438
  finalText: `# 배포 커맨드 결과\n\n종료 코드: ${output.code}\n\n\`\`\`\n${output.out.trim() || '(출력 없음)'}\n\`\`\`\n\nPHASE_RESULT: ${ok ? 'PASS' : 'FAIL'}`,
441
439
  flag: ok ? 'pass' : 'fail',
442
440
  sessionId: step.session_id ?? null,
441
+ // 배포 성공 시점의 병합 완성본(refined) — remediate·continue 가 늘린 커밋까지 포함된
442
+ // 정확한 sha 로 implement 시점 보고를 덮어쓴다(서버 update_task 는 null 무시).
443
+ branchTip: ok ? mergeSha : undefined,
443
444
  };
444
445
  }
445
446
  // deploy_command 없음 — Claude 가 관례를 파악해 배포(검증 세션 resume, 워크트리 안에서).
@@ -452,7 +453,7 @@ async function runDeploy({ step, task, project, buf, cancelled }) {
452
453
  // error·git 은 확정 완료(base 전진·브랜치 삭제)" 상태 분리를 막는다.
453
454
  const deployOk = result.ok && !cancelled() && result.flag === 'pass';
454
455
  if (deployOk) await finalizeWorktree();
455
- return result;
456
+ return deployOk ? { ...result, branchTip: mergeSha } : result;
456
457
  }
457
458
 
458
459
  await mergeToBase(project.folder_path, base, branch);
@@ -470,11 +471,15 @@ async function runDeploy({ step, task, project, buf, cancelled }) {
470
471
  finalText: `# 배포 커맨드 결과\n\n종료 코드: ${output.code}\n\n\`\`\`\n${output.out.trim() || '(출력 없음)'}\n\`\`\`\n\nPHASE_RESULT: ${ok ? 'PASS' : 'FAIL'}`,
471
472
  flag: ok ? 'pass' : 'fail',
472
473
  sessionId: step.session_id ?? null,
474
+ branchTip: ok ? await headSha(project.folder_path) : undefined, // 병합 완성본(base 위 HEAD)
473
475
  };
474
476
  }
475
477
 
476
478
  // deploy_command 없음 — Claude 가 프로젝트 관례(CLAUDE.md/스크립트)를 파악해 배포.
477
- return runPhase({ step, task, project, buf, cancelled });
479
+ // 성공 시 병합 완성본 sha 로 implement 시점 팁을 덮어쓴다(워크트리 경로와 동일 계약).
480
+ const result = await runPhase({ step, task, project, buf, cancelled });
481
+ const ok = result.ok && !cancelled() && result.flag === 'pass';
482
+ return ok ? { ...result, branchTip: await headSha(project.folder_path) } : result;
478
483
  }
479
484
 
480
485
  /** deploy_command 실행 — 타임아웃(DEPLOY_TIMEOUT_S)·취소(프로세스 그룹 종료) 내장. */
@@ -485,7 +490,7 @@ function runDeployCommand(project, cwd, cancelled) {
485
490
  const child = spawn(project.deploy_command, {
486
491
  cwd,
487
492
  shell: true,
488
- env: process.env,
493
+ env: childEnv(), // 러너 토큰은 머신 신원 — 배포 커맨드 자식 env 에서 제외(claude.mjs 참조)
489
494
  detached: process.platform !== 'win32',
490
495
  });
491
496
  let out = '';