nx-kv 0.68.2 → 0.69.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 +68 -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 +6 -0
- package/src/core/db/migrations/v16-data.ts +167 -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/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 +5 -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-boardtasks.ts +39 -39
- 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 +79 -3
- 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 +16 -1
- package/src/web/frontend/api/client.generated.ts +11 -3
- 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/panes/live-block.tsx +3 -11
- 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/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/settings/style.css +12 -2
- 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/frontend/styles-v2/shell.css +16 -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-BL344XZg.js} +1 -1
- package/src/web/public/assets/composer-panel-D0ojgf7z.js +1 -0
- package/src/web/public/assets/dag-BY0lf-Nl.js +1 -0
- package/src/web/public/assets/{dir-B0nwSQhy.js → dir-BNHyviHQ.js} +1 -1
- package/src/web/public/assets/{doc-DgYKv2wo.css → doc-Ka-2V5jn.css} +1 -1
- package/src/web/public/assets/doc-wmc4swmo.js +6 -0
- package/src/web/public/assets/group-BSQ9_Gjs.js +1 -0
- package/src/web/public/assets/index-D2P-v30u.js +3 -0
- package/src/web/public/assets/{index-GyxCJY9y.css → index-DHLeXl42.css} +1 -1
- package/src/web/public/assets/md-history-D0bYVPZY.js +47 -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-Cf4ZbAra.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-BahZhXq3.js +1 -0
- package/src/web/public/assets/repos-C2cZtRFo.js +12 -0
- package/src/web/public/assets/{route-crumb-DvXzznKm.js → route-crumb-DS76cmRK.js} +1 -1
- package/src/web/public/assets/{settings-BD9rXOpy.js → settings-C_VmzG7F.js} +1 -1
- package/src/web/public/assets/settings-CjXDi7qu.css +1 -0
- package/src/web/public/assets/task-C4Sqe4vT.js +14 -0
- package/src/web/public/assets/{task-j7fMfJUp.css → task-Dcd2eA8B.css} +1 -1
- package/src/web/public/assets/task-ops-SFagO-OC.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-B8jnGSAl.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-CtZxisjE.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-Btmv_9MI.js +0 -1
- package/src/web/public/assets/dag-CD7N_yfu.js +0 -1
- package/src/web/public/assets/doc-R8KHVCxp.js +0 -6
- package/src/web/public/assets/group-B-f_aoow.js +0 -1
- package/src/web/public/assets/index-Bs5BehN8.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/settings-d2ah_h6O.css +0 -1
- package/src/web/public/assets/task-CJyFbImw.js +0 -14
- package/src/web/public/assets/task-ops-CsiArYZB.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-BC-bPIfY.js +0 -10
- package/src/web/public/assets/use-rail-drag-C3GpkThI.js +0 -1
|
@@ -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;
|
|
@@ -158,9 +158,9 @@ export async function updateSettings({ timeoutSec }: UpdateSettingsInput = {}):
|
|
|
158
158
|
return settingsRepo.settingsView();
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
/** 任务标题 =
|
|
161
|
+
/** 任务标题 = 正文首个非空行(去前导 #,截 80 字)。#197 正文无 frontmatter 头。 */
|
|
162
162
|
function taskTitleOf(row: any): string {
|
|
163
|
-
const body = String(
|
|
163
|
+
const body = String((row && row.text) || '').trim();
|
|
164
164
|
const first = body.split(/\r?\n/).map((s) => s.trim()).find(Boolean) || '';
|
|
165
165
|
const title = first.replace(/^#+\s*/, '').trim().slice(0, 80);
|
|
166
166
|
return title || `任务 #${Number(row && row.id) || ''}`;
|
|
@@ -192,3 +192,79 @@ export async function pendingQueueInfo(key: string, excludeId?: number | string)
|
|
|
192
192
|
.map((x: any) => ({ id: Number(x.id) || 0, title: taskTitleOf(x), topic }));
|
|
193
193
|
return { topic, count: list.length, list };
|
|
194
194
|
}
|
|
195
|
+
|
|
196
|
+
// ─── #199:仓库/组登记时自动持有自己的 topic(幂等)─────────────────────────
|
|
197
|
+
//
|
|
198
|
+
// 口径:**一个仓库 = 一条目录队列 topic**(cwd=仓库登记路径),**一个组 = 一条组 topic**
|
|
199
|
+
// (key=group:<组key>)。登记时就建好,侧栏/命令行就不用再「按目录猜队列」;
|
|
200
|
+
// 删除仓库/组时不用手工收尾——topics.repo_key 是 ON DELETE CASCADE,跟着一起走。
|
|
201
|
+
//
|
|
202
|
+
// SQLite **不支持条件外键**(外键不能带 WHERE),所以「每个仓库必须有且只有一条队列」
|
|
203
|
+
// 这种父→子的存在性约束只能靠这里保证:登记时 ensure(本函数)+ 编排后自动刷新
|
|
204
|
+
// (syncQueuesQuiet)+ 「仓库管理」页的「刷新队列」按钮(同一个 syncQueues)。
|
|
205
|
+
|
|
206
|
+
/** 仓库登记后建/取其目录队列 topic。 */
|
|
207
|
+
export function ensureRepoQueue({ repoKey, cwd, name }: { repoKey: string; cwd: string; name?: string }): { topicId: number; key: string } {
|
|
208
|
+
const rk = String(repoKey || '').trim();
|
|
209
|
+
const dir = String(cwd || '').trim();
|
|
210
|
+
if (!rk) throw badInput('ensureRepoQueue: 需要仓库 key');
|
|
211
|
+
if (!dir) throw badInput('ensureRepoQueue: 需要仓库登记路径');
|
|
212
|
+
openStore();
|
|
213
|
+
const key = topicKeyOf(dir, '');
|
|
214
|
+
const t = topicsRepo.ensureTopic(key, { cwd: dir, name: name || '', repoKey: rk });
|
|
215
|
+
return { topicId: Number(t.id), key };
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** 组登记后建/取其组 topic(key=group:<组key>)。 */
|
|
219
|
+
export function ensureGroupQueue({ groupKey, name }: { groupKey: string; name?: string }): { topicId: number; key: string } {
|
|
220
|
+
const gk = String(groupKey || '').trim();
|
|
221
|
+
if (!gk) throw badInput('ensureGroupQueue: 需要组 key');
|
|
222
|
+
openStore();
|
|
223
|
+
const t = topicsRepo.ensureGroupTopic(gk, name || '');
|
|
224
|
+
return { topicId: Number(t.id), key: t.key };
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* 补齐老库缺的队列 topic(幂等):遍历已登记仓库/组,缺的补建。
|
|
229
|
+
* 返回值便于 CLI/日志核对;重复调用无副作用。
|
|
230
|
+
*
|
|
231
|
+
* 直接查 repos 表(同库,不经 repos service)——避免 localtask→repos 的运行时耦合:
|
|
232
|
+
* 这里只需要 key / path / name 三个字段,拿「旧 JSON store 快照」是杀鸡用牛刀。
|
|
233
|
+
*/
|
|
234
|
+
export async function syncQueues(): Promise<{ repos: number; groups: number }> {
|
|
235
|
+
openStore();
|
|
236
|
+
return tx((conn) => {
|
|
237
|
+
let r = 0;
|
|
238
|
+
let g = 0;
|
|
239
|
+
for (const repo of conn.all("SELECT key, path, name FROM repos WHERE type = 'repo' AND path <> '' AND deleted_at IS NULL")) {
|
|
240
|
+
const rk = String(repo.key || '');
|
|
241
|
+
const cwd = String(repo.path || '');
|
|
242
|
+
if (!rk || !cwd) continue;
|
|
243
|
+
const before = conn.get('SELECT id FROM topics WHERE key = :k', { k: topicKeyOf(cwd, '') });
|
|
244
|
+
ensureRepoQueue({ repoKey: rk, cwd, name: String(repo.name || '') });
|
|
245
|
+
if (!before) r += 1;
|
|
246
|
+
}
|
|
247
|
+
for (const b of conn.all("SELECT key, name FROM repos WHERE type = 'group' AND deleted_at IS NULL")) {
|
|
248
|
+
const gk = String(b.key || '');
|
|
249
|
+
if (!gk) continue;
|
|
250
|
+
const before = conn.get('SELECT id FROM topics WHERE key = :k', { k: `group:${gk}` });
|
|
251
|
+
ensureGroupQueue({ groupKey: gk, name: String(b.name || '') });
|
|
252
|
+
if (!before) g += 1;
|
|
253
|
+
}
|
|
254
|
+
return { repos: r, groups: g };
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* 编排(登记 / 加组成员 / 移除 / 删除)后的自动刷新:补齐队列,失败**不拦主操作**。
|
|
260
|
+
*
|
|
261
|
+
* 编排是用户正在做的事,队列只是配套资源——补建失败不该让「加成员」报错;
|
|
262
|
+
* 失败的缺口由「仓库管理」页的「刷新队列」按钮兜(同一份 syncQueues)。
|
|
263
|
+
*/
|
|
264
|
+
export async function syncQueuesQuiet(): Promise<{ repos: number; groups: number }> {
|
|
265
|
+
try {
|
|
266
|
+
return await syncQueues();
|
|
267
|
+
} catch {
|
|
268
|
+
return { repos: 0, groups: 0 };
|
|
269
|
+
}
|
|
270
|
+
}
|
|
@@ -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
|
}
|
|
@@ -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.assign 的入参契约(CLI 与 HTTP 共用同一份)。 */
|
|
@@ -29,7 +30,10 @@ export class BoardAssignAction extends ActionBase<typeof input> {
|
|
|
29
30
|
})
|
|
30
31
|
override async run(ctx: ActionInput<this['_input']>) {
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
const r: any = await boards.assignRepo(ctx);
|
|
34
|
+
// #199:成员编排(加/移出成员)后自动刷新队列(幂等只补不删;失败不拦编排)。
|
|
35
|
+
await orchestrateQuiet();
|
|
36
|
+
return r;
|
|
33
37
|
|
|
34
38
|
}
|
|
35
39
|
}
|
|
@@ -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.remove 的入参契约(CLI 与 HTTP 共用同一份)。 */
|
|
@@ -24,7 +25,10 @@ export class BoardRemoveAction extends ActionBase<typeof input> {
|
|
|
24
25
|
})
|
|
25
26
|
override async run(ctx: ActionInput<this['_input']>) {
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
const r: any = await boards.removeBoard(ctx.id);
|
|
29
|
+
// #199:删组后自动刷新队列(幂等只补不删;失败不拦编排)。
|
|
30
|
+
await orchestrateQuiet();
|
|
31
|
+
return r;
|
|
28
32
|
|
|
29
33
|
}
|
|
30
34
|
}
|
|
@@ -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 serviceNs from '../service.js';
|
|
8
|
+
import { orchestrateQuiet } from '../orchestrate.js';
|
|
8
9
|
const service: any = serviceNs;
|
|
9
10
|
|
|
10
11
|
/** repo.add 的入参契约(CLI 与 HTTP 共用同一份)。 */
|
|
@@ -32,11 +33,14 @@ export class RepoAddAction extends ActionBase<typeof input> {
|
|
|
32
33
|
})
|
|
33
34
|
override async run(ctx: ActionInput<this['_input']>) {
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
const r: any = await service.addRepo({
|
|
36
37
|
...ctx,
|
|
37
38
|
// 给了 --key 就视为自定义;否则用显式的 --key-custom(缺省 false = 跟随 remote)
|
|
38
39
|
keyCustom: ctx.key ? true : ctx['key-custom'] === true,
|
|
39
40
|
});
|
|
41
|
+
// #199:登记即编排——补齐队列 topic(幂等,只补不删);失败不拦登记。
|
|
42
|
+
await orchestrateQuiet();
|
|
43
|
+
return r;
|
|
40
44
|
|
|
41
45
|
}
|
|
42
46
|
}
|
|
@@ -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 serviceNs from '../service.js';
|
|
8
|
+
import { orchestrateQuiet } from '../orchestrate.js';
|
|
8
9
|
const service: any = serviceNs;
|
|
9
10
|
|
|
10
11
|
/** repo.update 的入参契约(CLI 与 HTTP 共用同一份)。 */
|
|
@@ -42,7 +43,10 @@ export class RepoUpdateAction extends ActionBase<typeof input> {
|
|
|
42
43
|
...(ctx['get-loop-minutes'] !== undefined ? { waitMinutes: ctx['get-loop-minutes'] } : {}),
|
|
43
44
|
};
|
|
44
45
|
}
|
|
45
|
-
|
|
46
|
+
const r: any = await service.updateRepo(ctx.id, patch);
|
|
47
|
+
// #199:改登记路径也算编排——自动刷新队列(幂等只补不删;失败不拦编辑)。
|
|
48
|
+
await orchestrateQuiet();
|
|
49
|
+
return r;
|
|
46
50
|
|
|
47
51
|
}
|
|
48
52
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// 看板的导入导出(board import/export)与按前缀归组(board prefix,一次性命令)。
|
|
2
|
+
import { normRepoPath } from '../../../core/db/repo-match.js';
|
|
2
3
|
import {
|
|
3
4
|
loadStore,
|
|
4
5
|
mutateStore,
|
|
@@ -43,7 +44,7 @@ export async function importBoards({ json }: { json?: unknown } = {}): Promise<I
|
|
|
43
44
|
return mutateStore((s) => {
|
|
44
45
|
const byName = new Map(s.repos.map((r): [string, string] => [String(r.name).trim(), deriveKey(r)]));
|
|
45
46
|
// path 匹配(大小写不敏感、分隔符归一)——老格式的导入文件按 path 引用
|
|
46
|
-
const byPath = new Map(s.repos.map((r): [string, string] => [
|
|
47
|
+
const byPath = new Map(s.repos.map((r): [string, string] => [normRepoPath(r.path), deriveKey(r)]));
|
|
47
48
|
let created = 0;
|
|
48
49
|
let merged = 0;
|
|
49
50
|
let matched = 0;
|
|
@@ -65,7 +66,7 @@ export async function importBoards({ json }: { json?: unknown } = {}): Promise<I
|
|
|
65
66
|
const k = e.key
|
|
66
67
|
? normalizeKey(e.key)
|
|
67
68
|
: (e.path
|
|
68
|
-
? byPath.get(
|
|
69
|
+
? byPath.get(normRepoPath(e.path))
|
|
69
70
|
: (e.name ? byName.get(String(e.name).trim()) : null));
|
|
70
71
|
if (!k) {
|
|
71
72
|
unmatched.push({ board: nm, entry: e.key || e.path || e.name || '(空)' });
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// 仓库/组的**编排后收口**(#199):编排动作(登记 / 改路径 / 建组 / 成员变更 / 删组)
|
|
2
|
+
// 执行成功后,补齐仓库与组各自的队列 topic。
|
|
3
|
+
//
|
|
4
|
+
// 为什么收在这一个文件:repos→localtask 是模块域间依赖,分层棘轮按文件数计数——
|
|
5
|
+
// 跨域通知只许从这一个文件过,新增编排动作必须复用 orchestrateQuiet(),
|
|
6
|
+
// 不许各自 `import('../localtask/service.js')`。
|
|
7
|
+
//
|
|
8
|
+
// 口径:队列是编排的**配套资源**,补建失败绝不拦主操作(syncQueuesQuiet 内部吞错)。
|
|
9
|
+
// 「仓库管理」页的「刷新队列」按钮是同一份逻辑的手动出口,兜历史数据缺口。
|
|
10
|
+
|
|
11
|
+
/** 编排完成后自动刷新队列(幂等只补不删;失败不拦主操作)。 */
|
|
12
|
+
export function orchestrateQuiet(): Promise<{ repos: number; groups: number }> {
|
|
13
|
+
return import('../localtask/service.js').then(
|
|
14
|
+
(lt: any) => lt.syncQueuesQuiet(),
|
|
15
|
+
() => ({ repos: 0, groups: 0 }),
|
|
16
|
+
);
|
|
17
|
+
}
|