@feigi/fleet-ctl 3.45.1 → 3.46.0

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.
@@ -18,7 +18,7 @@ Before touching labeled PR `N`, list every open PR below `N` lacking the label.
18
18
  ~/.fleet/bin/fleet-run pr-overlap.mjs --a <lower-pr> --b <N>
19
19
  ```
20
20
 
21
- **Any** of its four signals (`files`, `modules`, `dirs`, `prose`) firing means related. Path equality alone is too weak: a repo mid-migration has `src/…/foo.test.ts` in one PR and `tests/unit/…/foo.test.ts` in the other — same module, zero shared paths.
21
+ **Any** of its four signals (`files`, `modules`, `dirs`, `prose`) firing means related. Path equality alone is too weak: a repo mid-migration has `src/…/test_foo.py` in one PR and `tests/unit/…/test_foo.py` in the other — same module, zero shared paths. A module is a test file's name with its test affix and extension removed, in any language (`foo.test.ts`, `foo_test.go` and `test_foo.py` are all `foo`); other files are not modules.
22
22
 
23
23
  Two false positives in signal 3:
24
24
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feigi/fleet-ctl",
3
- "version": "3.45.1",
3
+ "version": "3.46.0",
4
4
  "description": "Agent fleet: run-team controller, merge bot, PR reviewer, and the ticket pipeline they share",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -41,10 +41,25 @@ export const isTestDir = (p) => /(^|\/)(__tests__|tests?|e2e|__mocks__)\//i.test
41
41
  // suffix is a naming heuristic: it also claims a production component named like
42
42
  // `ABTest.tsx`, which is the accepted cost of recognising `FooTest.java` without
43
43
  // naming a language.
44
- export const isTestName = (p) =>
45
- /[._](test|spec)\.[^/.]+$/i.test(p) ||
46
- /(^|\/)test_[^/]*$/i.test(p) ||
47
- /[A-Za-z0-9]Tests?\.[^/.]+$/.test(p);
44
+ //
45
+ // Each shape captures the basename with its affix and extension removed, so
46
+ // `testSubject` names what the test is about from the same patterns this
47
+ // predicate judges by: `foo.test.ts`, `foo_test.go`, `test_foo.py` and
48
+ // `foo.spec.rb` give `foo`, and `FooTest.java` gives `Foo`. The first shape
49
+ // that matches decides. `null` means no test name.
50
+ const TEST_NAME_SHAPES = [
51
+ /(?:^|\/)([^/]*)[._](?:test|spec)\.[^/.]+$/i,
52
+ /(?:^|\/)test_([^/]*?)(?:\.[^/.]+)?$/i,
53
+ /(?:^|\/)([^/]*[A-Za-z0-9])Tests?\.[^/.]+$/,
54
+ ];
55
+ export const testSubject = (p) => {
56
+ for (const shape of TEST_NAME_SHAPES) {
57
+ const m = shape.exec(p);
58
+ if (m) return m[1];
59
+ }
60
+ return null;
61
+ };
62
+ export const isTestName = (p) => testSubject(p) !== null;
48
63
 
49
64
  // Only a prose or config extension, or a conventional name, makes a file docs or
50
65
  // config — which those already do anywhere, so neither `docs/` nor `.github/` has
@@ -14,6 +14,7 @@
14
14
  import { execFileSync } from "node:child_process";
15
15
  import { gitEnv } from "./git-env.mjs";
16
16
  import { basename, dirname, extname } from "node:path";
17
+ import { isConfig, isDocs, testSubject } from "./diff-stats.mjs";
17
18
  import { makeDie, defineFlags } from "./arg.mjs";
18
19
 
19
20
  const NAME = "pr-overlap";
@@ -96,20 +97,24 @@ const intersect = (xs, ys) => {
96
97
 
97
98
  // A repo mid-migration has src/…/foo.test.ts in one PR and
98
99
  // tests/unit/…/foo.test.ts in the other: same module, zero shared paths. That
99
- // migration case is what this signal exists for, and it is a TypeScript-module
100
- // notion — so only files whose extension is actually stripped participate.
100
+ // migration case is what this signal exists for, and it is a test-file notion
101
+ // in any language — so only a file whose name has a test shape participates,
102
+ // judged by diff-stats.mjs's own patterns, and its module is that name with
103
+ // the test affix and extension removed: `foo_test.go`, `test_foo.py` and
104
+ // `foo.test.ts` all give `foo`, `FooTest.java` gives `Foo`. Modules compare
105
+ // case-sensitively, as `files` compares paths.
101
106
  //
102
- // Matching on bare basenames instead produces confident nonsense: two PRs each
103
- // touching their own README.md, or their own hooks.json, reported as sharing a
104
- // "module". Measured in the proving ground: README.md ×8, SKILL.md ×6,
105
- // mcp-snippet.json ×9, hooks.json ×5 across unrelated directories. Returning
106
- // null for those drops them from the signal entirely rather than caveating them.
107
- const moduleOf = (f) => {
108
- const b = basename(f);
109
- if (b.endsWith(".test.ts")) return b.slice(0, -".test.ts".length);
110
- if (b.endsWith(".ts")) return b.slice(0, -".ts".length);
111
- return null;
112
- };
107
+ // A non-test source file never participates, `.ts` included: `types.ts` ×13
108
+ // and `index.ts` ×10 live in unrelated subtrees of the proving ground, and
109
+ // telling a shared module from a shared stock name would need a list of names.
110
+ // Docs and config never participate either, a test-shaped name included
111
+ // (`docs/test_plan.md`): matching their basenames produces confident nonsense,
112
+ // two PRs each touching their own README.md, or their own hooks.json, reported
113
+ // as sharing a "module". Measured in the proving ground: README.md ×8,
114
+ // SKILL.md ×6, mcp-snippet.json ×9, hooks.json ×5 across unrelated
115
+ // directories. Returning null for those drops them from the signal entirely
116
+ // rather than caveating them.
117
+ const moduleOf = (f) => (isDocs(f) || isConfig(f) ? null : testSubject(f) || null);
113
118
  const modulesOf = (fs) => fs.map(moduleOf).filter((m) => m !== null);
114
119
 
115
120
  // Repo root is excluded: every top-level file shares it, so it fires on PRs
@@ -143,7 +148,7 @@ const dirsOf = (fs) => fs.map(dirname).filter((d) => d !== ".");
143
148
  // with the verdict. An extension on neither list does not participate at all.
144
149
  //
145
150
  // Data side — an artifact whose meaning lives in prose somewhere else. A
146
- // `.ts` module's consumers are already found by `files`/`modules` above. `.md`
151
+ // `.ts` module's consumers are already found by `files` above. `.md`
147
152
  // is deliberately absent: a doc citing a doc is what `dirs` fires on, and
148
153
  // `SKILL.md` recurs 3× in this repo's 251 tracked files (measured), so it is
149
154
  // the ambiguous-basename shape `moduleOf` above already refuses to guess at.
@@ -386,13 +391,13 @@ if (signal === "dirs") {
386
391
  }
387
392
  if (signal === "modules") {
388
393
  // The hold rule this mechanises calls a module match a verdict, on a par with
389
- // a shared file. It is not one: `types.ts` ×13 and `index.ts` ×10 live in
390
- // unrelated subtrees of the proving ground, so two PRs can share a "module"
391
- // name and nothing else. Say so, because the caller's rule will not.
394
+ // a shared file. It is not one: two unrelated test files can share a name
395
+ // (a `test_utils.py` in each of two packages), so two PRs can share a
396
+ // "module" name and nothing else. Say so, because the caller's rule will not.
392
397
  console.error(
393
- `${NAME}: module-only hit — confirm before treating as a verdict. Common\n` +
394
- ` TypeScript basenames (types.ts, index.ts) recur across unrelated\n` +
395
- ` subtrees, so a shared name is not yet a shared module: ${modules.join(", ")}`,
398
+ `${NAME}: module-only hit — confirm before treating as a verdict. Unrelated\n` +
399
+ ` test files can share a name (test_utils.py in two packages), so a\n` +
400
+ ` shared name is not yet a shared module: ${modules.join(", ")}`,
396
401
  );
397
402
  }
398
403
  // Keyed on the count, not on `signal`, unlike the two notes above: a prose