* 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>
143 lines
4.3 KiB
JavaScript
143 lines
4.3 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
const assert = require('assert');
|
|
const fs = require('fs');
|
|
const os = require('os');
|
|
const path = require('path');
|
|
const { spawnSync } = require('child_process');
|
|
|
|
const root = path.join(__dirname, '..');
|
|
|
|
function run(script, env, input = '') {
|
|
return spawnSync(process.execPath, [path.join(root, 'hooks', script)], {
|
|
env: { ...process.env, ...env },
|
|
input,
|
|
encoding: 'utf8',
|
|
});
|
|
}
|
|
|
|
// Keep the base env clean so the default-dir checks are deterministic; the
|
|
// CLAUDE_CONFIG_DIR case sets it explicitly.
|
|
delete process.env.CLAUDE_CONFIG_DIR;
|
|
|
|
const temp = fs.mkdtempSync(path.join(os.tmpdir(), 'ponytail-hooks-'));
|
|
const home = path.join(temp, 'home');
|
|
const pluginData = path.join(temp, 'plugin-data');
|
|
fs.mkdirSync(home, { recursive: true });
|
|
|
|
// USERPROFILE alongside HOME: os.homedir() reads USERPROFILE on Windows, HOME on POSIX.
|
|
const codexEnv = {
|
|
HOME: home,
|
|
USERPROFILE: home,
|
|
PLUGIN_DATA: pluginData,
|
|
PONYTAIL_DEFAULT_MODE: 'ultra',
|
|
};
|
|
const codexState = path.join(pluginData, '.ponytail-active');
|
|
|
|
let result = run('ponytail-activate.js', codexEnv);
|
|
assert.equal(result.status, 0, result.stderr);
|
|
assert.equal(fs.readFileSync(codexState, 'utf8'), 'ultra');
|
|
let output = JSON.parse(result.stdout);
|
|
assert.equal(output.systemMessage, 'PONYTAIL:ULTRA');
|
|
assert.match(
|
|
output.hookSpecificOutput.additionalContext,
|
|
/PONYTAIL MODE ACTIVE — level: ultra/,
|
|
);
|
|
|
|
result = run(
|
|
'ponytail-mode-tracker.js',
|
|
codexEnv,
|
|
JSON.stringify({ prompt: '@ponytail lite' }),
|
|
);
|
|
assert.equal(result.status, 0, result.stderr);
|
|
assert.equal(fs.readFileSync(codexState, 'utf8'), 'lite');
|
|
output = JSON.parse(result.stdout);
|
|
assert.equal(output.systemMessage, 'PONYTAIL:LITE');
|
|
|
|
result = run(
|
|
'ponytail-mode-tracker.js',
|
|
codexEnv,
|
|
JSON.stringify({ prompt: 'normal mode' }),
|
|
);
|
|
assert.equal(result.status, 0, result.stderr);
|
|
assert.equal(fs.existsSync(codexState), false);
|
|
output = JSON.parse(result.stdout);
|
|
assert.equal(output.systemMessage, 'PONYTAIL:OFF');
|
|
|
|
const claudeEnv = {
|
|
HOME: home,
|
|
USERPROFILE: home,
|
|
PONYTAIL_DEFAULT_MODE: 'full',
|
|
};
|
|
delete claudeEnv.PLUGIN_DATA;
|
|
|
|
result = run('ponytail-activate.js', claudeEnv);
|
|
assert.equal(result.status, 0, result.stderr);
|
|
assert.equal(
|
|
fs.readFileSync(path.join(home, '.claude', '.ponytail-active'), 'utf8'),
|
|
'full',
|
|
);
|
|
|
|
// CLAUDE_CONFIG_DIR overrides ~/.claude for the flag file (issue #34).
|
|
const home2 = path.join(temp, 'home2');
|
|
fs.mkdirSync(home2, { recursive: true });
|
|
const customConfigDir = path.join(temp, 'custom-claude');
|
|
result = run('ponytail-activate.js', {
|
|
HOME: home2,
|
|
USERPROFILE: home2,
|
|
CLAUDE_CONFIG_DIR: customConfigDir,
|
|
PONYTAIL_DEFAULT_MODE: 'lite',
|
|
});
|
|
assert.equal(result.status, 0, result.stderr);
|
|
assert.equal(
|
|
fs.readFileSync(path.join(customConfigDir, '.ponytail-active'), 'utf8'),
|
|
'lite',
|
|
);
|
|
assert.equal(
|
|
fs.existsSync(path.join(home2, '.claude', '.ponytail-active')),
|
|
false,
|
|
'flag must not land in ~/.claude when CLAUDE_CONFIG_DIR is set',
|
|
);
|
|
|
|
const copilotData = path.join(temp, 'copilot-data');
|
|
const codexData = path.join(temp, 'codex-data-shadow');
|
|
result = run('ponytail-activate.js', {
|
|
HOME: home,
|
|
USERPROFILE: home,
|
|
COPILOT_PLUGIN_DATA: copilotData,
|
|
PLUGIN_DATA: codexData,
|
|
PONYTAIL_DEFAULT_MODE: 'full',
|
|
});
|
|
assert.equal(result.status, 0, result.stderr);
|
|
assert.equal(fs.readFileSync(path.join(copilotData, '.ponytail-active'), 'utf8'), 'full');
|
|
assert.equal(
|
|
fs.existsSync(path.join(codexData, '.ponytail-active')),
|
|
false,
|
|
'copilot hooks must not write mode state to codex PLUGIN_DATA',
|
|
);
|
|
output = JSON.parse(result.stdout);
|
|
assert.match(output.additionalContext, /PONYTAIL MODE ACTIVE — level: full/);
|
|
|
|
result = run(
|
|
'ponytail-mode-tracker.js',
|
|
{
|
|
HOME: home,
|
|
USERPROFILE: home,
|
|
COPILOT_PLUGIN_DATA: copilotData,
|
|
PLUGIN_DATA: codexData,
|
|
},
|
|
JSON.stringify({ prompt: '/ponytail ultra' }),
|
|
);
|
|
assert.equal(result.status, 0, result.stderr);
|
|
assert.equal(fs.readFileSync(path.join(copilotData, '.ponytail-active'), 'utf8'), 'ultra');
|
|
assert.equal(
|
|
fs.existsSync(path.join(codexData, '.ponytail-active')),
|
|
false,
|
|
'copilot mode tracker must keep codex PLUGIN_DATA untouched',
|
|
);
|
|
output = JSON.parse(result.stdout);
|
|
assert.deepEqual(output, {});
|
|
|
|
fs.rmSync(temp, { recursive: true, force: true });
|
|
console.log('hook compatibility checks passed');
|