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.
54 lines
2.2 KiB
JavaScript
54 lines
2.2 KiB
JavaScript
'use strict';
|
|
|
|
/**
|
|
* Which coding agent is driving a canvas session.
|
|
*
|
|
* The browser shows "Claude Code · listening" instead of an anonymous pill so
|
|
* the human can tell which terminal to look at. Detection is best effort and
|
|
* environment-based: every harness exports at least one distinctive variable
|
|
* into the shells it spawns. `ECC_CANVAS_AGENT` overrides the guess outright.
|
|
*/
|
|
|
|
const path = require('path');
|
|
|
|
const HARNESS_MARKERS = [
|
|
['Claude Code', ['CLAUDECODE', 'CLAUDE_CODE_ENTRYPOINT', 'CLAUDE_CODE_SSE_PORT']],
|
|
['Codex', ['CODEX_SANDBOX', 'CODEX_SANDBOX_NETWORK_DISABLED', 'CODEX_THREAD_ID', 'CODEX_CI']],
|
|
['Cursor', ['CURSOR_AGENT', 'CURSOR_TRACE_ID', 'CURSOR_SESSION_ID']],
|
|
['Gemini CLI', ['GEMINI_CLI', 'GEMINI_CLI_SESSION']],
|
|
['OpenCode', ['OPENCODE', 'OPENCODE_SESSION_ID', 'OPENCODE_SERVER_URL']],
|
|
['Copilot', ['COPILOT_AGENT', 'GITHUB_COPILOT_CLI', 'COPILOT_CLI_SESSION']],
|
|
['Kimi', ['KIMI_CLI', 'KIMI_SESSION_ID']],
|
|
['Qwen Code', ['QWEN_CODE', 'QWEN_CLI']]
|
|
];
|
|
|
|
function detectAgentName(env = process.env) {
|
|
const override = env.ECC_CANVAS_AGENT;
|
|
if (typeof override === 'string' && override.trim()) return override.trim().slice(0, 60);
|
|
for (const [name, markers] of HARNESS_MARKERS) {
|
|
if (markers.some(marker => typeof env[marker] === 'string' && env[marker] !== '')) return name;
|
|
}
|
|
return 'agent';
|
|
}
|
|
|
|
// Compact descriptor the CLI attaches to `await` so the server can show who
|
|
// is listening. The cwd is reduced to its basename: enough to tell projects
|
|
// apart without leaking a full path into the browser.
|
|
function agentDescriptor({ env = process.env, cwd = process.cwd() } = {}) {
|
|
return {
|
|
name: detectAgentName(env),
|
|
project: path.basename(cwd) || cwd
|
|
};
|
|
}
|
|
|
|
function sanitizeAgentDescriptor(raw) {
|
|
if (!raw || typeof raw !== 'object') return null;
|
|
const name = typeof raw.name === 'string' ? raw.name.trim().slice(0, 60) : '';
|
|
if (!name) return null;
|
|
const descriptor = { name };
|
|
if (typeof raw.project === 'string' && raw.project.trim()) descriptor.project = raw.project.trim().slice(0, 120);
|
|
return descriptor;
|
|
}
|
|
|
|
module.exports = { HARNESS_MARKERS, agentDescriptor, detectAgentName, sanitizeAgentDescriptor };
|