@rool-dev/cli 0.3.0 → 0.3.1
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/README.md +2 -13
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +6 -5
- package/dist/app.js.map +1 -1
- package/dist/chat.js +6 -6
- package/dist/chat.js.map +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +1 -1
- package/dist/constants.js.map +1 -1
- package/dist/create.d.ts +1 -1
- package/dist/create.d.ts.map +1 -1
- package/dist/create.js +15 -114
- package/dist/create.js.map +1 -1
- package/dist/program.js +2 -2
- package/dist/program.js.map +1 -1
- package/package.json +4 -4
- package/templates/svelte/AGENTS.md +0 -55
- package/templates/svelte/index.html +0 -12
- package/templates/svelte/package.json +0 -25
- package/templates/svelte/src/App.svelte +0 -57
- package/templates/svelte/src/Chat.svelte +0 -92
- package/templates/svelte/src/Header.svelte +0 -26
- package/templates/svelte/src/Objects.svelte +0 -39
- package/templates/svelte/src/Splash.svelte +0 -21
- package/templates/svelte/src/app.css +0 -1
- package/templates/svelte/src/main.ts +0 -5
- package/templates/svelte/tsconfig.json +0 -13
- package/templates/svelte/vite.config.ts +0 -8
- package/templates/vanilla/AGENTS.md +0 -59
- package/templates/vanilla/index.html +0 -12
- package/templates/vanilla/package.json +0 -21
- package/templates/vanilla/src/app.css +0 -1
- package/templates/vanilla/src/main.ts +0 -165
- package/templates/vanilla/tsconfig.json +0 -10
- package/templates/vanilla/vite.config.ts +0 -7
package/README.md
CHANGED
|
@@ -19,7 +19,6 @@ rool <command> [options]
|
|
|
19
19
|
| Command | Description |
|
|
20
20
|
|---------|-------------|
|
|
21
21
|
| `chat [prompt]` | Chat with a space (interactive if no prompt) |
|
|
22
|
-
| `create <name>` | Create a new Rool app |
|
|
23
22
|
| `media upload <file>` | Upload a file to a space and create an object with the media URL |
|
|
24
23
|
| `space list` | List all spaces |
|
|
25
24
|
| `space create <name>` | Create a new space |
|
|
@@ -30,6 +29,7 @@ rool <command> [options]
|
|
|
30
29
|
| `app slug [new-slug]` | Show or set your user slug |
|
|
31
30
|
| `user` | Show current user info |
|
|
32
31
|
| `logout` | Log out |
|
|
32
|
+
| `create [name]` | Create a new Rool app |
|
|
33
33
|
|
|
34
34
|
### Global Options
|
|
35
35
|
|
|
@@ -43,9 +43,7 @@ rool <command> [options]
|
|
|
43
43
|
| Option | Description | Default | Used by |
|
|
44
44
|
|--------|-------------|---------|---------|
|
|
45
45
|
| `-s, --space <name>` | space name | `Rool CLI` | `chat`, `media upload` |
|
|
46
|
-
| `-c, --
|
|
47
|
-
| `--svelte` | use Svelte template | | `create` |
|
|
48
|
-
| `--vanilla` | use vanilla TypeScript template | | `create` |
|
|
46
|
+
| `-c, --channel <id>` | channel ID | `rool-dev` | `chat` |
|
|
49
47
|
| `-m, --message <text>` | optional comment/description | | `media upload` |
|
|
50
48
|
| `-y, --yes` | skip confirmation prompt | | `space delete` |
|
|
51
49
|
| `-n, --name <name>` | app display name (defaults to app-id) | | `app publish` |
|
|
@@ -63,15 +61,6 @@ rool chat
|
|
|
63
61
|
# Use a specific space
|
|
64
62
|
rool chat -s "My Project" "Summarize the current state"
|
|
65
63
|
|
|
66
|
-
# Create a Svelte app
|
|
67
|
-
rool create --svelte my-app
|
|
68
|
-
|
|
69
|
-
# Create a vanilla TypeScript app
|
|
70
|
-
rool create --vanilla my-app
|
|
71
|
-
|
|
72
|
-
# Using npx
|
|
73
|
-
npx @rool-dev/cli create --svelte my-app
|
|
74
|
-
|
|
75
64
|
# Upload a file
|
|
76
65
|
rool media upload photo.jpg
|
|
77
66
|
|
package/dist/app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAmBzC,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAmBzC,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAsJlD"}
|
package/dist/app.js
CHANGED
|
@@ -46,11 +46,12 @@ Examples:
|
|
|
46
46
|
console.error(`Not a directory: ${resolvedPath}`);
|
|
47
47
|
process.exit(1);
|
|
48
48
|
}
|
|
49
|
-
// Check for index.html
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
console.error(
|
|
49
|
+
// Check for index.html (standalone) or rool-app.json (app bundle)
|
|
50
|
+
const hasIndex = fs.existsSync(path.join(resolvedPath, 'index.html'));
|
|
51
|
+
const hasAppManifest = fs.existsSync(path.join(resolvedPath, 'rool-app.json'));
|
|
52
|
+
if (!hasIndex && !hasAppManifest) {
|
|
53
|
+
console.error(`No index.html or rool-app.json found in ${resolvedPath}`);
|
|
54
|
+
console.error('The directory must contain an index.html or rool-app.json at the root.');
|
|
54
55
|
process.exit(1);
|
|
55
56
|
}
|
|
56
57
|
console.log(`Packaging ${resolvedPath}...`);
|
package/dist/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,KAAK,UAAU,YAAY,CAAC,OAAe;IACzC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC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AC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/dist/chat.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import * as readline from 'node:readline';
|
|
2
2
|
import { getClient } from './client.js';
|
|
3
3
|
import { formatMarkdown } from './format.js';
|
|
4
|
-
import { DEFAULT_SPACE_NAME,
|
|
4
|
+
import { DEFAULT_SPACE_NAME, DEFAULT_CHANNEL_ID } from './constants.js';
|
|
5
5
|
export function registerChat(program) {
|
|
6
6
|
program
|
|
7
7
|
.command('chat')
|
|
8
8
|
.description('Chat with a space (interactive if no prompt)')
|
|
9
9
|
.argument('[prompt...]', 'prompt to send')
|
|
10
10
|
.option('-s, --space <name>', 'space name', DEFAULT_SPACE_NAME)
|
|
11
|
-
.option('-c, --
|
|
11
|
+
.option('-c, --channel <id>', 'channel ID', DEFAULT_CHANNEL_ID)
|
|
12
12
|
.addHelpText('after', `
|
|
13
13
|
Examples:
|
|
14
14
|
# Chat with the default space
|
|
@@ -28,11 +28,11 @@ Examples:
|
|
|
28
28
|
const spaceInfo = spaces.find(s => s.name === opts.space);
|
|
29
29
|
let channel;
|
|
30
30
|
if (spaceInfo) {
|
|
31
|
-
channel = await client.openChannel(spaceInfo.id, opts.
|
|
31
|
+
channel = await client.openChannel(spaceInfo.id, opts.channel);
|
|
32
32
|
}
|
|
33
33
|
else {
|
|
34
34
|
const space = await client.createSpace(opts.space);
|
|
35
|
-
channel = await space.openChannel(opts.
|
|
35
|
+
channel = await space.openChannel(opts.channel);
|
|
36
36
|
}
|
|
37
37
|
if (prompt) {
|
|
38
38
|
// One-shot mode
|
|
@@ -66,7 +66,7 @@ async function sendPrompt(space, prompt) {
|
|
|
66
66
|
clearStatusLine();
|
|
67
67
|
process.stdout.write(tool ? `[${tool.name}]` : 'Thinking...');
|
|
68
68
|
};
|
|
69
|
-
space.on('
|
|
69
|
+
space.on('channelUpdated', onUpdate);
|
|
70
70
|
try {
|
|
71
71
|
const result = await space.prompt(prompt);
|
|
72
72
|
clearStatusLine();
|
|
@@ -77,7 +77,7 @@ async function sendPrompt(space, prompt) {
|
|
|
77
77
|
throw err;
|
|
78
78
|
}
|
|
79
79
|
finally {
|
|
80
|
-
space.off('
|
|
80
|
+
space.off('channelUpdated', onUpdate);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
async function interactiveMode(space, client) {
|
package/dist/chat.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.js","sourceRoot":"","sources":["../src/chat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAG1C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"chat.js","sourceRoot":"","sources":["../src/chat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAG1C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAoB,MAAM,gBAAgB,CAAC;AAE1F,MAAM,UAAU,YAAY,CAAC,OAAgB;IAC3C,OAAO;SACJ,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,8CAA8C,CAAC;SAC3D,QAAQ,CAAC,aAAa,EAAE,gBAAgB,CAAC;SACzC,MAAM,CAAC,oBAAoB,EAAE,YAAY,EAAE,kBAAkB,CAAC;SAC9D,MAAM,CAAC,oBAAoB,EAAE,YAAY,EAAE,kBAAkB,CAAC;SAC9D,WAAW,CAAC,OAAO,EAAE;;;;;;;;;4DASkC,CAAC;SACxD,MAAM,CAAC,KAAK,EAAE,WAAqB,EAAE,IAAwC,EAAE,OAAgB,EAAE,EAAE;QAClG,MAAM,EAAE,GAAG,EAA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CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const VERSION: string;
|
|
2
2
|
export declare const DEFAULT_SPACE_NAME = "Rool CLI";
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const DEFAULT_CHANNEL_ID = "rool-dev";
|
|
4
4
|
export type Environment = 'local' | 'dev' | 'prod';
|
|
5
5
|
export declare const DEFAULT_ENV: Environment;
|
|
6
6
|
export declare function getApiUrls(env: Environment): {
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,OAAO,QAAc,CAAC;AACnC,eAAO,MAAM,kBAAkB,aAAa,CAAC;AAC7C,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,OAAO,QAAc,CAAC;AACnC,eAAO,MAAM,kBAAkB,aAAa,CAAC;AAC7C,eAAO,MAAM,kBAAkB,aAAa,CAAC;AAE7C,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;AACnD,eAAO,MAAM,WAAW,EAAE,WAAoB,CAAC;AAQ/C,wBAAgB,UAAU,CAAC,GAAG,EAAE,WAAW,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAGjF"}
|
package/dist/constants.js
CHANGED
|
@@ -3,7 +3,7 @@ const require = createRequire(import.meta.url);
|
|
|
3
3
|
const pkg = require('../package.json');
|
|
4
4
|
export const VERSION = pkg.version;
|
|
5
5
|
export const DEFAULT_SPACE_NAME = 'Rool CLI';
|
|
6
|
-
export const
|
|
6
|
+
export const DEFAULT_CHANNEL_ID = 'rool-dev';
|
|
7
7
|
export const DEFAULT_ENV = 'prod';
|
|
8
8
|
const ENV_URLS = {
|
|
9
9
|
local: { target: 'http://localhost:1357', auth: 'https://api.dev.rool.dev/auth' },
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAwB,CAAC;AAE9D,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC;AACnC,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;AAC7C,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAwB,CAAC;AAE9D,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC;AACnC,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;AAC7C,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;AAG7C,MAAM,CAAC,MAAM,WAAW,GAAgB,MAAM,CAAC;AAE/C,MAAM,QAAQ,GAA0D;IACtE,KAAK,EAAE,EAAE,MAAM,EAAE,uBAAuB,EAAE,IAAI,EAAE,+BAA+B,EAAE;IACjF,GAAG,EAAE,EAAE,MAAM,EAAE,0BAA0B,EAAE,IAAI,EAAE,+BAA+B,EAAE;IAClF,IAAI,EAAE,EAAE,MAAM,EAAE,sBAAsB,EAAE,IAAI,EAAE,2BAA2B,EAAE;CAC5E,CAAC;AAEF,MAAM,UAAU,UAAU,CAAC,GAAgB;IACzC,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC3B,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;AACtD,CAAC"}
|
package/dist/create.d.ts
CHANGED
package/dist/create.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAiBrD"}
|
package/dist/create.js
CHANGED
|
@@ -1,120 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
5
|
-
const cliPkgJson = JSON.parse(fs.readFileSync(path.resolve(__dirname, '..', 'package.json'), 'utf-8'));
|
|
6
|
-
function getTemplatesDir() {
|
|
7
|
-
// In development: packages/cli/src -> packages/cli/templates
|
|
8
|
-
// In production: packages/cli/dist -> packages/cli/templates
|
|
9
|
-
return path.resolve(__dirname, '..', 'templates');
|
|
10
|
-
}
|
|
11
|
-
const SKIP_DIRS = new Set(['node_modules', '.git', 'dist']);
|
|
12
|
-
function copyDir(src, dest, replacements) {
|
|
13
|
-
fs.mkdirSync(dest, { recursive: true });
|
|
14
|
-
for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
|
|
15
|
-
const srcPath = path.join(src, entry.name);
|
|
16
|
-
const destPath = path.join(dest, entry.name);
|
|
17
|
-
if (entry.isDirectory()) {
|
|
18
|
-
if (!SKIP_DIRS.has(entry.name)) {
|
|
19
|
-
copyDir(srcPath, destPath, replacements);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
let content = fs.readFileSync(srcPath, 'utf-8');
|
|
24
|
-
for (const [from, to] of replacements) {
|
|
25
|
-
content = content.replaceAll(from, to);
|
|
26
|
-
}
|
|
27
|
-
fs.writeFileSync(destPath, content);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
function toValidPackageName(name) {
|
|
32
|
-
return name
|
|
33
|
-
.toLowerCase()
|
|
34
|
-
.replace(/\s+/g, '-')
|
|
35
|
-
.replace(/[^a-z0-9-_]/g, '');
|
|
36
|
-
}
|
|
37
|
-
function toTitleCase(name) {
|
|
38
|
-
return name
|
|
39
|
-
.split(/[-_\s]+/)
|
|
40
|
-
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
|
41
|
-
.join(' ');
|
|
42
|
-
}
|
|
1
|
+
import { spawnSync } from 'child_process';
|
|
2
|
+
import { createRequire } from 'module';
|
|
3
|
+
import { resolve, dirname } from 'path';
|
|
43
4
|
export function registerCreate(program) {
|
|
44
5
|
program
|
|
45
|
-
.command('create')
|
|
6
|
+
.command('create [name]')
|
|
46
7
|
.description('Create a new Rool app')
|
|
47
|
-
.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
# Using npx
|
|
59
|
-
$ npx @rool-dev/cli create --svelte my-app`)
|
|
60
|
-
.action(async (name, opts) => {
|
|
61
|
-
// Determine framework
|
|
62
|
-
let framework;
|
|
63
|
-
if (opts.svelte && opts.vanilla) {
|
|
64
|
-
console.error('Error: Cannot use both --svelte and --vanilla');
|
|
65
|
-
process.exit(1);
|
|
66
|
-
}
|
|
67
|
-
else if (opts.svelte) {
|
|
68
|
-
framework = 'svelte';
|
|
69
|
-
}
|
|
70
|
-
else if (opts.vanilla) {
|
|
71
|
-
framework = 'vanilla';
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
console.error('Error: Please specify a framework: --svelte or --vanilla');
|
|
75
|
-
process.exit(1);
|
|
76
|
-
}
|
|
77
|
-
// Check if directory exists
|
|
78
|
-
const targetDir = path.resolve(process.cwd(), name);
|
|
79
|
-
if (fs.existsSync(targetDir)) {
|
|
80
|
-
console.error(`Error: Directory "${name}" already exists`);
|
|
81
|
-
process.exit(1);
|
|
82
|
-
}
|
|
83
|
-
// Find template
|
|
84
|
-
const templatesDir = getTemplatesDir();
|
|
85
|
-
const templateDir = path.join(templatesDir, framework);
|
|
86
|
-
if (!fs.existsSync(templateDir)) {
|
|
87
|
-
console.error(`Error: Template "${framework}" not found at ${templateDir}`);
|
|
88
|
-
process.exit(1);
|
|
89
|
-
}
|
|
90
|
-
// Copy template with replacements
|
|
91
|
-
const packageName = toValidPackageName(name);
|
|
92
|
-
const title = toTitleCase(name);
|
|
93
|
-
console.log(`Creating ${framework} app in ${name}/...\n`);
|
|
94
|
-
copyDir(templateDir, targetDir, [
|
|
95
|
-
['rool-app', packageName],
|
|
96
|
-
['Rool App', title],
|
|
97
|
-
['"@rool-dev/sdk": "workspace:*"', `"@rool-dev/sdk": "^${cliPkgJson.version}"`],
|
|
98
|
-
['"@rool-dev/svelte": "workspace:*"', `"@rool-dev/svelte": "^${cliPkgJson.version}"`],
|
|
99
|
-
]);
|
|
100
|
-
// Print next steps
|
|
101
|
-
console.log(`Done! Next steps:\n`);
|
|
102
|
-
console.log(` cd ${name}`);
|
|
103
|
-
console.log(` pnpm install`);
|
|
104
|
-
console.log(` pnpm dev\n`);
|
|
105
|
-
console.log(`Key patterns:`);
|
|
106
|
-
if (framework === 'svelte') {
|
|
107
|
-
console.log(` • createRool() initializes the reactive client`);
|
|
108
|
-
console.log(` • rool.openSpace() connects to a space`);
|
|
109
|
-
console.log(` • space.collection() creates reactive queries`);
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
console.log(` • new RoolClient() initializes the client`);
|
|
113
|
-
console.log(` • client.openSpace() connects to a space`);
|
|
114
|
-
console.log(` • space.on() subscribes to real-time events`);
|
|
115
|
-
}
|
|
116
|
-
console.log(` • space.prompt() invokes the AI agent\n`);
|
|
117
|
-
console.log(`Docs: https://docs.rool.dev`);
|
|
8
|
+
.action((name) => {
|
|
9
|
+
// Resolve the rool-app binary from @rool-dev/app
|
|
10
|
+
const require = createRequire(import.meta.url);
|
|
11
|
+
const appPkg = require.resolve('@rool-dev/app/package.json');
|
|
12
|
+
const bin = resolve(dirname(appPkg), 'dist/cli/index.js');
|
|
13
|
+
const args = ['init', ...(name ? [name] : [])];
|
|
14
|
+
const result = spawnSync(process.execPath, [bin, ...args], {
|
|
15
|
+
stdio: 'inherit',
|
|
16
|
+
cwd: process.cwd(),
|
|
17
|
+
});
|
|
18
|
+
process.exit(result.status ?? 1);
|
|
118
19
|
});
|
|
119
20
|
}
|
|
120
21
|
//# sourceMappingURL=create.js.map
|
package/dist/create.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAExC,MAAM,UAAU,cAAc,CAAC,OAAgB;IAC7C,OAAO;SACJ,OAAO,CAAC,eAAe,CAAC;SACxB,WAAW,CAAC,uBAAuB,CAAC;SACpC,MAAM,CAAC,CAAC,IAAa,EAAE,EAAE;QACxB,iDAAiD;QACjD,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC/C,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,4BAA4B,CAAC,CAAC;QAC7D,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,mBAAmB,CAAC,CAAC;QAE1D,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC/C,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,EAAE;YACzD,KAAK,EAAE,SAAS;YAChB,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;SACnB,CAAC,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/dist/program.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { VERSION, DEFAULT_ENV } from './constants.js';
|
|
3
3
|
import { registerChat } from './chat.js';
|
|
4
|
-
import { registerCreate } from './create.js';
|
|
5
4
|
import { registerMedia } from './media.js';
|
|
6
5
|
import { registerSpace } from './space.js';
|
|
7
6
|
import { registerApp } from './app.js';
|
|
8
7
|
import { registerUser } from './user.js';
|
|
9
8
|
import { registerLogout } from './logout.js';
|
|
9
|
+
import { registerCreate } from './create.js';
|
|
10
10
|
function validateEnv(value) {
|
|
11
11
|
if (value !== 'local' && value !== 'dev' && value !== 'prod') {
|
|
12
12
|
throw new Error(`Invalid environment: ${value}. Must be local, dev, or prod.`);
|
|
@@ -21,12 +21,12 @@ export function createProgram() {
|
|
|
21
21
|
.description('Command-line interface for the Rool platform')
|
|
22
22
|
.option('-e, --env <environment>', 'target environment (local, dev, prod)', validateEnv, DEFAULT_ENV);
|
|
23
23
|
registerChat(program);
|
|
24
|
-
registerCreate(program);
|
|
25
24
|
registerMedia(program);
|
|
26
25
|
registerSpace(program);
|
|
27
26
|
registerApp(program);
|
|
28
27
|
registerUser(program);
|
|
29
28
|
registerLogout(program);
|
|
29
|
+
registerCreate(program);
|
|
30
30
|
return program;
|
|
31
31
|
}
|
|
32
32
|
//# sourceMappingURL=program.js.map
|
package/dist/program.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"program.js","sourceRoot":"","sources":["../src/program.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAoB,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"program.js","sourceRoot":"","sources":["../src/program.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAoB,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,SAAS,WAAW,CAAC,KAAa;IAChC,IAAI,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,KAAK,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;QAC7D,MAAM,IAAI,KAAK,CAAC,wBAAwB,KAAK,gCAAgC,CAAC,CAAC;IACjF,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,aAAa;IAC3B,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAE9B,OAAO;SACJ,IAAI,CAAC,MAAM,CAAC;SACZ,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,8CAA8C,CAAC;SAC3D,MAAM,CAAC,yBAAyB,EAAE,uCAAuC,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;IAExG,YAAY,CAAC,OAAO,CAAC,CAAC;IACtB,aAAa,CAAC,OAAO,CAAC,CAAC;IACvB,aAAa,CAAC,OAAO,CAAC,CAAC;IACvB,WAAW,CAAC,OAAO,CAAC,CAAC;IACrB,YAAY,CAAC,OAAO,CAAC,CAAC;IACtB,cAAc,CAAC,OAAO,CAAC,CAAC;IACxB,cAAc,CAAC,OAAO,CAAC,CAAC;IAExB,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rool-dev/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Command-line interface for working with Rool Spaces",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -9,8 +9,7 @@
|
|
|
9
9
|
"rool": "./dist/index.js"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
|
-
"dist"
|
|
13
|
-
"templates"
|
|
12
|
+
"dist"
|
|
14
13
|
],
|
|
15
14
|
"publishConfig": {
|
|
16
15
|
"access": "public"
|
|
@@ -38,7 +37,8 @@
|
|
|
38
37
|
"commander": "^14.0.3",
|
|
39
38
|
"marked": "^15.0.12",
|
|
40
39
|
"marked-terminal": "^7.3.0",
|
|
41
|
-
"@rool-dev/
|
|
40
|
+
"@rool-dev/app": "0.3.1",
|
|
41
|
+
"@rool-dev/sdk": "0.3.1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/archiver": "^7.0.0",
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
# Rool App
|
|
2
|
-
|
|
3
|
-
A Svelte 5 app built on Rool Spaces - a persistent, collaborative environment for AI-driven object management.
|
|
4
|
-
|
|
5
|
-
## Technology Stack
|
|
6
|
-
|
|
7
|
-
- **Framework**: Svelte 5
|
|
8
|
-
- **Styling**: TailwindCSS v4
|
|
9
|
-
- **Language**: TypeScript
|
|
10
|
-
- **Package manager**: pnpm
|
|
11
|
-
|
|
12
|
-
For Rool documentation, **always read the README first**:
|
|
13
|
-
|
|
14
|
-
```
|
|
15
|
-
node_modules/@rool-dev/svelte/README.md # The svelte wrapper
|
|
16
|
-
node_modules/@rool-dev/sdk/README.md # The core SDK
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
## Rool Primitives
|
|
20
|
-
|
|
21
|
-
**RoolClient** - Authentication and space lifecycle. One per app.
|
|
22
|
-
|
|
23
|
-
**ReactiveSpace** - The workspace. Contains objects and conversations.
|
|
24
|
-
- `space.collection({ where? })` - Reactive query returning `{ objects }`
|
|
25
|
-
- `space.prompt(text)` - Invoke AI to create/modify objects
|
|
26
|
-
- `space.checkpoint()` - Create undo point before mutations
|
|
27
|
-
- `space.interactions` - Chat history for current conversation
|
|
28
|
-
|
|
29
|
-
**Objects** - Key-value records with `id` field. Created via `space.createObject()` or AI. References between objects are data fields whose values are object IDs.
|
|
30
|
-
|
|
31
|
-
## Key Patterns
|
|
32
|
-
|
|
33
|
-
```typescript
|
|
34
|
-
// Reactive collection - auto-updates when objects change
|
|
35
|
-
let collection = space.collection({ where: { type: 'task' } });
|
|
36
|
-
let tasks = $derived(collection.objects);
|
|
37
|
-
|
|
38
|
-
// AI mutation - always checkpoint first for undo
|
|
39
|
-
await space.checkpoint();
|
|
40
|
-
await space.prompt('Create a task for tomorrow');
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
Use `space.on('objectCreated', ...)` for side effects outside Svelte's reactivity.
|
|
44
|
-
|
|
45
|
-
## Entry Point
|
|
46
|
-
|
|
47
|
-
`src/main.ts` mounts `App.svelte`, which handles auth and space setup.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
## Adding Functionality
|
|
51
|
-
|
|
52
|
-
Useful packages to consider:
|
|
53
|
-
|
|
54
|
-
- **@iconify/svelte** - Icons (`<Icon icon="mdi:home" />`)
|
|
55
|
-
- **@humanspeak/svelte-markdown** - Render markdown from AI responses
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
|
|
6
|
-
<title>Rool App</title>
|
|
7
|
-
</head>
|
|
8
|
-
<body>
|
|
9
|
-
<div id="app"></div>
|
|
10
|
-
<script type="module" src="/src/main.ts"></script>
|
|
11
|
-
</body>
|
|
12
|
-
</html>
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "rool-app",
|
|
3
|
-
"private": true,
|
|
4
|
-
"version": "0.0.0",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"dev": "vite",
|
|
8
|
-
"build": "vite build",
|
|
9
|
-
"preview": "vite preview",
|
|
10
|
-
"typecheck": "tsc --noEmit && svelte-check --tsconfig ./tsconfig.json"
|
|
11
|
-
},
|
|
12
|
-
"dependencies": {
|
|
13
|
-
"@rool-dev/sdk": "workspace:*",
|
|
14
|
-
"@rool-dev/svelte": "workspace:*"
|
|
15
|
-
},
|
|
16
|
-
"devDependencies": {
|
|
17
|
-
"@sveltejs/vite-plugin-svelte": "^5.0.0",
|
|
18
|
-
"@tailwindcss/vite": "^4.0.0",
|
|
19
|
-
"svelte": "^5.0.0",
|
|
20
|
-
"svelte-check": "^4.0.0",
|
|
21
|
-
"tailwindcss": "^4.0.0",
|
|
22
|
-
"typescript": "^5.0.0",
|
|
23
|
-
"vite": "^6.0.0"
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { createRool, type ReactiveChannel } from '@rool-dev/svelte';
|
|
3
|
-
import Splash from './Splash.svelte';
|
|
4
|
-
import Header from './Header.svelte';
|
|
5
|
-
import Chat from './Chat.svelte';
|
|
6
|
-
import Objects from './Objects.svelte';
|
|
7
|
-
|
|
8
|
-
const APP_NAME = 'Rool App';
|
|
9
|
-
|
|
10
|
-
const rool = createRool();
|
|
11
|
-
rool.init();
|
|
12
|
-
|
|
13
|
-
let space = $state<ReactiveChannel | null>(null);
|
|
14
|
-
|
|
15
|
-
// Open space when ready
|
|
16
|
-
$effect(() => {
|
|
17
|
-
if (rool.authenticated && rool.spaces && !space) {
|
|
18
|
-
openSpace();
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
async function openSpace() {
|
|
23
|
-
const spaces = rool.spaces!;
|
|
24
|
-
const existing = spaces.find(s => s.name === APP_NAME);
|
|
25
|
-
|
|
26
|
-
if (existing) {
|
|
27
|
-
space = await rool.openChannel(existing.id, 'main');
|
|
28
|
-
} else {
|
|
29
|
-
const newSpace = await rool.createSpace(APP_NAME);
|
|
30
|
-
space = await rool.openChannel(newSpace.id, 'main');
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
</script>
|
|
34
|
-
|
|
35
|
-
{#if rool.authenticated === undefined}
|
|
36
|
-
<div class="min-h-dvh flex items-center justify-center bg-gray-50">
|
|
37
|
-
<p class="text-gray-500">Loading...</p>
|
|
38
|
-
</div>
|
|
39
|
-
{:else if rool.authenticated === false}
|
|
40
|
-
<Splash appName={APP_NAME} onLogin={() => rool.login(APP_NAME)} />
|
|
41
|
-
{:else}
|
|
42
|
-
<div class="min-h-dvh flex flex-col bg-gray-50">
|
|
43
|
-
<Header appName={APP_NAME} {space} onLogout={() => rool.logout()} />
|
|
44
|
-
|
|
45
|
-
{#if !space}
|
|
46
|
-
<div class="flex-1 flex items-center justify-center">
|
|
47
|
-
<p class="text-gray-500">Loading space...</p>
|
|
48
|
-
</div>
|
|
49
|
-
{:else}
|
|
50
|
-
<!-- Mobile: horizontal swipe with scroll-snap. Desktop: side-by-side -->
|
|
51
|
-
<div class="flex-1 flex overflow-x-auto snap-x snap-mandatory md:overflow-visible min-h-0">
|
|
52
|
-
<Chat {space} />
|
|
53
|
-
<Objects {space} />
|
|
54
|
-
</div>
|
|
55
|
-
{/if}
|
|
56
|
-
</div>
|
|
57
|
-
{/if}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { ReactiveChannel } from '@rool-dev/svelte';
|
|
3
|
-
|
|
4
|
-
interface Props {
|
|
5
|
-
space: ReactiveChannel;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
let { space }: Props = $props();
|
|
9
|
-
|
|
10
|
-
let input = $state('');
|
|
11
|
-
let isSending = $state(false);
|
|
12
|
-
let messagesEl: HTMLElement | null = $state(null);
|
|
13
|
-
|
|
14
|
-
let interactions = $derived(space.interactions);
|
|
15
|
-
|
|
16
|
-
// Auto-scroll on new messages
|
|
17
|
-
$effect(() => {
|
|
18
|
-
if (interactions.length > 0 && messagesEl) {
|
|
19
|
-
messagesEl.scrollTop = messagesEl.scrollHeight;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
async function send() {
|
|
24
|
-
if (!input.trim() || isSending) return;
|
|
25
|
-
|
|
26
|
-
const text = input.trim();
|
|
27
|
-
input = '';
|
|
28
|
-
isSending = true;
|
|
29
|
-
|
|
30
|
-
try {
|
|
31
|
-
await space.checkpoint();
|
|
32
|
-
await space.prompt(text);
|
|
33
|
-
} finally {
|
|
34
|
-
isSending = false;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function handleKeydown(e: KeyboardEvent) {
|
|
39
|
-
if (e.key === 'Enter' && !e.shiftKey) {
|
|
40
|
-
e.preventDefault();
|
|
41
|
-
send();
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
</script>
|
|
45
|
-
|
|
46
|
-
<div class="w-full shrink-0 snap-start md:flex-1 md:shrink md:snap-align-none flex flex-col min-w-0">
|
|
47
|
-
<div class="flex-1 overflow-y-auto p-4 space-y-4" bind:this={messagesEl}>
|
|
48
|
-
{#if interactions.length === 0}
|
|
49
|
-
<div class="text-center py-16 text-gray-500">
|
|
50
|
-
<p class="text-lg mb-2">Welcome!</p>
|
|
51
|
-
<p class="text-sm">Ask the AI to create objects, answer questions, or help with tasks.</p>
|
|
52
|
-
</div>
|
|
53
|
-
{:else}
|
|
54
|
-
{#each interactions as msg (msg.id)}
|
|
55
|
-
<div class="flex justify-end">
|
|
56
|
-
<div class="max-w-[75%] bg-blue-600 text-white rounded-2xl rounded-br-sm px-4 py-2">
|
|
57
|
-
<p class="text-sm whitespace-pre-wrap">{msg.input}</p>
|
|
58
|
-
</div>
|
|
59
|
-
</div>
|
|
60
|
-
<div class="flex justify-start">
|
|
61
|
-
<div class="max-w-[75%] bg-white border border-gray-200 rounded-2xl rounded-bl-sm px-4 py-2 shadow-sm">
|
|
62
|
-
{#if msg.output}
|
|
63
|
-
<p class="text-sm text-gray-700 whitespace-pre-wrap">{msg.output}</p>
|
|
64
|
-
{:else}
|
|
65
|
-
<p class="text-sm text-gray-400 italic">Thinking...</p>
|
|
66
|
-
{/if}
|
|
67
|
-
</div>
|
|
68
|
-
</div>
|
|
69
|
-
{/each}
|
|
70
|
-
{/if}
|
|
71
|
-
</div>
|
|
72
|
-
|
|
73
|
-
<div class="border-t border-gray-200 bg-white p-4">
|
|
74
|
-
<div class="flex gap-2">
|
|
75
|
-
<textarea
|
|
76
|
-
class="flex-1 px-4 py-2 border border-gray-300 rounded-xl resize-none focus:outline-none focus:ring-2 focus:ring-blue-500 min-h-[44px] max-h-32"
|
|
77
|
-
placeholder="Type a message..."
|
|
78
|
-
rows="1"
|
|
79
|
-
bind:value={input}
|
|
80
|
-
onkeydown={handleKeydown}
|
|
81
|
-
disabled={isSending}
|
|
82
|
-
></textarea>
|
|
83
|
-
<button
|
|
84
|
-
class="px-5 py-2 bg-blue-600 text-white rounded-xl hover:bg-blue-700 disabled:opacity-50"
|
|
85
|
-
onclick={send}
|
|
86
|
-
disabled={isSending || !input.trim()}
|
|
87
|
-
>
|
|
88
|
-
{isSending ? '...' : 'Send'}
|
|
89
|
-
</button>
|
|
90
|
-
</div>
|
|
91
|
-
</div>
|
|
92
|
-
</div>
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { ReactiveChannel } from '@rool-dev/svelte';
|
|
3
|
-
|
|
4
|
-
interface Props {
|
|
5
|
-
appName: string;
|
|
6
|
-
space: ReactiveChannel | null;
|
|
7
|
-
onLogout: () => void;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
let { appName, space, onLogout }: Props = $props();
|
|
11
|
-
</script>
|
|
12
|
-
|
|
13
|
-
<header class="bg-white border-b border-gray-200 px-4 py-3 flex items-center justify-between">
|
|
14
|
-
<h1 class="text-lg font-semibold text-gray-900">{appName}</h1>
|
|
15
|
-
<div class="flex items-center gap-3">
|
|
16
|
-
{#if space}
|
|
17
|
-
<span class="text-sm text-gray-500 hidden sm:inline">{space.name}</span>
|
|
18
|
-
{/if}
|
|
19
|
-
<button
|
|
20
|
-
class="px-3 py-1.5 text-sm text-gray-500 hover:text-gray-700"
|
|
21
|
-
onclick={onLogout}
|
|
22
|
-
>
|
|
23
|
-
Sign out
|
|
24
|
-
</button>
|
|
25
|
-
</div>
|
|
26
|
-
</header>
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { ReactiveChannel, ReactiveWatch } from '@rool-dev/svelte';
|
|
3
|
-
|
|
4
|
-
interface Props {
|
|
5
|
-
space: ReactiveChannel;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
let { space }: Props = $props();
|
|
9
|
-
|
|
10
|
-
let collection = $state<ReactiveWatch | null>(null);
|
|
11
|
-
|
|
12
|
-
$effect(() => {
|
|
13
|
-
const c = space.watch({});
|
|
14
|
-
collection = c;
|
|
15
|
-
return () => c.close();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
let objects = $derived(collection?.objects ?? []);
|
|
19
|
-
</script>
|
|
20
|
-
|
|
21
|
-
<!-- Mobile: full width swipe panel. Desktop: side panel -->
|
|
22
|
-
<aside class="w-full shrink-0 snap-start md:w-80 md:shrink md:snap-align-none border-l border-gray-200 bg-white flex flex-col">
|
|
23
|
-
<div class="px-4 py-3 border-b border-gray-200">
|
|
24
|
-
<h2 class="font-medium text-gray-700">Objects ({objects.length})</h2>
|
|
25
|
-
</div>
|
|
26
|
-
<div class="flex-1 overflow-y-auto p-4 space-y-3">
|
|
27
|
-
{#if objects.length === 0}
|
|
28
|
-
<p class="text-gray-400 text-sm text-center py-4">
|
|
29
|
-
Objects created by the AI will appear here
|
|
30
|
-
</p>
|
|
31
|
-
{:else}
|
|
32
|
-
{#each objects as obj (obj.id)}
|
|
33
|
-
<div class="p-3 bg-gray-50 rounded-lg border border-gray-200">
|
|
34
|
-
<pre class="text-xs text-gray-600 overflow-auto">{JSON.stringify(obj, null, 2)}</pre>
|
|
35
|
-
</div>
|
|
36
|
-
{/each}
|
|
37
|
-
{/if}
|
|
38
|
-
</div>
|
|
39
|
-
</aside>
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
interface Props {
|
|
3
|
-
appName: string;
|
|
4
|
-
onLogin: () => void;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
let { appName, onLogin }: Props = $props();
|
|
8
|
-
</script>
|
|
9
|
-
|
|
10
|
-
<div class="min-h-dvh flex flex-col items-center justify-center bg-gray-50 p-8">
|
|
11
|
-
<div class="text-center max-w-sm">
|
|
12
|
-
<h1 class="text-3xl font-bold text-gray-900 mb-2">{appName}</h1>
|
|
13
|
-
<p class="text-gray-500 mb-8">Sign in to get started</p>
|
|
14
|
-
<button
|
|
15
|
-
class="px-6 py-3 bg-gray-900 hover:bg-gray-800 text-white font-medium rounded-lg transition-colors"
|
|
16
|
-
onclick={onLogin}
|
|
17
|
-
>
|
|
18
|
-
Sign in
|
|
19
|
-
</button>
|
|
20
|
-
</div>
|
|
21
|
-
</div>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@import 'tailwindcss';
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ESNext",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"moduleResolution": "bundler",
|
|
6
|
-
"verbatimModuleSyntax": true,
|
|
7
|
-
"resolveJsonModule": true,
|
|
8
|
-
"isolatedModules": true,
|
|
9
|
-
"strict": true,
|
|
10
|
-
"noEmit": true
|
|
11
|
-
},
|
|
12
|
-
"include": ["src/**/*.ts", "src/**/*.svelte"]
|
|
13
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
# Rool App
|
|
2
|
-
|
|
3
|
-
A vanilla TypeScript app built on Rool Spaces - a persistent, collaborative environment for AI-driven object management.
|
|
4
|
-
|
|
5
|
-
## Technology Stack
|
|
6
|
-
|
|
7
|
-
- **Language**: TypeScript
|
|
8
|
-
- **Styling**: TailwindCSS v4
|
|
9
|
-
- **Bundler**: Vite
|
|
10
|
-
- **Package manager**: pnpm
|
|
11
|
-
|
|
12
|
-
For Rool documentation, **always read the README first**:
|
|
13
|
-
|
|
14
|
-
```
|
|
15
|
-
node_modules/@rool-dev/sdk/README.md
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## Rool Primitives
|
|
19
|
-
|
|
20
|
-
**RoolClient** - Authentication and space lifecycle. One per app.
|
|
21
|
-
|
|
22
|
-
**RoolSpace** - The workspace. Contains objects and conversations.
|
|
23
|
-
- `space.prompt(text)` - Invoke AI to create/modify objects
|
|
24
|
-
- `space.checkpoint()` - Create undo point before mutations
|
|
25
|
-
- `space.on(event, handler)` - Subscribe to real-time events
|
|
26
|
-
- `space.findObjects({ where? })` - Query objects
|
|
27
|
-
|
|
28
|
-
**Objects** - Key-value records with `id` field. Created via `space.createObject()` or AI. References between objects are data fields whose values are object IDs.
|
|
29
|
-
|
|
30
|
-
## Event-Driven Pattern
|
|
31
|
-
|
|
32
|
-
The SDK emits events for all changes. Build reactive UIs by subscribing:
|
|
33
|
-
|
|
34
|
-
```typescript
|
|
35
|
-
space.on('objectCreated', ({ objectId, object, source }) => {
|
|
36
|
-
// source: 'local_user' | 'remote_user' | 'remote_agent' | 'system'
|
|
37
|
-
updateUI(object);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
space.on('objectUpdated', ({ objectId, object }) => { ... });
|
|
41
|
-
space.on('objectDeleted', ({ objectId }) => { ... });
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
## Key Pattern
|
|
45
|
-
|
|
46
|
-
```typescript
|
|
47
|
-
// Always checkpoint before AI mutations for undo support
|
|
48
|
-
await space.checkpoint();
|
|
49
|
-
const { message, objects } = await space.prompt('Create a task');
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
## Entry Point
|
|
53
|
-
|
|
54
|
-
`src/main.ts` - Single file with auth, rendering, and event handlers.
|
|
55
|
-
|
|
56
|
-
## Adding Functionality
|
|
57
|
-
|
|
58
|
-
Useful packages:
|
|
59
|
-
- **marked** - Render markdown from AI responses
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
|
|
6
|
-
<title>Rool App</title>
|
|
7
|
-
</head>
|
|
8
|
-
<body>
|
|
9
|
-
<div id="app"></div>
|
|
10
|
-
<script type="module" src="/src/main.ts"></script>
|
|
11
|
-
</body>
|
|
12
|
-
</html>
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "rool-app",
|
|
3
|
-
"private": true,
|
|
4
|
-
"version": "0.0.0",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"dev": "vite",
|
|
8
|
-
"build": "vite build",
|
|
9
|
-
"preview": "vite preview",
|
|
10
|
-
"typecheck": "tsc --noEmit"
|
|
11
|
-
},
|
|
12
|
-
"dependencies": {
|
|
13
|
-
"@rool-dev/sdk": "workspace:*"
|
|
14
|
-
},
|
|
15
|
-
"devDependencies": {
|
|
16
|
-
"@tailwindcss/vite": "^4.0.0",
|
|
17
|
-
"tailwindcss": "^4.0.0",
|
|
18
|
-
"typescript": "^5.0.0",
|
|
19
|
-
"vite": "^6.0.0"
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@import 'tailwindcss';
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import { RoolClient, type RoolChannel, generateEntityId } from '@rool-dev/sdk';
|
|
2
|
-
import './app.css';
|
|
3
|
-
|
|
4
|
-
const APP_NAME = 'Rool App';
|
|
5
|
-
|
|
6
|
-
const client = new RoolClient();
|
|
7
|
-
const app = document.getElementById('app')!;
|
|
8
|
-
|
|
9
|
-
let logEl: HTMLElement;
|
|
10
|
-
let inputEl: HTMLInputElement;
|
|
11
|
-
let buttonEl: HTMLButtonElement;
|
|
12
|
-
|
|
13
|
-
// --- Rendering ---
|
|
14
|
-
|
|
15
|
-
function renderSplash() {
|
|
16
|
-
app.innerHTML = `
|
|
17
|
-
<div class="min-h-dvh flex flex-col items-center justify-center bg-gray-50 p-8">
|
|
18
|
-
<div class="text-center max-w-sm">
|
|
19
|
-
<h1 class="text-3xl font-bold text-gray-900 mb-2">${APP_NAME}</h1>
|
|
20
|
-
<p class="text-gray-500 mb-8">Sign in to get started</p>
|
|
21
|
-
<button id="login-btn" class="px-6 py-3 bg-gray-900 hover:bg-gray-800 text-white font-medium rounded-lg">
|
|
22
|
-
Sign in
|
|
23
|
-
</button>
|
|
24
|
-
</div>
|
|
25
|
-
</div>
|
|
26
|
-
`;
|
|
27
|
-
document.getElementById('login-btn')!.onclick = () => client.login(APP_NAME);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function renderApp(space: RoolChannel) {
|
|
31
|
-
app.innerHTML = `
|
|
32
|
-
<div class="min-h-dvh flex flex-col bg-gray-900 text-gray-100 font-mono text-sm">
|
|
33
|
-
<header class="flex items-center justify-between px-4 py-2 border-b border-gray-700">
|
|
34
|
-
<span class="text-gray-400">${APP_NAME}</span>
|
|
35
|
-
<button id="logout-btn" class="text-gray-500 hover:text-gray-300">logout</button>
|
|
36
|
-
</header>
|
|
37
|
-
<div id="log" class="flex-1 overflow-y-auto p-4 space-y-1"></div>
|
|
38
|
-
<form id="prompt-form" class="border-t border-gray-700 p-4">
|
|
39
|
-
<div class="flex gap-2">
|
|
40
|
-
<span class="text-green-400">></span>
|
|
41
|
-
<input
|
|
42
|
-
type="text"
|
|
43
|
-
id="prompt-input"
|
|
44
|
-
placeholder="Type a prompt..."
|
|
45
|
-
class="flex-1 bg-transparent outline-none text-gray-100 placeholder-gray-600"
|
|
46
|
-
autocomplete="off"
|
|
47
|
-
/>
|
|
48
|
-
<button type="submit" id="submit-btn" class="text-gray-500 hover:text-gray-300 disabled:opacity-50">
|
|
49
|
-
send
|
|
50
|
-
</button>
|
|
51
|
-
</div>
|
|
52
|
-
</form>
|
|
53
|
-
</div>
|
|
54
|
-
`;
|
|
55
|
-
|
|
56
|
-
logEl = document.getElementById('log')!;
|
|
57
|
-
inputEl = document.getElementById('prompt-input') as HTMLInputElement;
|
|
58
|
-
buttonEl = document.getElementById('submit-btn') as HTMLButtonElement;
|
|
59
|
-
|
|
60
|
-
document.getElementById('logout-btn')!.onclick = () => {
|
|
61
|
-
client.logout();
|
|
62
|
-
location.reload();
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const form = document.getElementById('prompt-form') as HTMLFormElement;
|
|
66
|
-
form.onsubmit = async (e) => {
|
|
67
|
-
e.preventDefault();
|
|
68
|
-
const text = inputEl.value.trim();
|
|
69
|
-
if (!text) return;
|
|
70
|
-
|
|
71
|
-
log('prompt', text);
|
|
72
|
-
inputEl.value = '';
|
|
73
|
-
inputEl.disabled = true;
|
|
74
|
-
buttonEl.disabled = true;
|
|
75
|
-
|
|
76
|
-
try {
|
|
77
|
-
await space.checkpoint();
|
|
78
|
-
const { message } = await space.prompt(text);
|
|
79
|
-
log('response', message);
|
|
80
|
-
} catch (err) {
|
|
81
|
-
log('error', err instanceof Error ? err.message : String(err));
|
|
82
|
-
} finally {
|
|
83
|
-
inputEl.disabled = false;
|
|
84
|
-
buttonEl.disabled = false;
|
|
85
|
-
inputEl.focus();
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
// Subscribe to space events
|
|
90
|
-
space.on('objectCreated', ({ objectId, object }) => {
|
|
91
|
-
log('objectCreated', `${objectId}: ${JSON.stringify(object)}`);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
space.on('objectUpdated', ({ objectId, object }) => {
|
|
95
|
-
log('objectUpdated', `${objectId}: ${JSON.stringify(object)}`);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
space.on('objectDeleted', ({ objectId }) => {
|
|
99
|
-
log('objectDeleted', objectId);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
space.on('linked', ({ sourceId, relation, targetId }) => {
|
|
103
|
-
log('linked', `${sourceId} --${relation}--> ${targetId}`);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
space.on('unlinked', ({ sourceId, relation, targetId }) => {
|
|
107
|
-
log('unlinked', `${sourceId} --${relation}--> ${targetId}`);
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
log('info', `Connected to space "${space.name}"`);
|
|
111
|
-
log('info', 'Type a prompt to create or modify objects. Events will appear here.');
|
|
112
|
-
inputEl.focus();
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function log(type: string, content: string) {
|
|
116
|
-
const line = document.createElement('div');
|
|
117
|
-
const colors: Record<string, string> = {
|
|
118
|
-
prompt: 'text-green-400',
|
|
119
|
-
response: 'text-blue-400',
|
|
120
|
-
info: 'text-gray-500',
|
|
121
|
-
error: 'text-red-400',
|
|
122
|
-
objectCreated: 'text-yellow-400',
|
|
123
|
-
objectUpdated: 'text-yellow-400',
|
|
124
|
-
objectDeleted: 'text-orange-400',
|
|
125
|
-
linked: 'text-purple-400',
|
|
126
|
-
unlinked: 'text-purple-400',
|
|
127
|
-
};
|
|
128
|
-
const color = colors[type] || 'text-gray-400';
|
|
129
|
-
|
|
130
|
-
line.innerHTML = `<span class="${color}">[${type}]</span> <span class="text-gray-300">${escapeHtml(content)}</span>`;
|
|
131
|
-
logEl.appendChild(line);
|
|
132
|
-
logEl.scrollTop = logEl.scrollHeight;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
function escapeHtml(text: string): string {
|
|
136
|
-
return text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// --- Main ---
|
|
140
|
-
|
|
141
|
-
async function main() {
|
|
142
|
-
const authenticated = await client.initialize();
|
|
143
|
-
|
|
144
|
-
if (!authenticated) {
|
|
145
|
-
renderSplash();
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// Find or create a space for this app
|
|
150
|
-
const spaces = await client.listSpaces();
|
|
151
|
-
const existing = spaces.find((s) => s.name === APP_NAME);
|
|
152
|
-
|
|
153
|
-
const channelId = generateEntityId();
|
|
154
|
-
let channel: RoolChannel;
|
|
155
|
-
if (existing) {
|
|
156
|
-
channel = await client.openChannel(existing.id, channelId);
|
|
157
|
-
} else {
|
|
158
|
-
const space = await client.createSpace(APP_NAME);
|
|
159
|
-
channel = await space.openChannel(channelId);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
renderApp(channel);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
main().catch(console.error);
|