@puredesktop/create-app 2.1.4 → 2.1.6
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/create-puredesktop-app.mjs +319 -319
- package/package.json +1 -1
- package/template/README.md +52 -52
- package/template/agents.md +11 -11
- package/template/docs/README.md +30 -30
- package/template/docs/agent.md +58 -58
- package/template/docs/app-lifecycle.md +60 -60
- package/template/docs/bridge/README.md +84 -84
- package/template/docs/bridge/dialog.md +56 -56
- package/template/docs/bridge/fs.md +95 -95
- package/template/docs/bridge/network.md +38 -38
- package/template/docs/bridge/settings.md +63 -63
- package/template/docs/bridge/storage.md +48 -48
- package/template/docs/plugin-manifest.md +104 -104
- package/template/docs/theme-vars.md +138 -138
- package/template/docs/tool-handlers.md +122 -122
- package/template/docs/ui-and-components.md +57 -56
- package/template/package.json +10 -10
- package/template/plugin.json +20 -20
- package/template/src/App.tsx +4 -4
- package/template/src/bridge/platformBridge.ts +122 -122
- package/template/src/components/AppShell.tsx +9 -9
|
@@ -1,124 +1,124 @@
|
|
|
1
|
-
# Tool Handlers
|
|
2
|
-
|
|
3
|
-
App agent tools have two halves:
|
|
4
|
-
|
|
5
|
-
- `plugin.json` declares the tool schema for the shell agent.
|
|
6
|
-
- app source registers a runtime handler after the iframe bridge is ready.
|
|
7
|
-
|
|
8
|
-
The names must match exactly.
|
|
9
|
-
|
|
10
|
-
## Generated Structure
|
|
11
|
-
|
|
12
|
-
When the manifest includes `app.agents.tools`, the generator creates this
|
|
13
|
-
structure and wires `useAppAgentTools(ready)` into `src/App.tsx`:
|
|
14
|
-
|
|
15
|
-
```text
|
|
16
|
-
src/
|
|
17
|
-
agents/
|
|
18
|
-
catalog.ts
|
|
19
|
-
handlers/
|
|
20
|
-
index.ts
|
|
21
|
-
hooks/
|
|
22
|
-
useAppAgentTools.ts
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## Catalog
|
|
26
|
-
|
|
27
|
-
Generated from manifest tool names:
|
|
28
|
-
|
|
29
|
-
```ts
|
|
30
|
-
export const APP_AGENT_TOOL_NAMES = ['listItems'] as const
|
|
31
|
-
|
|
32
|
-
export const APP_AGENT_LOG_LABEL = '{{APP_SLUG}}'
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
Keep this list in the same order as `plugin.json` `app.agents.tools`.
|
|
36
|
-
|
|
37
|
-
## Registration Hook
|
|
38
|
-
|
|
39
|
-
Generated when tools exist:
|
|
40
|
-
|
|
41
|
-
```ts
|
|
42
|
-
import { usePlatformAgentTools } from '@puredesktop/puredesktop-ui-bridge/bridge/react/usePlatformAgentTools'
|
|
43
|
-
import { APP_AGENT_LOG_LABEL, APP_AGENT_TOOL_NAMES } from '../agents/catalog'
|
|
44
|
-
import { appAgentHandlers } from '../agents/handlers'
|
|
45
|
-
|
|
46
|
-
export function useAppAgentTools(ready: boolean): void {
|
|
47
|
-
usePlatformAgentTools({
|
|
48
|
-
ready,
|
|
49
|
-
tools: APP_AGENT_TOOL_NAMES,
|
|
50
|
-
logLabel: APP_AGENT_LOG_LABEL,
|
|
51
|
-
handlers: appAgentHandlers,
|
|
52
|
-
})
|
|
53
|
-
}
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
Call this hook from `src/App.tsx` after `usePlatformBridge()`:
|
|
57
|
-
|
|
58
|
-
```ts
|
|
59
|
-
useAppAgentTools(ready)
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
## Handler Shape
|
|
63
|
-
|
|
64
|
-
Generated handlers start as explicit not-implemented tool errors. Replace each
|
|
65
|
-
stub with app domain logic.
|
|
66
|
-
|
|
67
|
-
```ts
|
|
68
|
-
import {
|
|
69
|
-
agentToolErrorContent,
|
|
70
|
-
formatAgentToolJson,
|
|
71
|
-
readAgentToolStringArg,
|
|
72
|
-
} from '@puredesktop/puredesktop-ui-bridge/bridge/agentToolHelpers'
|
|
73
|
-
import type { AgentToolHandler } from '@puredesktop/puredesktop-ui-bridge/bridge/react/usePlatformAgentTools'
|
|
74
|
-
|
|
75
|
-
const listItems: AgentToolHandler = async invoke => {
|
|
76
|
-
const status = readAgentToolStringArg(invoke.arguments, 'status')
|
|
77
|
-
|
|
78
|
-
return {
|
|
79
|
-
content: formatAgentToolJson({
|
|
80
|
-
items: [],
|
|
81
|
-
status: status || null,
|
|
82
|
-
}),
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export const appAgentHandlers = {
|
|
87
|
-
listItems,
|
|
88
|
-
} satisfies Record<string, AgentToolHandler>
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
Return compact JSON for structured data. Return `agentToolErrorContent(message)`
|
|
92
|
-
for validation failures that the agent can correct.
|
|
93
|
-
|
|
94
|
-
## Read Tool Pattern
|
|
95
|
-
|
|
96
|
-
Read tools return current app state, ids, paths, and exact values needed before a
|
|
97
|
-
write. The agent needs stable ids and exact target names.
|
|
98
|
-
|
|
99
|
-
## Write Tool Pattern
|
|
100
|
-
|
|
101
|
-
Write tools validate precise targets. A write handler returns a short result
|
|
102
|
-
with the changed id/path and enough data for the agent to explain what changed.
|
|
103
|
-
|
|
104
|
-
Manifest write tools that mutate files, records, external services, or broad app
|
|
105
|
-
state set `requiresApproval: true` unless the action is intentionally safe.
|
|
106
|
-
|
|
107
|
-
## Validation
|
|
108
|
-
|
|
1
|
+
# Tool Handlers
|
|
2
|
+
|
|
3
|
+
App agent tools have two halves:
|
|
4
|
+
|
|
5
|
+
- `plugin.json` declares the tool schema for the shell agent.
|
|
6
|
+
- app source registers a runtime handler after the iframe bridge is ready.
|
|
7
|
+
|
|
8
|
+
The names must match exactly.
|
|
9
|
+
|
|
10
|
+
## Generated Structure
|
|
11
|
+
|
|
12
|
+
When the manifest includes `app.agents.tools`, the generator creates this
|
|
13
|
+
structure and wires `useAppAgentTools(ready)` into `src/App.tsx`:
|
|
14
|
+
|
|
15
|
+
```text
|
|
16
|
+
src/
|
|
17
|
+
agents/
|
|
18
|
+
catalog.ts
|
|
19
|
+
handlers/
|
|
20
|
+
index.ts
|
|
21
|
+
hooks/
|
|
22
|
+
useAppAgentTools.ts
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Catalog
|
|
26
|
+
|
|
27
|
+
Generated from manifest tool names:
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
export const APP_AGENT_TOOL_NAMES = ['listItems'] as const
|
|
31
|
+
|
|
32
|
+
export const APP_AGENT_LOG_LABEL = '{{APP_SLUG}}'
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Keep this list in the same order as `plugin.json` `app.agents.tools`.
|
|
36
|
+
|
|
37
|
+
## Registration Hook
|
|
38
|
+
|
|
39
|
+
Generated when tools exist:
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { usePlatformAgentTools } from '@puredesktop/puredesktop-ui-bridge/bridge/react/usePlatformAgentTools'
|
|
43
|
+
import { APP_AGENT_LOG_LABEL, APP_AGENT_TOOL_NAMES } from '../agents/catalog'
|
|
44
|
+
import { appAgentHandlers } from '../agents/handlers'
|
|
45
|
+
|
|
46
|
+
export function useAppAgentTools(ready: boolean): void {
|
|
47
|
+
usePlatformAgentTools({
|
|
48
|
+
ready,
|
|
49
|
+
tools: APP_AGENT_TOOL_NAMES,
|
|
50
|
+
logLabel: APP_AGENT_LOG_LABEL,
|
|
51
|
+
handlers: appAgentHandlers,
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Call this hook from `src/App.tsx` after `usePlatformBridge()`:
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
useAppAgentTools(ready)
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Handler Shape
|
|
63
|
+
|
|
64
|
+
Generated handlers start as explicit not-implemented tool errors. Replace each
|
|
65
|
+
stub with app domain logic.
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
import {
|
|
69
|
+
agentToolErrorContent,
|
|
70
|
+
formatAgentToolJson,
|
|
71
|
+
readAgentToolStringArg,
|
|
72
|
+
} from '@puredesktop/puredesktop-ui-bridge/bridge/agentToolHelpers'
|
|
73
|
+
import type { AgentToolHandler } from '@puredesktop/puredesktop-ui-bridge/bridge/react/usePlatformAgentTools'
|
|
74
|
+
|
|
75
|
+
const listItems: AgentToolHandler = async invoke => {
|
|
76
|
+
const status = readAgentToolStringArg(invoke.arguments, 'status')
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
content: formatAgentToolJson({
|
|
80
|
+
items: [],
|
|
81
|
+
status: status || null,
|
|
82
|
+
}),
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export const appAgentHandlers = {
|
|
87
|
+
listItems,
|
|
88
|
+
} satisfies Record<string, AgentToolHandler>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Return compact JSON for structured data. Return `agentToolErrorContent(message)`
|
|
92
|
+
for validation failures that the agent can correct.
|
|
93
|
+
|
|
94
|
+
## Read Tool Pattern
|
|
95
|
+
|
|
96
|
+
Read tools return current app state, ids, paths, and exact values needed before a
|
|
97
|
+
write. The agent needs stable ids and exact target names.
|
|
98
|
+
|
|
99
|
+
## Write Tool Pattern
|
|
100
|
+
|
|
101
|
+
Write tools validate precise targets. A write handler returns a short result
|
|
102
|
+
with the changed id/path and enough data for the agent to explain what changed.
|
|
103
|
+
|
|
104
|
+
Manifest write tools that mutate files, records, external services, or broad app
|
|
105
|
+
state set `requiresApproval: true` unless the action is intentionally safe.
|
|
106
|
+
|
|
107
|
+
## Validation
|
|
108
|
+
|
|
109
109
|
`npm run puredesktop:check` verifies declared tool names appear in source and in
|
|
110
110
|
the built output. For generated tool scaffolds, it also verifies:
|
|
111
|
-
|
|
112
|
-
- `src/agents/catalog.ts` exports `APP_AGENT_TOOL_NAMES`;
|
|
113
|
-
- every manifest tool name appears in the catalog;
|
|
114
|
-
- `src/agents/handlers/index.ts` exports `appAgentHandlers`;
|
|
115
|
-
- every manifest tool name appears in the handler map;
|
|
116
|
-
- `src/hooks/useAppAgentTools.ts` registers with `usePlatformAgentTools`;
|
|
117
|
-
- `src/App.tsx` calls `useAppAgentTools(ready)`.
|
|
118
|
-
|
|
119
|
-
Build before running it:
|
|
120
|
-
|
|
121
|
-
```bash
|
|
122
|
-
npm run build
|
|
123
|
-
npm run puredesktop:check
|
|
124
|
-
```
|
|
111
|
+
|
|
112
|
+
- `src/agents/catalog.ts` exports `APP_AGENT_TOOL_NAMES`;
|
|
113
|
+
- every manifest tool name appears in the catalog;
|
|
114
|
+
- `src/agents/handlers/index.ts` exports `appAgentHandlers`;
|
|
115
|
+
- every manifest tool name appears in the handler map;
|
|
116
|
+
- `src/hooks/useAppAgentTools.ts` registers with `usePlatformAgentTools`;
|
|
117
|
+
- `src/App.tsx` calls `useAppAgentTools(ready)`.
|
|
118
|
+
|
|
119
|
+
Build before running it:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
npm run build
|
|
123
|
+
npm run puredesktop:check
|
|
124
|
+
```
|
|
@@ -1,59 +1,60 @@
|
|
|
1
|
-
# UI And Components
|
|
2
|
-
|
|
3
|
-
The generated app starts intentionally small. Build the real workflow in
|
|
4
|
-
`src/components/AppShell.tsx` and move domain logic into `src/lib/` as it grows.
|
|
5
|
-
|
|
6
|
-
## AppFrame
|
|
7
|
-
|
|
8
|
-
Every render path in `src/App.tsx` uses `AppFrame`. This gives the iframe the
|
|
9
|
-
PureDesktop reset, theme CSS variables, and shell-compatible surface styling.
|
|
10
|
-
|
|
11
|
-
## Component Shape
|
|
12
|
-
|
|
13
|
-
Start with controlled, simple components:
|
|
14
|
-
|
|
15
|
-
```text
|
|
16
|
-
src/
|
|
17
|
-
components/
|
|
18
|
-
AppShell.tsx
|
|
19
|
-
ItemList.tsx
|
|
20
|
-
ItemDetail.tsx
|
|
21
|
-
lib/
|
|
22
|
-
items.ts
|
|
23
|
-
items.test.ts
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
Keep app state close to the workflow until a shared hook or reducer removes real
|
|
27
|
-
duplication.
|
|
28
|
-
|
|
29
|
-
## Platform Components
|
|
30
|
-
|
|
31
|
-
Import shared UI
|
|
32
|
-
|
|
1
|
+
# UI And Components
|
|
2
|
+
|
|
3
|
+
The generated app starts intentionally small. Build the real workflow in
|
|
4
|
+
`src/components/AppShell.tsx` and move domain logic into `src/lib/` as it grows.
|
|
5
|
+
|
|
6
|
+
## AppFrame
|
|
7
|
+
|
|
8
|
+
Every render path in `src/App.tsx` uses `AppFrame`. This gives the iframe the
|
|
9
|
+
PureDesktop reset, theme CSS variables, and shell-compatible surface styling.
|
|
10
|
+
|
|
11
|
+
## Component Shape
|
|
12
|
+
|
|
13
|
+
Start with controlled, simple components:
|
|
14
|
+
|
|
15
|
+
```text
|
|
16
|
+
src/
|
|
17
|
+
components/
|
|
18
|
+
AppShell.tsx
|
|
19
|
+
ItemList.tsx
|
|
20
|
+
ItemDetail.tsx
|
|
21
|
+
lib/
|
|
22
|
+
items.ts
|
|
23
|
+
items.test.ts
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Keep app state close to the workflow until a shared hook or reducer removes real
|
|
27
|
+
duplication.
|
|
28
|
+
|
|
29
|
+
## Platform Components
|
|
30
|
+
|
|
31
|
+
Import shared UI by exact exported package paths before creating custom
|
|
32
|
+
primitives. Do not invent component folders.
|
|
33
33
|
|
|
34
34
|
Useful starting points:
|
|
35
35
|
|
|
36
|
-
- `AppFrame`
|
|
37
|
-
- `EmptyState`
|
|
38
|
-
- `Heading`
|
|
39
|
-
- `Text`
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
36
|
+
- `AppFrame` from `@puredesktop/puredesktop-ui-bridge/components/common/containers/AppFrame`
|
|
37
|
+
- `EmptyState` from `@puredesktop/puredesktop-ui-bridge/components/common/feedback/EmptyState`
|
|
38
|
+
- `Heading` from `@puredesktop/puredesktop-ui-bridge/components/common/typography/Heading`
|
|
39
|
+
- `Text` from `@puredesktop/puredesktop-ui-bridge/components/common/typography/Text`
|
|
40
|
+
- `Button` from `@puredesktop/puredesktop-ui-bridge/components/common/buttons/Button`
|
|
41
|
+
|
|
42
|
+
## Styling
|
|
43
|
+
|
|
44
|
+
Use styled-components and platform CSS variables:
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
const Root = styled.div`
|
|
48
|
+
display: flex;
|
|
49
|
+
flex-direction: column;
|
|
50
|
+
gap: var(--platform-spacing-md);
|
|
51
|
+
color: var(--platform-colors-text);
|
|
52
|
+
background: var(--platform-colors-bg);
|
|
53
|
+
`
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Use app-local CSS variables only for app-specific meaning, for example
|
|
57
|
+
`--{{APP_SLUG}}-accent`.
|
|
58
|
+
|
|
59
|
+
See [Theme CSS variables](./theme-vars.md) for the generated list of available
|
|
60
|
+
platform variables by domain.
|
package/template/package.json
CHANGED
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
"private": true,
|
|
4
4
|
"version": "0.1.0",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"dev": "vite",
|
|
8
|
-
"build": "vite build",
|
|
9
|
-
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
10
|
-
"puredesktop:check": "node scripts/validate-puredesktop-app.mjs"
|
|
11
|
-
},
|
|
12
|
-
"dependencies": {
|
|
13
|
-
"@puredesktop/puredesktop-ui-bridge": "2.1.
|
|
14
|
-
"react": "^19.1.0",
|
|
15
|
-
"react-dom": "^19.1.0",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite",
|
|
8
|
+
"build": "vite build",
|
|
9
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
10
|
+
"puredesktop:check": "node scripts/validate-puredesktop-app.mjs"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@puredesktop/puredesktop-ui-bridge": "2.1.6",
|
|
14
|
+
"react": "^19.1.0",
|
|
15
|
+
"react-dom": "^19.1.0",
|
|
16
16
|
"styled-components": "^6.1.18"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
package/template/plugin.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
{
|
|
2
|
-
"schemaVersion": 1,
|
|
3
|
-
"id": "{{PLUGIN_ID}}",
|
|
4
|
-
"name": "{{APP_TITLE}}",
|
|
5
|
-
"permissions": ["network", "settings", "agents"],
|
|
6
|
-
"entrypoint": {
|
|
7
|
-
"kind": "dev-url",
|
|
8
|
-
"url": "http://localhost:{{APP_PORT}}"
|
|
9
|
-
},
|
|
10
|
-
"app": {
|
|
11
|
-
"id": "plugin.{{APP_SLUG}}",
|
|
12
|
-
"slug": "{{APP_SLUG}}",
|
|
13
|
-
"name": "{{APP_TITLE}}",
|
|
14
|
-
"navigationLabel": "{{APP_TITLE}}",
|
|
15
|
-
"productName": "pure.{{APP_SLUG}}",
|
|
16
|
-
"kind": "{{APP_SLUG}}",
|
|
17
|
-
"description": "{{APP_TITLE}} - built with PureDesktop.",
|
|
18
|
-
"usePureDesktopAiPanel": true
|
|
19
|
-
}
|
|
20
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"id": "{{PLUGIN_ID}}",
|
|
4
|
+
"name": "{{APP_TITLE}}",
|
|
5
|
+
"permissions": ["network", "settings", "agents"],
|
|
6
|
+
"entrypoint": {
|
|
7
|
+
"kind": "dev-url",
|
|
8
|
+
"url": "http://localhost:{{APP_PORT}}"
|
|
9
|
+
},
|
|
10
|
+
"app": {
|
|
11
|
+
"id": "plugin.{{APP_SLUG}}",
|
|
12
|
+
"slug": "{{APP_SLUG}}",
|
|
13
|
+
"name": "{{APP_TITLE}}",
|
|
14
|
+
"navigationLabel": "{{APP_TITLE}}",
|
|
15
|
+
"productName": "pure.{{APP_SLUG}}",
|
|
16
|
+
"kind": "{{APP_SLUG}}",
|
|
17
|
+
"description": "{{APP_TITLE}} - built with PureDesktop.",
|
|
18
|
+
"usePureDesktopAiPanel": true
|
|
19
|
+
}
|
|
20
|
+
}
|
package/template/src/App.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AppFrame } from '@puredesktop/puredesktop-ui-bridge/components/common/containers/AppFrame'
|
|
2
|
-
import { EmptyState } from '@puredesktop/puredesktop-ui-bridge/components/common/feedback/EmptyState'
|
|
1
|
+
import { AppFrame } from '@puredesktop/puredesktop-ui-bridge/components/common/containers/AppFrame'
|
|
2
|
+
import { EmptyState } from '@puredesktop/puredesktop-ui-bridge/components/common/feedback/EmptyState'
|
|
3
3
|
import { usePlatformBridge } from '@puredesktop/puredesktop-ui-bridge/bridge/react/usePlatformBridge'
|
|
4
4
|
import { AppShell } from './components/AppShell'
|
|
5
5
|
import { isStandaloneDevMode } from './bridge/platformBridge'
|
|
@@ -33,8 +33,8 @@ export function App(): React.ReactElement {
|
|
|
33
33
|
bootError
|
|
34
34
|
? bootError.message
|
|
35
35
|
: booting
|
|
36
|
-
? 'Loading...'
|
|
37
|
-
: 'Waiting for PureDesktop shell bridge...'
|
|
36
|
+
? 'Loading...'
|
|
37
|
+
: 'Waiting for PureDesktop shell bridge...'
|
|
38
38
|
}
|
|
39
39
|
/>
|
|
40
40
|
</AppFrame>
|