@hamp10/agentforge 0.2.46 → 0.2.48

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hamp10/agentforge",
3
- "version": "0.2.46",
3
+ "version": "0.2.48",
4
4
  "description": "AgentForge worker — connect your machine to agentforge.ai",
5
5
  "type": "module",
6
6
  "bin": {
@@ -522,6 +522,33 @@ try {
522
522
  /Requested scoped UI targets: alpha, beta/i,
523
523
  'multi-target UI quality retries should preserve the full scoped target set'
524
524
  );
525
+ const originalFindIncompleteScopedUiTargets = worker._findIncompleteScopedUiTargets;
526
+ worker._findIncompleteScopedUiTargets = () => [{
527
+ repo: fixture.repo,
528
+ missingSlugs: ['beta-ai'],
529
+ touchedSlugs: ['alpha-ai'],
530
+ changedFiles: ['public_html/domains/alpha-ai.html'],
531
+ }];
532
+ const incompleteRepairLead = worker._formatIncompleteScopedUiRepairLead(
533
+ baseline,
534
+ 'Work on the Example.com listing pages for Alpha.ai and Beta.ai. Delete and rebuild both listing pages from a clean start.'
535
+ );
536
+ worker._findIncompleteScopedUiTargets = originalFindIncompleteScopedUiTargets;
537
+ assert.match(
538
+ incompleteRepairLead,
539
+ /missing-target pass for target page\(s\) not yet changed in the current diff: beta-ai/i,
540
+ 'missing-target retries should name only the targets not yet addressed'
541
+ );
542
+ assert.match(
543
+ incompleteRepairLead,
544
+ /Do not delete, rewrite, or restart target page\(s\) already changed[\s\S]*alpha-ai/i,
545
+ 'missing-target retries should avoid replaying earlier work on targets already touched in the diff'
546
+ );
547
+ assert.doesNotMatch(
548
+ incompleteRepairLead,
549
+ /The task is:|Delete and rebuild both/i,
550
+ 'missing-target retries should not put the original reset-heavy task text at the top of the retry prompt'
551
+ );
525
552
  assert.equal(
526
553
  worker._formatRepeatedVisualRepairNudge(2),
527
554
  '',
@@ -540,6 +567,25 @@ try {
540
567
  /Keep other requested target page\(s\) intact[\s\S]*alpha-ai, beta-ai/i,
541
568
  'visual-warning retries should focus on the failing target instead of recreating unrelated completed targets'
542
569
  );
570
+ const focusedRepairLead = worker._formatVisualRepairTaskLead(
571
+ 'Work on the Example.com listing pages for Alpha.ai, Beta.ai, and Gamma.ai. Delete and rebuild Alpha.ai and Beta.ai from a clean start, and fix Gamma.ai so all three are visually polished.',
572
+ 'gamma-ai: Visual warning: target hero text is clipped.'
573
+ );
574
+ assert.match(
575
+ focusedRepairLead,
576
+ /visual repair pass for currently failing target page\(s\): gamma-ai/i,
577
+ 'focused visual repair retries should name the failing target set'
578
+ );
579
+ assert.match(
580
+ focusedRepairLead,
581
+ /Do not repeat initial delete\/rebuild\/reset\/setup work[\s\S]*alpha-ai, beta-ai/i,
582
+ 'focused visual repair retries should not replay clean-start work for already-built non-failing targets'
583
+ );
584
+ assert.doesNotMatch(
585
+ focusedRepairLead,
586
+ /The task is:|Delete and rebuild Alpha\.ai/i,
587
+ 'focused visual repair retries should not put the original reset-heavy task text at the top of the retry prompt'
588
+ );
543
589
  assert.match(
544
590
  worker._buildScopedUiTargetSetNudge(baseline, message),
545
591
  /one delivery set/i,
package/src/worker.js CHANGED
@@ -1491,6 +1491,23 @@ export class AgentForgeWorker extends EventEmitter {
1491
1491
  ].filter(Boolean).join('\n');
1492
1492
  }
1493
1493
 
1494
+ _formatVisualRepairTaskLead(userMessage, output) {
1495
+ const { slugs: allSlugs } = this._extractExplicitScope(userMessage);
1496
+ const failedSlugs = this._extractUiVerificationFailureSlugs(output, userMessage);
1497
+ if (allSlugs.length >= 2 && failedSlugs.length > 0 && failedSlugs.length < allSlugs.length) {
1498
+ const preservedSlugs = allSlugs.filter(slug => !failedSlugs.includes(slug));
1499
+ return [
1500
+ `Original scoped UI target set: ${allSlugs.join(', ')}.`,
1501
+ `This retry is a visual repair pass for currently failing target page(s): ${failedSlugs.join(', ')}.`,
1502
+ preservedSlugs.length > 0
1503
+ ? `Do not repeat initial delete/rebuild/reset/setup work for target page(s) not currently failing: ${preservedSlugs.join(', ')}.`
1504
+ : '',
1505
+ 'Continue from the current repo state and change only files needed to repair the failing target page(s), then re-verify every requested target page locally before completion or delivery.',
1506
+ ].filter(Boolean).join('\n');
1507
+ }
1508
+ return `The task is: "${userMessage}"`;
1509
+ }
1510
+
1494
1511
  _formatUiVerificationFailureLogSummary(nudge) {
1495
1512
  const lines = String(nudge || '')
1496
1513
  .split('\n')
@@ -1715,6 +1732,23 @@ export class AgentForgeWorker extends EventEmitter {
1715
1732
  return warnings.length > 0 ? this._formatIncompleteScopedUiTargetsNudge(warnings) : '';
1716
1733
  }
1717
1734
 
1735
+ _formatIncompleteScopedUiRepairLead(repoBaselines, userMessage) {
1736
+ const warnings = this._findIncompleteScopedUiTargets(repoBaselines, userMessage);
1737
+ if (warnings.length === 0) return `The task is: "${userMessage}"`;
1738
+ const { slugs: allSlugs } = this._extractExplicitScope(userMessage);
1739
+ const missingSlugs = [...new Set(warnings.flatMap(w => w.missingSlugs || []))];
1740
+ if (allSlugs.length < 2 || missingSlugs.length === 0) return `The task is: "${userMessage}"`;
1741
+ const alreadyTouchedSlugs = allSlugs.filter(slug => !missingSlugs.includes(slug));
1742
+ return [
1743
+ `Original scoped UI target set: ${allSlugs.join(', ')}.`,
1744
+ `This retry is a missing-target pass for target page(s) not yet changed in the current diff: ${missingSlugs.join(', ')}.`,
1745
+ alreadyTouchedSlugs.length > 0
1746
+ ? `Do not delete, rewrite, or restart target page(s) already changed in this diff just to repeat earlier work: ${alreadyTouchedSlugs.join(', ')}.`
1747
+ : '',
1748
+ 'Continue from the current repo state, edit the missing target page(s) directly, then verify every requested target page locally before completion or delivery.',
1749
+ ].filter(Boolean).join('\n');
1750
+ }
1751
+
1718
1752
  _formatScopedUiTargetSetReminder(userMessage) {
1719
1753
  if (!this._isBroadUiQualityTask(userMessage)) return '';
1720
1754
  const { slugs: allowedSlugs, pageOnly } = this._extractExplicitScope(userMessage);
@@ -4304,7 +4338,8 @@ export class AgentForgeWorker extends EventEmitter {
4304
4338
  nudgeCount++;
4305
4339
  if (nudgeCount < MAX_NUDGES) {
4306
4340
  console.log(`[${taskId}] Iteration missed scoped UI target(s) — continuing (${nudgeCount}/${MAX_NUDGES}, total UI repairs ${uiRepairNudgeCount}/${UI_REPAIR_NUDGE_LIMIT})`);
4307
- iterationMessage = withTaskContext(`The task is: "${userMessage}"\n\n${interimIncompleteScopedUiTargetsNudge}\n\nContinue from the current changed files. Do not restart from scratch; address the missing target page(s), then verify each edited target screen after the final edit.`);
4341
+ const incompleteScopedRepairLead = this._formatIncompleteScopedUiRepairLead(repoBaselines, scopeAwareUserMessage);
4342
+ iterationMessage = withTaskContext(`${incompleteScopedRepairLead}\n\n${interimIncompleteScopedUiTargetsNudge}\n\nContinue from the current changed files. Do not restart from scratch; address the missing target page(s), then verify each edited target screen after the final edit.`);
4308
4343
  continue;
4309
4344
  }
4310
4345
  throw new Error('Task missed scoped UI target pages after repeated retries');
@@ -4425,13 +4460,14 @@ export class AgentForgeWorker extends EventEmitter {
4425
4460
  const scopedTargetSetNudge = this._formatScopedUiTargetSetReminder(scopeAwareUserMessage);
4426
4461
  const repeatedVisualRepairNudge = this._formatRepeatedVisualRepairNudge(uiRepairNudgeCount);
4427
4462
  const visualFailureFocusNudge = this._formatVisualFailureFocusNudge(output, scopeAwareUserMessage);
4463
+ const visualRepairTaskLead = this._formatVisualRepairTaskLead(scopeAwareUserMessage, output);
4428
4464
  const visualFailureSummary = this._formatUiVerificationFailureLogSummary(uiVerificationFailureNudge);
4429
4465
  if (nudgeCount < MAX_NUDGES) {
4430
4466
  console.log(`[${taskId}] UI completion still had visual verification warnings — nudging (${nudgeCount}/${MAX_NUDGES}, total UI repairs ${repairBudget})`);
4431
4467
  if (visualFailureSummary) {
4432
4468
  console.log(`[${taskId}] UI visual verification issue(s): ${visualFailureSummary}`);
4433
4469
  }
4434
- iterationMessage = withTaskContext(`The task is: "${userMessage}"\n\n${[uiVerificationFailureNudge, visualFailureFocusNudge, scopedTargetSetNudge, repeatedVisualRepairNudge].filter(Boolean).join('\n\n')}\n\nFix the visible UI issues, verify again with the browser, and only then end with ✓ TASK_COMPLETE.`);
4470
+ iterationMessage = withTaskContext(`${visualRepairTaskLead}\n\n${[uiVerificationFailureNudge, visualFailureFocusNudge, scopedTargetSetNudge, repeatedVisualRepairNudge].filter(Boolean).join('\n\n')}\n\nFix the visible UI issues, verify again with the browser, and only then end with ✓ TASK_COMPLETE.`);
4435
4471
  continue;
4436
4472
  }
4437
4473
  throw new Error('UI task claimed completion while visual verification still reported issues');
@@ -4472,7 +4508,8 @@ export class AgentForgeWorker extends EventEmitter {
4472
4508
  nudgeCount++;
4473
4509
  if (nudgeCount < MAX_NUDGES) {
4474
4510
  console.log(`[${taskId}] UI completion missed scoped target(s) — nudging (${nudgeCount}/${MAX_NUDGES}, total UI repairs ${uiRepairNudgeCount}/${UI_REPAIR_NUDGE_LIMIT})`);
4475
- iterationMessage = withTaskContext(`The task is: "${userMessage}"\n\n${incompleteScopedUiTargetsNudge}\n\nDo not mark complete until every named target page has been addressed directly and visually verified.`);
4511
+ const incompleteScopedRepairLead = this._formatIncompleteScopedUiRepairLead(repoBaselines, scopeAwareUserMessage);
4512
+ iterationMessage = withTaskContext(`${incompleteScopedRepairLead}\n\n${incompleteScopedUiTargetsNudge}\n\nDo not mark complete until every named target page has been addressed directly and visually verified.`);
4476
4513
  continue;
4477
4514
  }
4478
4515
  throw new Error('UI task claimed completion while missing scoped target pages after repeated retries');
@@ -4698,13 +4735,14 @@ export class AgentForgeWorker extends EventEmitter {
4698
4735
  const scopedTargetSetNudge = this._formatScopedUiTargetSetReminder(scopeAwareUserMessage);
4699
4736
  const repeatedVisualRepairNudge = this._formatRepeatedVisualRepairNudge(uiRepairNudgeCount);
4700
4737
  const visualFailureFocusNudge = this._formatVisualFailureFocusNudge(output, scopeAwareUserMessage);
4738
+ const visualRepairTaskLead = this._formatVisualRepairTaskLead(scopeAwareUserMessage, output);
4701
4739
  const visualFailureSummary = this._formatUiVerificationFailureLogSummary(uiVerificationFailureNudge);
4702
4740
  if (nudgeCount < MAX_NUDGES) {
4703
4741
  console.log(`[${taskId}] Publish evidence still had visual verification warnings — continuing (${nudgeCount}/${MAX_NUDGES}, total UI repairs ${repairBudget})`);
4704
4742
  if (visualFailureSummary) {
4705
4743
  console.log(`[${taskId}] UI visual verification issue(s): ${visualFailureSummary}`);
4706
4744
  }
4707
- iterationMessage = withTaskContext(`The task is: "${userMessage}"\n\n${[uiVerificationFailureNudge, visualFailureFocusNudge, scopedTargetSetNudge, repeatedVisualRepairNudge].filter(Boolean).join('\n\n')}\n\nContinue from the current repo state, fix the visible UI issues, verify again, then commit/push any additional changes before reporting delivery complete.`);
4745
+ iterationMessage = withTaskContext(`${visualRepairTaskLead}\n\n${[uiVerificationFailureNudge, visualFailureFocusNudge, scopedTargetSetNudge, repeatedVisualRepairNudge].filter(Boolean).join('\n\n')}\n\nContinue from the current repo state, fix the visible UI issues, verify again, then commit/push any additional changes before reporting delivery complete.`);
4708
4746
  continue;
4709
4747
  }
4710
4748
  throw new Error('Publish task still had visual verification issues after repeated retries');
@@ -4745,7 +4783,8 @@ export class AgentForgeWorker extends EventEmitter {
4745
4783
  nudgeCount++;
4746
4784
  if (nudgeCount < MAX_NUDGES) {
4747
4785
  console.log(`[${taskId}] Publish evidence missed scoped target(s) — continuing (${nudgeCount}/${MAX_NUDGES}, total UI repairs ${uiRepairNudgeCount}/${UI_REPAIR_NUDGE_LIMIT})`);
4748
- iterationMessage = withTaskContext(`The task is: "${userMessage}"\n\n${incompleteScopedUiTargetsNudge}\n\nContinue from the current repo state, address the missing target page(s), verify all edited target screens, then commit/push any additional changes before reporting delivery complete.`);
4786
+ const incompleteScopedRepairLead = this._formatIncompleteScopedUiRepairLead(repoBaselines, scopeAwareUserMessage);
4787
+ iterationMessage = withTaskContext(`${incompleteScopedRepairLead}\n\n${incompleteScopedUiTargetsNudge}\n\nContinue from the current repo state, address the missing target page(s), verify all edited target screens, then commit/push any additional changes before reporting delivery complete.`);
4749
4788
  continue;
4750
4789
  }
4751
4790
  throw new Error('Publish task missed scoped target pages after repeated retries');
@@ -4843,6 +4882,7 @@ export class AgentForgeWorker extends EventEmitter {
4843
4882
  const scopedTargetSetNudge = this._formatScopedUiTargetSetReminder(scopeAwareUserMessage);
4844
4883
  const repeatedVisualRepairNudge = this._formatRepeatedVisualRepairNudge(uiVerificationRetryCount);
4845
4884
  const visualFailureFocusNudge = this._formatVisualFailureFocusNudge(output, scopeAwareUserMessage);
4885
+ const visualRepairTaskLead = this._formatVisualRepairTaskLead(scopeAwareUserMessage, output);
4846
4886
  const visualFailureSummary = this._formatUiVerificationFailureLogSummary(visualVerificationFailureNudge);
4847
4887
  nudgeCount = 0;
4848
4888
  console.log(`[${taskId}] UI task visual verification still reported visible issues — retrying (${uiVerificationRetryCount}/${UI_REPAIR_NUDGE_LIMIT}, total UI repairs ${repairBudget})`);
@@ -4852,7 +4892,7 @@ export class AgentForgeWorker extends EventEmitter {
4852
4892
  const retryInstruction = generatedResetNudge
4853
4893
  ? 'Rebuild the removed target page file(s) from already-inspected project context and comparable existing pages. Do not reuse the rejected generated page as the basis for the next attempt. Address every requested target that is currently missing or changed in one coherent pass, fix the visible issues reported by local browser verification, reopen each edited target screen locally after the final edit, and only then end with ✓ TASK_COMPLETE.'
4854
4894
  : 'Continue from the current changed files and latest browser evidence. Fix the visible issues reported by the local browser verification, reopen each edited target screen locally after the final edit, and only then end with ✓ TASK_COMPLETE.';
4855
- iterationMessage = withTaskContext(`The task is: "${userMessage}"\n\n${[visualVerificationFailureNudge, visualFailureFocusNudge, generatedResetNudge, scopedTargetSetNudge, repeatedVisualRepairNudge].filter(Boolean).join('\n\n')}\n\n${retryInstruction}`);
4895
+ iterationMessage = withTaskContext(`${visualRepairTaskLead}\n\n${[visualVerificationFailureNudge, visualFailureFocusNudge, generatedResetNudge, scopedTargetSetNudge, repeatedVisualRepairNudge].filter(Boolean).join('\n\n')}\n\n${retryInstruction}`);
4856
4896
  } else if (hasMissingLocalUiVerification) {
4857
4897
  uiVerificationRetryCount++;
4858
4898
  const uiVerificationFailureDetails = this._extractUiVerificationFailureDetails(output);