mirror of
https://github.com/affaan-m/ECC.git
synced 2026-11-23 08:15:29 +00:00
Add UI Canvas: an agent writes a self-contained HTML mockup, the human edits
it directly in the browser (select, resize, reorder, nudge, edit text,
remove, restyle), checks mobile, desktop, and exact viewports, chats with the
agent, and clicks Save and Finish to export the edited markup and an edit log.
- skills/ui-canvas, commands/ui-canvas.md, bin ecc-ui-canvas
(scripts/ui-canvas.js), a profile over the Plan Canvas server via a
session mode of 'ui'.
- scripts/lib/ui-canvas/{editor,feedback,ui,fields}.js: in-page editor,
feedback normalization, browser shell, and inspector field helpers.
- Inspector: grouped slider rows (size, fill, text, spacing, border,
effects); double-click any value to type it, sanitized and clamped before
it reaches the mockup; HSL plus alpha color sliders; per-property clear.
- ECC green accent on near-black, no gradient branding; selection overlay
is green.
- Plan Canvas: agent identity in presence, mode-aware server and hooks.
Editing conventions credit VisBug and Onlook; the review loop credits
lavish-axi by @kunchenguid.
91 lines
3.0 KiB
JavaScript
91 lines
3.0 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Plan Canvas and UI Canvas open-session surfacing (SessionStart)
|
|
*
|
|
* Cross-platform (Windows, macOS, Linux)
|
|
*
|
|
* If a Plan Canvas review is still open from a previous agent session,
|
|
* surface it at session start so a fresh session can resume the loop with
|
|
* `plan-canvas await <file>` instead of leaving the human talking to an
|
|
* empty chair in the browser.
|
|
*
|
|
* Never blocks: exits 0 on every error, prints nothing when there is
|
|
* nothing to resume.
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const os = require('os');
|
|
|
|
// Resolve the Claude profile directory the same way everywhere.
|
|
//
|
|
// Duplicated rather than imported on purpose: hooks ship in managed installs
|
|
// that carry top-level `scripts/` without `scripts/lib/` (see #3259), so a
|
|
// require into lib/ would make the hook unloadable there. `~` is expanded the
|
|
// way `scripts/lib/agent-data-home.js` expands it, so a profile written as
|
|
// `~/.claude-work` resolves to one place rather than two.
|
|
function claudeConfigDir() {
|
|
const configured = process.env.CLAUDE_CONFIG_DIR;
|
|
const trimmed = configured ? String(configured).trim() : '';
|
|
if (!trimmed) return path.join(os.homedir(), '.claude');
|
|
if (trimmed.startsWith('~')) {
|
|
const remainder = trimmed.slice(1).replace(/^[/\\]+/, '');
|
|
return remainder ? path.join(os.homedir(), remainder) : os.homedir();
|
|
}
|
|
return path.resolve(trimmed);
|
|
}
|
|
|
|
function stateDir() {
|
|
const override = process.env.ECC_PLAN_CANVAS_STATE_DIR;
|
|
if (override && override.trim()) return path.resolve(override.trim());
|
|
return path.join(claudeConfigDir(), 'plan-canvas');
|
|
}
|
|
|
|
function openSessions() {
|
|
try {
|
|
const parsed = JSON.parse(fs.readFileSync(path.join(stateDir(), 'sessions.json'), 'utf8'));
|
|
return Object.values(parsed.sessions || {}).filter(session => session.status !== 'ended');
|
|
} catch {
|
|
return [];
|
|
}
|
|
}
|
|
|
|
function buildContext(sessions) {
|
|
const lines = [
|
|
'[PlanCanvas] Open browser review sessions from a previous run:'
|
|
];
|
|
for (const session of sessions.slice(0, 5)) {
|
|
const pending = session.pendingFeedback && session.pendingFeedback.length;
|
|
const tag = session.mode === 'ui' ? ' [ui canvas]' : '';
|
|
lines.push(` - ${session.file}${tag}${pending ? ` (${pending} undelivered feedback item${pending === 1 ? '' : 's'})` : ''}`);
|
|
}
|
|
lines.push(
|
|
'Resume with `node scripts/plan-canvas.js await <file>` (plan-canvas skill), or `end <file>` if the review is obsolete.'
|
|
);
|
|
if (sessions.some(session => session.mode === 'ui')) {
|
|
lines.push('Sessions tagged [ui canvas] resume with `node scripts/ui-canvas.js await <file>` (ui-canvas skill) instead.');
|
|
}
|
|
return lines.join('\n');
|
|
}
|
|
|
|
function run() {
|
|
const sessions = openSessions();
|
|
if (sessions.length > 0) {
|
|
process.stdout.write(`${buildContext(sessions)}\n`);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
if (require.main === module) {
|
|
try {
|
|
process.exit(run());
|
|
} catch (error) {
|
|
process.stderr.write(`[PlanCanvas] WARNING: ${error.message}\n`);
|
|
process.exit(0);
|
|
}
|
|
}
|
|
|
|
module.exports = { run, openSessions, buildContext };
|