@veewo/claw-core 0.1.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 (56) hide show
  1. package/README.md +7 -0
  2. package/dist/src/completion-hooks.d.ts +6 -0
  3. package/dist/src/completion-hooks.js +64 -0
  4. package/dist/src/completion-hooks.js.map +1 -0
  5. package/dist/src/context.d.ts +7 -0
  6. package/dist/src/context.js +171 -0
  7. package/dist/src/context.js.map +1 -0
  8. package/dist/src/errors.d.ts +6 -0
  9. package/dist/src/errors.js +11 -0
  10. package/dist/src/errors.js.map +1 -0
  11. package/dist/src/index.d.ts +15 -0
  12. package/dist/src/index.js +16 -0
  13. package/dist/src/index.js.map +1 -0
  14. package/dist/src/init.d.ts +22 -0
  15. package/dist/src/init.js +91 -0
  16. package/dist/src/init.js.map +1 -0
  17. package/dist/src/io.d.ts +6 -0
  18. package/dist/src/io.js +47 -0
  19. package/dist/src/io.js.map +1 -0
  20. package/dist/src/memory.d.ts +4 -0
  21. package/dist/src/memory.js +240 -0
  22. package/dist/src/memory.js.map +1 -0
  23. package/dist/src/paths.d.ts +6 -0
  24. package/dist/src/paths.js +73 -0
  25. package/dist/src/paths.js.map +1 -0
  26. package/dist/src/plan-events.d.ts +12 -0
  27. package/dist/src/plan-events.js +8 -0
  28. package/dist/src/plan-events.js.map +1 -0
  29. package/dist/src/plan-view.d.ts +6 -0
  30. package/dist/src/plan-view.js +69 -0
  31. package/dist/src/plan-view.js.map +1 -0
  32. package/dist/src/plan.d.ts +10 -0
  33. package/dist/src/plan.js +510 -0
  34. package/dist/src/plan.js.map +1 -0
  35. package/dist/src/project-check.d.ts +3 -0
  36. package/dist/src/project-check.js +238 -0
  37. package/dist/src/project-check.js.map +1 -0
  38. package/dist/src/requirements-gate.d.ts +23 -0
  39. package/dist/src/requirements-gate.js +49 -0
  40. package/dist/src/requirements-gate.js.map +1 -0
  41. package/dist/src/switch-task.d.ts +2 -0
  42. package/dist/src/switch-task.js +60 -0
  43. package/dist/src/switch-task.js.map +1 -0
  44. package/dist/src/task-retention.d.ts +2 -0
  45. package/dist/src/task-retention.js +126 -0
  46. package/dist/src/task-retention.js.map +1 -0
  47. package/dist/src/truth.d.ts +2 -0
  48. package/dist/src/truth.js +33 -0
  49. package/dist/src/truth.js.map +1 -0
  50. package/dist/src/types.d.ts +476 -0
  51. package/dist/src/types.js +2 -0
  52. package/dist/src/types.js.map +1 -0
  53. package/dist/src/workflow-guidance.d.ts +10 -0
  54. package/dist/src/workflow-guidance.js +233 -0
  55. package/dist/src/workflow-guidance.js.map +1 -0
  56. package/package.json +32 -0
@@ -0,0 +1,476 @@
1
+ export type ProjectConfig = {
2
+ id?: string;
3
+ name?: string;
4
+ maxTasksToKeep?: number;
5
+ externalTruthSkill?: string | null;
6
+ externalAdrSkill?: string | null;
7
+ contextPaths?: string[];
8
+ memory?: {
9
+ externalDocPaths?: string[];
10
+ };
11
+ gitnexus?: {
12
+ enabled?: boolean;
13
+ };
14
+ };
15
+ export type PlanPhase = "prepare" | "process" | "end";
16
+ export type PlanStatus = "prepare.requirements" | "prepare.review" | "process.active" | "process.wait" | "process.discussing" | "end.completed" | "end.closed" | "end.leave";
17
+ export type LegacyPlanStatus = "requirements" | "review" | "active" | "wait" | "discussing" | "completed" | "closed" | "leave";
18
+ export type PlanTaskStatus = "pending" | "in_progress" | "subagent_running" | "done" | "blocked";
19
+ export type PlanLeaveReason = "manual_leave" | "switch_to_new_plan";
20
+ export type TaskStatus = "active" | "completed" | "paused" | "interrupted" | "abandoned";
21
+ export type PlanReference = {
22
+ why: string;
23
+ path: string;
24
+ };
25
+ export type PlanRetrospective = {
26
+ summary: string;
27
+ whatWorked?: string[];
28
+ issues?: string[];
29
+ followUps?: string[];
30
+ knowledgeCandidates?: string[];
31
+ };
32
+ export type PlanTaskReview = {
33
+ dissatisfied: true;
34
+ reason: string;
35
+ reviewedAt: string;
36
+ };
37
+ export type PlanTask = {
38
+ id: number;
39
+ title: string;
40
+ detail?: string;
41
+ status: PlanTaskStatus;
42
+ execution?: {
43
+ type?: "default" | "subagent" | "subplan";
44
+ subplan?: string;
45
+ planPath?: string;
46
+ };
47
+ sessionKey?: string;
48
+ review?: string | PlanTaskReview;
49
+ };
50
+ export type PlanDocument = {
51
+ title: string;
52
+ status: PlanStatus;
53
+ goal: {
54
+ text: string;
55
+ };
56
+ parentPlan?: string;
57
+ parentTaskId?: number;
58
+ summary?: string;
59
+ leaveReason?: PlanLeaveReason;
60
+ taskType?: string;
61
+ tasks: PlanTask[];
62
+ keyDecisions?: string[];
63
+ references?: PlanReference[];
64
+ rules?: string[];
65
+ retrospective?: PlanRetrospective;
66
+ };
67
+ export type PlanReviewDimensions = {
68
+ atomicity: number;
69
+ stage_completeness: number;
70
+ workflow_match: number;
71
+ completion_clarity: number;
72
+ };
73
+ export type PlanReviewIssue = {
74
+ severity: "error" | "warning";
75
+ taskId: number | null;
76
+ message: string;
77
+ };
78
+ export type PlanReviewResult = {
79
+ score: number;
80
+ matchedWorkflow: string;
81
+ dimensions: PlanReviewDimensions;
82
+ issues: PlanReviewIssue[];
83
+ suggestions: string[];
84
+ completionPolicy: "requires_user_confirmation" | "auto_completable";
85
+ };
86
+ export type WorkflowGuidanceOption = {
87
+ id: string;
88
+ label: string;
89
+ description: string;
90
+ recommended?: boolean;
91
+ };
92
+ export type WorkflowGuidanceSubagentName = "truth-writer" | "adr-writer";
93
+ export type WorkflowGuidanceSubagent = {
94
+ name: WorkflowGuidanceSubagentName;
95
+ skill: string;
96
+ model: "gpt-5.4-mini";
97
+ waitForCompletion: boolean;
98
+ preferReuseSameTypeInThread: true;
99
+ inputContract: string;
100
+ outputContract: string;
101
+ closePolicy: "close_after_result" | "keep_open_for_reuse";
102
+ };
103
+ export type WorkflowGuidance = {
104
+ stage: "requirements" | "review" | "discussion" | "execution" | "done" | "deposition" | "paused";
105
+ summary: string;
106
+ nextStep: string;
107
+ nextTask?: {
108
+ id: number;
109
+ title: string;
110
+ status: PlanTaskStatus;
111
+ detail?: string;
112
+ };
113
+ notes?: string[];
114
+ recommendedCommands?: string[];
115
+ delegateSubagents?: WorkflowGuidanceSubagent[];
116
+ goalMode?: {
117
+ recommendedObjective: string;
118
+ setWhen: "on_plan_write";
119
+ ifNoActiveGoal: true;
120
+ doNotOverwriteExisting: true;
121
+ supportedSurfaces: Array<"/goal" | "create_goal">;
122
+ };
123
+ askUser?: {
124
+ reason: string;
125
+ useCodexOptions: true;
126
+ options: WorkflowGuidanceOption[];
127
+ };
128
+ };
129
+ export type PlanViewTask = {
130
+ id: number;
131
+ title: string;
132
+ status: PlanTaskStatus;
133
+ detail?: string;
134
+ };
135
+ export type PlanViewModel = {
136
+ taskName: string;
137
+ planFile: string;
138
+ title: string;
139
+ status: PlanStatus;
140
+ collapsedSummary: string;
141
+ counts: {
142
+ completed: number;
143
+ total: number;
144
+ };
145
+ goal: {
146
+ text: string;
147
+ defaultCollapsed: true;
148
+ };
149
+ tasks: {
150
+ ordering: "unfinished_first_stable";
151
+ items: PlanViewTask[];
152
+ };
153
+ expanded: {
154
+ sections: Array<{
155
+ id: "goal";
156
+ label: "Goal";
157
+ type: "disclosure";
158
+ defaultExpanded: false;
159
+ content: {
160
+ text: string;
161
+ };
162
+ } | {
163
+ id: "tasks";
164
+ label: "Tasks";
165
+ type: "list";
166
+ defaultExpanded: true;
167
+ ordering: "unfinished_first_stable";
168
+ items: PlanViewTask[];
169
+ }>;
170
+ };
171
+ renderHints: {
172
+ defaultCollapsed: true;
173
+ supportsGoalDisclosure: true;
174
+ refreshOn: Array<"plan.write" | "plan.edit" | "plan.done">;
175
+ };
176
+ };
177
+ export type PlanReviewInput = {
178
+ planContent: PlanDocument;
179
+ isSubPlan: boolean;
180
+ workflowDefinitions?: string;
181
+ projectId?: string;
182
+ taskName?: string;
183
+ };
184
+ export type PlanReviewer = (input: PlanReviewInput) => Promise<PlanReviewResult | null> | PlanReviewResult | null;
185
+ export type TruthDepositionCandidate = {
186
+ projectId: string;
187
+ taskName: string;
188
+ planPath: string;
189
+ planTitle: string;
190
+ goalText: string;
191
+ planStatus: PlanStatus;
192
+ summary?: string;
193
+ rules?: string[];
194
+ references?: PlanReference[];
195
+ retrospective?: PlanRetrospective;
196
+ keyDecisions?: string[];
197
+ suggestedTruthPaths: string[];
198
+ };
199
+ export type AdrDepositionCandidate = {
200
+ projectId: string;
201
+ taskName: string;
202
+ planPath: string;
203
+ planTitle: string;
204
+ planStatus: PlanStatus;
205
+ keyDecisions: string[];
206
+ shouldWriteAdr: boolean;
207
+ reason: string;
208
+ };
209
+ export type SubplanClosureCandidate = {
210
+ taskName: string;
211
+ parentPlan: string;
212
+ parentTaskId: number;
213
+ };
214
+ export type PlanCompletionHooks = {
215
+ truthCandidate: TruthDepositionCandidate;
216
+ adrCandidate: AdrDepositionCandidate;
217
+ subplanClosureCandidate?: SubplanClosureCandidate;
218
+ };
219
+ export type TaskSourceSnapshot = {
220
+ projectId: string;
221
+ task: string;
222
+ status?: TaskStatus;
223
+ updatedAt?: string;
224
+ activePlan?: string;
225
+ planStatus?: string;
226
+ planPath?: string;
227
+ };
228
+ export type LeaveState = {
229
+ leftAt: string;
230
+ updatedAt?: string;
231
+ reason: "split_to_new_task" | "user_switch" | "manual_leave" | "switch_to_new_plan" | "completed" | "paused" | "abandoned";
232
+ fromTask?: string;
233
+ toTask?: string;
234
+ continueNeeded?: boolean;
235
+ nextTask?: string;
236
+ handoff?: string;
237
+ sourceSnapshot?: TaskSourceSnapshot;
238
+ };
239
+ export type PreviousTaskRef = {
240
+ projectId: string;
241
+ task: string;
242
+ linkedAt: string;
243
+ reason: LeaveState["reason"];
244
+ leaveStateAt?: string;
245
+ };
246
+ export type InheritedFrom = {
247
+ projectId?: string;
248
+ task: string;
249
+ mode: "history_tail" | "prev_task" | "split_from_plan";
250
+ linkedAt?: string;
251
+ historyLimit: number;
252
+ sourceSnapshot?: TaskSourceSnapshot;
253
+ reason?: LeaveState["reason"];
254
+ sourceStatus: string;
255
+ sourceUpdatedAt: string;
256
+ sourceLeaveStateUpdatedAt: string;
257
+ sourceLeaveState: LeaveState;
258
+ };
259
+ export type TaskMeta = {
260
+ name: string;
261
+ description: string;
262
+ projectId: string;
263
+ createdAt: string;
264
+ updatedAt: string;
265
+ subagents: unknown[];
266
+ status?: TaskStatus;
267
+ taskType?: string;
268
+ activePlan?: string;
269
+ rules?: string[];
270
+ prevTask?: string;
271
+ leaveState?: LeaveState;
272
+ inheritedFrom?: InheritedFrom;
273
+ previousTask?: PreviousTaskRef;
274
+ [key: string]: unknown;
275
+ };
276
+ export type ProjectContext = {
277
+ projectRoot: string;
278
+ clawDir: string;
279
+ projectJsonPath: string;
280
+ truthDir: string;
281
+ tasksDir: string;
282
+ projectId: string;
283
+ projectName?: string;
284
+ projectConfig: ProjectConfig | null;
285
+ };
286
+ export type TaskContext = {
287
+ project: ProjectContext;
288
+ taskName: string;
289
+ taskDir: string;
290
+ metaPath: string;
291
+ meta: TaskMeta;
292
+ activePlan: string;
293
+ activePlanPath: string;
294
+ };
295
+ export type ResolvedContext = {
296
+ project: ProjectContext;
297
+ task?: TaskContext;
298
+ };
299
+ export type PlanWriteInput = {
300
+ cwd: string;
301
+ taskName?: string;
302
+ filePath?: string;
303
+ title?: string;
304
+ description?: string;
305
+ goalText?: string;
306
+ planStatus?: string;
307
+ content?: PlanDocument;
308
+ parentTaskId?: number;
309
+ reviewer?: PlanReviewer;
310
+ workflowDefinitions?: string;
311
+ };
312
+ export type PlanWriteResult = {
313
+ taskName: string;
314
+ taskDir: string;
315
+ metaPath: string;
316
+ planPath: string;
317
+ planFile: string;
318
+ planStatus: PlanStatus;
319
+ createdTask: boolean;
320
+ createdPlan: boolean;
321
+ eventType: "plan_created" | "plan_changed";
322
+ parentPlan?: string;
323
+ parentTaskId?: number;
324
+ planReview?: PlanReviewResult;
325
+ nextAction?: "collect_requirements" | "revise_plan_from_review" | "proceed";
326
+ instruction?: string;
327
+ workflowGuidance: WorkflowGuidance;
328
+ planView: PlanViewModel;
329
+ };
330
+ export type PlanEditInput = {
331
+ cwd: string;
332
+ taskName: string;
333
+ planFile?: string;
334
+ changeSummary?: string;
335
+ patch?: Partial<PlanDocument>;
336
+ planStatus?: string;
337
+ taskId?: number;
338
+ taskStatus?: PlanTaskStatus;
339
+ appendTasks?: PlanTask[];
340
+ reviewer?: PlanReviewer;
341
+ workflowDefinitions?: string;
342
+ };
343
+ export type PlanEditResult = {
344
+ taskName: string;
345
+ planPath: string;
346
+ planFile: string;
347
+ planStatus: PlanStatus;
348
+ previousPlanStatus: PlanStatus;
349
+ emittedEvents: string[];
350
+ changedTaskIds: number[];
351
+ planReview?: PlanReviewResult;
352
+ nextAction?: "collect_requirements" | "revise_plan_from_review" | "proceed";
353
+ instruction?: string;
354
+ completionHooks?: PlanCompletionHooks;
355
+ workflowGuidance: WorkflowGuidance;
356
+ planView: PlanViewModel;
357
+ };
358
+ export type PlanShowInput = {
359
+ cwd: string;
360
+ taskName: string;
361
+ planFile?: string;
362
+ };
363
+ export type PlanShowResult = {
364
+ taskName: string;
365
+ planPath: string;
366
+ planFile: string;
367
+ plan: PlanDocument;
368
+ planView: PlanViewModel;
369
+ };
370
+ export type SwitchTaskInput = {
371
+ cwd: string;
372
+ fromTask: string;
373
+ toTask: string;
374
+ reason?: LeaveState["reason"];
375
+ mode?: InheritedFrom["mode"];
376
+ historyLimit?: number;
377
+ };
378
+ export type SwitchTaskResult = {
379
+ fromTask: string;
380
+ toTask: string;
381
+ sourceMetaPath: string;
382
+ targetMetaPath: string;
383
+ leaveState: LeaveState;
384
+ };
385
+ export type MemoryScope = "project" | "task";
386
+ export type MemoryIndexInput = {
387
+ cwd: string;
388
+ scope?: MemoryScope;
389
+ taskName?: string;
390
+ };
391
+ export type MemorySearchInput = {
392
+ cwd: string;
393
+ query: string;
394
+ scope?: MemoryScope;
395
+ taskName?: string;
396
+ limit?: number;
397
+ };
398
+ export type MemorySourceEntry = {
399
+ sourcePath: string;
400
+ kind: string;
401
+ content: string;
402
+ };
403
+ export type MemorySearchResultEntry = {
404
+ sourcePath: string;
405
+ kind: string;
406
+ snippet: string;
407
+ score: number;
408
+ };
409
+ export type MemoryIndexResult = {
410
+ scope: MemoryScope;
411
+ storePath: string;
412
+ indexedCount: number;
413
+ sources: string[];
414
+ };
415
+ export type MemorySearchResult = {
416
+ scope: MemoryScope;
417
+ storePath: string;
418
+ results: MemorySearchResultEntry[];
419
+ };
420
+ export type MemoryGetInput = {
421
+ cwd: string;
422
+ scope?: MemoryScope;
423
+ taskName?: string;
424
+ };
425
+ export type MemoryGetResult = {
426
+ scope: MemoryScope;
427
+ storePath: string;
428
+ sources: MemorySourceEntry[];
429
+ };
430
+ export type TruthIngestInput = {
431
+ cwd: string;
432
+ target: string;
433
+ content: string;
434
+ append?: boolean;
435
+ };
436
+ export type TruthIngestResult = {
437
+ truthRoot: string;
438
+ targetPath: string;
439
+ bytesWritten: number;
440
+ mode: "append" | "replace";
441
+ };
442
+ export type ProjectProtocolIssue = {
443
+ path: string;
444
+ message: string;
445
+ };
446
+ export type ProjectProtocolCheckResult = {
447
+ ok: boolean;
448
+ projectRoot: string;
449
+ projectJsonPath: string;
450
+ issues: ProjectProtocolIssue[];
451
+ };
452
+ export type ProjectProtocolEnsureResult = {
453
+ ok: boolean;
454
+ changed: boolean;
455
+ projectRoot: string;
456
+ projectJsonPath: string;
457
+ issueCountBefore: number;
458
+ issueCountAfter: number;
459
+ fixedPaths: string[];
460
+ issuesBefore: ProjectProtocolIssue[];
461
+ issuesAfter: ProjectProtocolIssue[];
462
+ projectConfig: ProjectConfig;
463
+ };
464
+ export type ArchivedTaskRecord = {
465
+ taskName: string;
466
+ sourceTaskDir: string;
467
+ archivedTaskDir: string;
468
+ archivedPlanPath?: string;
469
+ updatedAt?: string;
470
+ };
471
+ export type TaskRetentionResult = {
472
+ enabled: boolean;
473
+ maxTasksToKeep: number;
474
+ archivedCurrentTask?: ArchivedTaskRecord;
475
+ prunedArchivedTasks: ArchivedTaskRecord[];
476
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ import type { PlanCompletionHooks, PlanDocument, ProjectConfig, PlanStatus, WorkflowGuidance } from "./types.js";
2
+ export declare function buildPlanWorkflowGuidance(params: {
3
+ taskName: string;
4
+ planFile: string;
5
+ plan: PlanDocument;
6
+ projectConfig?: ProjectConfig | null;
7
+ previousStatus?: PlanStatus;
8
+ completionHooks?: PlanCompletionHooks;
9
+ changedTaskIds?: number[];
10
+ }): WorkflowGuidance;