@openacp/cli 2026.330.3 → 2026.331.2

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 (173) hide show
  1. package/README.md +19 -1
  2. package/dist/cli.d.ts +11 -0
  3. package/dist/cli.js +25134 -278
  4. package/dist/cli.js.map +1 -1
  5. package/dist/data/registry-snapshot.json +1 -1
  6. package/dist/index.d.ts +259 -30
  7. package/dist/index.js +17632 -404
  8. package/dist/index.js.map +1 -1
  9. package/package.json +2 -2
  10. package/dist/adapter-AWSI4GML.js +0 -13
  11. package/dist/adapter-AWSI4GML.js.map +0 -1
  12. package/dist/agent-catalog-SZQQERV7.js +0 -10
  13. package/dist/agent-catalog-SZQQERV7.js.map +0 -1
  14. package/dist/agent-dependencies-ED2ZTUHG.js +0 -23
  15. package/dist/agent-dependencies-ED2ZTUHG.js.map +0 -1
  16. package/dist/agent-registry-YOGP656W.js +0 -8
  17. package/dist/agent-registry-YOGP656W.js.map +0 -1
  18. package/dist/agent-store-5UHZH2XI.js +0 -8
  19. package/dist/agent-store-5UHZH2XI.js.map +0 -1
  20. package/dist/api-client-XTLRRFPX.js +0 -13
  21. package/dist/api-client-XTLRRFPX.js.map +0 -1
  22. package/dist/api-server-5VNYFWJE.js +0 -7
  23. package/dist/api-server-5VNYFWJE.js.map +0 -1
  24. package/dist/api-server-JLBDKCU4.js +0 -10
  25. package/dist/api-server-JLBDKCU4.js.map +0 -1
  26. package/dist/autostart-CUPZMKKC.js +0 -22
  27. package/dist/autostart-CUPZMKKC.js.map +0 -1
  28. package/dist/chunk-237WYH6H.js +0 -235
  29. package/dist/chunk-237WYH6H.js.map +0 -1
  30. package/dist/chunk-2HEFALTZ.js +0 -44
  31. package/dist/chunk-2HEFALTZ.js.map +0 -1
  32. package/dist/chunk-2KT6TROD.js +0 -129
  33. package/dist/chunk-2KT6TROD.js.map +0 -1
  34. package/dist/chunk-2R5XM3ES.js +0 -154
  35. package/dist/chunk-2R5XM3ES.js.map +0 -1
  36. package/dist/chunk-3EWTPOF7.js +0 -51
  37. package/dist/chunk-3EWTPOF7.js.map +0 -1
  38. package/dist/chunk-3NAFXVQM.js +0 -67
  39. package/dist/chunk-3NAFXVQM.js.map +0 -1
  40. package/dist/chunk-4WXALZA3.js +0 -45
  41. package/dist/chunk-4WXALZA3.js.map +0 -1
  42. package/dist/chunk-566W6INH.js +0 -83
  43. package/dist/chunk-566W6INH.js.map +0 -1
  44. package/dist/chunk-5HKQCYOI.js +0 -145
  45. package/dist/chunk-5HKQCYOI.js.map +0 -1
  46. package/dist/chunk-5OCGO27U.js +0 -125
  47. package/dist/chunk-5OCGO27U.js.map +0 -1
  48. package/dist/chunk-5WGVYX3C.js +0 -55
  49. package/dist/chunk-5WGVYX3C.js.map +0 -1
  50. package/dist/chunk-7ZCQF6QM.js +0 -27
  51. package/dist/chunk-7ZCQF6QM.js.map +0 -1
  52. package/dist/chunk-AFKX424Q.js +0 -92
  53. package/dist/chunk-AFKX424Q.js.map +0 -1
  54. package/dist/chunk-APS6UEFU.js +0 -259
  55. package/dist/chunk-APS6UEFU.js.map +0 -1
  56. package/dist/chunk-BTJHGSLM.js +0 -1116
  57. package/dist/chunk-BTJHGSLM.js.map +0 -1
  58. package/dist/chunk-CDAUYTVP.js +0 -41
  59. package/dist/chunk-CDAUYTVP.js.map +0 -1
  60. package/dist/chunk-FCTC7KDT.js +0 -101
  61. package/dist/chunk-FCTC7KDT.js.map +0 -1
  62. package/dist/chunk-FNRSWA2K.js +0 -1
  63. package/dist/chunk-FNRSWA2K.js.map +0 -1
  64. package/dist/chunk-GEOXPGCO.js +0 -650
  65. package/dist/chunk-GEOXPGCO.js.map +0 -1
  66. package/dist/chunk-IZ5UEZF7.js +0 -138
  67. package/dist/chunk-IZ5UEZF7.js.map +0 -1
  68. package/dist/chunk-KDU3ZEWT.js +0 -97
  69. package/dist/chunk-KDU3ZEWT.js.map +0 -1
  70. package/dist/chunk-LGFWH3AE.js +0 -26
  71. package/dist/chunk-LGFWH3AE.js.map +0 -1
  72. package/dist/chunk-MITTQMGZ.js +0 -543
  73. package/dist/chunk-MITTQMGZ.js.map +0 -1
  74. package/dist/chunk-MLF4W5R6.js +0 -101
  75. package/dist/chunk-MLF4W5R6.js.map +0 -1
  76. package/dist/chunk-MPGEHTGE.js +0 -679
  77. package/dist/chunk-MPGEHTGE.js.map +0 -1
  78. package/dist/chunk-OYSAN7UX.js +0 -15
  79. package/dist/chunk-OYSAN7UX.js.map +0 -1
  80. package/dist/chunk-PA6MNBG4.js +0 -190
  81. package/dist/chunk-PA6MNBG4.js.map +0 -1
  82. package/dist/chunk-QWVHCTCA.js +0 -172
  83. package/dist/chunk-QWVHCTCA.js.map +0 -1
  84. package/dist/chunk-R6KZYF7D.js +0 -231
  85. package/dist/chunk-R6KZYF7D.js.map +0 -1
  86. package/dist/chunk-S64CB6J3.js +0 -98
  87. package/dist/chunk-S64CB6J3.js.map +0 -1
  88. package/dist/chunk-TMVTSWVH.js +0 -228
  89. package/dist/chunk-TMVTSWVH.js.map +0 -1
  90. package/dist/chunk-UCIZM5SW.js +0 -3917
  91. package/dist/chunk-UCIZM5SW.js.map +0 -1
  92. package/dist/chunk-UWH7KIAA.js +0 -701
  93. package/dist/chunk-UWH7KIAA.js.map +0 -1
  94. package/dist/chunk-V2YZWYXT.js +0 -484
  95. package/dist/chunk-V2YZWYXT.js.map +0 -1
  96. package/dist/chunk-W26AUH5B.js +0 -61
  97. package/dist/chunk-W26AUH5B.js.map +0 -1
  98. package/dist/chunk-W4LK6WJP.js +0 -446
  99. package/dist/chunk-W4LK6WJP.js.map +0 -1
  100. package/dist/chunk-WQCJTU2C.js +0 -84
  101. package/dist/chunk-WQCJTU2C.js.map +0 -1
  102. package/dist/chunk-XBZIHNKV.js +0 -6410
  103. package/dist/chunk-XBZIHNKV.js.map +0 -1
  104. package/dist/chunk-ZSLHHQPQ.js +0 -282
  105. package/dist/chunk-ZSLHHQPQ.js.map +0 -1
  106. package/dist/config-KN6NKKPF.js +0 -20
  107. package/dist/config-KN6NKKPF.js.map +0 -1
  108. package/dist/config-editor-76RVZS4B.js +0 -10
  109. package/dist/config-editor-76RVZS4B.js.map +0 -1
  110. package/dist/config-registry-ZXAIJNYB.js +0 -17
  111. package/dist/config-registry-ZXAIJNYB.js.map +0 -1
  112. package/dist/context-NXXW62NJ.js +0 -9
  113. package/dist/context-NXXW62NJ.js.map +0 -1
  114. package/dist/core-plugins-BPZY7SEB.js +0 -22
  115. package/dist/core-plugins-BPZY7SEB.js.map +0 -1
  116. package/dist/daemon-XFEMMJSZ.js +0 -29
  117. package/dist/daemon-XFEMMJSZ.js.map +0 -1
  118. package/dist/dev-loader-7P3HZCIA.js +0 -37
  119. package/dist/dev-loader-7P3HZCIA.js.map +0 -1
  120. package/dist/doctor-AV6AUO22.js +0 -9
  121. package/dist/doctor-AV6AUO22.js.map +0 -1
  122. package/dist/file-service-HHB3JQIO.js +0 -8
  123. package/dist/file-service-HHB3JQIO.js.map +0 -1
  124. package/dist/install-cloudflared-JRJ4BSOM.js +0 -32
  125. package/dist/install-cloudflared-JRJ4BSOM.js.map +0 -1
  126. package/dist/install-context-EHYV5WRY.js +0 -77
  127. package/dist/install-context-EHYV5WRY.js.map +0 -1
  128. package/dist/install-jq-ISTGT263.js +0 -31
  129. package/dist/install-jq-ISTGT263.js.map +0 -1
  130. package/dist/integrate-JIEZYDOR.js +0 -371
  131. package/dist/integrate-JIEZYDOR.js.map +0 -1
  132. package/dist/log-YZ243M5G.js +0 -25
  133. package/dist/log-YZ243M5G.js.map +0 -1
  134. package/dist/main-VEJCG5PY.js +0 -654
  135. package/dist/main-VEJCG5PY.js.map +0 -1
  136. package/dist/menu-ALFN37IR.js +0 -15
  137. package/dist/menu-ALFN37IR.js.map +0 -1
  138. package/dist/notifications-MO23S7S3.js +0 -8
  139. package/dist/notifications-MO23S7S3.js.map +0 -1
  140. package/dist/plugin-create-EHL76ZZG.js +0 -966
  141. package/dist/plugin-create-EHL76ZZG.js.map +0 -1
  142. package/dist/plugin-installer-VSTYZSXC.js +0 -9
  143. package/dist/plugin-installer-VSTYZSXC.js.map +0 -1
  144. package/dist/plugin-registry-6J3YSFHF.js +0 -7
  145. package/dist/plugin-registry-6J3YSFHF.js.map +0 -1
  146. package/dist/plugin-search-MGKAL5JM.js +0 -39
  147. package/dist/plugin-search-MGKAL5JM.js.map +0 -1
  148. package/dist/post-upgrade-Y26S2ZQ7.js +0 -79
  149. package/dist/post-upgrade-Y26S2ZQ7.js.map +0 -1
  150. package/dist/read-text-file-DJBTITIB.js +0 -7
  151. package/dist/read-text-file-DJBTITIB.js.map +0 -1
  152. package/dist/registry-client-GTBWLXYU.js +0 -7
  153. package/dist/registry-client-GTBWLXYU.js.map +0 -1
  154. package/dist/security-2BA265LN.js +0 -8
  155. package/dist/security-2BA265LN.js.map +0 -1
  156. package/dist/settings-manager-B4UN2LAC.js +0 -7
  157. package/dist/settings-manager-B4UN2LAC.js.map +0 -1
  158. package/dist/setup-DISPNDEK.js +0 -802
  159. package/dist/setup-DISPNDEK.js.map +0 -1
  160. package/dist/speech-SG62JYIF.js +0 -9
  161. package/dist/speech-SG62JYIF.js.map +0 -1
  162. package/dist/suggest-RST5VOHB.js +0 -36
  163. package/dist/suggest-RST5VOHB.js.map +0 -1
  164. package/dist/telegram-L3YM6SQJ.js +0 -7
  165. package/dist/telegram-L3YM6SQJ.js.map +0 -1
  166. package/dist/tunnel-HWJ27WDH.js +0 -7
  167. package/dist/tunnel-HWJ27WDH.js.map +0 -1
  168. package/dist/tunnel-service-ZMO4THKE.js +0 -1261
  169. package/dist/tunnel-service-ZMO4THKE.js.map +0 -1
  170. package/dist/validators-GITLOFXC.js +0 -11
  171. package/dist/validators-GITLOFXC.js.map +0 -1
  172. package/dist/version-AXXV6IV2.js +0 -15
  173. package/dist/version-AXXV6IV2.js.map +0 -1
@@ -1,966 +0,0 @@
1
- import {
2
- getCurrentVersion
3
- } from "./chunk-S64CB6J3.js";
4
-
5
- // src/cli/commands/plugin-create.ts
6
- import * as p from "@clack/prompts";
7
- import fs from "fs";
8
- import path from "path";
9
-
10
- // src/cli/plugin-template/package-json.ts
11
- function generatePackageJson(params) {
12
- const packageJson = {
13
- name: params.pluginName,
14
- version: "0.1.0",
15
- description: params.description || "",
16
- type: "module",
17
- main: "dist/index.js",
18
- types: "dist/index.d.ts",
19
- scripts: {
20
- build: "tsc",
21
- dev: "tsc --watch",
22
- test: "vitest",
23
- prepublishOnly: "npm run build"
24
- },
25
- author: params.author || "",
26
- license: params.license,
27
- keywords: ["openacp", "openacp-plugin"],
28
- engines: {
29
- openacp: `>=${params.cliVersion}`
30
- },
31
- peerDependencies: {
32
- "@openacp/cli": `>=${params.cliVersion}`
33
- },
34
- devDependencies: {
35
- "@openacp/plugin-sdk": params.cliVersion,
36
- typescript: "^5.4.0",
37
- vitest: "^3.0.0"
38
- }
39
- };
40
- return JSON.stringify(packageJson, null, 2) + "\n";
41
- }
42
-
43
- // src/cli/plugin-template/tsconfig.ts
44
- function generateTsconfig() {
45
- const tsconfig = {
46
- compilerOptions: {
47
- target: "ES2022",
48
- module: "NodeNext",
49
- moduleResolution: "NodeNext",
50
- declaration: true,
51
- outDir: "dist",
52
- rootDir: "src",
53
- strict: true,
54
- esModuleInterop: true,
55
- skipLibCheck: true,
56
- forceConsistentCasingInFileNames: true
57
- },
58
- include: ["src"],
59
- exclude: ["node_modules", "dist", "src/**/__tests__"]
60
- };
61
- return JSON.stringify(tsconfig, null, 2) + "\n";
62
- }
63
-
64
- // src/cli/plugin-template/dotfiles.ts
65
- function generateGitignore() {
66
- return ["node_modules/", "dist/", "*.tsbuildinfo", ".DS_Store", ""].join("\n");
67
- }
68
- function generateNpmignore() {
69
- return ["src/", "tsconfig.json", ".editorconfig", ".gitignore", "*.test.ts", "__tests__/", ""].join("\n");
70
- }
71
- function generateEditorconfig() {
72
- return [
73
- "root = true",
74
- "",
75
- "[*]",
76
- "indent_style = space",
77
- "indent_size = 2",
78
- "end_of_line = lf",
79
- "charset = utf-8",
80
- "trim_trailing_whitespace = true",
81
- "insert_final_newline = true",
82
- ""
83
- ].join("\n");
84
- }
85
-
86
- // src/cli/plugin-template/readme.ts
87
- function generateReadme(params) {
88
- return [
89
- `# ${params.pluginName}`,
90
- "",
91
- params.description || "An OpenACP plugin.",
92
- "",
93
- "## Installation",
94
- "",
95
- "```bash",
96
- `openacp plugin add ${params.pluginName}`,
97
- "```",
98
- "",
99
- "## Development",
100
- "",
101
- "```bash",
102
- "npm install",
103
- "npm run build",
104
- "npm test",
105
- "",
106
- "# Live development with hot-reload:",
107
- `openacp dev .`,
108
- "```",
109
- "",
110
- "## License",
111
- "",
112
- params.license,
113
- ""
114
- ].join("\n");
115
- }
116
-
117
- // src/cli/plugin-template/plugin-source.ts
118
- function generatePluginSource(params) {
119
- const dirName = params.pluginName.replace(/^@[^/]+\//, "");
120
- const escapedDescription = (params.description || "").replace(/'/g, "\\'");
121
- return `import type { OpenACPPlugin, PluginContext, InstallContext, MigrateContext } from '@openacp/plugin-sdk'
122
-
123
- const plugin: OpenACPPlugin = {
124
- name: '${params.pluginName}',
125
- version: '0.1.0',
126
- description: '${escapedDescription}',
127
-
128
- // Declare which permissions your plugin needs.
129
- // Available: events:read, events:emit, services:register, services:use,
130
- // middleware:register, commands:register, storage:read, storage:write, kernel:access
131
- permissions: ['events:read', 'services:register'],
132
-
133
- // Dependencies on other plugins (loaded before this one).
134
- // pluginDependencies: { '@openacp/security': '>=1.0.0' },
135
-
136
- // Optional dependencies (used if available, gracefully degrade if not).
137
- // optionalPluginDependencies: { '@openacp/usage': '>=1.0.0' },
138
-
139
- /**
140
- * Called during server startup in dependency order.
141
- * Register services, middleware, commands, and event listeners here.
142
- */
143
- async setup(ctx: PluginContext): Promise<void> {
144
- ctx.log.info('Plugin setup started')
145
-
146
- // Example: register a service
147
- // ctx.registerService('my-service', myServiceImpl)
148
-
149
- // Example: listen to events
150
- // ctx.on('session:created', (event) => { ... })
151
-
152
- // Example: register a slash command
153
- // ctx.registerCommand({
154
- // name: 'mycommand',
155
- // description: 'Does something useful',
156
- // category: 'plugin',
157
- // async handler(args) {
158
- // return { type: 'text', text: 'Hello from ${params.pluginName}!' }
159
- // },
160
- // })
161
-
162
- ctx.log.info('Plugin setup complete')
163
- },
164
-
165
- /**
166
- * Called during server shutdown in reverse dependency order.
167
- * Clean up resources, close connections, stop timers here.
168
- * Has a 10-second timeout.
169
- */
170
- async teardown(): Promise<void> {
171
- // Clean up resources here
172
- },
173
-
174
- /**
175
- * Called when user runs \`openacp plugin add ${params.pluginName}\`.
176
- * Use ctx.terminal for interactive prompts to gather configuration.
177
- */
178
- async install(ctx: InstallContext): Promise<void> {
179
- ctx.terminal.log.info('Installing ${params.pluginName}...')
180
-
181
- // Example: prompt for configuration
182
- // const apiKey = await ctx.terminal.text({
183
- // message: 'Enter your API key',
184
- // validate: (v) => v.length === 0 ? 'Required' : undefined,
185
- // })
186
- // await ctx.settings.set('apiKey', apiKey)
187
-
188
- ctx.terminal.log.success('Installation complete!')
189
- },
190
-
191
- /**
192
- * Called when user runs \`openacp plugin configure ${params.pluginName}\`.
193
- * Re-run configuration prompts to update settings.
194
- */
195
- async configure(ctx: InstallContext): Promise<void> {
196
- ctx.terminal.log.info('Configuring ${params.pluginName}...')
197
-
198
- // Re-run configuration prompts, pre-filling with current values
199
- // const current = await ctx.settings.getAll()
200
- // ...
201
-
202
- ctx.terminal.log.success('Configuration updated!')
203
- },
204
-
205
- /**
206
- * Called during boot when the plugin version has changed.
207
- * Migrate settings from the old format to the new format.
208
- */
209
- async migrate(ctx: MigrateContext, oldSettings: unknown, oldVersion: string): Promise<unknown> {
210
- ctx.log.info(\`Migrating from v\${oldVersion}\`)
211
- // Return the migrated settings object
212
- return oldSettings
213
- },
214
-
215
- /**
216
- * Called when user runs \`openacp plugin remove ${params.pluginName}\`.
217
- * Clean up any external resources. If opts.purge is true, delete all data.
218
- */
219
- async uninstall(ctx: InstallContext, opts: { purge: boolean }): Promise<void> {
220
- ctx.terminal.log.info('Uninstalling ${params.pluginName}...')
221
- if (opts.purge) {
222
- await ctx.settings.clear()
223
- }
224
- ctx.terminal.log.success('Uninstalled!')
225
- },
226
- }
227
-
228
- export default plugin
229
- `;
230
- }
231
-
232
- // src/cli/plugin-template/plugin-test.ts
233
- function generatePluginTest(params) {
234
- return `import { describe, it, expect } from 'vitest'
235
- import { createTestContext, createTestInstallContext } from '@openacp/plugin-sdk/testing'
236
- import plugin from '../index.js'
237
-
238
- describe('${params.pluginName}', () => {
239
- it('has correct metadata', () => {
240
- expect(plugin.name).toBe('${params.pluginName}')
241
- expect(plugin.version).toBeDefined()
242
- expect(plugin.setup).toBeInstanceOf(Function)
243
- })
244
-
245
- it('sets up without errors', async () => {
246
- const ctx = createTestContext({
247
- pluginName: '${params.pluginName}',
248
- pluginConfig: { enabled: true },
249
- permissions: plugin.permissions,
250
- })
251
- await expect(plugin.setup(ctx)).resolves.not.toThrow()
252
- })
253
-
254
- it('tears down without errors', async () => {
255
- if (plugin.teardown) {
256
- await expect(plugin.teardown()).resolves.not.toThrow()
257
- }
258
- })
259
-
260
- it('installs without errors', async () => {
261
- if (plugin.install) {
262
- const ctx = createTestInstallContext({
263
- pluginName: '${params.pluginName}',
264
- terminalResponses: { password: [''], confirm: [true], select: ['apiKey'] },
265
- })
266
- await expect(plugin.install(ctx)).resolves.not.toThrow()
267
- }
268
- })
269
- })
270
- `;
271
- }
272
-
273
- // src/cli/plugin-template/claude-md.ts
274
- function generateClaudeMd(params) {
275
- return `# CLAUDE.md
276
-
277
- This file provides context for AI coding agents (Claude, Cursor, etc.) working on this plugin.
278
-
279
- ## What is OpenACP?
280
-
281
- OpenACP is an open-source platform that bridges AI coding agents (Claude Code, Codex, etc.) to messaging platforms (Telegram, Discord, Slack) and custom UIs via the Agent Client Protocol (ACP). It features a microkernel plugin architecture where all features \u2014 adapters, services, commands \u2014 are plugins.
282
-
283
- - **Website & Docs**: https://openacp.gitbook.io/docs
284
- - **GitHub**: https://github.com/Open-ACP/OpenACP
285
- - **Plugin Registry**: https://github.com/Open-ACP/plugin-registry
286
-
287
- Key documentation pages:
288
- - [Getting Started](https://openacp.gitbook.io/docs/getting-started) \u2014 What is OpenACP, quickstart
289
- - [Plugin Development](https://openacp.gitbook.io/docs/extending/building-plugins) \u2014 How to build plugins
290
- - [Architecture](https://openacp.gitbook.io/docs/extending/architecture) \u2014 System design, plugin lifecycle
291
- - [Dev Mode](https://openacp.gitbook.io/docs/extending/dev-mode) \u2014 Hot-reload development workflow
292
- - [CLI Commands](https://openacp.gitbook.io/docs/api-reference/cli-commands) \u2014 Full CLI reference
293
- - [Platform Setup](https://openacp.gitbook.io/docs/platform-setup) \u2014 Telegram, Discord, Slack guides
294
- - [Configuration](https://openacp.gitbook.io/docs/self-hosting/configuration) \u2014 Config and settings reference
295
-
296
- ## Project Overview
297
-
298
- This is an OpenACP plugin. Plugins extend OpenACP with new adapters, services, commands, and middleware.
299
-
300
- - **Package**: ${params.pluginName}
301
- - **SDK**: \`@openacp/plugin-sdk\` (types, base classes, testing utilities)
302
- - **Entry point**: \`src/index.ts\` (default export of \`OpenACPPlugin\` object)
303
-
304
- ## Build & Run
305
-
306
- \`\`\`bash
307
- npm install # Install dependencies
308
- npm run build # Compile TypeScript (tsc)
309
- npm run dev # Watch mode (tsc --watch)
310
- npm test # Run tests (vitest)
311
- \`\`\`
312
-
313
- ### Development with hot-reload
314
-
315
- \`\`\`bash
316
- openacp dev . # Compiles, watches, and reloads plugin on changes
317
- \`\`\`
318
-
319
- ## File Structure
320
-
321
- \`\`\`
322
- src/
323
- index.ts \u2014 Plugin entry point (exports OpenACPPlugin)
324
- __tests__/
325
- index.test.ts \u2014 Tests using @openacp/plugin-sdk/testing
326
- package.json \u2014 engines.openacp declares minimum CLI version
327
- tsconfig.json \u2014 ES2022, NodeNext, strict mode
328
- CLAUDE.md \u2014 This file (AI agent context)
329
- PLUGIN_GUIDE.md \u2014 Human-readable developer guide
330
- \`\`\`
331
-
332
- ## Architecture: How OpenACP Plugins Work
333
-
334
- ### Plugin Lifecycle
335
-
336
- \`\`\`
337
- install \u2500\u2500> [reboot] \u2500\u2500> migrate? \u2500\u2500> setup \u2500\u2500> [running] \u2500\u2500> teardown \u2500\u2500> uninstall
338
- \`\`\`
339
-
340
- | Hook | Trigger | Interactive? | Has Services? |
341
- |------|---------|-------------|---------------|
342
- | \`install(ctx)\` | \`openacp plugin add <name>\` | Yes | No |
343
- | \`migrate(ctx, oldSettings, oldVersion)\` | Boot \u2014 stored version differs from plugin version | No | No |
344
- | \`configure(ctx)\` | \`openacp plugin configure <name>\` | Yes | No |
345
- | \`setup(ctx)\` | Every boot, after migrate | No | Yes |
346
- | \`teardown()\` | Shutdown (10s timeout) | No | Yes |
347
- | \`uninstall(ctx, opts)\` | \`openacp plugin remove <name>\` | Yes | No |
348
-
349
- ### OpenACPPlugin Interface
350
-
351
- \`\`\`typescript
352
- interface OpenACPPlugin {
353
- name: string // unique identifier, e.g. '@myorg/my-plugin'
354
- version: string // semver
355
- description?: string
356
- permissions?: PluginPermission[]
357
- pluginDependencies?: Record<string, string> // name -> semver range
358
- optionalPluginDependencies?: Record<string, string> // used if available
359
- overrides?: string // replace a built-in plugin entirely
360
- settingsSchema?: ZodSchema // Zod validation for settings
361
- essential?: boolean // true = needs setup before system can run
362
-
363
- setup(ctx: PluginContext): Promise<void>
364
- teardown?(): Promise<void>
365
- install?(ctx: InstallContext): Promise<void>
366
- configure?(ctx: InstallContext): Promise<void>
367
- migrate?(ctx: MigrateContext, oldSettings: unknown, oldVersion: string): Promise<unknown>
368
- uninstall?(ctx: InstallContext, opts: { purge: boolean }): Promise<void>
369
- }
370
- \`\`\`
371
-
372
- ### PluginContext API (available in setup)
373
-
374
- \`\`\`typescript
375
- interface PluginContext {
376
- pluginName: string
377
- pluginConfig: Record<string, unknown> // from settings.json
378
-
379
- // Events (requires 'events:read' / 'events:emit')
380
- on(event: string, handler: (...args: unknown[]) => void): void
381
- off(event: string, handler: (...args: unknown[]) => void): void
382
- emit(event: string, payload: unknown): void
383
-
384
- // Services (requires 'services:register' / 'services:use')
385
- registerService<T>(name: string, implementation: T): void
386
- getService<T>(name: string): T | undefined
387
-
388
- // Middleware (requires 'middleware:register')
389
- registerMiddleware<H extends MiddlewareHook>(hook: H, opts: MiddlewareOptions<MiddlewarePayloadMap[H]>): void
390
-
391
- // Commands (requires 'commands:register')
392
- registerCommand(def: CommandDef): void
393
-
394
- // Storage (requires 'storage:read' / 'storage:write')
395
- storage: PluginStorage // get, set, delete, list, getDataDir
396
-
397
- // Messaging (requires 'services:use')
398
- sendMessage(sessionId: string, content: OutgoingMessage): Promise<void>
399
-
400
- // Kernel access (requires 'kernel:access')
401
- sessions: SessionManager
402
- config: ConfigManager
403
- eventBus: EventBus
404
-
405
- // Always available
406
- log: Logger // trace, debug, info, warn, error, fatal, child
407
- }
408
- \`\`\`
409
-
410
- ### CommandDef and CommandResponse
411
-
412
- \`\`\`typescript
413
- interface CommandDef {
414
- name: string // command name without slash
415
- description: string // shown in /help
416
- usage?: string // e.g. '<city>' or 'on|off'
417
- category: 'system' | 'plugin'
418
- handler(args: CommandArgs): Promise<CommandResponse | void>
419
- }
420
-
421
- interface CommandArgs {
422
- raw: string // text after command name
423
- sessionId: string | null
424
- channelId: string // 'telegram', 'discord', 'slack'
425
- userId: string
426
- reply(content: string | CommandResponse): Promise<void>
427
- }
428
-
429
- type CommandResponse =
430
- | { type: 'text'; text: string }
431
- | { type: 'menu'; title: string; options: MenuOption[] }
432
- | { type: 'list'; title: string; items: ListItem[] }
433
- | { type: 'confirm'; question: string; onYes: string; onNo: string }
434
- | { type: 'error'; message: string }
435
- | { type: 'silent' }
436
- \`\`\`
437
-
438
- ### Settings System
439
-
440
- - \`settingsSchema\`: Zod schema for validation
441
- - \`SettingsAPI\` (in InstallContext): get, set, getAll, setAll, delete, clear, has
442
- - Settings stored at \`~/.openacp/plugins/@scope/name/settings.json\`
443
- - \`PluginStorage\` (in PluginContext): key-value store at \`~/.openacp/plugins/data/@scope/name/kv.json\`
444
- - \`storage.getDataDir()\`: returns path for large files, databases, caches
445
-
446
- ### InstallContext (for install/configure/uninstall)
447
-
448
- \`\`\`typescript
449
- interface InstallContext {
450
- pluginName: string
451
- terminal: TerminalIO // text, select, confirm, password, multiselect, log, spinner, note
452
- settings: SettingsAPI
453
- legacyConfig?: Record<string, unknown>
454
- dataDir: string
455
- log: Logger
456
- }
457
- \`\`\`
458
-
459
- ### Service Interfaces (available via ctx.getService)
460
-
461
- | Service name | Interface | Description |
462
- |---|---|---|
463
- | \`security\` | \`SecurityService\` | Access control, session limits, user roles |
464
- | \`file-service\` | \`FileServiceInterface\` | File saving, resolving, format conversion |
465
- | \`notifications\` | \`NotificationService\` | Send notifications to users |
466
- | \`usage\` | \`UsageService\` | Token/cost tracking and budget checking |
467
- | \`speech\` | \`SpeechServiceInterface\` | Text-to-speech and speech-to-text |
468
- | \`tunnel\` | \`TunnelServiceInterface\` | Port tunneling and public URL management |
469
- | \`context\` | \`ContextService\` | Context building for agent sessions |
470
-
471
- ## Plugin Permissions
472
-
473
- Declare in \`permissions\` array. Only request what you need.
474
-
475
- | Permission | Allows |
476
- |---|---|
477
- | \`events:read\` | \`ctx.on()\` \u2014 subscribe to events |
478
- | \`events:emit\` | \`ctx.emit()\` \u2014 emit custom events (must prefix with plugin name) |
479
- | \`services:register\` | \`ctx.registerService()\` \u2014 provide services to other plugins |
480
- | \`services:use\` | \`ctx.getService()\`, \`ctx.sendMessage()\` \u2014 consume services |
481
- | \`middleware:register\` | \`ctx.registerMiddleware()\` \u2014 intercept and modify flows |
482
- | \`commands:register\` | \`ctx.registerCommand()\` \u2014 add chat commands |
483
- | \`storage:read\` | \`ctx.storage.get()\`, \`ctx.storage.list()\` |
484
- | \`storage:write\` | \`ctx.storage.set()\`, \`ctx.storage.delete()\` |
485
- | \`kernel:access\` | \`ctx.sessions\`, \`ctx.config\`, \`ctx.eventBus\`, \`ctx.core\` |
486
-
487
- Calling a method without the required permission throws \`PluginPermissionError\`.
488
-
489
- ## Middleware Hooks (18 total)
490
-
491
- Register with \`ctx.registerMiddleware(hook, { priority?, handler })\`. Return \`null\` to block the flow, call \`next()\` to continue.
492
-
493
- ### Message flow
494
- - \`message:incoming\` \u2014 incoming user message (channelId, threadId, userId, text, attachments)
495
- - \`message:outgoing\` \u2014 outgoing message to user (sessionId, message)
496
-
497
- ### Agent flow
498
- - \`agent:beforePrompt\` \u2014 before prompt is sent to agent (sessionId, text, attachments)
499
- - \`agent:beforeEvent\` \u2014 before agent event is processed (sessionId, event)
500
- - \`agent:afterEvent\` \u2014 after agent event, before delivery (sessionId, event, outgoingMessage)
501
-
502
- ### Turn lifecycle
503
- - \`turn:start\` \u2014 agent turn begins (sessionId, promptText, promptNumber)
504
- - \`turn:end\` \u2014 agent turn ends (sessionId, stopReason, durationMs)
505
-
506
- ### File system
507
- - \`fs:beforeRead\` \u2014 before file read (sessionId, path, line, limit)
508
- - \`fs:beforeWrite\` \u2014 before file write (sessionId, path, content)
509
-
510
- ### Terminal
511
- - \`terminal:beforeCreate\` \u2014 before terminal process spawned (sessionId, command, args, env, cwd)
512
- - \`terminal:afterExit\` \u2014 after terminal process exits (sessionId, terminalId, command, exitCode, durationMs)
513
-
514
- ### Permission
515
- - \`permission:beforeRequest\` \u2014 before permission prompt (sessionId, request, autoResolve)
516
- - \`permission:afterResolve\` \u2014 after permission resolved (sessionId, requestId, decision, userId, durationMs)
517
-
518
- ### Session
519
- - \`session:beforeCreate\` \u2014 before session creation (agentName, workingDir, userId, channelId, threadId)
520
- - \`session:afterDestroy\` \u2014 after session destroyed (sessionId, reason, durationMs, promptCount)
521
-
522
- ### Control
523
- - \`mode:beforeChange\` \u2014 before mode change (sessionId, fromMode, toMode)
524
- - \`config:beforeChange\` \u2014 before config change (sessionId, configId, oldValue, newValue)
525
- - \`model:beforeChange\` \u2014 before model change (sessionId, fromModel, toModel)
526
- - \`agent:beforeCancel\` \u2014 before agent cancellation (sessionId, reason)
527
-
528
- ## Plugin Events (subscribe with ctx.on)
529
-
530
- ### System
531
- - \`kernel:booted\`, \`system:ready\`, \`system:shutdown\`, \`system:commands-ready\`
532
-
533
- ### Plugin lifecycle
534
- - \`plugin:loaded\`, \`plugin:failed\`, \`plugin:disabled\`, \`plugin:unloaded\`
535
-
536
- ### Session
537
- - \`session:created\`, \`session:ended\`, \`session:named\`, \`session:updated\`
538
-
539
- ### Agent
540
- - \`agent:event\`, \`agent:prompt\`
541
-
542
- ### Permission
543
- - \`permission:request\`, \`permission:resolved\`
544
-
545
- ## Testing
546
-
547
- Use \`@openacp/plugin-sdk/testing\`:
548
-
549
- \`\`\`typescript
550
- import { createTestContext, createTestInstallContext, mockServices } from '@openacp/plugin-sdk/testing'
551
- \`\`\`
552
-
553
- ### createTestContext(opts)
554
-
555
- Creates a test \`PluginContext\`. All state is in-memory.
556
-
557
- \`\`\`typescript
558
- const ctx = createTestContext({
559
- pluginName: '${params.pluginName}',
560
- pluginConfig: { enabled: true },
561
- permissions: plugin.permissions,
562
- services: { security: mockServices.security() },
563
- })
564
- await plugin.setup(ctx)
565
- expect(ctx.registeredCommands.has('mycommand')).toBe(true)
566
- const response = await ctx.executeCommand('mycommand', { raw: 'test' })
567
- \`\`\`
568
-
569
- Inspection properties: \`registeredServices\`, \`registeredCommands\`, \`registeredMiddleware\`, \`emittedEvents\`, \`sentMessages\`, \`executeCommand()\`.
570
-
571
- ### createTestInstallContext(opts)
572
-
573
- Creates a test \`InstallContext\`. Terminal prompts auto-answered from \`terminalResponses\`.
574
-
575
- \`\`\`typescript
576
- const ctx = createTestInstallContext({
577
- pluginName: '${params.pluginName}',
578
- terminalResponses: { password: ['sk-test-key'], select: ['en'] },
579
- })
580
- await plugin.install!(ctx)
581
- expect(ctx.settingsData.get('apiKey')).toBe('sk-test-key')
582
- \`\`\`
583
-
584
- ### mockServices
585
-
586
- Factory functions for mock service implementations:
587
-
588
- \`\`\`typescript
589
- mockServices.security(overrides?) // checkAccess, checkSessionLimit, getUserRole
590
- mockServices.fileService(overrides?) // saveFile, resolveFile, readTextFileWithRange
591
- mockServices.notifications(overrides?) // notify, notifyAll
592
- mockServices.usage(overrides?) // trackUsage, checkBudget, getSummary
593
- mockServices.speech(overrides?) // textToSpeech, speechToText, register*
594
- mockServices.tunnel(overrides?) // getPublicUrl, start, stop, getStore, fileUrl, diffUrl
595
- mockServices.context(overrides?) // buildContext, registerProvider
596
- \`\`\`
597
-
598
- ## Conventions
599
-
600
- - **ESM-only**: \`"type": "module"\` in package.json
601
- - **Import extensions**: All imports must use \`.js\` extension (e.g., \`import x from './util.js'\`)
602
- - **TypeScript strict mode**: \`strict: true\` in tsconfig.json
603
- - **Target**: ES2022, module NodeNext
604
- - **Test framework**: Vitest
605
- - **Test files**: \`src/**/__tests__/*.test.ts\`
606
-
607
- ## How to Add a Command
608
-
609
- \`\`\`typescript
610
- // In setup():
611
- ctx.registerCommand({
612
- name: 'mycommand',
613
- description: 'Does something useful',
614
- usage: '<arg>',
615
- category: 'plugin',
616
- async handler(args) {
617
- const input = args.raw.trim()
618
- if (!input) return { type: 'error', message: 'Usage: /mycommand <arg>' }
619
- return { type: 'text', text: \\\`Result: \\\${input}\\\` }
620
- },
621
- })
622
- \`\`\`
623
-
624
- Requires \`commands:register\` permission. Available as \`/mycommand\` (if no conflict) and \`/pluginscope:mycommand\` (always).
625
-
626
- ## How to Add a Service
627
-
628
- \`\`\`typescript
629
- // In setup():
630
- const myService = new MyService()
631
- ctx.registerService('my-service', myService)
632
- \`\`\`
633
-
634
- Requires \`services:register\` permission. Other plugins consume with \`ctx.getService<MyService>('my-service')\`.
635
-
636
- ## How to Add Middleware
637
-
638
- \`\`\`typescript
639
- // In setup():
640
- ctx.registerMiddleware('message:outgoing', {
641
- priority: 50, // lower = earlier execution
642
- handler: async (payload, next) => {
643
- payload.message.text = modifyText(payload.message.text)
644
- return next() // continue chain; return null to block
645
- },
646
- })
647
- \`\`\`
648
-
649
- Requires \`middleware:register\` permission.
650
-
651
- ## How Settings Work
652
-
653
- 1. Define \`settingsSchema\` (Zod) on the plugin object
654
- 2. In \`install()\`: use \`ctx.terminal\` for interactive prompts, save with \`ctx.settings.set()\`
655
- 3. In \`configure()\`: re-run prompts with current values pre-filled
656
- 4. In \`setup()\`: read settings from \`ctx.pluginConfig\`
657
- 5. In \`migrate()\`: transform old settings to new format on version change
658
-
659
- ## Version Compatibility
660
-
661
- The \`engines.openacp\` field in package.json declares the minimum CLI version. OpenACP checks this on install and warns if incompatible.
662
- `;
663
- }
664
-
665
- // src/cli/plugin-template/plugin-guide.ts
666
- function generatePluginGuide(params) {
667
- return `# Plugin Developer Guide
668
-
669
- ## Overview
670
-
671
- **${params.pluginName}** is an OpenACP plugin.
672
-
673
- > TODO: Describe what this plugin does.
674
-
675
- ## Project Structure
676
-
677
- \`\`\`
678
- src/
679
- index.ts \u2014 Plugin entry point (exports OpenACPPlugin object)
680
- __tests__/
681
- index.test.ts \u2014 Tests using Vitest + @openacp/plugin-sdk/testing
682
- package.json \u2014 npm package config with engines.openacp constraint
683
- tsconfig.json \u2014 TypeScript strict mode, ES2022, NodeNext
684
- CLAUDE.md \u2014 Full technical reference for AI coding agents
685
- PLUGIN_GUIDE.md \u2014 This file
686
- \`\`\`
687
-
688
- ## Development Workflow
689
-
690
- 1. **Edit** \`src/index.ts\` \u2014 implement your plugin logic
691
- 2. **Dev mode**: \`openacp dev .\` \u2014 compiles, watches, and hot-reloads your plugin
692
- 3. **Test**: \`npm test\` \u2014 runs Vitest with SDK testing utilities
693
- 4. **Build**: \`npm run build\` \u2014 compiles TypeScript to \`dist/\`
694
-
695
- \`\`\`bash
696
- npm install
697
- openacp dev . # start developing with hot-reload
698
- npm test # run tests
699
- npm run build # compile for publishing
700
- \`\`\`
701
-
702
- ## Adding a Command
703
-
704
- Register commands in your \`setup()\` function. Requires \`commands:register\` permission.
705
-
706
- \`\`\`typescript
707
- async setup(ctx: PluginContext) {
708
- ctx.registerCommand({
709
- name: 'greet',
710
- description: 'Send a greeting',
711
- usage: '[name]',
712
- category: 'plugin',
713
- async handler(args) {
714
- const name = args.raw.trim() || 'World'
715
- return { type: 'text', text: \\\`Hello, \\\${name}!\\\` }
716
- },
717
- })
718
- }
719
- \`\`\`
720
-
721
- The command will be available as \`/greet\` in all messaging platforms.
722
-
723
- ## Adding a Service
724
-
725
- Provide a service that other plugins can consume. Requires \`services:register\` permission.
726
-
727
- \`\`\`typescript
728
- async setup(ctx: PluginContext) {
729
- const myService = {
730
- doSomething(input: string): string {
731
- return input.toUpperCase()
732
- },
733
- }
734
- ctx.registerService('my-service', myService)
735
- }
736
- \`\`\`
737
-
738
- Other plugins access it with \`ctx.getService<MyServiceType>('my-service')\`.
739
-
740
- ## Adding Middleware
741
-
742
- Intercept and modify message flows. Requires \`middleware:register\` permission.
743
-
744
- \`\`\`typescript
745
- async setup(ctx: PluginContext) {
746
- ctx.registerMiddleware('message:outgoing', {
747
- priority: 50,
748
- handler: async (payload, next) => {
749
- // Modify the message before delivery
750
- payload.message.text += '\\n-- sent via ${params.pluginName}'
751
- return next() // continue the chain
752
- // return null to block the message entirely
753
- },
754
- })
755
- }
756
- \`\`\`
757
-
758
- ## Handling Settings
759
-
760
- ### Install flow (first-time setup)
761
-
762
- \`\`\`typescript
763
- async install(ctx: InstallContext) {
764
- const apiKey = await ctx.terminal.password({
765
- message: 'Enter your API key:',
766
- validate: (v) => v.length > 0 ? undefined : 'Required',
767
- })
768
- await ctx.settings.set('apiKey', apiKey)
769
- ctx.terminal.log.success('Configured!')
770
- }
771
- \`\`\`
772
-
773
- ### Configure flow (reconfiguration)
774
-
775
- \`\`\`typescript
776
- async configure(ctx: InstallContext) {
777
- const current = await ctx.settings.getAll()
778
- const apiKey = await ctx.terminal.password({
779
- message: \\\`API key (current: \\\${current.apiKey ? '***' : 'not set'}):\\\`,
780
- })
781
- if (apiKey) await ctx.settings.set('apiKey', apiKey)
782
- ctx.terminal.log.success('Updated!')
783
- }
784
- \`\`\`
785
-
786
- ### Reading settings at runtime
787
-
788
- \`\`\`typescript
789
- async setup(ctx: PluginContext) {
790
- const apiKey = ctx.pluginConfig.apiKey as string
791
- if (!apiKey) {
792
- ctx.log.warn('Not configured \u2014 run: openacp plugin configure ${params.pluginName}')
793
- return
794
- }
795
- // Use apiKey...
796
- }
797
- \`\`\`
798
-
799
- ## Testing
800
-
801
- Tests use Vitest and \`@openacp/plugin-sdk/testing\`.
802
-
803
- \`\`\`typescript
804
- import { describe, it, expect } from 'vitest'
805
- import { createTestContext, createTestInstallContext, mockServices } from '@openacp/plugin-sdk/testing'
806
- import plugin from '../index.js'
807
-
808
- describe('${params.pluginName}', () => {
809
- it('registers commands on setup', async () => {
810
- const ctx = createTestContext({ pluginName: '${params.pluginName}' })
811
- await plugin.setup(ctx)
812
- expect(ctx.registeredCommands.has('greet')).toBe(true)
813
- })
814
-
815
- it('command returns expected response', async () => {
816
- const ctx = createTestContext({ pluginName: '${params.pluginName}' })
817
- await plugin.setup(ctx)
818
- const res = await ctx.executeCommand('greet', { raw: 'Alice' })
819
- expect(res).toEqual({ type: 'text', text: 'Hello, Alice!' })
820
- })
821
-
822
- it('install saves settings', async () => {
823
- const ctx = createTestInstallContext({
824
- pluginName: '${params.pluginName}',
825
- terminalResponses: { password: ['sk-test-key'] },
826
- })
827
- await plugin.install!(ctx)
828
- expect(ctx.settingsData.get('apiKey')).toBe('sk-test-key')
829
- })
830
- })
831
- \`\`\`
832
-
833
- ### Available mock services
834
-
835
- \`\`\`typescript
836
- const ctx = createTestContext({
837
- pluginName: '${params.pluginName}',
838
- services: {
839
- security: mockServices.security(),
840
- usage: mockServices.usage({ async checkBudget() { return { ok: false, percent: 100 } } }),
841
- },
842
- })
843
- \`\`\`
844
-
845
- ## Publishing
846
-
847
- 1. Update \`version\` in both \`package.json\` and \`src/index.ts\`
848
- 2. Build and test:
849
- \`\`\`bash
850
- npm run build
851
- npm test
852
- \`\`\`
853
- 3. Publish:
854
- \`\`\`bash
855
- npm publish --access public
856
- \`\`\`
857
- 4. Users install with:
858
- \`\`\`bash
859
- openacp plugin install ${params.pluginName}
860
- \`\`\`
861
- 5. Submit to the [OpenACP Plugin Registry](https://github.com/Open-ACP/plugin-registry) for discoverability.
862
-
863
- ## Useful Links
864
-
865
- - [Architecture: Plugin System](https://docs.openacp.dev/architecture/plugin-system)
866
- - [Architecture: Writing Plugins](https://docs.openacp.dev/architecture/writing-plugins)
867
- - [Architecture: Command System](https://docs.openacp.dev/architecture/command-system)
868
- - [Plugin SDK Reference](https://docs.openacp.dev/extending/plugin-sdk-reference)
869
- - [Getting Started: Your First Plugin](https://docs.openacp.dev/extending/getting-started-plugin)
870
- - [Dev Mode](https://docs.openacp.dev/extending/dev-mode)
871
- - [Contributing](https://github.com/Open-ACP/OpenACP/blob/main/CONTRIBUTING.md)
872
- `;
873
- }
874
-
875
- // src/cli/commands/plugin-create.ts
876
- async function cmdPluginCreate() {
877
- p.intro("Create a new OpenACP plugin");
878
- const result = await p.group(
879
- {
880
- name: () => p.text({
881
- message: "Plugin name (e.g., @myorg/adapter-matrix)",
882
- placeholder: "@myorg/my-plugin",
883
- validate: (value) => {
884
- if (!value || !value.trim()) return "Plugin name is required";
885
- if (!/^(@[a-z0-9-]+\/)?[a-z0-9-]+$/.test(value.trim())) {
886
- return "Must be a valid npm package name (lowercase, hyphens, optional @scope/)";
887
- }
888
- return void 0;
889
- }
890
- }),
891
- description: () => p.text({
892
- message: "Description",
893
- placeholder: "A short description of your plugin"
894
- }),
895
- author: () => p.text({
896
- message: "Author",
897
- placeholder: "Your Name <email@example.com>"
898
- }),
899
- license: () => p.select({
900
- message: "License",
901
- options: [
902
- { value: "MIT", label: "MIT" },
903
- { value: "Apache-2.0", label: "Apache 2.0" },
904
- { value: "ISC", label: "ISC" },
905
- { value: "UNLICENSED", label: "Unlicensed (private)" }
906
- ]
907
- })
908
- },
909
- {
910
- onCancel: () => {
911
- p.cancel("Plugin creation cancelled.");
912
- process.exit(0);
913
- }
914
- }
915
- );
916
- const pluginName = result.name.trim();
917
- const dirName = pluginName.replace(/^@[^/]+\//, "");
918
- const targetDir = path.resolve(process.cwd(), dirName);
919
- if (fs.existsSync(targetDir)) {
920
- p.cancel(`Directory "${dirName}" already exists.`);
921
- process.exit(1);
922
- }
923
- const spinner2 = p.spinner();
924
- spinner2.start("Scaffolding plugin...");
925
- fs.mkdirSync(path.join(targetDir, "src", "__tests__"), { recursive: true });
926
- const params = {
927
- pluginName,
928
- description: result.description || "",
929
- author: result.author || "",
930
- license: result.license,
931
- cliVersion: getCurrentVersion()
932
- };
933
- const files = [
934
- { relativePath: "package.json", content: generatePackageJson(params) },
935
- { relativePath: "tsconfig.json", content: generateTsconfig() },
936
- { relativePath: ".gitignore", content: generateGitignore() },
937
- { relativePath: ".npmignore", content: generateNpmignore() },
938
- { relativePath: ".editorconfig", content: generateEditorconfig() },
939
- { relativePath: "README.md", content: generateReadme(params) },
940
- { relativePath: "CLAUDE.md", content: generateClaudeMd(params) },
941
- { relativePath: "PLUGIN_GUIDE.md", content: generatePluginGuide(params) },
942
- { relativePath: path.join("src", "index.ts"), content: generatePluginSource(params) },
943
- { relativePath: path.join("src", "__tests__", "index.test.ts"), content: generatePluginTest(params) }
944
- ];
945
- for (const file of files) {
946
- fs.writeFileSync(path.join(targetDir, file.relativePath), file.content);
947
- }
948
- spinner2.stop("Plugin scaffolded!");
949
- p.note(
950
- [
951
- `cd ${dirName}`,
952
- "npm install",
953
- "npm run build",
954
- "npm test",
955
- "",
956
- "# Start development with hot-reload:",
957
- `openacp dev .`
958
- ].join("\n"),
959
- "Next steps"
960
- );
961
- p.outro(`Plugin ${pluginName} created in ./${dirName}`);
962
- }
963
- export {
964
- cmdPluginCreate
965
- };
966
- //# sourceMappingURL=plugin-create-EHL76ZZG.js.map