@rantingjs/studio 0.0.0-stage → 0.1.0

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.
Files changed (54) hide show
  1. package/README.md +145 -2
  2. package/dist/badge.d.ts +2 -0
  3. package/dist/badge.js +17 -0
  4. package/dist/badge.js.map +1 -0
  5. package/dist/commands.d.ts +8 -0
  6. package/dist/commands.js +49 -0
  7. package/dist/commands.js.map +1 -0
  8. package/dist/config.d.ts +24 -0
  9. package/dist/config.js +26 -0
  10. package/dist/config.js.map +1 -0
  11. package/dist/forge.d.ts +67 -0
  12. package/dist/forge.js +138 -0
  13. package/dist/forge.js.map +1 -0
  14. package/dist/http.d.ts +25 -0
  15. package/dist/http.js +248 -0
  16. package/dist/http.js.map +1 -0
  17. package/dist/index.d.ts +4 -0
  18. package/dist/index.js +4 -0
  19. package/dist/index.js.map +1 -0
  20. package/dist/opencode.d.ts +30 -0
  21. package/dist/opencode.js +113 -0
  22. package/dist/opencode.js.map +1 -0
  23. package/dist/page.d.ts +11 -0
  24. package/dist/page.js +31 -0
  25. package/dist/page.js.map +1 -0
  26. package/dist/studio.module.d.ts +21 -0
  27. package/dist/studio.module.js +129 -0
  28. package/dist/studio.module.js.map +1 -0
  29. package/package.json +99 -4
  30. package/src/config.ts +26 -0
  31. package/ui/app.tsx +862 -0
  32. package/ui/changes.tsx +420 -0
  33. package/ui/code.tsx +194 -0
  34. package/ui/composer.tsx +362 -0
  35. package/ui/conversations.tsx +103 -0
  36. package/ui/editor.ts +144 -0
  37. package/ui/forge.tsx +236 -0
  38. package/ui/icons.tsx +59 -0
  39. package/ui/logic.ts +304 -0
  40. package/ui/logs.tsx +87 -0
  41. package/ui/model-picker.tsx +121 -0
  42. package/ui/notify.ts +45 -0
  43. package/ui/page.ts +27 -0
  44. package/ui/popover.tsx +66 -0
  45. package/ui/prose.tsx +50 -0
  46. package/ui/providers.tsx +384 -0
  47. package/ui/queue.tsx +89 -0
  48. package/ui/shared.ts +74 -0
  49. package/ui/splitter.tsx +70 -0
  50. package/ui/styles.css +2632 -0
  51. package/ui/terminal.tsx +108 -0
  52. package/ui/tsconfig.json +13 -0
  53. package/ui/urls.ts +9 -0
  54. package/ui/usage.tsx +86 -0
package/dist/http.js ADDED
@@ -0,0 +1,248 @@
1
+ import { existsSync, statSync } from 'node:fs';
2
+ import { relative } from 'node:path';
3
+ import { app, preloadedValue } from '@rantingjs/framework';
4
+ import { ModuleRef } from '@nestjs/core';
5
+ import { detectForge, forgeMcp, forgeServerName, forgeToken } from './forge.js';
6
+ import { authorization, readServer } from './opencode.js';
7
+ import { renderPage } from './page.js';
8
+ /** The page's front end: built from `ui/` once per process, or as `ranting build --compile` built it. */
9
+ async function studioUi() {
10
+ const built = preloadedValue('@rantingjs/studio');
11
+ if (built)
12
+ return built;
13
+ const { buildUi } = (await import(new URL('../ui/page.ts', import.meta.url).href));
14
+ return buildUi();
15
+ }
16
+ /** A provider of the app, or undefined: through ModuleRef, as app() logs every miss as an error. */
17
+ function provided(token) {
18
+ try {
19
+ return app().get(ModuleRef).get(token, { strict: false });
20
+ }
21
+ catch {
22
+ return undefined;
23
+ }
24
+ }
25
+ /** A browser's request from this site: its Origin names this host, or (without one) Sec-Fetch-Site says same-origin. */
26
+ function sameOrigin(request) {
27
+ const origin = request.headers.origin;
28
+ if (origin) {
29
+ try {
30
+ return new URL(origin).host === new URL(`${request.protocol}://${request.headers.host}`).host;
31
+ }
32
+ catch {
33
+ return false;
34
+ }
35
+ }
36
+ const site = request.headers['sec-fetch-site'];
37
+ return site === undefined || site === 'same-origin' || site === 'none';
38
+ }
39
+ /** The headers of OpenCode's answer the browser gets: its type and caching, not its length or encoding (fetch decoded it). */
40
+ const PASSED_HEADERS = ['content-type', 'cache-control', 'x-accel-buffering'];
41
+ /** Registers the page, the API it reads and the proxy to the project's OpenCode server on the app's Fastify instance. */
42
+ export function registerRoutes(fastify, path, site) {
43
+ const base = `/${path.replace(/^\/|\/$/g, '')}`;
44
+ const api = `${base}/api`;
45
+ const proxied = `${api}/opencode`;
46
+ fastify.addHook('onRoute', (route) => {
47
+ if (route.url !== base && !route.url.startsWith(`${base}/`))
48
+ return;
49
+ // A development tool: in a local app it answers only on this machine's names (`devHosts`), so a site that points
50
+ // its own name at 127.0.0.1 (DNS rebinding) cannot drive the agent. The page carries no CSRF token of the app's:
51
+ // every API call must come from this origin (guarded()).
52
+ route.config = { ...route.config, devHosts: true, ...(route.url.startsWith(`${api}/`) ? { csrf: false } : {}) };
53
+ });
54
+ /**
55
+ * The `viewStudio` ability decides, for the signed-in user or a guest; until the app defines its own it allows everyone
56
+ * while `app.env` is `local`. An app without the auth component gets that rule without the gate.
57
+ */
58
+ const denial = async () => {
59
+ const forbidden = { status: 403, message: 'Forbidden' };
60
+ let auth;
61
+ try {
62
+ const { Gate, Gatekeeper } = await import('@rantingjs/framework/auth');
63
+ const gate = provided(Gatekeeper);
64
+ auth = gate ? { Gate, gate } : undefined;
65
+ }
66
+ catch {
67
+ auth = undefined;
68
+ }
69
+ if (!auth)
70
+ return site.appEnv() === 'local' ? undefined : forbidden;
71
+ if (!auth.gate.has('viewStudio'))
72
+ auth.gate.define('viewStudio', () => site.appEnv() === 'local', { guests: true });
73
+ const response = await auth.Gate.inspect('viewStudio');
74
+ return response.allowed ? undefined : { status: response.status, message: response.message ?? forbidden.message };
75
+ };
76
+ const guarded = (handler) => async (request, reply) => {
77
+ const isApi = request.url.startsWith(api);
78
+ const denied = await denial();
79
+ if (denied)
80
+ return reply.status(denied.status).type(isApi ? 'application/json' : 'text/html; charset=utf-8').send(isApi ? { message: denied.message } : denied.message);
81
+ // The agent edits files and runs commands: another site may not drive it.
82
+ if (isApi && !sameOrigin(request))
83
+ return reply.status(403).send({ message: 'Cross-site request refused' });
84
+ return handler(request, reply);
85
+ };
86
+ fastify.get(base, guarded(async (_request, reply) => {
87
+ const ui = await studioUi();
88
+ const config = { appName: site.appName, appUrl: site.appUrl, base, api, opencode: proxied, directory: site.basePath };
89
+ return reply.type('text/html; charset=utf-8').header('cache-control', 'no-store').send(renderPage({ ...ui, config }));
90
+ }));
91
+ fastify.get(`${api}/exception`, guarded(async () => ({ data: (await site.lastException()) ?? null })));
92
+ // The app's log file as it grows: `?from=` the offset the last answer ended at (none: its last part).
93
+ fastify.get(`${api}/logs`, guarded(async (request) => {
94
+ const file = site.logFile();
95
+ if (!file)
96
+ return { data: null };
97
+ const from = Number(request.query.from);
98
+ return { data: { file: relative(site.basePath, file), ...(await readFrom(file, Number.isFinite(from) ? from : undefined)) } };
99
+ }));
100
+ // The queue: how many jobs wait on the default queue, and the failed ones, retried or forgotten from here.
101
+ fastify.get(`${api}/queue`, guarded(async () => {
102
+ const queues = site.queues();
103
+ const connection = site.queueConnection();
104
+ const size = await queues.size(undefined, connection).catch(() => null);
105
+ const failed = await queues.failer().all().catch(() => []);
106
+ return { data: { connection, size, failed: failed.map(failedJob) } };
107
+ }));
108
+ fastify.post(`${api}/queue/failed/:id/retry`, guarded(async (request, reply) => {
109
+ const queues = site.queues();
110
+ const job = await queues.failer().find(request.params.id);
111
+ if (!job)
112
+ return reply.status(404).send({ message: 'No such failed job' });
113
+ // As `queue:retry` does: back on its queue, then out of the failed ones.
114
+ await queues.connection(job.connection).push(job.queue, job.payload, 0);
115
+ await queues.failer().forget(job.id);
116
+ return { data: { retried: job.id } };
117
+ }));
118
+ fastify.delete(`${api}/queue/failed/:id`, guarded(async (request, reply) => {
119
+ const forgotten = await site.queues().failer().forget(request.params.id);
120
+ return forgotten ? { data: { forgotten: true } } : reply.status(404).send({ message: 'No such failed job' });
121
+ }));
122
+ // A commit of everything changed in the project's folder (only there: the app may live in a bigger repository).
123
+ // OpenCode has no commit of its own. The message goes to git as one argument, through no shell.
124
+ fastify.post(`${api}/git/commit`, guarded(async (request, reply) => {
125
+ const message = String(request.body?.message ?? '').trim();
126
+ if (!message)
127
+ return reply.status(422).send({ message: 'Write a commit message first.' });
128
+ try {
129
+ const added = await git(site.basePath, ['add', '-A', '--', '.']);
130
+ if (added.code)
131
+ return reply.status(409).send({ message: added.output });
132
+ const committed = await git(site.basePath, ['commit', '-m', message, '--', '.']);
133
+ if (committed.code)
134
+ return reply.status(409).send({ message: committed.output || 'git commit failed' });
135
+ const hash = (await git(site.basePath, ['rev-parse', '--short', 'HEAD'])).output;
136
+ return { data: { hash, subject: message.split('\n')[0] } };
137
+ }
138
+ catch {
139
+ return reply.status(500).send({ message: 'git is not installed, or not on the PATH of `bunx ranting dev`.' });
140
+ }
141
+ }));
142
+ // The repository's forge: what it is and whether its MCP server has a token (never the token itself). `refresh`
143
+ // finds it again (after `gh auth login`, a GITHUB_TOKEN set, an administrator's change) and gives OpenCode its MCP
144
+ // server from here, so a token goes from this machine to OpenCode only.
145
+ let forge;
146
+ const forgeState = async () => {
147
+ const found = await detectForge(site.basePath, site.forge);
148
+ const token = found.forge ? await forgeToken(found.forge) : undefined;
149
+ return { ...found, token };
150
+ };
151
+ const forgeAnswer = async (state) => ({
152
+ data: state.forge
153
+ ? { ...state.forge, origin: state.origin ?? null, server: forgeServerName(state.forge), token: state.token?.source ?? null, ready: Boolean(state.forge.mcp && (state.token || state.forge.type === 'gitlab')) }
154
+ : null,
155
+ });
156
+ fastify.get(`${api}/forge`, guarded(async () => forgeAnswer(await (forge ??= forgeState()))));
157
+ fastify.post(`${api}/forge/refresh`, guarded(async (_request, reply) => {
158
+ forge = forgeState();
159
+ const state = await forge;
160
+ const mcp = state.forge ? forgeMcp(state.forge, state.token?.token) : undefined;
161
+ const server = readServer(site.basePath);
162
+ if (state.forge && mcp && server) {
163
+ // OpenCode's `experimental.mcp.add`: for this run only (it writes no file).
164
+ const target = new URL(`/api/experimental/mcp/${encodeURIComponent(forgeServerName(state.forge))}`, server.url);
165
+ target.searchParams.set('location[directory]', site.basePath);
166
+ const added = await fetch(target, {
167
+ method: 'PUT',
168
+ headers: { authorization: authorization(server), 'content-type': 'application/json' },
169
+ body: JSON.stringify({ config: mcp }),
170
+ }).catch(() => undefined);
171
+ if (!added?.ok)
172
+ return reply.status(502).send({ message: `OpenCode did not take the ${state.forge.type === 'gitlab' ? 'GitLab' : 'GitHub'} MCP server${added ? ` (${added.status})` : ''}.` });
173
+ }
174
+ return forgeAnswer(state);
175
+ }));
176
+ // Everything else of the page goes to OpenCode as it is, with the server's password added here. In a scope of its
177
+ // own that takes any body as its bytes: a file the editor saves is sent as application/octet-stream.
178
+ void fastify.register(async (scope) => {
179
+ scope.removeAllContentTypeParsers();
180
+ scope.addContentTypeParser('*', { parseAs: 'buffer', bodyLimit: 64 * 1024 * 1024 }, (_request, body, done) => done(null, body));
181
+ scope.all('/*', proxy);
182
+ }, { prefix: proxied });
183
+ const proxy = guarded(async (request, reply) => {
184
+ const server = readServer(site.basePath);
185
+ if (!server)
186
+ return reply.status(503).send({ message: 'OpenCode is not running: start the app with `bunx ranting dev`.' });
187
+ const headers = { authorization: authorization(server), accept: String(request.headers.accept ?? '*/*') };
188
+ for (const name of ['content-type', 'x-opencode-ticket'])
189
+ if (request.headers[name])
190
+ headers[name] = String(request.headers[name]);
191
+ const body = request.method === 'GET' || request.method === 'HEAD' || !(request.body instanceof Buffer) || !request.body.length ? undefined : request.body;
192
+ // An event stream ends with the browser's request.
193
+ const aborted = new AbortController();
194
+ request.raw.once('close', () => aborted.abort());
195
+ // Only to the server itself: `//other.host/...` would resolve elsewhere and carry the password there.
196
+ const target = new URL(request.url.slice(proxied.length), server.url);
197
+ if (target.origin !== new URL(server.url).origin)
198
+ return reply.status(400).send({ message: 'Not a path of the OpenCode server' });
199
+ let response;
200
+ try {
201
+ response = await fetch(target, { method: request.method, headers, body, signal: aborted.signal, redirect: 'manual' });
202
+ }
203
+ catch {
204
+ return reply.status(503).send({ message: 'OpenCode does not answer: is `bunx ranting dev` running?' });
205
+ }
206
+ reply.status(response.status);
207
+ for (const name of PASSED_HEADERS) {
208
+ const value = response.headers.get(name);
209
+ if (value)
210
+ reply.header(name, value);
211
+ }
212
+ return reply.send(response.body ?? '');
213
+ });
214
+ }
215
+ /** git run in `cwd`, never asking anything: its exit code and what it printed. */
216
+ async function git(cwd, args) {
217
+ const child = Bun.spawn(['git', ...args], { cwd, stdin: 'ignore', stdout: 'pipe', stderr: 'pipe', env: { ...process.env, GIT_TERMINAL_PROMPT: '0' } });
218
+ const [out, err, code] = await Promise.all([new Response(child.stdout).text(), new Response(child.stderr).text(), child.exited]);
219
+ return { code, output: `${out}${err}`.trim() };
220
+ }
221
+ /** The most of a log file one answer carries; the first one starts this far from its end. */
222
+ const LOG_CHUNK = 256 * 1024;
223
+ const LOG_START = 64 * 1024;
224
+ /** A log file from `from` on (from its last part without one, or when it shrank: cleared, rotated), whole lines. */
225
+ async function readFrom(file, from) {
226
+ const size = existsSync(file) ? statSync(file).size : 0;
227
+ const fresh = from === undefined || from > size;
228
+ const start = fresh ? Math.max(0, size - LOG_START) : from;
229
+ const end = Math.min(size, start + LOG_CHUNK);
230
+ let text = end > start ? await Bun.file(file).slice(start, end).text() : '';
231
+ // A start inside a line (the file's last part) begins at the next one.
232
+ if (fresh && start > 0)
233
+ text = text.slice(text.indexOf('\n') + 1);
234
+ return { text, offset: end, reset: fresh };
235
+ }
236
+ /** A failed job as the page shows it: its class, where it ran, when and why it failed. */
237
+ function failedJob(job) {
238
+ let name = 'Job';
239
+ try {
240
+ const payload = JSON.parse(job.payload);
241
+ name = payload.displayName ?? payload.job ?? name;
242
+ }
243
+ catch {
244
+ // A payload of another kind: shown by its id.
245
+ }
246
+ return { id: job.id, uuid: job.uuid, name, connection: job.connection, queue: job.queue, failedAt: job.failedAt, exception: job.exception };
247
+ }
248
+ //# sourceMappingURL=http.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,GAAG,EAAE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,IAAI,IAAI,GAAG,KAAK,CAAC;IACjB,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAA2C,CAAC;QAClF,IAAI,GAAG,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC;IACpD,CAAC;IAAC,MAAM,CAAC;QACP,8CAA8C;IAChD,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,CAAC,UAAU,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE,SAAS,EAAE,GAAG,CAAC,SAAS,EAAE,CAAC;AAC9I,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { StudioModule, STUDIO_OPTIONS, type StudioOptions } from './studio.module.js';
2
+ export { authorization, openCodeBinary, openCodeConfig, readServer, startServer, stateFile, type OpenCodeServer } from './opencode.js';
3
+ export { badgeScript } from './badge.js';
4
+ export type { LastException } from './http.js';
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { StudioModule, STUDIO_OPTIONS } from './studio.module.js';
2
+ export { authorization, openCodeBinary, openCodeConfig, readServer, startServer, stateFile } from './opencode.js';
3
+ export { badgeScript } from './badge.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAsB,MAAM,oBAAoB,CAAC;AACtF,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAuB,MAAM,eAAe,CAAC;AACvI,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,30 @@
1
+ /** Where a running server is: its URL, the password it takes (user `opencode`) and its process. */
2
+ export interface OpenCodeServer {
3
+ url: string;
4
+ password: string;
5
+ pid: number;
6
+ }
7
+ export declare const stateFile: (basePath: string) => string;
8
+ /** The running server, or undefined before `ranting dev` started one. */
9
+ export declare function readServer(basePath: string): OpenCodeServer | undefined;
10
+ /** The Authorization header the server takes. */
11
+ export declare const authorization: (server: OpenCodeServer) => string;
12
+ /**
13
+ * The app's OpenCode binary, from @opencode/cli (a devDependency of the app): the one its postinstall put in place, else
14
+ * the one of this platform's package beside it, as Bun runs a postinstall only for a trusted dependency.
15
+ */
16
+ export declare function openCodeBinary(basePath: string): string;
17
+ /**
18
+ * The OpenCode config laid over the project's: the app's `studio.opencode`, plus Assist's MCP server when installed and
19
+ * the MCP servers given (the forge's). The app's own `opencode.mcp` has the last word.
20
+ */
21
+ export declare function openCodeConfig(basePath: string, extra: Record<string, unknown>, servers?: Record<string, unknown>): Record<string, unknown>;
22
+ /**
23
+ * Starts `opencode serve` in the project on a free local port, writes where it listens to storage/framework/studio.json
24
+ * and resolves once it does. The file is removed when the server ends.
25
+ */
26
+ export declare function startServer(basePath: string, command: string[], config: Record<string, unknown>, output?: (line: string) => void): Promise<{
27
+ url: string;
28
+ child: Bun.Subprocess<"ignore", "pipe", "inherit">;
29
+ stop: () => void;
30
+ }>;
@@ -0,0 +1,113 @@
1
+ // The project's OpenCode server: started by `studio:serve` (a `ranting dev` process), found by the app through
2
+ // storage/framework/studio.json. It listens on 127.0.0.1 with a password of its own; only the app's proxy holds it.
3
+ import { randomBytes } from 'node:crypto';
4
+ import { existsSync, mkdirSync, readFileSync, realpathSync, rmSync, statSync, writeFileSync } from 'node:fs';
5
+ import { dirname, join } from 'node:path';
6
+ export const stateFile = (basePath) => join(basePath, 'storage/framework/studio.json');
7
+ /** The running server, or undefined before `ranting dev` started one. */
8
+ export function readServer(basePath) {
9
+ try {
10
+ return JSON.parse(readFileSync(stateFile(basePath), 'utf8'));
11
+ }
12
+ catch {
13
+ return undefined;
14
+ }
15
+ }
16
+ /** The Authorization header the server takes. */
17
+ export const authorization = (server) => `Basic ${Buffer.from(`opencode:${server.password}`).toString('base64')}`;
18
+ /** A file of a package the app has, looked up in node_modules from its root upward (the resolver caches misses). */
19
+ function resolveFrom(basePath, file) {
20
+ for (let dir = basePath;; dir = dirname(dir)) {
21
+ const candidate = join(dir, 'node_modules', file);
22
+ if (existsSync(candidate))
23
+ return candidate;
24
+ if (dirname(dir) === dir)
25
+ return undefined;
26
+ }
27
+ }
28
+ const PLATFORM = { darwin: 'darwin', linux: 'linux', win32: 'windows' }[process.platform] ?? process.platform;
29
+ /**
30
+ * The app's OpenCode binary, from @opencode/cli (a devDependency of the app): the one its postinstall put in place, else
31
+ * the one of this platform's package beside it, as Bun runs a postinstall only for a trusted dependency.
32
+ */
33
+ export function openCodeBinary(basePath) {
34
+ const manifest = resolveFrom(basePath, '@opencode/cli/package.json');
35
+ if (!manifest)
36
+ throw new Error('OpenCode is not installed: bun add -d @opencode/cli');
37
+ const launcher = join(dirname(manifest), JSON.parse(readFileSync(manifest, 'utf8')).bin.opencode);
38
+ // Until the postinstall replaces it, the launcher is a small script that only says it did not run.
39
+ if (existsSync(launcher) && statSync(launcher).size > 1_000_000)
40
+ return launcher;
41
+ // ponytail: the plain build first, as the postinstall does on a CPU with AVX2; an older CPU needs the postinstall
42
+ // (bun pm trust @opencode/cli), which picks the baseline build.
43
+ const base = `@opencode/cli-${PLATFORM}-${process.arch}`;
44
+ // Its dependencies, seen from where the package really is (Bun's isolated installs link it from node_modules/.bun).
45
+ const from = dirname(realpathSync(manifest));
46
+ for (const name of [base, `${base}-baseline`, `${base}-musl`, `${base}-baseline-musl`]) {
47
+ const binary = resolveFrom(from, `${name}/bin/${process.platform === 'win32' ? 'opencode.exe' : 'opencode'}`);
48
+ if (binary)
49
+ return binary;
50
+ }
51
+ throw new Error(`OpenCode has no binary for ${PLATFORM}-${process.arch} here: run \`bun pm trust @opencode/cli\` (it adds it to trustedDependencies).`);
52
+ }
53
+ /**
54
+ * The OpenCode config laid over the project's: the app's `studio.opencode`, plus Assist's MCP server when installed and
55
+ * the MCP servers given (the forge's). The app's own `opencode.mcp` has the last word.
56
+ */
57
+ export function openCodeConfig(basePath, extra, servers = {}) {
58
+ const config = { $schema: 'https://opencode.ai/config.json', ...extra };
59
+ // ponytail: OpenCode leaves MCP tools out of a run's first request (anomalyco/opencode#51812); an OpenCode
60
+ // plugin that registers them as plugin tools gets around it, add one if the first answer of a chat needs them.
61
+ const assist = resolveFrom(basePath, '@rantingjs/assist/package.json') ? { 'ranting-assist': { type: 'local', enabled: true, command: ['bun', 'x', 'ranting', 'assist:mcp'] } } : {};
62
+ const mcp = { ...assist, ...servers, ...extra.mcp };
63
+ if (Object.keys(mcp).length)
64
+ config.mcp = mcp;
65
+ return config;
66
+ }
67
+ /**
68
+ * Starts `opencode serve` in the project on a free local port, writes where it listens to storage/framework/studio.json
69
+ * and resolves once it does. The file is removed when the server ends.
70
+ */
71
+ export async function startServer(basePath, command, config, output = (line) => console.log(line)) {
72
+ const password = randomBytes(32).toString('base64url');
73
+ const child = Bun.spawn([...command, 'serve', '--hostname', '127.0.0.1', '--port', '0'], {
74
+ cwd: basePath,
75
+ env: { ...process.env, OPENCODE_PASSWORD: password, OPENCODE_CONFIG_CONTENT: JSON.stringify(config) },
76
+ stdout: 'pipe',
77
+ stderr: 'inherit',
78
+ });
79
+ const file = stateFile(basePath);
80
+ const removeState = () => {
81
+ if (readServer(basePath)?.pid === child.pid)
82
+ rmSync(file, { force: true });
83
+ };
84
+ void child.exited.then(removeState);
85
+ const url = await new Promise((resolve, reject) => {
86
+ let found = false;
87
+ let buffer = '';
88
+ void (async () => {
89
+ const decoder = new TextDecoder();
90
+ for await (const chunk of child.stdout) {
91
+ buffer += decoder.decode(chunk, { stream: true });
92
+ const lines = buffer.split(/\r?\n/);
93
+ buffer = lines.pop() ?? '';
94
+ for (const line of lines) {
95
+ const listening = /server listening on (\S+)/.exec(line);
96
+ if (listening && !found) {
97
+ found = true;
98
+ resolve(listening[1]);
99
+ }
100
+ output(line);
101
+ }
102
+ }
103
+ if (!found)
104
+ reject(new Error(`OpenCode exited (${await child.exited}) before it listened`));
105
+ })();
106
+ });
107
+ mkdirSync(dirname(file), { recursive: true });
108
+ // It holds the password: readable by its owner only (a stale file from a killed run is replaced, not reused).
109
+ rmSync(file, { force: true });
110
+ writeFileSync(file, JSON.stringify({ url, password, pid: child.pid }), { mode: 0o600 });
111
+ return { url, child, stop: () => (child.kill(), removeState()) };
112
+ }
113
+ //# sourceMappingURL=opencode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opencode.js","sourceRoot":"","sources":["../src/opencode.ts"],"names":[],"mappings":"AAAA,+GAA+G;AAC/G,oHAAoH;AACpH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7G,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAS1C,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,QAAgB,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,+BAA+B,CAAC,CAAC;AAE/F,yEAAyE;AACzE,MAAM,UAAU,UAAU,CAAC,QAAgB;IACzC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAmB,CAAC;IACjF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,iDAAiD;AACjD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,MAAsB,EAAE,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,CAAC,YAAY,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,QAA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ACnE,CAAC"}
package/dist/page.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ /** The front end ui/page.ts builds. */
2
+ export interface StudioUi {
3
+ js: string;
4
+ css: string;
5
+ }
6
+ /** The whole document, the bundle and the styles inlined (no static file routes needed). */
7
+ export declare function renderPage(options: {
8
+ js: string;
9
+ css: string;
10
+ config: Record<string, unknown>;
11
+ }): string;
package/dist/page.js ADDED
@@ -0,0 +1,31 @@
1
+ // The page's HTML document: the bundled front end and styles inlined. Kept apart from ui/page.ts, which builds them,
2
+ // so a compiled executable (`ranting build --compile`) carries it.
3
+ const escapeHtml = (text) => text.replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;').replaceAll('"', '&quot;');
4
+ const FAVICON = 'data:image/svg+xml,' +
5
+ encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><rect width="32" height="32" rx="7" fill="#14181f"/><circle cx="16" cy="16" r="5" fill="#e8590c"/></svg>');
6
+ /** The whole document, the bundle and the styles inlined (no static file routes needed). */
7
+ export function renderPage(options) {
8
+ const title = `Studio${options.config.appName ? ` - ${String(options.config.appName)}` : ''}`;
9
+ const unsafe = new RegExp('[<' + String.fromCharCode(0x2028, 0x2029) + ']', 'g');
10
+ const config = JSON.stringify(options.config).replace(unsafe, (c) => String.fromCharCode(92) + 'u' + c.charCodeAt(0).toString(16).padStart(4, '0'));
11
+ return `<!DOCTYPE html>
12
+ <html lang="en">
13
+ <head>
14
+ <meta charset="utf-8">
15
+ <meta name="viewport" content="width=device-width, initial-scale=1">
16
+ <link rel="shortcut icon" type="image/svg+xml" href="${FAVICON}">
17
+ <meta name="robots" content="noindex, nofollow">
18
+ <title>${escapeHtml(title)}</title>
19
+ <link rel="preconnect" href="https://fonts.googleapis.com">
20
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
21
+ <link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=Instrument+Sans:wght@400;500;600;700&display=swap" rel="stylesheet">
22
+ <style>${options.css.replace(/<\/style/gi, '<\\/style')}</style>
23
+ </head>
24
+ <body>
25
+ <div id="studio"></div>
26
+ <script type="module">window.Studio = ${config};
27
+ ${options.js.replace(/<\/script/gi, '<\\/script')}</script>
28
+ </body>
29
+ </html>`;
30
+ }
31
+ //# sourceMappingURL=page.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page.js","sourceRoot":"","sources":["../src/page.ts"],"names":[],"mappings":"AAAA,qHAAqH;AACrH,mEAAmE;AAQnE,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;AAE7I,MAAM,OAAO,GACX,qBAAqB;IACrB,kBAAkB,CAChB,sKAAsK,CACvK,CAAC;AAEJ,4FAA4F;AAC5F,MAAM,UAAU,UAAU,CAAC,OAAqE;IAC9F,MAAM,KAAK,GAAG,SAAS,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IAC9F,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,GAAG,EAAE,GAAG,CAAC,CAAC;IACjF,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;IACpJ,OAAO;;;;;uDAK8C,OAAO;;SAErD,UAAU,CAAC,KAAK,CAAC;;;;SAIjB,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,WAAW,CAAC;;;;wCAIf,MAAM;EAC5C,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,aAAa,EAAE,YAAY,CAAC;;QAEzC,CAAC;AACT,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { type DynamicModule, type OnModuleInit } from '@nestjs/common';
2
+ import { HttpAdapterHost } from '@nestjs/core';
3
+ import { Application, Dispatcher } from '@rantingjs/framework';
4
+ import defaults from './config.js';
5
+ export type StudioOptions = typeof defaults;
6
+ export declare const STUDIO_OPTIONS: unique symbol;
7
+ /**
8
+ * Studio in the running app: the page at `/ranting-studio`, its proxy to the project's OpenCode server (which
9
+ * `ranting dev` starts), the last exception, and the badge on every HTML page. Only in a local app (or with APP_DEBUG
10
+ * on), never in tests. Discovered from package.json; `StudioModule.forRoot(options)` when imported by hand.
11
+ */
12
+ export declare class StudioModule implements OnModuleInit {
13
+ #private;
14
+ private readonly adapterHost;
15
+ private readonly application;
16
+ private readonly events;
17
+ private readonly options;
18
+ static forRoot(options?: Partial<StudioOptions>): DynamicModule;
19
+ constructor(adapterHost: HttpAdapterHost, application: Application, events: Dispatcher, options: StudioOptions);
20
+ onModuleInit(): void;
21
+ }