mirror of
https://github.com/affaan-m/ECC.git
synced 2026-10-20 23:11:46 +02:00
* test(lib): cover feedback-links routes and payload Pins the three public issue routes to the ECC repository and checks each template name actually exists under .github/ISSUE_TEMPLATE. Also locks the ecc.feedback.v1 payload shape, the no-diagnostics-upload promise, and that every call returns fresh copies so a caller cannot alter the frozen route table. * test(lib): cover cursor-agent-names prefixing and path handling Pins the ecc- prefix rule the Cursor install applies to agent files: idempotent, lowercase-prefix only, empty names pass through. Covers the relative path variant across backslash, repeated, and trailing separators, and that a leading separator cannot re-root the destination under the target agents directory. * test(lib): cover agent-tool-map Pi mapping and authority invariant Pins the Claude to Pi tool table: six core tools, every target a real Pi built-in, and read-only tools never escalating to bash, edit, or write. Covers the unsupported path for MCP, web, unknown, empty, and non-string names, and that prototype member names like constructor are not treated as table hits. * test(lib): cover compute-sponsor URL and passive copy Pins the compute URL to the bare https route with no path, query, or credentials, and that the sponsor copy links it exactly once and nowhere else. Locks the wording that keeps the link passive, keeps the ecc ito find bridge opt-in and non-reserving, and does not claim managed inference is live. The existing surface test only reads docs and CLI output, so the module itself had no direct test. * test(lib): cover invocation-environment precedence and isolation Pins the three branches every install path relies on: an explicit env is copied and wins, a scoped homeDir yields an empty environment so ambient variables cannot leak into a contained install, and anything else snapshots process.env. Also checks the copy is shallow, own-keys only, and never writes back.
81 lines
3.9 KiB
JavaScript
81 lines
3.9 KiB
JavaScript
'use strict';
|
|
|
|
const test = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const path = require('path');
|
|
|
|
const { toCursorAgentFileName, toCursorAgentRelativePath } = require('../../scripts/lib/cursor-agent-names');
|
|
|
|
test('a bare file name gets the ecc- prefix', () => {
|
|
assert.equal(toCursorAgentFileName('planner.md'), 'ecc-planner.md');
|
|
assert.equal(toCursorAgentFileName('code-reviewer.md'), 'ecc-code-reviewer.md');
|
|
});
|
|
|
|
test('an already prefixed name is left alone, so the transform is idempotent', () => {
|
|
assert.equal(toCursorAgentFileName('ecc-planner.md'), 'ecc-planner.md');
|
|
assert.equal(toCursorAgentFileName(toCursorAgentFileName('planner.md')), 'ecc-planner.md');
|
|
});
|
|
|
|
test('empty and missing names pass through unchanged', () => {
|
|
assert.equal(toCursorAgentFileName(''), '');
|
|
assert.equal(toCursorAgentFileName(undefined), undefined);
|
|
assert.equal(toCursorAgentFileName(null), null);
|
|
});
|
|
|
|
test('only a leading, lowercase ecc- counts as the prefix', () => {
|
|
assert.equal(toCursorAgentFileName('my-ecc-agent.md'), 'ecc-my-ecc-agent.md');
|
|
assert.equal(toCursorAgentFileName('ECC-planner.md'), 'ecc-ECC-planner.md');
|
|
assert.equal(toCursorAgentFileName('ecc.md'), 'ecc-ecc.md');
|
|
assert.equal(toCursorAgentFileName('ecc_planner.md'), 'ecc-ecc_planner.md');
|
|
});
|
|
|
|
test('a relative path keeps its directories and renames only the last segment', () => {
|
|
assert.equal(toCursorAgentRelativePath('review/planner.md'), path.join('review', 'ecc-planner.md'));
|
|
assert.equal(toCursorAgentRelativePath('a/b/c.md'), path.join('a', 'b', 'ecc-c.md'));
|
|
assert.equal(toCursorAgentRelativePath('ecc-review/planner.md'), path.join('ecc-review', 'ecc-planner.md'));
|
|
});
|
|
|
|
test('a path without directories behaves like a bare file name', () => {
|
|
assert.equal(toCursorAgentRelativePath('planner.md'), 'ecc-planner.md');
|
|
assert.equal(toCursorAgentRelativePath('ecc-planner.md'), 'ecc-planner.md');
|
|
});
|
|
|
|
test('backslash and repeated separators are normalized to the platform separator', () => {
|
|
assert.equal(toCursorAgentRelativePath('review\\planner.md'), path.join('review', 'ecc-planner.md'));
|
|
assert.equal(toCursorAgentRelativePath('review//planner.md'), path.join('review', 'ecc-planner.md'));
|
|
assert.equal(toCursorAgentRelativePath('review\\\\sub/planner.md'), path.join('review', 'sub', 'ecc-planner.md'));
|
|
});
|
|
|
|
test('a trailing separator is dropped and the last real segment is renamed', () => {
|
|
assert.equal(toCursorAgentRelativePath('review/planner.md/'), path.join('review', 'ecc-planner.md'));
|
|
});
|
|
|
|
test('empty, missing, and separator-only paths come back unchanged', () => {
|
|
assert.equal(toCursorAgentRelativePath(''), '');
|
|
assert.equal(toCursorAgentRelativePath(undefined), undefined);
|
|
assert.equal(toCursorAgentRelativePath(null), null);
|
|
assert.equal(toCursorAgentRelativePath('/'), '/');
|
|
assert.equal(toCursorAgentRelativePath('\\\\'), '\\\\');
|
|
});
|
|
|
|
test('the result is always relative to the destination root', () => {
|
|
// The executor joins the result under the target agents directory, so a
|
|
// leading separator must not be able to re-root the destination.
|
|
const result = toCursorAgentRelativePath('/etc/planner.md');
|
|
assert.equal(result, path.join('etc', 'ecc-planner.md'));
|
|
assert.equal(path.isAbsolute(result), false);
|
|
});
|
|
|
|
test('dot segments are not interpreted; the transform renames, it does not resolve', () => {
|
|
// The executor walks real directory entries, so these never reach the
|
|
// transform in practice. Pin that it does not quietly collapse them either.
|
|
assert.equal(toCursorAgentRelativePath('./planner.md'), path.join('.', 'ecc-planner.md'));
|
|
assert.equal(toCursorAgentRelativePath('../planner.md'), path.join('..', 'ecc-planner.md'));
|
|
});
|
|
|
|
test('the relative path transform composes the file name transform', () => {
|
|
for (const file of ['planner.md', 'ecc-planner.md', 'README']) {
|
|
assert.equal(toCursorAgentRelativePath(`nested/${file}`), path.join('nested', toCursorAgentFileName(file)));
|
|
}
|
|
});
|