ai_co_discuss 0.4.28 → 0.4.30
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 +9 -1
- package/package.json +1 -1
- package/runner/account_env.mjs +155 -0
- package/runner/admin_panel.mjs +591 -382
- package/runner/cli_login.mjs +307 -0
- package/runner/cli_login_agent.mjs +259 -0
- package/runner/discussion_setup.mjs +30 -16
- package/runner/launcher.mjs +99 -5
- package/runner/os_users.mjs +258 -288
- package/runner/skill_library.mjs +116 -0
- package/runner/tray.mjs +14 -2
- package/web/admin.css +1 -2
- package/web/admin.js +13 -12
- package/web/modern.js +39 -39
package/docs/runner.md
CHANGED
|
@@ -41,7 +41,15 @@ codiscuss setup
|
|
|
41
41
|
|
|
42
42
|
不选项目目录时,房间使用**草稿空间**:程序在草稿空间里为这个房间单独建一个文件夹(房间名加短编号)并作为它的项目目录,成员生成的文件存在这里,“文件”页可以浏览,成员也可以设为可写。草稿空间默认在服务目录旁(`~/.codiscuss-workspace`)。房间画的图除了作为附件随消息发出,成员对项目目录可写时、或房间在草稿空间时,还会在该目录的 `images/` 下留一份。
|
|
43
43
|
|
|
44
|
-
Windows 上在终端运行 `codiscuss setup` 时,“安装配置”一步有“桌面快捷方式”:还没有时默认勾选“创建‘共议’快捷方式”,已有时显示为“重新生成”、默认不勾(非交互运行不创建);也可随时运行 `codiscuss launcher`
|
|
44
|
+
Windows 上在终端运行 `codiscuss setup` 时,“安装配置”一步有“桌面快捷方式”:还没有时默认勾选“创建‘共议’快捷方式”,已有时显示为“重新生成”、默认不勾(非交互运行不创建);也可随时运行 `codiscuss launcher` 生成或重新生成。它会生成“共议”程序,桌面和开始菜单各有一个快捷方式,双击即可启动服务并打开网站。服务运行时任务栏右下角有共议图标:左键打开**管理面板**(也可运行 `codiscuss panel`),右键可打开共议、重启或关闭服务。管理面板的“概览”页显示本机服务状态(可启动、重启、停止)、你自己的 Claude Code / Codex / Antigravity 登录(可直接登录、切换方式、退出;Claude Code 推荐 Setup Token)、检查并安装新版本(同时更新你的房间技能)、开关“登录 Windows 时自动启动”;面板只能在这台电脑上打开。第一次需要在“设置 → 个性化 → 任务栏 → 其他系统托盘图标”里打开“共议”,图标才会常驻任务栏。
|
|
45
|
+
|
|
46
|
+
给别人开账号用这台电脑上的 AI 时,在 setup 的“安装配置”里勾选“托管管理”(或加 `--hosting`,`--no-hosting` 关闭;选择会记住),面板会多出“托管账号”页:
|
|
47
|
+
- 点“新建账号”,填账号名,默认“隔离”(给它一个独立的 Windows 用户,电脑会弹出一次管理员确认);向导会一次装好它要用的程序、房间技能、系统提示词和随包工作流,并启动它的网站,最后显示一次密码。
|
|
48
|
+
- 点某个账号进入它的页面:登录它的命令行、配置 API 密钥、从技能库勾选技能、修改它的系统提示词、启动或停止、重设密码。
|
|
49
|
+
- “技能库”里可以拖入技能文件夹或 .zip,再到账号页选择装给谁。
|
|
50
|
+
- 更新共议时,隔离账号的程序、技能会一起更新,运行中的网站会重启。
|
|
51
|
+
|
|
52
|
+
一般自用不需要打开托管管理。
|
|
45
53
|
|
|
46
54
|
### 浏览项目文件
|
|
47
55
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* The AI environment of the Windows user this runs as: one skills folder and one system prompt shared by Claude Code,
|
|
4
|
+
* Codex and Antigravity, laid out the way the computer owner's own is.
|
|
5
|
+
*
|
|
6
|
+
* skills ~/.agents/skills (Codex reads it as is); ~/.claude/skills is a junction to it; Antigravity lists it in
|
|
7
|
+
* ~/.gemini/config/skills.json.
|
|
8
|
+
* prompt ~/.codex/AGENTS.md; ~/.claude/CLAUDE.md and ~/.gemini/config/AGENTS.md are hard links to the same file.
|
|
9
|
+
*
|
|
10
|
+
* The management panel runs this as a hosted account's own Windows user, from the shared copy of this program, because
|
|
11
|
+
* that user's files are its own and the owner cannot reach them. Usage: node account_env.mjs <action> <job folder>, the job
|
|
12
|
+
* folder holding request.json; prints one JSON line.
|
|
13
|
+
* init lay out the folders, write the prompt if there is none (request.prompt), install the discussion skills
|
|
14
|
+
* (an edited copy is kept) and the shipped workflows the instance lacks (request.home, its service home).
|
|
15
|
+
* status the skills installed, the prompt, and whether the layout is complete.
|
|
16
|
+
* skills install the skill folders in <job>/skills/ (replacing a copy of the same name) and remove request.remove.
|
|
17
|
+
* prompt write request.prompt as the system prompt of all three.
|
|
18
|
+
*/
|
|
19
|
+
import { cpSync, existsSync, linkSync, lstatSync, mkdirSync, readdirSync, readFileSync, readlinkSync, renameSync, rmSync, symlinkSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
20
|
+
import { homedir } from 'node:os';
|
|
21
|
+
import { dirname, join, resolve } from 'node:path';
|
|
22
|
+
|
|
23
|
+
import { SKILLS, install_skills, install_workflows, remove_legacy_skills, shipped_workflows } from './discussion_skills.mjs';
|
|
24
|
+
import { workflow_directory } from './workflows.mjs';
|
|
25
|
+
|
|
26
|
+
const HOME = homedir();
|
|
27
|
+
const SKILLS_DIR = join(HOME, '.agents', 'skills');
|
|
28
|
+
const CLAUDE_SKILLS = join(HOME, '.claude', 'skills');
|
|
29
|
+
const AGY_SKILL_CONFIG = join(HOME, '.gemini', 'config', 'skills.json');
|
|
30
|
+
// A folder an earlier version of the panel filled with its own copies; they move into the shared folder.
|
|
31
|
+
const OLD_AGY_SKILLS = join(HOME, '.gemini', 'config', 'skills');
|
|
32
|
+
const PROMPT = join(HOME, '.codex', 'AGENTS.md');
|
|
33
|
+
const PROMPT_LINKS = [join(HOME, '.claude', 'CLAUDE.md'), join(HOME, '.gemini', 'config', 'AGENTS.md')];
|
|
34
|
+
const RECORD = 'skills-manifest.json';
|
|
35
|
+
const SKILL_NAME = /^[\w.-]{1,64}$/;
|
|
36
|
+
|
|
37
|
+
// ---- Layout ----
|
|
38
|
+
|
|
39
|
+
function is_link(path) {
|
|
40
|
+
try { return lstatSync(path).isSymbolicLink(); } catch { return false; }
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Make ~/.claude/skills a junction to the shared folder, first moving in anything a real folder there held. */
|
|
44
|
+
function link_claude_skills() {
|
|
45
|
+
if (is_link(CLAUDE_SKILLS) && resolve(readlinkSync(CLAUDE_SKILLS)).toLowerCase() === resolve(SKILLS_DIR).toLowerCase()) return;
|
|
46
|
+
if (existsSync(CLAUDE_SKILLS) && !is_link(CLAUDE_SKILLS)) {
|
|
47
|
+
for (const name of readdirSync(CLAUDE_SKILLS)) {
|
|
48
|
+
const target = join(SKILLS_DIR, name);
|
|
49
|
+
if (!existsSync(target)) renameSync(join(CLAUDE_SKILLS, name), target);
|
|
50
|
+
}
|
|
51
|
+
rmSync(CLAUDE_SKILLS, { recursive: true, force: true });
|
|
52
|
+
} else if (is_link(CLAUDE_SKILLS)) unlinkSync(CLAUDE_SKILLS);
|
|
53
|
+
mkdirSync(dirname(CLAUDE_SKILLS), { recursive: true });
|
|
54
|
+
// A junction needs no administrator rights, unlike a symbolic link.
|
|
55
|
+
symlinkSync(SKILLS_DIR, CLAUDE_SKILLS, 'junction');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** List the shared folder in Antigravity's skills.json, keeping any other entries. */
|
|
59
|
+
function list_for_agy() {
|
|
60
|
+
let config = {};
|
|
61
|
+
try { config = JSON.parse(readFileSync(AGY_SKILL_CONFIG, 'utf8')); } catch { config = {}; }
|
|
62
|
+
const entries = Array.isArray(config.entries) ? config.entries : [];
|
|
63
|
+
const path = SKILLS_DIR.replaceAll('\\', '/');
|
|
64
|
+
if (entries.some(entry => String(entry?.path || '').replaceAll('\\', '/').toLowerCase() === path.toLowerCase())) return;
|
|
65
|
+
mkdirSync(dirname(AGY_SKILL_CONFIG), { recursive: true });
|
|
66
|
+
writeFileSync(AGY_SKILL_CONFIG, `${JSON.stringify({ ...config, entries: [...entries, { path }] }, null, 2)}\n`);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Make the two other prompt files hard links to the one prompt, keeping the prompt's text. */
|
|
70
|
+
function link_prompts(fallback = '') {
|
|
71
|
+
mkdirSync(dirname(PROMPT), { recursive: true });
|
|
72
|
+
if (!existsSync(PROMPT)) writeFileSync(PROMPT, fallback);
|
|
73
|
+
for (const path of PROMPT_LINKS) {
|
|
74
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
75
|
+
if (existsSync(path)) {
|
|
76
|
+
if (lstatSync(path).ino === lstatSync(PROMPT).ino) continue;
|
|
77
|
+
unlinkSync(path);
|
|
78
|
+
}
|
|
79
|
+
linkSync(PROMPT, path);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function layout_status() {
|
|
84
|
+
const prompt_inode = existsSync(PROMPT) ? lstatSync(PROMPT).ino : -1;
|
|
85
|
+
let agy = false;
|
|
86
|
+
try { agy = JSON.parse(readFileSync(AGY_SKILL_CONFIG, 'utf8')).entries.some(entry => String(entry.path).replaceAll('\\', '/').toLowerCase() === SKILLS_DIR.replaceAll('\\', '/').toLowerCase()); } catch { agy = false; }
|
|
87
|
+
return { skills_folder: existsSync(SKILLS_DIR), claude_linked: is_link(CLAUDE_SKILLS), agy_listed: agy,
|
|
88
|
+
prompt_linked: prompt_inode !== -1 && PROMPT_LINKS.every(path => existsSync(path) && lstatSync(path).ino === prompt_inode) };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// ---- Actions ----
|
|
92
|
+
|
|
93
|
+
function init(request) {
|
|
94
|
+
mkdirSync(SKILLS_DIR, { recursive: true });
|
|
95
|
+
const record = join(request.home, RECORD);
|
|
96
|
+
// Copies an earlier version put in Antigravity's own folder go, unless someone edited them; the shared folder has them.
|
|
97
|
+
remove_legacy_skills(OLD_AGY_SKILLS, record);
|
|
98
|
+
link_claude_skills();
|
|
99
|
+
list_for_agy();
|
|
100
|
+
link_prompts(String(request.prompt || ''));
|
|
101
|
+
const results = install_skills(SKILLS_DIR, record);
|
|
102
|
+
const missing = shipped_workflows().map(item => item.name).filter(name => !existsSync(workflow_directory(request.home, name)));
|
|
103
|
+
const workflows = (missing.length ? install_workflows(request.home, missing) : []).map(({ name, status }) => ({ name, status }));
|
|
104
|
+
return { skills: results.map(({ name, status }) => ({ name, status })), workflows, layout: layout_status() };
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** A skill's one-line description, from the front matter of its SKILL.md. */
|
|
108
|
+
function describe(folder) {
|
|
109
|
+
try {
|
|
110
|
+
const text = readFileSync(join(folder, 'SKILL.md'), 'utf8');
|
|
111
|
+
return text.match(/^description:\s*(.+)$/m)?.[1].replace(/^["']|["']$/g, '').trim().slice(0, 200) || '';
|
|
112
|
+
} catch { return ''; }
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function status() {
|
|
116
|
+
const skills = existsSync(SKILLS_DIR) ? readdirSync(SKILLS_DIR, { withFileTypes: true }).filter(entry => entry.isDirectory() || entry.isSymbolicLink())
|
|
117
|
+
.map(entry => ({ name: entry.name, discussion: SKILLS.includes(entry.name), description: describe(join(SKILLS_DIR, entry.name)) })) : [];
|
|
118
|
+
return { skills, prompt: existsSync(PROMPT) ? readFileSync(PROMPT, 'utf8') : '', layout: layout_status() };
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function skills(job, request) {
|
|
122
|
+
mkdirSync(SKILLS_DIR, { recursive: true });
|
|
123
|
+
const incoming = join(job, 'skills'), installed = [], removed = [];
|
|
124
|
+
for (const name of existsSync(incoming) ? readdirSync(incoming) : []) {
|
|
125
|
+
if (!SKILL_NAME.test(name)) continue;
|
|
126
|
+
rmSync(join(SKILLS_DIR, name), { recursive: true, force: true });
|
|
127
|
+
cpSync(join(incoming, name), join(SKILLS_DIR, name), { recursive: true });
|
|
128
|
+
installed.push(name);
|
|
129
|
+
}
|
|
130
|
+
for (const name of Array.isArray(request.remove) ? request.remove : []) {
|
|
131
|
+
if (!SKILL_NAME.test(name) || !existsSync(join(SKILLS_DIR, name))) continue;
|
|
132
|
+
rmSync(join(SKILLS_DIR, name), { recursive: true, force: true });
|
|
133
|
+
removed.push(name);
|
|
134
|
+
}
|
|
135
|
+
return { installed, removed };
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function prompt(request) {
|
|
139
|
+
link_prompts();
|
|
140
|
+
// Writing in place keeps the hard links: all three names point at this one file.
|
|
141
|
+
writeFileSync(PROMPT, String(request.prompt || ''));
|
|
142
|
+
return { ok: true, layout: layout_status() };
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function main() {
|
|
146
|
+
const [action, job] = process.argv.slice(2);
|
|
147
|
+
const path = join(job, 'request.json');
|
|
148
|
+
const request = existsSync(path) ? JSON.parse(readFileSync(path, 'utf8')) : {};
|
|
149
|
+
rmSync(path, { force: true });
|
|
150
|
+
const run = { init, status, skills: () => skills(job, request), prompt }[action];
|
|
151
|
+
if (!run) throw new Error(`未知操作:${action}`);
|
|
152
|
+
process.stdout.write(`${JSON.stringify(run(request))}\n`);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
try { main(); } catch (error) { process.stdout.write(`${JSON.stringify({ error: error.message })}\n`); process.exitCode = 1; }
|