@choiceopen/automation-plugin-cli 0.2.0 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +65 -65
  2. package/dist/commands/auth/login.js +5 -5
  3. package/dist/commands/auth/status.js +2 -2
  4. package/dist/commands/plugin/init.js +7 -2
  5. package/dist/commands/plugin/refresh-key.js +2 -2
  6. package/dist/templates/OVERVIEW.md +58 -0
  7. package/dist/templates/common/.claude/commands/commit.md +13 -0
  8. package/dist/templates/common/.env +2 -0
  9. package/dist/templates/common/.gitignore.eta +6 -0
  10. package/dist/templates/common/.spec/ARCHITECTURE.md +193 -0
  11. package/dist/templates/common/LICENSE.md.eta +21 -0
  12. package/dist/templates/common/PRIVACY.md.eta +47 -0
  13. package/dist/templates/typescript/.editorconfig +15 -0
  14. package/dist/templates/typescript/.typesafe-i18n.json +8 -0
  15. package/dist/templates/typescript/README.md.eta +21 -0
  16. package/dist/templates/typescript/biome.json.eta +32 -0
  17. package/dist/templates/typescript/package.json.eta +57 -0
  18. package/dist/templates/typescript/src/README.md.eta +24 -0
  19. package/dist/templates/typescript/src/i18n/README.md +29 -0
  20. package/dist/templates/typescript/src/i18n/en-US/README.md +12 -0
  21. package/dist/templates/typescript/src/i18n/en-US/index.ts.eta +13 -0
  22. package/dist/templates/typescript/src/i18n/formatters.ts.eta +12 -0
  23. package/dist/templates/typescript/src/i18n/i18n-node.ts.eta +31 -0
  24. package/dist/templates/typescript/src/i18n/i18n-types.ts.eta +79 -0
  25. package/dist/templates/typescript/src/i18n/i18n-util.async.ts.eta +33 -0
  26. package/dist/templates/typescript/src/i18n/i18n-util.sync.ts.eta +26 -0
  27. package/dist/templates/typescript/src/i18n/i18n-util.ts.eta +63 -0
  28. package/dist/templates/typescript/src/i18n/zh-Hans/README.md +12 -0
  29. package/dist/templates/typescript/src/i18n/zh-Hans/index.ts.eta +13 -0
  30. package/dist/templates/typescript/src/index.ts.eta +25 -0
  31. package/dist/templates/typescript/src/tools/README.md +18 -0
  32. package/dist/templates/typescript/src/tools/demo.ts.eta +29 -0
  33. package/dist/templates/typescript/test/README.md +15 -0
  34. package/dist/templates/typescript/test/index.test.ts.eta +65 -0
  35. package/dist/templates/typescript/tsconfig.json.eta +20 -0
  36. package/dist/templates/typescript/tsdown.config.ts.eta +11 -0
  37. package/oclif.manifest.json +1 -1
  38. package/package.json +13 -14
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
- automation-plugin-cli
1
+ atomemo-plugin-cli
2
2
  =================
3
3
 
4
- A command-line utility for building and publishing Choiceform Automation Plugin.
4
+ A command-line utility for building and publishing Choiceform Atomemo Plugin.
5
5
 
6
6
 
7
7
  [![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
@@ -17,37 +17,37 @@ A command-line utility for building and publishing Choiceform Automation Plugin.
17
17
  <!-- usage -->
18
18
  ```sh-session
19
19
  $ npm install -g @choiceopen/automation-plugin-cli
20
- $ automation COMMAND
20
+ $ atomemo COMMAND
21
21
  running command...
22
- $ automation (--version)
23
- @choiceopen/automation-plugin-cli/0.2.0 darwin-arm64 node-v24.13.0
24
- $ automation --help [COMMAND]
22
+ $ atomemo (--version)
23
+ @choiceopen/automation-plugin-cli/0.2.3 darwin-arm64 node-v24.13.0
24
+ $ atomemo --help [COMMAND]
25
25
  USAGE
26
- $ automation COMMAND
26
+ $ atomemo COMMAND
27
27
  ...
28
28
  ```
29
29
  <!-- usagestop -->
30
30
  # Commands
31
31
  <!-- commands -->
32
- * [`automation auth login`](#automation-auth-login)
33
- * [`automation auth status`](#automation-auth-status)
34
- * [`automation autocomplete [SHELL]`](#automation-autocomplete-shell)
35
- * [`automation help [COMMAND]`](#automation-help-command)
36
- * [`automation plugin checksum [FILE]`](#automation-plugin-checksum-file)
37
- * [`automation plugin init`](#automation-plugin-init)
38
- * [`automation plugin pack [FILE]`](#automation-plugin-pack-file)
39
- * [`automation plugin permission [FILE]`](#automation-plugin-permission-file)
40
- * [`automation plugin refresh-key`](#automation-plugin-refresh-key)
41
- * [`automation plugin run [FILE]`](#automation-plugin-run-file)
42
- * [`automation version`](#automation-version)
43
-
44
- ## `automation auth login`
32
+ * [`atomemo auth login`](#atomemo-auth-login)
33
+ * [`atomemo auth status`](#atomemo-auth-status)
34
+ * [`atomemo autocomplete [SHELL]`](#atomemo-autocomplete-shell)
35
+ * [`atomemo help [COMMAND]`](#atomemo-help-command)
36
+ * [`atomemo plugin checksum [FILE]`](#atomemo-plugin-checksum-file)
37
+ * [`atomemo plugin init`](#atomemo-plugin-init)
38
+ * [`atomemo plugin pack [FILE]`](#atomemo-plugin-pack-file)
39
+ * [`atomemo plugin permission [FILE]`](#atomemo-plugin-permission-file)
40
+ * [`atomemo plugin refresh-key`](#atomemo-plugin-refresh-key)
41
+ * [`atomemo plugin run [FILE]`](#atomemo-plugin-run-file)
42
+ * [`atomemo version`](#atomemo-version)
43
+
44
+ ## `atomemo auth login`
45
45
 
46
46
  Uses device authorization flow to login with your Choiceform account by following these steps:
47
47
 
48
48
  ```
49
49
  USAGE
50
- $ automation auth login
50
+ $ atomemo auth login
51
51
 
52
52
  DESCRIPTION
53
53
  Uses device authorization flow to login with your Choiceform account by following these steps:
@@ -60,18 +60,18 @@ DESCRIPTION
60
60
  EXAMPLES
61
61
  Login by using device authorization flow
62
62
 
63
- $ automation auth login
63
+ $ atomemo auth login
64
64
  ```
65
65
 
66
- _See code: [src/commands/auth/login.ts](https://github.com/choice-open/automation-plugin-cli/blob/v0.2.0/src/commands/auth/login.ts)_
66
+ _See code: [src/commands/auth/login.ts](https://github.com/choice-open/automation-plugin-cli/blob/v0.2.3/src/commands/auth/login.ts)_
67
67
 
68
- ## `automation auth status`
68
+ ## `atomemo auth status`
69
69
 
70
70
  Display the current authentication status.
71
71
 
72
72
  ```
73
73
  USAGE
74
- $ automation auth status
74
+ $ atomemo auth status
75
75
 
76
76
  DESCRIPTION
77
77
  Display the current authentication status.
@@ -82,18 +82,18 @@ DESCRIPTION
82
82
  EXAMPLES
83
83
  Check current authentication status
84
84
 
85
- $ automation auth status
85
+ $ atomemo auth status
86
86
  ```
87
87
 
88
- _See code: [src/commands/auth/status.ts](https://github.com/choice-open/automation-plugin-cli/blob/v0.2.0/src/commands/auth/status.ts)_
88
+ _See code: [src/commands/auth/status.ts](https://github.com/choice-open/automation-plugin-cli/blob/v0.2.3/src/commands/auth/status.ts)_
89
89
 
90
- ## `automation autocomplete [SHELL]`
90
+ ## `atomemo autocomplete [SHELL]`
91
91
 
92
92
  Display autocomplete installation instructions.
93
93
 
94
94
  ```
95
95
  USAGE
96
- $ automation autocomplete [SHELL] [-r]
96
+ $ atomemo autocomplete [SHELL] [-r]
97
97
 
98
98
  ARGUMENTS
99
99
  [SHELL] (zsh|bash|powershell) Shell type
@@ -105,26 +105,26 @@ DESCRIPTION
105
105
  Display autocomplete installation instructions.
106
106
 
107
107
  EXAMPLES
108
- $ automation autocomplete
108
+ $ atomemo autocomplete
109
109
 
110
- $ automation autocomplete bash
110
+ $ atomemo autocomplete bash
111
111
 
112
- $ automation autocomplete zsh
112
+ $ atomemo autocomplete zsh
113
113
 
114
- $ automation autocomplete powershell
114
+ $ atomemo autocomplete powershell
115
115
 
116
- $ automation autocomplete --refresh-cache
116
+ $ atomemo autocomplete --refresh-cache
117
117
  ```
118
118
 
119
119
  _See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v3.2.39/src/commands/autocomplete/index.ts)_
120
120
 
121
- ## `automation help [COMMAND]`
121
+ ## `atomemo help [COMMAND]`
122
122
 
123
- Display help for automation.
123
+ Display help for atomemo.
124
124
 
125
125
  ```
126
126
  USAGE
127
- $ automation help [COMMAND...] [-n]
127
+ $ atomemo help [COMMAND...] [-n]
128
128
 
129
129
  ARGUMENTS
130
130
  [COMMAND...] Command to show help for.
@@ -133,18 +133,18 @@ FLAGS
133
133
  -n, --nested-commands Include all nested commands in the output.
134
134
 
135
135
  DESCRIPTION
136
- Display help for automation.
136
+ Display help for atomemo.
137
137
  ```
138
138
 
139
139
  _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.36/src/commands/help.ts)_
140
140
 
141
- ## `automation plugin checksum [FILE]`
141
+ ## `atomemo plugin checksum [FILE]`
142
142
 
143
143
  describe the command here
144
144
 
145
145
  ```
146
146
  USAGE
147
- $ automation plugin checksum [FILE] [-f] [-n <value>]
147
+ $ atomemo plugin checksum [FILE] [-f] [-n <value>]
148
148
 
149
149
  ARGUMENTS
150
150
  [FILE] file to read
@@ -157,19 +157,19 @@ DESCRIPTION
157
157
  describe the command here
158
158
 
159
159
  EXAMPLES
160
- $ automation plugin checksum
160
+ $ atomemo plugin checksum
161
161
  ```
162
162
 
163
- _See code: [src/commands/plugin/checksum.ts](https://github.com/choice-open/automation-plugin-cli/blob/v0.2.0/src/commands/plugin/checksum.ts)_
163
+ _See code: [src/commands/plugin/checksum.ts](https://github.com/choice-open/automation-plugin-cli/blob/v0.2.3/src/commands/plugin/checksum.ts)_
164
164
 
165
- ## `automation plugin init`
165
+ ## `atomemo plugin init`
166
166
 
167
167
  Initialize a new plugin with step-by-step interactive instructions.
168
168
 
169
169
  ```
170
170
  USAGE
171
- $ automation plugin init [-i] [-n my-awesome-plugin] [-d Descriptive
172
- text...] [-a John Doe] [-e john.doe@example.com] [-u <value>] [--locales en_US|zh_Hans|ja_JP...] [-l
171
+ $ atomemo plugin init [-i] [-n my-awesome-plugin] [-d Descriptive text...]
172
+ [-a John Doe] [-e john.doe@example.com] [-u <value>] [--locales en_US|zh_Hans|ja_JP...] [-l
173
173
  elixir|python|typescript] [-t extension|llm|tool|trigger]
174
174
 
175
175
  FLAGS
@@ -194,18 +194,18 @@ DESCRIPTION
194
194
  EXAMPLES
195
195
  Start with interactive initialization:
196
196
 
197
- $ automation plugin init
197
+ $ atomemo plugin init
198
198
  ```
199
199
 
200
- _See code: [src/commands/plugin/init.ts](https://github.com/choice-open/automation-plugin-cli/blob/v0.2.0/src/commands/plugin/init.ts)_
200
+ _See code: [src/commands/plugin/init.ts](https://github.com/choice-open/automation-plugin-cli/blob/v0.2.3/src/commands/plugin/init.ts)_
201
201
 
202
- ## `automation plugin pack [FILE]`
202
+ ## `atomemo plugin pack [FILE]`
203
203
 
204
204
  describe the command here
205
205
 
206
206
  ```
207
207
  USAGE
208
- $ automation plugin pack [FILE] [-f] [-n <value>]
208
+ $ atomemo plugin pack [FILE] [-f] [-n <value>]
209
209
 
210
210
  ARGUMENTS
211
211
  [FILE] file to read
@@ -218,18 +218,18 @@ DESCRIPTION
218
218
  describe the command here
219
219
 
220
220
  EXAMPLES
221
- $ automation plugin pack
221
+ $ atomemo plugin pack
222
222
  ```
223
223
 
224
- _See code: [src/commands/plugin/pack.ts](https://github.com/choice-open/automation-plugin-cli/blob/v0.2.0/src/commands/plugin/pack.ts)_
224
+ _See code: [src/commands/plugin/pack.ts](https://github.com/choice-open/automation-plugin-cli/blob/v0.2.3/src/commands/plugin/pack.ts)_
225
225
 
226
- ## `automation plugin permission [FILE]`
226
+ ## `atomemo plugin permission [FILE]`
227
227
 
228
228
  describe the command here
229
229
 
230
230
  ```
231
231
  USAGE
232
- $ automation plugin permission [FILE] [-f] [-n <value>]
232
+ $ atomemo plugin permission [FILE] [-f] [-n <value>]
233
233
 
234
234
  ARGUMENTS
235
235
  [FILE] file to read
@@ -242,35 +242,35 @@ DESCRIPTION
242
242
  describe the command here
243
243
 
244
244
  EXAMPLES
245
- $ automation plugin permission
245
+ $ atomemo plugin permission
246
246
  ```
247
247
 
248
- _See code: [src/commands/plugin/permission.ts](https://github.com/choice-open/automation-plugin-cli/blob/v0.2.0/src/commands/plugin/permission.ts)_
248
+ _See code: [src/commands/plugin/permission.ts](https://github.com/choice-open/automation-plugin-cli/blob/v0.2.3/src/commands/plugin/permission.ts)_
249
249
 
250
- ## `automation plugin refresh-key`
250
+ ## `atomemo plugin refresh-key`
251
251
 
252
252
  Refresh or create API Key for plugin debugging in development stage.
253
253
 
254
254
  ```
255
255
  USAGE
256
- $ automation plugin refresh-key
256
+ $ atomemo plugin refresh-key
257
257
 
258
258
  DESCRIPTION
259
259
  Refresh or create API Key for plugin debugging in development stage.
260
260
 
261
261
  EXAMPLES
262
- $ automation plugin refresh-key
262
+ $ atomemo plugin refresh-key
263
263
  ```
264
264
 
265
- _See code: [src/commands/plugin/refresh-key.ts](https://github.com/choice-open/automation-plugin-cli/blob/v0.2.0/src/commands/plugin/refresh-key.ts)_
265
+ _See code: [src/commands/plugin/refresh-key.ts](https://github.com/choice-open/automation-plugin-cli/blob/v0.2.3/src/commands/plugin/refresh-key.ts)_
266
266
 
267
- ## `automation plugin run [FILE]`
267
+ ## `atomemo plugin run [FILE]`
268
268
 
269
269
  describe the command here
270
270
 
271
271
  ```
272
272
  USAGE
273
- $ automation plugin run [FILE] [-f] [-n <value>]
273
+ $ atomemo plugin run [FILE] [-f] [-n <value>]
274
274
 
275
275
  ARGUMENTS
276
276
  [FILE] file to read
@@ -283,16 +283,16 @@ DESCRIPTION
283
283
  describe the command here
284
284
 
285
285
  EXAMPLES
286
- $ automation plugin run
286
+ $ atomemo plugin run
287
287
  ```
288
288
 
289
- _See code: [src/commands/plugin/run.ts](https://github.com/choice-open/automation-plugin-cli/blob/v0.2.0/src/commands/plugin/run.ts)_
289
+ _See code: [src/commands/plugin/run.ts](https://github.com/choice-open/automation-plugin-cli/blob/v0.2.3/src/commands/plugin/run.ts)_
290
290
 
291
- ## `automation version`
291
+ ## `atomemo version`
292
292
 
293
293
  ```
294
294
  USAGE
295
- $ automation version [--json] [--verbose]
295
+ $ atomemo version [--json] [--verbose]
296
296
 
297
297
  FLAGS
298
298
  --verbose Show additional information about the CLI.
@@ -23,7 +23,7 @@ export default class AuthLogin extends Command {
23
23
  ];
24
24
  static flags = {};
25
25
  pollingInterval = 5;
26
- client_id = "automation_plugin_cli";
26
+ client_id = "atomemo_plugin_cli";
27
27
  grant_type = "urn:ietf:params:oauth:grant-type:device_code";
28
28
  async run() {
29
29
  await this.parse(AuthLogin);
@@ -49,14 +49,14 @@ export default class AuthLogin extends Command {
49
49
  const session = await fetch(`${this.endpoint}/v1/auth/get-session`, {
50
50
  headers: {
51
51
  "Content-Type": "application/json",
52
- "User-Agent": "Choiceform (Automation Plugin CLI)",
52
+ "User-Agent": "Choiceform (Atomemo Plugin CLI)",
53
53
  Authorization: `Bearer ${result.access_token}`,
54
54
  },
55
55
  }).then((response) => response.json());
56
56
  this.log(colorize("greenBright", dedent `
57
57
  Welcome back, ${session.user.name} <${session.user.email}>!
58
58
  To create a new plugin, you can use the following command:
59
- \`${colorize("bold", colorize("yellowBright", "automation plugin init"))}\`
59
+ \`${colorize("bold", colorize("yellowBright", "atomemo plugin init"))}\`
60
60
  `));
61
61
  }
62
62
  async requestDeviceCode(endpoint) {
@@ -64,7 +64,7 @@ export default class AuthLogin extends Command {
64
64
  method: "POST",
65
65
  headers: {
66
66
  "Content-Type": "application/json",
67
- "User-Agent": "Choiceform (Automation Plugin CLI)",
67
+ "User-Agent": "Choiceform (Atomemo Plugin CLI)",
68
68
  },
69
69
  body: JSON.stringify({ client_id: this.client_id }),
70
70
  });
@@ -77,7 +77,7 @@ export default class AuthLogin extends Command {
77
77
  method: "POST",
78
78
  headers: {
79
79
  "Content-Type": "application/json",
80
- "User-Agent": "Choiceform (Automation Plugin CLI)",
80
+ "User-Agent": "Choiceform (Atomemo Plugin CLI)",
81
81
  },
82
82
  body: JSON.stringify({
83
83
  grant_type: this.grant_type,
@@ -20,7 +20,7 @@ export default class AuthStatus extends Command {
20
20
  await this.parse(AuthStatus);
21
21
  const config = await configStore.load();
22
22
  if (!config.auth?.access_token) {
23
- this.log(colorize("yellow", "Your device has not been authenticated yet. Please execute `automation auth login`."));
23
+ this.log(colorize("yellow", "Your device has not been authenticated yet. Please execute `atomemo auth login`."));
24
24
  return;
25
25
  }
26
26
  assert(config.auth?.endpoint, "Auth endpoint is required");
@@ -42,7 +42,7 @@ export default class AuthStatus extends Command {
42
42
  const response = await fetch(`${endpoint}/v1/auth/get-session`, {
43
43
  headers: {
44
44
  "Content-Type": "application/json",
45
- "User-Agent": "Choiceform (Automation Plugin CLI)",
45
+ "User-Agent": "Choiceform (Atomemo Plugin CLI)",
46
46
  Authorization: `Bearer ${accessToken}`,
47
47
  },
48
48
  });
@@ -89,7 +89,12 @@ export default class PluginInit extends Command {
89
89
  assert(flags.name, "flags.name should be valid here...");
90
90
  assert(flags.language, "flags.language should be valid here...");
91
91
  const generator = createPluginGenerator(flags.language, {
92
- props: { ...flags, createdAt: new Date().toISOString() },
92
+ props: {
93
+ ...flags,
94
+ createdAt: new Date().toISOString(),
95
+ date: new Date().toISOString().slice(0, 10),
96
+ year: new Date().getFullYear().toString(),
97
+ },
93
98
  target: path.join(process.cwd(), flags.name),
94
99
  });
95
100
  await generator.generate();
@@ -104,7 +109,7 @@ export default class PluginInit extends Command {
104
109
  if (!flags.interactive && !this.nameIsValid(flags.name)) {
105
110
  this.log(colorize("redBright", dedent `
106
111
  Without interactive mode, you should provide initial information manually.
107
- Use ${colorize("blue", "automation help plugin init")} to see all available options.
112
+ Use ${colorize("blue", "atomemo help plugin init")} to see all available options.
108
113
  `));
109
114
  this.exit(0);
110
115
  }
@@ -13,7 +13,7 @@ export default class PluginRefreshKey extends Command {
13
13
  // Step 1: Check access token
14
14
  const config = await configStore.load();
15
15
  if (!config.auth?.access_token) {
16
- this.log(colorize("red", "✗ You're not authenticated yet, please run 'automation auth login' first."));
16
+ this.log(colorize("red", "✗ You're not authenticated yet, please run 'atomemo auth login' first."));
17
17
  return process.exit(1);
18
18
  }
19
19
  try {
@@ -42,7 +42,7 @@ export default class PluginRefreshKey extends Command {
42
42
  method: "GET",
43
43
  headers: {
44
44
  "Content-Type": "application/json",
45
- "User-Agent": "Choiceform (Automation Plugin CLI)",
45
+ "User-Agent": "Choiceform (Atomemo Plugin CLI)",
46
46
  Authorization: `Bearer ${accessToken}`,
47
47
  },
48
48
  });
@@ -0,0 +1,58 @@
1
+ # Templates
2
+
3
+ Eta 模板引擎模板文件目录,用于生成新插件项目的脚手架代码。
4
+
5
+ ## 目录结构
6
+
7
+ ```
8
+ templates/
9
+ ├── common/ # 语言无关的通用模板
10
+ │ ├── manifest.yaml.eta
11
+ │ ├── license.eta
12
+ │ └── privacy.eta
13
+ └── typescript/ # TypeScript 专用模板
14
+ ├── package.json.eta
15
+ ├── README.md.eta
16
+ ├── tsconfig.json.eta
17
+ ├── tsdown.config.ts.eta
18
+ ├── src/
19
+ │ └── main.ts.eta
20
+ └── test/
21
+ └── main.test.ts.eta
22
+ ```
23
+
24
+ ## 模板引擎
25
+
26
+ 使用 [Eta](https://eta.js.org/) 模板引擎,配置如下:
27
+
28
+ ```typescript
29
+ new Eta({
30
+ autoTrim: false, // 保留空白
31
+ autoEscape: false, // 不转义 HTML
32
+ varName: "props", // 变量名
33
+ views: "templates/" // 模板根目录
34
+ })
35
+ ```
36
+
37
+ ## 模板语法
38
+
39
+ ```eta
40
+ <%# 注释 %>
41
+ <%= props.name %> // 输出变量
42
+ <%- rawContent %> // 原始输出
43
+ <% for (const x of arr) { %> // 控制流
44
+ <%= x %>
45
+ <% } %>
46
+ <%- %> // 去除尾部空白
47
+ ```
48
+
49
+ ## 子目录
50
+
51
+ - [`common/`](./common/OVERVIEW.md) - 通用模板
52
+ - [`typescript/`](./typescript/OVERVIEW.md) - TypeScript 模板
53
+
54
+ ## 扩展规划
55
+
56
+ 未来将支持更多语言:
57
+ - `elixir/` - Elixir 插件模板(计划中)
58
+ - `python/` - Python 插件模板(计划中)
@@ -0,0 +1,13 @@
1
+ # 提交变更
2
+
3
+ ## 概述
4
+
5
+ 提交代码并根据代码的变更创建或者更新变更日志。
6
+
7
+ ## 步骤
8
+
9
+ 1. 使用 Conventional Commits 编写提交信息,提交信息使用英文撰写
10
+ 2. 如果你认为有必要,可以把提交拆分为多个,但是**你必须先向我展示你的提交计划并获得我的确认**
11
+ 3. 如果当前项目还没有初始化 Git,你可以询问是否要初始化,并且询问 `config.name` 和 `config.email`
12
+ 4. 创建或更新项目的变更日志,使用 keepachangelog 的约定:https://keepachangelog.com/zh-CN/1.1.0/
13
+ 5. 遇到更新日期的时候,请务必使用当前的时间
@@ -0,0 +1,2 @@
1
+ DEBUG_API_KEY=
2
+ HUB_SERVER_WS_URL=wss://automation-plugin-api.choiceform.io/debug_socket
@@ -0,0 +1,6 @@
1
+ dist
2
+ node_modules
3
+
4
+ *.log
5
+ .DS_Store
6
+ .env
@@ -0,0 +1,193 @@
1
+ # 项目架构文档
2
+
3
+ **最后更新:** 2026-01-18
4
+
5
+ ## 概述
6
+
7
+ 这是一个基于 ChoiceOpen Automation Plugin SDK 的测试插件项目。插件提供工具执行功能,支持英文和简体中文两种语言。
8
+
9
+ ## 技术栈
10
+
11
+ - **语言**: TypeScript
12
+ - **运行时**: Node.js / Bun
13
+ - **构建工具**: tsdown
14
+ - **国际化**: typesafe-i18n
15
+ - **测试框架**: Vitest
16
+ - **代码格式化**: Biome
17
+ - **SDK**: @choiceopen/automation-plugin-sdk-js
18
+
19
+ ## 项目结构
20
+
21
+ ```
22
+ testing-plugin/
23
+ ├── src/ # 源代码目录
24
+ │ ├── tools/ # 工具定义
25
+ │ │ └── demo.ts # 演示工具
26
+ │ ├── i18n/ # 国际化
27
+ │ │ ├── en-US/ # 英文翻译
28
+ │ │ ├── zh-Hans/ # 中文翻译
29
+ │ │ ├── formatters.ts # 格式化器
30
+ │ │ ├── i18n-node.ts # Node.js 入口
31
+ │ │ ├── i18n-types.ts # 类型定义(自动生成)
32
+ │ │ ├── i18n-util.ts # 工具函数
33
+ │ │ ├── i18n-util.async.ts # 异步加载
34
+ │ │ └── i18n-util.sync.ts # 同步加载
35
+ │ ├── index.ts # 插件入口
36
+ │ └── README.md # 源码说明
37
+ ├── tests/ # 测试文件
38
+ │ └── index.test.ts # 主测试文件(空)
39
+ ├── dist/ # 构建输出
40
+ └── .spec/ # 架构文档
41
+ ```
42
+
43
+ ## 核心模块
44
+
45
+ ### 1. 插件入口 (src/index.ts)
46
+
47
+ 插件的主入口文件,负责:
48
+ - 异步加载所有国际化语言包
49
+ - 创建插件实例并配置基本信息(名称、描述、图标、作者等)
50
+ - 注册工具组件
51
+ - 启动插件服务
52
+
53
+ ```typescript
54
+ const plugin = createPlugin({
55
+ name: packageJSON.name,
56
+ display_name: t("PLUGIN_DISPLAY_NAME"),
57
+ description: t("PLUGIN_DESCRIPTION"),
58
+ icon: "🎛️",
59
+ author: "Choiceform",
60
+ // ...
61
+ })
62
+
63
+ plugin.addTool(demoTool)
64
+ plugin.run()
65
+ ```
66
+
67
+ ### 2. 工具模块 (src/tools/)
68
+
69
+ 定义插件提供的可执行工具。当前包含一个演示工具 `demo-tool`:
70
+
71
+ - **名称**: demo-tool
72
+ - **图标**: 🧰
73
+ - **参数**:
74
+ - `location` (string, required) - 位置参数,支持表达式
75
+
76
+ 工具执行时返回包含位置信息的消息。
77
+
78
+ ### 3. 国际化模块 (src/i18n/)
79
+
80
+ 基于 typesafe-i18n 实现类型安全的国际化系统:
81
+
82
+ **支持的语言**:
83
+ - 英文(en-US)
84
+ - 简体中文(zh-Hans)
85
+
86
+ **翻译键**:
87
+ - `PLUGIN_DISPLAY_NAME` - 插件显示名称
88
+ - `PLUGIN_DESCRIPTION` - 插件描述
89
+ - `DEMO_TOOL_DISPLAY_NAME` - 演示工具显示名称
90
+ - `DEMO_TOOL_DESCRIPTION` - 演示工具描述
91
+ - `LOCATION_DISPLAY_NAME` - 位置参数显示名称
92
+ - `LOCATION_HINT` - 位置参数提示
93
+ - `LOCATION_PLACEHOLDER` - 位置参数占位符
94
+
95
+ ## 数据流
96
+
97
+ ```mermaid
98
+ graph TD
99
+ A[index.ts] -->|加载| B[i18n 模块]
100
+ A -->|注册| C[工具模块]
101
+
102
+ C -->|使用| B
103
+
104
+ B -->|提供翻译| D[UI 文本]
105
+
106
+ E[Plugin SDK] -->|管理| A
107
+ A -->|运行| E
108
+ ```
109
+
110
+ ## 模块依赖关系
111
+
112
+ ```mermaid
113
+ graph LR
114
+ A[index.ts] --> B[tools/demo.ts]
115
+ A --> C[i18n]
116
+
117
+ B --> C
118
+
119
+ C --> D[en-US]
120
+ C --> E[zh-Hans]
121
+ ```
122
+
123
+ ## 构建流程
124
+
125
+ 1. **开发模式**: `bun run dev`
126
+ - 使用 tsdown watch 模式监听文件变化
127
+ - 同时运行 typesafe-i18n 生成类型定义
128
+
129
+ 2. **构建**: `bun run build`
130
+ - 使用 tsdown 编译 TypeScript
131
+ - 生成类型定义文件(.d.ts)
132
+ - 输出到 `dist/` 目录
133
+
134
+ 3. **测试**: `bun run test`
135
+ - 使用 Vitest 运行测试用例
136
+
137
+ 4. **类型检查**: `bun run typecheck`
138
+ - 使用 tsc 进行类型检查
139
+
140
+ ## 国际化机制
141
+
142
+ 插件使用 typesafe-i18n 实现类型安全的国际化:
143
+
144
+ 1. **翻译文件**: 位于 `src/i18n/{locale}/index.ts`
145
+ 2. **类型生成**: 自动生成 `i18n-types.ts` 包含所有翻译键的类型
146
+ 3. **加载方式**:
147
+ - 同步加载(`i18n-util.sync.ts`)
148
+ - 异步加载(`i18n-util.async.ts`,用于动态导入)
149
+ 4. **使用方式**: 通过 `t()` 函数获取翻译,编译时类型检查
150
+
151
+ ## 插件注册流程
152
+
153
+ ```mermaid
154
+ sequenceDiagram
155
+ participant Main as index.ts
156
+ participant I18n as i18n 模块
157
+ participant SDK as Plugin SDK
158
+ participant Tool as tools/demo.ts
159
+
160
+ Main->>I18n: loadAllLocalesAsync()
161
+ I18n-->>Main: 语言包加载完成
162
+
163
+ Main->>SDK: createPlugin()
164
+ SDK-->>Main: 插件实例
165
+
166
+ Main->>Tool: addTool(demoTool)
167
+
168
+ Main->>SDK: plugin.run()
169
+ SDK-->>Main: 插件运行中
170
+ ```
171
+
172
+ ## 待办事项
173
+
174
+ ### 功能改进
175
+ - [ ] 完善测试用例(`tests/index.test.ts` 当前为空)
176
+ - [ ] 添加更多工具支持
177
+ - [ ] 实现工具的实际业务逻辑(当前仅为演示)
178
+ - [ ] 添加凭证管理功能(如需要 API 密钥)
179
+ - [ ] 添加模型定义功能(如需要 AI 模型支持)
180
+
181
+ ### 代码质量
182
+ - [ ] 添加错误处理机制
183
+ - [ ] 完善类型定义和文档注释
184
+ - [ ] 添加代码示例和使用文档
185
+
186
+ ### 国际化
187
+ - [ ] 考虑添加更多语言支持
188
+ - [ ] 完善翻译文本的内容
189
+
190
+ ### 构建和部署
191
+ - [ ] 配置 CI/CD 流程
192
+ - [ ] 添加版本管理和发布流程
193
+ - [ ] 优化构建产物大小