Skip to content

prompt-enhancement <- Scaffolding architecture - #109

Open
hi0001234d wants to merge 97 commits into
prompt-enhancementfrom
scaffolding-architecture
Open

hi0001234d wants to merge 97 commits into
prompt-enhancementfrom
scaffolding-architecture

Conversation

@hi0001234d

Copy link
Copy Markdown
Owner

No description provided.

Vedansi18 added 30 commits June 30, 2026 16:53
…adapters

Extracts the classification/session pipeline into src/core/ with zero Node deps
so the browser extension service worker can run the same pipeline in B2+.

- 7 port interfaces in src/core/ports/ (StoragePort, LLMPort, LogPort, etc.)
- Core copies in src/core/classifier/ (all 9 classifier files, port-adapted)
- src/core/session-state.ts (SessionStateManager via StoragePort)
- src/core/stage2.ts + src/core/decision/pinch.ts (LLMPort-based)
- src/core/decision/options.ts (re-export bridge, no file movement)
- 6 re-export bridges in src/classifier/ (zero regression for all callers)
- 3 CLI adapters: SqlJsStorageAdapter, OpenAILLMAdapter, loggerAdapter
- auto.ts + stop.ts wired to core via adapters (same external signatures)
- Frozen UI contract + mock harness with 6 fixtures in src/ext-browser/ui/

Zero regression: 118 test files, 4666 tests — all green.
Claude/Cursor/Windsurf/Devin pipeline flows all intact.
8 new test files covering every new module introduced in B1:
- core/session-state.test.ts — SessionStateManager with mock StoragePort
- core/stage2.test.ts — runStage2 with mock LLMPort (+ pure helpers)
- core/classifier/LLMProfileClassifier.test.ts — classifyUserProfileLLM with LLMPort
- core/classifier/StreamBPresenceClassifier.test.ts — classifyStreamBPresence with LLMPort
- core/classifier/PromptClassifier.test.ts — tidfClassifier optionality + tier cascade
- core/decision/pinch.test.ts — generatePinchLabel + validatePinchLabel with LLMPort
- cli/adapters/llm.adapter.test.ts — OpenAILLMAdapter param forwarding
- cli/adapters/storage.adapter.test.ts — SqlJsStorageAdapter load/save/language

All tests use mock LLMPort/StoragePort — zero regression on existing 4666 tests.
126 test files, 4866 tests, all green.
…g core pipeline

- 7 browser adapters: IDB storage, fetch LLM, console log, browser clock,
  chrome.storage key store, offscreen embedding, sync-over-async memory bridge
- MV3 service worker: full prompt→classify→stage2→advisory pipeline with
  SW ephemerality-safe IDB flush before every await
- Content scripts: ISOLATED-world injector drops main-world.js <script>,
  forwards postMessage↔chrome.runtime; inject.ts mounts stub panel
- MAIN-world script: patches window.fetch; exposes emit helpers for B3/B4/B5
- Offscreen document stub (B5 wires real Transformers.js)
- Shadow-DOM stub panel with XSS escaping (B5b replaces with real UI)
- Options page: saves OpenAI API key to chrome.storage.local
- Chrome + Firefox manifests; esbuild script → dist/ext-chrome/ + dist/ext-firefox/
- 9 unit test files, 72 tests — 4938/4938 total green, zero regressions
Adds 7 test files for modules B2 shipped without coverage (service-worker,
offscreen, embedding-offscreen, inject, main-world-injector, panel-adapter,
options). Fixes found in the process: postMessage was broadcasting to '*'
instead of location.origin, offscreen doc creation used an in-memory flag
instead of hasDocument() (breaks on SW restart), manifests were missing
content/inject.js so the panel could never mount, and options page gained
a real key-validation Test button + self-check panel.
Adds build:ui-harness (esbuild) script and the standalone harness page,
completing the B1 UI-developer handoff package. Verified live in Chrome:
all 6 real fixtures load and fire panel events with zero console errors.
…on, idempotent-injection guards for stale content-script instances
…on, live-confirmed bug fixes

Capture side confirmed live on real Replit sessions (prompt-submit +
response-stop each fire exactly once per turn). Fixes: missing icons,
MV3 content-script bundle format, hidden console.debug logs, page-load
history replay, duplicate bundling, stale content-script instances on
extension reload, duplicate capture from Replit's own DOM re-renders,
and a wrong response-stop selector (disabled-toggle never fired;
Replit swaps in a separate stop-button element instead).
panel-adapter.ts awaited a content-script reply that main-world-injector.ts
never sent, so every advisory silently resolved as dismiss regardless of
what the user clicked. Added a symmetric nexpath:panel-event bridge.
…ash) + 4 other real bugs surfaced by finally running tsconfig.ext-browser.json

Root tsc --noEmit excludes src/ext-browser entirely — never caught these.
Added npm run typecheck:ext so this can't silently regress again.
…ngine gating

Ports cli/commands/auto.ts's entire frequency-gating pipeline (warmup,
dedup, cooldown, session cap, confidence overrides) into service-worker.ts,
previously entirely absent from the browser. Adds frequency + role
selectors to the options page, matching the CLI installer's exact value
sets/labels/defaults, wired to browser.storage.local under the same key
names the engine now reads.
…the mock harness

The frozen ui-contract.ts was a stale, pre-brief draft that never matched
either the brief document or the real engine's Stage enum. Rewrote it to
match the brief exactly, with the stage field corrected to the real
8-value taxonomy (confirmed live via a real 'review_testing' advisory).
Also fixed ui-mock-harness/ (6 fixtures + bootstrap script), which imports
from this file and was broken the same way — the UI developer never
received a working harness despite brief §7 promising one.
…owing it

Confirmed real bug: capture silently stopped mid-session with zero error
anywhere, matching an empty .catch() on the SW-bound sendMessage calls.
MV3 service workers can be asleep/mid-restart when a message arrives —
previously any failure there vanished without trace. Now retries once
and always logs loudly on final failure.
… toggles

Previously only watched childList mutations (element add/remove) — a
longer, multi-action response may toggle the stop button's visibility
via attribute change on a persistent element instead, which this
silently missed. Also logs the detection moment to the page console,
independent of message delivery, closing an observability gap.
…mechanism guesses

Two prior fixes assumed specific mutation types (childList, then
childList+attributes) and both still failed live. Adds a 1.5s interval
poll that checks the stop button's actual presence directly, so
detection no longer depends on knowing which DOM change Replit uses.
…ctor

Three stop-button-based strategies all failed live on longer responses.
Rather than a fourth guess at that same mechanism, adds a completely
separate signal confirmed present in every test screenshot this session,
both working and failing cases — Replit's own turn-completion label.
…ages + reconciliation sweep

Root cause of 'first prompt captured, later prompts silent' (seen 2026-07-02
Publish flow and 2026-07-03 prompt 2): elements were marked seen before their
text was read, permanently consuming shell-first renders. Not a regression —
capture logic was untouched by today's commits; sendMessage theory disproven
by the retry logging staying silent.
…line fallback; adapter capture tiers corrected to include dom-events
…at/v2), TipTap composer capture, stop/version response-stop detectors, per-agent inject dispatch
…t) + stage-2 verdict observability (silent LLM decline)
…<id> persist POST replayed historical prompts on load (spurious advisory)
…erged all projects into one session; landing pages skip capture
…ive MV3 teardown; options Recent Activity section + debug-channel access
…jected feedback clears funnel; auto-reload agent tabs on update; Replit-flow regression tests
…rectly after navigation into a project (Replit's new UI has no re-capture channel)
…in rejection, Recent Activity 20-row cap, fire-path verdict persistence
…pathEndsWith guard), TipTap composer, #usr message observer, sessionStorage-backed stash for hard-nav landing flow, inject dispatch
Vedansi18 and others added 30 commits July 23, 2026 16:12
… (Lovable aria-label relabel)

Lovable renamed its composer aria-label 'Chat input' -> 'Ask Lovable...', so the
exact-label selector matched nothing and 'Send to your agent' fell back to clipboard
instead of pasting + auto-submitting. injectViaSimulatedPaste now accepts a prioritised
selector list (original label kept as top priority) and prefers the first rendered match.
Purely additive; no existing selector or code path removed. Live-verified on lovable.dev.
…lassifier-parity

fix(ext-browser): harden agent composer lookup against site DOM drift…
…he public repo

Relocated docs/capture-recon (third-party API/DOM reverse-engineering) and
docs/architecture (internal classifier design) to the private planning submodule.
Cleaned the now-dangling recon-doc citations in code comments (comment-only).
CHANGELOG keeps the Lovable composer aria-label drift-fix entry.
…lassifier-parity

chore: remove internal reverse-engineering + architecture docs from t…
… merge/sub-11-into-scaffolding-architecture

# Conflicts:
#	src/classifier/AbsenceDetector.ts
#	src/classifier/signals.ts
…rchitecture

Merge/sub 11 into scaffolding architecture
…surface

Injection is entirely declarative (content_scripts + web_accessible_resources),
so the `scripting` permission was never used by any code path. Remove it from
both manifests (now storage + tabs only) to minimise the store-review permission
surface, and add a manifest guard test so an unused permission can't reappear.

No runtime behaviour change: the permission was inert. Full ext suite green (7464/7464).
…ermission

fix(ext-browser): drop unused `scripting` permission; pin permission …
…ub-11

User experience improvements sub 11 -> scaffolding
Chrome derives the store summary from the manifest `description` (not editable in the
dashboard). Update both manifests to the VS Code extension's proven pattern —
"AI coding assistant for Replit, Bolt, StackBlitz, and Lovable — a behaviour-guidance
layer for vibe coders." — for brand consistency across CLI/VS Code/browser and store
discoverability, within Chrome's 132-char limit. Guard test now asserts description
parity + length. Inert metadata; no runtime change.
…ead decision)

Drop the StackBlitz brand word from all user-facing text — manifest description
(store summary), options-page supported-sites badge, and privacy page — per
team-lead branding decision. Also removes a stale `scripting` mention from the
privacy page (that permission was dropped in 0.1.5).

No regression: the stackblitz.com host support (host_permissions, agent-hosts
routing, service-worker patterns, and its tests) is intentionally KEPT — bolt.new /
stackblitz behaviour is unchanged. typecheck:ext + ext suite (380/380) + build:ext green.
…gnment

Fix/ext store summary brand alignment
…ub-11

User experience improvements sub 11 -> scaffolding
…wport

Bug #1 — the advisory popup showed with NO selectable options (only "Send to
your agent") on a short terminal/popup window. computeLayout's sticky-header
tiers could fill the viewport down to avail === 0, so the option window slice
came out empty.

Two additive guards, no change to the avail/windowing formulas the budget tests
lock: (1) reserve MIN_OPTION_BAND_ROWS (3) when dropping Tier 2 header rows so the
header stops one step before it leaves zero room for options; (2) a hard floor in
the option windowing loop that always keeps at least the focused option's first
line, so options.length > 0 never renders zero options.

+6 regression tests (rows 6/10/12/14 tall-header repro + roomy baseline) that fail
on the pre-fix code. Full suite 7472/7472; no existing render-loop test changed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…viewport

On a short browser window the fixed-size header squeezed .np-scroll to 0px, so no
selectable option rendered and a blind Enter jumped straight to the send-confirm.
Let the header shrink/clip (why-help drops, pinch+question stay) and floor the
options band at min-height:56px. Inert on normal windows (byte-identical render).
Reproduced live across 6 fixtures at vp<=230px (blank 19->0); +regression test.
…-viewport

fix(ext-browser): never collapse the options band to zero on a short …
fix(render-loop): never render zero selectable options on a short vie…
- drop the removed `scripting` permission from the store permission
  justifications (manifest + guard test are storage/tabs only); note
  injection is declarative so no scripting perm is needed
- align the AMO reproducible-build Node version to 20 (what the publish
  workflow actually builds the uploaded zip with); 24 was the outlier
docs(ext-browser): correct PUBLISH.md permission + Node-version drift
…t/Lovable/Bolt order

- move the Scope disclaimer from the top to the end (kept — clarifies this
  policy covers the browser extension only, not the CLI/VS Code)
- 'four supported AI coding sites' -> 'three' (StackBlitz not user-facing)
- reorder site lists to Replit, Lovable, Bolt.new (site-access + affiliation
  line + meta description); bump last-updated date
Reorder the site-name list in the manifest description (store summary),
README, and CHANGELOG to match the privacy page. Display/metadata only —
no code, routing, or functionality touched (routing keys off hostnames in
agent-hosts.ts). Full suite 7474/7474, manifest guard 11/11, typecheck:ext
clean, description 95/132 chars.
docs(privacy): team-lead edits — Scope box to end, three sites, Repli…
Inline source maps inflated service-worker.js to ~5.3 MB, which Firefox AMO's
linter rejects ('File is too large to parse'). Store builds must not ship maps.
SW 5.31 MB -> 1.76 MB; store zips 1.6 MB -> 0.51 MB. Opt in for local debugging
with NEXPATH_EXT_SOURCEMAP=1. No functional change; typecheck:ext clean, suite 7474/7474.
fix(ext-browser): drop inline source maps from the store build
The prior AMO add-on (gecko id {1c62eba0-...}) is being deleted to publish a
LISTED (public) submission. A deleted AMO add-on id is permanently unusable, so
a new gecko id is required. Version stays 0.1.5 — no functional change.

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.

2 participants