ai_co_discuss 0.3.34 → 0.3.37

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.
package/docs/en/runner.md CHANGED
@@ -91,6 +91,7 @@ Permissions are set per automatically started CLI member and default to read-onl
91
91
  | Open the local site | `codiscuss local open` |
92
92
  | Show status | `codiscuss local status` |
93
93
  | Stop | `codiscuss local stop` |
94
+ | Restart the discussion service (picks up new environment variables; run it from a terminal that has them) | `codiscuss service restart` |
94
95
  | Start at login (Windows) | `codiscuss service autostart on` |
95
96
 
96
97
  ## Command Line
package/docs/runner.md CHANGED
@@ -110,6 +110,7 @@ API 成员可以担任专家或主持人。房间指定了项目目录时,它
110
110
  | 打开本机网站 | `codiscuss local open` |
111
111
  | 查看状态 | `codiscuss local status` |
112
112
  | 停止 | `codiscuss local stop` |
113
+ | 重启讨论服务(使新环境变量生效,须在已有新值的终端执行) | `codiscuss service restart` |
113
114
  | 登录时自动启动(Windows) | `codiscuss service autostart on` |
114
115
 
115
116
  ## 命令行
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai_co_discuss",
3
- "version": "0.3.34",
3
+ "version": "0.3.37",
4
4
  "bin": {
5
5
  "codiscuss": "runner/codiscuss.mjs"
6
6
  },
@@ -1,4 +1,4 @@
1
- /** Own the local website and only the discussion service started by this supervisor. */
1
+ /** Own the local website and the discussion service it starts; local stop also stops a pre-existing service. */
2
2
  import { spawn } from 'node:child_process';
3
3
  import { createHash, randomBytes } from 'node:crypto';
4
4
  import { appendFileSync, closeSync, existsSync, mkdirSync, openSync, readFileSync, unlinkSync } from 'node:fs';
@@ -226,16 +226,15 @@ export function restart_reason(home = service_home()) {
226
226
  return null;
227
227
  }
228
228
 
229
- /** Ask the owned supervisor to stop, retaining its database and user configuration. */
229
+ /** Stop the supervisor and any discussion service, retaining the database and user configuration. */
230
230
  async function stop_local(home) {
231
- if (!local_status(home).pid) return local_status(home);
232
- const path = join(home, 'local', 'stop.request');
233
- atomic_json(path, { requested_at: Date.now() });
234
- for (let waited = 0; waited < STOP_WAIT_MS; waited += POLL_MS) {
235
- if (!local_status(home).pid) return local_status(home);
236
- await sleep(POLL_MS);
231
+ if (local_status(home).pid) {
232
+ atomic_json(join(home, 'local', 'stop.request'), { requested_at: Date.now() });
233
+ for (let waited = 0; waited < STOP_WAIT_MS && local_status(home).pid; waited += POLL_MS) await sleep(POLL_MS);
234
+ if (local_status(home).pid) throw new Error('本机服务尚未停止,请查看 local/supervisor.log');
237
235
  }
238
- throw new Error('本机服务尚未停止,请查看 local/supervisor.log');
236
+ if (service_pid(home)) await service_main(['stop'], () => {});
237
+ return local_status(home);
239
238
  }
240
239
 
241
240
  /** Open the supervisor's loopback URL or a website explicitly authorized by local connect. */
@@ -258,8 +257,7 @@ function local_summary(command, result, opened) {
258
257
  status: result.running ? [`本机网站运行中:${site}`]
259
258
  : result.website_running ? [`本机网站运行中:${site},但讨论服务未运行;运行 codiscuss local open 恢复`]
260
259
  : ['本机网站未运行;运行 codiscuss local open 启动'],
261
- stop: result.service_pid ? [`本机网站已停止;独立讨论服务仍在运行(PID ${result.service_pid}),可用 codiscuss service stop 单独停止;数据已保留`]
262
- : ['本机网站与讨论服务已停止;数据已保留,运行 codiscuss local open 重新启动'],
260
+ stop: ['本机网站与讨论服务已停止;数据已保留,运行 codiscuss local open 重新启动'],
263
261
  connect: [`已连接 ${result.connected};本机网站 ${tone.cyan(result.local_url || '')}`,
264
262
  opened ? '已在浏览器打开连接链接,请在该页面完成接入;连接链接不要转发' : `请在浏览器打开连接链接完成接入,链接不要转发:${result.url}`],
265
263
  disconnect: [`已撤销 ${result.disconnected} 的本机启动权限;正在运行的讨论需在进度看板暂停`],
@@ -43,7 +43,7 @@ const REPO_ROOT = dirname(dirname(SCRIPT));
43
43
  const SHORTCUT_NAME = 'AI CoDiscuss 讨论服务.lnk';
44
44
  const TICK_STATES = { undefined: 'running', waiting: 'paused', false: 'idle' };
45
45
  const STATUS_LABELS = { running: '运行中', paused: '已暂停', idle: '等待启动', error: '异常' };
46
- const USAGE = '用法: discussion_service.mjs start|stop|status|open|run|list|add|remove|clean|shortcut|autostart [--config 私有配置.json] [on|off]';
46
+ const USAGE = '用法: discussion_service.mjs start|stop|restart|status|open|run|list|add|remove|clean|shortcut|autostart [--config 私有配置.json] [on|off]';
47
47
  export const CONNECTION_FIELDS = ['executable', 'ipc_directory'];
48
48
 
49
49
  /** Read one atomic configuration version for editing and worker acknowledgement. */
@@ -798,6 +798,7 @@ export async function main(args = process.argv.slice(2), print = value => proces
798
798
  case 'run': return run_service(home);
799
799
  case 'start': return print(await start_service(home));
800
800
  case 'stop': return print(await stop_service(home));
801
+ case 'restart': await stop_service(home); return print(await start_service(home));
801
802
  case 'status': return print(service_status(home));
802
803
  case 'open': return print({ ...(await start_service(home)), opened: open_sites(home) });
803
804
  case 'list': return print({ home, configs: read_registry(home) });