mirror of
https://github.com/DeusData/codebase-memory-mcp.git
synced 2026-11-04 10:48:20 +00:00
64 lines
4.4 KiB
JavaScript
64 lines
4.4 KiB
JavaScript
import { test } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { WATCHED_NAMES } from '../../tools/lib/forbidden-names.mjs';
|
|
import { operationalClientReference } from '../../tools/lib/operational-client-reference.mjs';
|
|
|
|
const client = WATCHED_NAMES[0];
|
|
test('permits only operational client terms in the exact setup source/test files', () => {
|
|
const files = ['src/agents/AgentSetup.tsx', 'src/agents/AgentSetup.test.tsx',
|
|
'agents/hooks/atlas-trace.py', 'agents/hooks/test_atlas_trace.py'];
|
|
for (const file of files) for (const line of [
|
|
`${client} Code on macOS/Linux`, `--install-${client}`, `install_${client}(root)`,
|
|
`root / '.${client}'`, `.${client}/settings.local.json`,
|
|
]) assert.equal(operationalClientReference(file, line), true, `${file}: ${line}`);
|
|
assert.equal(operationalClientReference('src/App.tsx', `${client} Code`), false);
|
|
assert.equal(operationalClientReference('verification/proof.json', `.${client}/settings.local.json`), false);
|
|
assert.equal(operationalClientReference('src/agents/AgentSetup.tsx', client), false);
|
|
assert.equal(operationalClientReference('src/agents/AgentSetup.tsx', `${client} Code ${WATCHED_NAMES[1]}`), false);
|
|
assert.equal(operationalClientReference('README.md', `${client} Code`), false);
|
|
const instruction = `adds a PostToolUse entry to \`.${client}/settings.local.json\`, and copies the hook`;
|
|
assert.equal(operationalClientReference('README.md', instruction), true);
|
|
const installPaths = `\`.${client}/settings.local.json\` and \`.${client}/hooks/\`.`;
|
|
assert.equal(operationalClientReference('README.md', installPaths), true);
|
|
assert.equal(operationalClientReference('README.md', installPaths + ` written by ${client}`), false);
|
|
assert.equal(operationalClientReference('other/README.md', instruction), false);
|
|
assert.equal(operationalClientReference('README.md', instruction + `; written by ${client}`), false);
|
|
});
|
|
|
|
test('the configuration reference may name only the client configuration variable', () => {
|
|
const variable = `${client.toUpperCase()}_CONFIG_DIR`;
|
|
const file = 'src/settings/ConfigReference.tsx';
|
|
assert.equal(operationalClientReference(file, `['${variable} · CODEX_HOME · KIRO_HOME', 'Agent integration locations.'],`), true);
|
|
for (const line of [`${client} Code`, `.${client}/settings.json`, `--install-${client}`, `${variable} for ${client}`,
|
|
`${variable}; written by ${client}`, `${variable}_EXTRA`]) {
|
|
assert.equal(operationalClientReference(file, line), false, line);
|
|
}
|
|
assert.equal(operationalClientReference('src/settings/SettingsPanel.tsx', variable), false);
|
|
});
|
|
|
|
test('authorship claims stay forbidden even beside an otherwise valid protocol reference', () => {
|
|
for (const text of [`written by ${client}`, `Co-authored-by: ${client}`,
|
|
`generated with ${client}`, `${client} authored this`, `@${client}`]) {
|
|
assert.equal(operationalClientReference('src/agents/AgentSetup.tsx', `${text}; --install-${client}`), false);
|
|
}
|
|
});
|
|
|
|
test('local verification exemptions are limited to named configuration and command fields', () => {
|
|
for (const path of ['verification/pr-2068/final-agent-boundary-initial-unavailable.json',
|
|
'verification/pr-2068/final-agent-diagnosis-restart.json']) {
|
|
assert.equal(operationalClientReference(path, `"path": "/repo/.${client}/settings.local.json",`), true);
|
|
assert.equal(operationalClientReference(path, `"path": "/user/.${client}/settings.json",`), true);
|
|
const command = `python3 ~/Downloads/cbm-atlas-trace.py --install-${client} --root '/repo' --project 'p' --daemon-url 'http://127.0.0.1:9749'`;
|
|
assert.equal(operationalClientReference(path, `"command": ${JSON.stringify(command)},`), true);
|
|
assert.equal(operationalClientReference(path, `"message": "${client} Code"`), false);
|
|
assert.equal(operationalClientReference(path, `"path": "/repo/.${client}/unrelated.txt"`), false);
|
|
assert.equal(operationalClientReference(path, `"command": "written by ${client}; ${command}"`), false);
|
|
}
|
|
assert.equal(operationalClientReference('verification/unrelated.json', `"path": "/repo/.${client}/settings.json"`), false);
|
|
});
|
|
|
|
test('archived hook captures are not operational integration sources', () => {
|
|
assert.equal(operationalClientReference('verification/pr-2068/final-downloaded-hook.txt',
|
|
`def install_${client}(root):`), false);
|
|
});
|