Files
msd-core/tests/helpers/agent-roster.cjs
Jakub Zych a9a7a328e6 refactor: hard-fork GSD -> MSD (Make Software Done)
Mechanical rename produced by scripts/msd-rename.cjs: gsd/Gsd/GSD -> msd/Msd/MSD
across contents and paths, upstream package/repo coordinates -> @golem15/msd-core
and golem15com/msd-core. Deep links into upstream history, sibling upstream
packages, the GSD-2 import feature, CHANGELOG.md and .changeset/ are kept as-is.

Hand edits on top: MSD block-letter banner and logos, LICENSE copyright line,
package/plugin identity, regenerated lockfile, install-tree fixtures, derived
registries and benchmark baseline; migration checksum baseline re-locked
(MSD keeps its own install state, so no install had applied the old sums);
sort-order and regex-escaped expectations in tests adjusted.
2026-10-06 01:47:40 +02:00

51 lines
2.0 KiB
JavaScript

'use strict';
/**
* Shared helper for the canonical shipped-agent roster.
*
* Several tests derive "the set of agents we ship" from the source `agents/`
* directory via `fs.readdirSync(...).filter(/^msd-.*\.md$/)`. This consolidates
* that hand-duplicated logic into one canonical SOURCE-roster derivation.
*
* NOTE: This returns the SOURCE roster (basenames without `.md`, sorted). Sites
* with different semantics — installed-destination dirs, absolute-path returns,
* or `.toml`-inclusive Codex rosters — must NOT use this helper.
*
* NOTE (#4407): `agents/*.compact.md` variant siblings are deliberately EXCLUDED.
* A compact variant is not a new agent — it is an alternate rendition of an
* existing roster entry, served by the `#2454` fallback in `cmdAgentSkills`
* (`src/init.cts`) when `workflow.compact_content` is on. Every roster-identity
* check this helper backs (frontmatter/tools invariants, "every shipped agent"
* install assertions, etc.) is about the SET of distinct agents MSD ships, which
* a variant does not add to.
*/
const fs = require('node:fs');
const path = require('node:path');
// Canonical source agents directory: <repo-root>/agents, relative to this
// helper at tests/helpers/. Matches the path the consolidated call sites used.
const AGENTS_DIR = path.join(__dirname, '..', '..', 'agents');
/**
* List shipped agent basenames (without the `.md` extension), sorted.
*
* @param {string} [agentsDir] Override for the source agents directory.
* Defaults to the canonical `<repo-root>/agents`.
* @returns {string[]} Sorted `msd-*` basenames with `.md` stripped.
*/
function listAgentFiles(agentsDir = AGENTS_DIR) {
return fs
.readdirSync(agentsDir)
.filter((f) => /^msd-.*\.md$/.test(f) && !f.endsWith('.compact.md'))
.map((f) => f.replace(/\.md$/, ''))
.sort();
}
module.exports = {
// AGENTS_DIR is exported (not yet consumed by a call site) so future tests that
// need the canonical source agents path can reuse it instead of rediscovering it.
AGENTS_DIR,
listAgentFiles,
};