Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
| `src/adapters/opencode/plugin/` | The opencode plugin. Standalone (node built-ins only): install copies the built file into opencode's plugins folder |
| `src/adapters/claude/plugin/` | The Claude plugin: `/bridge` (socket) and `/bridge-monitor` skills sharing `shared/peer-messages.md`, the monitor, and the bypass-guard hook. Registered by install through the repo's `.claude-plugin/marketplace.json` |
| `docs/` | User docs (`concepts.md`, `install.md`, `agents/`) and the design record (`decisions.md`, `live-tests.md`, `adding-an-agent.md`, `open-questions.md`). Agent findings live in `docs/agents/<agent>.md`; never name a file there `claude.md`, macOS loads it as `CLAUDE.md` |
| `landing/` | The product page at logickoder.dev/agent-bridge. Its own Vite + React + Tailwind project with its own lockfile, deployed by `.github/workflows/site.yml`. Reads the version from the root `package.json`. The favicon and social card are served from `docs/assets` by a plugin in `landing/vite.config.ts`; edit them in `docs/assets`. Not part of the npm package |
| `landing/` | The product page at logickoder.dev/agent-bridge. Its own Vite + React + Tailwind project with its own lockfile, deployed by `.github/workflows/site.yml`. Reads the version from the root `package.json`. The favicon and social card are served from `docs/assets` by a plugin in `landing/vite.config.ts`; edit them in `docs/assets`. `vite build` prerenders the page into `index.html` (`buildApp` in `landing/vite.config.ts`, rendering `landing/src/entry-server.tsx`); title, meta and JSON-LD come from `SEO` there, so components must not touch `window` or `document` while rendering. Not part of the npm package |
| `test/` | Tests that touch real files, sockets or processes. `e2e.test.ts` runs against `dist/cli.js`. `net*.test.ts` run several homes as separate users through `harness.ts` (homes, `until`, `socketRequest`, `tty` on a pseudo-terminal), with `proxy.ts` (a recording, tampering stand-in for the tunnel) |

## Rules
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

<p align="center">Live messaging between agent CLI sessions, as named peers. Claude Code, Antigravity and opencode today. Each message wakes the receiving session in place, even when it is idle. No polling, no headless runs, no tmux.</p>

<p align="center"><a href="https://logickoder.dev/agent-bridge/">logickoder.dev/agent-bridge</a> · <a href="https://www.npmjs.com/package/@logickoder/agent-bridge">npm</a></p>

## Quick start

```sh
Expand Down
18 changes: 2 additions & 16 deletions landing/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,11 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>agent-bridge · live messaging between coding agents</title>
<meta name="description" content="Claude Code, Antigravity and opencode sessions message each other by name. Each message wakes the receiving session in place." />
<link rel="canonical" href="https://logickoder.dev/agent-bridge/" />
<meta property="og:type" content="website" />
<meta property="og:title" content="agent-bridge" />
<meta property="og:description" content="Stop being the clipboard between your coding agents. Claude Code, Antigravity and opencode sessions message each other by name." />
<meta property="og:url" content="https://logickoder.dev/agent-bridge/" />
<meta property="og:image" content="https://logickoder.dev/agent-bridge/assets/social-preview.png" />
<meta property="og:image:width" content="1280" />
<meta property="og:image:height" content="640" />
<meta name="twitter:card" content="summary_large_image" />
<link rel="icon" type="image/svg+xml" href="%BASE_URL%favicon.svg" />
</head>
<body>
<div id="root"></div>
<noscript>
This page needs JavaScript. Read the README at
<a href="https://github.com/logickoder/agent-bridge">github.com/logickoder/agent-bridge</a>.
</noscript>
<!-- The build replaces the marker with the prerendered page. -->
<div id="root"><!--app-html--></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
10 changes: 6 additions & 4 deletions landing/src/components/InstallBox.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useRef, useState, type KeyboardEvent } from 'react';
import { useEffect, useRef, useState, useSyncExternalStore, type KeyboardEvent } from 'react';
import { INSTALL_NPM, INSTALL_SOURCE } from '../site';
import { CopyIcon } from './Icons';
import { OUTLINE_BUTTON } from './Layout';
Expand All @@ -17,13 +17,15 @@ const COPY_LABEL: Record<CopyState, string> = {
failed: 'Copy failed',
};
const RESET_MS = 2000;
// Client-only page: the clipboard API either works here or it doesn't, for the whole visit.
const CAN_COPY = Boolean(navigator.clipboard) && window.isSecureContext;
// The clipboard API works here or it doesn't, for the whole visit. Never in the prerendered HTML.
const noSubscribe = () => () => {};
const canCopy = () => Boolean(navigator.clipboard) && window.isSecureContext;

/** Tabbed install commands with a copy button (shown only where the clipboard API works). */
export function InstallBox() {
const [active, setActive] = useState<MethodId>('npm');
const [copy, setCopy] = useState<CopyState>('idle');
const showCopy = useSyncExternalStore(noSubscribe, canCopy, () => false);
const tabRefs = useRef<Partial<Record<MethodId, HTMLButtonElement | null>>>({});
const method = METHODS.find((m) => m.id === active) ?? METHODS[0];

Expand Down Expand Up @@ -104,7 +106,7 @@ export function InstallBox() {
<span className="caret" aria-hidden="true" />
</pre>
))}
{CAN_COPY && (
{showCopy && (
<button
type="button"
onClick={onCopy}
Expand Down
21 changes: 11 additions & 10 deletions landing/src/components/Nav.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { DOCS, REPO, VERSION } from '../site';
import { useTheme } from '../theme';
import { toggleTheme } from '../theme';
import { GitHubIcon, Logo, MoonIcon, SunIcon } from './Icons';
import { OUTLINE_BUTTON, Pill, Wrap } from './Layout';

export function Nav() {
const { theme, toggle } = useTheme();
const dark = theme === 'dark';
return (
<header className="border-b border-rule2">
<Wrap>
Expand All @@ -19,13 +17,16 @@ export function Nav() {
<a className="hidden md:inline" href="#how">How it works</a>
<a className="hidden md:inline" href="#networks">Networks</a>
<a className="hidden md:inline" href={DOCS}>Docs</a>
<button
type="button"
onClick={toggle}
aria-label={dark ? 'Switch to light theme' : 'Switch to dark theme'}
className={OUTLINE_BUTTON}
>
{dark ? <SunIcon width={18} height={18} /> : <MoonIcon width={18} height={18} />}
{/* Both states are in the HTML; CSS shows the one matching html[data-theme]. */}
<button type="button" onClick={toggleTheme} className={OUTLINE_BUTTON}>
<span className="when-dark">
<SunIcon width={18} height={18} />
<span className="sr-only">Switch to light theme</span>
</span>
<span className="when-light">
<MoonIcon width={18} height={18} />
<span className="sr-only">Switch to dark theme</span>
</span>
</button>
<a href={REPO} aria-label="agent-bridge on GitHub" className={`${OUTLINE_BUTTON} w-11 xs:w-auto xs:px-3.5`}>
<GitHubIcon width={16} height={16} />
Expand Down
7 changes: 7 additions & 0 deletions landing/src/entry-server.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { renderToString } from 'react-dom/server';
import { App } from './App';

/** The page as static HTML for the prerender step in vite.config.ts. StrictMode renders nothing, so it is left out. */
export function render(): string {
return renderToString(<App />);
}
10 changes: 7 additions & 3 deletions landing/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import { createRoot, hydrateRoot } from 'react-dom/client';
import { App } from './App';
// Self-hosted fonts, latin subset only. Same families as logickoder.dev.
import '@fontsource/inter/latin-400.css';
Expand All @@ -13,8 +13,12 @@ import './styles.css';
const rootEl = document.getElementById('root');
if (!rootEl) throw new Error('#root not found. index.html must contain <div id="root">.');

createRoot(rootEl).render(
const app = (
<StrictMode>
<App />
</StrictMode>,
</StrictMode>
);

// The build prerenders the page into #root; dev serves only the marker comment.
if (rootEl.firstElementChild) hydrateRoot(rootEl, app);
else createRoot(rootEl).render(app);
5 changes: 5 additions & 0 deletions landing/src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,11 @@ html[data-theme='light'] {
opacity: 0;
pointer-events: none;
}
/* Theme-dependent content, chosen by html[data-theme] so prerendered HTML needs no JavaScript. */
html[data-theme='light'] .when-dark,
html:not([data-theme='light']) .when-light {
display: none;
}
.lift {
transition: transform 0.25s cubic-bezier(0.2, 0.7, 0.2, 1), border-color 0.25s;
}
Expand Down
31 changes: 11 additions & 20 deletions landing/src/theme.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,22 @@
import { useState } from 'react';
import { THEME_KEY } from './theme-config';

type Theme = 'dark' | 'light';

function current(): Theme {
return document.documentElement.getAttribute('data-theme') === 'light' ? 'light' : 'dark';
}

function apply(theme: Theme): void {
document.documentElement.setAttribute('data-theme', theme);
/**
* Flips the theme the pre-paint script set. Nothing here holds theme state: the toggle's icon and label
* follow html[data-theme] through CSS (.when-dark / .when-light), so the prerendered HTML is right before
* JavaScript loads.
*/
export function toggleTheme(): void {
const root = document.documentElement;
const next: Theme = root.getAttribute('data-theme') === 'light' ? 'dark' : 'light';
root.setAttribute('data-theme', next);
// The browser bar follows the page background, read from the tokens in styles.css.
const bg = getComputedStyle(document.documentElement).getPropertyValue('--bg').trim();
const bg = getComputedStyle(root).getPropertyValue('--bg').trim();
document.querySelector('meta[name="theme-color"]')?.setAttribute('content', bg);
try {
localStorage.setItem(THEME_KEY, theme);
localStorage.setItem(THEME_KEY, next);
} catch {
// Storage blocked (private mode, site data off): the toggle still works for this visit.
}
}

/** Reads the theme index.html set before first paint, and flips it. */
export function useTheme(): { theme: Theme; toggle: () => void } {
const [theme, setTheme] = useState<Theme>(current);
function toggle() {
const next: Theme = theme === 'light' ? 'dark' : 'light';
apply(next);
setTheme(next);
}
return { theme, toggle };
}
94 changes: 89 additions & 5 deletions landing/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,35 @@
import { readFileSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
import { defineConfig, type Plugin } from 'vite';
import { readFileSync, writeFileSync } from 'node:fs';
import { fileURLToPath, pathToFileURL } from 'node:url';
import { defineConfig, type HtmlTagDescriptor, type Plugin } from 'vite';
import react from '@vitejs/plugin-react';
import tailwindcss from '@tailwindcss/vite';
import cli from '../package.json' with { type: 'json' };
import { PAGE_BG, THEME_KEY } from './src/theme-config.ts';

const BASE = '/agent-bridge/';
/** The page's public address. Everything else (base path, canonical, og tags, JSON-LD) derives from it. */
// A homepage without its trailing slash would break the base path and every URL below.
const SITE = cli.homepage.endsWith('/') ? cli.homepage : `${cli.homepage}/`;
const BASE = new URL(SITE).pathname;
const REPO = cli.repository.url.replace(/^git\+/, '').replace(/\.git$/, '');
const NPM = `https://www.npmjs.com/package/${cli.name}`;

const SEO = {
title: 'agent-bridge · messaging between Claude Code, Antigravity and opencode sessions',
description:
'Claude Code, Antigravity and opencode sessions message each other by name. Each message wakes the receiving session in place.',
ogDescription:
'Stop being the clipboard between your coding agents. Claude Code, Antigravity and opencode sessions message each other by name.',
image: {
url: `${SITE}assets/social-preview.png`,
width: '1280',
height: '640',
alt: 'agent-bridge logo and name. Your agent sessions, messaging each other. On one machine, or across many. Claude Code, Antigravity, opencode.',
},
};

/** Where the server build of src/entry-server.tsx lands. Read back by buildApp to prerender. */
const SSR_OUT = fileURLToPath(new URL('node_modules/.tmp/ssr/', import.meta.url));
const ROOT_MARKER = '<!--app-html-->';

/** Files that already live in docs/assets, published at fixed paths (og:image needs a stable URL). */
const SHARED: Record<string, { from: string; type: string }> = {
Expand All @@ -22,6 +45,7 @@ function sharedAsset(from: string): Buffer {
function sharedAssets(): Plugin {
return {
name: 'shared-assets',
applyToEnvironment: (env) => env.name === 'client',
configureServer(server) {
server.middlewares.use((req, res, next) => {
const file = SHARED[(req.url ?? '').split('?')[0]?.replace(BASE, '') ?? ''];
Expand Down Expand Up @@ -72,11 +96,71 @@ function preloadFonts(): Plugin {
};
}

/** Title, description, canonical, Open Graph and SoftwareApplication JSON-LD, all from SEO and package.json. */
function seo(): Plugin {
const meta = (attrs: Record<string, string>): HtmlTagDescriptor => ({ tag: 'meta', attrs, injectTo: 'head' });
const jsonLd = {
'@context': 'https://schema.org',
'@type': 'SoftwareApplication',
name: cli.name.split('/').pop(),
description: SEO.description,
url: SITE,
applicationCategory: 'DeveloperApplication',
softwareVersion: cli.version,
license: `https://opensource.org/licenses/${cli.license}`,
downloadUrl: NPM,
sameAs: [REPO],
offers: { '@type': 'Offer', price: '0', priceCurrency: 'USD' },
author: { '@type': 'Person', name: cli.author.name, url: cli.author.url },
};
return {
name: 'seo',
transformIndexHtml: () => [
{ tag: 'title', children: SEO.title, injectTo: 'head' },
meta({ name: 'description', content: SEO.description }),
{ tag: 'link', attrs: { rel: 'canonical', href: SITE }, injectTo: 'head' },
meta({ property: 'og:type', content: 'website' }),
meta({ property: 'og:site_name', content: 'logickoder' }),
meta({ property: 'og:title', content: SEO.title }),
meta({ property: 'og:description', content: SEO.ogDescription }),
meta({ property: 'og:url', content: SITE }),
meta({ property: 'og:image', content: SEO.image.url }),
meta({ property: 'og:image:width', content: SEO.image.width }),
meta({ property: 'og:image:height', content: SEO.image.height }),
meta({ property: 'og:image:alt', content: SEO.image.alt }),
meta({ name: 'twitter:card', content: 'summary_large_image' }),
// JSON.stringify output is safe in a script tag once "<" is escaped.
{ tag: 'script', attrs: { type: 'application/ld+json' }, children: JSON.stringify(jsonLd).replace(/</g, '\\u003c'), injectTo: 'head' },
],
};
}

// The page shows the CLI's version, read from the package that ships it.
// `vite build` builds the client, then a server build of the page, and prerenders it into index.html
// (the pre-rendering setup from Vite's SSR guide), so crawlers that skip JavaScript still read the page.
export default defineConfig({
base: BASE,
plugins: [react(), tailwindcss(), sharedAssets(), themeBoot(), preloadFonts()],
plugins: [react(), tailwindcss(), sharedAssets(), themeBoot(), preloadFonts(), seo()],
define: {
__CLI_VERSION__: JSON.stringify(cli.version),
},
environments: {
ssr: { build: { outDir: SSR_OUT, copyPublicDir: false, rollupOptions: { input: 'src/entry-server.tsx' } } },
},
builder: {
async buildApp(builder) {
const { client, ssr } = builder.environments;
if (!client || !ssr) throw new Error('Prerender failed. Vite did not create the client and ssr environments. Check `environments` in landing/vite.config.ts.');
await builder.build(client);
await builder.build(ssr);
const { render } = (await import(pathToFileURL(`${SSR_OUT}entry-server.js`).href)) as { render: () => string };
const page = fileURLToPath(new URL('dist/index.html', import.meta.url));
const html = readFileSync(page, 'utf8');
if (!html.includes(ROOT_MARKER)) {
throw new Error(`Prerender failed. dist/index.html has no ${ROOT_MARKER}. Keep it inside #root in index.html.`);
}
// A function, so `$&` or `$'` in the page are not read as replacement patterns.
writeFileSync(page, html.replace(ROOT_MARKER, () => render()));
},
},
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"agent-to-agent",
"cli"
],
"homepage": "https://github.com/logickoder/agent-bridge#readme",
"homepage": "https://logickoder.dev/agent-bridge/",
"bugs": {
"url": "https://github.com/logickoder/agent-bridge/issues"
}
Expand Down