@yemi33/minions 0.1.492 → 0.1.493

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/CHANGELOG.md CHANGED
@@ -1,8 +1,9 @@
1
1
  # Changelog
2
2
 
3
- ## 0.1.492 (2026-04-07)
3
+ ## 0.1.493 (2026-04-07)
4
4
 
5
5
  ### Fixes
6
+ - reconcile agent completions during engine downtime (closes #376) (#385)
6
7
  - settings button shows modal immediately with loading state
7
8
  - CC respects user scroll position — no auto-scroll when reading history
8
9
  - steering feedback — toast notification, ensure polling resumes
package/engine/cli.js CHANGED
@@ -221,17 +221,43 @@ const commands = {
221
221
  const hasError = output.includes('"is_error":true') || output.includes('"is_error": true');
222
222
  if (!hasResult && !hasError) continue;
223
223
 
224
- const isSuccess = hasResult && !hasError;
225
- const result = isSuccess ? DISPATCH_RESULT.SUCCESS : DISPATCH_RESULT.ERROR;
226
-
227
- e.log('info', `Orphan recovery: ${agentId} (${item.id}) completed while engine was down — result: ${result}`);
224
+ let isSuccess = hasResult && !hasError;
228
225
 
229
- // Extract PRs from output
226
+ // Extract PRs from output first — if PRs were created, the agent succeeded
227
+ // regardless of intermediate error lines in the log
230
228
  let prsCreated = 0;
231
229
  try {
232
230
  prsCreated = lifecycle.syncPrsFromOutput(output, agentId, item.meta, config);
233
231
  } catch (err) { e.log('warn', `Orphan PR sync: ${err.message}`); }
234
232
 
233
+ // If PRs were created or a matching PR exists, treat as success
234
+ if (!isSuccess && prsCreated > 0) {
235
+ e.log('info', `Orphan recovery: ${agentId} (${item.id}) has ${prsCreated} PR(s) — overriding to success`);
236
+ isSuccess = true;
237
+ }
238
+
239
+ // Fallback: check pull-requests.json for a matching PR by work item ID
240
+ if (!isSuccess && item.meta?.item?.id) {
241
+ try {
242
+ const projName = item.meta.project?.name;
243
+ if (projName) {
244
+ const prPath = path.join(MINIONS_DIR, 'projects', projName, 'pull-requests.json');
245
+ const prs = safeJson(prPath) || [];
246
+ const matchingPr = prs.find(pr =>
247
+ (pr.prdItems || []).includes(item.meta.item.id) &&
248
+ pr.status !== 'abandoned' && pr.status !== 'closed'
249
+ );
250
+ if (matchingPr) {
251
+ e.log('info', `Orphan recovery: ${agentId} (${item.id}) has matching PR ${matchingPr.id} — overriding to success`);
252
+ isSuccess = true;
253
+ }
254
+ }
255
+ } catch (err) { e.log('warn', `Orphan PR lookup: ${err.message}`); }
256
+ }
257
+
258
+ const result = isSuccess ? DISPATCH_RESULT.SUCCESS : DISPATCH_RESULT.ERROR;
259
+ e.log('info', `Orphan recovery: ${agentId} (${item.id}) completed while engine was down — result: ${result}`);
260
+
235
261
  // Update work item status
236
262
  if (item.meta?.item?.id) {
237
263
  const status = isSuccess ? WI_STATUS.DONE : WI_STATUS.FAILED;
package/engine.js CHANGED
@@ -838,7 +838,10 @@ function reconcileItemsWithPrs(items, allPrs, { onlyIds } = {}) {
838
838
  const prLinks = shared.getPrLinks();
839
839
  let reconciled = 0;
840
840
  for (const wi of items) {
841
- if (wi.status !== WI_STATUS.PENDING || wi._pr) continue;
841
+ // Reconcile pending items AND failed items that have a matching PR
842
+ // (failed items may have been incorrectly marked during engine downtime)
843
+ if (wi._pr && wi.status !== WI_STATUS.FAILED) continue;
844
+ if (wi.status !== WI_STATUS.PENDING && wi.status !== WI_STATUS.FAILED) continue;
842
845
  if (onlyIds && !onlyIds.has(wi.id)) continue;
843
846
 
844
847
  let exactPr = allPrs.find(pr => (pr.prdItems || []).includes(wi.id));
@@ -849,6 +852,10 @@ function reconcileItemsWithPrs(items, allPrs, { onlyIds } = {}) {
849
852
  if (exactPr) {
850
853
  wi.status = WI_STATUS.DONE;
851
854
  wi._pr = exactPr.id;
855
+ // Clear failure artifacts if reconciling a previously failed item
856
+ if (wi.failReason) delete wi.failReason;
857
+ if (wi.failedAt) delete wi.failedAt;
858
+ if (!wi.completedAt) wi.completedAt = new Date().toISOString();
852
859
  reconciled++;
853
860
  }
854
861
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yemi33/minions",
3
- "version": "0.1.492",
3
+ "version": "0.1.493",
4
4
  "description": "Multi-agent AI dev team that runs from ~/.minions/ — five autonomous agents share a single engine, dashboard, and knowledge base",
5
5
  "bin": {
6
6
  "minions": "bin/minions.js"