@soleone/factory 0.2.1 → 0.2.2

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/README.md CHANGED
@@ -11,7 +11,7 @@ Needs node 22+, git, [workwork](https://github.com/Soleone/workwork) with `--jso
11
11
 
12
12
  ## How it works
13
13
 
14
- - **Repos** are yours on GitHub, cloned under `$SRC`, which is where workwork looks. The folder button right of the tabs lists the ones you haven't cloned yet, newest first, and clones one into a folder of `$SRC` you pick.
14
+ - **Repos** are yours on GitHub, cloned under `$SRC`, which is where workwork looks. In the Candidates tab, choose **Clone project...** from the repo dropdown to see the ones you haven't cloned yet, newest first, and clone one directly into `$SRC`.
15
15
  - **Jobs** are workwork candidates in the queue. Your picks always go first, in the order you give them; auto jobs follow. A job can name its agent, model and effort. Once an agent has started a job, the job stays with that agent.
16
16
  - **Auto mode** only fills the queue: while the factory is on, it keeps up to 5 of its jobs per agent queued, cheapest attention first, with repos taking turns. It never re-queues a candidate that already had a job. You can limit it to some levels and plays.
17
17
  - **The factory** is what works the queue, one worker per agent. With nothing to do it waits, and it picks up new jobs within seconds. Turning it on starts a **run** with its own agents, models, efforts, limit and end time, defaulting to the settings.
package/dist/cli.mjs CHANGED
@@ -1543,12 +1543,18 @@ Propose what to queue and why, briefly, and add jobs only once the user agrees.
1543
1543
  //#endregion
1544
1544
  //#region src/backend/repos.ts
1545
1545
  /** Where workwork --all looks for repos, with the same fallback. */
1546
- const SRC = process.env.SRC ?? process.cwd();
1546
+ const sourceRoot = () => resolve(process.env.SRC ?? process.cwd());
1547
+ /** Local repos are available as filters even when workwork finds no candidates in them. */
1548
+ function localRepos() {
1549
+ const root = sourceRoot();
1550
+ return existsSync(root) ? findRepos(root, 4) : [];
1551
+ }
1547
1552
  /**
1548
1553
  * The GitHub user's own repos (not forked or archived) that aren't cloned anywhere under $SRC
1549
1554
  * yet, newest first.
1550
1555
  */
1551
1556
  async function clonableRepos() {
1557
+ const root = sourceRoot();
1552
1558
  const listed = JSON.parse(await output("gh", [
1553
1559
  "repo",
1554
1560
  "list",
@@ -1558,30 +1564,29 @@ async function clonableRepos() {
1558
1564
  "5000",
1559
1565
  "--json",
1560
1566
  "nameWithOwner,description,createdAt"
1561
- ], SRC));
1562
- const local = findRepos(SRC, 4);
1563
- const cloned = new Set(await Promise.all(local.map(originName)));
1564
- const repos = listed.filter((repo) => !cloned.has(repo.nameWithOwner.toLowerCase())).map((repo) => ({
1565
- name: repo.nameWithOwner,
1566
- description: repo.description,
1567
- createdAt: repo.createdAt
1568
- })).sort((a, b) => b.createdAt.localeCompare(a.createdAt));
1567
+ ], root));
1568
+ const cloned = new Set(await Promise.all(localRepos().map(originName)));
1569
1569
  return {
1570
- root: SRC,
1571
- repos
1570
+ root,
1571
+ repos: listed.filter((repo) => !cloned.has(repo.nameWithOwner.toLowerCase())).map((repo) => ({
1572
+ name: repo.nameWithOwner,
1573
+ description: repo.description,
1574
+ createdAt: repo.createdAt
1575
+ })).sort((a, b) => b.createdAt.localeCompare(a.createdAt))
1572
1576
  };
1573
1577
  }
1574
1578
  /** Clones `name` (owner/repo) to $SRC/<repo> and returns that path. */
1575
1579
  async function cloneRepo(name) {
1576
1580
  if (!/^[\w.-]+\/[\w.-]+$/.test(name)) throw new Error(`${name} isn't a GitHub owner/repo`);
1577
- const path = join(SRC, name.split("/")[1]);
1581
+ const root = sourceRoot();
1582
+ const path = join(root, name.split("/")[1]);
1578
1583
  if (existsSync(path)) throw new Error(`${path} already exists`);
1579
1584
  await output("gh", [
1580
1585
  "repo",
1581
1586
  "clone",
1582
1587
  name,
1583
1588
  path
1584
- ], SRC);
1589
+ ], root);
1585
1590
  return path;
1586
1591
  }
1587
1592
  /** Repos under `dir`, searched the way workwork --all does. */
@@ -1825,9 +1830,15 @@ function serve(state, port, host) {
1825
1830
  }
1826
1831
  const routes = {
1827
1832
  "GET /api/state": () => snapshot(state, (urls) => prs.get(urls), train.cars()),
1828
- "GET /api/candidates": () => readCandidates(state) ?? {
1829
- at: null,
1830
- items: []
1833
+ "GET /api/candidates": () => {
1834
+ const cached = readCandidates(state);
1835
+ const items = cached?.items ?? [];
1836
+ const repos = [.../* @__PURE__ */ new Set([...localRepos(), ...items.map((item) => item.repo)])].sort();
1837
+ return {
1838
+ at: cached?.at ?? null,
1839
+ items,
1840
+ repos
1841
+ };
1831
1842
  },
1832
1843
  "POST /api/candidates/refresh": () => {
1833
1844
  refreshCandidates(state, "workwork").catch((error) => console.error(`factory: workwork failed: ${error.message}`));
@@ -1977,7 +1988,7 @@ function send(response, type, body) {
1977
1988
  }
1978
1989
  //#endregion
1979
1990
  //#region package.json
1980
- var version = "0.2.1";
1991
+ var version = "0.2.2";
1981
1992
  //#endregion
1982
1993
  //#region src/backend/cli.ts
1983
1994
  const USAGE = `factory: works a queue of workwork candidates with headless coding agents