mirror of
https://github.com/Jeuners/ECC.git
synced 2026-09-16 18:16:10 +02:00
feat: Plan Canvas, a browser review canvas for plans (#2467)
* 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>
This commit is contained in:
parent
4130457d67
commit
a511395613
42 changed files with 4398 additions and 60 deletions
53
scripts/lib/loopback-guard.js
Normal file
53
scripts/lib/loopback-guard.js
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
'use strict';
|
||||
|
||||
/**
|
||||
* Host/Origin gating for ECC's loopback HTTP servers (control pane, plan
|
||||
* canvas). DNS rebinding can point an attacker-controlled hostname at
|
||||
* 127.0.0.1, so every request must present a Host header from this
|
||||
* allowlist before the server does any work.
|
||||
*/
|
||||
|
||||
const LOOPBACK_HOSTNAMES = new Set(['127.0.0.1', 'localhost', '[::1]', '::1']);
|
||||
|
||||
// Extract the hostname portion of an HTTP Host header value, stripping any
|
||||
// port. Returns null when the header is missing or malformed.
|
||||
function parseHostHeader(value) {
|
||||
if (!value || typeof value !== 'string') return null;
|
||||
const trimmed = value.trim();
|
||||
if (!trimmed) return null;
|
||||
const match = trimmed.match(/^(\[[^\]]+\]|[^:]+)(?::\d+)?$/);
|
||||
if (!match) return null;
|
||||
return match[1].toLowerCase();
|
||||
}
|
||||
|
||||
function buildAllowedHostnames(configuredHost) {
|
||||
const set = new Set(LOOPBACK_HOSTNAMES);
|
||||
if (configuredHost) set.add(String(configuredHost).toLowerCase());
|
||||
return set;
|
||||
}
|
||||
|
||||
function isAllowedHostHeader(hostHeader, allowedHostnames) {
|
||||
const hostname = parseHostHeader(hostHeader);
|
||||
if (!hostname) return false;
|
||||
return allowedHostnames.has(hostname);
|
||||
}
|
||||
|
||||
// Origin is absent on same-origin navigations and CLI clients; when present
|
||||
// it must resolve to an allowed hostname.
|
||||
function isAllowedOrigin(originHeader, allowedHostnames) {
|
||||
if (!originHeader || typeof originHeader !== 'string') return true;
|
||||
try {
|
||||
const url = new URL(originHeader);
|
||||
return allowedHostnames.has(url.hostname.toLowerCase());
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
LOOPBACK_HOSTNAMES,
|
||||
buildAllowedHostnames,
|
||||
isAllowedHostHeader,
|
||||
isAllowedOrigin,
|
||||
parseHostHeader
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue