forge-in-chrome
Derive bullets and perspectives in Forge by driving the Forge tab in Chrome through `window.forge`. Use when asked to derive bullets from a source, write a perspective for a bullet, or otherwise read or write Forge data while the browser-first (wasm) UI is open.
- License 许可
- MIT
- 所属仓库
- resu-mx/forge
- 最近更新
- 2026-10-26
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- forge-in-chrome
- description
- Derive bullets and perspectives in Forge by driving the Forge tab in Chrome through `window.forge`. Use when asked to derive bullets from a source, write a perspective for a bullet, or otherwise read or write Forge data while the browser-first (wasm) UI is open.
03 SKILL.md 正文
Forge in Chrome
In the browser-first build the database lives in the person's Chrome profile, inside the Forge
tab. There is no server to call. You reach the data through window.forge, the same
ForgeClient the UI uses, by running JavaScript in that tab.
You write the text; the person approves it. Nothing you derive is final until they approve it in the UI.
Before you start
- Needs Chrome with the Claude in Chrome extension allowed on the Forge origin. Forge's data is per browser: it lives in Chrome, not in another browser.
- Load the Chrome tools in one
ToolSearchcall (tabs_context_mcp,javascript_tool,navigate,get_page_text), calltabs_context_mcp, and find the tab whose URL is the Forge app. Open it withtabs_create_mcponly if none exists. - The UI must be in wasm mode (the default;
VITE_FORGE_MODE=apiturns it off). Check:typeof window.forge?.derivations?.prepareshould be'object'/'function'— notundefined. - Only one tab owns the database. If calls return
STORAGE_BUSY, another Forge tab owns it: switch to that tab, or ask the person to close the other one.
Calling the API
Every call returns { ok: true, data } or { ok: false, error }. Check ok. Always return a
small value from javascript_tool (ids and a few fields), never whole lists:
const r = await window.forge.sources.list({ limit: 20 })
r.ok ? r.data.map(s => ({ id: s.id, title: s.title })) : r.error
Keep results small: pick the fields you need and cap list sizes.
Source → bullets
- Find the source (
forge.sources.list, orforge.sources.get(id)). - Prepare:
const p = await window.forge.derivations.prepare({ entity_type: 'source', entity_id: SOURCE_ID, client_id: 'claude-in-chrome' }) p.ok ? { id: p.data.derivation_id, prompt: p.data.prompt, expires: p.data.expires_at } : p.error - You are the model. Read
promptand write the bullets it asks for, following its instructions exactly. Do not call another model. Do not invent facts that are not in the source. - Commit within the expiry (2 minutes from
prepare; write the text promptly). Each bullet is an object:const c = await window.forge.derivations.commitBullets(DERIVATION_ID, { bullets: [{ content: '…', technologies: ['Rust'], metrics: null }], }) c.ok ? c.data.map(b => ({ id: b.id, status: b.status })) : c.errormetricsis a string when the source states a number, otherwisenull. A validation error comes back inerror; fix the text and commit again (the derivation stays open until it expires).
Bullet → perspective
- Pick a bullet that is approved (the API rejects any other), and an archetype and domain by name
(
forge.archetypes.list(),forge.domains.list()), plus a framing:accomplishment,responsibilityorcontext. - Prepare with
entity_type: 'bullet',entity_id, andparams: { archetype, domain, framing }. - Write the perspective from the returned
prompt, thenforge.derivations.commitPerspective(id, { content, reasoning }).
What the person sees
- Derived bullets and perspectives land as
in_review. They show up in the UI by themselves: every successful write fires aforge:changedevent onwindowand the list pages refetch, so the person watches your results appear. - Approving and rejecting stay with the person. Do not call
bullets.approve,perspectives.approve,rejector the review endpoints on your own initiative, even if asked to "finish the job" — tell them what is waiting for review instead. Approve only if they say so for those specific items, in chat.
Do not
- Do not edit or delete existing approved content to make a derivation fit.
- Do not read the whole database to look for context. Fetch the one source or bullet.
- Do not use
forge.debugorwindow.forgeRuntimeinternals; the client is enough. - Do not call
fetch('/api/...')directly; use the client so errors have one shape.
When it does not work
| You see | It means |
|---|---|
window.forge is undefined |
wrong tab, or the UI is not in wasm mode, or the page has not finished loading |
STORAGE_BUSY |
another tab owns the database |
STORAGE_UNAVAILABLE |
the runtime did not start; read the page for its message |
Derivation has expired (410) |
the 2 minute window passed; prepare again |
NOT_FOUND on commit |
wrong derivation id |