@lumenflow/cli 5.4.0 → 5.7.12

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 (227) hide show
  1. package/README.md +42 -40
  2. package/dist/db-journal-recover.js +400 -0
  3. package/dist/db-journal-recover.js.map +1 -0
  4. package/dist/docs-sync.js +8 -3
  5. package/dist/docs-sync.js.map +1 -1
  6. package/dist/gate-defaults.js +191 -9
  7. package/dist/gate-defaults.js.map +1 -1
  8. package/dist/gate-registry.js.map +1 -1
  9. package/dist/gates/monolithic-file-contention-guard.js +167 -0
  10. package/dist/gates/monolithic-file-contention-guard.js.map +1 -0
  11. package/dist/gates/prod-migration-drift.js +207 -0
  12. package/dist/gates/prod-migration-drift.js.map +1 -0
  13. package/dist/gates/test-over-deletion-guard.js +255 -0
  14. package/dist/gates/test-over-deletion-guard.js.map +1 -0
  15. package/dist/gates-runners.js +401 -2
  16. package/dist/gates-runners.js.map +1 -1
  17. package/dist/gates.js +349 -4
  18. package/dist/gates.js.map +1 -1
  19. package/dist/lumenflow-setup.js +144 -0
  20. package/dist/lumenflow-setup.js.map +1 -0
  21. package/dist/lumenflow-upgrade.js +2 -1
  22. package/dist/lumenflow-upgrade.js.map +1 -1
  23. package/dist/mem-create.js +10 -1
  24. package/dist/mem-create.js.map +1 -1
  25. package/dist/mem-signal.js +21 -4
  26. package/dist/mem-signal.js.map +1 -1
  27. package/dist/metrics-cli.js +19 -2
  28. package/dist/metrics-cli.js.map +1 -1
  29. package/dist/metrics-snapshot.js +25 -2
  30. package/dist/metrics-snapshot.js.map +1 -1
  31. package/dist/orchestrate-initiative.js +28 -3
  32. package/dist/orchestrate-initiative.js.map +1 -1
  33. package/dist/public-manifest.js +17 -0
  34. package/dist/public-manifest.js.map +1 -1
  35. package/dist/release.js +53 -18
  36. package/dist/release.js.map +1 -1
  37. package/dist/wu-done-gates.js +121 -8
  38. package/dist/wu-done-gates.js.map +1 -1
  39. package/dist/wu-done.js +30 -6
  40. package/dist/wu-done.js.map +1 -1
  41. package/dist/wu-edit-operations.js +74 -0
  42. package/dist/wu-edit-operations.js.map +1 -1
  43. package/dist/wu-edit-validators.js +58 -0
  44. package/dist/wu-edit-validators.js.map +1 -1
  45. package/dist/wu-edit.js +106 -4
  46. package/dist/wu-edit.js.map +1 -1
  47. package/dist/wu-prep.js +132 -8
  48. package/dist/wu-prep.js.map +1 -1
  49. package/dist/wu-recover.js +6 -0
  50. package/dist/wu-recover.js.map +1 -1
  51. package/dist/wu-release.js +120 -2
  52. package/dist/wu-release.js.map +1 -1
  53. package/dist/wu-sizing-validation.js +47 -17
  54. package/dist/wu-sizing-validation.js.map +1 -1
  55. package/dist/wu-status.js +33 -0
  56. package/dist/wu-status.js.map +1 -1
  57. package/package.json +13 -11
  58. package/packs/agent-runtime/package.json +1 -1
  59. package/packs/sidekick/package.json +1 -1
  60. package/packs/software-delivery/package.json +1 -1
  61. package/templates/core/AGENTS.md.template +162 -26
  62. package/templates/core/LUMENFLOW.md.template +381 -70
  63. package/templates/core/ai/onboarding/agent-invocation-guide.md.template +0 -5
  64. package/templates/core/ai/onboarding/agent-safety-card.md.template +63 -17
  65. package/templates/core/ai/onboarding/initiative-orchestration.md.template +4 -0
  66. package/templates/core/ai/onboarding/release-process.md.template +7 -7
  67. package/templates/core/ai/onboarding/vendor-support.md.template +74 -10
  68. package/templates/vendors/claude/.claude/skills/frontend-design/SKILL.md.template +1 -1
  69. package/templates/vendors/claude/.claude/skills/wu-lifecycle/SKILL.md.template +28 -0
  70. package/packs/agent-runtime/agent-heartbeat.ts +0 -163
  71. package/packs/agent-runtime/auto-session-integration.ts +0 -888
  72. package/packs/agent-runtime/capability-factory.ts +0 -104
  73. package/packs/agent-runtime/constants.ts +0 -21
  74. package/packs/agent-runtime/delegation-registry-schema.ts +0 -220
  75. package/packs/agent-runtime/delegation-registry-store.ts +0 -269
  76. package/packs/agent-runtime/delegation-tree.ts +0 -328
  77. package/packs/agent-runtime/index.ts +0 -20
  78. package/packs/agent-runtime/manifest.ts +0 -348
  79. package/packs/agent-runtime/memory-coordination-contract.ts +0 -86
  80. package/packs/agent-runtime/orchestration.ts +0 -2027
  81. package/packs/agent-runtime/pack-registration.ts +0 -110
  82. package/packs/agent-runtime/policy-factory.ts +0 -165
  83. package/packs/agent-runtime/remote-controls/index.ts +0 -7
  84. package/packs/agent-runtime/remote-controls/operations.ts +0 -405
  85. package/packs/agent-runtime/remote-controls/port.ts +0 -48
  86. package/packs/agent-runtime/remote-controls/state-store.ts +0 -258
  87. package/packs/agent-runtime/remote-controls/types.ts +0 -105
  88. package/packs/agent-runtime/session-schema.ts +0 -467
  89. package/packs/agent-runtime/tool-impl/agent-turn-tools.ts +0 -793
  90. package/packs/agent-runtime/tool-impl/index.ts +0 -6
  91. package/packs/agent-runtime/tool-impl/provider-adapters.ts +0 -1245
  92. package/packs/agent-runtime/tool-impl/remote-controls.mock.ts +0 -256
  93. package/packs/agent-runtime/tool-impl/remote-controls.ts +0 -273
  94. package/packs/agent-runtime/tools/index.ts +0 -4
  95. package/packs/agent-runtime/tools/types.ts +0 -47
  96. package/packs/agent-runtime/turn-lifecycle-events.ts +0 -590
  97. package/packs/agent-runtime/types.ts +0 -128
  98. package/packs/agent-runtime/vitest.config.ts +0 -11
  99. package/packs/sidekick/channel-ingress.ts +0 -137
  100. package/packs/sidekick/constants.ts +0 -10
  101. package/packs/sidekick/index.ts +0 -8
  102. package/packs/sidekick/manifest-schema.ts +0 -49
  103. package/packs/sidekick/manifest.ts +0 -512
  104. package/packs/sidekick/pack-registration.ts +0 -110
  105. package/packs/sidekick/policy-factory.ts +0 -38
  106. package/packs/sidekick/sidekick-events.ts +0 -694
  107. package/packs/sidekick/src/adapters/cloud-queue.ts +0 -101
  108. package/packs/sidekick/src/adapters/control-plane-bridge.adapter.ts +0 -386
  109. package/packs/sidekick/src/adapters/filesystem-bridge.adapter.ts +0 -228
  110. package/packs/sidekick/src/domain/channel.types.ts +0 -64
  111. package/packs/sidekick/src/ports/channel-bridge.port.ts +0 -92
  112. package/packs/sidekick/src/routines/commit.ts +0 -74
  113. package/packs/sidekick/tool-impl/channel-tools.ts +0 -577
  114. package/packs/sidekick/tool-impl/channel-transports.ts +0 -75
  115. package/packs/sidekick/tool-impl/index.ts +0 -29
  116. package/packs/sidekick/tool-impl/memory-tools.ts +0 -290
  117. package/packs/sidekick/tool-impl/routine-commit.ts +0 -102
  118. package/packs/sidekick/tool-impl/routine-tools.ts +0 -440
  119. package/packs/sidekick/tool-impl/runtime-context.ts +0 -28
  120. package/packs/sidekick/tool-impl/shared.ts +0 -125
  121. package/packs/sidekick/tool-impl/storage.ts +0 -325
  122. package/packs/sidekick/tool-impl/system-tools.ts +0 -160
  123. package/packs/sidekick/tool-impl/task-tools.ts +0 -506
  124. package/packs/sidekick/tools/channel-tools.ts +0 -53
  125. package/packs/sidekick/tools/index.ts +0 -9
  126. package/packs/sidekick/tools/memory-tools.ts +0 -53
  127. package/packs/sidekick/tools/routine-tools.ts +0 -53
  128. package/packs/sidekick/tools/system-tools.ts +0 -47
  129. package/packs/sidekick/tools/task-tools.ts +0 -61
  130. package/packs/sidekick/tools/types.ts +0 -57
  131. package/packs/sidekick/vitest.config.ts +0 -11
  132. package/packs/software-delivery/constants.ts +0 -10
  133. package/packs/software-delivery/extensions.ts +0 -140
  134. package/packs/software-delivery/gate-policies.ts +0 -134
  135. package/packs/software-delivery/index.ts +0 -8
  136. package/packs/software-delivery/manifest-schema.ts +0 -268
  137. package/packs/software-delivery/manifest.ts +0 -657
  138. package/packs/software-delivery/pack-registration.ts +0 -113
  139. package/packs/software-delivery/src/commands/index.ts +0 -5
  140. package/packs/software-delivery/src/config/delivery-review-contract.ts +0 -256
  141. package/packs/software-delivery/src/config/env-accessors.ts +0 -66
  142. package/packs/software-delivery/src/config/index.ts +0 -8
  143. package/packs/software-delivery/src/config/normalize-config-keys.ts +0 -9
  144. package/packs/software-delivery/src/config/schemas/lumenflow-config-schema-types.ts +0 -460
  145. package/packs/software-delivery/src/config/workspace-reader.ts +0 -375
  146. package/packs/software-delivery/src/constants/backlog-patterns.ts +0 -31
  147. package/packs/software-delivery/src/constants/client-ids.ts +0 -19
  148. package/packs/software-delivery/src/constants/config-contract.ts +0 -7
  149. package/packs/software-delivery/src/constants/docs-layout-presets.ts +0 -50
  150. package/packs/software-delivery/src/constants/duration-constants.ts +0 -20
  151. package/packs/software-delivery/src/constants/gate-constants.ts +0 -32
  152. package/packs/software-delivery/src/constants/index.ts +0 -29
  153. package/packs/software-delivery/src/constants/lock-constants.ts +0 -35
  154. package/packs/software-delivery/src/constants/object-guards.ts +0 -12
  155. package/packs/software-delivery/src/constants/section-headings.ts +0 -107
  156. package/packs/software-delivery/src/constants/wu-cli-constants.ts +0 -488
  157. package/packs/software-delivery/src/constants/wu-domain-constants.ts +0 -466
  158. package/packs/software-delivery/src/constants/wu-git-constants.ts +0 -7
  159. package/packs/software-delivery/src/constants/wu-id-format.ts +0 -327
  160. package/packs/software-delivery/src/constants/wu-paths-constants.ts +0 -384
  161. package/packs/software-delivery/src/constants/wu-statuses.ts +0 -287
  162. package/packs/software-delivery/src/constants/wu-type-helpers.ts +0 -67
  163. package/packs/software-delivery/src/constants/wu-ui-constants.ts +0 -267
  164. package/packs/software-delivery/src/constants/wu-validation-constants.ts +0 -73
  165. package/packs/software-delivery/src/domain/index.ts +0 -5
  166. package/packs/software-delivery/src/domain/orchestration.constants.ts +0 -166
  167. package/packs/software-delivery/src/domain/orchestration.schemas.ts +0 -238
  168. package/packs/software-delivery/src/domain/orchestration.types.ts +0 -176
  169. package/packs/software-delivery/src/methodology/incremental-test.ts +0 -122
  170. package/packs/software-delivery/src/methodology/index.ts +0 -6
  171. package/packs/software-delivery/src/methodology/manual-test-validator.ts +0 -292
  172. package/packs/software-delivery/src/policy/coverage-gate.ts +0 -270
  173. package/packs/software-delivery/src/policy/gates-agent-mode.ts +0 -223
  174. package/packs/software-delivery/src/policy/gates-config-internal.ts +0 -121
  175. package/packs/software-delivery/src/policy/gates-config.ts +0 -300
  176. package/packs/software-delivery/src/policy/gates-coverage.ts +0 -356
  177. package/packs/software-delivery/src/policy/gates-presets.ts +0 -134
  178. package/packs/software-delivery/src/policy/gates-schemas.ts +0 -173
  179. package/packs/software-delivery/src/policy/index.ts +0 -22
  180. package/packs/software-delivery/src/policy/package-manager-resolver.ts +0 -319
  181. package/packs/software-delivery/src/policy/resolve-policy.ts +0 -601
  182. package/packs/software-delivery/src/ports/config.ports.ts +0 -90
  183. package/packs/software-delivery/src/ports/dashboard-renderer.port.ts +0 -125
  184. package/packs/software-delivery/src/ports/index.ts +0 -10
  185. package/packs/software-delivery/src/ports/sync-validator.ports.ts +0 -59
  186. package/packs/software-delivery/src/ports/wu-helpers.ports.ts +0 -168
  187. package/packs/software-delivery/src/ports/wu-state.ports.ts +0 -241
  188. package/packs/software-delivery/src/primitives/index.ts +0 -5
  189. package/packs/software-delivery/src/runtime/index.ts +0 -6
  190. package/packs/software-delivery/src/runtime/work-classifier.ts +0 -561
  191. package/packs/software-delivery/src/sandbox/index.ts +0 -10
  192. package/packs/software-delivery/src/sandbox/sandbox-allowlist.ts +0 -118
  193. package/packs/software-delivery/src/sandbox/sandbox-backend-linux.ts +0 -88
  194. package/packs/software-delivery/src/sandbox/sandbox-backend-macos.ts +0 -154
  195. package/packs/software-delivery/src/sandbox/sandbox-backend-windows.ts +0 -47
  196. package/packs/software-delivery/src/sandbox/sandbox-profile.ts +0 -153
  197. package/packs/software-delivery/src/schemas/index.ts +0 -5
  198. package/packs/software-delivery/src/state/date-utils.ts +0 -158
  199. package/packs/software-delivery/src/state/index.ts +0 -15
  200. package/packs/software-delivery/src/state/state-machine.ts +0 -119
  201. package/packs/software-delivery/src/state/wu-doc-types.ts +0 -51
  202. package/packs/software-delivery/src/state/wu-paths.ts +0 -381
  203. package/packs/software-delivery/src/state/wu-schema.ts +0 -1139
  204. package/packs/software-delivery/src/state/wu-state-schema.ts +0 -255
  205. package/packs/software-delivery/src/state/wu-yaml.ts +0 -338
  206. package/packs/software-delivery/tool-impl/agent-tools.ts +0 -263
  207. package/packs/software-delivery/tool-impl/delegation-tools.ts +0 -66
  208. package/packs/software-delivery/tool-impl/flow-metrics-tools.ts +0 -219
  209. package/packs/software-delivery/tool-impl/git-runner.ts +0 -113
  210. package/packs/software-delivery/tool-impl/git-tools.ts +0 -316
  211. package/packs/software-delivery/tool-impl/index.ts +0 -15
  212. package/packs/software-delivery/tool-impl/initiative-orchestration-tools.ts +0 -720
  213. package/packs/software-delivery/tool-impl/lane-lock.ts +0 -246
  214. package/packs/software-delivery/tool-impl/memory-tools.ts +0 -470
  215. package/packs/software-delivery/tool-impl/pending-runtime-tools.ts +0 -21
  216. package/packs/software-delivery/tool-impl/runtime-cli-adapter.ts +0 -329
  217. package/packs/software-delivery/tool-impl/runtime-native-tools.ts +0 -687
  218. package/packs/software-delivery/tool-impl/worker-loader.ts +0 -52
  219. package/packs/software-delivery/tool-impl/worktree-tools.ts +0 -46
  220. package/packs/software-delivery/tool-impl/wu-lifecycle-tools.ts +0 -807
  221. package/packs/software-delivery/tools/delegation-tools.ts +0 -23
  222. package/packs/software-delivery/tools/git-tools.ts +0 -55
  223. package/packs/software-delivery/tools/index.ts +0 -8
  224. package/packs/software-delivery/tools/lane-lock-tool.ts +0 -37
  225. package/packs/software-delivery/tools/types.ts +0 -71
  226. package/packs/software-delivery/tools/worktree-tools.ts +0 -49
  227. package/packs/software-delivery/vitest.config.ts +0 -11
@@ -1,506 +0,0 @@
1
- // Copyright (c) 2026 Hellmai Ltd
2
- // SPDX-License-Identifier: LicenseRef-LumenFlow-Proprietary
3
-
4
- import { getStoragePort, type TaskPriority, type TaskRecord } from './storage.js';
5
- import {
6
- asInteger,
7
- asNonEmptyString,
8
- asStringArray,
9
- buildAuditEvent,
10
- createId,
11
- failure,
12
- includesText,
13
- isDryRun,
14
- matchesTags,
15
- nowIso,
16
- success,
17
- toRecord,
18
- type ToolContextLike,
19
- type ToolOutput,
20
- } from './shared.js';
21
- import {
22
- buildTaskCompletedEvent,
23
- buildTaskCreatedEvent,
24
- buildTaskScheduledEvent,
25
- buildTaskSnoozedEvent,
26
- emitSidekickEvent,
27
- } from '../sidekick-events.js';
28
-
29
- // ---------------------------------------------------------------------------
30
- // Constants
31
- // ---------------------------------------------------------------------------
32
-
33
- const TOOL_NAMES = {
34
- CREATE: 'task:create',
35
- LIST: 'task:list',
36
- UPDATE: 'task:update',
37
- CANCEL: 'task:cancel',
38
- COMPLETE: 'task:complete',
39
- SCHEDULE: 'task:schedule',
40
- } as const;
41
-
42
- const VALID_PRIORITIES: TaskPriority[] = ['P0', 'P1', 'P2', 'P3'];
43
- const DEFAULT_PRIORITY: TaskPriority = 'P2';
44
- const TASK_ID_REQUIRED_MESSAGE = 'id is required.';
45
-
46
- // ---------------------------------------------------------------------------
47
- // Helpers
48
- // ---------------------------------------------------------------------------
49
-
50
- function asPriority(value: unknown): TaskPriority {
51
- return VALID_PRIORITIES.includes(value as TaskPriority)
52
- ? (value as TaskPriority)
53
- : DEFAULT_PRIORITY;
54
- }
55
-
56
- function resolveTaskUpdatePatch(parsed: Record<string, unknown>): Partial<TaskRecord> {
57
- const patch: Partial<TaskRecord> = {};
58
- const title = asNonEmptyString(parsed.title);
59
- const description =
60
- typeof parsed.description === 'string'
61
- ? (asNonEmptyString(parsed.description) ?? undefined)
62
- : null;
63
- const dueAt =
64
- typeof parsed.due_at === 'string' ? (asNonEmptyString(parsed.due_at) ?? undefined) : null;
65
- const cron =
66
- typeof parsed.cron === 'string' ? (asNonEmptyString(parsed.cron) ?? undefined) : null;
67
-
68
- if (title) {
69
- patch.title = title;
70
- }
71
- if (description !== null) {
72
- patch.description = description;
73
- }
74
- if (dueAt !== null) {
75
- patch.due_at = dueAt;
76
- }
77
- if (cron !== null) {
78
- patch.cron = cron;
79
- }
80
- if (parsed.priority !== undefined) {
81
- patch.priority = asPriority(parsed.priority);
82
- }
83
- if (parsed.tags !== undefined) {
84
- patch.tags = asStringArray(parsed.tags);
85
- }
86
-
87
- return patch;
88
- }
89
-
90
- function applyTaskPatch(task: TaskRecord, patch: Partial<TaskRecord>): TaskRecord {
91
- return {
92
- ...task,
93
- ...patch,
94
- updated_at: nowIso(),
95
- };
96
- }
97
-
98
- function buildCanceledTask(task: TaskRecord): TaskRecord {
99
- return {
100
- ...task,
101
- status: 'canceled',
102
- canceled_at: nowIso(),
103
- updated_at: nowIso(),
104
- };
105
- }
106
-
107
- function movedDueDateLater(
108
- previousDueAt: string | undefined,
109
- nextDueAt: string | undefined,
110
- ): boolean {
111
- if (!previousDueAt || !nextDueAt) {
112
- return false;
113
- }
114
- return Date.parse(nextDueAt) > Date.parse(previousDueAt);
115
- }
116
-
117
- // ---------------------------------------------------------------------------
118
- // task:create
119
- // ---------------------------------------------------------------------------
120
-
121
- async function taskCreateTool(input: unknown, context?: ToolContextLike): Promise<ToolOutput> {
122
- const parsed = toRecord(input);
123
- const title = asNonEmptyString(parsed.title);
124
-
125
- if (!title) {
126
- return failure('INVALID_INPUT', 'title is required.');
127
- }
128
-
129
- const task: TaskRecord = {
130
- id: createId('task'),
131
- title,
132
- description: asNonEmptyString(parsed.description) ?? undefined,
133
- priority: asPriority(parsed.priority),
134
- status: 'pending',
135
- tags: asStringArray(parsed.tags),
136
- due_at: asNonEmptyString(parsed.due_at) ?? undefined,
137
- created_at: nowIso(),
138
- updated_at: nowIso(),
139
- };
140
-
141
- if (isDryRun(parsed)) {
142
- return success({ dry_run: true, task: task as unknown as Record<string, unknown> });
143
- }
144
-
145
- const storage = getStoragePort();
146
- await storage.withLock(async () => {
147
- const tasks = await storage.readStore('tasks');
148
- tasks.push(task);
149
- await storage.writeStore('tasks', tasks);
150
- await storage.appendAudit(
151
- buildAuditEvent({
152
- tool: TOOL_NAMES.CREATE,
153
- op: 'create',
154
- context,
155
- ids: [task.id],
156
- }),
157
- );
158
- });
159
-
160
- await emitSidekickEvent(buildTaskCreatedEvent(task));
161
-
162
- return success({ task: task as unknown as Record<string, unknown> });
163
- }
164
-
165
- // ---------------------------------------------------------------------------
166
- // task:list
167
- // ---------------------------------------------------------------------------
168
-
169
- async function taskListTool(input: unknown, _context?: ToolContextLike): Promise<ToolOutput> {
170
- const parsed = toRecord(input);
171
- const statusFilter = asNonEmptyString(parsed.status);
172
- const priorityFilter = asNonEmptyString(parsed.priority);
173
- const tags = asStringArray(parsed.tags);
174
- const search = asNonEmptyString(parsed.search);
175
- const dueBefore = asNonEmptyString(parsed.due_before);
176
- const limit = asInteger(parsed.limit);
177
-
178
- const storage = getStoragePort();
179
- const tasks = await storage.readStore('tasks');
180
-
181
- const filtered = tasks.filter((task) => {
182
- if (statusFilter && task.status !== statusFilter) {
183
- return false;
184
- }
185
- if (priorityFilter && task.priority !== priorityFilter) {
186
- return false;
187
- }
188
- if (!matchesTags(tags, task.tags)) {
189
- return false;
190
- }
191
- if (!includesText(`${task.title}\n${task.description ?? ''}`, search)) {
192
- return false;
193
- }
194
- if (dueBefore && task.due_at) {
195
- if (Date.parse(task.due_at) >= Date.parse(dueBefore)) {
196
- return false;
197
- }
198
- }
199
- if (dueBefore && !task.due_at) {
200
- return false;
201
- }
202
- return true;
203
- });
204
-
205
- const sorted = filtered.toSorted((a, b) => Date.parse(b.updated_at) - Date.parse(a.updated_at));
206
-
207
- const items = limit && limit > 0 ? sorted.slice(0, limit) : sorted;
208
-
209
- return success({
210
- items: items as unknown as Record<string, unknown>,
211
- count: items.length,
212
- });
213
- }
214
-
215
- // ---------------------------------------------------------------------------
216
- // task:update
217
- // ---------------------------------------------------------------------------
218
-
219
- async function taskUpdateTool(input: unknown, context?: ToolContextLike): Promise<ToolOutput> {
220
- const parsed = toRecord(input);
221
- const id = asNonEmptyString(parsed.id);
222
-
223
- if (!id) {
224
- return failure('INVALID_INPUT', TASK_ID_REQUIRED_MESSAGE);
225
- }
226
-
227
- const patch = resolveTaskUpdatePatch(parsed);
228
- if (Object.keys(patch).length === 0) {
229
- return failure(
230
- 'INVALID_INPUT',
231
- 'task:update requires at least one of title, description, priority, tags, due_at, or cron.',
232
- );
233
- }
234
-
235
- const storage = getStoragePort();
236
- const tasks = await storage.readStore('tasks');
237
- const task = tasks.find((entry) => entry.id === id);
238
-
239
- if (!task) {
240
- return failure('NOT_FOUND', `task ${id} was not found.`);
241
- }
242
- if (task.status === 'canceled') {
243
- return failure(
244
- 'INVALID_STATE',
245
- `task ${id} is canceled and cannot be completed. Reopen it with task:update before completing.`,
246
- );
247
- }
248
-
249
- if (isDryRun(parsed)) {
250
- return success({
251
- dry_run: true,
252
- task: applyTaskPatch(task, patch) as unknown as Record<string, unknown>,
253
- });
254
- }
255
-
256
- const previousDueAt = task.due_at ?? null;
257
-
258
- await storage.withLock(async () => {
259
- const latest = await storage.readStore('tasks');
260
- const target = latest.find((entry) => entry.id === id);
261
- if (!target) {
262
- return;
263
- }
264
- Object.assign(target, applyTaskPatch(target, patch));
265
- await storage.writeStore('tasks', latest);
266
- await storage.appendAudit(
267
- buildAuditEvent({
268
- tool: TOOL_NAMES.UPDATE,
269
- op: 'update',
270
- context,
271
- ids: [id],
272
- }),
273
- );
274
- });
275
-
276
- const updated = await storage.readStore('tasks');
277
- const updatedTask = updated.find((entry) => entry.id === id);
278
- if (updatedTask && movedDueDateLater(previousDueAt ?? undefined, updatedTask.due_at)) {
279
- await emitSidekickEvent(
280
- buildTaskSnoozedEvent({
281
- task_id: id,
282
- previous_due_at: previousDueAt,
283
- due_at: updatedTask.due_at ?? previousDueAt ?? '',
284
- }),
285
- );
286
- }
287
- return success({ task: updatedTask as unknown as Record<string, unknown> });
288
- }
289
-
290
- // ---------------------------------------------------------------------------
291
- // task:complete
292
- // ---------------------------------------------------------------------------
293
-
294
- async function taskCompleteTool(input: unknown, context?: ToolContextLike): Promise<ToolOutput> {
295
- const parsed = toRecord(input);
296
- const id = asNonEmptyString(parsed.id);
297
-
298
- if (!id) {
299
- return failure('INVALID_INPUT', TASK_ID_REQUIRED_MESSAGE);
300
- }
301
-
302
- const storage = getStoragePort();
303
- const tasks = await storage.readStore('tasks');
304
- const task = tasks.find((t) => t.id === id);
305
-
306
- if (!task) {
307
- return failure('NOT_FOUND', `task ${id} was not found.`);
308
- }
309
-
310
- if (isDryRun(parsed)) {
311
- const preview = { ...task, status: 'done' as const, completed_at: nowIso() };
312
- return success({
313
- dry_run: true,
314
- task: preview as unknown as Record<string, unknown>,
315
- });
316
- }
317
-
318
- await storage.withLock(async () => {
319
- const latest = await storage.readStore('tasks');
320
- const target = latest.find((t) => t.id === id);
321
- if (target) {
322
- target.status = 'done';
323
- target.completed_at = nowIso();
324
- target.updated_at = nowIso();
325
- if (parsed.note) {
326
- target.note = asNonEmptyString(parsed.note) ?? undefined;
327
- }
328
- await storage.writeStore('tasks', latest);
329
- await storage.appendAudit(
330
- buildAuditEvent({
331
- tool: TOOL_NAMES.COMPLETE,
332
- op: 'update',
333
- context,
334
- ids: [id],
335
- }),
336
- );
337
- }
338
- });
339
-
340
- const updated = await storage.readStore('tasks');
341
- const completedTask = updated.find((t) => t.id === id);
342
- if (completedTask) {
343
- await emitSidekickEvent(buildTaskCompletedEvent(completedTask));
344
- }
345
-
346
- return success({ task: completedTask as unknown as Record<string, unknown> });
347
- }
348
-
349
- // ---------------------------------------------------------------------------
350
- // task:cancel
351
- // ---------------------------------------------------------------------------
352
-
353
- async function taskCancelTool(input: unknown, context?: ToolContextLike): Promise<ToolOutput> {
354
- const parsed = toRecord(input);
355
- const id = asNonEmptyString(parsed.id);
356
-
357
- if (!id) {
358
- return failure('INVALID_INPUT', TASK_ID_REQUIRED_MESSAGE);
359
- }
360
-
361
- const storage = getStoragePort();
362
- const tasks = await storage.readStore('tasks');
363
- const task = tasks.find((entry) => entry.id === id);
364
-
365
- if (!task) {
366
- return failure('NOT_FOUND', `task ${id} was not found.`);
367
- }
368
- if (task.status === 'done') {
369
- return failure(
370
- 'INVALID_STATE',
371
- `task ${id} is already done and cannot be canceled. Use task:update if you only need to adjust metadata.`,
372
- );
373
- }
374
-
375
- if (isDryRun(parsed)) {
376
- return success({
377
- dry_run: true,
378
- task: buildCanceledTask(task) as unknown as Record<string, unknown>,
379
- });
380
- }
381
-
382
- await storage.withLock(async () => {
383
- const latest = await storage.readStore('tasks');
384
- const target = latest.find((entry) => entry.id === id);
385
- if (!target) {
386
- return;
387
- }
388
- Object.assign(target, buildCanceledTask(target));
389
- await storage.writeStore('tasks', latest);
390
- await storage.appendAudit(
391
- buildAuditEvent({
392
- tool: TOOL_NAMES.CANCEL,
393
- op: 'update',
394
- context,
395
- ids: [id],
396
- }),
397
- );
398
- });
399
-
400
- const updated = await storage.readStore('tasks');
401
- const canceledTask = updated.find((entry) => entry.id === id);
402
- return success({ task: canceledTask as unknown as Record<string, unknown> });
403
- }
404
-
405
- // ---------------------------------------------------------------------------
406
- // task:schedule
407
- // ---------------------------------------------------------------------------
408
-
409
- async function taskScheduleTool(input: unknown, context?: ToolContextLike): Promise<ToolOutput> {
410
- const parsed = toRecord(input);
411
- const id = asNonEmptyString(parsed.id);
412
-
413
- if (!id) {
414
- return failure('INVALID_INPUT', TASK_ID_REQUIRED_MESSAGE);
415
- }
416
-
417
- const storage = getStoragePort();
418
- const tasks = await storage.readStore('tasks');
419
- const task = tasks.find((t) => t.id === id);
420
-
421
- if (!task) {
422
- return failure('NOT_FOUND', `task ${id} was not found.`);
423
- }
424
-
425
- const dueAt = asNonEmptyString(parsed.due_at);
426
- const cron = asNonEmptyString(parsed.cron);
427
- const previousDueAt = task.due_at ?? null;
428
-
429
- if (isDryRun(parsed)) {
430
- const preview = {
431
- ...task,
432
- ...(dueAt ? { due_at: dueAt } : {}),
433
- ...(cron ? { cron } : {}),
434
- };
435
- return success({
436
- dry_run: true,
437
- task: preview as unknown as Record<string, unknown>,
438
- });
439
- }
440
-
441
- await storage.withLock(async () => {
442
- const latest = await storage.readStore('tasks');
443
- const target = latest.find((t) => t.id === id);
444
- if (target) {
445
- if (dueAt) {
446
- target.due_at = dueAt;
447
- }
448
- if (cron) {
449
- target.cron = cron;
450
- }
451
- target.updated_at = nowIso();
452
- await storage.writeStore('tasks', latest);
453
- await storage.appendAudit(
454
- buildAuditEvent({
455
- tool: TOOL_NAMES.SCHEDULE,
456
- op: 'update',
457
- context,
458
- ids: [id],
459
- }),
460
- );
461
- }
462
- });
463
-
464
- const updated = await storage.readStore('tasks');
465
- const scheduledTask = updated.find((t) => t.id === id);
466
- if (scheduledTask) {
467
- await emitSidekickEvent(buildTaskScheduledEvent(scheduledTask));
468
- if (movedDueDateLater(previousDueAt ?? undefined, scheduledTask.due_at)) {
469
- await emitSidekickEvent(
470
- buildTaskSnoozedEvent({
471
- task_id: id,
472
- previous_due_at: previousDueAt,
473
- due_at: scheduledTask.due_at ?? previousDueAt ?? '',
474
- }),
475
- );
476
- }
477
- }
478
-
479
- return success({ task: scheduledTask as unknown as Record<string, unknown> });
480
- }
481
-
482
- // ---------------------------------------------------------------------------
483
- // Router (default export)
484
- // ---------------------------------------------------------------------------
485
-
486
- export default async function taskTools(
487
- input: unknown,
488
- context?: ToolContextLike,
489
- ): Promise<ToolOutput> {
490
- switch (context?.tool_name) {
491
- case TOOL_NAMES.CREATE:
492
- return taskCreateTool(input, context);
493
- case TOOL_NAMES.LIST:
494
- return taskListTool(input, context);
495
- case TOOL_NAMES.UPDATE:
496
- return taskUpdateTool(input, context);
497
- case TOOL_NAMES.CANCEL:
498
- return taskCancelTool(input, context);
499
- case TOOL_NAMES.COMPLETE:
500
- return taskCompleteTool(input, context);
501
- case TOOL_NAMES.SCHEDULE:
502
- return taskScheduleTool(input, context);
503
- default:
504
- return failure('UNKNOWN_TOOL', `Unknown task tool: ${context?.tool_name ?? 'unknown'}`);
505
- }
506
- }
@@ -1,53 +0,0 @@
1
- // Copyright (c) 2026 Hellmai Ltd
2
- // SPDX-License-Identifier: LicenseRef-LumenFlow-Proprietary
3
-
4
- import {
5
- TOOL_PERMISSIONS,
6
- TOOL_SCOPE_ACCESS,
7
- TOOL_SCOPE_TYPES,
8
- createToolDescriptor,
9
- } from './types.js';
10
-
11
- const CHANNEL_READ_SCOPE = {
12
- type: TOOL_SCOPE_TYPES.PATH,
13
- pattern: '.sidekick/channels/**',
14
- access: TOOL_SCOPE_ACCESS.READ,
15
- } as const;
16
-
17
- const CHANNEL_WRITE_SCOPE = {
18
- type: TOOL_SCOPE_TYPES.PATH,
19
- pattern: '.sidekick/channels/**',
20
- access: TOOL_SCOPE_ACCESS.WRITE,
21
- } as const;
22
-
23
- const AUDIT_WRITE_SCOPE = {
24
- type: TOOL_SCOPE_TYPES.PATH,
25
- pattern: '.sidekick/audit/**',
26
- access: TOOL_SCOPE_ACCESS.WRITE,
27
- } as const;
28
-
29
- const CHANNEL_TOOLS_ENTRY = 'tool-impl/channel-tools.ts';
30
-
31
- export const channelConfigureDescriptor = createToolDescriptor({
32
- name: 'channel:configure',
33
- permission: TOOL_PERMISSIONS.WRITE,
34
- required_scopes: [CHANNEL_READ_SCOPE, CHANNEL_WRITE_SCOPE, AUDIT_WRITE_SCOPE],
35
- entry: CHANNEL_TOOLS_ENTRY,
36
- description: 'Configure a messaging channel (terminal-only in v0.1).',
37
- });
38
-
39
- export const channelSendDescriptor = createToolDescriptor({
40
- name: 'channel:send',
41
- permission: TOOL_PERMISSIONS.WRITE,
42
- required_scopes: [CHANNEL_READ_SCOPE, CHANNEL_WRITE_SCOPE, AUDIT_WRITE_SCOPE],
43
- entry: CHANNEL_TOOLS_ENTRY,
44
- description: 'Send a message to a channel. Supports dry_run.',
45
- });
46
-
47
- export const channelReceiveDescriptor = createToolDescriptor({
48
- name: 'channel:receive',
49
- permission: TOOL_PERMISSIONS.READ,
50
- required_scopes: [CHANNEL_READ_SCOPE],
51
- entry: CHANNEL_TOOLS_ENTRY,
52
- description: 'Receive messages from a channel with optional limit and since filter.',
53
- });
@@ -1,9 +0,0 @@
1
- // Copyright (c) 2026 Hellmai Ltd
2
- // SPDX-License-Identifier: LicenseRef-LumenFlow-Proprietary
3
-
4
- export * from './types.js';
5
- export * from './task-tools.js';
6
- export * from './memory-tools.js';
7
- export * from './channel-tools.js';
8
- export * from './routine-tools.js';
9
- export * from './system-tools.js';
@@ -1,53 +0,0 @@
1
- // Copyright (c) 2026 Hellmai Ltd
2
- // SPDX-License-Identifier: LicenseRef-LumenFlow-Proprietary
3
-
4
- import {
5
- TOOL_PERMISSIONS,
6
- TOOL_SCOPE_ACCESS,
7
- TOOL_SCOPE_TYPES,
8
- createToolDescriptor,
9
- } from './types.js';
10
-
11
- const MEMORY_READ_SCOPE = {
12
- type: TOOL_SCOPE_TYPES.PATH,
13
- pattern: '.sidekick/memory/**',
14
- access: TOOL_SCOPE_ACCESS.READ,
15
- } as const;
16
-
17
- const MEMORY_WRITE_SCOPE = {
18
- type: TOOL_SCOPE_TYPES.PATH,
19
- pattern: '.sidekick/memory/**',
20
- access: TOOL_SCOPE_ACCESS.WRITE,
21
- } as const;
22
-
23
- const AUDIT_WRITE_SCOPE = {
24
- type: TOOL_SCOPE_TYPES.PATH,
25
- pattern: '.sidekick/audit/**',
26
- access: TOOL_SCOPE_ACCESS.WRITE,
27
- } as const;
28
-
29
- const MEMORY_TOOLS_ENTRY = 'tool-impl/memory-tools.ts';
30
-
31
- export const memoryStoreDescriptor = createToolDescriptor({
32
- name: 'memory:store',
33
- permission: TOOL_PERMISSIONS.WRITE,
34
- required_scopes: [MEMORY_READ_SCOPE, MEMORY_WRITE_SCOPE, AUDIT_WRITE_SCOPE],
35
- entry: MEMORY_TOOLS_ENTRY,
36
- description: 'Store a typed memory entry (fact, preference, note, snippet) with optional tags.',
37
- });
38
-
39
- export const memoryRecallDescriptor = createToolDescriptor({
40
- name: 'memory:recall',
41
- permission: TOOL_PERMISSIONS.READ,
42
- required_scopes: [MEMORY_READ_SCOPE],
43
- entry: MEMORY_TOOLS_ENTRY,
44
- description: 'Recall memory entries by substring search and/or tag filter.',
45
- });
46
-
47
- export const memoryForgetDescriptor = createToolDescriptor({
48
- name: 'memory:forget',
49
- permission: TOOL_PERMISSIONS.WRITE,
50
- required_scopes: [MEMORY_READ_SCOPE, MEMORY_WRITE_SCOPE, AUDIT_WRITE_SCOPE],
51
- entry: MEMORY_TOOLS_ENTRY,
52
- description: 'Remove a memory entry by ID. Supports dry_run.',
53
- });
@@ -1,53 +0,0 @@
1
- // Copyright (c) 2026 Hellmai Ltd
2
- // SPDX-License-Identifier: LicenseRef-LumenFlow-Proprietary
3
-
4
- import {
5
- TOOL_PERMISSIONS,
6
- TOOL_SCOPE_ACCESS,
7
- TOOL_SCOPE_TYPES,
8
- createToolDescriptor,
9
- } from './types.js';
10
-
11
- const ROUTINE_READ_SCOPE = {
12
- type: TOOL_SCOPE_TYPES.PATH,
13
- pattern: '.sidekick/routines/**',
14
- access: TOOL_SCOPE_ACCESS.READ,
15
- } as const;
16
-
17
- const ROUTINE_WRITE_SCOPE = {
18
- type: TOOL_SCOPE_TYPES.PATH,
19
- pattern: '.sidekick/routines/**',
20
- access: TOOL_SCOPE_ACCESS.WRITE,
21
- } as const;
22
-
23
- const AUDIT_WRITE_SCOPE = {
24
- type: TOOL_SCOPE_TYPES.PATH,
25
- pattern: '.sidekick/audit/**',
26
- access: TOOL_SCOPE_ACCESS.WRITE,
27
- } as const;
28
-
29
- const ROUTINE_TOOLS_ENTRY = 'tool-impl/routine-tools.ts';
30
-
31
- export const routineCreateDescriptor = createToolDescriptor({
32
- name: 'routine:create',
33
- permission: TOOL_PERMISSIONS.WRITE,
34
- required_scopes: [ROUTINE_READ_SCOPE, ROUTINE_WRITE_SCOPE, AUDIT_WRITE_SCOPE],
35
- entry: ROUTINE_TOOLS_ENTRY,
36
- description: 'Create a named routine with ordered tool+input steps and optional cron.',
37
- });
38
-
39
- export const routineListDescriptor = createToolDescriptor({
40
- name: 'routine:list',
41
- permission: TOOL_PERMISSIONS.READ,
42
- required_scopes: [ROUTINE_READ_SCOPE],
43
- entry: ROUTINE_TOOLS_ENTRY,
44
- description: 'List routines with optional enabled_only filter.',
45
- });
46
-
47
- export const routineRunDescriptor = createToolDescriptor({
48
- name: 'routine:run',
49
- permission: TOOL_PERMISSIONS.READ,
50
- required_scopes: [ROUTINE_READ_SCOPE],
51
- entry: ROUTINE_TOOLS_ENTRY,
52
- description: 'Generate an execution plan for a routine (plan-only, does not execute).',
53
- });