@yancyyu/openhermit 1.6.11 → 1.6.12

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 (2) hide show
  1. package/bin/hermit.mjs +29 -12
  2. package/package.json +1 -1
package/bin/hermit.mjs CHANGED
@@ -84,7 +84,8 @@ const ccConnectConfigPath =
84
84
  process.env.HERMIT_CC_CONNECT_CONFIG ||
85
85
  process.env.CC_CONNECT_CONFIG ||
86
86
  path.join(hermitHome, 'cc-connect', 'config.toml');
87
- const bootstrapProjectName = '__openhermit_bootstrap__';
87
+ const bootstrapProjectName = 'default';
88
+ const legacyBootstrapProjectName = '__openhermit_bootstrap__';
88
89
 
89
90
  // ---------------------------------------------------------------------------
90
91
  // Update command
@@ -216,21 +217,37 @@ callback_path = "/openhermit-bootstrap"
216
217
  `;
217
218
  }
218
219
 
219
- function migrateManagedBootstrapProject(raw) {
220
- const projectPattern = /(^|\n)(#.*\n)*\[\[projects\]\]\nname\s*=\s*"__openhermit_bootstrap__"[\s\S]*?(?=\n(#.*\n)*\[\[projects\]\]|\s*$)/m;
220
+ function escapeRegExp(value) {
221
+ return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
222
+ }
223
+
224
+ function findProjectBlock(raw, name) {
225
+ const projectPattern = new RegExp(
226
+ `\\[\\[projects\\]\\]\\nname\\s*=\\s*"${escapeRegExp(name)}"[\\s\\S]*?(?=\\n\\[\\[projects\\]\\]|\\s*$)`
227
+ );
221
228
  const match = raw.match(projectPattern);
222
- if (!match) return raw;
229
+ return match ? { pattern: projectPattern, match } : null;
230
+ }
223
231
 
224
- const block = match[0];
225
- const isLegacyManagedBootstrap =
226
- block.includes('type = "feishu"') &&
227
- block.includes('app_id = "placeholder"') &&
228
- block.includes('app_secret = "placeholder"');
232
+ function isManagedBootstrapBlock(block) {
233
+ return (
234
+ block.includes('disabled_commands = ["*"]') &&
235
+ (block.includes('app_id = "placeholder"') ||
236
+ block.includes('channel_token = "openhermit-bootstrap"') ||
237
+ block.includes('callback_path = "/openhermit-bootstrap"'))
238
+ );
239
+ }
240
+
241
+ function migrateManagedBootstrapProject(raw) {
242
+ const legacyBlock = findProjectBlock(raw, legacyBootstrapProjectName);
243
+ if (!legacyBlock || !isManagedBootstrapBlock(legacyBlock.match[0])) return raw;
229
244
 
230
- if (!isLegacyManagedBootstrap) return raw;
245
+ const withoutLegacy = raw.replace(legacyBlock.pattern, '').replace(/\n{3,}/g, '\n\n').trimEnd();
246
+ if (findProjectBlock(withoutLegacy, bootstrapProjectName)) {
247
+ return `${withoutLegacy}\n`;
248
+ }
231
249
 
232
- const prefix = match[1] === '\n' ? '\n' : '';
233
- return raw.replace(projectPattern, `${prefix}${buildBootstrapProjectToml().trimStart()}`);
250
+ return `${withoutLegacy}\n${buildBootstrapProjectToml()}`;
234
251
  }
235
252
 
236
253
  function ensureCcConnectConfig() {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@yancyyu/openhermit",
3
3
  "type": "module",
4
- "version": "1.6.11",
4
+ "version": "1.6.12",
5
5
  "description": "openHermit: team-oriented agent management workbench atop cc-connect.",
6
6
  "license": "AGPL-3.0",
7
7
  "author": {