Skip to content

An agentic browser harness: an AI side panel & orb in your own logged-in Chrome, Edge, Arc, Brave or even Firefox run by the agent/subscription you already use (Claude Code, Codex, Antigravity). Free, open source, no API key. Also an MCP server.

feat(sidepanel): add the skills panel and the site map review

Shahriar1535404cea84
diff --git a/components/site-map-review.tsx b/components/site-map-review.tsx
new file mode 100644
index 0000000..d4aaf9b
--- /dev/null
+++ b/components/site-map-review.tsx
@@ -0,0 +1,108 @@
+import { useState } from 'react';
+import { AlertTriangle, Check, FolderOpen, Images, Trash2 } from 'lucide-react';
+
+import { Badge } from '@/components/ui/badge';
+import { Button } from '@/components/ui/button';
+import type { SiteMapDraft } from '@/lib/skills/site-map';
+
+/**
+ * The review step for a freshly mapped site.
+ *
+ * This is the only place a person sees what a mapping run actually wrote. Everything in the map
+ * was derived from pages the agent read, and once armed it joins the system prompt of every
+ * future run on that host — so the whole point of this sheet is that nothing is summarised away.
+ *
+ * The markdown is rendered **literally**, in a monospaced block. Rendering it would let a
+ * heading, a link or a zero-width run hide text that the model will still read.
+ */
+export function SiteMapReview({
+ draft,
+ onActivate,
+ onDiscard,
+}: {
+ draft: SiteMapDraft;
+ onActivate: (exactHost?: boolean) => void;
+ onDiscard: () => void;
+}) {
+ const [exactHost, setExactHost] = useState(false);
+ const matching = exactHost ? draft.host : draft.domain;
+
+ return (
+ <div className="mb-2 overflow-hidden rounded-md border border-amber-500/40 bg-amber-500/5">
+ <div className="flex items-start gap-2 border-b border-amber-500/30 px-2.5 py-2">
+ <div className="min-w-0 flex-1">
+ <p className="text-xs font-medium">Mapped {draft.host}</p>
+ <p className="mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-muted-foreground">
+ <span>{draft.pages} pages</span>
+ <span className="inline-flex items-center gap-0.5">
+ <Images className="size-2.5" /> {draft.screenshots}
+ </span>
+ <span>{new Date(draft.generatedAt).toLocaleString()}</span>
+ </p>
+ </div>
+ <Badge variant="secondary" className="h-4 shrink-0 px-1 text-[10px]">
+ not active yet
+ </Badge>
+ </div>
+
+ <div className="px-2.5 py-2">
+ <p className="mb-1.5 text-[11px] leading-relaxed text-muted-foreground">
+ This was written from pages the agent read. Once you activate it, it joins the instructions for every future
+ request on <span className="font-mono">{matching}</span>. Read it first.
+ </p>
+
+ {draft.warnings.length > 0 && (
+ <div className="mb-1.5 rounded bg-amber-500/15 px-2 py-1.5">
+ {draft.warnings.map((warning) => (
+ <p key={warning} className="flex gap-1.5 text-[11px] text-amber-700 dark:text-amber-400">
+ <AlertTriangle className="mt-0.5 size-3 shrink-0" />
+ <span>{warning}</span>
+ </p>
+ ))}
+ </div>
+ )}
+
+ {/*
+ Literal, never rendered — a rendered heading or link can hide what the model reads.
+ A plain scroller, not ScrollArea: Radix wraps the viewport contents in a `display: table`
+ element sized `h-full`, which against a `max-h-*` parent with no definite height resolves
+ to auto — so it clips neither axis and the document spills over the buttons below.
+ */}
+ <div className="max-h-56 overflow-x-hidden overflow-y-auto rounded border bg-background/60">
+ <pre className="px-2 py-1.5 font-mono text-[10px] leading-relaxed break-words whitespace-pre-wrap">
+ {draft.markdown}
+ </pre>
+ </div>
+
+ <p className="mt-1.5 flex items-start gap-1 text-[10px] break-all text-muted-foreground">
+ <FolderOpen className="mt-0.5 size-2.5 shrink-0" />
+ {draft.directory}
+ </p>
+ {draft.screenshots > 0 && (
+ <p className="mt-0.5 text-[10px] text-muted-foreground">
+ Screenshots may show pages you were signed in to. They stay on this machine.
+ </p>
+ )}
+
+ <label className="mt-2 flex items-center gap-1.5 text-[11px] text-muted-foreground">
+ <input
+ type="checkbox"
+ checked={exactHost}
+ onChange={(event) => setExactHost(event.target.checked)}
+ className="size-3"
+ />
+ Only on <span className="font-mono">{draft.host}</span>, not its subdomains
+ </label>
+
+ <div className="mt-2 flex gap-1">
+ <Button variant="ghost" size="sm" className="h-7 flex-1 text-xs" onClick={onDiscard}>
+ <Trash2 className="size-3" /> Discard
+ </Button>
+ <Button size="sm" className="h-7 flex-1 text-xs" onClick={() => onActivate(exactHost)}>
+ <Check className="size-3" /> Activate
+ </Button>
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/components/skills-panel.tsx b/components/skills-panel.tsx
new file mode 100644
index 0000000..2235adc
--- /dev/null
+++ b/components/skills-panel.tsx
@@ -0,0 +1,311 @@
+import { useRef, useState } from 'react';
+import { BookOpen, Check, Compass, Globe, Loader2, Upload, X } from 'lucide-react';
+import { browser } from 'wxt/browser';
+
+import { BRIDGE_CHANNEL } from '@/lib/actions/protocol';
+import { Badge } from '@/components/ui/badge';
+import { Button } from '@/components/ui/button';
+import { Input } from '@/components/ui/input';
+import { putSkill, type StoredSkillMeta } from '@/lib/bridge/skill-store';
+import { useStoredSkills } from '@/lib/bridge/use-stored-skills';
+import {
+ draftFromFile,
+ hostMatchesDomains,
+ hostnameOf,
+ normalizeDomain,
+ validateSkillDraft,
+ type SkillDraft,
+} from '@/lib/skills/format';
+import { cn } from '@/lib/utils';
+
+/**
+ * The library of skills the user has uploaded. A skill is markdown the agent is given as part
+ * of its system prompt; a site-exploration one carries the domains it applies to and engages
+ * only on those, which is what makes it safe to keep several around at once.
+ *
+ * Uploads live in `storage.local` and are pushed to the daemon, which writes them into its
+ * skills directory — nothing here ever reaches the repo.
+ */
+export function SkillsPanel({
+ tabUrl,
+ connected,
+ onMapSite,
+ mapping,
+}: {
+ tabUrl: string;
+ connected: boolean;
+ /** Start a mapping run for the current tab. Absent when the surface cannot host one. */
+ onMapSite?: () => void;
+ /** True while any run is active — one at a time, and a crawl takes minutes. */
+ mapping?: boolean;
+}) {
+ const skills = useStoredSkills();
+ const fileInputRef = useRef<HTMLInputElement>(null);
+ const [draft, setDraft] = useState<SkillDraft | null>(null);
+ const [domainText, setDomainText] = useState('');
+ const [error, setError] = useState<string | null>(null);
+
+ const host = hostnameOf(tabUrl);
+ const mappable = !!onMapSite && connected && !mapping && /^https?:/.test(tabUrl);
+ const alreadyMapped = skills.some(
+ (skill) => skill.origin === 'generated' && hostMatchesDomains(host, skill.domains),
+ );
+
+ async function onPickFile() {
+ const input = fileInputRef.current;
+ const file = input?.files?.[0];
+ if (input) input.value = ''; // let the same file be picked again later
+ if (!file) return;
+ // Markdown is text — read it as text, and let the form fill in whatever the file omits.
+ const parsed = draftFromFile(await file.text(), file.name);
+ setDraft(parsed);
+ setDomainText(parsed.domains.join(', '));
+ setError(null);
+ }
+
+ async function onSave() {
+ if (!draft) return;
+ const domains = domainText.split(',').map(normalizeDomain).filter(Boolean);
+ const checked = validateSkillDraft({ ...draft, domains });
+ if (!checked.ok) {
+ setError(checked.message);
+ return;
+ }
+ const skill = checked.draft;
+ const id = crypto.randomUUID();
+ const meta: StoredSkillMeta = {
+ id,
+ name: skill.name,
+ description: skill.description,
+ category: skill.category,
+ domains: skill.domains,
+ status: 'pending',
+ addedAt: Date.now(),
+ };
+ await putSkill(meta, { id, body: skill.body, triggers: skill.triggers });
+ await browser.runtime.sendMessage({ channel: BRIDGE_CHANNEL, op: 'saveSkill', skillId: id });
+ setDraft(null);
+ setError(null);
+ }
+
+ return (
+ <div className="mb-2 rounded-md border bg-muted/30 p-2.5">
+ <div className="mb-2 flex items-center gap-1.5">
+ <BookOpen className="size-3.5 shrink-0 text-muted-foreground" />
+ <span className="flex-1 text-xs font-medium">Skills</span>
+ {!draft && (
+ <>
+ {onMapSite && (
+ <Button
+ variant="ghost"
+ size="sm"
+ className="h-6 px-2 text-xs"
+ onClick={onMapSite}
+ disabled={!mappable}
+ // Naming the host makes the consent unambiguous: this drives that site for minutes.
+ title={mappable ? `Map ${host}` : 'Open an http(s) page, with no run in progress'}
+ >
+ <Compass className="size-3" /> {alreadyMapped ? 'Re-map' : 'Map'} {host || 'site'}
+ </Button>
+ )}
+ <Button variant="ghost" size="sm" className="h-6 px-2 text-xs" onClick={() => fileInputRef.current?.click()}>
+ <Upload className="size-3" /> Upload
+ </Button>
+ </>
+ )}
+ </div>
+
+ {draft ? (
+ <SkillForm
+ draft={draft}
+ domainText={domainText}
+ error={error}
+ connected={connected}
+ onChange={(patch) => {
+ setDraft({ ...draft, ...patch });
+ setError(null);
+ }}
+ onDomainText={(value) => {
+ setDomainText(value);
+ setError(null);
+ }}
+ onCancel={() => {
+ setDraft(null);
+ setError(null);
+ }}
+ onSave={() => void onSave()}
+ />
+ ) : (
+ <SkillList skills={skills} host={host} />
+ )}
+
+ <input
+ ref={fileInputRef}
+ type="file"
+ accept=".md,.markdown,text/markdown"
+ className="hidden"
+ onChange={() => void onPickFile()}
+ />
+ </div>
+ );
+}
+
+/** Everything the daemon needs, prefilled from the file's own front matter where it had any. */
+function SkillForm({
+ draft,
+ domainText,
+ error,
+ connected,
+ onChange,
+ onDomainText,
+ onCancel,
+ onSave,
+}: {
+ draft: SkillDraft;
+ domainText: string;
+ error: string | null;
+ connected: boolean;
+ onChange: (patch: Partial<SkillDraft>) => void;
+ onDomainText: (value: string) => void;
+ onCancel: () => void;
+ onSave: () => void;
+}) {
+ const isSite = draft.category === 'site-exploration';
+ return (
+ <div className="flex flex-col gap-2">
+ <Input
+ value={draft.name}
+ onChange={(e) => onChange({ name: e.target.value.toLowerCase() })}
+ placeholder="skill-name"
+ aria-label="Skill name"
+ className="h-8 font-mono text-xs"
+ />
+ <Input
+ value={draft.description}
+ onChange={(e) => onChange({ description: e.target.value })}
+ placeholder="What is this for?"
+ aria-label="Skill description"
+ className="h-8 text-xs"
+ />
+
+ <div className="flex gap-1">
+ <Button
+ variant={isSite ? 'outline' : 'default'}
+ size="sm"
+ className="h-7 flex-1 text-xs"
+ onClick={() => onChange({ category: 'general' })}
+ >
+ General
+ </Button>
+ <Button
+ variant={isSite ? 'default' : 'outline'}
+ size="sm"
+ className="h-7 flex-1 text-xs"
+ onClick={() => onChange({ category: 'site-exploration' })}
+ >
+ <Globe className="size-3" /> Site notes
+ </Button>
+ </div>
+
+ {isSite && (
+ <Input
+ value={domainText}
+ onChange={(e) => onDomainText(e.target.value)}
+ placeholder="acme.com, admin.acme.com"
+ aria-label="Domains this skill applies to"
+ className="h-8 font-mono text-xs"
+ />
+ )}
+
+ <p className="line-clamp-3 rounded bg-background/60 px-2 py-1.5 text-[11px] leading-relaxed text-muted-foreground">
+ {draft.body || 'This file has no instructions in it.'}
+ </p>
+
+ {error && (
+ <p className="rounded-md bg-amber-500/10 px-2 py-1.5 text-[11px] text-amber-600 dark:text-amber-400">{error}</p>
+ )}
+
+ <div className="flex gap-1">
+ <Button variant="ghost" size="sm" className="h-7 flex-1 text-xs" onClick={onCancel}>
+ Cancel
+ </Button>
+ <Button size="sm" className="h-7 flex-1 text-xs" onClick={onSave} disabled={!connected}>
+ <Check className="size-3" /> Save skill
+ </Button>
+ </div>
+ {!connected && (
+ <p className="text-center text-[10px] text-muted-foreground">Pair the browser to save skills.</p>
+ )}
+ </div>
+ );
+}
+
+function SkillList({ skills, host }: { skills: StoredSkillMeta[]; host: string }) {
+ if (skills.length === 0) {
+ return (
+ <p className="px-1 py-1 text-[11px] leading-relaxed text-muted-foreground">
+ Upload a markdown file of notes about a site — where things are, how its lists load — and tag it with that
+ site&apos;s domain. It joins the agent&apos;s instructions whenever you are on that site, and stays out of the
+ way everywhere else.
+ </p>
+ );
+ }
+ return (
+ <div className="flex max-h-48 flex-col gap-1.5 overflow-y-auto">
+ {skills.map((skill) => (
+ <SkillRow key={skill.id} skill={skill} host={host} />
+ ))}
+ </div>
+ );
+}
+
+function SkillRow({ skill, host }: { skill: StoredSkillMeta; host: string }) {
+ // The one thing worth knowing at a glance: is this skill in play on the tab I am looking at?
+ const activeHere = skill.category === 'site-exploration' && hostMatchesDomains(host, skill.domains);
+ const generated = skill.origin === 'generated';
+ const Icon = generated ? Compass : BookOpen;
+ return (
+ <div className="flex items-start gap-2 rounded-md border bg-background/60 px-2.5 py-1.5 text-xs">
+ <Icon className={cn('mt-0.5 size-3.5 shrink-0', activeHere ? 'text-emerald-500' : 'text-muted-foreground')} />
+ <div className="min-w-0 flex-1">
+ <div className="flex items-center gap-1.5">
+ <span className="truncate font-medium">{skill.name}</span>
+ {generated && (
+ <Badge variant="outline" className="h-4 shrink-0 px-1 text-[10px]">
+ mapped
+ </Badge>
+ )}
+ {activeHere && (
+ <Badge variant="secondary" className="h-4 shrink-0 px-1 text-[10px]">
+ on this site
+ </Badge>
+ )}
+ </div>
+ {skill.domains.length > 0 && (
+ <p className="mt-0.5 truncate font-mono text-[10px] text-muted-foreground">{skill.domains.join(', ')}</p>
+ )}
+ {skill.description && (
+ <p className="mt-0.5 line-clamp-2 text-[11px] text-muted-foreground">{skill.description}</p>
+ )}
+ {skill.status === 'pending' && (
+ <span className="mt-0.5 flex items-center gap-1 text-[11px] text-muted-foreground">
+ <Loader2 className="size-3 animate-spin" /> Saving…
+ </span>
+ )}
+ {skill.status === 'error' && (
+ <span className="mt-0.5 block text-[11px] text-destructive">{skill.error ?? 'Could not save'}</span>
+ )}
+ </div>
+ <button
+ type="button"
+ onClick={() =>
+ void browser.runtime.sendMessage({ channel: BRIDGE_CHANNEL, op: 'removeSkill', skillId: skill.id })
+ }
+ aria-label={`Remove ${skill.name}`}
+ className="mt-0.5 shrink-0 rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground"
+ >
+ <X className="size-3" />
+ </button>
+ </div>
+ );
+}
diff --git a/entrypoints/sidepanel/App.tsx b/entrypoints/sidepanel/App.tsx
index f257054..039c41c 100644
--- a/entrypoints/sidepanel/App.tsx
+++ b/entrypoints/sidepanel/App.tsx
@@ -1,15 +1,18 @@
import { useEffect, useRef, useState } from 'react';
-import { AudioLines, Bot, FileText, FileUp, Loader2, Mic, MicOff, Paperclip, RotateCcw, Send, Square, X } from 'lucide-react';
+import { AudioLines, Bot, BookOpen, FileText, FileUp, Loader2, Mic, MicOff, Paperclip, RotateCcw, Send, Square, X } from 'lucide-react';
import { browser } from 'wxt/browser';
import { invokeInActiveTab } from '@/lib/actions/client';
import { getPageInfo } from '@/lib/actions/page/get-page-info';
import { BRIDGE_CHANNEL } from '@/lib/actions/protocol';
import { RunTimeline } from '@/components/run-timeline';
+import { SiteMapReview } from '@/components/site-map-review';
+import { SkillsPanel } from '@/components/skills-panel';
import { Button } from '@/components/ui/button';
import { ScrollArea } from '@/components/ui/scroll-area';
import { Textarea } from '@/components/ui/textarea';
import { putFile, removeFile, type StoredFileMeta } from '@/lib/bridge/file-store';
+import { useActiveTabUrl } from '@/lib/bridge/use-active-tab-url';
import { useDaemonState } from '@/lib/bridge/use-daemon-state';
import { useRun } from '@/lib/bridge/use-run';
import { useStoredFiles } from '@/lib/bridge/use-stored-files';
@@ -27,7 +30,9 @@ export default function App() {
const bottomRef = useRef<HTMLDivElement>(null);
const fileInputRef = useRef<HTMLInputElement>(null);
const files = useStoredFiles();
+ const tabUrl = useActiveTabUrl();
const [attachError, setAttachError] = useState<string | null>(null);
+ const [skillsOpen, setSkillsOpen] = useState(false);
const connected = daemon?.connected ?? false;
@@ -145,6 +150,20 @@ export default function App() {
{attachError}
</p>
)}
+ {run.draft && (
+ <SiteMapReview draft={run.draft} onActivate={run.activateMap} onDiscard={run.discardMap} />
+ )}
+ {skillsOpen && (
+ <SkillsPanel
+ tabUrl={tabUrl}
+ connected={connected}
+ onMapSite={() => {
+ setSkillsOpen(false);
+ run.mapSite();
+ }}
+ mapping={run.running}
+ />
+ )}
<FilesList files={files} onRemove={(id) => void removeFile(id)} />
<VoiceStatus voice={voice} voiceEnabled={voiceEnabled} connected={connected} />
@@ -181,6 +200,14 @@ export default function App() {
>
<FileUp />
</Button>
+ <Button
+ variant={skillsOpen ? 'default' : 'ghost'}
+ size="icon"
+ aria-label={skillsOpen ? 'Hide skills' : 'Show skills'}
+ onClick={() => setSkillsOpen(!skillsOpen)}
+ >
+ <BookOpen />
+ </Button>
<Button
variant={voiceEnabled && !voice.error ? 'default' : 'ghost'}
size="icon"
diff --git a/lib/bridge/use-active-tab-url.ts b/lib/bridge/use-active-tab-url.ts
new file mode 100644
index 0000000..0773fda
--- /dev/null
+++ b/lib/bridge/use-active-tab-url.ts
@@ -0,0 +1,45 @@
+import { useEffect, useState } from 'react';
+import { browser } from 'wxt/browser';
+
+/**
+ * The URL of the tab this extension page is looking at, kept current as the user switches tabs
+ * or navigates. It decides which uploaded skills apply, so the panel can show that before an
+ * instruction is sent, and it rides along on the instruction itself.
+ *
+ * `currentWindow: true` is unambiguous here because an extension page belongs to one window —
+ * this is why the tab is resolved in the page rather than in the shared background worker.
+ * Reading `tab.url` needs no `tabs` permission: the manifest's host permissions cover it.
+ */
+export function useActiveTabUrl(): string {
+ const [url, setUrl] = useState('');
+
+ useEffect(() => {
+ let live = true;
+ const refresh = () => {
+ void browser.tabs
+ .query({ active: true, currentWindow: true })
+ .then(([tab]) => {
+ if (live) setUrl(tab?.url ?? '');
+ })
+ .catch(() => {
+ if (live) setUrl('');
+ });
+ };
+ refresh();
+
+ const onActivated = () => refresh();
+ // Only the active tab's own navigations matter; a background tab loading is noise.
+ const onUpdated = (_id: number, changes: { url?: string }, tab: { active?: boolean }) => {
+ if (changes.url && tab.active) refresh();
+ };
+ browser.tabs.onActivated.addListener(onActivated);
+ browser.tabs.onUpdated.addListener(onUpdated);
+ return () => {
+ live = false;
+ browser.tabs.onActivated.removeListener(onActivated);
+ browser.tabs.onUpdated.removeListener(onUpdated);
+ };
+ }, []);
+
+ return url;
+}