@puredesktop/create-app 1.0.0-beta.2 → 2.1.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/bin/create-puredesktop-app.mjs +308 -77
- package/package.json +2 -2
- package/template/README.md +39 -296
- package/template/docs/README.md +31 -0
- package/template/docs/agent.md +58 -0
- package/template/docs/app-lifecycle.md +60 -0
- package/template/docs/bridge/README.md +79 -0
- package/template/docs/bridge/dialog.md +56 -0
- package/template/docs/bridge/fs.md +95 -0
- package/template/docs/bridge/network.md +38 -0
- package/template/docs/bridge/settings.md +63 -0
- package/template/docs/bridge/storage.md +48 -0
- package/template/docs/plugin-manifest.md +108 -0
- package/template/docs/theme-vars.md +138 -0
- package/template/docs/tool-handlers.md +124 -0
- package/template/docs/ui-and-components.md +59 -0
- package/template/package.json +4 -4
- package/template/plugin.json +1 -1
- package/template/scripts/validate-puredesktop-app.mjs +66 -1
- package/template/src/App.tsx +2 -2
- package/template/src/bridge/platformBridge.ts +62 -15
|
@@ -199,6 +199,9 @@ async function validateAgentTools(manifest, distPath) {
|
|
|
199
199
|
|
|
200
200
|
if (toolNames.size === 0) return
|
|
201
201
|
|
|
202
|
+
const manifestToolNames = [...toolNames]
|
|
203
|
+
await validateAgentToolScaffold(manifestToolNames)
|
|
204
|
+
|
|
202
205
|
const sourceText = await readProjectText(join(ROOT, 'src'))
|
|
203
206
|
const distText = await readProjectText(distPath)
|
|
204
207
|
const registrationHints = ['usePlatformAgentTools', 'registerAgentTools', 'agents.tools.register']
|
|
@@ -206,7 +209,7 @@ async function validateAgentTools(manifest, distPath) {
|
|
|
206
209
|
errors.push('Declared app agent tools must be registered in source with usePlatformAgentTools or agents.tools.register.')
|
|
207
210
|
}
|
|
208
211
|
|
|
209
|
-
for (const toolName of
|
|
212
|
+
for (const toolName of manifestToolNames) {
|
|
210
213
|
if (!sourceText.includes(toolName)) {
|
|
211
214
|
errors.push(`Declared app agent tool "${toolName}" was not found in source files.`)
|
|
212
215
|
}
|
|
@@ -220,6 +223,68 @@ async function validateAgentTools(manifest, distPath) {
|
|
|
220
223
|
}
|
|
221
224
|
}
|
|
222
225
|
|
|
226
|
+
async function validateAgentToolScaffold(toolNames) {
|
|
227
|
+
const catalogPath = join(ROOT, 'src', 'agents', 'catalog.ts')
|
|
228
|
+
const handlersPath = join(ROOT, 'src', 'agents', 'handlers', 'index.ts')
|
|
229
|
+
const hookPath = join(ROOT, 'src', 'hooks', 'useAppAgentTools.ts')
|
|
230
|
+
const appPath = join(ROOT, 'src', 'App.tsx')
|
|
231
|
+
|
|
232
|
+
const catalogText = await readRequiredText(
|
|
233
|
+
catalogPath,
|
|
234
|
+
'Declared app agent tools require src/agents/catalog.ts.',
|
|
235
|
+
)
|
|
236
|
+
const handlersText = await readRequiredText(
|
|
237
|
+
handlersPath,
|
|
238
|
+
'Declared app agent tools require src/agents/handlers/index.ts.',
|
|
239
|
+
)
|
|
240
|
+
const hookText = await readRequiredText(
|
|
241
|
+
hookPath,
|
|
242
|
+
'Declared app agent tools require src/hooks/useAppAgentTools.ts.',
|
|
243
|
+
)
|
|
244
|
+
const appText = await readRequiredText(
|
|
245
|
+
appPath,
|
|
246
|
+
'Declared app agent tools require src/App.tsx.',
|
|
247
|
+
)
|
|
248
|
+
|
|
249
|
+
if (!catalogText || !handlersText || !hookText || !appText) return
|
|
250
|
+
|
|
251
|
+
if (!catalogText.includes('APP_AGENT_TOOL_NAMES')) {
|
|
252
|
+
errors.push('src/agents/catalog.ts must export APP_AGENT_TOOL_NAMES.')
|
|
253
|
+
}
|
|
254
|
+
if (!handlersText.includes('appAgentHandlers')) {
|
|
255
|
+
errors.push('src/agents/handlers/index.ts must export appAgentHandlers.')
|
|
256
|
+
}
|
|
257
|
+
if (!hookText.includes('usePlatformAgentTools')) {
|
|
258
|
+
errors.push('src/hooks/useAppAgentTools.ts must call usePlatformAgentTools.')
|
|
259
|
+
}
|
|
260
|
+
if (!hookText.includes('APP_AGENT_TOOL_NAMES')) {
|
|
261
|
+
errors.push('src/hooks/useAppAgentTools.ts must register APP_AGENT_TOOL_NAMES.')
|
|
262
|
+
}
|
|
263
|
+
if (!appText.includes('useAppAgentTools(ready)')) {
|
|
264
|
+
errors.push('src/App.tsx must call useAppAgentTools(ready).')
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
for (const toolName of toolNames) {
|
|
268
|
+
if (!catalogText.includes(toolName)) {
|
|
269
|
+
errors.push(`src/agents/catalog.ts is missing app agent tool "${toolName}".`)
|
|
270
|
+
}
|
|
271
|
+
if (!handlersText.includes(toolName)) {
|
|
272
|
+
errors.push(`src/agents/handlers/index.ts is missing app agent tool "${toolName}".`)
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
async function readRequiredText(path, message) {
|
|
278
|
+
if (!(await isFile(path))) {
|
|
279
|
+
errors.push(message)
|
|
280
|
+
return ''
|
|
281
|
+
}
|
|
282
|
+
return readFile(path, 'utf8').catch(error => {
|
|
283
|
+
errors.push(`${message} ${errorMessage(error)}`)
|
|
284
|
+
return ''
|
|
285
|
+
})
|
|
286
|
+
}
|
|
287
|
+
|
|
223
288
|
async function readProjectText(root) {
|
|
224
289
|
const chunks = []
|
|
225
290
|
await collectText(root, chunks)
|
package/template/src/App.tsx
CHANGED
|
@@ -1,9 +1,58 @@
|
|
|
1
|
-
import { bridge } from '@puredesktop/puredesktop-ui-bridge/bridge/client'
|
|
2
|
-
import {
|
|
3
|
-
import { APP_SLUG } from '../constants'
|
|
4
|
-
import type { AppSettings } from '../types'
|
|
5
|
-
|
|
6
|
-
export {
|
|
1
|
+
import { bridge } from '@puredesktop/puredesktop-ui-bridge/bridge/client'
|
|
2
|
+
import { getPlatformAppSettings } from '@puredesktop/puredesktop-ui-bridge/bridge/appSettings'
|
|
3
|
+
import { APP_SLUG } from '../constants'
|
|
4
|
+
import type { AppSettings } from '../types'
|
|
5
|
+
|
|
6
|
+
export {
|
|
7
|
+
getPlatformAppSettings,
|
|
8
|
+
updatePlatformAppSettings,
|
|
9
|
+
} from '@puredesktop/puredesktop-ui-bridge/bridge/appSettings'
|
|
10
|
+
export {
|
|
11
|
+
getPlatformPreferences,
|
|
12
|
+
patchPlatformPreferences,
|
|
13
|
+
} from '@puredesktop/puredesktop-ui-bridge/bridge/preferences'
|
|
14
|
+
export {
|
|
15
|
+
networkFetch,
|
|
16
|
+
type PlatformNetworkFetchRequest,
|
|
17
|
+
type PlatformNetworkFetchResponse,
|
|
18
|
+
} from '@puredesktop/puredesktop-ui-bridge/bridge/network'
|
|
19
|
+
export {
|
|
20
|
+
createPlatformFolder,
|
|
21
|
+
deletePlatformFile,
|
|
22
|
+
listPlatformFiles,
|
|
23
|
+
readPlatformFileBinary,
|
|
24
|
+
readPlatformFileBinaryDataUrl,
|
|
25
|
+
readPlatformFilePreview,
|
|
26
|
+
readPlatformFilePreviewUrl,
|
|
27
|
+
readPlatformTextFile,
|
|
28
|
+
renamePlatformFile,
|
|
29
|
+
writePlatformFileBinary,
|
|
30
|
+
writePlatformTextFile,
|
|
31
|
+
type PlatformFileCreateFolderResult,
|
|
32
|
+
type PlatformFileDeleteResult,
|
|
33
|
+
type PlatformFileEntry,
|
|
34
|
+
type PlatformFileListResult,
|
|
35
|
+
type PlatformFilePreviewUrlResult,
|
|
36
|
+
type PlatformFileReadBinaryResult,
|
|
37
|
+
type PlatformFileReadPreviewResult,
|
|
38
|
+
type PlatformFileRenameResult,
|
|
39
|
+
type PlatformFileWriteResult,
|
|
40
|
+
} from '@puredesktop/puredesktop-ui-bridge/bridge/fs'
|
|
41
|
+
export {
|
|
42
|
+
openPlatformFileDialog,
|
|
43
|
+
openPlatformFolderDialog,
|
|
44
|
+
openPlatformImageDialog,
|
|
45
|
+
savePlatformFolderDialog,
|
|
46
|
+
} from '@puredesktop/puredesktop-ui-bridge/bridge/dialog'
|
|
47
|
+
export {
|
|
48
|
+
readPlatformStorageJson,
|
|
49
|
+
writePlatformStorageJson,
|
|
50
|
+
type PlatformStorageJsonReadResult,
|
|
51
|
+
type PlatformStorageJsonRequest,
|
|
52
|
+
type PlatformStorageJsonWriteRequest,
|
|
53
|
+
type PlatformStorageJsonWriteResult,
|
|
54
|
+
} from '@puredesktop/puredesktop-ui-bridge/bridge/storage'
|
|
55
|
+
export { bridge }
|
|
7
56
|
|
|
8
57
|
const STANDALONE_SETTINGS_KEY = 'puredesktop:{{APP_SLUG}}:settings'
|
|
9
58
|
|
|
@@ -20,12 +69,10 @@ function readStandaloneSettings(): AppSettings {
|
|
|
20
69
|
}
|
|
21
70
|
}
|
|
22
71
|
|
|
23
|
-
export async function fetchAppSettings(): Promise<AppSettings> {
|
|
24
|
-
if (isStandaloneDevMode()) {
|
|
25
|
-
return readStandaloneSettings()
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return
|
|
29
|
-
|
|
30
|
-
])
|
|
31
|
-
}
|
|
72
|
+
export async function fetchAppSettings(): Promise<AppSettings> {
|
|
73
|
+
if (isStandaloneDevMode()) {
|
|
74
|
+
return readStandaloneSettings()
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return getPlatformAppSettings(APP_SLUG) as Promise<AppSettings>
|
|
78
|
+
}
|