@yancyyu/openhermit 1.6.3 → 1.6.4

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 +38 -2
  2. package/package.json +1 -1
package/bin/hermit.mjs CHANGED
@@ -95,6 +95,7 @@ const ccConnectConfigPath =
95
95
  process.env.HERMIT_CC_CONNECT_CONFIG ||
96
96
  process.env.CC_CONNECT_CONFIG ||
97
97
  path.join(hermitHome, 'cc-connect', 'config.toml');
98
+ const bootstrapProjectName = '__openhermit_bootstrap__';
98
99
 
99
100
  function readDaemonPid() {
100
101
  try {
@@ -365,6 +366,36 @@ function parseTomlToken(raw, section) {
365
366
  return match?.[1] || '';
366
367
  }
367
368
 
369
+ function hasProjectEntries(raw) {
370
+ return /^\s*\[\[projects\]\]/m.test(raw);
371
+ }
372
+
373
+ function buildBootstrapProjectToml() {
374
+ return `
375
+ # Internal bootstrap project used only so cc-connect can start with an otherwise empty config.
376
+ # It is safe to keep this project; users can replace or delete it after creating real teams.
377
+ [[projects]]
378
+ name = "${bootstrapProjectName}"
379
+ disabled_commands = ["*"]
380
+
381
+ [projects.agent]
382
+ type = "claudecode"
383
+
384
+ [projects.agent.options]
385
+ work_dir = "${escapeTomlPath(hermitHome)}"
386
+ mode = "default"
387
+
388
+ [[projects.platforms]]
389
+ type = "line"
390
+
391
+ [projects.platforms.options]
392
+ channel_secret = "openhermit-bootstrap"
393
+ channel_token = "openhermit-bootstrap"
394
+ port = "0"
395
+ callback_path = "/openhermit-bootstrap"
396
+ `;
397
+ }
398
+
368
399
  function ensureCcConnectConfig() {
369
400
  mkdirSync(path.dirname(ccConnectConfigPath), { recursive: true });
370
401
  if (!existsSync(ccConnectConfigPath)) {
@@ -388,11 +419,16 @@ path = "/bridge/ws"
388
419
 
389
420
  [log]
390
421
  level = "info"
391
- `;
422
+ ${buildBootstrapProjectToml()}`;
392
423
  writeFileSync(ccConnectConfigPath, config, 'utf-8');
393
424
  }
394
425
 
395
- const raw = readFileSync(ccConnectConfigPath, 'utf-8');
426
+ let raw = readFileSync(ccConnectConfigPath, 'utf-8');
427
+ if (!hasProjectEntries(raw)) {
428
+ raw = `${raw.trimEnd()}\n${buildBootstrapProjectToml()}`;
429
+ writeFileSync(ccConnectConfigPath, raw, 'utf-8');
430
+ }
431
+
396
432
  return {
397
433
  managementToken:
398
434
  process.env.CC_CONNECT_TOKEN ||
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@yancyyu/openhermit",
3
3
  "type": "module",
4
- "version": "1.6.3",
4
+ "version": "1.6.4",
5
5
  "description": "openHermit: team-oriented agent management workbench atop cc-connect.",
6
6
  "license": "AGPL-3.0",
7
7
  "author": {