Files
msd-core/tests/settings-integrations.test.cjs
Tom Boucher 87917131f2 refactor(#2790): consolidate 86 gsd-* skills to 59 — fold flags, delete dead skills (#2824)
* feat(#2790): consolidate 86 gsd-* skills to 59 — zero functional loss

Closes #2790

- `capture.md` — absorbs add-todo (default), note (--note), add-backlog
  (--backlog), plant-seed (--seed), check-todos (--list)
- `phase.md` — absorbs add-phase (default), insert-phase (--insert),
  remove-phase (--remove), edit-phase (--edit)
- `config.md` — absorbs settings-advanced (--advanced),
  settings-integrations (--integrations), set-profile (--profile);
  settings.md retained as-is
- `workspace.md` — absorbs new-workspace (--new), list-workspaces
  (--list), remove-workspace (--remove)

- `update.md` — adds --sync (absorbs sync-skills) and --reapply
  (absorbs reapply-patches)
- `sketch.md` — adds --wrap-up (absorbs sketch-wrap-up)
- `spike.md` — adds --wrap-up (absorbs spike-wrap-up)
- `map-codebase.md` — adds --fast (absorbs scan) and --query (absorbs
  intel)
- `code-review.md` — adds --fix (absorbs code-review-fix)
- `progress.md` — adds --next (absorbs next) and --do (absorbs do)

join-discord, research-phase, session-report, from-gsd2,
analyze-dependencies, list-phase-assumptions, plan-milestone-gaps

autonomous.md: updated Skill(skill="gsd:code-review-fix") →
Skill(skill="gsd:code-review", args="--fix --auto") to match
the consolidated skill name

- New: tests/enh-2790-skill-consolidation.test.cjs (48 tests)
- Updated: 14 existing test files redirected from deleted command paths
  to their consolidated equivalents
- docs/INVENTORY.md: Commands count 86→59, ghost rows removed, new
  consolidated rows added
- docs/INVENTORY-MANIFEST.json: regenerated to match filesystem

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs(#2790): add CHANGELOG entry for skill consolidation

* docs(#2790): update COMMANDS.md for 86→59 skill consolidation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(#2790): address CodeRabbit review findings

- CHANGELOG.md: add --next alongside --do in progress flag list
- config.md: remove trailing space from --profile code span (MD038)
- COMMANDS.md: add required descriptions to /gsd-phase examples;
  /gsd-phase without args errors, not interactive
- COMMANDS.md: add --next and --do to /gsd-progress flags table + examples
- test: convert content.includes('--reapply') to structural frontmatter
  parse; add allow-test-rule comment for workflow content assertions
- test: replace redundant existsSync duplicate with assertion that verifies
  the full consolidated flag surface (--sync | --reapply) in argument-hint

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(#2790): restore reapply-patches workflow and strengthen test assertions

- Create get-shit-done/workflows/reapply-patches.md: the #2790 consolidation
  deleted the 14K combined command+workflow file (reapply-patches.md) but
  update.md already referenced the workflow via execution_context_extended.
  Restoring it fixes a silent behavioral gap where --reapply had no workflow
  to load. Includes full three-way merge logic, hunk verification table
  (Step 4), and the Hunk Verification Gate (Step 5) that blocks cleanup
  until all user-added hunks are confirmed present in the merged output.

- Fix update.md: /gsd-reapply-patches → /gsd-update --reapply (stale ref)

- Fix reapply-verify-hunks.test.cjs: was checking existsSync(update.md) 8×;
  now points to the workflow file and asserts real behavioral content
  (Post-merge verification, Hunk presence check, Line-count check, backup
  reference, per-file tracking, structural ordering)

- Fix reapply-patches.test.cjs: replace content.includes() stubs with
  frontmatter-parsed argument-hint assertions; replace 4 existsSync(update.md)
  no-ops with real assertions against the workflow content

- Fix edit-phase.test.cjs: /gsd-edit-phase → /gsd-phase (COMMANDS.md now
  documents the consolidated command with --edit flag)

- Fix next-safety-gates.test.cjs: split OR predicates into independent
  assertions — --next in progress.md and --force in next.md workflow

- Fix workspace.test.cjs: add allow-test-rule comment for routing content
  checks (command routing text IS the deployed behavioral contract)

- Fix bug-2439 test: strengthen pre-flight assertion to verify gsd-sdk is
  referenced (not just --profile)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: address CodeRabbit review findings (CR round 2)

- INVENTORY.md: update sync-skills.md row to reference /gsd-update --sync
  instead of stale /gsd-sync-skills (absorbed in #2790)

- enh-2380-sync-skills.test.cjs: align INVENTORY.md assertion with the
  corrected reference; was asserting the old /gsd-sync-skills name while the
  manifest test correctly asserted /gsd-update, creating conflicting expectations
  in the same suite

- reapply-verify-hunks.test.cjs: add explicit notEqual(-1) assertions for all
  three anchors before the ordering check so a missing anchor produces a clear
  failure instead of a false positive (writeIdx=-1 < verifyIdx=5 is true)

- bug-2439-set-profile-gsd-sdk-preflight.test.cjs: defer fs.readFileSync until
  after the existence assertion; eager describe-level read caused the suite to
  crash before the existence test could run, making it effectively dead code

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(#2790): address CR — INVENTORY routing + reapply test contract wording

Two unresolved CodeRabbit findings (Major):

- docs/INVENTORY.md: workflow-file table still pointed at obsolete
  /gsd-do, /gsd-next, /gsd-note, /gsd-add-todo, /gsd-add-backlog,
  /gsd-check-todos, /gsd-plant-seed slash commands. Re-route to the
  consolidated /gsd-progress (--next, --do) and /gsd-capture (--note,
  --backlog, --seed, --list) so the inventory is internally consistent.

- tests/reapply-verify-hunks.test.cjs: 'verification tracks per-file
  status' asserted on phrasing that doesn't appear in reapply-patches.md
  (the 'per-file' substring only matched accidentally via 'sequential
  integer per file'). Switch to the actual contract text — Hunk
  Verification Table, one row per hunk per file, verified column.

* test(#2790): update CR-INTEGRATION tests for consolidated --fix invocation

After the merge of main (which carries #2843's hyphen-form fix), the
consolidation in this branch absorbs gsd-code-review-fix into gsd-code-review
as the --fix flag. Update the two CR-INTEGRATION tests that previously
asserted on the standalone gsd-code-review-fix skill name to instead assert
on a gsd-code-review invocation carrying --fix in its arg tokens.

Tests still parse Skill() invocations structurally; only the asserted
skill-name + arg-token shape changed.

* test(#2790): scope success_criteria check to the <success_criteria> block

CodeRabbit nitpick: 'success criteria includes verification' did a
whole-file substring check, which can false-pass if the phrase appears
elsewhere in the document. Extract the <success_criteria>...</success_criteria>
block first via extractTagBlock() and assert against that scope only.

* fix(#2790): post-rebase reconciliation with main

- INVENTORY.md/JSON: add reapply-patches workflow row + bump count to 85
- autonomous.md: switch consolidated --fix invocation to hyphen Skill name
- analyze-dependencies test: assert COMMANDS.md does NOT document the
  consolidated-away /gsd-analyze-dependencies entry (was: bare .includes())

* fix(#2790): address remaining CR findings — strengthen contract tests

Doc-fixes:
- INVENTORY.md: route transition.md & edit-phase.md rows to consolidated
  /gsd-progress --next and /gsd-phase --edit (was: deleted /gsd-next, /gsd-edit-phase)
- config.md --profile branch: document #2439 pre-flight `command -v gsd-sdk`
  guard + install hint BEFORE the gsd-sdk invocation (closes opaque
  "command not found: gsd-sdk" regression path)

Test discipline (no-source-grep contract):
- bug-2439: replace bare `content.includes('gsd-sdk')` with structured
  parse of <context> block + --profile branch; assert pre-flight token,
  install hint, #2439 citation, and ordering vs gsd-sdk invocation
- edit-phase: parse INVENTORY.md edit-phase.md row's "Invoked by" column
  and assert `/gsd-phase --edit` (not the deleted /gsd-edit-phase)
- next-safety-gates: tighten `--next` documentation contract — require
  --next AND --force AND completeness routing (was OR-based, passed when
  only --next present)
- reapply-patches: parse argument-hint flag list structurally; scan ALL
  <execution_context*> blocks for the @-include of reapply-patches.md;
  parse Hunk Verification Table header columns directly; locate Step 5
  via heading parsing then assert (i) table reference, (ii) verified=no
  gate, (iii) STOP/halt directive, (iv) explicit absent-table halt path
- workspace: parse frontmatter, tokenize argument-hint across multiple
  bracketed segments, parse @-include targets from <execution_context>
  rather than substring-matching the file body

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-30 00:43:47 -04:00

390 lines
18 KiB
JavaScript

'use strict';
/**
* #2529 — /gsd-settings-integrations: configure third-party search and review integrations.
*
* Covers:
* - Artifacts exist (command, workflow, skill stub) with correct frontmatter
* - Workflow references the four search API key fields
* - Workflow exposes review.models.{claude,codex,gemini,opencode} routing
* - Workflow exposes agent_skills.<agent-type> injection input
* - Masking convention (****last4) is documented in the workflow and the displayed
* confirmation pattern does not echo plaintext
* - config-set round-trips all integration keys through VALID_CONFIG_KEYS + dynamic patterns
* - Config merge preserves unrelated keys
* - /gsd:settings confirmation output mentions /gsd:settings-integrations
* - Negative: invalid agent-type name (path traversal / special char) is rejected
* - Negative: malformed review.models key is rejected
* - Logging: plaintext API keys do not appear in any file written under .planning/
* by the config-set flow other than config.json itself
*/
const { describe, test } = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const { createTempProject, cleanup, runGsdTools } = require('./helpers.cjs');
const {
VALID_CONFIG_KEYS,
isValidConfigKey,
} = require('../get-shit-done/bin/lib/config-schema.cjs');
const REPO_ROOT = path.join(__dirname, '..');
// #2790: settings-integrations.md was consolidated into config.md as the --integrations flag.
const COMMAND_PATH = path.join(REPO_ROOT, 'commands', 'gsd', 'config.md');
const WORKFLOW_PATH = path.join(REPO_ROOT, 'get-shit-done', 'workflows', 'settings-integrations.md');
const SKILL_PATH = path.join(REPO_ROOT, '.claude', 'skills', 'gsd-settings-integrations.md');
const SETTINGS_WORKFLOW_PATH = path.join(REPO_ROOT, 'get-shit-done', 'workflows', 'settings.md');
function readIfExists(p) {
try { return fs.readFileSync(p, 'utf-8'); } catch { return null; }
}
// ─── Artifacts ───────────────────────────────────────────────────────────────
describe('#2529 artifacts', () => {
test('consolidated config.md command exists (#2790: settings-integrations absorbed)', () => {
// #2790: settings-integrations.md was absorbed into config.md as the --integrations flag.
assert.ok(fs.existsSync(COMMAND_PATH), `missing ${COMMAND_PATH}`);
});
test('config.md frontmatter declares name gsd:config and routes to --integrations', () => {
const src = fs.readFileSync(COMMAND_PATH, 'utf-8');
// #2790: consolidated command uses gsd:config name
assert.match(src, /name:\s*gsd:config/);
assert.match(src, /description:\s*.+/);
assert.match(src, /allowed-tools:/);
assert.match(src, /AskUserQuestion/);
});
test('workflow exists at get-shit-done/workflows/settings-integrations.md', () => {
assert.ok(fs.existsSync(WORKFLOW_PATH), `missing ${WORKFLOW_PATH}`);
});
test('skill stub or canonical command surface ships (#2790: via config.md --integrations)', () => {
// #2790: The command surface is now config.md + settings-integrations.md workflow.
const hasStub = fs.existsSync(SKILL_PATH);
const hasCanonical =
fs.existsSync(COMMAND_PATH) && fs.existsSync(WORKFLOW_PATH);
assert.ok(
hasStub || hasCanonical,
`neither ${SKILL_PATH} nor the canonical command/workflow pair exists`
);
});
test('config.md routes --integrations to the settings-integrations workflow', () => {
const src = fs.readFileSync(COMMAND_PATH, 'utf-8');
assert.ok(
src.includes('workflows/settings-integrations.md') || src.includes('--integrations'),
'config.md must reference settings-integrations workflow or --integrations flag'
);
});
});
// ─── Content: search API keys ────────────────────────────────────────────────
describe('#2529 workflow — search integrations', () => {
test('workflow references all four search fields', () => {
const src = fs.readFileSync(WORKFLOW_PATH, 'utf-8');
for (const key of ['brave_search', 'firecrawl', 'exa_search', 'search_gitignored']) {
assert.ok(src.includes(key), `workflow must reference ${key}`);
}
});
});
// ─── Content: review.models routing ──────────────────────────────────────────
describe('#2529 workflow — review.models routing', () => {
test('workflow references all four reviewer CLIs', () => {
const src = fs.readFileSync(WORKFLOW_PATH, 'utf-8');
for (const cli of ['claude', 'codex', 'gemini', 'opencode']) {
assert.ok(
src.includes(`review.models.${cli}`),
`workflow must reference review.models.${cli}`
);
}
});
test('review.models.<cli> matches the dynamic pattern validator', () => {
for (const cli of ['claude', 'codex', 'gemini', 'opencode']) {
assert.ok(
isValidConfigKey(`review.models.${cli}`),
`review.models.${cli} must pass isValidConfigKey`
);
}
});
});
// ─── Content: agent_skills.<agent-type> injection ────────────────────────────
describe('#2529 workflow — agent_skills injection', () => {
test('workflow references agent_skills.<agent-type> injection concept', () => {
const src = fs.readFileSync(WORKFLOW_PATH, 'utf-8');
assert.ok(src.includes('agent_skills'), 'workflow must reference agent_skills');
assert.ok(
/agent_skills\.<[^>]+>|agent_skills\.\w+/.test(src),
'workflow must reference agent_skills.<agent-type> or concrete agent_skills.<slug>'
);
});
test('agent_skills.<valid-slug> passes validator', () => {
assert.ok(isValidConfigKey('agent_skills.gsd-executor'));
assert.ok(isValidConfigKey('agent_skills.gsd-planner'));
assert.ok(isValidConfigKey('agent_skills.my_custom_agent'));
});
});
// ─── Content: masking ────────────────────────────────────────────────────────
describe('#2529 workflow — API key masking', () => {
test('workflow documents the **** masking convention', () => {
const src = fs.readFileSync(WORKFLOW_PATH, 'utf-8');
// Must reference the **** mask pattern
assert.ok(src.includes('****'), 'workflow must document the **** mask pattern');
// Must explicitly state that plaintext is not displayed
assert.ok(
/never\s+(echo|display|log|show)[^.]*plaintext|plaintext[^.]*never\s+(echo|display|log|shown)|plaintext[^.]*not\s+(echoed|displayed|logged|shown)|not\s+(echoed|displayed|logged|shown)[^.]*plaintext/i.test(src),
'workflow must explicitly forbid displaying plaintext API keys'
);
});
test('workflow shows masked-value confirmation pattern, not raw secrets', () => {
const src = fs.readFileSync(WORKFLOW_PATH, 'utf-8');
// The confirmation table in the workflow must describe the masked display
assert.ok(
/\*\*\*\*\w{0,4}|\*\*\*\* *already set|\*\*\*\*<last.?4>/i.test(src),
'workflow must describe a masked confirmation pattern (e.g. ****last4 or **** already set)'
);
});
test('workflow includes a Leave / Replace / Clear flow for already-set keys', () => {
const src = fs.readFileSync(WORKFLOW_PATH, 'utf-8');
assert.ok(/Leave/i.test(src) && /Replace/i.test(src) && /Clear/i.test(src),
'workflow must offer Leave / Replace / Clear when a key is already set');
});
});
// ─── config-set round-trip ───────────────────────────────────────────────────
describe('#2529 config-set round-trip', () => {
test('brave_search, firecrawl, exa_search, search_gitignored are valid keys', () => {
for (const k of ['brave_search', 'firecrawl', 'exa_search', 'search_gitignored']) {
assert.ok(VALID_CONFIG_KEYS.has(k), `${k} must be in VALID_CONFIG_KEYS`);
}
});
test('config-set writes brave_search, firecrawl, exa_search values to config.json', (t) => {
const tmp = createTempProject();
t.after(() => cleanup(tmp));
runGsdTools(['config-ensure-section'], tmp);
const r1 = runGsdTools(['config-set', 'brave_search', 'BSKY-111111112222'], tmp);
assert.ok(r1.success, `brave_search set failed: ${r1.error}`);
const r2 = runGsdTools(['config-set', 'firecrawl', 'fc-aaaaaaaabbbbcccc'], tmp);
assert.ok(r2.success, `firecrawl set failed: ${r2.error}`);
const r3 = runGsdTools(['config-set', 'exa_search', 'ex-000011112222dddd'], tmp);
assert.ok(r3.success, `exa_search set failed: ${r3.error}`);
const r4 = runGsdTools(['config-set', 'search_gitignored', 'true'], tmp);
assert.ok(r4.success, `search_gitignored set failed: ${r4.error}`);
const cfg = JSON.parse(fs.readFileSync(path.join(tmp, '.planning', 'config.json'), 'utf-8'));
assert.strictEqual(cfg.brave_search, 'BSKY-111111112222');
assert.strictEqual(cfg.firecrawl, 'fc-aaaaaaaabbbbcccc');
assert.strictEqual(cfg.exa_search, 'ex-000011112222dddd');
assert.ok(
cfg.search_gitignored === true || cfg.search_gitignored === 'true',
`search_gitignored round-trip mismatch: got ${JSON.stringify(cfg.search_gitignored)}`
);
});
test('config-set round-trips review.models.<cli>', (t) => {
const tmp = createTempProject();
t.after(() => cleanup(tmp));
runGsdTools(['config-ensure-section'], tmp);
const r = runGsdTools(
['config-set', 'review.models.codex', 'codex exec --model gpt-5'],
tmp
);
assert.ok(r.success, `review.models.codex set failed: ${r.error}`);
const cfg = JSON.parse(fs.readFileSync(path.join(tmp, '.planning', 'config.json'), 'utf-8'));
assert.strictEqual(cfg.review?.models?.codex, 'codex exec --model gpt-5');
});
test('config-set round-trips agent_skills.<agent-type>', (t) => {
const tmp = createTempProject();
t.after(() => cleanup(tmp));
runGsdTools(['config-ensure-section'], tmp);
const r = runGsdTools(
['config-set', 'agent_skills.gsd-executor', 'skill-a,skill-b'],
tmp
);
assert.ok(r.success, `agent_skills.gsd-executor set failed: ${r.error}`);
const cfg = JSON.parse(fs.readFileSync(path.join(tmp, '.planning', 'config.json'), 'utf-8'));
// Accept either array or string — validator accepts both shapes today.
const v = cfg.agent_skills?.['gsd-executor'];
assert.ok(v === 'skill-a,skill-b' || (Array.isArray(v) && v.join(',') === 'skill-a,skill-b'),
`expected agent_skills.gsd-executor to contain both skills, got ${JSON.stringify(v)}`);
});
});
// ─── Config merge preserves unrelated keys ───────────────────────────────────
describe('#2529 config merge safety', () => {
test('setting brave_search preserves unrelated workflow.research key', (t) => {
const tmp = createTempProject();
t.after(() => cleanup(tmp));
runGsdTools(['config-ensure-section'], tmp);
runGsdTools(['config-set', 'workflow.research', 'false'], tmp);
const r = runGsdTools(['config-set', 'brave_search', 'BSKY-preserve-me-9999'], tmp);
assert.ok(r.success, `set failed: ${r.error}`);
const cfg = JSON.parse(fs.readFileSync(path.join(tmp, '.planning', 'config.json'), 'utf-8'));
assert.strictEqual(cfg.workflow?.research, false, 'unrelated workflow.research must be preserved');
assert.strictEqual(cfg.brave_search, 'BSKY-preserve-me-9999');
});
test('setting agent_skills.gsd-executor preserves unrelated review.models.codex', (t) => {
const tmp = createTempProject();
t.after(() => cleanup(tmp));
runGsdTools(['config-ensure-section'], tmp);
runGsdTools(['config-set', 'review.models.codex', 'codex exec'], tmp);
const r = runGsdTools(['config-set', 'agent_skills.gsd-planner', 'a,b'], tmp);
assert.ok(r.success, `set failed: ${r.error}`);
const cfg = JSON.parse(fs.readFileSync(path.join(tmp, '.planning', 'config.json'), 'utf-8'));
assert.strictEqual(cfg.review?.models?.codex, 'codex exec', 'unrelated review.models.codex must be preserved');
assert.ok(cfg.agent_skills?.['gsd-planner'], 'agent_skills.gsd-planner must be set');
});
});
// ─── /gsd-settings mentions /gsd-settings-integrations ──────────────────────
describe('#2529 /gsd-settings mentions new command', () => {
test('settings workflow mentions /gsd-settings-integrations in its confirmation output', () => {
const src = fs.readFileSync(SETTINGS_WORKFLOW_PATH, 'utf-8');
assert.ok(
src.includes('/gsd-settings-integrations'),
'settings.md must mention /gsd-settings-integrations as a follow-up'
);
});
});
// ─── Negative scenarios ──────────────────────────────────────────────────────
describe('#2529 negative — invalid inputs rejected', () => {
test('invalid agent-type with path separators is rejected by validator', () => {
assert.ok(!isValidConfigKey('agent_skills.../etc/passwd'),
'agent_skills.../etc/passwd must be rejected');
assert.ok(!isValidConfigKey('agent_skills./evil'),
'agent_skills./evil must be rejected');
assert.ok(!isValidConfigKey('agent_skills.a b c'),
'agent_skills with spaces must be rejected');
assert.ok(!isValidConfigKey('agent_skills.$(whoami)'),
'agent_skills with shell metacharacters must be rejected');
});
test('config-set rejects agent_skills with path traversal', (t) => {
const tmp = createTempProject();
t.after(() => cleanup(tmp));
runGsdTools(['config-ensure-section'], tmp);
const r = runGsdTools(['config-set', 'agent_skills.../etc/passwd', 'x'], tmp);
assert.ok(!r.success, 'config-set must reject path-traversal agent-type slug');
});
test('malformed review.models entry (empty cli) is rejected', () => {
assert.ok(!isValidConfigKey('review.models.'),
'review.models. (empty) must be rejected');
assert.ok(!isValidConfigKey('review.models'),
'review.models (no cli) must be rejected');
assert.ok(!isValidConfigKey('review.models.claude/../../x'),
'review.models with path separators must be rejected');
});
});
// ─── Security: plaintext never leaks to disk outside config.json ─────────────
describe('#2529 security — plaintext containment', () => {
test('after setting brave_search, plaintext appears only in config.json', (t) => {
const tmp = createTempProject();
t.after(() => cleanup(tmp));
runGsdTools(['config-ensure-section'], tmp);
// Build sentinel via concat so secret-scanners do not flag the literal.
const marker = ['MASKCHECK', '9f3a7b2c'].join('-');
const r = runGsdTools(['config-set', 'brave_search', marker], tmp);
assert.ok(r.success, `set failed: ${r.error}`);
const planning = path.join(tmp, '.planning');
const hits = [];
function walk(dir) {
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
const full = path.join(dir, entry.name);
if (entry.isDirectory()) { walk(full); continue; }
if (!entry.isFile()) continue;
let buf;
try { buf = fs.readFileSync(full, 'utf-8'); } catch { continue; }
if (buf.includes(marker)) hits.push(full);
}
}
walk(planning);
assert.deepStrictEqual(
hits.map(h => path.basename(h)).sort(),
['config.json'],
`plaintext marker leaked outside config.json: found in ${hits.join(', ')}`
);
});
test('config-set does not echo plaintext secret on stdout/stderr', (t) => {
const tmp = createTempProject();
t.after(() => cleanup(tmp));
runGsdTools(['config-ensure-section'], tmp);
const marker = ['ECHOCHECK', '77aa33bb'].join('-');
const r = runGsdTools(['config-set', 'brave_search', marker], tmp);
assert.ok(r.success, `set failed: ${r.error}`);
const combined = `${r.output || ''}\n${r.error || ''}`;
assert.ok(
!combined.includes(marker),
`config-set output must not echo the plaintext marker. Got:\n${combined}`
);
});
test('config-get masks secrets and never echoes plaintext for brave_search/firecrawl/exa_search', (t) => {
const tmp = createTempProject();
t.after(() => cleanup(tmp));
runGsdTools(['config-ensure-section'], tmp);
const cases = [
{ key: 'brave_search', marker: ['GETMASK', 'brave', 'aaaa1111'].join('-') },
{ key: 'firecrawl', marker: ['GETMASK', 'fc', 'bbbb2222'].join('-') },
{ key: 'exa_search', marker: ['GETMASK', 'ex', 'cccc3333'].join('-') },
];
for (const { key, marker } of cases) {
const set = runGsdTools(['config-set', key, marker], tmp);
assert.ok(set.success, `${key} set failed: ${set.error}`);
const get = runGsdTools(['config-get', key], tmp);
assert.ok(get.success, `${key} get failed: ${get.error}`);
const combined = `${get.output || ''}\n${get.error || ''}`;
assert.ok(
!combined.includes(marker),
`config-get must not echo plaintext for ${key}. Got:\n${combined}`
);
// Must contain the masked tail (last 4 of marker)
const expectedMask = '****' + marker.slice(-4);
assert.ok(
combined.includes(expectedMask),
`config-get must show masked form (${expectedMask}) for ${key}. Got:\n${combined}`
);
}
});
});