ai_co_discuss 0.4.26 → 0.4.27
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/runner.md +1 -1
- package/package.json +1 -1
- package/runner/admin_panel.mjs +9 -3
- package/runner/discussion_setup.mjs +9 -5
- package/runner/launcher.mjs +29 -9
- package/web/modern.js +1 -1
package/docs/runner.md
CHANGED
|
@@ -41,7 +41,7 @@ codiscuss setup
|
|
|
41
41
|
|
|
42
42
|
不选项目目录时,房间使用**草稿空间**:程序在草稿空间里为这个房间单独建一个文件夹(房间名加短编号)并作为它的项目目录,成员生成的文件存在这里,“文件”页可以浏览,成员也可以设为可写。草稿空间默认在服务目录旁(`~/.codiscuss-workspace`)。房间画的图除了作为附件随消息发出,成员对项目目录可写时、或房间在草稿空间时,还会在该目录的 `images/` 下留一份。
|
|
43
43
|
|
|
44
|
-
Windows
|
|
44
|
+
Windows 上在终端运行 `codiscuss setup` 时,“安装配置”一步有“桌面快捷方式”:还没有时默认勾选“创建‘共议’快捷方式”,已有时显示为“重新生成”、默认不勾(非交互运行不创建);也可随时运行 `codiscuss launcher` 生成或重新生成。它会生成“共议”程序,桌面和开始菜单各有一个快捷方式,双击即可启动服务并打开网站。服务运行时任务栏右下角有共议图标:左键打开**管理面板**,右键可打开共议、重启或关闭服务(也可运行 `codiscuss panel`)。第一次需要在“设置 → 个性化 → 任务栏 → 其他系统托盘图标”里打开“共议”,图标才会常驻任务栏。面板只在这台电脑上打开,用来管理托管的用户、为每个用户建立独立的 Windows 用户、登录 Claude Code / Codex / Antigravity 命令行,以及给用户配置 API 密钥。
|
|
45
45
|
|
|
46
46
|
### 浏览项目文件
|
|
47
47
|
|
package/package.json
CHANGED
package/runner/admin_panel.mjs
CHANGED
|
@@ -246,9 +246,11 @@ const EDGE_PATHS = [join(process.env['ProgramFiles(x86)'] || 'C:\\Program Files
|
|
|
246
246
|
/**
|
|
247
247
|
* Show the panel in a window of its own: Edge, which every Windows 10/11 has, in app mode (no address bar or tabs, its
|
|
248
248
|
* own taskbar entry), with a profile kept in the owner's service directory. A window already open is brought forward
|
|
249
|
-
* instead of opening another; without Edge the default browser opens the page.
|
|
249
|
+
* instead of opening another; without Edge the default browser opens the page. `look_first` is false when the taskbar
|
|
250
|
+
* icon asks: it has just looked for the window itself, and looking again here delays the new window by a second.
|
|
250
251
|
*/
|
|
251
|
-
function open_panel_window(data, url) {
|
|
252
|
+
function open_panel_window(data, url, look_first = true) {
|
|
253
|
+
if (!look_first) return launch_panel_window(data, url);
|
|
252
254
|
// The title goes in a script file with a byte-order mark: on a command line Windows would pass it in the ANSI code page,
|
|
253
255
|
// the Chinese title would no longer match, and every call would open another window.
|
|
254
256
|
const script = join(tmpdir(), `codiscuss-focus-${process.pid}.ps1`);
|
|
@@ -256,6 +258,10 @@ function open_panel_window(data, url) {
|
|
|
256
258
|
const focused = spawnSync('powershell.exe', ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', script], { encoding: 'utf8', windowsHide: true, timeout: 10_000 });
|
|
257
259
|
rmSync(script, { force: true });
|
|
258
260
|
if (focused.stdout?.trim() === 'focused') return;
|
|
261
|
+
launch_panel_window(data, url);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function launch_panel_window(data, url) {
|
|
259
265
|
const edge = EDGE_PATHS.find(path => existsSync(path));
|
|
260
266
|
if (!edge) return open_browser(url);
|
|
261
267
|
spawn(edge, [`--app=${url}`, `--user-data-dir=${join(data, 'panel-window')}`, `--window-size=${WINDOW_SIZE}`, '--no-first-run', '--no-default-browser-check', '--lang=zh-CN', '--disable-features=Translate,msTranslate'],
|
|
@@ -302,7 +308,7 @@ function run_panel(data, port) {
|
|
|
302
308
|
});
|
|
303
309
|
const rendered = join(data, 'launcher', 'codiscuss.ico');
|
|
304
310
|
const tray = show_tray({ title: '共议 · 管理面板', icon_path: existsSync(rendered) ? rendered : '', window_title: WINDOW_TITLE, host: join(data, 'launcher', '共议.exe'), on_action: action => {
|
|
305
|
-
if (action === 'open') open_panel_window(data, panel_url(state));
|
|
311
|
+
if (action === 'open') open_panel_window(data, panel_url(state), false);
|
|
306
312
|
if (action === 'site') open_browser(site_url(data));
|
|
307
313
|
if (action === 'restart') run_owner_service(data, 'stop').then(() => run_owner_service(data, 'start')).catch(() => {});
|
|
308
314
|
if (action === 'stop') run_owner_service(data, 'stop').catch(() => {}).finally(shutdown);
|
|
@@ -11,7 +11,7 @@ import { launch_settings, save_launch_settings } from './discussion_launch.mjs';
|
|
|
11
11
|
import { assert_shared_home, service_home } from './discussion_service.mjs';
|
|
12
12
|
import { SKILLS, install_skills, install_workflows, remove_legacy_skills, shipped_workflows } from './discussion_skills.mjs';
|
|
13
13
|
import { ask, checkbox_prompt, intro, outro, pad, short_path, spinner, step, styled, text_width, tone, tree_prompt } from './discussion_tui.mjs';
|
|
14
|
-
import { install_launcher,
|
|
14
|
+
import { install_launcher, launcher_installed } from './launcher.mjs';
|
|
15
15
|
export { checkbox_prompt } from './discussion_tui.mjs';
|
|
16
16
|
|
|
17
17
|
const ROOT = fileURLToPath(new URL('../', import.meta.url));
|
|
@@ -168,23 +168,27 @@ async function selected_clients(options, detected) {
|
|
|
168
168
|
/**
|
|
169
169
|
* The install settings of this run: which shipped workflows to install, and whether to build the 共议 launcher.
|
|
170
170
|
* Workflows: nothing by default; an interactive run offers them unchecked, a non-interactive one installs them only with
|
|
171
|
-
* --workflows. Launcher: offered
|
|
172
|
-
* a non-interactive run never builds it (`codiscuss launcher`
|
|
171
|
+
* --workflows. Launcher: always offered to an interactive run on Windows, checked while the exe or its desktop shortcut
|
|
172
|
+
* is missing and unchecked (to rebuild) once both exist; a non-interactive run never builds it (`codiscuss launcher`
|
|
173
|
+
* does). Never remembered between runs.
|
|
173
174
|
*/
|
|
174
175
|
async function install_choices(options, home) {
|
|
175
176
|
const shipped = shipped_workflows();
|
|
176
177
|
const offer_workflows = options.workflows === undefined && shipped.length;
|
|
177
|
-
const offer_launcher = process.platform === 'win32'
|
|
178
|
+
const offer_launcher = process.platform === 'win32';
|
|
178
179
|
const defaults = { workflows: options.workflows ? shipped.map(item => item.name) : [], launcher: false };
|
|
179
180
|
// The tree needs key-by-key input; a terminal that cannot give it keeps the default.
|
|
180
181
|
if (options.yes || !process.stdin.isTTY || typeof process.stdin.setRawMode !== 'function' || (!offer_workflows && !offer_launcher)) return defaults;
|
|
182
|
+
const installed = offer_launcher && launcher_installed(home);
|
|
181
183
|
const groups = [];
|
|
182
184
|
if (offer_workflows) groups.push({ label: '随包工作流',
|
|
183
185
|
description: '把安装包自带的工作流装进本机工作流库;已有同名的覆盖为最新版,原来那份先备份到服务目录 backups/workflows/',
|
|
184
186
|
items: shipped.map(item => ({ label: item.label, hint: item.name, description: item.description, checked: false })) });
|
|
185
187
|
if (offer_launcher) groups.push({ label: '桌面快捷方式',
|
|
186
188
|
description: '在桌面与开始菜单放一个“共议”,双击启动网站与讨论服务;以后也可运行 codiscuss launcher 生成',
|
|
187
|
-
items: [
|
|
189
|
+
items: [installed
|
|
190
|
+
? { label: '重新生成“共议”快捷方式', hint: 'launcher', description: '已经有了;Node 或共议的安装位置变了、双击打不开时再勾选', checked: false }
|
|
191
|
+
: { label: '创建“共议”快捷方式', hint: 'launcher', description: '用本机自带的 C# 编译器生成 共议.exe,不下载任何东西', checked: true }] });
|
|
188
192
|
const picked = await tree_prompt('安装配置', groups);
|
|
189
193
|
return {
|
|
190
194
|
workflows: offer_workflows ? shipped.filter((_, index) => picked[0][index]).map(item => item.name) : defaults.workflows,
|
package/runner/launcher.mjs
CHANGED
|
@@ -82,6 +82,11 @@ static class Tray {
|
|
|
82
82
|
[DllImport("user32.dll")] static extern bool IsIconic(IntPtr window);
|
|
83
83
|
[DllImport("user32.dll")] static extern bool ShowWindow(IntPtr window, int command);
|
|
84
84
|
[DllImport("user32.dll")] static extern bool SetForegroundWindow(IntPtr window);
|
|
85
|
+
[DllImport("user32.dll")] static extern IntPtr GetForegroundWindow();
|
|
86
|
+
[DllImport("user32.dll")] static extern bool BringWindowToTop(IntPtr window);
|
|
87
|
+
[DllImport("user32.dll")] static extern uint GetWindowThreadProcessId(IntPtr window, IntPtr process);
|
|
88
|
+
[DllImport("user32.dll")] static extern bool AttachThreadInput(uint from, uint to, bool attach);
|
|
89
|
+
[DllImport("kernel32.dll")] static extern uint GetCurrentThreadId();
|
|
85
90
|
[DllImport("user32.dll")] static extern bool SetProcessDPIAware();
|
|
86
91
|
[DllImport("user32.dll")] static extern bool SetProcessDpiAwarenessContext(IntPtr context);
|
|
87
92
|
|
|
@@ -105,16 +110,23 @@ static class Tray {
|
|
|
105
110
|
return found;
|
|
106
111
|
}
|
|
107
112
|
|
|
108
|
-
// Bring
|
|
109
|
-
//
|
|
113
|
+
// Bring a window forward. Windows may refuse SetForegroundWindow to a taskbar icon's program even right after its click,
|
|
114
|
+
// leaving the window behind the others; sharing input with the program in front (the taskbar) makes it allowed.
|
|
115
|
+
static void Raise(IntPtr window) {
|
|
116
|
+
ShowWindow(window, IsIconic(window) ? 9 : 5);
|
|
117
|
+
uint mine = GetCurrentThreadId(), front = GetWindowThreadProcessId(GetForegroundWindow(), IntPtr.Zero);
|
|
118
|
+
bool attached = front != 0 && front != mine && AttachThreadInput(front, mine, true);
|
|
119
|
+
BringWindowToTop(window);
|
|
120
|
+
SetForegroundWindow(window);
|
|
121
|
+
if (attached) AttachThreadInput(front, mine, false);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Bring the panel window forward, or ask for one; a new window takes a few seconds to appear, so a click meanwhile does
|
|
125
|
+
// not ask again.
|
|
110
126
|
static void OpenPanel() {
|
|
111
127
|
List<IntPtr> windows = Windows();
|
|
112
|
-
if (windows.Count > 0) {
|
|
113
|
-
|
|
114
|
-
SetForegroundWindow(windows[0]);
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
if ((DateTime.Now - asked).TotalSeconds < 10) return;
|
|
128
|
+
if (windows.Count > 0) { Raise(windows[0]); return; }
|
|
129
|
+
if ((DateTime.Now - asked).TotalSeconds < 5) return;
|
|
118
130
|
asked = DateTime.Now;
|
|
119
131
|
Say("open");
|
|
120
132
|
}
|
|
@@ -385,11 +397,19 @@ function write_shortcut(folder, exe, icon) {
|
|
|
385
397
|
return result.stdout.trim();
|
|
386
398
|
}
|
|
387
399
|
|
|
388
|
-
/** Where the launcher of a service home lives
|
|
400
|
+
/** Where the launcher of a service home lives. */
|
|
389
401
|
export function launcher_path(home = join(homedir(), '.codiscuss')) {
|
|
390
402
|
return join(home, 'launcher', EXE_NAME);
|
|
391
403
|
}
|
|
392
404
|
|
|
405
|
+
/** Whether the launcher and its desktop shortcut both exist; the desktop is asked of Windows, as it may be redirected. */
|
|
406
|
+
export function launcher_installed(home = join(homedir(), '.codiscuss')) {
|
|
407
|
+
if (!existsSync(launcher_path(home))) return false;
|
|
408
|
+
const desktop = spawnSync('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command',
|
|
409
|
+
"[Console]::OutputEncoding=[Text.Encoding]::UTF8; [Environment]::GetFolderPath('Desktop')"], { encoding: 'utf8', windowsHide: true }).stdout?.trim();
|
|
410
|
+
return Boolean(desktop) && existsSync(join(desktop, SHORTCUT_NAME));
|
|
411
|
+
}
|
|
412
|
+
|
|
393
413
|
/**
|
|
394
414
|
* Build 共议.exe and its shortcuts.
|
|
395
415
|
*
|