Skip to content

feat(design): DESIGN.md read, lint and draft behind the live flag (design mode v2 Phase DM) - #915

Open
sambitcreate wants to merge 31 commits into
t3/design-mode-v2-p2afrom
t3/design-mode-v2-dm
Open

sambitcreate wants to merge 31 commits into
t3/design-mode-v2-p2afrom
t3/design-mode-v2-dm

Conversation

@sambitcreate

@sambitcreate sambitcreate commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

This is stacked on #911 (Phase 2a), which sits on #908 (1b) and #894 (1a). Merge them in that order; GitHub retargets each PR when its base merges.

This is Phase DM of design mode v2:

  • spec: docs/superpowers/specs/2026-11-23-design-mode-live-app-design.md §6.9 and §8;
  • plan: docs/superpowers/plans/2026-11-24-design-mode-v2-dm-design-md.md, including its "As built" section;
  • amendments: S33–S44.

Aiden now reads, lints and drafts an app's DESIGN.md (Google's open format, @google/design.md pinned at exactly 0.4.0). All of it sits behind AIDEN_EXPERIMENTAL_DESIGN_LIVE. With the flag off, prompts, tools and behaviour are byte-for-byte unchanged, and no lint worker starts.

What changes

Feature flag

designLiveEnabled() in main/services/studio/feature-flags.ts is true only when design mode is on and AIDEN_EXPERIMENTAL_DESIGN_LIVE is 1, true, yes or on, trimmed and case-insensitive. studioCapabilities() reports designLive. Phases 2b–5 reuse this helper.

.aiden/canvas.json reader (canvas-config.ts)

  • Rules for paths and versions. Every path must be workspace-relative: a root of exactly . is allowed, and .., absolute paths, backslashes, NUL and anything over 200 characters are refused. The file is understood when version is missing or 1; any other value reads as unsupported-version.
  • Which roots each phase uses.
    • configuredRoots: the scripted entries that detection also sees as web apps. 2b uses this to decide what may start.
    • describedRoots: those entries, or detection when there are none. DESIGN.md lookup uses this.
  • What 2b's writer gets. readCanvasConfigText gives the reason a read failed (missing, link, too large or unreadable), and a raw-object read keeps fields a phase doesn't know about.

Finding and reading DESIGN.md (design-md/)

  • Where the lint runs. The lint runs in a worker thread, built as build/main/design-md-lint-worker.js.
    • The worker posts ready once it has imported the linter. Loading has a 10 s limit, then the lint has a 2 s deadline before the worker is terminated.
    • A timed-out result is cached for each content hash and retried after 5 minutes.
    • 0.4.0 slows down quadratically on runs of emphasis characters: a 64 KB file took 14 s synchronously. Behind the worker it now returns timed-out at about 2.2 s, and the main thread lags by at most 16 ms.
  • Limits. Files are capped at 64 KiB. At most 2 lints run at once and 16 can wait; past that the answer is busy. After a load timeout, the linter is marked unavailable for the rest of the run.
  • Read safety.
    • The final path segment is never followed.
    • The real path is checked again after the read, and the device and inode must match.
    • A FIFO, a directory or a link that leaves the workspace never gets read.
    • A DESIGN.md that resolves to a credential or env-secret file (.env, .npmrc, key files) is refused, the same way read_file refuses them.
  • Findings beyond the linter. Aiden adds two warnings that 0.4.0 doesn't give: aiden/duplicate-section, using its own alias table checked against the package's spec-config.yaml, and aiden/unresolved-ref.
  • Hostile names. Folder and app-root names that fail the path rules are counted, never named. Names that are shown are JSON.stringify-ed. Everything that comes from the file is fenced as data and length-bounded.

The design_system tool

  • Actions. read, lint (optionally with draft content), export and draft, where export targets are Tailwind v4, CSS variables and DTCG.
  • Draft. draft builds text from the app's own style files with v1's scanner, which moves to design-md/style-scan.ts. It never writes a file: Aiden writes it with write_file under the ordinary approvals.
  • Answer size. Every answer is fenced and capped at 64 KiB.

Turn integration

  • The status note. The design-canvas-status note gets one sentence with each app's DESIGN.md state. App roots are read in parallel, and the sentence has a 3 s budget.
  • The draft offer. When an app has no DESIGN.md, the note asks Aiden to offer a draft once per workspace and app root. Each offer is settled by its own key. The offer is made only when the chat can write and ask_user_question is offered and not excluded.
  • v1 tokens offer. With the flag on, the DESIGN.md offer replaces v1's tokens offer. The offer log moves to offer-log.ts, keeping the same HMAC.
  • Prompt cache. The prompt section gains one static bullet when the flag is on. A turn that changes a DESIGN.md count misses the cache once, as v1's canvas counts already do.

IPC and packaging

  • IPC. A read-only designCanvas:designSystem validates its request and checks the app root.
  • Leaner package. The package's CLI, nested node_modules, spec files, and 18 hoisted packages that only the CLI and MDX parsers reach are left out of the asar. Of these, verifyPackagedDesignMdLinter checks that the 18 packages are absent and that the trimmed linter still lints. A guard test fails if another production dependency starts needing one of them.
  • Release check. The new scripts/design-md-packaged-acceptance.mjs (npm run test:design-md:packaged) runs the IPC inside the packaged macOS app in release.yml, with AIDEN_ANALYTICS=0.

Analytics

Two new events, each with a registry entry, a docs row and a test:

  • design_md_linted, sent once for each new content of a file per run, and never for a content lint or an IPC read;
  • design_md_drafted {source: "app"}.

Their properties are only buckets or enums.

Review

  • Plan: two adversarial Opus reviews, then a cross-plan re-check with 2b that fixed shared contracts, version rules and the worker deadline.
  • Build: two Opus code reviews. One covered security, the worker and packaging, probing the real API with the quadratic fixture, queue limits, FIFOs, symlinks and a .env link. The other covered correctness, contracts and test quality.
  • Fixes: both reviews' findings were fixed in 14 commits, each test-first.

Tests

  • npm run test:design-mode: 1043/1043 (base 922), after the Pullfrog fixes.
  • test:analytics 175; feature-flags, prompt-prefix and harness 200; test:ci-policy 123; main-runtime-dependencies 2/2; verify-macos/linux package tests 47/47.
  • npx tsc --noEmit -p ., npm run lint, npm run build and npm run cli:build pass.
  • E2E in the Cua Space: 14/14 with the flag off, 3/3 with it on.
  • Packaging: an unsigned --dir build's asar passes verifyPackagedDesignMdLinter.

Notes

  • Not run locally: the full packaged-app launch (test:design-md:packaged). It opens a macOS window, and no PR workflow packages macOS, so it runs in release.yml.
  • Unrelated failures: a full npm run test under load had three failures that pass when run alone. One is guest-driver-install "suspending…", which is timing-sensitive and failed the same way on base. The other two are use-assistant-live microphone tests.
  • Base errors: npx tsc -p main/tsconfig.json reports the same errors on the base commit.
  • No screenshots: this PR changes no UI.
  • Bisect: three review-fix commits don't type-check on their own; the next commit fixes each, and the head is clean:
  • Follow-up: the command-capability list in main/index.ts is hard-coded, so a future studioCapabilities key would need adding there by hand.
  • Pullfrog's first review: fixed in 307b875 (overlapping reads share one lint and one event), 68a4b43 (every read answer fits in 64 KiB) and 9c84c72 (a turn that excludes design_system gets no DESIGN.md prompt, note or offer).

🤖 Generated with Claude Code

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

Three contract gaps need fixes before merge: duplicate concurrent lints/events, an answer-size overflow, and guidance for an excluded tool.

Reviewed changes across the complete Phase DM stack through d5083ab60, including the feature gate, canvas configuration and app discovery, DESIGN.md safety/lint/cache/draft/tool paths, turn and prompt integration, IPC/analytics, packaging, release verification, documentation, and tests.

  • DESIGN.md runtime: Adds safe lookup/read behavior, bounded worker-thread lint/export, caching, retries, and supplemental findings.
  • Agent surface: Adds fenced read/lint/export/draft responses, per-turn status and draft offers, analytics, and design-canvas prompt/tool wiring.
  • Distribution contracts: Pins and trims @google/design.md, verifies packaged contents and runtime behavior, and documents the gated feature.

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏

Comment thread main/services/llm-client.ts Resolved

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

A previously journaled DESIGN.md prompt can survive a later excluded-tool turn, so one prior contract gap remains.

Reviewed changes since the prior Pullfrog review at d5083ab60, covering the three review fixes and their as-built documentation.

  • Coalesced shared worker runs: Made overlapping reads and exports share one worker result while preserving per-caller cancellation and once-per-content analytics.
  • Bounded complete read payloads: Trimmed sections, omissions, and tokens together so JSON escaping cannot push the fenced data past 64 KiB.
  • Gated current-turn DESIGN.md wiring: Suppressed the newly built tool, static bullet, status sentence, and draft offer when design_system is excluded.
  • Recorded the review fixes: Updated the Phase DM as-built notes with the revised runtime contracts.

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏

Comment thread main/services/llm-client.ts Resolved

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes since the prior Pullfrog review at 6c4955ab5, covering the retained transcript-guidance fix.

  • Replaced stale DESIGN.md guidance: Updated withDesignModeSection to replace a journaled section containing the exact static DESIGN.md bullet when the current turn lacks design_system, while preserving unrelated flag-off sections.
  • Covered the retained-section lifecycle: Added a behavioral test that journals the live section, transitions to a turn without DESIGN.md support, verifies the tool guidance is gone, and confirms the following turn adds nothing.
  • Recorded the final review fix: Updated the Phase DM as-built notes to match the corrected prompt-section behavior.

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | View workflow run | Using GPT Sol | 𝕏

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant