dsh-taskbridge 1.7.0 → 1.8.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/CHANGELOG.md +18 -0
- package/LICENSE +21 -21
- package/README.md +150 -289
- package/THIRD_PARTY_NOTICES.txt +23 -23
- package/antigravity/agents/dsh-taskbridge.md +31 -0
- package/antigravity/skills/dsh-taskbridge/SKILL.md +51 -0
- package/codex/dsh-taskbridge.toml +170 -627
- package/cordis.patch.yml +6 -6
- package/docs/INTRODUCTION.md +119 -295
- package/docs/INTRODUCTION.zh.md +134 -279
- package/docs/antigravity-integration.md +42 -0
- package/docs/auth-contract.md +138 -138
- package/docs/claude-code.md +6 -11
- package/docs/codex-integration.md +13 -2
- package/docs/contracts-stage-b.md +443 -443
- package/docs/plugin-market.md +30 -30
- package/docs/redaction-contract.md +170 -170
- package/docs/releases/1.7.0.zh.md +11 -11
- package/docs/releases/1.8.0.zh.md +16 -0
- package/docs/runtime-compatibility.md +1 -1
- package/docs/taskbridge-upgrade.md +28 -28
- package/docs/taskdispatch-upgrade.md +25 -25
- package/docs/workspace-contract.md +538 -538
- package/docs/workspace-grouping.md +126 -126
- package/icon.svg +1 -1
- package/lib/client.d.ts +733 -699
- package/lib/client.js +7 -7
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +149 -144
- package/src/antigravity/installer.js +1046 -0
- package/src/antigravity/seam.js +142 -0
- package/src/auth/fence.js +361 -361
- package/src/auth/grants.js +789 -789
- package/src/client/api.js +143 -0
- package/src/client/index.jsx +113 -3
- package/src/client/sidebar.jsx +862 -862
- package/src/client/styles.js +624 -624
- package/src/client/task-cleanup.js +304 -304
- package/src/client/task-records-table.jsx +217 -217
- package/src/client/task-view.js +307 -307
- package/src/client/workspace-groups.js +482 -482
- package/src/client/workspaces-browser.jsx +770 -770
- package/src/codex/agent-ownership.js +270 -270
- package/src/codex/installer.js +6 -0
- package/src/codex/toml.js +784 -784
- package/src/config/redact.js +245 -245
- package/src/config/store.js +186 -186
- package/src/credentials/seam.js +202 -202
- package/src/http/respond.js +6 -5
- package/src/http/user-plane.js +72 -0
- package/src/index.js +25 -0
- package/src/jobs/diagnostics.js +15 -15
- package/src/jobs/plan-store.js +1020 -1020
- package/src/jobs/review-note.js +63 -63
- package/src/jobs/task-descriptions.js +82 -82
- package/src/jobs/task-display.js +73 -73
- package/src/jobs/task-tree.js +786 -786
- package/src/jobs/title.js +134 -134
- package/src/mcp/continuation.js +317 -317
- package/src/mcp/server.js +12 -5
- package/src/model/connectivity.js +371 -371
- package/src/model/discovery.js +582 -582
- package/src/model/native-catalog.js +68 -68
- package/src/model/openai-adapter.js +671 -671
- package/src/model/probe.js +264 -264
- package/src/model/providers.js +756 -756
- package/src/model/routing.js +321 -321
- package/src/runtime/permissions.js +1619 -1619
- package/src/runtime/question-call.js +162 -162
- package/src/runtime/questions.js +909 -909
- package/src/runtime/worker-prompt.js +60 -53
- package/src/workspace/audit.js +775 -775
- package/src/workspace/preflight.js +424 -424
- package/src/workspace/worktrees.js +679 -679
package/src/jobs/title.js
CHANGED
|
@@ -1,134 +1,134 @@
|
|
|
1
|
-
import { redactText } from '../config/redact.js';
|
|
2
|
-
|
|
3
|
-
const GOAL = /^(?:目标|任务目标|工作内容|任务|goal|objective|task)(?:\s*[::]\s*|$)(.*)$/iu;
|
|
4
|
-
const ROLE = /^(?:you are\b|you're\b|you will\b|you must\b|act as\b|your (?:role|task|job|objective)\b|as an?\b|你是|您是一名|你负责|你需要|你的(?:角色|任务|职责)|请作为|作为一)/iu;
|
|
5
|
-
const RULE = /^(?:instructions?|execution task rules?|task rules?|rules?|guidelines?|constraints?|requirements?|role|persona|system|context|background|overview|summary|steps?|procedure|执行任务规则|执行规则|任务规则|规则|约束|限制|要求|角色|身份|系统|背景|上下文|说明|验收|范围|步骤|流程|概述)(?:\s*[::].*|\s*)$/iu;
|
|
6
|
-
const RESTRICTION = /^(?:不要|不准|不得|禁止|必须|务必|请勿|别|do not\b|don't\b|never\b|must\b|always\b|avoid\b|use only\b)/iu;
|
|
7
|
-
const METADATA = /^(?:workspace|worktree|source|repo|repository|branch|commit|path|路径|工作区|仓库|分支|目录|提交)\s*[::]/iu;
|
|
8
|
-
const IDENTIFIER = /^(?:task-[0-9a-z][0-9a-z-]{5,}|[\da-f]{8}(?:-[\da-f]{4}){3}-[\da-f]{12}|sha256:[\da-f]{64})[::]?$/iu;
|
|
9
|
-
const ROOTED_PATH = /^(?:[a-z]:[\\/]|\\\\|\/|~\/)/iu;
|
|
10
|
-
const RELATIVE_PATH = /^(?:[^\s\\/]+[\\/])+[^\s\\/]+$/u;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Common work actions. A title is "path + work", not "path", only when one of these starts
|
|
14
|
-
* the description AND that description has an object. Deliberately short: a wording
|
|
15
|
-
* heuristic, not natural-language parsing.
|
|
16
|
-
*/
|
|
17
|
-
const CJK_ACTION = /^(?:修复|修改|修正|整改|更新|升级|补充|补齐|完善|新增|添加|删除|移除|替换|重构|重写|实现|支持|接入|迁移|优化|调整|对齐|统一|清理|整理|检查|校验|验证|排查|复现|回归|覆盖|编写|生成|同步|合并|拆分|提取|封装|加固|收紧|收口|处理|解决)/u;
|
|
18
|
-
const LATIN_ACTION = /^(?:fix(?:es|ed|ing)?|add(?:s|ed|ing)?|update(?:s|d|ing)?|remove(?:s|d|ing)?|delete(?:s|d|ing)?|refactor(?:s|ed|ing)?|implement(?:s|ed|ing)?|support(?:s|ed|ing)?|migrate|improve[sd]?|optimi[sz]e[sd]?|rename[sd]?|clean(?:s|ed|ing)?|test(?:s|ed|ing)?|check(?:s|ed|ing)?|review(?:s|ed|ing)?|sync(?:s|ed|ing)?|extract(?:s|ed|ing)?|merge[sd]?|align(?:s|ed|ing)?|tighten(?:s|ed|ing)?)\b/iu;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* The object that starts a description, after its action, or '' when there is none.
|
|
22
|
-
*
|
|
23
|
-
* A description needs something to act ON, so a bare verb (`Fix:`, an isolated `测试`) never
|
|
24
|
-
* qualifies. Chinese attaches its object directly (`修复API显示`), while a Latin verb must be
|
|
25
|
-
* separated from its object by whitespace or a colon — which is also why `Fix:` alone, with
|
|
26
|
-
* nothing after the colon, has no object.
|
|
27
|
-
* @param {string} text - the text right after the action.
|
|
28
|
-
* @returns {string} the object text, or '' when the action has no object.
|
|
29
|
-
*/
|
|
30
|
-
function actionObject(text) {
|
|
31
|
-
const trimmed = text.trim();
|
|
32
|
-
// A separator that leads nowhere (`Fix:` / `修复:`) is not an object.
|
|
33
|
-
return trimmed.replace(/^[::]+/u, '').trim();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Whether one rooted (absolute) line carries a work description after its path.
|
|
38
|
-
*
|
|
39
|
-
* A rooted line is ambiguous: `E:/repo 修复API显示` is a work title, while `E:/资料/修复记录`
|
|
40
|
-
* is a path whose last segment merely STARTS with a verb. Splitting on the first space
|
|
41
|
-
* cannot decide that — a path may itself contain spaces (`E:/资料/My Project 修复登录错误`) —
|
|
42
|
-
* so the boundary is searched for inside the LAST path segment:
|
|
43
|
-
*
|
|
44
|
-
* * a description may only begin at whitespace that follows at least one non-space path
|
|
45
|
-
* character, so index 0 and leading whitespace are never a boundary (that is what made
|
|
46
|
-
* `修复记录` and `Update notes` read as work);
|
|
47
|
-
* * the description may not cross a path separator, so `测试/历史` stays a path segment;
|
|
48
|
-
* * the action must have an object (see {@link actionObject});
|
|
49
|
-
* * Chinese attaches its object directly; Latin must be separated by whitespace or colon.
|
|
50
|
-
*
|
|
51
|
-
* A directory literally named after an action plus its object stays genuinely ambiguous;
|
|
52
|
-
* that is documented in the delivery, and no filesystem access is attempted.
|
|
53
|
-
* @param {string} line - one trimmed candidate line.
|
|
54
|
-
* @returns {boolean} true when the line reads as "path + work", not "path".
|
|
55
|
-
*/
|
|
56
|
-
function describesWorkAfterPath(line) {
|
|
57
|
-
// Everything after the last separator is the final segment, which may hold the description.
|
|
58
|
-
const slash = Math.max(line.lastIndexOf('/'), line.lastIndexOf('\\'));
|
|
59
|
-
const segment = slash >= 0 ? line.slice(slash + 1) : line;
|
|
60
|
-
for (let index = 1; index < segment.length; index += 1) {
|
|
61
|
-
// A boundary is whitespace preceded by a path character: never the segment start.
|
|
62
|
-
if (!/\s/u.test(segment[index]) || /\s/u.test(segment[index - 1])) continue;
|
|
63
|
-
const rest = segment.slice(index).trim();
|
|
64
|
-
if (rest === '') continue;
|
|
65
|
-
const cjk = CJK_ACTION.exec(rest);
|
|
66
|
-
if (cjk !== null && actionObject(rest.slice(cjk[0].length)) !== '') return true;
|
|
67
|
-
const latin = LATIN_ACTION.exec(rest);
|
|
68
|
-
// Latin needs an explicit separator, so `Fixings` or `Update` alone never matches.
|
|
69
|
-
if (latin !== null && /^[\s::]/u.test(rest.slice(latin[0].length)) && actionObject(rest.slice(latin[0].length)) !== '') {
|
|
70
|
-
return true;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return false;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function textLines(value) {
|
|
77
|
-
return typeof value === 'string' ? value.split(/\r\n?|\n/u).map((line) => line.trim()) : [];
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function plainLine(line) {
|
|
81
|
-
return line.replace(/^(?:#{1,6}\s*|(?:\d+[.)、]|[-*+])\s+)/u, '').trim();
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function outsideFences(value) {
|
|
85
|
-
let open = null;
|
|
86
|
-
return textLines(value).map((line) => {
|
|
87
|
-
const fence = /^(\x60{3,}|~{3,})(.*)$/u.exec(line);
|
|
88
|
-
if (open !== null) {
|
|
89
|
-
if (fence?.[1][0] === open[0] && fence[1].length >= open.length && fence[2].trim() === '') open = null;
|
|
90
|
-
return null;
|
|
91
|
-
}
|
|
92
|
-
if (fence) {
|
|
93
|
-
open = fence[1];
|
|
94
|
-
return null;
|
|
95
|
-
}
|
|
96
|
-
return plainLine(line);
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function candidate(line) {
|
|
101
|
-
if (!line || /^(?:[|>]|[-*_]{3,}|\x60[^\x60]*\x60$)/u.test(line)) return '';
|
|
102
|
-
if (ROLE.test(line) || RULE.test(line) || RESTRICTION.test(line) || METADATA.test(line) || IDENTIFIER.test(line)) return '';
|
|
103
|
-
if (ROOTED_PATH.test(line) && !describesWorkAfterPath(line)) return '';
|
|
104
|
-
if (RELATIVE_PATH.test(line) && !/\p{Script=Han}/u.test(line)) return '';
|
|
105
|
-
return redactText(line).replace(/[\u0000-\u001f\u007f]/gu, ' ').replace(/\s+/gu, ' ').trim();
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/** Use a short title, a structured goal, or one readable line from older callers. */
|
|
109
|
-
export function taskTitle(title, prompt = '') {
|
|
110
|
-
const explicit = outsideFences(title).map(candidate).find((line) => line && GOAL.exec(line)?.[1] !== '');
|
|
111
|
-
if (explicit) return boundedTitle(explicit);
|
|
112
|
-
|
|
113
|
-
const lines = outsideFences(prompt);
|
|
114
|
-
for (const [index, line] of lines.entries()) {
|
|
115
|
-
if (!line) continue;
|
|
116
|
-
const goal = GOAL.exec(line);
|
|
117
|
-
if (!goal) continue;
|
|
118
|
-
let body = goal[1];
|
|
119
|
-
if (body === '') {
|
|
120
|
-
let next = index + 1;
|
|
121
|
-
while (lines[next] === '') next += 1;
|
|
122
|
-
body = lines[next];
|
|
123
|
-
}
|
|
124
|
-
const text = candidate(body);
|
|
125
|
-
if (text && !GOAL.test(text)) return boundedTitle(text);
|
|
126
|
-
}
|
|
127
|
-
const fallback = lines.map(candidate).find((line) => line && !GOAL.test(line));
|
|
128
|
-
return boundedTitle(fallback || '委派任务');
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function boundedTitle(title) {
|
|
132
|
-
const chars = Array.from(title);
|
|
133
|
-
return chars.length > 48 ? chars.slice(0, 47).join('') + '…' : title;
|
|
134
|
-
}
|
|
1
|
+
import { redactText } from '../config/redact.js';
|
|
2
|
+
|
|
3
|
+
const GOAL = /^(?:目标|任务目标|工作内容|任务|goal|objective|task)(?:\s*[::]\s*|$)(.*)$/iu;
|
|
4
|
+
const ROLE = /^(?:you are\b|you're\b|you will\b|you must\b|act as\b|your (?:role|task|job|objective)\b|as an?\b|你是|您是一名|你负责|你需要|你的(?:角色|任务|职责)|请作为|作为一)/iu;
|
|
5
|
+
const RULE = /^(?:instructions?|execution task rules?|task rules?|rules?|guidelines?|constraints?|requirements?|role|persona|system|context|background|overview|summary|steps?|procedure|执行任务规则|执行规则|任务规则|规则|约束|限制|要求|角色|身份|系统|背景|上下文|说明|验收|范围|步骤|流程|概述)(?:\s*[::].*|\s*)$/iu;
|
|
6
|
+
const RESTRICTION = /^(?:不要|不准|不得|禁止|必须|务必|请勿|别|do not\b|don't\b|never\b|must\b|always\b|avoid\b|use only\b)/iu;
|
|
7
|
+
const METADATA = /^(?:workspace|worktree|source|repo|repository|branch|commit|path|路径|工作区|仓库|分支|目录|提交)\s*[::]/iu;
|
|
8
|
+
const IDENTIFIER = /^(?:task-[0-9a-z][0-9a-z-]{5,}|[\da-f]{8}(?:-[\da-f]{4}){3}-[\da-f]{12}|sha256:[\da-f]{64})[::]?$/iu;
|
|
9
|
+
const ROOTED_PATH = /^(?:[a-z]:[\\/]|\\\\|\/|~\/)/iu;
|
|
10
|
+
const RELATIVE_PATH = /^(?:[^\s\\/]+[\\/])+[^\s\\/]+$/u;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Common work actions. A title is "path + work", not "path", only when one of these starts
|
|
14
|
+
* the description AND that description has an object. Deliberately short: a wording
|
|
15
|
+
* heuristic, not natural-language parsing.
|
|
16
|
+
*/
|
|
17
|
+
const CJK_ACTION = /^(?:修复|修改|修正|整改|更新|升级|补充|补齐|完善|新增|添加|删除|移除|替换|重构|重写|实现|支持|接入|迁移|优化|调整|对齐|统一|清理|整理|检查|校验|验证|排查|复现|回归|覆盖|编写|生成|同步|合并|拆分|提取|封装|加固|收紧|收口|处理|解决)/u;
|
|
18
|
+
const LATIN_ACTION = /^(?:fix(?:es|ed|ing)?|add(?:s|ed|ing)?|update(?:s|d|ing)?|remove(?:s|d|ing)?|delete(?:s|d|ing)?|refactor(?:s|ed|ing)?|implement(?:s|ed|ing)?|support(?:s|ed|ing)?|migrate|improve[sd]?|optimi[sz]e[sd]?|rename[sd]?|clean(?:s|ed|ing)?|test(?:s|ed|ing)?|check(?:s|ed|ing)?|review(?:s|ed|ing)?|sync(?:s|ed|ing)?|extract(?:s|ed|ing)?|merge[sd]?|align(?:s|ed|ing)?|tighten(?:s|ed|ing)?)\b/iu;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The object that starts a description, after its action, or '' when there is none.
|
|
22
|
+
*
|
|
23
|
+
* A description needs something to act ON, so a bare verb (`Fix:`, an isolated `测试`) never
|
|
24
|
+
* qualifies. Chinese attaches its object directly (`修复API显示`), while a Latin verb must be
|
|
25
|
+
* separated from its object by whitespace or a colon — which is also why `Fix:` alone, with
|
|
26
|
+
* nothing after the colon, has no object.
|
|
27
|
+
* @param {string} text - the text right after the action.
|
|
28
|
+
* @returns {string} the object text, or '' when the action has no object.
|
|
29
|
+
*/
|
|
30
|
+
function actionObject(text) {
|
|
31
|
+
const trimmed = text.trim();
|
|
32
|
+
// A separator that leads nowhere (`Fix:` / `修复:`) is not an object.
|
|
33
|
+
return trimmed.replace(/^[::]+/u, '').trim();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Whether one rooted (absolute) line carries a work description after its path.
|
|
38
|
+
*
|
|
39
|
+
* A rooted line is ambiguous: `E:/repo 修复API显示` is a work title, while `E:/资料/修复记录`
|
|
40
|
+
* is a path whose last segment merely STARTS with a verb. Splitting on the first space
|
|
41
|
+
* cannot decide that — a path may itself contain spaces (`E:/资料/My Project 修复登录错误`) —
|
|
42
|
+
* so the boundary is searched for inside the LAST path segment:
|
|
43
|
+
*
|
|
44
|
+
* * a description may only begin at whitespace that follows at least one non-space path
|
|
45
|
+
* character, so index 0 and leading whitespace are never a boundary (that is what made
|
|
46
|
+
* `修复记录` and `Update notes` read as work);
|
|
47
|
+
* * the description may not cross a path separator, so `测试/历史` stays a path segment;
|
|
48
|
+
* * the action must have an object (see {@link actionObject});
|
|
49
|
+
* * Chinese attaches its object directly; Latin must be separated by whitespace or colon.
|
|
50
|
+
*
|
|
51
|
+
* A directory literally named after an action plus its object stays genuinely ambiguous;
|
|
52
|
+
* that is documented in the delivery, and no filesystem access is attempted.
|
|
53
|
+
* @param {string} line - one trimmed candidate line.
|
|
54
|
+
* @returns {boolean} true when the line reads as "path + work", not "path".
|
|
55
|
+
*/
|
|
56
|
+
function describesWorkAfterPath(line) {
|
|
57
|
+
// Everything after the last separator is the final segment, which may hold the description.
|
|
58
|
+
const slash = Math.max(line.lastIndexOf('/'), line.lastIndexOf('\\'));
|
|
59
|
+
const segment = slash >= 0 ? line.slice(slash + 1) : line;
|
|
60
|
+
for (let index = 1; index < segment.length; index += 1) {
|
|
61
|
+
// A boundary is whitespace preceded by a path character: never the segment start.
|
|
62
|
+
if (!/\s/u.test(segment[index]) || /\s/u.test(segment[index - 1])) continue;
|
|
63
|
+
const rest = segment.slice(index).trim();
|
|
64
|
+
if (rest === '') continue;
|
|
65
|
+
const cjk = CJK_ACTION.exec(rest);
|
|
66
|
+
if (cjk !== null && actionObject(rest.slice(cjk[0].length)) !== '') return true;
|
|
67
|
+
const latin = LATIN_ACTION.exec(rest);
|
|
68
|
+
// Latin needs an explicit separator, so `Fixings` or `Update` alone never matches.
|
|
69
|
+
if (latin !== null && /^[\s::]/u.test(rest.slice(latin[0].length)) && actionObject(rest.slice(latin[0].length)) !== '') {
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function textLines(value) {
|
|
77
|
+
return typeof value === 'string' ? value.split(/\r\n?|\n/u).map((line) => line.trim()) : [];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function plainLine(line) {
|
|
81
|
+
return line.replace(/^(?:#{1,6}\s*|(?:\d+[.)、]|[-*+])\s+)/u, '').trim();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function outsideFences(value) {
|
|
85
|
+
let open = null;
|
|
86
|
+
return textLines(value).map((line) => {
|
|
87
|
+
const fence = /^(\x60{3,}|~{3,})(.*)$/u.exec(line);
|
|
88
|
+
if (open !== null) {
|
|
89
|
+
if (fence?.[1][0] === open[0] && fence[1].length >= open.length && fence[2].trim() === '') open = null;
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
if (fence) {
|
|
93
|
+
open = fence[1];
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
return plainLine(line);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function candidate(line) {
|
|
101
|
+
if (!line || /^(?:[|>]|[-*_]{3,}|\x60[^\x60]*\x60$)/u.test(line)) return '';
|
|
102
|
+
if (ROLE.test(line) || RULE.test(line) || RESTRICTION.test(line) || METADATA.test(line) || IDENTIFIER.test(line)) return '';
|
|
103
|
+
if (ROOTED_PATH.test(line) && !describesWorkAfterPath(line)) return '';
|
|
104
|
+
if (RELATIVE_PATH.test(line) && !/\p{Script=Han}/u.test(line)) return '';
|
|
105
|
+
return redactText(line).replace(/[\u0000-\u001f\u007f]/gu, ' ').replace(/\s+/gu, ' ').trim();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** Use a short title, a structured goal, or one readable line from older callers. */
|
|
109
|
+
export function taskTitle(title, prompt = '') {
|
|
110
|
+
const explicit = outsideFences(title).map(candidate).find((line) => line && GOAL.exec(line)?.[1] !== '');
|
|
111
|
+
if (explicit) return boundedTitle(explicit);
|
|
112
|
+
|
|
113
|
+
const lines = outsideFences(prompt);
|
|
114
|
+
for (const [index, line] of lines.entries()) {
|
|
115
|
+
if (!line) continue;
|
|
116
|
+
const goal = GOAL.exec(line);
|
|
117
|
+
if (!goal) continue;
|
|
118
|
+
let body = goal[1];
|
|
119
|
+
if (body === '') {
|
|
120
|
+
let next = index + 1;
|
|
121
|
+
while (lines[next] === '') next += 1;
|
|
122
|
+
body = lines[next];
|
|
123
|
+
}
|
|
124
|
+
const text = candidate(body);
|
|
125
|
+
if (text && !GOAL.test(text)) return boundedTitle(text);
|
|
126
|
+
}
|
|
127
|
+
const fallback = lines.map(candidate).find((line) => line && !GOAL.test(line));
|
|
128
|
+
return boundedTitle(fallback || '委派任务');
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function boundedTitle(title) {
|
|
132
|
+
const chars = Array.from(title);
|
|
133
|
+
return chars.length > 48 ? chars.slice(0, 47).join('') + '…' : title;
|
|
134
|
+
}
|