mirror of
https://github.com/affaan-m/ECC.git
synced 2026-08-17 21:15:40 +02:00
* feat: add Plan Canvas - browser annotate-and-approve review for plan artifacts - scripts/plan-canvas.js CLI (open/await/end/stop/server; bin ecc-plan-canvas) - loopback server + ECC-styled chrome + annotation SDK + zero-dep markdown renderer - Approve/Request-changes verdicts wired to the /plan confirmation gate - plan-canvas skill, /plan-canvas command, SessionStart hook surfacing open reviews - shared scripts/lib/loopback-guard.js extracted from control-pane (API re-exported) - 121 new tests incl. full-workflow E2E; registered in manifests, catalog, registry Inspired by lavish-axi (https://github.com/kunchenguid/lavish-axi) by @kunchenguid; original ECC-native implementation, not a port. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * refactor(plan-canvas): invoke via ecc-plan-canvas bin so the skill works from any project Skill/command referenced a cwd-relative `node scripts/plan-canvas.js`, unusable outside the ECC root. Switch to the ecc-plan-canvas bin (and $CLAUDE_PLUGIN_ROOT fallback) and align CLI next_step hints so an agent can run it as a skill in any repo. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * feat(plan-canvas): render Mermaid diagrams + ship Codex cross-harness surface - markdown renderer emits <pre class="mermaid"> for ```mermaid blocks (source entity-escaped so the browser decodes it for the renderer while blocking injection) - artifact template loads a pinned Mermaid build only when a diagram is present, themed to ECC dark, securityLevel strict, graceful offline fallback to source (ECC_PLAN_CANVAS_MERMAID_URL overrides for a local mirror) - skill teaches Mermaid-for-diagrams and states the CLI+JSON loop is harness-agnostic - add .agents/skills/plan-canvas (Codex) with agents/openai.yaml interface manifest - register in install-modules workflow-quality paths; docs updated Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * docs(plan-canvas): add demo screenshot Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix(ci): sync yarn.lock with new bin; add contributor checklist - yarn.lock records the ecc-plan-canvas bin so Yarn hardened-mode install no longer wants to modify the lockfile on public PRs - PR template + CONTRIBUTING gain a pre-push checklist covering the lockfile trap and the full skill/command/CLI registration surfaces Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Haley Chen <2022hachen@gmail.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
101 lines
3.1 KiB
JavaScript
101 lines
3.1 KiB
JavaScript
/**
|
|
* Integration tests for scripts/hooks/plan-canvas-sessions.js (SessionStart)
|
|
*
|
|
* Run with: node tests/hooks/plan-canvas-sessions-hook.test.js
|
|
*/
|
|
|
|
const assert = require('assert');
|
|
const fs = require('fs');
|
|
const os = require('os');
|
|
const path = require('path');
|
|
const { spawnSync } = require('child_process');
|
|
|
|
const HOOK = path.join(__dirname, '..', '..', 'scripts', 'hooks', 'plan-canvas-sessions.js');
|
|
|
|
function test(name, fn) {
|
|
try {
|
|
fn();
|
|
console.log(` ✓ ${name}`);
|
|
return true;
|
|
} catch (err) {
|
|
console.log(` ✗ ${name}`);
|
|
console.log(` Error: ${err.message}`);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function runHook(stateDir) {
|
|
return spawnSync('node', [HOOK], {
|
|
encoding: 'utf8',
|
|
input: '{}',
|
|
env: { ...process.env, ECC_PLAN_CANVAS_STATE_DIR: stateDir }
|
|
});
|
|
}
|
|
|
|
function writeState(stateDir, sessions) {
|
|
fs.mkdirSync(stateDir, { recursive: true });
|
|
fs.writeFileSync(path.join(stateDir, 'sessions.json'), JSON.stringify({ sessions }));
|
|
}
|
|
|
|
function runTests() {
|
|
console.log('\n=== Testing plan-canvas-sessions hook ===\n');
|
|
|
|
let passed = 0;
|
|
let failed = 0;
|
|
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'plan-canvas-hook-'));
|
|
|
|
if (test('exits 0 and prints nothing when no state exists', () => {
|
|
const result = runHook(path.join(tmp, 'missing'));
|
|
assert.strictEqual(result.status, 0);
|
|
assert.strictEqual(result.stdout, '');
|
|
})) passed++; else failed++;
|
|
|
|
if (test('exits 0 and prints nothing when all sessions are ended', () => {
|
|
const dir = path.join(tmp, 'ended');
|
|
writeState(dir, {
|
|
abc123abc123: { key: 'abc123abc123', file: '/x/plan.md', status: 'ended', endedBy: 'user', pendingFeedback: [] }
|
|
});
|
|
const result = runHook(dir);
|
|
assert.strictEqual(result.status, 0);
|
|
assert.strictEqual(result.stdout, '');
|
|
})) passed++; else failed++;
|
|
|
|
if (test('surfaces open sessions with resume guidance', () => {
|
|
const dir = path.join(tmp, 'open');
|
|
writeState(dir, {
|
|
abc123abc123: {
|
|
key: 'abc123abc123',
|
|
file: '/projects/x/.claude/plans/feature.plan.md',
|
|
status: 'feedback',
|
|
pendingFeedback: [{ id: 'fb-1' }, { id: 'fb-2' }]
|
|
}
|
|
});
|
|
const result = runHook(dir);
|
|
assert.strictEqual(result.status, 0);
|
|
assert.ok(result.stdout.includes('[PlanCanvas]'));
|
|
assert.ok(result.stdout.includes('/projects/x/.claude/plans/feature.plan.md'));
|
|
assert.ok(result.stdout.includes('2 undelivered feedback items'));
|
|
assert.ok(result.stdout.includes('plan-canvas.js await'));
|
|
})) passed++; else failed++;
|
|
|
|
if (test('exits 0 on corrupt state (never blocks session start)', () => {
|
|
const dir = path.join(tmp, 'corrupt');
|
|
fs.mkdirSync(dir, { recursive: true });
|
|
fs.writeFileSync(path.join(dir, 'sessions.json'), '{nope');
|
|
const result = runHook(dir);
|
|
assert.strictEqual(result.status, 0);
|
|
assert.strictEqual(result.stdout, '');
|
|
})) passed++; else failed++;
|
|
|
|
fs.rmSync(tmp, { recursive: true, force: true });
|
|
|
|
console.log('\n' + '='.repeat(40));
|
|
console.log(`Passed: ${passed}`);
|
|
console.log(`Failed: ${failed}`);
|
|
console.log('='.repeat(40));
|
|
|
|
process.exit(failed > 0 ? 1 : 0);
|
|
}
|
|
|
|
runTests();
|