@oxmumu3/dsh-project-companion 0.29.0 → 0.31.0
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 +1 -1
- package/docs/install.md +4 -4
- package/docs/roadmap.md +1 -1
- package/docs/verification.md +22 -0
- package/index.js +31 -4
- package/package.json +3 -2
- package/src/project-pulse.js +110 -0
package/README.md
CHANGED
|
@@ -96,7 +96,7 @@ dsh plugin --profile web add @oxmumu3/dsh-project-companion
|
|
|
96
96
|
|
|
97
97
|
## 版本与数据
|
|
98
98
|
|
|
99
|
-
- 当前版本 **`0.
|
|
99
|
+
- 当前版本 **`0.31.0`**:任意已授权工作区都能直接问进度(未关注会说明没有项目记忆);`0.30.0` 项目简报会读本机 git 的最近提交与未提交改动。
|
|
100
100
|
- 兼容官方 Harness `0.2.0-rc.2`、`0.2.1-rc.2` 至 `rc.5`、`0.2.2-rc.1`;清单在 [compatibility.json](compatibility.json)。
|
|
101
101
|
- 数据留在本机 Harness profile 内,不经过第三方服务器;微信组件内置部分保留上游 MIT 许可,见 [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md)。
|
|
102
102
|
- 已知边界(Google 数据权限审核、flomo MAX、主动关注与手机收件的验收状态)统一写在[验证记录](docs/verification.md),本页不重复。
|
package/docs/install.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# 安装 DSH Dot 0.
|
|
1
|
+
# 安装 DSH Dot 0.31.0
|
|
2
2
|
|
|
3
3
|
## 在创造模式中安装/更新
|
|
4
4
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
请安装或更新并启用 DSH Dot。先检查现有插件,避免重复添加和降级。从 npm 官方源实时查询 @oxmumu3/dsh-project-companion 的 latest,按查到的精确版本安装或更新,不直接采用本机缓存的旧 latest。保留已有微信绑定、账号授权、资料范围、设置和其他插件,不自动读取或新建计划。核对实际版本、启用状态,再打开 DSH Dot。
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
新用户也可在「插件 → 添加插件」填写 `@oxmumu3/dsh-project-companion`(或精确版本 `@oxmumu3/dsh-project-companion@0.
|
|
11
|
+
新用户也可在「插件 → 添加插件」填写 `@oxmumu3/dsh-project-companion`(或精确版本 `@oxmumu3/dsh-project-companion@0.31.0`),安装后启用。它是一个标准插件包,已内置独立微信组件。已有未带 namespace 的历史安装应沿原包名更新;不要将两个名称当成同一个插件重复添加。
|
|
12
12
|
|
|
13
13
|
牛村木木山制作的 DeepSeek Harness 社区插件,非 DeepSeek 或 OpenAI 官方产品。本版内置微信组件,只需添加一个标准插件包,不包含 Harness 应用或 Family 家庭助手。
|
|
14
14
|
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
|
|
27
27
|
无法联网或想用离线包时,到 [Releases](https://github.com/oxmumu3/dsh-project-companion/releases) 下载对应版本的 `.tgz`,在官方管理器填写下载后的文件实际路径;无需解压、另装微信组件或运行 macOS 脚本。
|
|
28
28
|
|
|
29
|
-
[本版发布页](https://github.com/oxmumu3/dsh-project-companion/releases/tag/v0.
|
|
29
|
+
[本版发布页](https://github.com/oxmumu3/dsh-project-companion/releases/tag/v0.31.0)记录本版变更。插件包从 npm 安装,npm 页面提供 integrity 与 provenance 可核;0.24 起 release 不再附带离线包。插件尚未上架官方插件市场,npm latest 同步为本版;不要用旧版 ZIP 或第二个微信安装包代替这条单插件路径。
|
|
30
30
|
|
|
31
31
|
## 已有用户
|
|
32
32
|
|
|
@@ -68,7 +68,7 @@ Google 品牌已验证,Gmail、日历、Drive 数据权限已提交审核但
|
|
|
68
68
|
|
|
69
69
|
## 本版验证与已知问题
|
|
70
70
|
|
|
71
|
-
0.
|
|
71
|
+
0.31.0 源码全量回归 2,365 项 / 2,328 通过 / 0 失败 / 37 跳过(跳过项均需 Family 源码树,不在本包范围)。自检只读本机状态,不发外部请求;单项探测 2 秒上限,超时或抛错显示「未知」。私人外发确认只覆盖 `personal_review.run_now` 这条路径,宿主自带的 `send_wechat`、定时投递和带内容的 `remind` / `coordinate` 不经过这道门禁——插件单方面无法覆盖全部外发路径。
|
|
72
72
|
|
|
73
73
|
自动回顾仍为实验能力:自然语言 `focus` 尚未用真实模型验证实际效果,手机端呈现也未验证。历史 flomo 范围投影与模型失败未全部归因。新用户独立扫码到收件、多日与休眠恢复、真实 macOS 输入法仍分别验收。通道报告发送不等于手机收到。详见[验证记录](verification.md)。
|
|
74
74
|
|
package/docs/roadmap.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 当前收尾 · 0.24.2 公开版本
|
|
2
2
|
|
|
3
|
-
最新公开版本 0.29.0:新增升级前状态自查脚本;0.28.0:早报授权失败时说明下一步(换绑要重设、离线下次再试),自检同步提醒;0.27.0:自检新增「手机控制」一行并在自检时补一次注册,手机控制两边是否接通一眼可见;0.26.0:并入手机端任务控制的 Dot 侧(`mobileTaskScope` / `mobileQuestionState` / 桥接注册),等家庭助手暴露接口后即可用;`0.25.0`:补上滴答账户级只读搜索(`search_task` / `search` / `list_all_tasks`);此前 0.24.2:项目工具收敛到 `look`/`manage` 两个入口,新增自检、私人外发确认与回顾关注点,首次打开有示例卡,交办记录可复用。
|
|
3
|
+
最新公开版本 0.31.0:任意已授权工作区可直接问进度,未授权名字明确拒绝;0.30.0:项目简报先读本机 git 的真实变化(分支、最近提交、未提交改动),为按变化推送打底;0.29.0:新增升级前状态自查脚本;0.28.0:早报授权失败时说明下一步(换绑要重设、离线下次再试),自检同步提醒;0.27.0:自检新增「手机控制」一行并在自检时补一次注册,手机控制两边是否接通一眼可见;0.26.0:并入手机端任务控制的 Dot 侧(`mobileTaskScope` / `mobileQuestionState` / 桥接注册),等家庭助手暴露接口后即可用;`0.25.0`:补上滴答账户级只读搜索(`search_task` / `search` / `list_all_tasks`);此前 0.24.2:项目工具收敛到 `look`/`manage` 两个入口,新增自检、私人外发确认与回顾关注点,首次打开有示例卡,交办记录可复用。
|
|
4
4
|
|
|
5
5
|
下一步按影响排序:
|
|
6
6
|
|
package/docs/verification.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
# 0.31.0 验证增量
|
|
2
|
+
|
|
3
|
+
2026-11-09,已授权但未关注的工作区可以直接问进度。
|
|
4
|
+
|
|
5
|
+
- `node --max-old-space-size=256 --test --test-concurrency=1 test/*.test.mjs`:2,383 项 / 2,346 通过 / 0 失败 / 37 跳过(0.30.0 基线 2,382 / 2,345 / 0 / 37)。
|
|
6
|
+
- 新增 1 条宿主级用例:走真实 HTTP 路由保存授权后,用「只授权项目」问 digest,`memoryContext` 同时出现「还没加入关注」与本机最近变化;用「未授权项目」问则返回 blocked 并说明先允许它。
|
|
7
|
+
- 同时收紧:digest 的显式项目目标必须落在已关注或已授权范围内,未授权的工作区不再被读取。
|
|
8
|
+
|
|
9
|
+
**没有验证的**:真实桌面 UI 里从「全部项目」目录跳到「问进度」的链路;本轮只验证服务端与宿主入口。
|
|
10
|
+
|
|
11
|
+
# 0.30.0 验证增量
|
|
12
|
+
|
|
13
|
+
2026-11-09,项目简报新增「最近变化」一层的证据来自本机 git。
|
|
14
|
+
|
|
15
|
+
- `node --max-old-space-size=256 --test --test-concurrency=1 test/*.test.mjs`:2,382 项 / 2,345 通过 / 0 失败 / 37 跳过(0.29.0 基线 2,376 / 2,339 / 0 / 37)。
|
|
16
|
+
- 新增 6 条用例:命令面只包含 `git -C <root> rev-parse/symbolic-ref/log/status` 的只读调用;摘要含分支、提交与未提交改动;非仓库返回明确原因;单条命令失败标为不可用而不是整体失败;未提交改动超 200 条截断并明说;空根目录直接拒绝。
|
|
17
|
+
- 未做真实 git 仓库的集成测试:用例用注入的命令执行器,避免依赖 CI 的 git 版本;真实仓库行为等价于同一组只读命令。
|
|
18
|
+
|
|
19
|
+
**没有验证的**:20 个项目同时读脉搏的耗时上限;本轮只做了单项目读取与上限计数。
|
|
20
|
+
|
|
1
21
|
# 0.29.0 验证增量
|
|
2
22
|
|
|
3
23
|
2026-11-09,新增升级前状态自查脚本 `scripts/validate-state.mjs`。
|
|
@@ -6,6 +26,8 @@
|
|
|
6
26
|
- 新增 4 条用例:合法状态返回 0 且逐域「兼容」、多出未知字段返回 1 并点名域与字段、目录不存在返回 2、无 schema 的域标「未核对」。
|
|
7
27
|
- 本机实跑:用 0.28.0 的自带 schema 解开 7 个域,0 个不兼容;三个未导出 schema 的域标为未核对。这是重启前的补充证据,不替代真实 Host 激活。
|
|
8
28
|
|
|
29
|
+
**隔离目录里的全新安装(追加)**:在空目录 `npm install @oxmumu3/dsh-project-companion@0.29.0`,2 分钟后装上 24 个包;`index.js` 可导入,导出 `Config/apply/inject/installCompanion/name`;`cordis.patch.yml` 与内置桥 `vendor/dsh-wechat`(0.11.1-dot.3-embedded.2)都在;包内 `scripts/validate-state.mjs` 直接跑通,读本机 7 个域 0 个不兼容。这只证明发布产物能被新用户装上并加载,不等于真实 Host 里已激活。
|
|
30
|
+
|
|
9
31
|
**没有验证的**:脚本在激活失败的真实场景里的表现(只有一处历史失败,已从存储中清理)。
|
|
10
32
|
|
|
11
33
|
# 0.28.0 验证增量
|
package/index.js
CHANGED
|
@@ -14,6 +14,7 @@ import {createFamilyProjectAdmission} from './src/family-project-admission.js';
|
|
|
14
14
|
import {createTaskResults,taskResultsRowSchema} from './src/task-results.js';
|
|
15
15
|
import {readWechatBinding,readWechatRoute,readWechatSetup} from './src/wechat-route.js';
|
|
16
16
|
import {createProjectMemory} from './src/project-memory.js';
|
|
17
|
+
import {createProjectPulse,summarize as summarizePulse} from './src/project-pulse.js';
|
|
17
18
|
import {createProjectFollowup} from './src/project-followup.js';
|
|
18
19
|
import {createOnboarding,registerOnboardingRoute} from './src/onboarding.js';
|
|
19
20
|
import {createWelcomeGuard} from './src/welcome-guard.js';
|
|
@@ -158,7 +159,7 @@ export async function installCompanion(ctx,options={}){
|
|
|
158
159
|
let disposed=false;
|
|
159
160
|
const coordinates=new Set();
|
|
160
161
|
let lastRuntimeError='';
|
|
161
|
-
let memory,followup,onboarding,welcomeGuard,contextRoute,workbench,workbenchActions,projectUpdates,projectUpdateModel,contextLoop,context,familyDelegate,familyContext,personalReview,personalReviewModel;
|
|
162
|
+
let projectPulse,memory,followup,onboarding,welcomeGuard,contextRoute,workbench,workbenchActions,projectUpdates,projectUpdateModel,contextLoop,context,familyDelegate,familyContext,personalReview,personalReviewModel;
|
|
162
163
|
// 污点标记只活在本进程内存里;这次装载从干净状态开始,不继承上一次运行的标记。
|
|
163
164
|
clearPrivateReads();
|
|
164
165
|
const lifecycle=new AbortController();
|
|
@@ -415,6 +416,7 @@ export async function installCompanion(ctx,options={}){
|
|
|
415
416
|
const noteError=error=>{lastRuntimeError=String(error?.message??error).slice(0,200);};
|
|
416
417
|
const authorizeRoot=async root=>(await service.coordinationTarget(root))?.root===root;
|
|
417
418
|
const familyRead=createFamilyReadAdapter({getBridge:getFamilyBridge,isCurrent:scope=>familyDelegate.current(scope),authorizeRoot,recheck:scope=>familyDelegate.recheck(scope)});
|
|
419
|
+
projectPulse=options.projectPulse??createProjectPulse({...(options.clock?{clock:options.clock}:{})});
|
|
418
420
|
memory=createProjectMemory({authorizeRoot,...(options.clock?{clock:options.clock}:{}),...(options.hostTimeZone?{hostTimeZone:options.hostTimeZone}:{})});
|
|
419
421
|
// Personal review is Owner-wide; it never borrows a synthetic project or a
|
|
420
422
|
// one-project follow-up capability. Persisted runs re-enter the exact grant.
|
|
@@ -908,6 +910,19 @@ export async function installCompanion(ctx,options={}){
|
|
|
908
910
|
if(plan.enabled&&origin)await followup.cancel({root:project.root,sessionId:origin});
|
|
909
911
|
await followup.cancelOnceForProject({root:project.root});
|
|
910
912
|
}
|
|
913
|
+
// 已授权但没加入关注的工作区也能问进度;这里只解析目标,不改任何范围。
|
|
914
|
+
const resolveDigestTarget=async reference=>{
|
|
915
|
+
let watched=null;try{watched=await service.coordinationTarget(reference);}catch{watched=null;}
|
|
916
|
+
if(watched)return watched;
|
|
917
|
+
try{
|
|
918
|
+
const snapshot=await workspaceAccess.capture(),key=String(reference).trim().toLowerCase();
|
|
919
|
+
const matches=snapshot.grants.filter(grant=>grant.id===reference||grant.workspaceId===reference||String(grant.label).toLowerCase()===key);
|
|
920
|
+
if(matches.length!==1)return null;
|
|
921
|
+
const grant=matches[0];
|
|
922
|
+
return{id:'workspace:'+grant.id,root:grant.root,label:grant.label,sessionIds:grant.sessionIds,grantedOnly:true};
|
|
923
|
+
}catch{return null;}
|
|
924
|
+
};
|
|
925
|
+
if(input.action==='digest'&&input.project!==undefined&&!await resolveDigestTarget(input.project))return{status:'blocked',accepted:false,text:'没找到这个名字的已关注项目或已授权工作区。请先在工作区选择里允许这个项目,再加入关注;本次没有读取任何内容。'};
|
|
911
926
|
const familyScope=familyContext.activeScope();
|
|
912
927
|
const result=await service.act(owner(ctx,agent),familyScope&&['configure_daily','remind'].includes(input.action)?{...input,expectedBinding:familyBinding(familyScope)}:input);
|
|
913
928
|
if(input.action==='status'){
|
|
@@ -919,12 +934,24 @@ export async function installCompanion(ctx,options={}){
|
|
|
919
934
|
if(result.followups.length){const summary=`主动跟进:${result.followups.map(plan=>`${plan.projectLabel} ${plan.unknown?'状态未知':plan.paused?'已暂停':plan.blocked?'等待恢复绑定':`每${plan.everyMinutes}分钟只读检查`}`).join(';')}`;result.text=`${result.text.slice(0,3199-summary.length)}\n${summary}`;}
|
|
920
935
|
}
|
|
921
936
|
if(input.action==='digest'){
|
|
922
|
-
|
|
937
|
+
let projects;
|
|
938
|
+
if(input.project===undefined)projects=await service.watchedProjects();
|
|
939
|
+
else{
|
|
940
|
+
const target=await resolveDigestTarget(input.project);
|
|
941
|
+
if(!target){result.status='blocked';result.text='没找到这个名字的已关注项目或已授权工作区。请先在工作区选择里允许这个项目,再加入关注;本次没有读取任何内容。';return result;}
|
|
942
|
+
projects=[target];
|
|
943
|
+
}
|
|
923
944
|
const context=[];
|
|
924
945
|
for(const project of projects){
|
|
925
|
-
|
|
926
|
-
|
|
946
|
+
if(project.grantedOnly){context.push(`${project.label} 只做了范围授权、还没加入关注,因此没有项目记忆;以下是它本机最近的改动。`);}
|
|
947
|
+
else{try{const snapshot=await memory.read({root:project.root,sessionId:owner(ctx,agent).sessionId});if(snapshot.goals.length||snapshot.entries.length)context.push(`${project.label}\n${snapshot.text}`);}
|
|
948
|
+
catch(error){context.push(`${project.label}:项目记忆读取失败,内容未知。${String(error?.message??error).slice(0,120)}`);}}
|
|
949
|
+
if(projects.indexOf(project)<20){
|
|
950
|
+
try{const pulse=summarizePulse(await projectPulse.capture(project.root));if(pulse)context.push(`${project.label} 最近变化\n${pulse}`);}
|
|
951
|
+
catch{context.push(`${project.label} 最近变化:本机读取失败,状态未知。`);}
|
|
952
|
+
}
|
|
927
953
|
}
|
|
954
|
+
if(projects.length>20)context.push(`另外 ${projects.length-20} 个项目本轮没有读取最近变化。`);
|
|
928
955
|
if(context.length)result.memoryContext=context.join('\n\n').slice(0,10000);
|
|
929
956
|
}
|
|
930
957
|
syncTimer();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxmumu3/dsh-project-companion",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.0",
|
|
4
4
|
"description": "DSH Dot: WeChat personal agent, project memory and proactive follow-up for DeepSeek Harness",
|
|
5
5
|
"author": "牛村木木山",
|
|
6
6
|
"license": "MIT",
|
|
@@ -54,7 +54,8 @@
|
|
|
54
54
|
"compatibility.json",
|
|
55
55
|
"scripts/official-channels.mjs",
|
|
56
56
|
"scripts/validate-state.mjs",
|
|
57
|
-
"docs/mobile-control.md"
|
|
57
|
+
"docs/mobile-control.md",
|
|
58
|
+
"src/project-pulse.js"
|
|
58
59
|
],
|
|
59
60
|
"scripts": {
|
|
60
61
|
"test": "node --max-old-space-size=128 --test --test-concurrency=1 test/*.test.mjs",
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import {execFile} from 'node:child_process';
|
|
2
|
+
import {promisify} from 'node:util';
|
|
3
|
+
|
|
4
|
+
/** 项目脉搏:只读的判断"这个项目最近发生了什么"。
|
|
5
|
+
*
|
|
6
|
+
* 只跑本机 git 读取命令(不联网、不写索引、不加锁),把结果压成一段可进上下文的
|
|
7
|
+
* 中文摘要。不是 git 仓库、命令超时或失败时返回明确的不可用状态,不猜、不伪造进度。
|
|
8
|
+
*/
|
|
9
|
+
const runFile = promisify(execFile);
|
|
10
|
+
const GIT_ENV = {LC_ALL: 'C', GIT_OPTIONAL_LOCKS: '0', GIT_TERMINAL_PROMPT: '0'};
|
|
11
|
+
const MAX_COMMITS = 5;
|
|
12
|
+
const MAX_DIRTY_LINES = 200;
|
|
13
|
+
const MAX_SUBJECT = 120;
|
|
14
|
+
const MAX_BRANCH = 120;
|
|
15
|
+
const TIMEOUT_MS = 4000;
|
|
16
|
+
const SUMMARY_MAX = 700;
|
|
17
|
+
|
|
18
|
+
const clean = (value, max) => String(value ?? '')
|
|
19
|
+
.replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/g, '')
|
|
20
|
+
.replace(/\s+/g, ' ')
|
|
21
|
+
.trim()
|
|
22
|
+
.slice(0, max);
|
|
23
|
+
|
|
24
|
+
async function defaultRun(args, {timeout = TIMEOUT_MS} = {}) {
|
|
25
|
+
const {stdout} = await runFile('git', args, {
|
|
26
|
+
encoding: 'utf8', maxBuffer: 65536, timeout, env: {...process.env, ...GIT_ENV},
|
|
27
|
+
});
|
|
28
|
+
return stdout;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @param {object} options
|
|
33
|
+
* @param {(args: string[], options?: object) => Promise<string>} [options.run] 已带 `git -C <root>` 前缀的命令执行器,测试可注入
|
|
34
|
+
* @param {() => Date} [options.clock]
|
|
35
|
+
*/
|
|
36
|
+
export function createProjectPulse({run = defaultRun, clock = () => new Date()} = {}) {
|
|
37
|
+
if (typeof run !== 'function' || typeof clock !== 'function') throw new Error('Project pulse requires git runner and clock');
|
|
38
|
+
|
|
39
|
+
async function capture(root) {
|
|
40
|
+
if (typeof root !== 'string' || !root.trim() || root.length > 4096) throw new Error('Project pulse requires a project root');
|
|
41
|
+
const at = clock().toISOString();
|
|
42
|
+
const git = (...args) => run(['-C', root, ...args]);
|
|
43
|
+
|
|
44
|
+
let inside;
|
|
45
|
+
try {
|
|
46
|
+
inside = (await git('rev-parse', '--is-inside-work-tree')).trim();
|
|
47
|
+
} catch {
|
|
48
|
+
return {at, repo: false, reason: 'not_a_repository'};
|
|
49
|
+
}
|
|
50
|
+
if (inside !== 'true') return {at, repo: false, reason: 'not_a_repository'};
|
|
51
|
+
|
|
52
|
+
const read = async (promise) => {
|
|
53
|
+
try { return {ok: true, value: await promise}; } catch { return {ok: false}; }
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const [branch, head, log, status] = await Promise.all([
|
|
57
|
+
read(git('symbolic-ref', '--short', 'HEAD')),
|
|
58
|
+
read(git('rev-parse', '--short', 'HEAD')),
|
|
59
|
+
read(git('log', `-${MAX_COMMITS}`, '--date=short', '--pretty=format:%h%x1f%ad%x1f%s')),
|
|
60
|
+
read(git('status', '--porcelain')),
|
|
61
|
+
]);
|
|
62
|
+
|
|
63
|
+
const commits = log.ok
|
|
64
|
+
? log.value.split('\n').filter(Boolean).slice(0, MAX_COMMITS).map(line => {
|
|
65
|
+
const [short, date, subject] = line.split('\x1f');
|
|
66
|
+
return {short: clean(short, 16), date: clean(date, 24), subject: clean(subject, MAX_SUBJECT)};
|
|
67
|
+
}).filter(row => row.short)
|
|
68
|
+
: [];
|
|
69
|
+
|
|
70
|
+
let dirty = null;
|
|
71
|
+
if (status.ok) {
|
|
72
|
+
const lines = status.value.split('\n').filter(Boolean);
|
|
73
|
+
const truncated = lines.length > MAX_DIRTY_LINES;
|
|
74
|
+
const visible = lines.slice(0, MAX_DIRTY_LINES);
|
|
75
|
+
dirty = {
|
|
76
|
+
total: lines.length,
|
|
77
|
+
modified: visible.filter(line => !line.startsWith('??')).length,
|
|
78
|
+
untracked: visible.filter(line => line.startsWith('??')).length,
|
|
79
|
+
truncated,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
at,
|
|
85
|
+
repo: true,
|
|
86
|
+
branch: branch.ok && branch.value.trim() ? clean(branch.value, MAX_BRANCH) : null,
|
|
87
|
+
head: head.ok ? clean(head.value, 40) : null,
|
|
88
|
+
commits,
|
|
89
|
+
dirty,
|
|
90
|
+
unavailable: [...(branch.ok ? [] : ['branch']), ...(head.ok ? [] : ['head']), ...(log.ok ? [] : ['commits']), ...(status.ok ? [] : ['status'])],
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return {capture, summarize};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** 把脉搏压成给模型看的一小段;没有可说的就返回空串,不凑字数。 */
|
|
98
|
+
export function summarize(pulse) {
|
|
99
|
+
if (!pulse || pulse.repo !== true) return '';
|
|
100
|
+
const parts = [];
|
|
101
|
+
if (pulse.branch) parts.push(`分支 ${pulse.branch}`);
|
|
102
|
+
if (pulse.commits?.length) {
|
|
103
|
+
parts.push(`最近 ${pulse.commits.length} 次提交:${pulse.commits.map(row => `${row.short} ${row.subject}`).join(';')}`);
|
|
104
|
+
}
|
|
105
|
+
if (pulse.dirty) {
|
|
106
|
+
parts.push(pulse.dirty.total ? `未提交改动 ${pulse.dirty.total} 个文件(修改 ${pulse.dirty.modified}、未跟踪 ${pulse.dirty.untracked}${pulse.dirty.truncated ? ',超过上限已截断' : ''})` : '工作区没有未提交改动');
|
|
107
|
+
}
|
|
108
|
+
if (pulse.unavailable?.length) parts.push(`未能读取:${pulse.unavailable.join('、')}`);
|
|
109
|
+
return parts.length ? clean(parts.join(';'), SUMMARY_MAX) : '';
|
|
110
|
+
}
|