@leeoohoo/ui-apps-devkit 0.1.2 → 0.1.3

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 +61 -62
  2. package/bin/chatos-uiapp.js +3 -4
  3. package/package.json +23 -23
  4. package/src/cli.js +53 -53
  5. package/src/commands/dev.js +14 -14
  6. package/src/commands/init.js +129 -129
  7. package/src/commands/install.js +45 -45
  8. package/src/commands/pack.js +72 -72
  9. package/src/commands/validate.js +90 -138
  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 -172
  16. package/src/sandbox/server.js +1204 -1028
  17. package/templates/basic/README.md +63 -65
  18. package/templates/basic/chatos.config.json +5 -5
  19. package/templates/basic/docs/CHATOS_UI_APPS_AI_CONTRIBUTIONS.md +209 -211
  20. package/templates/basic/docs/CHATOS_UI_APPS_BACKEND_PROTOCOL.md +73 -73
  21. package/templates/basic/docs/CHATOS_UI_APPS_HOST_API.md +136 -136
  22. package/templates/basic/docs/CHATOS_UI_APPS_OVERVIEW.md +106 -106
  23. package/templates/basic/docs/CHATOS_UI_APPS_PLUGIN_MANIFEST.md +239 -239
  24. package/templates/basic/docs/CHATOS_UI_APPS_STYLE_GUIDE.md +95 -95
  25. package/templates/basic/docs/CHATOS_UI_APPS_TROUBLESHOOTING.md +40 -40
  26. package/templates/basic/docs/CHATOS_UI_PROMPTS_PROTOCOL.md +392 -392
  27. package/templates/basic/plugin/apps/app/compact.mjs +41 -41
  28. package/templates/basic/plugin/apps/app/index.mjs +287 -287
  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 +38 -44
  35. package/templates/notepad/chatos.config.json +4 -4
  36. package/templates/notepad/docs/CHATOS_UI_APPS_AI_CONTRIBUTIONS.md +209 -211
  37. package/templates/notepad/docs/CHATOS_UI_APPS_BACKEND_PROTOCOL.md +73 -73
  38. package/templates/notepad/docs/CHATOS_UI_APPS_HOST_API.md +136 -136
  39. package/templates/notepad/docs/CHATOS_UI_APPS_OVERVIEW.md +106 -106
  40. package/templates/notepad/docs/CHATOS_UI_APPS_PLUGIN_MANIFEST.md +239 -239
  41. package/templates/notepad/docs/CHATOS_UI_APPS_STYLE_GUIDE.md +95 -95
  42. package/templates/notepad/docs/CHATOS_UI_APPS_TROUBLESHOOTING.md +40 -40
  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 -41
  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 +199 -199
  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 +39 -39
  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
+ }
@@ -8,39 +8,39 @@ const COMPAT_STATE_ROOT_DIRNAME = '.chatos';
8
8
  function normalizeString(value) {
9
9
  return typeof value === 'string' ? value.trim() : '';
10
10
  }
11
-
12
- function resolveHostApp(env) {
13
- const hostApp = normalizeString(env?.MODEL_CLI_HOST_APP);
14
- return hostApp || 'chatos';
15
- }
16
-
17
- function resolveHomeDir(env) {
18
- const homeEnv = normalizeString(env?.HOME) || normalizeString(env?.USERPROFILE);
19
- if (homeEnv) return homeEnv;
20
- try {
21
- return os.homedir();
22
- } catch {
23
- return '';
24
- }
25
- }
26
-
27
- function resolveSessionRoot(env) {
28
- return normalizeString(env?.MODEL_CLI_SESSION_ROOT);
29
- }
30
-
11
+
12
+ function resolveHostApp(env) {
13
+ const hostApp = normalizeString(env?.MODEL_CLI_HOST_APP);
14
+ return hostApp || 'chatos';
15
+ }
16
+
17
+ function resolveHomeDir(env) {
18
+ const homeEnv = normalizeString(env?.HOME) || normalizeString(env?.USERPROFILE);
19
+ if (homeEnv) return homeEnv;
20
+ try {
21
+ return os.homedir();
22
+ } catch {
23
+ return '';
24
+ }
25
+ }
26
+
27
+ function resolveSessionRoot(env) {
28
+ return normalizeString(env?.MODEL_CLI_SESSION_ROOT);
29
+ }
30
+
31
31
  function tryEnsureWritableDir(dirPath) {
32
32
  const target = normalizeString(dirPath);
33
33
  if (!target) return false;
34
- try {
35
- fs.mkdirSync(target, { recursive: true });
36
- } catch {
37
- return false;
38
- }
39
- try {
40
- fs.accessSync(target, fs.constants.W_OK);
41
- return true;
42
- } catch {
43
- return false;
34
+ try {
35
+ fs.mkdirSync(target, { recursive: true });
36
+ } catch {
37
+ return false;
38
+ }
39
+ try {
40
+ fs.accessSync(target, fs.constants.W_OK);
41
+ return true;
42
+ } catch {
43
+ return false;
44
44
  }
45
45
  }
46
46
 
@@ -54,8 +54,8 @@ export function resolveUiAppDataDir({ pluginId, env } = {}) {
54
54
  const id = normalizeString(pluginId);
55
55
  if (!id) throw new Error('pluginId is required');
56
56
  const resolvedEnv = env && typeof env === 'object' ? env : process.env;
57
- const hostApp = resolveHostApp(resolvedEnv);
58
- const home = resolveHomeDir(resolvedEnv);
57
+ const hostApp = resolveHostApp(resolvedEnv);
58
+ const home = resolveHomeDir(resolvedEnv);
59
59
  const sessionRoot = resolveSessionRoot(resolvedEnv);
60
60
 
61
61
  const candidates = [];
@@ -71,10 +71,10 @@ export function resolveUiAppDataDir({ pluginId, env } = {}) {
71
71
  const cwd = path.resolve(process.cwd());
72
72
  pushDataDir(candidates, cwd, STATE_ROOT_DIRNAME, hostApp, id);
73
73
  pushDataDir(candidates, cwd, COMPAT_STATE_ROOT_DIRNAME, hostApp, id);
74
-
75
- for (const candidate of candidates) {
76
- if (tryEnsureWritableDir(candidate)) return candidate;
77
- }
78
- return candidates[0];
79
- }
80
-
74
+
75
+ for (const candidate of candidates) {
76
+ if (tryEnsureWritableDir(candidate)) return candidate;
77
+ }
78
+ return candidates[0];
79
+ }
80
+