create-tokensafe-ui 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.
- package/bin/index.js +72 -0
- package/package.json +36 -3
- package/templates/default/README.md +23 -0
- package/templates/default/_gitignore +4 -0
- package/templates/default/_mcp.json +8 -0
- package/templates/default/index.html +13 -0
- package/templates/default/package.json +21 -0
- package/templates/default/src/App.tsx +46 -0
- package/templates/default/src/main.ts +7 -0
- package/templates/default/src/style.css +74 -0
- package/templates/default/tsconfig.json +12 -0
- package/templates/default/vite.config.ts +9 -0
- package/README.md +0 -3
package/bin/index.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = path.dirname(__filename);
|
|
9
|
+
|
|
10
|
+
const targetArg = process.argv[2];
|
|
11
|
+
|
|
12
|
+
if (!targetArg || targetArg === '--help' || targetArg === '-h') {
|
|
13
|
+
console.log(`
|
|
14
|
+
š TokenSafe UI Scaffolding CLI
|
|
15
|
+
|
|
16
|
+
Usage:
|
|
17
|
+
pnpm create tokensafe-ui <project-name>
|
|
18
|
+
npm create tokensafe-ui <project-name>
|
|
19
|
+
npx create-tokensafe-ui <project-name>
|
|
20
|
+
|
|
21
|
+
Example:
|
|
22
|
+
npx create-tokensafe-ui my-agent-app
|
|
23
|
+
`);
|
|
24
|
+
process.exit(0);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const targetDir = path.resolve(process.cwd(), targetArg);
|
|
28
|
+
const projectName = path.basename(targetDir);
|
|
29
|
+
|
|
30
|
+
if (fs.existsSync(targetDir) && fs.readdirSync(targetDir).length > 0) {
|
|
31
|
+
console.error(`ā Error: Target directory '${targetDir}' is not empty.`);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
console.log(`\nš¦ Scaffolding new TokenSafe UI project in ${targetDir}...\n`);
|
|
36
|
+
|
|
37
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
38
|
+
|
|
39
|
+
const templateDir = path.resolve(__dirname, '../templates/default');
|
|
40
|
+
|
|
41
|
+
function copyRecursive(src, dest) {
|
|
42
|
+
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
43
|
+
for (const entry of entries) {
|
|
44
|
+
const srcPath = path.join(src, entry.name);
|
|
45
|
+
const destName = entry.name.startsWith('_') ? '.' + entry.name.slice(1) : entry.name;
|
|
46
|
+
const destPath = path.join(dest, destName);
|
|
47
|
+
|
|
48
|
+
if (entry.isDirectory()) {
|
|
49
|
+
fs.mkdirSync(destPath, { recursive: true });
|
|
50
|
+
copyRecursive(srcPath, destPath);
|
|
51
|
+
} else {
|
|
52
|
+
let content = fs.readFileSync(srcPath, 'utf-8');
|
|
53
|
+
if (entry.name === 'package.json') {
|
|
54
|
+
content = content.replace(/__PROJECT_NAME__/g, projectName);
|
|
55
|
+
}
|
|
56
|
+
fs.writeFileSync(destPath, content, 'utf-8');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
copyRecursive(templateDir, targetDir);
|
|
62
|
+
|
|
63
|
+
console.log(`ā
Project created successfully!
|
|
64
|
+
|
|
65
|
+
Next steps:
|
|
66
|
+
cd ${targetArg}
|
|
67
|
+
pnpm install (or npm install)
|
|
68
|
+
pnpm dev (or npm run dev)
|
|
69
|
+
|
|
70
|
+
š¤ Coding Agent Integration:
|
|
71
|
+
Your project is pre-configured with .mcp.json for Antigravity, Claude Code, and Cursor.
|
|
72
|
+
`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-tokensafe-ui",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Scaffolding CLI for creating TokenSafe UI projects with OUMV Protocol support",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"create-tokensafe-ui": "./bin/index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin",
|
|
11
|
+
"templates"
|
|
12
|
+
],
|
|
13
|
+
"keywords": [
|
|
14
|
+
"tokensafe",
|
|
15
|
+
"create-tokensafe-ui",
|
|
16
|
+
"agent-dom",
|
|
17
|
+
"oumv",
|
|
18
|
+
"scaffold",
|
|
19
|
+
"starter",
|
|
20
|
+
"ai-agent"
|
|
21
|
+
],
|
|
22
|
+
"author": "TokenSafe Dev",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "https://github.com/tokensafe-dev/tokensafe-ui.git",
|
|
30
|
+
"directory": "packages/create-tokensafe-ui"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://github.com/tokensafe-dev/tokensafe-ui#readme",
|
|
33
|
+
"bugs": {
|
|
34
|
+
"url": "https://github.com/tokensafe-dev/tokensafe-ui/issues"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"test": "vitest run"
|
|
38
|
+
}
|
|
6
39
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# TokenSafe UI Starter App
|
|
2
|
+
|
|
3
|
+
A modern, deterministic frontend application built with **TokenSafe UI** and implementing **OUMV: The Universal Agent-UI Protocol**.
|
|
4
|
+
|
|
5
|
+
## Getting Started
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Install dependencies
|
|
9
|
+
pnpm install
|
|
10
|
+
|
|
11
|
+
# Start local dev server
|
|
12
|
+
pnpm dev
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Open [http://localhost:5173](http://localhost:5173) in your browser.
|
|
16
|
+
|
|
17
|
+
## AI Agent Integration
|
|
18
|
+
|
|
19
|
+
This project is pre-configured with `.mcp.json`. When you open this folder with Claude Code, Cursor, or Antigravity, the AI agent can autonomously:
|
|
20
|
+
- **Observe** the live UI via structured semantic snapshots (L0āL4).
|
|
21
|
+
- **Understand** the dynamic reactive dependency graph and causality traces.
|
|
22
|
+
- **Mutate** components safely with OCC versioning and atomic rollback.
|
|
23
|
+
- **Verify** state changes and user interactions in low single-digit milliseconds.
|
|
@@ -0,0 +1,13 @@
|
|
|
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" />
|
|
6
|
+
<title>TokenSafe UI App</title>
|
|
7
|
+
<link rel="stylesheet" href="/src/style.css" />
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div id="app"></div>
|
|
11
|
+
<script type="module" src="/src/main.ts"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "__PROJECT_NAME__",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite",
|
|
8
|
+
"build": "vite build",
|
|
9
|
+
"preview": "vite preview",
|
|
10
|
+
"typecheck": "tsc --noEmit"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"tokensafe-ui": "^0.1.0",
|
|
14
|
+
"zod": "^3.24.1"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@agent-dom/vite": "^0.1.0",
|
|
18
|
+
"typescript": "^5.7.2",
|
|
19
|
+
"vite": "^6.0.7"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { defineComponent, z, bind, h } from 'tokensafe-ui';
|
|
2
|
+
|
|
3
|
+
export const App = defineComponent({
|
|
4
|
+
id: 'app-root',
|
|
5
|
+
state: {
|
|
6
|
+
count: z.number().default(0),
|
|
7
|
+
name: z.string().default('Agent'),
|
|
8
|
+
},
|
|
9
|
+
actions: {
|
|
10
|
+
inc: (s) => ({ ...s, count: s.count + 1 }),
|
|
11
|
+
dec: (s) => ({ ...s, count: Math.max(0, s.count - 1) }),
|
|
12
|
+
setName: (s, name: string) => ({ ...s, name }),
|
|
13
|
+
},
|
|
14
|
+
render: ({ state, emit }) =>
|
|
15
|
+
h(
|
|
16
|
+
'div',
|
|
17
|
+
{ class: 'container', 'data-agent-id': 'app-root:container' },
|
|
18
|
+
h('h1', { 'data-agent-id': 'app-root:title' }, 'TokenSafe UI'),
|
|
19
|
+
h('p', { 'data-agent-id': 'app-root:greeting' }, `Hello, ${state.name}!`),
|
|
20
|
+
h('input', {
|
|
21
|
+
type: 'text',
|
|
22
|
+
placeholder: 'Enter your name',
|
|
23
|
+
'data-agent-id': 'app-root:input-name',
|
|
24
|
+
...bind(emit.setName, state.name),
|
|
25
|
+
}),
|
|
26
|
+
h(
|
|
27
|
+
'div',
|
|
28
|
+
{ class: 'counter-group', 'data-agent-id': 'app-root:counter-group' },
|
|
29
|
+
h(
|
|
30
|
+
'button',
|
|
31
|
+
{ 'data-agent-id': 'app-root:btn-dec', onClick: () => emit.dec() },
|
|
32
|
+
'-'
|
|
33
|
+
),
|
|
34
|
+
h(
|
|
35
|
+
'span',
|
|
36
|
+
{ class: 'count-value', 'data-agent-id': 'app-root:count-value' },
|
|
37
|
+
String(state.count)
|
|
38
|
+
),
|
|
39
|
+
h(
|
|
40
|
+
'button',
|
|
41
|
+
{ 'data-agent-id': 'app-root:btn-inc', onClick: () => emit.inc() },
|
|
42
|
+
'+'
|
|
43
|
+
)
|
|
44
|
+
)
|
|
45
|
+
),
|
|
46
|
+
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
3
|
+
line-height: 1.5;
|
|
4
|
+
color: #1e293b;
|
|
5
|
+
background-color: #f8fafc;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
body {
|
|
9
|
+
margin: 0;
|
|
10
|
+
display: flex;
|
|
11
|
+
place-items: center;
|
|
12
|
+
min-width: 320px;
|
|
13
|
+
min-height: 100vh;
|
|
14
|
+
justify-content: center;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.container {
|
|
18
|
+
background: #ffffff;
|
|
19
|
+
padding: 2.5rem;
|
|
20
|
+
border-radius: 12px;
|
|
21
|
+
box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
|
|
22
|
+
text-align: center;
|
|
23
|
+
max-width: 400px;
|
|
24
|
+
width: 100%;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
h1 {
|
|
28
|
+
font-size: 1.8rem;
|
|
29
|
+
margin-bottom: 0.5rem;
|
|
30
|
+
color: #0f172a;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
input {
|
|
34
|
+
width: 80%;
|
|
35
|
+
padding: 0.6rem 0.8rem;
|
|
36
|
+
border: 1px solid #cbd5e1;
|
|
37
|
+
border-radius: 6px;
|
|
38
|
+
font-size: 1rem;
|
|
39
|
+
margin-bottom: 1.5rem;
|
|
40
|
+
outline: none;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
input:focus {
|
|
44
|
+
border-color: #3b82f6;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.counter-group {
|
|
48
|
+
display: flex;
|
|
49
|
+
align-items: center;
|
|
50
|
+
justify-content: center;
|
|
51
|
+
gap: 1rem;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
button {
|
|
55
|
+
border-radius: 8px;
|
|
56
|
+
border: 1px solid transparent;
|
|
57
|
+
padding: 0.6em 1.2em;
|
|
58
|
+
font-size: 1.1em;
|
|
59
|
+
font-weight: 600;
|
|
60
|
+
cursor: pointer;
|
|
61
|
+
background-color: #2563eb;
|
|
62
|
+
color: white;
|
|
63
|
+
transition: background-color 0.2s;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
button:hover {
|
|
67
|
+
background-color: #1d4ed8;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.count-value {
|
|
71
|
+
font-size: 1.5rem;
|
|
72
|
+
font-weight: 700;
|
|
73
|
+
min-width: 2rem;
|
|
74
|
+
}
|
package/README.md
DELETED