Files
ponytail/tests/gemini-extension.test.js
T
c1c80f3cc8 Adding support for Copilot Marketplace plugin (#47)
* Add GitHub Copilot plugin and marketplace manifests for Ponytail

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Add Copilot hook adapters and plugin data runtime precedence

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Document Copilot plugin install flow and instruction fallback mode

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Fix Copilot hooks for native output context and state-only mode tracking

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* docs: add Copilot CLI namespaced command examples

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Collapse Copilot hooks into shared activate/mode-tracker

The Copilot hook files duplicated ponytail-activate.js and
ponytail-mode-tracker.js, differing only in output shape. Move that
difference into writeHookOutput (isCopilot branch) and point
copilot-hooks.json at the shared hooks. Deletes both forks (-73 lines).

Refs #1

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* Align Copilot manifest version to 4.4.0 with cross-manifest parity test

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Make Copilot and Codex host detection exclusive in runtime output routing

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Add Copilot debt command validation with a pull request acceptance checklist

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Removed PR template

* Drop tautological copilot command-form test

The namespaced-form assertion built '/ponytail:ponytail-debt' from two
constants and compared it to itself — it tests string concatenation, not
wiring. The file-exists check above already catches a renamed manifest.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-15 11:02:59 +02:00

80 lines
3.2 KiB
JavaScript

#!/usr/bin/env node
// Smoke test for the Gemini CLI adapter. The adapter is a single thin manifest
// (gemini-extension.json) that reuses the repo's existing files: AGENTS.md for
// always-on context, commands/*.toml for /ponytail + /ponytail-review, and
// skills/ for the agent skills. This test fails if the manifest is removed,
// loses its pinned version, or points contextFileName at a file that no longer
// carries the load-bearing rules — i.e. if the adapter stops wiring ponytail.
const test = require('node:test');
const assert = require('node:assert/strict');
const fs = require('fs');
const path = require('path');
const root = path.join(__dirname, '..');
const MANIFEST = 'gemini-extension.json';
const EXTENSION_NAME = 'ponytail';
// Floating refs are a supply-chain footgun; the manifest version must be pinned.
const PINNED_SEMVER = /^\d+\.\d+\.\d+$/;
const VERSIONED_MANIFESTS = [
'gemini-extension.json',
'.claude-plugin/plugin.json',
'.codex-plugin/plugin.json',
'.github/plugin/plugin.json',
];
// Gemini auto-discovers these by directory; the manifest is only useful if they exist.
const REUSED_COMMANDS = ['commands/ponytail.toml', 'commands/ponytail-review.toml'];
const REUSED_SKILLS = ['skills/ponytail/SKILL.md'];
// Same load-bearing phrases asserted by scripts/check-rule-copies.js: the file
// contextFileName points at must actually carry the rules, not just exist.
const RULE_INVARIANTS = [
'lazy senior',
'input validation at trust boundaries',
'naive heuristic',
];
function read(relPath) {
return fs.readFileSync(path.join(root, relPath), 'utf8');
}
// Read inside each test (not at module scope) so a missing or malformed manifest
// surfaces as a clean per-test assertion failure, not a load-time crash that
// collapses every case into one unreadable stack trace.
function loadManifest() {
assert.ok(fs.existsSync(path.join(root, MANIFEST)), `${MANIFEST} must exist`);
return JSON.parse(read(MANIFEST));
}
test('manifest names the ponytail extension with a pinned version', () => {
const manifest = loadManifest();
assert.equal(manifest.name, EXTENSION_NAME);
assert.match(manifest.version, PINNED_SEMVER);
});
test('version stays aligned with the other plugin manifests', () => {
const versions = VERSIONED_MANIFESTS.map((rel) => {
const manifest = JSON.parse(read(rel));
assert.match(manifest.version, PINNED_SEMVER, `${rel} version must be pinned semver`);
return manifest.version;
});
const [sharedVersion, ...rest] = versions;
for (const version of rest) {
assert.equal(version, sharedVersion);
}
});
test('contextFileName resolves to a file carrying the ponytail rules', () => {
const manifest = loadManifest();
assert.ok(manifest.contextFileName, 'contextFileName must be set so rules load every session');
const context = read(manifest.contextFileName);
for (const phrase of RULE_INVARIANTS) {
assert.ok(context.includes(phrase), `context file missing rule invariant: "${phrase}"`);
}
});
test('the commands and skills the adapter reuses are present', () => {
for (const rel of [...REUSED_COMMANDS, ...REUSED_SKILLS]) {
assert.ok(fs.existsSync(path.join(root, rel)), `reused file missing: ${rel}`);
}
});