@oxmumu3/dsh-project-companion 0.31.0 → 0.33.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 +21 -0
- package/index.js +48 -7
- package/package.json +1 -1
- package/scripts/validate-state.mjs +1 -0
- package/src/action-surface.js +3 -2
- package/src/project-pulse-ledger.js +167 -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.33.0`**:说一句「项目有变化就提醒我」即可,项目真的变了才发一条带证据的消息;`0.32.0` 项目变化账本。
|
|
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.33.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.33.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.33.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.33.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.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` 两个入口,新增自检、私人外发确认与回顾关注点,首次打开有示例卡,交办记录可复用。
|
|
3
|
+
最新公开版本 0.33.0:项目变化提醒接上定时器,变了才发且带证据;0.32.0:变化账本,同一项目第二次只看增量;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,24 @@
|
|
|
1
|
+
# 0.33.0 验证增量
|
|
2
|
+
|
|
3
|
+
2026-11-09,项目变化提醒接上定时器(事件驱动推送)。
|
|
4
|
+
|
|
5
|
+
- `node --max-old-space-size=256 --test --test-concurrency=1 test/*.test.mjs`:2,393 项 / 2,356 通过 / 0 失败 / 37 跳过(0.32.0 基线 2,390 / 2,353 / 0 / 37)。
|
|
6
|
+
- 新增 3 条用例:开启后按间隔检查、首次只是基线、真有变化才发一条且带证据与建议、无变化保持安静;关闭后不再检查、非法绑定/空项目被拒;宿主级:未连微信不开启、关闭给出明确文案。
|
|
7
|
+
- 路由与可发现性:新增 `manage` 的 `pulse` op、动作名 `pulse_projects`,并补入自然语料(「项目有变化就提醒我」);`contract-guidance` 与 `routing-surface` 全通过。
|
|
8
|
+
- 存储:`project_companion_pulse` 行新增可选 `policy`(会话、绑定、项目、间隔、上次检查/发送时间),旧行仍可解析。
|
|
9
|
+
|
|
10
|
+
**没有验证的**:真实微信通道上的到达确认与打扰频率手感;本轮只验证到"发出请求"与失败分类。
|
|
11
|
+
|
|
12
|
+
# 0.32.0 验证增量
|
|
13
|
+
|
|
14
|
+
2026-11-09,新增项目变化账本(`project_companion_pulse` 域)。
|
|
15
|
+
|
|
16
|
+
- `node --max-old-space-size=256 --test --test-concurrency=1 test/*.test.mjs`:2,390 项 / 2,353 通过 / 0 失败 / 37 跳过(0.31.0 基线 2,383 / 2,346 / 0 / 37)。
|
|
17
|
+
- 新增 7 条用例:首次只记账不报变化;HEAD/分支/未提交改动三项分别报出;无变化不产生噪音;读取失败保留旧记录;跨项目分开记账且上限 200;状态摘要不含路径;宿主级「第二次问进度报增量、第三次恢复安静」。
|
|
18
|
+
- 存储:新域 `project_companion_pulse`,行 schema 严格,只存指纹;`scripts/validate-state.mjs` 已登记该域,可被升级前自查覆盖。
|
|
19
|
+
|
|
20
|
+
**没有验证的**:事件触发的自动推送本身——本版只做账本与增量呈现,尚未在定时器里主动发出。
|
|
21
|
+
|
|
1
22
|
# 0.31.0 验证增量
|
|
2
23
|
|
|
3
24
|
2026-11-09,已授权但未关注的工作区可以直接问进度。
|
package/index.js
CHANGED
|
@@ -15,6 +15,7 @@ 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
17
|
import {createProjectPulse,summarize as summarizePulse} from './src/project-pulse.js';
|
|
18
|
+
import {createProjectPulseLedger,pulseLedgerRowSchema} from './src/project-pulse-ledger.js';
|
|
18
19
|
import {createProjectFollowup} from './src/project-followup.js';
|
|
19
20
|
import {createOnboarding,registerOnboardingRoute} from './src/onboarding.js';
|
|
20
21
|
import {createWelcomeGuard} from './src/welcome-guard.js';
|
|
@@ -95,6 +96,7 @@ const domainSpec=defineDomain({name:'project_companion',version:1,tables:{state:
|
|
|
95
96
|
const taskResultsDomainSpec=defineDomain({name:'project_companion_task_results',version:1,tables:{state:domainTable(taskResultsRowSchema)}});
|
|
96
97
|
const onboardingRow=z.object({id:z.literal('profile'),version:z.literal(1),completed:z.boolean(),welcomeStatus:z.enum(['none','dispatching','accepted','unknown']),sessionId:identity.nullable(),bindingKey:z.string().regex(/^[a-f0-9]{64}$/).nullable(),messageId:identity.nullable(),userReceivedAt:timestamp.optional(),welcomeRoots:z.array(z.string().min(1).max(4096)).min(1).max(5).optional(),previousAttempts:z.array(z.object({messageId:identity,status:z.enum(['stopped','no_text']),finishedAt:timestamp.optional()}).strict()).max(5).optional()}).strict();
|
|
97
98
|
const projectUpdatesDomainSpec=defineDomain({name:'project_companion_updates',version:1,tables:{state:domainTable(projectUpdateRowSchema)}});
|
|
99
|
+
const pulseLedgerDomainSpec=defineDomain({name:'project_companion_pulse',version:1,tables:{state:domainTable(pulseLedgerRowSchema)}});
|
|
98
100
|
const contextLoopDomainSpec=defineDomain({name:'project_companion_context_loop',version:1,tables:{state:domainTable(contextLoopRowSchema)}});
|
|
99
101
|
const contextDomainSpec=defineDomain({name:'project_companion_context',version:1,tables:{state:domainTable(contextRowSchema)}});
|
|
100
102
|
const familyDelegationRow=z.union([
|
|
@@ -148,6 +150,8 @@ export async function installCompanion(ctx,options={}){
|
|
|
148
150
|
const familyTable=familyDomain.table('state');
|
|
149
151
|
const projectUpdatesDomain=await ctx.storageDomain.open(projectUpdatesDomainSpec);
|
|
150
152
|
const projectUpdatesTable=projectUpdatesDomain.table('state');
|
|
153
|
+
const pulseLedgerDomain=await ctx.storageDomain.open(pulseLedgerDomainSpec);
|
|
154
|
+
const pulseLedgerTable=pulseLedgerDomain.table('state');
|
|
151
155
|
const contextLoopDomain=await ctx.storageDomain.open(contextLoopDomainSpec);
|
|
152
156
|
const contextLoopTable=contextLoopDomain.table('state');
|
|
153
157
|
const workspaceAccessDomain=await ctx.storageDomain.open(workspaceAccessDomainSpec);
|
|
@@ -159,7 +163,7 @@ export async function installCompanion(ctx,options={}){
|
|
|
159
163
|
let disposed=false;
|
|
160
164
|
const coordinates=new Set();
|
|
161
165
|
let lastRuntimeError='';
|
|
162
|
-
let projectPulse,memory,followup,onboarding,welcomeGuard,contextRoute,workbench,workbenchActions,projectUpdates,projectUpdateModel,contextLoop,context,familyDelegate,familyContext,personalReview,personalReviewModel;
|
|
166
|
+
let projectPulse,pulseLedger,memory,followup,onboarding,welcomeGuard,contextRoute,workbench,workbenchActions,projectUpdates,projectUpdateModel,contextLoop,context,familyDelegate,familyContext,personalReview,personalReviewModel;
|
|
163
167
|
// 污点标记只活在本进程内存里;这次装载从干净状态开始,不继承上一次运行的标记。
|
|
164
168
|
clearPrivateReads();
|
|
165
169
|
const lifecycle=new AbortController();
|
|
@@ -416,6 +420,7 @@ export async function installCompanion(ctx,options={}){
|
|
|
416
420
|
const noteError=error=>{lastRuntimeError=String(error?.message??error).slice(0,200);};
|
|
417
421
|
const authorizeRoot=async root=>(await service.coordinationTarget(root))?.root===root;
|
|
418
422
|
const familyRead=createFamilyReadAdapter({getBridge:getFamilyBridge,isCurrent:scope=>familyDelegate.current(scope),authorizeRoot,recheck:scope=>familyDelegate.recheck(scope)});
|
|
423
|
+
pulseLedger=options.pulseLedger??createProjectPulseLedger({store:{get:key=>pulseLedgerTable.get(key),put:(key,value)=>pulseLedgerTable.put(key,pulseLedgerRowSchema.parse(value))},...(options.clock?{clock:options.clock}:{})});
|
|
419
424
|
projectPulse=options.projectPulse??createProjectPulse({...(options.clock?{clock:options.clock}:{})});
|
|
420
425
|
memory=createProjectMemory({authorizeRoot,...(options.clock?{clock:options.clock}:{}),...(options.hostTimeZone?{hostTimeZone:options.hostTimeZone}:{})});
|
|
421
426
|
// Personal review is Owner-wide; it never borrows a synthetic project or a
|
|
@@ -473,6 +478,17 @@ export async function installCompanion(ctx,options={}){
|
|
|
473
478
|
readMemory:async(caller,root)=>{const result=await memory.inspect({root,sessionId:caller.sessionId});return[...result.goals,...result.entries].map(row=>({...row,text:reviewClean(row.text)}));},
|
|
474
479
|
});
|
|
475
480
|
personalReviewModel=options.personalReview?.model??createPersonalReviewModel(ctx,{...(options.clock?{clock:options.clock}:{})});
|
|
481
|
+
async function sendOwnerNotice(item){
|
|
482
|
+
if(disposed||lifecycle.signal.aborted)return{status:'failed'};
|
|
483
|
+
const familyScope=familyDelegate.scopeFor(item.sessionId);
|
|
484
|
+
if(item.sessionId.startsWith('family_owner_')||familyDelegate.matchesSession(item.sessionId)){
|
|
485
|
+
if(!familyScope||item.bindingKey!==familyScope.bindingRevision||!await familyDelegate.recheck(familyScope))return{status:'failed'};
|
|
486
|
+
try{const result=await getFamilyBridge()?.sendOwner({sessionId:item.sessionId,bindingRevision:familyScope.bindingRevision,text:item.text,requestId:item.requestId,authorize:()=>familyDelegate.current(familyScope)});return{status:result?.status==='accepted'?'reported_sent':result?.status==='failed'?'failed':'uncertain'};}catch{return{status:'uncertain'};}
|
|
487
|
+
}
|
|
488
|
+
const bridge=standaloneBridge(),binding=standaloneBinding(item.sessionId);
|
|
489
|
+
if(!bridge||!binding||binding.bindingKey!==item.bindingKey)return{status:'blocked'};
|
|
490
|
+
try{const result=await bridge.send({sessionId:item.sessionId,expectedBinding:item.bindingKey,requestId:item.requestId,text:item.text,authorize:()=>!disposed&&!lifecycle.signal.aborted});return{status:result?.status==='accepted'?'reported_sent':result?.status==='blocked'?'blocked':'uncertain'};}catch{return{status:'uncertain'};}
|
|
491
|
+
}
|
|
476
492
|
personalReview=createPersonalReviewService({
|
|
477
493
|
store:{get:key=>personalReviewTable.get(key),put:(key,value)=>personalReviewTable.put(key,personalReviewRowSchema.parse(value))},
|
|
478
494
|
readBinding:reviewBinding,readBindingSync:reviewBindingSync,authorization:reviewAuthorization,authorizationSync:reviewAuthorizationSync,
|
|
@@ -500,7 +516,7 @@ export async function installCompanion(ctx,options={}){
|
|
|
500
516
|
try{const result=await bridge.send({sessionId:item.sessionId,expectedBinding:item.bindingKey,requestId:item.requestId,text:item.text,authorize:()=>!disposed&&!lifecycle.signal.aborted&&!item.signal?.aborted&&item.authorize()===true});return{status:result?.status==='accepted'?'reported_sent':result?.status==='blocked'?'blocked':'uncertain'};}catch{return{status:'uncertain'};}
|
|
501
517
|
},
|
|
502
518
|
});
|
|
503
|
-
await personalReview.ready();
|
|
519
|
+
await personalReview.ready();await pulseLedger.ready();
|
|
504
520
|
|
|
505
521
|
const familyRoute={
|
|
506
522
|
getScope:sessionId=>familyDelegate.scopeFor(sessionId),
|
|
@@ -816,8 +832,8 @@ export async function installCompanion(ctx,options={}){
|
|
|
816
832
|
}
|
|
817
833
|
function syncTimer(){
|
|
818
834
|
if(disposed)return;
|
|
819
|
-
if((service.needsTimer()||taskResults.needsTimer()||news.needsTimer()||personalReview.needsTimer()||familyRecoveryPending)&&timer===undefined){timer=timers.setInterval(async()=>{try{await service.tick();await taskResults.tick();await news.tick();await personalReview.tick();if(familyRecoveryPending)await recoverFamilyPlans();}catch(error){noteError(error);}finally{syncTimer();}},15000);timer?.unref?.();}
|
|
820
|
-
else if(!service.needsTimer()&&!taskResults.needsTimer()&&!news.needsTimer()&&!personalReview.needsTimer()&&!familyRecoveryPending&&timer!==undefined){timers.clearInterval(timer);timer=undefined;}
|
|
835
|
+
if((service.needsTimer()||taskResults.needsTimer()||news.needsTimer()||personalReview.needsTimer()||pulseLedger.needsTimer()||familyRecoveryPending)&&timer===undefined){timer=timers.setInterval(async()=>{try{await service.tick();await taskResults.tick();await news.tick();await personalReview.tick();if(pulseLedger.needsTimer()&&!service.isPausedSync())await pulseLedger.tick({capture:root=>projectPulse.capture(root),notify:item=>sendOwnerNotice(item)});if(familyRecoveryPending)await recoverFamilyPlans();}catch(error){noteError(error);}finally{syncTimer();}},15000);timer?.unref?.();}
|
|
836
|
+
else if(!service.needsTimer()&&!taskResults.needsTimer()&&!news.needsTimer()&&!personalReview.needsTimer()&&!pulseLedger.needsTimer()&&!familyRecoveryPending&&timer!==undefined){timers.clearInterval(timer);timer=undefined;}
|
|
821
837
|
}
|
|
822
838
|
async function recoverFamilyPlans(){
|
|
823
839
|
if(disposed||familyRecoveryRunning)return;
|
|
@@ -900,6 +916,23 @@ export async function installCompanion(ctx,options={}){
|
|
|
900
916
|
return buildDoctorReport({now:clockNow(),hostTimeZone:zone,probes:doctorProbes(caller)});
|
|
901
917
|
}
|
|
902
918
|
async function act(agent,input){
|
|
919
|
+
if(input.action==='pulse_projects'){
|
|
920
|
+
const caller=owner(ctx,agent);
|
|
921
|
+
if(input.enabled===false){const view=await pulseLedger.disable();return{...view,text:'已停止项目变化提醒;不会再自动检查,也不会再发这类消息。'};}
|
|
922
|
+
const binding=await reviewBinding(caller.sessionId);
|
|
923
|
+
if(!binding?.bound)return{status:'blocked',text:'项目变化提醒要先连上微信:当前会话没有可用的微信绑定,所以没有开启。'};
|
|
924
|
+
const watched=await service.watchedProjects();
|
|
925
|
+
let projects=watched.map(row=>({root:row.root,label:row.label}));
|
|
926
|
+
if(input.project!==undefined){
|
|
927
|
+
const target=await service.coordinationTarget(input.project);
|
|
928
|
+
if(!target)return{status:'blocked',text:'没找到这个项目;先关注它再开启提醒。'};
|
|
929
|
+
projects=[{root:target.root,label:target.label}];
|
|
930
|
+
}
|
|
931
|
+
if(!projects.length)return{status:'blocked',text:'还没有关注项目;先关注一个项目,再开启变化提醒。'};
|
|
932
|
+
const minutes=Number.isSafeInteger(input.everyMinutes)?Math.min(1440,Math.max(5,input.everyMinutes)):30;
|
|
933
|
+
const view=await pulseLedger.enable({sessionId:caller.sessionId,bindingKey:binding.bindingKey,projects,intervalMinutes:minutes,capture:root=>projectPulse.capture(root)});
|
|
934
|
+
return{...view,text:`已开启:每 ${minutes} 分钟只看这 ${projects.length} 个项目的 git 变化,真的变了才发一条;没变不打扰。停止随时说一声。`};
|
|
935
|
+
}
|
|
903
936
|
if(input.action==='pause'){personalReview.suspend();news.suspend?.();context.suspend();projectUpdates.suspend();contextLoop.suspend();}
|
|
904
937
|
if(input.action==='unwatch'){
|
|
905
938
|
personalReview.suspend();projectUpdates.suspend();contextLoop.suspend();
|
|
@@ -947,7 +980,14 @@ export async function installCompanion(ctx,options={}){
|
|
|
947
980
|
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
981
|
catch(error){context.push(`${project.label}:项目记忆读取失败,内容未知。${String(error?.message??error).slice(0,120)}`);}}
|
|
949
982
|
if(projects.indexOf(project)<20){
|
|
950
|
-
try{
|
|
983
|
+
try{
|
|
984
|
+
const captured=await projectPulse.capture(project.root),pulse=summarizePulse(captured);
|
|
985
|
+
if(pulse)context.push(`${project.label} 最近变化\n${pulse}`);
|
|
986
|
+
if(captured?.repo===true){
|
|
987
|
+
try{const observed=await pulseLedger.observe({root:project.root,label:project.label,pulse:captured});if(observed?.changes?.length)context.push(`${project.label} 自上次查看以来:${observed.changes.join(';')}`);}
|
|
988
|
+
catch{context.push(`${project.label} 变化对比失败,本次只给当前状态。`);}
|
|
989
|
+
}
|
|
990
|
+
}
|
|
951
991
|
catch{context.push(`${project.label} 最近变化:本机读取失败,状态未知。`);}
|
|
952
992
|
}
|
|
953
993
|
}
|
|
@@ -1141,9 +1181,9 @@ export async function installCompanion(ctx,options={}){
|
|
|
1141
1181
|
}));
|
|
1142
1182
|
ctx.tools.register(defineTool({
|
|
1143
1183
|
name:'project_companion',
|
|
1144
|
-
description:'项目与交办。两类入口优先用:【看】action:look + view:progress=进展与卡点|change=相比上次的变化(本人明确问了才传 userRequested:true)|status=总状态|health=本机自检(doctor,只读本机状态,不发消息)|task=交办到哪了|once=一次检查|followup=周期跟进。【管】action:manage + op:watch/unwatch=关注或取消|memory/remember/correct_memory/forget_memory=项目记忆|pause/resume=暂停或恢复自动跟进|daily/cancel_daily=每日汇报|followup/cancel_followup
|
|
1184
|
+
description:'项目与交办。两类入口优先用:【看】action:look + view:progress=进展与卡点|change=相比上次的变化(本人明确问了才传 userRequested:true)|status=总状态|health=本机自检(doctor,只读本机状态,不发消息)|task=交办到哪了|once=一次检查|followup=周期跟进。【管】action:manage + op:watch/unwatch=关注或取消|memory/remember/correct_memory/forget_memory=项目记忆|pause/resume=暂停或恢复自动跟进|daily/cancel_daily=每日汇报|followup/cancel_followup=周期跟进配置|pulse=所有关注项目有变化才提醒(动作名 pulse_projects,可带 everyMinutes;enabled:false 关闭)。【做】保持独立动作:coordinate=明确要求执行或继续;remind=提醒;personal_context 读外部资料;personal_review 做回顾;ai_digest 做资讯。【兼容】旧动作名仍可用,不删是为了不破坏已安装:list、digest、project_update、status、doctor、task_status、once_status、cancel_once、followup_status、check_once、configure_daily、cancel_daily、configure_followup、cancel_followup、link_github、context_brief、context_status、context_handoff、context_check、context_forget,提醒取消用 cancel_reminder。新调用优先用 look/manage。',
|
|
1145
1185
|
parameters:{
|
|
1146
|
-
action:{type:'string',required:true,enum:['look','manage','doctor','watch','unwatch','list','digest','project_update','context_brief','context_status','context_handoff','context_check','context_forget','memory','remember','correct_memory','forget_memory','check_once','once_status','cancel_once','configure_followup','cancel_followup','followup_status','configure_daily','cancel_daily','pause','resume','remind','cancel_reminder','link_github','status','coordinate','task_status']},
|
|
1186
|
+
action:{type:'string',required:true,enum:['look','manage','doctor','watch','unwatch','list','digest','project_update','context_brief','context_status','context_handoff','context_check','context_forget','memory','remember','correct_memory','forget_memory','check_once','once_status','cancel_once','configure_followup','cancel_followup','followup_status','configure_daily','cancel_daily','pause','resume','remind','cancel_reminder','link_github','status','coordinate','task_status','pulse_projects']},
|
|
1147
1187
|
view:{type:'string',enum:LOOK_VIEWS,description:'look 的视角。'+SURFACE_COPY.look},
|
|
1148
1188
|
op:{type:'string',enum:MANAGE_OPS,description:'manage 的动作。'+SURFACE_COPY.manage},
|
|
1149
1189
|
reviewItemId:{type:'string',description:'coordinate可选:仅当本人任务全文明确引用个人回顾「事项原题」时,从prepare结果映射稳定itemId。目标须在该事项原回顾项目范围内;不自行添加源正文或宣称已处理。'},
|
|
@@ -1174,6 +1214,7 @@ export async function installCompanion(ctx,options={}){
|
|
|
1174
1214
|
sourceKind:{type:'string',enum:['user','assistant','file'],description:'remember来源角色。用户明确表达才用user并传userRequested:true;模型推断用assistant。'},
|
|
1175
1215
|
sourceReference:{type:'string',description:'remember来源:user/assistant用当前session:<会话ID>;file用项目内安全相对路径及可选行号,不得引用其他项目。内部填写,不让用户输入ID。'},
|
|
1176
1216
|
everyMinutes:{type:'number',description:'configure_followup:用户明确要求的跟进间隔,30–1440分钟;不默认开启。'},
|
|
1217
|
+
enabled:{type:'boolean',description:'pulse:省略或 true 表示开启提醒;false 表示关闭。'},
|
|
1177
1218
|
delaySeconds:{type:'number',description:'check_once:单次只读检查延迟,30–300整数秒;未指定默认60秒。无需用户输入命令。'},
|
|
1178
1219
|
},
|
|
1179
1220
|
output:{schema:{type:'object',additionalProperties:true},render:(args,value)=>{
|
package/package.json
CHANGED
|
@@ -23,6 +23,7 @@ const DOMAINS = {
|
|
|
23
23
|
project_companion_context_loop: ['context-loop.js', 'contextLoopRowSchema'],
|
|
24
24
|
project_companion_task_results: ['task-results.js', 'taskResultsRowSchema'],
|
|
25
25
|
project_companion_workspace_access: ['workspace-access.js', 'workspaceAccessRowSchema'],
|
|
26
|
+
project_companion_pulse: ['project-pulse-ledger.js', 'pulseLedgerRowSchema'],
|
|
26
27
|
};
|
|
27
28
|
|
|
28
29
|
if (!existsSync(storages)) {
|
package/src/action-surface.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* guard and test keeps working unchanged. Old action names stay valid.
|
|
7
7
|
*/
|
|
8
8
|
export const LOOK_VIEWS = ['progress', 'change', 'status', 'health', 'task', 'once', 'followup'];
|
|
9
|
-
export const MANAGE_OPS = ['watch', 'unwatch', 'memory', 'remember', 'correct_memory', 'forget_memory', 'pause', 'resume', 'daily', 'cancel_daily', 'followup', 'cancel_followup'];
|
|
9
|
+
export const MANAGE_OPS = ['watch', 'unwatch', 'memory', 'remember', 'correct_memory', 'forget_memory', 'pause', 'resume', 'daily', 'cancel_daily', 'followup', 'cancel_followup', 'pulse'];
|
|
10
10
|
|
|
11
11
|
const LOOK = {
|
|
12
12
|
progress: a => ({ action: 'digest', project: a.project, ...(a.detail ? { detail: a.detail } : {}) }),
|
|
@@ -31,6 +31,7 @@ const MANAGE = {
|
|
|
31
31
|
cancel_daily: () => ({ action: 'cancel_daily' }),
|
|
32
32
|
followup: a => ({ action: 'configure_followup', everyMinutes: a.everyMinutes, ...(a.project ? { project: a.project } : {}) }),
|
|
33
33
|
cancel_followup: a => ({ action: 'cancel_followup', ...(a.project ? { project: a.project } : {}) }),
|
|
34
|
+
pulse: a => ({ action: 'pulse_projects', ...(a.enabled === false ? { enabled: false } : {}), ...(a.project ? { project: a.project } : {}), ...(Number.isSafeInteger(a.everyMinutes) ? { everyMinutes: a.everyMinutes } : {}) }),
|
|
34
35
|
};
|
|
35
36
|
|
|
36
37
|
/** Pure translation. Unknown view/op or a missing discriminator throws, so a
|
|
@@ -53,5 +54,5 @@ export function normalizeSurfaceAction(args) {
|
|
|
53
54
|
/** What each composite view/op means, for the tool description and reports. */
|
|
54
55
|
export const SURFACE_COPY = {
|
|
55
56
|
look: 'progress=进展与卡点|change=相比上次的变化(需本人明确问了才传 userRequested:true)|status=助理总状态|health=本机自检(doctor)|task=交办到哪了|once=一次检查的状态|followup=周期跟进的状态',
|
|
56
|
-
manage: 'watch=关注项目|unwatch=取消关注|memory=读项目记忆|remember=记一条|correct_memory=改一条|forget_memory=忘一条|pause=暂停自动跟进|resume=恢复|daily=每日汇报时间|cancel_daily=取消日报|followup=设置周期跟进(要分钟数)|cancel_followup
|
|
57
|
+
manage: 'watch=关注项目|unwatch=取消关注|memory=读项目记忆|remember=记一条|correct_memory=改一条|forget_memory=忘一条|pause=暂停自动跟进|resume=恢复|daily=每日汇报时间|cancel_daily=取消日报|followup=设置周期跟进(要分钟数)|cancel_followup=取消周期跟进|pulse=所有关注项目有变化才提醒,可带 everyMinutes 与 enabled:false 关闭(动作名 pulse_projects)',
|
|
57
58
|
};
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import {z} from 'zod';
|
|
2
|
+
import {createHash} from 'node:crypto';
|
|
3
|
+
|
|
4
|
+
/** 项目变化账本:记住每个项目上次被看到时的样子,下次只报增量。
|
|
5
|
+
*
|
|
6
|
+
* 只存指纹级信息(提交短哈希、分支、未提交改动条数),不存文件内容、不存路径以外
|
|
7
|
+
* 的私人资料;读取失败时保留旧记录,不把"没读到"记成"没有变化"。
|
|
8
|
+
*/
|
|
9
|
+
const identity = z.string().min(1).max(200);
|
|
10
|
+
const timestamp = z.string().max(40);
|
|
11
|
+
const entrySchema = z.object({
|
|
12
|
+
id: identity, root: z.string().min(1).max(4096), label: z.string().max(120),
|
|
13
|
+
head: z.string().max(64).nullable(), branch: z.string().max(120).nullable(),
|
|
14
|
+
dirty: z.number().int().min(0).max(100000), at: timestamp,
|
|
15
|
+
}).strict();
|
|
16
|
+
const policySchema = z.object({
|
|
17
|
+
sessionId: identity,
|
|
18
|
+
bindingKey: z.string().regex(/^[a-f0-9]{64}$/),
|
|
19
|
+
projects: z.array(z.object({root: z.string().min(1).max(4096), label: z.string().max(120)}).strict()).min(1).max(50),
|
|
20
|
+
intervalMinutes: z.number().int().min(5).max(1440),
|
|
21
|
+
createdAt: timestamp, lastCheckAt: timestamp, lastNotifiedAt: timestamp.nullable(),
|
|
22
|
+
}).strict();
|
|
23
|
+
export const pulseLedgerRowSchema = z.object({
|
|
24
|
+
id: z.literal('profile'), version: z.literal(1),
|
|
25
|
+
projects: z.array(entrySchema).max(200),
|
|
26
|
+
policy: policySchema.nullable().optional(),
|
|
27
|
+
}).strict();
|
|
28
|
+
|
|
29
|
+
const key = root => createHash('sha256').update(String(root)).digest('hex').slice(0, 32);
|
|
30
|
+
const fresh = () => ({id: 'profile', version: 1, projects: [], policy: null});
|
|
31
|
+
|
|
32
|
+
const snapshot = (root, label, pulse) => ({
|
|
33
|
+
id: key(root), root, label: String(label ?? '').slice(0, 120),
|
|
34
|
+
head: pulse?.head ?? null, branch: pulse?.branch ?? null,
|
|
35
|
+
dirty: pulse?.dirty?.total ?? 0, at: pulse?.at ?? new Date(0).toISOString(),
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
function delta(previous, current, pulse) {
|
|
39
|
+
if (!previous) return null;
|
|
40
|
+
const changes = [];
|
|
41
|
+
if (previous.head !== current.head) {
|
|
42
|
+
const lines = (pulse?.commits ?? []).slice(0, 3).map(row => `${row.short} ${row.subject}`).join(';');
|
|
43
|
+
changes.push(`HEAD ${previous.head ?? '未知'} → ${current.head ?? '未知'}${lines ? `(${lines})` : ''}`);
|
|
44
|
+
}
|
|
45
|
+
if (previous.branch !== current.branch) changes.push(`分支 ${previous.branch ?? '未知'} → ${current.branch ?? '未知'}`);
|
|
46
|
+
if (previous.dirty !== current.dirty) {
|
|
47
|
+
const diff = current.dirty - previous.dirty;
|
|
48
|
+
changes.push(`未提交改动 ${previous.dirty} → ${current.dirty}${diff > 0 ? `(+${diff})` : `(${diff})`}`);
|
|
49
|
+
}
|
|
50
|
+
return changes.length ? changes : null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @param {object} options
|
|
55
|
+
* @param {{get:Function,put:Function}} options.store 存储单元
|
|
56
|
+
* @param {() => Date} [options.clock]
|
|
57
|
+
*/
|
|
58
|
+
export function createProjectPulseLedger({store, clock = () => new Date()} = {}) {
|
|
59
|
+
if (typeof store?.get !== 'function' || typeof store?.put !== 'function') throw new Error('Pulse ledger requires a persistent store');
|
|
60
|
+
let state;
|
|
61
|
+
|
|
62
|
+
let queue = Promise.resolve();
|
|
63
|
+
const serial = work => { const run = queue.then(work, work); queue = run.catch(() => {}); return run; };
|
|
64
|
+
|
|
65
|
+
async function load() {
|
|
66
|
+
if (state) return state;
|
|
67
|
+
const stored = await store.get('profile');
|
|
68
|
+
state = stored ? pulseLedgerRowSchema.parse(stored) : fresh();
|
|
69
|
+
return state;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const observe = args => serial(() => observeInner(args));
|
|
73
|
+
|
|
74
|
+
/** 对比并记账;返回自上次以来真正变了的项目。读取失败的项目保留旧记录。 */
|
|
75
|
+
async function observeInner({root, label, pulse}) {
|
|
76
|
+
const current = await load();
|
|
77
|
+
const next = snapshot(root, label, pulse);
|
|
78
|
+
const previous = current.projects.find(row => row.id === next.id) ?? null;
|
|
79
|
+
// 读不到就不记账:旧记录保留,"没读到"不能被记成"没有变化"。
|
|
80
|
+
if (pulse?.repo !== true) return {changed: false, changes: null, firstSeen: previous === null, skipped: true};
|
|
81
|
+
const changes = delta(previous, next, pulse);
|
|
82
|
+
current.projects = [...current.projects.filter(row => row.id !== next.id), next].slice(-200);
|
|
83
|
+
await store.put('profile', pulseLedgerRowSchema.parse(current));
|
|
84
|
+
return {changed: Boolean(changes), changes, firstSeen: previous === null};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async function status() {
|
|
88
|
+
const current = await load();
|
|
89
|
+
const policy = current.policy;
|
|
90
|
+
return {
|
|
91
|
+
version: 1,
|
|
92
|
+
projects: current.projects.map(row => ({label: row.label, head: row.head, branch: row.branch, dirty: row.dirty, at: row.at})),
|
|
93
|
+
watch: policy ? {intervalMinutes: policy.intervalMinutes, count: policy.projects.length, lastCheckAt: policy.lastCheckAt} : null,
|
|
94
|
+
text: policy
|
|
95
|
+
? `正在盯 ${policy.projects.length} 个项目,每 ${policy.intervalMinutes} 分钟看一次;只有真的变了才发消息。`
|
|
96
|
+
: current.projects.length
|
|
97
|
+
? `已记录 ${current.projects.length} 个项目的最近状态;还没有开启主动提醒。`
|
|
98
|
+
: '还没有记录任何项目的变化;看一次进度后才会开始记。',
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** 开启主动提醒:明确绑定到一个会话与绑定,换绑即失效,不自动迁移。 */
|
|
103
|
+
async function enable({sessionId, bindingKey, projects, intervalMinutes = 30, capture}) {
|
|
104
|
+
if (typeof sessionId !== 'string' || !sessionId || sessionId.length > 200) throw new Error('Pulse watch requires a session');
|
|
105
|
+
if (!/^[a-f0-9]{64}$/.test(String(bindingKey))) throw new Error('Pulse watch requires a current binding');
|
|
106
|
+
if (!Array.isArray(projects) || !projects.length || projects.length > 50) throw new Error('Pulse watch requires 1-50 projects');
|
|
107
|
+
const at = clock().toISOString();
|
|
108
|
+
const current = await load();
|
|
109
|
+
current.policy = {
|
|
110
|
+
sessionId, bindingKey,
|
|
111
|
+
projects: projects.map(row => ({root: row.root, label: String(row.label ?? '').slice(0, 120)})),
|
|
112
|
+
intervalMinutes, createdAt: at, lastCheckAt: at, lastNotifiedAt: null,
|
|
113
|
+
};
|
|
114
|
+
await store.put('profile', pulseLedgerRowSchema.parse(current));
|
|
115
|
+
// 立刻记一次基线:否则第一次到点检查只能记账,要再等一个间隔才能发现变化。
|
|
116
|
+
if (typeof capture === 'function') {
|
|
117
|
+
for (const project of current.policy.projects) {
|
|
118
|
+
let pulse; try { pulse = await capture(project.root); } catch { continue; }
|
|
119
|
+
if (pulse?.repo !== true) continue;
|
|
120
|
+
try { await observeInner({root: project.root, label: project.label, pulse}); } catch {}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return status();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
async function disable() {
|
|
127
|
+
const current = await load();
|
|
128
|
+
current.policy = null;
|
|
129
|
+
await store.put('profile', pulseLedgerRowSchema.parse(current));
|
|
130
|
+
return status();
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const needsTimer = () => Boolean(state?.policy);
|
|
134
|
+
|
|
135
|
+
/** 到点检查一次;只把真正变了的项目交给 notify,没有变化完全不打扰。 */
|
|
136
|
+
async function tickInner({capture, notify, now = clock()} = {}) {
|
|
137
|
+
if (typeof capture !== 'function' || typeof notify !== 'function') throw new Error('Pulse tick requires capture and notify');
|
|
138
|
+
const current = await load();
|
|
139
|
+
const policy = current.policy;
|
|
140
|
+
if (!policy) return {checked: 0, changed: 0};
|
|
141
|
+
if (now.getTime() - Date.parse(policy.lastCheckAt) < policy.intervalMinutes * 60000) return {checked: 0, changed: 0};
|
|
142
|
+
const changed = [];
|
|
143
|
+
for (const project of policy.projects) {
|
|
144
|
+
let pulse;
|
|
145
|
+
try { pulse = await capture(project.root); } catch { continue; }
|
|
146
|
+
if (pulse?.repo !== true) continue;
|
|
147
|
+
const observed = await observeInner({root: project.root, label: project.label, pulse});
|
|
148
|
+
if (observed.changes?.length) changed.push({label: project.label, changes: observed.changes});
|
|
149
|
+
}
|
|
150
|
+
policy.lastCheckAt = now.toISOString();
|
|
151
|
+
if (changed.length) {
|
|
152
|
+
const result = await notify({sessionId: policy.sessionId, bindingKey: policy.bindingKey, text: compose(changed), requestId: `pulse-${now.getTime()}`});
|
|
153
|
+
if (['reported_sent', 'queued'].includes(result?.status)) policy.lastNotifiedAt = now.toISOString();
|
|
154
|
+
}
|
|
155
|
+
await store.put('profile', pulseLedgerRowSchema.parse(current));
|
|
156
|
+
return {checked: policy.projects.length, changed: changed.length, delivered: changed.length > 0};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return {ready: load, observe, status, enable, disable, needsTimer, tick: args => serial(() => tickInner(args))};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** 推给本人的那段话:先说变了什么,再给一条能立刻做的下一步。 */
|
|
163
|
+
export function compose(changes) {
|
|
164
|
+
const lines = changes.slice(0, 6).map(row => `· ${row.label}:${row.changes.join(';')}`);
|
|
165
|
+
const more = changes.length > 6 ? `\n另有 ${changes.length - 6} 个项目也有变化,下次看进度时一起给。` : '';
|
|
166
|
+
return `项目有变化\n${lines.join('\n')}${more}\n\n建议:先看这几个项目最近的提交和未提交改动,决定是继续推进还是先收尾。这是本机 git 的变化,不代表任务已完成。`;
|
|
167
|
+
}
|