@evandu/super-pi 0.1.206 → 0.1.208
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/agents/project-leader.md +5 -3
- package/agents/super-pi-task/core.ts +1 -1
- package/dist/client/.super-pi-client-sources.json +7 -7
- package/dist/client/assets/{CodeMirrorEditor-KQDBvdAI.js → CodeMirrorEditor-DwrcXEYY.js} +2 -2
- package/dist/client/assets/{dist-Bz8mBVYg.js → dist-4ak44NZQ.js} +1 -1
- package/dist/client/assets/{dist-DpFdyk4c.js → dist-B6zrM0u4.js} +1 -1
- package/dist/client/assets/{dist-B2DwIkxS.js → dist-BJxViUrs.js} +1 -1
- package/dist/client/assets/{dist-DNFTA8eK.js → dist-BOEgsxxx.js} +1 -1
- package/dist/client/assets/{dist-EZxvaEWE.js → dist-BZWoEHZB.js} +1 -1
- package/dist/client/assets/{dist-B-wznWiJ.js → dist-BiBhoaIj.js} +1 -1
- package/dist/client/assets/{dist-DWD02ase.js → dist-BjPiwDOH.js} +1 -1
- package/dist/client/assets/{dist-xcgc6bsN.js → dist-BtkTzJx-.js} +1 -1
- package/dist/client/assets/{dist-Bim285Uv.js → dist-BvQXb6Gm.js} +1 -1
- package/dist/client/assets/{dist-DYys59TX.js → dist-CJTPl8e8.js} +1 -1
- package/dist/client/assets/{dist-B015qWBZ.js → dist-CPbgZWr6.js} +1 -1
- package/dist/client/assets/{dist-DNjtMha0.js → dist-CkiHQydv.js} +1 -1
- package/dist/client/assets/{dist-KL5ywpxl.js → dist-CmyNC3S-.js} +1 -1
- package/dist/client/assets/{dist-Ce0_mKRX.js → dist-D8SigXvW.js} +1 -1
- package/dist/client/assets/{dist-J3S-elPb.js → dist-DcrHAVus.js} +1 -1
- package/dist/client/assets/{dist-CWwcn5gh.js → dist-DgCku0zO.js} +1 -1
- package/dist/client/assets/{dist-50OrOetK.js → dist-DkQ7IzzE.js} +1 -1
- package/dist/client/assets/{dist-CA6dRqYD.js → dist-DrCHg03L.js} +1 -1
- package/dist/client/assets/{dist-1vBvKRAO.js → dist-DzeUf4I1.js} +1 -1
- package/dist/client/assets/{dist-BN2UnOQ2.js → dist-ZOHc7msq.js} +1 -1
- package/dist/client/assets/{dist-3nL837Fs.js → dist-k2Zy_gh4.js} +1 -1
- package/dist/client/assets/{dist-3UazBQPy.js → dist-xtg_Vigb.js} +1 -1
- package/dist/client/assets/{index-DcuTYCZ-.css → index-1gs_N5Ez.css} +1 -1
- package/dist/client/assets/{index-Bmx2_cFl.js → index-BWUV4T-z.js} +29 -29
- package/dist/client/index.html +2 -2
- package/dist/server/application/project-service.d.ts +5 -3
- package/dist/server/application/project-service.js +72 -40
- package/dist/server/team-context.d.ts +2 -2
- package/dist/server/team-context.js +2 -1
- package/dist/server/types.d.ts +4 -0
- package/dist/shared/project-overview.d.ts +50 -0
- package/dist/shared/project-overview.js +24 -0
- package/dist/shared/project-presentation.d.ts +52 -0
- package/dist/shared/project-presentation.js +103 -0
- package/dist/shared/team-context-view.d.ts +33 -0
- package/dist/shared/team-context-view.js +49 -0
- package/dist/shared/team-context.d.ts +7 -0
- package/package.json +5 -1
package/dist/client/index.html
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
<link rel="alternate icon" href="/favicon.ico" />
|
|
9
9
|
<link rel="apple-touch-icon" href="/favicon.svg" />
|
|
10
10
|
<title>Super Pi</title>
|
|
11
|
-
<script type="module" crossorigin src="/assets/index-
|
|
12
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
11
|
+
<script type="module" crossorigin src="/assets/index-BWUV4T-z.js"></script>
|
|
12
|
+
<link rel="stylesheet" crossorigin href="/assets/index-1gs_N5Ez.css">
|
|
13
13
|
</head>
|
|
14
14
|
<body>
|
|
15
15
|
<div id="root"></div>
|
|
@@ -19,8 +19,8 @@ import type { SessionOrchestratorService } from "./session-orchestrator-service.
|
|
|
19
19
|
* leader has no subordinates at all, so it is told the second half only - it must not decide
|
|
20
20
|
* alone either - and is never told about subordinates it does not have.
|
|
21
21
|
*/
|
|
22
|
-
export declare const STANDARD_LEADER_PROMPT = "\u4F60\u662F\u76F4\u63A5\u5411 Boss \u8D1F\u8D23\u7684\u9879\u76EE Leader\uFF0C\
|
|
23
|
-
export declare const LIGHTWEIGHT_LEADER_PROMPT = "\u4F60\u662F\u76F4\u63A5\u5411 Boss \u8D1F\u8D23\u7684\u9879\u76EE Leader\uFF0C\u8FD9\u662F\u4E00\u4E2A\u8F7B\u91CF\u9879\u76EE\uFF1A\u8FD9\u4E2A\u9879\u76EE\u7531\u4F60\u4EB2\u81EA\u5B8C\u6210\uFF0C\u4E0D\u8981\u62C6\u5B50\u4EFB\u52A1\u3001\u4E0D\u8981\u6D3E\u53D1\u7ED9\u522B\u4EBA\u3001\u4E5F\u6CA1\u6709\u72EC\u7ACB\u590D\u6838\u3002\u5F00\u7BC7\u4E0A\u4E0B\u6587\u5DF2\u7ED9\u51FA\u9879\u76EE\u76EE\u6807\u3001\u6A21\u5F0F\u4E0E\u5F53\u524D\u4EFB\u52A1\u6E05\u5355\uFF0C\u4E0D\u5FC5\u5148\u8C03\u7528 project(action=get) \u5C31\u80FD\u76F4\u63A5\u52A8\u624B\u3002\u7528 add_task \u767B\u8BB0\u4EFB\u52A1\uFF08\u660E\u786E\u76EE\u6807\u3001\u4EA4\u4ED8\u7269\u3001\u9A8C\u6536\u6807\u51C6\u3001\u4F9D\u8D56\uFF09\uFF0C\u4EFB\u52A1\u4E00\u5F8B\u767B\u8BB0\u4E3A\u6267\u884C\u4EFB\u52A1\uFF1Arole=leader \u6216\u5E26 parentTaskId \u90FD\u4F1A\u88AB\u62D2\u7EDD\u3002dispatch \u4F1A\u628A\u4EFB\u52A1\u4EA4\u56DE\u7ED9\u4F60\u81EA\u5DF1\uFF0C\u4F60\u4EB2\u81EA\u505A\u5B8C\uFF1B\u505A\u5B8C\u540E\u8C03\u7528 project(action=submit, projectId, taskId, output, evidenceRefs) \u63D0\u4EA4\u4EA4\u4ED8\uFF0C\u63D0\u4EA4\u5373\u5B8C\u6210\uFF0C\u4E0D\u4F1A\u6709\u4EBA\u56DE\u6765\u590D\u6838\uFF0C\u8BC1\u636E\u5FC5\u987B\u9644\u4E0A\u3002\u4E0D\u8981\u7528 session_spawn/session_dispatch \u6216 task/workflow \u7ED5\u5F00\u9879\u76EE\u804C\u8D23\u4E0E\u6C47\u62A5\u7EBF\u3002\u4E0D\u8981\u8F6E\u8BE2\u7B49\u5F85\uFF0C\u4E0D\u8981\u53CD\u590D\u65E0\u8FDB\u5C55\u91CD\u8BD5\u3002\u7528 report \
|
|
22
|
+
export declare const STANDARD_LEADER_PROMPT = "\u4F60\u662F\u76F4\u63A5\u5411 Boss \u8D1F\u8D23\u7684\u9879\u76EE Leader\uFF0C\u8D1F\u8D23\u654F\u6377\u5F00\u53D1\u4E0E\u5C0F\u6B65\u4EA4\u4ED8\u3002\u7528\u6237\u662F\u9876\u5C42\u51B3\u7B56\u8005\uFF0C\u4F60\u81EA\u884C\u5904\u7406\u5185\u90E8\u534F\u8C03\uFF0C\u53EA\u5411\u7528\u6237\u6C47\u603B\u8FDB\u5C55\u3001\u6210\u679C\u4E0E\u5FC5\u8981\u51B3\u7B56\u3002\u5F00\u7BC7\u4E0A\u4E0B\u6587\u5DF2\u7ED9\u51FA\u9879\u76EE\u76EE\u6807\u3001\u6A21\u5F0F\u3001\u5206\u5DE5\u4E0E\u5F53\u524D\u4EFB\u52A1\u6E05\u5355\uFF0C\u4E0D\u5FC5\u5148\u8C03\u7528 project(action=get) \u5C31\u80FD\u76F4\u63A5\u62C6\u89E3\u3001\u6D3E\u6D3B\u6216\u63A8\u8FDB\u3002\u5C0F\u9879\u76EE\u53EA\u62C6\u6700\u5C11\u5FC5\u8981\u4EFB\u52A1\uFF0C\u5927\u9879\u76EE\u6309\u4EA4\u4ED8\u8FB9\u754C\u5206\u5DE5\u3002\u7528 add_task \u767B\u8BB0\u4EFB\u52A1\uFF08\u660E\u786E\u76EE\u6807\u3001\u4EA4\u4ED8\u7269\u3001\u9A8C\u6536\u6807\u51C6\u3001\u4F9D\u8D56\uFF09\uFF1Badd_task / update_task \u65F6\u53EF\u4EE5\u5E26 executorProfile \u4E0E reviewerProfile\uFF08\u652F\u6301\u6307\u5B9A agentId\u3001cwd\u3001model\u3001thinkingLevel\u3001watchdogTimeoutSeconds\uFF09\uFF0C\u6309\u4EFB\u52A1\u6027\u8D28\u5C06\u6267\u884C\u4E0E\u590D\u6838\u59D4\u6D3E\u7ED9\u6700\u5408\u9002\u7684\u5458\u5DE5\uFF0C\u4E0D\u6307\u5B9A\u5219\u7EE7\u627F\u9879\u76EE\u9ED8\u8BA4\uFF1B\u9700\u8981\u7EE7\u7EED\u62C6\u89E3\u7684\u5DE5\u4F5C\u8BBE role=leader\uFF0C\u53F6\u5B50\u6267\u884C\u4EFB\u52A1\u8BBE role=executor\uFF0C\u5B50 Leader \u7528 parentTaskId \u767B\u8BB0\u81EA\u5DF1\u7684\u5B50\u4EFB\u52A1\uFF0Cdispatch \u7ACB\u5373\u542F\u52A8\u6267\u884C\u5B50\u4F1A\u8BDD\uFF1B\u4E0D\u8981\u7528 session_spawn/session_dispatch \u6216 task/workflow \u7ED5\u5F00\u9879\u76EE\u5206\u5DE5\u4E0E\u6C47\u62A5\u7EBF\u3002\u6536\u5230\u4EA4\u4ED8\u540E\u7528 request_review \u542F\u52A8\u72EC\u7ACB\u590D\u6838\u3002\u6D3E\u53D1\u540E\u5B50\u4F1A\u8BDD\u4F1A\u7ACB\u5373\u5F00\u59CB\u6267\u884C\u5E76\u5728\u5B8C\u6210\u540E\u81EA\u52A8\u56DE\u62A5\u7ED9\u4F60\uFF0C\u5C4A\u65F6\u7EE7\u7EED\u6D3E\u53D1 ready \u4EFB\u52A1\u3001\u590D\u6838\u5F85\u9A8C\u6536\u4EFB\u52A1\u6216\u6309 review.summary \u8FD4\u5DE5\uFF1B\u4E0D\u8981\u8F6E\u8BE2\u7B49\u5F85\uFF0C\u4E0D\u8981\u53CD\u590D\u65E0\u8FDB\u5C55\u91CD\u8BD5\uFF0C\u7B49\u5F85\u56DE\u62A5\u65F6\u76F4\u63A5\u7ED3\u675F\u5F53\u524D\u56DE\u590D\u3002\u7528 report \u767B\u8BB0\u5173\u952E\u8FDB\u5C55\u3002\u4F60\u7684\u4E0B\u5C5E\u7684\u5347\u7EA7\u5148\u5230\u4F60\u8FD9\u91CC\uFF1A\u4F60\u5728\u81EA\u5DF1\u8FD9\u4E00\u5C42\u5904\u7406\uFF0C\u80FD\u81EA\u5DF1\u89E3\u51B3\u7684\u81EA\u5DF1\u89E3\u51B3\uFF1B\u53EA\u6709\u786E\u5B9E\u9700\u8981 Boss \u51B3\u7B56\u7684\uFF08\u91CD\u5927\u504F\u5DEE\u3001\u6743\u9650\u6216\u8303\u56F4\u53D8\u66F4\uFF09\u624D\u7528 escalate \u4EA4\u7ED9 Boss\u3002\u4F60\u4E0D\u80FD\u66FF Boss \u505A\u51B3\u5B9A\uFF0C\u4E5F\u4E0D\u8981\u628A\u6CA1\u5904\u7406\u7684\u5347\u7EA7\u538B\u4E0B\u53BB\u4E0D\u7406\u3002\u6240\u6709\u4EFB\u52A1\u9A8C\u6536\u540E\uFF0C\u7528 complete \u63D0\u4EA4\u5E26\u8BC1\u636E\u7684\u6700\u7EC8\u4EA4\u4ED8\u603B\u7ED3\u3002\u4E0A\u4E0B\u6587\u6709\u9650\uFF0C\u660E\u786E\u5047\u8BBE\uFF0C\u4E3B\u52A8\u5BFB\u627E\u53CD\u8BC1\u3002\u53EA\u5728\u672C\u6B21\u89E6\u53D1\u8303\u56F4\u5185\u5DE5\u4F5C\u3002";
|
|
23
|
+
export declare const LIGHTWEIGHT_LEADER_PROMPT = "\u4F60\u662F\u76F4\u63A5\u5411 Boss \u8D1F\u8D23\u7684\u9879\u76EE Leader\uFF0C\u8FD9\u662F\u4E00\u4E2A\u8F7B\u91CF\u9879\u76EE\uFF1A\u8FD9\u4E2A\u9879\u76EE\u7531\u4F60\u4EB2\u81EA\u5B8C\u6210\uFF0C\u4E0D\u8981\u62C6\u5B50\u4EFB\u52A1\u3001\u4E0D\u8981\u6D3E\u53D1\u7ED9\u522B\u4EBA\u3001\u4E5F\u6CA1\u6709\u72EC\u7ACB\u590D\u6838\u3002\u5F00\u7BC7\u4E0A\u4E0B\u6587\u5DF2\u7ED9\u51FA\u9879\u76EE\u76EE\u6807\u3001\u6A21\u5F0F\u4E0E\u5F53\u524D\u4EFB\u52A1\u6E05\u5355\uFF0C\u4E0D\u5FC5\u5148\u8C03\u7528 project(action=get) \u5C31\u80FD\u76F4\u63A5\u52A8\u624B\u3002\u7528 add_task \u767B\u8BB0\u4EFB\u52A1\uFF08\u660E\u786E\u76EE\u6807\u3001\u4EA4\u4ED8\u7269\u3001\u9A8C\u6536\u6807\u51C6\u3001\u4F9D\u8D56\uFF09\uFF0C\u4EFB\u52A1\u4E00\u5F8B\u767B\u8BB0\u4E3A\u6267\u884C\u4EFB\u52A1\uFF1Arole=leader \u6216\u5E26 parentTaskId \u90FD\u4F1A\u88AB\u62D2\u7EDD\u3002dispatch \u4F1A\u628A\u4EFB\u52A1\u4EA4\u56DE\u7ED9\u4F60\u81EA\u5DF1\uFF0C\u4F60\u4EB2\u81EA\u505A\u5B8C\uFF1B\u505A\u5B8C\u540E\u8C03\u7528 project(action=submit, projectId, taskId, output, evidenceRefs) \u63D0\u4EA4\u4EA4\u4ED8\uFF0C\u63D0\u4EA4\u5373\u5B8C\u6210\uFF0C\u4E0D\u4F1A\u6709\u4EBA\u56DE\u6765\u590D\u6838\uFF0C\u8BC1\u636E\u5FC5\u987B\u9644\u4E0A\u3002\u4E0D\u8981\u7528 session_spawn/session_dispatch \u6216 task/workflow \u7ED5\u5F00\u9879\u76EE\u804C\u8D23\u4E0E\u6C47\u62A5\u7EBF\u3002\u4E0D\u8981\u8F6E\u8BE2\u7B49\u5F85\uFF0C\u4E0D\u8981\u53CD\u590D\u65E0\u8FDB\u5C55\u91CD\u8BD5\u3002\u7528 report \u6C47\u603B\u5173\u952E\u8FDB\u5C55\u3002\u666E\u901A\u6280\u672F\u51B3\u7B56\u3001\u963B\u585E\u4E0E\u8FD4\u5DE5\u7531\u4F60\u81EA\u884C\u5904\u7406\uFF1B\u53EA\u6709\u786E\u5B9E\u9700\u8981\u7528\u6237\u51B3\u5B9A\u7684\u76EE\u6807\u53D6\u820D\u3001\u6743\u9650\u6216\u5916\u90E8\u8D44\u6E90\u624D\u7528 escalate \u4EA4\u7ED9 Boss\uFF0C\u4E0D\u5F97\u66FF Boss \u51B3\u5B9A\u8FD9\u4E9B\u4E8B\u9879\u3002\u6240\u6709\u4EFB\u52A1\u4EA4\u4ED8\u540E\uFF0C\u7528 complete \u63D0\u4EA4\u5E26\u8BC1\u636E\u7684\u6700\u7EC8\u4EA4\u4ED8\u603B\u7ED3\u3002\u4E0A\u4E0B\u6587\u6709\u9650\uFF0C\u660E\u786E\u5047\u8BBE\uFF0C\u4E3B\u52A8\u5BFB\u627E\u53CD\u8BC1\u3002\u53EA\u5728\u672C\u6B21\u89E6\u53D1\u8303\u56F4\u5185\u5DE5\u4F5C\u3002";
|
|
24
24
|
export declare const profile: (value: unknown, label: string) => SessionProfile | undefined;
|
|
25
25
|
export declare const mergeProfile: (taskProfile?: SessionProfile, projectDefault?: SessionProfile) => SessionProfile | undefined;
|
|
26
26
|
/**
|
|
@@ -108,6 +108,7 @@ export declare class ProjectService {
|
|
|
108
108
|
shareContext(id: string, value: unknown, workspaceId: string, actor?: string): Promise<unknown>;
|
|
109
109
|
messageTask(id: string, taskId: string, content: string, workspaceId: string, actor?: string, targetConversationId?: string, deliveryMode?: string): Promise<unknown>;
|
|
110
110
|
getContext(id: string | undefined, workspaceId: string, actor?: string, taskId?: string, contextIds?: unknown): unknown;
|
|
111
|
+
private coordinationHints;
|
|
111
112
|
private assertWriteScope;
|
|
112
113
|
private taskCoordination;
|
|
113
114
|
private captureHandoff;
|
|
@@ -270,7 +271,8 @@ export declare class ProjectService {
|
|
|
270
271
|
private reconcile;
|
|
271
272
|
private resources;
|
|
272
273
|
list(workspaceId?: string): Project[];
|
|
273
|
-
headline(p: Project, actor?: string): string;
|
|
274
|
+
headline(p: Project, actor?: string, resources?: Project["resources"]): string;
|
|
275
|
+
private activitySessions;
|
|
274
276
|
private isActorRelated;
|
|
275
277
|
private projectSummary;
|
|
276
278
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { deriveProjectActivity, deriveTaskActivity } from "../../shared/project-presentation.js";
|
|
2
3
|
import { buildTeamHandoff, discoverTeamFiles, parseTeamContext, pathsOverlap, publishTeamContext, teamPaths } from "../team-context.js";
|
|
3
4
|
import { deriveReportingState, deriveSessionState, sessionStateWord, } from "../../shared/session-reporting.js";
|
|
4
5
|
const stamp = () => new Date().toISOString();
|
|
@@ -20,8 +21,8 @@ const stamp = () => new Date().toISOString();
|
|
|
20
21
|
* leader has no subordinates at all, so it is told the second half only - it must not decide
|
|
21
22
|
* alone either - and is never told about subordinates it does not have.
|
|
22
23
|
*/
|
|
23
|
-
export const STANDARD_LEADER_PROMPT = "你是直接向 Boss 负责的项目 Leader
|
|
24
|
-
export const LIGHTWEIGHT_LEADER_PROMPT = "你是直接向 Boss 负责的项目 Leader,这是一个轻量项目:这个项目由你亲自完成,不要拆子任务、不要派发给别人、也没有独立复核。开篇上下文已给出项目目标、模式与当前任务清单,不必先调用 project(action=get) 就能直接动手。用 add_task 登记任务(明确目标、交付物、验收标准、依赖),任务一律登记为执行任务:role=leader 或带 parentTaskId 都会被拒绝。dispatch 会把任务交回给你自己,你亲自做完;做完后调用 project(action=submit, projectId, taskId, output, evidenceRefs) 提交交付,提交即完成,不会有人回来复核,证据必须附上。不要用 session_spawn/session_dispatch 或 task/workflow 绕开项目职责与汇报线。不要轮询等待,不要反复无进展重试。用 report
|
|
24
|
+
export const STANDARD_LEADER_PROMPT = "你是直接向 Boss 负责的项目 Leader,负责敏捷开发与小步交付。用户是顶层决策者,你自行处理内部协调,只向用户汇总进展、成果与必要决策。开篇上下文已给出项目目标、模式、分工与当前任务清单,不必先调用 project(action=get) 就能直接拆解、派活或推进。小项目只拆最少必要任务,大项目按交付边界分工。用 add_task 登记任务(明确目标、交付物、验收标准、依赖);add_task / update_task 时可以带 executorProfile 与 reviewerProfile(支持指定 agentId、cwd、model、thinkingLevel、watchdogTimeoutSeconds),按任务性质将执行与复核委派给最合适的员工,不指定则继承项目默认;需要继续拆解的工作设 role=leader,叶子执行任务设 role=executor,子 Leader 用 parentTaskId 登记自己的子任务,dispatch 立即启动执行子会话;不要用 session_spawn/session_dispatch 或 task/workflow 绕开项目分工与汇报线。收到交付后用 request_review 启动独立复核。派发后子会话会立即开始执行并在完成后自动回报给你,届时继续派发 ready 任务、复核待验收任务或按 review.summary 返工;不要轮询等待,不要反复无进展重试,等待回报时直接结束当前回复。用 report 登记关键进展。你的下属的升级先到你这里:你在自己这一层处理,能自己解决的自己解决;只有确实需要 Boss 决策的(重大偏差、权限或范围变更)才用 escalate 交给 Boss。你不能替 Boss 做决定,也不要把没处理的升级压下去不理。所有任务验收后,用 complete 提交带证据的最终交付总结。上下文有限,明确假设,主动寻找反证。只在本次触发范围内工作。";
|
|
25
|
+
export const LIGHTWEIGHT_LEADER_PROMPT = "你是直接向 Boss 负责的项目 Leader,这是一个轻量项目:这个项目由你亲自完成,不要拆子任务、不要派发给别人、也没有独立复核。开篇上下文已给出项目目标、模式与当前任务清单,不必先调用 project(action=get) 就能直接动手。用 add_task 登记任务(明确目标、交付物、验收标准、依赖),任务一律登记为执行任务:role=leader 或带 parentTaskId 都会被拒绝。dispatch 会把任务交回给你自己,你亲自做完;做完后调用 project(action=submit, projectId, taskId, output, evidenceRefs) 提交交付,提交即完成,不会有人回来复核,证据必须附上。不要用 session_spawn/session_dispatch 或 task/workflow 绕开项目职责与汇报线。不要轮询等待,不要反复无进展重试。用 report 汇总关键进展。普通技术决策、阻塞与返工由你自行处理;只有确实需要用户决定的目标取舍、权限或外部资源才用 escalate 交给 Boss,不得替 Boss 决定这些事项。所有任务交付后,用 complete 提交带证据的最终交付总结。上下文有限,明确假设,主动寻找反证。只在本次触发范围内工作。";
|
|
25
26
|
const text = (value, label) => {
|
|
26
27
|
if (typeof value !== "string" || !value.trim())
|
|
27
28
|
throw new Error(`${label} 不能为空`);
|
|
@@ -164,7 +165,7 @@ const PROJECT_STATUS_TEXT = {
|
|
|
164
165
|
awaiting_review: "等待复核", completed: "已完成", cancelled: "已取消", failed: "失败",
|
|
165
166
|
};
|
|
166
167
|
const TASK_STATUS_TEXT = {
|
|
167
|
-
pending: "等待依赖", ready: "待派发", in_progress: "
|
|
168
|
+
pending: "等待依赖", ready: "待派发", in_progress: "执行阶段", interrupted: "已中断", blocked: "已阻塞",
|
|
168
169
|
awaiting_review: "待复核", completed: "已完成", failed: "失败", cancelled: "已取消",
|
|
169
170
|
};
|
|
170
171
|
const EVENT_TEXT = {
|
|
@@ -367,22 +368,25 @@ export class ProjectService {
|
|
|
367
368
|
return this.change(id, workspaceId, p => { this.live(p); this.publishContext(p, value, actor); return { revision: p.contextRevision ?? 0, entries: p.sharedContext ?? [] }; });
|
|
368
369
|
}
|
|
369
370
|
async messageTask(id, taskId, content, workspaceId, actor, targetConversationId, deliveryMode = "queue") {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
this.
|
|
371
|
+
return this.change(id, workspaceId, async (p) => {
|
|
372
|
+
this.live(p);
|
|
373
|
+
const task = this.task(p, taskId);
|
|
374
|
+
this.manager(p, task, actor);
|
|
375
|
+
if (!["in_progress", "awaiting_review", "blocked"].includes(task.status))
|
|
376
|
+
throw new Error("补充指令只用于执行、复核或阻塞中的任务;新工作请登记任务,返工请重新派发原任务");
|
|
377
|
+
if (!["queue", "steer"].includes(deliveryMode))
|
|
378
|
+
throw new Error("deliveryMode 只能是 queue 或 steer");
|
|
379
|
+
const target = targetConversationId ?? task.ownerConversationId;
|
|
380
|
+
if (!target || ![task.ownerConversationId, task.reviewerConversationId].includes(target))
|
|
381
|
+
throw new Error("补充指令只能发送给本任务已有的执行或复核会话");
|
|
382
|
+
if (target === task.ownerConversationId)
|
|
383
|
+
this.assertWriteScope(p, task);
|
|
384
|
+
if (!busy(this.store.conversation(target)?.status))
|
|
385
|
+
this.admission(p);
|
|
386
|
+
const result = await this.dispatchContext(target, text(content, "补充指令"), { wait: false, mode: deliveryMode }, task.id);
|
|
387
|
+
this.event(p, "task_message", `向「${task.title}」发送补充指令(${deliveryMode === "steer" ? "下一工具边界" : "排队"}),附带当前共享上下文`, task.id, actor);
|
|
388
|
+
return result;
|
|
384
389
|
});
|
|
385
|
-
return result;
|
|
386
390
|
}
|
|
387
391
|
getContext(id, workspaceId, actor, taskId, contextIds) {
|
|
388
392
|
const p = id ? this.raw(id, workspaceId) : actor ? this.projectForSession(actor) : undefined;
|
|
@@ -391,6 +395,7 @@ export class ProjectService {
|
|
|
391
395
|
if (p.workspaceId !== workspaceId)
|
|
392
396
|
throw new Error("项目不属于当前工作区");
|
|
393
397
|
this.member(p, actor);
|
|
398
|
+
this.reconcileInterrupted(p);
|
|
394
399
|
const assigned = taskId ? this.task(p, taskId) : actor === p.ownerConversationId ? undefined : p.tasks.filter(item => item.ownerConversationId === actor || item.reviewerConversationId === actor)
|
|
395
400
|
.sort((a, b) => Number(b.status === "in_progress" || b.status === "awaiting_review") - Number(a.status === "in_progress" || a.status === "awaiting_review") || (b.dispatchedAt ?? b.updatedAt).localeCompare(a.dispatchedAt ?? a.updatedAt))[0];
|
|
396
401
|
const task = assigned && actor && assigned.reviewerConversationId === actor ? { ...assigned, readOnly: true, ownedPaths: [] } : assigned;
|
|
@@ -403,8 +408,32 @@ export class ProjectService {
|
|
|
403
408
|
const source = assigned && actor && assigned.reviewerConversationId === actor ? assigned.ownerConversationId
|
|
404
409
|
: task?.parentTaskId ? p.tasks.find(parent => parent.id === task.parentTaskId)?.ownerConversationId : p.ownerConversationId;
|
|
405
410
|
const files = workspace && source ? discoverTeamFiles(this.store.conversation(source), workspace.path) : [];
|
|
406
|
-
const
|
|
407
|
-
|
|
411
|
+
const coordination = actor ? this.coordinationHints(p, actor) : [];
|
|
412
|
+
const handoff = buildTeamHandoff(p, task, source, files, actor ? this.store.conversation(actor)?.cwd : undefined, coordination);
|
|
413
|
+
return { projectId: p.id, revision: p.contextRevision ?? 0, ...handoff, coordination, navigationFiles: files };
|
|
414
|
+
}
|
|
415
|
+
coordinationHints(p, actor) {
|
|
416
|
+
if (closed(p))
|
|
417
|
+
return [];
|
|
418
|
+
const direct = p.tasks.filter(task => (task.parentTaskId ? p.tasks.find(parent => parent.id === task.parentTaskId)?.ownerConversationId : p.ownerConversationId) === actor);
|
|
419
|
+
const internal = p.escalations.filter(item => item.status === "open" && item.audience === "supervisor" && item.targetConversationId === actor);
|
|
420
|
+
const hints = internal.map(item => ({ action: "resolve_escalation", escalationId: item.id, taskId: item.taskId, reason: "先判断并处理直属成员的问题;普通技术决策由你解决,不转成用户待办" }));
|
|
421
|
+
for (const task of direct) {
|
|
422
|
+
if (["ready", "interrupted"].includes(task.status))
|
|
423
|
+
hints.push({ action: "dispatch", taskId: task.id, reason: task.status === "interrupted" ? "恢复原任务并派回原会话,先自行处理执行中断" : "已具备执行条件,可直接派发" });
|
|
424
|
+
else if (task.status === "awaiting_review") {
|
|
425
|
+
if (!task.reviewerConversationId)
|
|
426
|
+
hints.push({ action: "request_review", taskId: task.id, reason: "交付已提交,由你安排独立复核,不要求用户调度" });
|
|
427
|
+
else if (["completed", "idle", "failed", "stopped"].includes(this.store.conversation(task.reviewerConversationId)?.status ?? ""))
|
|
428
|
+
hints.push({ action: "message", taskId: task.id, targetConversationId: task.reviewerConversationId, reason: "继续原复核会话并要求给出结论" });
|
|
429
|
+
}
|
|
430
|
+
else if (task.ownerConversationId && (task.status === "in_progress" && ["completed", "idle"].includes(this.store.conversation(task.ownerConversationId)?.status ?? "") || task.status === "blocked" && !internal.some(item => item.taskId === task.id))) {
|
|
431
|
+
hints.push({ action: "message", taskId: task.id, reason: task.status === "blocked" ? "先排查并协调阻塞,给原执行者明确下一步;仅确需用户提供取舍或权限时才上收" : "本轮已结束但尚未交付,继续原会话或要求提交,不等待用户安排" });
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
if (actor === p.ownerConversationId && p.tasks.length && this.requiredComplete(p) && !p.escalations.some(item => item.status === "open"))
|
|
435
|
+
hints.push({ action: "complete", reason: "必需任务已验收,汇总成果与证据完成项目,不让用户替你收尾" });
|
|
436
|
+
return hints;
|
|
408
437
|
}
|
|
409
438
|
assertWriteScope(p, task) {
|
|
410
439
|
if (task.readOnly || !task.ownedPaths?.length)
|
|
@@ -540,7 +569,8 @@ export class ProjectService {
|
|
|
540
569
|
...p,
|
|
541
570
|
status: this.statusWithInterruptions(p),
|
|
542
571
|
resources,
|
|
543
|
-
|
|
572
|
+
activity: deriveProjectActivity({ ...p, status: this.statusWithInterruptions(p), resources }),
|
|
573
|
+
tasks: p.tasks.map((t) => ({ ...ProjectService.taskView(t, p), activity: deriveTaskActivity(t, resources.sessions, p.mode, p.tasks) })),
|
|
544
574
|
escalations: this.filterEscalations(p.escalations ?? [], actor),
|
|
545
575
|
};
|
|
546
576
|
}
|
|
@@ -985,6 +1015,7 @@ export class ProjectService {
|
|
|
985
1015
|
// WHOSE MEMORY THIS SESSION WORKS FROM. The project's own tree is the one the leader
|
|
986
1016
|
// opened; anything else is a session that still shares the initiator's chat memory.
|
|
987
1017
|
memoryTreeId: c.treeId,
|
|
1018
|
+
cwd: c.cwd,
|
|
988
1019
|
memoryScope: projectTreeId && c.treeId === projectTreeId ? "project" : "shared",
|
|
989
1020
|
role: c.id === p.ownerConversationId ? "项目负责人" : coordinatorIds.has(c.id) ? "分支 Leader" : p.tasks.some((t) => t.reviewerConversationId === c.id) ? "独立复核" : "执行者",
|
|
990
1021
|
};
|
|
@@ -1035,7 +1066,7 @@ export class ProjectService {
|
|
|
1035
1066
|
const scope = this.workspace(workspaceId);
|
|
1036
1067
|
return this.store.projects().filter((p) => p.workspaceId === scope).map((p) => this.projectView(p));
|
|
1037
1068
|
}
|
|
1038
|
-
headline(p, actor) {
|
|
1069
|
+
headline(p, actor, resources) {
|
|
1039
1070
|
const total = p.tasks.length;
|
|
1040
1071
|
const completed = p.tasks.filter((t) => t.status === "completed").length;
|
|
1041
1072
|
if (p.status === "completed") {
|
|
@@ -1053,7 +1084,7 @@ export class ProjectService {
|
|
|
1053
1084
|
: `项目已阻塞:${openEscalation.reason}`;
|
|
1054
1085
|
}
|
|
1055
1086
|
const blockedTask = p.tasks.find((t) => t.status === "blocked");
|
|
1056
|
-
if (blockedTask) {
|
|
1087
|
+
if (blockedTask && p.status === "blocked") {
|
|
1057
1088
|
const reason = blockedTask.blockedReason ? `(${blockedTask.blockedReason})` : "";
|
|
1058
1089
|
return `项目已阻塞:${blockedTask.title}${reason}`;
|
|
1059
1090
|
}
|
|
@@ -1070,22 +1101,15 @@ export class ProjectService {
|
|
|
1070
1101
|
if (interruptedTask) {
|
|
1071
1102
|
return `${completed}/${total} 任务完成,${interruptedTask.title} 已中断(执行会话不在了),等待恢复`;
|
|
1072
1103
|
}
|
|
1073
|
-
const
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
const
|
|
1082
|
-
if (readyTask) {
|
|
1083
|
-
return `${completed}/${total} 任务完成,待派发${readyTask.title}`;
|
|
1084
|
-
}
|
|
1085
|
-
if (total > 0) {
|
|
1086
|
-
return `${completed}/${total} 任务完成,等待前置依赖`;
|
|
1087
|
-
}
|
|
1088
|
-
return "项目规划中,尚未拆解任务";
|
|
1104
|
+
const sessions = this.activitySessions(p);
|
|
1105
|
+
const current = deriveProjectActivity({ ...p, resources: resources ?? this.resources(p) });
|
|
1106
|
+
const task = p.tasks.find(item => deriveTaskActivity(item, sessions, p.mode, p.tasks).kind === current.kind) ?? blockedTask;
|
|
1107
|
+
const label = current.kind === "executing" ? "正在执行" : current.kind === "reviewing" ? "正在复核" : current.label;
|
|
1108
|
+
return total > 0 ? `${completed}/${total} 任务完成,${label}${task ? `:${task.title}` : ""}` : "项目规划中,尚未拆解任务";
|
|
1109
|
+
}
|
|
1110
|
+
activitySessions(p) {
|
|
1111
|
+
const ids = new Set([p.ownerConversationId, ...p.tasks.flatMap(task => [task.ownerConversationId, task.reviewerConversationId])].filter(Boolean));
|
|
1112
|
+
return [...ids].flatMap(id => { const session = this.store.conversation(id); return session ? [{ id, status: session.status }] : []; });
|
|
1089
1113
|
}
|
|
1090
1114
|
isActorRelated(p, actor) {
|
|
1091
1115
|
return this.isMember(p, actor);
|
|
@@ -1101,7 +1125,8 @@ export class ProjectService {
|
|
|
1101
1125
|
name: p.title,
|
|
1102
1126
|
status: this.statusWithInterruptions(p),
|
|
1103
1127
|
mode: p.mode ?? "standard",
|
|
1104
|
-
headline: this.headline(p, actor),
|
|
1128
|
+
headline: this.headline(p, actor, resources),
|
|
1129
|
+
activity: deriveProjectActivity({ ...p, status: this.statusWithInterruptions(p), resources }),
|
|
1105
1130
|
tasks: {
|
|
1106
1131
|
total: p.tasks.length,
|
|
1107
1132
|
completed: p.tasks.filter((t) => t.status === "completed").length,
|
|
@@ -1195,6 +1220,10 @@ export class ProjectService {
|
|
|
1195
1220
|
lines.push(`> 验收标准:${p.acceptanceCriteria.map(oneLine).join(";")}`);
|
|
1196
1221
|
lines.push("", "## 概览", "");
|
|
1197
1222
|
lines.push(`- 状态:${PROJECT_STATUS_TEXT[p.status] ?? p.status}`);
|
|
1223
|
+
const activitySessions = this.activitySessions(p);
|
|
1224
|
+
const projectActivity = deriveProjectActivity({ ...p, resources: { sessions: activitySessions } });
|
|
1225
|
+
lines.push(`- 当前活动:${projectActivity.label}`);
|
|
1226
|
+
lines.push(`- 下一步:${projectActivity.nextStep}`);
|
|
1198
1227
|
lines.push(`- 模式:${lightweight(p) ? "轻量" : "标准"}`);
|
|
1199
1228
|
lines.push(`- 风险:${SEVERITY_TEXT[p.risk] ?? p.risk}`);
|
|
1200
1229
|
lines.push(`- 创建时间:${moment(p.createdAt)}`);
|
|
@@ -1212,6 +1241,9 @@ export class ProjectService {
|
|
|
1212
1241
|
lines.push(`### ${index + 1}. ${oneLine(t.title)}`, "");
|
|
1213
1242
|
lines.push(`- 角色:${role(t)}`);
|
|
1214
1243
|
lines.push(`- 状态:${TASK_STATUS_TEXT[t.status] ?? t.status}`);
|
|
1244
|
+
const taskActivity = deriveTaskActivity(t, activitySessions, p.mode, p.tasks);
|
|
1245
|
+
lines.push(`- 当前活动:${taskActivity.label}`);
|
|
1246
|
+
lines.push(`- 下一步:${taskActivity.nextStep}`);
|
|
1215
1247
|
if (t.status === "interrupted")
|
|
1216
1248
|
lines.push(`- 中断原因:${oneLine(t.interruptedReason ?? "执行会话不在了")}`);
|
|
1217
1249
|
lines.push(`- 负责人:${t.ownerConversationId ? session(t.ownerConversationId) : "未派发"}`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Conversation, Project, ProjectTask } from "./types.js";
|
|
2
|
-
import type { DiscoveryFile, TeamContextEntry, TeamContextInput, TeamHandoff } from "../shared/team-context.js";
|
|
2
|
+
import type { CoordinationHint, DiscoveryFile, TeamContextEntry, TeamContextInput, TeamHandoff } from "../shared/team-context.js";
|
|
3
3
|
export declare const TEAM_CONTEXT_BYTES = 16000;
|
|
4
4
|
/** Coordination paths are workspace-relative, independent of an employee's optional cwd. */
|
|
5
5
|
export declare function teamPaths(value: unknown): string[];
|
|
@@ -9,4 +9,4 @@ export declare function parseTeamContext(value: unknown): TeamContextInput[];
|
|
|
9
9
|
export declare function publishTeamContext(project: Project, inputs: TeamContextInput[], actor: string, canEdit: (entry: TeamContextEntry) => boolean): void;
|
|
10
10
|
/** Share navigation metadata only. Reading a file is not a finding, and tool output stays private. */
|
|
11
11
|
export declare function discoverTeamFiles(conversation: Conversation | undefined, workspace: string): DiscoveryFile[];
|
|
12
|
-
export declare function buildTeamHandoff(project: Project, task?: ProjectTask, sourceConversationId?: string, discoveryFiles?: DiscoveryFile[], sessionCwd?: string): TeamHandoff;
|
|
12
|
+
export declare function buildTeamHandoff(project: Project, task?: ProjectTask, sourceConversationId?: string, discoveryFiles?: DiscoveryFile[], sessionCwd?: string, coordination?: CoordinationHint[]): TeamHandoff;
|
|
@@ -124,7 +124,7 @@ const clip = (value, bytes) => {
|
|
|
124
124
|
}
|
|
125
125
|
return out;
|
|
126
126
|
};
|
|
127
|
-
export function buildTeamHandoff(project, task, sourceConversationId, discoveryFiles = [], sessionCwd = "") {
|
|
127
|
+
export function buildTeamHandoff(project, task, sourceConversationId, discoveryFiles = [], sessionCwd = "", coordination = []) {
|
|
128
128
|
const words = `${task?.title ?? project.title} ${task?.objective ?? project.objective} ${(task?.ownedPaths ?? []).join(" ")}`.normalize("NFKC").toLocaleLowerCase().match(/[\p{L}\p{N}_-]{2,}/gu) ?? [];
|
|
129
129
|
const active = (project.sharedContext ?? []).filter(entry => entry.status !== "withdrawn" && (!entry.taskIds.length || !task || entry.taskIds.includes(task.id) || entry.taskIds.some(id => task.dependencies.includes(id))));
|
|
130
130
|
const rank = (entry) => (task && entry.taskIds.includes(task.id) ? 1000 : 0) + (entry.kind === "decision" ? 50 : 0)
|
|
@@ -140,6 +140,7 @@ export function buildTeamHandoff(project, task, sourceConversationId, discoveryF
|
|
|
140
140
|
let frameDivisor = 1;
|
|
141
141
|
const frameClip = (value, bytes) => clip(value, Math.floor(bytes / frameDivisor));
|
|
142
142
|
const data = () => ({ projectId: project.id, revision: project.contextRevision ?? 0, entries: selected,
|
|
143
|
+
coordination: coordination.slice(0, 6).map(item => ({ ...item, reason: clip(item.reason, 120) })), omittedCoordination: Math.max(0, coordination.length - 6),
|
|
143
144
|
frameAbbreviated: frameDivisor > 1,
|
|
144
145
|
sessionCwd: Buffer.byteLength(sessionCwd) <= 512 ? sessionCwd || "." : undefined, sessionCwdOmitted: Buffer.byteLength(sessionCwd) > 512, pathBase: "workspace",
|
|
145
146
|
project: { title: frameClip(project.title, 160), objective: frameClip(project.objective, 500), objectiveTruncated: Buffer.byteLength(project.objective) > 500 / frameDivisor,
|
package/dist/server/types.d.ts
CHANGED
|
@@ -1005,6 +1005,7 @@ export type SessionProfile = {
|
|
|
1005
1005
|
watchdogTimeoutSeconds?: number;
|
|
1006
1006
|
};
|
|
1007
1007
|
export type ProjectTask = {
|
|
1008
|
+
activity?: import("../shared/project-presentation.js").ProjectActivity;
|
|
1008
1009
|
handoffNote?: string;
|
|
1009
1010
|
ownedPaths?: string[];
|
|
1010
1011
|
readOnly?: boolean;
|
|
@@ -1094,6 +1095,7 @@ export type ProjectEvent = {
|
|
|
1094
1095
|
createdAt: string;
|
|
1095
1096
|
};
|
|
1096
1097
|
export type Project = {
|
|
1098
|
+
activity?: import("../shared/project-presentation.js").ProjectActivity;
|
|
1097
1099
|
sharedContext?: import("../shared/team-context.js").TeamContextEntry[];
|
|
1098
1100
|
contextRevision?: number;
|
|
1099
1101
|
id: string;
|
|
@@ -1167,6 +1169,7 @@ export type Project = {
|
|
|
1167
1169
|
parentConversationId?: string;
|
|
1168
1170
|
memoryTreeId?: string;
|
|
1169
1171
|
memoryScope?: "project" | "shared";
|
|
1172
|
+
cwd?: string;
|
|
1170
1173
|
}[];
|
|
1171
1174
|
};
|
|
1172
1175
|
tasks: ProjectTask[];
|
|
@@ -1177,6 +1180,7 @@ export type Project = {
|
|
|
1177
1180
|
closedAt?: string;
|
|
1178
1181
|
};
|
|
1179
1182
|
export type ProjectSummary = {
|
|
1183
|
+
activity?: import("../shared/project-presentation.js").ProjectActivity;
|
|
1180
1184
|
id: string;
|
|
1181
1185
|
name: string;
|
|
1182
1186
|
status: string;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export type OverviewReport = {
|
|
2
|
+
id: string;
|
|
3
|
+
kind?: string;
|
|
4
|
+
taskId?: string;
|
|
5
|
+
authorConversationId?: string;
|
|
6
|
+
progress?: string;
|
|
7
|
+
summary?: string;
|
|
8
|
+
evidenceRefs?: string[];
|
|
9
|
+
createdAt?: string;
|
|
10
|
+
};
|
|
11
|
+
export type OverviewDecision = {
|
|
12
|
+
id: string;
|
|
13
|
+
status?: "open" | "resolved" | "dismissed" | "returned";
|
|
14
|
+
audience?: "boss" | "supervisor";
|
|
15
|
+
title?: string;
|
|
16
|
+
reason?: string;
|
|
17
|
+
severity?: string;
|
|
18
|
+
requestedByConversationId?: string;
|
|
19
|
+
createdAt?: string;
|
|
20
|
+
};
|
|
21
|
+
export type OverviewProject = {
|
|
22
|
+
id: string;
|
|
23
|
+
title: string;
|
|
24
|
+
objective?: string;
|
|
25
|
+
status: string;
|
|
26
|
+
mode?: string;
|
|
27
|
+
summary?: string;
|
|
28
|
+
ownerConversationId?: string;
|
|
29
|
+
reports?: OverviewReport[];
|
|
30
|
+
escalations?: OverviewDecision[];
|
|
31
|
+
resources?: {
|
|
32
|
+
activeWorkers?: number;
|
|
33
|
+
sessions?: {
|
|
34
|
+
id: string;
|
|
35
|
+
status?: string;
|
|
36
|
+
}[];
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
/** Internal coordination is not a request for the user's attention. */
|
|
40
|
+
export declare function userProjectDecisions(project: OverviewProject): OverviewDecision[];
|
|
41
|
+
export declare function ownerProjectReports(project: OverviewProject): OverviewReport[];
|
|
42
|
+
export declare function projectUserOverview(project: OverviewProject): {
|
|
43
|
+
label: string;
|
|
44
|
+
summary: string;
|
|
45
|
+
progress: OverviewReport | undefined;
|
|
46
|
+
delivery: OverviewReport | undefined;
|
|
47
|
+
decisions: OverviewDecision[];
|
|
48
|
+
ended: boolean;
|
|
49
|
+
deliveryLabel: string;
|
|
50
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** Internal coordination is not a request for the user's attention. */
|
|
2
|
+
export function userProjectDecisions(project) {
|
|
3
|
+
return (project.escalations ?? []).filter(item => item.status === "open" && (item.audience === "boss" || item.audience === undefined));
|
|
4
|
+
}
|
|
5
|
+
export function ownerProjectReports(project) {
|
|
6
|
+
return (project.reports ?? []).filter(report => !report.taskId && ["progress", "delivery"].includes(report.kind ?? "")
|
|
7
|
+
&& (report.authorConversationId === project.ownerConversationId && Boolean(project.ownerConversationId)
|
|
8
|
+
|| project.status === "completed" && report.kind === "delivery" && !report.authorConversationId));
|
|
9
|
+
}
|
|
10
|
+
export function projectUserOverview(project) {
|
|
11
|
+
const decisions = userProjectDecisions(project);
|
|
12
|
+
const reports = ownerProjectReports(project);
|
|
13
|
+
const progress = [...reports].reverse().find(report => report.kind === "progress");
|
|
14
|
+
const delivery = [...reports].reverse().find(report => report.kind === "delivery");
|
|
15
|
+
const ended = ["completed", "cancelled", "failed"].includes(project.status);
|
|
16
|
+
const owner = project.resources?.sessions?.find(session => session.id === project.ownerConversationId);
|
|
17
|
+
const busy = (project.resources?.activeWorkers ?? 0) > 0 || ["running", "waiting", "awaiting_background"].includes(owner?.status ?? "");
|
|
18
|
+
const label = project.status === "completed" ? "已交付" : project.status === "cancelled" ? "已取消" : project.status === "failed" ? "执行暂停"
|
|
19
|
+
: decisions.length ? "需要你决定" : busy ? "正在推进" : !project.ownerConversationId ? "待启动" : ["failed", "stopped"].includes(owner?.status ?? "") ? "执行暂停" : "未交付";
|
|
20
|
+
const summary = project.status === "completed" ? project.summary?.trim() || delivery?.progress?.trim() || delivery?.summary?.trim() || "交付已完成,成果与验证记录见下方。"
|
|
21
|
+
: progress?.progress?.trim() || progress?.summary?.trim() || (ended ? "项目已结束,已有记录会保留。" : "已交由负责人推进,进展和成果会在这里汇总。");
|
|
22
|
+
return { label, summary, progress, delivery, decisions, ended,
|
|
23
|
+
deliveryLabel: project.mode === "lightweight" ? "自评交付" : "交付成果" };
|
|
24
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** Business phases are persisted; activity is a read-only projection of current execution. */
|
|
2
|
+
export type ProjectActivity = {
|
|
3
|
+
kind: string;
|
|
4
|
+
label: string;
|
|
5
|
+
nextStep: string;
|
|
6
|
+
};
|
|
7
|
+
export type ActivitySession = {
|
|
8
|
+
id: string;
|
|
9
|
+
status?: string;
|
|
10
|
+
role?: string;
|
|
11
|
+
};
|
|
12
|
+
export type ActivityTask = {
|
|
13
|
+
id: string;
|
|
14
|
+
title: string;
|
|
15
|
+
status: string;
|
|
16
|
+
role?: string;
|
|
17
|
+
required?: boolean;
|
|
18
|
+
parentTaskId?: string;
|
|
19
|
+
ownerConversationId?: string;
|
|
20
|
+
reviewerConversationId?: string;
|
|
21
|
+
dependencies?: string[];
|
|
22
|
+
review?: {
|
|
23
|
+
verdict?: string;
|
|
24
|
+
lightweight?: boolean;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export type ActivityProject = {
|
|
28
|
+
status: string;
|
|
29
|
+
mode?: string;
|
|
30
|
+
ownerConversationId?: string;
|
|
31
|
+
tasks?: ActivityTask[];
|
|
32
|
+
resources?: {
|
|
33
|
+
activeWorkers?: number;
|
|
34
|
+
sessions?: ActivitySession[];
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
export declare const PROJECT_PHASE_WORDS: Record<string, string>;
|
|
38
|
+
export declare const PROJECT_TASK_FILTERS: string[];
|
|
39
|
+
export declare const projectPhaseWord: (status?: string) => string;
|
|
40
|
+
export declare const projectSessionBusy: (status?: string) => boolean;
|
|
41
|
+
export declare function deriveTaskActivity(task: ActivityTask, sessions?: ActivitySession[], mode?: string, tasks?: ActivityTask[]): ProjectActivity;
|
|
42
|
+
export declare function deriveProjectActivity(project: ActivityProject): ProjectActivity;
|
|
43
|
+
export declare function projectActivityStats(project: ActivityProject): {
|
|
44
|
+
total: number;
|
|
45
|
+
done: number;
|
|
46
|
+
active: number;
|
|
47
|
+
coordinators: number;
|
|
48
|
+
awaitingReview: number;
|
|
49
|
+
blocked: number;
|
|
50
|
+
interrupted: number;
|
|
51
|
+
};
|
|
52
|
+
export declare function taskDependencySummary(task: ActivityTask, tasks: ActivityTask[]): string;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
export const PROJECT_PHASE_WORDS = {
|
|
2
|
+
draft: "待澄清", planning: "待规划", planned: "已规划", awaiting_start: "待启动", active: "进行中",
|
|
3
|
+
pending: "等待依赖", ready: "待派发", assigned: "已委派", in_progress: "执行阶段", interrupted: "已中断",
|
|
4
|
+
blocked: "已阻塞", awaiting_approval: "等待审批", waiting_approval: "等待审批", awaiting_review: "待验收",
|
|
5
|
+
waiting_dependency: "等待依赖", rework: "返工阶段", review: "待验收", completed: "已完成", closed: "已关闭",
|
|
6
|
+
failed: "失败", cancelled: "已取消", running: "执行中", idle: "空闲", waiting: "排队中",
|
|
7
|
+
awaiting_background: "等待后台结果", stopped: "已停止", progress: "进展", delivery: "交付", decision_request: "请求决策",
|
|
8
|
+
};
|
|
9
|
+
export const PROJECT_TASK_FILTERS = ["pending", "ready", "in_progress", "awaiting_review", "interrupted", "blocked", "completed", "failed", "cancelled"];
|
|
10
|
+
export const projectPhaseWord = (status) => PROJECT_PHASE_WORDS[status ?? ""] ?? status ?? "未知状态";
|
|
11
|
+
export const projectSessionBusy = (status) => ["running", "waiting", "awaiting_background"].includes(status ?? "");
|
|
12
|
+
const activity = (kind, label, nextStep) => ({ kind, label, nextStep });
|
|
13
|
+
export function deriveTaskActivity(task, sessions = [], mode = "standard", tasks = []) {
|
|
14
|
+
const session = sessions.find(item => item.id === task.ownerConversationId);
|
|
15
|
+
const reviewer = sessions.find(item => item.id === task.reviewerConversationId);
|
|
16
|
+
switch (task.status) {
|
|
17
|
+
case "pending": return activity("waiting_dependency", "等待依赖", "前置任务验收后派发");
|
|
18
|
+
case "ready": return activity("ready", "待派发", "由直属负责人派发");
|
|
19
|
+
case "interrupted": return activity("interrupted", "已中断", "恢复原任务并重新派发");
|
|
20
|
+
case "blocked": return activity("blocked", "已阻塞", "由直属负责人协调阻塞");
|
|
21
|
+
case "failed": return activity("failed", "失败", "由直属负责人核对失败原因");
|
|
22
|
+
case "cancelled": return activity("cancelled", "已取消", "保留已有记录");
|
|
23
|
+
case "completed":
|
|
24
|
+
if (task.review?.lightweight || mode === "lightweight" && task.review?.verdict === "accepted")
|
|
25
|
+
return activity("self_delivered", "自评交付", "按轻量项目口径汇总");
|
|
26
|
+
if (mode !== "lightweight" && task.review?.verdict === "accepted")
|
|
27
|
+
return activity("accepted", "已独立验收", "推进下游或汇总交付");
|
|
28
|
+
return activity("completed", "已完成", "核对交付和验收记录");
|
|
29
|
+
case "awaiting_review":
|
|
30
|
+
if (!task.reviewerConversationId)
|
|
31
|
+
return activity("awaiting_review_assignment", "待安排复核", "由直属负责人安排独立复核");
|
|
32
|
+
if (reviewer?.status === "running")
|
|
33
|
+
return activity("reviewing", "复核中", "等待独立复核结论");
|
|
34
|
+
if (reviewer?.status === "waiting")
|
|
35
|
+
return activity("review_queued", "复核排队中", "等待复核会话开始执行");
|
|
36
|
+
if (reviewer?.status === "awaiting_background")
|
|
37
|
+
return activity("review_background", "等待复核后台结果", "后台结果返回后继续复核");
|
|
38
|
+
if (["failed", "stopped"].includes(reviewer?.status ?? ""))
|
|
39
|
+
return activity("review_interrupted", "复核已中断", "由直属负责人恢复复核会话");
|
|
40
|
+
return activity("awaiting_review_result", "待复核结论", "继续原复核会话并提交结论");
|
|
41
|
+
case "in_progress":
|
|
42
|
+
if (session?.status === "running")
|
|
43
|
+
return activity("executing", "执行中", "等待进展或由直属负责人补充指令");
|
|
44
|
+
if (session?.status === "waiting")
|
|
45
|
+
return activity("queued", "执行排队中", "等待执行会话开始运行");
|
|
46
|
+
if (session?.status === "awaiting_background")
|
|
47
|
+
return activity("background", "等待后台结果", "后台结果返回后继续执行");
|
|
48
|
+
if (["failed", "stopped"].includes(session?.status ?? ""))
|
|
49
|
+
return activity("interrupted", "已中断", "恢复原任务并重新派发");
|
|
50
|
+
if (task.role === "leader" && tasks.some(child => child.parentTaskId === task.id && !["completed", "cancelled"].includes(child.status))) {
|
|
51
|
+
return activity("awaiting_subordinates", "等待下属交付", "接收直属任务回报并汇总");
|
|
52
|
+
}
|
|
53
|
+
if (session?.status === "completed" || session?.status === "idle")
|
|
54
|
+
return activity("awaiting_delivery", "待继续·尚未交付", "继续原执行会话或要求提交交付");
|
|
55
|
+
return activity("unknown", "待核对执行状态", "由直属负责人核对执行会话");
|
|
56
|
+
default: return activity("unknown", projectPhaseWord(task.status), "核对任务记录");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export function deriveProjectActivity(project) {
|
|
60
|
+
if (["completed", "cancelled", "failed"].includes(project.status))
|
|
61
|
+
return activity(project.status, projectPhaseWord(project.status), "查看交付与项目记录");
|
|
62
|
+
if (["blocked", "awaiting_approval"].includes(project.status))
|
|
63
|
+
return activity(project.status, projectPhaseWord(project.status), "由项目负责人处理阻塞与升级");
|
|
64
|
+
const tasks = project.tasks ?? [];
|
|
65
|
+
const sessions = project.resources?.sessions ?? [];
|
|
66
|
+
const leader = sessions.find(session => session.id === project.ownerConversationId);
|
|
67
|
+
if (!project.ownerConversationId)
|
|
68
|
+
return activity(tasks.length ? "awaiting_start" : "planning", tasks.length ? "待启动" : "待规划", "由负责人启动项目并安排任务");
|
|
69
|
+
if (tasks.length && tasks.every(task => task.required === false || task.status === "completed")) {
|
|
70
|
+
return activity(projectSessionBusy(leader?.status) ? "summarizing" : "ready_to_close", projectSessionBusy(leader?.status) ? "汇总交付中" : "待汇总交付", "由项目负责人提交最终交付并关闭项目");
|
|
71
|
+
}
|
|
72
|
+
const activities = tasks.map(task => deriveTaskActivity(task, sessions, project.mode, tasks));
|
|
73
|
+
const live = activities.find(item => ["executing", "reviewing", "queued", "review_queued", "background", "review_background"].includes(item.kind));
|
|
74
|
+
if (live)
|
|
75
|
+
return live;
|
|
76
|
+
if ((project.resources?.activeWorkers ?? 0) > 0 && !sessions.some(session => projectSessionBusy(session.status)))
|
|
77
|
+
return activity("background", "等待后台结果", "等待项目内的一次性调用返回结果");
|
|
78
|
+
if (projectSessionBusy(leader?.status))
|
|
79
|
+
return activity("coordinating", "协调中", "项目负责人正在安排后续工作");
|
|
80
|
+
const awaiting = activities.find(item => ["awaiting_delivery", "awaiting_review_result", "review_interrupted", "awaiting_review_assignment", "interrupted", "awaiting_subordinates", "blocked", "ready", "waiting_dependency"].includes(item.kind));
|
|
81
|
+
if (awaiting?.kind === "blocked")
|
|
82
|
+
return activity("awaiting_coordination", "待负责人协调", "由直属负责人处理任务阻塞");
|
|
83
|
+
return awaiting ?? activity("planning", "待规划", "由项目负责人安排任务");
|
|
84
|
+
}
|
|
85
|
+
export function projectActivityStats(project) {
|
|
86
|
+
const tasks = project.tasks ?? [];
|
|
87
|
+
const sessions = project.resources?.sessions ?? [];
|
|
88
|
+
const coordinatorIds = new Set([project.ownerConversationId, ...tasks.filter(task => task.role === "leader").map(task => task.ownerConversationId)].filter(Boolean));
|
|
89
|
+
const fallbackWorkers = sessions.filter(session => projectSessionBusy(session.status) && (!coordinatorIds.has(session.id) || project.mode === "lightweight")).length;
|
|
90
|
+
return { total: tasks.length, done: tasks.filter(task => task.status === "completed").length,
|
|
91
|
+
active: project.resources?.activeWorkers ?? fallbackWorkers,
|
|
92
|
+
coordinators: sessions.filter(session => coordinatorIds.has(session.id) && projectSessionBusy(session.status) && project.mode !== "lightweight").length,
|
|
93
|
+
awaitingReview: tasks.filter(task => task.status === "awaiting_review").length,
|
|
94
|
+
blocked: tasks.filter(task => task.status === "blocked").length, interrupted: tasks.filter(task => task.status === "interrupted").length };
|
|
95
|
+
}
|
|
96
|
+
export function taskDependencySummary(task, tasks) {
|
|
97
|
+
const dependencies = task.dependencies ?? [];
|
|
98
|
+
if (!dependencies.length)
|
|
99
|
+
return "无前置依赖";
|
|
100
|
+
const pending = dependencies.filter(id => tasks.find(candidate => candidate.id === id)?.status !== "completed");
|
|
101
|
+
const names = (ids) => ids.map(id => tasks.find(candidate => candidate.id === id)?.title ?? "未知任务").join("、");
|
|
102
|
+
return pending.length ? `等待:${names(pending)}` : `前置已满足:${names(dependencies)}`;
|
|
103
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export type HandoffPacket = {
|
|
2
|
+
projectId: string;
|
|
3
|
+
revision: number;
|
|
4
|
+
project?: {
|
|
5
|
+
title?: string;
|
|
6
|
+
};
|
|
7
|
+
task?: {
|
|
8
|
+
title?: string;
|
|
9
|
+
};
|
|
10
|
+
handoff?: string;
|
|
11
|
+
entries: {
|
|
12
|
+
id: string;
|
|
13
|
+
title: string;
|
|
14
|
+
content: string;
|
|
15
|
+
revision: number;
|
|
16
|
+
kind?: string;
|
|
17
|
+
evidenceRefs?: string[];
|
|
18
|
+
}[];
|
|
19
|
+
omitted?: number;
|
|
20
|
+
truncated?: string[];
|
|
21
|
+
ownedPaths?: string[];
|
|
22
|
+
readOnly?: boolean;
|
|
23
|
+
};
|
|
24
|
+
export type HandoffMessagePart = {
|
|
25
|
+
kind: "markdown";
|
|
26
|
+
source: string;
|
|
27
|
+
} | {
|
|
28
|
+
kind: "handoff";
|
|
29
|
+
raw: string;
|
|
30
|
+
packet: HandoffPacket;
|
|
31
|
+
};
|
|
32
|
+
/** Preserve the original message and treat recognized packets as display data only. */
|
|
33
|
+
export declare function splitHandoffMessage(source: string): HandoffMessagePart[];
|