nx-kv 0.54.0 → 0.54.2

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.
Files changed (71) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/assets/nx-kv/references/A01-/351/242/206/345/217/226/344/273/273/345/212/241.md +2 -1
  3. package/assets/nx-kv/references/A05-/351/231/204/344/273/266.md +9 -0
  4. package/assets/nx-kv/references/B02-CLI/351/200/237/346/237/245.md +2 -1
  5. package/package.json +1 -1
  6. package/src/core/attachmentdb/folder.ts +97 -0
  7. package/src/core/attachmentdb/ids.ts +6 -1
  8. package/src/core/attachmentdb/resources.ts +2 -0
  9. package/src/core/attachmentdb.ts +6 -0
  10. package/src/core/db/migrations/index.ts +4 -0
  11. package/src/core/db/migrations/v10.sql +86 -0
  12. package/src/core/db/migrations/v9.sql +111 -0
  13. package/src/core/db/version.ts +5 -1
  14. package/src/modules/docs/actions/doc-attach.ts +2 -1
  15. package/src/modules/docs/attach.ts +14 -1
  16. package/src/modules/localtask/action-render.ts +2 -2
  17. package/src/modules/localtask/actions/_manifest.generated.ts +3 -0
  18. package/src/modules/localtask/actions/localtask-attach.ts +4 -2
  19. package/src/modules/localtask/actions/localtask-plan.ts +38 -0
  20. package/src/modules/localtask/task-ops.ts +49 -0
  21. package/src/modules/tasktool/attach-resource.ts +29 -3
  22. package/src/modules/tasktool/attach-template.ts +25 -1
  23. package/src/modules/tasktool/attach.ts +16 -2
  24. package/src/shared/prompt-blocks.ts +2 -2
  25. package/src/shared/task-status.ts +12 -0
  26. package/src/web/frontend/api/cli-tree.json +17 -2
  27. package/src/web/frontend/api/client.generated.ts +14 -4
  28. package/src/web/frontend/components/status-tag/model.ts +4 -2
  29. package/src/web/frontend/components/tool-acts/modules.ts +2 -0
  30. package/src/web/frontend/page/dir/api.ts +8 -0
  31. package/src/web/frontend/page/dir/landing.tsx +42 -0
  32. package/src/web/frontend/page/settings/prompt-template-params.ts +12 -2
  33. package/src/web/frontend/styles/board.css +2 -0
  34. package/src/web/public/assets/app-context-CR7f0AtI.js +1 -0
  35. package/src/web/public/assets/{bar-BBGb6Y5_.js → bar-BnAUiBVi.js} +1 -1
  36. package/src/web/public/assets/{board-view-BJCwrtHc.js → board-view-CUeSVy9F.js} +1 -1
  37. package/src/web/public/assets/{composer-launch-CjUpcCqD.js → composer-launch-DMiU1boX.js} +1 -1
  38. package/src/web/public/assets/{composer-panel-ECutPtRA.js → composer-panel-BCtBThwX.js} +1 -1
  39. package/src/web/public/assets/{dag-DISpxumr.js → dag-BzD3ZlnO.js} +1 -1
  40. package/src/web/public/assets/dir-26TlooV0.js +3 -0
  41. package/src/web/public/assets/{doc-CmGraKDe.js → doc-ByHuXtbj.js} +2 -2
  42. package/src/web/public/assets/{frontmatter-b044qTyx.js → frontmatter-DEIM0yF2.js} +2 -2
  43. package/src/web/public/assets/{group-BA0tiEYP.js → group-DDPw8Oun.js} +1 -1
  44. package/src/web/public/assets/index-B3LEHx5-.css +1 -0
  45. package/src/web/public/assets/{index-C2C8mDHD.js → index-CHHQ1EtL.js} +2 -2
  46. package/src/web/public/assets/{md-history-8KUZ9ipc.js → md-history-DUv-eEJZ.js} +5 -5
  47. package/src/web/public/assets/{md-parse-Bqb35k5w.js → md-parse-uaOFbIcA.js} +1 -1
  48. package/src/web/public/assets/{member-picker-CQksP35E.js → member-picker-B_LsCqNq.js} +1 -1
  49. package/src/web/public/assets/{model-lEeblPg0.js → model-Co--HRvt.js} +1 -1
  50. package/src/web/public/assets/{overview-VC4HFUS_.js → overview-DfrlYtyR.js} +1 -1
  51. package/src/web/public/assets/{progress-D0qBwZIV.js → progress-BsodHm4N.js} +2 -2
  52. package/src/web/public/assets/{refs-BhgP7Ryy.js → refs-D2v1gDms.js} +1 -1
  53. package/src/web/public/assets/{repo-form-modal-B_ruPwr0.js → repo-form-modal-DAhj7-rY.js} +1 -1
  54. package/src/web/public/assets/{repos-DP6AFrI6.js → repos-CyZSu5OK.js} +8 -8
  55. package/src/web/public/assets/{route-crumb-BHZU-2HE.js → route-crumb-CkhC1zw2.js} +1 -1
  56. package/src/web/public/assets/settings-JX0JIscd.js +8 -0
  57. package/src/web/public/assets/status-tag-BKA9au1l.js +1 -0
  58. package/src/web/public/assets/{task-IoEm4Lmw.js → task-DeRZSdrv.js} +5 -5
  59. package/src/web/public/assets/{task-row-3OXcmAJb.js → task-row-CHSIDNmR.js} +1 -1
  60. package/src/web/public/assets/task-utils-Bdx7ApC1.js +12 -0
  61. package/src/web/public/assets/{templates-B2zDwQG0.js → templates-CFCratP_.js} +1 -1
  62. package/src/web/public/assets/use-rail-drag-BeDwWqzF.js +1 -0
  63. package/src/web/public/assets/{workspace-BwpvQUst.js → workspace-C0PPPfA1.js} +3 -3
  64. package/src/web/public/index.html +14 -14
  65. package/src/web/public/assets/app-context-B0QwHGOd.js +0 -1
  66. package/src/web/public/assets/dir-B8B1sEfY.js +0 -3
  67. package/src/web/public/assets/index-59ZF4OlE.css +0 -1
  68. package/src/web/public/assets/settings-C_8mDUqx.js +0 -8
  69. package/src/web/public/assets/status-tag-DC7mdpkI.js +0 -1
  70. package/src/web/public/assets/task-utils-BqIPKFHQ.js +0 -12
  71. package/src/web/public/assets/use-rail-drag-2mF0AHna.js +0 -1
@@ -0,0 +1,38 @@
1
+ // localtask.plan —— 任务临时草稿态(#126)。
2
+ //
3
+ // 契约(zod schema)就声明在本文件里——入参类型由基类泛型模板封装;本文件只做「声明 + 实现」,业务在服务层。
4
+ import { action } from '../../../runtime/action-decorator.js';
5
+ import { z } from 'zod';
6
+ import { ActionBase, type ActionInput } from '../../../runtime/action-base.js';
7
+ import * as serviceNs from '../service.js';
8
+ const service: any = serviceNs;
9
+
10
+ /** localtask.plan 的入参契约(CLI 与 HTTP 共用)。 */
11
+ const input = z.object({
12
+ id: z.number().describe('任务编号'),
13
+ to: z.enum(['plan', 'pending']).optional().describe('plan=转成草稿(不进队列);pending=转回正常待领取;缺省 plan'),
14
+ cwd: z.string().optional(),
15
+ key: z.string().optional(),
16
+ });
17
+
18
+ export class LocaltaskPlanAction extends ActionBase<typeof input> {
19
+ @action({
20
+ id: 'localtask.plan',
21
+ cli: ['localtask', 'plan'],
22
+ http: ['PATCH', '/api/localtasks/plan'],
23
+ summary: '临时草稿态:plan 不进队列(get/wait 都领不到),pending 转回正常待领取;只允许 pending ↔ plan 双向切换',
24
+ input,
25
+ render: (d: any) =>
26
+ d.changed
27
+ ? `已把 #${d.id} @ ${d.name} 从 ${d.from} 切成 ${d.to}${d.to === 'plan' ? '(草稿,不进队列)' : '(回到待领取)'}`
28
+ : `#${d.id} 已经是 ${d.to},无需改动`,
29
+ })
30
+ override async run(ctx: ActionInput<this['_input']>) {
31
+ return service.setPlanStatus({
32
+ id: ctx.id,
33
+ to: ctx.to || 'plan',
34
+ cwd: ctx.cwd,
35
+ key: ctx.key,
36
+ });
37
+ }
38
+ }
@@ -492,3 +492,52 @@ export async function forkTask({ cwd: rawCwd, key: rawKey, id }: TaskAddress = {
492
492
  });
493
493
  return { ...res, forked: true, from: { key, id: want } };
494
494
  }
495
+
496
+ /**
497
+ * #126:在 `pending ↔ plan` 之间切换一条任务的状态。
498
+ *
499
+ * plan 是**不进队列的临时草稿**:脑子里的想法照样写成任务存进库,但因为不是 pending,
500
+ * 所有 `status='pending'` 的取任务路径(get / wait / 全局池 / 闸门扫描)天然看不到它。
501
+ * 只允许双向切换 pending↔plan,其余状态(claimed/done/cancelled)不许直接转,
502
+ * 免得把正在跑或已定格的活悄悄改掉。
503
+ */
504
+ export async function setPlanStatus({
505
+ cwd: rawCwd,
506
+ key: rawKey,
507
+ id,
508
+ to = 'plan',
509
+ } = {} as any): Promise<Record<string, any>> {
510
+ const key = resolveTaskKey({ key: rawKey, cwd: rawCwd });
511
+ const want = Number(id);
512
+ if (!Number.isFinite(want) || want <= 0) throw badInput('缺少参数 --id <任务编号>');
513
+ const target = String(to || '').trim();
514
+ if (target !== 'plan' && target !== 'pending') throw badInput('--to 只能是 plan 或 pending');
515
+
516
+ openStore();
517
+ const t = topicsRepo.getTopic(key);
518
+ const task = t && (t.tasks || []).find((x: any) => Number(x.id) === want && !x.deletedAt && !x.migratedTo);
519
+ if (!task) throw notFound(`主题「${t ? t.name : key}」里没有 #${want} 任务`);
520
+ const from = String(task.status || 'pending');
521
+ if (from === target) {
522
+ return { status: 'ok', changed: false, id: want, key, name: t!.name, from, to: target };
523
+ }
524
+ if (target === 'plan' && from !== 'pending') {
525
+ throw badInput(`只有待领取任务能转成草稿(#${want} 现在是 ${from})`);
526
+ }
527
+ if (target === 'pending' && from !== 'plan') {
528
+ throw badInput(`只有草稿能转回待领取(#${want} 现在是 ${from})`);
529
+ }
530
+ const updated = tasksRepo.updateTaskByKey(key, want, { status: target });
531
+ if (!updated) throw notFound(`任务不存在: #${want}`);
532
+ topicsRepo.updateTopic(key, { bumpRevision: true });
533
+ return {
534
+ status: 'ok',
535
+ changed: true,
536
+ id: want,
537
+ key,
538
+ name: t!.name,
539
+ from,
540
+ to: target,
541
+ task: updated,
542
+ };
543
+ }
@@ -11,7 +11,7 @@ import { existsSync } from 'node:fs';
11
11
  import { isImageName } from '../../core/filekind.js';
12
12
  import { stripFrontmatter } from '../../shared/frontmatter.js';
13
13
 
14
- const KIND_LABEL: Record<string, string> = { file: '附件', url: '链接', task: '任务', ref: '文档', mdfile: 'md' };
14
+ const KIND_LABEL: Record<string, string> = { file: '附件', url: '链接', task: '任务', ref: '文档', mdfile: 'md', folder: '文件夹' };
15
15
  const IMAGE_LABEL = '图片';
16
16
  export const ORIGIN_LABEL = { inline: '正文内嵌', area: '附件区' };
17
17
  export const STATUS_LABEL: Record<string, string> = { pending: '待领取', claimed: '进行中', done: '已完成', cancelled: '已作废' };
@@ -33,7 +33,7 @@ function metaOf(row: any): Record<string, any> {
33
33
  /** 资源类型归一:image / 空 / 其它未知值 → file;url/task/ref/mdfile 原样。 */
34
34
  function baseKind(row: any): string {
35
35
  const k = String((row && row.kind) || '');
36
- return k === 'url' || k === 'task' || k === 'ref' || k === 'mdfile' ? k : 'file';
36
+ return k === 'url' || k === 'task' || k === 'ref' || k === 'mdfile' || k === 'folder' ? k : 'file';
37
37
  }
38
38
 
39
39
  export function kindLabelOf(kind: unknown, isImage: unknown): string {
@@ -205,7 +205,7 @@ export function resourceOf(row: any, lookups: ResourceLookups = {}): any {
205
205
  areaLabel: ORIGIN_LABEL[origin],
206
206
  storage: kind === 'file' ? String(row.storage || '')
207
207
  : kind === 'url' ? 'url'
208
- : kind === 'mdfile' ? 'external' : 'internal',
208
+ : kind === 'mdfile' || kind === 'folder' ? 'external' : 'internal',
209
209
  synced: kind !== 'file',
210
210
  localPath: '',
211
211
  targetKind: String(row.targetKind || ''),
@@ -281,6 +281,32 @@ export function resourceOf(row: any, lookups: ResourceLookups = {}): any {
281
281
  };
282
282
  }
283
283
 
284
+ if (kind === 'folder') {
285
+ // 本地文件夹指针:库里只有 abs_path,目录内容不入库;交付只给路径让 agent 自己列目录。
286
+ const absPath = String(row.absPath || row.abs_path || meta.absPath || '');
287
+ const exists = !!absPath && existsSync(absPath);
288
+ const missing = !exists || (row.missingAt !== null && row.missingAt !== undefined);
289
+ const title = String(row.name || (absPath ? absPath.split(/[\\/]/).pop() : '') || base.id);
290
+ const readCmd = `nx-kv file content ${base.id}`;
291
+ const locator = `${title}${absPath ? `(${absPath})` : ''}`;
292
+ return {
293
+ ...base,
294
+ absPath,
295
+ exists,
296
+ missing,
297
+ fileId: base.id,
298
+ title,
299
+ readCmd,
300
+ target: absPath || locator,
301
+ needsSync: false,
302
+ cmd: readCmd,
303
+ locator,
304
+ usage: missing
305
+ ? `文件夹当前不可访问(${absPath || '路径为空'}):请确认目录是否还在本机`
306
+ : `这是本地文件夹的路径指针(目录内容不在库里):先列目录 ${absPath} 看结构,再用 Read 读需要的文件`,
307
+ };
308
+ }
309
+
284
310
  if (kind === 'mdfile') {
285
311
  // 外部 md 文件指针:字节在用户磁盘原地(storage='external'),库里只有 abs_path + hash。
286
312
  // 渲染分支只看 kind,不看 MIME / 扩展名。
@@ -21,13 +21,14 @@ import { hostOfUrl, kindLabelOf, ORIGIN_LABEL, sizeTextOf, STATUS_LABEL } from '
21
21
  * ref → { refId, title, desc, readCmd, content, truncated }
22
22
  * content 只在「文档资料」绑定(role='doc',交付读全文)且真的读到时非空。
23
23
  * mdfile → { absPath, anchorDir, content, truncated, stale, missing, readCmd }
24
+ * folder → { absPath, exists, missing, readCmd }(#127:目录内容不入库,只给路径)
24
25
  * content 是读时从磁盘现取的正文(截断 2 万字);missing 时为空、stale 表示指纹漂移。
25
26
  * 通用 note = 边上的说明(desc,#162):attach --note 的落点,清单行透出。
26
27
  * 旧模板兼容:平铺别名 localPath / fileId / urlText / href / taskId / title /
27
28
  * seq / showCmd / refId / target / area / areaLabel。
28
29
  */
29
30
  function ctxItemOf(a: any): any {
30
- const kind = ['url', 'task', 'ref', 'mdfile'].includes(a.kind) ? a.kind : 'file';
31
+ const kind = ['url', 'task', 'ref', 'mdfile', 'folder'].includes(a.kind) ? a.kind : 'file';
31
32
  const isImage = kind === 'file' && (a.isImage === undefined ? isImageName(a.name, a.mime) : !!a.isImage);
32
33
  const role = String(a.role || '');
33
34
  const origin =
@@ -132,6 +133,29 @@ function ctxItemOf(a: any): any {
132
133
  };
133
134
  }
134
135
 
136
+ if (kind === 'folder') {
137
+ const absPath = String(a.absPath || a.localPath || '');
138
+ const exists = a.exists === undefined ? !!absPath : !!a.exists;
139
+ const missing = a.missing === undefined ? !exists : !!a.missing;
140
+ const readCmd = String(a.readCmd || `nx-kv file content ${item.id}`);
141
+ const folder = { absPath, exists, missing, readCmd };
142
+ const usage = String(a.usage || (missing
143
+ ? `文件夹当前不可访问(${absPath || '路径为空'}):请确认目录是否还在本机`
144
+ : `这是本地文件夹的路径指针:先列目录 ${absPath} 看结构,再用 Read 读需要的文件`));
145
+ return {
146
+ ...item,
147
+ absPath,
148
+ path: absPath,
149
+ exists,
150
+ missing,
151
+ folder,
152
+ usage,
153
+ cmd: String(a.cmd !== undefined ? a.cmd : readCmd),
154
+ locator: String(a.locator || absPath || item.name),
155
+ needsSync: false,
156
+ };
157
+ }
158
+
135
159
  if (kind === 'mdfile') {
136
160
  const absPath = String(a.absPath || a.localPath || '');
137
161
  const anchorDir = String(a.anchorDir || '');
@@ -36,6 +36,7 @@ import {
36
36
  listTaskAttachmentsBySeq,
37
37
  readMdfile,
38
38
  registerMdfile,
39
+ registerFolder,
39
40
  resolveRefId,
40
41
  unlinkAttachment,
41
42
  updateAttachmentNote,
@@ -167,6 +168,8 @@ export interface AttachToTaskOptions {
167
168
  ref?: unknown;
168
169
  /** 本地 md 文件(kind=mdfile:只登记路径指针,不复制正文) */
169
170
  mdfile?: unknown;
171
+ /** 本地文件夹(kind=folder:只登记路径指针,不复制目录内容) */
172
+ folder?: unknown;
170
173
  note?: unknown;
171
174
  noEmbed?: unknown;
172
175
  inline?: unknown;
@@ -191,9 +194,10 @@ export interface AttachToTaskOptions {
191
194
  * --task <seq> 同主题下的另一条任务(kind=task,nxkv://task/<id>)
192
195
  * --ref <路径|id> 文档库里的 ref(kind=ref,nxkv://ref/<refId>)
193
196
  * --mdfile <路径> 本地 md 文件(kind=mdfile,nxkv://mdfile/<attId>;字节不入库)
197
+ * --folder <目录> 本地文件夹(kind=folder,nxkv://folder/<attId>;只登记路径,不复制目录内容)
194
198
  */
195
199
  export async function attachToTask({
196
- id, cwd, key, path, fileId, name, kind, url, task, ref, mdfile, note, noEmbed, inline,
200
+ id, cwd, key, path, fileId, name, kind, url, task, ref, mdfile, folder, note, noEmbed, inline,
197
201
  }: AttachToTaskOptions = {}): Promise<Record<string, any>> {
198
202
  const cur = await service.getTask({ id, cwd, key }); // 存在性与参数校验都在队列本体
199
203
  const topicKey = cur.key || key || '';
@@ -322,11 +326,21 @@ export async function attachToTask({
322
326
  displayName = displayName || rec.name;
323
327
  resolvedKind = 'mdfile';
324
328
  markdown = `[${displayName}](nxkv://mdfile/${rec.id})`;
329
+ } else if (folder) {
330
+ // 本地文件夹:只登记路径指针(kind=folder / storage=external),目录内容不入库
331
+ const rec = tx(
332
+ (conn) => registerFolder(conn, { path: folder, name: displayName }),
333
+ { db, mode: 'IMMEDIATE' }
334
+ );
335
+ attachmentId = rec.id;
336
+ displayName = displayName || rec.name;
337
+ resolvedKind = 'folder';
338
+ markdown = `[${displayName}](nxkv://folder/${rec.id})`;
325
339
  }
326
340
 
327
341
  if (!attachmentId) {
328
342
  throw badInput(
329
- '需要 --path <本机文件>、--fileId <已有附件>、--url <链接>、--task <编号>、--ref <文档> 或 --mdfile <本地 md> 之一'
343
+ '需要 --path <本机文件>、--fileId <已有附件>、--url <链接>、--task <编号>、--ref <文档>、--mdfile <本地 md> 或 --folder <本地目录> 之一'
330
344
  );
331
345
  }
332
346
  const wantInline = !!inline;
@@ -137,11 +137,11 @@ export const DEFAULT_CONTEXT_TEMPLATE = [
137
137
  */
138
138
  export const DEFAULT_ATTACH_TEMPLATE = [
139
139
  '{{#if attach}}',
140
- '〔附件〕本任务包含 {{attach.count}} 个附件(正文内嵌 {{attach.inlineCount}} · 附件区 {{attach.areaCount}})。请先识别附件内容(图片先看图、文档先读内容)再开始处理,不要跳过附件。',
140
+ '〔附件〕本任务包含 {{attach.count}} 个附件(正文内嵌 {{attach.inlineCount}} · 附件区 {{attach.areaCount}})。请先识别附件内容(图片先看图、文档先读内容、文件夹先列目录)再开始处理,不要跳过附件。',
141
141
  '',
142
142
  '附件清单:',
143
143
  '{{#each attach.list}}',
144
- ' - [{{originLabel}}] {{kindLabel}} {{name}}{{#if sizeText}}({{sizeText}}){{/if}}:{{#if file}}{{#if file.exists}}{{file.localPath}}{{else}}未同步到本地(fileId {{file.fileId}}){{/if}}{{/if}}{{#if url}}{{url.href}}{{/if}}{{#if task}}{{#if task.resolved}}#{{task.seq}} {{task.title}} · 地址 {{task.address}}({{task.statusLabel}}){{else}}地址 {{task.address}}({{task.statusLabel}}){{/if}}{{/if}}{{#if ref}}{{ref.title}}{{/if}}{{#if mdfile}}{{mdfile.absPath}}{{#if mdfile.missing}}(源文件已不在){{/if}}{{/if}}{{#if note}} # {{note}}{{/if}}',
144
+ ' - [{{originLabel}}] {{kindLabel}} {{name}}{{#if sizeText}}({{sizeText}}){{/if}}:{{#if file}}{{#if file.exists}}{{file.localPath}}{{else}}未同步到本地(fileId {{file.fileId}}){{/if}}{{/if}}{{#if url}}{{url.href}}{{/if}}{{#if task}}{{#if task.resolved}}#{{task.seq}} {{task.title}} · 地址 {{task.address}}({{task.statusLabel}}){{else}}地址 {{task.address}}({{task.statusLabel}}){{/if}}{{/if}}{{#if ref}}{{ref.title}}{{/if}}{{#if mdfile}}{{mdfile.absPath}}{{#if mdfile.missing}}(源文件已不在){{/if}}{{/if}}{{#if folder}}{{folder.absPath}}{{#if folder.missing}}(目录已不在){{/if}}{{/if}}{{#if note}} # {{note}}{{/if}}',
145
145
  '{{/each}}',
146
146
  '',
147
147
  '取用方式:',
@@ -26,6 +26,8 @@ export const TASK_STATUS = Object.freeze({
26
26
  CLAIMED: 'claimed',
27
27
  DONE: 'done',
28
28
  CANCELLED: 'cancelled',
29
+ /** #126:临时草稿态——存在库里,但绝不进队列、不被 get/wait 领取 */
30
+ PLAN: 'plan',
29
31
  } as const);
30
32
 
31
33
  /** 全部合法状态(顺序即面板展示顺序:待领取 → 已领取 → 已完成 → 已取消)。 */
@@ -34,6 +36,7 @@ export const TASK_STATUSES: readonly string[] = Object.freeze([
34
36
  TASK_STATUS.CLAIMED,
35
37
  TASK_STATUS.DONE,
36
38
  TASK_STATUS.CANCELLED,
39
+ TASK_STATUS.PLAN,
37
40
  ]);
38
41
 
39
42
  /** 状态的中文标签(CLI / 面板共用一份,避免两处措辞不同)。 */
@@ -42,6 +45,7 @@ export const STATUS_TAG: Record<string, string> = Object.freeze({
42
45
  claimed: '已领取',
43
46
  done: '已完成',
44
47
  cancelled: '已取消',
48
+ plan: '草稿',
45
49
  });
46
50
 
47
51
  /** 状态是否合法。 */
@@ -94,6 +98,14 @@ export function isCancelled(t?: TaskRowLike | null): boolean {
94
98
  return isLive(t) && t?.status === TASK_STATUS.CANCELLED;
95
99
  }
96
100
 
101
+ /**
102
+ * 草稿(#126):临时态,不是 pending、不是 open、不是终态。
103
+ * 所有 `status='pending'` 的取任务路径天然排除它——不需要在每条 SQL 里补条件。
104
+ */
105
+ export function isPlan(t?: TaskRowLike | null): boolean {
106
+ return isLive(t) && t?.status === TASK_STATUS.PLAN;
107
+ }
108
+
97
109
  /**
98
110
  * 终态:done / cancelled。
99
111
  * 依赖闸门用它判「这一条不会再动了,别永久挡住后面的人」(旧口径把 archived 也算终态)。
@@ -840,7 +840,7 @@
840
840
  "action": {
841
841
  "id": "doc.attach",
842
842
  "module": "docs",
843
- "summary": "给文档挂资源:--path / --fileId / --url / --task / --doc / --mdfile 之一;默认追加进正文,--no-embed 只挂附件区(不写正文)",
843
+ "summary": "给文档挂资源:--path / --fileId / --url / --task / --doc / --mdfile / --folder 之一;默认追加进正文,--no-embed 只挂附件区(不写正文)",
844
844
  "usage": "docs attach",
845
845
  "http": "POST /api/docs/attach"
846
846
  },
@@ -1161,7 +1161,7 @@
1161
1161
  "action": {
1162
1162
  "id": "localtask.attach",
1163
1163
  "module": "localtask",
1164
- "summary": "给任务挂附件:--path 存本机附件仓 / --fileId 引用已有附件 / --url / --task(同主题任务)/ --ref(文档)/ --mdfile(本地 md 指针);默认嵌进正文,--no-embed 只挂到附件区(不写正文),--ref 加 --inline 文档进原文(交付带全文)",
1164
+ "summary": "给任务挂附件:--path 存本机附件仓 / --fileId 引用已有附件 / --url / --task(同主题任务)/ --ref(文档)/ --mdfile(本地 md 指针)/ --folder(本地文件夹路径);默认嵌进正文,--no-embed 只挂到附件区(不写正文),--ref 加 --inline 文档进原文(交付带全文)",
1165
1165
  "usage": "localtask attach",
1166
1166
  "http": "POST /api/localtasks/attach"
1167
1167
  },
@@ -1377,6 +1377,21 @@
1377
1377
  },
1378
1378
  "children": []
1379
1379
  },
1380
+ {
1381
+ "name": "plan",
1382
+ "path": [
1383
+ "localtask",
1384
+ "plan"
1385
+ ],
1386
+ "action": {
1387
+ "id": "localtask.plan",
1388
+ "module": "localtask",
1389
+ "summary": "临时草稿态:plan 不进队列(get/wait 都领不到),pending 转回正常待领取;只允许 pending ↔ plan 双向切换",
1390
+ "usage": "localtask plan",
1391
+ "http": "PATCH /api/localtasks/plan"
1392
+ },
1393
+ "children": []
1394
+ },
1380
1395
  {
1381
1396
  "name": "presence",
1382
1397
  "path": [
@@ -56,6 +56,7 @@ import type {
56
56
  LocaltaskForkAction,
57
57
  LocaltaskGetAction,
58
58
  LocaltaskListAction,
59
+ LocaltaskPlanAction,
59
60
  LocaltaskPresenceAction,
60
61
  LocaltaskPreviewAction,
61
62
  LocaltaskPruneAction,
@@ -247,7 +248,7 @@ export interface ApiClient {
247
248
  repoUpdate(input: z.input<InstanceType<typeof RepoUpdateAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof RepoUpdateAction>['run']>>>;
248
249
  /** 改一条附件绑定的说明(desc):--attachment <资源 id> --note <说明>(只动说明,角色/位置不变) */
249
250
  attachNote(input: z.input<InstanceType<typeof DocAttachNoteAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof DocAttachNoteAction>['run']>>>;
250
- /** 给文档挂资源:--path / --fileId / --url / --task / --doc / --mdfile 之一;默认追加进正文,--no-embed 只挂附件区(不写正文) */
251
+ /** 给文档挂资源:--path / --fileId / --url / --task / --doc / --mdfile / --folder 之一;默认追加进正文,--no-embed 只挂附件区(不写正文) */
251
252
  attach(input: z.input<InstanceType<typeof DocAttachAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof DocAttachAction>['run']>>>;
252
253
  /** 这篇文档用了哪些资源(ref_attach:图片/文件/URL/内部 task、ref 引用) */
253
254
  attachments(input: z.input<InstanceType<typeof DocAttachmentsAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof DocAttachmentsAction>['run']>>>;
@@ -283,7 +284,7 @@ export interface ApiClient {
283
284
  localtaskAdd(input: z.input<InstanceType<typeof LocaltaskAddAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof LocaltaskAddAction>['run']>>>;
284
285
  /** 改一条附件绑定的说明(desc):--attachment <资源 id> --note <说明>(只动说明,角色/位置不变) */
285
286
  localtaskAttachNote(input: z.input<InstanceType<typeof LocaltaskAttachNoteAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof LocaltaskAttachNoteAction>['run']>>>;
286
- /** 给任务挂附件:--path 存本机附件仓 / --fileId 引用已有附件 / --url / --task(同主题任务)/ --ref(文档)/ --mdfile(本地 md 指针);默认嵌进正文,--no-embed 只挂到附件区(不写正文),--ref 加 --inline 文档进原文(交付带全文) */
287
+ /** 给任务挂附件:--path 存本机附件仓 / --fileId 引用已有附件 / --url / --task(同主题任务)/ --ref(文档)/ --mdfile(本地 md 指针)/ --folder(本地文件夹路径);默认嵌进正文,--no-embed 只挂到附件区(不写正文),--ref 加 --inline 文档进原文(交付带全文) */
287
288
  localtaskAttach(input: z.input<InstanceType<typeof LocaltaskAttachAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof LocaltaskAttachAction>['run']>>>;
288
289
  /** 列出某条任务引用的附件(正文里的 ![名](fileId) 嵌入),以及本地是否已有(给 agent 直接读本地文件) */
289
290
  localtaskAttachments(input: z.input<InstanceType<typeof LocaltaskAttachmentsAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof LocaltaskAttachmentsAction>['run']>>>;
@@ -313,6 +314,8 @@ export interface ApiClient {
313
314
  localtaskGet(input: z.input<InstanceType<typeof LocaltaskGetAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof LocaltaskGetAction>['run']>>>;
314
315
  /** 总览全部主题(工作目录、现状、是否等待中、待领取数) */
315
316
  localtaskList(): Promise<Awaited<ReturnType<InstanceType<typeof LocaltaskListAction>['run']>>>;
317
+ /** 临时草稿态:plan 不进队列(get/wait 都领不到),pending 转回正常待领取;只允许 pending ↔ plan 双向切换 */
318
+ plan(input: z.input<InstanceType<typeof LocaltaskPlanAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof LocaltaskPlanAction>['run']>>>;
316
319
  /** 探测主面板上当前打开的「实时任务」标签数(活动 SSE 连接数;用于 wait 不重复开页) */
317
320
  presence(): Promise<Awaited<ReturnType<InstanceType<typeof LocaltaskPresenceAction>['run']>>>;
318
321
  /** 预览一条任务在 get/wait 时的交付提示词(只读:不领取、不写盘、不启动计时、不为附件发网);草稿用 --text 直接预览 */
@@ -744,7 +747,7 @@ export function createApiClient(transport: Transport): ApiClient {
744
747
  async attach(input: z.input<InstanceType<typeof DocAttachAction>['_input']>) {
745
748
  const inp = input ?? ({} as z.input<InstanceType<typeof DocAttachAction>['_input']>);
746
749
  const path = `/api/docs/attach`;
747
- const body = { "ref": inp["ref"], "path": inp["path"], "fileId": inp["fileId"], "url": inp["url"], "task": inp["task"], "doc": inp["doc"], "mdfile": inp["mdfile"], "name": inp["name"], "note": inp["note"], "noEmbed": inp["noEmbed"], "no-embed": inp["no-embed"] };
750
+ const body = { "ref": inp["ref"], "path": inp["path"], "fileId": inp["fileId"], "url": inp["url"], "task": inp["task"], "doc": inp["doc"], "mdfile": inp["mdfile"], "folder": inp["folder"], "name": inp["name"], "note": inp["note"], "noEmbed": inp["noEmbed"], "no-embed": inp["no-embed"] };
748
751
  return (await transport.request("POST", path, body)) as Awaited<ReturnType<InstanceType<typeof DocAttachAction>['run']>>;
749
752
  },
750
753
  // action: doc.attachments
@@ -888,7 +891,7 @@ export function createApiClient(transport: Transport): ApiClient {
888
891
  async localtaskAttach(input: z.input<InstanceType<typeof LocaltaskAttachAction>['_input']>) {
889
892
  const inp = input ?? ({} as z.input<InstanceType<typeof LocaltaskAttachAction>['_input']>);
890
893
  const path = `/api/localtasks/attach`;
891
- const body = { "id": inp["id"], "cwd": inp["cwd"], "key": inp["key"], "path": inp["path"], "fileId": inp["fileId"], "url": inp["url"], "task": inp["task"], "ref": inp["ref"], "mdfile": inp["mdfile"], "inline": inp["inline"], "name": inp["name"], "kind": inp["kind"], "note": inp["note"], "noEmbed": inp["noEmbed"], "no-embed": inp["no-embed"] };
894
+ const body = { "id": inp["id"], "cwd": inp["cwd"], "key": inp["key"], "path": inp["path"], "fileId": inp["fileId"], "url": inp["url"], "task": inp["task"], "ref": inp["ref"], "mdfile": inp["mdfile"], "folder": inp["folder"], "inline": inp["inline"], "name": inp["name"], "kind": inp["kind"], "note": inp["note"], "noEmbed": inp["noEmbed"], "no-embed": inp["no-embed"] };
892
895
  return (await transport.request("POST", path, body)) as Awaited<ReturnType<InstanceType<typeof LocaltaskAttachAction>['run']>>;
893
896
  },
894
897
  // action: localtask.attachments
@@ -1008,6 +1011,13 @@ export function createApiClient(transport: Transport): ApiClient {
1008
1011
  const path = `/api/localtasks`;
1009
1012
  return (await transport.request("GET", path)) as Awaited<ReturnType<InstanceType<typeof LocaltaskListAction>['run']>>;
1010
1013
  },
1014
+ // action: localtask.plan
1015
+ async plan(input: z.input<InstanceType<typeof LocaltaskPlanAction>['_input']>) {
1016
+ const inp = input ?? ({} as z.input<InstanceType<typeof LocaltaskPlanAction>['_input']>);
1017
+ const path = `/api/localtasks/plan`;
1018
+ const body = { "id": inp["id"], "to": inp["to"], "cwd": inp["cwd"], "key": inp["key"] };
1019
+ return (await transport.request("PATCH", path, body)) as Awaited<ReturnType<InstanceType<typeof LocaltaskPlanAction>['run']>>;
1020
+ },
1011
1021
  // action: localtask.presence
1012
1022
  async presence() {
1013
1023
  const path = `/api/localtasks/presence`;
@@ -14,6 +14,7 @@ import {
14
14
  isClaimed,
15
15
  isDone,
16
16
  isCancelled,
17
+ isPlan,
17
18
  STATUS_TAG,
18
19
  } from '../../../../shared/task-status.js';
19
20
  import type { TaskRowLike } from '../../../../shared/task-status.js';
@@ -22,7 +23,7 @@ import type { TaskRowLike } from '../../../../shared/task-status.js';
22
23
  export type StatusRow = TaskRowLike;
23
24
 
24
25
  /** 四种语义色调(CSS 类后缀 tstat-<tone> 同名)。 */
25
- export type StatusTone = 'gone' | 'done' | 'doing' | 'pending';
26
+ export type StatusTone = 'gone' | 'done' | 'doing' | 'pending' | 'plan';
26
27
 
27
28
  /**
28
29
  * 四种语义色调。不认识的 status 给中性灰(pending 色),文案由 statusLabel
@@ -34,6 +35,7 @@ export function statusTone(t: StatusRow | null | undefined): StatusTone {
34
35
  if (isDone(t)) return 'done';
35
36
  if (isClaimed(t)) return 'doing';
36
37
  if (isCancelled(t)) return 'gone';
38
+ if (isPlan(t)) return 'plan';
37
39
  return 'pending';
38
40
  }
39
41
 
@@ -50,7 +52,7 @@ export function statusLabel(t: StatusRow | null | undefined): string {
50
52
  }
51
53
 
52
54
  /** 单字徽标(侧栏 / 队列表等窄处):等 / 跑 / 完 / 档——随色调一起统一。 */
53
- const TONE_SHORT: Record<StatusTone, string> = { pending: '等', doing: '跑', done: '完', gone: '档' };
55
+ const TONE_SHORT: Record<StatusTone, string> = { pending: '等', doing: '跑', done: '完', gone: '档', plan: '草' };
54
56
 
55
57
  /**
56
58
  * 单字徽标文案(窄处显示不下全称时用)。
@@ -32,6 +32,8 @@ export const DIR_MODULES: ToolModule[] = [
32
32
  { id: 'import', label: '导入', section: 'bar' },
33
33
  { id: 'progress', label: '进程', section: 'bar' },
34
34
  { id: 'orch', label: '编排', section: 'bar' },
35
+ // #126:草稿开关作用于选中的任务(没选中时给提示),默认在工具栏可见
36
+ { id: 'plan', label: '草稿', section: 'bar' },
35
37
  { id: 'more', label: '更多', section: 'bar', noHide: true },
36
38
  { id: 'refs', label: '查看列表', section: 'more' },
37
39
  ];
@@ -84,6 +84,14 @@ export function addTask(body: AddTaskBody): Promise<any> {
84
84
  return api('/api/localtasks', { method: 'POST', body });
85
85
  }
86
86
 
87
+ /**
88
+ * #126:在 pending ↔ plan 之间切换一条任务(PATCH /api/localtasks/plan)。
89
+ * plan 是不进队列的临时草稿,get/wait 都领不到;转回 pending 才重新排队。
90
+ */
91
+ export function setPlanStatus(body: TaskScope & { id: number; to: 'plan' | 'pending' }): Promise<any> {
92
+ return api('/api/localtasks/plan', { method: 'PATCH', body });
93
+ }
94
+
87
95
  /** 重开 / 追加反馈(POST /api/localtasks/reopen;kind=reopen|comment)。 */
88
96
  export function postReopen(body: Record<string, unknown>): Promise<TaskMutationResult> {
89
97
  return api('/api/localtasks/reopen', { method: 'POST', body });
@@ -18,6 +18,9 @@ import TaskPanel from '../../components/task-panel/index.jsx';
18
18
  import TaskPanelLayoutRaw from '../../components/task-panel/layout.jsx';
19
19
  import TaskRow from '../../components/task-panel/task-row.jsx';
20
20
  import type { LocalTask, LocalTopic, RepoRow } from '../../types.js';
21
+ import { useApp } from '../../app-context.jsx';
22
+ import { useToast } from '../../components/toast/index.jsx';
23
+ import { setPlanStatus } from './api.js';
21
24
 
22
25
  /** 拖动落点:行上半 = 之前,下半 = 之后。 */
23
26
  type DropZone = 'before' | 'after';
@@ -197,6 +200,28 @@ export default function Landing({
197
200
  const ok = await fn(ids);
198
201
  if (ok) setPicked(new Set());
199
202
  };
203
+
204
+ // #126:草稿态切换。plan 的任务照样存在库里,但因为不是 pending,
205
+ // get/wait/队列/闸门都看不到它;转回 pending 才重新进入待领取队列。
206
+ const app = useApp();
207
+ const toast = useToast();
208
+ const scope = topic?.key ? { key: topic.key } : {};
209
+ const pickedRows = pickedTasks;
210
+ const toPlan = pickedRows.filter((t) => t.status === 'pending');
211
+ const toPending = pickedRows.filter((t) => t.status === 'plan');
212
+ const switchPlan = async (rows: LocalTask[], to: 'plan' | 'pending') => {
213
+ if (!rows.length) return;
214
+ try {
215
+ for (const t of rows) await setPlanStatus({ ...scope, id: Number(t.id), to });
216
+ toast(to === 'plan' ? `已把 ${rows.length} 条任务转为草稿(不进队列)` : `已把 ${rows.length} 条草稿转回待领取`);
217
+ setPicked(new Set());
218
+ app.refreshLocal?.();
219
+ } catch (e) {
220
+ toast(String((e as Error).message || e));
221
+ }
222
+ };
223
+ const planTargets = toPlan.length ? toPlan : toPending;
224
+ const planTo: 'plan' | 'pending' = toPlan.length ? 'plan' : 'pending';
200
225
  // 只有待领取行能拖动调序(已领取/已完成/已取消都是固定历史)
201
226
  const movable = (t: LocalTask) => t.status === 'pending' && !t.migratedTo && !t.deletedAt;
202
227
  const zoneOf = (e: ReactDragEvent<HTMLElement>, tr: HTMLElement): DropZone => {
@@ -349,6 +374,12 @@ export default function Landing({
349
374
  不再在行尾铺一排图标(反馈 + 删除原来占两个最右位,行尾过挤)。 */
350
375
  <RowMenu
351
376
  items={[
377
+ t.status === 'pending' || t.status === 'plan'
378
+ ? {
379
+ label: t.status === 'pending' ? '转为草稿(不进队列)' : '转回待领取',
380
+ onPick: () => void switchPlan([t], t.status === 'pending' ? 'plan' : 'pending'),
381
+ }
382
+ : null,
352
383
  movableRow && onOpenDag
353
384
  ? { label: '编排依赖…', onPick: () => onOpenDag(t) }
354
385
  : null,
@@ -411,6 +442,9 @@ export default function Landing({
411
442
  kind="dir"
412
443
  labels={{
413
444
  more: '更多',
445
+ plan: pickedRows.length
446
+ ? planTo === 'plan' ? `转草稿 (${toPlan.length})` : `转回待领取 (${toPending.length})`
447
+ : '草稿',
414
448
  }}
415
449
  titles={{
416
450
  new: '按默认模板新建一页(▾ 选模板)',
@@ -418,6 +452,7 @@ export default function Landing({
418
452
  progress: '打开这个目录的进程面板',
419
453
  more: '更多操作',
420
454
  refs: '查看文档 / reference 列表',
455
+ plan: '选中任务后:待领取 ↔ 草稿(草稿不进 get/wait 队列;行尾 ⋯ 菜单也能单条切换)',
421
456
  }}
422
457
  renderers={{
423
458
  // #161 新建按钮拆两级(视觉一颗按钮、命中区两层):
@@ -462,6 +497,13 @@ export default function Landing({
462
497
  progress: onProg,
463
498
  orch: onOpenFlow,
464
499
  refs: onRefs,
500
+ plan: () => {
501
+ if (!planTargets.length) {
502
+ toast('先勾选任务:待领取可转草稿,草稿可转回待领取(行尾 ⋯ 菜单也能单条切换)');
503
+ return;
504
+ }
505
+ void switchPlan(planTargets, planTo);
506
+ },
465
507
  }}
466
508
  />
467
509
  </>
@@ -73,8 +73,8 @@ export const BLOCK_PARAMS: BlockParamTable = {
73
73
  {
74
74
  label: '附件条目(通用,attach.list 内循环)',
75
75
  items: [
76
- ['kind', '类型:file / url / task / ref'],
77
- ['kindLabel', '类型显示名:附件/图片/链接/任务/文档'],
76
+ ['kind', '类型:file / url / task / ref / mdfile / folder'],
77
+ ['kindLabel', '类型显示名:附件/图片/链接/任务/文档/md/文件夹'],
78
78
  ['name', '展示名(任务型为实时标题,不是正文)'],
79
79
  ['size', '字节数'],
80
80
  ['sizeText', '可读大小(1.2 MB)'],
@@ -100,6 +100,16 @@ export const BLOCK_PARAMS: BlockParamTable = {
100
100
  ['fileId', 'file.fileId 的平铺别名'],
101
101
  ],
102
102
  },
103
+ {
104
+ label: '文件夹型(kind=folder)· folder 子对象(#127)',
105
+ items: [
106
+ ['folder.absPath', '本地文件夹绝对路径(目录内容不入库)'],
107
+ ['folder.exists', '目录当前是否可访问'],
108
+ ['folder.missing', '目录是否已不在本机'],
109
+ ['folder.readCmd', '查看该附件登记信息的命令'],
110
+ ['usage', '取用说明:先列目录看结构,再用 Read 读需要的文件'],
111
+ ],
112
+ },
103
113
  {
104
114
  label: '链接型(kind=url)· url 子对象',
105
115
  items: [
@@ -18,6 +18,8 @@
18
18
  .tstat.tstat-doing { color: var(--doing, #2f5fb5); background: var(--doing-bg, #edf2fc); border-color: var(--doing-line, #c9d6f0); }
19
19
  .tstat.tstat-done { color: var(--live); background: rgba(31, 122, 77, 0.08); border-color: rgba(31, 122, 77, 0.28); }
20
20
  .tstat.tstat-gone { color: var(--faint); border-style: dashed; }
21
+ /* #126 草稿:与待领取区分开,金褐色文字 + 虚线边框,不占「进行中/已完成」语义色 */
22
+ .tstat.tstat-plan { color: var(--warn); background: var(--soft); border-color: var(--soft-2); border-style: dashed; }
21
23
 
22
24
  /* ---------- 表格:细线分隔,不画网格 ---------- */
23
25
  table { width: 100%; border-collapse: collapse; }
@@ -0,0 +1 @@
1
+ import{C as e,b as t}from"./frontmatter-DEIM0yF2.js";var n=e(t(),1),r=(0,n.createContext)({});function i(){return(0,n.useContext)(r)}export{i as n,r as t};
@@ -1 +1 @@
1
- import{S as e,v as t,y as n}from"./frontmatter-b044qTyx.js";import{w as r}from"./workspace-BwpvQUst.js";import{c as i,d as a,l as o,s,u as c}from"./use-rail-drag-2mF0AHna.js";var l=e(n(),1),u=r(),d=t();function f({kind:e,renderers:t={},actions:n={},titles:r={},disabled:f={},labels:p={},className:m=``}){let{layout:h,setLayout:g}=i(e),[_,v]=(0,l.useState)(!1),[y,b]=(0,l.useState)(null),[x,S]=(0,l.useState)(!1),C=(0,l.useRef)(null),w=(0,l.useRef)(null);(0,l.useEffect)(()=>{if(!_)return;let e=e=>{let t=e.target;C.current?.contains(t)||w.current?.contains(t)||v(!1)},t=e=>{e.key===`Escape`&&v(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[_]);let T=h.filter(t=>a(e,t)),E=h.filter(t=>o(e,t)),D=t=>p[t]||c(e,t).label||t,O=(e,t={})=>(0,d.jsx)(`button`,{type:`button`,className:t.primary?`btn small primary`:`btn small ghost`,title:r[e]||D(e),disabled:!!f[e],onClick:()=>n[e]&&n[e](),children:D(e)},e),k=n=>{if(n===`more`)return(0,d.jsxs)(`button`,{ref:C,type:`button`,className:`btn small ghost`+(_?` is-open`:``),title:r.more||`更多操作`,"aria-haspopup":`menu`,"aria-expanded":_,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();b({top:t.bottom+6,right:Math.max(8,window.innerWidth-t.right)}),v(e=>!e)},children:[D(`more`),` ▾`]},`more`);let i=t[n];return i?(0,d.jsx)(`span`,{className:`ta-slot`,children:i({open:_})},n):O(n,{primary:c(e,n).section===`primary`})};return(0,d.jsxs)(`div`,{className:`ta-bar`+(m?` ${m}`:``),children:[T.map(e=>k(e.id)),_&&y&&(0,u.createPortal)((0,d.jsxs)(`div`,{ref:w,className:`ta-more-menu`,role:`menu`,style:{top:y.top,right:y.right},children:[E.length===0&&(0,d.jsx)(`div`,{className:`ta-more-empty`,children:`没有收纳的工具——可在编排里把按钮收入更多`}),E.map(e=>(0,d.jsx)(`button`,{type:`button`,role:`menuitem`,className:`ta-more-it`,disabled:!!f[e.id],title:r[e.id]||D(e.id),onClick:()=>{v(!1);let t=n[e.id];t&&t()},children:D(e.id)},e.id)),(0,d.jsx)(`div`,{className:`ta-more-sep`}),(0,d.jsx)(`button`,{type:`button`,role:`menuitem`,className:`ta-more-it ta-more-cfg`,onClick:()=>{v(!1),S(!0)},children:`自定义工具栏…`})]}),document.body),x&&(0,u.createPortal)((0,d.jsx)(`div`,{className:`ta-panel-mask`,onClick:()=>S(!1),children:(0,d.jsx)(`div`,{className:`ta-panel-wrap`,onClick:e=>e.stopPropagation(),children:(0,d.jsx)(s,{kind:e,layout:h,setLayout:g,onClose:()=>S(!1)})})}),document.body)]})}export{f as t};
1
+ import{C as e,b as t,y as n}from"./frontmatter-DEIM0yF2.js";import{w as r}from"./workspace-C0PPPfA1.js";import{c as i,d as a,l as o,s,u as c}from"./use-rail-drag-BeDwWqzF.js";var l=e(t(),1),u=r(),d=n();function f({kind:e,renderers:t={},actions:n={},titles:r={},disabled:f={},labels:p={},className:m=``}){let{layout:h,setLayout:g}=i(e),[_,v]=(0,l.useState)(!1),[y,b]=(0,l.useState)(null),[x,S]=(0,l.useState)(!1),C=(0,l.useRef)(null),w=(0,l.useRef)(null);(0,l.useEffect)(()=>{if(!_)return;let e=e=>{let t=e.target;C.current?.contains(t)||w.current?.contains(t)||v(!1)},t=e=>{e.key===`Escape`&&v(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[_]);let T=h.filter(t=>a(e,t)),E=h.filter(t=>o(e,t)),D=t=>p[t]||c(e,t).label||t,O=(e,t={})=>(0,d.jsx)(`button`,{type:`button`,className:t.primary?`btn small primary`:`btn small ghost`,title:r[e]||D(e),disabled:!!f[e],onClick:()=>n[e]&&n[e](),children:D(e)},e),k=n=>{if(n===`more`)return(0,d.jsxs)(`button`,{ref:C,type:`button`,className:`btn small ghost`+(_?` is-open`:``),title:r.more||`更多操作`,"aria-haspopup":`menu`,"aria-expanded":_,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();b({top:t.bottom+6,right:Math.max(8,window.innerWidth-t.right)}),v(e=>!e)},children:[D(`more`),` ▾`]},`more`);let i=t[n];return i?(0,d.jsx)(`span`,{className:`ta-slot`,children:i({open:_})},n):O(n,{primary:c(e,n).section===`primary`})};return(0,d.jsxs)(`div`,{className:`ta-bar`+(m?` ${m}`:``),children:[T.map(e=>k(e.id)),_&&y&&(0,u.createPortal)((0,d.jsxs)(`div`,{ref:w,className:`ta-more-menu`,role:`menu`,style:{top:y.top,right:y.right},children:[E.length===0&&(0,d.jsx)(`div`,{className:`ta-more-empty`,children:`没有收纳的工具——可在编排里把按钮收入更多`}),E.map(e=>(0,d.jsx)(`button`,{type:`button`,role:`menuitem`,className:`ta-more-it`,disabled:!!f[e.id],title:r[e.id]||D(e.id),onClick:()=>{v(!1);let t=n[e.id];t&&t()},children:D(e.id)},e.id)),(0,d.jsx)(`div`,{className:`ta-more-sep`}),(0,d.jsx)(`button`,{type:`button`,role:`menuitem`,className:`ta-more-it ta-more-cfg`,onClick:()=>{v(!1),S(!0)},children:`自定义工具栏…`})]}),document.body),x&&(0,u.createPortal)((0,d.jsx)(`div`,{className:`ta-panel-mask`,onClick:()=>S(!1),children:(0,d.jsx)(`div`,{className:`ta-panel-wrap`,onClick:e=>e.stopPropagation(),children:(0,d.jsx)(s,{kind:e,layout:h,setLayout:g,onClose:()=>S(!1)})})}),document.body)]})}export{f as t};
@@ -1 +1 @@
1
- import{c as e}from"./frontmatter-b044qTyx.js";var t=`__GLOBAL__`;function n(e=[]){let t=Array.isArray(e)?e:[];return{pending:t.filter(e=>e.status===`pending`&&!e.deletedAt&&!e.migratedTo),claimed:t.filter(e=>e.status===`claimed`&&!e.deletedAt).slice().reverse(),done:t.filter(e=>e.status===`done`&&!e.deletedAt).slice().reverse(),cancelled:t.filter(e=>e.status===`cancelled`&&!e.deletedAt).slice().reverse(),deleted:t.filter(e=>!!e.deletedAt).slice().reverse(),migrated:t.filter(e=>!!e.migratedTo&&!e.deletedAt)}}function r(e=[]){let t=Array.isArray(e)?e:[],n=[],r=[],i=[],a=[],o=[],s=[];for(let e of t)e.deletedAt?s.push(e):e.status===`claimed`?r.push(e):e.status===`done`?i.push(e):e.status===`cancelled`?a.push(e):e.migratedTo?o.push(e):n.push(e);return[...n,...r.reverse(),...o,...i.reverse(),...a.reverse(),...s.reverse()]}function i(e){return!!(e&&e.boardMark)}function a(t){return e(t)}function o(e=[]){return(Array.isArray(e)?e:[]).filter(e=>!e.deletedAt&&!i(e))}function s(e=[]){return o(e).filter(a).length}function c(e){return[e&&e.id,e&&e.key,e&&e.name].filter(Boolean).map(String)}function l(e,t){return!i(e)||!e?!1:(Array.isArray(t)?t:c(t)).includes(String(e.boardMark))}function u(e=[],t=[],n,r){let i=(t||[]).find(e=>e&&(e.id===n||e.key===n||e.name===n))||null,a={board:i,topic:null,taskRow:null};if(!i||r==null||String(r)===``)return a;let o=new Set((i.repos||[]).map(e=>e&&(e.key||e.id)).filter(Boolean)),s=e=>{let t=e&&e.repo;return[t&&t.key,t&&t.id,e&&e.key].filter(Boolean)},l=c(i);for(let t of e||[]){if(!t||t.isGlobal||o.size&&!s(t).some(e=>o.has(e)))continue;let e=(t.tasks||[]).find(e=>e&&!e.deletedAt&&String(e.id)===String(r));if(e&&(a.topic||(a.topic=t,a.taskRow=e),l.includes(String(e.boardMark||``)))){a.topic=t,a.taskRow=e;break}}return a}export{s as a,l as c,a as i,u as n,r as o,i as r,n as s,t};
1
+ import{c as e}from"./frontmatter-DEIM0yF2.js";var t=`__GLOBAL__`;function n(e=[]){let t=Array.isArray(e)?e:[];return{pending:t.filter(e=>e.status===`pending`&&!e.deletedAt&&!e.migratedTo),claimed:t.filter(e=>e.status===`claimed`&&!e.deletedAt).slice().reverse(),done:t.filter(e=>e.status===`done`&&!e.deletedAt).slice().reverse(),cancelled:t.filter(e=>e.status===`cancelled`&&!e.deletedAt).slice().reverse(),deleted:t.filter(e=>!!e.deletedAt).slice().reverse(),migrated:t.filter(e=>!!e.migratedTo&&!e.deletedAt)}}function r(e=[]){let t=Array.isArray(e)?e:[],n=[],r=[],i=[],a=[],o=[],s=[];for(let e of t)e.deletedAt?s.push(e):e.status===`claimed`?r.push(e):e.status===`done`?i.push(e):e.status===`cancelled`?a.push(e):e.migratedTo?o.push(e):n.push(e);return[...n,...r.reverse(),...o,...i.reverse(),...a.reverse(),...s.reverse()]}function i(e){return!!(e&&e.boardMark)}function a(t){return e(t)}function o(e=[]){return(Array.isArray(e)?e:[]).filter(e=>!e.deletedAt&&!i(e))}function s(e=[]){return o(e).filter(a).length}function c(e){return[e&&e.id,e&&e.key,e&&e.name].filter(Boolean).map(String)}function l(e,t){return!i(e)||!e?!1:(Array.isArray(t)?t:c(t)).includes(String(e.boardMark))}function u(e=[],t=[],n,r){let i=(t||[]).find(e=>e&&(e.id===n||e.key===n||e.name===n))||null,a={board:i,topic:null,taskRow:null};if(!i||r==null||String(r)===``)return a;let o=new Set((i.repos||[]).map(e=>e&&(e.key||e.id)).filter(Boolean)),s=e=>{let t=e&&e.repo;return[t&&t.key,t&&t.id,e&&e.key].filter(Boolean)},l=c(i);for(let t of e||[]){if(!t||t.isGlobal||o.size&&!s(t).some(e=>o.has(e)))continue;let e=(t.tasks||[]).find(e=>e&&!e.deletedAt&&String(e.id)===String(r));if(e&&(a.topic||(a.topic=t,a.taskRow=e),l.includes(String(e.boardMark||``)))){a.topic=t,a.taskRow=e;break}}return a}export{s as a,l as c,a as i,u as n,r as o,i as r,n as s,t};