@yemi33/minions 0.1.2112 → 0.1.2113

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.
@@ -4,7 +4,7 @@ const dir = path.resolve(__dirname, '..');
4
4
 
5
5
  console.log('=== Work Items (non-done) ===');
6
6
  let items = [];
7
- try { items = JSON.parse(fs.readFileSync(path.join(dir, 'work-items.json'), 'utf8')); } catch {}
7
+ try { items = require('./queries').getWorkItems() || []; } catch {}
8
8
  items.filter(i => i.status !== 'done').forEach(i => {
9
9
  console.log(i.id, (i.status || '').padEnd(12), (i.type || '').padEnd(12), (i.title || '').slice(0, 60));
10
10
  });
package/engine/shared.js CHANGED
@@ -4970,33 +4970,24 @@ function getPrLinks() {
4970
4970
  if (!knownPrIdsByDisplay.has(displayId)) knownPrIdsByDisplay.set(displayId, new Set());
4971
4971
  knownPrIdsByDisplay.get(displayId).add(pr.id);
4972
4972
  };
4973
- // Primary source: derive from all projects/*/pull-requests.json prdItems
4974
- const projectsDir = path.join(MINIONS_DIR, 'projects');
4973
+ // Primary source: derive from all per-project + central PR records via the
4974
+ // SQL-canonical store (Phase 9). `readAllPullRequests` decorates each row
4975
+ // with `_scope` so we can look up the owning project for legacy-ID
4976
+ // normalization.
4975
4977
  const projectsByName = new Map(getProjects().map(project => [project.name || path.basename(project.localPath || ''), project]));
4976
4978
  try {
4977
- for (const d of fs.readdirSync(projectsDir, { withFileTypes: true })) {
4978
- if (!d.isDirectory()) continue;
4979
- try {
4980
- const prs = JSON.parse(fs.readFileSync(path.join(projectsDir, d.name, 'pull-requests.json'), 'utf8'));
4981
- const project = projectsByName.get(d.name) || null;
4982
- normalizePrRecords(prs, project);
4983
- for (const pr of prs) {
4984
- if (!pr.id) continue;
4985
- registerPrId(pr);
4986
- mergePrLinkItems(links, pr.id, pr.prdItems || []);
4987
- }
4988
- } catch { /* missing or invalid */ }
4989
- }
4990
- } catch { /* projects dir missing */ }
4991
- try {
4992
- const centralPrs = JSON.parse(fs.readFileSync(path.join(MINIONS_DIR, 'pull-requests.json'), 'utf8'));
4993
- normalizePrRecords(centralPrs, null);
4994
- for (const pr of centralPrs) {
4995
- if (!pr.id) continue;
4979
+ const store = require('./pull-requests-store');
4980
+ const allPrs = store.readAllPullRequests() || [];
4981
+ for (const pr of allPrs) {
4982
+ if (!pr?.id) continue;
4983
+ const scope = pr._scope;
4984
+ delete pr._scope;
4985
+ const project = scope && scope !== 'central' ? (projectsByName.get(scope) || null) : null;
4986
+ normalizePrRecords([pr], project);
4996
4987
  registerPrId(pr);
4997
4988
  mergePrLinkItems(links, pr.id, pr.prdItems || []);
4998
4989
  }
4999
- } catch { /* central file optional */ }
4990
+ } catch { /* SQL unavailable skip primary source */ }
5000
4991
  // Fallback: static pr-links.json for entries not covered above
5001
4992
  try {
5002
4993
  const static_ = JSON.parse(fs.readFileSync(PR_LINKS_PATH, 'utf8'));
@@ -5054,27 +5045,21 @@ function addPrLink(prId, itemId, { project = null, url = '', prNumber = null } =
5054
5045
  if (!project) return;
5055
5046
  const prPath = projectPrPath(project);
5056
5047
  const effectivePrNumber = getPrNumber(prNumber ?? effectivePrId);
5057
- const prLockPath = `${prPath}.lock`;
5058
- withFileLock(prLockPath, () => {
5059
- if (!fs.existsSync(prPath)) return;
5060
- let prs = safeJson(prPath);
5061
- if (!Array.isArray(prs)) prs = [];
5048
+ // Phase 9 SQL routing: mutatePullRequests writes through pull-requests-store
5049
+ // so SQL stays canonical; the JSON mirror is regenerated by the store.
5050
+ mutatePullRequests(prPath, (prs) => {
5051
+ if (!Array.isArray(prs) || prs.length === 0) return prs;
5062
5052
  normalizePrRecords(prs, project);
5063
5053
  const existingPr = prs.find(pr =>
5064
5054
  pr?.id === effectivePrId
5065
5055
  || (url && pr?.url === url)
5066
5056
  || (effectivePrNumber != null && getPrNumber(pr) === effectivePrNumber)
5067
5057
  );
5068
- if (!existingPr) return;
5069
- const backupPath = prPath + '.backup';
5070
- try { if (fs.existsSync(prPath)) fs.copyFileSync(prPath, backupPath); } catch { /* backup is best-effort */ }
5058
+ if (!existingPr) return prs;
5071
5059
  existingPr.prdItems = Array.isArray(existingPr.prdItems) ? existingPr.prdItems : [];
5072
- if (existingPr.prdItems.includes(itemId)) return;
5060
+ if (existingPr.prdItems.includes(itemId)) return prs;
5073
5061
  existingPr.prdItems.push(itemId);
5074
- safeWrite(prPath, prs);
5075
- }, {
5076
- retries: ENGINE_DEFAULTS.lockRetries,
5077
- retryBackoffMs: ENGINE_DEFAULTS.lockRetryBackoffMs
5062
+ return prs;
5078
5063
  });
5079
5064
  }
5080
5065
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yemi33/minions",
3
- "version": "0.1.2112",
3
+ "version": "0.1.2113",
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"