Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

2.4 KB
Raw Blame
#!/usr/bin/env node
// A release snapshot of actual Store publications, not filesystem mtimes or
// download estimates. Refresh after `git fetch origin store-catalog`.
import {execFileSync} from 'node:child_process';
import {writeFileSync, readFileSync, readdirSync} from 'node:fs';
import {fileURLToPath} from 'node:url';
const root = fileURLToPath(new URL('../..', import.meta.url));
const git = (...args) => execFileSync('git', ['-C', root, ...args], {encoding:'utf8', maxBuffer:32*1024*1024}).trim();
const ref = process.argv[2] || 'origin/store-catalog';
const history = new Map();
const commits = git('rev-list', '--reverse', ref).split('\n');
for (const commit of commits) {
  const at = new Date(git('show', '-s', '--format=%cI', commit)).toISOString();
  const catalog = JSON.parse(git('show', `${commit}:catalog.json`));
  for (const entry of catalog.entries) {
    if (entry.kind === 'viewer') continue;
    // A publisher advances the install ref on every publication. Only a change
    // to the package revision or metadata makes this entry newly updated.
    const fingerprint = JSON.stringify(Object.fromEntries(Object.entries(entry).filter(([key]) => key !== 'ref').sort(([a],[b]) => a.localeCompare(b))));
    const previous = history.get(entry.id);
    history.set(entry.id, {
      addedAt: previous?.addedAt ?? at,
      updatedAt: previous?.fingerprint === fingerprint ? previous.updatedAt : at,
      fingerprint,
    });
  }
}
const listed = readdirSync(`${root}/store/agents`).flatMap(name => {
  try {
    const facts = JSON.parse(readFileSync(`${root}/store/agents/${name}/store.json`));
    const manifest = JSON.parse(readFileSync(`${root}/store/agents/${name}/harness.json`));
    return facts.listed === false ? [] : [manifest.id];
  } catch { return []; }
});
const entries = listed.filter(id => history.has(id)).sort().map(id => {
  const item = history.get(id);
  return `  '${id}': (\n    addedAt: '${item.addedAt}',\n    updatedAt: '${item.updatedAt}',\n  ),`;
});
const text = `// Generated by desktop/tool/store_catalog_history.mjs.\n// Publication source: ${git('rev-parse', ref)}\n// A snapshot for this app release; unknown tools are never assigned fake dates.\nconst storeCatalogHistory = <String, ({String addedAt, String updatedAt})>{\n${entries.join('\n')}\n};\n`;
writeFileSync(`${root}/desktop/lib/store/store_catalog_history.g.dart`, text);
console.log(`Recorded publication history for ${entries.length} listed harnesses.`);