create-claude-workspace 2.3.15 → 2.3.16

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.
@@ -905,10 +905,6 @@ const PR_MAX_POLL_TIME = 30 * 60_000;
905
905
  async function pollAndMergePR(task, pipeline, branch, platform, projectDir, worktreePath, agents, deps) {
906
906
  const { pool, logger, state, onMessage, onSpawnStart, onSpawnEnd } = deps;
907
907
  const startTime = Date.now();
908
- let lastSeenCIStatus = 'none'; // Track CI transitions to detect stale status
909
- // Initial wait — give CI time to pick up the new push
910
- logger.info(`[${task.id}] Waiting for CI pipeline to start...`);
911
- await sleep(PR_POLL_INTERVAL);
912
908
  while (Date.now() - startTime < PR_MAX_POLL_TIME) {
913
909
  const prStatus = getPRStatus(projectDir, platform, branch);
914
910
  if (prStatus.status === 'merged')
@@ -918,37 +914,22 @@ async function pollAndMergePR(task, pipeline, branch, platform, projectDir, work
918
914
  // Ready to merge — CI passed and mergeable
919
915
  if (prStatus.mergeable) {
920
916
  logger.info(`[${task.id}] PR mergeable — merging`);
921
- const merged = mergePR(projectDir, platform, prStatus.number);
922
- return merged;
917
+ return mergePR(projectDir, platform, prStatus.number);
923
918
  }
924
- // CI still running or not started — wait
919
+ // CI still running or not started — poll
925
920
  if (prStatus.ciStatus === 'pending' || prStatus.ciStatus === 'not-found') {
926
- if (prStatus.ciStatus !== lastSeenCIStatus) {
927
- logger.info(`[${task.id}] CI: ${prStatus.ciStatus} — waiting...`);
928
- lastSeenCIStatus = prStatus.ciStatus;
929
- }
921
+ logger.info(`[${task.id}] CI: ${prStatus.ciStatus} polling...`);
930
922
  await sleep(PR_POLL_INTERVAL);
931
923
  continue;
932
924
  }
933
- // CI passed but not mergeable (needs approval, merge checks, etc.)
925
+ // CI passed but not mergeable (needs approval, merge checks, etc.) — poll
934
926
  if (prStatus.ciStatus === 'passed' && !prStatus.mergeable) {
935
- if (lastSeenCIStatus !== 'passed-not-mergeable') {
936
- logger.info(`[${task.id}] CI passed but not mergeable — waiting for approval or checks`);
937
- lastSeenCIStatus = 'passed-not-mergeable';
938
- }
927
+ logger.info(`[${task.id}] CI passed, not yet mergeable — polling...`);
939
928
  await sleep(PR_POLL_INTERVAL);
940
929
  continue;
941
930
  }
942
931
  // CI failed — delegate to implementing agent to fix
943
932
  if (prStatus.ciStatus === 'failed') {
944
- // Avoid re-fixing if we just pushed and the old pipeline result is stale
945
- if (lastSeenCIStatus === 'fix-pushed') {
946
- // We just pushed a fix — wait for new pipeline to start
947
- logger.info(`[${task.id}] Waiting for new CI pipeline after fix push...`);
948
- lastSeenCIStatus = 'pending-after-fix';
949
- await sleep(PR_POLL_INTERVAL * 2); // Extra wait for new pipeline
950
- continue;
951
- }
952
933
  if (pipeline.ciFixes >= MAX_CI_FIXES) {
953
934
  logger.error(`[${task.id}] CI fix limit (${MAX_CI_FIXES}) reached — giving up`);
954
935
  return false;
@@ -966,13 +947,13 @@ async function pollAndMergePR(task, pipeline, branch, platform, projectDir, work
966
947
  const sha = commitInWorktree(worktreePath, `fix: CI failure for ${task.title}`);
967
948
  if (sha) {
968
949
  forcePushWorktree(worktreePath);
969
- lastSeenCIStatus = 'fix-pushed';
970
- logger.info(`[${task.id}] Fix pushed waiting for new CI pipeline`);
971
- await sleep(PR_POLL_INTERVAL * 2); // Wait for new pipeline to start
950
+ logger.info(`[${task.id}] Fix pushed — polling for new CI pipeline`);
951
+ // Poll until CI status changes from 'failed' (= new pipeline picked up)
952
+ await waitForCIRefresh(task.id, projectDir, platform, branch, logger);
972
953
  continue;
973
954
  }
974
955
  }
975
- // Fix didn't produce changes or failed wait and retry
956
+ // Fix didn't produce changes — poll and let next iteration re-evaluate
976
957
  await sleep(PR_POLL_INTERVAL);
977
958
  continue;
978
959
  }
@@ -994,8 +975,9 @@ async function pollAndMergePR(task, pipeline, branch, platform, projectDir, work
994
975
  const sha = commitInWorktree(worktreePath, 'fix: address PR review comments');
995
976
  if (sha) {
996
977
  forcePushWorktree(worktreePath);
997
- lastSeenCIStatus = 'fix-pushed';
998
978
  appendEvent(projectDir, createEvent('pr_comment_resolved', { taskId: task.id, detail: `${unresolved.length} comments` }));
979
+ await waitForCIRefresh(task.id, projectDir, platform, branch, logger);
980
+ continue;
999
981
  }
1000
982
  }
1001
983
  await sleep(PR_POLL_INTERVAL);
@@ -1006,6 +988,24 @@ async function pollAndMergePR(task, pipeline, branch, platform, projectDir, work
1006
988
  logger.warn(`[${task.id}] PR poll timeout (${PR_MAX_POLL_TIME / 60_000}min)`);
1007
989
  return false;
1008
990
  }
991
+ /** Poll until CI status is no longer the previous 'failed' (= new pipeline started) */
992
+ async function waitForCIRefresh(taskId, projectDir, platform, branch, logger) {
993
+ const maxWait = 5 * 60_000; // 5 min max to wait for new pipeline
994
+ const start = Date.now();
995
+ while (Date.now() - start < maxWait) {
996
+ await sleep(PR_POLL_INTERVAL);
997
+ try {
998
+ const status = getPRStatus(projectDir, platform, branch);
999
+ if (status.ciStatus !== 'failed') {
1000
+ logger.info(`[${taskId}] New CI pipeline detected: ${status.ciStatus}`);
1001
+ return;
1002
+ }
1003
+ logger.info(`[${taskId}] CI still shows previous failure — polling...`);
1004
+ }
1005
+ catch { /* ignore */ }
1006
+ }
1007
+ logger.warn(`[${taskId}] Timed out waiting for new CI pipeline`);
1008
+ }
1009
1009
  function buildPRBody(task, pipeline) {
1010
1010
  const lines = [
1011
1011
  `## Summary`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-claude-workspace",
3
- "version": "2.3.15",
3
+ "version": "2.3.16",
4
4
  "author": "",
5
5
  "repository": {
6
6
  "type": "git",