@miroshnik/elves 2026.1105.0 → 2026.1105.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.
@@ -122,6 +122,9 @@ var Q = {
122
122
  repository(owner: $owner, name: $name) {
123
123
  issues(states: OPEN, first: 100, after: $after) { pageInfo { hasNextPage endCursor } nodes { id number } }
124
124
  }
125
+ }`,
126
+ IssueItems: `query IssueItems($ids: [ID!]!) {
127
+ nodes(ids: $ids) { ... on Issue { id projectItems(first: 20) { nodes { id isArchived project { id } } } } }
125
128
  }`,
126
129
  OwnerProjects: `query OwnerProjects($login: String!, $query: String!) {
127
130
  repositoryOwner(login: $login) { ... on ProjectV2Owner { projectsV2(first: 20, query: $query) { nodes { ${REF} } } } }
@@ -486,7 +489,24 @@ function loadState(io, slug) {
486
489
  const repo = loadRepo(io, slug);
487
490
  const openIssues = pages((after) => graphql(io, Q.RepoIssues, { owner, name, after }).repository.issues);
488
491
  const main = mainProject(repo);
489
- return { repo, project: main ? loadProject(io, main.id) : null, openIssues, labels: loadLabels(io, slug), decisions: loadDecisions(io, slug), merge: loadMerge(io, slug) };
492
+ const project = main ? loadProject(io, main.id) : null;
493
+ if (project)
494
+ markUnlisted(io, project, openIssues);
495
+ return { repo, project, openIssues, labels: loadLabels(io, slug), decisions: loadDecisions(io, slug), merge: loadMerge(io, slug) };
496
+ }
497
+ var NODES_PAGE = 100;
498
+ function markUnlisted(io, project, issues) {
499
+ const listed = new Set(project.items.map((it) => it.issue?.id));
500
+ const missing = issues.filter((i) => !listed.has(i.id));
501
+ for (let k = 0;k < missing.length; k += NODES_PAGE) {
502
+ const batch = missing.slice(k, k + NODES_PAGE);
503
+ for (const n of graphql(io, Q.IssueItems, { ids: batch.map((i) => i.id) })?.nodes ?? []) {
504
+ const item = (n?.projectItems?.nodes ?? []).find((it) => it?.project?.id === project.id && !it.isArchived);
505
+ const issue = batch.find((i) => i.id === n?.id);
506
+ if (item && issue)
507
+ issue.unlisted = item.id;
508
+ }
509
+ }
490
510
  }
491
511
  var statusChecks = (rule) => rule?.type === "REQUIRED_STATUS_CHECKS" ? { strict: !!rule.parameters?.strictRequiredStatusChecksPolicy, contexts: (rule.parameters?.requiredStatusChecks ?? []).map((c) => c.context) } : null;
492
512
  var WORST = ["fail", "cancel", "pending", "skipping", "pass"];
@@ -900,9 +920,13 @@ function analyze(s) {
900
920
  closedAdd(`closed without being done, but in the project: ${nums(dropped.map((it) => it.issue))}`, api(`remove from the project ${nums(dropped.map((it) => it.issue))}`, ...dropped.map((it) => ({ op: "DeleteItem", input: { projectId: p.id, itemId: it.id } }))));
901
921
  const open = add("open", `Open tasks of the repository — in the project, with ${STATUS}`);
902
922
  const inProject = new Set(issues.map((it) => it.issue.id));
903
- const missing = s.openIssues.filter((i) => !inProject.has(i.id));
923
+ const outside = s.openIssues.filter((i) => !inProject.has(i.id));
924
+ const unlisted = outside.filter((i) => i.unlisted);
925
+ const missing = outside.filter((i) => !i.unlisted);
904
926
  if (missing.length)
905
927
  open(`not in the project: ${nums(missing)}`, api(`add to the project ${nums(missing)}`, ...missing.map((i) => ({ op: "AddItem", input: { projectId: p.id, contentId: i.id } }))));
928
+ if (unlisted.length)
929
+ open.note(`GitHub doesn't return the item in the project's list: ${unlisted.map((i) => `#${i.number} (${i.unlisted})`).join(", ")} — the issue's projectItems has it`);
906
930
  const noStatus = issues.filter((it) => it.issue.state === "OPEN" && !it.status);
907
931
  if (noStatus.length)
908
932
  open(`without ${STATUS}: ${nums(noStatus.map((it) => it.issue))}`, ...statusReady ? [api(`${STATUS} ${q(N.status.backlog)}: ${nums(noStatus.map((it) => it.issue))}`, ...noStatus.map((it) => setStatus(it, N.status.backlog)))] : []);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miroshnik/elves",
3
- "version": "2026.1105.0",
3
+ "version": "2026.1105.2",
4
4
  "type": "module",
5
5
  "description": "Elves — a development flow with AI agents: shared rules and skills for any agent; install — bunx @miroshnik/elves install -g; the installer and skill scripts — TypeScript under Bun, tests — bun test in tests/",
6
6
  "repository": {
@@ -72,5 +72,5 @@
72
72
  "eslint-plugin-boundaries": "^7.2.0",
73
73
  "knip": "^6.41.0"
74
74
  },
75
- "gitHead": "85291db95dd59132267a5adc93ca6dfad3b00861"
75
+ "gitHead": "38c1d083a1df9e65e20715d1a841dc54fc0e10b7"
76
76
  }
@@ -372,7 +372,12 @@ outside git — ❌, `update` puts it into its commit.
372
372
  Others aren't checked.
373
373
  7. Closed tasks — in Done; those closed without being done (not planned,
374
374
  duplicate) — outside the project.
375
- 8. The repository's open tasks — in the project, each has a `Status`.
375
+ 8. The repository's open tasks — in the project, each has a `Status`. A
376
+ task the project's item list doesn't return is rechecked by its own
377
+ `projectItems`: a live (not archived) item of this project — GitHub
378
+ hasn't reindexed the project yet, and `AddItem` would answer with that
379
+ same item — is an `○` line with the item's id, item ✅, `task start`
380
+ goes on.
376
381
  9. Decision labels — by the spec tree of the default branch (via the API): the
377
382
  label name is the topic name (folder
378
383
  `tests/capabilities|standards|architecture/<topic>` or a model module), kind
@@ -333,7 +333,11 @@ export interface Merge {
333
333
  export interface State {
334
334
  repo: { id: string; name: string; nameWithOwner: string; owner: Owner; linked: ProjectRef[] };
335
335
  project: Project | null;
336
- openIssues: { id: string; number: number }[];
336
+ /**
337
+ * `unlisted` — the id of the project's item that the project's item list doesn't return, though the issue's own
338
+ * `projectItems` has it (`markUnlisted`).
339
+ */
340
+ openIssues: { id: string; number: number; unlisted?: string }[];
337
341
  labels: Label[];
338
342
  decisions: Decisions;
339
343
  /** An empty repository (no default branch) — null. */
@@ -413,6 +417,10 @@ export const Q = {
413
417
  repository(owner: $owner, name: $name) {
414
418
  issues(states: OPEN, first: 100, after: $after) { pageInfo { hasNextPage endCursor } nodes { id number } }
415
419
  }
420
+ }`,
421
+ /** The project items of issues by their ids — as the issue sees them (`markUnlisted`), at most `NODES_PAGE` ids. */
422
+ IssueItems: `query IssueItems($ids: [ID!]!) {
423
+ nodes(ids: $ids) { ... on Issue { id projectItems(first: 20) { nodes { id isArchived project { id } } } } }
416
424
  }`,
417
425
  OwnerProjects: `query OwnerProjects($login: String!, $query: String!) {
418
426
  repositoryOwner(login: $login) { ... on ProjectV2Owner { projectsV2(first: 20, query: $query) { nodes { ${REF} } } } }
@@ -834,9 +842,33 @@ const mainProject = (repo: State["repo"]) => repo.linked.find((p) => p.title ===
834
842
  export function loadState(io: Io, slug: string): State {
835
843
  const [owner, name] = slug.split("/") as [string, string];
836
844
  const repo = loadRepo(io, slug);
837
- const openIssues = pages<{ id: string; number: number }>((after) => graphql(io, Q.RepoIssues, { owner, name, after }).repository.issues);
845
+ const openIssues = pages<State["openIssues"][number]>((after) => graphql(io, Q.RepoIssues, { owner, name, after }).repository.issues);
838
846
  const main = mainProject(repo);
839
- return { repo, project: main ? loadProject(io, main.id) : null, openIssues, labels: loadLabels(io, slug), decisions: loadDecisions(io, slug), merge: loadMerge(io, slug) };
847
+ const project = main ? loadProject(io, main.id) : null;
848
+ if (project) markUnlisted(io, project, openIssues);
849
+ return { repo, project, openIssues, labels: loadLabels(io, slug), decisions: loadDecisions(io, slug), merge: loadMerge(io, slug) };
850
+ }
851
+
852
+ /** How many ids one `nodes(ids:)` query takes — GitHub's limit. */
853
+ const NODES_PAGE = 100;
854
+
855
+ /**
856
+ * GitHub sometimes leaves an item out of `ProjectV2.items` that the issue has (#791): `issue.projectItems` returns it,
857
+ * `AddItem` answers with that same item, and the list doesn't change until GitHub reindexes the project. An open issue
858
+ * missing from the list is asked by its own `projectItems`: a live (not archived) item of this project marks it
859
+ * `unlisted` — the task is in the project, it isn't added again.
860
+ */
861
+ function markUnlisted(io: Io, project: Project, issues: State["openIssues"]): void {
862
+ const listed = new Set(project.items.map((it) => it.issue?.id));
863
+ const missing = issues.filter((i) => !listed.has(i.id));
864
+ for (let k = 0; k < missing.length; k += NODES_PAGE) {
865
+ const batch = missing.slice(k, k + NODES_PAGE);
866
+ for (const n of graphql(io, Q.IssueItems, { ids: batch.map((i) => i.id) })?.nodes ?? []) {
867
+ const item = (n?.projectItems?.nodes ?? []).find((it: Any) => it?.project?.id === project.id && !it.isArchived);
868
+ const issue = batch.find((i) => i.id === n?.id);
869
+ if (item && issue) issue.unlisted = item.id;
870
+ }
871
+ }
840
872
  }
841
873
 
842
874
  const statusChecks = (rule: Any): { strict: boolean; contexts: string[] } | null =>
@@ -1319,8 +1351,13 @@ export function analyze(s: State): Check[] {
1319
1351
 
1320
1352
  const open = add("open", `Open tasks of the repository — in the project, with ${STATUS}`);
1321
1353
  const inProject = new Set(issues.map((it) => it.issue!.id));
1322
- const missing = s.openIssues.filter((i) => !inProject.has(i.id));
1354
+ // the item the issue has but the project's list doesn't return — the task is in the project: AddItem would answer
1355
+ // with the same item and change nothing (#791)
1356
+ const outside = s.openIssues.filter((i) => !inProject.has(i.id));
1357
+ const unlisted = outside.filter((i) => i.unlisted);
1358
+ const missing = outside.filter((i) => !i.unlisted);
1323
1359
  if (missing.length) open(`not in the project: ${nums(missing)}`, api(`add to the project ${nums(missing)}`, ...missing.map((i) => ({ op: "AddItem", input: { projectId: p.id, contentId: i.id } }))));
1360
+ if (unlisted.length) open.note(`GitHub doesn't return the item in the project's list: ${unlisted.map((i) => `#${i.number} (${i.unlisted})`).join(", ")} — the issue's projectItems has it`);
1324
1361
  const noStatus = issues.filter((it) => it.issue!.state === "OPEN" && !it.status);
1325
1362
  if (noStatus.length) open(`without ${STATUS}: ${nums(noStatus.map((it) => it.issue!))}`, ...(statusReady ? [api(`${STATUS} ${q(N.status.backlog)}: ${nums(noStatus.map((it) => it.issue!))}`, ...noStatus.map((it) => setStatus(it, N.status.backlog)))] : []));
1326
1363
 
@@ -226,7 +226,9 @@ no decision claims is dead and is deleted.
226
226
  creation the labels of its topics (the "Task tracking" section in `AGENTS.md`)
227
227
  and the scenarios section: future `it` names (or "describe › it") as a list,
228
228
  optionally with the decision folder in front, as `spec-diff` prints a test
229
- (`` `billing` · a draft is deleted `` — only a test of that folder matches):
229
+ (`` `billing` · a draft is deleted `` — only a test of that folder matches;
230
+ in a topic with sections — the section, `` `permissions` · … `` or
231
+ `` `routes#permissions` · … ``, while the topic matches any of its sections):
230
232
  from them the user sees the requirements before the code and can stop it.
231
233
  For a "registry + invariant" standard the harness generates the tests per
232
234
  element — the scenario is the name of the `describe` in which `invariant`
@@ -802,6 +802,9 @@ export function render(
802
802
  return lines.join("\n").trimEnd() + "\n";
803
803
  }
804
804
 
805
+ /** A test in `--json` — the same in the lists and the scenarios: the file tells apart the sections of one folder. */
806
+ const testJson = (t: Test) => ({ file: t.path, folder: L.folderOf(t), describes: t.describes, name: t.name });
807
+
805
808
  /** `unreported` — base tests only a run names, of files a partial report didn't run: not compared (`unreportedTests`). */
806
809
  function asJson(
807
810
  baseLabel: string,
@@ -813,18 +816,17 @@ function asJson(
813
816
  notStatements: number,
814
817
  unreported: Test[],
815
818
  ): string {
816
- const d = (t: Test) => ({ file: t.path, folder: L.folderOf(t), describes: t.describes, name: t.name });
817
819
  return (
818
820
  JSON.stringify(
819
821
  {
820
822
  base: baseLabel,
821
- removed: removed.map(d),
822
- changed: changed.map(([o, n]) => ({ old: d(o), new: d(n) })),
823
- added: added.map(d),
824
- moved: moved.map((m) => ({ from: m.from, ...d(m.test) })),
823
+ removed: removed.map(testJson),
824
+ changed: changed.map(([o, n]) => ({ old: testJson(o), new: testJson(n) })),
825
+ added: added.map(testJson),
826
+ moved: moved.map((m) => ({ from: m.from, ...testJson(m.test) })),
825
827
  out_of_tree_files: outFiles,
826
828
  not_statements: notStatements,
827
- unreported: unreported.map(d),
829
+ unreported: unreported.map(testJson),
828
830
  },
829
831
  null,
830
832
  2,
@@ -871,11 +873,17 @@ export function scenarioFolder(scenario: string): { folder: string | null; name:
871
873
  }
872
874
 
873
875
  /**
874
- * The prefix names the folder as spec-diff prints it (`tests/capabilities/billing`, with `#section` in a topic with
875
- * sections) or by its tail (`billing`, `capabilities/billing`).
876
+ * The prefix names the place as spec-diff prints it (`tests/capabilities/billing`, `tests/capabilities/routes#permissions`
877
+ * in a topic with sections) or by its tail (`billing`, `capabilities/billing`, `routes#permissions`). In a topic with
878
+ * sections (#685) the decision is a section, and the prefix is its name alone (`permissions`) — only that section's
879
+ * tests; the topic in front — any of its sections, as the decision folder before sections (#790).
876
880
  */
877
881
  const inFolder = (folder: string | null, places: string[]): boolean =>
878
- folder === null || places.some((p) => p === folder || p.endsWith(`/${folder}`));
882
+ folder === null ||
883
+ places.some((p) => {
884
+ const [topic, section] = p.split("#");
885
+ return section === folder || [p, topic!].some((q) => q === folder || q.endsWith(`/${folder}`));
886
+ });
879
887
 
880
888
  /** A scenario and what it became: new tests, a harness check's describe, or nothing. */
881
889
  export interface Found {
@@ -888,7 +896,7 @@ export interface Found {
888
896
  * Scenario ↔ new tests: each one whose it name or "describe › it" chain matches it (case-insensitive, without outer
889
897
  * quotes and a trailing mark) — one scenario is checked both on the server and in the UI; no test — the describe of a
890
898
  * new harness check, its name or chain. A scenario with the decision folder in front (`scenarioFolder`) is matched only
891
- * within that folder; without it — in any. Tests that check generated (`generated` — only from the report) are tests of
899
+ * within that folder or topic's section (`inFolder`); without it — in any. Tests that check generated (`generated` — only from the report) are tests of
892
900
  * its scenario, not beyond the scenarios.
893
901
  */
894
902
  export function matchScenarios(
@@ -1163,16 +1171,15 @@ export async function main(argv: string[]): Promise<number> {
1163
1171
  if (v.scenarios !== undefined) {
1164
1172
  if (v.json) {
1165
1173
  const j = JSON.parse(text);
1166
- const d = (t: Test) => ({ folder: L.folderOf(t), describes: t.describes, name: t.name });
1167
1174
  j.scenarios =
1168
1175
  scenarios === null
1169
1176
  ? null
1170
1177
  : match.found.map(({ scenario, tests, harness: h }) => ({
1171
1178
  scenario,
1172
- tests: tests.map(d),
1179
+ tests: tests.map(testJson),
1173
1180
  harness: h ? { folder: h.folder, describes: h.describes, checks: h.checks } : null,
1174
1181
  }));
1175
- j.extra_tests = match.extra.map(d);
1182
+ j.extra_tests = match.extra.map(testJson);
1176
1183
  text = JSON.stringify(j, null, 2) + "\n";
1177
1184
  } else {
1178
1185
  const listed = !summarized(removed, changed, added, limit);
@@ -79,16 +79,18 @@ function api<T>(endpoint: string): T {
79
79
  const time = (iso: string | undefined): number => Date.parse(iso ?? "");
80
80
 
81
81
  /**
82
- * Ids of the runs with a live artifact, newest first. Only this repository's runs count: a PR run from a fork can upload
83
- * an artifact with any name too. `before` — only artifacts uploaded by then: a run finished by a moment uploaded its
84
- * artifact before it. A page of 100: newer artifacts keep coming while a run lasts, an older source stays on it.
82
+ * Ids of the runs with a live artifact, newest upload first. Only this repository's runs count: a PR run from a fork can
83
+ * upload an artifact with any name too. `before` — only artifacts uploaded by then: a run finished by a moment uploaded
84
+ * its artifact before it. The API lists artifacts by id, descending, not by upload time — the two differ by tens of
85
+ * minutes, so they are sorted by `created_at` here. A page of 100: the id order strays from time by minutes, not by a
86
+ * page, and newer artifacts keep coming while a run lasts — an older source stays on it.
85
87
  */
86
88
  function runIds(artifact: string, before?: number): number[] {
87
89
  const { artifacts } = api<{ artifacts: Artifact[] }>(`repos/{owner}/{repo}/actions/artifacts?name=${encodeURIComponent(artifact)}&per_page=100`);
88
- const own = artifacts.filter(
89
- (a) => !a.expired && a.workflow_run && a.workflow_run.head_repository_id === a.workflow_run.repository_id && !(time(a.created_at) > (before ?? Infinity)),
90
- );
91
- // a rerun uploads the artifact again under the same run id
90
+ const own = artifacts
91
+ .filter((a) => !a.expired && a.workflow_run && a.workflow_run.head_repository_id === a.workflow_run.repository_id && !(time(a.created_at) > (before ?? Infinity)))
92
+ .sort((a, b) => time(b.created_at) - time(a.created_at));
93
+ // a rerun uploads the artifact again under the same run id: the run counts by its newest upload
92
94
  return [...new Set(own.map((a) => a.workflow_run!.id))];
93
95
  }
94
96