genaicode 2.18.2 → 2.18.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ui.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { AgentSession, SessionState } from './agents/session.js';
2
2
  import type { AgentTask, ApprovalDecision, CodingAgent } from './agents/types.js';
3
+ import { type Overlay, type OverlayLog } from './overlay/server.js';
3
4
  /**
4
5
  * `genaicode/ui`: the `genaicode ui` chat served on 127.0.0.1 for a host that shows it in its
5
6
  * own page (an iframe) and wants a say in the session: MCP servers, env, a prompt prefix.
@@ -7,6 +8,9 @@ import type { AgentTask, ApprovalDecision, CodingAgent } from './agents/types.js
7
8
  * The UI itself (React, Ink) is bundled in `dist/ui/` and loaded only when
8
9
  * `startEmbeddedWeb` runs, so importing this module pulls no UI code. For a chat drawn by the
9
10
  * host's own React tree, use `genaicode/react` instead.
11
+ *
12
+ * `createDevOverlay` puts the same chat into any Node dev server the way `genaicode/vite` does
13
+ * for Vite: the genaicode wolf in the page's corner, with the page's errors in its badge.
10
14
  */
11
15
  export interface EmbeddedWebOptions {
12
16
  /** Directory the agent works in. */
@@ -69,3 +73,30 @@ export type EmbeddedWebBundleOptions = EmbeddedWebOptions & {
69
73
  * `NoAgentError` when no agent CLI is installed (or `agent` is unknown).
70
74
  */
71
75
  export declare function startEmbeddedWeb(options: EmbeddedWebOptions): Promise<EmbeddedWeb>;
76
+ export interface DevOverlayOptions extends Omit<EmbeddedWebOptions, 'cwd' | 'frameAncestors'> {
77
+ /** Directory the agent works in. Default: `process.cwd()`. */
78
+ cwd?: string;
79
+ /** Collect the page's errors and offer to send them to the agent. Default true. */
80
+ captureErrors?: boolean;
81
+ /** Where the overlay says it started, or why not. Default: `console`. */
82
+ log?: OverlayLog;
83
+ }
84
+ /** The genaicode overlay for a dev server: its routes, and the tag that puts it in a page. */
85
+ export type DevOverlay = Overlay<EmbeddedWeb>;
86
+ /**
87
+ * The genaicode overlay for a dev server other than Vite (Express, webpack-dev-server, a
88
+ * script that serves static files...): the wolf in the corner opens the chat with the agent
89
+ * working in `cwd`, its badge counts the page's errors, and "Fix N errors" sends them to the
90
+ * agent. Development only.
91
+ *
92
+ * ```js
93
+ * const overlay = createDevOverlay();
94
+ * app.use(overlay.middleware); // Express, before the app's routes
95
+ * // ...and overlay.script in the dev HTML, or overlay.injectHtml(html) where HTML is served.
96
+ * ```
97
+ *
98
+ * The chat starts in the background on 127.0.0.1. Its token goes only to the app's own pages
99
+ * (same-origin), on this machine, opened at a loopback name (localhost, *.localhost,
100
+ * 127.0.0.1, [::1]). Without an agent CLI the overlay stays off and the app runs on.
101
+ */
102
+ export declare function createDevOverlay(options?: DevOverlayOptions): DevOverlay;
package/dist/ui.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { createRequire } from 'node:module';
2
2
  import { defaultAgents } from './agents/defaults.js';
3
+ import { createOverlay } from './overlay/server.js';
3
4
  /**
4
5
  * Start the chat UI on 127.0.0.1 for the host's page. Rejects with an error named
5
6
  * `NoAgentError` when no agent CLI is installed (or `agent` is unknown).
@@ -13,6 +14,26 @@ export async function startEmbeddedWeb(options) {
13
14
  frameAncestors: options.frameAncestors ?? (() => []),
14
15
  });
15
16
  }
17
+ /**
18
+ * The genaicode overlay for a dev server other than Vite (Express, webpack-dev-server, a
19
+ * script that serves static files...): the wolf in the corner opens the chat with the agent
20
+ * working in `cwd`, its badge counts the page's errors, and "Fix N errors" sends them to the
21
+ * agent. Development only.
22
+ *
23
+ * ```js
24
+ * const overlay = createDevOverlay();
25
+ * app.use(overlay.middleware); // Express, before the app's routes
26
+ * // ...and overlay.script in the dev HTML, or overlay.injectHtml(html) where HTML is served.
27
+ * ```
28
+ *
29
+ * The chat starts in the background on 127.0.0.1. Its token goes only to the app's own pages
30
+ * (same-origin), on this machine, opened at a loopback name (localhost, *.localhost,
31
+ * 127.0.0.1, [::1]). Without an agent CLI the overlay stays off and the app runs on.
32
+ */
33
+ export function createDevOverlay(options = {}) {
34
+ const { captureErrors = true, log = console, ...web } = options;
35
+ return createOverlay((frameAncestors) => startEmbeddedWeb({ ...web, cwd: web.cwd ?? process.cwd(), frameAncestors }), { captureErrors, log });
36
+ }
16
37
  /** The front ends are bundled into dist/ui by scripts/build-ui.mjs; the path is kept opaque to tsc. */
17
38
  function loadBundledUi() {
18
39
  const bundle = new URL('./ui/index.js', import.meta.url).href;
package/dist/ui.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"ui.js","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAyErD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,OAA2B;IAChE,MAAM,EAAE,GAAG,MAAM,aAAa,EAAE,CAAC;IACjC,OAAO,EAAE,CAAC,gBAAgB,CAAC;QACzB,GAAG,OAAO;QACV,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,aAAa,EAAE;QACzC,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,cAAc,EAAE;QAC5C,cAAc,EAAE,OAAO,CAAC,cAAc,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC;KACrD,CAAC,CAAC;AACL,CAAC;AAED,uGAAuG;AACvG,SAAS,aAAa;IACpB,MAAM,MAAM,GAAW,IAAI,GAAG,CAAC,eAAe,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;IACtE,OAAO,MAAM,CAAC,MAAM,CAAsB,CAAC;AAC7C,CAAC;AAED,SAAS,cAAc;IACrB,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/C,OAAQ,OAAO,CAAC,iBAAiB,CAAyB,CAAC,OAAO,CAAC;AACrE,CAAC"}
1
+ {"version":3,"file":"ui.js","sourceRo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,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/C,OAAQ,OAAO,CAAC,iBAAiB,CAAyB,CAAC,OAAO,CAAC;AACrE,CAAC"}
@@ -1,5 +1,7 @@
1
1
  import type { Plugin } from 'vite';
2
2
  import type { CodingAgent } from '../agents/types.js';
3
+ import { type OverlayUi } from '../overlay/server.js';
4
+ export { fixPrompt, isLoopback } from '../overlay/server.js';
3
5
  export interface GenaicodeViteOptions {
4
6
  /** Agent to start with. Default: the first installed one. */
5
7
  agent?: string;
@@ -29,18 +31,7 @@ export interface EmbeddedUiModule {
29
31
  version: string;
30
32
  port?: number;
31
33
  frameAncestors: () => readonly string[];
32
- }): Promise<{
33
- url: string;
34
- controller: {
35
- submit(text: string): unknown;
36
- get(): {
37
- session: {
38
- agent: string;
39
- };
40
- };
41
- };
42
- close(): Promise<void>;
43
- }>;
34
+ }): Promise<OverlayUi>;
44
35
  }
45
36
  /**
46
37
  * `genaicode/vite`: the genaicode UI inside a Vite dev server. The page gets a wolf in the
@@ -51,7 +42,3 @@ export interface EmbeddedUiModule {
51
42
  * server started with `--host` does not expose the agent to the network.
52
43
  */
53
44
  export declare function genaicode(options?: GenaicodeViteOptions): Plugin;
54
- /** The prompt for "Fix N errors", or undefined when the body is not a list of errors. */
55
- export declare function fixPrompt(body: unknown): string | undefined;
56
- /** 127.0.0.0/8 and ::1, also as IPv4-mapped IPv6 addresses. */
57
- export declare function isLoopback(address: string | undefined): boolean;
@@ -1,9 +1,8 @@
1
1
  import { createRequire } from 'node:module';
2
2
  import { defaultAgents } from '../agents/defaults.js';
3
- import { mountOverlay } from './overlay.js';
4
- const API = '/__genaicode';
3
+ import { API, handleOverlayRequest, overlayModule, startOverlayUi } from '../overlay/server.js';
4
+ export { fixPrompt, isLoopback } from '../overlay/server.js';
5
5
  const OVERLAY_ID = 'virtual:genaicode-overlay';
6
- const MAX_BODY = 256 * 1024;
7
6
  /**
8
7
  * `genaicode/vite`: the genaicode UI inside a Vite dev server. The page gets a wolf in the
9
8
  * corner that opens the chat with a coding agent working in the project, and its errors
@@ -14,6 +13,7 @@ const MAX_BODY = 256 * 1024;
14
13
  */
15
14
  export function genaicode(options = {}) {
16
15
  let started;
16
+ const overlay = { api: API, captureErrors: options.captureErrors ?? true };
17
17
  let base = '/';
18
18
  // Origins the app's pages were actually opened at (e.g. app.localhost), for frame-ancestors.
19
19
  const seen = new Set();
@@ -24,38 +24,29 @@ export function genaicode(options = {}) {
24
24
  base = config.base;
25
25
  },
26
26
  configureServer(server) {
27
- const log = server.config.logger;
28
- started = (async () => {
27
+ started = startOverlayUi(async () => {
29
28
  const ui = await (options.loadUi ?? loadBundledUi)();
30
- try {
31
- return await ui.startEmbeddedWeb({
32
- agents: options.agents ?? defaultAgents(),
33
- agent: options.agent,
34
- cwd: server.config.root,
35
- model: options.model,
36
- effort: options.effort,
37
- approveAll: options.approveAll,
38
- version: packageVersion(),
39
- port: options.port,
40
- frameAncestors: () => pageOrigins(server, seen),
41
- });
42
- }
43
- catch (error) {
44
- if (!(error instanceof ui.NoAgentError))
45
- throw error;
46
- log.warn(`[genaicode] ${error.message} The overlay is off.`);
47
- return undefined;
48
- }
49
- })().then((ui) => {
50
- if (ui)
51
- log.info(` ➜ genaicode: ${ui.controller.get().session.agent} in the page, or open ${ui.url}`);
52
- return ui;
53
- }, (error) => {
54
- log.error(`[genaicode] The UI did not start: ${error.message}`);
55
- return undefined;
56
- });
57
- server.middlewares.use(API, (req, res, next) => {
58
- handleApi(req, res, started, (origin) => seen.add(origin), !!server.config.server.https).catch(next);
29
+ return ui.startEmbeddedWeb({
30
+ agents: options.agents ?? defaultAgents(),
31
+ agent: options.agent,
32
+ cwd: server.config.root,
33
+ model: options.model,
34
+ effort: options.effort,
35
+ approveAll: options.approveAll,
36
+ version: packageVersion(),
37
+ port: options.port,
38
+ frameAncestors: () => pageOrigins(server, seen),
39
+ });
40
+ }, server.config.logger);
41
+ server.middlewares.use((req, res, next) => {
42
+ handleOverlayRequest(req, res, {
43
+ ui: started,
44
+ onPage: (origin) => seen.add(origin),
45
+ overlay,
46
+ https: !!server.config.server.https,
47
+ // Vite checks the Host itself (server.allowedHosts).
48
+ loopbackHosts: false,
49
+ }).then((done) => done || next(), next);
59
50
  });
60
51
  },
61
52
  resolveId(id) {
@@ -65,8 +56,7 @@ export function genaicode(options = {}) {
65
56
  load(id) {
66
57
  if (id !== `\0${OVERLAY_ID}`)
67
58
  return;
68
- const config = { api: API, captureErrors: options.captureErrors ?? true };
69
- return `(${mountOverlay.toString()})(${JSON.stringify(config)}, import.meta.hot);\n`;
59
+ return overlayModule(overlay, 'import.meta.hot');
70
60
  },
71
61
  async transformIndexHtml() {
72
62
  if (!(await started))
@@ -88,90 +78,6 @@ export function genaicode(options = {}) {
88
78
  },
89
79
  };
90
80
  }
91
- /** The dev server's own endpoints for the overlay: the UI link, and "fix these errors". */
92
- async function handleApi(req, res, started, onPage, https) {
93
- const send = (status, body) => {
94
- res.writeHead(status, { 'content-type': 'application/json', 'cache-control': 'no-store' });
95
- res.end(JSON.stringify(body));
96
- };
97
- // Only this machine: with --host the dev server also answers the network, and Sec-Fetch-Site
98
- // is just a header a client there could send. Then only the app's own pages: another site
99
- // open in the browser must not read the UI's token or start the agent.
100
- if (!isLoopback(req.socket.remoteAddress))
101
- return send(403, { error: 'this machine only' });
102
- if (req.headers['sec-fetch-site'] !== 'same-origin')
103
- return send(403, { error: 'same-origin only' });
104
- const ui = await started;
105
- if (!ui)
106
- return send(503, { error: 'genaicode is off; see the dev server terminal' });
107
- const path = (req.url ?? '/').split('?')[0];
108
- if (req.method === 'GET' && path === '/session') {
109
- const origin = pageOrigin(req.headers.host, https);
110
- if (origin)
111
- onPage(origin);
112
- return send(200, { url: ui.url, agent: ui.controller.get().session.agent });
113
- }
114
- if (req.method === 'POST' && path === '/fix') {
115
- if (!String(req.headers['content-type'] ?? '').startsWith('application/json')) {
116
- return send(415, { error: 'expected JSON' });
117
- }
118
- let prompt;
119
- try {
120
- prompt = fixPrompt(JSON.parse(await readBody(req)));
121
- }
122
- catch {
123
- prompt = undefined;
124
- }
125
- if (!prompt)
126
- return send(400, { error: 'bad request' });
127
- ui.controller.submit(prompt);
128
- return send(200, { ok: true });
129
- }
130
- send(404, { error: 'not found' });
131
- }
132
- const SOURCES = {
133
- vite: 'build error',
134
- error: 'uncaught error',
135
- rejection: 'unhandled rejection',
136
- console: 'console.error',
137
- };
138
- /** The prompt for "Fix N errors", or undefined when the body is not a list of errors. */
139
- export function fixPrompt(body) {
140
- if (!body || typeof body !== 'object')
141
- return undefined;
142
- const { page, errors } = body;
143
- if (!Array.isArray(errors) || errors.length === 0)
144
- return undefined;
145
- const items = [];
146
- for (const error of errors.slice(0, 20)) {
147
- if (!error || typeof error !== 'object')
148
- return undefined;
149
- const { source, message, stack } = error;
150
- if (typeof message !== 'string' || typeof source !== 'string' || !Object.hasOwn(SOURCES, source))
151
- return undefined;
152
- const trace = typeof stack === 'string' && stack && !message.includes(stack) ? `\n${stack.slice(0, 4000)}` : '';
153
- items.push(`${items.length + 1}. [${SOURCES[source]}] ${message.slice(0, 4000)}${trace}`);
154
- }
155
- const where = typeof page === 'string' && /^https?:\/\//.test(page) ? ` at ${page.slice(0, 500)}` : '';
156
- return (`The app running in the Vite dev server${where} reports ${items.length === 1 ? 'this error' : 'these errors'} ` +
157
- `in the browser. Find the cause in the code and fix it.\n\n` +
158
- '```\n' +
159
- items.join('\n\n').replace(/```/g, "'''") +
160
- '\n```');
161
- }
162
- /** 127.0.0.0/8 and ::1, also as IPv4-mapped IPv6 addresses. */
163
- export function isLoopback(address) {
164
- if (!address)
165
- return false;
166
- const v4 = address.startsWith('::ffff:') ? address.slice(7) : address;
167
- return address === '::1' || /^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(v4);
168
- }
169
- /** The origin a same-origin request came from, by its Host header. */
170
- function pageOrigin(host, https) {
171
- if (!host || !/^[\w.-]+(:\d+)?$|^\[[\da-f:.]+\](:\d+)?$/i.test(host))
172
- return undefined;
173
- return `${https ? 'https' : 'http'}://${host.toLowerCase()}`;
174
- }
175
81
  /** Where the app's pages come from, allowed to show the UI in a frame. */
176
82
  function pageOrigins(server, seen) {
177
83
  const urls = [...(server.resolvedUrls?.local ?? []), ...(server.resolvedUrls?.network ?? [])];
@@ -191,17 +97,6 @@ function pageOrigins(server, seen) {
191
97
  }
192
98
  return [...origins];
193
99
  }
194
- async function readBody(req) {
195
- let size = 0;
196
- const chunks = [];
197
- for await (const chunk of req) {
198
- size += chunk.length;
199
- if (size > MAX_BODY)
200
- throw new Error('Request too large');
201
- chunks.push(chunk);
202
- }
203
- return Buffer.concat(chunks).toString('utf8');
204
- }
205
100
  /** The front ends are bundled into dist/ui by scripts/build-ui.mjs; the path is kept opaque to tsc. */
206
101
  function loadBundledUi() {
207
102
  const bundle = new URL('../ui/index.js', import.meta.url).href;
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/vite/plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAsB,MAAM,cAAc,CAAC;AAyChE,MAAM,GAAG,GAAG,cAAc,CAAC;AAC3B,MAAM,UAAU,GAAG,2BAA2B,CAAC;AAC/C,MAAM,QAAQ,GAAG,GAAG,GAAG,IAAI,CAAC;AAE5B;;;;;;;GAOG;AACH,MAAM,UAAU,SAAS,CAAC,UAAgC,EAAE;IAC1D,IAAI,OAAkD,CAAC;IACvD,IAAI,IAAI,GAAG,GAAG,CAAC;IACf,6FAA6F;IAC7F,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAE/B,OAAO;QACL,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,OAAO;QAEd,cAAc,CAAC,MAAM;YACnB,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;QACrB,CAAC;QAED,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ACpB,MAAM,MAAM,GAAW,IAAI,GAAG,CAAC,gBAAgB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;IACvE,OAAO,MAAM,CAAC,MAAM,CAA8B,CAAC;AACrD,CAAC;AAED,SAAS,cAAc;IACrB,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/C,OAAQ,OAAO,CAAC,oBAAoB,CAAyB,CAAC,OAAO,CAAC;AACxE,CAAC"}
package/docs/CHANGELOG.md CHANGED
@@ -9,7 +9,22 @@
9
9
  `/auto off` asks again. `-y` starts with it on.
10
10
  - `genaicode embed` makes projects without a dev server work too: the agent writes a small
11
11
  dev-only server that serves the pages with the panel injected, leaving the files and the
12
- build untouched. It also keeps its shell commands few, since each one may need approval.
12
+ build untouched. That server opens the browser, and the agent's report starts with the one
13
+ command to run. It also keeps its shell commands few, since each one may need approval.
14
+ - `createDevOverlay()` in `genaicode/ui`: the Vite plugin's overlay (the wolf, its error
15
+ badge, "Fix N errors", the resizable panel) for any other Node dev server, as
16
+ `handle(req, res)` / `middleware` plus `injectHtml(html)`. `genaicode embed` now uses it
17
+ for non-Vite dev servers and for the dev server it writes, instead of a hand-made button.
18
+ - `!command` in `genaicode chat` (`!` on an empty prompt switches to shell mode, as in
19
+ Claude Code) and `genaicode ui` runs a shell command in the project
20
+ (e.g. `!npm run dev` after `genaicode embed`), its output in the transcript; `/stop`, Esc
21
+ or the Stop button end it and what it started, `!!` sends a leading `!` to the agent.
22
+ `<AgentChat canStop>` offers Stop while the agent is idle.
23
+
24
+ ### Changed
25
+
26
+ - The overlay's wolf stays light in dark mode, with a ring, so it shows on dark pages.
27
+ - The embed skill moved to `docs/skills/genaicode-embed/SKILL.md` (it was `skills/`).
13
28
 
14
29
  ## 2.18.0
15
30