Skip to content

Commit 138d1ed

Browse files
cliffhallclaude
andcommitted
Map npm's workspace spelling either way; dispatch a sweep rather than file a duplicate; reword the overview's opening
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: cliffhall <cliff@futurescale.com>
1 parent 2b728ec commit 138d1ed

4 files changed

Lines changed: 82 additions & 15 deletions

File tree

‎.claude/skills/issue-triage/SKILL.md‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,11 @@ the policy's point.
303303
PRs are switched off, and three scheduled sweeps file issues instead. One that
304304
appears anyway means a config came back or the `automated-security-fixes`
305305
setting was switched on again. Close it with a pointer to the sweep issue that
306-
covers the same bump (filing one with `issue-create` if none does), and raise
307-
the cause with a maintainer.
306+
covers the same bump, and raise the cause with a maintainer. If no sweep issue
307+
covers it yet, do **not** file one with `issue-create`: the sweeps trust only
308+
issues the automation wrote, so the next run would file a duplicate beside it.
309+
Dispatch the sweep instead (`gh workflow run dependabot-alerts.yml`, or
310+
`dependency-refresh.yml` for a version bump) and point at the issue it files.
308311

309312
Not touched by triage:
310313

‎docs/ai-software-factory.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
This document is the overview of how work gets done in this repository: the
44
rules, the procedures, the gates and the scheduled automation that let a
55
coding agent, driven by a maintainer, take an approved issue to a merged PR. It
6-
is written for someone who was not part of building it. It describes; the
7-
rules themselves live in [`AGENTS.md`](../AGENTS.md) and the procedures in
8-
[`.claude/skills/`](../.claude/skills), and where this page and those disagree,
9-
they win.
6+
is written for someone who was not part of building it. It explains rather
7+
than rules: the rules themselves live in [`AGENTS.md`](../AGENTS.md) and the
8+
procedures in [`.claude/skills/`](../.claude/skills), and where this page and
9+
those disagree, they win.
1010

1111
The model was adapted from the
1212
[MCP Inspector](https://github.com/modelcontextprotocol/inspector)'s, which

‎scripts/dependency-refresh.mjs‎

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,22 @@ export const parseMarker = (body) =>
7373
(body ?? "").startsWith(ISSUE_MARKER) ? true : null;
7474

7575
/**
76-
* The manifest a `dependent` from `npm outdated --workspaces` names. npm
77-
* reports a workspace by its directory name and the root by the checkout's
78-
* directory name, which differs between machines, so anything that is not a
79-
* server directory is the root.
76+
* The manifest a `dependent` from `npm outdated --workspaces` names.
77+
*
78+
* npm reports a workspace by its arborist node name, which for this repo's
79+
* workspaces is the directory (`everything`), but a package name
80+
* (`@modelcontextprotocol/server-everything`) is accepted too, so a change in
81+
* how npm spells it cannot fold every workspace into `root` silently. The
82+
* root is reported by the checkout's directory name, which differs between
83+
* machines, so anything that matches no workspace is the root.
8084
*
8185
* @param {string | undefined} dependent
86+
* @param {Record<string, string>} [workspaceNames] package name -> `src/<dir>`
8287
* @returns {string}
8388
*/
84-
export function installLabel(dependent) {
85-
return SERVERS.includes(dependent ?? "") ? `src/${dependent}` : "root";
89+
export function installLabel(dependent, workspaceNames = {}) {
90+
if (SERVERS.includes(dependent ?? "")) return `src/${dependent}`;
91+
return workspaceNames[dependent ?? ""] ?? "root";
8692
}
8793

8894
/**
@@ -91,16 +97,17 @@ export function installLabel(dependent) {
9197
* comes back as an array, one entry per dependent.
9298
*
9399
* @param {string} json raw stdout (may be `""` or `"{}"`)
100+
* @param {Record<string, string>} [workspaceNames] package name -> `src/<dir>`
94101
* @returns {Map<string, Array<{name: string, current: string, wanted: string, latest: string}>>}
95102
* keyed by `installLabel`, each list sorted by name
96103
*/
97-
export function parseNpmOutdated(json) {
104+
export function parseNpmOutdated(json, workspaceNames = {}) {
98105
const byInstall = new Map();
99106
const trimmed = json.trim();
100107
if (trimmed === "") return byInstall;
101108
for (const [name, info] of Object.entries(JSON.parse(trimmed))) {
102109
for (const entry of Array.isArray(info) ? info : [info]) {
103-
const label = installLabel(entry.dependent);
110+
const label = installLabel(entry.dependent, workspaceNames);
104111
const rows = byInstall.get(label) ?? [];
105112
// One manifest can reach a package twice (a dependency and a
106113
// devDependency); report it once.
@@ -429,6 +436,23 @@ export function buildClearedBody(isoDate) {
429436
].join("\n");
430437
}
431438

439+
/**
440+
* Each workspace's package name, mapped to its directory.
441+
*
442+
* @param {string} root
443+
* @returns {Record<string, string>}
444+
*/
445+
export function workspacePackageNames(root) {
446+
const names = {};
447+
for (const server of SERVERS) {
448+
const manifest = path.join(root, "src", server, "package.json");
449+
if (!existsSync(manifest)) continue;
450+
const { name } = JSON.parse(readFileSync(manifest, "utf8"));
451+
if (name) names[name] = `src/${server}`;
452+
}
453+
return names;
454+
}
455+
432456
function runOutdated(root, spawn) {
433457
const result = spawn(
434458
"npm",
@@ -546,7 +570,10 @@ export function main({
546570
if (!repo) throw new Error("repo not specified (GITHUB_REPOSITORY unset)");
547571
const writer = issueWriter({ repo, spawn, dryRun, sweep: SWEEP, log });
548572

549-
const npmByInstall = parseNpmOutdated(runOutdated(root, spawn));
573+
const npmByInstall = parseNpmOutdated(
574+
runOutdated(root, spawn),
575+
workspacePackageNames(root),
576+
);
550577
const npm = ["root", ...SERVERS.map((s) => `src/${s}`)]
551578
.filter((label) => npmByInstall.has(label))
552579
.map((label) => ({ label, packages: npmByInstall.get(label) }));

‎scripts/dependency-refresh.test.mjs‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
staleActions,
2727
unrankedPins,
2828
uvRows,
29+
workspacePackageNames,
2930
} from "./dependency-refresh.mjs";
3031

3132
const SHA = "d23441a48e516b6c34aea4fa41551a30e30af803";
@@ -41,6 +42,42 @@ test("installLabel maps npm's dependent onto a manifest", () => {
4142
assert.equal(installLabel("servers"), "root");
4243
assert.equal(installLabel("mcp-servers-4874"), "root");
4344
assert.equal(installLabel(undefined), "root");
45+
// A package-name spelling is mapped too, rather than folded into root.
46+
const names = {
47+
"@modelcontextprotocol/server-sequential-thinking":
48+
"src/sequentialthinking",
49+
};
50+
assert.equal(
51+
installLabel("@modelcontextprotocol/server-sequential-thinking", names),
52+
"src/sequentialthinking",
53+
);
54+
const byInstall = parseNpmOutdated(
55+
JSON.stringify({
56+
chalk: {
57+
current: "5.6.2",
58+
wanted: "5.6.2",
59+
latest: "6.0.1",
60+
dependent: "@modelcontextprotocol/server-sequential-thinking",
61+
},
62+
}),
63+
names,
64+
);
65+
assert.deepEqual([...byInstall.keys()], ["src/sequentialthinking"]);
66+
});
67+
68+
test("workspacePackageNames reads each workspace manifest", (t) => {
69+
const root = mkdtempSync(path.join(tmpdir(), "dependency-refresh-ws-"));
70+
t.after(() => rmSync(root, { recursive: true, force: true }));
71+
mkdirSync(path.join(root, "src/memory"), { recursive: true });
72+
writeFileSync(
73+
path.join(root, "src/memory/package.json"),
74+
JSON.stringify({ name: "@modelcontextprotocol/server-memory" }),
75+
);
76+
mkdirSync(path.join(root, "src/time"), { recursive: true });
77+
writeFileSync(path.join(root, "src/time/package.json"), "{}");
78+
assert.deepEqual(workspacePackageNames(root), {
79+
"@modelcontextprotocol/server-memory": "src/memory",
80+
});
4481
});
4582

4683
test("parseNpmOutdated splits by dependent and dedupes per manifest", () => {

0 commit comments

Comments
 (0)