@waq666/pneuma 0.8.0 → 0.8.1
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/README.md +10 -5
- package/lib/adapter/transcript.js +12 -1
- package/lib/app/Composer.js +14 -2
- package/lib/contract/plugin.d.ts +8 -0
- package/lib/contract/session.d.ts +8 -0
- package/lib/contract/snapshot.d.ts +5 -0
- package/lib/core/agent-roles.js +3 -2
- package/lib/core/commands-completion.d.ts +17 -0
- package/lib/core/commands-completion.js +56 -3
- package/lib/core/compact.d.ts +36 -6
- package/lib/core/compact.js +89 -17
- package/lib/core/events.d.ts +5 -0
- package/lib/core/git-info.d.ts +127 -15
- package/lib/core/git-info.js +307 -32
- package/lib/core/host-methods.d.ts +1 -1
- package/lib/core/host-methods.js +1 -0
- package/lib/core/llm.d.ts +9 -0
- package/lib/core/llm.js +1 -0
- package/lib/core/loop.js +8 -2
- package/lib/core/permission-scope.d.ts +12 -1
- package/lib/core/permission-scope.js +26 -1
- package/lib/core/presets.js +30 -2
- package/lib/core/session.d.ts +48 -7
- package/lib/core/session.js +263 -9
- package/lib/core/ui-methods.d.ts +1 -1
- package/lib/core/ui-methods.js +6 -0
- package/lib/plugins/agent.js +47 -6
- package/lib/plugins/commands.js +118 -14
- package/lib/plugins/compact.d.ts +2 -2
- package/lib/plugins/compact.js +150 -22
- package/lib/plugins/git.js +15 -1
- package/lib/plugins/goal.js +8 -4
- package/lib/plugins/host-stdio.js +11 -1
- package/lib/plugins/microcompact.d.ts +3 -0
- package/lib/plugins/microcompact.js +26 -0
- package/lib/plugins/remote.js +7 -1
- package/lib/plugins/runtime.js +5 -0
- package/lib/plugins/session.js +81 -7
- package/lib/plugins/skills.js +16 -0
- package/lib/plugins/subagent.js +47 -11
- package/lib/services/types.d.ts +66 -8
- package/lib/ui/assets/{app-MhfBFsp-.js → app-B-Jx5dnh.js} +60 -59
- package/lib/ui/assets/{chunk-Cq7xGE-D.js → chunk-Bfdlo8Me.js} +1 -1
- package/lib/ui/assets/{chunk-CA5f1pGf.js → chunk-DGX-i4eb.js} +1 -1
- package/lib/ui/assets/index.html +2 -2
- package/lib/ui/assets/style-WzxwEPaE.css +1 -0
- package/lib/ui/plugins/actions/bundle.json +2 -2
- package/lib/ui/plugins/ask/bundle.json +2 -2
- package/lib/ui/plugins/browser/bundle.json +2 -2
- package/lib/ui/plugins/composer/bundle.json +2 -2
- package/lib/ui/plugins/composer/client.js +57 -4
- package/lib/ui/plugins/files/bundle.json +2 -2
- package/lib/ui/plugins/manifest.json +1 -1
- package/lib/ui/plugins/palette/bundle.json +2 -2
- package/lib/ui/plugins/plugins/bundle.json +2 -2
- package/lib/ui/plugins/preview/bundle.json +2 -2
- package/lib/ui/plugins/prompt/bundle.json +2 -2
- package/lib/ui/plugins/sessions/bundle.json +2 -2
- package/lib/ui/plugins/sessions/client.js +41 -13
- package/lib/ui/plugins/settings/bundle.json +2 -2
- package/lib/ui/plugins/skills/bundle.json +2 -2
- package/lib/ui/plugins/status/bundle.json +2 -2
- package/lib/ui/plugins/status/client.js +162 -9
- package/lib/ui/plugins/statusbar/bundle.json +2 -2
- package/lib/ui/plugins/tasks/bundle.json +2 -2
- package/lib/ui/plugins/team/bundle.json +2 -2
- package/lib/ui/plugins/terminal/bundle.json +2 -2
- package/lib/ui/plugins/trace/bundle.json +2 -2
- package/lib/ui/plugins/transcript/bundle.json +2 -2
- package/lib/ui/plugins/transcript/client.js +156 -96
- package/lib/ui/sdk/@dsc/ui/package.json +1 -1
- package/lib/ui/sdk/@dsc/ui-core/package.json +1 -1
- package/lib/ui/sdk/@dsc/ui-dockkit/package.json +1 -1
- package/lib/ui/sdk/@dsc/ui-layout/package.json +1 -1
- package/lib/ui/sdk/@dsc/ui-primitives/icons.d.ts +13 -2
- package/lib/ui/sdk/@dsc/ui-primitives/image-lightbox.d.ts +21 -0
- package/lib/ui/sdk/@dsc/ui-primitives/index.d.ts +3 -0
- package/lib/ui/sdk/@dsc/ui-primitives/package.json +1 -1
- package/lib/ui/sdk/@dsc/ui-primitives/review-findings-card.d.ts +25 -0
- package/lib/ui/sdk/@dsc/ui-primitives/review-findings.d.ts +64 -0
- package/lib/ui/sdk/@dsc/ui-renderer/package.json +1 -1
- package/lib/ui/sdk/@dsc/ui-slots/package.json +1 -1
- package/package.json +1 -1
- package/lib/ui/assets/style-CIJVQKkj.css +0 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { applyMicrocompactPlan, DEFAULT_KEEP_RECENT_TOOL_RESULTS, DEFAULT_MIN_SAVE_TOKENS, planMicrocompact, planWorthApplying, roundKeyOf, } from '../core/microcompact.js';
|
|
2
|
+
import { estimateTokens } from '../core/compact.js';
|
|
2
3
|
import { resolvePluginConfig, writePluginConfig } from '../core/plugin-registry.js';
|
|
3
4
|
import { clampInt as clamp } from '../core/clamp.js';
|
|
4
5
|
/** 配置键(`~/.dsc/plugins.json` 条目树里 `file` 等于这个名字那一项的 `config`)。 */
|
|
@@ -90,6 +91,30 @@ export const microcompactPlugin = {
|
|
|
90
91
|
}
|
|
91
92
|
return applyMicrocompactPlan(messages, plan);
|
|
92
93
|
}, { order: PROJECTION_ORDER });
|
|
94
|
+
/**
|
|
95
|
+
* 投影估算服务(2026-11-02):把旧工具结果换成占位符之后,整段消息的估算 token 数。
|
|
96
|
+
* 只算不落盘,用的是本插件现读的 config 与同一套 plan / apply,跟真正发请求时一致。
|
|
97
|
+
*
|
|
98
|
+
* 失败/被拒的 tool_call_id 记在会话旁路(`Session.toolErrors`),这个接口只收消息、
|
|
99
|
+
* 拿不到会话,所以按空集算:那类结果本来就该保留,少清几条只会让估算偏保守
|
|
100
|
+
* (偏保守 = 更容易判定「装不下」= 老老实实去压摘要,不会误判成熟)。
|
|
101
|
+
*/
|
|
102
|
+
const service = {
|
|
103
|
+
projectedTokens(messages) {
|
|
104
|
+
// 关掉时没有投影,发出去的就是原文
|
|
105
|
+
if (!config.enabled)
|
|
106
|
+
return estimateTokens(messages);
|
|
107
|
+
const plan = planMicrocompact(messages, {
|
|
108
|
+
keepRecent: config.keepRecent,
|
|
109
|
+
minSaveTokens: config.minSaveTokens,
|
|
110
|
+
});
|
|
111
|
+
// 门槛没达到时投影也不生效(见 planWorthApplying 的注释),估算按原文算
|
|
112
|
+
if (!planWorthApplying(messages, plan, config.minFreePercent))
|
|
113
|
+
return estimateTokens(messages);
|
|
114
|
+
return estimateTokens(applyMicrocompactPlan(messages, plan));
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
const offService = ctx.provide('microcompact', service);
|
|
93
118
|
// ── 设置分区 ─────────────────────────────────────────────────────────────
|
|
94
119
|
const fields = [
|
|
95
120
|
{
|
|
@@ -184,6 +209,7 @@ export const microcompactPlugin = {
|
|
|
184
209
|
};
|
|
185
210
|
const offSection = ctx.settings.registerSection(section);
|
|
186
211
|
return () => {
|
|
212
|
+
offService();
|
|
187
213
|
offProjection();
|
|
188
214
|
offSection();
|
|
189
215
|
};
|
package/lib/plugins/remote.js
CHANGED
|
@@ -156,6 +156,8 @@ export function createRemoteServer(deps) {
|
|
|
156
156
|
const hub = new RemoteFrameHub();
|
|
157
157
|
let frameTimer = null;
|
|
158
158
|
let framePending = false;
|
|
159
|
+
/** 上一帧推出去的时刻(0 = 还没推过):节流按 leading-edge 走,见 scheduleFrame。 */
|
|
160
|
+
let lastFrameAt = 0;
|
|
159
161
|
/**
|
|
160
162
|
* 一条连接都没有的时候发生的会话变化:帧流那时不前进(没人看,白算),
|
|
161
163
|
* 所以下一条连接补完缓冲里的帧之后,必须再补一帧全量把这段时间的变化对上。
|
|
@@ -200,17 +202,21 @@ export function createRemoteServer(deps) {
|
|
|
200
202
|
framePending = true;
|
|
201
203
|
if (frameTimer !== null)
|
|
202
204
|
return;
|
|
205
|
+
// leading-edge(2026-11-03,与 host-stdio 同一口径):距上一帧已经超过窗口就立刻推,
|
|
206
|
+
// 窗口内的连续变化才合并。旧写法每次都要等满一个窗口,用户点完会话要干等 60–80ms。
|
|
207
|
+
const wait = Math.max(0, deps.throttleMs - (Date.now() - lastFrameAt));
|
|
203
208
|
frameTimer = setTimeout(() => {
|
|
204
209
|
frameTimer = null;
|
|
205
210
|
if (!framePending)
|
|
206
211
|
return;
|
|
207
212
|
framePending = false;
|
|
213
|
+
lastFrameAt = Date.now();
|
|
208
214
|
if (sockets.size === 0) {
|
|
209
215
|
missedWhileIdle = true;
|
|
210
216
|
return;
|
|
211
217
|
}
|
|
212
218
|
emitFrame(false);
|
|
213
|
-
},
|
|
219
|
+
}, wait);
|
|
214
220
|
};
|
|
215
221
|
const stopFrames = () => {
|
|
216
222
|
if (frameTimer !== null)
|
package/lib/plugins/runtime.js
CHANGED
|
@@ -311,6 +311,8 @@ export const runtimePlugin = {
|
|
|
311
311
|
args: spec.args,
|
|
312
312
|
description: spec.description,
|
|
313
313
|
...(spec.label === undefined ? {} : { label: spec.label }),
|
|
314
|
+
// 要收输入的命令(/review):壳据此把回车改成「先补全、不执行」。
|
|
315
|
+
...(spec.input === undefined ? {} : { input: spec.input }),
|
|
314
316
|
duringTask: spec.duringTask ?? 'allow',
|
|
315
317
|
}));
|
|
316
318
|
},
|
|
@@ -450,6 +452,9 @@ export const runtimePlugin = {
|
|
|
450
452
|
forkSession(path, index) {
|
|
451
453
|
return Promise.resolve(ctx.session.fork(path, index));
|
|
452
454
|
},
|
|
455
|
+
rewindSession(path, keep, text) {
|
|
456
|
+
return Promise.resolve(ctx.session.rewind(path, keep, text));
|
|
457
|
+
},
|
|
453
458
|
getUiPrefs() {
|
|
454
459
|
return ctx.settings.prefs().ui;
|
|
455
460
|
},
|
package/lib/plugins/session.js
CHANGED
|
@@ -104,8 +104,21 @@ export const sessionPlugin = {
|
|
|
104
104
|
...listSessions().map((item) => toSummary(item)),
|
|
105
105
|
...listArchivedSessions().map((item) => toSummary(item, item.archivedAt ?? item.updatedAt)),
|
|
106
106
|
];
|
|
107
|
-
//
|
|
108
|
-
//
|
|
107
|
+
// 还没发过消息的当前会话:给它一行看得见的回执(点「新会话」不该像没反应)。
|
|
108
|
+
//
|
|
109
|
+
// 只补**当前**这一条:它一旦不是当前会话就既没内容也没稳定身份,列表里不该留着
|
|
110
|
+
// ——这正是 2026-10-29 那次「点几次堆几行」要的结果。当时删的是“补行”,真正
|
|
111
|
+
// 的病灶(每次新建都在磁盘上建空壳文件)已经由 `Session` 的 pendingState 修掉
|
|
112
|
+
// (`src/core/session.ts` 的 write()),所以这行可以回来了。
|
|
113
|
+
if (!session.persisted && !listed.some((item) => item.id === session.filePath)) {
|
|
114
|
+
listed.unshift({
|
|
115
|
+
id: session.filePath,
|
|
116
|
+
cwd: session.meta.cwd,
|
|
117
|
+
createdAt: session.meta.createdAt,
|
|
118
|
+
updatedAt: session.meta.createdAt,
|
|
119
|
+
unsaved: true,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
109
122
|
sessions = listed;
|
|
110
123
|
}
|
|
111
124
|
catch (error) {
|
|
@@ -183,10 +196,16 @@ export const sessionPlugin = {
|
|
|
183
196
|
return { ok: false, error: errText(error) };
|
|
184
197
|
}
|
|
185
198
|
},
|
|
186
|
-
purge(paths) {
|
|
199
|
+
async purge(paths) {
|
|
187
200
|
if (paths.some((path) => path === session.filePath)) {
|
|
188
201
|
return { ok: false, error: '当前打开的会话不能删除,先切到别的会话' };
|
|
189
202
|
}
|
|
203
|
+
// 常驻 agent 先收摊再挪文件(与归档同一套,0.6.48 的口径):切走没多久的会话还在
|
|
204
|
+
// 「空闲保留」的名册里(见 agent.ts 的 rememberIdle),它攥着这个 jsonl 的写入流,
|
|
205
|
+
// 直接 rename 在 Windows 上是原生 EPERM。
|
|
206
|
+
const agent = ctx.get('agent');
|
|
207
|
+
for (const path of paths)
|
|
208
|
+
await agent?.stop(path);
|
|
190
209
|
try {
|
|
191
210
|
for (const path of paths)
|
|
192
211
|
purgeSession(path);
|
|
@@ -234,13 +253,67 @@ export const sessionPlugin = {
|
|
|
234
253
|
return { ok: false, error: errText(error) };
|
|
235
254
|
}
|
|
236
255
|
},
|
|
256
|
+
rewind(path, keep, text) {
|
|
257
|
+
// 只认当前会话:截断后的历史要由**常驻的那个 agent** 接着用,别的会话没有承接者
|
|
258
|
+
// (硬截了文件却没人重放,等于把界面和模型看到的东西拆成两半)。
|
|
259
|
+
if (path !== session.filePath) {
|
|
260
|
+
return { ok: false, error: '只能改当前会话里的消息:先切到那条会话再编辑' };
|
|
261
|
+
}
|
|
262
|
+
// 回合还在跑:这一轮的工具调用与结果正按老历史往下写,此时截断会让它在半截
|
|
263
|
+
// 历史上继续跑(工具结果对不上前面的调用)。界面那颗钮本来就是灰的,这里再挡一道。
|
|
264
|
+
if (ctx.get('agent')?.isRunning(path) === true) {
|
|
265
|
+
return { ok: false, error: '这一轮还在跑:等它结束或打断之后再改' };
|
|
266
|
+
}
|
|
267
|
+
const resident = ctx.get('agent')?.sessionFor(path);
|
|
268
|
+
try {
|
|
269
|
+
if (resident !== undefined) {
|
|
270
|
+
if (!resident.rewindToUser(keep))
|
|
271
|
+
return { ok: false, error: '这条消息已经不在会话里了(可能刚改过),刷新后再试' };
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
// 当前会话却没有常驻 agent(极端情形:agent 刚在别处收摊了)。拿一份临时副本
|
|
275
|
+
// 改完就关,日志照样落盘,界面这边由下面的 session-open 重新读回。
|
|
276
|
+
const temp = Session.load(path);
|
|
277
|
+
try {
|
|
278
|
+
if (!temp.rewindToUser(keep))
|
|
279
|
+
return { ok: false, error: '这条消息已经不在会话里了(可能刚改过),刷新后再试' };
|
|
280
|
+
}
|
|
281
|
+
finally {
|
|
282
|
+
temp.close();
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
catch (error) {
|
|
287
|
+
return { ok: false, error: errText(error) };
|
|
288
|
+
}
|
|
289
|
+
// 改的是第一条消息(keep = 0)时,侧栏标题得跟着换:标题的展示链是
|
|
290
|
+
// 用户改名 → 自动生成 → 首条用户消息,而自动生成那份还记着被作废的那句话。
|
|
291
|
+
// 只清自动生成的(用户手动改过的名字不动),下一条重扫就会按新的首条消息重算。
|
|
292
|
+
if (keep === 0) {
|
|
293
|
+
// 改过的那句话就是新的「第一句」:直接拿它当自动标题(与列表从首条用户消息
|
|
294
|
+
// 派生同一条口径:压成一行的前 60 字)。界面没给文字时退回「清掉自动标题」,
|
|
295
|
+
// 下一次成功起标题会覆盖它。
|
|
296
|
+
const derived = text === undefined ? '' : text.replace(/\s+/g, ' ').trim().slice(0, 60);
|
|
297
|
+
try {
|
|
298
|
+
patchSessionMeta(uuidOf(path), { autoTitle: derived === '' ? null : derived });
|
|
299
|
+
}
|
|
300
|
+
catch {
|
|
301
|
+
// 写不进只是标题暂时旧着,不值得让整次编辑失败
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
// 转录层按截断后的历史重建:与「打开会话」走同一条事件,`open()` 的那条
|
|
305
|
+
// 「已经在看这条就 no-op」短路在这里不适用(我们就是要它重放一遍)。
|
|
306
|
+
ctx.emit('dsc/session-open', { session, filePath: path });
|
|
307
|
+
ctx.emit('dsc/changed');
|
|
308
|
+
return { ok: true };
|
|
309
|
+
},
|
|
237
310
|
};
|
|
238
311
|
/**
|
|
239
312
|
* 第一条消息落地后把新会话补进列表缓存。
|
|
240
313
|
*
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
*
|
|
314
|
+
* 为什么需要:新会话在说话之前不落盘,列表里那一行是宿主动态补的临时行(`unsaved`),
|
|
315
|
+
* 「文件刚出现」与「列表缓存下一次重扫」之间有一段落差——那段里侧栏没有这条会话,
|
|
316
|
+
* 用户会以为自己的会话没保存。标题生成那条路(session-title.ts)
|
|
244
317
|
* 也会 refresh,但要等一次模型请求,失败就永远补不上。
|
|
245
318
|
*
|
|
246
319
|
* 只认「当前会话第一次真正落盘」这一种情形:命中缓存直接返回,其它会话的
|
|
@@ -248,7 +321,8 @@ export const sessionPlugin = {
|
|
|
248
321
|
*/
|
|
249
322
|
let refreshedFor = null;
|
|
250
323
|
ctx.on('dsc/changed', () => {
|
|
251
|
-
|
|
324
|
+
// 临时行(unsaved)不算“已经在列表里”:第一句话发出去之后正是要把它换成扫盘的真行。
|
|
325
|
+
if (sessions.some((item) => item.id === session.filePath && item.unsaved !== true))
|
|
252
326
|
return;
|
|
253
327
|
if (!existsSync(session.filePath))
|
|
254
328
|
return;
|
package/lib/plugins/skills.js
CHANGED
|
@@ -48,6 +48,14 @@ export const skillsPlugin = {
|
|
|
48
48
|
let catalog = '';
|
|
49
49
|
let inFlight = null;
|
|
50
50
|
let staleAgain = false;
|
|
51
|
+
/**
|
|
52
|
+
* 上一次重扫时的工作目录(null = 还没扫过)。
|
|
53
|
+
*
|
|
54
|
+
* 「切会话」是重扫技能目录的唯一日常触发点,而多数切换发生在同一个工作区里——
|
|
55
|
+
* 那种切换下技能目录、定制目录、停用清单一样都没变,重扫只是白读一遍磁盘
|
|
56
|
+
* (2026-11-03 实测:每次切换 8–30ms,且拖慢这次切换的回执)。
|
|
57
|
+
*/
|
|
58
|
+
let scannedCwd = null;
|
|
51
59
|
const commandDisposers = new Map();
|
|
52
60
|
const cwd = () => ctx.session.current().meta.cwd;
|
|
53
61
|
/** 扫全部内置目录 + 提供方缓存,重名按 rank 裁决,按名字排序。 */
|
|
@@ -350,12 +358,20 @@ export const skillsPlugin = {
|
|
|
350
358
|
ui.notice(`技能(${items.length} 个,主目录 ${DSC_SKILLS_DIR})\n${lines.join('\n')}`);
|
|
351
359
|
});
|
|
352
360
|
ctx.on('dsc/session-open', () => {
|
|
361
|
+
// 同一个工作区内换会话:技能目录(含工作区里的定制目录)一个字节都没变,重扫一遍
|
|
362
|
+
// 纯属白花——实测每次切会话要耗 8–30ms 的 stat 与文件读(2026-11-03 的量具)。
|
|
363
|
+
// 目录真变了才重扫;技能文件本身的改动走 `dsc/skills-changed` 那条,不受这里影响。
|
|
364
|
+
const next = cwd();
|
|
365
|
+
if (next === scannedCwd)
|
|
366
|
+
return;
|
|
367
|
+
scannedCwd = next;
|
|
353
368
|
void refresh();
|
|
354
369
|
});
|
|
355
370
|
ctx.on('dsc/skills-changed', () => {
|
|
356
371
|
void refresh();
|
|
357
372
|
});
|
|
358
373
|
ctx.provide('skills', service);
|
|
374
|
+
scannedCwd = cwd();
|
|
359
375
|
void refresh();
|
|
360
376
|
},
|
|
361
377
|
};
|
package/lib/plugins/subagent.js
CHANGED
|
@@ -32,7 +32,7 @@ import { redact } from '../core/secrets.js';
|
|
|
32
32
|
import { argsSummary } from '../core/tools.js';
|
|
33
33
|
import { ToolGuardRegistry, toolApprovalGuard } from '../core/tool-guards.js';
|
|
34
34
|
import { inboxAppend, REVIEW_FINDINGS_OPEN, TEAMMATE_REPORT_OPEN } from '../core/team-board.js';
|
|
35
|
-
import {
|
|
35
|
+
import { reviewTaskText, ReviewJournal, REVIEW_CANCELED_TEXT } from '../core/git-info.js';
|
|
36
36
|
import { clampInt as clamp } from '../core/clamp.js';
|
|
37
37
|
const CONFIG_KEY = 'subagent';
|
|
38
38
|
const DEFAULTS = {
|
|
@@ -656,11 +656,19 @@ ${body}
|
|
|
656
656
|
},
|
|
657
657
|
};
|
|
658
658
|
ctx.provide('team', teamService);
|
|
659
|
-
// ── 只读代码审查通道(
|
|
659
|
+
// ── 只读代码审查通道(T45)─────────────────────────────────────────────
|
|
660
660
|
// /review 的升级路径:派一个工牌被强制压到只读交集的队友(工具 = read/glob/grep,
|
|
661
661
|
// 审批 = forbid,与角色文件怎么改无关),后台审查,findings 以 <review-findings>
|
|
662
662
|
// 包裹写回发起会话——渲染层解析成卡片,主会话不吃模型轮。
|
|
663
|
+
//
|
|
664
|
+
// 完整 diff 由 core/git-info 的 collectReviewScope 落盘,任务书里只给路径与读法:
|
|
665
|
+
// 审查队友有 read,可以按 offset/limit 分批读完,不需要把 diff 截断塞进描述。
|
|
663
666
|
const READONLY_TOOLS = ['read', 'glob', 'grep'];
|
|
667
|
+
/**
|
|
668
|
+
* 审查记录账本:内存记「本会话有没有在跑的审查」,磁盘留最近一次的状态与结论。
|
|
669
|
+
* 数据目录取 settings.about().home(就是 DSC_HOME),重启后 /review-status 仍读得到。
|
|
670
|
+
*/
|
|
671
|
+
const reviewJournal = new ReviewJournal(ctx.settings.about().home);
|
|
664
672
|
const spawnReviewer = (request) => {
|
|
665
673
|
const parentSession = ctx.session.current();
|
|
666
674
|
const working = busyFor(parentSession.meta.id);
|
|
@@ -679,33 +687,61 @@ ${body}
|
|
|
679
687
|
const teammate = startTeammate({
|
|
680
688
|
name: uniqueName('reviewer'),
|
|
681
689
|
role,
|
|
682
|
-
task:
|
|
690
|
+
task: reviewTaskText(request.scope, request.focus),
|
|
683
691
|
caller: { name: LEAD, depth: 0, background: true },
|
|
684
692
|
background: true,
|
|
685
693
|
seed: null,
|
|
686
694
|
parentSession,
|
|
687
695
|
});
|
|
696
|
+
// 先登记再等收工:这中间用户可能已经 /review-status 或 /review-cancel
|
|
697
|
+
reviewJournal.begin(parentSession.meta.id, {
|
|
698
|
+
target: request.scope.label,
|
|
699
|
+
handle: teammate.name,
|
|
700
|
+
startedAt: teammate.startedAt,
|
|
701
|
+
});
|
|
688
702
|
void waitForIdle(teammate).then(() => deliverReview(teammate));
|
|
689
703
|
return { ok: true, name: teammate.name };
|
|
690
704
|
};
|
|
691
705
|
/** 审查收工:findings(或失败原因)写进发起会话,渲染层认 <review-findings> 标记出卡。 */
|
|
692
706
|
const deliverReview = (teammate) => {
|
|
707
|
+
const sessionId = teammate.parentSession.meta.id;
|
|
708
|
+
// 取消过的那次:记录与上屏都用同一句实话,别让「已停止」把「被取消」盖掉
|
|
709
|
+
const wasCancelled = reviewJournal.wasCancelled(sessionId);
|
|
693
710
|
const state = teammate.state === 'idle' ? '已完成' : teammate.state === 'stopped' ? '已停止' : '已失败';
|
|
694
|
-
const body =
|
|
695
|
-
?
|
|
696
|
-
: teammate.state === '
|
|
697
|
-
? '
|
|
698
|
-
: teammate.
|
|
699
|
-
? '
|
|
700
|
-
: teammate.lastText
|
|
711
|
+
const body = wasCancelled
|
|
712
|
+
? REVIEW_CANCELED_TEXT
|
|
713
|
+
: teammate.state === 'failed'
|
|
714
|
+
? `审查没有完成:${teammate.error ?? '未知错误'}`
|
|
715
|
+
: teammate.state === 'stopped'
|
|
716
|
+
? '审查被停止,没有交回结论。'
|
|
717
|
+
: teammate.lastText === ''
|
|
718
|
+
? '审查没有留下文字结论。'
|
|
719
|
+
: teammate.lastText;
|
|
701
720
|
const notice = `${REVIEW_FINDINGS_OPEN}teammate="${teammate.name}" state="${state}">\n${body}\n</review-findings>`;
|
|
702
721
|
const line = `审查队友 ${teammate.name},${state}`;
|
|
703
722
|
teammate.parentSession.appendUser(notice);
|
|
723
|
+
// 记录跟着收工:/review-status 回看的就是这里写下去的那份
|
|
724
|
+
reviewJournal.finish(sessionId, body, teammate.name);
|
|
704
725
|
const live = ctx.session.current() === teammate.parentSession;
|
|
705
726
|
ctx.transcript.system(live ? `${line},findings 已写进会话` : `${line},findings 写入了派出它的会话`);
|
|
706
727
|
ctx.transcript.touch();
|
|
707
728
|
};
|
|
708
|
-
const reviewService = {
|
|
729
|
+
const reviewService = {
|
|
730
|
+
spawn: spawnReviewer,
|
|
731
|
+
status() {
|
|
732
|
+
return reviewJournal.status(ctx.session.current().meta.id);
|
|
733
|
+
},
|
|
734
|
+
cancel() {
|
|
735
|
+
const sessionId = ctx.session.current().meta.id;
|
|
736
|
+
const run = reviewJournal.running(sessionId);
|
|
737
|
+
if (run === undefined)
|
|
738
|
+
return false;
|
|
739
|
+
// 叫停走队友那条现成的路(agent.cancel + 保留名册),再把记录标成取消
|
|
740
|
+
stopTeammate(run.handle, 'stop');
|
|
741
|
+
reviewJournal.cancel(sessionId);
|
|
742
|
+
return true;
|
|
743
|
+
},
|
|
744
|
+
};
|
|
709
745
|
ctx.provide('review', reviewService);
|
|
710
746
|
// ── 模型侧工具 ──────────────────────────────────────────────────────────
|
|
711
747
|
function uniqueName(role) {
|
package/lib/services/types.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ import type { Session, InboxOrigin } from '../core/session.js';
|
|
|
23
23
|
import type { UserFileAttachment } from '../core/attachments.js';
|
|
24
24
|
import type { ChatMessage, LlmAdapter, LlmRoute, StreamHandlers, StreamRequest, StreamResult } from '../core/llm.js';
|
|
25
25
|
import type { FileChangeSummary, ToolEntry } from '../core/tools.js';
|
|
26
|
+
import type { ReviewScope } from '../core/git-info.js';
|
|
26
27
|
import type { CoreEvent } from '../core/events.js';
|
|
27
28
|
import type { SkillDefinition, SkillSummary } from '../core/skills.js';
|
|
28
29
|
import type { DscPrefs } from '../core/prefs.js';
|
|
@@ -149,8 +150,12 @@ export interface SessionService {
|
|
|
149
150
|
archived(): ArchivedPage;
|
|
150
151
|
/** 从归档区恢复一批会话。 */
|
|
151
152
|
restore(paths: string[]): SettingsMutation;
|
|
152
|
-
/**
|
|
153
|
-
|
|
153
|
+
/**
|
|
154
|
+
* 永久删除一批会话(移进回收站,30 天后清)。
|
|
155
|
+
*
|
|
156
|
+
* 是异步的:切走不久、还在「空闲保留」名册里的会话握着写入流,要先等它收摊才能挪文件。
|
|
157
|
+
*/
|
|
158
|
+
purge(paths: string[]): Promise<SettingsMutation>;
|
|
154
159
|
/** 改会话显示名(写 meta.json,不动 jsonl)。 */
|
|
155
160
|
rename(path: string, title: string): SettingsMutation;
|
|
156
161
|
/** 置顶或取消置顶一个会话。 */
|
|
@@ -159,6 +164,17 @@ export interface SessionService {
|
|
|
159
164
|
userMessages(path: string): string[];
|
|
160
165
|
/** 分叉会话:复制到第 index 条用户消息之前,成功时给新会话路径。 */
|
|
161
166
|
fork(path: string, index: number): SessionForkResult;
|
|
167
|
+
/**
|
|
168
|
+
* 作废第 keep 条用户消息及其之后的内容(「编辑并重发」用):日志追加一条 `rewind`
|
|
169
|
+
* 记录并让转录层按截断后的历史重建,之后由调用方把改过的文字重新提交。
|
|
170
|
+
*
|
|
171
|
+
* 与 {@link fork} 的区别:分叉**保住**原会话、另开一条;这条是**在原地**截断重来。
|
|
172
|
+
* 因此它只对「当前正在看的那条会话」有效——别的会话没有常驻的 agent 承接截断后的历史。
|
|
173
|
+
*
|
|
174
|
+
* @param text - 改过的那句话(可选):作废的是第一条消息时,侧栏标题要跟着换成它,
|
|
175
|
+
* 否则会一直显示那句已经被作废的原文。
|
|
176
|
+
*/
|
|
177
|
+
rewind(path: string, keep: number, text?: string): SettingsMutation;
|
|
162
178
|
}
|
|
163
179
|
/** 审批服务:权限模式状态机(沙箱强制层)+ 工具执行的挂起 Promise ↔ UI 审批卡。 */
|
|
164
180
|
export interface ApprovalService extends ApprovalHandler {
|
|
@@ -439,6 +455,15 @@ export interface CommandSpec {
|
|
|
439
455
|
* 派发时统一查这一位——桌面 / TUI / 远端从同一个闸过,不再各防各的。
|
|
440
456
|
*/
|
|
441
457
|
duringTask?: 'allow' | 'deny';
|
|
458
|
+
/**
|
|
459
|
+
* 这条命令要收一段自由输入(不是从候选里挑的参数)。
|
|
460
|
+
*
|
|
461
|
+
* 有它就表示:输入框回车时**不执行**,只把 `/<名字> ` 补进输入并显示 `hint`,
|
|
462
|
+
* 让用户在后面写要求;再按回车才带着写好的要求执行。缺省 = 回车直接执行。
|
|
463
|
+
*/
|
|
464
|
+
input?: {
|
|
465
|
+
hint: string;
|
|
466
|
+
};
|
|
442
467
|
/**
|
|
443
468
|
* 壳(桌面 / 手机那份插件化界面)的 `/` 菜单里列不列、能不能执行。
|
|
444
469
|
*
|
|
@@ -590,6 +615,21 @@ export interface CompactService {
|
|
|
590
615
|
*/
|
|
591
616
|
registerCarry(contribute: () => string): () => void;
|
|
592
617
|
}
|
|
618
|
+
/**
|
|
619
|
+
* 旧工具结果微压缩的投影估算(microcompact 插件提供)。
|
|
620
|
+
*
|
|
621
|
+
* 为什么要这个服务:微压缩是**请求体投影**,不改会话日志——模型真正收到的那份请求
|
|
622
|
+
* 可能早就把旧工具结果换成了占位符。压缩插件在「请求爆窗了要不要压摘要」这一刻
|
|
623
|
+
* 必须看投影后的体积,否则会为了一个本来装得下的请求去牺牲历史。
|
|
624
|
+
*/
|
|
625
|
+
export interface MicrocompactService {
|
|
626
|
+
/**
|
|
627
|
+
* 按当前配置把旧工具结果换成占位符之后,整段消息的估算 token 数。
|
|
628
|
+
* 门槛没达到(清得太少不划算)或总开关关掉时,返回原文的估算值。
|
|
629
|
+
* @param messages - 要估算的消息(与请求体同一份)。
|
|
630
|
+
*/
|
|
631
|
+
projectedTokens(messages: readonly ChatMessage[]): number;
|
|
632
|
+
}
|
|
593
633
|
/** Agent 服务:ReAct 循环的对外操作面(0.6.48 起按会话常驻多 agent)。 */
|
|
594
634
|
export interface AgentService {
|
|
595
635
|
/**
|
|
@@ -750,9 +790,12 @@ export interface TeamService {
|
|
|
750
790
|
remove(name: string): Promise<string>;
|
|
751
791
|
}
|
|
752
792
|
/**
|
|
753
|
-
* 只读代码审查通道(
|
|
793
|
+
* 只读代码审查通道(T45):由 subagent 插件提供,/review 命令的升级路径。
|
|
754
794
|
* 派出去的队友工牌被强制压到只读交集(工具 = read/glob/grep,审批 = forbid),
|
|
755
795
|
* 与角色文件怎么改无关——审查通道天然安全,不靠配置自觉。
|
|
796
|
+
*
|
|
797
|
+
* 一次审查的范围与完整 diff 由 `core/git-info.ts` 的 `collectReviewScope` 备好落盘,
|
|
798
|
+
* 这里只负责派队友、记状态、叫停。
|
|
756
799
|
*/
|
|
757
800
|
export interface ReviewService {
|
|
758
801
|
/**
|
|
@@ -761,13 +804,15 @@ export interface ReviewService {
|
|
|
761
804
|
* @returns ok=false 时 reason 是给用户看的一句话(额度满/角色不可用等),调用方回落。
|
|
762
805
|
*/
|
|
763
806
|
spawn(request: ReviewSpawnRequest): ReviewSpawnResult;
|
|
807
|
+
/** 最近一次审查的状态与结论;没有记录返回 null。 */
|
|
808
|
+
status(): ReviewStatusView | null;
|
|
809
|
+
/** 取消当前会话正在跑的审查;没有在跑返回 false。 */
|
|
810
|
+
cancel(): boolean;
|
|
764
811
|
}
|
|
765
|
-
/** /review
|
|
812
|
+
/** /review 交给审查通道的输入:落盘好的范围 + 关注点。 */
|
|
766
813
|
export interface ReviewSpawnRequest {
|
|
767
|
-
/**
|
|
768
|
-
|
|
769
|
-
/** 未跟踪文件名单(diff 里没有,队友自己 read)。 */
|
|
770
|
-
untracked: string[];
|
|
814
|
+
/** 取数结果(完整 diff 已落盘,队友自己按 offset/limit 读)。 */
|
|
815
|
+
scope: ReviewScope;
|
|
771
816
|
/** 用户写在 /review 后面的关注点;空 = 不限。 */
|
|
772
817
|
focus: string;
|
|
773
818
|
}
|
|
@@ -779,6 +824,17 @@ export type ReviewSpawnResult = {
|
|
|
779
824
|
ok: false;
|
|
780
825
|
reason: string;
|
|
781
826
|
};
|
|
827
|
+
/** 一次审查的状态视图(`/review-status` 的数据源;记录文件里的字段与它同形)。 */
|
|
828
|
+
export interface ReviewStatusView {
|
|
829
|
+
/** running = 还在跑;finished = 已收工(含被取消)。 */
|
|
830
|
+
state: 'running' | 'finished';
|
|
831
|
+
/** 开始时间(毫秒时间戳)。 */
|
|
832
|
+
startedAt: number;
|
|
833
|
+
/** 范围的一句话描述(`ReviewScope.label`)。 */
|
|
834
|
+
target: string;
|
|
835
|
+
/** 收工后的 findings 正文;还在跑时没有。 */
|
|
836
|
+
findings?: string;
|
|
837
|
+
}
|
|
782
838
|
/**
|
|
783
839
|
* 技能提供方:本地目录之外,外部插件也能挂一个技能来源(例如公司内部库)。
|
|
784
840
|
* 返回的条目里 `local: false`,技能中心只展示不提供启停与导入。
|
|
@@ -1242,6 +1298,8 @@ declare module '@deepseek-ai/cordis' {
|
|
|
1242
1298
|
transcript: TranscriptService;
|
|
1243
1299
|
commands: CommandService;
|
|
1244
1300
|
compact: CompactService;
|
|
1301
|
+
/** 旧工具结果微压缩的投影估算(microcompact 插件提供;没开时不存在)。 */
|
|
1302
|
+
microcompact?: MicrocompactService;
|
|
1245
1303
|
agent: AgentService;
|
|
1246
1304
|
/** 请求组装扩展点(附加系统提示 + 请求体改写)。 */
|
|
1247
1305
|
prompt: PromptService;
|