nx-kv 0.56.2 → 0.57.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 +63 -0
- package/assets/nx-kv/references/A03-/346/226/207/346/241/243/344/270/216/345/275/222/345/261/236.md +4 -3
- package/assets/nx-kv/references/A04-/344/273/223/345/272/223/344/270/216/351/241/271/347/233/256/347/273/204.md +7 -2
- package/assets/nx-kv/references/B02-CLI/351/200/237/346/237/245.md +2 -2
- package/package.json +1 -1
- package/src/modules/docs/link-note.ts +171 -0
- package/src/modules/localtask/actions/_manifest.generated.ts +3 -0
- package/src/modules/localtask/actions/localtask-boardtasks.ts +156 -0
- package/src/modules/localtask/actions/localtask-tasks.ts +12 -2
- package/src/modules/repos/actions/repo-ref-note.ts +9 -5
- package/src/modules/repos/link-note.ts +111 -0
- package/src/modules/repos/ref.ts +40 -71
- package/src/web/frontend/api/cli-tree.json +17 -2
- package/src/web/frontend/api/client.generated.ts +15 -2
- package/src/web/frontend/page/repos/api.ts +0 -5
- package/src/web/frontend/page/repos/bind-modals.tsx +6 -55
- package/src/web/frontend/page/repos/board-refs.tsx +8 -18
- package/src/web/frontend/page/repos/index.tsx +2 -20
- package/src/web/frontend/page/repos/ref-panel.tsx +4 -8
- package/src/web/frontend/refs/api.ts +0 -5
- package/src/web/frontend/styles/modals.css +0 -30
- package/src/web/public/assets/{composer-panel-CzUeT8Wm.js → composer-panel-qX7uVyLW.js} +1 -1
- package/src/web/public/assets/{dir-T3tJ6mj6.js → dir-B360Miyq.js} +1 -1
- package/src/web/public/assets/{group-D5sEX31u.js → group-CCcRCEjR.js} +1 -1
- package/src/web/public/assets/{index-ChaDvo2D.js → index-BLrw-ZQc.js} +2 -2
- package/src/web/public/assets/index-BPxgsnXM.css +1 -0
- package/src/web/public/assets/repo-form-modal-pyqiC7pB.js +1 -0
- package/src/web/public/assets/repos-CeyrjSQ_.js +11 -0
- package/src/web/public/assets/{settings-bvwdOF-n.js → settings-DhX_fRMm.js} +1 -1
- package/src/web/public/assets/{task-D7taZbrH.js → task-XXG4USTn.js} +1 -1
- package/src/web/public/assets/{templates-CRHBAwpm.js → templates-C9a5CUFd.js} +1 -1
- package/src/web/public/index.html +3 -3
- package/src/web/public/assets/index-CLGiMYZc.css +0 -1
- package/src/web/public/assets/repo-form-modal-DxEqerLy.js +0 -1
- package/src/web/public/assets/repos-CKbhG3cI.js +0 -14
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,69 @@
|
|
|
2
2
|
|
|
3
3
|
本文件记录对外可见的变更。格式参考 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/)。
|
|
4
4
|
|
|
5
|
+
## [0.57.1] - 2026-11-15 dev skill 重排:A 序列 = 标准 SOP,B 序列 = 相关知识(#135)
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- **dev-nxkv 的两个序列按新口径重排**(此前是 R 需求原型 + P 原语):
|
|
10
|
+
- **A 序列 = 标准 SOP**(照着做):`A01-加一种附件类型` / `A02-领取任务与扩展上下文`(新写)/
|
|
11
|
+
`A03-加或改命令与业务规则` / `A04-改面板交互` / `A05-加面板页面` / `A06-改提示词交付` /
|
|
12
|
+
`A07-发版` / `A08-排障与定位` / `A09-查库与改数据` / `A10-改编排闸门` / `A11-校准skill`;
|
|
13
|
+
- **B 序列 = 相关知识与特殊规则**(可查的表 + grep 关键字,不贴无意义的代码量):
|
|
14
|
+
`B01-概念与寻址`(新写)/ `B02-命令与接口契约` / `B03-提示词模板与上下文`(新写)/
|
|
15
|
+
`B04-存储与迁移` / `B05-前端面板地图` / `B06-测试与夹具`(新写)/ `B07-契约与生成` /
|
|
16
|
+
`B08-交付门禁与红线`;
|
|
17
|
+
- SKILL.md 改为「A 序列照着做,B 序列查知识」的路由,frontmatter 触发词同步。
|
|
18
|
+
- **A02 是新写的核心 SOP**:领一条并读懂交付(`get` 的关键指令:`--timeout` 是**秒**、
|
|
19
|
+
`--param` 进 ctx、默认输出即交付原文),以及**如何规范扩展一条任务的上下文知识**:
|
|
20
|
+
先判定「事实 → 文档 / 规则 → 区块 / 运行时状态 → 插件 / 一次性要求 → 任务正文」,
|
|
21
|
+
再按落点走 B1(写文档)/ B2(加区块:ctx 字段 + 模板 + 变量表两处同步)/ B3(插件)。
|
|
22
|
+
- **A02 内含一次项目现状体检**(写它之前查的):交付 ctx 的装配分散在 4 处
|
|
23
|
+
(`wait.ts` / `delivery-template.ts` / `attach-template.ts` / `plugins/`)、变量知识化两处手写
|
|
24
|
+
(模板 `vars_schema` + 前端 `BLOCK_PARAMS`)、区块定义与 ctx 装配分离、模板变量写错**静默渲染成空**。
|
|
25
|
+
据此定了四条可优化项与「新的上下文代码集中在 `src/modules/tasktool/` 下的 context 目录」这条约定。
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
|
|
29
|
+
- **skill 门禁按新口径收紧**(`scripts/check-skill-sop.mjs`):文件名约定改 `<A|B><两位序号>-<动作>.md`;
|
|
30
|
+
**A 序列**必须四段骨架(前置 / 动作 / 自检 / 失败分支)+ 至少一条可执行命令;
|
|
31
|
+
**B 序列**必须至少一张表 + 至少一条 grep / 命令线索(否则判「这不是知识,是散文」)。
|
|
32
|
+
门禁输出:19 条骨架完整、68 处路径存在、23 条命令可解析。
|
|
33
|
+
|
|
34
|
+
## [0.57.0] - 2026-11-15 绑定描述完全归档到文档列表;面板去掉描述弹窗与「写描述」按钮(#134)
|
|
35
|
+
|
|
36
|
+
### Changed
|
|
37
|
+
|
|
38
|
+
- **绑定描述(组 ↔ 参考仓库 / 开发仓库 ↔ 参考仓库)= 参考仓库上的一篇文档**:
|
|
39
|
+
- 描述**完全归档**到右侧栏的「<参考仓库名> · 文档列表」,定位靠
|
|
40
|
+
`ref_bindings.tag = link-note:<关系 key>`——同一组 / 同一仓库重复写 = 改同一篇,
|
|
41
|
+
不新增;`--note ""` = 清除(删掉那篇文档);
|
|
42
|
+
- `repo ref note` 的返回多出 `refId` / `docId`,CLI 会告诉你「文档在它的文档列表里」;
|
|
43
|
+
- 面板上**没有**「组级绑定描述」弹窗,也没有「写描述」按钮:组页参考仓库行与
|
|
44
|
+
参考仓库面板里的描述入口整块删除,写描述就在文档列表里写;
|
|
45
|
+
- 关系边上留一份**冗余副本**(导出/导入要带走描述,备份不能丢),真身是文档;
|
|
46
|
+
只读展示(面板 chip、交付上下文的 `group.refRepos[].note`)取自文档。
|
|
47
|
+
- **前端清理**:删掉 `LinkNoteModal` 组件与两个入口、`page/repos/api.ts` 的 `refNote`
|
|
48
|
+
与 `refs/api.ts` 的 `setRefNote` 包装、失效的 `.rp-ref-note-chip` /
|
|
49
|
+
`.rp-link-chip-note-btn` 样式。
|
|
50
|
+
- **模块拆分**:`repos/ref.ts`(绑定描述的校验 + 落库)独立到 `repos/link-note.ts`
|
|
51
|
+
(docs 域的落点实现独立到 `docs/link-note.ts`);`repos/ref.ts` 649 行,
|
|
52
|
+
仍在行数门禁之下。
|
|
53
|
+
|
|
54
|
+
### Added
|
|
55
|
+
|
|
56
|
+
- 单测 `tests/unit/link-note-doc.test.mjs`:写描述 → 参考仓库文档列表多一篇(tag 定位、
|
|
57
|
+
desc 写明是哪条关系)/重复写改同一篇/留空清除/组级与仓库级各一篇/未绑定显式报错。
|
|
58
|
+
|
|
59
|
+
### 验证
|
|
60
|
+
|
|
61
|
+
- 全量单测与 lint / typecheck / build / 冒烟全过;`check-skill-sop` 与
|
|
62
|
+
`skill-cli-accurate` 全绿(内置 skill 的 A03 / A04 / B02 已同步新口径)。
|
|
63
|
+
- 实机(隔离库):`repo ref note --id <参考仓库key> --board <组id> --note "…"` →
|
|
64
|
+
`docs bindings --host <参考仓库key>` 立刻能看到那篇(`hostKind=ref`、
|
|
65
|
+
`tag=link-note:board/<组>`、desc=「在组「<组名>」里参考什么」);再写一次同一篇;
|
|
66
|
+
留空清除后条目消失。
|
|
67
|
+
|
|
5
68
|
## [0.56.2] - 2026-11-15 dev skill 按需求原型重排(R 需求 10 条 + P 原语 5 条)
|
|
6
69
|
|
|
7
70
|
### Changed
|
package/assets/nx-kv/references/A03-/346/226/207/346/241/243/344/270/216/345/275/222/345/261/236.md
CHANGED
|
@@ -105,8 +105,9 @@ nx-kv docs bindings --group <组key> --json
|
|
|
105
105
|
要看整个组域(含组内参考仓库)用 `--group`。
|
|
106
106
|
3. **组视图里参考仓库排在最后**(组 → 组内仓库 → 成员仓库自己 → 组内参考仓库自己),
|
|
107
107
|
徽标 `hostKind` = `dev` / `ref` / `group`——按它分清每篇挂在谁身上。
|
|
108
|
-
4.
|
|
109
|
-
|
|
108
|
+
4. **「组级描述」现在是文档**(#134):`repo ref note` 写的说明**完全归档**到该参考仓库
|
|
109
|
+
自己的文档列表(定位靠 `link-note:<关系 key>`),面板上不再有弹窗与「写描述」按钮;
|
|
110
|
+
关系边上只留一份供导出/导入带走的副本,真身是文档。
|
|
110
111
|
|
|
111
112
|
## 五、摘 / 删:三个动作别搞混
|
|
112
113
|
|
|
@@ -156,7 +157,7 @@ nx-kv docs detach --ref ref:<refId> --attachment <id> --json # 摘掉一个
|
|
|
156
157
|
| 把组内仓库的那篇挂成「组附加篇」 | 组内仓库篇用 `docs note-bind --board --repo`;附加篇是 `docs link` |
|
|
157
158
|
| 以为参考仓库不能挂文档 | 参考仓库与开发仓库只有 kind 差异,`docs ref add --owner repo --repo <refKey>` 一样能用 |
|
|
158
159
|
| 以为参考仓库只能被读、不能建文档列表 | 参考仓库是**文档列表的一等主题**:右侧栏能开「<名字> · 文档列表」,也能新建 |
|
|
159
|
-
|
|
|
160
|
+
| 在参考仓库行找「组级描述」却找不到入口 | 它已经是**文档**:点参考仓库的「文档列表」→ 在列表里新建/编辑;`repo ref note` 写的是同一篇 |
|
|
160
161
|
| 用 `docs list` 找某个参考仓库的文档 | `docs list` 是**自有文档全量**;要看某宿主的文档列表用 `docs bindings --host <key>` |
|
|
161
162
|
| 在组视图里找不到参考仓库的文档 | 参考仓库自己的文档排在**组域列表最后**(组 → 组内仓库 → 成员仓库自己 → 组内参考仓库自己) |
|
|
162
163
|
| 看不出某篇挂在开发仓库还是参考仓库 | 看 `hostKind`(`dev` / `ref` / `group`);面板上徽标分别是「仓库 · xxx」「参考 · xxx」「组 · xxx」 |
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
2. **克隆或登记**:`repo clone --remote …`(开发仓库)/ `repo ref clone --url …`(参考仓库)/ `repo ref add --path …`(已有 checkout)。
|
|
22
22
|
3. **对齐身份**:key 默认跟随 remote 归一化;要固化就 `--key`(或 `repo key set --follow` 恢复跟随)。
|
|
23
23
|
4. **挂进关系**:`board assign`(仓库↔组)/ `repo bind`(参考仓库↔组或仓库)。
|
|
24
|
-
5. **写清角色**:`board note`(组内角色)/ `repo ref note
|
|
24
|
+
5. **写清角色**:`board note`(组内角色)/ `repo ref note`(参考它的什么——写成该参考仓库的一篇文档)。
|
|
25
25
|
|
|
26
26
|
## 三、把远程仓库 git 到指定位置(细账)
|
|
27
27
|
|
|
@@ -91,6 +91,11 @@ nx-kv board note --id <仓库key> --board <组id> --note "<角色与配合关系
|
|
|
91
91
|
nx-kv repo ref note --id <参考仓库key> --board <组id> --note "<参考它的哪一块实现>" --json
|
|
92
92
|
```
|
|
93
93
|
|
|
94
|
+
**④ 的落点是「一篇文档」**(#134):这条说明**完全归档**到这个参考仓库自己的文档列表
|
|
95
|
+
(右侧栏「<参考仓库名> · 文档列表」里可见可编辑),定位靠 `link-note:<关系 key>`——
|
|
96
|
+
同一组 / 同一仓库重复写 = 改同一篇,不新增;`--note ""` = 清除(删掉那篇)。
|
|
97
|
+
面板上**没有**「写描述」按钮,也没有专属弹窗:写描述就在文档列表里写。
|
|
98
|
+
|
|
94
99
|
**批量与修复**:
|
|
95
100
|
|
|
96
101
|
```bash
|
|
@@ -159,7 +164,7 @@ nx-kv repo update --id <仓库key> --get-loop off --json
|
|
|
159
164
|
| 目录已存在还去 clone | 会报错让你改用 `repo ref add --path` 登记(不覆盖) |
|
|
160
165
|
| 改 key 当改名 | key 是身份不是名字:改名用 `repo update --id --name`;改 key 会连锁影响关系表 |
|
|
161
166
|
| 组内成员顺序乱了 | `board assign --before` 插位;顺序影响组视图里的呈现 |
|
|
162
|
-
| 参考仓库绑了但没人知道参考什么 | `repo ref note --id --board --note "…"
|
|
167
|
+
| 参考仓库绑了但没人知道参考什么 | `repo ref note --id --board --note "…"`(落成该参考仓库的一篇文档,在文档列表里看/改) |
|
|
163
168
|
| `board prune` / `bind-topics` 直接落盘 | 它们默认**预览**,确认清单后再 `--apply` |
|
|
164
169
|
| 每次都手动 `git pull` 参考仓库 | `repo ref sync --all`(ff-only,脏工作区不动) |
|
|
165
170
|
| 用 `repo update --desc` 改项目介绍 | 描述已改为文档,介绍走 [[A03-文档与归属]] 的绑定 |
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
| `repo clone` | `--remote` `--key` `--name` `--depth` | clone 并登记(普通仓库) |
|
|
87
87
|
| `repo ref add` / `repo ref clone` | `--path` / `--url` `--name` `--desc` `--board` `--bind` `--no-bind` `--depth` | 登记 / 克隆参考仓库(`--board` 顺手挂组,`--bind` 绑开发仓库) |
|
|
88
88
|
| `repo ref sync` / `check` / `of` | `--id` `--all` / — / `--id` | 更新 / 完整性检查 / 这个仓库的参考 |
|
|
89
|
-
| `repo ref note` | `--id` \| `--repo` \| `--board` `--note "…"` | 写参考绑定说明(`repo bind` 本身不收 note
|
|
89
|
+
| `repo ref note` | `--id` \| `--repo` \| `--board` `--note "…"` | 写参考绑定说明(`repo bind` 本身不收 note)。#134:说明落成该**参考仓库的一篇文档**(右侧栏「<名字> · 文档列表」可见可编辑),同一关系重复写 = 改同一篇,`--note ""` = 清除 |
|
|
90
90
|
| `repo bind` | `--id <ref>` `--repo` \| `--board` `--remove` | 绑参考到仓库/组(`--remove` 解绑) |
|
|
91
91
|
| `repo bind-topics` | `--repo` `--apply` | 按主题回填绑定(维护用) |
|
|
92
92
|
| `repo doc add` / `list` / `remove` | `--id` `--ref` \| `--path` `--note` `--tag` / `--index` | 仓库文档集(主篇 + 附加) |
|
|
@@ -142,7 +142,7 @@ nx-kv health # 服务与版本(纯本机)
|
|
|
142
142
|
4. `add --cwd` 是**接收方**目录;`--global` 会忽略它。
|
|
143
143
|
5. 追加附件会改写正文,连续操作一律用 `--id` 定位。
|
|
144
144
|
6. `docs` 的 ref 没有路径;读文件只有附件。
|
|
145
|
-
7. `repo bind` 不收 `--note`,写说明要用 `repo ref note
|
|
145
|
+
7. `repo bind` 不收 `--note`,写说明要用 `repo ref note`(落成该参考仓库的一篇文档)。
|
|
146
146
|
8. 克隆参考仓库前先设 `gitRepoRoot`(不设直接报错,不会落进 homedir)。
|
|
147
147
|
9. `docs remove` 会顺手清掉宿主 ext 里指向它的悬空引用——别手改库。
|
|
148
148
|
10. 读交付内容别用 `--json`(instruction 会被转义成一行):默认输出即逐字原文。
|
package/package.json
CHANGED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
// 关系描述(组 ↔ 参考仓库 / 开发仓库 ↔ 参考仓库)= **参考仓库上的一篇文档**。
|
|
2
|
+
//
|
|
3
|
+
// #134:描述不再挂在「关系」上(group_refs.note / ext_linked[].note),
|
|
4
|
+
// 也不再用弹窗编辑——它**完全归档**到右侧栏的文档列表:
|
|
5
|
+
// 这条关系对应这个参考仓库的一篇文档,定位靠 ref_bindings.tag
|
|
6
|
+
// (`link-note:<关系 key>`),所以同一关系恒定对应同一篇,重复写只是改内容。
|
|
7
|
+
//
|
|
8
|
+
// 为什么不用 note 列:note 是关系边上的一个字符串,改它只能靠「关系专属弹窗」,
|
|
9
|
+
// 于是同一条知识被拆成两处(文档库 ↔ 关系列),面板上还要多一个入口。
|
|
10
|
+
// 归档成文档后:只有文档库一个真相,编辑走现成的文档编辑器,
|
|
11
|
+
// 参考仓库的「文档列表」就是它的档案柜。
|
|
12
|
+
import { randomUUID } from 'node:crypto';
|
|
13
|
+
import { getDb } from '../../core/db/index.js';
|
|
14
|
+
import { tx } from '../../core/db/tx.js';
|
|
15
|
+
import { upsertRefBody } from '../../core/attachmentdb.js';
|
|
16
|
+
import { refIdFor } from '../../core/attachmentdb/ids.js';
|
|
17
|
+
import { notFound } from '../../core/errors.js';
|
|
18
|
+
import * as store from './store.js';
|
|
19
|
+
import { reposBridge } from './repos-bridge.js';
|
|
20
|
+
import { syncRefIndex } from './ref-sync.js';
|
|
21
|
+
|
|
22
|
+
/** 关系描述的作用域:组级(组内共享)或仓库级(绑在某个开发仓库上)。 */
|
|
23
|
+
export interface LinkNoteScope {
|
|
24
|
+
kind: 'board' | 'repo';
|
|
25
|
+
/** 组 key 或开发仓库 key(关系标识) */
|
|
26
|
+
key: string;
|
|
27
|
+
/** 组名 / 仓库名(写进文档短标签) */
|
|
28
|
+
name: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** 定位标签前缀(ref_bindings.tag)。 */
|
|
32
|
+
export const LINK_NOTE_TAG_PREFIX = 'link-note:';
|
|
33
|
+
|
|
34
|
+
/** 关系 → 定位标签。 */
|
|
35
|
+
export function linkNoteTagOf(scope: LinkNoteScope): string {
|
|
36
|
+
return LINK_NOTE_TAG_PREFIX + String(scope.key || '');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** 关系 → 文档短标签(列表里一眼看出「这是哪条关系的描述」)。 */
|
|
40
|
+
export function linkNoteDescOf(scope: LinkNoteScope): string {
|
|
41
|
+
return scope.kind === 'board'
|
|
42
|
+
? `在组「${scope.name}」里参考什么`
|
|
43
|
+
: `在仓库「${scope.name}」里参考什么`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** 按关系标签找这篇文档(没有 → 空串)。 */
|
|
47
|
+
export function findLinkNoteDoc(refKey: string, scope: LinkNoteScope): string {
|
|
48
|
+
const row = getDb().get(
|
|
49
|
+
`SELECT b.ref_id AS refId FROM ref_bindings b
|
|
50
|
+
WHERE b.type = 'repo' AND b.repo_key = :refKey AND b.tag = :tag`,
|
|
51
|
+
{ refKey: String(refKey || ''), tag: linkNoteTagOf(scope) },
|
|
52
|
+
);
|
|
53
|
+
return row ? String(row.refId || '') : '';
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** 这篇描述文档的正文(没有 → 空串)。 */
|
|
57
|
+
export async function linkNoteBodyOf(refKey: string, scope: LinkNoteScope): Promise<string> {
|
|
58
|
+
const refId = findLinkNoteDoc(refKey, scope);
|
|
59
|
+
if (!refId) return '';
|
|
60
|
+
try {
|
|
61
|
+
return await store.readOwnDoc(refId);
|
|
62
|
+
} catch {
|
|
63
|
+
return '';
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* 这条关系下**所有**参考仓库的描述正文(refKey → 正文)。
|
|
69
|
+
*
|
|
70
|
+
* 面板与交付上下文要显示「这个参考在本组里参考什么」时用它——描述已经不在
|
|
71
|
+
* 关系边上了(在文档里),但只读展示仍要有出处。
|
|
72
|
+
*/
|
|
73
|
+
export async function linkNoteBodiesOf(scope: LinkNoteScope): Promise<Map<string, string>> {
|
|
74
|
+
const out = new Map<string, string>();
|
|
75
|
+
const rows = getDb().all(
|
|
76
|
+
`SELECT repo_key AS repoKey, ref_id AS refId FROM ref_bindings
|
|
77
|
+
WHERE type = 'repo' AND tag = :tag`,
|
|
78
|
+
{ tag: linkNoteTagOf(scope) },
|
|
79
|
+
);
|
|
80
|
+
for (const r of rows) {
|
|
81
|
+
try {
|
|
82
|
+
out.set(String(r.repoKey || ''), await store.readOwnDoc(String(r.refId || '')));
|
|
83
|
+
} catch {
|
|
84
|
+
/* 正文缺失(已删)→ 跳过 */
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return out;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** 从宿主 ext 的文档集里摘掉这篇(再由 syncRefIndex 重算绑定索引)。 */
|
|
91
|
+
async function detachFromHost(refKey: string, refId: string): Promise<void> {
|
|
92
|
+
const { mutateStore, deriveKey } = await reposBridge();
|
|
93
|
+
await mutateStore((s: any) => {
|
|
94
|
+
const r = (s.repos || []).find((x: any) => deriveKey(x) === String(refKey || ''));
|
|
95
|
+
if (!r) return;
|
|
96
|
+
if (Array.isArray(r.docLinks)) {
|
|
97
|
+
r.docLinks = r.docLinks.filter((l: any) => !(l && l.ref === refId));
|
|
98
|
+
}
|
|
99
|
+
if (r.doc && r.doc.ref === refId) delete r.doc;
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** 删掉这篇描述文档(连宿主绑定与正文一起清)。 */
|
|
104
|
+
export async function removeLinkNoteDoc(refKey: string, scope: LinkNoteScope): Promise<boolean> {
|
|
105
|
+
const refId = findLinkNoteDoc(refKey, scope);
|
|
106
|
+
if (!refId) return false;
|
|
107
|
+
await detachFromHost(refKey, refId);
|
|
108
|
+
try {
|
|
109
|
+
await store.removeOwnDoc(refId);
|
|
110
|
+
} catch {
|
|
111
|
+
/* 已被删(幂等) */
|
|
112
|
+
}
|
|
113
|
+
await syncRefIndex();
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* 写关系描述:建一篇文档挂到这个参考仓库上,或改已有那篇。
|
|
119
|
+
*
|
|
120
|
+
* 文本留空 = 清除(删掉这篇文档)。
|
|
121
|
+
*/
|
|
122
|
+
export async function setLinkNoteDoc({ refKey, scope, text }: {
|
|
123
|
+
refKey: string;
|
|
124
|
+
scope: LinkNoteScope;
|
|
125
|
+
text?: unknown;
|
|
126
|
+
}): Promise<{ refId: string; desc: string; body: string; created: boolean; removed: boolean }> {
|
|
127
|
+
const key = String(refKey || '').trim();
|
|
128
|
+
if (!key) throw notFound('参考仓库 key 为空');
|
|
129
|
+
const body = String(text ?? '').trim();
|
|
130
|
+
const desc = linkNoteDescOf(scope);
|
|
131
|
+
const tag = linkNoteTagOf(scope);
|
|
132
|
+
|
|
133
|
+
const existing = findLinkNoteDoc(key, scope);
|
|
134
|
+
if (existing) {
|
|
135
|
+
if (!body) {
|
|
136
|
+
const removed = await removeLinkNoteDoc(key, scope);
|
|
137
|
+
return { refId: '', desc, body: '', created: false, removed };
|
|
138
|
+
}
|
|
139
|
+
await store.writeOwnDoc(existing, body);
|
|
140
|
+
await store.setOwnDocDesc(existing, desc);
|
|
141
|
+
return { refId: existing, desc, body, created: false, removed: false };
|
|
142
|
+
}
|
|
143
|
+
if (!body) return { refId: '', desc, body: '', created: false, removed: false };
|
|
144
|
+
|
|
145
|
+
// 新建:refs 行 + 正文(ref_bodies 是正文唯一真相)→ 挂到宿主文档集(附加篇,带 tag)
|
|
146
|
+
const refId = refIdFor(randomUUID());
|
|
147
|
+
const at = Date.now();
|
|
148
|
+
const db = getDb();
|
|
149
|
+
tx(
|
|
150
|
+
(conn: any) => {
|
|
151
|
+
conn.run(
|
|
152
|
+
`INSERT INTO refs (id, type, locator, state, version, deleted_at, created_at, updated_at, origin, body_bytes, "desc")
|
|
153
|
+
VALUES (:id, 'md', '', '', 0, NULL, :at, :at, 'own', 0, :desc)`,
|
|
154
|
+
{ id: refId, at, desc },
|
|
155
|
+
);
|
|
156
|
+
upsertRefBody(conn, { refId, body, atMs: at });
|
|
157
|
+
},
|
|
158
|
+
{ db, mode: 'IMMEDIATE' },
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
const { mutateStore, deriveKey } = await reposBridge();
|
|
162
|
+
await mutateStore((s: any) => {
|
|
163
|
+
const r = (s.repos || []).find((x: any) => deriveKey(x) === key);
|
|
164
|
+
if (!r) throw notFound('参考仓库不存在: ' + key);
|
|
165
|
+
if (!Array.isArray(r.docLinks)) r.docLinks = [];
|
|
166
|
+
// 附加篇(不是主篇):主篇是「项目介绍」,关系描述不抢那个位置
|
|
167
|
+
r.docLinks.push({ ref: refId, tag, note: '' });
|
|
168
|
+
});
|
|
169
|
+
await syncRefIndex();
|
|
170
|
+
return { refId, desc, body, created: true, removed: false };
|
|
171
|
+
}
|
|
@@ -10,6 +10,7 @@ import { LocaltaskAddAction } from './localtask-add.js';
|
|
|
10
10
|
import { LocaltaskAttachNoteAction } from './localtask-attach-note.js';
|
|
11
11
|
import { LocaltaskAttachAction } from './localtask-attach.js';
|
|
12
12
|
import { LocaltaskAttachmentsAction } from './localtask-attachments.js';
|
|
13
|
+
import { LocaltaskBoardTasksAction } from './localtask-boardtasks.js';
|
|
13
14
|
import { LocaltaskCancelAction } from './localtask-cancel.js';
|
|
14
15
|
import { LocaltaskCancelManyAction } from './localtask-cancelMany.js';
|
|
15
16
|
import { LocaltaskChainAction } from './localtask-chain.js';
|
|
@@ -46,6 +47,7 @@ export const ACTIONS: readonly (new (deps: Container) => ActionBase)[] = [
|
|
|
46
47
|
LocaltaskAttachNoteAction,
|
|
47
48
|
LocaltaskAttachAction,
|
|
48
49
|
LocaltaskAttachmentsAction,
|
|
50
|
+
LocaltaskBoardTasksAction,
|
|
49
51
|
LocaltaskCancelAction,
|
|
50
52
|
LocaltaskCancelManyAction,
|
|
51
53
|
LocaltaskChainAction,
|
|
@@ -82,6 +84,7 @@ export { LocaltaskAddAction };
|
|
|
82
84
|
export { LocaltaskAttachNoteAction };
|
|
83
85
|
export { LocaltaskAttachAction };
|
|
84
86
|
export { LocaltaskAttachmentsAction };
|
|
87
|
+
export { LocaltaskBoardTasksAction };
|
|
85
88
|
export { LocaltaskCancelAction };
|
|
86
89
|
export { LocaltaskCancelManyAction };
|
|
87
90
|
export { LocaltaskChainAction };
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// localtask.boardtasks —— 全部项目组的「本组任务」,一次拿全。
|
|
2
|
+
//
|
|
3
|
+
// 为什么需要这条(而不是让端侧自己拼):
|
|
4
|
+
//
|
|
5
|
+
// 组任务**物理上落在成员项目的队列里**(agent 按目录领活,队列归属不变),
|
|
6
|
+
// 归属只由正文 frontmatter 的 `board` 说明 —— 就是面板里的「两种走向」
|
|
7
|
+
// (board-view.ts 的 taskInBoard / projectPending)。面板自己有全量主题快照,
|
|
8
|
+
// 拼一下就有了;端侧(fr 手机界面)没有:
|
|
9
|
+
//
|
|
10
|
+
// · 逐个成员队列去问 → 28 个队列 28 次请求,每次服务端还要把整份 store 读一遍;
|
|
11
|
+
// · 去拉 /api/localtasks → 每个任务都带正文,一次几 MB(端侧只画 30 字标题)。
|
|
12
|
+
//
|
|
13
|
+
// 服务端本来就在同一个进程里同时握着「看板成员表」与「全部任务」,聚合放在这里
|
|
14
|
+
// 是一行的事,端侧一次请求拿到侧栏徽标 + 组页列表。
|
|
15
|
+
//
|
|
16
|
+
// 判据与面板逐字一致:`boardMark ∈ {看板 id, key, 名称}`,软删除 / 迁移 tombstone
|
|
17
|
+
// 不算;成员关系按仓库 key 对(与 `board.repos[].key` 同一键空间)。
|
|
18
|
+
// 项目标签取任务所在队列的仓库名(未登记目录取队列名),组页据此画项目 tag。
|
|
19
|
+
import { action } from '../../../runtime/action-decorator.js';
|
|
20
|
+
import { z } from 'zod';
|
|
21
|
+
import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
|
|
22
|
+
import * as serviceNs from '../service.js';
|
|
23
|
+
import * as boardsNs from '../../repos/boards.js';
|
|
24
|
+
|
|
25
|
+
const service: any = serviceNs;
|
|
26
|
+
const boardsSvc: any = boardsNs;
|
|
27
|
+
|
|
28
|
+
/** localtask.boardtasks 的入参契约:不给 board = 全部组。 */
|
|
29
|
+
const input = z.object({
|
|
30
|
+
board: z.string().optional().describe('只看一个组(id / key / 名称);不给 = 全部组'),
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
/** 组任务的一行:够画列表 + 点进详情,另带**归属项目**(组页的项目 tag)。 */
|
|
34
|
+
const taskRow = z.object({
|
|
35
|
+
id: z.int().describe('任务编号'),
|
|
36
|
+
status: z.string().describe('pending / claimed / done / cancelled'),
|
|
37
|
+
title: z.string().describe('正文首个标题行(没有标题就取首行,已截断)'),
|
|
38
|
+
round: z.int().describe('第几轮'),
|
|
39
|
+
ready: z.boolean().describe('当前是否可领取'),
|
|
40
|
+
project: z.string().describe('归属项目(任务所在队列的仓库名;未登记目录取队列名)'),
|
|
41
|
+
topicKey: z.string().describe('物理落点:任务所在队列的主题键(领取按它定位)'),
|
|
42
|
+
createdAt: z.string(),
|
|
43
|
+
consumedAt: z.string().describe('被领取的时间;未领取为空串'),
|
|
44
|
+
completedAt: z.string(),
|
|
45
|
+
claimedByName: z.string(),
|
|
46
|
+
roundSummary: z.string().describe('本轮完成总结;未完成时为空串'),
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const output = z.object({
|
|
50
|
+
boards: z.array(
|
|
51
|
+
z.object({
|
|
52
|
+
id: z.string().describe('看板 id(面板创建任务时写进 frontmatter 的就是它)'),
|
|
53
|
+
key: z.string().describe('看板键(board/xxx)'),
|
|
54
|
+
name: z.string().describe('看板名称'),
|
|
55
|
+
pending: z.int().describe('本组待领取数(= side bar 徽标口径)'),
|
|
56
|
+
total: z.int().describe('本组任务总数'),
|
|
57
|
+
tasks: z.array(taskRow),
|
|
58
|
+
})
|
|
59
|
+
),
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
/** 取正文里的标题:跳过 frontmatter,首个 `#` 标题优先,否则首行;按 80 字截断。 */
|
|
63
|
+
function titleOf(text: unknown): string {
|
|
64
|
+
const raw = String(text ?? '');
|
|
65
|
+
let body = raw;
|
|
66
|
+
if (raw.startsWith('---')) {
|
|
67
|
+
const end = raw.indexOf('\n---', 3);
|
|
68
|
+
if (end > 0) body = raw.slice(end + 4);
|
|
69
|
+
}
|
|
70
|
+
const lines = body.split('\n').map((l) => l.trim()).filter(Boolean);
|
|
71
|
+
const heading = lines.find((l) => /^#{1,6}\s+/.test(l));
|
|
72
|
+
const line = (heading ?? lines[0] ?? '').replace(/^#{1,6}\s+/, '');
|
|
73
|
+
return line.length > 80 ? line.slice(0, 80) + '…' : line;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export class LocaltaskBoardTasksAction extends ActionBase<typeof input> {
|
|
77
|
+
@action({
|
|
78
|
+
id: 'localtask.boardtasks',
|
|
79
|
+
cli: ['localtask', 'boardtasks'],
|
|
80
|
+
http: ['GET', '/api/localtasks/boardtasks'],
|
|
81
|
+
summary: '全部项目组的本组任务(端侧组页 / 侧栏徽标一次拿全):按 frontmatter 的 board 归属聚合,带归属项目',
|
|
82
|
+
input,
|
|
83
|
+
output,
|
|
84
|
+
render: (d: any) => {
|
|
85
|
+
const lines: string[] = [];
|
|
86
|
+
for (const b of d.boards) {
|
|
87
|
+
lines.push(`${b.name}(${b.key})· ${b.pending} 待领 / ${b.total} 条`);
|
|
88
|
+
for (const t of b.tasks) {
|
|
89
|
+
lines.push(` #${t.id} [${t.status}] 第${t.round}轮 ${t.project} · ${t.title}`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return lines.join('\n') || '(没有组任务)';
|
|
93
|
+
},
|
|
94
|
+
})
|
|
95
|
+
override async run(ctx: ActionInput<this['_input']>) {
|
|
96
|
+
const want = String(ctx.board ?? '').trim();
|
|
97
|
+
const boardList: any[] = ((await boardsSvc.listBoards())?.boards ?? []) as any[];
|
|
98
|
+
// 定位 & 归一:id / key / 名称都认(面板写 id,手写 frontmatter 可能是 key/名)
|
|
99
|
+
const picked = want
|
|
100
|
+
? boardList.filter((b) => [b.id, b.key, b.name].filter(Boolean).map(String).includes(want))
|
|
101
|
+
: boardList;
|
|
102
|
+
if (want && picked.length === 0) {
|
|
103
|
+
const { badInput } = await (import('../../../core/errors.js') as any);
|
|
104
|
+
throw badInput(`项目组不存在: ${want}`);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const list: any = await service.listTasks();
|
|
108
|
+
const topics: any[] = (list.topics ?? []) as any[];
|
|
109
|
+
|
|
110
|
+
const boards = picked.map((b) => {
|
|
111
|
+
const ids = [b.id, b.key, b.name].filter(Boolean).map(String);
|
|
112
|
+
const memberKeys = new Set<string>(
|
|
113
|
+
((b.repos ?? []) as any[]).map((m) => (m && m.key ? String(m.key) : '')).filter(Boolean)
|
|
114
|
+
);
|
|
115
|
+
const rows: any[] = [];
|
|
116
|
+
for (const t of topics) {
|
|
117
|
+
if (t.isGlobal) continue;
|
|
118
|
+
const repoKey = t.repo && t.repo.key ? String(t.repo.key) : '';
|
|
119
|
+
// 成员关系按仓库 key 对(与 board.repos[].key 同一键空间);
|
|
120
|
+
// 没登记仓库的目录队列不属于任何组,天然出局。
|
|
121
|
+
if (!repoKey || !memberKeys.has(repoKey)) continue;
|
|
122
|
+
const project = (t.repo && t.repo.name) || t.name || t.key;
|
|
123
|
+
for (const x of t.tasks ?? []) {
|
|
124
|
+
if (x.deletedAt || x.migratedTo) continue;
|
|
125
|
+
if (!ids.includes(String(x.boardMark ?? ''))) continue;
|
|
126
|
+
rows.push({
|
|
127
|
+
id: x.id,
|
|
128
|
+
status: x.status,
|
|
129
|
+
title: titleOf(x.text),
|
|
130
|
+
round: x.round ?? 1,
|
|
131
|
+
ready: !!x.ready,
|
|
132
|
+
project,
|
|
133
|
+
topicKey: t.key,
|
|
134
|
+
createdAt: x.createdAt ?? '',
|
|
135
|
+
consumedAt: x.consumedAt ?? '',
|
|
136
|
+
completedAt: x.completedAt ?? '',
|
|
137
|
+
claimedByName: x.claimedByName ?? '',
|
|
138
|
+
roundSummary: x.roundSummary ?? '',
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
// 待领在前、其余按编号倒序:组页最想看的是「还有什么没干」
|
|
143
|
+
rows.sort((a, b) => Number(b.status === 'pending') - Number(a.status === 'pending') || a.id - b.id);
|
|
144
|
+
return {
|
|
145
|
+
id: b.id,
|
|
146
|
+
key: b.key,
|
|
147
|
+
name: b.name,
|
|
148
|
+
pending: rows.filter((r) => r.status === 'pending').length,
|
|
149
|
+
total: rows.length,
|
|
150
|
+
tasks: rows,
|
|
151
|
+
};
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
return { boards };
|
|
155
|
+
}
|
|
156
|
+
}
|
|
@@ -25,12 +25,18 @@ const input = z.object({
|
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* 清单里的一行:够 UI 画出一个列表 + 点进详情,**不含正文**。
|
|
28
|
+
*
|
|
29
|
+
* `board` 是**组任务标注**(与面板 `boardMark` 同一份数据):组页要按它把任务从
|
|
30
|
+
* 成员队列里筛出来,项目页要按它把组任务剔除(两种走向,见 task-view.ts)。
|
|
31
|
+
* 端侧(fr)的组页就是靠这一格才画得出「本组任务」—— 没有它只能把组做成
|
|
32
|
+
* 「成员的导航」,那正是 11-03 改掉的形态。
|
|
28
33
|
*/
|
|
29
34
|
const row = z.object({
|
|
30
35
|
id: z.int().describe('任务编号'),
|
|
31
36
|
status: z.string().describe('pending / claimed / done / cancelled'),
|
|
32
37
|
title: z.string().describe('正文首个标题行(没有标题就取首行,已截断)'),
|
|
33
38
|
round: z.int().describe('第几轮'),
|
|
39
|
+
board: z.string().describe('组任务标注:正文 frontmatter 的 board 值(组 id/key/名);纯项目任务为空串'),
|
|
34
40
|
ready: z.boolean().describe('当前是否可领取'),
|
|
35
41
|
reopenCount: z.int(),
|
|
36
42
|
createdAt: z.string(),
|
|
@@ -68,13 +74,14 @@ export class LocaltaskTasksAction extends ActionBase<typeof input> {
|
|
|
68
74
|
id: 'localtask.tasks',
|
|
69
75
|
cli: ['localtask', 'tasks'],
|
|
70
76
|
http: ['GET', '/api/localtasks/tasks'],
|
|
71
|
-
summary: '看一个主题的任务清单(按 --key 或 --cwd
|
|
77
|
+
summary: '看一个主题的任务清单(按 --key 或 --cwd 定位):只回列表需要的字段(标题/状态/轮次/可领/组标注),不含正文',
|
|
72
78
|
input,
|
|
73
79
|
output,
|
|
74
80
|
render: (d: any) => {
|
|
75
81
|
const head = `${d.name}(${d.key})· ${d.tasks.length}/${d.total} 条`;
|
|
76
82
|
const rows = d.tasks.map(
|
|
77
|
-
|
|
83
|
+
// 组任务在 CLI 上也标出来:同一条队列里混着项目任务与组任务,不标就分不清
|
|
84
|
+
(t: any) => ` #${t.id} [${t.status}] 第${t.round}轮${t.board ? `(组 ${t.board})` : ''} ${t.title}`,
|
|
78
85
|
);
|
|
79
86
|
return [head, ...rows].join('\n');
|
|
80
87
|
},
|
|
@@ -100,6 +107,9 @@ export class LocaltaskTasksAction extends ActionBase<typeof input> {
|
|
|
100
107
|
status: t.status,
|
|
101
108
|
title: titleOf(t.text),
|
|
102
109
|
round: t.round ?? 1,
|
|
110
|
+
// 组任务标注:normalizeTask 已经把 frontmatter.board 解析成 boardMark,
|
|
111
|
+
// 这里只做「缺省为空串」的形状收口 —— 别在这层再解析一遍正文。
|
|
112
|
+
board: t.boardMark ?? '',
|
|
103
113
|
ready: !!t.ready,
|
|
104
114
|
reopenCount: t.reopenCount ?? 0,
|
|
105
115
|
createdAt: t.createdAt ?? '',
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
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
|
-
import * as
|
|
8
|
-
const
|
|
7
|
+
import * as linkNote from '../link-note.js';
|
|
8
|
+
const link: any = linkNote;
|
|
9
9
|
|
|
10
10
|
/** repo.ref.note 的入参契约(CLI 与 HTTP 共用同一份)。 */
|
|
11
11
|
const input = z.object({
|
|
@@ -20,14 +20,18 @@ export class RepoRefNoteAction extends ActionBase<typeof input> {
|
|
|
20
20
|
id: 'repo.ref.note',
|
|
21
21
|
cli: ['repo', 'ref', 'note'],
|
|
22
22
|
http: ['POST', '/api/repos/ref/note'],
|
|
23
|
-
summary:
|
|
23
|
+
summary:
|
|
24
|
+
'写/清绑定描述:这个参考在该组/该仓库里参考什么(#134:描述归档成该参考仓库的一篇文档,' +
|
|
25
|
+
'在「<参考仓库名> · 文档列表」里可见可编辑;--note 留空 = 清除)',
|
|
24
26
|
args: ['id'],
|
|
25
27
|
input,
|
|
26
|
-
render: (d: any) =>
|
|
28
|
+
render: (d: any) =>
|
|
29
|
+
`${d.note ? '已写' : '已清除'}绑定描述: ${d.name} @ ${d.group ? `组「${d.group}」` : `仓库「${d.repo}」`}` +
|
|
30
|
+
(d.refId ? `\n文档: ${d.docId || d.refId}(在它的文档列表里)` : ''),
|
|
27
31
|
})
|
|
28
32
|
override async run(ctx: ActionInput<this['_input']>) {
|
|
29
33
|
|
|
30
|
-
return
|
|
34
|
+
return link.setLinkNote(ctx);
|
|
31
35
|
|
|
32
36
|
}
|
|
33
37
|
}
|