nx-kv 0.65.2 → 0.65.4

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 (176) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/README.md +15 -37
  3. package/assets/nx-kv/QUICKSTART.md +110 -0
  4. package/assets/nx-kv/references/A05-/344/273/273/345/212/241/351/223/276/344/270/216/345/217/215/351/246/210/346/261/207/346/200/273.md +1 -1
  5. package/assets/nx-kv/references/B02-CLI/351/200/237/346/237/245.md +1 -2
  6. package/package.json +1 -1
  7. package/src/core/config.ts +23 -0
  8. package/src/core/db/settings.ts +1 -1
  9. package/src/core/instruction-template.ts +2 -2
  10. package/src/core/workflow/plugin-registry.ts +1 -1
  11. package/src/core/workflow/project.ts +1 -1
  12. package/src/core/workflow/types.ts +4 -4
  13. package/src/modules/claim/actions/_manifest.generated.ts +20 -0
  14. package/src/modules/{localtask → claim}/actions/localtask-claim.ts +5 -5
  15. package/src/modules/{localtask → claim}/actions/localtask-preview.ts +4 -4
  16. package/src/modules/{promptplug/delivery.ts → claim/assemble.ts} +6 -6
  17. package/src/modules/{tasktool → claim}/get.ts +5 -6
  18. package/src/modules/{tasktool → claim}/groupctx.ts +4 -7
  19. package/src/modules/{tasktool/delivery.ts → claim/host.ts} +7 -7
  20. package/src/modules/claim/index.ts +25 -0
  21. package/src/modules/{tasktool → claim}/panel-escort.ts +2 -2
  22. package/src/modules/{tasktool → claim}/params.ts +3 -3
  23. package/src/modules/{tasktool → claim}/preview.ts +5 -5
  24. package/src/modules/{tasktool → claim}/wait.ts +17 -17
  25. package/src/modules/{tasktool/plugins → claim}/waitgoal-config.ts +3 -24
  26. package/src/modules/docs/actions/_manifest.generated.ts +12 -0
  27. package/src/modules/{repos → docs}/actions/repo-doc-add.ts +3 -2
  28. package/src/modules/{repos → docs}/actions/repo-doc-list.ts +3 -2
  29. package/src/modules/{repos → docs}/actions/repo-doc-remove.ts +3 -2
  30. package/src/modules/{repos → docs}/actions/repo-knowledge.ts +3 -2
  31. package/src/modules/docs/knowledge.ts +8 -16
  32. package/src/modules/goals/index.ts +25 -0
  33. package/src/modules/{tasktool → goals}/plugins/discover.ts +3 -3
  34. package/src/modules/{tasktool → goals}/plugins/index.ts +0 -2
  35. package/src/modules/{tasktool → goals}/plugins/taskgoal-store.ts +2 -2
  36. package/src/modules/{tasktool → goals}/plugins/timegoal-cwd-store.ts +1 -1
  37. package/src/modules/{tasktool → goals}/plugins/timegoal-store.ts +3 -3
  38. package/src/modules/{tasktool → goals}/plugins/timegoal-task-store.ts +2 -2
  39. package/src/modules/{tasktool → goals}/support.ts +3 -1
  40. package/src/modules/localtask/actions/_manifest.generated.ts +0 -9
  41. package/src/modules/localtask/actions/localtask-add.ts +4 -4
  42. package/src/modules/localtask/actions/localtask-attach-note.ts +1 -1
  43. package/src/modules/localtask/actions/localtask-attach.ts +1 -1
  44. package/src/modules/localtask/actions/localtask-attachments.ts +2 -2
  45. package/src/modules/localtask/actions/localtask-cancel.ts +1 -1
  46. package/src/modules/localtask/actions/localtask-chain.ts +1 -1
  47. package/src/modules/localtask/actions/localtask-detach.ts +2 -2
  48. package/src/modules/localtask/actions/localtask-done.ts +1 -1
  49. package/src/modules/localtask/actions/localtask-get.ts +3 -3
  50. package/src/modules/localtask/actions/localtask-list.ts +1 -1
  51. package/src/modules/localtask/actions/localtask-reopen.ts +5 -5
  52. package/src/modules/localtask/actions/localtask-timegoalLog.ts +1 -1
  53. package/src/modules/localtask/actions/localtask-topic-removeMany.ts +1 -1
  54. package/src/modules/localtask/actions/localtask-update.ts +3 -3
  55. package/src/modules/localtask/{bus → infra/bus}/index.ts +1 -1
  56. package/src/modules/localtask/{engine.ts → infra/engine.ts} +1 -1
  57. package/src/modules/localtask/{events.ts → infra/events.ts} +3 -3
  58. package/src/modules/localtask/{mutator → infra/mutator}/index.ts +2 -2
  59. package/src/modules/localtask/{mutator → infra/mutator}/validate.ts +4 -4
  60. package/src/modules/localtask/{repo → infra/repo}/goals.ts +2 -2
  61. package/src/modules/localtask/{repo → infra/repo}/index.ts +1 -1
  62. package/src/modules/localtask/{repo → infra/repo}/links.ts +2 -2
  63. package/src/modules/localtask/{repo → infra/repo}/open.ts +4 -4
  64. package/src/modules/localtask/{repo → infra/repo}/presence.ts +1 -1
  65. package/src/modules/localtask/{repo → infra/repo}/rows.ts +1 -1
  66. package/src/modules/localtask/{repo → infra/repo}/settings.ts +5 -5
  67. package/src/modules/localtask/{repo → infra/repo}/snapshot.ts +9 -7
  68. package/src/modules/localtask/{repo → infra/repo}/tasks.ts +82 -4
  69. package/src/modules/localtask/{repo → infra/repo}/topics.ts +3 -3
  70. package/src/modules/localtask/{repo-ctx.ts → infra/repo-ctx.ts} +1 -1
  71. package/src/modules/localtask/{scheduler → infra/scheduler}/index.ts +1 -1
  72. package/src/modules/localtask/{scheduler → infra/scheduler}/state-drive.ts +4 -4
  73. package/src/modules/localtask/{store → infra/store}/file-adapter.ts +2 -2
  74. package/src/modules/localtask/{store → infra/store}/index.ts +4 -4
  75. package/src/modules/localtask/{store → infra/store}/memory-adapter.ts +2 -2
  76. package/src/modules/localtask/{store-io.ts → infra/store-io.ts} +1 -1
  77. package/src/modules/localtask/{writes.ts → infra/writes.ts} +3 -3
  78. package/src/modules/{tasktool → localtask/lifecycle}/add.ts +8 -8
  79. package/src/modules/localtask/{deletion.ts → lifecycle/deletion.ts} +4 -4
  80. package/src/modules/localtask/{task-lifecycle.ts → lifecycle/task-lifecycle.ts} +18 -19
  81. package/src/modules/localtask/{task-ops.ts → lifecycle/task-ops.ts} +14 -14
  82. package/src/modules/localtask/{task-remove.ts → lifecycle/task-remove.ts} +4 -4
  83. package/src/modules/localtask/{task-templates.ts → lifecycle/task-templates.ts} +2 -2
  84. package/src/modules/localtask/{task-view.ts → lifecycle/task-view.ts} +14 -13
  85. package/src/modules/localtask/{topics.ts → lifecycle/topics.ts} +7 -7
  86. package/src/modules/{tasktool → localtask/lifecycle}/update.ts +6 -6
  87. package/src/modules/{tasktool → localtask/ops}/attach-resource.ts +4 -4
  88. package/src/modules/{tasktool → localtask/ops}/attach-template.ts +3 -3
  89. package/src/modules/{tasktool → localtask/ops}/attach.ts +11 -11
  90. package/src/modules/localtask/{board-target.ts → ops/board-target.ts} +1 -1
  91. package/src/modules/{tasktool → localtask/ops}/doc-inline.ts +3 -3
  92. package/src/modules/{tasktool → localtask/ops}/group-store.ts +3 -3
  93. package/src/modules/localtask/service.ts +16 -16
  94. package/src/modules/localtask/{action-render.ts → ui/action-render.ts} +2 -2
  95. package/src/modules/localtask/{panel-guard.ts → ui/panel-guard.ts} +1 -1
  96. package/src/modules/localtask/{panel-presence.ts → ui/panel-presence.ts} +7 -7
  97. package/src/modules/localtask/waiters.ts +2 -2
  98. package/src/modules/localtask/waiting.ts +1 -1
  99. package/src/modules/promptplug/factory.ts +2 -2
  100. package/src/modules/promptplug/index.ts +5 -7
  101. package/src/modules/promptplug/plugins/attachment.ts +1 -1
  102. package/src/modules/promptplug/plugins/context.ts +9 -20
  103. package/src/modules/promptplug/plugins/goal-prompt.ts +1 -1
  104. package/src/modules/repos/actions/_manifest.generated.ts +0 -12
  105. package/src/modules/repos/service/crud.ts +1 -1
  106. package/src/runtime/cli.ts +1 -1
  107. package/src/runtime/registry.ts +4 -2
  108. package/src/{modules/tasktool → shared}/delivery-text.ts +5 -4
  109. package/src/shared/feedback-text.ts +80 -20
  110. package/src/shared/task-status.ts +42 -0
  111. package/src/web/frontend/api/cli-tree.json +202 -217
  112. package/src/web/frontend/api/client.generated.ts +141 -139
  113. package/src/web/frontend/modules/board/ack-nodes.ts +10 -13
  114. package/src/web/frontend/modules/board/reopen-text.ts +5 -0
  115. package/src/web/frontend/modules/md/styles/editor.css +8 -0
  116. package/src/web/public/assets/{bar-Dc5Tq1eE.js → bar-kaVB6FAa.js} +1 -1
  117. package/src/web/public/assets/{board-view-BVennxTs.js → board-view-Cwot54HC.js} +1 -1
  118. package/src/web/public/assets/{composer-launch-fp2IzGzQ.js → composer-launch-BMTU-BD9.js} +1 -1
  119. package/src/web/public/assets/{composer-panel-Dh681iO6.js → composer-panel-BF6gjNXv.js} +1 -1
  120. package/src/web/public/assets/{dag-DnaU0I_z.js → dag-BRE33yI8.js} +1 -1
  121. package/src/web/public/assets/dir-B0IW4NIn.js +3 -0
  122. package/src/web/public/assets/{doc-DRSKD0Re.js → doc-DsRb-4WT.js} +1 -1
  123. package/src/web/public/assets/frontmatter-Bcseml1q.js +2 -0
  124. package/src/web/public/assets/{group-Dc3ZgW24.js → group-CS8VP6z0.js} +1 -1
  125. package/src/web/public/assets/{index-Bg0m8gbJ.js → index-BT2y9cTX.js} +2 -2
  126. package/src/web/public/assets/{index-BIVxGd6t.css → index-DSAamoav.css} +1 -1
  127. package/src/web/public/assets/{md-history-DNtgaIdH.js → md-history-CJ1N9-Jf.js} +1 -1
  128. package/src/web/public/assets/{md-parse-C9Vd6ejP.js → md-parse-DAYCREP1.js} +1 -1
  129. package/src/web/public/assets/{model-CtG2jIDv.js → model-TD5kGXzR.js} +1 -1
  130. package/src/web/public/assets/{overview-C68QpcT9.js → overview-Bsq58sDd.js} +1 -1
  131. package/src/web/public/assets/{progress-CEmAFxo9.js → progress-B4DfpsyS.js} +1 -1
  132. package/src/web/public/assets/{refs-TzxZYy7T.js → refs-DIiA_49Z.js} +1 -1
  133. package/src/web/public/assets/{repo-form-modal-Dg3hJWUV.js → repo-form-modal-DChK4NSX.js} +1 -1
  134. package/src/web/public/assets/{repos-uNqSR5YB.js → repos-PGFYkUgf.js} +1 -1
  135. package/src/web/public/assets/{route-crumb-C4DgkJ8G.js → route-crumb-SiMi2C_T.js} +1 -1
  136. package/src/web/public/assets/{status-tag-8cLH8hl9.js → status-tag-C9YVBvQh.js} +1 -1
  137. package/src/web/public/assets/task-BL5uxmJh.js +11 -0
  138. package/src/web/public/assets/{task-row-CRjuAfKW.js → task-row-cE7qblNK.js} +1 -1
  139. package/src/web/public/assets/{task-utils-DAPxKm4c.js → task-utils-cBR6Gj_c.js} +8 -7
  140. package/src/web/public/assets/{templates-DNiGvmdq.js → templates-Cfn3Xmsf.js} +3 -3
  141. package/src/web/public/assets/{use-rail-drag-DxIYcszo.js → use-rail-drag-Boxl7pOG.js} +1 -1
  142. package/src/web/public/index.html +11 -11
  143. package/src/core/workflow/edges.ts +0 -28
  144. package/src/core/workflow/layout.ts +0 -118
  145. package/src/modules/localtask/actions/localtask-wait.ts +0 -41
  146. package/src/modules/tasktool/facade/get.ts +0 -54
  147. package/src/modules/tasktool/facade/index.ts +0 -4
  148. package/src/modules/tasktool/facade/submit.ts +0 -61
  149. package/src/modules/tasktool/facade/wait.ts +0 -3
  150. package/src/modules/tasktool/getloop.ts +0 -2
  151. package/src/modules/tasktool/index.ts +0 -24
  152. package/src/modules/tasktool/plugins/runtime.ts +0 -73
  153. package/src/modules/tasktool/plugins/waitgoal.ts +0 -71
  154. package/src/web/public/assets/dir-d16q1GLe.js +0 -3
  155. package/src/web/public/assets/frontmatter-CN6IlxWU.js +0 -2
  156. package/src/web/public/assets/task-DuFOXLPC.js +0 -11
  157. /package/src/modules/{tasktool → goals}/actions/_manifest.generated.ts +0 -0
  158. /package/src/modules/{tasktool → goals}/actions/timegoal-check.ts +0 -0
  159. /package/src/modules/{tasktool → goals}/actions/timegoal-clear.ts +0 -0
  160. /package/src/modules/{tasktool → goals}/actions/timegoal-list.ts +0 -0
  161. /package/src/modules/{tasktool → goals}/actions/timegoal-log.ts +0 -0
  162. /package/src/modules/{tasktool → goals}/actions/timegoal-prune.ts +0 -0
  163. /package/src/modules/{tasktool → goals}/actions/timegoal-set.ts +0 -0
  164. /package/src/modules/{tasktool → goals}/actions/timegoal-show.ts +0 -0
  165. /package/src/modules/{tasktool → goals}/actions/timegoal-update.ts +0 -0
  166. /package/src/modules/{tasktool → goals}/plugins/base.ts +0 -0
  167. /package/src/modules/{tasktool → goals}/plugins/blockgoal.ts +0 -0
  168. /package/src/modules/{tasktool → goals}/plugins/container.ts +0 -0
  169. /package/src/modules/{tasktool → goals}/plugins/taskgoal.ts +0 -0
  170. /package/src/modules/{tasktool → goals}/plugins/timegoal-core-store.ts +0 -0
  171. /package/src/modules/{tasktool → goals}/plugins/timegoal.ts +0 -0
  172. /package/src/modules/{tasktool → goals}/taskgoal.ts +0 -0
  173. /package/src/modules/{tasktool → goals}/timegoal.ts +0 -0
  174. /package/src/modules/localtask/{store → infra/store}/topic-adapter.ts +0 -0
  175. /package/src/modules/localtask/{action-flags.ts → ui/action-flags.ts} +0 -0
  176. /package/src/modules/localtask/{contract-views.ts → ui/contract-views.ts} +0 -0
@@ -1,6 +1,6 @@
1
- // tasktool/add.js —— 「派任务」的编排(从 localtask/index.js 的 action run 整体迁入)。
1
+ // localtask/add.ts —— 「派任务」的编排(从 localtask/index.js 的 action run 整体迁入)。
2
2
  //
3
- // 边界(与 get.js / wait.js 同一条分工:tasktool = 任务工具语义,localtask = 队列本体):
3
+ // 边界(与 claim/get.js 同一条分工:localtask = 队列本体 + 派任务编排):
4
4
  // 队列读写、落盘、唤醒注册表都在 localtask/service.js;这里只做**编排**——
5
5
  // 落点与 frontmatter 的统一解析 → 任务级 timegoal 声明归一 → 委托 service.addTask
6
6
  // 入队(有 wait 在等则即时投递)。
@@ -13,12 +13,12 @@
13
13
  //(认得出归属就补介绍引用、落点跟到项目队列)。
14
14
  //
15
15
  // 至此三个任务动词(领 get / 等 wait / 派 add)同构:action 层一律一行委托,
16
- // 编排住在 tasktool/<动词>.js,队列本体只有 service.js 一处。
17
- import { badInput } from '../../core/errors.js';
18
- import { addTask, normalizeCwd } from '../localtask/service.js';
19
- import { applyGroupFields, parseFrontmatter } from '../../shared/frontmatter.js';
20
- import { resolveGroupTarget } from '../localtask/board-target.js';
21
- import { normalizedGroupStore } from './group-store.js';
16
+ // 编排住在本域(add.js / update.js),队列本体只有 service.js 一处。
17
+ import { badInput } from '../../../core/errors.js';
18
+ import { addTask, normalizeCwd } from '../service.js';
19
+ import { applyGroupFields, parseFrontmatter } from '../../../shared/frontmatter.js';
20
+ import { resolveGroupTarget } from '../ops/board-target.js';
21
+ import { normalizedGroupStore } from '../ops/group-store.js';
22
22
 
23
23
  export interface SubmitTaskOptions {
24
24
  /** 任务正文(Markdown,frontmatter 允许在头部) */
@@ -4,9 +4,9 @@
4
4
  // 删除 = 软删 topics 行(deleted_at 打标;任务/依赖/presence 保留,同名目录再出现即恢复)。
5
5
  // 全局池例外:同一个 key 永远会再出现,软删会被下一次 ensureTopic 复活成「没删掉」,
6
6
  // 所以 force 清空全局池走真删(FK 级联清任务)。
7
- import { badInput } from '../../core/errors.js';
8
- import { isGlobalKey, normalizeCwd, resolveTopicKey } from './paths.js';
9
- import { openLocaltaskStore as openStore, topics as topicsRepo } from './repo/index.js';
7
+ import { badInput } from '../../../core/errors.js';
8
+ import { isGlobalKey, normalizeCwd, resolveTopicKey } from '../paths.js';
9
+ import { openLocaltaskStore as openStore, topics as topicsRepo } from '../infra/repo/index.js';
10
10
  import { isLiveWaiting, isPending, topicView } from './task-view.js';
11
11
  // ─── 删除判定:四条删除路径共用同一套规则 ──────────────────────────────
12
12
  //
@@ -106,7 +106,7 @@ export async function removeTopic({ cwd: rawCwd, key: rawKey, force = false }: R
106
106
  openStore();
107
107
  const t = topicsRepo.getTopic(key);
108
108
  if (!t) {
109
- const { notFound } = await import('../../core/errors.js');
109
+ const { notFound } = await import('../../../core/errors.js');
110
110
  throw notFound(`主题不存在(key ${key})`);
111
111
  }
112
112
  // 删除判定只写一份(deleteGuard):全局共享池 / 等待中 / 有未领取任务 → 都要 --force。
@@ -1,21 +1,21 @@
1
1
  // (#54 自 service.js 拆出)队列出口的任务生命周期:consumeFirstPending(D-first 领取,
2
2
  // 跳过被依赖/闸门挡住的 pending)、completeTask(完成门禁:timegoal 未到点返回 blocked
3
3
  // 业务值而不是抛错)、reopenTask(用户修改反馈 → **就地重开原任务**,历史进 history 链)。
4
- import { badInput, notFound } from '../../core/errors.js';
5
- import { formatDuration, renderInstruction } from '../../core/instruction-template.js';
6
- import { activeTemplateOf } from '../promptplug/index.js';
7
- import { taskGoalTemplateCtx } from '../promptplug/plugins/goal-prompt.js';
8
- import { preserveFrontmatter } from '../../shared/frontmatter.js';
4
+ import { badInput, notFound } from '../../../core/errors.js';
5
+ import { formatDuration, renderInstruction } from '../../../core/instruction-template.js';
6
+ import { activeTemplateOf } from '../../promptplug/index.js';
7
+ import { taskGoalTemplateCtx } from '../../promptplug/plugins/goal-prompt.js';
8
+ import { preserveFrontmatter } from '../../../shared/frontmatter.js';
9
9
  import {
10
10
  FEEDBACK_HEADING,
11
11
  PLAIN_FEEDBACK_HEADING,
12
12
  appendFeedback,
13
13
  appendAckFeedback,
14
- } from '../../shared/feedback-text.js';
15
- import { findFirstReadyPending } from './dag.js';
14
+ } from '../../../shared/feedback-text.js';
15
+ import { findFirstReadyPending } from '../dag.js';
16
16
  import { basename } from 'node:path';
17
- import { isGlobalKey, resolveTaskKey, topicKeyFor } from './paths.js';
18
- import { normalizeSummary, normalizeText, stampNow } from './store-io.js';
17
+ import { isGlobalKey, resolveTaskKey, topicKeyFor } from '../paths.js';
18
+ import { normalizeSummary, normalizeText, stampNow } from '../infra/store-io.js';
19
19
  import { normalizeTask, foreignResolver, isPending } from './task-view.js';
20
20
  import {
21
21
  openLocaltaskStore as openStore,
@@ -23,7 +23,7 @@ import {
23
23
  tasks as tasksRepo,
24
24
  links as linksRepo,
25
25
  txw as tx,
26
- } from './repo/index.js';
26
+ } from '../infra/repo/index.js';
27
27
 
28
28
  /** supersederRef 的出站形状(取代者的绝对地址)。 */
29
29
  interface SupersederRef {
@@ -233,8 +233,7 @@ export async function reopenTask({
233
233
  } else {
234
234
  // supersededBy 必须带上绝对地址:搬到别的队列后,光写目标队列的 seq 会被
235
235
  // 顺链逻辑按源主题解析到一条完全无关的任务上。
236
- tasksRepo.updateTask(curTopic.id, want, {
237
- status: 'cancelled',
236
+ tasksRepo.tombstoneAsCancelled(curTopic.id, want, {
238
237
  supersededBy: hostKey === srcKey ? inserted.id : `${hostKey}:${inserted.id}`,
239
238
  });
240
239
  }
@@ -344,13 +343,13 @@ export async function completeTask({ cwd: rawCwd, key: rawKey, id, summary: rawS
344
343
  id: want,
345
344
  key,
346
345
  name: t.name,
347
- hint: '任务还没被领取——先 wait/get 领取,干完再标完成',
346
+ hint: '任务还没被领取——先 get 领取,干完再标完成',
348
347
  };
349
348
  }
350
349
  let goal: Record<string, any> | null = null;
351
350
  if (task.timegoal) {
352
- // 门禁:查任务级 goal。动态 import——tasktool/wait.js 静态引用本模块,这里走动态避免环。
353
- const { taskGoalState, recordTaskCheck } = await import('../tasktool/taskgoal.js');
351
+ // 门禁:查任务级 goal。动态 import——claim/wait.ts 静态引用本模块,这里走动态避免环。
352
+ const { taskGoalState, recordTaskCheck } = await import('../../goals/taskgoal.js');
354
353
  const st = await taskGoalState({ topicKey: key, taskId: want });
355
354
  if (st.hasGoal && !st.reached) {
356
355
  // 「未到点就想 done」的拦截提示(#90):模板与其它区块同源,是 doneguard
@@ -411,11 +410,11 @@ export async function completeTask({ cwd: rawCwd, key: rawKey, id, summary: rawS
411
410
  }
412
411
  // 单一写路径:完成 → Mutator 标 success + 调度一轮(fail-open)
413
412
  try {
414
- const { markTaskSuccess } = await import('./writes.js');
413
+ const { markTaskSuccess } = await import('../infra/writes.js');
415
414
  await markTaskSuccess(key, want);
416
415
  } catch {
417
416
  try {
418
- const { refreshTopicAfterComplete } = await import('./engine.js');
417
+ const { refreshTopicAfterComplete } = await import('../infra/engine.js');
419
418
  await refreshTopicAfterComplete(key);
420
419
  } catch {
421
420
  /* ignore */
@@ -455,5 +454,5 @@ export async function completeTask({ cwd: rawCwd, key: rawKey, id, summary: rawS
455
454
  // 那不是"到点自动取消",那是把目录焊死了。这种情况该由 agent 自己的
456
455
  // `timegoal check`(reached:true)去处理。
457
456
  //
458
- // (goal 探针与目标上下文已随 wait 编排迁往 tasktool/wait.js——任务工具语义归
459
- // tasktool,队列本体不再依赖 timegoal 模块。)
457
+ // (goal 探针与目标上下文已随阻塞编排迁往 claim/wait.ts——任务工具语义归
458
+ // goals 域,队列本体不再依赖 timegoal 模块。)
@@ -1,15 +1,15 @@
1
1
  // (#54 自 service.js 拆出)单条任务的查/增/改:getTask、addTask(waiter 唤醒链 +
2
2
  // 全局池 FIFO 投递 + ignoredCwd 如实回带)、updateTask(正文/时间目标/DAG 依赖/改归属搬家)。
3
- import { badInput, notFound } from '../../core/errors.js';
4
- import { parseFrontmatter, preserveFrontmatter } from '../../shared/frontmatter.js';
5
- import { sanitizeTaskGoal } from '../tasktool/taskgoal.js';
6
- import { normalizeBlockBy, isReadyToClaim } from './dag.js';
7
- import { MAX_TEXT, normalizeSummary, normalizeText } from './store-io.js';
8
- import { openLocaltaskStore as openStore, topics as topicsRepo, tasks as tasksRepo, links as linksRepo, txw as tx, db } from './repo/index.js';
9
- import { GLOBAL_KEY, GLOBAL_NAME, GLOBAL_CWD, isGlobalKey, normalizeCwd, resolveTaskKey, topicKeyFor } from './paths.js';
3
+ import { badInput, notFound } from '../../../core/errors.js';
4
+ import { parseFrontmatter, preserveFrontmatter } from '../../../shared/frontmatter.js';
5
+ import { sanitizeTaskGoal } from '../../goals/taskgoal.js';
6
+ import { normalizeBlockBy, isReadyToClaim } from '../dag.js';
7
+ import { MAX_TEXT, normalizeSummary, normalizeText } from '../infra/store-io.js';
8
+ import { openLocaltaskStore as openStore, topics as topicsRepo, tasks as tasksRepo, links as linksRepo, txw as tx, db } from '../infra/repo/index.js';
9
+ import { GLOBAL_KEY, GLOBAL_NAME, GLOBAL_CWD, isGlobalKey, normalizeCwd, resolveTaskKey, topicKeyFor } from '../paths.js';
10
10
  import { normalizeTask, foreignResolver, queueRelationsOf, relocateTask, resolveForkRef } from './task-view.js';
11
- import { takeTopicWaiter, takeGlobalWaiter } from './waiters.js';
12
- import { presence as presenceRepo } from './repo/index.js';
11
+ import { takeTopicWaiter, takeGlobalWaiter } from '../waiters.js';
12
+ import { presence as presenceRepo } from '../infra/repo/index.js';
13
13
 
14
14
  /** 任务寻址入参(--cwd/--key + --id)。 */
15
15
  export interface TaskAddress {
@@ -69,7 +69,7 @@ export async function getTask({ cwd: rawCwd, key: rawKey, id }: TaskAddress = {}
69
69
  const t = topicsRepo.getTopic(key);
70
70
  const task = t && t.tasks.find((x: any) => Number(x.id) === want);
71
71
  if (!task) {
72
- const { notFound } = await import('../../core/errors.js');
72
+ const { notFound } = await import('../../../core/errors.js');
73
73
  throw notFound(`主题「${t ? t.name : cwd}」里没有 #${want} 任务`);
74
74
  }
75
75
  // key 一并回带:附件标注按 (topic.key, seq) 查 task_attach,不必再反查队列。
@@ -247,7 +247,7 @@ export async function addTask({
247
247
  // DAG 单一写路径:闸门/依赖经 Mutator 投影(fail-open,不挡入队)
248
248
  if (!toGlobal && (task.blocksFollowing || (task.blockBy && task.blockBy.length))) {
249
249
  try {
250
- const { syncNewTaskDag } = await import('./writes.js');
250
+ const { syncNewTaskDag } = await import('../infra/writes.js');
251
251
  await syncNewTaskDag(key, task);
252
252
  } catch {
253
253
  /* ignore */
@@ -308,7 +308,7 @@ export async function updateTask({
308
308
  const t = topicsRepo.getTopic(key);
309
309
  const task = t && t.tasks.find((x: any) => Number(x.id) === want);
310
310
  if (!task) {
311
- const { notFound } = await import('../../core/errors.js');
311
+ const { notFound } = await import('../../../core/errors.js');
312
312
  throw notFound(`主题「${t ? t.name : cwd}」里没有 #${want} 任务`);
313
313
  }
314
314
  let goalChanged: string | null = null; // 'set' | 'cleared' | null(render 与前端提示用)
@@ -416,7 +416,7 @@ export async function updateTask({
416
416
  });
417
417
  if (hasDagInput) {
418
418
  try {
419
- const { syncTaskDagUpdate } = await import('./writes.js');
419
+ const { syncTaskDagUpdate } = await import('../infra/writes.js');
420
420
  await syncTaskDagUpdate(host.key, Number(hostTask.id), { blockBy, clearBlockBy, blocksFollowing });
421
421
  } catch {
422
422
  /* fail-open */
@@ -527,7 +527,7 @@ export async function setPlanStatus({
527
527
  if (target === 'pending' && from !== 'plan') {
528
528
  throw badInput(`只有草稿能转回待领取(#${want} 现在是 ${from})`);
529
529
  }
530
- const updated = tasksRepo.updateTaskByKey(key, want, { status: target });
530
+ const updated = tasksRepo.switchPlanStatus(t!.id, want, target as 'plan' | 'pending');
531
531
  if (!updated) throw notFound(`任务不存在: #${want}`);
532
532
  topicsRepo.updateTopic(key, { bumpRevision: true });
533
533
  return {
@@ -4,9 +4,9 @@
4
4
  // T03:写入走 repo.tasks / repo.topics 的窄方法。**顺序(优先级)不在 seq 里** ——
5
5
  // seq 是对外编号、不可变(trg_tasks_identity 锁死),拖动排序改的是
6
6
  // topics.ext.ext_task_order(JSON 数组序的等价物,见 repo/topics.js 顶部说明)。
7
- import { badInput, notFound as notFoundImpl } from '../../core/errors.js';
8
- import { normalizeCwd, resolveTaskKey } from './paths.js';
9
- import { openLocaltaskStore as openStore, topics as topicsRepo, tasks as tasksRepo, txw as tx } from './repo/index.js';
7
+ import { badInput, notFound as notFoundImpl } from '../../../core/errors.js';
8
+ import { normalizeCwd, resolveTaskKey } from '../paths.js';
9
+ import { openLocaltaskStore as openStore, topics as topicsRepo, tasks as tasksRepo, txw as tx } from '../infra/repo/index.js';
10
10
  import { normalizeTask, topicView } from './task-view.js';
11
11
 
12
12
  /** 任务操作的公共入参(--cwd/--key + id(s))。 */
@@ -192,7 +192,7 @@ export async function cancelTasks({ cwd: rawCwd, key: rawKey, ids }: CancelClose
192
192
  });
193
193
  continue;
194
194
  }
195
- const next = tasksRepo.updateTask(topicId!, want, { status: 'cancelled' });
195
+ const next = tasksRepo.tombstoneAsCancelled(topicId!, want);
196
196
  cancelled.push(normalizeTask(next));
197
197
  }
198
198
  if (cancelled.length) topicsRepo.updateTopic(key, { bumpRevision: true });
@@ -15,7 +15,7 @@ export const DEFAULT_ACK_PROMPT =
15
15
  import {
16
16
  DEFAULT_APPEND_MODE,
17
17
  APPEND_MODES,
18
- } from '../../shared/prompt-blocks.js';
18
+ } from '../../../shared/prompt-blocks.js';
19
19
 
20
20
  /** 交付上下文模板(任务 #62)的长度上限——防把整本书塞进设置。 */
21
21
  export const MAX_DELIVERY_TEMPLATE_LEN = 8000;
@@ -31,7 +31,7 @@ export function clampDeliveryTemplate(v: unknown): string {
31
31
  // ─── 附件段提示词(settings.attachTemplate,任务 #82)──────────────────
32
32
  //
33
33
  // 交付里的〔附件〕段(附件清单 + 本地路径 + 拉取 SOP)原先硬编码在
34
- // tasktool/attach.js 的 attachmentInstruction。模板化后:
34
+ // localtask/attach.ts 的 attachmentInstruction。模板化后:
35
35
  // - 空串 = 用内置默认(**不是关掉**——附件段带本地路径,关掉 agent 就找不到文件);
36
36
  // - 新语法:{{task.id}} {{task.text}} {{attach.count}}、
37
37
  // `{{#each attach.list}}`(按 kind 分支的结构化清单 + 各类型子对象);
@@ -2,17 +2,17 @@
2
2
  // normalizeTask(含 ready 徽标)、topicView、跨队列依赖解析器(foreignResolver)、
3
3
  // 队列内关系清单(queueRelationsOf)与搬家(relocateTask)。
4
4
  import { existsSync } from 'node:fs';
5
- import { badInput, notFound } from '../../core/errors.js';
6
- import { sanitizeTaskGoal } from '../tasktool/taskgoal.js';
7
- import { normalizeBlockBy, isReadyToClaim } from './dag.js';
8
- import { isGlobalKey, topicKeyFor, resolveTaskKey } from './paths.js';
9
- import { parseStampMs, stampNow } from './store-io.js';
10
- import { topics as topicsRepo, tasks as tasksRepo, links as linksRepo, db } from './repo/index.js';
11
- import { parseFrontmatter } from '../../shared/frontmatter.js';
12
- import { isPending } from '../../shared/task-status.js';
13
- import type { ReadyOpts } from '../../core/workflow/readiness.js';
14
- import type { TaskObject } from './repo/rows.js';
15
- import type { ChainLinkNode } from './repo/links.js';
5
+ import { badInput, notFound } from '../../../core/errors.js';
6
+ import { sanitizeTaskGoal } from '../../goals/taskgoal.js';
7
+ import { normalizeBlockBy, isReadyToClaim } from '../dag.js';
8
+ import { isGlobalKey, topicKeyFor, resolveTaskKey } from '../paths.js';
9
+ import { parseStampMs, stampNow } from '../infra/store-io.js';
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
+ import { isPending } from '../../../shared/task-status.js';
13
+ import type { ReadyOpts } from '../../../core/workflow/readiness.js';
14
+ import type { TaskObject } from '../infra/repo/rows.js';
15
+ import type { ChainLinkNode } from '../infra/repo/links.js';
16
16
 
17
17
  /** normalizeTask / topicView 的入参任务行(JSON 形态 → any)。 */
18
18
  export type TaskInput = any;
@@ -111,10 +111,11 @@ export function relocateTask(fromTopic: any, seq: number | string, moveTo: any):
111
111
  });
112
112
  const newId = inserted.id;
113
113
 
114
- // 2. 源任务软删 + cancelled(tombstone:留一行"搬去哪了"的记录)
114
+ // 2. 源任务定格:status 走 tombstone 语义函数(原子守卫,done 保持 done);
115
+ // 软删与"搬去哪了"审计字段照旧走通用 patch——它们不是状态。
116
+ tasksRepo.tombstoneAsCancelled(fromTopic.id, oldSeq);
115
117
  tasksRepo.updateTask(fromTopic.id, oldSeq, {
116
118
  deletedAt: stampNow(),
117
- status: 'cancelled',
118
119
  moveFrom: { key: toKey, seq: newId, at: stampNow() },
119
120
  });
120
121
 
@@ -4,15 +4,15 @@
4
4
  // T03:存储切到 repo/(SQLite)。本文件不再直接读写任何存储形状 ——
5
5
  // 读走 repo.topics 的 JSON 形态投影,写走窄方法(一个动作一个事务)。
6
6
  import { existsSync } from 'node:fs';
7
- import { badInput } from '../../core/errors.js';
8
- import { normalizeCwd } from './paths.js';
9
- import { normalizeSummary } from './store-io.js';
10
- import { openLocaltaskStore as openStore, topics as topicsRepo, settings as settingsRepo, txw as tx } from './repo/index.js';
11
- import { DEFAULT_TIMEOUT_SEC, MAX_TIMEOUT_SEC } from './repo/settings.js';
7
+ import { badInput } from '../../../core/errors.js';
8
+ import { normalizeCwd } from '../paths.js';
9
+ import { normalizeSummary } from '../infra/store-io.js';
10
+ import { openLocaltaskStore as openStore, topics as topicsRepo, settings as settingsRepo, txw as tx } from '../infra/repo/index.js';
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';
13
+ import { stripFrontmatter } from '../../../shared/frontmatter.js';
14
14
  import { deleteGuard } from './deletion.js';
15
- import { repoContextIndex, repoCtxOf } from './repo-ctx.js';
15
+ import { repoContextIndex, repoCtxOf } from '../infra/repo-ctx.js';
16
16
 
17
17
  /** addTopic / pruneTopics 等主题操作的入参(HTTP/CLI body → any)。 */
18
18
  export type TopicOpInput = any;
@@ -1,4 +1,4 @@
1
- // tasktool/update.js —— 「改任务」的编排:改正文 + **改归属项目即搬家**。
1
+ // localtask/update.ts —— 「改任务」的编排:改正文 + **改归属项目即搬家**。
2
2
  //
3
3
  // 派任务(add.js 的 submitTask)有一条铁律:**归属决定落点**——`--project X` 的任务
4
4
  // 落进 X 的登记路径队列。但这条规则此前只在提交那一刻生效:用户提交后发现归属填错、
@@ -9,11 +9,11 @@
9
9
  // 任务搬进新项目的登记路径队列(service 的 moveTo),frontmatter 的介绍引用一并刷新。
10
10
  // 落点解析与 add.js 共用同一份实现(board-target.resolveGroupTarget + group-store),
11
11
  // 不另起炉灶。
12
- import { badInput } from '../../core/errors.js';
13
- import { applyGroupFields, parseFrontmatter, preserveFrontmatter } from '../../shared/frontmatter.js';
14
- import { resolveGroupTarget } from '../localtask/board-target.js';
15
- import * as service from '../localtask/service.js';
16
- import { normalizedGroupStore } from './group-store.js';
12
+ import { badInput } from '../../../core/errors.js';
13
+ import { applyGroupFields, parseFrontmatter, preserveFrontmatter } from '../../../shared/frontmatter.js';
14
+ import { resolveGroupTarget } from '../ops/board-target.js';
15
+ import * as service from '../service.js';
16
+ import { normalizedGroupStore } from '../ops/group-store.js';
17
17
 
18
18
  /** 改任务 / 重开的参数(透传 localtask/service,形状由 service 层校验;寻址三件套对齐 TaskAddress) */
19
19
  export interface UpdateTaskParams {
@@ -1,4 +1,4 @@
1
- // tasktool/attach-resource.js —— 附件的「资源视图模型」:关系表行 → 展示/取用信息。
1
+ // localtask/attach-resource.ts —— 附件的「资源视图模型」:关系表行 → 展示/取用信息。
2
2
  //
3
3
  // 资源类型只有五种(用户口径):file(含图片)/ url / task / ref / mdfile。
4
4
  // 旧数据里 kind='image' 或没有 kind 的一律按 file 处理(向后兼容)。
@@ -8,8 +8,8 @@
8
8
  // file 型资源的可达性(本机副本绝对路径 vs 仅 fileId)由 fileStateOf 给出,
9
9
  // 调用方(attach.js 的编排层)负责把本机附件仓的命中结果喂进来。
10
10
  import { existsSync } from 'node:fs';
11
- import { isImageName } from '../../core/filekind.js';
12
- import { stripFrontmatter } from '../../shared/frontmatter.js';
11
+ import { isImageName } from '../../../core/filekind.js';
12
+ import { stripFrontmatter } from '../../../shared/frontmatter.js';
13
13
 
14
14
  const KIND_LABEL: Record<string, string> = { file: '附件', url: '链接', task: '任务', ref: '文档', mdfile: 'md', folder: '文件夹' };
15
15
  const IMAGE_LABEL = '图片';
@@ -338,7 +338,7 @@ export function resourceOf(row: any, lookups: ResourceLookups = {}): any {
338
338
 
339
339
  // ref:文档库里的文档(v7 起 ref 是 DB 实体,没有物理路径)。
340
340
  // 标题口径(#168):**文档标题**(正文首行的 # 标题)优先 —— 服务端在标注层
341
- // (tasktool/attach.js 的 annotateRefTitles)读库补上并覆盖 title/name;
341
+ // (attach.ts 的 annotateRefTitles)读库补上并覆盖 title/name;
342
342
  // 这里先给 desc / 名字占位,读不到标题时前端回落它。
343
343
  const info = lookups.refs && lookups.refs.get(String(meta.refId || row.targetKey || ''));
344
344
  const refId = String(meta.refId || row.targetKey || (info && info.refId) || '');
@@ -1,10 +1,10 @@
1
- // tasktool/attach-template.js —— 交付 instruction〔附件〕段的模板 ctx 与渲染。
1
+ // localtask/attach-template.ts —— 交付 instruction〔附件〕段的模板 ctx 与渲染。
2
2
  //
3
3
  // 输出由模板渲染(内置 DEFAULT_ATTACH_TEMPLATE 或配置模板),保证「配置模板」与
4
4
  // 「内置默认」走同一份 ctx、同一套口径;渲染失败时用最朴素的逐条文本兜底
5
5
  // (fail-open:附件路径必须到达 agent,模板写错不许吞掉附件信息)。
6
- import { renderInstruction } from '../../core/instruction-template.js';
7
- import { isImageName } from '../../core/filekind.js';
6
+ import { renderInstruction } from '../../../core/instruction-template.js';
7
+ import { isImageName } from '../../../core/filekind.js';
8
8
  import { hostOfUrl, kindLabelOf, ORIGIN_LABEL, sizeTextOf, STATUS_LABEL } from './attach-resource.js';
9
9
 
10
10
  /**
@@ -1,4 +1,4 @@
1
- // tasktool/attach.js —— 本地任务链路的附件编排(标注 / 追加 / 清单)。
1
+ // localtask/attach.ts —— 本地任务链路的附件编排(标注 / 追加 / 清单)。
2
2
  //
3
3
  // 背景(任务 #15「localtask 附件功能未实现」):web 编辑器已把附件以
4
4
  // `![名](fileId)` 嵌进正文,但链路的 **agent 侧**对不上——get/wait 交付的
@@ -21,12 +21,12 @@
21
21
  // 本文件只做编排——标注、挂载、清单、解除。
22
22
  import { readFile } from 'node:fs/promises';
23
23
  import { basename, resolve as resolvePath } from 'node:path';
24
- import { badInput } from '../../core/errors.js';
25
- import { contentTypeOf, isImageName } from '../../core/filekind.js';
26
- import { localIndex as localStoreIndex, localResolve, localUpload } from '../../core/localatt.js';
27
- import { getDb } from '../../core/db/index.js';
28
- import { tx } from '../../core/db/tx.js';
29
- import { attachmentsRootFromEnv } from '../../core/paths.js';
24
+ import { badInput } from '../../../core/errors.js';
25
+ import { contentTypeOf, isImageName } from '../../../core/filekind.js';
26
+ import { localIndex as localStoreIndex, localResolve, localUpload } from '../../../core/localatt.js';
27
+ import { getDb } from '../../../core/db/index.js';
28
+ import { tx } from '../../../core/db/tx.js';
29
+ import { attachmentsRootFromEnv } from '../../../core/paths.js';
30
30
  import {
31
31
  deleteAttachment,
32
32
  ensureRefAttachment,
@@ -41,8 +41,8 @@ import {
41
41
  unlinkAttachment,
42
42
  updateAttachmentNote,
43
43
  upsertFileAttachment,
44
- } from '../../core/attachmentdb.js';
45
- import * as service from '../localtask/service.js';
44
+ } from '../../../core/attachmentdb.js';
45
+ import * as service from '../service.js';
46
46
  import { inlineDocContent } from './doc-inline.js';
47
47
  import { fileStateOf, resourceOf, targetLookupsOf, type ResourceLookups } from './attach-resource.js';
48
48
 
@@ -52,7 +52,7 @@ export { attachmentInstruction, attachInstructionOf, attachTemplateCtx } from '.
52
52
  // shared 在模块互依禁列里 → 动态 import(与 getloop/add 的 reposStore 同一惯例)。
53
53
  let todoAttach: any = null;
54
54
  async function todoAttachMod(): Promise<any> {
55
- if (!todoAttach) todoAttach = await import('../../shared/attach.js');
55
+ if (!todoAttach) todoAttach = await import('../../../shared/attach.js');
56
56
  return todoAttach;
57
57
  }
58
58
 
@@ -79,7 +79,7 @@ async function annotateRefTitles(attachments: any[]): Promise<any[]> {
79
79
  if (!refs.length) return attachments;
80
80
  let titles = new Map<string, string>();
81
81
  try {
82
- const { refTitlesOf } = await import('../docs/brief.js');
82
+ const { refTitlesOf } = await import('../../docs/brief.js');
83
83
  titles = await refTitlesOf(refs);
84
84
  } catch {
85
85
  titles = new Map();
@@ -23,7 +23,7 @@
23
23
  // 为什么不能从 cwd 反推项目:--cwd 是「队列地址」,--project 是「归属」——
24
24
  // 两件事。反推等于让地址决定归属,用户以为在挂项目,实际被目录牵着走。
25
25
  // 组内任务必须显式指明组内项目:归属不明就不该静默落在某个目录。
26
- import { badInput } from '../../core/errors.js';
26
+ import { badInput } from '../../../core/errors.js';
27
27
 
28
28
  /** 归一化后的看板形状(外部 JSON → any)。 */
29
29
  export type BoardLike = any;
@@ -1,4 +1,4 @@
1
- // tasktool/doc-inline.js —— 任务级文档绑定的「进原文」(#162)。
1
+ // localtask/doc-inline.ts —— 任务级文档绑定的「进原文」(#162)。
2
2
  //
3
3
  // role='doc' 的 kind=ref 附件 = **文档资料绑定**:交付时把文档全文附进 instruction,
4
4
  // 而不是只给一条 `docs get` 命令——agent 少跑一轮 nx-kv(任务原文口径:
@@ -10,8 +10,8 @@
10
10
  // 经 `readMdfile`(唯一文件读入口)取正文;没登记 → 显式提示 + 给登记命令;
11
11
  // - fail-open:读不到 → 内容留空,清单与取用命令照给,绝不拖垮领取。
12
12
  import { MAX_INLINE_DOC_CHARS } from './attach-resource.js';
13
- import { findMdfileByPath, noBodyReason, readMdfile, refDocById } from '../../core/attachmentdb.js';
14
- import { getDb } from '../../core/db/index.js';
13
+ import { findMdfileByPath, noBodyReason, readMdfile, refDocById } from '../../../core/attachmentdb.js';
14
+ import { getDb } from '../../../core/db/index.js';
15
15
 
16
16
  /** 外部 md 正文:只认已登记的 mdfile(唯一文件读入口)。 */
17
17
  function readExternalViaMdfile(db: any, locator: string): string | null {
@@ -1,15 +1,15 @@
1
- // tasktool/group-store.js —— 仓库/看板登记的**归一化视图**(board + repos)。
1
+ // localtask/group-store.ts —— 仓库/看板登记的**归一化视图**(board + repos)。
2
2
  //
3
3
  // 派任务(add.js)与改任务(update.js)共用一份落点判定:`--project/--board` 要
4
4
  // 解析成「项目登记的路径」才能定落点,而 repos 模块在**模块互依禁列**里
5
- //(localtask/tasktool 不能静态引它)→ 动态 import(add.js 既有惯例)。
5
+ //(localtask 不能静态引它)→ 动态 import(add.js 既有惯例)。
6
6
  //
7
7
  // 输入是 raw repos store,输出喂给 board-target.js 的 resolveGroupTarget:
8
8
  // boards[i] = { id, name, key, memberKeys: string[] } ← 成员键(不是 repoIds)
9
9
  // repos[i] = { key, name, path }
10
10
  let reposMod: any = null;
11
11
  async function reposStore(): Promise<any> {
12
- if (!reposMod) reposMod = await import('../repos/service.js');
12
+ if (!reposMod) reposMod = await import('../../repos/service.js');
13
13
  return reposMod;
14
14
  }
15
15
 
@@ -2,13 +2,13 @@
2
2
  // 领取(含阻塞等待子功能)+ 内嵌弹窗。
3
3
  //
4
4
  // 解决的问题:agent 在一个对话里需要用户继续给任务时,不必结束本轮、等用户去
5
- // 原始输入框打字,而是把 `nx-kv localtask wait --cwd "<工作目录>" --summary "<当前现状>"`
5
+ // 原始输入框打字,而是把 `nx-kv localtask get --cwd "<工作目录>" --timeout N`
6
6
  // 当作 **本轮最后一个动作**调用——命令阻塞、自动打开浏览器弹窗;用户在弹窗/面板回填,
7
7
  // 命令解除阻塞、把新任务作为结果返回给 agent,agent 接着干。
8
8
  //
9
9
  // 关键设计:
10
- // 1. **工作目录即主题,主题拥有队列。** wait 传入工作目录(默认进程 cwd),归一化后
11
- // 作为主题 key;同一目录的多次 wait(即便现状措辞不同)共用同一个任务队列,
10
+ // 1. **工作目录即主题,主题拥有队列。** get 传入工作目录(默认进程 cwd),归一化后
11
+ // 作为主题 key;同一目录的多次阻塞领取共用同一个任务队列,
12
12
  // 不同目录 → 不同主题 → 队列互不串。任务可在一个主题队列里逐条堆积,agent 按序领取。
13
13
  // 2. **全局主题兜底(工作窃取)。** 除按目录划分的本地队列外,还有一个跨目录共享的
14
14
  // 「全局主题」(key '__GLOBAL__'):本地队列取不到 pending 时,任何 wait 都自动去
@@ -29,11 +29,11 @@
29
29
  // 本文件曾是 2400+ 行的 god-file,已按分节拆成本目录的兄弟文件;这里只做
30
30
  // **门面再导出**——对外 API 路径('./service.js' 静态引用与动态 import)全部
31
31
  // 不变;模块内部依赖方向(单向无环)见各文件头注释。
32
- export * from './task-templates.js';
32
+ export * from './lifecycle/task-templates.js';
33
33
  export * from './paths.js';
34
- export * from './store-io.js';
34
+ export * from './infra/store-io.js';
35
35
  // 存储仓储(T03):reset 仅测试用(清空库);repo 是窄方法的命名空间聚合。
36
- export { resetLocaltaskStore, closeDb, default as repo } from './repo/index.js';
36
+ export { resetLocaltaskStore, closeDb, default as repo } from './infra/repo/index.js';
37
37
 
38
38
  /**
39
39
  * 只读快照:把库投成旧 JSON store 的形状({ version, settings, topics: {key: topic} })。
@@ -41,20 +41,20 @@ export { resetLocaltaskStore, closeDb, default as repo } from './repo/index.js';
41
41
  * **没有 saveStore**:写路径必须走 repo 窄方法,「读全表→改→整表重写」被禁止。
42
42
  */
43
43
  export async function loadStore(): Promise<Record<string, any>> {
44
- const repo = await import('./repo/index.js');
44
+ const repo = await import('./infra/repo/index.js');
45
45
  repo.openLocaltaskStore();
46
46
  const map: Record<string, any> = {};
47
47
  for (const t of repo.topics.listTopics()) map[t.key] = t;
48
48
  return { version: 4, settings: repo.settings.getLtSettings(), topics: map };
49
49
  }
50
- export * from './repo-ctx.js';
51
- export * from './task-view.js';
50
+ export * from './infra/repo-ctx.js';
51
+ export * from './lifecycle/task-view.js';
52
52
  export * from './waiters.js';
53
53
  export * from './waiting.js';
54
- export * from './deletion.js';
55
- export * from './task-lifecycle.js';
56
- export * from './topics.js';
57
- export * from './task-ops.js';
58
- export * from './task-remove.js';
59
- export * from './panel-presence.js';
60
- export * from './events.js';
54
+ export * from './lifecycle/deletion.js';
55
+ export * from './lifecycle/task-lifecycle.js';
56
+ export * from './lifecycle/topics.js';
57
+ export * from './lifecycle/task-ops.js';
58
+ export * from './lifecycle/task-remove.js';
59
+ export * from './ui/panel-presence.js';
60
+ export * from './infra/events.js';
@@ -1,7 +1,7 @@
1
1
  // action 的人读输出(render)函数(自 index.js 拆出):CLI 与 HTTP 共用同一份措辞。
2
2
  // STATUS_TAG 来自同构词表(src/shared/task-status.js):CLI 与面板共用一份措辞。
3
- import { STATUS_TAG } from '../../shared/task-status.js';
4
- import { deliveryBodyText } from '../tasktool/delivery-text.js';
3
+ import { STATUS_TAG } from '../../../shared/task-status.js';
4
+ import { deliveryBodyText } from '../../../shared/delivery-text.js';
5
5
 
6
6
  // 渲染入参都是 action 结果对象(HTTP/CLI body 透传)→ any。
7
7
  export type RenderInput = any;
@@ -16,7 +16,7 @@
16
16
  //
17
17
  // 与 wait 的关系:wait 等待期间主题是 waiting 的 → 第 2 条否决,面板不会释放;
18
18
  // wait 结束后若用户把页面关了,才会在宽限期后释放;下一次 wait 再拉起新实例。
19
- import { countWaitingTopics, panelPresence } from './service.js';
19
+ import { countWaitingTopics, panelPresence } from '../service.js';
20
20
 
21
21
  export const PANEL_IDLE_DEFAULTS = {
22
22
  // 见过面板之后:连续多久没有任何面板请求(且无活标签)就认为「页关掉了」。
@@ -1,13 +1,13 @@
1
1
  // (#54 自 service.js 拆出)面板 presence 观测与注册表:SSE 连接计数(含心跳剔除)、
2
2
  // 常驻主面板发现(APP_DIR/panels.json 登记)、逐端口活性探测、窗口重开节流判据
3
- // shouldReopenWindow(panel-guard 与 tasktool/panel-escort 用)。
3
+ // shouldReopenWindow(panel-guard 与 claim/panel-escort 用)。
4
4
  import http from 'node:http';
5
5
  import { readFileSync } from 'node:fs';
6
6
  import { join } from 'node:path';
7
- import { APP_DIR, DEFAULT_PORT } from '../../core/paths.js';
8
- import { atomicWriteTextSync } from '../../core/atomic-file.js';
9
- import { openLocaltaskStore as openStore, topics as topicsRepo } from './repo/index.js';
10
- import { isLiveWaiting } from './task-view.js';
7
+ import { APP_DIR, DEFAULT_PORT } from '../../../core/paths.js';
8
+ import { atomicWriteTextSync } from '../../../core/atomic-file.js';
9
+ import { openLocaltaskStore as openStore, topics as topicsRepo } from '../infra/repo/index.js';
10
+ import { isLiveWaiting } from '../lifecycle/task-view.js';
11
11
  // ─── 面板空闲自释放所需的观测接口(panel-guard.js 调用)────────────
12
12
 
13
13
  // 当前有多少主题「真的在等待」——常驻面板的空闲自释放据此否决退出:
@@ -193,7 +193,7 @@ async function fetchPanelPresence(timeoutMs: number = 900, port: number = DEFAUL
193
193
  *
194
194
  * SSE 活标签(用户停在「本地任务」页)**或** 面板最近有请求(用户停在任意页,
195
195
  * App 壳每 15s 打 /api/ping 兜底)都算「面板开着」→ 1;都没有 → 0。
196
- * 旧口径只数 SSE:用户一切到别的页(SSE 单视图挂载,切页即断)wait 就误判
196
+ * 旧口径只数 SSE:用户一切到别的页(SSE 单视图挂载,切页即断)等待就误判
197
197
  * 「没开」,于是重复开标签——这正是本次修复的根因。
198
198
  *
199
199
  * 任何探测失败都按 0 处理(保守地开一次页),绝不因探测失败而阻塞 wait。
@@ -321,7 +321,7 @@ export function readPanelRegistry(): PanelRegistryEntry[] {
321
321
  return readAllPanels();
322
322
  }
323
323
 
324
- // 复查节奏与重开上限(REVIEW_MS 已随 wait 编排迁往 tasktool/wait.js)。
324
+ // 复查节奏与重开上限(REVIEW_MS 已随阻塞编排迁往 claim/wait.ts)。
325
325
  const REOPEN_COOLDOWN_MS = 20_000;
326
326
  // 一次 wait 最多开 3 个窗口:够救「手滑关掉」,又不至于在浏览器拦截脚本时刷屏。
327
327
  const MAX_WINDOW_OPENS = 3;