@shiqianjiang/ceru-plugin-cli 0.1.2 → 0.2.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.
Files changed (70) hide show
  1. package/README.md +6 -6
  2. package/assets/core-contracts.js +1 -0
  3. package/assets/index.html +94 -93
  4. package/assets/playground.js +293 -30
  5. package/assets/sandbox.js +50 -19
  6. package/assets/style.css +16 -0
  7. package/dist/dependencies.d.ts +6 -0
  8. package/dist/dependencies.js +45 -0
  9. package/dist/dev.js +214 -119
  10. package/dist/index.js +5 -3
  11. package/dist/project.js +41 -16
  12. package/dist/socket-broker.d.ts +23 -0
  13. package/dist/socket-broker.js +230 -0
  14. package/package.json +71 -67
  15. package/schemas/config.schema.json +347 -0
  16. package/templates/connected-library/js/.vscode/ceru.code-snippets +37 -9
  17. package/templates/connected-library/js/package.json +2 -2
  18. package/templates/connected-library/js/src/index.js +7 -5
  19. package/templates/connected-library/ts/.vscode/ceru.code-snippets +37 -9
  20. package/templates/connected-library/ts/package.json +2 -2
  21. package/templates/connected-library/ts/src/index.ts +7 -5
  22. package/templates/guest-adapter/js/.vscode/ceru.code-snippets +37 -9
  23. package/templates/guest-adapter/js/package.json +2 -2
  24. package/templates/guest-adapter/ts/.vscode/ceru.code-snippets +37 -9
  25. package/templates/guest-adapter/ts/package.json +2 -2
  26. package/templates/importer/js/.vscode/ceru.code-snippets +37 -9
  27. package/templates/importer/js/README.md +1 -1
  28. package/templates/importer/js/ceru.plugin.json +8 -24
  29. package/templates/importer/js/package.json +2 -2
  30. package/templates/importer/js/src/index.js +28 -34
  31. package/templates/importer/ts/.vscode/ceru.code-snippets +37 -9
  32. package/templates/importer/ts/README.md +1 -1
  33. package/templates/importer/ts/ceru.plugin.json +8 -24
  34. package/templates/importer/ts/package.json +2 -2
  35. package/templates/importer/ts/src/index.ts +28 -34
  36. package/templates/react/js/.vscode/ceru.code-snippets +37 -9
  37. package/templates/react/js/package.json +2 -2
  38. package/templates/react/ts/.vscode/ceru.code-snippets +37 -9
  39. package/templates/react/ts/package.json +2 -2
  40. package/templates/snapshot.json +4 -2
  41. package/templates/source/js/.vscode/ceru.code-snippets +37 -9
  42. package/templates/source/js/ceru.plugin.json +9 -0
  43. package/templates/source/js/package.json +2 -2
  44. package/templates/source/js/src/index.js +29 -26
  45. package/templates/source/ts/.vscode/ceru.code-snippets +37 -9
  46. package/templates/source/ts/ceru.plugin.json +9 -0
  47. package/templates/source/ts/package.json +2 -2
  48. package/templates/source/ts/src/index.ts +29 -26
  49. package/templates/vue/js/.vscode/ceru.code-snippets +37 -9
  50. package/templates/vue/js/package.json +2 -2
  51. package/templates/vue/ts/.vscode/ceru.code-snippets +37 -9
  52. package/templates/vue/ts/package.json +2 -2
  53. package/templates/vue-tsx/js/.vscode/ceru.code-snippets +37 -9
  54. package/templates/vue-tsx/js/package.json +2 -2
  55. package/templates/vue-tsx/ts/.vscode/ceru.code-snippets +37 -9
  56. package/templates/vue-tsx/ts/package.json +2 -2
  57. package/templates/web-dist/js/.vscode/ceru.code-snippets +37 -9
  58. package/templates/web-dist/js/package.json +2 -2
  59. package/templates/web-dist/ts/.vscode/ceru.code-snippets +37 -9
  60. package/templates/web-dist/ts/package.json +2 -2
  61. package/templates/web-surface/js/.vscode/ceru.code-snippets +37 -9
  62. package/templates/web-surface/js/ceru.plugin.json +9 -0
  63. package/templates/web-surface/js/package.json +2 -2
  64. package/templates/web-surface/js/src/view.js +4 -1
  65. package/templates/web-surface/js/ui/search-note.css +3 -0
  66. package/templates/web-surface/ts/.vscode/ceru.code-snippets +37 -9
  67. package/templates/web-surface/ts/ceru.plugin.json +9 -0
  68. package/templates/web-surface/ts/package.json +2 -2
  69. package/templates/web-surface/ts/src/view.ts +4 -1
  70. package/templates/web-surface/ts/ui/search-note.css +3 -0
@@ -1,17 +1,45 @@
1
1
  {
2
2
  "Host platform icon": {
3
3
  "prefix": "ceru-icon",
4
- "body": [
5
- "{ kind: 'host', name: 'platform.${1:tx}' }"
6
- ],
7
- "description": "使用宿主平台图标,无需打入插件"
4
+ "body": ["{ kind: 'host', name: 'platform.${1:tx}' }"],
5
+ "description": "使用宿主平台图标,无需打入插件",
8
6
  },
9
7
  "Host lodash": {
10
8
  "prefix": "ceru-lodash",
9
+ "body": ["ctx.utils.lodash.${1:uniqBy}(${2:items}, ${3:key})"],
10
+ "description": "调用宿主的带类型 Lodash 工具",
11
+ },
12
+ "Host HTTP client": {
13
+ "prefix": "ceru-http",
14
+ "body": [
15
+ "const http = ctx.http.create({",
16
+ " baseURL: '${1:https://example.com}',",
17
+ " permissionKey: '${2:api}',",
18
+ " requestPermission: true,",
19
+ "})",
20
+ ],
21
+ "description": "使用宿主 Axios 代理;无需将请求库打入插件",
22
+ },
23
+ "Permission group": {
24
+ "prefix": "ceru-permission-group",
11
25
  "body": [
12
- "ctx.utils.lodash.${1:uniqBy}(${2:items}, ${3:key})"
26
+ "const permission = await ctx.permissions.requestGroup({",
27
+ " group: '${1:libraryRead}',",
28
+ " intent: operation.userIntent,",
29
+ "})",
13
30
  ],
14
- "description": "调用宿主的带类型 Lodash 工具"
31
+ "description": "一次申请一组用户可理解的能力",
32
+ },
33
+ "Grouped music provider": {
34
+ "prefix": "ceru-provider",
35
+ "body": [
36
+ "ctx.providers.register('${1:catalog}', {",
37
+ " tracks: { search: ${2:searchTracks}, resolve: ${3:resolveTrack}, lyrics: ${4:getLyrics} },",
38
+ " playlists: { search: ${5:searchPlaylists}, categories: ${6:getCategories}, list: ${7:listPlaylists}, get: ${8:getPlaylist} },",
39
+ " charts: { list: ${9:listCharts}, getTracks: ${10:getChartTracks} },",
40
+ "})",
41
+ ],
42
+ "description": "注册分组 Provider,返回标准歌曲/歌单/歌词 JSON",
15
43
  },
16
44
  "Source rate limit": {
17
45
  "prefix": "ceru-rate-limit",
@@ -20,8 +48,8 @@
20
48
  " code: 'RATE_LIMITED',",
21
49
  " message: '${1:请稍后重试}',",
22
50
  " recovery: { mode: 'await-user', maxWaitMs: 60000 }",
23
- "})"
51
+ "})",
24
52
  ],
25
- "description": "返回结构化限流结果,由 Host 决定换源与交互"
26
- }
53
+ "description": "返回结构化限流结果,由 Host 决定换源与交互",
54
+ },
27
55
  }
@@ -11,10 +11,10 @@
11
11
  "preview": "ceru-plugin preview dist/plugin.js"
12
12
  },
13
13
  "dependencies": {
14
- "@shiqianjiang/ceru-plugin-sdk": "^0.1.0"
14
+ "@shiqianjiang/ceru-plugin-sdk": "^0.2.0"
15
15
  },
16
16
  "devDependencies": {
17
- "@shiqianjiang/ceru-plugin-cli": "^0.1.2",
17
+ "@shiqianjiang/ceru-plugin-cli": "^0.2.0",
18
18
  "typescript": "~5.9.3",
19
19
  "electron": "^44.4.2",
20
20
  "prettier": "^3.6.2"
@@ -1,17 +1,45 @@
1
1
  {
2
2
  "Host platform icon": {
3
3
  "prefix": "ceru-icon",
4
- "body": [
5
- "{ kind: 'host', name: 'platform.${1:tx}' }"
6
- ],
7
- "description": "使用宿主平台图标,无需打入插件"
4
+ "body": ["{ kind: 'host', name: 'platform.${1:tx}' }"],
5
+ "description": "使用宿主平台图标,无需打入插件",
8
6
  },
9
7
  "Host lodash": {
10
8
  "prefix": "ceru-lodash",
9
+ "body": ["ctx.utils.lodash.${1:uniqBy}(${2:items}, ${3:key})"],
10
+ "description": "调用宿主的带类型 Lodash 工具",
11
+ },
12
+ "Host HTTP client": {
13
+ "prefix": "ceru-http",
14
+ "body": [
15
+ "const http = ctx.http.create({",
16
+ " baseURL: '${1:https://example.com}',",
17
+ " permissionKey: '${2:api}',",
18
+ " requestPermission: true,",
19
+ "})",
20
+ ],
21
+ "description": "使用宿主 Axios 代理;无需将请求库打入插件",
22
+ },
23
+ "Permission group": {
24
+ "prefix": "ceru-permission-group",
11
25
  "body": [
12
- "ctx.utils.lodash.${1:uniqBy}(${2:items}, ${3:key})"
26
+ "const permission = await ctx.permissions.requestGroup({",
27
+ " group: '${1:libraryRead}',",
28
+ " intent: operation.userIntent,",
29
+ "})",
13
30
  ],
14
- "description": "调用宿主的带类型 Lodash 工具"
31
+ "description": "一次申请一组用户可理解的能力",
32
+ },
33
+ "Grouped music provider": {
34
+ "prefix": "ceru-provider",
35
+ "body": [
36
+ "ctx.providers.register('${1:catalog}', {",
37
+ " tracks: { search: ${2:searchTracks}, resolve: ${3:resolveTrack}, lyrics: ${4:getLyrics} },",
38
+ " playlists: { search: ${5:searchPlaylists}, categories: ${6:getCategories}, list: ${7:listPlaylists}, get: ${8:getPlaylist} },",
39
+ " charts: { list: ${9:listCharts}, getTracks: ${10:getChartTracks} },",
40
+ "})",
41
+ ],
42
+ "description": "注册分组 Provider,返回标准歌曲/歌单/歌词 JSON",
15
43
  },
16
44
  "Source rate limit": {
17
45
  "prefix": "ceru-rate-limit",
@@ -20,8 +48,8 @@
20
48
  " code: 'RATE_LIMITED',",
21
49
  " message: '${1:请稍后重试}',",
22
50
  " recovery: { mode: 'await-user', maxWaitMs: 60000 }",
23
- "})"
51
+ "})",
24
52
  ],
25
- "description": "返回结构化限流结果,由 Host 决定换源与交互"
26
- }
53
+ "description": "返回结构化限流结果,由 Host 决定换源与交互",
54
+ },
27
55
  }
@@ -40,4 +40,4 @@ F5 执行当前下拉框中的配置,不会自动选择终端所在的子工
40
40
  凭据保险箱、完整音乐业务和 Guest 安装需要正式 Host;不支持的调试调用会明确报错。
41
41
  不要把私人 API Key、卡密或发行私钥提交到仓库。
42
42
 
43
- 此 demo 对逗号分隔的曲名去重并生成导入计划,不直接写入用户歌单。
43
+ 此 demo 注册一个歌单导入来源。插件只返回标准歌曲分页;正式 Host 复用软件现有导入窗口、目标歌单选择、本地/云保存和刷新流程。
@@ -14,33 +14,22 @@
14
14
  "logic": {
15
15
  "entry": "logic.main",
16
16
  "activation": ["onCommand:hello"]
17
- },
18
- "surfaces": [
19
- {
20
- "id": "settings",
21
- "kind": "schema",
22
- "entry": "schema.settings"
23
- }
24
- ]
17
+ }
25
18
  },
26
19
  "contributes": {
27
20
  "commands": [
28
21
  {
29
22
  "id": "hello",
30
- "title": "Hello",
23
+ "title": "打开歌单导入",
31
24
  "action": "hello"
32
- },
33
- {
34
- "id": "prepare-import",
35
- "title": "预览导入",
36
- "action": "import.prepare"
37
25
  }
38
26
  ],
39
- "settingsPages": [
27
+ "playlistImporters": [
40
28
  {
41
- "id": "settings",
42
- "title": "导入预览",
43
- "view": "settings"
29
+ "id": "text-list",
30
+ "title": "从文本清单导入(演示)",
31
+ "description": "复用宿主歌单导入窗口;每行一个标题",
32
+ "placeholder": "输入标题,以逗号分隔"
44
33
  }
45
34
  ]
46
35
  },
@@ -53,11 +42,6 @@
53
42
  "entries": {
54
43
  "logic.main": "src/index.js"
55
44
  },
56
- "resources": {
57
- "schema.settings": {
58
- "path": "ui/settings.json",
59
- "type": "json"
60
- }
61
- },
45
+ "resources": {},
62
46
  "output": "dist/plugin.js"
63
47
  }
@@ -11,10 +11,10 @@
11
11
  "preview": "ceru-plugin preview dist/plugin.js"
12
12
  },
13
13
  "dependencies": {
14
- "@shiqianjiang/ceru-plugin-sdk": "^0.1.0"
14
+ "@shiqianjiang/ceru-plugin-sdk": "^0.2.0"
15
15
  },
16
16
  "devDependencies": {
17
- "@shiqianjiang/ceru-plugin-cli": "^0.1.2",
17
+ "@shiqianjiang/ceru-plugin-cli": "^0.2.0",
18
18
  "typescript": "~5.9.3",
19
19
  "electron": "^44.4.2",
20
20
  "prettier": "^3.6.2"
@@ -1,37 +1,31 @@
1
1
  import { definePlugin } from '@shiqianjiang/ceru-plugin-sdk'
2
2
 
3
- export default definePlugin(async (ctx) => {
4
- await ctx.ui.setState('settings', {
5
- titles: 'Morning Light, Night Walk, Morning Light',
6
- preview: '尚未生成预览',
7
- })
8
- ctx.actions.register('hello', () => ctx.ui.openView('settings'))
9
-
10
- ctx.actions.register('import.prepare', async (input) => {
11
- const text =
12
- input &&
13
- typeof input === 'object' &&
14
- !Array.isArray(input) &&
15
- typeof input.titles === 'string'
16
- ? input.titles
17
- : ''
18
- const titles = ctx.utils.lodash.uniq(
19
- text
20
- .split(/[,,\n]+/)
21
- .map((title) => title.trim())
22
- .filter(Boolean),
23
- )
24
- const plan = {
25
- status: 'preview',
26
- operation: 'append',
27
- items: titles.map((title) => ({ title })),
28
- }
29
-
30
- // 这里只生成计划。真正写入歌单前,还需要 Host 批准目标和写入范围。
31
- await ctx.ui.setState('settings', {
32
- titles: text,
33
- preview: '去重后共 ' + titles.length + ' 首:' + titles.join(' / '),
34
- })
35
- return plan
36
- })
3
+ export default definePlugin((ctx) => {
4
+ ctx.effects.add(
5
+ ctx.playlistImporters.register('text-list', {
6
+ async getTracks(request) {
7
+ // Demo metadata only. A real importer resolves platform links and returns track IDs.
8
+ const titles = ctx.utils.lodash.uniq(
9
+ request.value
10
+ .split(/[,,\n]+/)
11
+ .map((title) => title.trim())
12
+ .filter(Boolean),
13
+ )
14
+ return {
15
+ name: '文本清单',
16
+ items: titles.map((title) => ({
17
+ ref: { pluginId: ctx.plugin.id, providerId: 'text-list', kind: 'track', id: title },
18
+ title,
19
+ playable: false,
20
+ metadata: { artists: [] },
21
+ capabilities: [],
22
+ })),
23
+ totalEstimate: titles.length,
24
+ }
25
+ },
26
+ }),
27
+ )
28
+ ctx.effects.add(
29
+ ctx.actions.register('hello', () => ctx.ui.playlistImport.open({ importerId: 'text-list' })),
30
+ )
37
31
  })
@@ -1,17 +1,45 @@
1
1
  {
2
2
  "Host platform icon": {
3
3
  "prefix": "ceru-icon",
4
- "body": [
5
- "{ kind: 'host', name: 'platform.${1:tx}' }"
6
- ],
7
- "description": "使用宿主平台图标,无需打入插件"
4
+ "body": ["{ kind: 'host', name: 'platform.${1:tx}' }"],
5
+ "description": "使用宿主平台图标,无需打入插件",
8
6
  },
9
7
  "Host lodash": {
10
8
  "prefix": "ceru-lodash",
9
+ "body": ["ctx.utils.lodash.${1:uniqBy}(${2:items}, ${3:key})"],
10
+ "description": "调用宿主的带类型 Lodash 工具",
11
+ },
12
+ "Host HTTP client": {
13
+ "prefix": "ceru-http",
14
+ "body": [
15
+ "const http = ctx.http.create({",
16
+ " baseURL: '${1:https://example.com}',",
17
+ " permissionKey: '${2:api}',",
18
+ " requestPermission: true,",
19
+ "})",
20
+ ],
21
+ "description": "使用宿主 Axios 代理;无需将请求库打入插件",
22
+ },
23
+ "Permission group": {
24
+ "prefix": "ceru-permission-group",
11
25
  "body": [
12
- "ctx.utils.lodash.${1:uniqBy}(${2:items}, ${3:key})"
26
+ "const permission = await ctx.permissions.requestGroup({",
27
+ " group: '${1:libraryRead}',",
28
+ " intent: operation.userIntent,",
29
+ "})",
13
30
  ],
14
- "description": "调用宿主的带类型 Lodash 工具"
31
+ "description": "一次申请一组用户可理解的能力",
32
+ },
33
+ "Grouped music provider": {
34
+ "prefix": "ceru-provider",
35
+ "body": [
36
+ "ctx.providers.register('${1:catalog}', {",
37
+ " tracks: { search: ${2:searchTracks}, resolve: ${3:resolveTrack}, lyrics: ${4:getLyrics} },",
38
+ " playlists: { search: ${5:searchPlaylists}, categories: ${6:getCategories}, list: ${7:listPlaylists}, get: ${8:getPlaylist} },",
39
+ " charts: { list: ${9:listCharts}, getTracks: ${10:getChartTracks} },",
40
+ "})",
41
+ ],
42
+ "description": "注册分组 Provider,返回标准歌曲/歌单/歌词 JSON",
15
43
  },
16
44
  "Source rate limit": {
17
45
  "prefix": "ceru-rate-limit",
@@ -20,8 +48,8 @@
20
48
  " code: 'RATE_LIMITED',",
21
49
  " message: '${1:请稍后重试}',",
22
50
  " recovery: { mode: 'await-user', maxWaitMs: 60000 }",
23
- "})"
51
+ "})",
24
52
  ],
25
- "description": "返回结构化限流结果,由 Host 决定换源与交互"
26
- }
53
+ "description": "返回结构化限流结果,由 Host 决定换源与交互",
54
+ },
27
55
  }
@@ -40,4 +40,4 @@ F5 执行当前下拉框中的配置,不会自动选择终端所在的子工
40
40
  凭据保险箱、完整音乐业务和 Guest 安装需要正式 Host;不支持的调试调用会明确报错。
41
41
  不要把私人 API Key、卡密或发行私钥提交到仓库。
42
42
 
43
- 此 demo 对逗号分隔的曲名去重并生成导入计划,不直接写入用户歌单。
43
+ 此 demo 注册一个歌单导入来源。插件只返回标准歌曲分页;正式 Host 复用软件现有导入窗口、目标歌单选择、本地/云保存和刷新流程。
@@ -14,33 +14,22 @@
14
14
  "logic": {
15
15
  "entry": "logic.main",
16
16
  "activation": ["onCommand:hello"]
17
- },
18
- "surfaces": [
19
- {
20
- "id": "settings",
21
- "kind": "schema",
22
- "entry": "schema.settings"
23
- }
24
- ]
17
+ }
25
18
  },
26
19
  "contributes": {
27
20
  "commands": [
28
21
  {
29
22
  "id": "hello",
30
- "title": "Hello",
23
+ "title": "打开歌单导入",
31
24
  "action": "hello"
32
- },
33
- {
34
- "id": "prepare-import",
35
- "title": "预览导入",
36
- "action": "import.prepare"
37
25
  }
38
26
  ],
39
- "settingsPages": [
27
+ "playlistImporters": [
40
28
  {
41
- "id": "settings",
42
- "title": "导入预览",
43
- "view": "settings"
29
+ "id": "text-list",
30
+ "title": "从文本清单导入(演示)",
31
+ "description": "复用宿主歌单导入窗口;每行一个标题",
32
+ "placeholder": "输入标题,以逗号分隔"
44
33
  }
45
34
  ]
46
35
  },
@@ -53,11 +42,6 @@
53
42
  "entries": {
54
43
  "logic.main": "src/index.ts"
55
44
  },
56
- "resources": {
57
- "schema.settings": {
58
- "path": "ui/settings.json",
59
- "type": "json"
60
- }
61
- },
45
+ "resources": {},
62
46
  "output": "dist/plugin.js"
63
47
  }
@@ -11,10 +11,10 @@
11
11
  "preview": "ceru-plugin preview dist/plugin.js"
12
12
  },
13
13
  "dependencies": {
14
- "@shiqianjiang/ceru-plugin-sdk": "^0.1.0"
14
+ "@shiqianjiang/ceru-plugin-sdk": "^0.2.0"
15
15
  },
16
16
  "devDependencies": {
17
- "@shiqianjiang/ceru-plugin-cli": "^0.1.2",
17
+ "@shiqianjiang/ceru-plugin-cli": "^0.2.0",
18
18
  "typescript": "~5.9.3",
19
19
  "electron": "^44.4.2",
20
20
  "prettier": "^3.6.2"
@@ -1,37 +1,31 @@
1
1
  import { definePlugin } from '@shiqianjiang/ceru-plugin-sdk'
2
2
 
3
- export default definePlugin(async (ctx) => {
4
- await ctx.ui.setState('settings', {
5
- titles: 'Morning Light, Night Walk, Morning Light',
6
- preview: '尚未生成预览',
7
- })
8
- ctx.actions.register('hello', () => ctx.ui.openView('settings'))
9
-
10
- ctx.actions.register('import.prepare', async (input) => {
11
- const text =
12
- input &&
13
- typeof input === 'object' &&
14
- !Array.isArray(input) &&
15
- typeof input.titles === 'string'
16
- ? input.titles
17
- : ''
18
- const titles = ctx.utils.lodash.uniq(
19
- text
20
- .split(/[,,\n]+/)
21
- .map((title) => title.trim())
22
- .filter(Boolean),
23
- )
24
- const plan = {
25
- status: 'preview',
26
- operation: 'append',
27
- items: titles.map((title) => ({ title })),
28
- }
29
-
30
- // 这里只生成计划。真正写入歌单前,还需要 Host 批准目标和写入范围。
31
- await ctx.ui.setState('settings', {
32
- titles: text,
33
- preview: '去重后共 ' + titles.length + ' 首:' + titles.join(' / '),
34
- })
35
- return plan
36
- })
3
+ export default definePlugin((ctx) => {
4
+ ctx.effects.add(
5
+ ctx.playlistImporters.register('text-list', {
6
+ async getTracks(request) {
7
+ // Demo metadata only. A real importer resolves platform links and returns track IDs.
8
+ const titles = ctx.utils.lodash.uniq(
9
+ request.value
10
+ .split(/[,,\n]+/)
11
+ .map((title) => title.trim())
12
+ .filter(Boolean),
13
+ )
14
+ return {
15
+ name: '文本清单',
16
+ items: titles.map((title) => ({
17
+ ref: { pluginId: ctx.plugin.id, providerId: 'text-list', kind: 'track', id: title },
18
+ title,
19
+ playable: false,
20
+ metadata: { artists: [] },
21
+ capabilities: [],
22
+ })),
23
+ totalEstimate: titles.length,
24
+ }
25
+ },
26
+ }),
27
+ )
28
+ ctx.effects.add(
29
+ ctx.actions.register('hello', () => ctx.ui.playlistImport.open({ importerId: 'text-list' })),
30
+ )
37
31
  })
@@ -1,17 +1,45 @@
1
1
  {
2
2
  "Host platform icon": {
3
3
  "prefix": "ceru-icon",
4
- "body": [
5
- "{ kind: 'host', name: 'platform.${1:tx}' }"
6
- ],
7
- "description": "使用宿主平台图标,无需打入插件"
4
+ "body": ["{ kind: 'host', name: 'platform.${1:tx}' }"],
5
+ "description": "使用宿主平台图标,无需打入插件",
8
6
  },
9
7
  "Host lodash": {
10
8
  "prefix": "ceru-lodash",
9
+ "body": ["ctx.utils.lodash.${1:uniqBy}(${2:items}, ${3:key})"],
10
+ "description": "调用宿主的带类型 Lodash 工具",
11
+ },
12
+ "Host HTTP client": {
13
+ "prefix": "ceru-http",
14
+ "body": [
15
+ "const http = ctx.http.create({",
16
+ " baseURL: '${1:https://example.com}',",
17
+ " permissionKey: '${2:api}',",
18
+ " requestPermission: true,",
19
+ "})",
20
+ ],
21
+ "description": "使用宿主 Axios 代理;无需将请求库打入插件",
22
+ },
23
+ "Permission group": {
24
+ "prefix": "ceru-permission-group",
11
25
  "body": [
12
- "ctx.utils.lodash.${1:uniqBy}(${2:items}, ${3:key})"
26
+ "const permission = await ctx.permissions.requestGroup({",
27
+ " group: '${1:libraryRead}',",
28
+ " intent: operation.userIntent,",
29
+ "})",
13
30
  ],
14
- "description": "调用宿主的带类型 Lodash 工具"
31
+ "description": "一次申请一组用户可理解的能力",
32
+ },
33
+ "Grouped music provider": {
34
+ "prefix": "ceru-provider",
35
+ "body": [
36
+ "ctx.providers.register('${1:catalog}', {",
37
+ " tracks: { search: ${2:searchTracks}, resolve: ${3:resolveTrack}, lyrics: ${4:getLyrics} },",
38
+ " playlists: { search: ${5:searchPlaylists}, categories: ${6:getCategories}, list: ${7:listPlaylists}, get: ${8:getPlaylist} },",
39
+ " charts: { list: ${9:listCharts}, getTracks: ${10:getChartTracks} },",
40
+ "})",
41
+ ],
42
+ "description": "注册分组 Provider,返回标准歌曲/歌单/歌词 JSON",
15
43
  },
16
44
  "Source rate limit": {
17
45
  "prefix": "ceru-rate-limit",
@@ -20,8 +48,8 @@
20
48
  " code: 'RATE_LIMITED',",
21
49
  " message: '${1:请稍后重试}',",
22
50
  " recovery: { mode: 'await-user', maxWaitMs: 60000 }",
23
- "})"
51
+ "})",
24
52
  ],
25
- "description": "返回结构化限流结果,由 Host 决定换源与交互"
26
- }
53
+ "description": "返回结构化限流结果,由 Host 决定换源与交互",
54
+ },
27
55
  }
@@ -11,10 +11,10 @@
11
11
  "preview": "ceru-plugin preview dist/plugin.js"
12
12
  },
13
13
  "dependencies": {
14
- "@shiqianjiang/ceru-plugin-sdk": "^0.1.0"
14
+ "@shiqianjiang/ceru-plugin-sdk": "^0.2.0"
15
15
  },
16
16
  "devDependencies": {
17
- "@shiqianjiang/ceru-plugin-cli": "^0.1.2",
17
+ "@shiqianjiang/ceru-plugin-cli": "^0.2.0",
18
18
  "typescript": "~5.9.3",
19
19
  "electron": "^44.4.2",
20
20
  "prettier": "^3.6.2",
@@ -1,17 +1,45 @@
1
1
  {
2
2
  "Host platform icon": {
3
3
  "prefix": "ceru-icon",
4
- "body": [
5
- "{ kind: 'host', name: 'platform.${1:tx}' }"
6
- ],
7
- "description": "使用宿主平台图标,无需打入插件"
4
+ "body": ["{ kind: 'host', name: 'platform.${1:tx}' }"],
5
+ "description": "使用宿主平台图标,无需打入插件",
8
6
  },
9
7
  "Host lodash": {
10
8
  "prefix": "ceru-lodash",
9
+ "body": ["ctx.utils.lodash.${1:uniqBy}(${2:items}, ${3:key})"],
10
+ "description": "调用宿主的带类型 Lodash 工具",
11
+ },
12
+ "Host HTTP client": {
13
+ "prefix": "ceru-http",
14
+ "body": [
15
+ "const http = ctx.http.create({",
16
+ " baseURL: '${1:https://example.com}',",
17
+ " permissionKey: '${2:api}',",
18
+ " requestPermission: true,",
19
+ "})",
20
+ ],
21
+ "description": "使用宿主 Axios 代理;无需将请求库打入插件",
22
+ },
23
+ "Permission group": {
24
+ "prefix": "ceru-permission-group",
11
25
  "body": [
12
- "ctx.utils.lodash.${1:uniqBy}(${2:items}, ${3:key})"
26
+ "const permission = await ctx.permissions.requestGroup({",
27
+ " group: '${1:libraryRead}',",
28
+ " intent: operation.userIntent,",
29
+ "})",
13
30
  ],
14
- "description": "调用宿主的带类型 Lodash 工具"
31
+ "description": "一次申请一组用户可理解的能力",
32
+ },
33
+ "Grouped music provider": {
34
+ "prefix": "ceru-provider",
35
+ "body": [
36
+ "ctx.providers.register('${1:catalog}', {",
37
+ " tracks: { search: ${2:searchTracks}, resolve: ${3:resolveTrack}, lyrics: ${4:getLyrics} },",
38
+ " playlists: { search: ${5:searchPlaylists}, categories: ${6:getCategories}, list: ${7:listPlaylists}, get: ${8:getPlaylist} },",
39
+ " charts: { list: ${9:listCharts}, getTracks: ${10:getChartTracks} },",
40
+ "})",
41
+ ],
42
+ "description": "注册分组 Provider,返回标准歌曲/歌单/歌词 JSON",
15
43
  },
16
44
  "Source rate limit": {
17
45
  "prefix": "ceru-rate-limit",
@@ -20,8 +48,8 @@
20
48
  " code: 'RATE_LIMITED',",
21
49
  " message: '${1:请稍后重试}',",
22
50
  " recovery: { mode: 'await-user', maxWaitMs: 60000 }",
23
- "})"
51
+ "})",
24
52
  ],
25
- "description": "返回结构化限流结果,由 Host 决定换源与交互"
26
- }
53
+ "description": "返回结构化限流结果,由 Host 决定换源与交互",
54
+ },
27
55
  }
@@ -11,10 +11,10 @@
11
11
  "preview": "ceru-plugin preview dist/plugin.js"
12
12
  },
13
13
  "dependencies": {
14
- "@shiqianjiang/ceru-plugin-sdk": "^0.1.0"
14
+ "@shiqianjiang/ceru-plugin-sdk": "^0.2.0"
15
15
  },
16
16
  "devDependencies": {
17
- "@shiqianjiang/ceru-plugin-cli": "^0.1.2",
17
+ "@shiqianjiang/ceru-plugin-cli": "^0.2.0",
18
18
  "typescript": "~5.9.3",
19
19
  "electron": "^44.4.2",
20
20
  "prettier": "^3.6.2",