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
28 changes: 4 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,44 +10,24 @@
</p>

<p align="center">
<a href="https://srcbook.com">Online app builder</a> ·
<a href="https://hub.srcbook.com">Examples</a> ·
<a href="https://discord.gg/shDEGBSe2d">Discord</a> ·
<a href="https://www.youtube.com/@srcbook">Youtube</a> ·
<a href="https://hub.srcbook.com">Hub</a>
</p>

## Maintainers Note

Srcbook is currently not under active development. After overwhelming demand of making it a managed service, we have built and are operating https://getmocha.com for this purpose!

In the future, we might revive Srcbook for its notebook product (over the app builder one, which is better served by Mocha).
Srcbook is not under active development.

## Srcbook

Srcbook is a TypeScript-centric app development platform, with 2 main products:

- an AI app builder (also available [hosted online](https://srcbook.com/))
- a TypeScript notebook
Srcbook is a TypeScript notebook that runs locally on your machine.

Srcbook is open-source (apache2) and runs locally on your machine. You'll need to bring your own API key for AI usage (we strongly recommend Anthropic with `claude-3-5-sonnet-latest`).

## Features

### App Builder

- AI app builder for TypeScript
- Create, edit and run web apps
- Use AI to generate the boilerplate, modify the code, and fix things
- Edit the app with a hot-reloading web preview

<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://i.imgur.com/lLJPZOs.png">
<source media="(prefers-color-scheme: light)" srcset="https://i.imgur.com/k4xAyCQ.png">
<img alt="Example Srcbook" src="https://i.imgur.com/k4xAyCQ.png">
</picture>

### Notebooks

- Create, run, and share TypeScript notebooks
- Export to valid markdown format (.src.md)
- AI features for exploring and iterating on ideas
Expand Down Expand Up @@ -120,7 +100,7 @@ Options:

Commands:
start [options] Start the Srcbook server
import [options] <specifier> Import a Notebook
import [options] <specifier> Import a notebook
help [command] display help for command
```

Expand Down
103 changes: 0 additions & 103 deletions packages/api/ai/app-parser.mts

This file was deleted.

84 changes: 1 addition & 83 deletions packages/api/ai/generate.mts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { streamText, generateText, type GenerateTextResult } from 'ai';
import { generateText, type GenerateTextResult } from 'ai';
import { getModel } from './config.mjs';
import {
type CodeLanguageType,
Expand All @@ -12,8 +12,6 @@ import { readFileSync } from 'node:fs';
import Path from 'node:path';
import { PROMPTS_DIR } from '../constants.mjs';
import { encode, decodeCells } from '../srcmd.mjs';
import { buildProjectXml, type FileContent } from '../ai/app-parser.mjs';
import { logAppGeneration } from './logger.mjs';

const makeGenerateSrcbookSystemPrompt = () => {
return readFileSync(Path.join(PROMPTS_DIR, 'srcbook-generator.txt'), 'utf-8');
Expand All @@ -26,34 +24,6 @@ const makeGenerateCellSystemPrompt = (language: CodeLanguageType) => {
const makeFixDiagnosticsSystemPrompt = () => {
return readFileSync(Path.join(PROMPTS_DIR, 'fix-cell-diagnostics.txt'), 'utf-8');
};
const makeAppBuilderSystemPrompt = () => {
return readFileSync(Path.join(PROMPTS_DIR, 'app-builder.txt'), 'utf-8');
};
const makeAppEditorSystemPrompt = () => {
return readFileSync(Path.join(PROMPTS_DIR, 'app-editor.txt'), 'utf-8');
};

const makeAppEditorUserPrompt = (projectId: string, files: FileContent[], query: string) => {
const projectXml = buildProjectXml(files, projectId);
const userRequestXml = `<userRequest>${query}</userRequest>`;
return `Following below are the project XML and the user request.

${projectXml}

${userRequestXml}
`.trim();
};

const makeAppCreateUserPrompt = (projectId: string, files: FileContent[], query: string) => {
const projectXml = buildProjectXml(files, projectId);
const userRequestXml = `<userRequest>${query}</userRequest>`;
return `Following below are the project XML and the user request.

${projectXml}

${userRequestXml}
`.trim();
};

const makeGenerateCellUserPrompt = (session: SessionType, insertIdx: number, query: string) => {
// Make sure we copy cells so we don't mutate the session
Expand Down Expand Up @@ -242,55 +212,3 @@ export async function fixDiagnostics(

return result.text;
}

export async function generateApp(
projectId: string,
files: FileContent[],
query: string,
): Promise<string> {
const model = await getModel();
const result = await generateText({
model,
system: makeAppBuilderSystemPrompt(),
prompt: makeAppCreateUserPrompt(projectId, files, query),
});
return result.text;
}

export async function streamEditApp(
projectId: string,
files: FileContent[],
query: string,
appId: string,
planId: string,
) {
const model = await getModel();

const systemPrompt = makeAppEditorSystemPrompt();
const userPrompt = makeAppEditorUserPrompt(projectId, files, query);

let response = '';

const result = await streamText({
model,
system: systemPrompt,
prompt: userPrompt,
onChunk: (chunk) => {
if (chunk.chunk.type === 'text-delta') {
response += chunk.chunk.textDelta;
}
},
onFinish: () => {
if (process.env.SRCBOOK_DISABLE_ANALYTICS !== 'true') {
logAppGeneration({
appId,
planId,
llm_request: { model, system: systemPrompt, prompt: userPrompt },
llm_response: response,
});
}
},
});

return result.textStream;
}
31 changes: 0 additions & 31 deletions packages/api/ai/logger.mts

This file was deleted.

Loading
Loading