@leeoohoo/ui-apps-devkit 0.1.0 → 0.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.
Files changed (61) hide show
  1. package/README.md +76 -70
  2. package/bin/chatos-uiapp.js +4 -4
  3. package/package.json +25 -22
  4. package/src/cli.js +53 -53
  5. package/src/commands/dev.js +14 -14
  6. package/src/commands/init.js +142 -141
  7. package/src/commands/install.js +55 -55
  8. package/src/commands/pack.js +72 -72
  9. package/src/commands/validate.js +113 -103
  10. package/src/lib/args.js +49 -49
  11. package/src/lib/config.js +29 -29
  12. package/src/lib/fs.js +78 -78
  13. package/src/lib/path-boundary.js +16 -16
  14. package/src/lib/plugin.js +45 -45
  15. package/src/lib/template.js +172 -168
  16. package/src/sandbox/server.js +1200 -861
  17. package/templates/basic/README.md +77 -58
  18. package/templates/basic/chatos.config.json +5 -5
  19. package/templates/basic/docs/CHATOS_UI_APPS_AI_CONTRIBUTIONS.md +194 -163
  20. package/templates/basic/docs/CHATOS_UI_APPS_BACKEND_PROTOCOL.md +74 -74
  21. package/templates/basic/docs/CHATOS_UI_APPS_HOST_API.md +136 -123
  22. package/templates/basic/docs/CHATOS_UI_APPS_OVERVIEW.md +113 -110
  23. package/templates/basic/docs/CHATOS_UI_APPS_PLUGIN_MANIFEST.md +226 -212
  24. package/templates/basic/docs/CHATOS_UI_APPS_STYLE_GUIDE.md +95 -0
  25. package/templates/basic/docs/CHATOS_UI_APPS_TROUBLESHOOTING.md +45 -0
  26. package/templates/basic/docs/CHATOS_UI_PROMPTS_PROTOCOL.md +392 -392
  27. package/templates/basic/plugin/apps/app/compact.mjs +41 -0
  28. package/templates/basic/plugin/apps/app/index.mjs +287 -263
  29. package/templates/basic/plugin/apps/app/mcp-prompt.en.md +7 -7
  30. package/templates/basic/plugin/apps/app/mcp-prompt.zh.md +7 -7
  31. package/templates/basic/plugin/apps/app/mcp-server.mjs +15 -15
  32. package/templates/basic/plugin/backend/index.mjs +37 -37
  33. package/templates/basic/template.json +7 -7
  34. package/templates/notepad/README.md +58 -36
  35. package/templates/notepad/chatos.config.json +4 -4
  36. package/templates/notepad/docs/CHATOS_UI_APPS_AI_CONTRIBUTIONS.md +194 -163
  37. package/templates/notepad/docs/CHATOS_UI_APPS_BACKEND_PROTOCOL.md +74 -74
  38. package/templates/notepad/docs/CHATOS_UI_APPS_HOST_API.md +136 -123
  39. package/templates/notepad/docs/CHATOS_UI_APPS_OVERVIEW.md +113 -110
  40. package/templates/notepad/docs/CHATOS_UI_APPS_PLUGIN_MANIFEST.md +226 -212
  41. package/templates/notepad/docs/CHATOS_UI_APPS_STYLE_GUIDE.md +95 -0
  42. package/templates/notepad/docs/CHATOS_UI_APPS_TROUBLESHOOTING.md +45 -0
  43. package/templates/notepad/docs/CHATOS_UI_PROMPTS_PROTOCOL.md +392 -392
  44. package/templates/notepad/plugin/apps/app/api.mjs +30 -30
  45. package/templates/notepad/plugin/apps/app/compact.mjs +41 -0
  46. package/templates/notepad/plugin/apps/app/dom.mjs +14 -14
  47. package/templates/notepad/plugin/apps/app/ds-tree.mjs +35 -35
  48. package/templates/notepad/plugin/apps/app/index.mjs +1056 -1056
  49. package/templates/notepad/plugin/apps/app/layers.mjs +338 -338
  50. package/templates/notepad/plugin/apps/app/markdown.mjs +120 -120
  51. package/templates/notepad/plugin/apps/app/mcp-prompt.en.md +22 -22
  52. package/templates/notepad/plugin/apps/app/mcp-prompt.zh.md +22 -22
  53. package/templates/notepad/plugin/apps/app/mcp-server.mjs +200 -200
  54. package/templates/notepad/plugin/apps/app/styles.mjs +355 -355
  55. package/templates/notepad/plugin/apps/app/tags.mjs +21 -21
  56. package/templates/notepad/plugin/apps/app/ui.mjs +280 -280
  57. package/templates/notepad/plugin/backend/index.mjs +99 -99
  58. package/templates/notepad/plugin/plugin.json +23 -23
  59. package/templates/notepad/plugin/shared/notepad-paths.mjs +62 -62
  60. package/templates/notepad/plugin/shared/notepad-store.mjs +765 -765
  61. package/templates/notepad/template.json +8 -8
@@ -1,99 +1,99 @@
1
- import { createNotepadStore } from '../shared/notepad-store.mjs';
2
- import { resolveUiAppDataDir } from '../shared/notepad-paths.mjs';
3
-
4
- function normalizeString(value) {
5
- return typeof value === 'string' ? value.trim() : '';
6
- }
7
-
8
- function resolveFallbackDataDir(ctx) {
9
- const pluginId = normalizeString(ctx?.pluginId) || '__PLUGIN_ID__';
10
- return resolveUiAppDataDir({ pluginId });
11
- }
12
-
13
- export async function createUiAppsBackend(ctx) {
14
- const dataDir = normalizeString(ctx?.dataDir) || resolveFallbackDataDir(ctx);
15
- const store = createNotepadStore({ dataDir });
16
-
17
- return {
18
- methods: {
19
- async ping(params, ctx2) {
20
- return { ok: true, params: params ?? null, pluginId: ctx2?.pluginId || '' };
21
- },
22
-
23
- async 'notes.init'() {
24
- return await store.init();
25
- },
26
-
27
- async 'notes.listFolders'() {
28
- return await store.listFolders();
29
- },
30
-
31
- async 'notes.createFolder'(params) {
32
- return await store.createFolder({ folder: params?.folder });
33
- },
34
-
35
- async 'notes.renameFolder'(params) {
36
- return await store.renameFolder({ from: params?.from, to: params?.to });
37
- },
38
-
39
- async 'notes.deleteFolder'(params) {
40
- return await store.deleteFolder({ folder: params?.folder, recursive: params?.recursive === true });
41
- },
42
-
43
- async 'notes.listNotes'(params) {
44
- return await store.listNotes({
45
- folder: params?.folder,
46
- recursive: params?.recursive,
47
- tags: params?.tags,
48
- match: params?.match,
49
- query: params?.query,
50
- limit: params?.limit,
51
- });
52
- },
53
-
54
- async 'notes.createNote'(params) {
55
- return await store.createNote({
56
- folder: params?.folder,
57
- title: params?.title,
58
- content: params?.content,
59
- tags: params?.tags,
60
- });
61
- },
62
-
63
- async 'notes.getNote'(params) {
64
- return await store.getNote({ id: params?.id });
65
- },
66
-
67
- async 'notes.updateNote'(params) {
68
- return await store.updateNote({
69
- id: params?.id,
70
- title: params?.title,
71
- content: params?.content,
72
- folder: params?.folder,
73
- tags: params?.tags,
74
- });
75
- },
76
-
77
- async 'notes.deleteNote'(params) {
78
- return await store.deleteNote({ id: params?.id });
79
- },
80
-
81
- async 'notes.listTags'() {
82
- return await store.listTags();
83
- },
84
-
85
- async 'notes.searchNotes'(params) {
86
- return await store.searchNotes({
87
- query: params?.query,
88
- folder: params?.folder,
89
- recursive: params?.recursive,
90
- tags: params?.tags,
91
- match: params?.match,
92
- includeContent: params?.includeContent !== false,
93
- limit: params?.limit,
94
- });
95
- },
96
- },
97
- async dispose() {},
98
- };
99
- }
1
+ import { createNotepadStore } from '../shared/notepad-store.mjs';
2
+ import { resolveUiAppDataDir } from '../shared/notepad-paths.mjs';
3
+
4
+ function normalizeString(value) {
5
+ return typeof value === 'string' ? value.trim() : '';
6
+ }
7
+
8
+ function resolveFallbackDataDir(ctx) {
9
+ const pluginId = normalizeString(ctx?.pluginId) || '__PLUGIN_ID__';
10
+ return resolveUiAppDataDir({ pluginId });
11
+ }
12
+
13
+ export async function createUiAppsBackend(ctx) {
14
+ const dataDir = normalizeString(ctx?.dataDir) || resolveFallbackDataDir(ctx);
15
+ const store = createNotepadStore({ dataDir });
16
+
17
+ return {
18
+ methods: {
19
+ async ping(params, ctx2) {
20
+ return { ok: true, params: params ?? null, pluginId: ctx2?.pluginId || '' };
21
+ },
22
+
23
+ async 'notes.init'() {
24
+ return await store.init();
25
+ },
26
+
27
+ async 'notes.listFolders'() {
28
+ return await store.listFolders();
29
+ },
30
+
31
+ async 'notes.createFolder'(params) {
32
+ return await store.createFolder({ folder: params?.folder });
33
+ },
34
+
35
+ async 'notes.renameFolder'(params) {
36
+ return await store.renameFolder({ from: params?.from, to: params?.to });
37
+ },
38
+
39
+ async 'notes.deleteFolder'(params) {
40
+ return await store.deleteFolder({ folder: params?.folder, recursive: params?.recursive === true });
41
+ },
42
+
43
+ async 'notes.listNotes'(params) {
44
+ return await store.listNotes({
45
+ folder: params?.folder,
46
+ recursive: params?.recursive,
47
+ tags: params?.tags,
48
+ match: params?.match,
49
+ query: params?.query,
50
+ limit: params?.limit,
51
+ });
52
+ },
53
+
54
+ async 'notes.createNote'(params) {
55
+ return await store.createNote({
56
+ folder: params?.folder,
57
+ title: params?.title,
58
+ content: params?.content,
59
+ tags: params?.tags,
60
+ });
61
+ },
62
+
63
+ async 'notes.getNote'(params) {
64
+ return await store.getNote({ id: params?.id });
65
+ },
66
+
67
+ async 'notes.updateNote'(params) {
68
+ return await store.updateNote({
69
+ id: params?.id,
70
+ title: params?.title,
71
+ content: params?.content,
72
+ folder: params?.folder,
73
+ tags: params?.tags,
74
+ });
75
+ },
76
+
77
+ async 'notes.deleteNote'(params) {
78
+ return await store.deleteNote({ id: params?.id });
79
+ },
80
+
81
+ async 'notes.listTags'() {
82
+ return await store.listTags();
83
+ },
84
+
85
+ async 'notes.searchNotes'(params) {
86
+ return await store.searchNotes({
87
+ query: params?.query,
88
+ folder: params?.folder,
89
+ recursive: params?.recursive,
90
+ tags: params?.tags,
91
+ match: params?.match,
92
+ includeContent: params?.includeContent !== false,
93
+ limit: params?.limit,
94
+ });
95
+ },
96
+ },
97
+ async dispose() {},
98
+ };
99
+ }
@@ -1,23 +1,23 @@
1
- {
2
- "manifestVersion": 1,
3
- "id": "__PLUGIN_ID__",
4
- "name": "__PLUGIN_NAME__",
5
- "version": "__VERSION__",
6
- "description": "A ChatOS UI Apps example: Markdown notepad with folders & tags.",
7
- "backend": { "entry": "backend/index.mjs" },
8
- "apps": [
9
- {
10
- "id": "__APP_ID__",
11
- "name": "__PLUGIN_NAME__",
12
- "description": "Markdown 编辑/预览,文件夹分类,标签管理与快速检索。",
13
- "entry": { "type": "module", "path": "apps/__APP_ID__/index.mjs" },
14
- "ai": {
15
- "mcpPrompt": {
16
- "title": "__PLUGIN_NAME__ · MCP Prompt",
17
- "zh": "apps/__APP_ID__/mcp-prompt.zh.md",
18
- "en": "apps/__APP_ID__/mcp-prompt.en.md"
19
- }
20
- }
21
- }
22
- ]
23
- }
1
+ {
2
+ "manifestVersion": 1,
3
+ "id": "__PLUGIN_ID__",
4
+ "name": "__PLUGIN_NAME__",
5
+ "version": "__VERSION__",
6
+ "description": "A ChatOS UI Apps example: Markdown notepad with folders & tags.",
7
+ "backend": { "entry": "backend/index.mjs" },
8
+ "apps": [
9
+ {
10
+ "id": "__APP_ID__",
11
+ "name": "__PLUGIN_NAME__",
12
+ "description": "Markdown 编辑/预览,文件夹分类,标签管理与快速检索。",
13
+ "entry": { "type": "module", "path": "apps/__APP_ID__/index.mjs" },
14
+ "ai": {
15
+ "mcpPrompt": {
16
+ "title": "__PLUGIN_NAME__ · MCP Prompt",
17
+ "zh": "apps/__APP_ID__/mcp-prompt.zh.md",
18
+ "en": "apps/__APP_ID__/mcp-prompt.en.md"
19
+ }
20
+ }
21
+ }
22
+ ]
23
+ }
@@ -1,62 +1,62 @@
1
- import fs from 'fs';
2
- import os from 'os';
3
- import path from 'path';
4
-
5
- function normalizeString(value) {
6
- return typeof value === 'string' ? value.trim() : '';
7
- }
8
-
9
- function resolveHostApp(env) {
10
- const hostApp = normalizeString(env?.MODEL_CLI_HOST_APP);
11
- return hostApp || 'chatos';
12
- }
13
-
14
- function resolveHomeDir(env) {
15
- const homeEnv = normalizeString(env?.HOME) || normalizeString(env?.USERPROFILE);
16
- if (homeEnv) return homeEnv;
17
- try {
18
- return os.homedir();
19
- } catch {
20
- return '';
21
- }
22
- }
23
-
24
- function resolveSessionRoot(env) {
25
- return normalizeString(env?.MODEL_CLI_SESSION_ROOT);
26
- }
27
-
28
- function tryEnsureWritableDir(dirPath) {
29
- const target = normalizeString(dirPath);
30
- if (!target) return false;
31
- try {
32
- fs.mkdirSync(target, { recursive: true });
33
- } catch {
34
- return false;
35
- }
36
- try {
37
- fs.accessSync(target, fs.constants.W_OK);
38
- return true;
39
- } catch {
40
- return false;
41
- }
42
- }
43
-
44
- export function resolveUiAppDataDir({ pluginId, env } = {}) {
45
- const id = normalizeString(pluginId);
46
- if (!id) throw new Error('pluginId is required');
47
- const resolvedEnv = env && typeof env === 'object' ? env : process.env;
48
- const hostApp = resolveHostApp(resolvedEnv);
49
- const home = resolveHomeDir(resolvedEnv);
50
- const sessionRoot = resolveSessionRoot(resolvedEnv);
51
-
52
- const candidates = [];
53
- if (home) candidates.push(path.join(home, '.deepseek_cli', hostApp, 'ui_apps', 'data', id));
54
- if (sessionRoot) candidates.push(path.join(path.resolve(sessionRoot), '.deepseek_cli', hostApp, 'ui_apps', 'data', id));
55
- candidates.push(path.join(path.resolve(process.cwd()), '.deepseek_cli', hostApp, 'ui_apps', 'data', id));
56
-
57
- for (const candidate of candidates) {
58
- if (tryEnsureWritableDir(candidate)) return candidate;
59
- }
60
- return candidates[0];
61
- }
62
-
1
+ import fs from 'fs';
2
+ import os from 'os';
3
+ import path from 'path';
4
+
5
+ function normalizeString(value) {
6
+ return typeof value === 'string' ? value.trim() : '';
7
+ }
8
+
9
+ function resolveHostApp(env) {
10
+ const hostApp = normalizeString(env?.MODEL_CLI_HOST_APP);
11
+ return hostApp || 'chatos';
12
+ }
13
+
14
+ function resolveHomeDir(env) {
15
+ const homeEnv = normalizeString(env?.HOME) || normalizeString(env?.USERPROFILE);
16
+ if (homeEnv) return homeEnv;
17
+ try {
18
+ return os.homedir();
19
+ } catch {
20
+ return '';
21
+ }
22
+ }
23
+
24
+ function resolveSessionRoot(env) {
25
+ return normalizeString(env?.MODEL_CLI_SESSION_ROOT);
26
+ }
27
+
28
+ function tryEnsureWritableDir(dirPath) {
29
+ const target = normalizeString(dirPath);
30
+ if (!target) return false;
31
+ try {
32
+ fs.mkdirSync(target, { recursive: true });
33
+ } catch {
34
+ return false;
35
+ }
36
+ try {
37
+ fs.accessSync(target, fs.constants.W_OK);
38
+ return true;
39
+ } catch {
40
+ return false;
41
+ }
42
+ }
43
+
44
+ export function resolveUiAppDataDir({ pluginId, env } = {}) {
45
+ const id = normalizeString(pluginId);
46
+ if (!id) throw new Error('pluginId is required');
47
+ const resolvedEnv = env && typeof env === 'object' ? env : process.env;
48
+ const hostApp = resolveHostApp(resolvedEnv);
49
+ const home = resolveHomeDir(resolvedEnv);
50
+ const sessionRoot = resolveSessionRoot(resolvedEnv);
51
+
52
+ const candidates = [];
53
+ if (home) candidates.push(path.join(home, '.deepseek_cli', hostApp, 'ui_apps', 'data', id));
54
+ if (sessionRoot) candidates.push(path.join(path.resolve(sessionRoot), '.deepseek_cli', hostApp, 'ui_apps', 'data', id));
55
+ candidates.push(path.join(path.resolve(process.cwd()), '.deepseek_cli', hostApp, 'ui_apps', 'data', id));
56
+
57
+ for (const candidate of candidates) {
58
+ if (tryEnsureWritableDir(candidate)) return candidate;
59
+ }
60
+ return candidates[0];
61
+ }
62
+