nx-kv 0.68.3 → 0.69.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +62 -0
- package/package.json +1 -1
- package/src/core/attachmentdb/query.ts +10 -1
- package/src/core/attachmentdb/resources.ts +4 -16
- package/src/core/db/bootstrap.ts +4 -3
- package/src/core/db/import-json/links.ts +2 -2
- package/src/core/db/import-json/repos.ts +3 -24
- package/src/core/db/import-json/tasks.ts +92 -7
- package/src/core/db/import-json.ts +1 -2
- package/src/core/db/migrations/index.ts +8 -0
- package/src/core/db/migrations/v16-data.ts +166 -0
- package/src/core/db/migrations/v16.sql +15 -0
- package/src/core/db/migrations/v17-data.ts +110 -0
- package/src/core/db/migrations/v17.sql +112 -0
- package/src/core/db/migrations/v18.sql +24 -0
- package/src/core/db/repo-match.ts +52 -0
- package/src/core/db/seed-templates.ts +46 -11
- package/src/core/db/verify.ts +2 -2
- package/src/core/db/version.ts +7 -1
- package/src/modules/claim/groupctx.ts +1 -1
- package/src/modules/claim/host.ts +5 -5
- package/src/modules/goals/plugins/timegoal-task-store.ts +1 -1
- package/src/modules/localtask/actions/_manifest.generated.ts +3 -0
- package/src/modules/localtask/actions/localtask-add.ts +4 -4
- package/src/modules/localtask/actions/localtask-boardtasks.ts +40 -40
- package/src/modules/localtask/actions/localtask-reopen.ts +5 -0
- package/src/modules/localtask/actions/localtask-sync-queues.ts +35 -0
- package/src/modules/localtask/actions/localtask-tasks.ts +3 -2
- package/src/modules/localtask/actions/localtask-update.ts +6 -0
- package/src/modules/localtask/infra/repo/goals.ts +2 -2
- package/src/modules/localtask/infra/repo/links.ts +1 -1
- package/src/modules/localtask/infra/repo/rows.ts +16 -0
- package/src/modules/localtask/infra/repo/tasks.ts +45 -41
- package/src/modules/localtask/infra/repo/topics.ts +61 -4
- package/src/modules/localtask/lifecycle/add.ts +15 -23
- package/src/modules/localtask/lifecycle/task-lifecycle.ts +7 -7
- package/src/modules/localtask/lifecycle/task-ops.ts +22 -11
- package/src/modules/localtask/lifecycle/task-view.ts +17 -11
- package/src/modules/localtask/lifecycle/topics.ts +82 -4
- package/src/modules/localtask/lifecycle/update.ts +28 -29
- package/src/modules/localtask/ops/attach-resource.ts +3 -4
- package/src/modules/localtask/ops/attach.ts +2 -2
- package/src/modules/localtask/ops/board-target.ts +8 -28
- package/src/modules/repos/actions/board-add.ts +5 -1
- package/src/modules/repos/actions/board-assign.ts +5 -1
- package/src/modules/repos/actions/board-remove.ts +5 -1
- package/src/modules/repos/actions/repo-add.ts +5 -1
- package/src/modules/repos/actions/repo-update.ts +5 -1
- package/src/modules/repos/boards/transfer.ts +3 -2
- package/src/modules/repos/orchestrate.ts +17 -0
- package/src/modules/repos/transfer/export.ts +24 -18
- package/src/modules/templates/actions/template-update.ts +1 -1
- package/src/modules/templates/service.ts +3 -0
- package/src/web/frontend/api/cli-tree.json +17 -2
- package/src/web/frontend/api/client.generated.ts +12 -4
- package/src/web/frontend/components/Introduction/style.css +1 -1
- package/src/web/frontend/components/layout/vsc-crumbs-model.ts +16 -8
- package/src/web/frontend/components/layout/vsc-crumbs.css +9 -16
- package/src/web/frontend/components/layout/vsc-crumbs.tsx +63 -57
- package/src/web/frontend/components/md/attachments/attach-modal.tsx +1 -1
- package/src/web/frontend/components/md/hooks/use-live-preview.ts +1 -1
- package/src/web/frontend/components/md/model/divider/index.ts +0 -3
- package/src/web/frontend/components/md/panes/live-block.tsx +3 -11
- package/src/web/frontend/components/md/panes/md-panes-helpers.ts +1 -3
- package/src/web/frontend/components/md/panes/md-panes-keys.ts +1 -2
- package/src/web/frontend/components/md/panes/md-panes.tsx +2 -4
- package/src/web/frontend/components/popup/index.tsx +17 -3
- package/src/web/frontend/components/popup/style.css +9 -0
- package/src/web/frontend/components/sidebar/model.ts +2 -2
- package/src/web/frontend/components/tool-acts/modules.ts +1 -0
- package/src/web/frontend/modules/md/doc-store.ts +6 -0
- package/src/web/frontend/modules/md/md-blocks.ts +4 -43
- package/src/web/frontend/modules/md/md-parse.ts +2 -5
- package/src/web/frontend/modules/md/md-render.ts +2 -2
- package/src/web/frontend/modules/md/styles/docs.css +1 -1
- package/src/web/frontend/modules/md/styles/editor.css +0 -26
- package/src/web/frontend/modules/prompts/template-preview.ts +5 -6
- package/src/web/frontend/page/dag/index.tsx +6 -5
- package/src/web/frontend/page/dir/task-actions.ts +16 -13
- package/src/web/frontend/page/dir/task-beside.ts +10 -20
- package/src/web/frontend/page/dir/task-board-section.tsx +3 -5
- package/src/web/frontend/page/dir/task-derived-ctx.ts +10 -5
- package/src/web/frontend/page/dir/task-utils.ts +9 -1
- package/src/web/frontend/page/dir/task.tsx +4 -4
- package/src/web/frontend/page/group/index.tsx +8 -8
- package/src/web/frontend/page/progress/index.tsx +7 -11
- package/src/web/frontend/page/repos/api.ts +5 -0
- package/src/web/frontend/page/repos/index.tsx +12 -1
- package/src/web/frontend/page/templates/index.tsx +9 -0
- package/src/web/frontend/page/templates/template-list.tsx +2 -1
- package/src/web/frontend/styles/base.css +1 -1
- package/src/web/frontend/styles/bindings.css +1 -1
- package/src/web/public/assets/app-context-DPFYOrgE.js +1 -0
- package/src/web/public/assets/{bar-DEY9q8mI.js → bar-I4qGaKTO.js} +1 -1
- package/src/web/public/assets/board-view-jt8QixVg.js +1 -0
- package/src/web/public/assets/{button-BRGGaUcY.js → button-VP4pjVsx.js} +1 -1
- package/src/web/public/assets/{composer-launch-DEHhs8k_.js → composer-launch-C20VCKMu.js} +1 -1
- package/src/web/public/assets/composer-panel-C3ET4SBT.js +1 -0
- package/src/web/public/assets/dag-xQRISqLX.js +1 -0
- package/src/web/public/assets/{dir-C8HhVpFz.js → dir-B-UPu7OY.js} +1 -1
- package/src/web/public/assets/{doc-DgYKv2wo.css → doc-Ka-2V5jn.css} +1 -1
- package/src/web/public/assets/doc-zDLeR8PE.js +6 -0
- package/src/web/public/assets/group-Hh-NL_sa.js +1 -0
- package/src/web/public/assets/{index-CUnLXQWJ.css → index-DXJxcKIU.css} +1 -1
- package/src/web/public/assets/index-Di6ErKBG.js +3 -0
- package/src/web/public/assets/md-history-B7TamGno.js +45 -0
- package/src/web/public/assets/md-parse-BjzYV8n7.js +6 -0
- package/src/web/public/assets/{member-picker-BJ-Ucm-9.js → member-picker-BtWykPer.js} +1 -1
- package/src/web/public/assets/{popup-BdVXUaJk.js → popup-DLfU1TXG.js} +1 -1
- package/src/web/public/assets/{popup-CHK8uSG4.css → popup-DzBICcYS.css} +1 -1
- package/src/web/public/assets/progress-CQAvP9-n.js +3 -0
- package/src/web/public/assets/{refs-Cb9pmVsb.js → refs-C6rZJhnb.js} +1 -1
- package/src/web/public/assets/{reopen-text-C3dnqygC.js → reopen-text-D0eQ2XAC.js} +1 -1
- package/src/web/public/assets/repo-form-modal-DpwLdBYp.js +1 -0
- package/src/web/public/assets/repos-BjVw1SQ2.js +12 -0
- package/src/web/public/assets/{route-crumb-DvXzznKm.js → route-crumb-DS76cmRK.js} +1 -1
- package/src/web/public/assets/{settings-BiqKrd8o.js → settings-C1NfJqNk.js} +1 -1
- package/src/web/public/assets/{task-j7fMfJUp.css → task-Dcd2eA8B.css} +1 -1
- package/src/web/public/assets/task-Ddr-iU14.js +14 -0
- package/src/web/public/assets/task-ops-s9kkuLcK.js +2 -0
- package/src/web/public/assets/task-utils-Y-j-zi8J.js +1 -0
- package/src/web/public/assets/template-preview-EM3OQ1Rc.js +1 -0
- package/src/web/public/assets/templates-BnEJVU91.js +10 -0
- package/src/web/public/assets/{tool-bar-CAMqYt5j.js → tool-bar-NHeX0Kmo.js} +2 -2
- package/src/web/public/assets/use-rail-drag-4iK6t5ab.js +1 -0
- package/src/web/public/index.html +15 -15
- package/src/shared/frontmatter.ts +0 -107
- package/src/web/public/assets/app-context-KCsdqNTq.js +0 -1
- package/src/web/public/assets/board-view-C8OQhkyi.js +0 -1
- package/src/web/public/assets/composer-panel-Cke_nbex.js +0 -1
- package/src/web/public/assets/dag-BvkJhdpX.js +0 -1
- package/src/web/public/assets/doc-R8KHVCxp.js +0 -6
- package/src/web/public/assets/group-d9wqo1pL.js +0 -1
- package/src/web/public/assets/index-DqTSNBzX.js +0 -3
- package/src/web/public/assets/md-history-BR2jLhFQ.js +0 -47
- package/src/web/public/assets/progress-CLSIX544.js +0 -3
- package/src/web/public/assets/repo-form-modal-awEPCcJK.js +0 -1
- package/src/web/public/assets/repos-CIgKjolu.js +0 -12
- package/src/web/public/assets/task-C664y4Vd.js +0 -14
- package/src/web/public/assets/task-ops-D8L16-TP.js +0 -2
- package/src/web/public/assets/task-status-Cjsm0xF7.js +0 -7
- package/src/web/public/assets/task-utils-Dh33OFKe.js +0 -1
- package/src/web/public/assets/template-preview-CjQ-ucPt.js +0 -1
- package/src/web/public/assets/templates-BZ1EM7W4.js +0 -10
- package/src/web/public/assets/use-rail-drag-C3GpkThI.js +0 -1
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
// 至此三个任务动词(领 get / 等 wait / 派 add)同构:action 层一律一行委托,
|
|
16
16
|
// 编排住在本域(add.js / update.js),队列本体只有 service.js 一处。
|
|
17
17
|
import { addTask, normalizeCwd } from '../service.js';
|
|
18
|
-
import { applyGroupFields, parseFrontmatter } from '../../../shared/frontmatter.js';
|
|
19
18
|
import { resolveGroupTarget } from '../ops/board-target.js';
|
|
20
19
|
import { normalizedGroupStore } from '../ops/group-store.js';
|
|
21
20
|
|
|
@@ -70,42 +69,32 @@ export async function submitTask({
|
|
|
70
69
|
forkOf,
|
|
71
70
|
forkKind,
|
|
72
71
|
}: SubmitTaskOptions = {}): Promise<Record<string, any>> {
|
|
73
|
-
|
|
72
|
+
const text = String(rawText ?? '');
|
|
74
73
|
let cwd: unknown = rawCwd;
|
|
75
74
|
// 任务级 timegoal 声明(--duration/--goal-prompt 落下来的):校验在 sanitizeTaskGoal
|
|
76
75
|
// (时长写法错误在**发布时报**,不在领取时报);只带了 goal-prompt 没带 duration → 报错。
|
|
77
76
|
const timegoal = duration || goalPrompt ? { duration, prompt: goalPrompt } : undefined;
|
|
78
77
|
|
|
78
|
+
// #197:归属不再写进正文 frontmatter——组上下文与所属仓库作为结构化参数交给 addTask,
|
|
79
|
+
// 由它落 topics.group_key / tasks.repo_key。正文只留 markdown 本身。
|
|
80
|
+
let groupKey = '';
|
|
81
|
+
let groupName = '';
|
|
82
|
+
let repoKey = '';
|
|
79
83
|
if (board || project) {
|
|
80
84
|
// --cwd **只在显式给了**时才参与校验(须与 --project 指向同一个项目)。
|
|
81
|
-
// 没给就留空:不能拿「进程当前目录」去跟项目比对——在别的仓库里执行
|
|
82
|
-
// `--project alpha` 是完全正常的用法(给了 --project 就不用再给 --cwd)。
|
|
83
85
|
const explicitCwd = rawCwd ? normalizeCwd(rawCwd as string).cwd : '';
|
|
84
86
|
const target = resolveGroupTarget(
|
|
85
87
|
{ board: board as string | undefined, project: project as string | undefined, cwd: explicitCwd },
|
|
86
88
|
await normalizedGroupStore(),
|
|
87
89
|
);
|
|
88
|
-
|
|
90
|
+
groupKey = target.boardKey;
|
|
91
|
+
groupName = target.boardName;
|
|
92
|
+
repoKey = target.projectKey;
|
|
89
93
|
if (target.cwd) cwd = target.cwd;
|
|
90
|
-
} else {
|
|
91
|
-
// 正文自带 frontmatter(面板草稿 / CLI 直接写 / 导入的 md)→ fail-open 补齐归属语义。
|
|
92
|
-
const fm = parseFrontmatter(text);
|
|
93
|
-
if (fm.board || fm.project) {
|
|
94
|
-
try {
|
|
95
|
-
const target = resolveGroupTarget(
|
|
96
|
-
{ board: fm.board, project: fm.project, cwd: '' } as { board?: string; project?: string; cwd?: string },
|
|
97
|
-
await normalizedGroupStore(),
|
|
98
|
-
);
|
|
99
|
-
text = applyGroupFields(text, target.fields as Record<string, unknown>);
|
|
100
|
-
// 落点跟到解析出的项目队列——**只在调用方没显式给 cwd 时**:显式意图优先,
|
|
101
|
-
// 不静默挪窝(与严格口径「cwd 与 project 冲突直接报错」同一精神,fail-open 只是
|
|
102
|
-
// 不拦任务,不是替调用方改主意)。
|
|
103
|
-
if (target.cwd && !rawCwd) cwd = target.cwd;
|
|
104
|
-
} catch {
|
|
105
|
-
/* 保留原正文与调用方落点 */
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
94
|
}
|
|
95
|
+
// #197:**不再从正文 frontmatter 提取归属** —— 归属只有两个来源:
|
|
96
|
+
// 显式参数(board/project)或调用方所在的队列(cwd);正文只存 markdown,
|
|
97
|
+
// 历史 --- 头在 v16/v17 迁移时已剥光,运行时不再有读/剥逻辑。
|
|
109
98
|
|
|
110
99
|
// localtask 的 addTask 尚未类型化(解构参数只推断出带默认值的键),按运行时形状整包断言
|
|
111
100
|
return addTask({
|
|
@@ -118,5 +107,8 @@ export async function submitTask({
|
|
|
118
107
|
// 任务链(#69):这条任务从哪条派生(裸数字=同主题父任务,'key:id'=跨主题)
|
|
119
108
|
forkOf,
|
|
120
109
|
forkKind,
|
|
110
|
+
groupKey,
|
|
111
|
+
groupName,
|
|
112
|
+
repoKey,
|
|
121
113
|
} as Record<string, any>);
|
|
122
114
|
}
|
|
@@ -5,7 +5,6 @@ import { badInput, notFound } from '../../../core/errors.js';
|
|
|
5
5
|
import { formatDuration, renderInstruction } from '../../../core/instruction-template.js';
|
|
6
6
|
import { activeTemplateOf } from '../../promptplug/index.js';
|
|
7
7
|
import { taskGoalTemplateCtx } from '../../promptplug/plugins/goal-prompt.js';
|
|
8
|
-
import { preserveFrontmatter } from '../../../shared/frontmatter.js';
|
|
9
8
|
import {
|
|
10
9
|
FEEDBACK_HEADING,
|
|
11
10
|
PLAIN_FEEDBACK_HEADING,
|
|
@@ -156,27 +155,28 @@ export async function reopenTask({
|
|
|
156
155
|
// 评论 / 「反馈修改」无轮次语义,维持旧段名。
|
|
157
156
|
let newText = task.text;
|
|
158
157
|
if (body) {
|
|
159
|
-
|
|
158
|
+
// #197:正文无 frontmatter——直接换 markdown,归属在关联里
|
|
159
|
+
newText = normalizeText(body);
|
|
160
160
|
} else if (fb) {
|
|
161
161
|
const heading = String(feedbackHeading ?? '').trim()
|
|
162
162
|
|| (kind === 'comment' ? PLAIN_FEEDBACK_HEADING : FEEDBACK_HEADING);
|
|
163
163
|
const useBold = typeof feedbackBold === 'boolean' ? feedbackBold : kind !== 'comment';
|
|
164
164
|
if (heading === FEEDBACK_HEADING) {
|
|
165
|
-
newText =
|
|
165
|
+
newText = appendAckFeedback({
|
|
166
166
|
base: task.text,
|
|
167
167
|
ack: task.roundSummary || '',
|
|
168
168
|
quote,
|
|
169
169
|
feedback: fb,
|
|
170
170
|
bold: useBold,
|
|
171
|
-
})
|
|
171
|
+
});
|
|
172
172
|
} else {
|
|
173
|
-
newText =
|
|
173
|
+
newText = appendFeedback({
|
|
174
174
|
base: task.text,
|
|
175
175
|
heading,
|
|
176
176
|
quote,
|
|
177
177
|
feedback: fb,
|
|
178
178
|
bold: useBold,
|
|
179
|
-
})
|
|
179
|
+
});
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
|
|
@@ -217,7 +217,7 @@ export async function reopenTask({
|
|
|
217
217
|
// 2. 链:src=新, dst=旧(task_links 是链的唯一来源)
|
|
218
218
|
linksRepo.addLink({
|
|
219
219
|
srcId: Number(
|
|
220
|
-
(conn.get('SELECT id FROM tasks WHERE
|
|
220
|
+
(conn.get('SELECT id FROM tasks WHERE repo_topic_id = :t AND seq = :s', {
|
|
221
221
|
t: hostTopic.id,
|
|
222
222
|
s: inserted.id,
|
|
223
223
|
}) || {}).id
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// (#54 自 service.js 拆出)单条任务的查/增/改:getTask、addTask(waiter 唤醒链 +
|
|
2
2
|
// 投递与唤醒)、updateTask(正文/时间目标/DAG 依赖/改归属搬家)。
|
|
3
3
|
import { badInput, notFound } from '../../../core/errors.js';
|
|
4
|
-
import { parseFrontmatter, preserveFrontmatter } from '../../../shared/frontmatter.js';
|
|
5
4
|
import { sanitizeTaskGoal } from '../../goals/taskgoal.js';
|
|
6
5
|
import { normalizeBlockBy, isReadyToClaim } from '../dag.js';
|
|
7
6
|
import { MAX_TEXT, normalizeSummary, normalizeText } from '../infra/store-io.js';
|
|
8
7
|
import { openLocaltaskStore as openStore, topics as topicsRepo, tasks as tasksRepo, links as linksRepo, txw as tx, db } from '../infra/repo/index.js';
|
|
9
8
|
import { normalizeCwd, resolveTaskKey, topicKeyFor } from '../paths.js';
|
|
9
|
+
import { topicKeyOf } from '../../../core/topic-key.js';
|
|
10
10
|
import { normalizeTask, foreignResolver, queueRelationsOf, relocateTask, resolveForkRef } from './task-view.js';
|
|
11
11
|
import { takeTopicWaiter } from '../waiters.js';
|
|
12
12
|
import { presence as presenceRepo } from '../infra/repo/index.js';
|
|
@@ -89,7 +89,14 @@ export async function addTask({
|
|
|
89
89
|
blocksFollowing = false,
|
|
90
90
|
forkOf: rawForkOf,
|
|
91
91
|
forkKind: rawForkKind,
|
|
92
|
+
groupKey: rawGroupKey,
|
|
93
|
+
repoKey: rawRepoKey,
|
|
94
|
+
groupName: rawGroupName,
|
|
92
95
|
} = {} as any): Promise<Record<string, any>> {
|
|
96
|
+
// #197:归属落两条 topic 关联——repo topic(编号/领取按它)+ group topic(组归属)。
|
|
97
|
+
const groupKey = String(rawGroupKey ?? '');
|
|
98
|
+
const repoKey = String(rawRepoKey ?? '');
|
|
99
|
+
const groupName = String(rawGroupName ?? '');
|
|
93
100
|
const body = normalizeText(text);
|
|
94
101
|
const summary = normalizeSummary(rawSummary, { optional: true });
|
|
95
102
|
// 任务级 timegoal 声明(--duration/--goal-prompt 落下来的):校验在 sanitizeTaskGoal
|
|
@@ -102,8 +109,12 @@ export async function addTask({
|
|
|
102
109
|
|
|
103
110
|
openStore();
|
|
104
111
|
// #190:只有目录队列。rawCwd 缺省时由 normalizeCwd 落到当前进程工作目录。
|
|
105
|
-
const {
|
|
106
|
-
|
|
112
|
+
const { cwd, name } = normalizeCwd(rawCwd);
|
|
113
|
+
// #197:编号与领取仍按仓库队列(key 由 cwd 派生,与改造前一致);
|
|
114
|
+
// 组归属单独挂 group topic(组本身也是一个 topic),两条关联同时写。
|
|
115
|
+
const key = topicKeyOf(cwd, '');
|
|
116
|
+
const t: { id: number; name: string; summary?: string } = topicsRepo.ensureTopic(key, { cwd, name, repoKey });
|
|
117
|
+
const groupTopicId = groupKey ? topicsRepo.ensureGroupTopic(groupKey, groupName).id : null;
|
|
107
118
|
const tView = topicsRepo.getTopic(key)!;
|
|
108
119
|
|
|
109
120
|
// 编号只在插入的同一个事务里取(insertTask 用 UPDATE ... RETURNING)。
|
|
@@ -130,6 +141,8 @@ export async function addTask({
|
|
|
130
141
|
const taskDraft = {
|
|
131
142
|
// 不写 id:真实编号由 insertTask 在事务内分配,避免事务外读号撞车
|
|
132
143
|
text: body,
|
|
144
|
+
// #197:组队列(可空)——组归属的唯一来源
|
|
145
|
+
groupTopicId,
|
|
133
146
|
status: 'pending',
|
|
134
147
|
timegoal,
|
|
135
148
|
round: forkRound,
|
|
@@ -171,7 +184,7 @@ export async function addTask({
|
|
|
171
184
|
const parentRow = tasksRepo.getTaskRow(parentTopic.id, parentSeq)!;
|
|
172
185
|
linksRepo.addLink({
|
|
173
186
|
srcId: Number(
|
|
174
|
-
(db().get('SELECT id FROM tasks WHERE
|
|
187
|
+
(db().get('SELECT id FROM tasks WHERE repo_topic_id = :t AND seq = :s', {
|
|
175
188
|
t: t.id,
|
|
176
189
|
s: inserted.id,
|
|
177
190
|
}) || {}).id
|
|
@@ -303,10 +316,9 @@ export async function updateTask({
|
|
|
303
316
|
if (moveTo) {
|
|
304
317
|
const toKey = topicKeyFor(String(moveTo.cwd || ''));
|
|
305
318
|
if (toKey && toKey !== key) {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
const
|
|
309
|
-
const explicitChange = !!newProject && newProject !== oldProject;
|
|
319
|
+
// #197:归属不再从正文读——moveTo 给了就是显式改归属(用户意图),
|
|
320
|
+
// 搬不动(已领取 / 队列内依赖)必须报错,绝不静默吞。
|
|
321
|
+
const explicitChange = true;
|
|
310
322
|
const rel = queueRelationsOf(t, task);
|
|
311
323
|
// 正判定:#190 起草稿态 plan 与待领取 pending 都能改归属(两者都还没「领取落点」);
|
|
312
324
|
// 已领取 / 已完成的落点在领取时定下,要改先 reopen。
|
|
@@ -335,9 +347,8 @@ export async function updateTask({
|
|
|
335
347
|
}
|
|
336
348
|
}
|
|
337
349
|
if (body) {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
});
|
|
350
|
+
// #197:正文只存 markdown——归属在关联里,不需要 preserveFrontmatter
|
|
351
|
+
tasksRepo.updateTask(host.id, hostTask.id, { text: body });
|
|
341
352
|
}
|
|
342
353
|
if (hasGoalInput) {
|
|
343
354
|
const live = topicsRepo.getTopic(host.key)!.tasks.find((x: any) => Number(x.id) === Number(hostTask.id))!;
|
|
@@ -8,7 +8,6 @@ import { normalizeBlockBy, isReadyToClaim } from '../dag.js';
|
|
|
8
8
|
import { topicKeyFor, resolveTaskKey } from '../paths.js';
|
|
9
9
|
import { parseStampMs, stampNow } from '../infra/store-io.js';
|
|
10
10
|
import { topics as topicsRepo, tasks as tasksRepo, links as linksRepo, db } from '../infra/repo/index.js';
|
|
11
|
-
import { parseFrontmatter } from '../../../shared/frontmatter.js';
|
|
12
11
|
import { isPending } from '../../../shared/task-status.js';
|
|
13
12
|
import type { ReadyOpts } from '../../../core/workflow/readiness.js';
|
|
14
13
|
import type { TaskObject } from '../infra/repo/rows.js';
|
|
@@ -108,6 +107,10 @@ export function relocateTask(fromTopic: any, seq: number | string, moveTo: any):
|
|
|
108
107
|
moveFrom: { key: fromTopic.key, seq: oldSeq, at: stampNow() },
|
|
109
108
|
blocksFollowing: !!src.task.blocksFollowing,
|
|
110
109
|
blockBy: (src.task.blockBy || []).filter((d: unknown) => String(d).includes(':')).map(String),
|
|
110
|
+
// #197:moveTo 带组就用新组(改组),否则组归属跟着任务走(只换仓库队列)
|
|
111
|
+
groupTopicId: moveTo?.groupKey
|
|
112
|
+
? topicsRepo.ensureGroupTopic(String(moveTo.groupKey), String(moveTo.groupName || '')).id
|
|
113
|
+
: ((src.task as any).groupTopicId ?? null),
|
|
111
114
|
});
|
|
112
115
|
const newId = inserted.id;
|
|
113
116
|
|
|
@@ -122,7 +125,7 @@ export function relocateTask(fromTopic: any, seq: number | string, moveTo: any):
|
|
|
122
125
|
// 3. 链:新 → 旧,type='reopen'(搬队列是派生的特例)
|
|
123
126
|
linksRepo.addLink({
|
|
124
127
|
srcId: Number(
|
|
125
|
-
(db().get('SELECT id FROM tasks WHERE
|
|
128
|
+
(db().get('SELECT id FROM tasks WHERE repo_topic_id = :t AND seq = :s', {
|
|
126
129
|
t: target.id,
|
|
127
130
|
s: newId,
|
|
128
131
|
}) || {}).id
|
|
@@ -134,15 +137,15 @@ export function relocateTask(fromTopic: any, seq: number | string, moveTo: any):
|
|
|
134
137
|
});
|
|
135
138
|
|
|
136
139
|
// 4. 跨队列引用改写:指向旧地址的 "fromKey:oldSeq" → 新地址
|
|
137
|
-
for (const row of db().all('SELECT
|
|
140
|
+
for (const row of db().all('SELECT repo_topic_id FROM tasks WHERE ext LIKE :pat', {
|
|
138
141
|
pat: '%' + fromTopic.key + ':' + oldSeq + '%',
|
|
139
142
|
})) {
|
|
140
|
-
for (const other of tasksRepo.listTaskRowsByTopic(Number(row.
|
|
143
|
+
for (const other of tasksRepo.listTaskRowsByTopic(Number(row.repo_topic_id))) {
|
|
141
144
|
if (!Array.isArray(other.task.blockBy) || !other.task.blockBy.some((d: unknown) => String(d).includes(':'))) continue;
|
|
142
145
|
const from = fromTopic.key + ':' + oldSeq;
|
|
143
146
|
const to = toKey + ':' + newId;
|
|
144
147
|
if (!other.task.blockBy.some((d: unknown) => String(d) === from)) continue;
|
|
145
|
-
tasksRepo.updateTask(Number(row.
|
|
148
|
+
tasksRepo.updateTask(Number(row.repo_topic_id), other.task.id, {
|
|
146
149
|
blockBy: other.task.blockBy.map((d: unknown) => (String(d) === from ? to : d)),
|
|
147
150
|
});
|
|
148
151
|
}
|
|
@@ -180,13 +183,11 @@ export function foreignResolver(): (topicKey: string, taskId: number | string) =
|
|
|
180
183
|
};
|
|
181
184
|
}
|
|
182
185
|
|
|
183
|
-
// 组任务标注(#85
|
|
184
|
-
//
|
|
185
|
-
//
|
|
186
|
-
// parseFrontmatter 不抛错(无块/坏块都回空对象),没有 board → ''(= 纯项目任务)。
|
|
186
|
+
// 组任务标注(#85):#197 起不再解析正文 frontmatter —— 归属来自库内关联,
|
|
187
|
+
// 由 TASK_SELECT 的 JOIN 带出(task.boardKey = topics.group_key,组 job 的 repos.key)。
|
|
188
|
+
// 没有 group_key → ''(= 纯仓库任务)。正文里的 `---` 头在迁移/提交时已剥掉。
|
|
187
189
|
function boardMarkOf(t: TaskInput): string {
|
|
188
|
-
|
|
189
|
-
return fm.board ? String(fm.board).trim() : '';
|
|
190
|
+
return String((t as any).boardKey ?? '').trim();
|
|
190
191
|
}
|
|
191
192
|
|
|
192
193
|
export function normalizeTask(t: TaskInput, siblings?: any[] | null, readyOpts: ReadyOpts = {}): Record<string, any> {
|
|
@@ -217,6 +218,11 @@ export function normalizeTask(t: TaskInput, siblings?: any[] | null, readyOpts:
|
|
|
217
218
|
// 组任务标注(#85):frontmatter.board 原样(面板创建写 board id,也可能有
|
|
218
219
|
// 手写 key/name);'' = 纯项目任务。分流判据只在标注,不重复解析正文。
|
|
219
220
|
boardMark: boardMarkOf(t),
|
|
221
|
+
// #197:归属关联透传(repo topic 必填 / group topic 可空),前端与交付上下文直接读
|
|
222
|
+
repoTopicId: Number((t as any).repoTopicId ?? 0),
|
|
223
|
+
groupTopicId: (t as any).groupTopicId != null ? Number((t as any).groupTopicId) : null,
|
|
224
|
+
repoKey: String((t as any).repoKey ?? ''),
|
|
225
|
+
boardKey: String((t as any).boardKey ?? ''),
|
|
220
226
|
// 迁出标记:本机 → 云端迁移后原条目保留在此,作为 tombstone(可撤销/移除)。
|
|
221
227
|
// 带 migratedTo 的任务**不再算待领取**(不会被派发给 agent,也不再进看板的
|
|
222
228
|
// 待领取列)——它只是一条「去哪了」的记录。结构 {side:'cloud', topic, targetId, at}。
|
|
@@ -10,9 +10,9 @@ import { normalizeSummary } from '../infra/store-io.js';
|
|
|
10
10
|
import { openLocaltaskStore as openStore, topics as topicsRepo, settings as settingsRepo, txw as tx } from '../infra/repo/index.js';
|
|
11
11
|
import { DEFAULT_TIMEOUT_SEC, MAX_TIMEOUT_SEC } from '../infra/repo/settings.js';
|
|
12
12
|
import { foreignResolver, isPending, topicView } from './task-view.js';
|
|
13
|
-
import { stripFrontmatter } from '../../../shared/frontmatter.js';
|
|
14
13
|
import { deleteGuard } from './deletion.js';
|
|
15
14
|
import { repoContextIndex, repoCtxOf } from '../infra/repo-ctx.js';
|
|
15
|
+
import { topicKeyOf } from '../../../core/topic-key.js';
|
|
16
16
|
|
|
17
17
|
/** addTopic / pruneTopics 等主题操作的入参(HTTP/CLI body → any)。 */
|
|
18
18
|
export type TopicOpInput = any;
|
|
@@ -106,7 +106,9 @@ export async function pruneTopics({
|
|
|
106
106
|
if (!deleteGuard(t, { force: false, key: t.key, scope: 'prune' }).ok) continue;
|
|
107
107
|
const tasks = t.tasks;
|
|
108
108
|
const hasPending = tasks.some(isPending);
|
|
109
|
-
|
|
109
|
+
// #200:旧模型无目录分支同样不许带活任务——带 pending 的队列清了就是幽灵
|
|
110
|
+
//(活任务挂软删队列,任何 cwd 都领不到)。存量由 v18 迁移恢复。
|
|
111
|
+
const isLegacy = !t.cwd && !hasPending;
|
|
110
112
|
const isEmpty = tasks.length === 0;
|
|
111
113
|
const isFinished = allFinished && tasks.length > 0 && !hasPending;
|
|
112
114
|
const cwdGone = missingDir && !!t.cwd && !hasPending && !existsSync(String(t.cwd));
|
|
@@ -158,9 +160,9 @@ export async function updateSettings({ timeoutSec }: UpdateSettingsInput = {}):
|
|
|
158
160
|
return settingsRepo.settingsView();
|
|
159
161
|
}
|
|
160
162
|
|
|
161
|
-
/** 任务标题 =
|
|
163
|
+
/** 任务标题 = 正文首个非空行(去前导 #,截 80 字)。#197 正文无 frontmatter 头。 */
|
|
162
164
|
function taskTitleOf(row: any): string {
|
|
163
|
-
const body = String(
|
|
165
|
+
const body = String((row && row.text) || '').trim();
|
|
164
166
|
const first = body.split(/\r?\n/).map((s) => s.trim()).find(Boolean) || '';
|
|
165
167
|
const title = first.replace(/^#+\s*/, '').trim().slice(0, 80);
|
|
166
168
|
return title || `任务 #${Number(row && row.id) || ''}`;
|
|
@@ -192,3 +194,79 @@ export async function pendingQueueInfo(key: string, excludeId?: number | string)
|
|
|
192
194
|
.map((x: any) => ({ id: Number(x.id) || 0, title: taskTitleOf(x), topic }));
|
|
193
195
|
return { topic, count: list.length, list };
|
|
194
196
|
}
|
|
197
|
+
|
|
198
|
+
// ─── #199:仓库/组登记时自动持有自己的 topic(幂等)─────────────────────────
|
|
199
|
+
//
|
|
200
|
+
// 口径:**一个仓库 = 一条目录队列 topic**(cwd=仓库登记路径),**一个组 = 一条组 topic**
|
|
201
|
+
// (key=group:<组key>)。登记时就建好,侧栏/命令行就不用再「按目录猜队列」;
|
|
202
|
+
// 删除仓库/组时不用手工收尾——topics.repo_key 是 ON DELETE CASCADE,跟着一起走。
|
|
203
|
+
//
|
|
204
|
+
// SQLite **不支持条件外键**(外键不能带 WHERE),所以「每个仓库必须有且只有一条队列」
|
|
205
|
+
// 这种父→子的存在性约束只能靠这里保证:登记时 ensure(本函数)+ 编排后自动刷新
|
|
206
|
+
// (syncQueuesQuiet)+ 「仓库管理」页的「刷新队列」按钮(同一个 syncQueues)。
|
|
207
|
+
|
|
208
|
+
/** 仓库登记后建/取其目录队列 topic。 */
|
|
209
|
+
export function ensureRepoQueue({ repoKey, cwd, name }: { repoKey: string; cwd: string; name?: string }): { topicId: number; key: string } {
|
|
210
|
+
const rk = String(repoKey || '').trim();
|
|
211
|
+
const dir = String(cwd || '').trim();
|
|
212
|
+
if (!rk) throw badInput('ensureRepoQueue: 需要仓库 key');
|
|
213
|
+
if (!dir) throw badInput('ensureRepoQueue: 需要仓库登记路径');
|
|
214
|
+
openStore();
|
|
215
|
+
const key = topicKeyOf(dir, '');
|
|
216
|
+
const t = topicsRepo.ensureTopic(key, { cwd: dir, name: name || '', repoKey: rk });
|
|
217
|
+
return { topicId: Number(t.id), key };
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** 组登记后建/取其组 topic(key=group:<组key>)。 */
|
|
221
|
+
export function ensureGroupQueue({ groupKey, name }: { groupKey: string; name?: string }): { topicId: number; key: string } {
|
|
222
|
+
const gk = String(groupKey || '').trim();
|
|
223
|
+
if (!gk) throw badInput('ensureGroupQueue: 需要组 key');
|
|
224
|
+
openStore();
|
|
225
|
+
const t = topicsRepo.ensureGroupTopic(gk, name || '');
|
|
226
|
+
return { topicId: Number(t.id), key: t.key };
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* 补齐老库缺的队列 topic(幂等):遍历已登记仓库/组,缺的补建。
|
|
231
|
+
* 返回值便于 CLI/日志核对;重复调用无副作用。
|
|
232
|
+
*
|
|
233
|
+
* 直接查 repos 表(同库,不经 repos service)——避免 localtask→repos 的运行时耦合:
|
|
234
|
+
* 这里只需要 key / path / name 三个字段,拿「旧 JSON store 快照」是杀鸡用牛刀。
|
|
235
|
+
*/
|
|
236
|
+
export async function syncQueues(): Promise<{ repos: number; groups: number }> {
|
|
237
|
+
openStore();
|
|
238
|
+
return tx((conn) => {
|
|
239
|
+
let r = 0;
|
|
240
|
+
let g = 0;
|
|
241
|
+
for (const repo of conn.all("SELECT key, path, name FROM repos WHERE type = 'repo' AND path <> '' AND deleted_at IS NULL")) {
|
|
242
|
+
const rk = String(repo.key || '');
|
|
243
|
+
const cwd = String(repo.path || '');
|
|
244
|
+
if (!rk || !cwd) continue;
|
|
245
|
+
const before = conn.get('SELECT id FROM topics WHERE key = :k', { k: topicKeyOf(cwd, '') });
|
|
246
|
+
ensureRepoQueue({ repoKey: rk, cwd, name: String(repo.name || '') });
|
|
247
|
+
if (!before) r += 1;
|
|
248
|
+
}
|
|
249
|
+
for (const b of conn.all("SELECT key, name FROM repos WHERE type = 'group' AND deleted_at IS NULL")) {
|
|
250
|
+
const gk = String(b.key || '');
|
|
251
|
+
if (!gk) continue;
|
|
252
|
+
const before = conn.get('SELECT id FROM topics WHERE key = :k', { k: `group:${gk}` });
|
|
253
|
+
ensureGroupQueue({ groupKey: gk, name: String(b.name || '') });
|
|
254
|
+
if (!before) g += 1;
|
|
255
|
+
}
|
|
256
|
+
return { repos: r, groups: g };
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* 编排(登记 / 加组成员 / 移除 / 删除)后的自动刷新:补齐队列,失败**不拦主操作**。
|
|
262
|
+
*
|
|
263
|
+
* 编排是用户正在做的事,队列只是配套资源——补建失败不该让「加成员」报错;
|
|
264
|
+
* 失败的缺口由「仓库管理」页的「刷新队列」按钮兜(同一份 syncQueues)。
|
|
265
|
+
*/
|
|
266
|
+
export async function syncQueuesQuiet(): Promise<{ repos: number; groups: number }> {
|
|
267
|
+
try {
|
|
268
|
+
return await syncQueues();
|
|
269
|
+
} catch {
|
|
270
|
+
return { repos: 0, groups: 0 };
|
|
271
|
+
}
|
|
272
|
+
}
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
// 落点解析与 add.js 共用同一份实现(board-target.resolveGroupTarget + group-store),
|
|
11
11
|
// 不另起炉灶。
|
|
12
12
|
import { badInput } from '../../../core/errors.js';
|
|
13
|
-
import { applyGroupFields, parseFrontmatter, preserveFrontmatter } from '../../../shared/frontmatter.js';
|
|
14
13
|
import { resolveGroupTarget } from '../ops/board-target.js';
|
|
15
14
|
import * as service from '../service.js';
|
|
16
15
|
import { normalizedGroupStore } from '../ops/group-store.js';
|
|
@@ -25,42 +24,38 @@ export interface UpdateTaskParams {
|
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
/**
|
|
28
|
-
*
|
|
27
|
+
* 解析这次编辑的**归属落点**(#197:归属改由显式参数给出,不再读正文 frontmatter)。
|
|
29
28
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* 但队列还在 nx-as,字段没变、搬家用不上,用户怎么改都「没有变化」。
|
|
34
|
-
* 同队列 → null(纯文案编辑,与搬家无关)。
|
|
35
|
-
*
|
|
36
|
-
* @returns null | { moveTo: {cwd: string, name: string}, text: string }
|
|
29
|
+
* @param project 目标归属仓库(key / 名称 / 路径);不传 = 不改归属
|
|
30
|
+
* @param board 目标组(id / key / 名称);不传 = 不改组
|
|
31
|
+
* @returns null(纯文案编辑)或 { moveTo, text, groupKey, groupName }
|
|
37
32
|
*/
|
|
38
|
-
async function resolveAttributionChange({
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const merged = preserveFrontmatter(current.text, String(text));
|
|
43
|
-
const newFm = parseFrontmatter(merged);
|
|
44
|
-
const oldProject = String(oldFm.project || '').trim();
|
|
45
|
-
const newProject = String(newFm.project || '').trim();
|
|
46
|
-
if (!newProject) return null;
|
|
47
|
-
const projectChanged = newProject !== oldProject;
|
|
33
|
+
async function resolveAttributionChange({ text, project, board }: UpdateTaskParams): Promise<
|
|
34
|
+
null | { moveTo: { cwd: string; name: string; groupKey: string; groupName: string }; text: string }
|
|
35
|
+
> {
|
|
36
|
+
if (!project && !board) return null;
|
|
48
37
|
let target: any;
|
|
49
38
|
try {
|
|
50
39
|
target = resolveGroupTarget(
|
|
51
|
-
{ board: String(
|
|
40
|
+
{ board: String(board || '').trim(), project: String(project || '').trim(), cwd: '' },
|
|
52
41
|
await normalizedGroupStore(),
|
|
53
42
|
);
|
|
54
43
|
} catch (err) {
|
|
55
|
-
//
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
44
|
+
// 归属是这次明确要改的:解析不到(未登记 / 不是本组成员)就明说,不静默吞
|
|
45
|
+
throw badInput(`改归属失败:${(err as Error).message}`);
|
|
46
|
+
}
|
|
47
|
+
if (!target.cwd) {
|
|
48
|
+
throw badInput('改归属失败:没有解析出目标项目路径(--project 必须指向已登记仓库)');
|
|
59
49
|
}
|
|
60
50
|
return {
|
|
61
|
-
moveTo: {
|
|
62
|
-
|
|
63
|
-
|
|
51
|
+
moveTo: {
|
|
52
|
+
cwd: target.cwd,
|
|
53
|
+
name: target.projectName || target.projectKey,
|
|
54
|
+
groupKey: target.boardKey,
|
|
55
|
+
groupName: target.boardName,
|
|
56
|
+
},
|
|
57
|
+
// #197:正文只存 markdown(历史 --- 头在迁移时已剥光,运行时不剥)
|
|
58
|
+
text: text === undefined || text === null ? '' : String(text),
|
|
64
59
|
};
|
|
65
60
|
}
|
|
66
61
|
|
|
@@ -68,12 +63,16 @@ async function resolveAttributionChange({ cwd, key, id, text }: UpdateTaskParams
|
|
|
68
63
|
export async function updateTask(params: UpdateTaskParams): Promise<Record<string, any>> {
|
|
69
64
|
const plan = await resolveAttributionChange(params);
|
|
70
65
|
if (!plan) return service.updateTask(params as Record<string, any>); // service 层参数尚未类型化
|
|
71
|
-
|
|
66
|
+
const patch: Record<string, any> = { ...params, moveTo: plan.moveTo };
|
|
67
|
+
if (plan.text) patch.text = plan.text; // 只改归属、不动正文时别把正文清空
|
|
68
|
+
return service.updateTask(patch);
|
|
72
69
|
}
|
|
73
70
|
|
|
74
71
|
/** 重开任务(用户的修改反馈;--text 可能带着改过的归属,同样搬家)。 */
|
|
75
72
|
export async function reopenTask(params: UpdateTaskParams): Promise<Record<string, any>> {
|
|
76
73
|
const plan = await resolveAttributionChange(params);
|
|
77
74
|
if (!plan) return service.reopenTask(params);
|
|
78
|
-
|
|
75
|
+
const patch: Record<string, any> = { ...params, moveTo: plan.moveTo };
|
|
76
|
+
if (plan.text) patch.text = plan.text;
|
|
77
|
+
return service.reopenTask(patch);
|
|
79
78
|
}
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
// 调用方(attach.js 的编排层)负责把本机附件仓的命中结果喂进来。
|
|
10
10
|
import { existsSync } from 'node:fs';
|
|
11
11
|
import { isImageName } from '../../../core/filekind.js';
|
|
12
|
-
import { stripFrontmatter } from '../../../shared/frontmatter.js';
|
|
13
12
|
|
|
14
13
|
const KIND_LABEL: Record<string, string> = { file: '附件', url: '链接', task: '任务', ref: '文档', mdfile: 'md', folder: '文件夹', repo: '仓库' };
|
|
15
14
|
const IMAGE_LABEL = '图片';
|
|
@@ -58,9 +57,9 @@ export function hostOfUrl(href: unknown): string {
|
|
|
58
57
|
}
|
|
59
58
|
}
|
|
60
59
|
|
|
61
|
-
/** 任务标题 =
|
|
60
|
+
/** 任务标题 = 正文首个非空行,去 # 前缀,截 80 字。#197 正文无 frontmatter 头。 */
|
|
62
61
|
function taskTitleOf(body: unknown): string {
|
|
63
|
-
const text = String(
|
|
62
|
+
const text = String(body || '').trim();
|
|
64
63
|
const first = text.split(/\r?\n/).map((s) => s.trim()).find(Boolean) || '';
|
|
65
64
|
return first.replace(/^#+\s*/, '').trim().slice(0, 80);
|
|
66
65
|
}
|
|
@@ -81,7 +80,7 @@ export function targetLookupsOf(db: any, rows: any): ResourceLookups {
|
|
|
81
80
|
if (!db) return { tasks, refs };
|
|
82
81
|
const taskSql = `SELECT t.id, t.seq, t.status, t.body, t.deleted_at,
|
|
83
82
|
k.key AS topicKey, k.name AS topicName
|
|
84
|
-
FROM tasks t JOIN topics k ON k.id = t.
|
|
83
|
+
FROM tasks t JOIN topics k ON k.id = t.repo_topic_id`;
|
|
85
84
|
for (const row of rows) {
|
|
86
85
|
const meta = metaOf(row);
|
|
87
86
|
if (baseKind(row) === 'task') {
|
|
@@ -297,7 +297,7 @@ export async function attachToTask({
|
|
|
297
297
|
const seq = Number(String(task).replace(/^#/, ''));
|
|
298
298
|
if (!Number.isFinite(seq)) throw badInput(`--task 需要任务编号(同主题 seq): ${task}`);
|
|
299
299
|
const row = db.get(
|
|
300
|
-
`SELECT t.id, t.seq FROM tasks t JOIN topics k ON k.id = t.
|
|
300
|
+
`SELECT t.id, t.seq FROM tasks t JOIN topics k ON k.id = t.repo_topic_id
|
|
301
301
|
WHERE k.key = :key AND t.seq = :seq AND t.deleted_at IS NULL`,
|
|
302
302
|
{ key: topicKey, seq }
|
|
303
303
|
);
|
|
@@ -440,7 +440,7 @@ function topicNameOf(t: any): string {
|
|
|
440
440
|
/** 关系表挂的是全局 tasks.id,而 CLI 只有 (topicKey, seq)——统一在这里换算。 */
|
|
441
441
|
function taskGlobalIdOf(conn: any, { topicKey, seq }: { topicKey: unknown; seq: unknown }): number {
|
|
442
442
|
const row = conn.get(
|
|
443
|
-
`SELECT t.id FROM tasks t JOIN topics k ON k.id = t.
|
|
443
|
+
`SELECT t.id FROM tasks t JOIN topics k ON k.id = t.repo_topic_id
|
|
444
444
|
WHERE k.key = :key AND t.seq = :seq AND t.deleted_at IS NULL`,
|
|
445
445
|
{ key: String(topicKey || ''), seq: Number(seq) }
|
|
446
446
|
);
|
|
@@ -32,15 +32,6 @@ export type RepoLike = any;
|
|
|
32
32
|
|
|
33
33
|
const normPath = (p: unknown): string => String(p || '').replace(/[\\/]+/g, '/').replace(/\/$/, '').toLowerCase();
|
|
34
34
|
|
|
35
|
-
/**
|
|
36
|
-
* 介绍文档的地址:ref:<refId>(绑定存在时);没有绑定给空串。
|
|
37
|
-
* agent 拿到后用 `nx-kv docs get --ref <refId>` 读正文。
|
|
38
|
-
*/
|
|
39
|
-
function introDocId(ref: unknown): string {
|
|
40
|
-
const r = ref as { ref?: string } | null | undefined;
|
|
41
|
-
return r && typeof r === 'object' && r.ref ? 'ref:' + r.ref : '';
|
|
42
|
-
}
|
|
43
|
-
|
|
44
35
|
/** 看板按 id / key / 名称匹配(组名最像人话,agent 上下文里只有组名) */
|
|
45
36
|
export function findBoard(boards: BoardLike[], want: unknown): BoardLike | null {
|
|
46
37
|
const w = String(want ?? '').trim();
|
|
@@ -93,18 +84,19 @@ export interface GroupTargetStore {
|
|
|
93
84
|
/** resolveGroupTarget 的出站形状。 */
|
|
94
85
|
export interface GroupTargetResult {
|
|
95
86
|
boardId: string;
|
|
87
|
+
/** #197:组的 repos.key(存 topics.group_key 用;前端/CLI 侧仍用 boardId 寻址) */
|
|
88
|
+
boardKey: string;
|
|
96
89
|
boardName: string;
|
|
97
90
|
projectKey: string;
|
|
98
91
|
projectName: string;
|
|
99
92
|
cwd: string;
|
|
100
|
-
fields: Record<string, unknown>;
|
|
101
93
|
}
|
|
102
94
|
|
|
103
95
|
/**
|
|
104
96
|
* 解析提交目标。
|
|
105
97
|
* @param {{board?: string, project?: string, cwd?: string}} want --board / --project / --cwd 原始值
|
|
106
98
|
* @param {{boards: Array, repos: Array}} store 仓库登记与看板(由调用方注入,归一化后)
|
|
107
|
-
* @returns {{boardId: string, boardName: string, projectKey: string, projectName: string, cwd: string
|
|
99
|
+
* @returns {{boardId: string, boardKey: string, boardName: string, projectKey: string, projectName: string, cwd: string}}
|
|
108
100
|
*/
|
|
109
101
|
export function resolveGroupTarget(want: GroupTargetWant, store: GroupTargetStore): GroupTargetResult {
|
|
110
102
|
const boards = (store && store.boards) || [];
|
|
@@ -113,7 +105,7 @@ export function resolveGroupTarget(want: GroupTargetWant, store: GroupTargetStor
|
|
|
113
105
|
const projWant = String(want.project ?? '').trim();
|
|
114
106
|
const cwdWant = String(want.cwd ?? '').trim();
|
|
115
107
|
if (!boardWant && !projWant) {
|
|
116
|
-
return { boardId: '', boardName: '', projectKey: '', projectName: '', cwd: ''
|
|
108
|
+
return { boardId: '', boardKey: '', boardName: '', projectKey: '', projectName: '', cwd: '' };
|
|
117
109
|
}
|
|
118
110
|
|
|
119
111
|
let board: BoardLike | null = null;
|
|
@@ -158,28 +150,16 @@ export function resolveGroupTarget(want: GroupTargetWant, store: GroupTargetStor
|
|
|
158
150
|
);
|
|
159
151
|
}
|
|
160
152
|
|
|
161
|
-
// frontmatter
|
|
162
|
-
//
|
|
163
|
-
//
|
|
164
|
-
const fields: Record<string, unknown> = {};
|
|
165
|
-
if (board) {
|
|
166
|
-
fields.board = board.id;
|
|
167
|
-
fields.boardIntro = introDocId(board.doc);
|
|
168
|
-
fields.boardDesc = String(board.desc || '').trim();
|
|
169
|
-
}
|
|
170
|
-
if (repo) {
|
|
171
|
-
fields.project = repo.key;
|
|
172
|
-
fields.projectIntro = introDocId(repo.doc);
|
|
173
|
-
fields.projectDesc = String(repo.desc || '').trim();
|
|
174
|
-
}
|
|
175
|
-
|
|
153
|
+
// #197/#200:frontmatter 字段(board/project/介绍引用)已随正文 frontmatter 一起删除——
|
|
154
|
+
// 归属由调用方落库(topics.group_topic_id / tasks.repo_topic_id),介绍引用挂组/仓库的
|
|
155
|
+
// 文档列表(docs ref add --owner),不再进任务正文。
|
|
176
156
|
return {
|
|
177
157
|
boardId: board ? board.id : '',
|
|
158
|
+
boardKey: board ? String(board.key || '') : '',
|
|
178
159
|
boardName: board ? board.name || '' : '',
|
|
179
160
|
projectKey: repo ? repo.key : '',
|
|
180
161
|
projectName: repo ? repo.name || repo.key : '',
|
|
181
162
|
// 落点:有项目就用项目登记的路径(进它的队列);否则调用方给的 cwd 说了算
|
|
182
163
|
cwd: repo ? repo.path || '' : '',
|
|
183
|
-
fields,
|
|
184
164
|
};
|
|
185
165
|
}
|
|
@@ -5,6 +5,7 @@ import { action } from '../../../runtime/action-decorator.js';
|
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
|
|
7
7
|
import * as boardsNs from '../boards.js';
|
|
8
|
+
import { orchestrateQuiet } from '../orchestrate.js';
|
|
8
9
|
const boards: any = boardsNs;
|
|
9
10
|
|
|
10
11
|
/** board.add 的入参契约(CLI 与 HTTP 共用同一份)。 */
|
|
@@ -25,7 +26,10 @@ export class BoardAddAction extends ActionBase<typeof input> {
|
|
|
25
26
|
})
|
|
26
27
|
override async run(ctx: ActionInput<this['_input']>) {
|
|
27
28
|
|
|
28
|
-
|
|
29
|
+
const b: any = await boards.createBoard(ctx);
|
|
30
|
+
// #199:登记即编排——补齐队列 topic(幂等,只补不删);失败不拦登记。
|
|
31
|
+
await orchestrateQuiet();
|
|
32
|
+
return b;
|
|
29
33
|
|
|
30
34
|
}
|
|
31
35
|
}
|