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